Started on window for managing the server.
This commit is contained in:
parent
f51105bde0
commit
2f95c2f096
17 changed files with 163 additions and 8 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "connectionmanagerwindow.h"
|
||||
#include "connectionlistmodel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "ServerWindow.h"
|
||||
|
||||
|
||||
MasterController::MasterController(QObject *parent) : QObject(parent)
|
||||
|
|
@ -27,7 +28,7 @@ void MasterController::showConnectionManager()
|
|||
m_connectionManagerWindow->show();
|
||||
}
|
||||
|
||||
void MasterController::openWindowForConnection(int connection_index)
|
||||
void MasterController::openSqlWindowForConnection(int connection_index)
|
||||
{
|
||||
auto cc = m_connectionListModel->get(connection_index);
|
||||
m_connectionListModel->save(connection_index);
|
||||
|
|
@ -39,3 +40,15 @@ void MasterController::openWindowForConnection(int connection_index)
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
void MasterController::openServerWindowForConnection(int connection_index)
|
||||
{
|
||||
auto cc = m_connectionListModel->get(connection_index);
|
||||
m_connectionListModel->save(connection_index);
|
||||
if (cc.valid()) {
|
||||
auto w = new ServerWindow(this, nullptr);
|
||||
w->setAttribute( Qt::WA_DeleteOnClose );
|
||||
//w->setConfig(cc.get());
|
||||
w->show();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ public:
|
|||
}
|
||||
|
||||
void showConnectionManager();
|
||||
|
||||
void openWindowForConnection(int connection_index);
|
||||
void openSqlWindowForConnection(int connection_index);
|
||||
void openServerWindowForConnection(int connection_index);
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
|||
14
src/ServerWindow.cpp
Normal file
14
src/ServerWindow.cpp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#include "ServerWindow.h"
|
||||
#include "ui_ServerWindow.h"
|
||||
|
||||
ServerWindow::ServerWindow(MasterController *master, QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::ServerWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
ServerWindow::~ServerWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
24
src/ServerWindow.h
Normal file
24
src/ServerWindow.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#ifndef SERVERWINDOW_H
|
||||
#define SERVERWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class ServerWindow;
|
||||
}
|
||||
|
||||
class MasterController;
|
||||
|
||||
class ServerWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ServerWindow(MasterController *master, QWidget *parent = 0);
|
||||
~ServerWindow();
|
||||
|
||||
private:
|
||||
Ui::ServerWindow *ui;
|
||||
};
|
||||
|
||||
#endif // SERVERWINDOW_H
|
||||
37
src/ServerWindow.ui
Normal file
37
src/ServerWindow.ui
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ServerWindow</class>
|
||||
<widget class="QMainWindow" name="ServerWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -131,3 +131,4 @@ bool SqlLexer::nextBasicToken(int &startpos, int &length, BasicTokenType &tokent
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ private:
|
|||
QString m_block;
|
||||
int m_pos = 0;
|
||||
LexerState m_state;
|
||||
|
||||
};
|
||||
|
||||
#endif // SQLLEXER_H
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ void ConnectionManagerWindow::setupWidgetMappings()
|
|||
void ConnectionManagerWindow::on_actionConnect_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openWindowForConnection(ci.row());
|
||||
m_masterController->openSqlWindowForConnection(ci.row());
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionQuit_application_triggered()
|
||||
|
|
@ -104,3 +104,9 @@ void ConnectionManagerWindow::on_actionBackup_database_triggered()
|
|||
{
|
||||
// BACKUP
|
||||
}
|
||||
|
||||
void ConnectionManagerWindow::on_actionManage_server_triggered()
|
||||
{
|
||||
auto ci = ui->listView->selectionModel()->currentIndex();
|
||||
m_masterController->openServerWindowForConnection(ci.row());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ private slots:
|
|||
|
||||
void on_actionBackup_database_triggered();
|
||||
|
||||
void on_actionManage_server_triggered();
|
||||
|
||||
private:
|
||||
Ui::ConnectionManagerWindow *ui;
|
||||
QDataWidgetMapper *m_mapper = nullptr;
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
@ -223,6 +223,8 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionConnect"/>
|
||||
<addaction name="actionManage_server"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionAdd_Connection"/>
|
||||
<addaction name="actionDelete_connection"/>
|
||||
<addaction name="separator"/>
|
||||
|
|
@ -274,6 +276,16 @@
|
|||
<string>Backup database</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionManage_server">
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normalon>:/icons/server_edit.png</normalon>
|
||||
</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Manage server</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="resources.qrc"/>
|
||||
|
|
|
|||
BIN
src/icons/server_edit.png
Normal file
BIN
src/icons/server_edit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
|
|
@ -197,6 +197,17 @@ void MainWindow::on_actionCancel_triggered()
|
|||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
// TODO collect which files need saving
|
||||
std::vector<QString> files_to_save;
|
||||
int n = ui->tabWidget->count();
|
||||
for (int i = 0; i < n; ++i) {
|
||||
QWidget *w = ui->tabWidget->widget(i);
|
||||
QueryTab *qt = dynamic_cast<QueryTab*>(w);
|
||||
if (qt) {
|
||||
if (qt->isChanged()) {
|
||||
files_to_save.push_back(qt->fileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!m_queryTextChanged || continueWithoutSaving()) {
|
||||
// event->accept();
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -55,6 +55,18 @@ private:
|
|||
|
||||
MasterController *m_masterController;
|
||||
|
||||
// class OpenDocumentController {
|
||||
// public:
|
||||
|
||||
// private:
|
||||
|
||||
// QString path = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
||||
// QDir dir(path);
|
||||
// if (!dir.exists()) {
|
||||
// dir.mkpath(".");
|
||||
// }
|
||||
|
||||
// };
|
||||
|
||||
QueryTab *GetActiveQueryTab();
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ public:
|
|||
|
||||
void copyQueryAsCString();
|
||||
void exportData(const QString &filename);
|
||||
|
||||
QString fileName() const { return m_fileName; }
|
||||
bool isChanged() const { return m_queryTextChanged; }
|
||||
private:
|
||||
|
||||
// struct ResultTab {
|
||||
|
|
|
|||
|
|
@ -19,5 +19,6 @@
|
|||
<file>icons/backups.png</file>
|
||||
<file>icons/page_white_copy.png</file>
|
||||
<file>icons/token_shortland_character.png</file>
|
||||
<file>icons/server_edit.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@ SOURCES += main.cpp\
|
|||
ParamListModel.cpp \
|
||||
MainWindow.cpp \
|
||||
SqlSyntaxHighlighter.cpp \
|
||||
SqlLexer.cpp
|
||||
SqlLexer.cpp \
|
||||
ServerWindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
sqlparser.h \
|
||||
|
|
@ -89,7 +90,8 @@ HEADERS += \
|
|||
ParamListModel.h \
|
||||
MainWindow.h \
|
||||
SqlSyntaxHighlighter.h \
|
||||
SqlLexer.h
|
||||
SqlLexer.h \
|
||||
ServerWindow.h
|
||||
|
||||
FORMS += mainwindow.ui \
|
||||
databasewindow.ui \
|
||||
|
|
@ -97,7 +99,8 @@ FORMS += mainwindow.ui \
|
|||
databaseinspectorwidget.ui \
|
||||
tuplesresultwidget.ui \
|
||||
querytab.ui \
|
||||
backupdialog.ui
|
||||
backupdialog.ui \
|
||||
ServerWindow.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
|
|
|
|||
|
|
@ -26,3 +26,18 @@ TEST(mycase, lexer)
|
|||
ASSERT_THAT( out, Eq(QString("SELECT")) );
|
||||
}
|
||||
|
||||
TEST(mycase, lexer_quote_in_string)
|
||||
{
|
||||
QString input = " 'abc''def' ";
|
||||
SqlLexer lexer(input, LexerState::Null);
|
||||
|
||||
int startpos, length;
|
||||
BasicTokenType tokentype;
|
||||
QString out;
|
||||
lexer.nextBasicToken(startpos, length, tokentype, out);
|
||||
|
||||
ASSERT_THAT(startpos, Eq(1));
|
||||
ASSERT_THAT(length, Eq(10));
|
||||
ASSERT_THAT(tokentype, Eq(BasicTokenType::QuotedString));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue