mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Merge SQLLogDock and MainWindow
Move the SQL log dock into the main window. This means the log dock is now included in the MainWindow.ui file and its logic in MainWindow,cpp.
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "PreferencesDialog.h"
|
||||
#include "EditDialog.h"
|
||||
#include "FindDialog.h"
|
||||
#include "SQLLogDock.h"
|
||||
#include "SQLiteSyntaxHighlighter.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
@@ -46,10 +45,10 @@ MainWindow::~MainWindow()
|
||||
|
||||
void MainWindow::init()
|
||||
{
|
||||
// Create the SQL log dock
|
||||
logWin = new SQLLogDock(this);
|
||||
db.logWin = logWin;
|
||||
addDockWidget(Qt::BottomDockWidgetArea, logWin);
|
||||
// Init the SQL log dock
|
||||
db.mainWindow = this;
|
||||
sqliteHighlighterLogUser = new SQLiteSyntaxHighlighter(ui->editLogUser->document());
|
||||
sqliteHighlighterLogApp = new SQLiteSyntaxHighlighter(ui->editLogApplication->document());
|
||||
|
||||
// Set up the db tree widget
|
||||
ui->dbTreeWidget->setColumnHidden(1, true);
|
||||
@@ -60,7 +59,7 @@ void MainWindow::init()
|
||||
ui->editGoto->setValidator(gotoValidator);
|
||||
|
||||
// Create the SQL sytax highlighter
|
||||
sqliteHighlighter = new SQLiteSyntaxHighlighter(ui->sqlTextEdit->document());
|
||||
sqliteHighlighterTabSql = new SQLiteSyntaxHighlighter(ui->sqlTextEdit->document());
|
||||
|
||||
// Set up DB model
|
||||
queryResultListModel = new QStandardItemModel(this);
|
||||
@@ -87,23 +86,20 @@ void MainWindow::init()
|
||||
popupFieldMenu->addAction(ui->editDeleteFieldActionPopup);
|
||||
|
||||
// Set state of checkable menu actions
|
||||
ui->sqlLogAction->setChecked(!logWin->isHidden());
|
||||
ui->sqlLogAction->setChecked(!ui->dockLog->isHidden());
|
||||
ui->viewDBToolbarAction->setChecked(!ui->toolbarDB->isHidden());
|
||||
|
||||
// Connect some more signals and slots
|
||||
connect(ui->dataTable->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(browseTableHeaderClicked(int)));
|
||||
connect(ui->sqlLogAction, SIGNAL(toggled(bool)), logWin, SLOT(setVisible(bool)));
|
||||
connect(ui->dataTable->verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(setRecordsetLabel()));
|
||||
connect(editWin, SIGNAL(goingAway()), this, SLOT(editWinAway()));
|
||||
connect(editWin, SIGNAL(updateRecordText(int, int , QString)), this, SLOT(updateRecordText(int, int , QString)));
|
||||
connect(logWin, SIGNAL(goingAway()), this, SLOT(logWinAway()));
|
||||
connect(logWin, SIGNAL(dbState(bool)),this, SLOT(dbState(bool)));
|
||||
|
||||
// Load window settings
|
||||
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
|
||||
restoreGeometry(settings.value("MainWindow/geometry").toByteArray());
|
||||
restoreState(settings.value("MainWindow/windowState").toByteArray());
|
||||
logWin->comboLogType()->setCurrentIndex(logWin->comboLogType()->findText(settings.value("SQLLogDock/Log", "Application").toString()));
|
||||
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(settings.value("SQLLogDock/Log", "Application").toString()));
|
||||
|
||||
// Set other window settings
|
||||
setAcceptDrops(true);
|
||||
@@ -168,7 +164,9 @@ void MainWindow::populateStructure()
|
||||
}
|
||||
db.updateSchema();
|
||||
QStringList tblnames = db.getBrowsableObjectNames();
|
||||
sqliteHighlighter->setTableNames(tblnames);
|
||||
sqliteHighlighterTabSql->setTableNames(tblnames);
|
||||
sqliteHighlighterLogUser->setTableNames(tblnames);
|
||||
sqliteHighlighterLogApp->setTableNames(tblnames);
|
||||
|
||||
QMap<QString, QTreeWidgetItem*> typeToParentItem;
|
||||
QTreeWidgetItem* itemTables = new QTreeWidgetItem(ui->dbTreeWidget);
|
||||
@@ -285,7 +283,7 @@ void MainWindow::fileClose()
|
||||
populateStructure();
|
||||
loadPragmas();
|
||||
activateFields(false);
|
||||
logWin->clearLog();
|
||||
ui->buttonLogClear->click();
|
||||
}
|
||||
|
||||
void MainWindow::fileExit()
|
||||
@@ -309,7 +307,7 @@ void MainWindow::closeEvent( QCloseEvent* event )
|
||||
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
|
||||
settings.setValue("MainWindow/geometry", saveGeometry());
|
||||
settings.setValue("MainWindow/windowState", saveState());
|
||||
settings.setValue("SQLLogDock/Log", logWin->comboLogType()->currentText());
|
||||
settings.setValue("SQLLogDock/Log", ui->comboLogSubmittedBy->currentText());
|
||||
fileExit();
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
@@ -658,11 +656,6 @@ void MainWindow::updateRecordText(int row, int col, QString newtext)
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::logWinAway()
|
||||
{
|
||||
ui->sqlLogAction->toggle();
|
||||
}
|
||||
|
||||
void MainWindow::editWinAway()
|
||||
{
|
||||
editWin->hide();
|
||||
@@ -1151,3 +1144,15 @@ void MainWindow::savePragmas()
|
||||
db.setPragma("user_version", QString::number(ui->spinPragmaUserVersion->value()));
|
||||
db.setPragma("wal_autocheckpoint", QString::number(ui->spinPragmaWalAutoCheckpoint->value()));
|
||||
}
|
||||
|
||||
void MainWindow::logSql(const QString& sql, int msgtype)
|
||||
{
|
||||
if(msgtype == kLogMsg_User)
|
||||
{
|
||||
ui->editLogUser->append(sql);
|
||||
ui->editLogUser->verticalScrollBar()->setValue(ui->editLogUser->verticalScrollBar()->maximum());
|
||||
} else {
|
||||
ui->editLogApplication->append(sql);
|
||||
ui->editLogApplication->verticalScrollBar()->setValue(ui->editLogApplication->verticalScrollBar()->maximum());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#define ORDERMODE_DESC 1
|
||||
|
||||
class QDragEnterEvent;
|
||||
class SQLLogDock;
|
||||
class EditDialog;
|
||||
class FindDialog;
|
||||
class SQLiteSyntaxHighlighter;
|
||||
@@ -29,14 +28,15 @@ public:
|
||||
|
||||
private:
|
||||
Ui::MainWindow* ui;
|
||||
SQLLogDock * logWin;
|
||||
|
||||
QStandardItemModel *queryResultListModel;
|
||||
QMenu *popupTableMenu;
|
||||
QMenu *popupFieldMenu;
|
||||
QMenu *recentFilesMenu;
|
||||
|
||||
SQLiteSyntaxHighlighter* sqliteHighlighter;
|
||||
SQLiteSyntaxHighlighter* sqliteHighlighterTabSql;
|
||||
SQLiteSyntaxHighlighter* sqliteHighlighterLogUser;
|
||||
SQLiteSyntaxHighlighter* sqliteHighlighterLogApp;
|
||||
|
||||
enum { MaxRecentFiles = 5 };
|
||||
QAction *recentFileActs[MaxRecentFiles];
|
||||
@@ -66,6 +66,8 @@ protected:
|
||||
|
||||
public slots:
|
||||
virtual void fileOpen( const QString & fileName );
|
||||
virtual void logSql(const QString &sql, int msgtype);
|
||||
virtual void dbState(bool dirty);
|
||||
|
||||
private slots:
|
||||
virtual void createTreeContextMenu(const QPoint & qPoint);
|
||||
@@ -100,14 +102,12 @@ private slots:
|
||||
virtual void helpWhatsThis();
|
||||
virtual void helpAbout();
|
||||
virtual void updateRecordText( int row, int col, QString newtext );
|
||||
virtual void logWinAway();
|
||||
virtual void editWinAway();
|
||||
virtual void editText( int row, int col );
|
||||
virtual void doubleClickTable( int row, int col );
|
||||
virtual void executeQuery();
|
||||
virtual void importTableFromCSV();
|
||||
virtual void exportTableToCSV();
|
||||
virtual void dbState( bool dirty );
|
||||
virtual void fileSave();
|
||||
virtual void fileRevert();
|
||||
virtual void exportDatabaseToSQL();
|
||||
|
||||
@@ -1029,6 +1029,98 @@
|
||||
<addaction name="fileSaveAction"/>
|
||||
<addaction name="fileRevertAction"/>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="dockLog">
|
||||
<property name="features">
|
||||
<set>QDockWidget::AllDockWidgetFeatures</set>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SQL Log</string>
|
||||
</property>
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelLogSubmittedBy">
|
||||
<property name="text">
|
||||
<string>&Show SQL submitted by</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>comboLogSubmittedBy</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboLogSubmittedBy">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>User</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Application</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="buttonLogClear">
|
||||
<property name="text">
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="stackLog">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="editLogUser">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Monospace</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="editLogApplication">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Monospace</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<action name="fileNewAction">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/icons.qrc">
|
||||
@@ -1416,6 +1508,8 @@
|
||||
<tabstop>spinPragmaUserVersion</tabstop>
|
||||
<tabstop>spinPragmaWalAutoCheckpoint</tabstop>
|
||||
<tabstop>buttonBoxPragmas</tabstop>
|
||||
<tabstop>comboLogSubmittedBy</tabstop>
|
||||
<tabstop>buttonLogClear</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="icons/icons.qrc"/>
|
||||
@@ -1492,8 +1586,8 @@
|
||||
<slot>populateTable(QString)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>87</x>
|
||||
<y>91</y>
|
||||
<x>59</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1508,8 +1602,8 @@
|
||||
<slot>addRecord()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>623</x>
|
||||
<y>91</y>
|
||||
<x>584</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1524,8 +1618,8 @@
|
||||
<slot>deleteRecord()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>733</x>
|
||||
<y>91</y>
|
||||
<x>687</x>
|
||||
<y>82</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1541,7 +1635,7 @@
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>22</x>
|
||||
<y>559</y>
|
||||
<y>321</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1557,7 +1651,7 @@
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>114</x>
|
||||
<y>559</y>
|
||||
<y>321</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1572,8 +1666,8 @@
|
||||
<slot>navigateGoto()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>461</x>
|
||||
<y>559</y>
|
||||
<x>443</x>
|
||||
<y>321</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1588,8 +1682,8 @@
|
||||
<slot>navigateGoto()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>644</x>
|
||||
<y>558</y>
|
||||
<x>511</x>
|
||||
<y>321</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1604,8 +1698,8 @@
|
||||
<slot>browseFind(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>143</x>
|
||||
<y>91</y>
|
||||
<x>141</x>
|
||||
<y>81</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1620,8 +1714,8 @@
|
||||
<slot>browseRefresh()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>173</x>
|
||||
<y>91</y>
|
||||
<x>171</x>
|
||||
<y>81</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1684,8 +1778,8 @@
|
||||
<slot>doubleClickTable(int,int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>399</x>
|
||||
<y>325</y>
|
||||
<x>99</x>
|
||||
<y>113</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -1716,8 +1810,8 @@
|
||||
<slot>executeQuery()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>82</x>
|
||||
<y>302</y>
|
||||
<x>86</x>
|
||||
<y>177</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
@@ -2004,8 +2098,8 @@
|
||||
<slot>loadPragmas()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>243</x>
|
||||
<y>551</y>
|
||||
<x>247</x>
|
||||
<y>705</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
@@ -2020,8 +2114,8 @@
|
||||
<slot>savePragmas()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>715</x>
|
||||
<y>550</y>
|
||||
<x>360</x>
|
||||
<y>705</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>802</x>
|
||||
@@ -2029,6 +2123,86 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonLogClear</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>editLogApplication</receiver>
|
||||
<slot>clear()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>750</x>
|
||||
<y>392</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>642</x>
|
||||
<y>454</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonLogClear</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>editLogUser</receiver>
|
||||
<slot>clear()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>754</x>
|
||||
<y>387</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>611</x>
|
||||
<y>426</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>comboLogSubmittedBy</sender>
|
||||
<signal>currentIndexChanged(int)</signal>
|
||||
<receiver>stackLog</receiver>
|
||||
<slot>setCurrentIndex(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>193</x>
|
||||
<y>392</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>492</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>sqlLogAction</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>dockLog</receiver>
|
||||
<slot>setVisible(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>399</x>
|
||||
<y>467</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>dockLog</sender>
|
||||
<signal>visibilityChanged(bool)</signal>
|
||||
<receiver>sqlLogAction</receiver>
|
||||
<slot>setChecked(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>399</x>
|
||||
<y>467</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>-1</x>
|
||||
<y>-1</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>fileOpen()</slot>
|
||||
|
||||
@@ -1,172 +0,0 @@
|
||||
#include "SQLLogDock.h"
|
||||
#include <QScrollBar>
|
||||
#include "sqlitedb.h"
|
||||
#include "SQLiteSyntaxHighlighter.h"
|
||||
|
||||
/*
|
||||
* Constructs a sqlLogForm as a child of 'parent', with the
|
||||
* name 'name' and widget flags set to 'f'.
|
||||
*
|
||||
* The dialog will by default be modeless, unless you set 'modal' to
|
||||
* true to construct a modal dialog.
|
||||
*/
|
||||
SQLLogDock::SQLLogDock(QWidget* parent)
|
||||
: QDockWidget(tr("SQL Log"), parent)
|
||||
{
|
||||
setupUi();
|
||||
}
|
||||
|
||||
void SQLLogDock::setupUi()
|
||||
{
|
||||
contentWidget = new QWidget(this);
|
||||
this->setWidget(contentWidget);
|
||||
if (this->objectName().isEmpty())
|
||||
this->setObjectName(QString::fromUtf8("sqlLogForm"));
|
||||
vboxLayout = new QVBoxLayout(contentWidget);
|
||||
vboxLayout->setMargin(2);
|
||||
vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
|
||||
|
||||
hboxLayout = new QHBoxLayout();
|
||||
hboxLayout->setSpacing(3);
|
||||
hboxLayout->setObjectName(QString::fromUtf8("hboxLayout"));
|
||||
textLabel1 = new QLabel(this);
|
||||
textLabel1->setObjectName(QString::fromUtf8("textLabel1"));
|
||||
textLabel1->setWordWrap(false);
|
||||
|
||||
hboxLayout->addWidget(textLabel1);
|
||||
|
||||
m_comboLogType = new QComboBox(this);
|
||||
m_comboLogType->setObjectName(QString::fromUtf8("comboBox3"));
|
||||
|
||||
hboxLayout->addWidget(m_comboLogType);
|
||||
|
||||
spacer10 = new QSpacerItem(150, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
||||
|
||||
hboxLayout->addItem(spacer10);
|
||||
|
||||
clearButton = new QPushButton(this);
|
||||
clearButton->setObjectName(QString::fromUtf8("clearButton"));
|
||||
|
||||
hboxLayout->addWidget(clearButton);
|
||||
|
||||
vboxLayout->addLayout(hboxLayout);
|
||||
|
||||
logStack = new QStackedWidget(this);
|
||||
logStack->setObjectName(QString::fromUtf8("logStack"));
|
||||
WStackPage = new QWidget(logStack);
|
||||
WStackPage->setObjectName(QString::fromUtf8("WStackPage"));
|
||||
gridLayout = new QGridLayout(WStackPage);
|
||||
gridLayout->setSpacing(3);
|
||||
gridLayout->setContentsMargins(11, 11, 11, 11);
|
||||
gridLayout->setObjectName(QString::fromUtf8("gridLayout"));
|
||||
gridLayout->setContentsMargins(0, 0, 0, 0);
|
||||
userLogText = new QTextEdit(WStackPage);
|
||||
userLogText->setObjectName(QString::fromUtf8("userLogText"));
|
||||
userLogText->setReadOnly(true);
|
||||
|
||||
QFont font;
|
||||
font.setFamily("Courier");
|
||||
font.setFixedPitch(true);
|
||||
font.setPixelSize(11);
|
||||
userLogText->setFont(font);
|
||||
|
||||
mUserSqliteHighlighter = new SQLiteSyntaxHighlighter(userLogText->document());
|
||||
|
||||
gridLayout->addWidget(userLogText, 0, 0, 1, 1);
|
||||
logStack->addWidget(WStackPage);
|
||||
WStackPage->setLayout(gridLayout);
|
||||
|
||||
WStackPage1 = new QWidget(logStack);
|
||||
WStackPage1->setObjectName(QString::fromUtf8("WStackPage1"));
|
||||
vboxLayout1 = new QVBoxLayout(WStackPage1);
|
||||
vboxLayout1->setSpacing(3);
|
||||
vboxLayout1->setContentsMargins(11, 11, 11, 11);
|
||||
vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1"));
|
||||
vboxLayout1->setContentsMargins(0, 0, 0, 0);
|
||||
appLogText = new QTextEdit(WStackPage1);
|
||||
appLogText->setObjectName(QString::fromUtf8("appLogText"));
|
||||
appLogText->setReadOnly(true);
|
||||
appLogText->setFont(font);
|
||||
|
||||
mAppSqliteHighlighter = new SQLiteSyntaxHighlighter(appLogText->document());
|
||||
|
||||
logStack->addWidget(WStackPage1);
|
||||
vboxLayout1->addWidget(appLogText);
|
||||
WStackPage1->setLayout(vboxLayout1);
|
||||
|
||||
vboxLayout->addWidget(logStack);
|
||||
contentWidget->setLayout(vboxLayout);
|
||||
|
||||
|
||||
retranslateUi();
|
||||
QObject::connect(clearButton, SIGNAL(clicked()), this, SLOT(clearLog()));
|
||||
QObject::connect(m_comboLogType, SIGNAL(currentIndexChanged(int)), logStack, SLOT(setCurrentIndex(int)));
|
||||
|
||||
QMetaObject::connectSlotsByName(this);
|
||||
}
|
||||
|
||||
void SQLLogDock::retranslateUi()
|
||||
{
|
||||
this->setWindowTitle(QObject::tr("SQL Log"));
|
||||
textLabel1->setText(QObject::tr("Show SQL submitted by:"));
|
||||
m_comboLogType->clear();
|
||||
m_comboLogType->insertItems(0, QStringList()
|
||||
<< QObject::tr("User")
|
||||
<< QObject::tr("Application")
|
||||
);
|
||||
clearButton->setText(QObject::tr("Clear"));
|
||||
} // retranslateUi
|
||||
|
||||
|
||||
/*
|
||||
* Destroys the object and frees any allocated resources
|
||||
*/
|
||||
SQLLogDock::~SQLLogDock()
|
||||
{
|
||||
// no need to delete child widgets, Qt does it all for us
|
||||
}
|
||||
|
||||
/*
|
||||
* Sets the strings of the subwidgets using the current
|
||||
* language.
|
||||
*/
|
||||
void SQLLogDock::languageChange()
|
||||
{
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void SQLLogDock::closeEvent( QCloseEvent * )
|
||||
{
|
||||
emit goingAway();
|
||||
}
|
||||
|
||||
void SQLLogDock::log( QString & statement, int msgtype)
|
||||
{
|
||||
QScrollBar* sb = 0;
|
||||
if (msgtype==kLogMsg_User)
|
||||
{
|
||||
userLogText->append(statement);
|
||||
sb = userLogText->verticalScrollBar();
|
||||
} else {
|
||||
appLogText->append(statement);
|
||||
sb = appLogText->verticalScrollBar();
|
||||
}
|
||||
sb->setValue(sb->maximum());
|
||||
}
|
||||
|
||||
void SQLLogDock::msgDBDirtyState( bool dirty)
|
||||
{
|
||||
emit dbState(dirty);
|
||||
}
|
||||
|
||||
|
||||
void SQLLogDock::clearLog()
|
||||
{
|
||||
if (logStack->currentIndex()==kLogMsg_User)
|
||||
{
|
||||
userLogText->clear();
|
||||
} else {
|
||||
appLogText->clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
#ifndef SQLLOGFORM_H
|
||||
#define SQLLOGFORM_H
|
||||
|
||||
#include <QTextEdit>
|
||||
#include <QStackedWidget>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QSpacerItem>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
class SQLiteSyntaxHighlighter;
|
||||
|
||||
class SQLLogDock : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SQLLogDock(QWidget* parent = 0);
|
||||
~SQLLogDock();
|
||||
|
||||
QComboBox* comboLogType() { return m_comboLogType; }
|
||||
SQLiteSyntaxHighlighter* userSqliteHighlighter() { return mUserSqliteHighlighter; }
|
||||
SQLiteSyntaxHighlighter* appSqliteHighlighter() { return mAppSqliteHighlighter; }
|
||||
|
||||
private:
|
||||
QWidget* contentWidget;
|
||||
QVBoxLayout *vboxLayout;
|
||||
QHBoxLayout *hboxLayout;
|
||||
QLabel *textLabel1;
|
||||
QComboBox *m_comboLogType;
|
||||
QSpacerItem *spacer10;
|
||||
QPushButton *clearButton;
|
||||
QStackedWidget *logStack;
|
||||
QWidget *WStackPage;
|
||||
QGridLayout *gridLayout;
|
||||
QTextEdit *userLogText;
|
||||
QWidget *WStackPage1;
|
||||
QVBoxLayout *vboxLayout1;
|
||||
QTextEdit *appLogText;
|
||||
|
||||
SQLiteSyntaxHighlighter* mUserSqliteHighlighter;
|
||||
SQLiteSyntaxHighlighter* mAppSqliteHighlighter;
|
||||
|
||||
void setupUi();
|
||||
void retranslateUi();
|
||||
|
||||
public slots:
|
||||
virtual void closeEvent( QCloseEvent * );
|
||||
virtual void log( QString & statement, int msgtype );
|
||||
virtual void msgDBDirtyState( bool dirty );
|
||||
virtual void clearLog();
|
||||
|
||||
signals:
|
||||
void goingAway();
|
||||
void dbState(bool dirty);
|
||||
|
||||
protected slots:
|
||||
virtual void languageChange();
|
||||
|
||||
};
|
||||
|
||||
#endif // SQLLOGFORM_H
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "sqlitedb.h"
|
||||
#include "sqlbrowser_util.h"
|
||||
#include "MainWindow.h"
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QProgressDialog>
|
||||
#include "SQLLogDock.h"
|
||||
#include <QApplication>
|
||||
#include <QTextStream>
|
||||
|
||||
@@ -20,19 +20,15 @@ bool DBBrowserDB::isOpen ( )
|
||||
void DBBrowserDB::setDirty(bool dirtyval)
|
||||
{
|
||||
dirty = dirtyval;
|
||||
if (logWin)
|
||||
{
|
||||
logWin->msgDBDirtyState(dirty);
|
||||
}
|
||||
if(mainWindow)
|
||||
mainWindow->dbState(dirtyval);
|
||||
}
|
||||
|
||||
void DBBrowserDB::setDirtyDirect(bool dirtyval)
|
||||
{
|
||||
dirty = dirtyval;
|
||||
if (logWin)
|
||||
{
|
||||
logWin->msgDBDirtyState(dirty);
|
||||
}
|
||||
if(mainWindow)
|
||||
mainWindow->dbState(dirtyval);
|
||||
}
|
||||
|
||||
bool DBBrowserDB::getDirty()
|
||||
@@ -863,7 +859,7 @@ int DBBrowserDB::getRecordCount()
|
||||
|
||||
void DBBrowserDB::logSQL(QString statement, int msgtype)
|
||||
{
|
||||
if (logWin)
|
||||
if(mainWindow)
|
||||
{
|
||||
/*limit log message to a sensible size, this will truncate some binary messages*/
|
||||
int loglimit = 300;
|
||||
@@ -872,7 +868,7 @@ void DBBrowserDB::logSQL(QString statement, int msgtype)
|
||||
statement.truncate(32);
|
||||
statement.append(QObject::tr("... <string too wide to log, probably contains binary data> ..."));
|
||||
}
|
||||
logWin->log(statement, msgtype);
|
||||
mainWindow->logSql(statement, msgtype);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
#include <sqlite3.h>
|
||||
|
||||
class SQLLogDock;
|
||||
class MainWindow;
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -82,7 +81,7 @@ private:
|
||||
class DBBrowserDB
|
||||
{
|
||||
public:
|
||||
DBBrowserDB (): _db( 0 ) , hasValidBrowseSet(false), curEncoding(kEncodingUTF8) {}
|
||||
DBBrowserDB (): _db( 0 ) , hasValidBrowseSet(false), curEncoding(kEncodingUTF8), mainWindow(0) {}
|
||||
~DBBrowserDB (){}
|
||||
bool open ( const QString & db);
|
||||
bool create ( const QString & db);
|
||||
@@ -143,7 +142,7 @@ public:
|
||||
int curEncoding;
|
||||
QString curNewData;
|
||||
|
||||
SQLLogDock * logWin;
|
||||
MainWindow* mainWindow;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@@ -13,7 +13,6 @@ CONFIG += qt \
|
||||
HEADERS += \
|
||||
sqlitedb.h \
|
||||
sqlbrowser_util.h \
|
||||
SQLLogDock.h \
|
||||
MainWindow.h \
|
||||
SQLiteSyntaxHighlighter.h \
|
||||
CreateIndexDialog.h \
|
||||
@@ -29,7 +28,6 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
sqlitedb.cpp \
|
||||
sqlbrowser_util.c \
|
||||
SQLLogDock.cpp \
|
||||
main.cpp \
|
||||
MainWindow.cpp \
|
||||
SQLiteSyntaxHighlighter.cpp \
|
||||
|
||||
Reference in New Issue
Block a user