-
-
Notifications
You must be signed in to change notification settings - Fork 277
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start reworking UI after learning more about Qt
The sliderules tab will now use two "models" that contains encoding and decoding data. Custom Qt widgets and the Qt signal/slot mechanism will be used for all data/filter updates. For example, a signal that is emitted when the encoding table's ISA family is changed is connected only to a slot in the encoding model. The model would then emit its own signal that is connected to any UI slot that needs to display the changed data. This flow of `User Interaction -> Model Update -> UI Update` will ensure there are no recursive loops in the signal/slot connection tree.
- Loading branch information
Showing
5 changed files
with
167 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "sliderulesmodels.h" | ||
|
||
#include "processorhandler.h" | ||
|
||
namespace Ripes { | ||
|
||
ISAEncodingTableModel::ISAEncodingTableModel(QObject *parent) | ||
: QAbstractTableModel(parent) { | ||
const auto isaInfo = ProcessorHandler::currentISA(); | ||
setFamily(isaInfo->isaFamily()); | ||
} | ||
|
||
void ISAEncodingTableModel::setFamily(ISAFamily family) { | ||
if (!m_isaInfo || m_isaInfo->isaFamily() != family) { | ||
m_isaInfo = ISAInfoRegistry::getISA(*ISAFamilySets.at(family).begin(), | ||
QStringList()); | ||
emit familyChanged(family); | ||
} | ||
} | ||
|
||
int ISAEncodingTableModel::rowCount(const QModelIndex &) const { return 1; } | ||
|
||
int ISAEncodingTableModel::columnCount(const QModelIndex &) const { return 1; } | ||
|
||
QVariant ISAEncodingTableModel::data(const QModelIndex &index, int role) const { | ||
if (role == Qt::DisplayRole) { | ||
return QVariant::fromValue(m_isaInfo->isaFamily()); | ||
} | ||
return QVariant(); | ||
} | ||
|
||
} // namespace Ripes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#pragma once | ||
|
||
#include "isainfo.h" | ||
|
||
#include <QTableView> | ||
|
||
namespace Ripes { | ||
|
||
class ISAEncodingTableModel : public QAbstractTableModel { | ||
Q_OBJECT | ||
public: | ||
ISAEncodingTableModel(QObject *parent = nullptr); | ||
|
||
// TODO(raccog): This could be a variable that is controlable in the UI. | ||
constexpr static size_t BIT_COLUMNS = 32; | ||
|
||
enum Column { | ||
EXTENSION = 0, | ||
TYPE, | ||
DESCRIPTION, | ||
OPCODE, | ||
// TODO(raccog): The field columns should be variable based on the maximum | ||
// number of fields | ||
FIELD0, | ||
FIELD1, | ||
FIELD2, | ||
BIT_START, | ||
BIT_END = BIT_START + BIT_COLUMNS | ||
}; | ||
|
||
virtual int rowCount(const QModelIndex &) const override; | ||
virtual int columnCount(const QModelIndex &) const override; | ||
virtual QVariant data(const QModelIndex &index, | ||
int role = Qt::DisplayRole) const override; | ||
// virtual QVariant headerData(int section, Qt::Orientation orientation, | ||
// int role = Qt::DisplayRole) const override; | ||
|
||
public slots: | ||
/// Updates the Model and emits `familyChanged()` signal if the model's ISA | ||
/// family has changed. | ||
/// | ||
/// This should only be `connect()`ed to UI signals whose function names end | ||
/// in `Activated`. Can also be `connect()`ed to | ||
/// `ProcessorHandler::processorChanged()`. | ||
void setFamily(ISAFamily family); | ||
|
||
signals: | ||
/// Called when the ISA family of the model changes. Use this to update UI. | ||
void familyChanged(ISAFamily family); | ||
|
||
protected: | ||
std::shared_ptr<const ISAInfoBase> m_isaInfo = nullptr; | ||
}; | ||
|
||
} // namespace Ripes |
Oops, something went wrong.