File indexing completed on 2024-04-21 05:50:00
0001 //************************************************************************** 0002 // Copyright 2006 - 2017 Martin Koller, kollix@aon.at 0003 // 0004 // This program is free software; you can redistribute it and/or modify 0005 // it under the terms of the GNU General Public License as published by 0006 // the Free Software Foundation, version 2 of the License 0007 // 0008 //************************************************************************** 0009 0010 #ifndef _SELECTOR_H_ 0011 #define _SELECTOR_H_ 0012 0013 // the selection widget lets the user select which files/dirs to back up 0014 0015 #include <QTreeView> 0016 #include <QStandardItemModel> 0017 0018 #include <KService> 0019 0020 class KActionCollection; 0021 class ListItem; 0022 class QMenu; 0023 0024 class Selector : public QTreeView 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 explicit Selector(QWidget *parent, KActionCollection *actionCollection); 0030 0031 void getBackupList(QStringList &includes, QStringList &excludes) const; 0032 void setBackupList(const QStringList &includes, const QStringList &excludes); 0033 void setShowHiddenFiles(bool show); 0034 void openHomeDir(); 0035 0036 QSize minimumSizeHint() const override; 0037 0038 protected: 0039 void contextMenuEvent(QContextMenuEvent *event) override; 0040 0041 private: 0042 void fillTree(ListItem *parent, const QString &path, bool on); 0043 QString getPath(QStandardItem *item) const; 0044 void getBackupLists(QStandardItem *start, QStringList &includes, QStringList &excludes, bool add = true) const; 0045 0046 QStandardItem *findItemByPath(const QString &path); 0047 QStandardItem *findItem(QStandardItem *start, const QString &toFind) const; 0048 0049 ListItem *getSelectedItem() const; 0050 0051 private Q_SLOTS: 0052 void expandedSlot(const QModelIndex &index); 0053 void populateOpenMenu(); 0054 void doubleClickedSlot(); 0055 void open(); 0056 void openWith(QAction *action); 0057 void deleteFile(); 0058 void properties(); 0059 0060 private: 0061 QSize minSize; 0062 QStandardItemModel *itemModel = nullptr; 0063 QMenu *menu = nullptr, *openWithSubMenu = nullptr; 0064 QAction *deleteFileAction = nullptr; 0065 QMap<QString, KService::Ptr> serviceForName; 0066 bool showHiddenFiles = true; 0067 }; 0068 0069 #endif