101 lines
2.3 KiB
C++
101 lines
2.3 KiB
C++
#ifndef SYSTEMCONFIGURATION_H
|
|
#define SYSTEMCONFIGURATION_H
|
|
|
|
#include <QDialog>
|
|
#include <QTableView>
|
|
#include <QAbstractTableModel>
|
|
#include <QStringList>
|
|
#include <QAbstractTableModel>
|
|
#include <QStringList>
|
|
#include "shimlccontroller.h"
|
|
|
|
class ConfigViewModel : public QAbstractTableModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
QList<QList<QString>> tableData;
|
|
ConfigViewModel(QObject *parent = nullptr)
|
|
: QAbstractTableModel(parent)
|
|
{
|
|
// Initialize the data
|
|
for (int row = 0; row < 12; ++row) {
|
|
QList<QString> rowData;
|
|
for (int col = 0; col < 3; ++col) {
|
|
rowData.append(QString("-"));
|
|
}
|
|
tableData.append(rowData);
|
|
}
|
|
}
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override
|
|
{
|
|
Q_UNUSED(parent);
|
|
return 12; // Fixed 12 rows
|
|
}
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override
|
|
{
|
|
Q_UNUSED(parent);
|
|
return 3; // Fixed 4 columns
|
|
}
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override
|
|
{
|
|
if (!index.isValid())
|
|
return QVariant();
|
|
|
|
if (role == Qt::DisplayRole) {
|
|
return tableData[index.row()][index.column()];
|
|
}
|
|
|
|
return QVariant();
|
|
}
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
|
|
{
|
|
if (role == Qt::DisplayRole) {
|
|
if (orientation == Qt::Horizontal) {
|
|
if(section == 0)
|
|
return QString("Name");
|
|
if(section == 1)
|
|
return QString("Version");
|
|
if(section == 2)
|
|
return QString("Serial");
|
|
} else if (orientation == Qt::Vertical) {
|
|
return QString("Port %1").arg(section + 1);
|
|
}
|
|
}
|
|
return QVariant();
|
|
}
|
|
|
|
private:
|
|
};
|
|
|
|
|
|
|
|
namespace Ui {
|
|
class SystemConfiguration;
|
|
}
|
|
|
|
class SystemConfiguration : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit SystemConfiguration(ShimLCController* cmd, QWidget *parent);
|
|
~SystemConfiguration();
|
|
|
|
private:
|
|
Ui::SystemConfiguration *ui;
|
|
ConfigViewModel config_view_model;
|
|
ShimLCController* cmd;
|
|
|
|
private slots:
|
|
void updateTable();
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // SYSTEMCONFIGURATION_H
|