MultiQFileDialog::MultiQFileDialog(QWidget *parent, const QString &caption, const QString &directory, bool multiSelect, const QString &filter) : QFileDialog(parent, caption, directory, filter) { this->showHidden = false; this->multiSelect = multiSelect; setOption(QFileDialog::DontUseNativeDialog, false); if (multiSelect) { setOption(QFileDialog::DontUseNativeDialog, true); le = findChild<QLineEdit*>(QString::fromUtf8("fileNameEdit")); QListView *l = findChild<QListView*>(QString::fromUtf8("listView")); if (l) { l->setSelectionMode(QListView::ExtendedSelection); if (le) { connect(l->selectionModel(), SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )), this, SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & ))); } } QTreeView *t = findChild<QTreeView*>(); if (t) { t->setSelectionMode(QAbstractItemView::ExtendedSelection); if (le) { connect(t->selectionModel(), SIGNAL(selectionChanged ( const QItemSelection &, const QItemSelection & )), this, SLOT(onSelectionChanged ( const QItemSelection &, const QItemSelection & ))); } } QLabel *label = findChild<QLabel*>(QString::fromUtf8("fileNameLabel")); if (label) { label->hide(); } label = findChild<QLabel*>(QString::fromUtf8("fileTypeLabel")); if (label) { label->hide(); } label = findChild<QLabel*>(QString::fromUtf8("lookInLabel")); if (label) { label->hide(); } QDialogButtonBox *buttonBox = findChild<QDialogButtonBox*>(QString::fromUtf8("buttonBox")); if (buttonBox) { buttonBox->button(QDialogButtonBox::Open)->setText(QCoreApplication::translate("QDialogButtonBox", "&OK")); } setFileMode(QFileDialog::ExistingFiles); if (le) { le->setText(QCoreApplication::translate("ShellExtension", "Upload to MEGA")); } } QList<QWidget *> widgets = findChildren<QWidget *>(); for (QList<QWidget *>::const_iterator it = widgets.begin(); it != widgets.end(); ++it) { (*it)->installEventFilter(this); } installEventFilter(this); }
QString QG_FileDialog::getOpenFile(RS2::FormatType* type){ // bool fileAccepted = false; setAcceptMode ( QFileDialog::AcceptOpen ); // read default settings: RS_SETTINGS->beginGroup("/Paths"); QString defDir = RS_SETTINGS->readEntry("/Open", RS_SYSTEM->getHomeDir()); RS_SETTINGS->endGroup(); RS_DEBUG->print("defDir: %s", defDir.toLatin1().data()); QString fn = ""; QStringList filters; #ifdef USE_DXFRW filters << fDxf << fDxfrw << fDxf1 << fLff << fCxf << fJww; #else filters << fDxf << fDxf1 << fLff << fCxf << fJww; #endif setWindowTitle(tr("Open %1").arg(name)); #if QT_VERSION >= 0x040400 setNameFilters(filters); #endif setDirectory(defDir); setFileMode(QFileDialog::ExistingFile); #if QT_VERSION >= 0x040400 selectNameFilter(fDxfrw); #endif ftype= RS2::FormatDXFRW; RS_DEBUG->print("defFilter: %s", fDxfrw.toLatin1().data()); /* preview RVT PORT preview is currently not supported by QT4 RS_Graphic* gr = new RS_Graphic; QG_GraphicView* prev = new QG_GraphicView(parent); prev->setContainer(gr); prev->setBorders(1, 1, 1, 1); fileDlg->setContentsPreviewEnabled(true); fileDlg->setContentsPreview(prev, prev); */ if (exec()==QDialog::Accepted) { QStringList fl = selectedFiles(); if (!fl.isEmpty()) { fn = fl[0]; } fn = QDir::convertSeparators( QFileInfo(fn).absoluteFilePath() ); if (type!=NULL) { getType(selectedFilter()); *type = ftype; } // store new default settings: RS_SETTINGS->beginGroup("/Paths"); RS_SETTINGS->writeEntry("/Open", QFileInfo(fn).absolutePath()); RS_SETTINGS->writeEntry("/OpenFilter", selectedFilter()); RS_SETTINGS->endGroup(); } RS_DEBUG->print("QG_FileDialog::getOpenFileName: fileName: %s", fn.toLatin1().data()); RS_DEBUG->print("QG_FileDialog::getOpenFileName: OK"); // RVT PORT delete prev; // RVT PORT delete gr; return fn; }
ImportASCIIDialog::ImportASCIIDialog(bool new_windows_only, QWidget * parent, bool extended, Qt::WFlags flags ) : ExtensibleFileDialog(parent, extended, flags ) { setWindowTitle(tr("QtiPlot - Import ASCII File(s)")); QStringList filters; filters << tr("All files") + " (*)"; filters << tr("Text files") + " (*.TXT *.txt)"; filters << tr("Data files") + " (*.DAT *.dat)"; filters << tr("Comma Separated Values") + " (*.CSV *.csv)"; setFilters( filters ); setFileMode( QFileDialog::ExistingFiles ); d_current_path = QString::null; initAdvancedOptions(); setNewWindowsOnly(new_windows_only); setExtensionWidget(d_advanced_options); // get rembered option values ApplicationWindow *app = (ApplicationWindow *)parent; setLocale(app->locale()); d_strip_spaces->setChecked(app->strip_spaces); d_simplify_spaces->setChecked(app->simplify_spaces); d_ignored_lines->setValue(app->ignoredLines); d_rename_columns->setChecked(app->renameColumns); setColumnSeparator(app->columnSeparator); d_comment_string->setText(app->d_ASCII_comment_string); d_import_comments->setChecked(app->d_ASCII_import_comments); d_read_only->setChecked(app->d_ASCII_import_read_only); if (app->d_ASCII_import_locale.name() == QLocale::c().name()) boxDecimalSeparator->setCurrentIndex(1); else if (app->d_ASCII_import_locale.name() == QLocale(QLocale::German).name()) boxDecimalSeparator->setCurrentIndex(2); else if (app->d_ASCII_import_locale.name() == QLocale(QLocale::French).name()) boxDecimalSeparator->setCurrentIndex(3); boxDecimalSeparator->setEnabled(app->d_import_dec_separators); d_import_dec_separators->setChecked(app->d_import_dec_separators); connect(d_import_mode, SIGNAL(currentIndexChanged(int)), this, SLOT(updateImportMode(int))); if (app->d_ASCII_import_mode < d_import_mode->count()) d_import_mode->setCurrentIndex(app->d_ASCII_import_mode); d_preview_lines_box->setValue(app->d_preview_lines); d_preview_button->setChecked(app->d_ASCII_import_preview); boxEndLine->setCurrentIndex((int)app->d_ASCII_end_line); if (!app->d_ASCII_import_preview) d_preview_stack->hide(); initPreview(d_import_mode->currentIndex()); connect(d_preview_lines_box, SIGNAL(valueChanged(int)), this, SLOT(preview())); connect(d_rename_columns, SIGNAL(clicked()), this, SLOT(preview())); connect(d_import_comments, SIGNAL(clicked()), this, SLOT(preview())); connect(d_strip_spaces, SIGNAL(clicked()), this, SLOT(preview())); connect(d_simplify_spaces, SIGNAL(clicked()), this, SLOT(preview())); connect(d_ignored_lines, SIGNAL(valueChanged(int)), this, SLOT(preview())); connect(d_import_dec_separators, SIGNAL(clicked()), this, SLOT(preview())); connect(d_column_separator, SIGNAL(currentIndexChanged(int)), this, SLOT(preview())); connect(boxDecimalSeparator, SIGNAL(currentIndexChanged(int)), this, SLOT(preview())); connect(d_comment_string, SIGNAL(textChanged(const QString&)), this, SLOT(preview())); connect(this, SIGNAL(currentChanged(const QString&)), this, SLOT(changePreviewFile(const QString&))); }