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 KateSmartRange* completionRange(KTextEditor::CodeCompletionModel* model = 0) const;
00087 QMap<KTextEditor::CodeCompletionModel*, KateSmartRange*> completionRanges( ) const;
00088
00089
00090 void pageDown();
00091 void pageUp();
00092 void top();
00093 void bottom();
00094
00095 QWidget* currentEmbeddedWidget();
00096
00097 bool canExpandCurrentItem() const;
00098
00099 bool canCollapseCurrentItem() const;
00100
00101 void setCurrentItemExpanded( bool );
00102
00103
00104 bool updatePosition(bool force = false);
00105
00106 virtual bool eventFilter( QObject * watched, QEvent * event );
00107
00108 KateArgumentHintTree* argumentHintTree() const;
00109
00110 KateArgumentHintModel* argumentHintModel() const;
00111
00113
00114 void updateHeight();
00115
00116 public Q_SLOTS:
00117 void abortCompletion();
00118 void showConfig();
00119
00120
00121 void updatePositionSlot();
00122 void automaticInvocation();
00123
00124
00125 void argumentHintsChanged(bool hasContent);
00126
00127 bool navigateUp();
00128 bool navigateDown();
00129 bool navigateLeft();
00130 bool navigateRight();
00131 bool navigateAccept();
00132 bool navigateBack();
00133
00134 bool hadNavigation() const;
00135 void resetHadNavigation();
00136
00137 protected:
00138 virtual void showEvent ( QShowEvent * event );
00139 virtual void resizeEvent ( QResizeEvent * event );
00140 virtual void hideEvent ( QHideEvent * event );
00141
00142
00143 private Q_SLOTS:
00144 void modelContentChanged();
00145 void cursorPositionChanged();
00146 void editDone(KateEditInfo* edit);
00147 void modelReset();
00148 void startCharacterDeleted(KTextEditor::SmartCursor* cursor, bool deletedBefore);
00149 void rowsInserted(const QModelIndex& parent, int row, int rowEnd);
00150 void viewFocusOut();
00151 private:
00152 void updateAndShow();
00153 void updateArgumentHintGeometry();
00154 QModelIndex selectedIndex() const;
00155
00156 void clear();
00157
00158 void switchList();
00159 KTextEditor::Range determineRange() const;
00160 void completionRangeChanged(KTextEditor::CodeCompletionModel*, const KTextEditor::Range& word);
00161
00162 QList<KTextEditor::CodeCompletionModel*> m_sourceModels;
00163 KateCompletionModel* m_presentationModel;
00164
00165 QMap<KTextEditor::CodeCompletionModel*, KateSmartRange*> m_completionRanges;
00166 KTextEditor::Cursor m_lastCursorPosition;
00167
00168 KateCompletionTree* m_entryList;
00169 KateArgumentHintModel* m_argumentHintModel;
00170 KateArgumentHintTree* m_argumentHintTree;
00171
00172 QTimer* m_automaticInvocationTimer;
00173
00174 QWidget* m_statusBar;
00175 QToolButton* m_sortButton;
00176 QLabel* m_sortText;
00177 QToolButton* m_filterButton;
00178 QLabel* m_filterText;
00179 QPushButton* m_configButton;
00180
00181 KTextEditor::Cursor m_automaticInvocationAt;
00182 QString m_automaticInvocationLine;
00183 int m_automaticInvocationDelay;
00184 bool m_filterInstalled;
00185
00186 class KateCompletionConfig* m_configWidget;
00187 bool m_lastInsertionByUser;
00188 bool m_inCompletionList;
00189 bool m_isSuspended;
00190 bool m_dontShowArgumentHints;
00191 bool m_needShow;
00192
00193 bool m_hadCompletionNavigation;
00194
00195 int m_expandedAddedHeightBase;
00196 };
00197
00198 #endif