Falkon Develop
Cross-platform Qt-based web browser
treewidget.h
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#ifndef BOOKMARKSTREEWIDGET_H
19#define BOOKMARKSTREEWIDGET_H
20
21#include "qzcommon.h"
22
23#include <QTreeWidget>
24
25class FALKON_EXPORT TreeWidget : public QTreeWidget
26{
27 Q_OBJECT
28public:
29 explicit TreeWidget(QWidget* parent = nullptr);
30 enum ItemShowMode { ItemsCollapsed = 0, ItemsExpanded = 1 };
31 ItemShowMode defaultItemShowMode() { return m_showMode; }
32 void setDefaultItemShowMode(ItemShowMode mode) { m_showMode = mode; }
33 QList<QTreeWidgetItem*> allItems();
34
35 bool appendToParentItem(const QString &parentText, QTreeWidgetItem* item);
36 bool appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item);
37 bool prependToParentItem(const QString &parentText, QTreeWidgetItem* item);
38 bool prependToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item);
39
40 void addTopLevelItem(QTreeWidgetItem* item);
41 void addTopLevelItems(const QList<QTreeWidgetItem*> &items);
42 void insertTopLevelItem(int index, QTreeWidgetItem* item);
43 void insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items);
44
45 void deleteItem(QTreeWidgetItem* item);
46 void deleteItems(const QList<QTreeWidgetItem*> &items);
47
48Q_SIGNALS:
49 void itemControlClicked(QTreeWidgetItem* item);
50 void itemMiddleButtonClicked(QTreeWidgetItem* item);
51
52public Q_SLOTS:
53 void filterString(const QString &string);
54 void clear();
55
56private Q_SLOTS:
57 void sheduleRefresh();
58
59private:
60 void mousePressEvent(QMouseEvent* event) override;
61 void iterateAllItems(QTreeWidgetItem* parent);
62
63 bool m_refreshAllItemsNeeded;
64 QList<QTreeWidgetItem*> m_allTreeItems;
65 ItemShowMode m_showMode;
66};
67
68#endif // BOOKMARKSTREEWIDGET_H
void itemMiddleButtonClicked(QTreeWidgetItem *item)
void setDefaultItemShowMode(ItemShowMode mode)
Definition: treewidget.h:32
void itemControlClicked(QTreeWidgetItem *item)
ItemShowMode defaultItemShowMode()
Definition: treewidget.h:31
#define FALKON_EXPORT
Definition: qzcommon.h:28