QtiPlot
0.9.8.2
|
00001 /*************************************************************************** 00002 File : Folder.h 00003 Project : QtiPlot 00004 -------------------------------------------------------------------- 00005 Copyright : (C) 2006 by Ion Vasilief 00006 Email (use @ for *) : ion_vasilief*yahoo.fr 00007 Description : Folder for the project explorer 00008 00009 ***************************************************************************/ 00010 00011 /*************************************************************************** 00012 * * 00013 * This program is free software; you can redistribute it and/or modify * 00014 * it under the terms of the GNU General Public License as published by * 00015 * the Free Software Foundation; either version 2 of the License, or * 00016 * (at your option) any later version. * 00017 * * 00018 * This program is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00021 * GNU General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU General Public License * 00024 * along with this program; if not, write to the Free Software * 00025 * Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00026 * Boston, MA 02110-1301 USA * 00027 * * 00028 ***************************************************************************/ 00029 #ifndef FOLDER_H 00030 #define FOLDER_H 00031 00032 #include <QObject> 00033 #include <QEvent> 00034 #include <q3listview.h> 00035 #include <q3iconview.h> 00036 00037 #include "MdiSubWindow.h" 00038 00039 class FolderListItem; 00040 class Table; 00041 class Matrix; 00042 class MultiLayer; 00043 class Note; 00044 class Graph3D; 00045 00046 class QDragEnterEvent; 00047 class QDragMoveEvent; 00048 class QDragLeaveEvent; 00049 class QDropEvent; 00050 class Q3DragObject; 00051 00053 class Folder : public QObject 00054 { 00055 Q_OBJECT 00056 00057 public: 00058 Folder( Folder *parent, const QString &name ); 00059 00060 QList<MdiSubWindow *> windowsList(){return lstWindows;}; 00061 00062 void addWindow( MdiSubWindow *w ); 00063 void removeWindow( MdiSubWindow *w ); 00064 00066 QStringList subfolders(); 00067 00069 QList<Folder*> folders(); 00070 00072 Folder* findSubfolder(const QString& s, bool caseSensitive = true, bool partialMatch = false); 00073 00075 MdiSubWindow* findWindow(const QString& s, bool windowNames, bool labels, 00076 bool caseSensitive, bool partialMatch); 00077 00079 00084 MdiSubWindow *window(const QString &name, const char *cls="MdiSubWindow", bool recursive=false); 00086 Table *table(const QString &name, bool recursive=false) { return (Table*) window(name, "Table", recursive); } 00088 Matrix *matrix(const QString &name, bool recursive=false) { return (Matrix*) window(name, "Matrix", recursive); } 00090 MultiLayer *graph(const QString &name, bool recursive=false) { return (MultiLayer*) window(name, "MultiLayer", recursive); } 00092 Note *note(const QString &name, bool recursive=false) { return (Note*) window(name, "Note", recursive); } 00094 Graph3D *plot3D(const QString &name, bool recursive=false) { return (Graph3D*) window(name, "Graph3D", recursive); } 00095 00097 QString path(); 00098 00100 int depth(); 00101 00102 Folder *folderBelow(); 00103 00105 Folder* rootFolder(); 00106 00108 QString sizeToString(); 00109 00110 QString birthDate(){return birthdate;}; 00111 void setBirthDate(const QString& s){birthdate = s;}; 00112 00113 QString modificationDate(){return modifDate;}; 00114 void setModificationDate(const QString& s){modifDate = s;}; 00115 00117 FolderListItem * folderListItem(){return myFolderListItem;}; 00118 void setFolderListItem(FolderListItem *it){myFolderListItem = it;}; 00119 00120 MdiSubWindow *activeWindow(){return d_active_window;}; 00121 void setActiveWindow(MdiSubWindow *w){d_active_window = w;}; 00122 00123 QString logInfo(){return d_log_info;}; 00124 void appendLogInfo(const QString& text){d_log_info += text;}; 00125 void clearLogInfo(){d_log_info = QString();}; 00126 00127 protected: 00128 QString birthdate, modifDate; 00129 QString d_log_info; 00130 QList<MdiSubWindow *> lstWindows; 00131 FolderListItem *myFolderListItem; 00132 00134 MdiSubWindow *d_active_window; 00135 }; 00136 00137 /***************************************************************************** 00138 * 00139 * Class WindowListItem 00140 * 00141 *****************************************************************************/ 00143 class WindowListItem : public Q3ListViewItem 00144 { 00145 public: 00146 WindowListItem( Q3ListView *parent, MdiSubWindow *w ); 00147 00148 MdiSubWindow *window() { return myWindow; }; 00149 00150 protected: 00151 MdiSubWindow *myWindow; 00152 }; 00153 00154 /***************************************************************************** 00155 * 00156 * Class FolderListItem 00157 * 00158 *****************************************************************************/ 00160 class FolderListItem : public Q3ListViewItem 00161 { 00162 public: 00163 FolderListItem( Q3ListView *parent, Folder *f ); 00164 FolderListItem( FolderListItem *parent, Folder *f ); 00165 00166 enum {RTTI = 1001}; 00167 00168 void setActive( bool o ); 00169 00170 virtual int rtti() const {return (int)RTTI;}; 00171 00172 Folder *folder() { return myFolder; }; 00173 00175 00178 bool isChildOf(FolderListItem *src); 00179 00180 protected: 00181 Folder *myFolder; 00182 }; 00183 00184 /***************************************************************************** 00185 * 00186 * Class FolderListView 00187 * 00188 *****************************************************************************/ 00190 class FolderListView : public Q3ListView 00191 { 00192 Q_OBJECT 00193 00194 public: 00195 FolderListView( QWidget *parent = 0, const char *name = 0 ); 00196 00197 public slots: 00198 void adjustColumns(); 00199 00200 protected slots: 00201 void expandedItem(Q3ListViewItem *item); 00202 00203 protected: 00204 void startDrag(); 00205 00206 void contentsDropEvent( QDropEvent *e ); 00207 void contentsMouseMoveEvent( QMouseEvent *e ); 00208 void contentsMousePressEvent( QMouseEvent *e ); 00209 void contentsMouseDoubleClickEvent( QMouseEvent* e ); 00210 void keyPressEvent ( QKeyEvent * e ); 00211 void contentsMouseReleaseEvent( QMouseEvent *){mousePressed = false;}; 00212 void enterEvent(QEvent *){mousePressed = false;}; 00213 00214 signals: 00215 void dragItems(QList<Q3ListViewItem *> items); 00216 void dropItems(Q3ListViewItem *dest); 00217 void renameItem(Q3ListViewItem *item); 00218 void addFolderItem(); 00219 void deleteSelection(); 00220 00221 private: 00222 bool mousePressed; 00223 QPoint presspos; 00224 }; 00225 00226 #endif