itom 2.2.1
K:/git-itom/sources/itom/itomWidgets/pathLineEdit.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 and its software development toolkit (SDK).
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     In addition, as a special exception, the Institut fuer Technische
00015     Optik (ITO) gives you certain additional rights.
00016     These rights are described in the ITO LGPL Exception version 1.0,
00017     which can be found in the file LGPL_EXCEPTION.txt in this package.
00018 
00019     itom is distributed in the hope that it will be useful, but
00020     WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00022     General Public Licence for more details.
00023 
00024     You should have received a copy of the GNU Library General Public License
00025     along with itom. If not, see <http://www.gnu.org/licenses/>.
00026 
00027     This file is a port and modified version of the 
00028     CTK Common Toolkit (http://www.commontk.org)
00029 *********************************************************************** */
00030 /*=========================================================================
00031 
00032 Program:   Maverick
00033 Module:    $RCSfile: config.h,v $
00034 
00035 Copyright (c) Kitware Inc. 28 Corporate Drive,
00036 Clifton Park, NY, 12065, USA.
00037 
00038 All rights reserved. No part of this software may be reproduced, distributed,
00039 or modified, in any form or by any means, without permission in writing from
00040 Kitware Inc.
00041 
00042 IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
00043 DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
00044 OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
00045 EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00046 
00047 THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
00048 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
00049 PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN
00050 "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
00051 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
00052 
00053 =========================================================================*/
00054 
00055 #ifndef PATHLINEEDIT_H
00056 #define PATHLINEEDIT_H
00057 
00058 // Qt includes
00059 #include <QDir>
00060 #include <QWidget>
00061 class QComboBox;
00062 
00063 // CTK includes
00064 #include "commonWidgets.h"
00065 class PathLineEditPrivate;
00066 
00071 class ITOMWIDGETS_EXPORT PathLineEdit: public QWidget
00072 {
00073   Q_OBJECT
00074   Q_FLAGS(Filters)
00075   Q_PROPERTY ( QString label READ label WRITE setLabel )
00076 
00077   Q_PROPERTY ( Filters filters READ filters WRITE setFilters)
00078   Q_PROPERTY ( QString currentPath READ currentPath WRITE setCurrentPath USER true )
00082 #ifdef USE_QFILEDIALOG_OPTIONS
00083   Q_PROPERTY(QFileDialog::Options options READ options WRITE setOptions)
00084 #else
00085   Q_PROPERTY(Options options READ options WRITE setOptions)
00086   Q_FLAGS(Option Options)
00087 #endif
00088 
00097   Q_PROPERTY(QString settingKey READ settingKey WRITE setSettingKey )
00098 
00099   
00100 
00101 
00102 
00103   Q_PROPERTY(bool showBrowseButton READ showBrowseButton WRITE setShowBrowseButton)
00104 
00109   Q_PROPERTY(bool showHistoryButton READ showHistoryButton WRITE setShowHistoryButton)
00110 
00114   Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
00115 
00120   Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
00121 
00125   Q_PROPERTY(QStringList nameFilters READ nameFilters WRITE setNameFilters)
00126 
00127 public:
00128   enum Filter { Dirs        = 0x001,
00129                 Files       = 0x002,
00130                 Drives      = 0x004,
00131                 NoSymLinks  = 0x008,
00132                 AllEntries  = Dirs | Files | Drives,
00133                 TypeMask    = 0x00f,
00134                 Readable    = 0x010,
00135                 Writable    = 0x020,
00136                 Executable  = 0x040,
00137                 PermissionMask    = 0x070,
00138                 Modified    = 0x080,
00139                 Hidden      = 0x100,
00140                 System      = 0x200,
00141                 AccessMask  = 0x3F0,
00142                 AllDirs       = 0x400,
00143                 CaseSensitive = 0x800,
00144                 NoDotAndDotDot = 0x1000, // ### Qt5 NoDotAndDotDot = NoDot|NoDotDot
00145                 NoDot         = 0x2000,
00146                 NoDotDot      = 0x4000,
00147                 NoFilter = -1
00148   };
00149   Q_DECLARE_FLAGS(Filters, Filter)
00150 
00151 #ifndef USE_QFILEDIALOG_OPTIONS
00152   // Same options than QFileDialog::Options
00153   enum Option
00154   {
00155     ShowDirsOnly          = 0x00000001,
00156     DontResolveSymlinks   = 0x00000002,
00157     DontConfirmOverwrite  = 0x00000004,
00158     DontUseSheet          = 0x00000008,
00159     DontUseNativeDialog   = 0x00000010,
00160     ReadOnly              = 0x00000020,
00161     HideNameFilterDetails = 0x00000040
00162   };
00163   Q_DECLARE_FLAGS(Options, Option)
00164 #endif
00165 
00166   enum SizeAdjustPolicy
00167   {
00169     AdjustToContents,
00171     AdjustToContentsOnFirstShow,
00174     AdjustToMinimumContentsLength
00175   };
00176 
00179   PathLineEdit(QWidget *parent = 0);
00180 
00187   PathLineEdit( const QString& label,
00188                    const QStringList& nameFilters,
00189                    Filters filters = PathLineEdit::AllEntries,
00190                    QWidget *parent=0 );
00191   virtual ~PathLineEdit();
00192   QString currentPath()const;
00193 
00194   void setLabel(const QString &label);
00195   const QString& label()const;
00196 
00197   void setNameFilters(const QStringList &nameFilters);
00198   const QStringList& nameFilters()const;
00199 
00200   void setFilters(const Filters& filters);
00201   Filters filters()const;
00202 
00205 #ifdef USE_QFILEDIALOG_OPTIONS
00206   void setOptions(const QFileDialog::Options& options);
00207   const QFileDialog::Options& options()const;
00208 #else
00209   void setOptions(const Options& options);
00210   const Options& options()const;
00211 #endif
00212 
00215   void setCurrentFileExtension(const QString& extension);
00216 
00217   QString settingKey()const;
00218   void setSettingKey(const QString& key);
00219 
00220   bool showBrowseButton()const;
00221   void setShowBrowseButton(bool visible);
00222 
00223   bool showHistoryButton()const;
00224   void setShowHistoryButton(bool visible);
00225 
00232   SizeAdjustPolicy sizeAdjustPolicy() const;
00233 
00234   void setSizeAdjustPolicy(SizeAdjustPolicy policy);
00235 
00236   int minimumContentsLength()const;
00237   void setMinimumContentsLength(int lenght);
00238 
00240   QComboBox* comboBox() const;
00241 
00244   virtual QSize minimumSizeHint()const;
00245 
00248   virtual QSize sizeHint()const;
00249 
00250 signals:
00253   void validInputChanged(bool);
00254 
00255   void currentPathChanged(const QString& path);
00256 
00257 public slots:
00258   void setCurrentPath(const QString& path);
00259 
00265   void browse();
00266 
00271   void retrieveHistory();
00272 
00276   void addCurrentPathToHistory();
00277 
00278 protected Q_SLOTS:
00279   void setCurrentDirectory(const QString& directory);
00280   void updateHasValidInput();
00281 
00282 protected:
00283   QScopedPointer<PathLineEditPrivate> d_ptr;
00284 
00285 private:
00286   Q_DECLARE_PRIVATE(PathLineEdit);
00287   Q_DISABLE_COPY(PathLineEdit);
00288 
00289   Q_PRIVATE_SLOT(d_ptr, void _q_recomputeCompleterPopupSize())
00290 };
00291 
00292 Q_DECLARE_OPERATORS_FOR_FLAGS(PathLineEdit::Filters)
00293 #ifndef USE_QFILEDIALOG_OPTIONS
00294 Q_DECLARE_OPERATORS_FOR_FLAGS(PathLineEdit::Options);
00295 #endif
00296 
00297 #endif // PATHLINEEDIT_H
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties Friends