aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/guiSQLiteStudio/dataview.cpp
diff options
context:
space:
mode:
authorLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
committerLibravatarUnit 193 <unit193@unit193.net>2023-04-30 18:30:36 -0400
commit3565aad630864ecdbe53fdaa501ea708555b3c7c (patch)
treec743e4ad0bad39ebdb2f514c7cc52d34a257ebbe /SQLiteStudio3/guiSQLiteStudio/dataview.cpp
parent1fdc150116cad39aae5c5da407c3312b47a59e3a (diff)
New upstream version 3.4.4+dfsg.upstream/3.4.4+dfsg
Diffstat (limited to 'SQLiteStudio3/guiSQLiteStudio/dataview.cpp')
-rw-r--r--SQLiteStudio3/guiSQLiteStudio/dataview.cpp51
1 files changed, 32 insertions, 19 deletions
diff --git a/SQLiteStudio3/guiSQLiteStudio/dataview.cpp b/SQLiteStudio3/guiSQLiteStudio/dataview.cpp
index 568954c..e7ae9b5 100644
--- a/SQLiteStudio3/guiSQLiteStudio/dataview.cpp
+++ b/SQLiteStudio3/guiSQLiteStudio/dataview.cpp
@@ -1,11 +1,9 @@
#include "dataview.h"
-#include "datagrid/sqltablemodel.h"
#include "datagrid/sqlquerymodel.h"
#include "datagrid/sqlqueryview.h"
#include "formview.h"
#include "common/extlineedit.h"
#include "mainwindow.h"
-#include "statusfield.h"
#include "common/intvalidator.h"
#include "common/extaction.h"
#include "iconmanager.h"
@@ -77,7 +75,7 @@ void DataView::initSlots()
connect(model, SIGNAL(executionStarted()), gridView, SLOT(executionStarted()));
connect(model, SIGNAL(loadingEnded(bool)), gridView, SLOT(executionEnded()));
connect(model, SIGNAL(totalRowsAndPagesAvailable()), this, SLOT(totalRowsAndPagesAvailable()));
- connect(gridView->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(columnsHeaderClicked(int)));
+ connect(gridView->horizontalHeader(), SIGNAL(sectionDoubleClicked(int)), this, SLOT(columnsHeaderDoubleClicked(int)));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
connect(model, SIGNAL(itemEditionEnded(SqlQueryItem*)), this, SLOT(adjustColumnWidth(SqlQueryItem*)));
connect(gridView, SIGNAL(scrolledBy(int, int)), this, SLOT(syncFilterScrollPosition()));
@@ -235,8 +233,8 @@ void DataView::createActions()
createAction(SELECTIVE_COMMIT, ICONS.COMMIT, tr("Commit changes for selected cells", "data view"), this, SLOT(selectiveCommitGrid()), this);
createAction(SELECTIVE_ROLLBACK, ICONS.ROLLBACK, tr("Rollback changes for selected cells", "data view"), this, SLOT(selectiveRollbackGrid()), this);
- createAction(SHOW_GRID_VIEW, tr("Show grid view of results", "sql editor"), this, SLOT(showGridView()), this);
- createAction(SHOW_FORM_VIEW, tr("Show form view of results", "sql editor"), this, SLOT(showFormView()), this);
+ createAction(SHOW_GRID_VIEW, tr("Show grid view of results", "data view"), this, SLOT(showGridView()), this);
+ createAction(SHOW_FORM_VIEW, tr("Show form view of results", "data view"), this, SLOT(showFormView()), this);
connect(gridView, SIGNAL(requestForRowInsert()), this, SLOT(insertRow()));
connect(gridView, SIGNAL(requestForMultipleRowInsert()), this, SLOT(insertMultipleRows()));
@@ -310,14 +308,11 @@ void DataView::resizeColumnsInitiallyToContents()
continue;
}
+ int headerMinSize = qMax(gridView->horizontalHeader()->sizeHintForColumn(i), 60);
if (wd > CFG_UI.General.MaxInitialColumnWith.get())
- {
gridView->setColumnWidth(i, CFG_UI.General.MaxInitialColumnWith.get());
- }
- else if (wd < 60)
- {
- gridView->setColumnWidth(i, 60);
- }
+ else if (wd < headerMinSize)
+ gridView->setColumnWidth(i, headerMinSize);
}
gridView->setIgnoreColumnWidthChanges(false);
}
@@ -427,7 +422,6 @@ void DataView::goToFormRow(IndexModifier idxMod)
return;
gridView->setCurrentIndex(newRowIdx);
- model->loadFullDataForEntireRow(row);
formView->updateFromGrid();
updateCurrentFormViewRow();
}
@@ -551,6 +545,9 @@ void DataView::adjustColumnWidth(SqlQueryItem* item)
if (model->getDesiredColumnWidth(col) > -1)
return;
+ if (!CFG_UI.General.EnlargeColumnForValue.get())
+ return;
+
gridView->resizeColumnToContents(col);
if (gridView->columnWidth(col) > CFG_UI.General.MaxInitialColumnWith.get())
gridView->setColumnWidth(col, CFG_UI.General.MaxInitialColumnWith.get());
@@ -564,6 +561,9 @@ void DataView::syncFilterScrollPosition()
void DataView::resizeFilter(int section, int oldSize, int newSize)
{
UNUSED(oldSize);
+ if (!model->features().testFlag(SqlQueryModel::FILTERING))
+ return;
+
if (filterInputs.isEmpty())
return;
@@ -841,6 +841,9 @@ void DataView::applyFilter()
case DataView::FilterMode::REGEXP:
model->applyRegExpFilter(filterValues);
break;
+ case FilterMode::EXACT:
+ model->applyStrictFilter(filterValues);
+ break;
}
}
else
@@ -857,6 +860,9 @@ void DataView::applyFilter()
case DataView::FilterMode::REGEXP:
model->applyRegExpFilter(value);
break;
+ case DataView::FilterMode::EXACT:
+ model->applyStrictFilter(value);
+ break;
}
}
}
@@ -938,19 +944,22 @@ void DataView::formViewFocusFirstEditor()
void DataView::recreateFilterInputs()
{
+ if (!model->features().testFlag(SqlQueryModel::FILTERING))
+ return;
+
qApp->processEvents();
- for (QLineEdit* edit : filterInputs)
+ for (ExtLineEdit*& edit : filterInputs)
delete edit;
filterInputs.clear();
filterLeftSpacer->setFixedSize(gridView->verticalHeader()->width() + 1, 1);
- QLineEdit* edit = nullptr;
+ ExtLineEdit* edit = nullptr;
for (int i = 0, total = gridView->horizontalHeader()->count(); i < total; ++i)
{
- edit = new QLineEdit(perColumnWidget);
+ edit = new ExtLineEdit(perColumnWidget);
edit->setPlaceholderText(tr("Filter"));
edit->setClearButtonEnabled(true);
edit->setFixedWidth(gridView->columnWidth(i));
@@ -982,20 +991,24 @@ void DataView::recreateFilterInputs()
void DataView::createFilteringActions()
{
- createAction(FILTER_STRING, ICONS.APPLY_FILTER_TXT, tr("Filter by text", "data view"), this, SLOT(filterModeSelected()), this);
+ createAction(FILTER_STRING, ICONS.APPLY_FILTER_TXT, tr("Filter by text (if contains)", "data view"), this, SLOT(filterModeSelected()), this);
+ createAction(FILTER_EXACT, ICONS.APPLY_FILTER_TXT_STRICT, tr("Filter strictly by text (if equals)", "data view"), this, SLOT(filterModeSelected()), this);
createAction(FILTER_REGEXP, ICONS.APPLY_FILTER_RE, tr("Filter by the Regular Expression", "data view"), this, SLOT(filterModeSelected()), this);
createAction(FILTER_SQL, ICONS.APPLY_FILTER_SQL, tr("Filter by SQL expression", "data view"), this, SLOT(filterModeSelected()), this);
actionMap[FILTER_STRING]->setProperty(DATA_VIEW_FILTER_PROP, static_cast<int>(FilterMode::STRING));
+ actionMap[FILTER_EXACT]->setProperty(DATA_VIEW_FILTER_PROP, static_cast<int>(FilterMode::EXACT));
actionMap[FILTER_REGEXP]->setProperty(DATA_VIEW_FILTER_PROP, static_cast<int>(FilterMode::REGEXP));
actionMap[FILTER_SQL]->setProperty(DATA_VIEW_FILTER_PROP, static_cast<int>(FilterMode::SQL));
QActionGroup* filterGroup = new QActionGroup(gridToolBar);
filterGroup->addAction(actionMap[FILTER_STRING]);
+ filterGroup->addAction(actionMap[FILTER_EXACT]);
filterGroup->addAction(actionMap[FILTER_SQL]);
filterGroup->addAction(actionMap[FILTER_REGEXP]);
actionMap[FILTER_STRING]->setCheckable(true);
+ actionMap[FILTER_EXACT]->setCheckable(true);
actionMap[FILTER_REGEXP]->setCheckable(true);
actionMap[FILTER_SQL]->setCheckable(true);
actionMap[FILTER_STRING]->setChecked(true);
@@ -1006,6 +1019,7 @@ void DataView::createFilteringActions()
actionMap[FILTER_VALUE] = gridToolBar->addWidget(filterEdit);
createAction(FILTER, tr("Apply filter", "data view"), this, SLOT(applyFilter()), gridToolBar);
attachActionInMenu(FILTER, actionMap[FILTER_STRING], gridToolBar);
+ attachActionInMenu(FILTER, actionMap[FILTER_EXACT], gridToolBar);
attachActionInMenu(FILTER, actionMap[FILTER_REGEXP], gridToolBar);
attachActionInMenu(FILTER, actionMap[FILTER_SQL], gridToolBar);
addSeparatorInMenu(FILTER, gridToolBar);
@@ -1018,7 +1032,8 @@ void DataView::createFilteringActions()
gridView->getHeaderContextMenu()->addAction(actionMap[FILTER_PER_COLUMN]);
}
-void DataView::columnsHeaderClicked(int columnIdx)
+
+void DataView::columnsHeaderDoubleClicked(int columnIdx)
{
model->changeSorting(columnIdx);
}
@@ -1038,8 +1053,6 @@ void DataView::tabChanged(int newIndex)
if (!gridView->getCurrentIndex().isValid() && model->rowCount() > 0)
gridView->setCurrentRow(0);
- int row = gridView->getCurrentIndex().row();
- model->loadFullDataForEntireRow(row);
formView->updateFromGrid();
updateCurrentFormViewRow();
break;