]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/label/label.cpp
Add icon to label class in page selector.
[bacula/bacula] / bacula / src / qt-console / label / label.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2007 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation plus additions
11    that are listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of John Walker.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28  
29 /*
30  *  Label Page class
31  *
32  *   Kern Sibbald, February MMVII
33  *
34  */ 
35
36 #include "bat.h"
37 #include "label.h"
38 #include <QMessageBox>
39
40 labelPage::labelPage()
41 {
42    QString deflt("");
43    m_closeable = false;
44    showPage(deflt);
45 }
46
47 /*
48  * An overload of the constructor to have a default storage show in the
49  * combobox on start.  Used from context sensitive in storage class.
50  */
51 labelPage::labelPage(QString &defString)
52 {
53    m_closeable = true;
54    showPage(defString);
55 }
56
57 /*
58  * moved the constructor code here for the overload.
59  */
60 void labelPage::showPage(QString &defString)
61 {
62    m_name = "Label";
63    pgInitialize();
64    setupUi(this);
65    m_console->notify(false);
66    QTreeWidgetItem* thisitem = mainWin->getFromHash(this);
67    thisitem->setIcon(0,QIcon(QString::fromUtf8(":images/label.png")));
68
69    storageCombo->addItems(m_console->storage_list);
70    int index = storageCombo->findText(defString, Qt::MatchExactly);
71    if (index != -1) {
72       storageCombo->setCurrentIndex(index);
73    }
74    poolCombo->addItems(m_console->pool_list);
75    connect(okButton, SIGNAL(pressed()), this, SLOT(okButtonPushed()));
76    connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancelButtonPushed()));
77    connect(automountOnButton, SIGNAL(pressed()), this, SLOT(automountOnButtonPushed()));
78    connect(automountOffButton, SIGNAL(pressed()), this, SLOT(automountOffButtonPushed()));
79    dockPage();
80    setCurrent();
81    this->show();
82 }
83
84
85 void labelPage::okButtonPushed()
86 {
87    QString scmd;
88    if (volumeName->text().toUtf8().data()[0] == 0) {
89       QMessageBox::warning(this, "No Volume name", "No Volume name given",
90                            QMessageBox::Ok, QMessageBox::Ok);
91       return;
92    }
93    this->hide();
94    scmd = QString("label volume=\"%1\" pool=\"%2\" storage=\"%3\" slot=%4\n")
95                   .arg(volumeName->text())
96                   .arg(poolCombo->currentText())
97                   .arg(storageCombo->currentText()) 
98                   .arg(slotSpin->value());
99    if (mainWin->m_commandDebug) {
100       Pmsg1(000, "sending command : %s\n",scmd.toUtf8().data());
101    }
102    m_console->write_dir(scmd.toUtf8().data());
103    m_console->displayToPrompt();
104    m_console->notify(true);
105    closeStackPage();
106    mainWin->resetFocus();
107 }
108
109 void labelPage::cancelButtonPushed()
110 {
111    this->hide();
112    m_console->notify(true);
113    closeStackPage();
114    mainWin->resetFocus();
115 }
116
117 /* turn automount on */
118 void labelPage::automountOnButtonPushed()
119 {
120    QString cmd("automount on");
121    consoleCommand(cmd);
122 }
123
124 /* turn automount off */
125 void labelPage::automountOffButtonPushed()
126 {
127    QString cmd("automount off");
128    consoleCommand(cmd);
129 }