Skip to content

Commit

Permalink
Make many methods and attributes of classes private
Browse files Browse the repository at this point in the history
Make most variables, functions, slots etc. private instead of public.

Also make the constructors explicit.
  • Loading branch information
MKleusberg committed Jan 20, 2013
1 parent a0c209e commit e4e840d
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 69 deletions.
2 changes: 1 addition & 1 deletion src/CreateIndexDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateIndexDialog : public QDialog
Q_OBJECT

public:
CreateIndexDialog(DBBrowserDB* db, QWidget* parent = 0);
explicit CreateIndexDialog(DBBrowserDB* db, QWidget* parent = 0);
~CreateIndexDialog();

private slots:
Expand Down
20 changes: 12 additions & 8 deletions src/EditDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ class EditDialog : public QDialog
Q_OBJECT

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

int curCol;
int curRow;
QString defaultlocation;

public:
int getCurrentCol() { return curCol; }
int getCurrentRow() { return curRow; }

public slots:
virtual void reset();
virtual void loadText(QString text, int row, int col);

private slots:
virtual void enableExport(bool enabled);
virtual void setDataType(int type, int size);
virtual void closeEvent(QCloseEvent*);
virtual void loadText(QString text, int row, int col);
virtual void importData();
virtual void exportData();
virtual void clearData();
Expand All @@ -35,12 +39,12 @@ public slots:
void goingAway();
void updateRecordText(int, int, QString);

protected:
int dataType;
int dataSize;

private:
Ui::EditDialog* ui;
int dataType;
int dataSize;
int curCol;
int curRow;
};

#endif
9 changes: 5 additions & 4 deletions src/EditFieldDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ class EditFieldDialog : public QDialog
Q_OBJECT

public:
EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent = 0);
explicit EditFieldDialog(DBBrowserDB* db, bool new_field, QString table, QString fld_name, QString fld_type, QWidget* parent = 0);
~EditFieldDialog();

public slots:
QString getFieldName() { return field_name; }
QString getFieldType() { return field_type; }

private slots:
virtual void accept();
virtual void checkInput();

Expand All @@ -27,8 +30,6 @@ public slots:
QString original_field_name;
QString table_name;
bool is_new;

public:
QString field_name;
QString field_type;
};
Expand Down
10 changes: 5 additions & 5 deletions src/EditTableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void EditTableDialog::reject()
if(curTable != "")
{
// Then rollback to our savepoint
pdb->executeSQL(QString("ROLLBACK TO SAVEPOINT edittable_%1_save;").arg(curTable));
pdb->executeSQL(QString("ROLLBACK TO SAVEPOINT edittable_%1_save;").arg(curTable));
}

QDialog::reject();
Expand All @@ -128,8 +128,8 @@ void EditTableDialog::editField()
EditFieldDialog dialog(pdb, curTable == "", curTable, item->text(0), item->text(1), this);
if(dialog.exec())
{
item->setText(0, dialog.field_name);
item->setText(1, dialog.field_type);
item->setText(0, dialog.getFieldName());
item->setText(1, dialog.getFieldType());
}
}

Expand All @@ -139,8 +139,8 @@ void EditTableDialog::addField()
if(dialog.exec())
{
QTreeWidgetItem *tbitem = new QTreeWidgetItem(ui->treeWidget);
tbitem->setText(0, dialog.field_name);
tbitem->setText(1, dialog.field_type);
tbitem->setText(0, dialog.getFieldName());
tbitem->setText(1, dialog.getFieldType());
ui->treeWidget->addTopLevelItem(tbitem);
checkInput();
}
Expand Down
4 changes: 2 additions & 2 deletions src/EditTableDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class EditTableDialog : public QDialog
Q_OBJECT

public:
EditTableDialog(DBBrowserDB* pdb, QString tableName, QWidget* parent = 0);
explicit EditTableDialog(DBBrowserDB* pdb, QString tableName, QWidget* parent = 0);
~EditTableDialog();

public slots:
private slots:
virtual void populateFields();
virtual void editField();
virtual void addField();
Expand Down
4 changes: 2 additions & 2 deletions src/ExportCsvDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class ExportCsvDialog : public QDialog
Q_OBJECT

public:
ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent = 0);
explicit ExportCsvDialog(DBBrowserDB* db, QString deflocation, QWidget* parent = 0);
~ExportCsvDialog();

public slots:
private slots:
virtual void accept();

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

public:
FindDialog(QWidget* parent = 0);
explicit FindDialog(QWidget* parent = 0);
~FindDialog();

public slots:
virtual void showResults(resultMap rmap);
virtual void find();
virtual void resetFields(QStringList fieldlist = QStringList());

private slots:
virtual void find();
virtual void recordSelected(QTableWidgetItem* witem);
virtual void closeEvent(QCloseEvent*);

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

public:
ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent = 0);
explicit ImportCsvDialog(QString filename, DBBrowserDB* db, QWidget* parent = 0);
~ImportCsvDialog();

protected slots:
private slots:
virtual void accept();
virtual void updatePreview();
virtual void checkInput();
Expand Down
6 changes: 3 additions & 3 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ void MainWindow::editWinAway()
{
editWin->hide();
activateWindow();
ui->dataTable->setRangeSelected( QTableWidgetSelectionRange(editWin->curRow, editWin->curCol, editWin->curRow, editWin->curCol), true);
ui->dataTable->setRangeSelected(QTableWidgetSelectionRange(editWin->getCurrentRow(), editWin->getCurrentCol(), editWin->getCurrentRow(), editWin->getCurrentCol()), true);
}

