mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Make many methods and attributes of classes private
Make most variables, functions, slots etc. private instead of public. Also make the constructors explicit.
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
@@ -35,12 +39,12 @@ signals:
|
||||
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
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -27,8 +30,6 @@ private:
|
||||
QString original_field_name;
|
||||
QString table_name;
|
||||
bool is_new;
|
||||
|
||||
public:
|
||||
QString field_name;
|
||||
QString field_type;
|
||||
};
|
||||
|
||||
@@ -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();
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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*);
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@ class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWindow(QWidget* parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
SQLLogDock * logWin;
|
||||
@@ -41,16 +45,13 @@ private:
|
||||
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();
|
||||
@@ -59,14 +60,19 @@ private:
|
||||
|
||||
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();
|
||||
@@ -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
|
||||
|
||||
@@ -12,7 +12,7 @@ class PreferencesDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PreferencesDialog(QWidget* parent = 0);
|
||||
explicit PreferencesDialog(QWidget* parent = 0);
|
||||
~PreferencesDialog();
|
||||
|
||||
QString defaulttext;
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
QString defaultnewdata;
|
||||
QString defaultencoding;
|
||||
|
||||
public slots:
|
||||
private slots:
|
||||
virtual void defaultDataChanged( int which );
|
||||
virtual void defaultTextChanged( int which );
|
||||
virtual void encodingChanged( int which );
|
||||
|
||||
@@ -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.
|
||||
@@ -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;
|
||||
@@ -89,7 +79,7 @@ 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;
|
||||
@@ -97,7 +87,7 @@ void process_input(sqlite3 * db, FILE *in, int * lineErr){
|
||||
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++){}
|
||||
@@ -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);
|
||||
@@ -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*/
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user