Skip to content

Commit e4e840d

Browse files
committed
Make many methods and attributes of classes private
Make most variables, functions, slots etc. private instead of public. Also make the constructors explicit.
1 parent a0c209e commit e4e840d

13 files changed

Lines changed: 70 additions & 69 deletions

src/CreateIndexDialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class CreateIndexDialog : public QDialog
1313
Q_OBJECT
1414

1515
public:
16-
CreateIndexDialog(DBBrowserDB* db, QWidget* parent = 0);
16+
explicit CreateIndexDialog(DBBrowserDB* db, QWidget* parent = 0);
1717
~CreateIndexDialog();
1818

1919
private slots:

src/EditDialog.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,23 @@ class EditDialog : public QDialog
1212
Q_OBJECT
1313

1414
public:
15-
EditDialog(QWidget* parent = 0);
15+
explicit EditDialog(QWidget* parent = 0);
1616
~EditDialog();
1717

18-
int curCol;
19-
int curRow;
2018
QString defaultlocation;
2119

20+
public:
21+
int getCurrentCol() { return curCol; }
22+
int getCurrentRow() { return curRow; }
23+
2224
public slots:
2325
virtual void reset();
26+
virtual void loadText(QString text, int row, int col);
27+
28+
private slots:
2429
virtual void enableExport(bool enabled);
2530
virtual void setDataType(int type, int size);
2631
virtual void closeEvent(QCloseEvent*);
27-
virtual void loadText(QString text, int row, int col);
2832
virtual void importData();
2933
virtual void exportData();
3034
virtual void clearData();
@@ -35,12 +39,12 @@ public slots:
3539
void goingAway();
3640
void updateRecordText(int, int, QString);
3741

38-
protected:
39-
int dataType;
40-
int dataSize;
41-
4242
private:
4343
Ui::EditDialog* ui;
44+
int dataType;
45+
int dataSize;
46+
int curCol;
47+
int curRow;
4448
};
4549

4650
#endif

src/EditFieldDialog.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ class EditFieldDialog : public QDialog
1414
Q_OBJECT
1515

1616
public:
17-
EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent = 0);
17+
explicit EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent = 0);
1818
~EditFieldDialog();
1919

20-
public slots:
20+
QString getFieldName() { return field_name; }
21+
QString getFieldType() { return field_type; }
22+
23+
private slots:
2124
virtual void accept();
2225
virtual void checkInput();
2326

@@ -27,8 +30,6 @@ public slots:
2730
QString original_field_name;
2831
QString table_name;
2932
bool is_new;
30-
31-
public:
3233
QString field_name;
3334
QString field_type;
3435
};

src/EditTableDialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void EditTableDialog::reject()
101101
if(curTable != "")
102102
{
103103
// Then rollback to our savepoint
104-
pdb->executeSQL(QString("ROLLBACK TO SAVEPOINT edittable_%1_save;").arg(curTable));
104+
pdb->executeSQL(QString("ROLLBACK TO SAVEPOINT edittable_%1_save;").arg(curTable));
105105
}
106106

107107
QDialog::reject();
@@ -128,8 +128,8 @@ void EditTableDialog::editField()
128128
EditFieldDialog dialog(pdb, curTable == "", curTable, item->text(0), item->text(1), this);
129129
if(dialog.exec())
130130
{
131-
item->setText(0, dialog.field_name);
132-
item->setText(1, dialog.field_type);
131+
item->setText(0, dialog.getFieldName());
132+
item->setText(1, dialog.getFieldType());
133133
}
134134
}
135135

@@ -139,8 +139,8 @@ void EditTableDialog::addField()
139139
if(dialog.exec())
140140
{
141141
QTreeWidgetItem *tbitem = new QTreeWidgetItem(ui->treeWidget);
142-
tbitem->setText(0, dialog.field_name);
143-
tbitem->setText(1, dialog.field_type);
142+
tbitem->setText(0, dialog.getFieldName());
143+
tbitem->setText(1, dialog.getFieldType());
144144
ui->treeWidget->addTopLevelItem(tbitem);
145145
checkInput();
146146
}

src/EditTableDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class EditTableDialog : public QDialog
1313
Q_OBJECT
1414

1515
public:
16-
EditTableDialog(DBBrowserDB* pdb, QString tableName, QWidget* parent = 0);
16+
explicit EditTableDialog(DBBrowserDB* pdb, QString tableName, QWidget* parent = 0);
1717
~EditTableDialog();
1818

19-
public slots:
19+
private slots:
2020
virtual void populateFields();
2121
virtual void editField();
2222
virtual void addField();

src/ExportCsvDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class ExportCsvDialog : public QDialog
1313
Q_OBJECT
1414

