ConnectionWindow::ConnectionWindow(QWidget *parent, RedisServerItem * srv)
    : QDialog(parent), inEditMode(false)
{
    ui.setupUi(this);

    this->setWindowFlags(Qt::Tool);        
    this->setModal(true);

    ui.validationWarning->hide();

    if (parent) {
        mainForm = qobject_cast<MainWin *>(parent);
    }

    // connect slots to signals
    connect(ui.okButton, SIGNAL(clicked()), this, SLOT(OnOkButtonClick()));
    connect(ui.okButton, SIGNAL(pressed()), this,  SLOT(clicked()));
    connect(ui.showPasswordCheckbox, SIGNAL(stateChanged(int)), this,  SLOT(OnShowPasswordCheckboxChanged(int)));    

    //edit mode
    if (srv != nullptr) {    
        server = srv;
        loadValuesFromConnection(srv->getConnection());
    } else {
        ui.namespaceSeparator->setText(QString(RedisConnectionConfig::DEFAULT_NAMESPACE_SEPARATOR));
        ui.connectionTimeout->setValue(DEFAULT_TIMEOUT_IN_MS / 1000);
        ui.executionTimeout->setValue(DEFAULT_TIMEOUT_IN_MS / 1000);
    }
}
connection::connection(QWidget *parent, RedisServerItem * srv)
	: QDialog(parent), inEditMode(false)
{
	ui.setupUi(this);

	this->setWindowFlags(Qt::Tool);		
	this->setModal(true);

	if (parent) {
		mainForm = qobject_cast<MainWin *>(parent);
	}

	// connect slots to signals
	connect(ui.okButton, SIGNAL(clicked()), this, SLOT(OnOkButtonClick()));
	connect(ui.okButton, SIGNAL(pressed()), this,  SLOT(clicked()));

	//edit mode
	if (srv != nullptr) {	
		server = srv;
		loadValuesFromConnection(srv->getConnection());
	}
}