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