File indexing completed on 2024-05-12 04:58:29
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #ifndef BOOKMARKSTREEWIDGET_H 0019 #define BOOKMARKSTREEWIDGET_H 0020 0021 #include "qzcommon.h" 0022 0023 #include <QTreeWidget> 0024 0025 class FALKON_EXPORT TreeWidget : public QTreeWidget 0026 { 0027 Q_OBJECT 0028 public: 0029 explicit TreeWidget(QWidget* parent = nullptr); 0030 enum ItemShowMode { ItemsCollapsed = 0, ItemsExpanded = 1 }; 0031 ItemShowMode defaultItemShowMode() { return m_showMode; } 0032 void setDefaultItemShowMode(ItemShowMode mode) { m_showMode = mode; } 0033 QList<QTreeWidgetItem*> allItems(); 0034 0035 bool appendToParentItem(const QString &parentText, QTreeWidgetItem* item); 0036 bool appendToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item); 0037 bool prependToParentItem(const QString &parentText, QTreeWidgetItem* item); 0038 bool prependToParentItem(QTreeWidgetItem* parent, QTreeWidgetItem* item); 0039 0040 void addTopLevelItem(QTreeWidgetItem* item); 0041 void addTopLevelItems(const QList<QTreeWidgetItem*> &items); 0042 void insertTopLevelItem(int index, QTreeWidgetItem* item); 0043 void insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items); 0044 0045 void deleteItem(QTreeWidgetItem* item); 0046 void deleteItems(const QList<QTreeWidgetItem*> &items); 0047 0048 Q_SIGNALS: 0049 void itemControlClicked(QTreeWidgetItem* item); 0050 void itemMiddleButtonClicked(QTreeWidgetItem* item); 0051 0052 public Q_SLOTS: 0053 void filterString(const QString &string); 0054 void clear(); 0055 0056 private Q_SLOTS: 0057 void sheduleRefresh(); 0058 0059 private: 0060 void mousePressEvent(QMouseEvent* event) override; 0061 void iterateAllItems(QTreeWidgetItem* parent); 0062 0063 bool m_refreshAllItemsNeeded; 0064 QList<QTreeWidgetItem*> m_allTreeItems; 0065 ItemShowMode m_showMode; 0066 }; 0067 0068 #endif // BOOKMARKSTREEWIDGET_H