diff options
| author | Matthias Fuchs <[email protected]> | 2009-10-05 18:46:35 +0000 |
|---|---|---|
| committer | Matthias Fuchs <[email protected]> | 2009-10-05 18:46:35 +0000 |
| commit | b6310bf521ebb42ef5b4a4adc39c75fe2d2a545a (patch) | |
| tree | f9ab399d796ecfe21a8f7263cb2be796453f3b15 /src/dolphinsearchbox.h | |
| parent | 647e1469b51fbdaf3cf52ea7e6b81048cce3d3fc (diff) | |
Adds autocompletition to the dolphin-search-box. So far existing tags and commands like "and", "or" and "-" (for not) are offered as completition-suggestions.
svn path=/trunk/KDE/kdebase/apps/; revision=1031685
Diffstat (limited to 'src/dolphinsearchbox.h')
| -rw-r--r-- | src/dolphinsearchbox.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/dolphinsearchbox.h b/src/dolphinsearchbox.h index 949c0b547..2f1c6e172 100644 --- a/src/dolphinsearchbox.h +++ b/src/dolphinsearchbox.h @@ -21,11 +21,46 @@ #include <QWidget> +#include <KIcon> + class KLineEdit; class KUrl; +class QCompleter; +class QModelIndex; +class QStandardItemModel; class QToolButton; /** + * @brief used for completition for the DolphinSearchBox + */ +class DolphinSearchCompleter : public QObject +{ + Q_OBJECT + public: + DolphinSearchCompleter(KLineEdit *linedit); + + void init(); + + public slots: + void highlighted(const QModelIndex& index); + void activated(const QModelIndex& index); + void slotTextEdited(const QString &text); + + private: + void addCompletionItem(const QString& displayed, const QString& usedForCompletition, const QString& description = QString(), const KIcon& icon = KIcon()); + + void findText(int* wordStart, int* wordEnd, QString* newWord, int cursorPos, const QString &input); + + private: + KLineEdit* q; + QCompleter* m_completer; + QStandardItemModel* m_completionModel; + QString m_userText; + int m_wordStart; + int m_wordEnd; +}; + +/** * @brief Input box for searching files with Nepomuk. */ class DolphinSearchBox : public QWidget @@ -50,9 +85,14 @@ signals: private slots: void emitSearchSignal(); + + + private: KLineEdit* m_searchInput; QToolButton* m_searchButton; + + DolphinSearchCompleter* m_completer; }; #endif |
