]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/select/select.cpp
This is the fix to http://bugs.bacula.org/view.php?id=1276. The select
[bacula/bacula] / bacula / src / qt-console / select / select.cpp
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2007-2009 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 and included
11    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 Kern Sibbald.
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  *  Select dialog class
31  *
32  *   Kern Sibbald, March MMVII
33  *
34  *  $Id$
35  */ 
36
37 #include "bat.h"
38 #include "select.h"
39
40 /*
41  * Read the items for the selection
42  */
43 selectDialog::selectDialog(Console *console, int conn) 
44 {
45    m_conn = conn;
46    QDateTime dt;
47    int stat;
48    QListWidgetItem *item;
49    int row = 0;
50
51    m_console = console;
52    setupUi(this);
53    connect(listBox, SIGNAL(currentRowChanged(int)), this, SLOT(index_change(int)));
54    setAttribute(Qt::WA_DeleteOnClose);
55    m_console->read(m_conn);                 /* get title */
56    labelWidget->setText(m_console->msg(m_conn));
57    while ((stat=m_console->read(m_conn)) > 0) {
58       item = new QListWidgetItem;
59       item->setText(m_console->msg(m_conn));
60       listBox->insertItem(row++, item);
61    }
62    m_console->displayToPrompt(m_conn);
63    this->show();
64 }
65
66 void selectDialog::accept()
67 {
68    char cmd[100];
69
70    this->hide();
71    bsnprintf(cmd, sizeof(cmd), "%d", m_index+1);
72    m_console->write_dir(m_conn, cmd);
73    m_console->displayToPrompt(m_conn);
74    this->close();
75    mainWin->resetFocus();
76    m_console->displayToPrompt(m_conn);
77    m_console->notify(m_conn, true);
78 }
79
80
81 void selectDialog::reject()
82 {
83    this->hide();
84    mainWin->set_status(tr(" Canceled"));
85    this->close();
86    mainWin->resetFocus();
87    m_console->beginNewCommand(m_conn);
88    m_console->notify(m_conn, true);
89 }
90
91 /*
92  * Called here when the jobname combo box is changed.
93  *  We load the default values for the new job in the
94  *  other combo boxes.
95  */
96 void selectDialog::index_change(int index)
97 {
98    m_index = index;
99 }
100
101 /*
102  * Handle yesno PopUp when Bacula asks a yes/no question.
103  */
104 /*
105  * Read the items for the selection
106  */
107 yesnoPopUp::yesnoPopUp(Console *console, int conn) 
108 {
109    QMessageBox msgBox;
110
111    setAttribute(Qt::WA_DeleteOnClose);
112    console->read(conn);                 /* get yesno question */
113    msgBox.setWindowTitle(tr("Bat Question"));
114    msgBox.setText(console->msg(conn));
115    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
116    console->displayToPrompt(conn);
117    switch (msgBox.exec()) {
118    case QMessageBox::Yes:
119       console->write_dir("yes");
120       break;
121    case QMessageBox::No:
122       console->write_dir("no");
123       break;
124    }
125    console->displayToPrompt(conn);
126    mainWin->resetFocus();
127 }