1
/***************************************************************************
2
* Copyright (C) 2003 by Julian Rockey *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
9
***************************************************************************/
11
#include "filecreate_filedialog.h"
13
#include <qfileinfo.h>
14
#include <kdeversion.h>
15
#include <kurlcombobox.h>
18
#include "filecreate_part.h"
19
#include "filecreate_filetype.h"
21
namespace FileCreate {
23
FileDialog::FileDialog(const QString& startDir, const QString& filter,
24
QWidget *parent, const char *name,
25
bool modal, QWidget * extraWidget) :
26
#if KDE_VERSION >= 310
27
KFileDialog(startDir, filter, parent, name, modal, extraWidget) {
29
KFileDialog(startDir, filter, parent, name, modal) {
30
if (extraWidget) setPreviewWidget(extraWidget);
33
setOperationMode(Saving);
35
m_extraWidget = extraWidget;
36
m_typeChooser = dynamic_cast<TypeChooser*>(extraWidget);
38
connect(this, SIGNAL(filterChanged(const QString &)), this, SLOT(slotActionFilterChanged(const QString &)) );
39
connect(locationEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotActionTextChanged(const QString &)) );
43
FileDialog::~FileDialog() { }
46
void FileDialog::initGUI()
48
KFileDialog::initGUI();
51
void FileDialog::slotActionFilterChanged(const QString & /*filter*/) {
54
void FileDialog::slotActionTextChanged(const QString & text) {
55
kdDebug(9034) << "slotActionTextChanged - " << text << endl;
56
if (!m_typeChooser) return;
57
QString ext = QFileInfo(text).extension();
58
kdDebug(9034) << "Extension is: " << ext << endl;
59
FileType * filetype = m_typeChooser->part()->getType(ext);
60
if (!filetype) return;
61
kdDebug(9034) << "found matching extension: " << ext << endl;
62
kdDebug(9034) << "Description: " << filetype->descr() << endl;
63
m_typeChooser->setCurrent(filetype);
70
#include "filecreate_filedialog.moc"