• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

kig

  • sources
  • kde-4.12
  • kdeedu
  • kig
  • misc
kigfiledialog.cc
Go to the documentation of this file.
1 // Copyright (C) 2005 Pino Toscano <toscano.pino@tiscali.it>
2 
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
7 
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
16 // USA
17 
18 #include "kigfiledialog.h"
19 #include "kigfiledialog.moc"
20 
21 #include <qfile.h>
22 
23 #include <klocale.h>
24 #include <kmessagebox.h>
25 
26 KigFileDialog::KigFileDialog( const QString& startDir, const QString& filter,
27  const QString& caption, QWidget* parent )
28  : KFileDialog( startDir, filter, parent ),
29  mow( 0L )
30 {
31  setCaption( caption );
32  setOperationMode( Saving );
33  setMode( KFile::File | KFile::LocalOnly );
34  moptcaption = i18n( "Options" );
35 }
36 
37 void KigFileDialog::setOptionsWidget( QWidget* w )
38 {
39  mow = w;
40 }
41 
42 void KigFileDialog::accept()
43 {
44  // i know this is an ugly hack, but i hadn't found other ways to get
45  // the selected file name _before_ the dialog is accept()'ed or
46  // reject()'ed... in every case, below we make sure to accept() or
47  // reject()...
48  setResult( QDialog::Accepted );
49 
50  QString sFile = selectedFile();
51  if ( QFile::exists( sFile ) )
52  {
53  int ret = KMessageBox::warningContinueCancel( this,
54  i18n( "The file \"%1\" already exists. Do you wish to overwrite it?" ,
55  sFile ), i18n( "Overwrite File?" ), KStandardGuiItem::overwrite() );
56  if ( ret != KMessageBox::Continue )
57  {
58  KFileDialog::reject();
59  return;
60  }
61  }
62  if ( mow )
63  {
64  KDialog* optdlg = new KDialog( this );
65  optdlg->setCaption( moptcaption );
66  optdlg->setButtons( KDialog::Cancel | KDialog::Ok );
67  mow->setParent( optdlg );
68  optdlg->setMainWidget( mow );
69  optdlg->exec() == QDialog::Accepted ? KFileDialog::accept() : KFileDialog::reject();
70  }
71  else
72  KFileDialog::accept();
73 }
74 
75 void KigFileDialog::setOptionCaption( const QString& caption )
76 {
77  if ( caption.isEmpty() )
78  return;
79 
80  moptcaption = caption;
81 }
KigFileDialog::accept
virtual void accept()
Definition: kigfiledialog.cc:42
QWidget
KDialog
KFileDialog
KigFileDialog::KigFileDialog
KigFileDialog(const QString &startDir, const QString &filter, const QString &caption, QWidget *parent)
Construct a new KigFileDialog.
Definition: kigfiledialog.cc:26
KigFileDialog::setOptionCaption
void setOptionCaption(const QString &caption)
Set the caption of the option dialog.
Definition: kigfiledialog.cc:75
KigFileDialog::setOptionsWidget
void setOptionsWidget(QWidget *w)
Use this to set the widget containing the options of eg an export filter.
Definition: kigfiledialog.cc:37
kigfiledialog.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:35:39 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kig

Skip menu "kig"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal