Most of functionality for connections in tree works now. Old list largely removed.
This commit is contained in:
parent
8840d3bcbb
commit
b3a98f6dc0
10 changed files with 399 additions and 158 deletions
|
|
@ -57,7 +57,7 @@ ConnectionConfig::ConnectionConfig()
|
|||
: m_applicationName(QCoreApplication::applicationName().toUtf8().data())
|
||||
{}
|
||||
|
||||
ConnectionGroup *ConnectionConfig::parent()
|
||||
const ConnectionGroup *ConnectionConfig::parent() const
|
||||
{
|
||||
return m_group;
|
||||
}
|
||||
|
|
@ -301,6 +301,21 @@ void ConnectionConfig::clean()
|
|||
m_dirty = false;
|
||||
}
|
||||
|
||||
QString ConnectionConfig::makeLongDescription() const
|
||||
{
|
||||
std::string result(name());
|
||||
result += " (";
|
||||
result += user();
|
||||
result += "@";
|
||||
result += host();
|
||||
result += ":";
|
||||
result += std::to_string(port());
|
||||
result += "/";
|
||||
result += dbname();
|
||||
result += ")";
|
||||
return stdStrToQ(result);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
PGHOST behaves the same as the host connection parameter.
|
||||
|
|
@ -358,8 +373,21 @@ void ConnectionConfig::strToEnv(QProcessEnvironment &env, const QString &var, co
|
|||
env.insert(var, stdStrToQ(val));
|
||||
}
|
||||
|
||||
void ConnectionGroup::add(std::shared_ptr<ConnectionConfig> cc)
|
||||
void ConnectionGroup::erase(int idx, int count)
|
||||
{
|
||||
m_connections.remove(idx, count);
|
||||
}
|
||||
|
||||
int ConnectionGroup::add(std::shared_ptr<ConnectionConfig> cc)
|
||||
{
|
||||
cc->setParent(this);
|
||||
m_connections.push_back(cc);
|
||||
return m_connections.size() - 1;
|
||||
}
|
||||
|
||||
void ConnectionGroup::update(int idx, const ConnectionConfig &cc)
|
||||
{
|
||||
auto node = m_connections[idx];
|
||||
*node = cc;
|
||||
node->setParent(this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,10 @@ public:
|
|||
using Connections = QVector<std::shared_ptr<ConnectionConfig>>;
|
||||
const Connections& connections() const { return m_connections; }
|
||||
|
||||
void add(std::shared_ptr<ConnectionConfig> cc);
|
||||
void erase(int idx, int count = 1);
|
||||
/// Adds cc to the group and returns the index within the group.
|
||||
int add(std::shared_ptr<ConnectionConfig> cc);
|
||||
void update(int idx, const ConnectionConfig &cc);
|
||||
|
||||
bool operator==(const ConnectionGroup &rhs) const {
|
||||
return conngroup_id == rhs.conngroup_id
|
||||
|
|
@ -57,7 +60,7 @@ class ConnectionConfig: public ConnectionNode {
|
|||
public:
|
||||
ConnectionConfig(); // Default object containing invalid uuid
|
||||
|
||||
ConnectionGroup* parent();
|
||||
const ConnectionGroup* parent() const;
|
||||
void setParent(ConnectionGroup *grp);
|
||||
|
||||
void setUuid(const QUuid &uuid);
|
||||
|
|
@ -113,6 +116,8 @@ public:
|
|||
void clean();
|
||||
|
||||
bool operator==(QUuid id) const { return m_uuid == id; }
|
||||
|
||||
QString makeLongDescription() const;
|
||||
private:
|
||||
QUuid m_uuid;
|
||||
std::string m_name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue