5 #include <QRandomGenerator>
25 return mDataEntries.size();
38 case 1:
return entry.
key;
40 case 3:
return style.valueString;
44 return style.valueColor;
89 const char* horizontalHeader[] = {
"Category",
"Key",
"Type",
"Value"};
91 return QString(horizontalHeader[section]);
106 return mDataEntries.at(row);
112 mDataEntries.clear();
113 mEntryToRowStyle.
clear();
114 for(
const auto& [key, value] : dataMap)
121 std::sort(mDataEntries.begin(), mDataEntries.end(),
125 if(a.category == b.category)
127 return (a.key < b.key);
131 if(a.category ==
"generic")
133 else if(b.category ==
"generic")
136 return (a.category < b.category);
148 Q_EMIT layoutChanged();
151 DataTableModel::RowStyle DataTableModel::getRowStyleByEntry(
const DataTableEntry& entry,
int rowIdx)
const
154 style.keyFont =
QFont();
156 style.valueToolTip =
QString();
157 style.valueColor =
QColor();
160 if(entry.dataType ==
"string")
162 style.valueString =
QString(
"\"%1\"").
arg(entry.value);
165 else if(entry.dataType ==
"bit_value" || entry.dataType ==
"bit_vector")
167 style.valueString =
QString(
"0x%1").
arg(entry.value);
170 else if(entry.dataType ==
"integer")
172 style.valueString = entry.value;
177 style.valueString = entry.value;
185 style.keyToolTip = entry.category +
" ";
186 style.valueToolTip = entry.dataType +
" ";
191 style.keyToolTip = entry.category +
QChar(0x00A0);
192 style.valueToolTip = entry.dataType +
QChar(0x00A0);
QString dataType
The data's key.
QString key
The data's category.
DataTableModel(QObject *parent=nullptr)
bool setData(const QModelIndex &index, const QVariant &value, int role) override
int columnCount(const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
void updateData(const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string >> &dc)
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
DataTableEntry getEntryAtRow(int row) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
std::unique_ptr< BasePluginInterface > instance
void layoutAboutToBeChanged(const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
QObject * parent() const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QString fromStdString(const std::string &str)