2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
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.
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 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
21 * ComboBox helper functions
23 * Riccardo Ghetta, May 2008
30 #include <QStringList>
31 #include "fmtwidgetitem.h"
32 #include "comboutil.h"
34 static const QString QS_ANY(QObject::tr("Any"));
37 /* selects value val on combo, if exists */
38 void comboSel(QComboBox *combo, const QString &val)
40 int index = combo->findText(val, Qt::MatchExactly);
42 combo->setCurrentIndex(index);
46 /* if the combo has selected something different from "Any" uses the selection
47 * to build a condition on field fldname and adds it to the condition list */
48 void comboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
50 int index = combo->currentIndex();
51 if (index != -1 && combo->itemText(index) != QS_ANY) {
52 cndlist.append( QString("%1='%2'").arg(fldname).arg(combo->itemText(index)) );
57 /* boolean combo (yes/no) */
58 void boolComboFill(QComboBox *combo)
60 combo->addItem(QS_ANY, -1);
61 combo->addItem(QObject::tr("No"), 0);
62 combo->addItem(QObject::tr("Yes"), 1);
65 void boolComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
67 int index = combo->currentIndex();
68 if (index != -1 && combo->itemData(index).toInt() >= 0 ) {
69 QString cnd = combo->itemData(index).toString();
70 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
74 /* backup level combo */
75 void levelComboFill(QComboBox *combo)
77 combo->addItem(QS_ANY);
78 combo->addItem(job_level_to_str(L_FULL), L_FULL);
79 combo->addItem(job_level_to_str(L_INCREMENTAL), L_INCREMENTAL);
80 combo->addItem(job_level_to_str(L_DIFFERENTIAL), L_DIFFERENTIAL);
81 combo->addItem(job_level_to_str(L_SINCE), L_SINCE);
82 combo->addItem(job_level_to_str(L_VERIFY_CATALOG), L_VERIFY_CATALOG);
83 combo->addItem(job_level_to_str(L_VERIFY_INIT), L_VERIFY_INIT);
84 combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
85 combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
86 combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
87 /* combo->addItem(job_level_to_str(L_BASE), L_BASE); base jobs ignored */
90 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
92 int index = combo->currentIndex();
93 if (index != -1 && combo->itemText(index) != QS_ANY ) {
94 QString cnd = combo->itemData(index).toChar();
95 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
99 /* job status combo */
100 void jobStatusComboFill(QComboBox *combo)
102 static const char js[] = {
130 combo->addItem(QS_ANY);
131 for (pos = 0 ; js[pos] != '\0' ; ++pos) {
132 combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
136 void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
138 int index = combo->currentIndex();
139 if (index != -1 && combo->itemText(index) != QS_ANY ) {
140 QString cnd = combo->itemData(index).toChar();
141 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );