2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef COMPLETIONWIDGET_H
|
|
|
|
|
#define COMPLETIONWIDGET_H
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QListView>
|
2010-04-15 14:34:31 +02:00
|
|
|
#include <QtCore/QPointer>
|
|
|
|
|
#include <QtCore/QTimer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace TextEditor {
|
|
|
|
|
|
2010-08-13 12:53:36 +02:00
|
|
|
class CompletionItem;
|
2011-02-21 16:02:26 +01:00
|
|
|
class ITextEditor;
|
2010-11-01 16:29:45 +01:00
|
|
|
class CompletionSupport;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-02-17 10:46:19 +01:00
|
|
|
class AutoCompletionModel;
|
|
|
|
|
class CompletionListView;
|
2010-04-09 12:59:20 +02:00
|
|
|
class CompletionInfoFrame;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
/* The completion widget is responsible for showing a list of possible completions.
|
|
|
|
|
It is only used by the CompletionSupport.
|
|
|
|
|
*/
|
2010-02-17 10:46:19 +01:00
|
|
|
class CompletionWidget : public QFrame
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2011-02-21 16:02:26 +01:00
|
|
|
CompletionWidget(CompletionSupport *support, ITextEditor *editor);
|
2010-02-17 10:46:19 +01:00
|
|
|
~CompletionWidget();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void setCompletionItems(const QList<TextEditor::CompletionItem> &completionitems);
|
|
|
|
|
void showCompletions(int startPos);
|
2010-02-17 10:46:19 +01:00
|
|
|
|
2010-07-09 15:12:44 +02:00
|
|
|
QChar typedChar() const;
|
2010-08-03 16:13:00 +02:00
|
|
|
CompletionItem currentCompletionItem() const;
|
|
|
|
|
|
|
|
|
|
void setCurrentIndex(int index);
|
|
|
|
|
bool explicitlySelected() const;
|
2010-07-09 15:12:44 +02:00
|
|
|
|
2010-02-17 10:46:19 +01:00
|
|
|
signals:
|
|
|
|
|
void itemSelected(const TextEditor::CompletionItem &item);
|
|
|
|
|
void completionListClosed();
|
|
|
|
|
|
|
|
|
|
public slots:
|
2008-12-02 12:01:29 +01:00
|
|
|
void closeList(const QModelIndex &index = QModelIndex());
|
|
|
|
|
|
2010-02-17 10:46:19 +01:00
|
|
|
private:
|
|
|
|
|
void updatePositionAndSize(int startPos);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
CompletionSupport *m_support;
|
2011-02-21 16:02:26 +01:00
|
|
|
ITextEditor *m_editor;
|
2010-02-17 10:46:19 +01:00
|
|
|
CompletionListView *m_completionListView;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CompletionListView : public QListView
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
~CompletionListView();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-08-03 16:13:00 +02:00
|
|
|
CompletionItem currentCompletionItem() const;
|
|
|
|
|
bool explicitlySelected() const;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
|
|
|
|
void itemSelected(const TextEditor::CompletionItem &item);
|
|
|
|
|
void completionListClosed();
|
|
|
|
|
|
2010-02-17 10:46:19 +01:00
|
|
|
protected:
|
|
|
|
|
bool event(QEvent *e);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-09 12:59:20 +02:00
|
|
|
void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
2010-02-17 10:46:19 +01:00
|
|
|
friend class CompletionWidget;
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
CompletionListView(CompletionSupport *support, ITextEditor *editor, CompletionWidget *completionWidget);
|
2010-02-17 10:46:19 +01:00
|
|
|
|
|
|
|
|
void setCompletionItems(const QList<TextEditor::CompletionItem> &completionitems);
|
|
|
|
|
void keyboardSearch(const QString &search);
|
|
|
|
|
void closeList(const QModelIndex &index);
|
2011-02-21 14:02:00 +01:00
|
|
|
|
2010-04-09 14:15:21 +02:00
|
|
|
private slots:
|
2010-04-09 12:59:20 +02:00
|
|
|
void maybeShowInfoTip();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-21 14:02:00 +01:00
|
|
|
private:
|
2008-12-02 12:01:29 +01:00
|
|
|
bool m_blockFocusOut;
|
2011-02-21 16:02:26 +01:00
|
|
|
ITextEditor *m_editor;
|
2008-12-02 12:01:29 +01:00
|
|
|
QWidget *m_editorWidget;
|
2010-02-17 10:46:19 +01:00
|
|
|
CompletionWidget *m_completionWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
AutoCompletionModel *m_model;
|
|
|
|
|
CompletionSupport *m_support;
|
2010-04-09 12:59:20 +02:00
|
|
|
QPointer<CompletionInfoFrame> m_infoFrame;
|
2010-04-15 14:34:31 +02:00
|
|
|
QTimer m_infoTimer;
|
2010-07-09 15:12:44 +02:00
|
|
|
QChar m_typedChar;
|
2010-08-03 16:13:00 +02:00
|
|
|
bool m_explicitlySelected;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace TextEditor
|
|
|
|
|
|
|
|
|
|
#endif // COMPLETIONWIDGET_H
|
|
|
|
|
|