scidavis  2.3.0
About: SciDAVis is a free application for Scientific Data Analysis and Visualization (a fork off of QtiPlot).
  Fossies Dox: scidavis-2.3.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

ExtensibleFileDialog Class Reference

QFileDialog plus generic extension support. More...

#include <ExtensibleFileDialog.h>

Inheritance diagram for ExtensibleFileDialog:
[legend]
Collaboration diagram for ExtensibleFileDialog:
[legend]

Public Member Functions

 ExtensibleFileDialog (QWidget *parent=0, bool extended=true, Qt::WindowFlags flags=0)
 Constructor. More...
 
void setExtensionWidget (QWidget *extension)
 Set the extension widget to be displayed when the user presses the toggle button. More...
 
bool isExtendable ()
 Tells weather the dialog has a valid extension widget. More...
 
bool isExtended ()
 
void setExtended (bool extended)
 

Protected Attributes

QPushButton * d_extension_toggle
 Button for toggling display of extension on/off. More...
 

Private Slots

void resize (bool extension_on)
 Resize to make/take space for the extension widget. More...
 

Private Attributes

QWidget * d_extension
 The extension widget. More...
 
int d_extension_row
 The layout row (of the assumed QGridLayout) used for extensions. More...
 

Detailed Description

QFileDialog plus generic extension support.

File : ExtensibleFileDialog.h

Project : SciDAVis

Copyright : (C) 2007 by Knut Franke Email (use @ for *) : knut.franke*gmx.de Description : QFileDialog plus generic extension support

  • 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. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *
    • This is a simple hack on top of QFileDialog that allows a custom extension widget to be added to the bottom of the dialog. A button is provided for toggling display of this widget on/off.

For the placement of button and extension widget, it is assumed that QFileDialog uses a QGridLayout as its top-level layout. Other layouts will probably lead to a strange outlook, although the functionality should stay intact.

Definition at line 44 of file ExtensibleFileDialog.h.

Constructor & Destructor Documentation

◆ ExtensibleFileDialog()

ExtensibleFileDialog::ExtensibleFileDialog ( QWidget *  parent = 0,
bool  extended = true,
Qt::WindowFlags  flags = 0 
)

Constructor.

Parameters
parentparent widget (only affects placement of the dialog)
extendedflag: show/hide the advanced options on start-up
flagswindow flags

File : ExtensibleFileDialog.cpp

Project : SciDAVis

Copyright : (C) 2007 by Knut Franke Email (use @ for *) : knut.franke*gmx.de Description : QFileDialog plus generic extension support

  • 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. *
    • This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *
    • You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301 USA *

Definition at line 33 of file ExtensibleFileDialog.cpp.

34  : QFileDialog(parent, flags)
35 {
36  d_extension = 0;
37 
38 #if QT_VERSION >= 0x050000
39  // needed to extend the Qt5 QFileDialog
40  setOption(QFileDialog::DontUseNativeDialog, true);
41 #endif
42 
43  d_extension_toggle = new QPushButton(tr("<< &Advanced"));
44  d_extension_toggle->setCheckable(true);
45  if (extended)
46  d_extension_toggle->toggle();
47  d_extension_toggle->hide(); // show only for d_extension != 0
48 
49  QGridLayout *main_layout = qobject_cast<QGridLayout*>(layout());
50  if (main_layout) {
51  d_extension_row = main_layout->rowCount();
52  main_layout->addWidget(d_extension_toggle, d_extension_row, main_layout->columnCount()-1);
53  main_layout->setRowStretch(d_extension_row, 0);
54  main_layout->setRowStretch(d_extension_row+1, 0);
55  } else {
56  // fallback in case QFileDialog uses a different layout in the future (=> main_layout==0)
57  // would probably look a mess, but at least all functions would be accessible
58  layout()->addWidget(d_extension_toggle);
59  }
60 
61  connect(d_extension_toggle, SIGNAL(toggled(bool)), this, SLOT(resize(bool)));
62  connect(this, SIGNAL(accepted()), this, SLOT(close()));
63  connect(this, SIGNAL(rejected()), this, SLOT(close()));
64 }

References d_extension, d_extension_row, d_extension_toggle, and resize().

Here is the call graph for this function:

Member Function Documentation

◆ isExtendable()

bool ExtensibleFileDialog::isExtendable ( )
inline

