[3e4acc]: plugins / saveblocks / SaveBlocksDialog.cpp Maximize Restore History

Download this file

SaveBlocksDialog.cpp    119 lines (103 with data), 4.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/***************************************************************************
SaveBlocksDialog.cpp - Extended KwaveFileDialog for saving blocks
-------------------
begin : Thu Mar 01 2007
copyright : (C) 2007 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "config.h"
#include <QComboBox>
#include <QString>
#include <kabstractfilewidget.h>
#include <kfiledialog.h>
#include <kurlcombobox.h>
#include "SaveBlocksDialog.h"
#include "SaveBlocksWidget.h"
//***************************************************************************
SaveBlocksDialog::SaveBlocksDialog(const QString &startDir,
const QString &filter,
QWidget *parent,
bool modal,
const QString last_url,
const QString last_ext,
QString filename_pattern,
SaveBlocksPlugin::numbering_mode_t numbering_mode,
bool selection_only,
bool have_selection
)
:KwaveFileDialog(startDir, filter, parent, modal, last_url, last_ext),
m_widget(new SaveBlocksWidget(this, filename_pattern,
numbering_mode, selection_only, have_selection))
{
Q_ASSERT(m_widget);
fileWidget()->setCustomWidget(m_widget);
connect(m_widget, SIGNAL(somethingChanged()),
this, SLOT(emitUpdate()));
// if something in the file selection changes
connect(this, SIGNAL(filterChanged(const QString &)),
this, SLOT(textChanged(const QString &)));
connect(locationEdit(), SIGNAL(editTextChanged(const QString &)),
this, SLOT(textChanged(const QString &)));
}
//***************************************************************************
SaveBlocksDialog::~SaveBlocksDialog()
{
if (m_widget) delete m_widget;
m_widget = 0;
}
//***************************************************************************
QString SaveBlocksDialog::pattern()
{
Q_ASSERT(m_widget);
return (m_widget) ? m_widget->pattern() : "";
}
//***************************************************************************
SaveBlocksPlugin::numbering_mode_t SaveBlocksDialog::numberingMode()
{
Q_ASSERT(m_widget);
return (m_widget) ? m_widget->numberingMode() :
SaveBlocksPlugin::CONTINUE;
}
//***************************************************************************
bool SaveBlocksDialog::selectionOnly()
{
Q_ASSERT(m_widget);
return (m_widget) ? m_widget->selectionOnly() : false;
}
//***************************************************************************
void SaveBlocksDialog::setNewExample(const QString &example)
{
Q_ASSERT(m_widget);
if (m_widget) m_widget->setNewExample(example);
}
//***************************************************************************
void SaveBlocksDialog::emitUpdate()
{
QString path = baseUrl().path(KUrl::AddTrailingSlash);
QString filename = path + locationEdit()->currentText();
QFileInfo file(filename);
if (!file.suffix().length()) {
// append the currently selected extension if it's missing
QString extension = selectedExtension().section(" ", 0, 0);
filename += extension.remove(0, 1);
}
emit sigSelectionChanged(filename, pattern(),
numberingMode(), selectionOnly());
}
//***************************************************************************
void SaveBlocksDialog::textChanged(const QString &)
{
emitUpdate();
}
//***************************************************************************
#include "SaveBlocksDialog.moc"
//***************************************************************************
//***************************************************************************