kwave  18.07.70
SaveBlocksDialog.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  SaveBlocksDialog.cpp - Extended KwaveFileDialog for saving blocks
3  -------------------
4  begin : Thu Mar 01 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 <QString>
21 #include <QUrl>
22 
23 #include <KComboBox>
24 #include <KUrlComboBox>
25 
26 #include "libkwave/String.h"
27 
28 #include "SaveBlocksDialog.h"
29 #include "SaveBlocksWidget.h"
30 
31 //***************************************************************************
33  const QString &filter,
34  QWidget *parent,
35  const QUrl &last_url,
36  const QString &last_ext,
37  QString &filename_pattern,
39  bool selection_only,
40  bool have_selection
41 )
42  :Kwave::FileDialog(startDir, Kwave::FileDialog::SaveFile, filter, parent,
43  last_url, last_ext),
44  m_widget(new(std::nothrow) Kwave::SaveBlocksWidget(this, filename_pattern,
45  numbering_mode, selection_only, have_selection))
46 {
47  Q_ASSERT(m_widget);
49  connect(m_widget, SIGNAL(somethingChanged()),
50  this, SLOT(emitUpdate()));
51 
52  // if something in the file selection changes
53  connect(this, SIGNAL(filterChanged(QString)),
54  this, SLOT(emitUpdate()));
55  connect(locationEdit(), SIGNAL(editTextChanged(QString)),
56  this, SLOT(emitUpdate()));
57 }
58 
59 //***************************************************************************
61 {
62  if (m_widget) delete m_widget;
63  m_widget = Q_NULLPTR;
64 }
65 
66 //***************************************************************************
68 {
69  Q_ASSERT(m_widget);
70  return (m_widget) ? m_widget->pattern() : _("");
71 }
72 
73 //***************************************************************************
75 {
76  Q_ASSERT(m_widget);
77  return (m_widget) ? m_widget->numberingMode() :
79 }
80 
81 //***************************************************************************
83 {
84  Q_ASSERT(m_widget);
85  return (m_widget) ? m_widget->selectionOnly() : false;
86 }
87 
88 //***************************************************************************
89 void Kwave::SaveBlocksDialog::setNewExample(const QString &example)
90 {
91  Q_ASSERT(m_widget);
92  if (m_widget) m_widget->setNewExample(example);
93 }
94 
95 //***************************************************************************
97 {
98  QString path = baseUrl().path() + QDir::separator();
99  QString filename = path + locationEdit()->currentText();
100  QFileInfo file(filename);
101 
102  if (!file.suffix().length()) {
103  // append the currently selected extension if missing
104  QString extension = selectedExtension();
105  if (extension.contains(_(" ")))
106  extension = extension.section(_(" "), 0, 0);
107  filename += extension.remove(0, 1);
108  }
109 
110  emit sigSelectionChanged(filename, pattern(),
112 }
113 
114 //***************************************************************************
115 //***************************************************************************
SaveBlocksDialog(const QString &startDir, const QString &filter, QWidget *parent, const QUrl &last_url, const QString &last_ext, QString &filename_pattern, Kwave::SaveBlocksPlugin::numbering_mode_t numbering_mode, bool selection_only, bool have_selection)
KUrlComboBox * locationEdit() const
Definition: FileDialog.cpp:346
Definition: App.h:33
Kwave::SaveBlocksPlugin::numbering_mode_t numberingMode()
void setCustomWidget(QWidget *widget)
Definition: FileDialog.cpp:340
QString selectedExtension()
Definition: FileDialog.cpp:246
Kwave::SaveBlocksPlugin::numbering_mode_t numberingMode()
QUrl baseUrl() const
Definition: FileDialog.cpp:259
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void setNewExample(const QString &example)
void setNewExample(const QString &example)
#define _(m)
Definition: memcpy.c:66
void sigSelectionChanged(const QString &filename, const QString &pattern, Kwave::SaveBlocksPlugin::numbering_mode_t mode, bool selection_only)
Kwave::SaveBlocksWidget * m_widget
void filterChanged(const QString &filter)