DlgCustomizeSpaceball.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2011 Thomas Anderson <ta@nextgenengineering>            *
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 #ifndef GUI_DIALOG_DLGCUSTOMIZESPACEBALL_H
00024 #define GUI_DIALOG_DLGCUSTOMIZESPACEBALL_H
00025 
00026 #include <QTreeView>
00027 #include <QListView>
00028 #include <QAbstractListModel>
00029 #include "PropertyPage.h"
00030 
00031 class Command;
00032 class QPushButton;
00033 
00034 namespace Gui
00035 {
00036     namespace Dialog
00037     {
00038         class ButtonView : public QListView
00039         {
00040             Q_OBJECT
00041         public:
00042             ButtonView(QWidget *parent = 0);
00043             void selectButton(int number);
00044         Q_SIGNALS:
00045             void changeCommandSelection(const QString& commandName);
00046         private Q_SLOTS:
00047             void goSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
00048 
00049         public Q_SLOTS:
00050             void goChangedCommand(const QString& commandName);
00051         };
00052 
00053         class ButtonModel : public QAbstractListModel
00054         {
00055             Q_OBJECT
00056         public:
00057             ButtonModel(QObject *parent);
00058             virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
00059             virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00060             void insertRows(int number);
00061             void setCommand(int row, QString command);
00062             void goButtonPress(int number);
00063             void goMacroRemoved(const QByteArray& macroName);
00064             void goClear();
00065         private:
00066             ParameterGrp::handle spaceballButtonGroup() const;
00067             QString getLabel(const int &number) const;
00068         };
00069 
00070         class CommandView : public QTreeView
00071         {
00072             Q_OBJECT
00073         public:
00074             CommandView(QWidget *parent = 0);
00075         public Q_SLOTS:
00076             void goChangeCommandSelection(const QString& commandName);
00077         private Q_SLOTS:
00078             void goClicked(const QModelIndex &index);
00079         Q_SIGNALS:
00080             void changedCommand(const QString& commandName);
00081         };
00082 
00083         class CommandNode
00084         {
00085         public:
00086             enum NodeType {RootType, GroupType, CommandType};
00087 
00088             CommandNode(NodeType typeIn);
00089             ~CommandNode();
00090 
00091             NodeType nodeType;
00092             Command *aCommand;
00093             QString labelText;
00094             CommandNode *parent;
00095             QList<CommandNode *> children;
00096         };
00097 
00098         class CommandModel : public QAbstractItemModel
00099         {
00100             Q_OBJECT
00101         public:
00102             CommandModel(QObject *parent = 0);
00103             ~CommandModel();
00104             virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00105             virtual QModelIndex parent(const QModelIndex &index) const;
00106             virtual int rowCount(const QModelIndex &parent) const;
00107             virtual int columnCount(const QModelIndex &parent) const;
00108             virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00109             virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00110             virtual Qt::ItemFlags flags (const QModelIndex &index) const;
00111             void goAddMacro(const QByteArray &macroName);
00112             void goRemoveMacro(const QByteArray &macroName);
00113         private:
00114             CommandNode *rootNode;
00115             CommandNode* nodeFromIndex(const QModelIndex &index) const;
00116             void initialize();
00117             void groupCommands(const QString& groupName);
00118             QStringList orderedGroups();
00119         };
00120 
00121         class PrintModel : public QAbstractTableModel
00122         {
00123             Q_OBJECT
00124         public:
00125             PrintModel(QObject *parent, ButtonModel *buttonModelIn, CommandModel *commandModelIn);
00126             virtual int rowCount(const QModelIndex &parent) const;
00127             virtual int columnCount(const QModelIndex &parent) const;
00128             virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
00129             virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00130         private:
00131             ButtonModel *buttonModel;
00132             CommandModel *commandModel;
00133         };
00134 
00135         class DlgCustomizeSpaceball : public CustomizeActionPage
00136         {
00137             Q_OBJECT
00138         public:
00139             DlgCustomizeSpaceball(QWidget *parent = 0);
00140             virtual ~DlgCustomizeSpaceball();
00141         protected:
00142             void changeEvent(QEvent *e);
00143             virtual bool event(QEvent *event);
00144             virtual void hideEvent(QHideEvent *event);
00145             virtual void showEvent (QShowEvent *event);
00146 
00147         protected Q_SLOTS:
00148             void onAddMacroAction(const QByteArray &macroName);
00149             void onRemoveMacroAction(const QByteArray &macroName);
00150             void onModifyMacroAction(const QByteArray &macroName);
00151 
00152         private Q_SLOTS:
00153             void goClear();
00154             void goPrint();
00155 
00156         private:
00157             void setupButtonModelView();
00158             void setupCommandModelView();
00159             void setupLayout();
00160             void setMessage(const QString& message);
00161 
00162             ButtonView *buttonView;
00163             ButtonModel *buttonModel;
00164             CommandView *commandView;
00165             CommandModel *commandModel;
00166             QPushButton *clearButton;
00167             QPushButton *printReference;
00168         };
00169     }
00170 }
00171 
00172 #endif //GUI_DIALOG_DLGCUSTOMIZESPACEBALL_H

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