• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

Kate

katecompletionwidget.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 2005-2006 Hamish Rodda <rodda@kde.org>
00003    Copyright (C) 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License version 2 as published by the Free Software Foundation.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017    Boston, MA 02110-1301, USA.
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     //Executed when return is pressed while completion is active.
00069     void execute();
00070         //Callbacks for keyboard-input, they return true when the event was handled, and should not be reached on.
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       //Whenever the cursor goes before this position, the completion is stopped, unless it is invalid.
00098       KTextEditor::Cursor leftBoundary;
00099     };
00100     
00101     KateSmartRange* completionRange(KTextEditor::CodeCompletionModel* model = 0) const;
00102     QMap<KTextEditor::CodeCompletionModel*, CompletionRange> completionRanges( ) const;
00103 
00104     // Navigation
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     //Returns true if a screen border has been hit
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 /*    void viewFocusIn();
00137     void viewFocusOut();*/
00138     void updatePositionSlot();
00139     void automaticInvocation();
00140 
00141 /*    void updateFocus();*/
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 //    virtual void focusInEvent ( QFocusEvent * event );
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     //Switch cursor between argument-hint list / completion-list
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     //QTimer* m_updateFocusTimer;
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; //Are we in the completion-list? If not, we're in the argument-hint list
00211     bool m_isSuspended;
00212     bool m_dontShowArgumentHints; //Used temporarily to prevent flashing
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

Kate

Skip menu "Kate"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal