Menu item "Checkout" spawns a dialog, thus requires ellipsis
[qgit4/redivivus.git] / src / treeview.h
blob2ff41147da29c4709b63dd9808a75d56b661017e
1 /*
2 Description: files tree view
4 Author: Marco Costalba (C) 2005-2007
6 Copyright: See COPYING file that comes with this distribution
8 */
9 #ifndef TREEVIEW_H
10 #define TREEVIEW_H
12 #include <QTreeWidget>
13 #include "common.h"
14 #include "git.h"
16 class DirItem;
17 class TreeView;
18 class Git;
19 class StateInfo;
20 class Domain;
22 class FileItem : public QTreeWidgetItem {
23 public:
24 FileItem(FileItem* p, SCRef nm) : QTreeWidgetItem(p, QStringList(nm)) {}
25 FileItem(QTreeWidget* p, SCRef nm) : QTreeWidgetItem(p, QStringList(nm)) {}
27 virtual QString fullName() const;
28 void setBold(bool b);
31 class DirItem : public FileItem {
32 public:
33 DirItem(QTreeWidget* parent, SCRef ts, SCRef nm);
34 DirItem(DirItem* parent, SCRef ts, SCRef nm);
36 protected:
37 friend class TreeView;
39 QString treeSha;
42 class TreeView : public QTreeWidget {
43 Q_OBJECT
44 public:
45 TreeView(QWidget* par) : QTreeWidget(par), d(NULL), git(NULL), treeIsValid(false) {}
46 void setup(Domain* d, Git* g);
47 void setTreeName(SCRef treeName) { rootName = treeName; }
48 void updateTree();
49 const QString fullName(QTreeWidgetItem* item);
50 bool isDir(SCRef fileName);
51 bool isModified(SCRef path, bool isDir = false);
52 void clear();
53 void getTreeSelectedItems(QStringList& selectedItems);
54 bool getTree(SCRef tSha, Git::TreeInfo& ti, bool wd, SCRef tPath);
56 const QPixmap* folderClosed;
57 const QPixmap* folderOpen;
58 const QPixmap* fileDefault;
60 signals:
61 void updateViews(const QString& newRevSha, const QString& newFileName);
62 void contextMenu(const QString&, int type);
64 protected slots:
65 void on_customContextMenuRequested(const QPoint&);
66 void on_currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*);
67 void on_itemExpanded(QTreeWidgetItem*);
68 void on_itemCollapsed(QTreeWidgetItem*);
70 private:
71 void setTree(SCRef treeSha);
72 void setFile(SCRef fileName);
73 void restoreStuff();
75 Domain* d;
76 Git* git;
77 StateInfo* st;
78 QString rootName;
79 QStringList modifiedFiles; // no need a map, should not be a lot
80 QStringList modifiedDirs;
81 bool ignoreCurrentChanged;
82 bool treeIsValid;
83 bool isWorkingDir;
86 #endif