kwave  18.07.70
K3BExportWidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * K3BExportWidget.cpp - widget for K3b export options in the file open dlg
3  * -------------------
4  * begin : Thu Apr 13 2017
5  * copyright : (C) 2017 by Thomas Eschenbacher
6  * email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "config.h"
19 
20 #include <QCheckBox>
21 #include <QLineEdit>
22 
23 #include <KComboBox>
24 
25 #include "libkwave/String.h"
26 
27 #include "K3BExportWidget.h"
28 
29 //***************************************************************************
31  QWidget *parent,
32  QString &pattern,
33  bool selection_only,
34  bool have_selection,
37 )
38  :QWidget(parent), Ui::K3BExportWidgetBase()
39 {
40  setupUi(this);
41 
42  cbLabelPattern->addItem(i18nc(
43  "default entry of the list of placeholder patterns in "
44  "the K3b export plugin (used for detecting title and artist "
45  "from a label description)",
46  "(auto detect)"
47  ));
48  foreach (const QString &p, Kwave::K3BExportPlugin::knownPatterns())
49  cbLabelPattern->addItem(p);
50 
51  Q_ASSERT(cbLabelPattern);
52  if (pattern.trimmed().length())
53  cbLabelPattern->setCurrentText(pattern.trimmed());
54  else
55  cbLabelPattern->setCurrentIndex(0);
56 
57  // the "selection only" checkbox
58  Q_ASSERT(chkSelectionOnly);
59  if (have_selection) {
60  // we have a selection
61  chkSelectionOnly->setEnabled(true);
62  chkSelectionOnly->setChecked(selection_only);
63  } else {
64  // no selection -> force it to "off"
65  chkSelectionOnly->setEnabled(false);
66  chkSelectionOnly->setChecked(false);
67  }
68 
69  Q_ASSERT(cbExportLocation);
70  cbExportLocation->setCurrentIndex(static_cast<int>(export_location));
71 
72  Q_ASSERT(cbOverwritePolicy);
73  cbOverwritePolicy->setCurrentIndex(static_cast<int>(overwrite_policy));
74 }
75 
76 //***************************************************************************
78 {
79 }
80 
81 //***************************************************************************
83 {
84  Q_ASSERT(cbLabelPattern);
85  if (!cbLabelPattern) return QString();
86 
87  // special handling: the first entry in the list is the default pattern
88  // (which is "auto-detect") -> map this to empty pattern
89  QString p = cbLabelPattern->currentText().trimmed();
90  if (p == cbLabelPattern->itemText(0)) return QString();
91 
92  return p;
93 }
94 
95 //***************************************************************************
97 {
98  Q_ASSERT(chkSelectionOnly);
99  return (chkSelectionOnly) ? chkSelectionOnly->isChecked() : false;
100 }
101 
102 //***************************************************************************
105 {
106  Q_ASSERT(cbExportLocation);
107  return static_cast<Kwave::K3BExportPlugin::export_location_t>(
108  (cbExportLocation) ?
109  cbExportLocation->currentIndex() : 0
110  );
111 }
112 
113 //***************************************************************************
116 {
117  Q_ASSERT(cbOverwritePolicy);
118  return static_cast<Kwave::K3BExportPlugin::overwrite_policy_t>(
119  (cbOverwritePolicy) ?
120  cbOverwritePolicy->currentIndex() : 0
121  );
122 }
123 
124 //***************************************************************************
125 //***************************************************************************
Kwave::K3BExportPlugin::export_location_t exportLocation() const
static QStringList knownPatterns()
K3BExportWidget(QWidget *widget, QString &pattern, bool selection_only, bool have_selection, Kwave::K3BExportPlugin::export_location_t export_location, Kwave::K3BExportPlugin::overwrite_policy_t overwrite_policy)
Kwave::K3BExportPlugin::overwrite_policy_t overwritePolicy() const