Updates and Vessels viewmodel
This commit is contained in:
parent
72a4842800
commit
9a4b71de36
6 changed files with 34 additions and 12 deletions
|
|
@ -25,7 +25,8 @@ SOURCES += \
|
||||||
system/object_system.cpp \
|
system/object_system.cpp \
|
||||||
usereditdialog.cpp \
|
usereditdialog.cpp \
|
||||||
vesseleditdialog.cpp \
|
vesseleditdialog.cpp \
|
||||||
viewmodels/usersviewmodel.cpp
|
viewmodels/usersviewmodel.cpp \
|
||||||
|
viewmodels/vesselsviewmodel.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
adminpanel.h \
|
adminpanel.h \
|
||||||
|
|
@ -45,7 +46,8 @@ HEADERS += \
|
||||||
system/object_system.h \
|
system/object_system.h \
|
||||||
usereditdialog.h \
|
usereditdialog.h \
|
||||||
vesseleditdialog.h \
|
vesseleditdialog.h \
|
||||||
viewmodels/usersviewmodel.h
|
viewmodels/usersviewmodel.h \
|
||||||
|
viewmodels/vesselsviewmodel.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
adminpanel.ui \
|
adminpanel.ui \
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ UsersViewModel::UsersViewModel(QObject *parent) : QAbstractTableModel(parent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int UsersViewModel::rowCount(const QModelIndex &/*parent*/) const {
|
int UsersViewModel::rowCount(const QModelIndex &/*parent*/) const {
|
||||||
return apparatus::instance()->get_object_subsystem()->vessels().size();
|
return apparatus::instance()->get_auth_subsystem()->users().length();
|
||||||
}
|
}
|
||||||
|
|
||||||
int UsersViewModel::columnCount(const QModelIndex &/*parent*/) const {
|
int UsersViewModel::columnCount(const QModelIndex &/*parent*/) const {
|
||||||
|
|
@ -61,5 +61,6 @@ QVariant UsersViewModel::data(const QModelIndex &index, int role) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsersViewModel::update() {
|
void UsersViewModel::update() {
|
||||||
this->resetInternalData();
|
this->beginResetModel();
|
||||||
|
this->endResetModel();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ class UsersViewModel : public QAbstractTableModel
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
UsersViewModel(QObject *parent = nullptr);
|
UsersViewModel(QObject *parent = nullptr);
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||||
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void update();
|
void update();
|
||||||
|
|
|
||||||
6
sea_transport/viewmodels/vesselsviewmodel.cpp
Normal file
6
sea_transport/viewmodels/vesselsviewmodel.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
#include "vesselsviewmodel.h"
|
||||||
|
|
||||||
|
VesselsViewModel::VesselsViewModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
13
sea_transport/viewmodels/vesselsviewmodel.h
Normal file
13
sea_transport/viewmodels/vesselsviewmodel.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#ifndef VESSELSVIEWMODEL_H
|
||||||
|
#define VESSELSVIEWMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractTableModel>
|
||||||
|
|
||||||
|
class VesselsViewModel : public QAbstractTableModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VesselsViewModel();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VESSELSVIEWMODEL_H
|
||||||
|
|
@ -165,7 +165,7 @@ void st_test::vessel_entity_serialization_test() {
|
||||||
stream.setDevice(&f);
|
stream.setDevice(&f);
|
||||||
|
|
||||||
dpoint_entity test_harbor("test_harbor_for_vessel");
|
dpoint_entity test_harbor("test_harbor_for_vessel");
|
||||||
ent1 = vessel_entity(test_harbor, 256);
|
ent1 = vessel_entity(test_harbor.id(), 256);
|
||||||
ent1.serialize(stream);
|
ent1.serialize(stream);
|
||||||
|
|
||||||
stream.setDevice(nullptr);
|
stream.setDevice(nullptr);
|
||||||
|
|
@ -181,7 +181,7 @@ void st_test::vessel_entity_serialization_test() {
|
||||||
}
|
}
|
||||||
|
|
||||||
QVERIFY2(
|
QVERIFY2(
|
||||||
ent1.id() == ent2.id() && ent1.harbor().id() == ent2.harbor().id() && ent1.capacity() == ent2.capacity(),
|
ent1.id() == ent2.id() && ent1.harbor() == ent2.harbor() && ent1.capacity() == ent2.capacity(),
|
||||||
"Delivery Point entity not serialized properly"
|
"Delivery Point entity not serialized properly"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue