diff options
Diffstat (limited to 'utils/regtools/qeditor/utils.h')
-rw-r--r-- | utils/regtools/qeditor/utils.h | 178 |
1 files changed, 169 insertions, 9 deletions
diff --git a/utils/regtools/qeditor/utils.h b/utils/regtools/qeditor/utils.h index 026466fae0..83992274b7 100644 --- a/utils/regtools/qeditor/utils.h +++ b/utils/regtools/qeditor/utils.h | |||
@@ -40,6 +40,7 @@ | |||
40 | #include <QScrollBar> | 40 | #include <QScrollBar> |
41 | #include <QGroupBox> | 41 | #include <QGroupBox> |
42 | #include <QSortFilterProxyModel> | 42 | #include <QSortFilterProxyModel> |
43 | #include <QDebug> | ||
43 | #include "settings.h" | 44 | #include "settings.h" |
44 | #include "backend.h" | 45 | #include "backend.h" |
45 | 46 | ||
@@ -180,6 +181,50 @@ protected: | |||
180 | soc_desc::field_t m_field; | 181 | soc_desc::field_t m_field; |
181 | }; | 182 | }; |
182 | 183 | ||
184 | Q_DECLARE_METATYPE(soc_desc::access_t) | ||
185 | |||
186 | class SocAccessItemDelegate: public QStyledItemDelegate | ||
187 | { | ||
188 | public: | ||
189 | SocAccessItemDelegate(const QString& unspec_text, QObject *parent = 0) | ||
190 | :QStyledItemDelegate(parent), m_unspec_text(unspec_text) {} | ||
191 | |||
192 | virtual QString displayText(const QVariant& value, const QLocale& locale) const; | ||
193 | protected: | ||
194 | QString m_unspec_text; | ||
195 | }; | ||
196 | |||
197 | class SocAccessEditor : public QComboBox | ||
198 | { | ||
199 | Q_OBJECT | ||
200 | Q_PROPERTY(soc_desc::access_t access READ access WRITE setAccess USER true) | ||
201 | public: | ||
202 | SocAccessEditor(const QString& unspec_text, QWidget *parent = 0); | ||
203 | virtual ~SocAccessEditor(); | ||
204 | |||
205 | soc_desc::access_t access() const; | ||
206 | void setAccess(soc_desc::access_t acc); | ||
207 | |||
208 | protected slots: | ||
209 | /* bla */ | ||
210 | |||
211 | protected: | ||
212 | soc_desc::access_t m_access; | ||
213 | }; | ||
214 | |||
215 | class SocAccessEditorCreator : public QItemEditorCreatorBase | ||
216 | { | ||
217 | public: | ||
218 | SocAccessEditorCreator(const QString& unspec_text = "Unspecified") | ||
219 | :m_unspec_text(unspec_text) {} | ||
220 | |||
221 | virtual QWidget *createWidget(QWidget *parent) const; | ||
222 | virtual QByteArray valuePropertyName() const; | ||
223 | |||
224 | protected: | ||
225 | QString m_unspec_text; | ||
226 | }; | ||
227 | |||
183 | class SocFieldCachedValue | 228 | class SocFieldCachedValue |
184 | { | 229 | { |
185 | public: | 230 | public: |
@@ -209,8 +254,11 @@ public: | |||
209 | SocFieldBitRange(int first, int last):m_first_bit(first), m_last_bit(last) {} | 254 | SocFieldBitRange(int first, int last):m_first_bit(first), m_last_bit(last) {} |
210 | unsigned GetFirstBit() const { return m_first_bit; } | 255 | unsigned GetFirstBit() const { return m_first_bit; } |
211 | unsigned GetLastBit() const { return m_last_bit; } | 256 | unsigned GetLastBit() const { return m_last_bit; } |
257 | void SetFirstBit(unsigned bit) { m_first_bit = bit; } | ||
258 | void SetLastBit(unsigned bit) { m_last_bit = bit; } | ||
212 | 259 | ||
213 | bool operator<(const SocFieldBitRange& o) const; | 260 | bool operator<(const SocFieldBitRange& o) const; |
261 | bool operator!=(const SocFieldBitRange& o) const; | ||
214 | protected: | 262 | protected: |
215 | unsigned m_first_bit, m_last_bit; | 263 | unsigned m_first_bit, m_last_bit; |
216 | }; | 264 | }; |
@@ -301,6 +349,7 @@ public: | |||
301 | 349 | ||
302 | signals: | 350 | signals: |
303 | void OnValueModified(int index); | 351 | void OnValueModified(int index); |
352 | void OnBitrangeModified(int index); | ||
304 | 353 | ||
305 | protected: | 354 | protected: |
306 | void RecomputeTheme(); | 355 | void RecomputeTheme(); |
@@ -337,19 +386,79 @@ protected: | |||
337 | bool lessThan(const QModelIndex& left, const QModelIndex& right) const; | 386 | bool lessThan(const QModelIndex& left, const QModelIndex& right) const; |
338 | }; | 387 | }; |
339 | 388 | ||
389 | class YRegDisplay; | ||
390 | class YRegDisplayItemDelegate; | ||
391 | |||
392 | class YRegDisplayItemEditor : public QWidget | ||
393 | { | ||
394 | Q_OBJECT | ||
395 | public: | ||
396 | YRegDisplayItemEditor(QWidget *parent, YRegDisplay *display, | ||
397 | YRegDisplayItemDelegate *delegate, QModelIndex bitrange_index, | ||
398 | QModelIndex name_index); | ||
399 | virtual ~YRegDisplayItemEditor(); | ||
400 | void setEditorData(QModelIndex bitrange_index, QModelIndex name_index); | ||
401 | void getEditorData(QVariant& name, QVariant& birange); | ||
402 | |||
403 | protected: | ||
404 | virtual void paintEvent(QPaintEvent *event); | ||
405 | virtual void mouseMoveEvent(QMouseEvent *event); | ||
406 | virtual void mousePressEvent(QMouseEvent *event); | ||
407 | virtual void mouseReleaseEvent(QMouseEvent *event); | ||
408 | virtual void leaveEvent(QEvent *event); | ||
409 | |||
410 | enum Zone | ||
411 | { | ||
412 | NoZone, | ||
413 | MoveZone, | ||
414 | ResizeLeftZone, | ||
415 | ResizeRightZone | ||
416 | }; | ||
417 | |||
418 | Zone GetZone(const QPoint& pt); | ||
419 | |||
420 | YRegDisplayItemDelegate *m_display_delegate; | ||
421 | YRegDisplay *m_display; | ||
422 | QModelIndex m_bitrange_index, m_name_index; | ||
423 | enum | ||
424 | { | ||
425 | Idle, | ||
426 | InResizeZone, | ||
427 | InMoveZone, | ||
428 | Moving, | ||
429 | ResizingLeft, | ||
430 | ResizingRight, | ||
431 | }m_state; | ||
432 | int m_col_width; | ||
433 | int m_resize_margin; | ||
434 | int m_move_offset; | ||
435 | SocFieldBitRange m_bitrange; | ||
436 | }; | ||
437 | |||
340 | class YRegDisplayItemDelegate : public QStyledItemDelegate | 438 | class YRegDisplayItemDelegate : public QStyledItemDelegate |
341 | { | 439 | { |
440 | Q_OBJECT | ||
441 | friend class YRegDisplayItemEditor; | ||
342 | public: | 442 | public: |
343 | YRegDisplayItemDelegate(QObject *parent = 0); | 443 | YRegDisplayItemDelegate(QObject *parent = 0); |
344 | virtual void paint(QPainter * painter, const QStyleOptionViewItem& option, | 444 | virtual void paint(QPainter *painter, const QStyleOptionViewItem& option, |
345 | const QModelIndex & index) const; | 445 | const QModelIndex& index) const; |
446 | virtual void MyPaint(QPainter *painter, const QStyleOptionViewItemV4& option) const; | ||
346 | virtual QSize sizeHint(const QStyleOptionViewItem& option, | 447 | virtual QSize sizeHint(const QStyleOptionViewItem& option, |
347 | const QModelIndex & index) const; | 448 | const QModelIndex& index) const; |
449 | /* don't bother using the item factory and such, we only use this delegate | ||
450 | * for very specific models anyway */ | ||
451 | virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem& option, | ||
452 | const QModelIndex& index) const; | ||
453 | virtual void setEditorData(QWidget *editor, const QModelIndex& index) const; | ||
454 | virtual void setModelData(QWidget *editor, QAbstractItemModel *model, | ||
455 | const QModelIndex& index) const; | ||
348 | }; | 456 | }; |
349 | 457 | ||
350 | class YRegDisplay : public QAbstractItemView | 458 | class YRegDisplay : public QAbstractItemView |
351 | { | 459 | { |
352 | Q_OBJECT | 460 | Q_OBJECT |
461 | friend class YRegDisplayItemEditor; | ||
353 | public: | 462 | public: |
354 | YRegDisplay(QWidget *parent = 0); | 463 | YRegDisplay(QWidget *parent = 0); |
355 | virtual QModelIndex indexAt(const QPoint& point) const; | 464 | virtual QModelIndex indexAt(const QPoint& point) const; |
@@ -360,6 +469,8 @@ public: | |||
360 | void setWidth(int nr_bits); | 469 | void setWidth(int nr_bits); |
361 | /* returns the bit column at a point, or -1 if none except if closest=true */ | 470 | /* returns the bit column at a point, or -1 if none except if closest=true */ |
362 | int bitColumnAt(const QPoint& point, bool closest = true) const; | 471 | int bitColumnAt(const QPoint& point, bool closest = true) const; |
472 | /* return rect for a bitrange */ | ||
473 | QRect BitrangeRect(const SocFieldBitRange& range) const; | ||
363 | 474 | ||
364 | protected slots: | 475 | protected slots: |
365 | virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); | 476 | virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight); |
@@ -509,18 +620,20 @@ protected: | |||
509 | QLineEdit *m_data_sel_edit; | 620 | QLineEdit *m_data_sel_edit; |
510 | #ifdef HAVE_HWSTUB | 621 | #ifdef HAVE_HWSTUB |
511 | QComboBox *m_dev_selector; | 622 | QComboBox *m_dev_selector; |
512 | HWStubBackendHelper m_hwstub_helper; | 623 | QComboBox *m_ctx_selector; |
624 | QPushButton *m_ctx_manage_button; | ||
625 | HWStubContextModel *m_ctx_model; | ||
626 | HWStubManager *m_ctx_manager; | ||
513 | #endif | 627 | #endif |
514 | QLabel *m_nothing_text; | 628 | QLabel *m_nothing_text; |
515 | 629 | ||
516 | private slots: | 630 | private slots: |
631 | void OnDataSelChanged(int index); | ||
517 | #ifdef HAVE_HWSTUB | 632 | #ifdef HAVE_HWSTUB |
518 | void OnDevListChanged(); | 633 | void OnContextSelChanged(int index); |
519 | void OnDevChanged(int index); | 634 | void OnDeviceSelChanged(int index); |
520 | void OnDevListChanged2(bool, struct libusb_device *); | 635 | void OnDeviceSelActivated(int index); |
521 | void ClearDevList(); | ||
522 | #endif | 636 | #endif |
523 | void OnDataSelChanged(int index); | ||
524 | }; | 637 | }; |
525 | 638 | ||
526 | class MessageWidget : public QFrame | 639 | class MessageWidget : public QFrame |
@@ -567,6 +680,7 @@ public: | |||
567 | inline bool tabOpenable() const { return m_tab_openable; } | 680 | inline bool tabOpenable() const { return m_tab_openable; } |
568 | void setTabOpenable(bool openable); | 681 | void setTabOpenable(bool openable); |
569 | void setTabOpenMenu(QMenu *menu); | 682 | void setTabOpenMenu(QMenu *menu); |
683 | void setOtherMenu(QMenu *menu); | ||
570 | 684 | ||
571 | signals: | 685 | signals: |
572 | void tabOpenRequested(); | 686 | void tabOpenRequested(); |
@@ -577,6 +691,52 @@ protected slots: | |||
577 | protected: | 691 | protected: |
578 | bool m_tab_openable; | 692 | bool m_tab_openable; |
579 | QToolButton *m_tab_open_button; | 693 | QToolButton *m_tab_open_button; |
694 | QToolButton *m_other_button; | ||
695 | }; | ||
696 | |||
697 | class YIconManager : public QObject | ||
698 | { | ||
699 | Q_OBJECT | ||
700 | protected: | ||
701 | YIconManager(); | ||
702 | public: | ||
703 | virtual ~YIconManager(); | ||
704 | /* list of icons */ | ||
705 | enum IconType | ||
706 | { | ||
707 | ListAdd = 0, | ||
708 | ListRemove, | ||
709 | DocumentNew, | ||
710 | DocumentEdit, | ||
711 | DocumentOpen, | ||
712 | DocumentSave, | ||
713 | DocumentSaveAs, | ||
714 | Preferences, | ||
715 | FolderNew, | ||
716 | Computer, | ||
717 | Cpu, | ||
718 | DialogError, | ||
719 | ViewRefresh, | ||
720 | SytemRun, | ||
721 | ApplicationExit, | ||
722 | HelpAbout, | ||
723 | FormatTextBold, | ||
724 | FormatTextItalic, | ||
725 | FormatTextUnderline, | ||
726 | TextGeneric, | ||
727 | MultimediaPlayer, | ||
728 | MaxIcon | ||
729 | }; | ||
730 | /* return instance */ | ||
731 | static YIconManager *Get(); | ||
732 | QIcon GetIcon(IconType it); | ||
733 | |||
734 | protected: | ||
735 | void Render(IconType type); | ||
736 | |||
737 | static YIconManager *m_singleton; // single instance | ||
738 | QIcon m_icon[MaxIcon]; /* list add icon */ | ||
739 | QString m_icon_name[MaxIcon]; /* icon name from theme */ | ||
580 | }; | 740 | }; |
581 | 741 | ||
582 | class Misc | 742 | class Misc |