removed old code
This commit is contained in:
@@ -24,87 +24,6 @@ extern "C" {
|
||||
#include "qt_deviceconfig.hpp"
|
||||
#include "qt_models_common.hpp"
|
||||
|
||||
/*
|
||||
class MachineModel : public QAbstractListModel {
|
||||
public:
|
||||
MachineModel(QObject* parent) : QAbstractListModel(parent) {}
|
||||
|
||||
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
|
||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
||||
private:
|
||||
struct Entry {
|
||||
QString name;
|
||||
int id;
|
||||
};
|
||||
QList<Entry> entries;
|
||||
};
|
||||
|
||||
bool MachineModel::insertRows(int row, int count, const QModelIndex &parent) {
|
||||
beginInsertRows(parent, row, row + count - 1);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
entries.insert(row, Entry{});
|
||||
}
|
||||
endInsertRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MachineModel::removeRows(int row, int count, const QModelIndex &parent) {
|
||||
beginRemoveRows(parent, row, row + count - 1);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
entries.removeAt(row);
|
||||
}
|
||||
endRemoveRows();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QVariant MachineModel::data(const QModelIndex &index, int role) const {
|
||||
Q_ASSERT(checkIndex(index, QAbstractItemModel::CheckIndexOption::IndexIsValid | QAbstractItemModel::CheckIndexOption::ParentIsInvalid));
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
return entries.at(index.row()).name;
|
||||
case Qt::UserRole:
|
||||
return entries.at(index.row()).id;
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
int MachineModel::rowCount(const QModelIndex &parent) const {
|
||||
(void) parent;
|
||||
return entries.size();
|
||||
}
|
||||
|
||||
bool MachineModel::setData(const QModelIndex &index, const QVariant &value, int role) {
|
||||
Entry* entry = nullptr;
|
||||
if (index.row() < entries.size()) {
|
||||
entry = &entries[index.row()];
|
||||
} else if (index.row() == entries.size()) {
|
||||
entries.append(Entry{});
|
||||
entry = &entries.back();
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
if (entry != nullptr) {
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
entry->name = value.toString();
|
||||
case Qt::UserRole:
|
||||
entry->id = value.toInt();
|
||||
default:
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
|
||||
SettingsMachine::SettingsMachine(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SettingsMachine)
|
||||
|
Reference in New Issue
Block a user