@@ -57,12 +57,12 @@ TableView::TableView(QWidget *parent) :
5757 qfLogFuncFrame () << this ;
5858 setItemDelegate (new TableItemDelegate (this ));
5959 {
60- HeaderView *h = new HeaderView (Qt::Horizontal, this );
60+ auto *h = new HeaderView (Qt::Horizontal, this );
6161 setHorizontalHeader (h);
6262 connect (this , &TableView::seekStringChanged, h, &HeaderView::setSeekString);
6363 }
6464 {
65- HeaderView *h = new HeaderView (Qt::Vertical, this );
65+ auto *h = new HeaderView (Qt::Vertical, this );
6666 setVerticalHeader (h);
6767 }
6868 setSortingEnabled (true );
@@ -132,7 +132,7 @@ QAbstractProxyModel* TableView::lastProxyModel() const
132132{
133133 QAbstractProxyModel *ret = nullptr ;
134134 for (auto m=Super::model (); m; ) {
135- QAbstractProxyModel *pxm = qobject_cast<QAbstractProxyModel*>(m);
135+ auto *pxm = qobject_cast<QAbstractProxyModel*>(m);
136136 if (pxm) {
137137 ret = pxm;
138138 m = pxm->sourceModel ();
@@ -156,7 +156,7 @@ void TableView::setModel(QAbstractItemModel *model)
156156
157157qf::core::model::TableModel *TableView::tableModel () const
158158{
159- qf::core::model::TableModel *ret = qobject_cast<qf::core::model::TableModel *>(lastProxyModel ()->sourceModel ());
159+ auto *ret = qobject_cast<qf::core::model::TableModel *>(lastProxyModel ()->sourceModel ());
160160 return ret;
161161}
162162
@@ -355,8 +355,9 @@ void TableView::setDirtyRowsMenuSectionEnabled(bool b)
355355
356356void TableView::setReadOnly (bool ro)
357357{
358- if (ro == isReadOnly ())
358+ if (ro == isReadOnly ()) {
359359 return ;
360+ }
360361 m_isReadOnly = ro;
361362
362363 setEditRowsMenuSectionEnabled (!ro);
@@ -523,7 +524,7 @@ void TableView::paste()
523524 try {
524525 dialogs::Dialog dlg (this );
525526 dlg.setButtons (QDialogButtonBox::Ok);
526- internal::TableViewCopyToDialogWidget *w = new internal::TableViewCopyToDialogWidget ();
527+ auto *w = new internal::TableViewCopyToDialogWidget ();
527528 dlg.setCentralWidget (w);
528529 int col_cnt = 0 ;
529530 {
@@ -567,7 +568,7 @@ void TableView::paste()
567568 r.clearEditFlags ();
568569 }
569570 TableView *tv = w->tableView ();
570- qfm::TableModel *tm = new qfm::TableModel (tv);
571+ auto *tm = new qfm::TableModel (tv);
571572 tm->setTable (t);
572573 tv->setTableModel (tm);
573574 tv->setContextMenuActions (tv->contextMenuActionsForGroups (AllActions));
@@ -698,7 +699,7 @@ void TableView::editCellContentInEditor()
698699 cell_text = QString::fromUtf8 (cell_value.toByteArray ());
699700 else
700701 cell_text = cell_value.toString ();
701- TextEditWidget *w = new TextEditWidget (this );
702+ auto *w = new TextEditWidget (this );
702703 w->setText (cell_text);
703704 w->setSuggestedFileName (" new_file.txt" );
704705 /*
@@ -708,7 +709,7 @@ void TableView::editCellContentInEditor()
708709 }
709710 */
710711 dialogs::Dialog dlg (this );
711- DialogButtonBox *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
712+ auto *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
712713 QAbstractButton *bt_save = bb->addButton (QDialogButtonBox::Save);
713714 connect (bt_save, &QAbstractButton::clicked, &dlg, &QDialog::accept);
714715 dlg.setButtonBox (bb);
@@ -742,13 +743,13 @@ void TableView::exportCSV()
742743 if (!m)
743744 return ;
744745
745- qf::qmlwidgets::ExportCsvTableViewWidget *w = new qf::qmlwidgets::ExportCsvTableViewWidget (this , this );
746+ auto *w = new qf::qmlwidgets::ExportCsvTableViewWidget (this , this );
746747 if (!persistentSettingsPath ().isEmpty ()) {
747748 w->setPersistentOptionsPath (persistentSettingsPath () + " /exportCSV" );
748749 w->loadPersistentOptions ();
749750 }
750751 dialogs::Dialog dlg (this );
751- DialogButtonBox *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
752+ auto *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
752753 QAbstractButton *bt_apply = bb->addButton (QDialogButtonBox::Apply);
753754 connect (bt_apply, &QAbstractButton::clicked, w, &qf::qmlwidgets::ExportCsvTableViewWidget::applyOptions, Qt::QueuedConnection);
754755 dlg.setButtonBox (bb);
@@ -762,13 +763,13 @@ void TableView::exportCSV()
762763void TableView::exportReport ()
763764{
764765 qfLogFuncFrame ();
765- reports::PrintTableViewWidget *w = new reports::PrintTableViewWidget (this );
766+ auto *w = new reports::PrintTableViewWidget (this );
766767 if (!persistentSettingsPath ().isEmpty ()) {
767768 w->setPersistentOptionsPath (persistentSettingsPath () + " /exportReport" );
768769 w->loadPersistentOptions ();
769770 }
770771 dialogs::Dialog dlg (this );
771- DialogButtonBox *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
772+ auto *bb = new DialogButtonBox (QDialogButtonBox::Cancel, this );
772773 QAbstractButton *bt_apply = bb->addButton (QDialogButtonBox::Apply);
773774 connect (bt_apply, &QAbstractButton::clicked, w, &reports::PrintTableViewWidget::applyOptions, Qt::QueuedConnection);
774775 dlg.setButtonBox (bb);
@@ -931,7 +932,7 @@ void TableView::exportReport_helper(const QVariant& _options)
931932
932933 // qfInfo() << ttable.toString();
933934
934- reports::ReportViewWidget *rw = new reports::ReportViewWidget (nullptr );
935+ auto *rw = new reports::ReportViewWidget (nullptr );
935936 rw->setTableData (QString (), ttable);
936937 QString report_fn = opts.value (" report" ).toMap ().value (" fileName" ).toString ();
937938 rw->setReport (report_fn);
@@ -1341,7 +1342,7 @@ void TableView::savePersistentSettings()
13411342 if (!path.isEmpty ()) {
13421343 QSettings settings;
13431344 settings.beginGroup (path);
1344- HeaderView *horiz_header = qobject_cast<HeaderView*>(horizontalHeader ());
1345+ auto *horiz_header = qobject_cast<HeaderView*>(horizontalHeader ());
13451346
13461347 QByteArray header_state = horiz_header->saveState ();
13471348 settings.setValue (" horizontalheader" , QString::fromLatin1 (header_state.toBase64 ()));
@@ -1357,7 +1358,7 @@ void TableView::onSqlException(const QString &what, const QString &where, const
13571358
13581359void TableView::keyPressEvent (QKeyEvent *e)
13591360{
1360- qfLogFuncFrame () << " key:" << e->key () << " modifiers:" << e->modifiers ();
1361+ // qfLogFuncFrame() << "key:" << e->key() << "modifiers:" << e->modifiers();
13611362 if (!model ()) {
13621363 e->ignore ();
13631364 return ;
@@ -1375,12 +1376,12 @@ void TableView::keyPressEvent(QKeyEvent *e)
13751376 e->accept ();
13761377 return ;
13771378 }
1378- else if (e->key () == Qt::Key_V) {
1379+ if (e->key () == Qt::Key_V) {
13791380 paste ();
13801381 e->accept ();
13811382 return ;
13821383 }
1383- else if (e->key () == Qt::Key_Enter || e->key () == Qt::Key_Return) {
1384+ if (e->key () == Qt::Key_Enter || e->key () == Qt::Key_Return) {
13841385 qfDebug () << " \t CTRL+ENTER" ;
13851386 postRow ();
13861387 e->accept ();
@@ -1458,9 +1459,7 @@ void TableView::keyPressEvent(QKeyEvent *e)
14581459 e->accept ();
14591460 return ;
14601461 }
1461- else {
1462- cancelSeek ();
1463- }
1462+ cancelSeek ();
14641463 // bool event_should_be_accepted = false;
14651464 // / nejedna se o inkrementalni vyhledavani, zkusime editaci
14661465 if (state () == EditingState) {
@@ -1808,7 +1807,7 @@ void TableView::createActions()
18081807 a->setOid (" select" );
18091808 m_actionGroups[SelectActions] << a->oid ();
18101809 m_actions[a->oid ()] = a;
1811- QMenu *m = new QMenu (this );
1810+ auto *m = new QMenu (this );
18121811 a->setMenu (m);
18131812 {
18141813 a = new Action (tr (" Select current column" ), this );
@@ -1835,7 +1834,7 @@ void TableView::createActions()
18351834 a->setOid (" calculate" );
18361835 m_actionGroups[CalculateActions] << a->oid ();
18371836 m_actions[a->oid ()] = a;
1838- QMenu *m = new QMenu (this );
1837+ auto *m = new QMenu (this );
18391838 a->setMenu (m);
18401839 {
18411840 a = new Action (tr (" Sum column" ), this );
@@ -1855,7 +1854,7 @@ void TableView::createActions()
18551854 a->setOid (" export" );
18561855 m_actionGroups[ExportActions] << a->oid ();
18571856 m_actions[a->oid ()] = a;
1858- QMenu *m = new QMenu (this );
1857+ auto *m = new QMenu (this );
18591858 a->setMenu (m);
18601859 {
18611860 a = new Action (tr (" Report" ), this );
@@ -1900,7 +1899,7 @@ void TableView::createActions()
19001899 a->setOid (" import" );
19011900 m_actionGroups[ImportActions] << a->oid ();
19021901 m_actions[a->oid ()] = a;
1903- QMenu *m = new QMenu (this );
1902+ auto *m = new QMenu (this );
19041903 a->setMenu (m);
19051904 {
19061905 a = new Action (tr (" CSV" ), this );
@@ -2126,7 +2125,7 @@ void TableView::insertRowInline()
21262125 if (tri < 0 ) {
21272126 qfWarning () << " Valid proxy model index has invalid table model index!" ;
21282127 // / this can happen when one inserts to empty table ???? why ????
2129- tri = ri = 0 ;
2128+ tri = 0 ;
21302129 }
21312130 }
21322131 tableModel ()->insertRow (tri);
@@ -2247,9 +2246,7 @@ bool TableView::edit(const QModelIndex& index, EditTrigger trigger, QEvent* even
22472246 }
22482247 else {
22492248 if (trigger == QTableView::DoubleClicked || trigger == QTableView::EditKeyPressed) {
2250- if (read_only) {
2251- }
2252- else {
2249+ if (!read_only) {
22532250 emit editCellRequest (index);
22542251 QVariant id = selectedRow ().value (idColumnName ());
22552252 if (id.isValid ()) {
0 commit comments