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

ListEditor.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: David Wojnar $
00032 // $Authors: David Wojnar $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_VISUAL_LISTEDITOR_H
00036 #define OPENMS_VISUAL_LISTEDITOR_H
00037 
00038 
00039 #include <OpenMS/DATASTRUCTURES/StringList.h>
00040 #include <QtGui/QDialog>
00041 #include <QtGui/QListWidget>
00042 #include <QtGui/QItemDelegate>
00043 
00044 class QPushButton;
00045 
00046 namespace OpenMS
00047 {
00048   namespace Internal
00049   {
00050     class ListTable;
00051     class ListEditorDelegate;
00052   }
00053 
00057   class OPENMS_GUI_DLLAPI ListEditor :
00058     public QDialog
00059   {
00060     Q_OBJECT
00061 
00062 public:
00063     //types of lists
00064     enum Type
00065     {
00066       INT,
00067       FLOAT,
00068       STRING,
00069       OUTPUT_FILE,
00070       INPUT_FILE
00071     };
00072 
00074     ListEditor(QWidget * parent = 0, QString title = "");
00076     StringList getList() const;
00078     void setList(const StringList & list, ListEditor::Type type);
00080     void setListRestrictions(const String & restrictions);
00082     void setTypeName(QString name);
00083 
00084 private:
00086     ListEditor::Type type_;
00088     Internal::ListTable * listTable_;
00090     Internal::ListEditorDelegate * listDelegate_;
00092     QPushButton * newRowButton_;
00094     QPushButton * removeRowButton_;
00096     QPushButton * OkButton_;
00098     QPushButton * CancelButton_;
00099   };
00100 
00105   namespace Internal
00106   {
00107     class OPENMS_GUI_DLLAPI ListTable :
00108       public QListWidget
00109     {
00110       Q_OBJECT
00111 
00112 public:
00113 
00114       //Default Constructor
00115       ListTable(QWidget * parent = 0);
00116 
00117       //returns a list_
00118       StringList getList();
00119 
00120       //sets new list
00121       void setList(const StringList & list, ListEditor::Type type);
00122 
00123 public slots:
00124       void createNewRow();
00125       void removeCurrentRow();
00126 
00127 private:
00129       ListEditor::Type type_;
00130       //everything is internally stored as stringlist
00131       StringList list_;
00132     };
00133 
00139     class OPENMS_GUI_DLLAPI ListEditorDelegate :
00140       public QItemDelegate
00141     {
00142       Q_OBJECT
00143 
00144 public:
00146       ListEditorDelegate(QObject * parent);
00148       QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index) const;
00150       void setEditorData(QWidget * editor, const QModelIndex & index) const;
00152       void setModelData(QWidget * editor, QAbstractItemModel * model, const QModelIndex & index) const;
00154       void updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const;
00155 
00156       //sets Type of List
00157       void setType(const ListEditor::Type type);
00158       //sets restrictions for listelements
00159       void setRestrictions(const String & restrictions);
00161       void setTypeName(QString name);
00163       void setFileName(QString name);
00164 
00165 private:
00167       ListEditorDelegate();
00169       ListEditor::Type type_;
00171       String restrictions_;
00173       QString typeName_;
00175       mutable QString file_name_;
00176 
00177 
00178     };
00179   }
00180 
00181 
00182 
00183 
00184 
00185 } // namespace OpenMS
00186 #endif //OPENMS_VISUAL_LISTEDITOR_H

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