From 6459cd4fc70fbaa0aa8131e298c639d49e8b34b7 Mon Sep 17 00:00:00 2001 From: Peinthor Rene Date: Sun, 20 Jan 2013 22:01:49 +0100 Subject: [PATCH] move the whole mainwindow ui into a layout file .ui there might still be crashes or bad behavior because i missed some widgets --- src/icons/edit-find.png | Bin 0 -> 617 bytes src/icons/icons.qrc | 1 + src/mainwindow.cpp | 1102 ++++++++------------------------------- src/mainwindow.h | 161 ++---- src/mainwindow.ui | 545 +++++++++++++++++++ src/src.pro | 2 +- 6 files changed, 796 insertions(+), 1015 deletions(-) create mode 100644 src/icons/edit-find.png create mode 100644 src/mainwindow.ui diff --git a/src/icons/edit-find.png b/src/icons/edit-find.png new file mode 100644 index 0000000000000000000000000000000000000000..d072d3cbe2dadb1494f77e950952123813613677 GIT binary patch literal 617 zcmV-v0+#)WP)4+SOttuFuo0rp8m zK~y-)osvy!6Hyq2pF7DUO`2wgN>U06wOwc$MHIn>xD*Oicj6|$z;CJaABeUjK|~aE zS$9RDeGK5zq#vnP18H_P9en3BbiKg914X(U4?fX zv=3%78D?M10+5(X0MN8+cL(3TuaZiqIeKc0ZN-aeE4XBZ)ck8EZr_Z=qW7OQ{wVDZ zG+iT=PIKtw7@rGX1_uI+90*bpKD5zs{F**C6zm9u?EJ zQ5_2JmL<2Flg761XDbP7v)0}Ku5Shi%_G^x}q%2kVgpPOH0wIvBfN{N(qOE7M? z3xuFtwW!u4n_D&9s)POg9;6U0U2p=nX__rgY-58pql(|7qW8J5Es5XbtmWcc6+03YVxryf3dbXat2*wyQorvicCWHaaM z^${Ko^E;cZ_ht1ff`3FT9+eG|{}KR{SUhS0lnsNw28{O8e>3MU00000NkvXXu0mjf D_c;L2 literal 0 HcmV?d00001 diff --git a/src/icons/icons.qrc b/src/icons/icons.qrc index 7601cf15..2ec40a79 100644 --- a/src/icons/icons.qrc +++ b/src/icons/icons.qrc @@ -19,6 +19,7 @@ table.png tag_blue.png view-refresh.png + edit-find.png oldimages/128.png diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 219cb962..ff89c2b5 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,6 +12,7 @@ #include #include +#include "ui_mainwindow.h" #include "createtableform.h" #include "createindexform.h" #include "deletetableform.h" @@ -28,801 +29,6 @@ #include "SQLLogDock.h" #include "sqlitesyntaxhighlighter.h" -void MainWindow::setupUi() -{ - if (this->objectName().isEmpty()){ - this->setObjectName(QString::fromUtf8("mainForm")); - } - - logWin = new SQLLogDock(this); - sqlLogAction = logWin->toggleViewAction(); - sqlLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); - this->addDockWidget(Qt::BottomDockWidgetArea, logWin); - - //** New DB File - fileNewAction = new QAction(this); - fileNewAction->setObjectName(QString::fromUtf8("fileNewAction")); - fileNewAction->setText("fileNewAction"); - fileNewAction->setIcon(QIcon(":/icons/db_new")); - - //** Open DB File - fileOpenAction = new QAction(this); - fileOpenAction->setObjectName(QString::fromUtf8("fileOpenAction")); - fileOpenAction->setText("fileOpenAction"); - fileOpenAction->setIcon(QIcon(":/icons/db_open")); - - //** Save DB Action - fileSaveAction = new QAction(this); - fileSaveAction->setObjectName(QString::fromUtf8("fileSaveAction")); - fileSaveAction->setText("fileSaveAction"); - fileSaveAction->setEnabled(false); - fileSaveAction->setIcon(QIcon(":/icons/db_save")); - QFont fntS = fileSaveAction->font(); - fntS.setBold(true); - fileSaveAction->setFont(fntS); - - //** Db Revert - fileRevertAction = new QAction(this); - fileRevertAction->setObjectName(QString::fromUtf8("fileRevertAction")); - fileRevertAction->setText("fileRevertAction"); - fileRevertAction->setEnabled(false); - fileRevertAction->setIcon(QIcon(":/icons/db_revert")); - QFont fntR = fileRevertAction->font(); - fntR.setBold(true); - fileRevertAction->setFont(fntR); - - // Recent dbs - for(int i = 0; i < MaxRecentFiles; ++i) { - recentFileActs[i] = new QAction(this); - recentFileActs[i]->setVisible(false); - this->connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); - } - - - //** Exit - fileExitAction = new QAction(this); - fileExitAction->setObjectName(QString::fromUtf8("fileExitAction")); - fileExitAction->setText("fileExitAction"); - - editCopyAction = new QAction(this); - editCopyAction->setObjectName(QString::fromUtf8("editCopyAction")); - editCopyAction->setText("editCopyAction"); - editPasteAction = new QAction(this); - editPasteAction->setObjectName(QString::fromUtf8("editPasteAction")); - editPasteAction->setText("editPasteAction"); - editFindAction = new QAction(this); - editFindAction->setObjectName(QString::fromUtf8("editFindAction")); - editFindAction->setText("editFindAction"); - editFindAction->setIcon(QIcon(":/oldimages/searchfind")); - editFindAction->setIconVisibleInMenu(true); - helpContentsAction = new QAction(this); - helpContentsAction->setObjectName(QString::fromUtf8("helpContentsAction")); - helpContentsAction->setText("helpContentsAction"); - helpIndexAction = new QAction(this); - helpIndexAction->setObjectName(QString::fromUtf8("helpIndexAction")); - helpIndexAction->setText("helpIndexAction"); - helpAboutAction = new QAction(this); - helpAboutAction->setObjectName(QString::fromUtf8("helpAboutAction")); - helpAboutAction->setText("helpAboutAction"); - - //** Close Database ?? - fileCloseAction = new QAction(this); - fileCloseAction->setObjectName(QString::fromUtf8("fileCloseAction")); - fileCloseAction->setText("fileCloseAction"); - fileCloseAction->setEnabled(false); - - newRecordAction = new QAction(this); - newRecordAction->setObjectName(QString::fromUtf8("newRecordAction")); - newRecordAction->setText("newRecordAction"); - fileCompactAction = new QAction(this); - fileCompactAction->setObjectName(QString::fromUtf8("fileCompactAction")); - fileCompactAction->setText("fileCompactAction"); - fileCompactAction->setEnabled(false); - helpWhatsThisAction = new QAction(this); - helpWhatsThisAction->setObjectName(QString::fromUtf8("helpWhatsThisAction")); - helpWhatsThisAction->setText("helpWhatsThisAction"); - helpWhatsThisAction->setIcon(QIcon(":/oldimages/whatis")); - helpWhatsThisAction->setIconVisibleInMenu(true); - - sqlLogAction->setText("sqlLogAction"); - sqlLogAction->setIcon(QIcon(":/oldimages/log")); - sqlLogAction->setIconVisibleInMenu(true); - - - fileImportCSVAction = new QAction(this); - fileImportCSVAction->setObjectName(QString::fromUtf8("fileImportCSVAction")); - fileImportCSVAction->setText("fileImportCSVAction"); - fileExportCSVAction = new QAction(this); - fileExportCSVAction->setObjectName(QString::fromUtf8("fileExportCSVAction")); - fileExportCSVAction->setText("fileExportCSVAction"); - - - - - //fileImportAction = new QAction(this); - //fileImportAction->setObjectName(QString::fromUtf8("fileImportAction")); - //fileImportAction->setName("fileImportAction"); - //fileExportAction = new QAction(this); - //fileExportAction->setObjectName(QString::fromUtf8("fileExportAction")); - //fileExportAction->setName("fileExportAction"); - - //** Create Table - editCreateTableAction = new QAction(this); - editCreateTableAction->setObjectName(QString::fromUtf8("editCreateTableAction")); - editCreateTableAction->setText("editCreateTableAction"); - editCreateTableAction->setEnabled(false); - editCreateTableAction->setIcon(QIcon(":/icons/table_create")); - - //** Delete table - editDeleteTableAction = new QAction(this); - editDeleteTableAction->setObjectName(QString::fromUtf8("editDeleteTableAction")); - editDeleteTableAction->setText("editDeleteTableAction"); - editDeleteTableAction->setEnabled(false); - editDeleteTableAction->setIcon(QIcon(":/icons/table_delete")); - - editDeleteTableActionPopup = new QAction(this); - editDeleteTableActionPopup->setEnabled(false); - editDeleteTableActionPopup->setIcon(QIcon(":/icons/table_delete")); - - //** Modify Table - editModifyTableAction = new QAction(this); - editModifyTableAction->setObjectName(QString::fromUtf8("editModifyTableAction")); - editModifyTableAction->setText("editModifyTableAction"); - editModifyTableAction->setEnabled(false); - editModifyTableAction->setIcon(QIcon(":/icons/table_modify")); - - editModifyTableActionPopup = new QAction(this); - editModifyTableActionPopup->setEnabled(false); - editModifyTableActionPopup->setIcon(QIcon(":/icons/table_modify")); - - - //************************************************ - //** Add, Modify, Delete Field - editAddFieldActionPopup = new QAction(this); - editAddFieldActionPopup->setText("Add Field"); - editAddFieldActionPopup->setDisabled(true); - editAddFieldActionPopup->setIcon(QIcon(":/icons/field_add")); - - editModifyFieldActionPopup = new QAction(this); - editModifyFieldActionPopup->setText("Modify Field"); - editModifyFieldActionPopup->setDisabled(true); - editModifyFieldActionPopup->setIcon(QIcon(":/icons/field_edit")); - - editDeleteFieldActionPopup = new QAction(this); - editDeleteFieldActionPopup->setText("Delete Field"); - editDeleteFieldActionPopup->setDisabled(true); - editDeleteFieldActionPopup->setIcon(QIcon(":/icons/field_delete")); - - //************************************************ - //** Create/Delete Index - editCreateIndexAction = new QAction(this); - editCreateIndexAction->setObjectName(QString::fromUtf8("editCreateIndexAction")); - editCreateIndexAction->setText("editCreateIndexAction"); - editCreateIndexAction->setEnabled(false); - editCreateIndexAction->setIcon(QIcon(":/icons/index_create")); - - editDeleteIndexAction = new QAction(this); - editDeleteIndexAction->setObjectName(QString::fromUtf8("editDeleteIndexAction")); - editDeleteIndexAction->setText("editDeleteIndexAction"); - editDeleteIndexAction->setEnabled(false); - editDeleteIndexAction->setIcon(QIcon(":/icons/index_delete")); - - fileImportSQLAction = new QAction(this); - fileImportSQLAction->setObjectName(QString::fromUtf8("fileImportSQLAction")); - fileImportSQLAction->setText("fileImportSQLAction"); - fileExportSQLAction = new QAction(this); - fileExportSQLAction->setObjectName(QString::fromUtf8("fileExportSQLAction")); - fileExportSQLAction->setText("fileExportSQLAction"); - editPreferencesAction = new QAction(this); - editPreferencesAction->setObjectName(QString::fromUtf8("editPreferencesAction")); - editPreferencesAction->setText("editPreferencesAction"); - widget = new QWidget(this); - widget->setObjectName(QString::fromUtf8("widget")); - vboxLayout = new QVBoxLayout(widget); - vboxLayout->setSpacing(0); - vboxLayout->setContentsMargins(0,0,0,0); - vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); - vboxLayout->setContentsMargins(0, 0, 0, 0); - mainTab = new QTabWidget(widget); - mainTab->setObjectName(QString::fromUtf8("mainTab")); - structure = new QWidget(); - structure->setObjectName(QString::fromUtf8("structure")); - - - vboxLayout1 = new QVBoxLayout(structure); - vboxLayout1->setSpacing(0); - vboxLayout1->setContentsMargins(0,0,0,0); - vboxLayout1->setObjectName(QString::fromUtf8("vboxLayout1")); - - //**** Structure *********************************** - QToolBar *dbToolbar = new QToolBar(); - vboxLayout1->addWidget(dbToolbar); - dbToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - dbToolbar->addAction(editCreateTableAction); - dbToolbar->addAction(editModifyTableActionPopup); - dbToolbar->addAction(editDeleteTableActionPopup); - dbToolbar->addSeparator(); - dbToolbar->addAction(editAddFieldActionPopup); - dbToolbar->addAction(editModifyFieldActionPopup); - dbToolbar->addAction(editDeleteFieldActionPopup); - - //*** Tree Widget Setup - dbTreeWidget = new QTreeWidget(); - vboxLayout1->addWidget(dbTreeWidget); - QTreeWidgetItem *headerItem = dbTreeWidget->headerItem(); - headerItem->setText(0, QApplication::translate("mainForm", "Name", 0, QApplication::UnicodeUTF8)); - headerItem->setText(1, QApplication::translate("mainForm", "Object", 0, QApplication::UnicodeUTF8)); - headerItem->setText(2, QApplication::translate("mainForm", "Type", 0, QApplication::UnicodeUTF8)); - headerItem->setText(3, QApplication::translate("mainForm", "Schema", 0, QApplication::UnicodeUTF8)); - dbTreeWidget->setColumnHidden(1, true); - dbTreeWidget->setColumnWidth(0, 300); - dbTreeWidget->setAlternatingRowColors(true); - dbTreeWidget->setRootIsDecorated(true); - dbTreeWidget->setAnimated(true); - dbTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu ); - - - - mainTab->addTab(structure, QString()); - browser = new QWidget(); - browser->setObjectName(QString::fromUtf8("browser")); - vboxLayout2 = new QVBoxLayout(browser); - vboxLayout2->setSpacing(6); - vboxLayout2->setContentsMargins(11, 11, 11, 11); - vboxLayout2->setObjectName(QString::fromUtf8("vboxLayout2")); - hboxLayout = new QHBoxLayout(); - hboxLayout->setSpacing(6); - hboxLayout->setObjectName(QString::fromUtf8("hboxLayout")); - textLabel1 = new QLabel(browser); - textLabel1->setObjectName(QString::fromUtf8("textLabel1")); - textLabel1->setWordWrap(false); - - hboxLayout->addWidget(textLabel1); - - comboBrowseTable = new QComboBox(browser); - comboBrowseTable->setObjectName(QString::fromUtf8("comboBrowseTable")); - comboBrowseTable->setMinimumSize(QSize(115, 0)); - comboBrowseTable->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); - - hboxLayout->addWidget(comboBrowseTable); - - buttonFind = new QPushButton(browser); - buttonFind->setObjectName(QString::fromUtf8("buttonFind")); - buttonFind->setIcon(QIcon(":/oldimages/searchfind")); - buttonFind->setCheckable(true); - - hboxLayout->addWidget(buttonFind); - - buttonRefresh = new QPushButton(browser); - buttonRefresh->setObjectName("buttonRefresh"); - buttonRefresh->setIcon(QIcon(":/icons/refresh")); - buttonRefresh->setShortcut(QKeySequence(Qt::Key_F5)); - - hboxLayout->addWidget(buttonRefresh); - - spacer1 = new QSpacerItem(51, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout->addItem(spacer1); - - buttonNewRecord = new QPushButton(browser); - buttonNewRecord->setObjectName(QString::fromUtf8("buttonNewRecord")); - - hboxLayout->addWidget(buttonNewRecord); - - buttonDeleteRecord = new QPushButton(browser); - buttonDeleteRecord->setObjectName(QString::fromUtf8("buttonDeleteRecord")); - - hboxLayout->addWidget(buttonDeleteRecord); - - - vboxLayout2->addLayout(hboxLayout); - - dataTable = new QTableWidget(browser); - dataTable->setObjectName(QString::fromUtf8("dataTable")); - dataTable->setAcceptDrops(true); - dataTable->setRowCount(0); - dataTable->setColumnCount(0); - dataTable->setSelectionMode(QTableWidget::SingleSelection); - dataTable->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); - - vboxLayout2->addWidget(dataTable); - - hboxLayout1 = new QHBoxLayout(); - hboxLayout1->setSpacing(6); - hboxLayout1->setObjectName(QString::fromUtf8("hboxLayout1")); - buttonPrevious = new QPushButton(browser); - buttonPrevious->setObjectName(QString::fromUtf8("buttonPrevious")); - QSizePolicy sizePolicy(static_cast(0), static_cast(0)); - sizePolicy.setHorizontalStretch(0); - sizePolicy.setVerticalStretch(0); - sizePolicy.setHeightForWidth(buttonPrevious->sizePolicy().hasHeightForWidth()); - buttonPrevious->setSizePolicy(sizePolicy); - - hboxLayout1->addWidget(buttonPrevious); - - labelRecordset = new QLabel(browser); - labelRecordset->setObjectName(QString::fromUtf8("labelRecordset")); - labelRecordset->setWordWrap(false); - - hboxLayout1->addWidget(labelRecordset); - - buttonNext = new QPushButton(browser); - buttonNext->setObjectName(QString::fromUtf8("buttonNext")); - sizePolicy.setHeightForWidth(buttonNext->sizePolicy().hasHeightForWidth()); - buttonNext->setSizePolicy(sizePolicy); - - hboxLayout1->addWidget(buttonNext); - - spacer4 = new QSpacerItem(50, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout1->addItem(spacer4); - - buttonGoto = new QPushButton(browser); - buttonGoto->setObjectName(QString::fromUtf8("buttonGoto")); - - hboxLayout1->addWidget(buttonGoto); - - editGoto = new QLineEdit(browser); - editGoto->setObjectName(QString::fromUtf8("editGoto")); - sizePolicy.setHeightForWidth(editGoto->sizePolicy().hasHeightForWidth()); - editGoto->setSizePolicy(sizePolicy); - - hboxLayout1->addWidget(editGoto); - - - vboxLayout2->addLayout(hboxLayout1); - - mainTab->addTab(browser, QString()); - query = new QWidget(); - query->setObjectName(QString::fromUtf8("query")); - vboxLayout3 = new QVBoxLayout(query); - vboxLayout3->setSpacing(6); - vboxLayout3->setContentsMargins(11, 11, 11, 11); - vboxLayout3->setObjectName(QString::fromUtf8("vboxLayout3")); - textLabel1_2 = new QLabel(query); - textLabel1_2->setObjectName(QString::fromUtf8("textLabel1_2")); - textLabel1_2->setWordWrap(false); - - vboxLayout3->addWidget(textLabel1_2); - - sqlTextEdit = new QTextEdit(query); - sqlTextEdit->setObjectName(QString::fromUtf8("sqlTextEdit")); - QSizePolicy sizePolicy1(static_cast(7), static_cast(5)); - sizePolicy1.setHorizontalStretch(0); - sizePolicy1.setVerticalStretch(0); - sizePolicy1.setHeightForWidth(sqlTextEdit->sizePolicy().hasHeightForWidth()); - sqlTextEdit->setSizePolicy(sizePolicy1); - QFont font; - font.setFamily("Courier"); - font.setFixedPitch(true); - font.setPixelSize(11); - sqlTextEdit->setFont(font); - - sqliteHighlighter = new SQLiteSyntaxHighlighter(sqlTextEdit->document()); - - vboxLayout3->addWidget(sqlTextEdit); - - hboxLayout2 = new QHBoxLayout(); - hboxLayout2->setSpacing(6); - hboxLayout2->setObjectName(QString::fromUtf8("hboxLayout2")); - executeQueryButton = new QPushButton(query); - executeQueryButton->setObjectName(QString::fromUtf8("executeQueryButton")); - - hboxLayout2->addWidget(executeQueryButton); - - spacer4_2 = new QSpacerItem(325, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); - - hboxLayout2->addItem(spacer4_2); - - - vboxLayout3->addLayout(hboxLayout2); - - textLabel2 = new QLabel(query); - textLabel2->setObjectName(QString::fromUtf8("textLabel2")); - textLabel2->setWordWrap(false); - - vboxLayout3->addWidget(textLabel2); - - queryErrorLineEdit = new QLineEdit(query); - queryErrorLineEdit->setObjectName(QString::fromUtf8("queryErrorLineEdit")); - queryErrorLineEdit->setReadOnly(true); - queryErrorLineEdit->setDisabled(true); - - vboxLayout3->addWidget(queryErrorLineEdit); - - textLabel3 = new QLabel(query); - textLabel3->setObjectName(QString::fromUtf8("textLabel3")); - textLabel3->setWordWrap(false); - - vboxLayout3->addWidget(textLabel3); - - queryResultListModel = new QStandardItemModel(query); - - queryResultTableView = new QTableView(query); - queryResultTableView->setObjectName(QString::fromUtf8("queryResultTableView")); - queryResultTableView->setSelectionMode(QTreeView::NoSelection); - queryResultTableView->setModel(queryResultListModel); - queryResultTableView->setEditTriggers(QAbstractItemView::NoEditTriggers); - queryResultTableView->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); - - vboxLayout3->addWidget(queryResultTableView); - - mainTab->addTab(query, QString()); - - vboxLayout->addWidget(mainTab); - - this->setCentralWidget(widget); - - //*** Setup Toolbar - toolbarDB = new QToolBar(); - this->addToolBar(Qt::TopToolBarArea, toolbarDB); - toolbarDB->setObjectName(QString::fromUtf8("Toolbar")); - toolbarDB->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); - - viewDBToolbarAction = toolbarDB->toggleViewAction(); - - //*** Setup main Menu - menubar = this->menuBar(); //new QMenuBar(this); - menubar->setObjectName(QString::fromUtf8("menubar")); - fileMenu = new QMenu(menubar); - fileMenu->setObjectName(QString::fromUtf8("fileMenu")); - importMenu = new QMenu(fileMenu); - importMenu->setObjectName(QString::fromUtf8("PopupMenuEditor_9")); - exportMenu = new QMenu(fileMenu); - exportMenu->setObjectName(QString::fromUtf8("PopupMenuEditor_12")); - EditMenu = new QMenu(menubar); - EditMenu->setObjectName(QString::fromUtf8("EditMenu")); - ViewMenu = new QMenu(menubar); - ViewMenu->setObjectName(QString::fromUtf8("ViewMenu")); - PopupMenu = new QMenu(menubar); - PopupMenu->setObjectName(QString::fromUtf8("PopupMenu")); - - toolbarDB->addAction(fileNewAction); - toolbarDB->addAction(fileOpenAction); - toolbarDB->addSeparator(); - - toolbarDB->addAction(fileSaveAction); - toolbarDB->addAction(fileRevertAction); - toolbarDB->addSeparator(); - - /* - Toolbar->addAction(editCreateTableAction); - Toolbar->addAction(editDeleteTableAction); - Toolbar->addAction(editModifyTableAction); - Toolbar->addSeparator(); - - Toolbar->addAction(editCreateIndexAction); - Toolbar->addAction(editDeleteIndexAction); - Toolbar->addSeparator(); - - Toolbar->addAction(sqlLogAction); - Toolbar->addSeparator(); - Toolbar->addAction(helpWhatsThisAction); - */ - - menubar->addAction(fileMenu->menuAction()); - menubar->addAction(EditMenu->menuAction()); - menubar->addAction(ViewMenu->menuAction()); - menubar->addAction(PopupMenu->menuAction()); - - fileMenu->addAction(fileNewAction); - fileMenu->addAction(fileOpenAction); - fileMenu->addAction(fileCloseAction); - fileMenu->addSeparator(); - fileMenu->addAction(fileSaveAction); - fileMenu->addAction(fileRevertAction); - fileMenu->addAction(fileCompactAction); - fileMenu->addSeparator(); - //fileMenu->addAction(fileImportAction); - fileMenu->addAction(importMenu->menuAction()); - //fileMenu->addAction(fileExportAction); - fileMenu->addAction(exportMenu->menuAction()); - - recentSeparatorAct = fileMenu->addSeparator(); - for(int i = 0; i < MaxRecentFiles; ++i) - fileMenu->addAction(recentFileActs[i]); - - - fileMenu->addSeparator(); - fileMenu->addAction(fileExitAction); - importMenu->addAction(fileImportSQLAction); - importMenu->addAction(fileImportCSVAction); - exportMenu->addAction(fileExportSQLAction); - exportMenu->addAction(fileExportCSVAction); - EditMenu->addAction(editCreateTableAction); - EditMenu->addAction(editDeleteTableAction); - EditMenu->addAction(editModifyTableAction); - EditMenu->addSeparator(); - EditMenu->addAction(editCreateIndexAction); - EditMenu->addAction(editDeleteIndexAction); - EditMenu->addSeparator(); - EditMenu->addAction(editPreferencesAction); - ViewMenu->addAction(sqlLogAction); - ViewMenu->addAction(viewDBToolbarAction); - PopupMenu->addAction(helpWhatsThisAction); - PopupMenu->addAction(helpAboutAction); - - //***********************************************8 - //** Db Tree Popup Menus - popupTableMenu = new QMenu(this); - popupTableMenu->addAction(editModifyTableActionPopup); - popupTableMenu->addAction(editAddFieldActionPopup); - popupTableMenu->addSeparator(); - popupTableMenu->addAction(editDeleteTableActionPopup); - - popupFieldMenu = new QMenu(this); - popupFieldMenu->addAction(editModifyFieldActionPopup); - popupFieldMenu->addAction(editDeleteFieldActionPopup); - //spopupFieldMenu->addSeparator(); - //popupFieldMenu->addAction(editDeleteTableActionPopup); - - - retranslateUi(); - QObject::connect(fileExitAction, SIGNAL(triggered()), this, SLOT(close())); - QObject::connect(fileOpenAction, SIGNAL(activated()), this, SLOT(fileOpen())); - QObject::connect(fileNewAction, SIGNAL(activated()), this, SLOT(fileNew())); - QObject::connect(fileCloseAction, SIGNAL(activated()), this, SLOT(fileClose())); - QObject::connect(comboBrowseTable, SIGNAL(activated(QString)), this, SLOT(populateTable(QString))); - QObject::connect(buttonNewRecord, SIGNAL(clicked()), this, SLOT(addRecord())); - QObject::connect(buttonDeleteRecord, SIGNAL(clicked()), this, SLOT(deleteRecord())); - QObject::connect(buttonPrevious, SIGNAL(clicked()), this, SLOT(navigatePrevious())); - QObject::connect(buttonNext, SIGNAL(clicked()), this, SLOT(navigateNext())); - QObject::connect(editGoto, SIGNAL(returnPressed()), this, SLOT(navigateGoto())); - QObject::connect(buttonGoto, SIGNAL(clicked()), this, SLOT(navigateGoto())); - QObject::connect(buttonFind, SIGNAL(toggled(bool)), this, SLOT(browseFind(bool))); - QObject::connect(buttonRefresh, SIGNAL(clicked()), this, SLOT(browseRefresh())); - QObject::connect(fileCompactAction, SIGNAL(activated()), this, SLOT(compact())); - QObject::connect(editCopyAction, SIGNAL(activated()), this, SLOT(copy())); - QObject::connect(editPasteAction, SIGNAL(activated()), this, SLOT(paste())); - QObject::connect(helpWhatsThisAction, SIGNAL(activated()), this, SLOT(helpWhatsThis())); - QObject::connect(helpAboutAction, SIGNAL(activated()), this, SLOT(helpAbout())); - QObject::connect(dataTable, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickTable(int,int))); - QObject::connect(dataTable->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(browseTableHeaderClicked(int))); - QObject::connect(mainTab, SIGNAL(currentChanged(int)), this, SLOT(mainTabSelected(int))); - QObject::connect(executeQueryButton, SIGNAL(clicked()), this, SLOT(executeQuery())); - QObject::connect(fileImportCSVAction, SIGNAL(activated()), this, SLOT(importTableFromCSV())); - QObject::connect(fileExportCSVAction, SIGNAL(activated()), this, SLOT(exportTableToCSV())); - QObject::connect(fileRevertAction, SIGNAL(activated()), this, SLOT(fileRevert())); - QObject::connect(fileSaveAction, SIGNAL(activated()), this, SLOT(fileSave())); - QObject::connect(editDeleteIndexAction, SIGNAL(activated()), this, SLOT(deleteIndex())); - QObject::connect(editCreateIndexAction, SIGNAL(activated()), this, SLOT(createIndex())); - QObject::connect(editCreateTableAction, SIGNAL(activated()), this, SLOT(createTable())); - - QObject::connect(editDeleteTableAction, SIGNAL(activated()), this, SLOT(deleteTable())); - QObject::connect(editModifyTableAction, SIGNAL(activated()), this, SLOT(editTable())); - QObject::connect(editDeleteTableActionPopup, SIGNAL(activated()), this, SLOT(deleteTablePopup())); - QObject::connect(editModifyTableActionPopup, SIGNAL(activated()), this, SLOT(editTablePopup())); - QObject::connect(editAddFieldActionPopup, SIGNAL(activated()), this, SLOT(on_add_field())); - QObject::connect(editModifyFieldActionPopup, SIGNAL(activated()), this, SLOT(on_edit_field())); - - QObject::connect(fileExportSQLAction, SIGNAL(activated()), this, SLOT(exportDatabaseToSQL())); - QObject::connect(fileImportSQLAction, SIGNAL(activated()), this, SLOT(importDatabaseFromSQL())); - QObject::connect(editPreferencesAction, SIGNAL(activated()), this, SLOT(openPreferences())); - - QObject::connect(dbTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(on_tree_context_menu(const QPoint &))); - QObject::connect(dbTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(on_tree_selection_changed())); -} // setupUi - -void MainWindow::retranslateUi() -{ - this->setWindowTitle(QObject::tr("Browser")); - - fileNewAction->setIconText(QObject::tr("New Database")); - fileNewAction->setText(QObject::tr("&New Database")); - fileNewAction->setToolTip(QObject::tr("Create a new database file")); - fileNewAction->setWhatsThis(QObject::tr("This option is used to create a new database file.")); - fileNewAction->setShortcut(QObject::tr("Ctrl+N")); - - fileOpenAction->setIconText(QObject::tr("Open Database")); - fileOpenAction->setText(QObject::tr("&Open Database")); - fileOpenAction->setToolTip(QObject::tr("Open an existing database file")); - fileOpenAction->setWhatsThis(QObject::tr("This option is used to open an existing database file.")); - fileOpenAction->setShortcut(QObject::tr("Ctrl+O")); - - fileExitAction->setIconText(QObject::tr("Exit")); - fileExitAction->setText(QObject::tr("E&xit")); - fileExitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); - - editCopyAction->setIconText(QObject::tr("Copy")); - editCopyAction->setText(QObject::tr("&Copy")); - editCopyAction->setWhatsThis(QObject::tr("Copies the selected text to the clipboard")); - editCopyAction->setShortcut(QObject::tr("Ctrl+C")); - - editPasteAction->setIconText(QObject::tr("Paste")); - editPasteAction->setText(QObject::tr("&Paste")); - editPasteAction->setWhatsThis(QObject::tr("Pastes text from the clipboard into the current text insertion point")); - editPasteAction->setShortcut(QObject::tr("Ctrl+V")); - - editFindAction->setIconText(QObject::tr("Find")); - editFindAction->setText(QObject::tr("&Find...")); - editFindAction->setShortcut(QObject::tr("F")); - - helpContentsAction->setIconText(QObject::tr("Contents")); - helpContentsAction->setText(QObject::tr("&Contents...")); - helpContentsAction->setShortcut(QString()); - - helpIndexAction->setIconText(QObject::tr("Index")); - helpIndexAction->setText(QObject::tr("&Index...")); - helpIndexAction->setShortcut(QString()); - - helpAboutAction->setIconText(QObject::tr("About")); - helpAboutAction->setText(QObject::tr("&About")); - helpAboutAction->setShortcut(QString()); - - fileCloseAction->setIconText(QObject::tr("Close Database")); - fileCloseAction->setText(QObject::tr("&Close Database")); - fileCloseAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); - - newRecordAction->setIconText(QObject::tr("New Record")); - newRecordAction->setText(QObject::tr("New Record")); - - fileCompactAction->setIconText(QObject::tr("Compact Database")); - fileCompactAction->setText(QObject::tr("Compact Database")); - fileCompactAction->setStatusTip(QObject::tr("Compact the database file, removing space wasted by deleted records.")); - fileCompactAction->setWhatsThis(QObject::tr("Compact the database file, removing space wasted by deleted records.")); - - helpWhatsThisAction->setIconText(QObject::tr("What's This?")); - helpWhatsThisAction->setText(QObject::tr("What's This?")); - helpWhatsThisAction->setShortcut(QObject::tr("Shift+F1")); - - sqlLogAction->setIconText(QObject::tr("SQL Log")); - sqlLogAction->setText(QObject::tr("SQL &Log")); - sqlLogAction->setWhatsThis(QObject::tr("Display or hide the SQL log window, which stores all SQL commands issued by the user or the application.")); - - viewDBToolbarAction->setText(QObject::tr("&DB Toolbar")); - sqlLogAction->setWhatsThis(QObject::tr("Shows or hides the Database toolbar.")); - - fileImportCSVAction->setIconText(QObject::tr("Table from CSV file")); - fileImportCSVAction->setText(QObject::tr("Table from CSV file")); - fileImportCSVAction->setToolTip(QObject::tr("Open a wizard that lets you import data from a comma separated text file into a database table.")); - fileImportCSVAction->setWhatsThis(QObject::tr("Open a wizard that lets you import data from a comma separated text file into a database table. CSV files can be created on most database and spreadsheet applications.")); - - fileExportCSVAction->setIconText(QObject::tr("Table as CSV file")); - fileExportCSVAction->setText(QObject::tr("Table as CSV file")); - fileExportCSVAction->setToolTip(QObject::tr("Export a database table as a comma separated text file.")); - fileExportCSVAction->setWhatsThis(QObject::tr("Export a database table as a comma separated text file, ready to be imported into other database or spreadsheet applications.")); - - fileSaveAction->setIconText(QObject::tr("Write Changes")); - fileSaveAction->setText(QObject::tr("Revert Changes")); - fileSaveAction->setToolTip(QObject::tr("Write changes to the database file")); - fileSaveAction->setWhatsThis(QObject::tr("This option is used to save changes to the database file.")); - - fileRevertAction->setIconText(QObject::tr("Revert Changes")); - fileRevertAction->setText(QObject::tr("Revert Changes")); - fileRevertAction->setToolTip(QObject::tr("Revert database to last saved state")); - fileRevertAction->setWhatsThis(QObject::tr("This option is used to revert the current database file to its last saved state. All changes made since the last save operation are lost.")); - - //fileImportAction->setIconText(QObject::tr("Import")); - //fileImportAction->setText(QObject::tr("Import")); - //fileExportAction->setIconText(QObject::tr("Export")); - //fileExportAction->setText(QObject::tr("Export")); - - editCreateTableAction->setIconText(QObject::tr("Create Table")); - editCreateTableAction->setText(QObject::tr("Create Table")); - editCreateTableAction->setWhatsThis(QObject::tr("Open the Create Table wizard, where it is possible to define the name and fields for a new table in the database")); - - editDeleteTableAction->setIconText(QObject::tr("Delete Table")); - editDeleteTableAction->setText(QObject::tr("Delete Table")); - - editDeleteTableActionPopup->setIconText(QObject::tr("Delete Table")); - editDeleteTableActionPopup->setText(QObject::tr("Delete Table")); - - - editDeleteTableAction->setWhatsThis(QObject::tr("Open the Delete Table wizard, where you can select a database table to be dropped.")); - - editModifyTableAction->setIconText(QObject::tr("Modify Table")); - editModifyTableAction->setText(QObject::tr("Modify Table")); - - editModifyTableActionPopup->setIconText(QObject::tr("Modify Table")); - editModifyTableActionPopup->setText(QObject::tr("Modify Table")); - - editModifyTableAction->setWhatsThis(QObject::tr("Open the Modify Table wizard, where it is possible to rename an existing table. It is also possible to add or delete fields form a table, as well as modify field names and types.")); - - editCreateIndexAction->setIconText(QObject::tr("Create Index")); - editCreateIndexAction->setText(QObject::tr("Create Index")); - editCreateIndexAction->setWhatsThis(QObject::tr("Open the Create Index wizard, where it is possible to define a new index on an existing database table.")); - - editDeleteIndexAction->setIconText(QObject::tr("Delete Index")); - editDeleteIndexAction->setText(QObject::tr("Delete Index")); - editDeleteIndexAction->setWhatsThis(QObject::tr("Open the Delete Index wizard, where you can select a database index to be dropped.")); - - fileImportSQLAction->setIconText(QObject::tr("Database from SQL file")); - fileImportSQLAction->setText(QObject::tr("Database from SQL file")); - fileImportSQLAction->setToolTip(QObject::tr("Import data from an .sql dump text file into a new or existing database.")); - fileImportSQLAction->setWhatsThis(QObject::tr("This option lets you import data from an .sql dump text file into a new or existing database. SQL dump files can be created on most database engines, including MySQL and PostgreSQL.")); - - fileExportSQLAction->setIconText(QObject::tr("Database to SQL file")); - fileExportSQLAction->setText(QObject::tr("Database to SQL file")); - fileExportSQLAction->setToolTip(QObject::tr("Export a database to a .sql dump text file.")); - fileExportSQLAction->setWhatsThis(QObject::tr("This option lets you export a database to a .sql dump text file. SQL dump files contain all data necessary to recreate the database on most database engines, including MySQL and PostgreSQL.")); - - editPreferencesAction->setIconText(QObject::tr("Preferences")); - editPreferencesAction->setText(QObject::tr("&Preferences")); - editPreferencesAction->setToolTip(QObject::tr("Open the preferences window..")); - editPreferencesAction->setWhatsThis(QObject::tr("Open the preferences window.")); - - mainTab->setProperty("toolTip", QVariant(QString())); - mainTab->setTabText(mainTab->indexOf(structure), QObject::tr("Database &Structure")); - - textLabel1->setText(QObject::tr("Table:")); - - comboBrowseTable->clear(); - comboBrowseTable->insertItems(0, QStringList() - << QObject::tr("select") - << QObject::tr("users") - ); - comboBrowseTable->setProperty("toolTip", QVariant(QObject::tr("Select a table to browse data"))); - comboBrowseTable->setProperty("whatsThis", QVariant(QObject::tr("Use this list to select a table to be displayed in the database view"))); - - buttonFind->setText(QString()); - buttonFind->setProperty("toolTip", QVariant(QObject::tr("Open or close the floating find window"))); - buttonFind->setProperty("whatsThis", QVariant(QObject::tr("This button toggles the appearance of the Find window, used to search records in the database view"))); - buttonFind->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); - - - buttonRefresh->setProperty("toolTip", QVariant( QObject::tr("Refresh the data in the selected table."))); - buttonRefresh->setProperty("whatsThis", QVariant( QObject::tr("This button refreshes the data in the currently selected table."))); - - buttonNewRecord->setText(QObject::tr("New Record")); - buttonNewRecord->setProperty("toolTip", QVariant(QObject::tr("Insert a new record in the current table"))); - buttonNewRecord->setProperty("whatsThis", QVariant(QObject::tr("This button creates a new, empty record in the database"))); - - buttonDeleteRecord->setText(QObject::tr("Delete Record")); - buttonDeleteRecord->setProperty("toolTip", QVariant(QObject::tr("Delete the current record"))); - buttonDeleteRecord->setProperty("whatsThis", QVariant(QObject::tr("This button deletes the record currently selected in the database"))); - - - dataTable->setProperty("toolTip", QVariant(QString())); - dataTable->setProperty("whatsThis", QVariant(QObject::tr("This is the database view. You can double-click any record to edit its contents in the cell editor window."))); - - buttonPrevious->setText(QObject::tr("<")); - buttonPrevious->setProperty("toolTip", QVariant(QObject::tr("Go to previous record set page"))); - buttonPrevious->setProperty("whatsThis", QVariant(QObject::tr("This button is used to navigate to the previous set of 1000 records in the database view"))); - - labelRecordset->setText(QObject::tr("1000 - 2000 of 100000")); - - buttonNext->setText(QObject::tr(">")); - buttonNext->setProperty("toolTip", QVariant(QObject::tr("Go to next record set page"))); - buttonNext->setProperty("whatsThis", QVariant(QObject::tr("This button is used to navigate to the next 1000 records set in the database view"))); - - buttonGoto->setText(QObject::tr("Go to:")); - buttonGoto->setProperty("toolTip", QVariant(QObject::tr("Click here to browse the specified record "))); - buttonGoto->setProperty("whatsThis", QVariant(QObject::tr("This button is used to navigate to the record number specied in the Go to: area."))); - - editGoto->setText(QObject::tr("0")); - editGoto->setProperty("toolTip", QVariant(QObject::tr("Enter record number to browse"))); - editGoto->setProperty("whatsThis", QVariant(QObject::tr("Type a record number in this area and click the Go to: button to display the record in the database view"))); - - mainTab->setTabText(mainTab->indexOf(browser), QObject::tr("&Browse Data")); - textLabel1_2->setText(QObject::tr("SQL string:")); - - sqlTextEdit->setProperty("toolTip", QVariant(QObject::tr("Type SQL string here"))); - sqlTextEdit->setProperty("whatsThis", QVariant(QObject::tr("Type the SQL query in this area, and press the button below to execute it. Results and error messages will be shown in the fields at the bottom of this form."))); - - executeQueryButton->setText(QObject::tr("Execute query")); - executeQueryButton->setProperty("toolTip", QVariant(QObject::tr("Execute SQL query"))); - executeQueryButton->setProperty("whatsThis", QVariant(QObject::tr("This button is used to execute the SQL query entered in the text area above."))); - - textLabel2->setText(QObject::tr("Error message from database engine:")); - - queryErrorLineEdit->setProperty("toolTip", QVariant(QObject::tr("Error messages"))); - queryErrorLineEdit->setProperty("whatsThis", QVariant(QObject::tr("Messages returned from the database engine when the SQL query is executed are displayed in this area."))); - - textLabel3->setText(QObject::tr("Data returned:")); - - queryResultTableView->setProperty("toolTip", QVariant(QObject::tr("Query generated data"))); - queryResultTableView->setProperty("whatsThis", QVariant(QObject::tr("This table displays data returned from the database engine as a result of the SQL query. You can not modify data directly on this view, only consult it."))); - - mainTab->setTabText(mainTab->indexOf(query), QObject::tr("E&xecute SQL")); - //Toolbar->setLabel(QObject::tr("Toolbar")); - fileMenu->setTitle(QObject::tr("&File")); - importMenu->setTitle(QObject::tr("&Import")); - exportMenu->setTitle(QObject::tr("&Export")); - EditMenu->setTitle(QObject::tr("&Edit")); - ViewMenu->setTitle(QObject::tr("&View")); - PopupMenu->setTitle(QObject::tr("&Help")); -} // retranslateUi - /* * Constructs a mainForm as a child of 'parent', with the * name 'name' and widget flags set to 'f'. @@ -830,7 +36,9 @@ void MainWindow::retranslateUi() */ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent) + , ui(new Ui::MainWindow) { + ui->setupUi(this); setupUi(); setAcceptDrops(true); @@ -844,21 +52,139 @@ MainWindow::MainWindow(QWidget* parent) MainWindow::~MainWindow() { destroy(); - // no need to delete child widgets, Qt does it all for us + delete ui; } -/* - * Sets the strings of the subwidgets using the current - * language. - */ -void MainWindow::languageChange() +void MainWindow::setupUi() { - retranslateUi(); -} + logWin = new SQLLogDock(this); + sqlLogAction = logWin->toggleViewAction(); + sqlLogAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L)); + this->addDockWidget(Qt::BottomDockWidgetArea, logWin); + + // Recent dbs + for(int i = 0; i < MaxRecentFiles; ++i) { + recentFileActs[i] = new QAction(this); + recentFileActs[i]->setVisible(false); + this->connect(recentFileActs[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); + } + + sqlLogAction->setText(QObject::tr("SQL &Log")); + sqlLogAction->setIcon(QIcon(":/oldimages/log")); + sqlLogAction->setIconVisibleInMenu(true); + + // structure tab + // this tab needs manual love, because toolbars are normaly not in child widgets + + QToolBar *dbToolbar = new QToolBar(); + ui->structureTab->layout()->addWidget(dbToolbar); + dbToolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + dbToolbar->addAction(ui->actionCreateTable); + dbToolbar->addAction(ui->actionModify_Table); + dbToolbar->addAction(ui->actionDelete_Table); + dbToolbar->addSeparator(); + dbToolbar->addAction(ui->actionCreate_Field); + dbToolbar->addAction(ui->actionModifyField); + dbToolbar->addAction(ui->actionDelete_Field); + + dbTreeWidget = new QTreeWidget(); + ui->structureTab->layout()->addWidget(dbTreeWidget); + QTreeWidgetItem *headerItem = dbTreeWidget->headerItem(); + headerItem->setText(0, QApplication::translate("mainForm", "Name", 0, QApplication::UnicodeUTF8)); + headerItem->setText(1, QApplication::translate("mainForm", "Object", 0, QApplication::UnicodeUTF8)); + headerItem->setText(2, QApplication::translate("mainForm", "Type", 0, QApplication::UnicodeUTF8)); + headerItem->setText(3, QApplication::translate("mainForm", "Schema", 0, QApplication::UnicodeUTF8)); + dbTreeWidget->setColumnHidden(1, true); + dbTreeWidget->setColumnWidth(0, 300); + dbTreeWidget->setAlternatingRowColors(true); + dbTreeWidget->setRootIsDecorated(true); + dbTreeWidget->setAnimated(true); + dbTreeWidget->setContextMenuPolicy( Qt::CustomContextMenu ); + + ui->dataTable->setAcceptDrops(true); + ui->dataTable->setRowCount(0); + ui->dataTable->setColumnCount(0); + ui->dataTable->setSelectionMode(QTableWidget::SingleSelection); + ui->dataTable->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); + + sqliteHighlighter = new SQLiteSyntaxHighlighter(ui->textEditSQLexpression->document()); + + queryResultListModel = new QStandardItemModel(ui->queryResultTableView); + + ui->queryResultTableView->setSelectionMode(QTreeView::NoSelection); + ui->queryResultTableView->setModel(queryResultListModel); + ui->queryResultTableView->setEditTriggers(QAbstractItemView::NoEditTriggers); + ui->queryResultTableView->setHorizontalScrollMode( QAbstractItemView::ScrollPerPixel ); + + recentSeparatorAct = ui->menu_File->insertSeparator(ui->action_Quit); + for(int i = 0; i < MaxRecentFiles; ++i) + ui->menu_File->insertAction(recentSeparatorAct, recentFileActs[i]); + + ui->menu_View->addAction(sqlLogAction); + QAction* toggleDBToolbar = ui->toolBarDB->toggleViewAction(); + toggleDBToolbar->setText(QObject::tr("DB Toolbar")); + ui->menu_View->addAction(toggleDBToolbar); + + //***********************************************8 + //** Db Tree Popup Menus + popupTableMenu = new QMenu(this); + popupTableMenu->addAction(ui->actionModify_Table); + popupTableMenu->addAction(ui->actionCreateTable); + popupTableMenu->addSeparator(); + popupTableMenu->addAction(ui->actionDelete_Table); + + popupFieldMenu = new QMenu(this); + popupFieldMenu->addAction(ui->actionModifyField); + popupFieldMenu->addAction(ui->actionDelete_Field); + + + QObject::connect(ui->action_Quit, SIGNAL(triggered()), this, SLOT(close())); + QObject::connect(ui->action_Open_Database, SIGNAL(activated()), this, SLOT(fileOpen())); + QObject::connect(ui->action_New_Database, SIGNAL(activated()), this, SLOT(fileNew())); + QObject::connect(ui->action_Close_Database, SIGNAL(activated()), this, SLOT(fileClose())); + QObject::connect(ui->comboBrowseTable, SIGNAL(activated(QString)), this, SLOT(populateTable(QString))); + QObject::connect(ui->pushButtonNewRecord, SIGNAL(clicked()), this, SLOT(addRecord())); + QObject::connect(ui->pushButtonDeleteRecord, SIGNAL(clicked()), this, SLOT(deleteRecord())); + QObject::connect(ui->pushButtonPrevious, SIGNAL(clicked()), this, SLOT(navigatePrevious())); + QObject::connect(ui->pushButtonNext, SIGNAL(clicked()), this, SLOT(navigateNext())); + QObject::connect(ui->lineEditGoto, SIGNAL(returnPressed()), this, SLOT(navigateGoto())); + QObject::connect(ui->pushButtonGoto, SIGNAL(clicked()), this, SLOT(navigateGoto())); + QObject::connect(ui->pushButtonFind, SIGNAL(toggled(bool)), this, SLOT(browseFind(bool))); + QObject::connect(ui->pushButtonRefresh, SIGNAL(clicked()), this, SLOT(browseRefresh())); + QObject::connect(ui->actionCom_pact_Database, SIGNAL(activated()), this, SLOT(compact())); +// QObject::connect(editCopyAction, SIGNAL(activated()), this, SLOT(copy())); +// QObject::connect(editPasteAction, SIGNAL(activated()), this, SLOT(paste())); + QObject::connect(ui->actionWhats_this, SIGNAL(activated()), this, SLOT(helpWhatsThis())); + QObject::connect(ui->action_About, SIGNAL(activated()), this, SLOT(helpAbout())); + QObject::connect(ui->dataTable, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(doubleClickTable(int,int))); + QObject::connect(ui->dataTable->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(browseTableHeaderClicked(int))); + QObject::connect(ui->mainTabContainer, SIGNAL(currentChanged(int)), this, SLOT(mainTabSelected(int))); + QObject::connect(ui->executeQueryButton, SIGNAL(clicked()), this, SLOT(executeQuery())); + QObject::connect(ui->actionFrom_CSV_File, SIGNAL(activated()), this, SLOT(importTableFromCSV())); + QObject::connect(ui->actionTable_t_o_CSV_File, SIGNAL(activated()), this, SLOT(exportTableToCSV())); + QObject::connect(ui->action_Revert_Changes, SIGNAL(activated()), this, SLOT(fileRevert())); + QObject::connect(ui->action_Write_Changes, SIGNAL(activated()), this, SLOT(fileSave())); + QObject::connect(ui->actionDelete_Index, SIGNAL(activated()), this, SLOT(deleteIndex())); + QObject::connect(ui->actionCreate_Index, SIGNAL(activated()), this, SLOT(createIndex())); + QObject::connect(ui->actionCreateTable, SIGNAL(activated()), this, SLOT(createTable())); + QObject::connect(ui->actionDelete_Table, SIGNAL(activated()), this, SLOT(deleteTable())); + QObject::connect(ui->actionModify_Table, SIGNAL(activated()), this, SLOT(editTable())); + + QObject::connect(ui->actionDelete_Table, SIGNAL(activated()), this, SLOT(deleteTablePopup())); + QObject::connect(ui->actionModify_Table, SIGNAL(activated()), this, SLOT(editTablePopup())); + QObject::connect(ui->actionCreate_Field, SIGNAL(activated()), this, SLOT(on_add_field())); + QObject::connect(ui->actionModifyField, SIGNAL(activated()), this, SLOT(on_edit_field())); + + QObject::connect(ui->actionDatabase_to_SQL_File, SIGNAL(activated()), this, SLOT(exportDatabaseToSQL())); + QObject::connect(ui->actionFrom_SQL_File, SIGNAL(activated()), this, SLOT(importDatabaseFromSQL())); + QObject::connect(ui->action_Preference, SIGNAL(activated()), this, SLOT(openPreferences())); + + QObject::connect(dbTreeWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(on_tree_context_menu(const QPoint &))); + QObject::connect(dbTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(on_tree_selection_changed())); +} // setupUi void MainWindow::init() { - findWin = 0; editWin = 0; @@ -867,13 +193,13 @@ void MainWindow::init() recsPerView = 1000; recAtTop = 0; gotoValidator = new QIntValidator(0, 0, this); - editGoto->setValidator(gotoValidator); + ui->lineEditGoto->setValidator(gotoValidator); gotoValidator->setRange ( 0, 0); resetBrowser(); this->setWindowTitle(QApplication::applicationName()); this->setWindowIcon( QPixmap( g_applicationIconName ) ); - buttonNext->setEnabled(false); - buttonPrevious->setEnabled(false); + ui->pushButtonNext->setEnabled(false); + ui->pushButtonPrevious->setEnabled(false); updateRecentFileActions(); @@ -1024,8 +350,8 @@ void MainWindow::populateTable( const QString & tablename, bool keepColumnWidths QString orderby = QString::number(curBrowseOrderByIndex) + " " + (curBrowseOrderByMode == ORDERMODE_ASC ? "ASC" : "DESC"); if (!db.browseTable(tablename, orderby)){ - dataTable->setRowCount( 0 ); - dataTable->setColumnCount( 0 ); + ui->dataTable->setRowCount( 0 ); + ui->dataTable->setColumnCount( 0 ); QApplication::restoreOverrideCursor(); if (findWin){ findWin->resetFields(db.getTableFields("")); @@ -1055,19 +381,19 @@ void MainWindow::populateTable( const QString & tablename, bool keepColumnWidths void MainWindow::resetBrowser() { recAtTop = 0; - QString sCurrentTable = comboBrowseTable->currentText(); - comboBrowseTable->clear(); + QString sCurrentTable = ui->comboBrowseTable->currentText(); + ui->comboBrowseTable->clear(); QStringList tab = db.getTableNames(); if(!tab.isEmpty()) { - comboBrowseTable->addItems(tab); + ui->comboBrowseTable->addItems(tab); } setRecordsetLabel(); - int pos = comboBrowseTable->findText(sCurrentTable); + int pos = ui->comboBrowseTable->findText(sCurrentTable); pos = pos == -1 ? 0 : pos; - comboBrowseTable->setCurrentIndex(pos); + ui->comboBrowseTable->setCurrentIndex(pos); curBrowseOrderByIndex = 1; curBrowseOrderByMode = ORDERMODE_ASC; - populateTable(comboBrowseTable->currentText()); + populateTable(ui->comboBrowseTable->currentText()); } void MainWindow::fileClose() @@ -1130,9 +456,9 @@ void MainWindow::addRecord() void MainWindow::deleteRecord() { - if (dataTable->currentRow()!=-1){ - int lastselected = dataTable->currentRow(); - db.deleteRecord(dataTable->currentRow()+recAtTop); + if (ui->dataTable->currentRow()!=-1){ + int lastselected = ui->dataTable->currentRow(); + db.deleteRecord(ui->dataTable->currentRow()+recAtTop); populateTable(db.curBrowseTableName); int nextselected = lastselected ; if (nextselected > db.getRecordCount()){ @@ -1169,9 +495,9 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) // qDebug("line to select value is %d, rowAttop = %d",lineToSelect, recAtTop); QApplication::setOverrideCursor( Qt::WaitCursor ); - dataTable->setRowCount(0); - dataTable->setColumnCount( db.browseFields.count() ); - dataTable->setHorizontalHeaderLabels(db.browseFields); + ui->dataTable->setRowCount(0); + ui->dataTable->setColumnCount( db.browseFields.count() ); + ui->dataTable->setHorizontalHeaderLabels(db.browseFields); rowList tab = db.browseRecs; int maxRecs = db.getRecordCount(); @@ -1182,7 +508,7 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) // qDebug("recsthisview= %d\n",recsThisView); - dataTable->setRowCount(recsThisView); + ui->dataTable->setRowCount(recsThisView); if ( recsThisView > 0 ) { @@ -1194,7 +520,7 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) //for ( int = tab.at(recAtTop); rt !=tab.end(); ++rt ) { rowLabel.setNum(recAtTop+rowNum+1); - dataTable->setVerticalHeaderItem(rowNum, new QTableWidgetItem( rowLabel )); + ui->dataTable->setVerticalHeaderItem(rowNum, new QTableWidgetItem( rowLabel )); colNum = 0; QStringList& rt = tab[i]; for (int e = 1; e < rt.size(); ++e) @@ -1207,7 +533,7 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) QTableWidgetItem* item = new QTableWidgetItem(content); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); item->setToolTip(wrapText(content)); - dataTable->setItem( rowNum, colNum, item); + ui->dataTable->setItem( rowNum, colNum, item); colNum++; //} } @@ -1218,14 +544,14 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) } if(!keepColumnWidths) { - for(int i = 0; i < dataTable->columnCount(); ++i) + for(int i = 0; i < ui->dataTable->columnCount(); ++i) { - dataTable->resizeColumnToContents(i); - if( dataTable->columnWidth(i) > 400 ) - dataTable->setColumnWidth(i, 400); + ui->dataTable->resizeColumnToContents(i); + if( ui->dataTable->columnWidth(i) > 400 ) + ui->dataTable->setColumnWidth(i, 400); } } - //dataTable->clearSelection(true); + //ui->dataTable->clearSelection(true); if (lineToSelect!=-1){ //qDebug("inside selection"); selectTableLine(lineToSelect); @@ -1236,10 +562,10 @@ void MainWindow::updateTableView(int lineToSelect, bool keepColumnWidths) void MainWindow::selectTableLine(int lineToSelect) { - dataTable->clearSelection(); - dataTable->selectRow(lineToSelect); - dataTable->setCurrentCell(lineToSelect, 0); - dataTable->scrollToItem(dataTable->itemAt(lineToSelect, 0)); + ui->dataTable->clearSelection(); + ui->dataTable->selectRow(lineToSelect); + ui->dataTable->setCurrentCell(lineToSelect, 0); + ui->dataTable->scrollToItem(ui->dataTable->itemAt(lineToSelect, 0)); } void MainWindow::navigatePrevious() @@ -1265,7 +591,7 @@ void MainWindow::navigateNext() void MainWindow::navigateGoto() { - QString typed = editGoto->text(); + QString typed = ui->lineEditGoto->text(); bool ok; int dec = typed.toInt( &ok); if (dec==0) dec=1; @@ -1273,13 +599,13 @@ void MainWindow::navigateGoto() recAtTop = ((dec-1)/recsPerView)*recsPerView; updateTableView(dec-recAtTop-1); - editGoto->setText(QString::number(dec,10)); + ui->lineEditGoto->setText(QString::number(dec,10)); } void MainWindow::setRecordsetLabel() { if (db.getRecordCount()==0){ - labelRecordset->setText("0 - 0 of 0"); + ui->labelRecordset->setText("0 - 0 of 0"); } else { QString label = QString::number(recAtTop+1,10); label.append(" - "); @@ -1289,24 +615,24 @@ void MainWindow::setRecordsetLabel() label.append(QString::number(lastthisview,10)); label.append(" of "); label.append(QString::number(db.getRecordCount(),10)); - labelRecordset->setText(label); + ui->labelRecordset->setText(label); } gotoValidator->setRange ( 0, db.getRecordCount()); if (db.getRecordCount()>1000){ if (recAtTop>=1000) { - buttonPrevious->setEnabled(TRUE); + ui->pushButtonPrevious->setEnabled(TRUE); } else { - buttonPrevious->setEnabled(FALSE); + ui->pushButtonPrevious->setEnabled(FALSE); } if (db.getRecordCount()>=(recAtTop+1000)) { - buttonNext->setEnabled(TRUE); + ui->pushButtonNext->setEnabled(TRUE); } else { - buttonNext->setEnabled(FALSE); + ui->pushButtonNext->setEnabled(FALSE); } } else { - buttonNext->setEnabled(FALSE); - buttonPrevious->setEnabled(FALSE); + ui->pushButtonNext->setEnabled(FALSE); + ui->pushButtonPrevious->setEnabled(FALSE); } } @@ -1331,12 +657,12 @@ void MainWindow::browseFind(bool open) void MainWindow::browseFindAway() { - buttonFind->toggle(); + ui->pushButtonFind->toggle(); } void MainWindow::browseRefresh() { - populateTable(comboBrowseTable->currentText(), true); + populateTable(ui->comboBrowseTable->currentText(), true); } void MainWindow::lookfor( const QString & wfield, const QString & woperator, const QString & wsearchterm ) @@ -1450,8 +776,8 @@ void MainWindow::compact() db.open(db.curDBFilename); populateStructure(); resetBrowser(); - fileCloseAction->setEnabled(true); - fileCompactAction->setEnabled(true); + ui->action_Close_Database->setEnabled(true); + ui->actionCom_pact_Database->setEnabled(true); QApplication::restoreOverrideCursor( ); } @@ -1579,7 +905,7 @@ void MainWindow::deleteIndex() void MainWindow::copy() { - QWidget * t =dataTable->cellWidget(dataTable->currentRow(), dataTable->currentColumn()); + QWidget * t =ui->dataTable->cellWidget(ui->dataTable->currentRow(), ui->dataTable->currentColumn()); if (t!=0){ if (QString(t->metaObject()->className()) == "QLineEdit"){ /*we are in edit mode*/ @@ -1589,14 +915,14 @@ void MainWindow::copy() } } } - if (editGoto->hasFocus()) - editGoto->copy(); + if (ui->lineEditGoto->hasFocus()) + ui->lineEditGoto->copy(); } void MainWindow::paste() { - QWidget * t =dataTable->cellWidget(dataTable->currentRow(), dataTable->currentColumn()); + QWidget * t =ui->dataTable->cellWidget(ui->dataTable->currentRow(), ui->dataTable->currentColumn()); if (t!=0){ if ( QString(t->metaObject()->className()) == "QLineEdit" ){ /*we are in edit mode*/ @@ -1605,8 +931,8 @@ void MainWindow::paste() le->paste();} } } - if (editGoto->hasFocus()) - editGoto->paste(); + if (ui->lineEditGoto->hasFocus()) + ui->lineEditGoto->paste(); } @@ -1635,7 +961,7 @@ void MainWindow::updateRecordText(int row, int col, QString newtext) QTableWidgetItem* item = new QTableWidgetItem(cv); item->setToolTip( wrapText(cv) ); - dataTable->setItem( row - recAtTop, col, item); + ui->dataTable->setItem( row - recAtTop, col, item); } @@ -1648,7 +974,7 @@ void MainWindow::editWinAway() { editWin->hide(); activateWindow(); - dataTable->setRangeSelected( QTableWidgetSelectionRange(editWin->curRow - recAtTop, editWin->curCol, editWin->curRow- recAtTop, editWin->curCol), true); + ui->dataTable->setRangeSelected( QTableWidgetSelectionRange(editWin->curRow - recAtTop, editWin->curCol, editWin->curRow- recAtTop, editWin->curCol), true); } @@ -1680,7 +1006,7 @@ void MainWindow::doubleClickTable( int row, int col ) void MainWindow::executeQuery() { - QString query = sqlTextEdit->toPlainText().trimmed(); + QString query = ui->textEditSQLexpression->toPlainText().trimmed(); if (query.isEmpty()) { QMessageBox::information( this, QApplication::applicationName(), "Query string is empty" ); @@ -1738,8 +1064,8 @@ void MainWindow::executeQuery() }else{ lastErrorMessage = QString (sqlite3_errmsg(db._db)); } - queryErrorLineEdit->setText(lastErrorMessage); - queryResultTableView->resizeColumnsToContents(); + ui->queryErrorLineEdit->setText(lastErrorMessage); + ui->queryResultTableView->resizeColumnsToContents(); if(err!=SQLITE_OK) break; } while( tail && *tail != 0 ); @@ -1877,8 +1203,8 @@ void MainWindow::exportTableToCSV() void MainWindow::dbState( bool dirty ) { - fileSaveAction->setEnabled(dirty); - fileRevertAction->setEnabled(dirty); + ui->action_Write_Changes->setEnabled(dirty); + ui->action_Revert_Changes->setEnabled(dirty); } @@ -2015,10 +1341,9 @@ void MainWindow::on_tree_context_menu(const QPoint &qPoint){ QTreeWidgetItem *cItem = dbTreeWidget->currentItem(); if(cItem->text(1) == "table"){ - editDeleteTableActionPopup->setDisabled(false); - editModifyTableActionPopup->setDisabled(false); + ui->actionDelete_Table->setDisabled(false); + ui->actionModify_Table->setDisabled(false); popupTableMenu->exec( dbTreeWidget->mapToGlobal(qPoint) ); - }else if(cItem->text(1) == "field"){ popupFieldMenu->exec( dbTreeWidget->mapToGlobal(qPoint) ); } @@ -2026,27 +1351,26 @@ void MainWindow::on_tree_context_menu(const QPoint &qPoint){ //** Tree selection changed void MainWindow::on_tree_selection_changed(){ if (!dbTreeWidget->selectionModel()->hasSelection()){ - editDeleteTableActionPopup->setEnabled(false); - editModifyTableActionPopup->setEnabled(false); - editAddFieldActionPopup->setEnabled(false); - editModifyFieldActionPopup->setEnabled(false); - editDeleteFieldActionPopup->setEnabled(false); + ui->actionDelete_Table->setEnabled(false); + ui->actionModify_Table->setEnabled(false); + ui->actionCreate_Field->setEnabled(false); + ui->actionModifyField->setEnabled(false); + ui->actionDelete_Field->setEnabled(false); return; } if(dbTreeWidget->currentItem()->text(1) == "table"){ - editDeleteTableActionPopup->setEnabled(true); - editModifyTableActionPopup->setEnabled(true); - editAddFieldActionPopup->setEnabled(true); - editModifyFieldActionPopup->setEnabled(false); - editDeleteFieldActionPopup->setEnabled(false); - + ui->actionDelete_Table->setEnabled(true); + ui->actionModify_Table->setEnabled(true); + ui->actionCreate_Field->setEnabled(true); + ui->actionModifyField->setEnabled(false); + ui->actionDelete_Field->setEnabled(false); }else if(dbTreeWidget->currentItem()->text(1) == "field"){ - editAddFieldActionPopup->setEnabled(false); - editDeleteTableActionPopup->setEnabled(false); - editModifyTableActionPopup->setEnabled(false); - editModifyFieldActionPopup->setEnabled(true); - editDeleteFieldActionPopup->setEnabled(true); + ui->actionDelete_Table->setEnabled(false); + ui->actionModify_Table->setEnabled(false); + ui->actionCreate_Field->setEnabled(false); + ui->actionModifyField->setEnabled(true); + ui->actionDelete_Field->setEnabled(true); } } @@ -2166,15 +1490,15 @@ void MainWindow::dropEvent(QDropEvent *event) void MainWindow::activateFields(bool enable) { - fileCloseAction->setEnabled(enable); - fileCompactAction->setEnabled(enable); - editCreateTableAction->setEnabled(enable); - editDeleteTableAction->setEnabled(enable); - editModifyTableAction->setEnabled(enable); - editCreateIndexAction->setEnabled(enable); - editDeleteIndexAction->setEnabled(enable); + ui->action_Close_Database->setEnabled(enable); + ui->actionCom_pact_Database->setEnabled(enable); + ui->actionCreateTable->setEnabled(enable); + ui->actionDelete_Table->setEnabled(enable); + ui->actionModify_Table->setEnabled(enable); + ui->actionCreate_Index->setEnabled(enable); + ui->actionDelete_Index->setEnabled(enable); - executeQueryButton->setEnabled(enable); + ui->executeQueryButton->setEnabled(enable); } void MainWindow::browseTableHeaderClicked(int logicalindex) @@ -2182,9 +1506,9 @@ void MainWindow::browseTableHeaderClicked(int logicalindex) // instead of the column name we just use the column index, +2 because 'rowid, *' is the projection curBrowseOrderByIndex = logicalindex + 2; curBrowseOrderByMode = curBrowseOrderByMode == ORDERMODE_ASC ? ORDERMODE_DESC : ORDERMODE_ASC; - populateTable(comboBrowseTable->currentText(), true); + populateTable(ui->comboBrowseTable->currentText(), true); // select the first item in the column so the header is bold // we might try to select the last selected item - dataTable->setCurrentCell(0, logicalindex); + ui->dataTable->setCurrentCell(0, logicalindex); } diff --git a/src/mainwindow.h b/src/mainwindow.h index f0a32a22..66b21209 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -1,32 +1,14 @@ #ifndef MAINFORM_H #define MAINFORM_H -#include -#include #include #include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include #include #include "sqlitedb.h" @@ -34,6 +16,10 @@ #define ORDERMODE_ASC 0 #define ORDERMODE_DESC 1 +namespace Ui { +class MainWindow; +} + class SQLLogDock; class editForm; class findForm; @@ -43,120 +29,49 @@ class MainWindow : public QMainWindow { Q_OBJECT -private: - SQLLogDock * logWin; - - QAction *fileNewAction; - QAction *fileOpenAction; - QAction *fileExitAction; - QAction *editCopyAction; - QAction *editPasteAction; - QAction *editFindAction; - QAction *helpContentsAction; - QAction *helpIndexAction; - QAction *helpAboutAction; - QAction *fileCloseAction; - QAction *newRecordAction; - QAction *fileCompactAction; - QAction *helpWhatsThisAction; - QAction *sqlLogAction; - QAction *viewDBToolbarAction; - QAction *fileImportCSVAction; - QAction *fileExportCSVAction; - QAction *fileSaveAction; - QAction *fileRevertAction; - //QAction *fileImportAction; - //QAction *fileExportAction; - QAction *editCreateTableAction; - QAction *editDeleteTableAction; - QAction *editModifyTableAction; - QAction *editCreateIndexAction; - QAction *editDeleteIndexAction; - QAction *fileImportSQLAction; - QAction *fileExportSQLAction; - QAction *editPreferencesAction; - QWidget *widget; - QVBoxLayout *vboxLayout; - QTabWidget *mainTab; - QWidget *structure; - QVBoxLayout *vboxLayout1; - - QTreeWidget *dbTreeWidget; - QMenu *popupTableMenu; - QMenu *popupFieldMenu; - - QAction *editModifyTableActionPopup; - QAction *editDeleteTableActionPopup; - QAction *editAddFieldActionPopup; - QAction *editModifyFieldActionPopup; - QAction *editDeleteFieldActionPopup; - - QWidget *browser; - QVBoxLayout *vboxLayout2; - QHBoxLayout *hboxLayout; - QLabel *textLabel1; - QComboBox *comboBrowseTable; - QPushButton *buttonFind; - QPushButton *buttonRefresh; - QSpacerItem *spacer1; - QPushButton *buttonNewRecord; - QPushButton *buttonDeleteRecord; - QTableWidget *dataTable; - QHBoxLayout *hboxLayout1; - QPushButton *buttonPrevious; - QLabel *labelRecordset; - QPushButton *buttonNext; - QSpacerItem *spacer4; - QPushButton *buttonGoto; - QLineEdit *editGoto; - QWidget *query; - QVBoxLayout *vboxLayout3; - QLabel *textLabel1_2; - QTextEdit *sqlTextEdit; - QHBoxLayout *hboxLayout2; - QPushButton *executeQueryButton; - QSpacerItem *spacer4_2; - QLabel *textLabel2; - QLineEdit *queryErrorLineEdit; - QLabel *textLabel3; - QTableView *queryResultTableView; - QStandardItemModel *queryResultListModel; - QToolBar *toolbarDB; - QMenuBar *menubar; - QMenu *fileMenu; - QMenu *importMenu; - QMenu *exportMenu; - QMenu *EditMenu; - QMenu *ViewMenu; - QMenu *PopupMenu; - QMenu *recentFilesMenu; - - SQLiteSyntaxHighlighter* sqliteHighlighter; - - enum { MaxRecentFiles = 5 }; - QAction *recentFileActs[MaxRecentFiles]; - QAction *recentSeparatorAct; - - int curBrowseOrderByIndex; - int curBrowseOrderByMode; - public: MainWindow(QWidget* parent = 0); ~MainWindow(); - editForm * editWin; - QClipboard * clipboard; - findForm * findWin; +protected: + DBBrowserDB db; + +private: + Ui::MainWindow *ui; + QAction *sqlLogAction; + SQLLogDock * logWin; + + QMenu *popupTableMenu; + QMenu *popupFieldMenu; + + QMenu *recentFilesMenu; + enum { MaxRecentFiles = 5 }; + QAction *recentFileActs[MaxRecentFiles]; + QAction *recentSeparatorAct; + + QTreeWidget *dbTreeWidget; + QStandardItemModel *queryResultListModel; + + SQLiteSyntaxHighlighter* sqliteHighlighter; + + int curBrowseOrderByIndex; + int curBrowseOrderByMode; + int recAtTop; int recsPerView; - QIntValidator * gotoValidator; - QString defaultlocation; + + QClipboard * clipboard; + + editForm * editWin; + findForm * findWin; + + QIntValidator * gotoValidator; + QString defaultlocation; private: void init(); void destroy(); void setupUi(); - void retranslateUi(); void updateRecentFileActions(); void setCurrentFile(const QString& fileName); @@ -219,15 +134,11 @@ public slots: virtual void updatePreferences(); virtual void openRecentFile(); -protected: - DBBrowserDB db; - protected: void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); protected slots: - virtual void languageChange(); virtual void deleteTablePopup(); virtual void editTablePopup(); virtual void mainTabSelected( int tabindex ); diff --git a/src/mainwindow.ui b/src/mainwindow.ui new file mode 100644 index 00000000..cc7f9f97 --- /dev/null +++ b/src/mainwindow.ui @@ -0,0 +1,545 @@ + + + Rene Peinthor + MainWindow + + + + 0 + 0 + 800 + 600 + + + + MainWindow + + + + + + + 1 + + + + Database &Structure + + + + + + &Browse Data + + + + + + + + + Table: + + + + + + + + 0 + 0 + + + + + 115 + 0 + + + + + + + + + + + + :/icons/find:/icons/find + + + Ctrl+F + + + true + + + + + + + + + + + :/icons/refresh:/icons/refresh + + + + + + + Qt::Horizontal + + + + 51 + 20 + + + + + + + + New Record + + + + + + + Delete Record + + + + + + + + + + + + + + + + < + + + + + + + 0 - 0 of 0 + + + + + + + > + + + + + + + Qt::Horizontal + + + + 50 + 20 + + + + + + + + Go to: + + + + + + + + 0 + 0 + + + + + + + + + + + + E&xecute SQL + + + + + + SQL expression: + + + + + + + + Courier + 11 + + + + + + + + + 0 + 0 + + + + Execute query + + + + + + + Error message from dtabase: + + + + + + + true + + + + + + + Data returned: + + + + + + + + + + + + + + + + 0 + 0 + 800 + 20 + + + + + &File + + + + &Import + + + + + + + &Export + + + + + + + + + + + + + + + + + + + + &Edit + + + + + + + + + + + + + &View + + + + + &Help + + + + + + + + + + + + + DB Toolbar + + + Qt::ToolButtonTextBesideIcon + + + TopToolBarArea + + + false + + + + + + + + + + &About... + + + + + &What's this? + + + + + + :/oldimages/log:/oldimages/log + + + SQL &Log + + + Ctrl+L + + + + + false + + + + :/icons/table_create:/icons/table_create + + + &Create Table + + + + + false + + + + :/icons/table_delete:/icons/table_delete + + + &Delete Table + + + + + false + + + + :/icons/table_modify:/icons/table_modify + + + &Modify Table + + + + + false + + + Create &Index + + + + + false + + + Delete I&ndex + + + + + &Preferences... + + + + + + :/icons/db_new:/icons/db_new + + + &New Database... + + + Ctrl+N + + + + + + :/icons/db_open:/icons/db_open + + + &Open Database... + + + Ctrl+O + + + + + &Close Database + + + Ctrl+W + + + + + false + + + + :/icons/db_revert:/icons/db_revert + + + &Revert Changes + + + + + false + + + + :/icons/db_save:/icons/db_save + + + &Write Changes + + + + + Com&pact Database + + + + + Database from &SQL File + + + + + &Table from CSV File + + + + + Database &to SQL File + + + + + Table t&o CSV File + + + + + E&xit + + + Ctrl+Q + + + + + false + + + + :/icons/field_add:/icons/field_add + + + Create &Field + + + + + false + + + + :/icons/field_edit:/icons/field_edit + + + Modify Field + + + + + false + + + + :/icons/field_delete:/icons/field_delete + + + Delete Field + + + + + + + + diff --git a/src/src.pro b/src/src.pro index 8cdead7c..14a217d2 100644 --- a/src/src.pro +++ b/src/src.pro @@ -78,6 +78,6 @@ mac { } RESOURCES += icons/icons.qrc -FORMS += \ +FORMS += mainwindow.ui \ createtabledialog.ui \ dialogabout.ui