[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: extragear/office/tellico
From: Robby Stephenson <robby () periapsis ! org>
Date: 2011-02-14 2:37:44
Message-ID: 20110214023744.D5526AC8BF () svn ! kde ! org
[Download RAW message or body]
SVN commit 1220482 by rstephenson:
Added check for duplicate bibtex keys
BUG:245225
M +4 -0 ChangeLog
M +1 -0 src/CMakeLists.txt
A src/bibtexkeydialog.cpp [License: GPL (v2/3)]
A src/bibtexkeydialog.h [License: GPL (v2/3)]
M +18 -0 src/collections/bibtexcollection.cpp
M +2 -0 src/collections/bibtexcollection.h
M +30 -0 src/mainwindow.cpp
M +10 -0 src/mainwindow.h
M +4 -1 src/tellicoui.rc
M +31 -0 src/tests/bibtextest.cpp
M +1 -0 src/tests/bibtextest.h
U src/tests/collectiontest.cpp
--- trunk/extragear/office/tellico/ChangeLog #1220481:1220482
@@ -1,3 +1,7 @@
+2011-02-13 Robby Stephenson <robby@periapsis.org>
+
+ * Added check for duplicate bibtex keys (Bug 245225).
+
2011-02-02 Robby Stephenson <robby@periapsis.org>
* Added capability to import ADS format for z39.50 sources.
--- trunk/extragear/office/tellico/src/CMakeLists.txt #1220481:1220482
@@ -22,6 +22,7 @@
########### next target ###############
SET(tellico_SRCS
+ bibtexkeydialog.cpp
borrower.cpp
borrowerdialog.cpp
collection.cpp
--- trunk/extragear/office/tellico/src/collections/bibtexcollection.cpp \
#1220481:1220482 @@ -322,6 +322,7 @@
Tellico::Data::EntryPtr BibtexCollection::entryByBibtexKey(const QString& key_) \
const { EntryPtr entry;
+ // we do assume unique keys
foreach(EntryPtr e, entries()) {
if(e->field(QLatin1String("bibtex-key")) == key_) {
entry = e;
@@ -506,4 +507,21 @@
return entry_->setField(field, value);
}
+Tellico::Data::EntryList BibtexCollection::duplicateBibtexKeys() const {
+ QSet<EntryPtr> dupes;
+ QHash<QString, EntryPtr> keyHash;
+
+ const QString keyField = QLatin1String("bibtex-key");
+ QString keyValue;
+ foreach(EntryPtr entry, entries()) {
+ keyValue = entry->field(keyField);
+ if(keyHash.contains(keyValue)) {
+ dupes << keyHash.value(keyValue) << entry;
+ } else {
+ keyHash.insert(keyValue, entry);
+ }
+ }
+ return dupes.toList();
+}
+
#include "bibtexcollection.moc"
--- trunk/extragear/office/tellico/src/collections/bibtexcollection.h \
#1220481:1220482 @@ -68,6 +68,8 @@
virtual QString prepareText(const QString& text) const;
virtual int sameEntry(Data::EntryPtr entry1, Data::EntryPtr entry2) const;
+ EntryList duplicateBibtexKeys() const;
+
static FieldList defaultFields();
static CollPtr convertBookCollection(CollPtr coll);
static bool setFieldValue(EntryPtr entry, const QString& bibtexField, const \
QString& value, CollPtr existingCollection);
--- trunk/extragear/office/tellico/src/mainwindow.cpp #1220481:1220482
@@ -50,6 +50,7 @@
#include "translators/bibtexhandler.h" // needed for bibtex options
#include "fetchdialog.h"
#include "reportdialog.h"
+#include "bibtexkeydialog.h"
#include "tellico_strings.h"
#include "filterview.h"
#include "loanview.h"
@@ -140,6 +141,7 @@
m_filterDlg(0),
m_collFieldsDlg(0),
m_stringMacroDlg(0),
+ m_bibtexKeyDlg(0),
m_fetchDlg(0),
m_reportDlg(0),
m_queuedFilters(0),
@@ -548,6 +550,11 @@
action->setIcon(KIcon(QLatin1String("fileview-text")));
action->setToolTip(i18n("Edit the bibtex string macros"));
+ action = actionCollection()->addAction(QLatin1String("coll_key_manager"), this, \
SLOT(slotShowBibtexKeyDialog())); + action->setText(i18n("Check for Duplicate \
Keys...")); + action->setIcon(KIcon(QLatin1String("text/x-bibtex")));
+ action->setToolTip(i18n("Check for duplicate citation keys"));
+
QSignalMapper* citeMapper = new QSignalMapper(this);
connect(citeMapper, SIGNAL(mapped(int)),
this, SLOT(slotCiteEntry(int)));
@@ -1819,6 +1826,29 @@
}
}
+void MainWindow::slotShowBibtexKeyDialog() {
+ if(Data::Document::self()->collection()->type() != Data::Collection::Bibtex) {
+ return;
+ }
+
+ if(!m_bibtexKeyDlg) {
+ m_bibtexKeyDlg = new BibtexKeyDialog(Data::Document::self()->collection(), \
this); + connect(m_bibtexKeyDlg, SIGNAL(finished()), \
SLOT(slotHideBibtexKeyDialog())); + connect(m_bibtexKeyDlg, \
SIGNAL(signalUpdateFilter(Tellico::FilterPtr)), + this, \
SLOT(slotUpdateFilter(Tellico::FilterPtr))); + } else {
+ KWindowSystem::activateWindow(m_bibtexKeyDlg->winId());
+ }
+ m_bibtexKeyDlg->show();
+}
+
+void MainWindow::slotHideBibtexKeyDialog() {
+ if(m_bibtexKeyDlg) {
+ m_bibtexKeyDlg->delayedDestruct();
+ m_bibtexKeyDlg = 0;
+ }
+}
+
void MainWindow::slotNewEntry() {
m_toggleEntryEditor->setChecked(true);
slotToggleEntryEditor();
--- trunk/extragear/office/tellico/src/mainwindow.h #1220481:1220482
@@ -64,6 +64,7 @@
class ConfigDialog;
class CollectionFieldsDialog;
class StringMapDialog;
+ class BibtexKeyDialog;
class EntryItem;
class FetchDialog;
class ReportDialog;
@@ -306,6 +307,14 @@
*/
void slotHideStringMacroDialog();
/**
+ * Shows the citation key dialog
+ */
+ void slotShowBibtexKeyDialog();
+ /**
+ * Hides the citation key dialog
+ */
+ void slotHideBibtexKeyDialog();
+ /**
* Handle a url that indicates some actino should be taken
*/
void slotURLAction(const KUrl& url);
@@ -514,6 +523,7 @@
FilterDialog* m_filterDlg;
CollectionFieldsDialog* m_collFieldsDlg;
StringMapDialog* m_stringMacroDlg;
+ BibtexKeyDialog* m_bibtexKeyDlg;
FetchDialog* m_fetchDlg;
ReportDialog* m_reportDlg;
--- trunk/extragear/office/tellico/src/tellicoui.rc #1220481:1220482
@@ -1,6 +1,6 @@
<?xml version = '1.0'?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui version="29" name="tellico">
+<kpartgui version="30" name="tellico">
<MenuBar>
<Menu name="file">
<text>&File</text>
@@ -92,6 +92,7 @@
<text>&Bibliography</text>
<Action name="coll_convert_bibliography"/>
<Action name="coll_string_macros"/>
+ <Action name="coll_key_manager"/>
<Action name="cite_clipboard"/>
<Action name="cite_lyxpipe"/>
</Menu>
@@ -137,6 +138,7 @@
<Action name="file_export_amc"/>
<Action name="coll_convert_bibliography"/>
<Action name="coll_string_macros"/>
+ <Action name="coll_key_manager"/>
<Action name="cite_clipboard"/>
<Action name="cite_lyxpipe"/>
</Disable>
@@ -155,6 +157,7 @@
<Action name="file_export_bibtex"/>
<Action name="file_export_bibtexml"/>
<Action name="coll_string_macros"/>
+ <Action name="coll_key_manager"/>
</Enable>
</State>
--- trunk/extragear/office/tellico/src/tests/bibtextest.cpp #1220481:1220482
@@ -99,3 +99,34 @@
}
}
}
+
+void BibtexTest::testDuplicateKeys() {
+ Tellico::Data::CollPtr coll(new Tellico::Data::BibtexCollection(true));
+ Tellico::Data::BibtexCollection* bColl = \
static_cast<Tellico::Data::BibtexCollection*>(coll.data()); +
+ Tellico::Data::EntryList dupes = bColl->duplicateBibtexKeys();
+ QVERIFY(dupes.isEmpty());
+
+ Tellico::Data::EntryPtr entry1(new Tellico::Data::Entry(coll));
+ entry1->setField(QLatin1String("title"), QLatin1String("Title 1"));
+ entry1->setField(QLatin1String("bibtex-key"), QLatin1String("title1"));
+
+ Tellico::Data::EntryPtr entry2(new Tellico::Data::Entry(coll));
+ entry2->setField(QLatin1String("title"), QLatin1String("Title 2"));
+ entry2->setField(QLatin1String("bibtex-key"), QLatin1String("title1"));
+
+ Tellico::Data::EntryPtr entry3(new Tellico::Data::Entry(coll));
+ entry3->setField(QLatin1String("title"), QLatin1String("Title 3"));
+ entry3->setField(QLatin1String("bibtex-key"), QLatin1String("title3"));
+
+ coll->addEntries(Tellico::Data::EntryList() << entry1 << entry2 << entry3);
+
+ QCOMPARE(coll->entries().count(), 3);
+
+ dupes = bColl->duplicateBibtexKeys();
+ QCOMPARE(dupes.count(), 2);
+
+ entry2->setField(QLatin1String("bibtex-key"), QLatin1String("title2"));
+ dupes = bColl->duplicateBibtexKeys();
+ QCOMPARE(dupes.count(), 0);
+}
--- trunk/extragear/office/tellico/src/tests/bibtextest.h #1220481:1220482
@@ -33,6 +33,7 @@
private Q_SLOTS:
void initTestCase();
void testImport();
+ void testDuplicateKeys();
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic