Added ability to test the connection in the dialog where the connection details are entered.

This commit is contained in:
eelke 2021-07-04 16:45:50 +02:00
parent 45795333f2
commit c00a0452d1
7 changed files with 201 additions and 43 deletions

32
pglablib/TestConnection.h Normal file
View file

@ -0,0 +1,32 @@
#pragma once
#include <QString>
#include <QStringList>
class ConnectionConfig;
class TestConnectionResult {
public:
/// Creates an instance signalling failure
static TestConnectionResult Failed(QString msg);
/// Creates a result instance signalling success
static TestConnectionResult Success(QStringList databases);
TestConnectionResult() = default;
bool ok() const;
QString message() const;
const QStringList& databases() const;
private:
bool Ok;
QString Message;
QStringList Databases;
TestConnectionResult(bool ok, QString msg, QStringList databases);
};
/// Test if a connection can be opened using the details in cc
///
/// It returns either the error message from the string on failure
/// or a list of databases the details give access to.
TestConnectionResult TestConnection(const ConnectionConfig &cc);