1515
public:
16-
ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent = 0);
16+
explicit ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent = 0);
1717
~ExportCsvDialog();
1818

19-
public slots:
19+
private slots:
2020
virtual void accept();
2121

2222
private:

src/FindDialog.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ class FindDialog : public QDialog
1414
Q_OBJECT
1515

1616
public:
17-
FindDialog(QWidget* parent = 0);
17+
explicit FindDialog(QWidget* parent = 0);
1818
~FindDialog();
1919

2020
public slots:
2121
virtual void showResults(resultMap rmap);
22-
virtual void find();
2322
virtual void resetFields(QStringList fieldlist = QStringList());
23+
24+
private slots:
25+
virtual void find();
2426
virtual void recordSelected(QTableWidgetItem* witem);
2527
virtual void closeEvent(QCloseEvent*);
2628

src/ImportCsvDialog.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ class ImportCsvDialog : public QDialog
1313
Q_OBJECT
1414

1515
public:
16-
ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent = 0);
16+
explicit ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent = 0);
1717
~ImportCsvDialog();
1818

19-
protected slots:
19+
private slots:
2020
virtual void accept();
2121
virtual void updatePreview();
2222
virtual void checkInput();

src/MainWindow.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ void MainWindow::editWinAway()
667667
{
668668
editWin->hide();
669669
activateWindow();
670-
ui->dataTable->setRangeSelected( QTableWidgetSelectionRange(editWin->curRow, editWin->curCol, editWin->curRow, editWin->curCol), true);
670+
ui->dataTable->setRangeSelected(QTableWidgetSelectionRange(editWin->getCurrentRow(), editWin->getCurrentCol(), editWin->getCurrentRow(), editWin->getCurrentCol()), true);
671671
}
672672

673673
void MainWindow::editText(int row, int col)
@@ -972,8 +972,8 @@ void MainWindow::editField()
972972
EditFieldDialog dialog(&db, false, item->parent()->text(0), item->text(0), item->text(2), this);
973973
if(dialog.exec())
974974
{
975-
item->setText(0, dialog.field_name);
976-
item->setText(2, dialog.field_type);
975+
item->setText(0, dialog.getFieldName());
976+
item->setText(2, dialog.getFieldType());
977977
}
978978
}
979979

src/MainWindow.h

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class MainWindow : public QMainWindow
2323
{
2424
Q_OBJECT
2525

26+
public:
27+
MainWindow(QWidget* parent = 0);
28+
~MainWindow();
29+
2630
private:
2731
Ui::MainWindow* ui;
2832
SQLLogDock * logWin;
@@ -41,16 +45,13 @@ class MainWindow : public QMainWindow
4145
int curBrowseOrderByIndex;
4246
int curBrowseOrderByMode;
4347

44-
public:
45-
MainWindow(QWidget* parent = 0);
46-
~MainWindow();
47-
4848
EditDialog* editWin;
4949
FindDialog* findWin;
50-
QIntValidator * gotoValidator;
50+
QIntValidator* gotoValidator;
5151
QString defaultlocation;
5252

53-
private:
53+
DBBrowserDB db;
54+
5455
void init();
5556

5657
void updateRecentFileActions();
@@ -59,14 +60,19 @@ class MainWindow : public QMainWindow
5960

6061
protected:
6162
void closeEvent(QCloseEvent *);
63+
void dragEnterEvent(QDragEnterEvent *event);
64+
void dropEvent(QDropEvent *event);
65+
void resizeEvent(QResizeEvent *event);
6266

6367
public slots:
68+
virtual void fileOpen( const QString & fileName );
69+
70+
private slots:
6471
virtual void createTreeContextMenu(const QPoint & qPoint);
6572
virtual void changeTreeSelection();
6673
virtual void addField();
6774
virtual void editField();
6875
virtual void deleteField();
69-
virtual void fileOpen( const QString & fileName );
7076
virtual void fileOpen();
7177
virtual void fileNew();
7278
virtual void populateStructure();
@@ -111,18 +117,8 @@ public slots:
111117
virtual void openRecentFile();
112118
virtual void loadPragmas();
113119
virtual void savePragmas();
114-
115-
protected:
116-
DBBrowserDB db;
117-
118-
void dragEnterEvent(QDragEnterEvent *event);
119-
void dropEvent(QDropEvent *event);
120-
void resizeEvent(QResizeEvent *event);
121-
122-
protected slots:
123120
virtual void mainTabSelected( int tabindex );
124121
virtual void browseTableHeaderClicked(int logicalindex);
125-
126122
};
127123

128-
#endif // MAINFORM_H
124+
#endif

0 commit comments

Comments
 (0)