Folder.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     File                 : Folder.h
00003     Project              : QtiPlot
00004     --------------------------------------------------------------------
00005     Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
00006     Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
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 
00045 class QDragEnterEvent;
00046 class QDragMoveEvent;
00047 class QDragLeaveEvent;
00048 class QDropEvent;
00049 class Q3DragObject;
00050 
00052 class Folder : public QObject
00053 {
00054     Q_OBJECT
00055 
00056 public:
00057     Folder( Folder *parent, const QString &name );
00058 
00059     QList<MdiSubWindow *> windowsList(){return lstWindows;};
00060 
00061     void addWindow( MdiSubWindow *w );
00062     void removeWindow( MdiSubWindow *w );
00063 
00065     QStringList subfolders();
00066 
00068     QList<Folder*> folders();
00069 
00071     Folder* findSubfolder(const QString& s, bool caseSensitive = true, bool partialMatch = false);
00072 
00074     MdiSubWindow* findWindow(const QString& s, bool windowNames, bool labels,
00075                              bool caseSensitive, bool partialMatch);
00076 
00078 
00083     MdiSubWindow *window(const QString &name, const char *cls="MdiSubWindow", bool recursive=false);
00085     Table *table(const QString &name, bool recursive=false) { return (Table*) window(name, "Table", recursive); }
00087     Matrix *matrix(const QString &name, bool recursive=false) { return (Matrix*) window(name, "Matrix", recursive); }
00089     MultiLayer *graph(const QString &name, bool recursive=false) { return (MultiLayer*) window(name, "MultiLayer", recursive); }
00091     Note *note(const QString &name, bool recursive=false) { return (Note*) window(name, "Note", recursive); }
00092 
00094     QString path();
00095     
00097     int depth();
00098     
00099     Folder *folderBelow();
00100 
00102     Folder* rootFolder();
00103 
00105     QString sizeToString();
00106 
00107     QString birthDate(){return birthdate;};
00108     void setBirthDate(const QString& s){birthdate = s;};
00109 
00110     QString modificationDate(){return modifDate;};
00111     void setModificationDate(const QString& s){modifDate = s;};
00112 
00114     FolderListItem * folderListItem(){return myFolderListItem;};
00115     void setFolderListItem(FolderListItem *it){myFolderListItem = it;};
00116 
00117     MdiSubWindow *activeWindow(){return d_active_window;};
00118     void setActiveWindow(MdiSubWindow *w){d_active_window = w;};
00119 
00120     QString logInfo(){return d_log_info;};
00121     void appendLogInfo(const QString& text){d_log_info += text;};
00122     void clearLogInfo(){d_log_info = QString();};
00123     
00124 protected:
00125     QString birthdate, modifDate;
00126     QString d_log_info;
00127     QList<MdiSubWindow *> lstWindows;
00128     FolderListItem *myFolderListItem;
00129 
00131     MdiSubWindow *d_active_window;
00132 };
00133 
00134 /*****************************************************************************
00135  *
00136  * Class WindowListItem
00137  *
00138  *****************************************************************************/
00140 class WindowListItem : public Q3ListViewItem
00141 {
00142 public:
00143     WindowListItem( Q3ListView *parent, MdiSubWindow *w );
00144 
00145     MdiSubWindow *window() { return myWindow; };
00146 
00147 protected:
00148     MdiSubWindow *myWindow;
00149 };
00150 
00151 /*****************************************************************************
00152  *
00153  * Class FolderListItem
00154  *
00155  *****************************************************************************/
00157 class FolderListItem : public Q3ListViewItem
00158 {
00159 public:
00160     FolderListItem( Q3ListView *parent, Folder *f );
00161     FolderListItem( FolderListItem *parent, Folder *f );
00162 
00163     enum {RTTI = 1001};
00164 
00165     void setActive( bool o );
00166 
00167     virtual int rtti() const {return (int)RTTI;};
00168 
00169     Folder *folder() { return myFolder; };
00170 
00172 
00175     bool isChildOf(FolderListItem *src);
00176 
00177 protected:
00178     Folder *myFolder;
00179 };
00180 
00181 /*****************************************************************************
00182  *
00183  * Class FolderListView
00184  *
00185  *****************************************************************************/
00187 class FolderListView : public Q3ListView
00188 {
00189     Q_OBJECT
00190 
00191 public:
00192     FolderListView( QWidget *parent = 0, const char *name = 0 );
00193 
00194 public slots:
00195     void adjustColumns();
00196 
00197 protected slots:
00198     void expandedItem(Q3ListViewItem *item);
00199 
00200 protected:
00201     void startDrag();
00202 
00203     void contentsDropEvent( QDropEvent *e );
00204     void contentsMouseMoveEvent( QMouseEvent *e );
00205     void contentsMousePressEvent( QMouseEvent *e );
00206     void contentsMouseDoubleClickEvent( QMouseEvent* e );
00207     void keyPressEvent ( QKeyEvent * e );
00208     void contentsMouseReleaseEvent( QMouseEvent *){mousePressed = false;};
00209     void enterEvent(QEvent *){mousePressed = false;};
00210 
00211 signals:
00212     void dragItems(QList<Q3ListViewItem *> items);
00213     void dropItems(Q3ListViewItem *dest);
00214     void renameItem(Q3ListViewItem *item);
00215     void addFolderItem();
00216     void deleteSelection();
00217 
00218 private:
00219     bool mousePressed;
00220     QPoint presspos;
00221 };
00222 
00223 #endif

Generated on Tue Nov 3 10:48:50 2009 for QtiPlot by  doxygen 1.6.1