Пример #1
0
    void SettingsManager::save()
    {
        QSettings settings(common::convertFromString<QString>(common::file_system::prepare_path(iniPath)), QSettings::IniFormat);
        DCHECK(settings.status() == QSettings::NoError);

        settings.setValue(STYLE, curStyle_);
        settings.setValue(LANGUAGE, curLanguage_);
        settings.setValue(VIEW, views_);

        QList<QVariant> clusters;
        for(ClusterSettingsContainerType::const_iterator it = clusters_.begin(); it != clusters_.end(); ++it){
            IClusterSettingsBaseSPtr conn = *it;
            if(conn){
               std::string raw = conn->toString();
               std::string enc = common::utils::base64::encode64(raw);
               QString qdata = common::convertFromString<QString>(enc);
               clusters.push_back(qdata);
            }
        }
        settings.setValue(CLUSTERS, clusters);

        QList<QVariant> connections;
        for(ConnectionSettingsContainerType::const_iterator it = connections_.begin(); it != connections_.end(); ++it){
            IConnectionSettingsBaseSPtr conn = *it;
            if(conn){
               std::string raw = conn->toString();
               std::string enc = common::utils::base64::encode64(raw);
               QString qdata = common::convertFromString<QString>(enc);
               connections.push_back(qdata);
            }
        }
        settings.setValue(CONNECTIONS, connections);

        QStringList rconnections;
        for(QStringList::const_iterator it = recentConnections_.begin(); it != recentConnections_.end(); ++it){
            QString conn = *it;
            if(!conn.isEmpty()){
               std::string raw = common::convertToString(conn);
               std::string enc = common::utils::base64::encode64(raw);
               QString qdata = common::convertFromString<QString>(enc);
               rconnections.push_back(qdata);
            }
        }
        settings.setValue(RCONNECTIONS, rconnections);

        settings.setValue(SYNCTABS, syncTabs_);
        settings.setValue(LOGGINGDIR, loggingDir_);
        settings.setValue(CHECKUPDATES, autoCheckUpdate_);
        settings.setValue(AUTOCOMPLETION, autoCompletion_);
        settings.setValue(AUTOOPENCONSOLE, autoOpenConsole_);
    }
Пример #2
0
    void ConnectionsDialog::edit()
    {
        QTreeWidgetItem* qitem = listWidget_->currentItem();
        if(!qitem){
            return;
        }

        ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem *>(qitem);
        if(currentItem){
            QTreeWidgetItem* qpitem = qitem->parent();
            if(!qpitem){
                IConnectionSettingsBaseSPtr con = currentItem->connection();
                ConnectionDialog dlg(this, dynamic_cast<IConnectionSettingsBase*>(con->clone()));
                int result = dlg.exec();
                IConnectionSettingsBaseSPtr newConnection = dlg.connection();
                if(result == QDialog::Accepted && newConnection){
                    currentItem->setConnection(newConnection);
                    SettingsManager::instance().removeConnection(con);
                    SettingsManager::instance().addConnection(newConnection);
                }
                return;
            }
            else{
                qitem = qpitem;
            }
        }


        ClusterConnectionListWidgetItem* clCurrentItem = dynamic_cast<ClusterConnectionListWidgetItem *>(qitem);
        if(clCurrentItem){
            IClusterSettingsBaseSPtr con = clCurrentItem->connection();
            ClusterDialog dlg(this, dynamic_cast<IClusterSettingsBase*>(con->clone()));
            int result = dlg.exec();
            IClusterSettingsBaseSPtr newConnection = dlg.connection();
            if(result == QDialog::Accepted && newConnection){
                clCurrentItem->setConnection(newConnection);
                SettingsManager::instance().removeCluster(con);
                SettingsManager::instance().addCluster(newConnection);
            }
        }
    }
Пример #3
0
IClusterSPtr ServersManager::createCluster(IClusterSettingsBaseSPtr settings) {
  if (!settings) {
    NOTREACHED();
    return IClusterSPtr();
  }

  connectionTypes conT = settings->type();
#ifdef BUILD_WITH_REDIS
  if (conT == REDIS) {
    IClusterSPtr cl(new redis::RedisCluster(settings->name()));
    IClusterSettingsBase::cluster_connection_type nodes = settings->nodes();
    for (size_t i = 0; i < nodes.size(); ++i) {
      IConnectionSettingsBaseSPtr nd = nodes[i];
      IServerSPtr serv = createServer(nd);
      cl->addServer(serv);
    }
    return cl;
  }
#endif

  NOTREACHED();
  return IClusterSPtr();
}