|
|
@ -99,7 +99,7 @@ public slots:
|
|
|
|
m_permissionDenied = false;
|
|
|
|
m_permissionDenied = false;
|
|
|
|
connectService();
|
|
|
|
connectService();
|
|
|
|
|
|
|
|
|
|
|
|
m_tableModel->setData(service()->all());
|
|
|
|
m_tableModel->setData(listForGrid());
|
|
|
|
tableView()->setModel(m_tableModel);
|
|
|
|
tableView()->setModel(m_tableModel);
|
|
|
|
|
|
|
|
|
|
|
|
QList<QVariant> varList = Context::instance().settings()->value("grids/" + pluginId() + "/hide").toList();
|
|
|
|
QList<QVariant> varList = Context::instance().settings()->value("grids/" + pluginId() + "/hide").toList();
|
|
|
@ -174,10 +174,8 @@ private slots:
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
virtual void handleNewRecord() override
|
|
|
|
virtual void handleNewRecord() override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
if (!checkPermAdd())
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_ADD))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to add new record."));
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -194,10 +192,8 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
virtual void handleEditRecord() override
|
|
|
|
virtual void handleEditRecord() override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
if (!checkPermEdit())
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_EDIT))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to edit record."));
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -214,10 +210,8 @@ protected:
|
|
|
|
|
|
|
|
|
|
|
|
void handleDeleteRecord() override
|
|
|
|
void handleDeleteRecord() override
|
|
|
|
{
|
|
|
|
{
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
if (!checkPermDelete())
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_DELETE))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to delete record."));
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -234,7 +228,7 @@ protected:
|
|
|
|
if (reply == QMessageBox::Yes)
|
|
|
|
if (reply == QMessageBox::Yes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QSharedPointer<T> entity = m_tableModel->itemFromIndex(tableView()->currentIndex());
|
|
|
|
QSharedPointer<T> entity = m_tableModel->itemFromIndex(tableView()->currentIndex());
|
|
|
|
service()->erase(entity);
|
|
|
|
doDelete(entity);
|
|
|
|
|
|
|
|
|
|
|
|
if (!m_permissionDenied)
|
|
|
|
if (!m_permissionDenied)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -244,6 +238,42 @@ protected:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool checkPermAdd()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_ADD))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to add new record."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool checkPermEdit()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_EDIT))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to edit record."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool checkPermDelete()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
PermissionEvaluator permEv;
|
|
|
|
|
|
|
|
if (!permEv.hasPermission(pluginId(), PERM_DELETE))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::critical(this, tr("Permission denied"), tr("You don't have permission to delete record."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual int currentRecordId()
|
|
|
|
virtual int currentRecordId()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (tableView()->currentIndex().isValid())
|
|
|
|
if (tableView()->currentIndex().isValid())
|
|
|
@ -254,6 +284,26 @@ protected:
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSharedPointer<T> currentEntity()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (tableView()->currentIndex().isValid())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return m_tableModel->itemFromIndex(tableView()->currentIndex());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return QSharedPointer<T>();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual void doDelete(QSharedPointer<T> entity)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
service()->erase(entity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
virtual QList<QSharedPointer<T> > listForGrid()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return service()->all();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void addRow(QSharedPointer<T> entity)
|
|
|
|
void addRow(QSharedPointer<T> entity)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_tableModel->addRow(entity);
|
|
|
|
m_tableModel->addRow(entity);
|
|
|
|