/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+ Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
/*
* Label Dialog class
*
- * Kern Sibbald, February MMVI
+ * Kern Sibbald, February MMVII
*
*/
#include "bat.h"
#include "label.h"
+#include <QMessageBox>
labelDialog::labelDialog(Console *console)
{
+ QString deflt("");
+ showDialog(console, deflt);
+}
+
+/*
+ * An overload of the constructor to have a default storage show in the
+ * combobox on start. Used from context sensitive in storage class.
+ */
+labelDialog::labelDialog(Console *console, QString &defString)
+{
+ showDialog(console, defString);
+}
+
+/*
+ * moved the constructor code here for the overload.
+ */
+void labelDialog::showDialog(Console *console, QString &defString)
+{
+ m_console = console;
+ m_console->notify(false);
setupUi(this);
storageCombo->addItems(console->storage_list);
+ int index = storageCombo->findText(defString, Qt::MatchExactly);
+ if (index != -1) {
+ storageCombo->setCurrentIndex(index);
+ }
poolCombo->addItems(console->pool_list);
this->show();
}
+
void labelDialog::accept()
{
- printf("Storage=%s\n"
- "Pool=%s\n",
- storageCombo->currentText().toUtf8().data(),
- poolCombo->currentText().toUtf8().data());
- this->hide();
-
-#ifdef xxx
- volume = get_entry_text(label_dialog, "label_entry_volume");
-
- slot = get_spin_text(label_dialog, "label_slot");
-
- if (!pool || !storage || !volume || !(*volume)) {
- set_status_ready();
+ QString scmd;
+ if (volumeName->text().toUtf8().data()[0] == 0) {
+ QMessageBox::warning(this, "No Volume name", "No Volume name given",
+ QMessageBox::Ok, QMessageBox::Ok);
return;
}
-
- bsnprintf(cmd, sizeof(cmd),
- "label volume=\"%s\" pool=\"%s\" storage=\"%s\" slot=%s\n",
- volume, pool, storage, slot);
- write_director(cmd);
- set_text(cmd, strlen(cmd));
-#endif
+ this->hide();
+ scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
+ .arg(volumeName->text())
+ .arg(poolCombo->currentText())
+ .arg(storageCombo->currentText())
+ .arg(slotSpin->value());
+ /* FIXME Make this a user configurable logging action and dont use printf */
+ //printf("sending command : %s\n",scmd.toUtf8().data());
+ m_console->write_dir(scmd.toUtf8().data());
+ m_console->displayToPrompt();
+ m_console->notify(true);
+ delete this;
+ mainWin->resetFocus();
}
void labelDialog::reject()
{
- printf("Rejected\n");
this->hide();
+ m_console->notify(true);
+ delete this;
+ mainWin->resetFocus();
}