2 Bacula® - The Network Backup Solution
4 Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
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
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.
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
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.
32 * ComboBox helper functions
34 * Riccardo Ghetta, May 2008
41 #include <QStringList>
42 #include "fmtwidgetitem.h"
43 #include "comboutil.h"
45 static const QString QS_ANY(QObject::tr("Any"));
48 /* selects value val on combo, if exists */
49 void comboSel(QComboBox *combo, const QString &val)
51 int index = combo->findText(val, Qt::MatchExactly);
53 combo->setCurrentIndex(index);
57 /* if the combo has selected something different from "Any" uses the selection
58 * to build a condition on field fldname and adds it to the condition list */
59 void comboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
61 int index = combo->currentIndex();
62 if (index != -1 && combo->itemText(index) != QS_ANY) {
63 cndlist.append( QString("%1='%2'").arg(fldname).arg(combo->itemText(index)) );
68 /* boolean combo (yes/no) */
69 void boolComboFill(QComboBox *combo)
71 combo->addItem(QS_ANY, -1);
72 combo->addItem(QObject::tr("No"), 0);
73 combo->addItem(QObject::tr("Yes"), 1);
76 void boolComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
78 int index = combo->currentIndex();
79 if (index != -1 && combo->itemData(index).toInt() >= 0 ) {
80 QString cnd = combo->itemData(index).toString();
81 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
85 /* backup level combo */
86 void levelComboFill(QComboBox *combo)
88 combo->addItem(QS_ANY);
89 combo->addItem(job_level_to_str(L_FULL), L_FULL);
90 combo->addItem(job_level_to_str(L_INCREMENTAL), L_INCREMENTAL);
91 combo->addItem(job_level_to_str(L_DIFFERENTIAL), L_DIFFERENTIAL);
92 combo->addItem(job_level_to_str(L_SINCE), L_SINCE);
93 combo->addItem(job_level_to_str(L_VERIFY_CATALOG), L_VERIFY_CATALOG);
94 combo->addItem(job_level_to_str(L_VERIFY_INIT), L_VERIFY_INIT);
95 combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
96 combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
97 combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
98 /* combo->addItem(job_level_to_str(L_BASE), L_BASE); base jobs ignored */
101 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
103 int index = combo->currentIndex();
104 if (index != -1 && combo->itemText(index) != QS_ANY ) {
105 QString cnd = combo->itemData(index).toChar();
106 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
110 /* job status combo */
111 void jobStatusComboFill(QComboBox *combo)
113 static const char js[] = {
141 combo->addItem(QS_ANY);
142 for (pos = 0 ; js[pos] != '\0' ; ++pos) {
143 combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
147 void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
149 int index = combo->currentIndex();
150 if (index != -1 && combo->itemText(index) != QS_ANY ) {
151 QString cnd = combo->itemData(index).toChar();
152 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );