itom 1.0.14
D:/git-itom/sources/itom/Qitom/widgets/fileSystemDockWidget.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2013, Institut für Technische Optik (ITO),
00005     Universität Stuttgart, Germany
00006 
00007     This file is part of itom.
00008   
00009     itom is free software; you can redistribute it and/or modify it
00010     under the terms of the GNU Library General Public Licence as published by
00011     the Free Software Foundation; either version 2 of the Licence, or (at
00012     your option) any later version.
00013 
00014     itom is distributed in the hope that it will be useful, but
00015     WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00017     General Public Licence for more details.
00018 
00019     You should have received a copy of the GNU Library General Public License
00020     along with itom. If not, see <http://www.gnu.org/licenses/>.
00021 *********************************************************************** */
00022 
00023 #ifndef FILESYSTEMDOCKWIDGET_H
00024 #define FILESYSTEMDOCKWIDGET_H
00025 
00026 #include "../helper/IOHelper.h"
00027 #include "abstractDockWidget.h"
00028 
00029 #include <qwidget.h>
00030 #include <qaction.h>
00031 #include <qtoolbar.h>
00032 
00033 #include <qtextbrowser.h>
00034 #include <qtreeview.h>
00035 #include <qlabel.h>
00036 #include <qfilesystemmodel.h>
00037 #include <qhash.h>
00038 #include <qmutex.h>
00039 #include <qmenu.h>
00040 #include <qcombobox.h>
00041 #include <qprocess.h>
00042 #include <qevent.h>
00043 #include <qurl.h>
00044 
00045 #include <qsignalmapper.h>
00046 
00047 
00048 namespace ito
00049 {
00050     class FileSystemDockWidget : public AbstractDockWidget
00051     {
00052         Q_OBJECT
00053 
00054         public:
00055             FileSystemDockWidget(const QString &title, QWidget *parent = NULL, bool docked = true, bool isDockAvailable = true, tFloatingStyle floatingStyle = floatingNone, tMovingStyle movingStyle = movingEnabled, const QString &baseDirectory = QDir::currentPath());
00056             ~FileSystemDockWidget();
00057 
00058         protected:
00059             class FileSystemTreeView : public QTreeView
00060             {
00061             public:
00062                 FileSystemTreeView ( QWidget * parent = 0 ) : QTreeView(parent) {}
00063                 ~FileSystemTreeView () {}
00064 
00065                 QModelIndexList selectedIndexes() const
00066                 { 
00067                     return QTreeView::selectedIndexes();
00068                 }
00069 
00070                 //void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected)
00071                 //{
00072                 //    QTreeView::selectionChanged(selected, deselected);
00073                 //    AbstractDockWidget *adw = qobject_cast<AbstractDockWidget*>(parent());
00074                 //    if(adw) adw->updateActions();
00075                 //}
00076                 
00078 
00086                         /*
00087                 void mouseDoubleClickEvent ( QMouseEvent * event )
00088                 {
00089                     QModelIndexList currents = selectedIndexes();
00090 
00091                     if(currents.size() > 0)
00092                     {
00093                                         emit activated(currents[0]);
00094                                         event->accept();
00095                     }
00096                     else
00097                     {
00098                         event->ignore();
00099                     }
00100                 }
00101                         */
00102 
00103             };
00104 
00105             void createActions();
00106             void createMenus();
00107             void createToolBars();
00108             void createStatusBar(){}
00109             void updateActions();
00110             void updatePythonActions(){ updateActions(); }
00111 
00112             QString getHtmlTag(const QString &tag);
00113 
00114             bool eventFilter(QObject *obj, QEvent *event);
00115 
00116         private:
00117             void fillFilterList();
00118             void showInGraphicalShell(const QString &filePath);
00119 
00120             QMenu* m_pShowDirListMenu;
00121             QMenu* m_pFileSystemSettingMenu;
00122             QMenu* m_pContextMenu;
00123             QTextBrowser* m_pPathEdit;
00124             QToolBar* m_pMainToolbar;
00125             FileSystemTreeView* m_pTreeView;
00126             QLabel* m_pLblFilter;
00127             QComboBox* m_pCmbFilter;
00128             QFileSystemModel* m_pFileSystemModel;
00129             QSignalMapper *m_newDirSelectedMapper;
00130             QString baseDirectory;
00131             QHash<QString,QStringList> defaultFilterPatterns;
00132             QMutex baseDirChangeMutex;
00133             QList<QUrl> m_clipboardCutData; //this mime-data has recently be selected by a cut action and is no available in QClipboard
00134             int *m_pColumnWidth;
00135 
00136             ShortcutAction* m_pActMoveCDUp;
00137             ShortcutAction* m_pActSelectCD;
00138             ShortcutAction* m_pActCopyDir;
00139             ShortcutAction* m_pActPasteDir;
00140             ShortcutAction* m_pActOpenFile;
00141             ShortcutAction* m_pActExecuteFile;
00142             ShortcutAction* m_pActLocateOnDisk;
00143             ShortcutAction* m_pActRenameItem;
00144             ShortcutAction* m_pActDeleteItems;
00145             ShortcutAction* m_pActCutItems;
00146             ShortcutAction* m_pActCopyItems;
00147             ShortcutAction* m_pActPasteItems;
00148             ShortcutAction* m_pActNewDir;
00149             ShortcutAction* m_pActNewPyFile;
00150             ShortcutAction* m_pViewList;
00151             ShortcutAction* m_pViewDetails;
00152 
00153             QAction *m_lastMovedShowDirAction;
00154 
00155         signals:
00156             void currentDirChanged();
00157 
00158         private slots:
00159             void mnuMoveCDUp();
00160             void mnuSelectCD();
00161             void mnuCopyDir();
00162             void mnuPasteDir();
00163             void mnuLocateOnDisk();
00164             void mnuExecuteFile();
00165             void mnuOpenFile();
00166             void mnuRenameItem();
00167             void mnuDeleteItems();
00168             void mnuCutItems();
00169             void mnuCopyItems();
00170             void mnuPasteItems();
00171             void mnuNewDir();
00172             void mnuNewPyFile();
00173             void showList();
00174             void showDetails();
00175             void mnuToggleView();
00176             void newDirSelected(const QString& text);
00177             void cmbFilterEditTextChanged(const QString &text);
00178             void openFile(const QModelIndex& index);
00179             void treeViewContextMenuRequested(const QPoint &pos);
00180             void setTreeViewHideColumns(const bool &hide);
00181             void removeActionFromDirList(const int &pos);
00182                 void changeDir();
00183 
00184             void pathAnchorClicked(const QUrl &link);
00185 
00186         public slots:
00187             RetVal changeBaseDirectory(QString dir);
00188             void processError(QProcess::ProcessError error);
00189     };
00190 
00191 } //end namespace ito
00192 
00193 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends