]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/qt-console/select/select.cpp
Get bat select dialog working
[bacula/bacula] / bacula / src / qt-console / select / select.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  *  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  * Setup all the combo boxes and display the dialog
42  */
43 selectDialog::selectDialog(Console *console) 
44 {
45    QDateTime dt;
46    int stat;
47    QListWidgetItem *item;
48    int row = 0;
49
50    m_console = console;
51    setupUi(this);
52    connect(listBox, SIGNAL(currentRowChanged(int)), this, SLOT(index_change(int)));
53    m_console->read();                 /* get title */
54    labelWidget->setText(m_console->msg());
55    while ((stat=m_console->read()) > 0) {
56       item = new QListWidgetItem;
57       item->setText(m_console->msg());
58       listBox->insertItem(row++, item);
59    }
60 // Dmsg1(000, "Stat=%d\n", stat);
61    m_console->read();                 /* get prompt signal */
62    m_console->read();                 /* get prompt */
63 // Dmsg1(000, "Prompt=%s", m_console->msg());
64    this->show();
65 }
66
67 void selectDialog::accept()
68 {
69    char cmd[100];
70
71    this->hide();
72    
73    bsnprintf(cmd, sizeof(cmd), "%d", m_index+1);
74    m_console->write_dir(cmd);
75    m_console->displayToPrompt();
76    delete this;
77    mainWin->resetFocus();
78 }
79
80
81 void selectDialog::reject()
82 {
83    mainWin->set_status(" Canceled");
84    this->hide();
85    delete this;
86    mainWin->resetFocus();
87 }
88
89 /*
90  * Called here when the jobname combo box is changed.
91  *  We load the default values for the new job in the
92  *  other combo boxes.
93  */
94 void selectDialog::index_change(int index)
95 {
96 // Dmsg1(000, "Index=%d\n", index);
97    m_index = index;
98 }