QtiPlot  0.9.8.2
Folder.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : Folder.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2006 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Folder for the project explorer
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #ifndef FOLDER_H
30 #define FOLDER_H
31 
32 #include <QObject>
33 #include <QEvent>
34 #include <q3listview.h>
35 #include <q3iconview.h>
36 
37 #include "MdiSubWindow.h"
38 
39 class FolderListItem;
40 class Table;
41 class Matrix;
42 class MultiLayer;
43 class Note;
44 class Graph3D;
45 
46 class QDragEnterEvent;
47 class QDragMoveEvent;
48 class QDragLeaveEvent;
49 class QDropEvent;
50 class Q3DragObject;
51 
53 class Folder : public QObject
54 {
55  Q_OBJECT
56 
57 public:
58  Folder( Folder *parent, const QString &name );
59 
60  QList<MdiSubWindow *> windowsList(){return lstWindows;};
61 
62  void addWindow( MdiSubWindow *w );
63  void removeWindow( MdiSubWindow *w );
64 
66  QStringList subfolders();
67 
69  QList<Folder*> folders();
70 
72  Folder* findSubfolder(const QString& s, bool caseSensitive = true, bool partialMatch = false);
73 
75  MdiSubWindow* findWindow(const QString& s, bool windowNames, bool labels,
76  bool caseSensitive, bool partialMatch);
77 
79 
84  MdiSubWindow *window(const QString &name, const char *cls="MdiSubWindow", bool recursive=false);
86  Table *table(const QString &name, bool recursive=false) { return (Table*) window(name, "Table", recursive); }
88  Matrix *matrix(const QString &name, bool recursive=false) { return (Matrix*) window(name, "Matrix", recursive); }
90  MultiLayer *graph(const QString &name, bool recursive=false) { return (MultiLayer*) window(name, "MultiLayer", recursive); }
92  Note *note(const QString &name, bool recursive=false) { return (Note*) window(name, "Note", recursive); }
94  Graph3D *plot3D(const QString &name, bool recursive=false) { return (Graph3D*) window(name, "Graph3D", recursive); }
95 
97  QString path();
98 
100  int depth();
101 
102  Folder *folderBelow();
103 
105  Folder* rootFolder();
106 
108  QString sizeToString();
109 
110  QString birthDate(){return birthdate;};
111  void setBirthDate(const QString& s){birthdate = s;};
112 
113  QString modificationDate(){return modifDate;};
114  void setModificationDate(const QString& s){modifDate = s;};
115 
119 
122 
123  QString logInfo(){return d_log_info;};
124  void appendLogInfo(const QString& text){d_log_info += text;};
125  void clearLogInfo(){d_log_info = QString();};
126 
127 protected:
128  QString birthdate, modifDate;
129  QString d_log_info;
130  QList<MdiSubWindow *> lstWindows;
132 
135 };
136 
137 /*****************************************************************************
138  *
139  * Class WindowListItem
140  *
141  *****************************************************************************/
143 class WindowListItem : public Q3ListViewItem
144 {
145 public:
146  WindowListItem( Q3ListView *parent, MdiSubWindow *w );
147 
148  MdiSubWindow *window() { return myWindow; };
149 
150 protected:
152 };
153 
154 /*****************************************************************************
155  *
156  * Class FolderListItem
157  *
158  *****************************************************************************/
160 class FolderListItem : public Q3ListViewItem
161 {
162 public:
163  FolderListItem( Q3ListView *parent, Folder *f );
164  FolderListItem( FolderListItem *parent, Folder *f );
165 
166  enum {RTTI = 1001};
167 
168  void setActive( bool o );
169 
170  virtual int rtti() const {return (int)RTTI;};
171 
172  Folder *folder() { return myFolder; };
173 
175 
178  bool isChildOf(FolderListItem *src);
179 
180 protected:
182 };
183 
184 /*****************************************************************************
185  *
186  * Class FolderListView
187  *
188  *****************************************************************************/
190 class FolderListView : public Q3ListView
191 {
192  Q_OBJECT
193 
194 public:
195  FolderListView( QWidget *parent = 0, const char *name = 0 );
196 
197 public slots:
198  void adjustColumns();
199 
200 protected slots:
201  void expandedItem(Q3ListViewItem *item);
202 
203 protected:
204  void startDrag();
205 
206  void contentsDropEvent( QDropEvent *e );
207  void contentsMouseMoveEvent( QMouseEvent *e );
208  void contentsMousePressEvent( QMouseEvent *e );
209  void contentsMouseDoubleClickEvent( QMouseEvent* e );
210  void keyPressEvent ( QKeyEvent * e );
211  void contentsMouseReleaseEvent( QMouseEvent *){mousePressed = false;};
212  void enterEvent(QEvent *){mousePressed = false;};
213 
214 signals:
215  void dragItems(QList<Q3ListViewItem *> items);
216  void dropItems(Q3ListViewItem *dest);
217  void renameItem(Q3ListViewItem *item);
218  void addFolderItem();
219  void deleteSelection();
220 
221 private:
223  QPoint presspos;
224 };
225 
226 #endif