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); hideColumns(hide);
enableButtons(); enableButtons();
connect(tableView()->selectionModel(), &QItemSelectionModel::currentRowChanged, [this](const QModelIndex &current, const QModelIndex &){
currentIndexChanged(current);
});
return !m_permissionDenied; return !m_permissionDenied;
} }

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

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

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

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

Loading…
Cancel
Save