model directly from the DMX::Universe
This commit is contained in:
parent
91128ca9f3
commit
1563e620b9
|
@ -19,7 +19,7 @@ UniverseWindow::UniverseWindow(QWidget *parent, QSacnUniverse *universe)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
auto model = new UniverseModel(this, universe);
|
||||
auto model = new UniverseModel(this, universe->get());
|
||||
ui->tableView->setModel(model);
|
||||
|
||||
// update the status bar whenever the universe refreshes
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
* @param parent
|
||||
* @param universe
|
||||
*/
|
||||
UniverseModel::UniverseModel(QObject *parent, QSacnUniverse *universe)
|
||||
UniverseModel::UniverseModel(QObject *parent, std::shared_ptr<DMX::Universe> universe)
|
||||
: QAbstractTableModel(parent)
|
||||
, universe_(universe)
|
||||
, data_mode_(Decimal)
|
||||
|
@ -18,9 +18,8 @@ UniverseModel::UniverseModel(QObject *parent, QSacnUniverse *universe)
|
|||
if (!universe_)
|
||||
return;
|
||||
|
||||
connect(universe_, &QSacnUniverse::dataChanged,
|
||||
this, [this](){
|
||||
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||
data_change_token = universe_->onDataChange([this] (DMX::Universe*) {
|
||||
emit dataChanged(createIndex(0,0), createIndex(rowCount(), columnCount()));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -197,10 +196,9 @@ Qt::ItemFlags UniverseModel::flags(const QModelIndex &index) const
|
|||
* @brief UniverseModel::setDataMode
|
||||
* @param mode
|
||||
*/
|
||||
void UniverseModel::setDataMode(const QString mode)
|
||||
void UniverseModel::setDataMode(const UniverseModel::data_modes mode)
|
||||
{
|
||||
auto metaEnum = QMetaEnum::fromType<data_modes>();
|
||||
data_mode_ = static_cast<data_modes>(metaEnum.keyToValue(mode.toLocal8Bit()));
|
||||
data_mode_ = mode;
|
||||
emit dataChanged(index(0,0), index(rowCount(), columnCount()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
#include "qsacn_global.h"
|
||||
#include "qsacnuniverse.h"
|
||||
#include <universe.h>
|
||||
|
||||
class QT_EXPORT UniverseModel
|
||||
class UniverseModel
|
||||
: public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UniverseModel(QObject *parent = nullptr,
|
||||
QSacnUniverse *universe = nullptr);
|
||||
std::shared_ptr<DMX::Universe> universe = nullptr);
|
||||
// Model overrides:
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const override;
|
||||
|
@ -32,9 +31,11 @@ public:
|
|||
data_modes dataMode();
|
||||
|
||||
public slots:
|
||||
void setDataMode(const QString mode);
|
||||
void setDataMode(const UniverseModel::data_modes mode);
|
||||
|
||||
private:
|
||||
QSacnUniverse* universe_;
|
||||
std::shared_ptr<DMX::Universe> universe_;
|
||||
data_modes data_mode_;
|
||||
|
||||
std::shared_ptr<void> data_change_token;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user