]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/select/select.cpp
8d628de687a654f1f8c662e9275b1f5adc760356
[bacula/bacula] / bacula / src / qt-console / select / select.cpp
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2015 Kern Sibbald
5    Copyright (C) 2007-2010 Free Software Foundation Europe e.V.
6
7    The original author of Bacula is Kern Sibbald, with contributions
8    from many others, a complete list can be found in the file AUTHORS.
9
10    You may use this file and others of this release according to the
11    license defined in the LICENSE file, which includes the Affero General
12    Public License, v3.0 ("AGPLv3") and some additional permissions and
13    terms pursuant to its AGPLv3 Section 7.
14
15    This notice must be preserved when any source code is 
16    conveyed and/or propagated.
17
18    Bacula(R) is a registered trademark of Kern Sibbald.
19 */
20  
21 /*
22  *  Select dialog class
23  *
24  *   Kern Sibbald, March MMVII
25  *
26  */ 
27
28 #include "bat.h"
29 #include "select.h"
30
31 /*
32  * Read the items for the selection
33  */
34 selectDialog::selectDialog(Console *console, int conn) : QDialog()
35 {
36    m_conn = conn;
37    QDateTime dt;
38    int stat;
39    QListWidgetItem *item;
40    int row = 0;
41
42    m_console = console;
43    m_console->notify(m_conn, false);
44    setupUi(this);
45    connect(listBox, SIGNAL(currentRowChanged(int)), this, SLOT(index_change(int)));
46    setAttribute(Qt::WA_DeleteOnClose);
47    m_console->read(m_conn);                 /* get title */
48    labelWidget->setText(m_console->msg(m_conn));
49    while ((stat=m_console->read(m_conn)) > 0) {
50       item = new QListWidgetItem;
51       item->setText(m_console->msg(m_conn));
52       listBox->insertItem(row++, item);
53    }
54    m_console->displayToPrompt(m_conn);
55    this->show();
56 }
57
58 void selectDialog::accept()
59 {
60    char cmd[100];
61
62    this->hide();
63    bsnprintf(cmd, sizeof(cmd), "%d", m_index+1);
64    m_console->write_dir(m_conn, cmd);
65    m_console->displayToPrompt(m_conn);
66    this->close();
67    mainWin->resetFocus();
68    m_console->displayToPrompt(m_conn);
69    m_console->notify(m_conn, true);
70 }
71
72
73 void selectDialog::reject()
74 {
75    this->hide();
76    mainWin->set_status(tr(" Canceled"));
77    this->close();
78    mainWin->resetFocus();
79    m_console->beginNewCommand(m_conn);
80    m_console->notify(m_conn, true);
81 }
82
83 /*
84  * Called here when the jobname combo box is changed.
85  *  We load the default values for the new job in the
86  *  other combo boxes.
87  */
88 void selectDialog::index_change(int index)
89 {
90    m_index = index;
91 }
92
93 /*
94  * Handle yesno PopUp when Bacula asks a yes/no question.
95  */
96 /*
97  * Read the items for the selection
98  */
99 yesnoPopUp::yesnoPopUp(Console *console, int conn)  : QDialog()
100 {
101    QMessageBox msgBox;
102
103    setAttribute(Qt::WA_DeleteOnClose);
104    console->read(conn);                 /* get yesno question */
105    msgBox.setWindowTitle(tr("Bat Question"));
106    msgBox.setText(console->msg(conn));
107    msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
108    console->displayToPrompt(conn);
109    switch (msgBox.exec()) {
110    case QMessageBox::Yes:
111       console->write_dir(conn, "yes");
112       break;
113    case QMessageBox::No:
114       console->write_dir(conn, "no");
115       break;
116    }
117    console->displayToPrompt(conn);
118    mainWin->resetFocus();
119 }