pythonSettings.h

Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef BALL_VIEW_DIALOGS_PYTHONSETTINGS_H
00006 #define BALL_VIEW_DIALOGS_PYTHONSETTINGS_H
00007 
00008 #ifndef BALL_COMMON_GLOBAL_H
00009 # include <BALL/COMMON/global.h>
00010 #endif
00011 
00012 #ifndef BALL_VIEW_KERNEL_PREFERENCESENTRY
00013 # include <BALL/VIEW/KERNEL/preferencesEntry.h>
00014 #endif
00015 
00016 #ifndef BALL_VIEW_WIDGETS_PYWIDGET_H
00017 # include <BALL/VIEW/WIDGETS/pyWidget.h>
00018 #endif
00019 
00020 #include <BALL/VIEW/UIC/ui_pythonSettings.h>
00021 
00022 #include <QtGui/QTableWidget>
00023 #include <QtGui/QWidget>
00024 #include <QtGui/QItemDelegate>
00025 #include <QtGui/QFont>
00026 
00027 namespace BALL
00028 {
00029   namespace VIEW
00030   {
00031 
00032     class ComboBoxDelegate
00033       : public QItemDelegate
00034     {
00035       public:
00036 
00037         ComboBoxDelegate(QObject* parent = 0);
00038 
00039         QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
00040                               const QModelIndex &index) const;
00041 
00042         void setEditorData(QWidget *editor, const QModelIndex &index) const;
00043         void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00044 
00045         void updateEditorGeometry(QWidget *editor,
00046                                   const QStyleOptionViewItem &option, const QModelIndex &index) const;
00047       private:
00048 
00049         QStringList sl_keys_;
00050         QStringList sl_modifier_;
00051     };
00052 
00056     class BALL_VIEW_EXPORT HotkeyTable
00057       : public QTableWidget,
00058         public PreferencesEntry::ExtendedPreferencesObject
00059     {
00060       Q_OBJECT
00061 
00062       public:
00063 
00065         enum Modifier
00066         {
00067           NONE = 0,
00068           SHIFT
00069           // ALT // currently not working!
00070         };
00071 
00073         HotkeyTable(QWidget* parent = 0, const char* name = "PythonSettings");
00074         
00076         virtual bool getValue(String& value) const;
00077 
00079         virtual bool setValue(const String& value);
00080 
00082         List<Hotkey> getContent() const;
00083 
00085         void setContent(const List<Hotkey>& hotkeys);
00086 
00087         public slots:
00088         
00090         virtual void addEmptyRow();
00091         
00093         virtual void removeSelection();
00094 
00098         virtual void appendHotkey(const String& modif, const String& F_key, 
00099                                   const String& command, String comment = "");
00100         
00101       private:
00102 
00103 //          bool edit (const QModelIndex & index, EditTrigger trigger, QEvent* event);
00104         QStringList modifier_, keys_;
00105         ComboBoxDelegate delegate_;
00106     };
00107 
00108 
00114     class BALL_VIEW_EXPORT PythonSettings 
00115       : public QWidget,
00116         public Ui_PythonSettingsData,
00117         public PreferencesEntry
00118     { 
00119       Q_OBJECT
00120 
00121       public:
00122 
00124       PythonSettings(QWidget* parent = 0, const char* name = 0);
00125 
00127       ~PythonSettings() {}
00128 
00130       QFont getEditorFont() const { return font_;}
00131 
00133       void setFilename(const String& filename);
00134 
00136       String getFilename() const;
00137 
00139       const List<Hotkey> getContent() const;
00140       
00142       void setContent(const List<Hotkey>& hotkeys);
00143 
00145       void writePreferenceEntries(INIFile& inifile);
00146 
00148       void readPreferenceEntries(const INIFile& inifile);
00149 
00150       public slots:
00151 
00153       void fileSelected();
00154 
00156       void clearStartupScript();
00157 
00159       virtual void rowSelected();
00160 
00162       void selectFont();
00163 
00164       protected:
00165 
00166       HotkeyTable*  table;
00167       QFont         font_;
00168     };
00169 } }
00170 
00171 #endif