Added possibility to add custom widget to GridForm. Small fix in ReportDialog.

master
Josef Rokos 8 years ago
parent cf937aee96
commit e5b33fa973

@ -118,6 +118,10 @@ public slots:
hideColumns(hide);
enableButtons();
connect(tableView()->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, const QModelIndex &){
currentIndexChanged(current);
});
return !m_permissionDenied;
}

@ -24,10 +24,6 @@ IGridForm::IGridForm(QWidget *parent) :
m_columnDialog = new ColumnDialog(this);
connect(m_columnDialog, SIGNAL(accepted()), this, SLOT(columnsAccepted()));
connect(ui->tableView->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, const QModelIndex &){
currentIndexChanged(current);
});
m_varFiller = new VariableFiller();
}
@ -93,6 +89,11 @@ QWidget *IGridForm::filterWidget()
return ui->filterWidget;
}
QVBoxLayout *IGridForm::mainLayout()
{
return ui->verticalLayout;
}
void IGridForm::enableButtons()
{
ui->btnNew->setEnabled(canAddRecord());
@ -179,7 +180,7 @@ void IGridForm::on_tableView_clicked(const QModelIndex &)
void IGridForm::on_btnPrint_clicked()
{
ReportDialog *dialog = new ReportDialog(this);
ReportDialog *dialog = new ReportDialog(currentRecordId() != 0, this);
dialog->setAttribute(Qt::WA_DeleteOnClose);
if (m_varFiller != NULL)

@ -6,6 +6,7 @@
#include <QTableView>
#include <QMenu>
#include <QList>
#include <QVBoxLayout>
#include <QWidget>
#include "columndialog.h"
@ -50,6 +51,7 @@ protected:
virtual void currentIndexChanged(const QModelIndex &current) { Q_UNUSED(current) }
void hideColumns(const QList<int> &cols);
QWidget *filterWidget();
QVBoxLayout *mainLayout();
void enableButtons();
private slots:

@ -6,11 +6,12 @@
#include "reportviewer.h"
ReportDialog::ReportDialog(QWidget *parent) :
ReportDialog::ReportDialog(bool recordSelected, QWidget *parent) :
QDialog(parent),
ui(new Ui::ReportDialog)
{
ui->setupUi(this);
m_recordSelected = recordSelected;
}
ReportDialog::~ReportDialog()
@ -33,6 +34,7 @@ void ReportDialog::setReports(ReportList reports)
foreach (ReportPtr report, reports) {
QStandardItem *item = new QStandardItem((report->listReport() ? QIcon(":/icons/list.svg") : QIcon(":/icons/report.svg")), report->name());
item->setEnabled(report->listReport() || m_recordSelected);
model->appendRow(item);
}
@ -41,14 +43,13 @@ void ReportDialog::setReports(ReportList reports)
connect(ui->listReports->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex, QModelIndex){
ui->textDescription->setText(m_reports[ui->listReports->currentIndex().row()]->description());
ui->btnPreview->setEnabled(ui->listReports->currentIndex().isValid());
ui->btnPrint->setEnabled(ui->listReports->currentIndex().isValid());
});
if (!reports.isEmpty())
{
ui->btnPreview->setEnabled(true);
ui->btnPrint->setEnabled(true);
ui->listReports->setCurrentIndex(model->index(0, 0));
}
}

@ -13,7 +13,7 @@ class ReportDialog : public QDialog
Q_OBJECT
public:
explicit ReportDialog(QWidget *parent = 0);
explicit ReportDialog(bool recordSelected = false, QWidget *parent = 0);
~ReportDialog();
void setReports(ReportList reports);
@ -28,6 +28,7 @@ private slots:
private:
Ui::ReportDialog *ui;
ReportList m_reports;
bool m_recordSelected;
};
#endif // REPORTDIALOG_H

Loading…
Cancel
Save