Tells weather the dialog has a valid extension widget.

Definition at line 60 of file ExtensibleFileDialog.h.

60 {return d_extension != NULL;};

References d_extension.

Referenced by OpenProjectDialog::closeEvent().

Here is the caller graph for this function:

◆ isExtended()

bool ExtensibleFileDialog::isExtended ( )
inline

Definition at line 61 of file ExtensibleFileDialog.h.

61 {return d_extension_toggle->isChecked();};

References d_extension_toggle.

Referenced by ImageExportDialog::closeEvent(), ImportASCIIDialog::closeEvent(), and OpenProjectDialog::closeEvent().

Here is the caller graph for this function:

◆ resize

void ExtensibleFileDialog::resize ( bool  extension_on)
privateslot

Resize to make/take space for the extension widget.

Definition at line 91 of file ExtensibleFileDialog.cpp.

92 {
93  QSize geo = size();
94  geo.setHeight(geo.height() + (extension_on ? 1 : -1) * (d_extension->sizeHint().height()-44));
95  setGeometry(QRect(geometry().topLeft(), geo));
96 }

References d_extension.

Referenced by ExtensibleFileDialog().

Here is the caller graph for this function:

◆ setExtended()

void ExtensibleFileDialog::setExtended ( bool  extended)
inline

Definition at line 62 of file ExtensibleFileDialog.h.

62 { d_extension_toggle->setChecked(extended);};

References d_extension_toggle.

◆ setExtensionWidget()

void ExtensibleFileDialog::setExtensionWidget ( QWidget *  extension)

Set the extension widget to be displayed when the user presses the toggle button.

Definition at line 66 of file ExtensibleFileDialog.cpp.

67 {
68  if (d_extension == extension)
69  return;
70  if (d_extension) {
71  d_extension->hide();
72  disconnect(d_extension_toggle, SIGNAL(toggled(bool)));
73  }
74  d_extension = extension;
75  if (!d_extension) {
76  d_extension_toggle->hide();
77  return;
78  }
79  d_extension_toggle->show();
80 
81  QGridLayout *main_layout = qobject_cast<QGridLayout*>(layout());
82  if (main_layout)
83  main_layout->addWidget(d_extension, d_extension_row, 0, 2, main_layout->columnCount()-1);
84  else
85  layout()->addWidget(d_extension);
86 
87  d_extension->setVisible(d_extension_toggle->isChecked());
88  connect(d_extension_toggle, SIGNAL(toggled(bool)), d_extension, SLOT(setVisible(bool)));
89 }

References d_extension, d_extension_row, and d_extension_toggle.

Referenced by ApplicationWindow::appendProject(), ImageExportDialog::ImageExportDialog(), ImportASCIIDialog::ImportASCIIDialog(), OpenProjectDialog::OpenProjectDialog(), and TeXTableExportDialog::TeXTableExportDialog().

Here is the caller graph for this function:

Member Data Documentation

◆ d_extension

QWidget* ExtensibleFileDialog::d_extension
private

The extension widget.

Definition at line 74 of file ExtensibleFileDialog.h.

Referenced by ExtensibleFileDialog(), isExtendable(), resize(), and setExtensionWidget().

◆ d_extension_row

int ExtensibleFileDialog::d_extension_row
private

The layout row (of the assumed QGridLayout) used for extensions.

Definition at line 76 of file ExtensibleFileDialog.h.

Referenced by ExtensibleFileDialog(), and setExtensionWidget().

◆ d_extension_toggle

QPushButton* ExtensibleFileDialog::d_extension_toggle
protected

The documentation for this class was generated from the following files:
ExtensibleFileDialog::d_extension_row
int d_extension_row
The layout row (of the assumed QGridLayout) used for extensions.
Definition: ExtensibleFileDialog.h:76
ExtensibleFileDialog::d_extension
QWidget * d_extension
The extension widget.
Definition: ExtensibleFileDialog.h:74
ExtensibleFileDialog::d_extension_toggle
QPushButton * d_extension_toggle
Button for toggling display of extension on/off.
Definition: ExtensibleFileDialog.h:62
python-sipcmd.flags
list flags
Definition: python-sipcmd.py:61
ExtensibleFileDialog::resize
void resize(bool extension_on)
Resize to make/take space for the extension widget.
Definition: ExtensibleFileDialog.cpp:91