~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to parts/filecreate/filecreate_filedialog.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2006-05-23 18:39:42 UTC
  • Revision ID: james.westby@ubuntu.com-20060523183942-hucifbvh68k2bwz7
Tags: upstream-3.3.2
Import upstream version 3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2003 by Julian Rockey                                   *
 
3
 *   linux@jrockey.com                                                     *
 
4
 *                                                                         *
 
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
 ***************************************************************************/
 
10
 
 
11
#include "filecreate_filedialog.h"
 
12
 
 
13
#include <qfileinfo.h>
 
14
#include <kdeversion.h>
 
15
#include <kurlcombobox.h>
 
16
#include <kdebug.h>
 
17
 
 
18
#include "filecreate_part.h"
 
19
#include "filecreate_filetype.h"
 
20
 
 
21
namespace FileCreate {
 
22
 
 
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) {
 
28
#else
 
29
    KFileDialog(startDir, filter, parent, name, modal) {
 
30
      if (extraWidget) setPreviewWidget(extraWidget);
 
31
#endif
 
32
 
 
33
    setOperationMode(Saving);
 
34
 
 
35
    m_extraWidget = extraWidget;
 
36
    m_typeChooser = dynamic_cast<TypeChooser*>(extraWidget);
 
37
 
 
38
    connect(this, SIGNAL(filterChanged(const QString &)), this, SLOT(slotActionFilterChanged(const QString &)) );
 
39
    connect(locationEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotActionTextChanged(const QString &)) );
 
40
 
 
41
  }
 
42
 
 
43
  FileDialog::~FileDialog() { }
 
44
 
 
45
 
 
46
  void FileDialog::initGUI()
 
47
  {
 
48
    KFileDialog::initGUI();
 
49
  }
 
50
 
 
51
  void FileDialog::slotActionFilterChanged(const QString & /*filter*/) {
 
52
  }
 
53
 
 
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);
 
64
  }
 
65
 
 
66
 
 
67
 
 
68
}
 
69
 
 
70
#include "filecreate_filedialog.moc"