| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> |
| 3 | SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de> |
| 4 | |
| 5 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #ifndef KATECOMPLETIONTREE_H |
| 9 | #define KATECOMPLETIONTREE_H |
| 10 | |
| 11 | #include <QTreeView> |
| 12 | |
| 13 | class KateCompletionWidget; |
| 14 | class KateCompletionModel; |
| 15 | |
| 16 | class QTimer; |
| 17 | |
| 18 | class KateCompletionTree final : public QTreeView |
| 19 | { |
| 20 | public: |
| 21 | explicit KateCompletionTree(KateCompletionWidget *parent); |
| 22 | |
| 23 | KateCompletionWidget *widget() const; |
| 24 | KateCompletionModel *kateModel() const; |
| 25 | |
| 26 | void resizeColumns(bool firstShow = false, bool forceResize = false); |
| 27 | |
| 28 | int sizeHintForColumn(int column) const override |
| 29 | { |
| 30 | return columnWidth(column); |
| 31 | } |
| 32 | |
| 33 | // Navigation |
| 34 | bool nextCompletion(); |
| 35 | bool previousCompletion(); |
| 36 | bool pageDown(); |
| 37 | bool pageUp(); |
| 38 | void top(); |
| 39 | void bottom(); |
| 40 | |
| 41 | void scheduleUpdate(); |
| 42 | |
| 43 | void setScrollingEnabled(bool); |
| 44 | |
| 45 | int textColumnOffset() const; |
| 46 | |
| 47 | private: |
| 48 | void resizeColumnsSlot(); |
| 49 | |
| 50 | protected: |
| 51 | void currentChanged(const QModelIndex ¤t, const QModelIndex &previous) override; /// Not available as a signal in this way |
| 52 | void scrollContentsBy(int dx, int dy) override; |
| 53 | void initViewItemOption(QStyleOptionViewItem *option) const override; |
| 54 | |
| 55 | private: |
| 56 | bool m_scrollingEnabled; |
| 57 | QTimer *m_resizeTimer; |
| 58 | }; |
| 59 | |
| 60 | #endif |
| 61 | |