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