Updates and Vessels viewmodel

This commit is contained in:
Andrew nuark G 2020-12-22 22:18:05 +07:00
parent 72a4842800
commit 9a4b71de36
6 changed files with 34 additions and 12 deletions

View file

@ -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 \

View file

@ -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();
} }

View file

@ -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();

View file

@ -0,0 +1,6 @@
#include "vesselsviewmodel.h"
VesselsViewModel::VesselsViewModel()
{
}

View file

@ -0,0 +1,13 @@
#ifndef VESSELSVIEWMODEL_H
#define VESSELSVIEWMODEL_H
#include <QAbstractTableModel>
class VesselsViewModel : public QAbstractTableModel
{
Q_OBJECT
public:
VesselsViewModel();
};
#endif // VESSELSVIEWMODEL_H

View file

@ -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"
); );
} }