Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

ParamEditor.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: Timo Sachsenberg$
00032 // $Authors: Marc Sturm $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_VISUAL_PARAMEDITOR_H
00036 #define OPENMS_VISUAL_PARAMEDITOR_H
00037 
00038 #include <OpenMS/CONCEPT/Types.h>
00039 
00040 #include <OpenMS/VISUAL/UIC/ui_ParamEditor.h>
00041 
00042 
00043 #include <QtGui/QItemDelegate>
00044 #include <QtGui/QTreeWidget>
00045 
00046 class QModelIndex;
00047 class QStyleOptionViewItem;
00048 class QAbstractItemModel;
00049 class QStringList;
00050 class QString;
00051 
00052 namespace OpenMS
00053 {
00054   class String;
00055   class Param;
00056   class ParamEditor;
00061   namespace Internal
00062   {
00068     class OPENMS_GUI_DLLAPI ParamEditorDelegate :
00069       public QItemDelegate
00070     {
00071       Q_OBJECT
00072 
00073 public:
00075       ParamEditorDelegate(QObject * parent);
00077       QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
00079       void setEditorData(QWidget * editor, const QModelIndex & index) const;
00081       void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
00083       void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
00084 
00085 signals:
00087       void modified(bool) const;
00088 
00089 protected:
00091       bool exists_(QString name, QModelIndex index) const;
00092 
00093 private slots:
00095       void commitAndCloseListEditor_();
00097       void commitAndCloseComboBox_();
00099       void closeListEditor_();
00100 private:
00102       ParamEditorDelegate();
00104       mutable QString fileName_;
00105     };
00106 
00108     class OPENMS_GUI_DLLAPI ParamTree :
00109       public QTreeWidget
00110     {
00111       Q_OBJECT
00112 
00113 public:
00115       ParamTree(QWidget * parent);
00117       bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event);
00118 
00119 signals:
00121       void selected(const QModelIndex & index);
00122 
00123 protected slots:
00125       void selectionChanged(const QItemSelection & selected, const QItemSelection &);
00126     };
00127 
00128   }
00129 
00141   class OPENMS_GUI_DLLAPI ParamEditor :
00142     public QWidget,
00143     public Ui::ParamEditorTemplate
00144   {
00145     Q_OBJECT
00146 
00147 public:
00149     enum
00150     {
00151       NODE,                           
00152       NORMAL_ITEM,              
00153       ADVANCED_ITEM             
00154     };
00155 
00157     ParamEditor(QWidget * parent = 0);
00159     void load(Param & param);
00161     void store();
00163     bool isModified() const;
00165     void clear();
00166 
00167 public slots:
00170     void setModified(bool is_modified);
00171 
00172 signals:
00174     void modified(bool);
00175 
00176 protected slots:
00178     void toggleAdvancedMode(bool advanced);
00180     void showDocumentation(const QModelIndex & index);
00181 
00182 protected:
00184     void storeRecursive_(QTreeWidgetItem * child, String path, std::map<String, String> & section_descriptions);
00185 
00187     Internal::ParamTree * tree_;
00189     Param * param_;
00191     bool modified_;
00193     bool advanced_mode_;
00194   };
00195 
00196 
00197 } // namespace OpenMS
00198 
00199 #endif // OPENMS_VISUAL_PARAMEDITOR_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:43 using doxygen 1.7.1