Most of functionality for connections in tree works now. Old list largely removed.

This commit is contained in:
eelke 2019-08-27 20:12:00 +02:00
parent 8840d3bcbb
commit b3a98f6dc0
10 changed files with 399 additions and 158 deletions

View file

@ -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);
}