#include "connectionManager.h" #include ConnectionManager::ConnectionManager(QObject *parent): QObject{parent} { } ConnectionManager::~ConnectionManager() { } void ConnectionManager::insert(std::shared_ptr conn) { if(conn){ bool same = false; for(int i=0;i=0 && idx<=connectionVec.length()){ if(connectionVec[idx]->isConnected()){ connectionVec[idx]->close(); } QString name = connectionVec[idx]->getConnectionName(); connectionVec[idx]->disconnect(); std::shared_ptr connPtr = connectionVec[idx]; connectionVec.remove(idx); emit connectionRemovedSignal(connPtr); } } void ConnectionManager::remove(std::shared_ptr conn) { int idx = -1; for(int i=0;iisConnected()){ conn->close(); } idx = i; break; } } if(idx>=0){ QString name = connectionVec[idx]->getConnectionName(); connectionVec[idx]->disconnect(); connectionVec.remove(idx); emit connectionRemovedSignal(conn); } } int ConnectionManager::getConnectionCounts() { return connectionVec.length(); } std::shared_ptr ConnectionManager::getConnection(int idx) { std::shared_ptr conn = nullptr; if(idx>=0 && idx<=connectionVec.length()){ conn = connectionVec[idx]; } return conn; } std::shared_ptr ConnectionManager::getConnection(const QString &connectionName) { std::shared_ptr conn = nullptr; for(int i=0;igetConnectionName()){ conn = connectionVec[i]; } } return conn; }