Пример #1
0
    /**
     * @brief Initiate 'edit' action, usually when user clicked on Edit button
     */
    void ConnectionsDialog::edit()
    {
        ConnectionListWidgetItem *currentItem =
            (ConnectionListWidgetItem *) _listWidget->currentItem();

        // Do nothing if no item selected
        if (currentItem == 0)
            return;

        ConnectionSettings *connection = currentItem->connection();
        boost::scoped_ptr<ConnectionSettings> clonedConnection(connection->clone());
        ConnectionDialog editDialog(clonedConnection.get());

        // Do nothing if not accepted
        if (editDialog.exec() != QDialog::Accepted) {
            // on linux focus is lost - we need to activate connections dialog
            activateWindow();
            return;
        }

        connection->apply(editDialog.connection());       

        // on linux focus is lost - we need to activate connections dialog
        activateWindow();

        int size = _connectionItems.size();
        for (int i=0; i<size; ++i)
        {
            ConnectionListWidgetItem *item = _connectionItems[i];
            if (_connectionItems[i]->connection() == connection) {
                item->setConnection(connection);
                break;
            }
        }        
    }
Пример #2
0
    /**
     * @brief Update specified connection (if it exists for this dialog)
     */
    void ConnectionsDialog::update(ConnectionSettings *connection)
    {
        ConnectionListWidgetItem *item = _hash.value(connection);
        if (!item)
            return;

        item->setConnection(connection);
    }
Пример #3
0
void ClusterDialog::setStartNode() {
  ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem());  // +

  // Do nothing if no item selected
  if (!currentItem) {
    return;
  }

  ConnectionListWidgetItem* top = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->topLevelItem(0));  // +
  if (top == currentItem) {
    return;
  }

  proxy::IConnectionSettingsBaseSPtr tc = top->connection();
  proxy::IConnectionSettingsBaseSPtr cc = currentItem->connection();
  currentItem->setConnection(tc);
  top->setConnection(cc);
}
ClusterConnectionListWidgetItemContainer::ClusterConnectionListWidgetItemContainer(core::IClusterSettingsBaseSPtr connection,
                                                                                   QTreeWidgetItem* parent)
  : QTreeWidgetItem(parent), connection_() {
  setConnection(connection);

  auto nodes = connection_->nodes();
  for (size_t i = 0; i < nodes.size(); ++i) {
    core::IConnectionSettingsBaseSPtr con = nodes[i];
    ConnectionListWidgetItem* item = new ConnectionListWidgetItem(this);
    item->setConnection(con);
    addChild(item);
  }
}
Пример #5
0
void ClusterDialog::edit() {
  ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem());  // +

  // Do nothing if no item selected
  if (!currentItem) {
    return;
  }

#ifdef BUILD_WITH_REDIS
  proxy::IConnectionSettingsBaseSPtr oldConnection = currentItem->connection();
  ConnectionDialog dlg(oldConnection->Clone(), this);
  dlg.setFolderEnabled(false);
  int result = dlg.exec();
  proxy::IConnectionSettingsBaseSPtr newConnection = dlg.connection();
  if (result == QDialog::Accepted && newConnection) {
    currentItem->setConnection(newConnection);
  }
#endif
}
SentinelConnectionListWidgetItemContainer::SentinelConnectionListWidgetItemContainer(core::ISentinelSettingsBaseSPtr connection,
                                                                                     QTreeWidgetItem* parent)
  : QTreeWidgetItem(parent), connection_() {
  setConnection(connection);

  core::ISentinelSettingsBase::sentinel_connections_t sentinels = connection_->sentinels();
  for (size_t i = 0; i < sentinels.size(); ++i) {
    core::SentinelSettings sent = sentinels[i];
    SentinelConnectionWidgetItem* item = new SentinelConnectionWidgetItem(core::MASTER, this);
    item->setConnection(sent.sentinel);
    addChild(item);
    for (size_t j = 0; j < sent.sentinel_nodes.size(); ++j) {
      core::IConnectionSettingsBaseSPtr con = sent.sentinel_nodes[j];
      ConnectionListWidgetItem* child = new ConnectionListWidgetItem(item);
      child->setConnection(con);
      item->addChild(child);
    }
  }
}
Пример #7
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);
            }
        }
    }
Пример #8
0
void ClusterDialog::addConnection(core::IConnectionSettingsBaseSPtr con) {
  ConnectionListWidgetItem* item = new ConnectionListWidgetItem(nullptr);
  item->setConnection(con);
  listWidget_->addTopLevelItem(item);
}