itom 2.0.0
D:/git-itom/sources/itom/Qitom/helper/IOHelper.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 IOHELPER_H
00024 #define IOHELPER_H
00025 
00026 #include "../global.h"
00027 #include "../common/sharedStructures.h"
00028 #include "../common/sharedStructuresQt.h"
00029 #include "../../common/addInInterface.h"
00030 
00031 #include <qstring.h>
00032 #include <qobject.h>
00033 #include <qicon.h>
00034 
00035 namespace ito {
00036 
00037 class IOHelper : public QObject
00038 {
00039     Q_OBJECT
00040 public:
00041     enum IOFilter
00042     {
00043         IOInput = 0x001,        
00044         IOOutput = 0x002,       
00045         IOPlugin = 0x004,       
00046         IOAllFiles = 0x008,     
00047         IOWorkspace = 0x010,     
00048         IOMimeDataObject = 0x020,
00049         IOMimePointCloud = 0x040,
00050         IOMimePolygonMesh = 0x080,
00051         IOMimeAll = IOMimeDataObject | IOMimePointCloud | IOMimePolygonMesh
00052     };
00053     Q_DECLARE_FLAGS(IOFilters, IOFilter)
00054 
00055     enum SearchFolder
00056     {
00057         SFResources = 0x001,
00058         SFDirect = 0x002,
00059         SFCurrent = 0x004,
00060         SFAppDir = 0x008,
00061         SFAppDirQItom = 0x010,
00062         SFAll = SFResources | SFDirect | SFCurrent | SFAppDir | SFAppDirQItom
00063     };
00064     Q_DECLARE_FLAGS(SearchFolders, SearchFolder)
00065 
00066 
00067     static RetVal openGeneralFile(const QString &generalFileName, bool openUnknownsWithExternalApp = true, bool showMessages = false, QWidget* parent = NULL, const char* errorSlotMemberOfParent = NULL, bool globalNotLocalWorkspace = true);
00068 
00069     static RetVal uiExportPyWorkspaceVars(bool globalNotLocal, const QStringList &varNames, QVector<int> compatibleParamBaseTypes, QString defaultPath = QString::Null(), QWidget* parent = NULL);
00070     static RetVal exportPyWorkspaceVars(const QString &filename, bool globalNotLocal, const QStringList &varNames);
00071 
00072     static RetVal uiImportPyWorkspaceVars(bool globalNotLocal, IOFilters IOfilters, QString defaultPath = QString::Null(), QWidget* parent = NULL);
00073     static RetVal importPyWorkspaceVars(const QString &filename, bool globalNotLocal);
00074 
00075     static RetVal uiOpenPythonScript(QString defaultPath = QString::Null(), QWidget* parent = NULL);
00076     static RetVal openPythonScript(const QString &filename);
00077 
00078     static RetVal uiOpenFileWithFilter(const ito::AddInAlgo::FilterDef *filter, const QString &filename, QWidget *parent = NULL, bool globalNotLocal = true);
00079     static RetVal uiSaveFileWithFilter(QSharedPointer<ito::ParamBase> &value, const QString &filename, QWidget *parent = NULL);
00080 
00081     static RetVal openUIFile(const QString &filename, QWidget* parent = NULL, const char* errorSlotMemberOfParent = NULL);
00082 
00083     static QString getFileFilters(const IOFilters &IOfilters, QStringList *allPatterns = NULL);
00084 
00085     static bool fileFitsToFileFilters(const QString &filename, const IOFilters &IOfilters);
00086 
00087     static void elideFilepathMiddle(QString &path, int pixelLength);
00088 
00089     static QIcon searchIcon(const QString &filename, SearchFolders searchFolders = SFAll, const QIcon &fallbackIcon = QIcon());
00090 
00091 private:
00092     IOHelper() {};
00093     ~IOHelper() {};
00094     IOHelper(const IOHelper &) : QObject() {};
00095 
00096 };
00097 
00098 } //end namespace ito
00099 
00100 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends