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 many
7 others, a complete list can be found in the file AUTHORS.
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.
14 Bacula® is a registered trademark of Kern Sibbald.
20 * ComboBox helper functions
22 * Riccardo Ghetta, May 2008
29 #include <QStringList>
30 #include "fmtwidgetitem.h"
31 #include "comboutil.h"
33 static const QString QS_ANY(QObject::tr("Any"));
36 /* selects value val on combo, if exists */
37 void comboSel(QComboBox *combo, const QString &val)
39 int index = combo->findText(val, Qt::MatchExactly);
41 combo->setCurrentIndex(index);
45 /* if the combo has selected something different from "Any" uses the selection
46 * to build a condition on field fldname and adds it to the condition list */
47 void comboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
49 int index = combo->currentIndex();
50 if (index != -1 && combo->itemText(index) != QS_ANY) {
51 cndlist.append( QString("%1='%2'").arg(fldname).arg(combo->itemText(index)) );
56 /* boolean combo (yes/no) */
57 void boolComboFill(QComboBox *combo)
59 combo->addItem(QS_ANY, -1);
60 combo->addItem(QObject::tr("No"), 0);
61 combo->addItem(QObject::tr("Yes"), 1);
64 void boolComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
66 int index = combo->currentIndex();
67 if (index != -1 && combo->itemData(index).toInt() >= 0 ) {
68 QString cnd = combo->itemData(index).toString();
69 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
73 /* backup level combo */
74 void levelComboFill(QComboBox *combo)
76 combo->addItem(QS_ANY);
77 combo->addItem(job_level_to_str(L_FULL), L_FULL);
78 combo->addItem(job_level_to_str(L_INCREMENTAL), L_INCREMENTAL);
79 combo->addItem(job_level_to_str(L_DIFFERENTIAL), L_DIFFERENTIAL);
80 combo->addItem(job_level_to_str(L_SINCE), L_SINCE);
81 combo->addItem(job_level_to_str(L_VERIFY_CATALOG), L_VERIFY_CATALOG);
82 combo->addItem(job_level_to_str(L_VERIFY_INIT), L_VERIFY_INIT);
83 combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
84 combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
85 combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
86 /* combo->addItem(job_level_to_str(L_BASE), L_BASE); base jobs ignored */
89 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
91 int index = combo->currentIndex();
92 if (index != -1 && combo->itemText(index) != QS_ANY ) {
93 QString cnd = combo->itemData(index).toChar();
94 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
98 /* job status combo */
99 void jobStatusComboFill(QComboBox *combo)
101 static const char js[] = {
129 combo->addItem(QS_ANY);
130 for (pos = 0 ; js[pos] != '\0' ; ++pos) {
131 combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
135 void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
137 int index = combo->currentIndex();
138 if (index != -1 && combo->itemText(index) != QS_ANY ) {
139 QString cnd = combo->itemData(index).toChar();
140 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );