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)  

OpenProjectDialog.cpp
Go to the documentation of this file.
1 
11 
30 #include "OpenProjectDialog.h"
31 #include "ApplicationWindow.h"
32 
33 #include <QHBoxLayout>
34 #include <QLabel>
35 #include <QPushButton>
36 #include <QCloseEvent>
37 
38 OpenProjectDialog::OpenProjectDialog(QWidget *parent, bool extended, Qt::WindowFlags flags)
39  : ExtensibleFileDialog(parent, extended, flags)
40 {
41  setWindowTitle(tr("Open Project"));
42  setFileMode(ExistingFile);
43  QStringList filters;
44  filters << tr("SciDAVis project") + " (*.sciprj)"
45  << tr("Compressed SciDAVis project") + " (*.sciprj.gz)"
46  << tr("QtiPlot project") + " (*.qti)"
47  << tr("Compressed QtiPlot project") + " (*.qti.gz)"
48 #ifdef ORIGIN_IMPORT
49  << tr("Origin project") + " (*.opj *.OPJ)"
50  << tr("Origin matrix") + " (*.ogm *.OGM)"
51  << tr("Origin worksheet") + " (*.ogw *.OGW)"
52  << tr("Origin graph") + " (*.ogg *.OGG)"
53  << tr("Origin 3.5 project") + " (*.org *.ORG)"
54 #endif
55  << tr("Backup files") + " (*.sciprj~)"
56  //<< tr("Python Source") + " (*.py *.PY)"
57  << tr("All files") + " (*)";
58  setNameFilters(filters);
59 
60  QWidget *advanced_options = new QWidget();
61  QHBoxLayout *advanced_layout = new QHBoxLayout();
62  advanced_options->setLayout(advanced_layout);
63  advanced_layout->addWidget(new QLabel(tr("Open As")));
64  d_open_mode = new QComboBox();
65  // Important: Keep this is sync with enum OpenMode.
66  d_open_mode->addItem(tr("New Project Window"));
67  d_open_mode->addItem(tr("New Folder"));
68  advanced_layout->addWidget(d_open_mode);
69  setExtensionWidget(advanced_options);
70 
71 #if QT_VERSION >= 0x040300
72  connect(this, SIGNAL(filterSelected ( const QString & )),
73  this, SLOT(updateAdvancedOptions ( const QString & )));
74 #else
75  QList<QComboBox*> combo_boxes = findChildren<QComboBox*>();
76  if (combo_boxes.size() >= 2)
77  connect(combo_boxes[1], SIGNAL(currentIndexChanged ( const QString & )),
78  this, SLOT(updateAdvancedOptions ( const QString & )));
79 #endif
80  updateAdvancedOptions(selectedNameFilter());
81 }
82 
83 void OpenProjectDialog::updateAdvancedOptions (const QString & filter)
84 {
85  if (filter.contains("*.ogm") || filter.contains("*.ogw")) {
86  d_extension_toggle->setChecked(false);
87  d_extension_toggle->setEnabled(false);
88  return;
89  }
90  d_extension_toggle->setEnabled(true);
91 }
92 
93 void OpenProjectDialog::closeEvent(QCloseEvent* e)
94 {
95  if (isExtendable()){
96  ApplicationWindow *app = (ApplicationWindow *)this->parent();
97  if (app)
98  app->d_extended_open_dialog = this->isExtended();
99  }
100 
101  e->accept();
102 }
OpenProjectDialog::updateAdvancedOptions
void updateAdvancedOptions(const QString &filter)
Update which options are visible and enabled based on the output format.
Definition: OpenProjectDialog.cpp:83
ExtensibleFileDialog::isExtendable
bool isExtendable()
Tells weather the dialog has a valid extension widget.
Definition: ExtensibleFileDialog.h:60
ExtensibleFileDialog::setExtensionWidget
void setExtensionWidget(QWidget *extension)
Set the extension widget to be displayed when the user presses the toggle button.
Definition: ExtensibleFileDialog.cpp:66
OpenProjectDialog::closeEvent
void closeEvent(QCloseEvent *)
Definition: OpenProjectDialog.cpp:93
ExtensibleFileDialog::d_extension_toggle
QPushButton * d_extension_toggle
Button for toggling display of extension on/off.
Definition: ExtensibleFileDialog.h:62
OpenProjectDialog.h
ApplicationWindow::d_extended_open_dialog
bool d_extended_open_dialog
Definition: ApplicationWindow.h:931
python-sipcmd.flags
list flags
Definition: python-sipcmd.py:61
ExtensibleFileDialog
QFileDialog plus generic extension support.
Definition: ExtensibleFileDialog.h:45
ApplicationWindow
SciDAVis's main window.
Definition: ApplicationWindow.h:122
OpenProjectDialog::OpenProjectDialog
OpenProjectDialog(QWidget *parent=0, bool extended=true, Qt::WindowFlags flags=0)
Definition: OpenProjectDialog.cpp:38
ExtensibleFileDialog::isExtended
bool isExtended()
Definition: ExtensibleFileDialog.h:61
OpenProjectDialog::d_open_mode
QComboBox * d_open_mode
Definition: OpenProjectDialog.h:45
ApplicationWindow.h