itom 2.2.1
K:/git-itom/sources/itom/Qitom/helper/IOHelper.h
00001 /* ********************************************************************
00002     itom software
00003     URL: http://www.uni-stuttgart.de/ito
00004     Copyright (C) 2016, Institut fuer Technische Optik (ITO),
00005     Universitaet 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 
00038 
00039 class IOHelper : public QObject
00040 {
00041     Q_OBJECT
00042 public:
00043 
00048     enum IOFilter
00049     {
00050         IOInput = 0x001,        
00051         IOOutput = 0x002,       
00052         IOPlugin = 0x004,       
00053         IOAllFiles = 0x008,     
00054         IOWorkspace = 0x010,     
00055         IOMimeDataObject = 0x020, 
00056         IOMimePointCloud = 0x040, 
00057         IOMimePolygonMesh = 0x080, 
00058         IOMimeAll = IOMimeDataObject | IOMimePointCloud | IOMimePolygonMesh 
00059     };
00060     Q_DECLARE_FLAGS(IOFilters, IOFilter)
00061     
00062     
00066     enum SearchFolder
00067     {
00068         SFResources = 0x001,   
00069         SFDirect = 0x002,      
00070         SFCurrent = 0x004,     
00071         SFAppDir = 0x008,      
00072         SFAppDirQItom = 0x010, 
00073         SFAll = SFResources | SFDirect | SFCurrent | SFAppDir | SFAppDirQItom 
00074     };
00075     Q_DECLARE_FLAGS(SearchFolders, SearchFolder)
00076 
00077 
00078     static RetVal openGeneralFile(const QString &generalFileName, bool openUnknownsWithExternalApp = true, bool showMessages = false, QWidget* parent = NULL, const char* errorSlotMemberOfParent = NULL, bool globalNotLocalWorkspace = true);
00079 
00080     static RetVal uiExportPyWorkspaceVars(bool globalNotLocal, const QStringList &varNames, QVector<int> compatibleParamBaseTypes, QString defaultPath = QString::Null(), QWidget* parent = NULL);
00081     static RetVal exportPyWorkspaceVars(const QString &filename, bool globalNotLocal, const QStringList &varNames);
00082 
00083     static RetVal uiImportPyWorkspaceVars(bool globalNotLocal, const IOFilters &IOfilters, QString defaultPath = QString::Null(), QWidget* parent = NULL);
00084     static RetVal importPyWorkspaceVars(const QString &filename, bool globalNotLocal);
00085 
00086     static RetVal openPythonScript(const QString &filename);
00087 
00088     static RetVal uiOpenFileWithFilter(const ito::AddInAlgo::FilterDef *filter, const QString &filename, QWidget *parent = NULL, bool globalNotLocal = true);
00089     static RetVal uiSaveFileWithFilter(QSharedPointer<ito::ParamBase> &value, const QString &filename, QWidget *parent = NULL);
00090 
00091     static RetVal openUIFile(const QString &filename, QWidget* parent = NULL, const char* errorSlotMemberOfParent = NULL);
00092 
00093     static QString getFileFilters(const IOFilters &IOfilters, QStringList *allPatterns = NULL);
00094 
00095     static bool fileFitsToFileFilters(const QString &filename, const IOFilters &IOfilters);
00096 
00097     static void elideFilepathMiddle(QString &path, int pixelLength);
00098 
00099     static QIcon searchIcon(const QString &filename, const SearchFolders &searchFolders = SFAll, const QIcon &fallbackIcon = QIcon());
00100 
00101 private:
00102     IOHelper() {}; 
00103     ~IOHelper() {}; 
00104     IOHelper(const IOHelper &) : QObject() {};
00105 
00106 };
00107 
00108 } //end namespace ito
00109 
00110 Q_DECLARE_OPERATORS_FOR_FLAGS(ito::IOHelper::IOFilters)
00111 
00112 #endif
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends