diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-09-10 23:55:48 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-09-10 23:55:48 +0800 |
commit | aec5e972e8968255e8843eb22314b96a8f23b041 (patch) | |
tree | 55990275b78a10188f7ec08436e748cc01461a91 /qmidiplayer-desktop/qmpchannelswindow.hpp | |
parent | 1e0c10a001c61d27b210ae87652be849cbd5bcfe (diff) | |
download | QMidiPlayer-aec5e972e8968255e8843eb22314b96a8f23b041.tar.xz |
We refactorin', eh? Hell yeah.
(Almost) Completely rewritten qmpChannelsWindow, one of the oldest
component, now with a dedicated data model.
Removed dumb design (CMidiPlayer::getChstates).
Now QMidiPlayer requires C++14 to build.
More refactoring like this coming up soon.
Diffstat (limited to 'qmidiplayer-desktop/qmpchannelswindow.hpp')
-rw-r--r-- | qmidiplayer-desktop/qmpchannelswindow.hpp | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp index 207ee8d..ab3227f 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.hpp +++ b/qmidiplayer-desktop/qmpchannelswindow.hpp @@ -8,6 +8,8 @@ #include <QShowEvent> #include <QCloseEvent> #include <QMoveEvent> +#include <QAbstractTableModel> +#include <QStyledItemDelegate> #include "qmppresetselect.hpp" #include "qmpchanneleditor.hpp" #include "../core/qmpmidiplay.hpp" @@ -60,6 +62,42 @@ class qmpChannelFunc:public qmpFuncBaseIntf void close(); }; +class qmpChannelsModel:public QAbstractTableModel +{ + Q_OBJECT + public: + explicit qmpChannelsModel(QObject*parent=nullptr); + int columnCount(const QModelIndex&parent=QModelIndex())const override; + int rowCount(const QModelIndex&parent=QModelIndex())const override; + QModelIndex parent(const QModelIndex&child)const override; + QVariant data(const QModelIndex&index,int role=Qt::ItemDataRole::DisplayRole)const override; + QVariant headerData(int section,Qt::Orientation orientation,int role=Qt::ItemDataRole::DisplayRole)const override; + Qt::ItemFlags flags(const QModelIndex&idx)const override; + public slots: + void updateChannelActivity(); + void channelMSClicked(const QModelIndex&idx); + void channelMSClearAll(int type); + private: + int evh; + bool updatequeued; + bool mute[16],solo[16]; +}; + +class qmpDeviceItemDelegate:public QStyledItemDelegate +{ + Q_OBJECT + public: + explicit qmpDeviceItemDelegate(QWidget*parent=nullptr); + void paint(QPainter*painter,const QStyleOptionViewItem&option,const QModelIndex&index)const override; + QSize sizeHint(const QStyleOptionViewItem&option,const QModelIndex&index)const override; + QWidget* createEditor(QWidget*parent,const QStyleOptionViewItem&option,const QModelIndex&index)const override; + void setEditorData(QWidget*editor,const QModelIndex&index)const override; + void setModelData(QWidget*editor,QAbstractItemModel*model,const QModelIndex&index)const override; + void updateEditorGeometry(QWidget*editor,const QStyleOptionViewItem&option,const QModelIndex&index)const override; + private: + QWidget *par; +}; + class qmpChannelsWindow:public QWidget { Q_OBJECT @@ -69,32 +107,22 @@ class qmpChannelsWindow:public QWidget ~qmpChannelsWindow(); void showEvent(QShowEvent *event); void closeEvent(QCloseEvent *event); - void resetAcitivity(); public slots: - void channelWindowsUpdate(); - void updateChannelActivity(); - void channelMSChanged(); - void showPresetWindow(int chid,int col); void showChannelEditorWindow(int chid); - void changeMidiMapping(int chid,int idx); void on_pbUnmute_clicked(); void on_pbUnsolo_clicked(); signals: void noteOn(); - protected: - bool eventFilter(QObject *o,QEvent *e); - private: Ui::qmpChannelsWindow *ui; qmpPresetSelector *pselectw; qmpChannelEditor *ceditw; + qmpChannelsModel *chmodel; QIcon *cha,*chi; qmpChannelFunc *chnlf; int eh; - //callback fuse... (avoid black midi blocking the main thread) - int callbacksc,cbcnt,fused; }; #endif // QMPCHANNELSWINDOW_H |