2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2007-2009 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
22 * ComboBox helper functions
24 * Riccardo Ghetta, May 2008
31 #include <QStringList>
32 #include "fmtwidgetitem.h"
33 #include "comboutil.h"
35 static const QString QS_ANY(QObject::tr("Any"));
38 /* selects value val on combo, if exists */
39 void comboSel(QComboBox *combo, const QString &val)
41 int index = combo->findText(val, Qt::MatchExactly);
43 combo->setCurrentIndex(index);
47 /* if the combo has selected something different from "Any" uses the selection
48 * to build a condition on field fldname and adds it to the condition list */
49 void comboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
51 int index = combo->currentIndex();
52 if (index != -1 && combo->itemText(index) != QS_ANY) {
53 cndlist.append( QString("%1='%2'").arg(fldname).arg(combo->itemText(index)) );
58 /* boolean combo (yes/no) */
59 void boolComboFill(QComboBox *combo)
61 combo->addItem(QS_ANY, -1);
62 combo->addItem(QObject::tr("No"), 0);
63 combo->addItem(QObject::tr("Yes"), 1);
66 void boolComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
68 int index = combo->currentIndex();
69 if (index != -1 && combo->itemData(index).toInt() >= 0 ) {
70 QString cnd = combo->itemData(index).toString();
71 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
75 /* backup level combo */
76 void levelComboFill(QComboBox *combo)
78 combo->addItem(QS_ANY);
79 combo->addItem(job_level_to_str(L_FULL), L_FULL);
80 combo->addItem(job_level_to_str(L_INCREMENTAL), L_INCREMENTAL);
81 combo->addItem(job_level_to_str(L_DIFFERENTIAL), L_DIFFERENTIAL);
82 combo->addItem(job_level_to_str(L_SINCE), L_SINCE);
83 combo->addItem(job_level_to_str(L_VERIFY_CATALOG), L_VERIFY_CATALOG);
84 combo->addItem(job_level_to_str(L_VERIFY_INIT), L_VERIFY_INIT);
85 combo->addItem(job_level_to_str(L_VERIFY_VOLUME_TO_CATALOG), L_VERIFY_VOLUME_TO_CATALOG);
86 combo->addItem(job_level_to_str(L_VERIFY_DISK_TO_CATALOG), L_VERIFY_DISK_TO_CATALOG);
87 combo->addItem(job_level_to_str(L_VERIFY_DATA), L_VERIFY_DATA);
88 /* combo->addItem(job_level_to_str(L_BASE), L_BASE); base jobs ignored */
91 void levelComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
93 int index = combo->currentIndex();
94 if (index != -1 && combo->itemText(index) != QS_ANY ) {
95 QString cnd = combo->itemData(index).toChar();
96 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );
100 /* job status combo */
101 void jobStatusComboFill(QComboBox *combo)
103 static const char js[] = {
131 combo->addItem(QS_ANY);
132 for (pos = 0 ; js[pos] != '\0' ; ++pos) {
133 combo->addItem(convertJobStatus( QString(js[pos]) ), js[pos]);
137 void jobStatusComboCond(QStringList &cndlist, const QComboBox *combo, const char *fldname)
139 int index = combo->currentIndex();
140 if (index != -1 && combo->itemText(index) != QS_ANY ) {
141 QString cnd = combo->itemData(index).toChar();
142 cndlist.append( QString("%1='%2'").arg(fldname).arg(cnd) );