Skip to content

Commit

Permalink
Implement connection groups
Browse files Browse the repository at this point in the history
Fix #3367
  • Loading branch information
uglide committed Sep 7, 2020
1 parent 806cfcd commit 77323ab
Show file tree
Hide file tree
Showing 26 changed files with 1,296 additions and 249 deletions.
3 changes: 0 additions & 3 deletions src/app/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ class Events : public QObject, public QEnableSharedFromThis<Events> {
std::function<void()> callback, int dbIndex,
QString keyPrefix);

// Connections
void createNewConnection(RedisClient::ConnectionConfig config);

// Notifications
void error(const QString& msg);

Expand Down
26 changes: 22 additions & 4 deletions src/app/models/connectionconf.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
#include "connectionconf.h"

ServerConfig::ServerConfig(const QString &host, const QString &auth, const uint port, const QString &name)
: RedisClient::ConnectionConfig(host, auth, port, name)
: RedisClient::ConnectionConfig(host, auth, port, name),
m_owner(QSharedPointer<TreeOperations>())
{
}

ServerConfig::ServerConfig(const RedisClient::ConnectionConfig &other)
ServerConfig::ServerConfig(const QVariantHash &options)
: RedisClient::ConnectionConfig(options),
m_owner(QSharedPointer<TreeOperations>())
{
m_parameters = other.getInternalParameters();
m_owner = other.getOwner();

}

ServerConfig::ServerConfig(const ServerConfig &other)
{
m_parameters = other.m_parameters;
m_owner = other.m_owner;
}

QString ServerConfig::keysPattern() const
Expand Down Expand Up @@ -45,3 +53,13 @@ bool ServerConfig::useSshTunnel() const
{
return RedisClient::ConnectionConfig::useSshTunnel();
}

QWeakPointer<TreeOperations> ServerConfig::owner() const
{
return m_owner;
}

void ServerConfig::setOwner(QWeakPointer<TreeOperations> o)
{
m_owner = o;
}
13 changes: 12 additions & 1 deletion src/app/models/connectionconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include <QObject>
#include <qredisclient/connectionconfig.h>


class TreeOperations;

class ServerConfig : public RedisClient::ConnectionConfig
{
Q_GADGET
Expand Down Expand Up @@ -47,7 +50,9 @@ class ServerConfig : public RedisClient::ConnectionConfig
ServerConfig(const QString & host = "127.0.0.1", const QString & auth = "",
const uint port = DEFAULT_REDIS_PORT, const QString & name = "");

ServerConfig(const RedisClient::ConnectionConfig&);
ServerConfig(const QVariantHash& options);

ServerConfig(const ServerConfig& options);

QString keysPattern() const;
void setKeysPattern(QString keyGlobPattern);
Expand All @@ -62,6 +67,12 @@ class ServerConfig : public RedisClient::ConnectionConfig
void setDatabaseScanLimit(uint limit);

Q_INVOKABLE bool useSshTunnel() const;

QWeakPointer<TreeOperations> owner() const;
void setOwner(QWeakPointer<TreeOperations> o);

private:
QWeakPointer<TreeOperations> m_owner;
};

Q_DECLARE_METATYPE(ServerConfig)
22 changes: 22 additions & 0 deletions src/app/models/connectiongroup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "connectiongroup.h"

#include "connections-tree/items/servergroup.h"

ConnectionGroup::ConnectionGroup(QSharedPointer<ConnectionsTree::ServerGroup> g)
: m_group(g) {}

ConnectionGroup::ConnectionGroup() : m_group(nullptr) {}

QString ConnectionGroup::name() const {
if (!m_group) return QString();

return m_group->getDisplayName();
}

void ConnectionGroup::setName(const QString &n) {
if (m_group) m_group->setName(n);
}

QSharedPointer<ConnectionsTree::ServerGroup> ConnectionGroup::serverGroup() const {
return m_group;
}
29 changes: 29 additions & 0 deletions src/app/models/connectiongroup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once
#include <QObject>
#include <QSharedPointer>

namespace ConnectionsTree {
class ServerGroup;
}

class ConnectionGroup {
Q_GADGET

Q_PROPERTY(QString name READ name WRITE setName)

public:
ConnectionGroup();

ConnectionGroup(QSharedPointer<ConnectionsTree::ServerGroup> g);

QString name() const;

void setName(const QString& n);

QSharedPointer<ConnectionsTree::ServerGroup> serverGroup() const;

private:
QSharedPointer<ConnectionsTree::ServerGroup> m_group;
};

Q_DECLARE_METATYPE(ConnectionGroup)
Loading

0 comments on commit 77323ab

Please sign in to comment.