Compiles, links and runs (functionality not tested)
This commit is contained in:
parent
04723a289b
commit
6a97c0447a
48 changed files with 224 additions and 149 deletions
4
BUILD
Normal file
4
BUILD
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
If it doesn't detect Qt CMAKE_PREFIX_PATH needs to be set
|
||||||
|
|
||||||
|
export CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/cmake
|
||||||
|
|
@ -1,29 +1,35 @@
|
||||||
cmake_minimum_required(VERSION 3.1.0)
|
cmake_minimum_required(VERSION 3.1.0)
|
||||||
project(pglaball)
|
project(pglaball)
|
||||||
|
|
||||||
#include(CheckCXXCompilerFlag)
|
set (CMAKE_PREFIX_PATH /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/cmake)
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
|
|
||||||
|
# include(CheckCXXCompilerFlag)
|
||||||
|
#
|
||||||
|
# # Check for standard to use
|
||||||
|
# check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
|
||||||
|
# if(HAVE_FLAG_STD_CXX17)
|
||||||
|
# # Have -std=c++17, use it
|
||||||
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
||||||
|
# else()
|
||||||
|
# check_cxx_compiler_flag(-std=c++1z HAVE_FLAG_STD_CXX1Z)
|
||||||
|
# if(HAVE_FLAG_STD_CXX1Z)
|
||||||
|
# # Have -std=c++1z, use it
|
||||||
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
|
||||||
|
# else()
|
||||||
|
# check_cxx_compiler_flag(-std=c++14 HAVE_FLAG_STD_CXX14)
|
||||||
|
# if(HAVE_FLAG_STD_CXX14)
|
||||||
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||||
|
# endif()
|
||||||
|
#
|
||||||
|
# # And so on and on...
|
||||||
|
# endif()
|
||||||
|
# endif()
|
||||||
|
|
||||||
# Check for standard to use
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
#set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
include(CheckCXXCompilerFlag)
|
|
||||||
|
|
||||||
# Check for standard to use
|
|
||||||
check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
|
|
||||||
if(HAVE_FLAG_STD_CXX17)
|
|
||||||
# Have -std=c++17, use it
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
|
|
||||||
else()
|
|
||||||
check_cxx_compiler_flag(-std=c++1z HAVE_FLAG_STD_CXX1Z)
|
|
||||||
if(HAVE_FLAG_STD_CXX1Z)
|
|
||||||
# Have -std=c++1z, use it
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z")
|
|
||||||
else()
|
|
||||||
# And so on and on...
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_compile_options( -Wall -fpic -march=native )
|
add_compile_options( -Wall -fpic -march=native )
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
|
||||||
|
|
@ -32,6 +38,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Og")
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
# Instruct CMake to run moc automatically when needed.
|
# Instruct CMake to run moc automatically when needed.
|
||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_AUTOUIC ON)
|
||||||
|
|
||||||
pkg_check_modules(Botan REQUIRED botan-2)
|
pkg_check_modules(Botan REQUIRED botan-2)
|
||||||
include_directories( ${Botan_INCLUDE_DIRS} )
|
include_directories( ${Botan_INCLUDE_DIRS} )
|
||||||
|
|
@ -94,17 +101,27 @@ add_executable(pglab
|
||||||
pglab/QueryTab.cpp
|
pglab/QueryTab.cpp
|
||||||
pglab/RolesTableModel.cpp
|
pglab/RolesTableModel.cpp
|
||||||
pglab/ServerWindow.cpp
|
pglab/ServerWindow.cpp
|
||||||
pglab/sqlhighlighter.cpp
|
pglab/SqlHighlighter.cpp
|
||||||
pglab/sqlparser.cpp
|
pglab/sqlparser.cpp
|
||||||
pglab/SqlSyntaxHighlighter.cpp
|
pglab/SqlSyntaxHighlighter.cpp
|
||||||
pglab/stopwatch.cpp
|
pglab/stopwatch.cpp
|
||||||
pglab/tsqueue.cpp
|
pglab/tsqueue.cpp
|
||||||
pglab/tuplesresultwidget.cpp
|
pglab/tuplesresultwidget.cpp
|
||||||
pglab/typeselectionitemmodel.cpp
|
pglab/TypeSelectionItemModel.cpp
|
||||||
pglab/util.cpp
|
pglab/util.cpp
|
||||||
pglab/waithandlelist.cpp
|
pglab/waithandlelist.cpp
|
||||||
pglab/win32event.cpp
|
pglab/win32event.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(pglab PUBLIC
|
target_include_directories(pglab PUBLIC
|
||||||
./core
|
./core
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_link_libraries( pglab
|
||||||
|
core
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
Qt5::Widgets
|
||||||
|
${Pq_LIBRARIES}
|
||||||
|
${Botan_LIBRARIES}
|
||||||
|
pthread
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#include "waithandlelist.h"
|
#include "waithandlelist.h"
|
||||||
#include "ScopeGuard.h"
|
#include "ScopeGuard.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
ASyncDBConnection::ASyncDBConnection()
|
ASyncDBConnection::ASyncDBConnection()
|
||||||
{
|
{
|
||||||
|
|
@ -46,7 +47,7 @@ bool ASyncDBConnection::send(const std::string &command, on_result_callback on_r
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
||||||
m_threadData.m_commandQueue.m_queue.emplace(command, on_result);
|
m_threadData.m_commandQueue.m_queue.emplace(command, on_result);
|
||||||
m_threadData.m_commandQueue.m_newEvent.set();
|
m_threadData.m_commandQueue.m_newEvent.notify_one();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +57,7 @@ bool ASyncDBConnection::send(const std::string &command, Pgsql::Params params, o
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
std::lock_guard<std::mutex> lg(m_threadData.m_commandQueue.m_mutex);
|
||||||
m_threadData.m_commandQueue.m_queue.emplace(command, std::move(params), on_result);
|
m_threadData.m_commandQueue.m_queue.emplace(command, std::move(params), on_result);
|
||||||
m_threadData.m_commandQueue.m_newEvent.set();
|
m_threadData.m_commandQueue.m_newEvent.notify_one();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -79,7 +80,6 @@ void ASyncDBConnection::setNoticeCallback(on_notice_callback notice_callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
ASyncDBConnection::Thread::Thread()
|
ASyncDBConnection::Thread::Thread()
|
||||||
: m_stopEvent(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::run()
|
void ASyncDBConnection::Thread::run()
|
||||||
|
|
@ -124,14 +124,16 @@ bool ASyncDBConnection::Thread::cancel()
|
||||||
|
|
||||||
bool ASyncDBConnection::Thread::makeConnection()
|
bool ASyncDBConnection::Thread::makeConnection()
|
||||||
{
|
{
|
||||||
using namespace std::chrono_literals;
|
//using namespace std::literals::chrono_literals;
|
||||||
|
|
||||||
|
// start connecting
|
||||||
|
auto keywords = m_config.getKeywords();
|
||||||
|
auto values = m_config.getValues();
|
||||||
|
#if true
|
||||||
|
return m_connection.connect(keywords, values, 0);
|
||||||
|
#else
|
||||||
while (!terminateRequested) {
|
while (!terminateRequested) {
|
||||||
|
|
||||||
// start connecting
|
|
||||||
//bool ok = m_connection.connectStart(m_initString + " client_encoding=utf8");
|
|
||||||
auto keywords = m_config.getKeywords();
|
|
||||||
auto values = m_config.getValues();
|
|
||||||
bool ok = m_connection.connectStart(keywords, values);
|
bool ok = m_connection.connectStart(keywords, values);
|
||||||
auto start = std::chrono::steady_clock::now();
|
auto start = std::chrono::steady_clock::now();
|
||||||
if (ok && m_connection.status() != CONNECTION_BAD) {
|
if (ok && m_connection.status() != CONNECTION_BAD) {
|
||||||
|
|
@ -144,7 +146,7 @@ bool ASyncDBConnection::Thread::makeConnection()
|
||||||
WSAEventSelect(sock, socket_event.handle(), fd);
|
WSAEventSelect(sock, socket_event.handle(), fd);
|
||||||
WaitHandleList whl;
|
WaitHandleList whl;
|
||||||
auto wait_result_socket_event = whl.add(socket_event);
|
auto wait_result_socket_event = whl.add(socket_event);
|
||||||
auto wait_result_stop = whl.add(m_stopEvent);
|
//auto wait_result_stop = whl.add(m_stopEvent);
|
||||||
|
|
||||||
auto nu = std::chrono::steady_clock::now();
|
auto nu = std::chrono::steady_clock::now();
|
||||||
std::chrono::duration<float, std::milli> diff = -(nu-start);
|
std::chrono::duration<float, std::milli> diff = -(nu-start);
|
||||||
|
|
@ -185,6 +187,7 @@ bool ASyncDBConnection::Thread::makeConnection()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::communicate()
|
void ASyncDBConnection::Thread::communicate()
|
||||||
|
|
@ -217,7 +220,7 @@ void ASyncDBConnection::Thread::communicate()
|
||||||
void ASyncDBConnection::Thread::stop()
|
void ASyncDBConnection::Thread::stop()
|
||||||
{
|
{
|
||||||
terminateRequested = true;
|
terminateRequested = true;
|
||||||
m_stopEvent.set();
|
//m_stopEvent.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::doStateCallback(State state)
|
void ASyncDBConnection::Thread::doStateCallback(State state)
|
||||||
|
|
@ -231,10 +234,21 @@ void ASyncDBConnection::Thread::doStateCallback(State state)
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::waitForAndSendCommand()
|
void ASyncDBConnection::Thread::waitForAndSendCommand()
|
||||||
{
|
{
|
||||||
|
// lock the data
|
||||||
|
std::unique_lock<std::mutex> lk(m_commandQueue.m_mutex);
|
||||||
|
if (m_commandQueue.m_queue.empty()) {
|
||||||
|
// no data wait till there is data
|
||||||
|
m_commandQueue.m_newEvent.wait(lk);
|
||||||
|
// can we use the predicate to reimplement the stop function???, []{return ready;});
|
||||||
|
|
||||||
|
}
|
||||||
|
doNewCommand();
|
||||||
|
|
||||||
|
#if false
|
||||||
WaitHandleList whl;
|
WaitHandleList whl;
|
||||||
auto wait_result_new_command = whl.add(m_commandQueue.m_newEvent);
|
auto wait_result_new_command = whl.add(m_commandQueue.m_newEvent);
|
||||||
//auto wait_result_stop =
|
//auto wait_result_stop =
|
||||||
whl.add(m_stopEvent);
|
//whl.add(m_stopEvent);
|
||||||
|
|
||||||
DWORD res = MsgWaitForMultipleObjectsEx(
|
DWORD res = MsgWaitForMultipleObjectsEx(
|
||||||
whl.count(), // _In_ DWORD nCount,
|
whl.count(), // _In_ DWORD nCount,
|
||||||
|
|
@ -247,6 +261,7 @@ void ASyncDBConnection::Thread::waitForAndSendCommand()
|
||||||
doNewCommand();
|
doNewCommand();
|
||||||
}
|
}
|
||||||
// if (res == wait_result_stop) return;
|
// if (res == wait_result_stop) return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::doNewCommand()
|
void ASyncDBConnection::Thread::doNewCommand()
|
||||||
|
|
@ -278,10 +293,60 @@ void ASyncDBConnection::Thread::doNewCommand()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ASyncDBConnection::Thread::consumeResultInput()
|
||||||
|
{
|
||||||
|
bool finished = false;
|
||||||
|
if (m_connection.consumeInput()) {
|
||||||
|
while ( ! finished && ! m_connection.isBusy()) {
|
||||||
|
auto res(m_connection.getResult());
|
||||||
|
{
|
||||||
|
qint64 ms = m_timer.restart();
|
||||||
|
std::lock_guard<std::mutex> lg(m_commandQueue.m_mutex);
|
||||||
|
m_commandQueue.m_queue.front().on_result(res, ms);
|
||||||
|
if (res == nullptr) {
|
||||||
|
m_timer.invalidate();
|
||||||
|
m_commandQueue.m_queue.pop();
|
||||||
|
doStateCallback(State::Connected);
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
// else is still waiting for more data
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// error during consume
|
||||||
|
|
||||||
|
}
|
||||||
|
return finished;
|
||||||
|
}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::waitForResult()
|
void ASyncDBConnection::Thread::waitForResult()
|
||||||
{
|
{
|
||||||
|
|
||||||
int sock = m_connection.socket();
|
int sock = m_connection.socket();
|
||||||
|
|
||||||
|
fd_set readfds;
|
||||||
|
timeval timeout;
|
||||||
|
bool finished = false;
|
||||||
|
while (!finished && !terminateRequested) {
|
||||||
|
FD_ZERO(&readfds);
|
||||||
|
FD_SET(sock, &readfds);
|
||||||
|
|
||||||
|
timeout.tv_sec = 5;
|
||||||
|
timeout.tv_usec = 0;
|
||||||
|
|
||||||
|
int select_result = select(1, &readfds, nullptr, nullptr, &timeout);
|
||||||
|
if (select_result > 0) {
|
||||||
|
if (FD_ISSET(sock, &readfds)) {
|
||||||
|
if (consumeResultInput()) {
|
||||||
|
finished = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
#if false
|
||||||
Win32Event socket_event(Win32Event::Reset::Manual, Win32Event::Initial::Clear);
|
Win32Event socket_event(Win32Event::Reset::Manual, Win32Event::Initial::Clear);
|
||||||
|
|
||||||
long fd = FD_READ | FD_CLOSE;
|
long fd = FD_READ | FD_CLOSE;
|
||||||
|
|
@ -292,7 +357,7 @@ void ASyncDBConnection::Thread::waitForResult()
|
||||||
|
|
||||||
WaitHandleList whl;
|
WaitHandleList whl;
|
||||||
auto wait_result_socket = whl.add(socket_event);
|
auto wait_result_socket = whl.add(socket_event);
|
||||||
auto wait_result_stop = whl.add(m_stopEvent);
|
//auto wait_result_stop = whl.add(m_stopEvent);
|
||||||
|
|
||||||
DWORD res = MsgWaitForMultipleObjectsEx(
|
DWORD res = MsgWaitForMultipleObjectsEx(
|
||||||
whl.count(), // _In_ DWORD nCount,
|
whl.count(), // _In_ DWORD nCount,
|
||||||
|
|
@ -306,29 +371,9 @@ void ASyncDBConnection::Thread::waitForResult()
|
||||||
WSAEnumNetworkEvents(sock, socket_event.handle(), &net_events);
|
WSAEnumNetworkEvents(sock, socket_event.handle(), &net_events);
|
||||||
|
|
||||||
if (net_events.lNetworkEvents & FD_READ) {
|
if (net_events.lNetworkEvents & FD_READ) {
|
||||||
if (m_connection.consumeInput()) {
|
if (consumeResultInput()) {
|
||||||
while ( ! finished && ! m_connection.isBusy()) {
|
finished = true;
|
||||||
auto res(m_connection.getResult());
|
}
|
||||||
{
|
|
||||||
qint64 ms = m_timer.restart();
|
|
||||||
std::lock_guard<std::mutex> lg(m_commandQueue.m_mutex);
|
|
||||||
m_commandQueue.m_queue.front().on_result(res, ms);
|
|
||||||
if (res == nullptr) {
|
|
||||||
m_timer.invalidate();
|
|
||||||
m_commandQueue.m_queue.pop();
|
|
||||||
doStateCallback(State::Connected);
|
|
||||||
finished = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// else is still waiting for more data
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// error during consume
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res == wait_result_stop) {
|
if (res == wait_result_stop) {
|
||||||
|
|
@ -339,6 +384,7 @@ void ASyncDBConnection::Thread::waitForResult()
|
||||||
}
|
}
|
||||||
} // end while
|
} // end while
|
||||||
// When last result received, remove command from queue
|
// When last result received, remove command from queue
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASyncDBConnection::Thread::processNotice(const PGresult *result)
|
void ASyncDBConnection::Thread::processNotice(const PGresult *result)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@
|
||||||
|
|
||||||
#include "PgsqlConn.h"
|
#include "PgsqlConn.h"
|
||||||
#include "Pgsql_Params.h"
|
#include "Pgsql_Params.h"
|
||||||
#include "win32event.h"
|
|
||||||
#include "ConnectionConfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <condition_variable>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
@ -86,9 +86,8 @@ private:
|
||||||
struct t_Command {
|
struct t_Command {
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
t_CommandQueue m_queue;
|
t_CommandQueue m_queue;
|
||||||
Win32Event m_newEvent;
|
std::condition_variable m_newEvent;
|
||||||
t_Command()
|
t_Command()
|
||||||
: m_newEvent(Win32Event::Reset::Auto, Win32Event::Initial::Clear)
|
|
||||||
{}
|
{}
|
||||||
} m_commandQueue;
|
} m_commandQueue;
|
||||||
|
|
||||||
|
|
@ -108,8 +107,8 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
/// \todo Implement new method to stop the thread
|
||||||
Win32Event m_stopEvent;
|
//Win32Event m_stopEvent;
|
||||||
Pgsql::Connection m_connection;
|
Pgsql::Connection m_connection;
|
||||||
bool terminateRequested = false; ///< is set when the thread should stop
|
bool terminateRequested = false; ///< is set when the thread should stop
|
||||||
bool m_terminated = true;
|
bool m_terminated = true;
|
||||||
|
|
@ -128,6 +127,11 @@ private:
|
||||||
|
|
||||||
|
|
||||||
void processNotice(const PGresult *result);
|
void processNotice(const PGresult *result);
|
||||||
|
/** Function to call when after sending a command the socket is ready for reading.
|
||||||
|
*
|
||||||
|
* It might take several consumes before all data is read.
|
||||||
|
*/
|
||||||
|
bool consumeResultInput();
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread m_threadData;
|
Thread m_threadData;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "backupdialog.h"
|
#include "BackupDialog.h"
|
||||||
#include "ui_backupdialog.h"
|
#include "ui_BackupDialog.h"
|
||||||
|
|
||||||
#include "BackupFormatModel.h"
|
#include "BackupFormatModel.h"
|
||||||
|
|
||||||
|
|
@ -9,8 +9,6 @@
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
BackupDialog::BackupDialog(QWidget *parent) :
|
BackupDialog::BackupDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::BackupDialog)
|
ui(new Ui::BackupDialog)
|
||||||
|
|
@ -234,13 +232,14 @@ void BackupDialog::on_btnStart_clicked()
|
||||||
auto p = new QProcess(this);
|
auto p = new QProcess(this);
|
||||||
ConnectTo(p);
|
ConnectTo(p);
|
||||||
p->setProcessEnvironment(env);
|
p->setProcessEnvironment(env);
|
||||||
|
#ifdef _WIN32
|
||||||
p->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
|
p->setCreateProcessArgumentsModifier([] (QProcess::CreateProcessArguments *args)
|
||||||
{
|
{
|
||||||
args->flags |= CREATE_NEW_CONSOLE;
|
args->flags |= CREATE_NEW_CONSOLE;
|
||||||
args->flags &= ~DETACHED_PROCESS;
|
args->flags &= ~DETACHED_PROCESS;
|
||||||
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
|
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES;
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
p->start(program, arguments);
|
p->start(program, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include "connectionconfig.h"
|
#include "ConnectionConfig.h"
|
||||||
|
|
||||||
void setupEnvironment(const ConnectionConfig &cc)
|
void setupEnvironment(const ConnectionConfig &cc)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "connectionconfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "ConnectionList.h"
|
#include "ConnectionList.h"
|
||||||
#include "scopeguard.h"
|
#include "ScopeGuard.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ConnectionListModel.h"
|
#include "ConnectionListModel.h"
|
||||||
#include "ConnectionList.h"
|
#include "ConnectionList.h"
|
||||||
#include "scopeguard.h"
|
#include "ScopeGuard.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#include <botan/cryptobox.h>
|
#include <botan/cryptobox.h>
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
|
|
||||||
#include "connectionconfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include "expected.h"
|
#include "Expected.h"
|
||||||
|
|
||||||
class ConnectionList;
|
class ConnectionList;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
#include "connectionmanagerwindow.h"
|
#include "ConnectionManagerWindow.h"
|
||||||
#include "ui_connectionmanagerwindow.h"
|
#include "ui_ConnectionManagerWindow.h"
|
||||||
//#include "mainwindow.h"
|
//#include "mainwindow.h"
|
||||||
#include "MasterController.h"
|
#include "MasterController.h"
|
||||||
#include <QDataWidgetMapper>
|
#include <QDataWidgetMapper>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include "ConnectionListModel.h"
|
||||||
#include "connectionlistmodel.h"
|
|
||||||
|
|
||||||
ConnectionManagerWindow::ConnectionManagerWindow(MasterController *master, QWidget *parent)
|
ConnectionManagerWindow::ConnectionManagerWindow(MasterController *master, QWidget *parent)
|
||||||
: QMainWindow(parent)
|
: QMainWindow(parent)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "databaseinspectorwidget.h"
|
#include "DatabaseInspectorWidget.h"
|
||||||
#include "ui_databaseinspectorwidget.h"
|
#include "ui_DatabaseInspectorWidget.h"
|
||||||
|
|
||||||
DatabaseInspectorWidget::DatabaseInspectorWidget(QWidget *parent) :
|
DatabaseInspectorWidget::DatabaseInspectorWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "databasewindow.h"
|
#include "DatabaseWindow.h"
|
||||||
#include "ui_databasewindow.h"
|
#include "ui_DatabaseWindow.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
DatabaseWindow::DatabaseWindow(QWidget *parent) :
|
DatabaseWindow::DatabaseWindow(QWidget *parent) :
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef DATABASEWINDOW_H
|
#ifndef DATABASEWINDOW_H
|
||||||
#define DATABASEWINDOW_H
|
#define DATABASEWINDOW_H
|
||||||
|
|
||||||
#include "asyncdbconnection.h"
|
#include "ASyncDBConnection.h"
|
||||||
#include "tsqueue.h"
|
#include "tsqueue.h"
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "explaintreemodelitem.h"
|
#include "ExplainTreeModelItem.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,16 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_MainWindow.h"
|
||||||
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTextTable>
|
#include <QTextTable>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <windows.h>
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QMetaObject>
|
#include <QMetaObject>
|
||||||
#include <QMetaMethod>
|
#include <QMetaMethod>
|
||||||
#include <querytab.h>
|
#include "QueryTab.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "MasterController.h"
|
#include "MasterController.h"
|
||||||
#include "OpenDatabase.h"
|
#include "OpenDatabase.h"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#ifndef MAINWINDOW_H
|
#ifndef MAINWINDOW_H
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include "asyncdbconnection.h"
|
#include "ASyncDBConnection.h"
|
||||||
#include "connectionconfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include "tsqueue.h"
|
#include "tsqueue.h"
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "ASyncWindow.h"
|
#include "ASyncWindow.h"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "OpenDatabase.h"
|
#include "OpenDatabase.h"
|
||||||
#include "pgsqldatabasecatalogue.h"
|
#include "PgsqlDatabaseCatalogue.h"
|
||||||
#include "PgsqlConn.h"
|
#include "PgsqlConn.h"
|
||||||
#include "typeselectionitemmodel.h"
|
#include "TypeSelectionItemModel.h"
|
||||||
|
|
||||||
Expected<OpenDatabase*> OpenDatabase::createOpenDatabase(const ConnectionConfig &cfg)
|
Expected<OpenDatabase*> OpenDatabase::createOpenDatabase(const ConnectionConfig &cfg)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@
|
||||||
#define OPENDATABASE_H
|
#define OPENDATABASE_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "connectionconfig.h"
|
#include "ConnectionConfig.h"
|
||||||
#include "expected.h"
|
#include "Expected.h"
|
||||||
|
|
||||||
class PgsqlDatabaseCatalogue;
|
class PgsqlDatabaseCatalogue;
|
||||||
class TypeSelectionItemModel;
|
class TypeSelectionItemModel;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef PGAUTHID_H
|
#ifndef PGAUTHID_H
|
||||||
#define PGAUTHID_H
|
#define PGAUTHID_H
|
||||||
|
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#include "pgclass.h"
|
#include "PgClass.h"
|
||||||
|
|
||||||
PgClass::PgClass() = default;
|
PgClass::PgClass() = default;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PGCLASS_H
|
#define PGCLASS_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
class PgClass {
|
class PgClass {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
class PgsqlDatabaseCatalogue;
|
class PgsqlDatabaseCatalogue;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PGDATABASE_H
|
#define PGDATABASE_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
class PgDatabase {
|
class PgDatabase {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "pgnamespace.h"
|
#include "PgNamespace.h"
|
||||||
|
|
||||||
PgNamespace::PgNamespace() = default;
|
PgNamespace::PgNamespace() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PGNAMESPACE_H
|
#define PGNAMESPACE_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
class PgNamespace
|
class PgNamespace
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "pgtype.h"
|
#include "PgType.h"
|
||||||
#include "PgsqlConn.h"
|
#include "PgsqlConn.h"
|
||||||
|
|
||||||
PgType::PgType() = default;
|
PgType::PgType() = default;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PGTYPE_H
|
#define PGTYPE_H
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
|
|
||||||
class PgType {
|
class PgType {
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "pgtypecontainer.h"
|
#include "PgTypeContainer.h"
|
||||||
#include "PgsqlConn.h"
|
#include "PgsqlConn.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
#define PGTYPECONTAINER_H
|
#define PGTYPECONTAINER_H
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "pgtype.h"
|
#include "PgType.h"
|
||||||
#include "PgContainer.h"
|
#include "PgContainer.h"
|
||||||
|
|
||||||
namespace Pgsql {
|
namespace Pgsql {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef PGSQLDATABASECATALOGUE_H
|
#ifndef PGSQLDATABASECATALOGUE_H
|
||||||
#define PGSQLDATABASECATALOGUE_H
|
#define PGSQLDATABASECATALOGUE_H
|
||||||
|
|
||||||
#include <pgsql/libpq-fe.h>
|
#include <libpq-fe.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ Value::operator Oid() const
|
||||||
return operator int();
|
return operator int();
|
||||||
}
|
}
|
||||||
|
|
||||||
Value::operator __int64() const
|
Value::operator long long() const
|
||||||
{
|
{
|
||||||
return std::strtoull(m_val, nullptr, 10);
|
return std::strtoull(m_val, nullptr, 10);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "queryexplainmodel.h"
|
#include "QueryExplainModel.h"
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
const int c_ColumnNode = 0;
|
const int c_ColumnNode = 0;
|
||||||
const int c_ColumnExclusive = 1;
|
const int c_ColumnExclusive = 1;
|
||||||
|
|
@ -79,7 +80,7 @@ if (role == Qt::DisplayRole) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (col == c_ColumnEstErr) {
|
if (col == c_ColumnEstErr) {
|
||||||
float e = fabs(item->estimateError());
|
float e = std::fabs(item->estimateError());
|
||||||
if (e > 1000.0f) {
|
if (e > 1000.0f) {
|
||||||
result = QColor(255, 192, 192);
|
result = QColor(255, 192, 192);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "explaintreemodelitem.h"
|
#include "ExplainTreeModelItem.h"
|
||||||
|
|
||||||
/** \brief Model class for displaying the explain of a query in a tree like format.
|
/** \brief Model class for displaying the explain of a query in a tree like format.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "queryresultmodel.h"
|
#include "QueryResultModel.h"
|
||||||
#include "Pgsql_declare.h"
|
#include "Pgsql_declare.h"
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "querytab.h"
|
#include "QueryTab.h"
|
||||||
#include "ui_querytab.h"
|
#include "ui_QueryTab.h"
|
||||||
|
|
||||||
#include "SqlSyntaxHighlighter.h"
|
#include "SqlSyntaxHighlighter.h"
|
||||||
|
|
||||||
|
|
@ -12,12 +12,12 @@
|
||||||
#include <QTextDocumentFragment>
|
#include <QTextDocumentFragment>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
#include "explaintreemodelitem.h"
|
#include "ExplainTreeModelItem.h"
|
||||||
#include "json/json.h"
|
#include "json/json.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "OpenDatabase.h"
|
#include "OpenDatabase.h"
|
||||||
#include "pgtypecontainer.h"
|
#include "PgTypeContainer.h"
|
||||||
#include "pgsqldatabasecatalogue.h"
|
#include "PgsqlDatabaseCatalogue.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
#ifndef QUERYTAB_H
|
#ifndef QUERYTAB_H
|
||||||
#define QUERYTAB_H
|
#define QUERYTAB_H
|
||||||
|
|
||||||
#include "asyncdbconnection.h"
|
#include "ASyncDBConnection.h"
|
||||||
#include "ParamListModel.h"
|
#include "ParamListModel.h"
|
||||||
#include "ParamTypeDelegate.h"
|
#include "ParamTypeDelegate.h"
|
||||||
#include "queryresultmodel.h"
|
#include "QueryResultModel.h"
|
||||||
#include "queryexplainmodel.h"
|
#include "QueryExplainModel.h"
|
||||||
#include "stopwatch.h"
|
#include "stopwatch.h"
|
||||||
#include "tuplesresultwidget.h"
|
#include "tuplesresultwidget.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#include "SqlHighlighter.h"
|
#include "SqlHighlighter.h"
|
||||||
|
|
||||||
static const wchar_t *keywords[] = {
|
// static const wchar_t *keywords[] = {
|
||||||
L"as", L"alter", L"all", L"and", L"any", L"by", L"char", L"column", L"create", L"database", L"date", L"from", L"full", L"group", L"having",
|
// L"as", L"alter", L"all", L"and", L"any", L"by", L"char", L"column", L"create", L"database", L"date", L"from", L"full", L"group", L"having",
|
||||||
L"in", L"inner", L"int", L"join", L"left", L"not", L"numeric", L"or", L"order", L"outer", L"right", L"select", L"smallint", L"table", L"time",
|
// L"in", L"inner", L"int", L"join", L"left", L"not", L"numeric", L"or", L"order", L"outer", L"right", L"select", L"smallint", L"table", L"time",
|
||||||
L"timestamp", L"timestamptz", L"varchar", L"where"
|
// L"timestamp", L"timestamptz", L"varchar", L"where"
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
static const wchar_t *operators[] = {
|
// static const wchar_t *operators[] = {
|
||||||
L"+", L"-", L"*", L"/", L"<", L">", L"<=", L">=", L"<>", L"!=", L"~"
|
// L"+", L"-", L"*", L"/", L"<", L">", L"<=", L">=", L"<>", L"!=", L"~"
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -17,7 +17,7 @@ static const wchar_t *operators[] = {
|
||||||
|
|
||||||
There are a few restrictions on your choice of name:
|
There are a few restrictions on your choice of name:
|
||||||
|
|
||||||
-- and /* cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
|
-- and C-comment start cannot appear anywhere in an operator name, since they will be taken as the start of a comment.
|
||||||
|
|
||||||
A multicharacter operator name cannot end in + or -, unless the name also contains at least one of these characters:
|
A multicharacter operator name cannot end in + or -, unless the name also contains at least one of these characters:
|
||||||
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "SqlSyntaxHighlighter.h"
|
#include "SqlSyntaxHighlighter.h"
|
||||||
|
|
||||||
#include "pgtypecontainer.h"
|
#include "PgTypeContainer.h"
|
||||||
#include "SqlLexer.h"
|
#include "SqlLexer.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include "typeselectionitemmodel.h"
|
#include "TypeSelectionItemModel.h"
|
||||||
#include "PgTypeContainer.h"
|
#include "PgTypeContainer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
@ -61,8 +61,8 @@ void TypeSelectionItemModel::setTypeList(const PgTypeContainer* types)
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_types.clear();
|
m_types.clear();
|
||||||
for (const auto &e : *types) {
|
for (const auto &e : *types) {
|
||||||
if (e.typcategory != 'A'
|
if (e.typcategory != "A"
|
||||||
&& e.typtype != 'c') {
|
&& e.typtype != "c") {
|
||||||
m_types.push_back(e.typname);
|
m_types.push_back(e.typname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
#include "MasterController.h"
|
#include "MasterController.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <winsock2.h>
|
#ifdef _WIN32
|
||||||
|
# include <winsock2.h>
|
||||||
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
|
/* Use the MAKEWORD(lowbyte, highbyte) macro declared in Windef.h */
|
||||||
|
#ifdef _WIN32
|
||||||
WORD wVersionRequested = MAKEWORD(2, 2);
|
WORD wVersionRequested = MAKEWORD(2, 2);
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int err = WSAStartup(wVersionRequested, &wsaData);
|
int err = WSAStartup(wVersionRequested, &wsaData);
|
||||||
|
|
@ -16,7 +19,7 @@ int main(int argc, char *argv[])
|
||||||
printf("WSAStartup failed with error: %d\n", err);
|
printf("WSAStartup failed with error: %d\n", err);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
QCoreApplication::setOrganizationName("pglab");
|
QCoreApplication::setOrganizationName("pglab");
|
||||||
|
|
@ -26,8 +29,9 @@ int main(int argc, char *argv[])
|
||||||
auto master_controller = std::make_unique<MasterController>();
|
auto master_controller = std::make_unique<MasterController>();
|
||||||
master_controller->init();
|
master_controller->init();
|
||||||
int result = a.exec();
|
int result = a.exec();
|
||||||
|
#ifdef _WIN32
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
#include "tsqueue.h"
|
#include "tsqueue.h"
|
||||||
|
|
||||||
TSQueue::TSQueue()
|
TSQueue::TSQueue()
|
||||||
: newData(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
// : newData(Win32Event::Reset::Manual, Win32Event::Initial::Clear)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void TSQueue::add(t_Callable callable)
|
void TSQueue::add(t_Callable callable)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> g(m);
|
std::lock_guard<std::mutex> g(m);
|
||||||
futureQueue.push_back(std::move(callable));
|
futureQueue.push_back(std::move(callable));
|
||||||
newData.set();
|
// newData.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TSQueue::empty()
|
bool TSQueue::empty()
|
||||||
|
|
@ -23,12 +23,12 @@ TSQueue::t_Callable TSQueue::pop()
|
||||||
auto f = std::move(futureQueue.front());
|
auto f = std::move(futureQueue.front());
|
||||||
futureQueue.pop_front();
|
futureQueue.pop_front();
|
||||||
if (futureQueue.empty()) {
|
if (futureQueue.empty()) {
|
||||||
newData.reset();
|
// newData.reset();
|
||||||
}
|
}
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE TSQueue::getNewDataEventHandle()
|
// HANDLE TSQueue::getNewDataEventHandle()
|
||||||
{
|
// {
|
||||||
return newData.handle();
|
// return newData.handle();
|
||||||
}
|
// }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef TSQUEUE_H
|
#ifndef TSQUEUE_H
|
||||||
#define TSQUEUE_H
|
#define TSQUEUE_H
|
||||||
|
|
||||||
#include "Win32Event.h"
|
//#include "Win32Event.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
@ -15,11 +15,11 @@ public:
|
||||||
bool empty();
|
bool empty();
|
||||||
t_Callable pop();
|
t_Callable pop();
|
||||||
|
|
||||||
HANDLE getNewDataEventHandle();
|
//HANDLE getNewDataEventHandle();
|
||||||
private:
|
private:
|
||||||
using t_CallableQueue = std::deque<t_Callable>;
|
using t_CallableQueue = std::deque<t_Callable>;
|
||||||
|
|
||||||
Win32Event newData;
|
//Win32Event newData;
|
||||||
std::mutex m;
|
std::mutex m;
|
||||||
t_CallableQueue futureQueue;
|
t_CallableQueue futureQueue;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef TUPLESRESULTWIDGET_H
|
#ifndef TUPLESRESULTWIDGET_H
|
||||||
#define TUPLESRESULTWIDGET_H
|
#define TUPLESRESULTWIDGET_H
|
||||||
|
|
||||||
#include "queryresultmodel.h"
|
#include "QueryResultModel.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "csvwriter.h"
|
#include "CsvWriter.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
|
@ -108,8 +108,7 @@ void copySelectionToClipboard(const QTableView *view)
|
||||||
|
|
||||||
QString ConvertToMultiLineCString(const QString &in)
|
QString ConvertToMultiLineCString(const QString &in)
|
||||||
{
|
{
|
||||||
// We need to atleast escape " and \
|
// We need to atleast escape " and \ and also any multi byte utf8 char
|
||||||
// also any multi byte utf8 char
|
|
||||||
|
|
||||||
QString out;
|
QString out;
|
||||||
out.append('"');
|
out.append('"');
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "waithandlelist.h"
|
#include "waithandlelist.h"
|
||||||
#include "win32event.h"
|
#include "win32event.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
WaitHandleList::WaitHandleList() = default;
|
WaitHandleList::WaitHandleList() = default;
|
||||||
WaitHandleList::~WaitHandleList() = default;
|
WaitHandleList::~WaitHandleList() = default;
|
||||||
|
|
||||||
|
|
@ -29,3 +30,5 @@ WaitHandleList::operator const HANDLE*() const
|
||||||
{
|
{
|
||||||
return m_waitHandles.data();
|
return m_waitHandles.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue