"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/c2bCiterWidget.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.

c2bCiterWidget.cpp  (cb2bib-1.9.9):c2bCiterWidget.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 "c2bCiterWidget.h" #include "c2bCiterWidget.h"
#include "c2b.h" #include "c2b.h"
#include "c2bCiterModel.h" #include "c2bCiterModel.h"
#include "c2bClipboard.h" #include "c2bClipboard.h"
#include "c2bCollectionIndex.h" #include "c2bCollectionIndex.h"
#include "c2bCoreCiter.h" #include "c2bCoreCiter.h"
#include "c2bFileDialog.h" #include "c2bFileDialog.h"
skipping to change at line 38 skipping to change at line 38
_tray_icon = 0; _tray_icon = 0;
setActions(); setActions();
_settingsP = c2bSettingsP; _settingsP = c2bSettingsP;
resize(_settingsP->value("c2bCiter/size", size()).toSize()); resize(_settingsP->value("c2bCiter/size", size()).toSize());
move(_settingsP->value("c2bCiter/position", pos()).toPoint()); move(_settingsP->value("c2bCiter/position", pos()).toPoint());
_clipboard_connected = true; _clipboard_connected = true;
_citations = new c2bCiterModel(this); _citations = new c2bCiterModel(this);
connect(_citations, SIGNAL(statusLabel(const QString&)), this, SLOT(showLabe connect(_citations, SIGNAL(statusLabel(QString)), this, SLOT(showLabel(QStri
l(const QString&))); ng)));
connect(_citations, SIGNAL(statusMessage(const QString&)), this, SLOT(showMe connect(_citations, SIGNAL(statusMessage(QString)), this, SLOT(showMessage(Q
ssage(const QString&))); String)));
connect(c2b::clipboard(), SIGNAL(cbDataChanged(const QString&)), this, SLOT( connect(c2b::clipboard(), SIGNAL(cbDataChanged(QString)), this, SLOT(filterD
filterDataChanged(const QString&))); ataChanged(QString)));
connect(ui.citationsView, SIGNAL(activated(const QModelIndex&)), _citations, connect(ui.citationsView, SIGNAL(activated(QModelIndex)), _citations, SLOT(s
SLOT(selectCitation(const QModelIndex&))); electCitation(QModelIndex)));
connect(ui.citationsView, SIGNAL(citeReferences()), this, SLOT(citeReference s())); connect(ui.citationsView, SIGNAL(citeReferences()), this, SLOT(citeReference s()));
connect(ui.citationsView, SIGNAL(editReference()), this, SLOT(editReference( ))); connect(ui.citationsView, SIGNAL(editReference()), this, SLOT(editReference( )));
connect(ui.citationsView, SIGNAL(hideCiter()), this, SLOT(hide())); connect(ui.citationsView, SIGNAL(hideCiter()), this, SLOT(hide()));
connect(ui.citationsView, SIGNAL(openAnnote()), this, SIGNAL(openAnnote())); connect(ui.citationsView, SIGNAL(openAnnote()), this, SIGNAL(openAnnote()));
connect(ui.citationsView, SIGNAL(openFile()), this, SLOT(openFile())); connect(ui.citationsView, SIGNAL(openFile()), this, SLOT(openFile()));
connect(ui.citationsView, SIGNAL(openUrl()), this, SLOT(openUrl())); connect(ui.citationsView, SIGNAL(openUrl()), this, SLOT(openUrl()));
connect(ui.citationsView, SIGNAL(patternFilterChanged(const bool, const QStr connect(ui.citationsView, SIGNAL(patternFilterChanged(bool,QString)), this,
ing&)), this, SLOT(updatePatternFilter(const bool, const QString&))); SLOT(updatePatternFilter(bool,QString)));
connect(ui.citationsView, SIGNAL(statusMessage(const QString&)), this, SLOT( connect(ui.citationsView, SIGNAL(statusMessage(QString)), this, SLOT(showMes
showMessage(const QString&))); sage(QString)));
} }
c2bCiterWidget::~c2bCiterWidget() c2bCiterWidget::~c2bCiterWidget()
{ {
if (!isFullScreen()) if (!isFullScreen())
{ {
_settingsP->setValue("c2bCiter/position", pos()); _settingsP->setValue("c2bCiter/position", pos());
_settingsP->setValue("c2bCiter/size", size()); _settingsP->setValue("c2bCiter/size", size());
} }
_settingsP->setValue("c2bCiter/format", static_cast<int>(_citations->lastCit ationFormat())); _settingsP->setValue("c2bCiter/format", static_cast<int>(_citations->lastCit ationFormat()));
} }
void c2bCiterWidget::load() void c2bCiterWidget::load()
{ {
_bibtex_files.clear(); _bibtex_files.clear();
if (_settingsP->cl_citer_filenames.count() == 0) if (_settingsP->cl_citer_filenames.count() == 0)
_bibtex_files = c2bUtils::filesInDir(QFileInfo(_settingsP->fileName("cb2 _bibtex_files = c2bUtils::filesInDir(QFileInfo(_settingsP->fileName("cb2
Bib/BibTeXFile")).absolutePath(), QStringList() << "*.bib"); Bib/BibTeXFile")).absolutePath(),
QStringList() << "*.bib");
else else
for (int i = 0; i < _settingsP->cl_citer_filenames.count(); ++i) for (int i = 0; i < _settingsP->cl_citer_filenames.count(); ++i)
_bibtex_files += c2bUtils::filesInDir(_settingsP->cl_citer_filenames .at(i), QStringList() << "*.bib"); _bibtex_files += c2bUtils::filesInDir(_settingsP->cl_citer_filenames .at(i), QStringList() << "*.bib");
c2bCiter::State state; c2bCiter::State state;
state.format = static_cast<c2bCiter::Format>(_settingsP->value("c2bCiter/for mat", state.format).toInt()); state.format = static_cast<c2bCiter::Format>(_settingsP->value("c2bCiter/for mat", state.format).toInt());
reload(state); reload(state);
} }
void c2bCiterWidget::reload() void c2bCiterWidget::reload()
{ {
const c2bCiter::State state(ui.citationsView->currentState()); const c2bCiter::State state(ui.citationsView->currentState());
reload(state); reload(state);
} }
void c2bCiterWidget::reload(const c2bCiter::State& state) void c2bCiterWidget::reload(const c2bCiter::State& state)
{ {
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
updatePatternFilter(false, QString()); updatePatternFilter(false, QString());
if (_bibtex_files.count() == 1) if (_bibtex_files.count() == 1)
setWindowTitle(tr("%1 - cb2Bib").arg(QDir::toNativeSeparators(QFileInfo( setWindowTitle(
_bibtex_files.at(0)).absoluteFilePath()))); tr("%1 - cb2Bib").arg(QDir::toNativeSeparators(QFileInfo(_bibtex_fil
es.at(0)).absoluteFilePath())));
else if (_bibtex_files.count() > 1) else if (_bibtex_files.count() > 1)
setWindowTitle(tr("%1 - cb2Bib").arg(QDir::toNativeSeparators(QFileInfo( _bibtex_files.at(0)).absolutePath()))); setWindowTitle(tr("%1 - cb2Bib").arg(QDir::toNativeSeparators(QFileInfo( _bibtex_files.at(0)).absolutePath())));
else else
setWindowTitle(tr("Citer - cb2Bib")); setWindowTitle(tr("Citer - cb2Bib"));
ui.citationsView->reloadModel(_citations, _bibtex_files, state); ui.citationsView->reloadModel(_citations, _bibtex_files, state);
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
} }
void c2bCiterWidget::toggleVisible() void c2bCiterWidget::toggleVisible()
{ {
skipping to change at line 115 skipping to change at line 118
if (isHidden()) if (isHidden())
QWidget::show(); QWidget::show();
raise(); raise();
activateWindow(); activateWindow();
ui.citationsView->setFocus(); ui.citationsView->setFocus();
} }
void c2bCiterWidget::setTrayIcon() void c2bCiterWidget::setTrayIcon()
{ {
_tray_icon = new QSystemTrayIcon(this); _tray_icon = new QSystemTrayIcon(this);
_tray_icon->setIcon(QIcon(":/icons/icons/cb2bib.png")); _tray_icon->setIcon(QIcon(":/icons/icons/cb2bib.ico"));
_tray_icon->setToolTip("c2bBib Citer"); _tray_icon->setToolTip("c2bBib Citer");
QMenu* tray_icon_menu = new QMenu(this); QMenu* tray_icon_menu = new QMenu(this);
foreach(QAction * a, actions()) foreach (QAction* a, actions())
{ {
tray_icon_menu->addAction(a); tray_icon_menu->addAction(a);
} }
_tray_icon->setContextMenu(tray_icon_menu); _tray_icon->setContextMenu(tray_icon_menu);
_tray_icon->show(); _tray_icon->show();
connect(_tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), connect(_tray_icon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), th
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); is,
SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
} }
void c2bCiterWidget::trayIconActivated(QSystemTrayIcon::ActivationReason r) void c2bCiterWidget::trayIconActivated(QSystemTrayIcon::ActivationReason r)
{ {
if (r == QSystemTrayIcon::Context) if (r == QSystemTrayIcon::Context)
return; return;
show(); show();
} }
void c2bCiterWidget::setActions() void c2bCiterWidget::setActions()
skipping to change at line 225 skipping to change at line 228
return; return;
_bibtex_files = c2bUtils::filesInDir(dir, QStringList() << "*.bib"); _bibtex_files = c2bUtils::filesInDir(dir, QStringList() << "*.bib");
reload(); reload();
} }
void c2bCiterWidget::openFiles() void c2bCiterWidget::openFiles()
{ {
QString dir; QString dir;
if (_bibtex_files.count() > 0) if (_bibtex_files.count() > 0)
dir = _bibtex_files.at(0); dir = _bibtex_files.at(0);
const QStringList fns(c2bFileDialog::getOpenFilenames(this, "Select BibTeX f const QStringList fns(
ilenames", dir, "BibTeX (*.bib);;All (*)")); c2bFileDialog::getOpenFilenames(this, "Select BibTeX filenames", dir, "B
ibTeX (*.bib);;All (*)"));
if (fns.count() > 0) if (fns.count() > 0)
{ {
_bibtex_files = fns; _bibtex_files = fns;
reload(); reload();
} }
} }
void c2bCiterWidget::doSearchInFiles() void c2bCiterWidget::doSearchInFiles()
{ {
const QString fn(_citations->isKeywordView() ? QString() : _citations->data const QString fn(_citations->isKeywordView() ? QString()
BibTeXFile(ui.citationsView->currentIndex())); : _citations->dataBibTeXFile(ui.citationsView->currentIndex
()));
if (fn.isEmpty()) if (fn.isEmpty())
showMessage(tr("No active reference.")); showMessage(tr("No active reference."));
else else
c2b::doSearchInFiles(QString(), fn); c2b::doSearchInFiles(QString(), fn);
} }
void c2bCiterWidget::toggleCb2Bib() void c2bCiterWidget::toggleCb2Bib()
{ {
if (c2b::mainWidget()->isVisible()) if (c2b::mainWidget()->isVisible())
c2b::mainWidget()->hide(); c2b::mainWidget()->hide();
 End of changes. 11 change blocks. 
26 lines changed or deleted 31 lines changed or added

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