Fix a ton of warnings from clang, clazy, cppcheck, etc.

This commit is contained in:
Martin Kleusberg
2021-01-22 13:50:49 +01:00
parent 3e06b2e4f9
commit 329c07e0b2
36 changed files with 764 additions and 774 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ class AboutDialog : public QDialog
public:
explicit AboutDialog(QWidget *parent = nullptr);
~AboutDialog();
~AboutDialog() override;
private:
Ui::AboutDialog *ui;
+24 -16
View File
@@ -11,6 +11,8 @@
#include <QLineEdit>
#include <QMenu>
namespace {
class NullLineEdit: public QLineEdit {
Q_OBJECT
private:
@@ -33,23 +35,24 @@ public:
m_isNull = value;
}
protected:
void contextMenuEvent(QContextMenuEvent *event)
{
QMenu* editContextMenu = createStandardContextMenu();
void contextMenuEvent(QContextMenuEvent *event) override
{
QMenu* editContextMenu = createStandardContextMenu();
QAction* nullAction = new QAction(QIcon(":/icons/set_to_null"), tr("Set to NULL"), editContextMenu);
connect(nullAction, &QAction::triggered, [&]() {
setNull(true);
});
nullAction->setShortcut(QKeySequence(tr("Alt+Del")));
editContextMenu->addSeparator();
editContextMenu->addAction(nullAction);
QAction* nullAction = new QAction(QIcon(":/icons/set_to_null"), tr("Set to NULL"), editContextMenu);
connect(nullAction, &QAction::triggered, nullAction, [&]() {
setNull(true);
});
nullAction->setShortcut(QKeySequence(tr("Alt+Del")));
editContextMenu->addSeparator();
editContextMenu->addAction(nullAction);
editContextMenu->exec(event->globalPos());
delete editContextMenu;
}
editContextMenu->exec(event->globalPos());
delete editContextMenu;
}
void keyPressEvent(QKeyEvent *evt) {
void keyPressEvent(QKeyEvent *evt) override
{
// Alt+Del sets field to NULL
if((evt->modifiers() & Qt::AltModifier) && (evt->key() == Qt::Key_Delete))
setNull(true);
@@ -112,6 +115,9 @@ public:
}
};
}
AddRecordDialog::AddRecordDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier& tableName, QWidget* parent, const std::vector<std::string>& _pseudo_pk)
: QDialog(parent),
ui(new Ui::AddRecordDialog),
@@ -188,8 +194,10 @@ void AddRecordDialog::populateFields()
{
sqlb::TablePtr m_table = pdb.getObjectByName<sqlb::Table>(curTable);
fields = m_table->fields;
for(const sqlb::Field& f : fields)
fks.push_back(m_table->constraint({f.name()}, sqlb::Constraint::ForeignKeyConstraintType));
std::transform(fields.begin(), fields.end(), std::back_inserter(fks), [m_table](const auto& f) {
return m_table->constraint({f.name()}, sqlb::Constraint::ForeignKeyConstraintType);
});
const auto pk_constraint = m_table->primaryKey();
if(pk_constraint)
+3 -3
View File
@@ -99,11 +99,11 @@ std::string CondFormat::filterToSqlCondition(const QString& value, const QString
op = value.left(2);
val = value.mid(2);
}
} else if(value.left(1) == ">" || value.left(1) == "<") {
} else if(value.front() == '>' || value.front() == '<') {
value.midRef(1).toFloat(&numeric);
op = value.at(0);
val = value.mid(1);
} else if(value.left(1) == "=") {
} else if(value.front() == '=') {
val = value.mid(1);
// Check if value to compare with is 'NULL'
@@ -117,7 +117,7 @@ std::string CondFormat::filterToSqlCondition(const QString& value, const QString
op = "IS";
numeric = true;
}
} else if(value.left(1) == "/" && value.right(1) == "/" && value.size() > 2) {
} else if(value.front() == '/' && value.back() == '/' && value.size() > 2) {
val = value.mid(1, value.length() - 2);
op = "REGEXP";
numeric = false;
+5 -5
View File
@@ -225,16 +225,16 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
// For names, export a (qualified) (escaped) identifier of the item for statement composition in SQL editor.
if(objectType == "field")
namesData.append(getNameForDropping(item->text(ColumnSchema), item->parent()->text(ColumnName), item->text(ColumnName)));
namesData.append(getNameForDropping(item->text(ColumnSchema), item->parent()->text(ColumnName), item->text(ColumnName)).toUtf8());
else if(objectType == "database")
namesData.append(getNameForDropping(item->text(ColumnName), "", ""));
namesData.append(getNameForDropping(item->text(ColumnName), "", "").toUtf8());
else if(!objectType.isEmpty())
namesData.append(getNameForDropping(item->text(ColumnSchema), item->text(ColumnName), ""));
namesData.append(getNameForDropping(item->text(ColumnSchema), item->text(ColumnName), "").toUtf8());
if(objectType != "field" && index.column() == ColumnSQL)
{
// Add the SQL code used to create the object
sqlData.append(data(index, Qt::DisplayRole).toString() + ";\n");
sqlData.append(data(index, Qt::DisplayRole).toByteArray() + ";\n");
// If it is a table also add the content
if(objectType == "table")
@@ -254,7 +254,7 @@ QMimeData* DbStructureModel::mimeData(const QModelIndexList& indices) const
insertStatement += QString("'%1',").arg(tableModel.data(tableModel.index(i, j), Qt::EditRole).toString());
insertStatement.chop(1);
insertStatement += ");\n";
sqlData.append(insertStatement);
sqlData.append(insertStatement.toUtf8());
}
}
}
+1 -1
View File
@@ -1166,7 +1166,7 @@ void EditDialog::openPrintDialog()
QPrinter printer;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
connect(dialog, &QPrintPreviewDialog::paintRequested, [this](QPrinter *previewPrinter) {
connect(dialog, &QPrintPreviewDialog::paintRequested, this, [this](QPrinter *previewPrinter) {
QTextDocument document;
switch (dataSource) {
case SciBuffer:
+2 -2
View File
@@ -75,7 +75,7 @@ EditIndexDialog::EditIndexDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
}
// Add event handler for index column name changes. These are only allowed for expression columns, though.
connect(ui->tableIndexColumns, &QTableWidget::itemChanged,
connect(ui->tableIndexColumns, &QTableWidget::itemChanged, this,
[=](QTableWidgetItem* item)
{
index.fields[static_cast<size_t>(item->row())].setName(item->text().toStdString());
@@ -166,7 +166,7 @@ void EditIndexDialog::updateColumnLists()
order->addItem("DESC");
order->setCurrentText(QString::fromStdString(indexFields.at(i).order()).toUpper());
ui->tableIndexColumns->setCellWidget(static_cast<int>(i), 1, order);
connect(order, &QComboBox::currentTextChanged,
connect(order, &QComboBox::currentTextChanged, this,
[=](QString new_order)
{
auto colnum = sqlb::findField(index, indexFields.at(i).name());
+8 -8
View File
@@ -58,10 +58,10 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
constraint_menu->addAction(ui->actionAddForeignKey);
constraint_menu->addAction(ui->actionAddUniqueConstraint);
constraint_menu->addAction(ui->actionAddCheckConstraint);
connect(ui->actionAddPrimaryKey, &QAction::triggered, [this]() { addConstraint(sqlb::Constraint::PrimaryKeyConstraintType); });
connect(ui->actionAddForeignKey, &QAction::triggered, [this]() { addConstraint(sqlb::Constraint::ForeignKeyConstraintType); });
connect(ui->actionAddUniqueConstraint, &QAction::triggered, [this]() { addConstraint(sqlb::Constraint::UniqueConstraintType); });
connect(ui->actionAddCheckConstraint, &QAction::triggered, [this]() { addConstraint(sqlb::Constraint::CheckConstraintType); });
connect(ui->actionAddPrimaryKey, &QAction::triggered, this, [this]() { addConstraint(sqlb::Constraint::PrimaryKeyConstraintType); });
connect(ui->actionAddForeignKey, &QAction::triggered, this, [this]() { addConstraint(sqlb::Constraint::ForeignKeyConstraintType); });
connect(ui->actionAddUniqueConstraint, &QAction::triggered, this, [this]() { addConstraint(sqlb::Constraint::UniqueConstraintType); });
connect(ui->actionAddCheckConstraint, &QAction::triggered, this, [this]() { addConstraint(sqlb::Constraint::CheckConstraintType); });
ui->buttonAddConstraint->setMenu(constraint_menu);
// Get list of all collations
@@ -106,7 +106,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
}
// Enable/disable remove constraint button depending on whether a constraint is selected
connect(ui->tableConstraints, &QTableWidget::itemSelectionChanged, [this]() {
connect(ui->tableConstraints, &QTableWidget::itemSelectionChanged, this, [this]() {
bool hasSelection = ui->tableConstraints->selectionModel()->hasSelection();
ui->buttonRemoveConstraint->setEnabled(hasSelection);
});
@@ -119,7 +119,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
updateColumnWidth();
// Allow editing of constraint columns by double clicking the columns column of the constraints table
connect(ui->tableConstraints, &QTableWidget::itemDoubleClicked, [this](QTableWidgetItem* item) {
connect(ui->tableConstraints, &QTableWidget::itemDoubleClicked, this, [this](QTableWidgetItem* item) {
// Check whether the double clicked item is in the columns column
if(item->column() == kConstraintColumns)
{
@@ -137,7 +137,7 @@ EditTableDialog::EditTableDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier&
dialog->show();
// When clicking the Apply button in the popup dialog, save the new columns list
connect(dialog, &SelectItemsPopup::accepted, [this, dialog, constraint]() {
connect(dialog, &SelectItemsPopup::accepted, this, [this, dialog, constraint]() {
// Check if column selection changed at all
sqlb::StringVector new_columns = dialog->selectedItems();
if(constraint->columnList() != new_columns)
@@ -292,7 +292,7 @@ void EditTableDialog::populateConstraints()
type->addItem(tr("Foreign Key"));
type->addItem(tr("Check"));
type->setCurrentIndex(constraint->type());
connect(type, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this, type, constraint](int index) {
connect(type, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this, type, constraint](int index) {
// Handle change of constraint type. Effectively this means removing the old constraint and replacing it by an entirely new one.
// Only the column list and the name can be migrated to the new constraint.
+7 -3
View File
@@ -89,7 +89,11 @@ void ExtendedScintilla::updateLineNumberAreaWidth()
// Calculate the width of this number if it was all zeros (this is because a 1 might require less space than a 0 and this could
// cause some flickering depending on the font) and set the new margin width.
#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
setMarginWidth(0, QFontMetrics(font()).width(QString("0").repeated(digits)) + 5);
#else
setMarginWidth(0, QFontMetrics(font()).horizontalAdvance(QString("0").repeated(digits)) + 5);
#endif
}
void ExtendedScintilla::dropEvent(QDropEvent* e)
@@ -138,8 +142,8 @@ void ExtendedScintilla::reloadCommonSettings()
setMarginsForegroundColor(QPalette().color(QPalette::Active, QPalette::WindowText));
break;
case Settings::DarkStyle :
setMarginsBackgroundColor(QColor("#32414B"));
setMarginsForegroundColor(QColor("#EFF0F1"));
setMarginsBackgroundColor(QColor(0x32, 0x41, 0x4B));
setMarginsForegroundColor(QColor(0xEF, 0xF0, 0xF1));
break;
}
setPaper(Settings::getValue("syntaxhighlighter", "background_colour").toString());
@@ -304,7 +308,7 @@ void ExtendedScintilla::openPrintDialog()
QsciPrinter printer;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
connect(dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter *previewPrinter) {
connect(dialog, &QPrintPreviewDialog::paintRequested, this, [&](QPrinter *previewPrinter) {
QsciPrinter* sciPrinter = static_cast<QsciPrinter*>(previewPrinter);
sciPrinter->printRange(this);
});
+21 -21
View File
@@ -310,7 +310,7 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
printAction->setShortcut(QKeySequence::Print);
// Set up context menu actions
connect(this, &QTableView::customContextMenuRequested,
connect(this, &QTableView::customContextMenuRequested, this,
[=](const QPoint& pos)
{
// Deactivate context menu options if there is no model set
@@ -338,70 +338,70 @@ ExtendedTableWidget::ExtendedTableWidget(QWidget* parent) :
// Show menu
m_contextMenu->popup(viewport()->mapToGlobal(pos));
});
connect(filterAction, &QAction::triggered, [&]() {
connect(filterAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("="));
});
connect(containingAction, &QAction::triggered, [&]() {
connect(containingAction, &QAction::triggered, this, [&]() {
useAsFilter(QString (""));
});
// Use a regular expression for the not containing filter. Simplify this if we ever support the NOT LIKE filter.
connect(notContainingAction, &QAction::triggered, [&]() {
connect(notContainingAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("/^((?!"), /* binary */ false, QString (").)*$/"));
});
connect(notEqualToAction, &QAction::triggered, [&]() {
connect(notEqualToAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("<>"));
});
connect(greaterThanAction, &QAction::triggered, [&]() {
connect(greaterThanAction, &QAction::triggered, this, [&]() {
useAsFilter(QString (">"));
});
connect(lessThanAction, &QAction::triggered, [&]() {
connect(lessThanAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("<"));
});
connect(greaterEqualAction, &QAction::triggered, [&]() {
connect(greaterEqualAction, &QAction::triggered, this, [&]() {
useAsFilter(QString (">="));
});
connect(lessEqualAction, &QAction::triggered, [&]() {
connect(lessEqualAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("<="));
});
connect(inRangeAction, &QAction::triggered, [&]() {
connect(inRangeAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("~"), /* binary */ true);
});
connect(regexpAction, &QAction::triggered, [&]() {
connect(regexpAction, &QAction::triggered, this, [&]() {
useAsFilter(QString ("/"), /* binary */ false, QString ("/"));
});
connect(condFormatAction, &QAction::triggered, [&]() {
connect(condFormatAction, &QAction::triggered, this, [&]() {
emit editCondFormats(currentIndex().column());
});
connect(nullAction, &QAction::triggered, [&]() {
connect(nullAction, &QAction::triggered, this, [&]() {
setToNull(selectedIndexes());
});
connect(copyAction, &QAction::triggered, [&]() {
connect(copyAction, &QAction::triggered, this, [&]() {
copy(false, false);
});
connect(cutAction, &QAction::triggered, this, &ExtendedTableWidget::cut);
connect(copyWithHeadersAction, &QAction::triggered, [&]() {
connect(copyWithHeadersAction, &QAction::triggered, this, [&]() {
copy(true, false);
});
connect(copyAsSQLAction, &QAction::triggered, [&]() {
connect(copyAsSQLAction, &QAction::triggered, this, [&]() {
copy(false, true);
});
connect(pasteAction, &QAction::triggered, [&]() {
connect(pasteAction, &QAction::triggered, this, [&]() {
paste();
});
connect(printAction, &QAction::triggered, [&]() {
connect(printAction, &QAction::triggered, this, [&]() {
openPrintDialog();
});
// Add spreadsheet shortcuts for selecting entire columns or entire rows.
QShortcut* selectColumnShortcut = new QShortcut(QKeySequence("Ctrl+Space"), this);
connect(selectColumnShortcut, &QShortcut::activated, [this]() {
connect(selectColumnShortcut, &QShortcut::activated, this, [this]() {
if(!hasFocus() || selectionModel()->selectedIndexes().isEmpty())
return;
selectionModel()->select(QItemSelection(selectionModel()->selectedIndexes().first(), selectionModel()->selectedIndexes().last()), QItemSelectionModel::Select | QItemSelectionModel::Columns);
});
QShortcut* selectRowShortcut = new QShortcut(QKeySequence("Shift+Space"), this);
connect(selectRowShortcut, &QShortcut::activated, [this]() {
connect(selectRowShortcut, &QShortcut::activated, this, [this]() {
if(!hasFocus() || selectionModel()->selectedIndexes().isEmpty())
return;
selectionModel()->select(QItemSelection(selectionModel()->selectedIndexes().first(), selectionModel()->selectedIndexes().last()), QItemSelectionModel::Select | QItemSelectionModel::Rows);
@@ -1131,7 +1131,7 @@ void ExtendedTableWidget::openPrintDialog()
QPrinter printer;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
connect(dialog, &QPrintPreviewDialog::paintRequested, [mimeData](QPrinter *previewPrinter) {
connect(dialog, &QPrintPreviewDialog::paintRequested, this, [mimeData](QPrinter *previewPrinter) {
QTextDocument document;
document.setHtml(mimeData->html());
document.print(previewPrinter);
+17 -17
View File
@@ -116,65 +116,65 @@ void FilterLineEdit::showContextMenu(const QPoint &pos)
QMenu* filterMenu = editContextMenu->addMenu(tr("Set Filter Expression"));
QAction* whatsThisAction = new QAction(QIcon(":/icons/whatis"), tr("What's This?"), editContextMenu);
connect(whatsThisAction, &QAction::triggered, [&]() {
connect(whatsThisAction, &QAction::triggered, this, [&]() {
QWhatsThis::showText(pos, whatsThis(), this);
});
QAction* isNullAction = new QAction(tr("Is NULL"), editContextMenu);
connect(isNullAction, &QAction::triggered, [&]() {
connect(isNullAction, &QAction::triggered, this, [&]() {
setText("=NULL");
});
QAction* isNotNullAction = new QAction(tr("Is not NULL"), editContextMenu);
connect(isNotNullAction, &QAction::triggered, [&]() {
connect(isNotNullAction, &QAction::triggered, this, [&]() {
setText("<>NULL");
});
QAction* isEmptyAction = new QAction(tr("Is empty"), editContextMenu);
connect(isEmptyAction, &QAction::triggered, [&]() {
connect(isEmptyAction, &QAction::triggered, this, [&]() {
setText("=''");
});
QAction* isNotEmptyAction = new QAction(tr("Is not empty"), editContextMenu);
connect(isNotEmptyAction, &QAction::triggered, [&]() {
connect(isNotEmptyAction, &QAction::triggered, this, [&]() {
setText("<>''");
});
// Simplify this if we ever support a NOT LIKE filter
QAction* notContainingAction = new QAction(tr("Not containing..."), editContextMenu);
connect(notContainingAction, &QAction::triggered, [&]() {
connect(notContainingAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("/^((?!"), QString(").)*$/"));
});
QAction* equalToAction = new QAction(tr("Equal to..."), editContextMenu);
connect(equalToAction, &QAction::triggered, [&]() {
connect(equalToAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("="));
});
QAction* notEqualToAction = new QAction(tr("Not equal to..."), editContextMenu);
connect(notEqualToAction, &QAction::triggered, [&]() {
connect(notEqualToAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("<>"));
});
QAction* greaterThanAction = new QAction(tr("Greater than..."), editContextMenu);
connect(greaterThanAction, &QAction::triggered, [&]() {
connect(greaterThanAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString (">"));
});
QAction* lessThanAction = new QAction(tr("Less than..."), editContextMenu);
connect(lessThanAction, &QAction::triggered, [&]() {
connect(lessThanAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("<"));
});
QAction* greaterEqualAction = new QAction(tr("Greater or equal..."), editContextMenu);
connect(greaterEqualAction, &QAction::triggered, [&]() {
connect(greaterEqualAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString (">="));
});
QAction* lessEqualAction = new QAction(tr("Less or equal..."), editContextMenu);
connect(lessEqualAction, &QAction::triggered, [&]() {
connect(lessEqualAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("<="));
});
QAction* inRangeAction = new QAction(tr("In range..."), editContextMenu);
connect(inRangeAction, &QAction::triggered, [&]() {
connect(inRangeAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("?~"));
});
QAction* regexpAction = new QAction(tr("Regular expression..."), editContextMenu);
connect(regexpAction, &QAction::triggered, [&]() {
connect(regexpAction, &QAction::triggered, this, [&]() {
setFilterHelper(QString ("/"), QString ("/"));
});
@@ -184,17 +184,17 @@ void FilterLineEdit::showContextMenu(const QPoint &pos)
QAction* conditionalFormatAction;
if (text().isEmpty()) {
conditionalFormatAction = new QAction(QIcon(":/icons/clear_cond_formats"), tr("Clear All Conditional Formats"), editContextMenu);
connect(conditionalFormatAction, &QAction::triggered, [&]() {
connect(conditionalFormatAction, &QAction::triggered, this, [&]() {
emit clearAllCondFormats();
});
} else {
conditionalFormatAction = new QAction(QIcon(":/icons/add_cond_format"), tr("Use for Conditional Format"), editContextMenu);
connect(conditionalFormatAction, &QAction::triggered, [&]() {
connect(conditionalFormatAction, &QAction::triggered, this, [&]() {
emit addFilterAsCondFormat(text());
});
}
QAction* editCondFormatsAction = new QAction(QIcon(":/icons/edit_cond_formats"), tr("Edit Conditional Formats..."), editContextMenu);
connect(editCondFormatsAction, &QAction::triggered, [&]() {
connect(editCondFormatsAction, &QAction::triggered, this, [&]() {
emit editCondFormats();
});
editContextMenu->addSeparator();
+6 -4
View File
@@ -30,14 +30,14 @@ public:
layout->setMargin(0);
setLayout(layout);
connect(m_btnReset, &QPushButton::clicked, [&]
connect(m_btnReset, &QPushButton::clicked, this, [&]
{
tablesComboBox->setCurrentIndex(-1);
idsComboBox->setCurrentIndex(-1);
clauseEdit->clear();
});
connect(tablesComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
connect(tablesComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
[=](int index)
{
// reset ids combo box
@@ -100,9 +100,11 @@ QWidget* ForeignKeyEditorDelegate::createEditor(QWidget* parent, const QStyleOpt
ForeignKeyEditor* editor = new ForeignKeyEditor(parent);
editor->setAutoFillBackground(true);
connect(editor->tablesComboBox, static_cast<void(QComboBox::*)(const QString&)>(&QComboBox::currentIndexChanged),
[=](const QString& tableName)
connect(editor->tablesComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
[=](int idx)
{
QString tableName = editor->tablesComboBox->itemText(idx);
QComboBox* box = editor->idsComboBox;
box->clear();
box->addItem(QString()); // for those heroes who don't like to specify key explicitly
+17 -6
View File
@@ -11,7 +11,7 @@ ImageViewer::ImageViewer(QWidget* parent) :
ui(new Ui::ImageViewer)
{
ui->setupUi(this);
connect(ui->buttonOriginalSize, &QToolButton::clicked, [this]{ scaleImage(100); });
connect(ui->buttonOriginalSize, &QToolButton::clicked, this, [this]{ scaleImage(100); });
ui->labelView->addAction(ui->actionPrintImage);
}
@@ -43,14 +43,20 @@ void ImageViewer::openPrintImageDialog()
QPrinter printer;
QPrintPreviewDialog dialog(&printer);
connect(&dialog, &QPrintPreviewDialog::paintRequested, [&](QPrinter* previewPrinter) {
connect(&dialog, &QPrintPreviewDialog::paintRequested, &dialog, [&](QPrinter* previewPrinter) {
QPainter painter(previewPrinter);
QRect rect = painter.viewport();
QSize size = ui->labelView->pixmap()->size();
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QPixmap pixmap = *ui->labelView->pixmap();
#else
QPixmap pixmap = ui->labelView->pixmap(Qt::ReturnByValue);
#endif
QSize size = pixmap.size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(ui->labelView->pixmap()->rect());
painter.drawPixmap(0, 0, *ui->labelView->pixmap());
painter.setWindow(pixmap.rect());
painter.drawPixmap(0, 0, pixmap);
});
dialog.exec();
@@ -76,7 +82,12 @@ void ImageViewer::scaleImage(int scale)
m_scale_factor = scale / 100.0;
// Resize the image
ui->labelView->resize(m_scale_factor * ui->labelView->pixmap()->size());
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QPixmap pixmap = *ui->labelView->pixmap();
#else
QPixmap pixmap = ui->labelView->pixmap(Qt::ReturnByValue);
#endif
ui->labelView->resize(m_scale_factor * pixmap.size());
// Uncheck the fit to window button
ui->buttonFitToWindow->setChecked(false);
+1 -1
View File
@@ -13,7 +13,7 @@ class ImageViewer : public QWidget
public:
explicit ImageViewer(QWidget* parent = nullptr);
~ImageViewer();
~ImageViewer() override;
void resetImage();
void setImage(const QImage& image);
+1 -2
View File
@@ -246,8 +246,7 @@ void ImportCsvDialog::updatePreview()
// Set horizontal header data
QStringList horizontalHeader;
for(const sqlb::Field& field : fieldList)
horizontalHeader.push_back(QString::fromStdString(field.name()));
std::transform(fieldList.begin(), fieldList.end(), std::back_inserter(horizontalHeader), [](const auto& field) { return QString::fromStdString(field.name()); });
ui->tablePreview->setHorizontalHeaderLabels(horizontalHeader);
// Parse file
+55 -53
View File
@@ -103,22 +103,20 @@ void MainWindow::init()
// Automatic update check
#ifdef CHECKNEWVERSION
connect(&RemoteNetwork::get(), &RemoteNetwork::networkReady, [this]() {
// Check for a new version if automatic update check aren't disabled in the settings dialog
if(Settings::getValue("checkversion", "enabled").toBool())
{
RemoteNetwork::get().fetch(QUrl("https://download.sqlitebrowser.org/currentrelease"), RemoteNetwork::RequestTypeCustom,
QString(), [this](const QByteArray& reply) {
QList<QByteArray> info = reply.split('\n');
if(info.size() >= 2)
{
QString version = info.at(0).trimmed();
QString url = info.at(1).trimmed();
checkNewVersion(version, url);
}
});
}
});
// Check for a new version if automatic update check aren't disabled in the settings dialog
if(Settings::getValue("checkversion", "enabled").toBool())
{
RemoteNetwork::get().fetch(QUrl("https://download.sqlitebrowser.org/currentrelease"), RemoteNetwork::RequestTypeCustom,
QString(), [this](const QByteArray& reply) {
QList<QByteArray> info = reply.split('\n');
if(info.size() >= 2)
{
QString version = info.at(0).trimmed();
QString url = info.at(1).trimmed();
checkNewVersion(version, url);
}
});
}
#endif
// create facade objects to dbTreeWidgets
@@ -315,11 +313,11 @@ void MainWindow::init()
action->setObjectName(widget->accessibleName());
action->setCheckable(true);
action->setChecked(ui->mainTab->indexOf(widget) != -1);
connect(action, &QAction::toggled, [=](bool show) { toggleTabVisible(widget, show); });
connect(action, &QAction::toggled, this, [=](bool show) { toggleTabVisible(widget, show); });
// Connect tabCloseRequested for setting checked the appropriate menu entry.
// Note these are called after the actual tab is closed only because they are connected
// after connecting closeTab.
connect(ui->mainTab, &QTabWidget::tabCloseRequested, [=](int /*index*/) {
connect(ui->mainTab, &QTabWidget::tabCloseRequested, this, [=](int /*index*/) {
action->setChecked(ui->mainTab->indexOf(widget) != -1);
});
}
@@ -331,7 +329,7 @@ void MainWindow::init()
QAction* resetLayoutAction = layoutMenu->addAction(tr("Reset Window Layout"));
resetLayoutAction->setShortcut(QKeySequence(tr("Alt+0")));
connect(resetLayoutAction, &QAction::triggered, [=]() {
connect(resetLayoutAction, &QAction::triggered, this, [=]() {
restoreState(defaultWindowState);
restoreOpenTabs(defaultOpenTabs);
ui->viewDBToolbarAction->setChecked(!ui->toolbarDB->isHidden());
@@ -340,7 +338,7 @@ void MainWindow::init()
});
QAction* simplifyLayoutAction = layoutMenu->addAction(tr("Simplify Window Layout"));
simplifyLayoutAction->setShortcut(QKeySequence(tr("Shift+Alt+0")));
connect(simplifyLayoutAction, &QAction::triggered, [=]() {
connect(simplifyLayoutAction, &QAction::triggered, this, [=]() {
ui->viewMenu->findChild<QAction *>(ui->pragmas->accessibleName())->activate(QAction::Trigger);
ui->dockLog->hide();
ui->dockPlot->hide();
@@ -349,15 +347,15 @@ void MainWindow::init()
ui->dockRemote->hide();
});
QAction* atBottomLayoutAction = layoutMenu->addAction(tr("Dock Windows at Bottom"));
connect(atBottomLayoutAction, &QAction::triggered, [=]() {
connect(atBottomLayoutAction, &QAction::triggered, this, [=]() {
moveDocksTo(Qt::BottomDockWidgetArea);
});
QAction* atLeftLayoutAction = layoutMenu->addAction(tr("Dock Windows at Left Side"));
connect(atLeftLayoutAction, &QAction::triggered, [=]() {
connect(atLeftLayoutAction, &QAction::triggered, this, [=]() {
moveDocksTo(Qt::LeftDockWidgetArea);
});
QAction* atTopLayoutAction = layoutMenu->addAction(tr("Dock Windows at Top"));
connect(atTopLayoutAction, &QAction::triggered, [=]() {
connect(atTopLayoutAction, &QAction::triggered, this, [=]() {
moveDocksTo(Qt::TopDockWidgetArea);
});
@@ -365,13 +363,13 @@ void MainWindow::init()
// Note that it is safe to call setCurrentIndex with a tab that is currently closed,
// since setCurrentIndex does nothing in that case.
QShortcut* setTab1Shortcut = new QShortcut(QKeySequence("Alt+1"), this);
connect(setTab1Shortcut, &QShortcut::activated, [this]() { ui->mainTab->setCurrentIndex(0); });
connect(setTab1Shortcut, &QShortcut::activated, this, [this]() { ui->mainTab->setCurrentIndex(0); });
QShortcut* setTab2Shortcut = new QShortcut(QKeySequence("Alt+2"), this);
connect(setTab2Shortcut, &QShortcut::activated, [this]() { ui->mainTab->setCurrentIndex(1); });
connect(setTab2Shortcut, &QShortcut::activated, this, [this]() { ui->mainTab->setCurrentIndex(1); });
QShortcut* setTab3Shortcut = new QShortcut(QKeySequence("Alt+3"), this);
connect(setTab3Shortcut, &QShortcut::activated, [this]() { ui->mainTab->setCurrentIndex(2); });
connect(setTab3Shortcut, &QShortcut::activated, this, [this]() { ui->mainTab->setCurrentIndex(2); });
QShortcut* setTab4Shortcut = new QShortcut(QKeySequence("Alt+4"), this);
connect(setTab4Shortcut, &QShortcut::activated, [this]() { ui->mainTab->setCurrentIndex(3); });
connect(setTab4Shortcut, &QShortcut::activated, this, [this]() { ui->mainTab->setCurrentIndex(3); });
// If we're not compiling in SQLCipher, hide its FAQ link in the help menu
#ifndef ENABLE_SQLCIPHER
@@ -414,17 +412,17 @@ void MainWindow::init()
ui->statusbar->addPermanentWidget(statusEncodingLabel);
// When changing the text of the toolbar actions, also automatically change their icon text and their tooltip text
connect(ui->editModifyObjectAction, &QAction::changed, [=]() {
connect(ui->editModifyObjectAction, &QAction::changed, this, [=]() {
ui->editModifyObjectAction->setIconText(ui->editModifyObjectAction->text());
ui->editModifyObjectAction->setToolTip(ui->editModifyObjectAction->text());
});
connect(ui->editDeleteObjectAction, &QAction::changed, [=]() {
connect(ui->editDeleteObjectAction, &QAction::changed, this, [=]() {
ui->editDeleteObjectAction->setIconText(ui->editDeleteObjectAction->text());
ui->editDeleteObjectAction->setToolTip(ui->editDeleteObjectAction->text());
});
// When clicking the interrupt query button in the status bar, ask SQLite to interrupt the current query
connect(statusStopButton, &QToolButton::clicked, [this]() {
connect(statusStopButton, &QToolButton::clicked, this, [this]() {
db.interruptQuery();
});
@@ -442,27 +440,27 @@ void MainWindow::init()
ui->actionDropQualifiedCheck->setChecked(Settings::getValue("SchemaDock", "dropQualifiedNames").toBool());
ui->actionEnquoteNamesCheck->setChecked(Settings::getValue("SchemaDock", "dropEnquotedNames").toBool());
connect(ui->actionSqlStop, &QAction::triggered, [this]() {
connect(ui->actionSqlStop, &QAction::triggered, this, [this]() {
if(execute_sql_worker && execute_sql_worker->isRunning())
execute_sql_worker->stop();
});
// Connect tool pragmas
connect(ui->actionIntegrityCheck, &QAction::triggered, [this]() {
connect(ui->actionIntegrityCheck, &QAction::triggered, this, [this]() {
runSqlNewTab("PRAGMA integrity_check;", ui->actionIntegrityCheck->text(), "https://www.sqlite.org/pragma.html#pragma_integrity_check");
});
connect(ui->actionQuickCheck, &QAction::triggered, [this]() {
connect(ui->actionQuickCheck, &QAction::triggered, this, [this]() {
runSqlNewTab("PRAGMA quick_check;", ui->actionQuickCheck->text(), "https://www.sqlite.org/pragma.html#pragma_quick_check");
});
connect(ui->actionForeignKeyCheck, &QAction::triggered, [this]() {
connect(ui->actionForeignKeyCheck, &QAction::triggered, this, [this]() {
runSqlNewTab("PRAGMA foreign_key_check;", ui->actionForeignKeyCheck->text(), "https://www.sqlite.org/pragma.html#pragma_foreign_key_check");
});
connect(ui->actionOptimize, &QAction::triggered, [this]() {
connect(ui->actionOptimize, &QAction::triggered, this, [this]() {
runSqlNewTab("PRAGMA optimize;", ui->actionOptimize->text(), "https://www.sqlite.org/pragma.html#pragma_optimize");
});
// Action for switching the table via the Database Structure tab
connect(ui->actionPopupSchemaDockBrowseTable, &QAction::triggered, [this]() {
connect(ui->actionPopupSchemaDockBrowseTable, &QAction::triggered, this, [this]() {
switchToBrowseDataTab(dockDbSelected->object());
refresh(); // Required in case the Browse Data tab already was the active main tab
});
@@ -968,13 +966,13 @@ void MainWindow::editObject()
refreshTableBrowsers();
} else if(type == "view") {
sqlb::ViewPtr view = db.getObjectByName<sqlb::View>(obj);
runSqlNewTab(QString("DROP VIEW %1;\n%2").arg(QString::fromStdString(obj.toString())).arg(QString::fromStdString(view->sql())),
runSqlNewTab(QString("DROP VIEW %1;\n%2").arg(QString::fromStdString(obj.toString()), QString::fromStdString(view->sql())),
tr("Edit View %1").arg(QString::fromStdString(obj.toDisplayString())),
"https://www.sqlite.org/lang_createview.html",
/* autoRun */ false);
} else if(type == "trigger") {
sqlb::TriggerPtr trigger = db.getObjectByName<sqlb::Trigger>(obj);
runSqlNewTab(QString("DROP TRIGGER %1;\n%2").arg(QString::fromStdString(obj.toString())).arg(QString::fromStdString(trigger->sql())),
runSqlNewTab(QString("DROP TRIGGER %1;\n%2").arg(QString::fromStdString(obj.toString()), QString::fromStdString(trigger->sql())),
tr("Edit Trigger %1").arg(QString::fromStdString(obj.toDisplayString())),
"https://www.sqlite.org/lang_createtrigger.html",
/* autoRun */ false);
@@ -1241,7 +1239,7 @@ void MainWindow::executeQuery()
// Wait until the initial loading of data (= first chunk and row count) has been performed
auto conn = std::make_shared<QMetaObject::Connection>();
*conn = connect(model, &SqliteTableModel::finishedFetch, [=](int fetched_row_begin, int fetched_row_end) {
*conn = connect(model, &SqliteTableModel::finishedFetch, this, [=](int fetched_row_begin, int fetched_row_end) {
// Avoid attaching the plot when the signal is notifying the row count, since the
// data wouldn't be available yet.
if(fetched_row_begin != fetched_row_end && fetched_row_begin != model->rowCount()) {
@@ -2108,7 +2106,7 @@ void MainWindow::openSqlFile()
tr("Select SQL file to open"),
tr("Text files(*.sql *.txt);;All files(*)"));
for(QString file: wfiles)
for(const QString& file: wfiles)
{
if(QFile::exists(file))
{
@@ -2300,7 +2298,7 @@ void MainWindow::reloadSettings()
db.loadExtensionsFromSettings();
// Refresh view
db.structureUpdated();
emit db.structureUpdated();
refreshTableBrowsers();
// Hide or show the remote dock as needed
@@ -2854,7 +2852,7 @@ static void saveCondFormatMap(const QString& elementName, const BrowseDataTableS
for(auto iter=condFormats.cbegin(); iter!=condFormats.cend(); ++iter) {
xml.writeStartElement("column");
xml.writeAttribute("index", QString::number(iter->first));
for(auto format : iter->second) {
for(const auto& format : iter->second) {
xml.writeStartElement("format");
xml.writeAttribute("condition", format.filter());
xml.writeAttribute("background", format.backgroundColor().name());
@@ -3511,7 +3509,7 @@ void MainWindow::printDbStructure ()
printer.setDocName(treeView->windowTitle());
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(&printer);
connect(dialog, &QPrintPreviewDialog::paintRequested, [strStream](QPrinter *previewPrinter) {
connect(dialog, &QPrintPreviewDialog::paintRequested, this, [strStream](QPrinter *previewPrinter) {
QTextDocument document;
document.setHtml(strStream);
document.print(previewPrinter);
@@ -3529,7 +3527,6 @@ void MainWindow::updateDatabaseBusyStatus(bool busy, const QString& user)
statusStopButton->setVisible(busy);
}
void MainWindow::closeTab(int index)
{
ui->mainTab->removeTab(index);
@@ -3547,7 +3544,11 @@ void MainWindow::restoreOpenTabs(QString tabs)
{
// Split the tab list, skipping the empty parts so the empty string turns to an empty list
// and not a list of one empty string.
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList tabList = tabs.split(' ', QString::SkipEmptyParts);
#else
QStringList tabList = tabs.split(' ', Qt::SkipEmptyParts);
#endif
// Clear the tabs and then add them in the order specified by the setting.
// Use the accessibleName attribute for restoring the tab label.
@@ -3606,13 +3607,13 @@ void MainWindow::showContextMenuSqlTabBar(const QPoint& pos)
// Prepare all menu actions
QAction* actionRename = new QAction(this);
actionRename->setText(tr("Rename Tab"));
connect(actionRename, &QAction::triggered, [this, tab]() {
connect(actionRename, &QAction::triggered, this, [this, tab]() {
renameSqlTab(tab);
});
QAction* actionDuplicate = new QAction(this);
actionDuplicate->setText(tr("Duplicate Tab"));
connect(actionDuplicate, &QAction::triggered, [this, tab]() {
connect(actionDuplicate, &QAction::triggered, this, [this, tab]() {
QString tab_name = ui->tabSqlAreas->tabText(tab).remove("&").remove(QRegExp(" \\(\\d+\\)$"));
QString new_tab_name;
for(int i=1;;i++)
@@ -3643,7 +3644,7 @@ void MainWindow::showContextMenuSqlTabBar(const QPoint& pos)
QAction* actionClose = new QAction(this);
actionClose->setText(tr("Close Tab"));
actionClose->setShortcut(tr("Ctrl+W"));
connect(actionClose, &QAction::triggered, [this, tab]() {
connect(actionClose, &QAction::triggered, this, [this, tab]() {
closeSqlTab(tab);
});
@@ -3712,8 +3713,9 @@ void MainWindow::tableBrowserTabClosed()
// If the currently active tab is closed activate another tab
if(currentTableBrowser && sender() == currentTableBrowser->parent())
{
allTableBrowserDocks().front()->activateWindow();
changeTableBrowserTab(allTableBrowserDocks().front());
auto all_docks = allTableBrowserDocks();
all_docks.front()->activateWindow();
changeTableBrowserTab(all_docks.front());
}
}
}
@@ -3729,7 +3731,7 @@ TableBrowserDock* MainWindow::newTableBrowserTab(const sqlb::ObjectIdentifier& t
d->tableBrowser()->setEnabled(ui->fileCloseAction->isEnabled());
// Connect signals and slots
connect(d, &TableBrowserDock::newDockRequested, [this]() {
connect(d, &TableBrowserDock::newDockRequested, this, [this]() {
newTableBrowserTab();
});
connect(d->tableBrowser(), &TableBrowser::projectModified, this, [this]() {
@@ -3747,13 +3749,13 @@ TableBrowserDock* MainWindow::newTableBrowserTab(const sqlb::ObjectIdentifier& t
connect(d->tableBrowser(), &TableBrowser::statusMessageRequested, ui->statusbar, [this](const QString& message) {
ui->statusbar->showMessage(message);
});
connect(d->tableBrowser(), &TableBrowser::foreignKeyClicked, [this](const sqlb::ObjectIdentifier& table, std::string column, const QByteArray& value) {
connect(d->tableBrowser(), &TableBrowser::foreignKeyClicked, this, [this](const sqlb::ObjectIdentifier& table, std::string column, const QByteArray& value) {
TableBrowserDock* foreign_key_dock = newTableBrowserTab(table);
foreign_key_dock->tableBrowser()->jumpToRow(table, column, value);
Application::processEvents(); // For some reason this is required for raise() to work here.
foreign_key_dock->raise();
});
connect(d->tableBrowser()->model(), &SqliteTableModel::finishedFetch, [this, d](){
connect(d->tableBrowser()->model(), &SqliteTableModel::finishedFetch, this, [this, d](){
auto& settings = d->tableBrowser()->settings(d->tableBrowser()->currentlyBrowsedTableName());
plotDock->updatePlot(d->tableBrowser()->model(), &settings, true, false);
});
@@ -3761,7 +3763,7 @@ TableBrowserDock* MainWindow::newTableBrowserTab(const sqlb::ObjectIdentifier& t
// Set up dock and add it to the tab
ui->tabBrowsers->addDockWidget(Qt::TopDockWidgetArea, d);
if(allTableBrowserDocks().size() > 1)
ui->tabBrowsers->tabifyDockWidget(allTableBrowserDocks().front(), d);
ui->tabBrowsers->tabifyDockWidget(allTableBrowserDocks().constFirst(), d);
// Set current model and browser
d->activateWindow();
+3 -3
View File
@@ -75,14 +75,14 @@ PlotDock::PlotDock(QWidget* parent)
QAction* copyAction = new QAction(QIcon(":/icons/copy"), tr("Copy"), m_contextMenu);
copyAction->setShortcut(shortcutCopy->key());
m_contextMenu->addAction(copyAction);
connect(copyAction, &QAction::triggered, [&]() {
connect(copyAction, &QAction::triggered, this, [&]() {
copy();
});
QAction* printAction = new QAction(QIcon(":/icons/print"), tr("Print..."), m_contextMenu);
printAction->setShortcut(shortcutPrint->key());
m_contextMenu->addAction(printAction);
connect(printAction, &QAction::triggered, [&]() {
connect(printAction, &QAction::triggered, this, [&]() {
openPrintDialog();
});
@@ -109,7 +109,7 @@ PlotDock::PlotDock(QWidget* parent)
ui->plotWidget->replot();
});
connect(ui->plotWidget, &QTableView::customContextMenuRequested,
connect(ui->plotWidget, &QTableView::customContextMenuRequested, this,
[=](const QPoint& pos) {
// Show menu
m_contextMenu->popup(ui->plotWidget->mapToGlobal(pos));
+3 -2
View File
@@ -356,10 +356,11 @@ void PreferencesDialog::saveSettings(bool accept)
void PreferencesDialog::showColourDialog(QTreeWidgetItem* item, int column)
{
if(item->text(column).left(1) != "#")
QString text = item->text(column);
if(!text.size() || text.at(0) != '#')
return;
QColor colour = QColorDialog::getColor(QColor(item->text(column)), this);
QColor colour = QColorDialog::getColor(text, this);
if(colour.isValid())
{
item->setForeground(column, colour);
+1 -1
View File
@@ -13,7 +13,7 @@ class ProxyDialog : public QDialog
public:
explicit ProxyDialog(QWidget* parent = nullptr);
~ProxyDialog();
~ProxyDialog() override;
void saveSettings() const;
+14 -14
View File
@@ -53,7 +53,7 @@ RemoteDock::RemoteDock(MainWindow* parent)
// When the Preferences link is clicked in the no-certificates-label, open the preferences dialog. For other links than the ones we know,
// just open them in a web browser
connect(ui->labelNoCert, &QLabel::linkActivated, [this](const QString& link) {
connect(ui->labelNoCert, &QLabel::linkActivated, this, [this](const QString& link) {
if(link == "#preferences")
{
PreferencesDialog dialog(mainWindow, PreferencesDialog::TabRemote);
@@ -65,13 +65,13 @@ RemoteDock::RemoteDock(MainWindow* parent)
});
// When changing the current branch in the branches combo box, update the tree view accordingly
connect(ui->comboDatabaseBranch, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this](int /*index*/) {
connect(ui->comboDatabaseBranch, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, [this](int /*index*/) {
remoteCommitsModel->refresh(current_commit_json, ui->comboDatabaseBranch->currentData().toString().toStdString(), currently_opened_file_info.commit_id);
ui->treeDatabaseCommits->expandAll();
});
// Fetch latest commit action
connect(ui->actionFetchLatestCommit, &QAction::triggered, [this]() {
connect(ui->actionFetchLatestCommit, &QAction::triggered, this, [this]() {
// Fetch last commit of current branch
// The URL and the branch name is that of the currently opened database file.
// The latest commit id is stored in the data bits of the branch combo box.
@@ -85,20 +85,20 @@ RemoteDock::RemoteDock(MainWindow* parent)
});
// Prepare context menu for list of remote databases
connect(ui->treeRemote->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex& index, const QModelIndex&) {
connect(ui->treeRemote->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex& index, const QModelIndex&) {
// Only enable database actions when a database was selected
bool enable = index.isValid() &&
remoteModel->modelIndexToItem(index)->value(RemoteModelColumnType).toString() == "database";
ui->actionCloneDatabaseDoubleClick->setEnabled(enable);
});
ui->treeRemote->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionCloneDatabaseDoubleClick, &QAction::triggered, [this]() {
emit ui->treeRemote->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionCloneDatabaseDoubleClick, &QAction::triggered, this, [this]() {
fetchDatabase(ui->treeRemote->currentIndex());
});
ui->treeRemote->addAction(ui->actionCloneDatabaseDoubleClick);
// Prepare context menu for list of local clones
connect(ui->treeLocal->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex& index, const QModelIndex&) {
connect(ui->treeLocal->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex& index, const QModelIndex&) {
// Only enable database actions when a database was selected
bool enable = index.isValid() &&
!index.sibling(index.row(), RemoteLocalFilesModel::ColumnFile).data().isNull();
@@ -106,11 +106,11 @@ RemoteDock::RemoteDock(MainWindow* parent)
ui->actionPushLocalDatabase->setEnabled(enable);
ui->actionDeleteDatabase->setEnabled(enable);
});
ui->treeLocal->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionOpenLocalDatabase, &QAction::triggered, [this]() {
emit ui->treeLocal->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionOpenLocalDatabase, &QAction::triggered, this, [this]() {
openLocalFile(ui->treeLocal->currentIndex());
});
connect(ui->actionDeleteDatabase, &QAction::triggered, [this]() {
connect(ui->actionDeleteDatabase, &QAction::triggered, this, [this]() {
deleteLocalDatabase(ui->treeLocal->currentIndex());
});
ui->treeLocal->addAction(ui->actionOpenLocalDatabase);
@@ -118,17 +118,17 @@ RemoteDock::RemoteDock(MainWindow* parent)
ui->treeLocal->addAction(ui->actionDeleteDatabase);
// Prepare context menu for list of commits
connect(ui->treeDatabaseCommits->selectionModel(), &QItemSelectionModel::currentChanged, [this](const QModelIndex& index, const QModelIndex&) {
connect(ui->treeDatabaseCommits->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex& index, const QModelIndex&) {
// Only enable database actions when a commit was selected
bool enable = index.isValid();
ui->actionFetchCommit->setEnabled(enable);
ui->actionDownloadCommit->setEnabled(enable);
});
ui->treeDatabaseCommits->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionFetchCommit, &QAction::triggered, [this]() {
emit ui->treeDatabaseCommits->selectionModel()->currentChanged(QModelIndex(), QModelIndex()); // Enable/disable all action initially
connect(ui->actionFetchCommit, &QAction::triggered, this, [this]() {
fetchCommit(ui->treeDatabaseCommits->currentIndex());
});
connect(ui->actionDownloadCommit, &QAction::triggered, [this]() {
connect(ui->actionDownloadCommit, &QAction::triggered, this, [this]() {
fetchCommit(ui->treeDatabaseCommits->currentIndex(), RemoteNetwork::RequestTypeDownload);
});
ui->treeDatabaseCommits->addAction(ui->actionFetchCommit);
+4 -25
View File
@@ -1,6 +1,5 @@
#include <QApplication>
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkConfigurationManager>
#include <QMessageBox>
#include <QtNetwork/QNetworkReply>
#include <QFile>
@@ -27,18 +26,10 @@ using json = nlohmann::json;
RemoteNetwork::RemoteNetwork() :
m_manager(new QNetworkAccessManager),
m_configurationManager(new QNetworkConfigurationManager),
m_progress(nullptr)
m_progress(nullptr),
m_sslConfiguration(QSslConfiguration::defaultConfiguration())
{
// Update network configurations
connect(m_configurationManager, &QNetworkConfigurationManager::updateCompleted, [this]() {
m_manager->setConfiguration(m_configurationManager->defaultConfiguration());
emit networkReady();
});
// Set up SSL configuration
m_sslConfiguration = QSslConfiguration::defaultConfiguration();
m_sslConfiguration.setPeerVerifyMode(QSslSocket::VerifyPeer);
// Load CA certs from resource file
@@ -228,6 +219,8 @@ void RemoteNetwork::gotReply(QNetworkReply* reply)
file.close();
}
break;
case RequestTypeCustom:
break;
}
// Delete reply later, i.e. after returning from this slot function
@@ -384,13 +377,6 @@ void RemoteNetwork::prepareProgressDialog(QNetworkReply* reply, bool upload, con
void RemoteNetwork::fetch(const QUrl& url, RequestType type, const QString& clientCert,
std::function<void(QByteArray)> when_finished, bool synchronous, bool ignore_errors)
{
// Check if network is accessible. If not, abort right here
if(m_manager->networkAccessible() == QNetworkAccessManager::NotAccessible)
{
QMessageBox::warning(nullptr, qApp->applicationName(), tr("Error: The network is not accessible."));
return;
}
// Build network request
QNetworkRequest request;
request.setUrl(url);
@@ -450,13 +436,6 @@ void RemoteNetwork::push(const QString& filename, const QUrl& url, const QString
const QString& commitMessage, const QString& licence, bool isPublic, const QString& branch,
bool forcePush, const QString& last_commit)
{
// Check if network is accessible. If not, abort right here
if(m_manager->networkAccessible() == QNetworkAccessManager::NotAccessible)
{
QMessageBox::warning(nullptr, qApp->applicationName(), tr("Error: The network is not accessible."));
return;
}
// Open the file to send and check if it exists
QFile* file = new QFile(filename);
if(!file->open(QFile::ReadOnly))
-6
View File
@@ -8,7 +8,6 @@
#include <map>
class QNetworkAccessManager;
class QNetworkConfigurationManager;
class QNetworkReply;
class QProgressDialog;
class QNetworkRequest;
@@ -53,10 +52,6 @@ public:
const QString& branch = QString("master"), bool forcePush = false, const QString& last_commit = QString());
signals:
// As soon as you can safely open a network connection, this signal is emitted. This can be used to delay early network requests
// which might otherwise fail.
void networkReady();
// The fetchFinished() signal is emitted when a fetch() call for a database is finished
void fetchFinished(QString filename, QString identity, const QUrl& url, std::string new_commit_id, std::string branch,
QDateTime last_modified, QIODevice* device);
@@ -88,7 +83,6 @@ private:
bool handleReply(QNetworkReply* reply);
QNetworkAccessManager* m_manager;
QNetworkConfigurationManager* m_configurationManager;
QProgressDialog* m_progress;
QSslConfiguration m_sslConfiguration;
std::map<QString, QSslCertificate> m_clientCertFiles;
+2 -2
View File
@@ -19,7 +19,7 @@ class SelectItemsPopup : public QDialog
public:
explicit SelectItemsPopup(const std::vector<std::string>& available, const std::vector<std::string>& selected = {}, QWidget* parent = nullptr);
~SelectItemsPopup();
~SelectItemsPopup() override;
std::vector<std::string> selectedItems() const;
@@ -33,7 +33,7 @@ private slots:
void moveItemDown();
protected:
void resizeEvent(QResizeEvent* ev);
void resizeEvent(QResizeEvent* ev) override;
private:
Ui::SelectItemsPopup* ui;
+16 -16
View File
@@ -20,12 +20,12 @@ static bool ends_with(const std::string& str, const std::string& with)
return str.rfind(with) == str.size() - with.size();
}
void Settings::setUserSettingsFile(const QString userSettingsFileArg)
void Settings::setUserSettingsFile(const QString& userSettingsFileArg)
{
userSettingsFile = userSettingsFileArg;
}
bool Settings::isVaildSettingsFile(const QString userSettingsFile)
bool Settings::isVaildSettingsFile(const QString& userSettingsFile)
{
/*
Variable that stores whether or not the settings file requested by the user is a normal settings file
@@ -482,17 +482,17 @@ QColor Settings::getDefaultColorValue(const std::string& group, const std::strin
break;
case DarkStyle :
if(name == "null_fg_colour")
return QColor("#787878");
return QColor(0x78, 0x78, 0x78);
if(name == "null_bg_colour")
return QColor("#19232D");
return QColor(0x19, 0x23, 0x2D);
if(name == "reg_fg_colour")
return QColor("#F0F0F0");
return QColor(0xF0, 0xF0, 0xF0);
if(name == "reg_bg_colour")
return QColor("#19232D");
return QColor(0x19, 0x23, 0x2D);
if(name == "bin_fg_colour")
return QColor("#787878");
return QColor(0x78, 0x78, 0x78);
if(name == "bin_bg_colour")
return QColor("#19232D");
return QColor(0x19, 0x23, 0x2D);
break;
}
}
@@ -512,8 +512,8 @@ QColor Settings::getDefaultColorValue(const std::string& group, const std::strin
foregroundColour = QPalette().color(QPalette::Active, QPalette::Text);
break;
case DarkStyle :
foregroundColour = QColor("#F0F0F0");
backgroundColour = QColor("#19232D");
foregroundColour = QColor(0xF0, 0xF0, 0xF0);
backgroundColour = QColor(0x19, 0x23, 0x2D);
break;
}
if(name == "foreground_colour")
@@ -584,16 +584,16 @@ void Settings::restoreDefaults ()
m_hCache.clear();
}
void Settings::exportSettings(const QString fileName)
void Settings::exportSettings(const QString& fileName)
{
QSettings* exportSettings = new QSettings(fileName, QSettings::IniFormat);
const QStringList groups = settings->childGroups();
foreach(QString currentGroup, groups)
for(const QString& currentGroup : groups)
{
settings->beginGroup(currentGroup);
const QStringList keys = settings->childKeys();
foreach(QString currentKey, keys)
for(const QString& currentKey : keys)
{
exportSettings->beginGroup(currentGroup);
exportSettings->setValue(currentKey, getValue((currentGroup.toStdString()), (currentKey.toStdString())));
@@ -603,7 +603,7 @@ void Settings::exportSettings(const QString fileName)
}
}
bool Settings::importSettings(const QString fileName)
bool Settings::importSettings(const QString& fileName)
{
if(!isVaildSettingsFile(fileName))
return false;
@@ -611,11 +611,11 @@ bool Settings::importSettings(const QString fileName)
QSettings* importSettings = new QSettings(fileName, QSettings::IniFormat);
const QStringList groups = importSettings->childGroups();
for(const QString currentGroup : groups)
for(const QString& currentGroup : groups)
{
importSettings->beginGroup(currentGroup);
const QStringList keys = importSettings->childKeys();
for(const QString currentKey : keys)
for(const QString& currentKey : keys)
{
settings->beginGroup(currentGroup);
settings->setValue(currentKey, importSettings->value(currentKey));
+4 -4
View File
@@ -15,15 +15,15 @@ public:
DarkStyle
};
static void setUserSettingsFile(const QString userSettingsFileArg);
static void setUserSettingsFile(const QString& userSettingsFileArg);
static QVariant getValue(const std::string& group, const std::string& name);
static void setValue(const std::string& group, const std::string& name, const QVariant& value, bool dont_save_to_disk = false);
static void clearValue(const std::string& group, const std::string& name);
static void restoreDefaults();
static void rememberDefaultFontSize(int size) { m_defaultFontSize = size; }
static void exportSettings(const QString fileName);
static bool importSettings(const QString fileName);
static void exportSettings(const QString& fileName);
static bool importSettings(const QString& fileName);
static void sync();
private:
@@ -43,7 +43,7 @@ private:
static QSettings* settings;
// This works verify that the settings file provided by the user is a normal settings file
static bool isVaildSettingsFile(const QString userSettingsFile);
static bool isVaildSettingsFile(const QString& userSettingsFile);
// This works initialize QSettings object
static void setSettingsObject();
+17 -14
View File
@@ -67,10 +67,10 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
popupHeaderMenu->addAction(ui->actionSetTableEncoding);
popupHeaderMenu->addAction(ui->actionSetAllTablesEncoding);
connect(ui->actionSelectColumn, &QAction::triggered, [this]() {
connect(ui->actionSelectColumn, &QAction::triggered, this, [this]() {
ui->dataTable->selectColumn(ui->actionBrowseTableEditDisplayFormat->property("clicked_column").toInt());
});
connect(ui->actionFreezeColumns, &QAction::triggered, [this](bool checked) {
connect(ui->actionFreezeColumns, &QAction::triggered, this, [this](bool checked) {
if(checked)
freezeColumns(ui->actionBrowseTableEditDisplayFormat->property("clicked_column").toUInt() + 1);
else
@@ -79,13 +79,13 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
// Set up shortcuts
QShortcut* dittoRecordShortcut = new QShortcut(QKeySequence("Ctrl+\""), this);
connect(dittoRecordShortcut, &QShortcut::activated, [this]() {
connect(dittoRecordShortcut, &QShortcut::activated, this, [this]() {
int currentRow = ui->dataTable->currentIndex().row();
duplicateRecord(currentRow);
});
// Lambda function for keyboard shortcuts for selecting next/previous table in Browse Data tab
connect(ui->dataTable, &ExtendedTableWidget::switchTable, [this](bool next) {
connect(ui->dataTable, &ExtendedTableWidget::switchTable, this, [this](bool next) {
int index = ui->comboBrowseTable->currentIndex();
int num_items = ui->comboBrowseTable->count();
if(next)
@@ -120,10 +120,13 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
// Set up global filter
connect(ui->editGlobalFilter, &FilterLineEdit::delayedTextChanged, this, [this](const QString& value) {
// Split up filter values
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList values = value.trimmed().split(" ", QString::SkipEmptyParts);
#else
QStringList values = value.trimmed().split(" ", Qt::SkipEmptyParts);
#endif
std::vector<QString> filters;
for(const auto& s : values)
filters.push_back(s);
std::copy(values.begin(), values.end(), std::back_inserter(filters));
// Have they changed?
BrowseDataTableSettings& settings = m_settings[currentlyBrowsedTableName()];
@@ -151,7 +154,7 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
connect(ui->dataTable, &ExtendedTableWidget::openFileFromDropEvent, this, &TableBrowser::requestFileOpen);
connect(ui->dataTable, &ExtendedTableWidget::selectedRowsToBeDeleted, this, &TableBrowser::deleteRecord);
connect(ui->dataTable, &ExtendedTableWidget::foreignKeyClicked, [this](const sqlb::ObjectIdentifier& table, const std::string& column, const QByteArray& value) {
connect(ui->dataTable, &ExtendedTableWidget::foreignKeyClicked, this, [this](const sqlb::ObjectIdentifier& table, const std::string& column, const QByteArray& value) {
// Just select the column that was just clicked instead of selecting an entire range which
// happens because of the Ctrl and Shift keys.
ui->dataTable->selectionModel()->select(ui->dataTable->currentIndex(), QItemSelectionModel::ClearAndSelect);
@@ -289,7 +292,7 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
QShortcut* shortcutActionFind = new QShortcut(QKeySequence("Ctrl+F"), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut);
connect(shortcutActionFind, &QShortcut::activated, ui->actionFind, &QAction::trigger);
connect(ui->actionFind, &QAction::triggered, [this](bool checked) {
connect(ui->actionFind, &QAction::triggered, this, [this](bool checked) {
if(checked)
{
ui->widgetReplace->hide();
@@ -303,7 +306,7 @@ TableBrowser::TableBrowser(DBBrowserDB* _db, QWidget* parent) :
QShortcut* shortcutActionReplace = new QShortcut(QKeySequence("Ctrl+H"), this, nullptr, nullptr, Qt::WidgetWithChildrenShortcut);
connect(shortcutActionReplace, &QShortcut::activated, ui->actionReplace, &QAction::trigger);
connect(ui->actionReplace, &QAction::triggered, [this](bool checked) {
connect(ui->actionReplace, &QAction::triggered, this, [this](bool checked) {
if(checked)
{
ui->widgetReplace->show();
@@ -462,7 +465,7 @@ void TableBrowser::refresh()
{
ui->dataTable->setModel(m_model);
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::currentChanged, this, &TableBrowser::selectionChanged);
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, [this](const QItemSelection&, const QItemSelection&) {
connect(ui->dataTable->selectionModel(), &QItemSelectionModel::selectionChanged, this, [this](const QItemSelection&, const QItemSelection&) {
updateInsertDeleteRecordButton();
const QModelIndexList& sel = ui->dataTable->selectionModel()->selectedIndexes();
@@ -1207,7 +1210,7 @@ void TableBrowser::showRecordPopupMenu(const QPoint& pos)
// Select the row if it is not already in the selection.
QModelIndexList rowList = ui->dataTable->selectionModel()->selectedRows();
bool found = false;
for (QModelIndex index : rowList) {
for (const QModelIndex& index : rowList) {
if (row == index.row()) {
found = true;
break;
@@ -1225,7 +1228,7 @@ void TableBrowser::showRecordPopupMenu(const QPoint& pos)
action->setShortcut(QKeySequence(tr("Ctrl+\"")));
popupRecordMenu.addAction(action);
connect(action, &QAction::triggered, [rowList, this]() {
connect(action, &QAction::triggered, this, [rowList, this]() {
for (const QModelIndex& index : rowList)
duplicateRecord(index.row());
});
@@ -1233,7 +1236,7 @@ void TableBrowser::showRecordPopupMenu(const QPoint& pos)
QAction* deleteRecordAction = new QAction(QIcon(":icons/delete_record"), ui->actionDeleteRecord->text(), &popupRecordMenu);
popupRecordMenu.addAction(deleteRecordAction);
connect(deleteRecordAction, &QAction::triggered, [&]() {
connect(deleteRecordAction, &QAction::triggered, this, [&]() {
deleteRecord();
});
@@ -1246,7 +1249,7 @@ void TableBrowser::showRecordPopupMenu(const QPoint& pos)
adjustRowHeightAction->setChecked(m_adjustRows);
popupRecordMenu.addAction(adjustRowHeightAction);
connect(adjustRowHeightAction, &QAction::toggled, [&](bool checked) {
connect(adjustRowHeightAction, &QAction::toggled, this, [&](bool checked) {
m_adjustRows = checked;
refresh();
});
+2 -1
View File
@@ -57,7 +57,8 @@ class TableBrowser : public QWidget
public:
explicit TableBrowser(DBBrowserDB* _db, QWidget* parent = nullptr);
~TableBrowser();
~TableBrowser() override;
void reset();
static void resetSharedSettings();
+3 -3
View File
@@ -28,7 +28,7 @@ TableBrowserDock::TableBrowserDock(QWidget* parent, MainWindow* mainWindow)
connect(this, &TableBrowserDock::customContextMenuRequested, this, &TableBrowserDock::showContextMenuTableBrowserTabBar);
// Connect browser signals
connect(browser, &TableBrowser::currentTableChanged, [this](const sqlb::ObjectIdentifier& table) {
connect(browser, &TableBrowser::currentTableChanged, this, [this](const sqlb::ObjectIdentifier& table) {
// Only update dock name when no custom name was set
if(!property("custom_title").toBool())
setWindowTitle(QString::fromStdString(table.toDisplayString()));
@@ -64,13 +64,13 @@ void TableBrowserDock::showContextMenuTableBrowserTabBar(const QPoint& pos)
QAction* actionRename = new QAction(this);
actionRename->setText(tr("Rename Data Browser"));
connect(actionRename, &QAction::triggered, [this]() {
connect(actionRename, &QAction::triggered, this, [this]() {
renameTableBrowserTab();
});
QAction* actionClose = new QAction(this);
actionClose->setText(tr("Close Data Browser"));
connect(actionClose, &QAction::triggered, [this]() {
connect(actionClose, &QAction::triggered, this, [this]() {
deleteLater();
});
+3 -3
View File
@@ -101,7 +101,7 @@ inline CSVField* addColumn(CSVRow& r, CSVField* field, bool trim)
// This function takes a parsed CSV row and hands it back to the caller of the CSV parser. It returns a null pointer if the parsing should be
// aborted, otherwise it returns a pointer to a new field object that can be used for storing the contents of the first field of the next row.
inline CSVField* addRow(CSVParser::csvRowFunction& f, CSVRow& r, size_t& rowCount)
inline CSVField* addRow(CSVParser::csvRowFunction f, CSVRow& r, size_t& rowCount)
{
// Call row function
if(!f(rowCount, r))
@@ -285,7 +285,7 @@ CSVParser::ParserResult CSVParser::parse(csvRowFunction insertFunction, QTextStr
{
addColumn(record, field, m_bTrimFields);
if(!(field = addRow(insertFunction, record, parsedRows)))
if(!addRow(insertFunction, record, parsedRows))
return ParserResult::ParserResultError;
}
@@ -310,7 +310,7 @@ bool CSVParser::look_ahead(QTextStream& stream, QByteArray& sBuffer, const char*
if(nit == *sBufferEnd && !stream.atEnd())
{
// Load one more byte
sBuffer.append(stream.read(1));
sBuffer.append(stream.read(1).toUtf8());
*sBufferEnd = sBuffer.constEnd();
// Restore both iterators. sBufferEnd points to the imagined char after the last one in the string. So the extra byte we've
+1 -1
View File
@@ -15,7 +15,7 @@ void db4sMessageOutput(QtMsgType type, const QMessageLogContext &context, const
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
localMsg = QString("%1 (%2, %3:%4)\n").arg(msg).arg(function).arg(file).arg(context.line).toLocal8Bit();
localMsg = QString("%1 (%2, %3:%4)\n").arg(msg, function, file).arg(context.line).toLocal8Bit();
// Log using the SQLite log mechanism, so it gets the same treatment than messages
// reported by SQLite itself. This will allow these messages to be seen in our Log window.
-1
View File
@@ -45,7 +45,6 @@ std::string escapeIdentifier(const std::string& id)
// selected.
return '[' + id + ']';
case DoubleQuotes:
default:
// This may produce a 'control reaches end of non-void function' warning if the
// default branch is removed, even though we have covered all possibilities in the
// switch statement.
+1 -1
View File
@@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.2.
// A Bison parser, made by GNU Bison 3.7.4.
// Locations for Bison parsers in C++
File diff suppressed because it is too large Load Diff
+21 -15
View File
@@ -1,4 +1,4 @@
// A Bison parser, made by GNU Bison 3.7.2.
// A Bison parser, made by GNU Bison 3.7.4.
// Skeleton interface for Bison LALR(1) parsers in C++
@@ -1145,7 +1145,7 @@ namespace sqlb { namespace parser {
/// Copy constructor.
basic_symbol (const basic_symbol& that);
/// Constructor for valueless symbols, and symbols from each type.
/// Constructors for typed symbols.
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, location_type&& l)
: Base (t)
@@ -1157,6 +1157,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, ColumndefData&& v, location_type&& l)
: Base (t)
@@ -1170,6 +1171,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, bool&& v, location_type&& l)
: Base (t)
@@ -1183,6 +1185,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::ConstraintPtr&& v, location_type&& l)
: Base (t)
@@ -1196,6 +1199,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::ConstraintSet&& v, location_type&& l)
: Base (t)
@@ -1209,6 +1213,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::IndexPtr&& v, location_type&& l)
: Base (t)
@@ -1222,6 +1227,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::IndexedColumn&& v, location_type&& l)
: Base (t)
@@ -1235,6 +1241,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::IndexedColumnVector&& v, location_type&& l)
: Base (t)
@@ -1248,6 +1255,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::StringVector&& v, location_type&& l)
: Base (t)
@@ -1261,6 +1269,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, sqlb::TablePtr&& v, location_type&& l)
: Base (t)
@@ -1274,6 +1283,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, std::string&& v, location_type&& l)
: Base (t)
@@ -1287,6 +1297,7 @@ namespace sqlb { namespace parser {
, location (l)
{}
#endif
#if 201103L <= YY_CPLUSPLUS
basic_symbol (typename Base::kind_type t, std::vector<ColumndefData>&& v, location_type&& l)
: Base (t)
@@ -1587,29 +1598,24 @@ switch (yykind)
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, location_type l)
: super_type(token_type (tok), std::move (l))
{
YY_ASSERT (tok == token::TOK_EOF || tok == token::TOK_YYerror || tok == token::TOK_YYUNDEF || tok == token::TOK_LPAREN || tok == token::TOK_RPAREN || tok == token::TOK_DOT || tok == token::TOK_COMMA || tok == token::TOK_SEMI || tok == token::TOK_PLUS || tok == token::TOK_MINUS || tok == token::TOK_STAR || tok == token::TOK_SLASH || tok == token::TOK_TILDE || tok == token::TOK_AMPERSAND || tok == token::TOK_PERCENT || tok == token::TOK_BITOR || tok == token::TOK_OROP || tok == token::TOK_EQUAL || tok == token::TOK_EQUAL2 || tok == token::TOK_GREATER || tok == token::TOK_GREATEREQUAL || tok == token::TOK_LOWER || tok == token::TOK_LOWEREQUAL || tok == token::TOK_UNEQUAL || tok == token::TOK_UNEQUAL2 || tok == token::TOK_BITWISELEFT || tok == token::TOK_BITWISERIGHT);
}
#else
symbol_type (int tok, const location_type& l)
: super_type(token_type (tok), l)
{
YY_ASSERT (tok == token::TOK_EOF || tok == token::TOK_YYerror || tok == token::TOK_YYUNDEF || tok == token::TOK_LPAREN || tok == token::TOK_RPAREN || tok == token::TOK_DOT || tok == token::TOK_COMMA || tok == token::TOK_SEMI || tok == token::TOK_PLUS || tok == token::TOK_MINUS || tok == token::TOK_STAR || tok == token::TOK_SLASH || tok == token::TOK_TILDE || tok == token::TOK_AMPERSAND || tok == token::TOK_PERCENT || tok == token::TOK_BITOR || tok == token::TOK_OROP || tok == token::TOK_EQUAL || tok == token::TOK_EQUAL2 || tok == token::TOK_GREATER || tok == token::TOK_GREATEREQUAL || tok == token::TOK_LOWER || tok == token::TOK_LOWEREQUAL || tok == token::TOK_UNEQUAL || tok == token::TOK_UNEQUAL2 || tok == token::TOK_BITWISELEFT || tok == token::TOK_BITWISERIGHT);
}
#endif
{
YY_ASSERT (tok == token::TOK_EOF
|| (token::TOK_YYerror <= tok && tok <= token::TOK_BITWISERIGHT));
}
#if 201103L <= YY_CPLUSPLUS
symbol_type (int tok, std::string v, location_type l)
: super_type(token_type (tok), std::move (v), std::move (l))
{
YY_ASSERT (tok == token::TOK_ABORT || tok == token::TOK_ACTION || tok == token::TOK_ALWAYS || tok == token::TOK_AND || tok == token::TOK_AND_BETWEEN || tok == token::TOK_AS || tok == token::TOK_ASC || tok == token::TOK_AUTOINCREMENT || tok == token::TOK_BETWEEN || tok == token::TOK_CASCADE || tok == token::TOK_CASE || tok == token::TOK_CAST || tok == token::TOK_CHECK || tok == token::TOK_COLLATE || tok == token::TOK_CONFLICT || tok == token::TOK_CONSTRAINT || tok == token::TOK_CREATE || tok == token::TOK_CURRENT_DATE || tok == token::TOK_CURRENT_TIME || tok == token::TOK_CURRENT_TIMESTAMP || tok == token::TOK_DEFAULT || tok == token::TOK_DEFERRABLE || tok == token::TOK_DEFERRED || tok == token::TOK_DELETE || tok == token::TOK_DESC || tok == token::TOK_DISTINCT || tok == token::TOK_ELSE || tok == token::TOK_END || tok == token::TOK_ESCAPE || tok == token::TOK_EXISTS || tok == token::TOK_FAIL || tok == token::TOK_FALSE || tok == token::TOK_FILTER || tok == token::TOK_FOLLOWING || tok == token::TOK_FOREIGN || tok == token::TOK_GENERATED || tok == token::TOK_GLOB || tok == token::TOK_IF || tok == token::TOK_IGNORE || tok == token::TOK_IMMEDIATE || tok == token::TOK_IN || tok == token::TOK_INDEX || tok == token::TOK_INITIALLY || tok == token::TOK_INSERT || tok == token::TOK_IS || tok == token::TOK_ISNULL || tok == token::TOK_KEY || tok == token::TOK_LIKE || tok == token::TOK_MATCH || tok == token::TOK_NO || tok == token::TOK_NOT || tok == token::TOK_NOTNULL || tok == token::TOK_NULL || tok == token::TOK_ON || tok == token::TOK_OR || tok == token::TOK_OVER || tok == token::TOK_PARTITION || tok == token::TOK_PRECEDING || tok == token::TOK_PRIMARY || tok == token::TOK_RAISE || tok == token::TOK_RANGE || tok == token::TOK_REFERENCES || tok == token::TOK_REGEXP || tok == token::TOK_REPLACE || tok == token::TOK_RESTRICT || tok == token::TOK_ROLLBACK || tok == token::TOK_ROWID || tok == token::TOK_ROWS || tok == token::TOK_SELECT || tok == token::TOK_SET || tok == token::TOK_STORED || tok == token::TOK_TABLE || tok == token::TOK_TEMP || tok == token::TOK_TEMPORARY || tok == token::TOK_THEN || tok == token::TOK_TRUE || tok == token::TOK_UNBOUNDED || tok == token::TOK_UNIQUE || tok == token::TOK_UPDATE || tok == token::TOK_USING || tok == token::TOK_VIRTUAL || tok == token::TOK_WHEN || tok == token::TOK_WHERE || tok == token::TOK_WITHOUT || tok == token::TOK_IDENTIFIER || tok == token::TOK_NUMERIC || tok == token::TOK_STRINGLITERAL || tok == token::TOK_QUOTEDLITERAL || tok == token::TOK_BLOBLITERAL || tok == token::TOK_BINDPARAMETER);
}
#else
symbol_type (int tok, const std::string& v, const location_type& l)
: super_type(token_type (tok), v, l)
{
YY_ASSERT (tok == token::TOK_ABORT || tok == token::TOK_ACTION || tok == token::TOK_ALWAYS || tok == token::TOK_AND || tok == token::TOK_AND_BETWEEN || tok == token::TOK_AS || tok == token::TOK_ASC || tok == token::TOK_AUTOINCREMENT || tok == token::TOK_BETWEEN || tok == token::TOK_CASCADE || tok == token::TOK_CASE || tok == token::TOK_CAST || tok == token::TOK_CHECK || tok == token::TOK_COLLATE || tok == token::TOK_CONFLICT || tok == token::TOK_CONSTRAINT || tok == token::TOK_CREATE || tok == token::TOK_CURRENT_DATE || tok == token::TOK_CURRENT_TIME || tok == token::TOK_CURRENT_TIMESTAMP || tok == token::TOK_DEFAULT || tok == token::TOK_DEFERRABLE || tok == token::TOK_DEFERRED || tok == token::TOK_DELETE || tok == token::TOK_DESC || tok == token::TOK_DISTINCT || tok == token::TOK_ELSE || tok == token::TOK_END || tok == token::TOK_ESCAPE || tok == token::TOK_EXISTS || tok == token::TOK_FAIL || tok == token::TOK_FALSE || tok == token::TOK_FILTER || tok == token::TOK_FOLLOWING || tok == token::TOK_FOREIGN || tok == token::TOK_GENERATED || tok == token::TOK_GLOB || tok == token::TOK_IF || tok == token::TOK_IGNORE || tok == token::TOK_IMMEDIATE || tok == token::TOK_IN || tok == token::TOK_INDEX || tok == token::TOK_INITIALLY || tok == token::TOK_INSERT || tok == token::TOK_IS || tok == token::TOK_ISNULL || tok == token::TOK_KEY || tok == token::TOK_LIKE || tok == token::TOK_MATCH || tok == token::TOK_NO || tok == token::TOK_NOT || tok == token::TOK_NOTNULL || tok == token::TOK_NULL || tok == token::TOK_ON || tok == token::TOK_OR || tok == token::TOK_OVER || tok == token::TOK_PARTITION || tok == token::TOK_PRECEDING || tok == token::TOK_PRIMARY || tok == token::TOK_RAISE || tok == token::TOK_RANGE || tok == token::TOK_REFERENCES || tok == token::TOK_REGEXP || tok == token::TOK_REPLACE || tok == token::TOK_RESTRICT || tok == token::TOK_ROLLBACK || tok == token::TOK_ROWID || tok == token::TOK_ROWS || tok == token::TOK_SELECT || tok == token::TOK_SET || tok == token::TOK_STORED || tok == token::TOK_TABLE || tok == token::TOK_TEMP || tok == token::TOK_TEMPORARY || tok == token::TOK_THEN || tok == token::TOK_TRUE || tok == token::TOK_UNBOUNDED || tok == token::TOK_UNIQUE || tok == token::TOK_UPDATE || tok == token::TOK_USING || tok == token::TOK_VIRTUAL || tok == token::TOK_WHEN || tok == token::TOK_WHERE || tok == token::TOK_WITHOUT || tok == token::TOK_IDENTIFIER || tok == token::TOK_NUMERIC || tok == token::TOK_STRINGLITERAL || tok == token::TOK_QUOTEDLITERAL || tok == token::TOK_BLOBLITERAL || tok == token::TOK_BINDPARAMETER);
}
#endif
{
YY_ASSERT ((token::TOK_ABORT <= tok && tok <= token::TOK_BINDPARAMETER));
}
};
/// Build a parser object.
@@ -4266,7 +4272,7 @@ switch (yykind)
#line 10 "sqlite3_parser.yy"
} } // sqlb::parser
#line 4270 "sqlite3_parser.hpp"
#line 4276 "sqlite3_parser.hpp"
+2
View File
@@ -772,6 +772,8 @@ columndef:
}
break;
}
default:
break;
}
}
+13 -33
View File
@@ -133,8 +133,7 @@ void UniqueConstraint::setColumnList(const StringVector& list)
// Create our own column list without sort orders etc
m_columns.clear();
for(const auto& c : list)
m_columns.push_back(IndexedColumn(c, false));
std::transform(list.begin(), list.end(), std::back_inserter(m_columns), [](const auto& c) { return IndexedColumn(c, false); });
}
void UniqueConstraint::addToColumnList(const std::string& key)
@@ -179,8 +178,7 @@ std::string UniqueConstraint::toSql() const
if(m_columns.size())
{
std::vector<std::string> u_columns;
for(const auto& c : m_columns)
u_columns.push_back(c.toString("", " "));
std::transform(m_columns.begin(), m_columns.end(), std::back_inserter(u_columns), [](const auto& c) { return c.toString("", " "); });
result += "(" + joinStringVector(u_columns, ",") + ")";
}
@@ -223,8 +221,7 @@ std::string PrimaryKeyConstraint::toSql() const
result = "CONSTRAINT " + escapeIdentifier(m_name) + " ";
std::vector<std::string> pk_columns;
for(const auto& c : m_columns)
pk_columns.push_back(c.toString("", " "));
std::transform(m_columns.begin(), m_columns.end(), std::back_inserter(pk_columns), [](const auto& c) { return c.toString("", " "); });
result += "PRIMARY KEY(" + joinStringVector(pk_columns, ",") + (m_auto_increment ? " AUTOINCREMENT" : "") + ")";
if(!m_conflictAction.empty())
@@ -424,20 +421,14 @@ bool Table::operator==(const Table& rhs) const
StringVector Table::fieldList() const
{
StringVector sl;
for(const Field& f : fields)
sl.push_back(f.toString());
std::transform(fields.begin(), fields.end(), std::back_inserter(sl), [](const auto& f) { return f.toString(); });
return sl;
}
StringVector Table::fieldNames() const
{
StringVector sl;
for(const Field& f : fields)
sl.push_back(f.name());
std::transform(fields.begin(), fields.end(), std::back_inserter(sl), [](const auto& f) { return f.name(); });
return sl;
}
@@ -453,8 +444,7 @@ StringVector Table::rowidColumns() const
FieldInfoList Table::fieldInformation() const
{
FieldInfoList result;
for(const Field& f : fields)
result.emplace_back(f.name(), f.type(), f.toString(" ", " "));
std::transform(fields.begin(), fields.end(), std::back_inserter(result), [](const auto& f) { return FieldInfo(f.name(), f.type(), f.toString(" ", " ")); });
return result;
}
@@ -558,11 +548,9 @@ ConstraintPtr Table::constraint(const StringVector& vStrFields, Constraint::Cons
std::vector<ConstraintPtr> Table::constraints(const StringVector& vStrFields, Constraint::ConstraintTypes type) const
{
std::vector<ConstraintPtr> clist;
for(const auto& it : m_constraints)
{
if((type == Constraint::NoType || it->type() == type) && (vStrFields.empty() || it->columnList() == vStrFields))
clist.push_back(it);
}
std::copy_if(m_constraints.begin(), m_constraints.end(), std::back_inserter(clist), [vStrFields, type](const auto& c) {
return (type == Constraint::NoType || c->type() == type) && (vStrFields.empty() || c->columnList() == vStrFields);
});
return clist;
}
@@ -654,10 +642,7 @@ Index& Index::operator=(const Index& rhs)
StringVector Index::columnSqlList() const
{
StringVector sl;
for(const IndexedColumn& c : fields)
sl.push_back(c.toString());
std::transform(fields.begin(), fields.end(), std::back_inserter(sl), [](const auto& c) { return c.toString(); });
return sl;
}
@@ -690,8 +675,7 @@ std::string Index::sql(const std::string& schema, bool ifNotExists) const
FieldInfoList Index::fieldInformation() const
{
FieldInfoList result;
for(const IndexedColumn& c : fields)
result.emplace_back(c.name(), c.order(), c.toString(" ", " "));
std::transform(fields.begin(), fields.end(), std::back_inserter(result), [](const auto& c) { return FieldInfo(c.name(), c.order(), c.toString(" ", " ")); });
return result;
}
@@ -723,18 +707,14 @@ ViewPtr View::parseSQL(const std::string& sSQL)
StringVector View::fieldNames() const
{
StringVector sl;
for(const Field& f : fields)
sl.push_back(f.name());
std::transform(fields.begin(), fields.end(), std::back_inserter(sl), [](const auto& f) { return f.name(); });
return sl;
}
FieldInfoList View::fieldInformation() const
{
FieldInfoList result;
for(const Field& f : fields)
result.emplace_back(f.name(), f.type(), f.toString(" ", " "));
std::transform(fields.begin(), fields.end(), std::back_inserter(result), [](const auto& f) { return FieldInfo(f.name(), f.type(), f.toString(" ", " ")); });
return result;
}
+1 -2
View File
@@ -1393,8 +1393,7 @@ bool DBBrowserDB::deleteRecords(const sqlb::ObjectIdentifier& table, const std::
// Quote all values in advance
std::vector<std::string> quoted_rowids;
for(QString rowid : rowids)
quoted_rowids.push_back(sqlb::escapeString(rowid.toStdString()));
std::transform(rowids.begin(), rowids.end(), std::back_inserter(quoted_rowids), [](const auto& rowid) { return sqlb::escapeString((rowid.toStdString())); });
// For a single rowid column we can use a SELECT ... IN(...) statement which is faster.
// For multiple rowid columns we have to use sqlb_make_single_value to decode the composed rowid values.