void MainWindow::editText(int row, int col)
Expand Down Expand Up @@ -972,8 +972,8 @@ void MainWindow::editField()
EditFieldDialog dialog(&db, false, item->parent()->text(0), item->text(0), item->text(2), this);
if(dialog.exec())
{
item->setText(0, dialog.field_name);
item->setText(2, dialog.field_type);
item->setText(0, dialog.getFieldName());
item->setText(2, dialog.getFieldType());
}
}

Expand Down
32 changes: 14 additions & 18 deletions src/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget* parent = 0);
~MainWindow();

private:
Ui::MainWindow* ui;
SQLLogDock * logWin;
Expand All @@ -41,16 +45,13 @@ class MainWindow : public QMainWindow
int curBrowseOrderByIndex;
int curBrowseOrderByMode;

public:
MainWindow(QWidget* parent = 0);
~MainWindow();

EditDialog* editWin;
FindDialog* findWin;
QIntValidator * gotoValidator;
QIntValidator* gotoValidator;
QString defaultlocation;

private:
DBBrowserDB db;

void init();

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

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

public slots:
virtual void fileOpen( const QString & fileName );

private slots:
virtual void createTreeContextMenu(const QPoint & qPoint);
virtual void changeTreeSelection();
virtual void addField();
virtual void editField();
virtual void deleteField();
virtual void fileOpen( const QString & fileName );
virtual void fileOpen();
virtual void fileNew();
virtual void populateStructure();
Expand Down Expand Up @@ -111,18 +117,8 @@ public slots:
virtual void openRecentFile();
virtual void loadPragmas();
virtual void savePragmas();

protected:
DBBrowserDB db;

void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void resizeEvent(QResizeEvent *event);

protected slots:
virtual void mainTabSelected( int tabindex );
virtual void browseTableHeaderClicked(int logicalindex);

};

#endif // MAINFORM_H
#endif
4 changes: 2 additions & 2 deletions src/PreferencesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class PreferencesDialog : public QDialog
Q_OBJECT

public:
PreferencesDialog(QWidget* parent = 0);
explicit PreferencesDialog(QWidget* parent = 0);
~PreferencesDialog();

QString defaulttext;
QString defaultlocation;
QString defaultnewdata;
QString defaultencoding;

public slots:
private slots:
virtual void defaultDataChanged( int which );
virtual void defaultTextChanged( int which );
virtual void encodingChanged( int which );
Expand Down
36 changes: 18 additions & 18 deletions src/sqlbrowser_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@

/*following routines extracted from shell.c for dump support*/

/*
/Dump database to a file
*/
int load_database(sqlite3 * db, FILE * infile, int * lineErr){
int rc = 0;
process_input(db, infile, lineErr);

return rc;
}

/*
** Return TRUE if the last non-whitespace character in z[] is a semicolon.
** z[] is N characters long.
Expand Down Expand Up @@ -51,7 +41,7 @@ static int _all_whitespace(const char *z){
}


char *sqlbrowser_getline(FILE *in){
static char *sqlbrowser_getline(FILE *in){
char *zLine;
int nLine;
int n;
Expand Down Expand Up @@ -89,15 +79,15 @@ char *sqlbrowser_getline(FILE *in){
return zLine;
}

void process_input(sqlite3 * db, FILE *in, int * lineErr){
static void process_input(sqlite3 * db, FILE *in, int * lineErr){
char *zLine;
char *zSql = 0;
char * zErrMsg = 0;
int nSql = 0;
int rc;
while((zLine = sqlbrowser_getline(in))!=0 ){
if( (zSql==0 || zSql[0]==0) && _all_whitespace(zLine) ) continue;
(*lineErr)++;
(*lineErr)++;
if( zSql==0 ){
int i;
for(i=0; zLine[i] && isspace(zLine[i]); i++){}
Expand Down Expand Up @@ -126,12 +116,12 @@ void process_input(sqlite3 * db, FILE *in, int * lineErr){
/*printf("SQL error: %s\n", zErrMsg);*/
free(zErrMsg);
zErrMsg = 0;
if( zSql ){
free(zSql);
}
return;
if( zSql ){
free(zSql);
}
return;
}/*else{
printf("SQL error: %s\n", sqlite3_error_string(rc));
printf("SQL error: %s\n", sqlite3_error_string(rc));
}*/
}
free(zSql);
Expand All @@ -147,4 +137,14 @@ void process_input(sqlite3 * db, FILE *in, int * lineErr){
*lineErr = 0;
}

/*
/Dump database to a file
*/
int load_database(sqlite3 * db, FILE * infile, int * lineErr){
int rc = 0;
process_input(db, infile, lineErr);

return rc;
}

/* end of shell.c routines*/
2 changes: 0 additions & 2 deletions src/sqlbrowser_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ extern "C" {
#include <stdio.h>

int load_database(sqlite3 * db, FILE * infile, int * lineErr);
void process_input(sqlite3 * db, FILE *in, int * lineErr);
char *sqlbrowser_getline(FILE *in);

#ifdef __cplusplus
} /* End of the 'extern "C"' block */
Expand Down

0 comments on commit e4e840d

Please sign in to comment.