summaryrefslogtreecommitdiffstats
path: root/utils/regtools/qeditor/regtab.h
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2014-04-07 11:28:04 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2014-05-01 19:34:18 +0200
commit4356666101e0e7985e65a19f86bc4a74519e93f9 (patch)
treebf8de8057d93d0fab0a30cae92a90f5a4edc79dc /utils/regtools/qeditor/regtab.h
parent3754624edc48539c5cc5acbf426ce909477e87d8 (diff)
downloadrockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.tar.gz
rockbox-4356666101e0e7985e65a19f86bc4a74519e93f9.zip
regtools: completely rework qeditor, improve soc desc library and tools
The graphical editor can now display and editor description files. The library has been improved to provide more useful function. The XML format has been slightly changed: only one soc is allowed per file (this is was already de facto the case since <soc> was the root tag). Also introduce a DTD to validate the files. Change-Id: If70ba35b6dc0242bdb87411cf4baee9597798aac
Diffstat (limited to 'utils/regtools/qeditor/regtab.h')
-rw-r--r--utils/regtools/qeditor/regtab.h119
1 files changed, 23 insertions, 96 deletions
diff --git a/utils/regtools/qeditor/regtab.h b/utils/regtools/qeditor/regtab.h
index 9fa1437119..78a10ba379 100644
--- a/utils/regtools/qeditor/regtab.h
+++ b/utils/regtools/qeditor/regtab.h
@@ -2,7 +2,6 @@
#define REGTAB_H
#include <QComboBox>
-#include <QEvent>
#include <QTreeWidget>
#include <QVBoxLayout>
#include <QTabWidget>
@@ -11,118 +10,41 @@
#include <QPushButton>
#include <QLabel>
#include <QListWidget>
-#include <QValidator>
#include <QGroupBox>
#include <QToolButton>
#include <QMenu>
#include <QCheckBox>
-#include <soc_desc.hpp>
#include "backend.h"
#include "settings.h"
+#include "mainwindow.h"
-enum
-{
- RegTreeDevType = QTreeWidgetItem::UserType,
- RegTreeRegType
-};
-
-class DevTreeItem : public QTreeWidgetItem
-{
-public:
- DevTreeItem(const QString& string, const SocDevRef& ref)
- :QTreeWidgetItem(QStringList(string), RegTreeDevType), m_ref(ref) {}
-
- const SocDevRef& GetRef() { return m_ref; }
-private:
- SocDevRef m_ref;
-};
-
-class RegTreeItem : public QTreeWidgetItem
+class RegTabPanel
{
public:
- RegTreeItem(const QString& string, const SocRegRef& ref)
- :QTreeWidgetItem(QStringList(string), RegTreeRegType), m_ref(ref) {}
-
- const SocRegRef& GetRef() { return m_ref; }
-private:
- SocRegRef m_ref;
+ RegTabPanel() {}
+ virtual ~RegTabPanel() {}
+ virtual void AllowWrite(bool en) = 0;
+ virtual QWidget *GetWidget() = 0;
};
-class SocFieldValidator : public QValidator
+class EmptyRegTabPanel : public QWidget, public RegTabPanel
{
- Q_OBJECT
public:
- SocFieldValidator(QObject *parent = 0);
- SocFieldValidator(const soc_reg_field_t& field, QObject *parent = 0);
-
- virtual void fixup(QString& input) const;
- virtual State validate(QString& input, int& pos) const;
- /* validate and return the interpreted value */
- State parse(const QString& input, soc_word_t& val) const;
-
-protected:
- soc_reg_field_t m_field;
-};
-
-class RegLineEdit : public QWidget
-{
- Q_OBJECT
-public:
- enum EditMode
- {
- Write, Set, Clear, Toggle
- };
-
- RegLineEdit(QWidget *parent = 0);
- ~RegLineEdit();
- void SetReadOnly(bool ro);
- void EnableSCT(bool en);
- void SetMode(EditMode mode);
- EditMode GetMode();
- QLineEdit *GetLineEdit();
-
-protected slots:
- void OnWriteAct();
- void OnSetAct();
- void OnClearAct();
- void OnToggleAct();
-protected:
- void ShowMode(bool show);
-
- QHBoxLayout *m_layout;
- QToolButton *m_button;
- QLineEdit *m_edit;
- EditMode m_mode;
- bool m_has_sct;
- bool m_readonly;
- QMenu *m_menu;
-};
-
-class RegDisplayPanel : public QGroupBox
-{
- Q_OBJECT
-public:
- RegDisplayPanel(QWidget *parent, IoBackend *io_backend, const SocRegRef& reg);
+ EmptyRegTabPanel(QWidget *parent = 0);
void AllowWrite(bool en);
-
-protected:
- IoBackend::WriteMode EditModeToWriteMode(RegLineEdit::EditMode mode);
-
- IoBackend *m_io_backend;
- const SocRegRef& m_reg;
- bool m_allow_write;
- RegLineEdit *m_raw_val_edit;
-
-private slots:
- void OnRawRegValueReturnPressed();
+ QWidget *GetWidget();
};
-class RegTab : public QSplitter
+class RegTab : public QSplitter, public DocumentTab
{
Q_OBJECT
public:
- RegTab(Backend *backend);
+ RegTab(Backend *backend, QWidget *parent = 0);
~RegTab();
+ virtual bool Quit();
+
+signals:
+ void OnModified(bool modified);
protected:
enum
@@ -134,12 +56,16 @@ protected:
#endif
};
- void FillDevSubTree(DevTreeItem *item);
+ void FillDevSubTree(QTreeWidgetItem *item);
void FillRegTree();
void FillAnalyserList();
void UpdateSocList();
void DisplayRegister(const SocRegRef& ref);
+ void DisplayDevice(const SocDevRef& ref);
void SetDataSocName(const QString& socname);
+ void SetPanel(RegTabPanel *panel);
+ void UpdateSocFilename();
+
QComboBox *m_soc_selector;
#ifdef HAVE_HWSTUB
QComboBox *m_dev_selector;
@@ -149,7 +75,7 @@ protected:
QTreeWidget *m_reg_tree;
SocRef m_cur_soc;
QVBoxLayout *m_right_panel;
- QWidget *m_right_content;
+ RegTabPanel *m_right_content;
QLineEdit *m_data_sel_edit;
QCheckBox *m_readonly_check;
QLabel *m_data_soc_label;
@@ -163,9 +89,10 @@ private slots:
#ifdef HAVE_HWSTUB
void OnDevListChanged();
void OnDevChanged(int index);
+ void ClearDevList();
#endif
void SetReadOnlyIndicator();
- void OnSocChanged(const QString& text);
+ void OnSocChanged(int index);
void OnSocListChanged();
void OnRegItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void OnRegItemClicked(QTreeWidgetItem *clicked, int col);