00001 /***************************************************************** 00002 * 00003 * This file is part of the FLIRTLib project 00004 * 00005 * FLIRTLib Copyright (c) 2010 Gian Diego Tipaldi and Kai O. Arras 00006 * 00007 * This software is licensed under the "Creative Commons 00008 * License (Attribution-NonCommercial-ShareAlike 3.0)" 00009 * and is copyrighted by Gian Diego Tipaldi and Kai O. Arras 00010 * 00011 * Further information on this license can be found at: 00012 * http://creativecommons.org/licenses/by-nc-sa/3.0/ 00013 * 00014 * FLIRTLib is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied 00016 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00017 * PURPOSE. 00018 * 00019 *****************************************************************/ 00020 00021 00022 00023 #ifndef DESCRIPTORCHOOSERPRESENTER_H_ 00024 #define DESCRIPTORCHOOSERPRESENTER_H_ 00025 00026 #include <gui/DescriptorPresenter.h> 00027 #include <gui/ParameterWidget.h> 00028 #include <QtGui/QComboBox> 00029 #include <QtGui/QLabel> 00030 #include <QtGui/QGridLayout> 00031 #include <QtCore/QVector> 00032 #include <QtCore/QObject> 00033 #include <QtCore/QString> 00034 00035 // class DescriptorChooserWidget: public QWidget{ 00036 // Q_OBJECT 00037 // 00038 // public: 00039 // DescriptorChooserWidget(QWidget * parent = 0); 00040 // 00041 // inline int getDescriptor() const 00042 // {return m_descriptor.currentIndex();} 00043 // inline void insertDescriptor(const QString& name) 00044 // {m_descriptor.addItem(name);} 00045 // 00046 // void resetDescriptor(); 00047 // 00048 // signals: 00049 // void descriptorChanged(int descriptor); 00050 // 00051 // public slots: 00052 // void changeDescriptor(int descriptor); 00053 // 00054 // protected: 00055 // void buildGui(); 00056 // 00057 // QComboBox m_descriptor; 00058 // QLabel m_descriptorLabel; 00059 // QGridLayout m_layout; 00060 // 00061 // }; 00062 00063 class DescriptorChooserPresenter: public QObject{ 00064 Q_OBJECT 00065 00066 public: 00067 DescriptorChooserPresenter(ParameterWidget* chooser); 00068 00069 void insertDescriptor(const QString& name, DescriptorPresenter* descriptor); 00070 00071 void setChooser(ParameterWidget* chooser); 00072 00073 inline const ParameterWidget* getChooserParameter() const 00074 {return m_chooser;} 00075 00076 inline const DescriptorPresenter* getCurrentDescriptorPresenter() const 00077 {return m_currentDescriptorPresenter;} 00078 00079 inline const DescriptorGenerator* getCurrentDescriptor() const 00080 {return m_currentDescriptorPresenter->getDescriptor();} 00081 00082 inline ParameterWidget* getChooserParameter() 00083 {return m_chooser;} 00084 00085 inline DescriptorPresenter* getCurrentDescriptorPresenter() 00086 {return m_currentDescriptorPresenter;} 00087 00088 inline DescriptorGenerator* getCurrentDescriptor() 00089 {return m_currentDescriptorPresenter->getDescriptor();} 00090 00091 signals: 00092 void descriptorChanged(); 00093 00094 public slots: 00095 void changeDescriptor(int descriptor); 00096 void changeParameter(const QString& name); 00097 00098 protected: 00099 void syncronize(); 00100 void reconnect(); 00101 ParameterWidget* m_chooser; 00102 DescriptorPresenter* m_currentDescriptorPresenter; 00103 int m_currentDescriptorPresenterIndex; 00104 QVector< DescriptorPresenter* > m_descriptorPresenters; 00105 QStringList m_descriptorPresenterNames; 00106 }; 00107 00108 #endif