Skip to content

Commit

Permalink
Remove some virtuals and add some overrides
Browse files Browse the repository at this point in the history
In our case this is more a question of code style.
  • Loading branch information
MKleusberg committed Oct 9, 2018
1 parent 00b57a7 commit fb1eba1
Show file tree
Hide file tree
Showing 34 changed files with 141 additions and 139 deletions.
8 changes: 4 additions & 4 deletions src/AddRecordDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class NullLineEdit: public QLineEdit {
class NoEditDelegate: public QStyledItemDelegate {
public:
NoEditDelegate(QObject* parent=nullptr): QStyledItemDelegate(parent) {}
virtual QWidget* createEditor(QWidget* /* parent */, const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const {
QWidget* createEditor(QWidget* /* parent */, const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const override {
return nullptr;
}
};
Expand All @@ -75,11 +75,11 @@ class EditDelegate: public QStyledItemDelegate {

public:
EditDelegate(QObject* parent=nullptr): QStyledItemDelegate(parent) {}
virtual QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const {
QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const override {
return new NullLineEdit(parent);
}

virtual void setEditorData(QWidget *editor, const QModelIndex &index) const {
void setEditorData(QWidget *editor, const QModelIndex &index) const override {

NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
// Set the editor in the null state (unless the user has actually written NULL)
Expand All @@ -91,7 +91,7 @@ class EditDelegate: public QStyledItemDelegate {
lineEditor->setNull(false);
}
}
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const {
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override {

NullLineEdit* lineEditor = dynamic_cast<NullLineEdit*>(editor);
// Restore NULL text (unless the user has already modified the value)
Expand Down
6 changes: 3 additions & 3 deletions src/AddRecordDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class AddRecordDialog : public QDialog

public:
explicit AddRecordDialog(DBBrowserDB& pdb, const sqlb::ObjectIdentifier& tableName, QWidget* parent = nullptr);
~AddRecordDialog();
~AddRecordDialog() override;

protected:
void keyPressEvent(QKeyEvent *evt);
void keyPressEvent(QKeyEvent *evt) override;

private:
enum Columns {
Expand All @@ -37,7 +37,7 @@ class AddRecordDialog : public QDialog
void setDefaultsStyle(QTreeWidgetItem* item);

private slots:
virtual void accept();
void accept() override;
void itemChanged(QTreeWidgetItem* item, int column);
void help();
void on_buttonBox_clicked(QAbstractButton* button);
Expand Down
4 changes: 2 additions & 2 deletions src/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Application : public QApplication

public:
explicit Application(int& argc, char** argv);
virtual ~Application();
~Application() override;

bool dontShowMainWindow() { return m_dontShowMainWindow; }

Expand All @@ -21,7 +21,7 @@ class Application : public QApplication
static QString versionString();

protected:
bool event(QEvent* event);
bool event(QEvent* event) override;

private:
bool m_dontShowMainWindow;
Expand Down
2 changes: 1 addition & 1 deletion src/CipherDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CipherDialog : public QDialog
// Set the encrypt parameter to true when the dialog is used to encrypt a database;
// set it to false if the dialog is used to ask the user for the key to decrypt a file.
explicit CipherDialog(QWidget* parent, bool encrypt);
~CipherDialog();
~CipherDialog() override;

CipherSettings getCipherSettings() const;

Expand Down
2 changes: 1 addition & 1 deletion src/ColumnDisplayFormatDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ColumnDisplayFormatDialog : public QDialog

public:
explicit ColumnDisplayFormatDialog(const QString& colname, QString current_format, QWidget* parent = nullptr);
~ColumnDisplayFormatDialog();
~ColumnDisplayFormatDialog() override;

QString selectedDisplayFormat() const;

Expand Down
26 changes: 13 additions & 13 deletions src/DbStructureModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ class DbStructureModel : public QAbstractItemModel

public:
explicit DbStructureModel(DBBrowserDB& db, QObject* parent = nullptr);
~DbStructureModel();
~DbStructureModel() override;

QVariant data(const QModelIndex& index, int role) const;
Qt::ItemFlags flags(const QModelIndex& index) const;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex& index) const;
int rowCount(const QModelIndex& parent = QModelIndex()) const;
int columnCount(const QModelIndex& = QModelIndex()) const;
QVariant data(const QModelIndex& index, int role) const override;
Qt::ItemFlags flags(const QModelIndex& index) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex& index) const override;
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& = QModelIndex()) const override;

QStringList mimeTypes() const;
QMimeData* mimeData(const QModelIndexList& indices) const;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent);
QStringList mimeTypes() const override;
QMimeData* mimeData(const QModelIndexList& indices) const override;
bool dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;

enum Columns
{
Expand All @@ -39,8 +39,8 @@ class DbStructureModel : public QAbstractItemModel

public slots:
void reloadData();
void setDropQualifiedNames(bool value) { m_dropQualifiedNames = value; };
void setDropEnquotedNames(bool value) { m_dropEnquotedNames = value; };
void setDropQualifiedNames(bool value) { m_dropQualifiedNames = value; }
void setDropEnquotedNames(bool value) { m_dropEnquotedNames = value; }

signals:
void structureUpdated();
Expand Down
10 changes: 5 additions & 5 deletions src/EditDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@ class EditDialog : public QDialog

public:
explicit EditDialog(QWidget* parent = nullptr);
~EditDialog();
~EditDialog() override;

void setCurrentIndex(const QModelIndex& idx);

public slots:
virtual void setFocus();
virtual void reject();
void setFocus();
void reject() override;
void setReadOnly(bool ro);
void reloadSettings();

protected:
virtual void showEvent(QShowEvent* ev);
void showEvent(QShowEvent* ev) override;

private slots:
void importData();
void exportData();
void setNull();
void updateApplyButton();
virtual void accept();
void accept() override;
void loadData(const QByteArray& data);
void toggleOverwriteMode();
void editModeChanged(int newMode);
Expand Down
6 changes: 3 additions & 3 deletions src/EditIndexDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class EditIndexDialog : public QDialog

public:
explicit EditIndexDialog(DBBrowserDB& db, const sqlb::ObjectIdentifier& indexName, bool createIndex, QWidget* parent = nullptr);
~EditIndexDialog();
~EditIndexDialog() override;

private slots:
void accept();
void reject();
void accept() override;
void reject() override;

void tableChanged(const QString& new_table, bool initialLoad = false);
void checkInput();
Expand Down
10 changes: 5 additions & 5 deletions src/EditTableDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class EditTableDialog : public QDialog

public:
explicit EditTableDialog(DBBrowserDB& pdb, const sqlb::ObjectIdentifier& tableName, bool createTable, QWidget* parent = nullptr);
~EditTableDialog();
~EditTableDialog() override;

protected:
void keyPressEvent(QKeyEvent *evt);
void keyPressEvent(QKeyEvent *evt) override;

private:
enum Columns {
Expand All @@ -47,12 +47,12 @@ private slots:
void addField();
void removeField();
void fieldSelectionChanged();
virtual void accept();
virtual void reject();
void accept() override;
void reject() override;
void checkInput();
void itemChanged(QTreeWidgetItem* item, int column);
void updateTypes(QObject *object);
bool eventFilter(QObject *object, QEvent *event);
bool eventFilter(QObject *object, QEvent *event) override;
void updateTypes();
void moveUp();
void moveDown();
Expand Down
4 changes: 2 additions & 2 deletions src/ExportDataDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class ExportDataDialog : public QDialog

explicit ExportDataDialog(DBBrowserDB& db, ExportFormats format, QWidget* parent = nullptr,
const QString& query = "", const sqlb::ObjectIdentifier& selection = sqlb::ObjectIdentifier());
~ExportDataDialog();
~ExportDataDialog() override;

private slots:
virtual void accept();
void accept() override;
void showCustomCharEdits();

private:
Expand Down
4 changes: 2 additions & 2 deletions src/ExportSqlDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ class ExportSqlDialog : public QDialog

public:
explicit ExportSqlDialog(DBBrowserDB* db, QWidget* parent = nullptr, const QString& selection = "");
~ExportSqlDialog();
~ExportSqlDialog() override;

private slots:
virtual void accept();
void accept() override;
void doSelectAll();
void doDeselectAll();
void whatChanged(int index);
Expand Down
6 changes: 3 additions & 3 deletions src/ExtendedScintilla.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class ExtendedScintilla : public QsciScintilla

public:
explicit ExtendedScintilla(QWidget *parent = nullptr);
virtual ~ExtendedScintilla();
~ExtendedScintilla() override;

bool findText(QString text, bool regexp, bool caseSensitive, bool words, bool wrap, bool forward);
void clearSelection();
// Override parent setLexer
void setLexer(QsciLexer *lexer);
void setLexer(QsciLexer *lexer) override;

public slots:
void reloadKeywords();
Expand All @@ -33,7 +33,7 @@ public slots:
void openPrintDialog();

protected:
void dropEvent(QDropEvent* e);
void dropEvent(QDropEvent* e) override;

void setupSyntaxHighlightingFormat(QsciLexer *lexer, const QString& settings_name, int style);
void reloadLexerSettings(QsciLexer *lexer);
Expand Down
10 changes: 5 additions & 5 deletions src/ExtendedTableWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ private slots:
void cellClicked(const QModelIndex& index);

protected:
virtual void keyPressEvent(QKeyEvent* event);
virtual void updateGeometries();
virtual void dragEnterEvent(QDragEnterEvent* event);
virtual void dragMoveEvent(QDragMoveEvent* event);
virtual void dropEvent(QDropEvent* event);
void keyPressEvent(QKeyEvent* event) override;
void updateGeometries() override;
void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent* event) override;
void dropEvent(QDropEvent* event) override;

FilterTableHeader* m_tableHeader;
QMenu* m_contextMenu;
Expand Down
2 changes: 1 addition & 1 deletion src/FileExtensionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FileExtensionManager : public QDialog

public:
explicit FileExtensionManager(QStringList init, QWidget *parent = nullptr);
~FileExtensionManager();
~FileExtensionManager() override;

QStringList getDBFileExtensions();

Expand Down
2 changes: 1 addition & 1 deletion src/FilterLineEdit.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private slots:
void delayedTextChanged(QString text);

protected:
void keyReleaseEvent(QKeyEvent* event);
void keyReleaseEvent(QKeyEvent* event) override;
void setFilterHelper(const QString& filterOperator);

private:
Expand Down
6 changes: 3 additions & 3 deletions src/FilterTableHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class FilterTableHeader : public QHeaderView

public:
explicit FilterTableHeader(QTableView* parent = nullptr);
virtual QSize sizeHint() const;
bool hasFilters() const {return (filterWidgets.count() > 0);};
QSize sizeHint() const override;
bool hasFilters() const {return (filterWidgets.count() > 0);}

public slots:
void generateFilters(int number, bool showFirst = false);
Expand All @@ -27,7 +27,7 @@ public slots:
void filterChanged(int column, QString value);

protected:
virtual void updateGeometries();
void updateGeometries() override;

private slots:
void inputChanged(const QString& new_value);
Expand Down
4 changes: 2 additions & 2 deletions src/FindReplaceDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FindReplaceDialog : public QDialog
public:

explicit FindReplaceDialog(QWidget* parent = nullptr);
~FindReplaceDialog();
~FindReplaceDialog() override;
void setExtendedScintilla(ExtendedScintilla* scintilla);
void show();

Expand All @@ -28,7 +28,7 @@ private slots:
void replaceAll();
void help();
void close();
void reject();
void reject() override;
void buttonBox_clicked(QAbstractButton* button);

private:
Expand Down
8 changes: 4 additions & 4 deletions src/ForeignKeyEditorDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ class ForeignKeyEditorDelegate : public QStyledItemDelegate
public:
explicit ForeignKeyEditorDelegate(const DBBrowserDB& db, sqlb::Table& table, QObject* parent = nullptr);

QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const Q_DECL_OVERRIDE;
void setEditorData(QWidget* editor, const QModelIndex& index) const Q_DECL_OVERRIDE;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const Q_DECL_OVERRIDE;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE;
QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
void setEditorData(QWidget* editor, const QModelIndex& index) const override;
void setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const override;
void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override;

void updateTablesList(const QString& oldTableName);

Expand Down
4 changes: 2 additions & 2 deletions src/ImportCsvDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class ImportCsvDialog : public QDialog

public:
explicit ImportCsvDialog(const QStringList& filenames, DBBrowserDB* db, QWidget* parent = nullptr);
~ImportCsvDialog();
~ImportCsvDialog() override;

private slots:
virtual void accept();
void accept() override;
void updatePreview();
void checkInput();
void selectFiles();
Expand Down
12 changes: 6 additions & 6 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class MainWindow : public QMainWindow

public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
~MainWindow() override;

DBBrowserDB& getDb() { return db; }
RemoteDatabase& getRemote() { return *m_remoteDb; }
Expand Down Expand Up @@ -197,11 +197,11 @@ class MainWindow : public QMainWindow
void applyBrowseTableSettings(BrowseDataTableSettings storedData, bool skipFilters = false);

protected:
void closeEvent(QCloseEvent *);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void resizeEvent(QResizeEvent *event);
void keyPressEvent(QKeyEvent* event);
void closeEvent(QCloseEvent *) override;
void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
void keyPressEvent(QKeyEvent* event) override;

public slots:
bool fileOpen(const QString& fileName = QString(), bool dontAddToRecentFiles = false, bool readOnly = false);
Expand Down
Loading

0 comments on commit fb1eba1

Please sign in to comment.