File indexing completed on 2024-05-05 17:56:44
0001 /* 0002 SPDX-FileCopyrightText: 2006 Jonas Bähr <jonas.baehr@web.de> 0003 SPDX-FileCopyrightText: 2006-2022 Krusader Krew <https://krusader.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef USERACTIONLISTVIEW_H 0009 #define USERACTIONLISTVIEW_H 0010 0011 #include "../GUI/krtreewidget.h" 0012 0013 class KrAction; 0014 class QString; 0015 class UserActionListViewItem; 0016 class QDomDocument; 0017 0018 class UserActionListView : public KrTreeWidget 0019 { 0020 Q_OBJECT 0021 0022 public: 0023 explicit UserActionListView(QWidget *parent = nullptr); 0024 ~UserActionListView() override; 0025 QSize sizeHint() const override; 0026 0027 void update(); 0028 void update(KrAction *action); 0029 UserActionListViewItem *insertAction(KrAction *action); 0030 0031 KrAction *currentAction() const; 0032 void setCurrentAction(const KrAction *); 0033 0034 QDomDocument dumpSelectedActions(QDomDocument *mergeDoc = nullptr) const; 0035 0036 void removeSelectedActions(); 0037 0038 /** 0039 * makes the first action in the list current 0040 */ 0041 void setFirstActionCurrent(); 0042 0043 /** 0044 * makes @e item current and ensures its visibility 0045 */ 0046 protected slots: 0047 void slotCurrentItemChanged(QTreeWidgetItem *); 0048 0049 protected: 0050 QTreeWidgetItem *findCategoryItem(const QString &category); 0051 UserActionListViewItem *findActionItem(const KrAction *action); 0052 }; 0053 0054 class UserActionListViewItem : public QTreeWidgetItem 0055 { 0056 public: 0057 UserActionListViewItem(QTreeWidget *view, KrAction *action); 0058 UserActionListViewItem(QTreeWidgetItem *item, KrAction *action); 0059 ~UserActionListViewItem() override; 0060 0061 void setAction(KrAction *action); 0062 KrAction *action() const; 0063 void update(); 0064 0065 /** 0066 * This reimplements qt's compare-function in order to have categories on the top of the list 0067 */ 0068 bool operator<(const QTreeWidgetItem &other) const override; 0069 0070 private: 0071 KrAction *_action; 0072 }; 0073 0074 #endif