00001
00002
00003
00004 #ifndef BALL_VIEW_DIALOGS_PYTHONSETTINGS_H
00005 #define BALL_VIEW_DIALOGS_PYTHONSETTINGS_H
00006
00007 #ifndef BALL_COMMON_GLOBAL_H
00008 # include <BALL/COMMON/global.h>
00009 #endif
00010
00011 #ifdef BALL_COMPILER_MSVC
00012 # include <BALL/VIEW/UIC/ui_pythonSettings.h>
00013 #else
00014 # include <BALL/VIEW/UIC/pythonSettingsData.h>
00015 #endif
00016
00017
00018 #ifndef BALL_VIEW_KERNEL_PREFERENCESENTRY
00019 # include <BALL/VIEW/KERNEL/preferencesEntry.h>
00020 #endif
00021
00022 #ifndef BALL_VIEW_WIDGETS_PYWIDGET_H
00023 #include <BALL/VIEW/WIDGETS/pyWidget.h>
00024 #endif
00025
00026 #include <QtGui/QTableWidget>
00027 #include <QtGui/QWidget>
00028 #include <QtGui/QItemDelegate>
00029 #include <QtGui/QFont>
00030
00031 namespace BALL
00032 {
00033 namespace VIEW
00034 {
00035
00036 class ComboBoxDelegate
00037 : public QItemDelegate
00038 {
00039 public:
00040
00041 ComboBoxDelegate(QObject* parent = 0);
00042
00043 QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
00044 const QModelIndex &index) const;
00045
00046 void setEditorData(QWidget *editor, const QModelIndex &index) const;
00047 void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
00048
00049 void updateEditorGeometry(QWidget *editor,
00050 const QStyleOptionViewItem &option, const QModelIndex &index) const;
00051 private:
00052
00053 QStringList sl_keys_;
00054 QStringList sl_modifier_;
00055 };
00056
00060 class BALL_VIEW_EXPORT HotkeyTable
00061 : public QTableWidget,
00062 public PreferencesEntry::ExtendedPreferencesObject
00063 {
00064 Q_OBJECT
00065
00066 public:
00067
00069 enum Modifier
00070 {
00071 NONE = 0,
00072 SHIFT
00073
00074 };
00075
00077 HotkeyTable(QWidget* parent = 0, const char* name = "PythonSettings");
00078
00080 virtual bool getValue(String& value) const;
00081
00083 virtual bool setValue(const String& value);
00084
00086 List<Hotkey> getContent() const;
00087
00089 void setContent(const List<Hotkey>& hotkeys);
00090
00091 public slots:
00092
00094 virtual void addEmptyRow();
00095
00097 virtual void removeSelection();
00098
00102 virtual void appendHotkey(const String& modif, const String& F_key,
00103 const String& command, String comment = "");
00104
00105 private:
00106
00107
00108 QStringList modifier_, keys_;
00109 ComboBoxDelegate delegate_;
00110 };
00111
00112
00118 class BALL_VIEW_EXPORT PythonSettings
00119 : public QWidget,
00120 public Ui_PythonSettingsData,
00121 public PreferencesEntry
00122 {
00123 Q_OBJECT
00124
00125 public:
00126
00128 PythonSettings(QWidget* parent = 0, const char* name = 0);
00129
00131 ~PythonSettings() {}
00132
00134 QFont getEditorFont() const { return font_;}
00135
00137 void setFilename(const String& filename);
00138
00140 String getFilename() const;
00141
00143 const List<Hotkey> getContent() const;
00144
00146 void setContent(const List<Hotkey>& hotkeys);
00147
00149 void writePreferenceEntries(INIFile& inifile);
00150
00152 void readPreferenceEntries(const INIFile& inifile);
00153
00154 public slots:
00155
00157 void fileSelected();
00158
00160 void clearStartupScript();
00161
00163 virtual void rowSelected();
00164
00166 void selectFont();
00167
00168 protected:
00169
00170 HotkeyTable* table;
00171 QFont font_;
00172 };
00173 } }
00174
00175 #endif