utilities/include/ui/configurationwidget.h

00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Tomassino Ferrauto                              *
00003  *   t_ferrauto@yahoo.it                                                   *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef CONFIGURATION_WIDGET_H
00022 #define CONFIGURATION_WIDGET_H
00023 
00024 #include <QSplitter>
00025 #include <QTreeWidget>
00026 #include <QTreeWidgetItem>
00027 #include <QTableWidget>
00028 #include <QTableWidgetItem>
00029 #include "configurationparameters.h"
00030 
00031 namespace farsa {
00032 
00045 class ConfigurationWidget : public QSplitter
00046 {
00047     Q_OBJECT
00048 
00049 public:
00056     ConfigurationWidget(QWidget *parent = NULL);
00057 
00061     ~ConfigurationWidget();
00062 
00068     void setConfigurationParameters(ConfigurationParameters *conf);
00069 
00077     ConfigurationParameters* getConfigurationParameters()
00078     {
00079         return m_configurationParameters;
00080     }
00081 
00089     const ConfigurationParameters* getCurrentParameters()
00090     {
00091         return &m_tmpParameters;
00092     }
00093 
00100     void updateParameters();
00101 
00108     void setReadOnly(bool readOnly);
00109 
00115     bool readOnly() const
00116     {
00117         return m_readOnly;
00118     }
00119 
00123     void store();
00124 
00131     void restore();
00132 
00140     bool valuesChanged() const
00141     {
00142         return m_valuesChanged;
00143     }
00144 
00145 signals:
00153     void valueHasChanged(QString parameter, QString oldValue, QString newValue);
00154 
00155 private slots:
00159     void changeTableContent(QTreeWidgetItem *item, int column);
00160 
00164     void storeChangedItem(QTableWidgetItem *item);
00165 
00166 private:
00174     void fillWidgetTree( QString groupName, QString groupFullPath, QTreeWidgetItem* root);
00175 
00180     ConfigurationParameters *m_configurationParameters;
00181 
00185     ConfigurationParameters m_tmpParameters;
00186 
00191     bool m_readOnly;
00192 
00197     bool m_valuesChanged;
00198 
00205     QTreeWidget *m_treeWidget;
00206 
00210     QTableWidget *m_tableWidget;
00211 };
00212 
00213 } // end namespace farsa
00214 
00215 #endif