Kate
katecompletionwidget.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef KATECOMPLETIONWIDGET_H
00020 #define KATECOMPLETIONWIDGET_H
00021
00022 #include <QtGui/QFrame>
00023 #include <QObject>
00024
00025 #include <ktexteditor/range.h>
00026 #include <ktexteditor/codecompletioninterface.h>
00027 #include <ktexteditor/codecompletionmodel.h>
00028
00029 class QToolButton;
00030 class QPushButton;
00031 class QLabel;
00032 class QTimer;
00033
00034 class KateView;
00035 class KateSmartRange;
00036 class KateCompletionModel;
00037 class KateCompletionTree;
00038 class KateEditInfo;
00039 class KateArgumentHintTree;
00040 class KateArgumentHintModel;
00041
00042 namespace KTextEditor {
00043 class EmbeddedWidgetInterface;
00044 }
00045
00052 class KateCompletionWidget : public QFrame
00053 {
00054 Q_OBJECT
00055
00056 public:
00057 explicit KateCompletionWidget(KateView* parent);
00058 ~KateCompletionWidget();
00059
00060 KateView* view() const;
00061 KateCompletionTree* treeView() const;
00062
00063 bool isCompletionActive() const;
00064 void startCompletion(KTextEditor::CodeCompletionModel::InvocationType invocationType);
00065 void startCompletion(const KTextEditor::Range& word, KTextEditor::CodeCompletionModel* model, KTextEditor::CodeCompletionModel::InvocationType invocationType = KTextEditor::CodeCompletionModel::ManualInvocation);
00066 void userInvokedCompletion();
00067
00068
00069 void execute();
00070
00071 void cursorDown();
00072 void cursorUp();
00073
00075 bool toggleExpanded(bool forceExpand = false, bool forceUnExpand = false);
00076
00077 const KateCompletionModel* model() const;
00078 KateCompletionModel* model();
00079
00080 void registerCompletionModel(KTextEditor::CodeCompletionModel* model);
00081 void unregisterCompletionModel(KTextEditor::CodeCompletionModel* model);
00082
00083 int automaticInvocationDelay() const;
00084 void setAutomaticInvocationDelay(int delay);
00085
00086 struct CompletionRange{
00087 CompletionRange() : range(0) {
00088 }
00089 CompletionRange(KateSmartRange* r) : range(r) {
00090 }
00091
00092 bool operator==(const CompletionRange& rhs) const {
00093 return range == rhs.range;
00094 }
00095
00096 KateSmartRange* range;
00097
00098 KTextEditor::Cursor leftBoundary;
00099 };
00100
00101 KateSmartRange* completionRange(KTextEditor::CodeCompletionModel* model = 0) const;
00102 QMap<KTextEditor::CodeCompletionModel*, CompletionRange> completionRanges( ) const;
00103
00104
00105 void pageDown();
00106 void pageUp();
00107 void top();
00108 void bottom();
00109
00110 QWidget* currentEmbeddedWidget();
00111
00112 bool canExpandCurrentItem() const;
00113
00114 bool canCollapseCurrentItem() const;
00115
00116 void setCurrentItemExpanded( bool );
00117
00118
00119 bool updatePosition(bool force = false);
00120
00121 virtual bool eventFilter( QObject * watched, QEvent * event );
00122
00123 KateArgumentHintTree* argumentHintTree() const;
00124
00125 KateArgumentHintModel* argumentHintModel() const;
00126
00128
00129 void updateHeight();
00130
00131 public Q_SLOTS:
00132 void waitForModelReset();
00133
00134 void abortCompletion();
00135 void showConfig();
00136
00137
00138 void updatePositionSlot();
00139 void automaticInvocation();
00140
00141
00142 void argumentHintsChanged(bool hasContent);
00143
00144 bool navigateUp();
00145 bool navigateDown();
00146 bool navigateLeft();
00147 bool navigateRight();
00148 bool navigateAccept();
00149 bool navigateBack();
00150
00151 bool hadNavigation() const;
00152 void resetHadNavigation();
00153
00154 protected:
00155 virtual void showEvent ( QShowEvent * event );
00156 virtual void resizeEvent ( QResizeEvent * event );
00157
00158
00159 private Q_SLOTS:
00160 void completionModelReset();
00161 void modelDestroyed(QObject* model);
00162 void modelContentChanged();
00163 void cursorPositionChanged();
00164 void editDone(KateEditInfo* edit);
00165 void modelReset();
00166 void startCharacterDeleted(KTextEditor::SmartCursor* cursor, bool deletedBefore);
00167 void rowsInserted(const QModelIndex& parent, int row, int rowEnd);
00168 void viewFocusOut();
00169 private:
00170 void updateAndShow();
00171 void updateArgumentHintGeometry();
00172 QModelIndex selectedIndex() const;
00173
00174 void clear();
00175
00176 void switchList();
00177 KTextEditor::Range determineRange() const;
00178 void completionRangeChanged(KTextEditor::CodeCompletionModel*, const KTextEditor::Range& word);
00179
00180 void deleteCompletionRanges();
00181
00182 QList<KTextEditor::CodeCompletionModel*> m_sourceModels;
00183 KateCompletionModel* m_presentationModel;
00184
00185 QMap<KTextEditor::CodeCompletionModel*, CompletionRange> m_completionRanges;
00186 QSet<KTextEditor::CodeCompletionModel*> m_waitingForReset;
00187
00188 KTextEditor::Cursor m_lastCursorPosition;
00189
00190 KateCompletionTree* m_entryList;
00191 KateArgumentHintModel* m_argumentHintModel;
00192 KateArgumentHintTree* m_argumentHintTree;
00193
00194 QTimer* m_automaticInvocationTimer;
00195
00196 QWidget* m_statusBar;
00197 QToolButton* m_sortButton;
00198 QLabel* m_sortText;
00199 QToolButton* m_filterButton;
00200 QLabel* m_filterText;
00201 QPushButton* m_configButton;
00202
00203 KTextEditor::Cursor m_automaticInvocationAt;
00204 QString m_automaticInvocationLine;
00205 int m_automaticInvocationDelay;
00206 bool m_filterInstalled;
00207
00208 class KateCompletionConfig* m_configWidget;
00209 bool m_lastInsertionByUser;
00210 bool m_inCompletionList;
00211 bool m_isSuspended;
00212 bool m_dontShowArgumentHints;
00213 bool m_needShow;
00214
00215 bool m_hadCompletionNavigation;
00216
00217 bool m_haveExactMatch;
00218
00219 int m_expandedAddedHeightBase;
00220 KTextEditor::CodeCompletionModel::InvocationType m_lastInvocationType;
00221 };
00222
00223 #endif