kwave  18.07.70
SaveBlocksWidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  SaveBlocksWidget.cpp - widget for extra options in the file open dialog
3  -------------------
4  begin : Fri Mar 02 2007
5  copyright : (C) 2007 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/FileInfo.h"
26 #include "libkwave/String.h"
27 
28 #include "SaveBlocksWidget.h"
29 
30 //***************************************************************************
32  QString filename_pattern,
34  bool selection_only,
35  bool have_selection)
36  :QWidget(parent), Ui::SaveBlocksWidgetBase()
37 {
38  setupUi(this);
39 
40  Kwave::FileInfo info;
41 
42  // the file name pattern combo box
43  cbPattern->addItem(_("[%2nr]-[%title]"));
44  cbPattern->addItem(_("[%filename] part [%nr] of [%total]"));
45  cbPattern->addItem(
46  _("[%fileinfo{") +
47  info.name(Kwave::INF_NAME) +
48  _("}] (part [%nr] of [%total])"));
49  cbPattern->addItem(_("[%filename] - [%04nr]"));
50  cbPattern->addItem(_("[%2nr] [%filename]"));
51  cbPattern->addItem(_("[%2nr]-[%filename]"));
52  cbPattern->addItem(_("[%02nr]-[%filename]"));
53  cbPattern->addItem(_("[%04nr]-[%filename]"));
54  cbPattern->addItem(_("[%02nr] of [%count] [%filename]"));
55  cbPattern->addItem(_("[%02nr] of [%total] [%filename]"));
56  if (filename_pattern.length())
57  cbPattern->setEditText(filename_pattern);
58  else
59  cbPattern->setCurrentIndex(0);
60 
61  // the numbering mode combo box
62  cbNumbering->setCurrentIndex(static_cast<int>(numbering_mode));
63 
64  // the "selection only" checkbox
65  if (have_selection) {
66  // we have a selection
67  chkSelectionOnly->setEnabled(true);
68  chkSelectionOnly->setChecked(selection_only);
69  } else {
70  // no selection -> force it to "off"
71  chkSelectionOnly->setEnabled(false);
72  chkSelectionOnly->setChecked(false);
73  }
74 
75  // combo box with pattern
76  connect(cbPattern, SIGNAL(editTextChanged(QString)),
77  this, SIGNAL(somethingChanged()));
78  connect(cbPattern, SIGNAL(highlighted(int)),
79  this, SIGNAL(somethingChanged()));
80  connect(cbPattern, SIGNAL(activated(int)),
81  this, SIGNAL(somethingChanged()));
82 
83  // combo box with numbering
84  connect(cbNumbering, SIGNAL(editTextChanged(QString)),
85  this, SIGNAL(somethingChanged()));
86  connect(cbNumbering, SIGNAL(highlighted(int)),
87  this, SIGNAL(somethingChanged()));
88  connect(cbNumbering, SIGNAL(activated(int)),
89  this, SIGNAL(somethingChanged()));
90 
91  // selection only checkbox
92  connect(chkSelectionOnly, SIGNAL(stateChanged(int)),
93  this, SIGNAL(somethingChanged()));
94 }
95 
96 //***************************************************************************
98 {
99 }
100 
101 //***************************************************************************
103 {
104  Q_ASSERT(cbPattern);
105  return (cbPattern) ? cbPattern->currentText() : _("");
106 }
107 
108 //***************************************************************************
110 {
111  Q_ASSERT(cbNumbering);
112  return (cbNumbering) ?
114  cbNumbering->currentIndex()) : Kwave::SaveBlocksPlugin::CONTINUE;
115 }
116 
117 //***************************************************************************
119 {
120  Q_ASSERT(chkSelectionOnly);
121  return (chkSelectionOnly) ? chkSelectionOnly->isChecked() : false;
122 }
123 
124 //***************************************************************************
125 void Kwave::SaveBlocksWidget::setNewExample(const QString &example)
126 {
127  Q_ASSERT(txtExample);
128  if (txtExample) txtExample->setText(example);
129 }
130 
131 //***************************************************************************
132 //***************************************************************************
SaveBlocksWidget(QWidget *widget, QString filename_pattern, Kwave::SaveBlocksPlugin::numbering_mode_t numbering_mode, bool selection_only, bool have_selection)
QString name(FileProperty key) const
Definition: FileInfo.h:227
Kwave::SaveBlocksPlugin::numbering_mode_t numberingMode()
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void setNewExample(const QString &example)
#define _(m)
Definition: memcpy.c:66