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 DETECTORCHOOSERPRESENTER_H_ 00024 #define DETECTORCHOOSERPRESENTER_H_ 00025 00026 #include <gui/DetectorPresenter.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 DetectorChooserWidget: public QWidget{ 00036 // Q_OBJECT 00037 // 00038 // public: 00039 // DetectorChooserWidget(QWidget * parent = 0); 00040 // 00041 // inline int getDetector() const 00042 // {return m_detector.currentIndex();} 00043 // inline void insertDetector(const QString& name) 00044 // {m_detector.addItem(name);} 00045 // 00046 // void resetDetector(); 00047 // 00048 // signals: 00049 // void detectorChanged(int detector); 00050 // 00051 // public slots: 00052 // void changeDetector(int detector); 00053 // 00054 // protected: 00055 // void buildGui(); 00056 // 00057 // QComboBox m_detector; 00058 // QLabel m_detectorLabel; 00059 // QGridLayout m_layout; 00060 // 00061 // }; 00062 00063 class DetectorChooserPresenter: public QObject{ 00064 Q_OBJECT 00065 00066 public: 00067 DetectorChooserPresenter(ParameterWidget* chooser); 00068 00069 void insertDetector(const QString& name, DetectorPresenter* detector); 00070 00071 void setChooser(ParameterWidget* chooser); 00072 00073 inline const ParameterWidget* getChooserParameter() const 00074 {return m_chooser;} 00075 00076 inline const DetectorPresenter* getCurrentDetectorPresenter() const 00077 {return m_currentDetectorPresenter;} 00078 00079 inline const Detector* getCurrentDetector() const 00080 {return m_currentDetectorPresenter->getDetector();} 00081 00082 inline ParameterWidget* getChooserParameter() 00083 {return m_chooser;} 00084 00085 inline DetectorPresenter* getCurrentDetectorPresenter() 00086 {return m_currentDetectorPresenter;} 00087 00088 inline Detector* getCurrentDetector() 00089 {return m_currentDetectorPresenter->getDetector();} 00090 00091 signals: 00092 void detectorChanged(); 00093 00094 public slots: 00095 void changeDetector(int detector); 00096 void changeParameter(const QString& name); 00097 00098 protected: 00099 void syncronize(); 00100 void reconnect(); 00101 ParameterWidget* m_chooser; 00102 DetectorPresenter* m_currentDetectorPresenter; 00103 int m_currentDetectorPresenterIndex; 00104 QVector< DetectorPresenter* > m_detectorPresenters; 00105 QStringList m_detectorPresenterNames; 00106 }; 00107 00108 #endif