diff --git a/core/gridform.h b/core/gridform.h index 54642b8..1b089d4 100644 --- a/core/gridform.h +++ b/core/gridform.h @@ -111,6 +111,7 @@ public slots: connect(tableView()->horizontalHeader(), SIGNAL(sectionResized(int,int,int)), this, SLOT(widthChanged(int,int,int))); hideColumns(hide); + enableButtons(); return !m_permissionDenied; } diff --git a/core/igridform.cpp b/core/igridform.cpp index 05d2c86..12cf933 100644 --- a/core/igridform.cpp +++ b/core/igridform.cpp @@ -71,6 +71,11 @@ QWidget *IGridForm::filterWidget() return ui->filterWidget; } +void IGridForm::enableButtons() +{ + ui->btnNew->setEnabled(canAddRecord()); +} + void IGridForm::on_btnNew_clicked() { @@ -143,8 +148,8 @@ void IGridForm::on_tableView_clicked(const QModelIndex &) { if (ui->tableView->currentIndex().isValid()) { - ui->btnEdit->setEnabled(true); - ui->btnDelete->setEnabled(true); + ui->btnEdit->setEnabled(canEditRecord()); + ui->btnDelete->setEnabled(canDeleteRecord()); } } diff --git a/core/igridform.h b/core/igridform.h index e419706..9c0970a 100644 --- a/core/igridform.h +++ b/core/igridform.h @@ -41,8 +41,12 @@ protected: virtual void handleNewRecord() = 0; virtual void handleEditRecord() = 0; virtual void handleDeleteRecord() = 0; + virtual bool canAddRecord() { return true; } + virtual bool canEditRecord() { return true; } + virtual bool canDeleteRecord() { return true; } void hideColumns(const QList &cols); QWidget *filterWidget(); + void enableButtons(); private slots: void on_btnNew_clicked();