void ImageIndexEditor::addNode() { //CatalogTreeNode* selectedNode = _index->getSelectedNode(); CatalogTreeNode* selectedNode = _index->getSelectedNode(); if (selectedNode == NULL) { // JOptionPane.showMessageDialog(this, tr("selectAddNode"), // tr("info"), JOptionPane.INFORMATION_MESSAGE); QMessageBox::information(this, tr("Information"), tr("Select a node where you want to add a child node.")); } else { #if 1 QString name = JOptionPane::showInputDialog(this, tr("Please enter a name for the node you want to add."), tr("Question"), JOptionPane::QUESTION_MESSAGE); if (name != NULL) { if(!_index->insertNodeIntoModel(name, selectedNode)) { JOptionPane::showMessageDialog(this, tr("The name \"%1}\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name), tr("error"), JOptionPane::ERROR_MESSAGE); } } #else QString name; InputDialog* dlg = new InputDialog(tr("Please enter a name for the node you want to add."),name); if(dlg->exec() == QDialog::Accepted) { name = dlg->value(); } if(name == "") { if(!_index->insertNodeIntoModel(name, selectedNode)) { QMessageBox::critical(this, tr("Error"), tr("The name \"%1}\" is a duplicate. Node names\n in the path to the root must be unique.").arg(name)); } } #endif } //invalidate(); }
void ImageIndexEditor::renameNode() { CatalogTreeNode* selectedNode = _index->getSelectedNode(); if (selectedNode == NULL) { JOptionPane::showMessageDialog(this, tr("Please enter a name for the node."), tr("Info"), JOptionPane::INFORMATION_MESSAGE); } else { #if 1 QString name = JOptionPane::showInputDialog(this, tr("Please enter a new name for the node."), selectedNode->getUserObject()); if (name != NULL) { if (!_index->nodeChange(selectedNode, name)){ JOptionPane::showMessageDialog(this, tr("The name \"%1\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name),tr("error"), JOptionPane::ERROR_MESSAGE); } } #else QString name; InputDialog* dlg = new InputDialog(tr("Please enter a new name for the node."),name); if(dlg->exec() == QDialog::Accepted) { name = dlg->value(); } if(name == "") { if(!_index->insertNodeIntoModel(name, selectedNode)) { QMessageBox::critical(this, tr("Error"), tr("The name \"%1\" is a duplicate. Node names\nin the path to the root must be unique.").arg(name)); } #endif } // invalidate(); } void ImageIndexEditor::deleteNode() { CatalogTreeNode* selectedNode = _index->getSelectedNode(); if (selectedNode == NULL) { // JOptionPane.showMessageDialog(this, tr("selectDeleteNode"), // tr("info"), JOptionPane.INFORMATION_MESSAGE); QMessageBox::information(this, tr("Info"), tr("Select the node you want to delete.")); } else { int numNodes = countSubNodes(selectedNode); int numIcons = countIcons(selectedNode); // int response = JOptionPane.showConfirmDialog(this, java.text.MessageFormat.format( // tr("confirmDeleteNode"), new Object[] // {(String)selectedNode.getUserObject(), Integer.valueOf(numNodes), Integer.valueOf(numIcons)}), // tr("question"), JOptionPane.YES_NO_OPTION, // JOptionPane.QUESTION_MESSAGE); // if (response == JOptionPane.YES_OPTION) { // _index.removeNodeFromModel(selectedNode); // } switch(QMessageBox::question(this, tr("Question"), tr("Delete node, %1, its %2 subnodes, and all %3 image indices?").arg(selectedNode->getUserObject().toString()).arg(numNodes).arg(numIcons))) { case QMessageBox::Yes: _index->removeNodeFromModel(selectedNode); default: break; } } }