"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/c2bFileDialog.cpp" between
cb2bib-1.9.9.tar.gz and cb2bib-2.0.0.tar.gz

About: cb2Bib is a multiplatform application for rapidly extracting unformatted, or unstandardized bibliographic references from email alerts, journal Web pages, and PDF files.

c2bFileDialog.cpp  (cb2bib-1.9.9):c2bFileDialog.cpp  (cb2bib-2.0.0)
/*************************************************************************** /***************************************************************************
* Copyright (C) 2004-2018 by Pere Constans * Copyright (C) 2004-2019 by Pere Constans
* constans@molspaces.com * constans@molspaces.com
* cb2Bib version 1.9.9. Licensed under the GNU GPL version 3. * cb2Bib version 2.0.0. Licensed under the GNU GPL version 3.
* See the LICENSE file that comes with this distribution. * See the LICENSE file that comes with this distribution.
***************************************************************************/ ***************************************************************************/
#include "c2bFileDialog.h" #include "c2bFileDialog.h"
#include "c2bSettings.h" #include "c2bSettings.h"
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include <QTimer> #include <QTimer>
c2bFileDialog::c2bFileDialog(QWidget* parentw, const QString& caption, const QSt ring& fpath, const QString& ffilter) c2bFileDialog::c2bFileDialog(QWidget* parentw, const QString& caption, const QSt ring& fpath, const QString& ffilter)
: QFileDialog(parentw, caption, fpath, ffilter) : QFileDialog(parentw, caption, fpath, ffilter)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
setWindowFlags(windowFlags() | Qt::WindowMinMaxButtonsHint);
setOptions(QFileDialog::DontUseNativeDialog); setOptions(QFileDialog::DontUseNativeDialog);
setModal(true); setModal(true);
settings = c2bSettingsP; settings = c2bSettingsP;
#ifdef Q_OS_UNIX
// Distinguish executable files
fip = new fileIconProvider();
setIconProvider(fip);
#endif
} }
c2bFileDialog::~c2bFileDialog() c2bFileDialog::~c2bFileDialog() {}
{
#ifdef Q_OS_UNIX
delete fip;
#endif
}
QString c2bFileDialog::getFilename(QWidget* parentw, const QString& caption, con st QString& path, const QString& filter) QString c2bFileDialog::getFilename(QWidget* parentw, const QString& caption, con st QString& path, const QString& filter)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter);
dlg->setConfirmOverwrite(false); dlg->setConfirmOverwrite(false);
dlg->setFileMode(AnyFile); dlg->setFileMode(AnyFile);
dlg->setAcceptMode(AcceptSave); dlg->setAcceptMode(AcceptSave);
dlg->setLabelText(QFileDialog::Accept, "Select"); dlg->setLabelText(QFileDialog::Accept, "Select");
const QString fn(dlg->fileName(path)); const QString fn(dlg->fileName(path));
delete dlg; delete dlg;
return fn; return fn;
} }
QString c2bFileDialog::getOpenFilename(QWidget* parentw, const QString& caption, QString c2bFileDialog::getOpenFilename(QWidget* parentw, const QString& caption,
const QString& path, const QString& filter) const QString& path,
const QString& filter)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter);
dlg->setFileMode(ExistingFile); dlg->setFileMode(ExistingFile);
dlg->setLabelText(QFileDialog::Accept, "Select"); dlg->setLabelText(QFileDialog::Accept, "Select");
const QString fn(dlg->fileName(path)); const QString fn(dlg->fileName(path));
delete dlg; delete dlg;
return fn; return fn;
} }
QStringList c2bFileDialog::getOpenFilenames(QWidget* parentw, const QString& cap QStringList c2bFileDialog::getOpenFilenames(QWidget* parentw, const QString& cap
tion, const QString& path, const QString& filter) tion, const QString& path,
const QString& filter)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select filename s"), caption), _path(path), filter); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select filename s"), caption), _path(path), filter);
dlg->setFileMode(ExistingFiles); dlg->setFileMode(ExistingFiles);
dlg->setLabelText(QFileDialog::Accept, "Select"); dlg->setLabelText(QFileDialog::Accept, "Select");
const QString fn(dlg->fileName(path)); const QString fn(dlg->fileName(path));
QStringList fns; QStringList fns;
if (!fn.isEmpty()) if (!fn.isEmpty())
fns = dlg->selectedFiles(); fns = dlg->selectedFiles();
delete dlg; delete dlg;
return fns; return fns;
} }
QString c2bFileDialog::getSaveFilename(QWidget* parentw, const QString& caption, QString c2bFileDialog::getSaveFilename(QWidget* parentw, const QString& caption,
const QString& path, const QString& filter) const QString& path,
const QString& filter)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Save As"), capt ion), _path(path), filter); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Save As"), capt ion), _path(path), filter);
dlg->setFileMode(AnyFile); dlg->setFileMode(AnyFile);
dlg->setAcceptMode(AcceptSave); dlg->setAcceptMode(AcceptSave);
const QString fn(dlg->fileName(path)); const QString fn(dlg->fileName(path));
delete dlg; delete dlg;
return fn; return fn;
} }
QString c2bFileDialog::getExistingDirectory(QWidget* parentw, const QString& cap tion, const QString& path) QString c2bFileDialog::getExistingDirectory(QWidget* parentw, const QString& cap tion, const QString& path)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption("Select directory", caption), _dirpath(path), QString()); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption("Select directory", caption), _dirpath(path), QString());
dlg->setFileMode(DirectoryOnly); dlg->setFileMode(DirectoryOnly);
dlg->setLabelText(QFileDialog::Accept, "Select"); dlg->setLabelText(QFileDialog::Accept, "Select");
const QString fn(dlg->fileName(QString())); const QString fn(dlg->fileName(QString()));
delete dlg; delete dlg;
return fn; return fn;
} }
QString c2bFileDialog::getSystemFilename(QWidget* parentw, const QString& captio QString c2bFileDialog::getSystemFilename(QWidget* parentw, const QString& captio
n, const QString& path, const QString& filter) n, const QString& path,
const QString& filter)
{ {
c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter); c2bFileDialog* dlg = new c2bFileDialog(parentw, _caption(tr("Select a filena me"), caption), _path(path), filter);
dlg->setFileMode(AnyFile); dlg->setFileMode(AnyFile);
dlg->setLabelText(QFileDialog::Accept, "Select"); dlg->setLabelText(QFileDialog::Accept, "Select");
dlg->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot | QDir::S ystem); dlg->setFilter(QDir::Drives | QDir::AllDirs | QDir::NoDotAndDotDot | QDir::S ystem);
dlg->setNameFilterDetailsVisible(false); dlg->setNameFilterDetailsVisible(false);
const QString fn(dlg->fileName(path)); const QString fn(dlg->fileName(path));
delete dlg; delete dlg;
return fn; return fn;
} }
skipping to change at line 221 skipping to change at line 216
return QFileInfo(path).absolutePath(); return QFileInfo(path).absolutePath();
} }
QString c2bFileDialog::_dirpath(const QString& path) QString c2bFileDialog::_dirpath(const QString& path)
{ {
if (path.isEmpty()) if (path.isEmpty())
return QDir::homePath(); return QDir::homePath();
else else
return QFileInfo(path + '/').absolutePath(); return QFileInfo(path + '/').absolutePath();
} }
/***************************************************************************
Class fileIconProvider
***************************************************************************/
fileIconProvider::fileIconProvider() : QFileIconProvider()
{
_exec_icon = QIcon(":/icons/icons/application-x-executable.png");
}
fileIconProvider::~fileIconProvider()
{}
QIcon fileIconProvider::icon(const QFileInfo& info) const
{
if (info.isExecutable() && !info.isDir())
return _exec_icon;
else
return QFileIconProvider::icon(info);
}
 End of changes. 10 change blocks. 
21 lines changed or deleted 16 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)