Ejemplo n.º 1
0
void ClusterDialog::remove() {
  ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem());  // +

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

  // Ask user
  int answer = QMessageBox::question(this, translations::trConnections,
                                     translations::trDeleteConnectionTemplate_1S.arg(currentItem->text(0)),
                                     QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);

  if (answer != QMessageBox::Yes) {
    return;
  }

  delete currentItem;
}
Ejemplo n.º 2
0
    void ConnectionsDialog::remove()
    {
        QTreeWidgetItem* qitem = listWidget_->currentItem();
        if(!qitem){
            return;
        }

        ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem *>(qitem);
        if(currentItem){

            QTreeWidgetItem* qpitem = qitem->parent();
            if(!qpitem){
                // Ask user
                int answer = QMessageBox::question(this, "Connections", QString("Really delete \"%1\" connection?").arg(currentItem->text(0)),
                                                   QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);

                if (answer != QMessageBox::Yes)
                    return;

                IConnectionSettingsBaseSPtr connection = currentItem->connection();
                delete currentItem;
                SettingsManager::instance().removeConnection(connection);
                return;
            }
            else{
                qitem = qpitem;
            }
        }

        ClusterConnectionListWidgetItem* clCurrentItem = dynamic_cast<ClusterConnectionListWidgetItem *>(qitem);
        if(clCurrentItem){

            // Ask user
            int answer = QMessageBox::question(this, "Connections", QString("Really delete \"%1\" cluster?").arg(clCurrentItem->text(0)),
                                               QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);

            if (answer != QMessageBox::Yes)
                return;

            IClusterSettingsBaseSPtr connection = clCurrentItem->connection();
            delete clCurrentItem;
            SettingsManager::instance().removeCluster(connection);
        }
    }