DlgParameterImp.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de>              *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 
00024 #ifndef GUI_DIALOG_DLGPARAMETER_H
00025 #define GUI_DIALOG_DLGPARAMETER_H
00026 
00027 #include "ui_DlgParameter.h"
00028 #include <Base/Parameter.h>
00029 
00030 #include <QTreeWidgetItem>
00031 #include <QTreeWidget>
00032 
00033 namespace Gui {
00034 namespace Dialog {
00035 
00040 class DlgParameterImp : public QDialog, public Ui_DlgParameter
00041 { 
00042     Q_OBJECT
00043 
00044 public:
00045     DlgParameterImp( QWidget* parent = 0, Qt::WFlags fl = 0 );
00046     ~DlgParameterImp();
00047 
00048     void accept();
00049     void reject();
00050 
00051 protected Q_SLOTS:
00052     void onChangeParameterSet(int);
00053     void on_buttonSaveToDisk_clicked();
00054 
00055     void onGroupSelected(QTreeWidgetItem *);
00056     void on_closeButton_clicked();
00057 
00058 protected:
00059     void changeEvent(QEvent *e);
00060     void showEvent(QShowEvent*);
00061     void closeEvent(QCloseEvent*);
00062 
00063 protected:
00064     QTreeWidget* paramGroup;
00065     QTreeWidget* paramValue;
00066 };
00067 
00068 // --------------------------------------------------------------------
00069 
00075 class ParameterGroup : public QTreeWidget
00076 {
00077     Q_OBJECT
00078 
00079 public:
00080     ParameterGroup( QWidget * parent = 0 );
00081     virtual ~ParameterGroup();
00082 
00083 protected:
00085     void contextMenuEvent ( QContextMenuEvent* event );
00087     void keyPressEvent (QKeyEvent* event);
00088 
00089 protected Q_SLOTS:
00093     void onDeleteSelectedItem();
00095     void onCreateSubgroup();
00099     void onToggleSelectedItem();
00101     void onExportToFile();
00103     void onImportFromFile();
00105     void onRenameSelectedItem();
00106 
00107 protected:
00108     void changeEvent(QEvent *e);
00109 
00110 private:
00111     QMenu* menuEdit;
00112     QAction* expandAct;
00113     QAction* subGrpAct;
00114     QAction* removeAct;
00115     QAction* renameAct;
00116     QAction* exportAct;
00117     QAction* importAct;
00118 };
00119 
00120 // --------------------------------------------------------------------
00121 
00127 class ParameterValue : public QTreeWidget
00128 {
00129     Q_OBJECT
00130 
00131 public:
00132     ParameterValue( QWidget * parent = 0 );
00133     virtual ~ParameterValue();
00134 
00136     void setCurrentGroup( const Base::Reference<ParameterGrp>& _hcGrp );
00137 
00138 protected:
00140     void contextMenuEvent ( QContextMenuEvent* event );
00142     void keyPressEvent (QKeyEvent* event);
00143 
00144 protected Q_SLOTS:
00146     void onChangeSelectedItem(QTreeWidgetItem*, int);
00147     void onChangeSelectedItem();
00151     void onDeleteSelectedItem();
00153     void onRenameSelectedItem();
00155     void onCreateTextItem();
00157     void onCreateIntItem();
00159     void onCreateUIntItem();
00161     void onCreateFloatItem();
00163     void onCreateBoolItem();
00168     bool edit ( const QModelIndex & index, EditTrigger trigger, QEvent * event );
00169 
00170 private:
00171     QMenu* menuEdit;
00172     QMenu* menuNew;
00173     QAction* changeAct;
00174     QAction* removeAct;
00175     QAction* renameAct;
00176     QAction* newStrAct;
00177     QAction* newFltAct;
00178     QAction* newIntAct;
00179     QAction* newUlgAct;
00180     QAction* newBlnAct;
00181     Base::Reference<ParameterGrp> _hcGrp;
00182 };
00183 
00191 class ParameterGroupItem : public QTreeWidgetItem
00192 {
00193 public:
00195     ParameterGroupItem( ParameterGroupItem * parent, const Base::Reference<ParameterGrp> &hcGrp );
00196     ParameterGroupItem( QTreeWidget* parent, const Base::Reference<ParameterGrp> &hcGrp);
00197     ~ParameterGroupItem();
00198 
00199     void setData ( int column, int role, const QVariant & value );
00200     QVariant data ( int column, int role ) const;
00201 
00202     void fillUp(void);
00203     Base::Reference<ParameterGrp> _hcGrp;
00204 };
00205 
00206 // --------------------------------------------------------------------
00207 
00215 class ParameterValueItem : public QTreeWidgetItem
00216 {
00217 public:
00219     ParameterValueItem ( QTreeWidget* parent, const Base::Reference<ParameterGrp> &hcGrp);
00220     virtual ~ParameterValueItem();
00221 
00223     virtual void setData ( int column, int role, const QVariant & value );
00225     virtual void changeValue() = 0;
00227     virtual void appendToGroup() = 0;
00229     virtual void removeFromGroup() = 0;
00230 
00231 protected:
00233     virtual void replace( const QString& oldName, const QString& newName ) = 0;
00234 
00235 protected:
00236     Base::Reference<ParameterGrp> _hcGrp;
00237 };
00238 
00243 class ParameterText : public ParameterValueItem
00244 {
00245 public:
00247     ParameterText ( QTreeWidget * parent, QString label1, const char* value, const Base::Reference<ParameterGrp> &hcGrp);
00248     ~ParameterText();
00249 
00250     void changeValue();
00251     void appendToGroup();
00252     void removeFromGroup();
00253 
00254 protected:
00255     void replace( const QString& oldName, const QString& newName );
00256 };
00257 
00262 class ParameterInt : public ParameterValueItem
00263 {
00264 public:
00266     ParameterInt ( QTreeWidget * parent, QString label1, long value, const Base::Reference<ParameterGrp> &hcGrp);
00267     ~ParameterInt();
00268 
00269     void changeValue();
00270     void appendToGroup();
00271     void removeFromGroup();
00272 
00273 protected:
00274     void replace( const QString& oldName, const QString& newName );
00275 };
00276 
00281 class ParameterUInt : public ParameterValueItem
00282 {
00283 public:
00285     ParameterUInt ( QTreeWidget * parent, QString label1, unsigned long value, const Base::Reference<ParameterGrp> &hcGrp);
00286     ~ParameterUInt();
00287 
00288     void changeValue();
00289     void appendToGroup();
00290     void removeFromGroup();
00291 
00292 protected:
00293     void replace( const QString& oldName, const QString& newName );
00294 };
00295 
00300 class ParameterFloat : public ParameterValueItem
00301 {
00302 public:
00304     ParameterFloat ( QTreeWidget * parent, QString label1, double value, const Base::Reference<ParameterGrp> &hcGrp);
00305     ~ParameterFloat();
00306 
00307     void changeValue();
00308     void appendToGroup();
00309     void removeFromGroup();
00310 
00311 protected:
00312     void replace( const QString& oldName, const QString& newName );
00313 };
00314 
00319 class ParameterBool : public ParameterValueItem
00320 {
00321 public:
00323     ParameterBool ( QTreeWidget * parent, QString label1, bool value, const Base::Reference<ParameterGrp> &hcGrp);
00324     ~ParameterBool();
00325 
00326     void changeValue();
00327     void appendToGroup();
00328     void removeFromGroup();
00329 
00330 protected:
00331     void replace( const QString& oldName, const QString& newName );
00332 };
00333 
00334 } // namespace Dialog
00335 } // namespace Gui
00336 
00337 #endif // GUI_DIALOG_DLGPARAMETER_H

Generated on Wed Nov 23 19:00:06 2011 for FreeCAD by  doxygen 1.6.1