bool RedisConnectionsManager::LoadConnectionsConfigFromFile(QString& config, bool saveChangesToFile)
{
    QFile conf(config);
    
    if (!conf.open(QIODevice::ReadOnly)) 
        return false;    
    
    QDomDocument xmlConf;

    if (xmlConf.setContent(&conf)) {

        QDomNodeList connectionsList = xmlConf.elementsByTagName("connection");
        
        for (int i = 0; i < connectionsList.size(); ++i) {

            QDomNode connection = connectionsList.at(i);

            if (connection.nodeName() != "connection") continue;

            RedisConnectionConfig conf = RedisConnectionConfig::createFromXml(connection);

            if (conf.isNull()) continue;

            AddConnection(new ConnectionBridge(conf));
        }        
    }
    conf.close();

    if (!saveChangesToFile)
        connectionSettingsChanged = false;    

    return true;
}
void connection::loadValuesFromConnection(ConnectionBridge * c)
{
	inEditMode = true;

    RedisConnectionConfig config = c->getConfig();

    ui.nameEdit->setText(config.name);
    ui.hostEdit->setText(config.host);
    ui.portSpinBox->setValue(config.port);
    ui.authEdit->setText(config.auth);

    if (config.useSshTunnel()) {
		ui.useSshTunnel->setCheckState(Qt::Checked);
        ui.sshHost->setText(config.sshHost);
        ui.sshUser->setText(config.sshUser);
        ui.sshPass->setText(config.sshPassword);
        ui.sshPort->setValue(config.sshPort);
	}
}
void ConnectionWindow::loadValuesFromConnection(ConnectionBridge * c)
{
    inEditMode = true;

    RedisConnectionConfig config = c->getConfig();

    ui.nameEdit->setText(config.name);
    ui.hostEdit->setText(config.host);
    ui.portSpinBox->setValue(config.port);
    ui.authEdit->setText(config.auth);
    ui.namespaceSeparator->setText(config.namespaceSeparator);
    ui.connectionTimeout->setValue(config.connectionTimeout / 1000);
    ui.executionTimeout->setValue(config.executeTimeout / 1000);

    if (config.useSshTunnel()) {
        ui.useSshTunnel->setCheckState(Qt::Checked);
        ui.sshHost->setText(config.sshHost);
        ui.sshUser->setText(config.sshUser);
        ui.sshPass->setText(config.sshPassword);
        ui.sshPort->setValue(config.sshPort);
    }
}