[go: up one dir, main page]

File: treeview.h

package info (click to toggle)
qgit 2.3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,152 kB
  • ctags: 1,477
  • sloc: cpp: 11,857; makefile: 51; sh: 39
file content (86 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
	Description: files tree view

	Author: Marco Costalba (C) 2005-2007

	Copyright: See COPYING file that comes with this distribution

*/
#ifndef TREEVIEW_H
#define TREEVIEW_H

#include <QTreeWidget>
#include "common.h"
#include "git.h"

class DirItem;
class TreeView;
class Git;
class StateInfo;
class Domain;

class FileItem : public QTreeWidgetItem {
public:
	FileItem(FileItem* p, SCRef nm) : QTreeWidgetItem(p, QStringList(nm)) {}
	FileItem(QTreeWidget* p, SCRef nm) : QTreeWidgetItem(p, QStringList(nm)) {}

	virtual QString fullName() const;
	void setBold(bool b);
};

class DirItem : public FileItem {
public:
	DirItem(QTreeWidget* parent, SCRef ts, SCRef nm);
	DirItem(DirItem* parent, SCRef ts, SCRef nm);

protected:
	friend class TreeView;

	QString treeSha;
};

class TreeView : public QTreeWidget {
Q_OBJECT
public:
	TreeView(QWidget* par) : QTreeWidget(par), d(NULL), git(NULL), treeIsValid(false) {}
	void setup(Domain* d, Git* g);
	void setTreeName(SCRef treeName) { rootName = treeName; }
	void updateTree();
	const QString fullName(QTreeWidgetItem* item);
	bool isDir(SCRef fileName);
	bool isModified(SCRef path, bool isDir = false);
	void clear();
	void getTreeSelectedItems(QStringList& selectedItems);
	bool getTree(SCRef tSha, Git::TreeInfo& ti, bool wd, SCRef tPath);

	const QPixmap* folderClosed;
	const QPixmap* folderOpen;
	const QPixmap* fileDefault;

signals:
	void updateViews(const QString& newRevSha, const QString& newFileName);
	void contextMenu(const QString&, int type);

protected slots:
	void on_customContextMenuRequested(const QPoint&);
	void on_currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*);
	void on_itemExpanded(QTreeWidgetItem*);
	void on_itemCollapsed(QTreeWidgetItem*);

private:
	void setTree(SCRef treeSha);
	void setFile(SCRef fileName);
	void restoreStuff();

	Domain* d;
	Git* git;
	StateInfo* st;
	QString rootName;
	QStringList modifiedFiles; // no need a map, should not be a lot
	QStringList modifiedDirs;
	bool ignoreCurrentChanged;
	bool treeIsValid;
	bool isWorkingDir;
};

#endif