~valavanisalex/ubuntu/maverick/scidavis/fix-604811

« back to all changes in this revision

Viewing changes to scidavis/src/ExtensibleFileDialog.h

  • Committer: Bazaar Package Importer
  • Author(s): Ruben Molina
  • Date: 2009-09-06 11:34:04 UTC
  • Revision ID: james.westby@ubuntu.com-20090906113404-4awaey82l3686w4q
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
    File                 : ExtensibleFileDialog.h
 
3
    Project              : SciDAVis
 
4
    --------------------------------------------------------------------
 
5
    Copyright            : (C) 2007 by Knut Franke
 
6
    Email (use @ for *)  : knut.franke*gmx.de
 
7
    Description          : QFileDialog plus generic extension support
 
8
 
 
9
 ***************************************************************************/
 
10
 
 
11
/***************************************************************************
 
12
 *                                                                         *
 
13
 *  This program is free software; you can redistribute it and/or modify   *
 
14
 *  it under the terms of the GNU General Public License as published by   *
 
15
 *  the Free Software Foundation; either version 2 of the License, or      *
 
16
 *  (at your option) any later version.                                    *
 
17
 *                                                                         *
 
18
 *  This program is distributed in the hope that it will be useful,        *
 
19
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
20
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 
21
 *  GNU General Public License for more details.                           *
 
22
 *                                                                         *
 
23
 *   You should have received a copy of the GNU General Public License     *
 
24
 *   along with this program; if not, write to the Free Software           *
 
25
 *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
 
26
 *   Boston, MA  02110-1301  USA                                           *
 
27
 *                                                                         *
 
28
 ***************************************************************************/
 
29
#ifndef EXTENSIBLE_FILE_DIALOG_H
 
30
#define EXTENSIBLE_FILE_DIALOG_H
 
31
 
 
32
#include <QFileDialog>
 
33
#include <QPushButton>
 
34
 
 
35
//! QFileDialog plus generic extension support.
 
36
/**
 
37
 * This is a simple hack on top of QFileDialog that allows a custom extension widget to be added to
 
38
 * the bottom of the dialog. A button is provided for toggling display of this widget on/off.
 
39
 *
 
40
 * For the placement of button and extension widget, it is assumed that QFileDialog uses a
 
41
 * QGridLayout as its top-level layout. Other layouts will probably lead to a strange outlook,
 
42
 * although the functionality should stay intact.
 
43
 */
 
44
class ExtensibleFileDialog : public QFileDialog
 
45
{
 
46
        Q_OBJECT
 
47
        
 
48
        public:
 
49
                //! Constructor.
 
50
                /**
 
51
                 * \param parent parent widget (only affects placement of the dialog)
 
52
                 * \param extended flag: show/hide the advanced options on start-up
 
53
                 * \param flags window flags
 
54
                 */
 
55
                ExtensibleFileDialog(QWidget *parent=0, bool extended = true, Qt::WFlags flags=0);
 
56
                //! Set the extension widget to be displayed when the user presses the toggle button.
 
57
                void setExtensionWidget(QWidget *extension);
 
58
        
 
59
                //! Tells weather the dialog has a valid extension widget
 
60
                bool isExtendable(){return d_extension != NULL;};
 
61
                bool isExtended(){return d_extension_toggle->isChecked();};
 
62
                void setExtended(bool extended){ d_extension_toggle->setChecked(extended);};
 
63
                
 
64
        protected:
 
65
                //! Button for toggling display of extension on/off.
 
66
                QPushButton *d_extension_toggle;
 
67
 
 
68
        private slots:
 
69
                //! Resize to make/take space for the extension widget.
 
70
                void resize(bool extension_on);
 
71
 
 
72
        private:
 
73
                //! The extension widget
 
74
                QWidget *d_extension;
 
75
                //! The layout row (of the assumed QGridLayout) used for extensions
 
76
                int d_extension_row;
 
77
};
 
78
 
 
79
#endif // ifndef EXTENSIBLE_FILE_DIALOG_H