|
|
@ -22,6 +22,7 @@ public:
|
|
|
|
IGridForm(parent)
|
|
|
|
IGridForm(parent)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_serviceConnected = false;
|
|
|
|
m_serviceConnected = false;
|
|
|
|
|
|
|
|
m_permissionDenied = false;
|
|
|
|
m_tableModel = NULL;
|
|
|
|
m_tableModel = NULL;
|
|
|
|
m_formHandler = new DefaultFormHandler();
|
|
|
|
m_formHandler = new DefaultFormHandler();
|
|
|
|
|
|
|
|
|
|
|
@ -80,12 +81,13 @@ public:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
public slots:
|
|
|
|
void fillData() {
|
|
|
|
bool fillData() {
|
|
|
|
if (m_tableModel == NULL) {
|
|
|
|
if (m_tableModel == NULL) {
|
|
|
|
Q_ASSERT(false);
|
|
|
|
Q_ASSERT(false);
|
|
|
|
return;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_permissionDenied = false;
|
|
|
|
connectService();
|
|
|
|
connectService();
|
|
|
|
|
|
|
|
|
|
|
|
m_tableModel->setData(service()->all());
|
|
|
|
m_tableModel->setData(service()->all());
|
|
|
@ -105,6 +107,8 @@ public slots:
|
|
|
|
|
|
|
|
|
|
|
|
connect(tableView()->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(widthChanged(int,int,int)));
|
|
|
|
connect(tableView()->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(widthChanged(int,int,int)));
|
|
|
|
hideColumns(hide);
|
|
|
|
hideColumns(hide);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return !m_permissionDenied;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
@ -140,12 +144,19 @@ private:
|
|
|
|
connect(service(), &IService::dbErrorDelete, [this](QString msg) {
|
|
|
|
connect(service(), &IService::dbErrorDelete, [this](QString msg) {
|
|
|
|
QMessageBox::critical(this, tr("Database error"), tr(msg.toStdString().c_str()));
|
|
|
|
QMessageBox::critical(this, tr("Database error"), tr(msg.toStdString().c_str()));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
this->connect(service(), &IService::permissionDenied, [this](QString permission) {
|
|
|
|
|
|
|
|
if (permission == PERM_READ || permission == PERM_DELETE) {
|
|
|
|
|
|
|
|
QMessageBox::critical(this, "Permission denied", permission .toStdString().c_str());
|
|
|
|
|
|
|
|
m_permissionDenied = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
m_serviceConnected = true;
|
|
|
|
m_serviceConnected = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool m_serviceConnected;
|
|
|
|
bool m_serviceConnected;
|
|
|
|
|
|
|
|
bool m_permissionDenied;
|
|
|
|
|
|
|
|
|
|
|
|
// IGridForm interface
|
|
|
|
// IGridForm interface
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
@ -177,6 +188,7 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
void handleDeleteRecord() override
|
|
|
|
void handleDeleteRecord() override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
m_permissionDenied = false;
|
|
|
|
connectService();
|
|
|
|
connectService();
|
|
|
|
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)
|
|
|
|
if (m_form == NULL || m_tableModel == NULL || tableView()->currentIndex().row() < 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -190,8 +202,12 @@ protected:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QSharedPointer<T> entity = m_tableModel->itemFromIndex(tableView()->currentIndex());
|
|
|
|
QSharedPointer<T> entity = m_tableModel->itemFromIndex(tableView()->currentIndex());
|
|
|
|
service()->erase(entity);
|
|
|
|
service()->erase(entity);
|
|
|
|
m_tableModel->removeRowAt(tableView()->currentIndex());
|
|
|
|
|
|
|
|
emit dataChanged();
|
|
|
|
if (!m_permissionDenied)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_tableModel->removeRowAt(tableView()->currentIndex());
|
|
|
|
|
|
|
|
emit dataChanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|