treeview.h

Go to the documentation of this file.
00001 /*
00002         Description: files tree view
00003 
00004         Author: Marco Costalba (C) 2005-2006
00005 
00006         Copyright: See COPYING file that comes with this distribution
00007 
00008 */
00009 #ifndef TREEVIEW_H
00010 #define TREEVIEW_H
00011 
00012 #include <qlistview.h>
00013 #include <qpixmap.h>
00014 #include <qdict.h>
00015 #include "common.h"
00016 
00017 class DirItem;
00018 class TreeView;
00019 class Git;
00020 class StateInfo;
00021 class Domain;
00022 
00023 class FileItem : public QListViewItem {
00024 public:
00025         FileItem(FileItem* p, SCRef nm) : QListViewItem(p, nm), isModified(false) {}
00026         FileItem(QListView* p, SCRef nm) : QListViewItem(p, nm), isModified(false) {}
00027 
00028         virtual void setModified(bool b) { isModified = b; }
00029         virtual QString fullName() const;
00030         virtual void paintCell(QPainter* p, const QColorGroup& cg, int c, int w, int a);
00031 
00032 protected:
00033         bool isModified;
00034 };
00035 
00036 class DirItem : public FileItem {
00037 public:
00038         DirItem(QListView* parent, SCRef ts, SCRef nm, TreeView* t);
00039         DirItem(DirItem* parent, SCRef ts, SCRef nm, TreeView* t);
00040 
00041         virtual void setOpen(bool b);
00042         virtual void setup();
00043 
00044 protected:
00045         friend class TreeView;
00046 
00047         QString treeSha;
00048         TreeView* tv;
00049         bool isWorkingDir;
00050 };
00051 
00052 class TreeView : public QObject {
00053 Q_OBJECT
00054 public:
00055         TreeView(Domain* d, Git* g, QListView* lv);
00056         void setTreeName(SCRef treeName) { rootName = treeName; }
00057         void initMimePix();
00058         void update();
00059         void setMimePix(SCRef ext, QPixmap* pix);
00060         const QPixmap* mimePix(SCRef ext);
00061         const QString fullName(QListViewItem* item);
00062         bool isDir(SCRef fileName);
00063         bool isModified(SCRef path, bool isDir = false);
00064         void clear();
00065         void getTreeSelectedItems(QStringList& selectedItems);
00066         bool getTree(SCRef tSha, SList nm, SList shas, SList types, bool wd, SCRef tPath);
00067 
00068         QPixmap* folderClosed;
00069         QPixmap* folderOpen;
00070         QPixmap* fileDefault;
00071 
00072 signals:
00073         void updateViews(const QString& newRevSha, const QString& newFileName);
00074         void contextMenu(const QString&, int type);
00075 
00076 protected slots:
00077         void on_contextMenuRequested(QListViewItem*,const QPoint&,int);
00078         void on_currentChanged(QListViewItem*);
00079 
00080 private:
00081         void setTree(SCRef treeSha);
00082         void setFile(SCRef fileName);
00083         void restoreStuff();
00084 
00085         Domain* d;
00086         Git* git;
00087         QListView* listView;
00088         StateInfo* st;
00089         QDict<QPixmap> mimePixMap;
00090         QString rootName;
00091         QStringList modifiedFiles; // no need a map, should not be a lot
00092         QStringList modifiedDirs;
00093         bool ignoreCurrentChanged;
00094         bool treeIsValid;
00095 };
00096 
00097 #endif

Generated on Fri Dec 7 21:57:38 2007 for QGit by  doxygen 1.5.3