summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am92
-rw-r--r--src/Makefile.in1710
-rw-r--r--src/comment.cpp93
-rw-r--r--src/comment.h49
-rw-r--r--src/commentwidget.cpp98
-rw-r--r--src/commentwidget.h55
-rw-r--r--src/documentlistview.cpp768
-rw-r--r--src/documentlistview.h127
-rw-r--r--src/documentlistviewitem.cpp151
-rw-r--r--src/documentlistviewitem.h55
-rw-r--r--src/documentsourceview.cpp380
-rw-r--r--src/documentsourceview.h96
-rw-r--r--src/documentwidget.cpp1740
-rw-r--r--src/documentwidget.h174
-rw-r--r--src/element.cpp50
-rw-r--r--src/element.h49
-rw-r--r--src/encoder.cpp25
-rw-r--r--src/encoder.h54
-rw-r--r--src/encoderlatex.cpp876
-rw-r--r--src/encoderlatex.h78
-rw-r--r--src/encoderxml.cpp127
-rw-r--r--src/encoderxml.h64
-rw-r--r--src/entry.cpp714
-rw-r--r--src/entry.h92
-rw-r--r--src/entryfield.cpp227
-rw-r--r--src/entryfield.h57
-rw-r--r--src/entrywidget.cpp677
-rw-r--r--src/entrywidget.h158
-rw-r--r--src/entrywidgetauthor.cpp114
-rw-r--r--src/entrywidgetauthor.h60
-rw-r--r--src/entrywidgetexternal.cpp297
-rw-r--r--src/entrywidgetexternal.h76
-rw-r--r--src/entrywidgetkeyword.cpp283
-rw-r--r--src/entrywidgetkeyword.h93
-rw-r--r--src/entrywidgetmisc.cpp172
-rw-r--r--src/entrywidgetmisc.h57
-rw-r--r--src/entrywidgetother.cpp319
-rw-r--r--src/entrywidgetother.h96
-rw-r--r--src/entrywidgetpublication.cpp563
-rw-r--r--src/entrywidgetpublication.h80
-rw-r--r--src/entrywidgetsource.cpp161
-rw-r--r--src/entrywidgetsource.h61
-rw-r--r--src/entrywidgettab.cpp91
-rw-r--r--src/entrywidgettab.h62
-rw-r--r--src/entrywidgettitle.cpp136
-rw-r--r--src/entrywidgettitle.h55
-rw-r--r--src/entrywidgetuserdefined.cpp144
-rw-r--r--src/entrywidgetuserdefined.h54
-rw-r--r--src/entrywidgetwarningsitem.cpp62
-rw-r--r--src/entrywidgetwarningsitem.h46
-rw-r--r--src/fieldlineedit.cpp369
-rw-r--r--src/fieldlineedit.h106
-rw-r--r--src/fieldlistview.cpp455
-rw-r--r--src/fieldlistview.h101
-rw-r--r--src/file.cpp402
-rw-r--r--src/file.h108
-rw-r--r--src/fileexporter.cpp36
-rw-r--r--src/fileexporter.h63
-rw-r--r--src/fileexporterbibtex.cpp491
-rw-r--r--src/fileexporterbibtex.h88
-rw-r--r--src/fileexporterbibutils.cpp259
-rw-r--r--src/fileexporterbibutils.h70
-rw-r--r--src/fileexporterdocbook5.cpp96
-rw-r--r--src/fileexporterdocbook5.h54
-rw-r--r--src/fileexporterexternal.cpp179
-rw-r--r--src/fileexporterexternal.h66
-rw-r--r--src/fileexporterpdf.cpp197
-rw-r--r--src/fileexporterpdf.h62
-rw-r--r--src/fileexporterps.cpp135
-rw-r--r--src/fileexporterps.h58
-rw-r--r--src/fileexporterris.cpp200
-rw-r--r--src/fileexporterris.h50
-rw-r--r--src/fileexporterrtf.cpp134
-rw-r--r--src/fileexporterrtf.h56
-rw-r--r--src/fileexportertoolchain.cpp232
-rw-r--r--src/fileexportertoolchain.h70
-rw-r--r--src/fileexporterxml.cpp228
-rw-r--r--src/fileexporterxml.h61
-rw-r--r--src/fileexporterxslt.cpp95
-rw-r--r--src/fileexporterxslt.h50
-rw-r--r--src/fileimporter.cpp57
-rw-r--r--src/fileimporter.h66
-rw-r--r--src/fileimporterbibtex.cpp658
-rw-r--r--src/fileimporterbibtex.h96
-rw-r--r--src/fileimporterbibutils.cpp296
-rw-r--r--src/fileimporterbibutils.h72
-rw-r--r--src/fileimporterexternal.cpp150
-rw-r--r--src/fileimporterexternal.h72
-rw-r--r--src/fileimporterris.cpp517
-rw-r--r--src/fileimporterris.h64
-rw-r--r--src/findduplicates.cpp444
-rw-r--r--src/findduplicates.h85
-rw-r--r--src/hi128-app-kbibtex.pngbin0 -> 21254 bytes
-rw-r--r--src/hi16-app-kbibtex.pngbin0 -> 836 bytes
-rw-r--r--src/hi22-app-kbibtex.pngbin0 -> 1363 bytes
-rw-r--r--src/hi32-app-kbibtex.pngbin0 -> 2468 bytes
-rw-r--r--src/hi48-app-kbibtex.pngbin0 -> 4715 bytes
-rw-r--r--src/hi64-app-kbibtex.pngbin0 -> 7301 bytes
-rw-r--r--src/idsuggestions.cpp363
-rw-r--r--src/idsuggestions.h75
-rw-r--r--src/idsuggestionswidget.cpp567
-rw-r--r--src/idsuggestionswidget.h163
-rw-r--r--src/iso5426converter.cpp892
-rw-r--r--src/iso5426converter.h52
-rw-r--r--src/iso6937converter.cpp606
-rw-r--r--src/iso6937converter.h50
-rw-r--r--src/kbibtex.desktop12
-rw-r--r--src/kbibtex.lsm15
-rw-r--r--src/kbibtex_part.cpp758
-rw-r--r--src/kbibtex_part.desktop15
-rw-r--r--src/kbibtex_part.h169
-rw-r--r--src/kbibtex_part.rc158
-rw-r--r--src/kbibtex_shell.rc31
-rw-r--r--src/kbibtexshell.cpp387
-rw-r--r--src/kbibtexshell.h100
-rw-r--r--src/latin1literal.h99
-rw-r--r--src/macro.cpp115
-rw-r--r--src/macro.h57
-rw-r--r--src/macrowidget.cpp99
-rw-r--r--src/macrowidget.h56
-rw-r--r--src/main.cpp128
-rw-r--r--src/mergeelements.cpp864
-rw-r--r--src/mergeelements.h179
-rw-r--r--src/messagehandler.cpp44
-rw-r--r--src/messagehandler.h56
-rw-r--r--src/preamble.cpp107
-rw-r--r--src/preamble.h54
-rw-r--r--src/preamblewidget.cpp84
-rw-r--r--src/preamblewidget.h59
-rw-r--r--src/searchbar.cpp192
-rw-r--r--src/searchbar.h78
-rw-r--r--src/settings.cpp966
-rw-r--r--src/settings.h205
-rw-r--r--src/settingsdlg.cpp137
-rw-r--r--src/settingsdlg.h70
-rw-r--r--src/settingsediting.cpp331
-rw-r--r--src/settingsediting.h100
-rw-r--r--src/settingsfileio.cpp341
-rw-r--r--src/settingsfileio.h73
-rw-r--r--src/settingsidsuggestions.cpp400
-rw-r--r--src/settingsidsuggestions.h108
-rw-r--r--src/settingskeyword.cpp194
-rw-r--r--src/settingskeyword.h69
-rw-r--r--src/settingssearchurl.cpp221
-rw-r--r--src/settingssearchurl.h68
-rw-r--r--src/settingsuserdefinedinput.cpp264
-rw-r--r--src/settingsuserdefinedinput.h74
-rw-r--r--src/settingsz3950.cpp364
-rw-r--r--src/settingsz3950.h128
-rw-r--r--src/sidebar.cpp255
-rw-r--r--src/sidebar.h89
-rw-r--r--src/value.cpp465
-rw-r--r--src/value.h162
-rw-r--r--src/valuewidget.cpp254
-rw-r--r--src/valuewidget.h77
-rw-r--r--src/webquery.cpp637
-rw-r--r--src/webquery.h179
-rw-r--r--src/webqueryamatex.cpp123
-rw-r--r--src/webqueryamatex.h64
-rw-r--r--src/webqueryarxiv.cpp568
-rw-r--r--src/webqueryarxiv.h87
-rw-r--r--src/webquerybibsonomy.cpp127
-rw-r--r--src/webquerybibsonomy.h64
-rw-r--r--src/webquerycitebase.cpp129
-rw-r--r--src/webquerycitebase.h64
-rw-r--r--src/webqueryciteseerx.cpp318
-rw-r--r--src/webqueryciteseerx.h141
-rw-r--r--src/webquerycsb.cpp289
-rw-r--r--src/webquerycsb.h89
-rw-r--r--src/webquerydblp.cpp213
-rw-r--r--src/webquerydblp.h70
-rw-r--r--src/webquerygooglescholar.cpp469
-rw-r--r--src/webquerygooglescholar.h111
-rw-r--r--src/webqueryieeexplore.cpp267
-rw-r--r--src/webqueryieeexplore.h83
-rw-r--r--src/webquerymathscinet.cpp188
-rw-r--r--src/webquerymathscinet.h67
-rw-r--r--src/webquerypubmed.cpp535
-rw-r--r--src/webquerypubmed.h106
-rw-r--r--src/webquerysciencedirect.cpp425
-rw-r--r--src/webquerysciencedirect.h90
-rw-r--r--src/webqueryspireshep.cpp248
-rw-r--r--src/webqueryspireshep.h76
-rw-r--r--src/webqueryz3950.cpp397
-rw-r--r--src/webqueryz3950.h122
-rw-r--r--src/webqueryzmath.cpp124
-rw-r--r--src/webqueryzmath.h64
-rw-r--r--src/xsltransform.cpp81
-rw-r--r--src/xsltransform.h46
-rw-r--r--src/z3950-servers.cfg263
-rw-r--r--src/z3950connection.cpp589
-rw-r--r--src/z3950connection.h131
192 files changed, 38809 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..68488d0
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,92 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes) $(LIBXSLT_CFLAGS) $(LIBXML_CFLAGS) $(LIBYAZ_CFLAGS) $(LIBBIBUTILS_CFLAGS)
+
+# these are the headers for your project
+noinst_HEADERS = documentlistviewitem.h fileexportertoolchain.h \
+ comment.h commentwidget.h documentlistview.h documentlistviewitem.h \
+ documentsourceview.h documentwidget.h element.h encoder.h encoderlatex.h encoderxml.h \
+ entry.h entryfield.h entrywidget.h entrywidgetauthor.h entrywidgetexternal.h \
+ entrywidgetkeyword.h entrywidgetmisc.h entrywidgetother.h entrywidgetpublication.h \
+ entrywidgetsource.h entrywidgettab.h entrywidgettitle.h entrywidgetuserdefined.h \
+ entrywidgetwarningsitem.h fieldlineedit.h fieldlistview.h file.h fileexporter.h \
+ fileexporterbibtex.h fileexporterbibutils.h fileexporterdocbook5.h fileexporterexternal.h \
+ fileexporterpdf.h fileexporterps.h fileexporterris.h fileimporterbibtex.h \
+ fileexporterrtf.h fileexporterxml.h fileexporterxslt.h fileimporter.h \
+ fileimporterbibutils.h fileimporterexternal.h fileimporterris.h findduplicates.h \
+ idsuggestions.h idsuggestionswidget.h iso5426converter.h iso6937converter.h \
+ kbibtex_part.h kbibtexshell.h latin1literal.h macro.h macrowidget.h mergeelements.h \
+ messagehandler.h preamble.h preamblewidget.h searchbar.h settings.h settingsdlg.h \
+ settingsediting.h settingsfileio.h settingsidsuggestions.h settingskeyword.h \
+ settingssearchurl.h settingsuserdefinedinput.h settingsz3950.h sidebar.h value.h \
+ valuewidget.h webquery.h webqueryamatex.h webqueryarxiv.h webquerybibsonomy.h \
+ webquerycitebase.h webqueryciteseerx.h webquerycsb.h webquerydblp.h \
+ webquerygooglescholar.h webqueryieeexplore.h webquerymathscinet.h webquerypubmed.h \
+ webquerysciencedirect.h webqueryspireshep.h webqueryz3950.h webqueryzmath.h xsltransform.h \
+ z3950connection.h
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(EXTRACTRC) *.rc >>rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kbibtex.pot
+
+KDE_ICON = AUTO
+
+# this Makefile creates both a KPart application and a KPart
+#########################################################################
+# APPLICATION SECTION
+#########################################################################
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+bin_PROGRAMS = kbibtex
+
+# the application source, library search path, and link libraries
+kbibtex_SOURCES = kbibtexshell.cpp main.cpp
+kbibtex_LDFLAGS = $(all_libraries)
+kbibtex_LDADD = $(LIB_KPARTS)
+
+# this is where the desktop file will go
+shelldesktopdir = $(xdg_appsdir)
+shelldesktop_DATA = kbibtex.desktop
+
+#########################################################################
+# KPART SECTION
+#########################################################################
+kde_module_LTLIBRARIES = libkbibtexpart.la
+
+# the Part's source, library search path, and link libraries
+libkbibtexpart_la_SOURCES = comment.cpp fileexporterdocbook5.cpp commentwidget.cpp documentlistview.cpp \
+ documentlistviewitem.cpp documentsourceview.cpp documentwidget.cpp element.cpp encoder.cpp \
+ encoderlatex.cpp encoderxml.cpp entry.cpp entryfield.cpp entrywidget.cpp \
+ entrywidgetauthor.cpp entrywidgetexternal.cpp entrywidgetkeyword.cpp entrywidgetmisc.cpp \
+ entrywidgetother.cpp entrywidgetpublication.cpp entrywidgetsource.cpp entrywidgettab.cpp \
+ entrywidgettitle.cpp entrywidgetuserdefined.cpp entrywidgetwarningsitem.cpp \
+ z3950connection.cpp fieldlineedit.cpp fieldlistview.cpp file.cpp fileexporter.cpp \
+ fileexporterbibtex.cpp fileexporterris.cpp fileexporterbibutils.cpp fileexporterexternal.cpp fileexporterpdf.cpp \
+ fileexporterps.cpp fileexporterrtf.cpp fileexportertoolchain.cpp fileexporterxml.cpp \
+ fileexporterxslt.cpp fileimporter.cpp fileimporterbibtex.cpp fileimporterbibutils.cpp \
+ fileimporterexternal.cpp fileimporterris.cpp idsuggestions.cpp idsuggestionswidget.cpp \
+ kbibtex_part.cpp macro.cpp macrowidget.cpp mergeelements.cpp preamble.cpp webqueryieeexplore.cpp \
+ preamblewidget.cpp searchbar.cpp settings.cpp settingsdlg.cpp settingsediting.cpp \
+ settingsfileio.cpp settingsidsuggestions.cpp settingskeyword.cpp settingssearchurl.cpp \
+ settingsuserdefinedinput.cpp sidebar.cpp value.cpp valuewidget.cpp webquery.cpp webqueryamatex.cpp \
+ webqueryarxiv.cpp webqueryciteseerx.cpp webquerybibsonomy.cpp webquerycsb.cpp webquerycitebase.cpp webquerydblp.cpp webqueryz3950.cpp \
+ webquerygooglescholar.cpp webquerypubmed.cpp webqueryspireshep.cpp webqueryzmath.cpp \
+ xsltransform.cpp webquerysciencedirect.cpp findduplicates.cpp settingsz3950.cpp \
+ messagehandler.cpp iso6937converter.cpp iso5426converter.cpp webquerymathscinet.cpp
+libkbibtexpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+libkbibtexpart_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KUTILS) $(LIBXSLT_LIBS) $(LIBXML_LIBS) $(LIBYAZ_LIBS) $(LIBBIBUTILS_LIBS) -lkatepartinterfaces
+
+# this is where the desktop file will go
+partdesktopdir = $(kde_servicesdir)
+partdesktop_DATA = kbibtex_part.desktop
+
+# this is where the XML-GUI resource fileis go
+partrcdir = ${kde_datadir}/kbibtexpart
+partrc_DATA = kbibtex_part.rc
+shellrcdir = ${kde_datadir}/kbibtex
+shellrc_DATA = kbibtex_shell.rc
+
+appdir = $(kde_datadir)/kbibtex
+app_DATA = z3950-servers.cfg
+
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..d858e05
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,1710 @@
+# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# KDE tags expanded automatically by am_edit - $Revision: 483858 $
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005 Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+bin_PROGRAMS = kbibtex$(EXEEXT)
+subdir = src
+DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
+am__installdirs = "$(DESTDIR)$(kde_moduledir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(appdir)" "$(DESTDIR)$(partdesktopdir)" \
+ "$(DESTDIR)$(partrcdir)" "$(DESTDIR)$(shelldesktopdir)" \
+ "$(DESTDIR)$(shellrcdir)"
+kde_moduleLTLIBRARIES_INSTALL = $(INSTALL)
+LTLIBRARIES = $(kde_module_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libkbibtexpart_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+am_libkbibtexpart_la_OBJECTS = comment.lo fileexporterdocbook5.lo \
+ commentwidget.lo documentlistview.lo documentlistviewitem.lo \
+ documentsourceview.lo documentwidget.lo element.lo encoder.lo \
+ encoderlatex.lo encoderxml.lo entry.lo entryfield.lo \
+ entrywidget.lo entrywidgetauthor.lo entrywidgetexternal.lo \
+ entrywidgetkeyword.lo entrywidgetmisc.lo entrywidgetother.lo \
+ entrywidgetpublication.lo entrywidgetsource.lo \
+ entrywidgettab.lo entrywidgettitle.lo \
+ entrywidgetuserdefined.lo entrywidgetwarningsitem.lo \
+ z3950connection.lo fieldlineedit.lo fieldlistview.lo file.lo \
+ fileexporter.lo fileexporterbibtex.lo fileexporterris.lo \
+ fileexporterbibutils.lo fileexporterexternal.lo \
+ fileexporterpdf.lo fileexporterps.lo fileexporterrtf.lo \
+ fileexportertoolchain.lo fileexporterxml.lo \
+ fileexporterxslt.lo fileimporter.lo fileimporterbibtex.lo \
+ fileimporterbibutils.lo fileimporterexternal.lo \
+ fileimporterris.lo idsuggestions.lo idsuggestionswidget.lo \
+ kbibtex_part.lo macro.lo macrowidget.lo mergeelements.lo \
+ preamble.lo webqueryieeexplore.lo preamblewidget.lo \
+ searchbar.lo settings.lo settingsdlg.lo settingsediting.lo \
+ settingsfileio.lo settingsidsuggestions.lo settingskeyword.lo \
+ settingssearchurl.lo settingsuserdefinedinput.lo sidebar.lo \
+ value.lo valuewidget.lo webquery.lo webqueryamatex.lo \
+ webqueryarxiv.lo webqueryciteseerx.lo webquerybibsonomy.lo \
+ webquerycsb.lo webquerycitebase.lo webquerydblp.lo \
+ webqueryz3950.lo webquerygooglescholar.lo webquerypubmed.lo \
+ webqueryspireshep.lo webqueryzmath.lo xsltransform.lo \
+ webquerysciencedirect.lo findduplicates.lo settingsz3950.lo \
+ messagehandler.lo iso6937converter.lo iso5426converter.lo \
+ webquerymathscinet.lo
+#>- libkbibtexpart_la_OBJECTS = $(am_libkbibtexpart_la_OBJECTS)
+#>+ 33
+libkbibtexpart_la_final_OBJECTS = libkbibtexpart_la.all_cpp.lo
+libkbibtexpart_la_nofinal_OBJECTS = comment.lo fileexporterdocbook5.lo \
+ commentwidget.lo documentlistview.lo documentlistviewitem.lo \
+ documentsourceview.lo documentwidget.lo element.lo encoder.lo \
+ encoderlatex.lo encoderxml.lo entry.lo entryfield.lo \
+ entrywidget.lo entrywidgetauthor.lo entrywidgetexternal.lo \
+ entrywidgetkeyword.lo entrywidgetmisc.lo entrywidgetother.lo \
+ entrywidgetpublication.lo entrywidgetsource.lo \
+ entrywidgettab.lo entrywidgettitle.lo \
+ entrywidgetuserdefined.lo entrywidgetwarningsitem.lo \
+ z3950connection.lo fieldlineedit.lo fieldlistview.lo file.lo \
+ fileexporter.lo fileexporterbibtex.lo fileexporterris.lo \
+ fileexporterbibutils.lo fileexporterexternal.lo \
+ fileexporterpdf.lo fileexporterps.lo fileexporterrtf.lo \
+ fileexportertoolchain.lo fileexporterxml.lo \
+ fileexporterxslt.lo fileimporter.lo fileimporterbibtex.lo \
+ fileimporterbibutils.lo fileimporterexternal.lo \
+ fileimporterris.lo idsuggestions.lo idsuggestionswidget.lo \
+ kbibtex_part.lo macro.lo macrowidget.lo mergeelements.lo \
+ preamble.lo webqueryieeexplore.lo preamblewidget.lo \
+ searchbar.lo settings.lo settingsdlg.lo settingsediting.lo \
+ settingsfileio.lo settingsidsuggestions.lo settingskeyword.lo \
+ settingssearchurl.lo settingsuserdefinedinput.lo sidebar.lo \
+ value.lo valuewidget.lo webquery.lo webqueryamatex.lo \
+ webqueryarxiv.lo webqueryciteseerx.lo webquerybibsonomy.lo \
+ webquerycsb.lo webquerycitebase.lo webquerydblp.lo \
+ webqueryz3950.lo webquerygooglescholar.lo webquerypubmed.lo \
+ webqueryspireshep.lo webqueryzmath.lo xsltransform.lo \
+ webquerysciencedirect.lo findduplicates.lo settingsz3950.lo \
+ messagehandler.lo iso6937converter.lo iso5426converter.lo \
+ webquerymathscinet.lo
+@KDE_USE_FINAL_FALSE@libkbibtexpart_la_OBJECTS = $(libkbibtexpart_la_nofinal_OBJECTS)
+@KDE_USE_FINAL_TRUE@libkbibtexpart_la_OBJECTS = $(libkbibtexpart_la_final_OBJECTS)
+binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
+PROGRAMS = $(bin_PROGRAMS)
+am_kbibtex_OBJECTS = kbibtexshell.$(OBJEXT) main.$(OBJEXT)
+#>- kbibtex_OBJECTS = $(am_kbibtex_OBJECTS)
+#>+ 4
+kbibtex_final_OBJECTS = kbibtex.all_cpp.o
+kbibtex_nofinal_OBJECTS = kbibtexshell.$(OBJEXT) main.$(OBJEXT)
+@KDE_USE_FINAL_FALSE@kbibtex_OBJECTS = $(kbibtex_nofinal_OBJECTS)
+@KDE_USE_FINAL_TRUE@kbibtex_OBJECTS = $(kbibtex_final_OBJECTS)
+kbibtex_DEPENDENCIES = $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/admin/depcomp
+am__depfiles_maybe = depfiles
+#>- CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+#>- $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+#>+ 2
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS)
+#>- LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
+#>- $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+#>- $(AM_CXXFLAGS) $(CXXFLAGS)
+#>+ 3
+LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS)
+CXXLD = $(CXX)
+#>- CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+#>- $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+#>+ 2
+CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(KDE_CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libkbibtexpart_la_SOURCES) $(kbibtex_SOURCES)
+DIST_SOURCES = $(libkbibtexpart_la_SOURCES) $(kbibtex_SOURCES)
+appDATA_INSTALL = $(INSTALL_DATA)
+partdesktopDATA_INSTALL = $(INSTALL_DATA)
+partrcDATA_INSTALL = $(INSTALL_DATA)
+shelldesktopDATA_INSTALL = $(INSTALL_DATA)
+shellrcDATA_INSTALL = $(INSTALL_DATA)
+DATA = $(app_DATA) $(partdesktop_DATA) $(partrc_DATA) \
+ $(shelldesktop_DATA) $(shellrc_DATA)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+#>+ 1
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST)
+ACLOCAL = @ACLOCAL@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+ARTSCCONFIG = @ARTSCCONFIG@
+AUTOCONF = @AUTOCONF@
+AUTODIRS = @AUTODIRS@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CONF_FILES = @CONF_FILES@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCOPIDL = @DCOPIDL@
+DCOPIDL2CPP = @DCOPIDL2CPP@
+DCOPIDLNG = @DCOPIDLNG@
+DCOP_DEPENDENCIES = @DCOP_DEPENDENCIES@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_PERMISSIVE_FLAG = @ENABLE_PERMISSIVE_FLAG@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+FRAMEWORK_COREAUDIO = @FRAMEWORK_COREAUDIO@
+GMSGFMT = @GMSGFMT@
+GREP = @GREP@
+HAVE_GCC_VISIBILITY = @HAVE_GCC_VISIBILITY@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KCFG_DEPENDENCIES = @KCFG_DEPENDENCIES@
+KCONFIG_COMPILER = @KCONFIG_COMPILER@
+KDECONFIG = @KDECONFIG@
+KDE_CHECK_PLUGIN = @KDE_CHECK_PLUGIN@
+KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@
+KDE_INCLUDES = @KDE_INCLUDES@
+KDE_LDFLAGS = @KDE_LDFLAGS@
+KDE_MT_LDFLAGS = @KDE_MT_LDFLAGS@
+KDE_MT_LIBS = @KDE_MT_LIBS@
+KDE_NO_UNDEFINED = @KDE_NO_UNDEFINED@
+KDE_PLUGIN = @KDE_PLUGIN@
+KDE_RPATH = @KDE_RPATH@
+KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@
+KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@
+KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@
+KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@
+KDE_USE_FPIE = @KDE_USE_FPIE@
+KDE_USE_NMCHECK_FALSE = @KDE_USE_NMCHECK_FALSE@
+KDE_USE_NMCHECK_TRUE = @KDE_USE_NMCHECK_TRUE@
+KDE_USE_PIE = @KDE_USE_PIE@
+KDE_XSL_STYLESHEET = @KDE_XSL_STYLESHEET@
+LDFLAGS = @LDFLAGS@
+LDFLAGS_AS_NEEDED = @LDFLAGS_AS_NEEDED@
+LDFLAGS_NEW_DTAGS = @LDFLAGS_NEW_DTAGS@
+LIBCOMPAT = @LIBCOMPAT@
+LIBCRYPT = @LIBCRYPT@
+LIBDL = @LIBDL@
+LIBJPEG = @LIBJPEG@
+LIBOBJS = @LIBOBJS@
+LIBPNG = @LIBPNG@
+LIBPTHREAD = @LIBPTHREAD@
+LIBRESOLV = @LIBRESOLV@
+LIBS = @LIBS@
+LIBSM = @LIBSM@
+LIBSOCKET = @LIBSOCKET@
+LIBTOOL = @LIBTOOL@
+LIBUCB = @LIBUCB@
+LIBUTIL = @LIBUTIL@
+LIBXML_CFLAGS = @LIBXML_CFLAGS@
+LIBXML_LIBS = @LIBXML_LIBS@
+LIBXSLT_CFLAGS = @LIBXSLT_CFLAGS@
+LIBXSLT_LIBS = @LIBXSLT_LIBS@
+LIBYAZ_CFLAGS = @LIBYAZ_CFLAGS@
+LIBYAZ_LIBS = @LIBYAZ_LIBS@
+LIBYAZ_RPATH = @LIBYAZ_RPATH@
+LIBZ = @LIBZ@
+LIB_KAB = @LIB_KAB@
+LIB_KABC = @LIB_KABC@
+LIB_KDECORE = @LIB_KDECORE@
+LIB_KDED = @LIB_KDED@
+LIB_KDEPIM = @LIB_KDEPIM@
+LIB_KDEPRINT = @LIB_KDEPRINT@
+LIB_KDEUI = @LIB_KDEUI@
+LIB_KDNSSD = @LIB_KDNSSD@
+LIB_KFILE = @LIB_KFILE@
+LIB_KFM = @LIB_KFM@
+LIB_KHTML = @LIB_KHTML@
+LIB_KIMPROXY = @LIB_KIMPROXY@
+LIB_KIO = @LIB_KIO@
+LIB_KJS = @LIB_KJS@
+LIB_KNEWSTUFF = @LIB_KNEWSTUFF@
+LIB_KPARTS = @LIB_KPARTS@
+LIB_KSPELL = @LIB_KSPELL@
+LIB_KSYCOCA = @LIB_KSYCOCA@
+LIB_KUNITTEST = @LIB_KUNITTEST@
+LIB_KUTILS = @LIB_KUTILS@
+LIB_POLL = @LIB_POLL@
+LIB_QPE = @LIB_QPE@
+LIB_QT = @LIB_QT@
+LIB_SMB = @LIB_SMB@
+LIB_X11 = @LIB_X11@
+LIB_XEXT = @LIB_XEXT@
+LIB_XRENDER = @LIB_XRENDER@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKEKDEWIDGETS = @MAKEKDEWIDGETS@
+MCOPIDL = @MCOPIDL@
+MEINPROC = @MEINPROC@
+MOC = @MOC@
+MSGFMT = @MSGFMT@
+NOOPT_CFLAGS = @NOOPT_CFLAGS@
+NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+QTE_NORTTI = @QTE_NORTTI@
+QT_INCLUDES = @QT_INCLUDES@
+QT_LDFLAGS = @QT_LDFLAGS@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TOPSUBDIRS = @TOPSUBDIRS@
+UIC = @UIC@
+UIC_TR = @UIC_TR@
+USER_INCLUDES = @USER_INCLUDES@
+USER_LDFLAGS = @USER_LDFLAGS@
+USE_EXCEPTIONS = @USE_EXCEPTIONS@
+USE_RTTI = @USE_RTTI@
+USE_THREADS = @USE_THREADS@
+VERSION = @VERSION@
+WOVERLOADED_VIRTUAL = @WOVERLOADED_VIRTUAL@
+XGETTEXT = @XGETTEXT@
+XMKMF = @XMKMF@
+XMLLINT = @XMLLINT@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_INCLUDES = @X_INCLUDES@
+X_LDFLAGS = @X_LDFLAGS@
+X_PRE_LIBS = @X_PRE_LIBS@
+X_RPATH = @X_RPATH@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_F77 = @ac_ct_F77@
+all_includes = @all_includes@
+all_libraries = @all_libraries@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+include_ARTS_FALSE = @include_ARTS_FALSE@
+include_ARTS_TRUE = @include_ARTS_TRUE@
+include_x11_FALSE = @include_x11_FALSE@
+include_x11_TRUE = @include_x11_TRUE@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+kde_appsdir = @kde_appsdir@
+kde_bindir = @kde_bindir@
+kde_confdir = @kde_confdir@
+kde_datadir = @kde_datadir@
+kde_htmldir = @kde_htmldir@
+kde_icondir = @kde_icondir@
+kde_includes = @kde_includes@
+kde_kcfgdir = @kde_kcfgdir@
+kde_libraries = @kde_libraries@
+kde_libs_htmldir = @kde_libs_htmldir@
+kde_libs_prefix = @kde_libs_prefix@
+kde_locale = @kde_locale@
+kde_mimedir = @kde_mimedir@
+kde_moduledir = @kde_moduledir@
+kde_qtver = @kde_qtver@
+kde_servicesdir = @kde_servicesdir@
+kde_servicetypesdir = @kde_servicetypesdir@
+kde_sounddir = @kde_sounddir@
+kde_styledir = @kde_styledir@
+kde_templatesdir = @kde_templatesdir@
+kde_wallpaperdir = @kde_wallpaperdir@
+kde_widgetdir = @kde_widgetdir@
+kdeinitdir = @kdeinitdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+qt_includes = @qt_includes@
+qt_libraries = @qt_libraries@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+unsermake_enable_pch_FALSE = @unsermake_enable_pch_FALSE@
+unsermake_enable_pch_TRUE = @unsermake_enable_pch_TRUE@
+x_includes = @x_includes@
+x_libraries = @x_libraries@
+xdg_appsdir = @xdg_appsdir@
+xdg_directorydir = @xdg_directorydir@
+xdg_menudir = @xdg_menudir@
+
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes) $(LIBXSLT_CFLAGS) $(LIBXML_CFLAGS) $(LIBYAZ_CFLAGS) $(LIBBIBUTILS_CFLAGS)
+
+# these are the headers for your project
+noinst_HEADERS = documentlistviewitem.h fileexportertoolchain.h \
+ comment.h commentwidget.h documentlistview.h documentlistviewitem.h \
+ documentsourceview.h documentwidget.h element.h encoder.h encoderlatex.h encoderxml.h \
+ entry.h entryfield.h entrywidget.h entrywidgetauthor.h entrywidgetexternal.h \
+ entrywidgetkeyword.h entrywidgetmisc.h entrywidgetother.h entrywidgetpublication.h \
+ entrywidgetsource.h entrywidgettab.h entrywidgettitle.h entrywidgetuserdefined.h \
+ entrywidgetwarningsitem.h fieldlineedit.h fieldlistview.h file.h fileexporter.h \
+ fileexporterbibtex.h fileexporterbibutils.h fileexporterdocbook5.h fileexporterexternal.h \
+ fileexporterpdf.h fileexporterps.h fileexporterris.h fileimporterbibtex.h \
+ fileexporterrtf.h fileexporterxml.h fileexporterxslt.h fileimporter.h \
+ fileimporterbibutils.h fileimporterexternal.h fileimporterris.h findduplicates.h \
+ idsuggestions.h idsuggestionswidget.h iso5426converter.h iso6937converter.h \
+ kbibtex_part.h kbibtexshell.h latin1literal.h macro.h macrowidget.h mergeelements.h \
+ messagehandler.h preamble.h preamblewidget.h searchbar.h settings.h settingsdlg.h \
+ settingsediting.h settingsfileio.h settingsidsuggestions.h settingskeyword.h \
+ settingssearchurl.h settingsuserdefinedinput.h settingsz3950.h sidebar.h value.h \
+ valuewidget.h webquery.h webqueryamatex.h webqueryarxiv.h webquerybibsonomy.h \
+ webquerycitebase.h webqueryciteseerx.h webquerycsb.h webquerydblp.h \
+ webquerygooglescholar.h webqueryieeexplore.h webquerymathscinet.h webquerypubmed.h \
+ webquerysciencedirect.h webqueryspireshep.h webqueryz3950.h webqueryzmath.h xsltransform.h \
+ z3950connection.h
+
+# let automoc handle all of the meta source files (moc)
+#>- METASOURCES = AUTO
+KDE_ICON = AUTO
+
+# the application source, library search path, and link libraries
+kbibtex_SOURCES = kbibtexshell.cpp main.cpp
+kbibtex_LDFLAGS = $(all_libraries)
+kbibtex_LDADD = $(LIB_KPARTS)
+
+# this is where the desktop file will go
+shelldesktopdir = $(xdg_appsdir)
+shelldesktop_DATA = kbibtex.desktop
+
+#########################################################################
+# KPART SECTION
+#########################################################################
+kde_module_LTLIBRARIES = libkbibtexpart.la
+
+# the Part's source, library search path, and link libraries
+libkbibtexpart_la_SOURCES = comment.cpp fileexporterdocbook5.cpp commentwidget.cpp documentlistview.cpp \
+ documentlistviewitem.cpp documentsourceview.cpp documentwidget.cpp element.cpp encoder.cpp \
+ encoderlatex.cpp encoderxml.cpp entry.cpp entryfield.cpp entrywidget.cpp \
+ entrywidgetauthor.cpp entrywidgetexternal.cpp entrywidgetkeyword.cpp entrywidgetmisc.cpp \
+ entrywidgetother.cpp entrywidgetpublication.cpp entrywidgetsource.cpp entrywidgettab.cpp \
+ entrywidgettitle.cpp entrywidgetuserdefined.cpp entrywidgetwarningsitem.cpp \
+ z3950connection.cpp fieldlineedit.cpp fieldlistview.cpp file.cpp fileexporter.cpp \
+ fileexporterbibtex.cpp fileexporterris.cpp fileexporterbibutils.cpp fileexporterexternal.cpp fileexporterpdf.cpp \
+ fileexporterps.cpp fileexporterrtf.cpp fileexportertoolchain.cpp fileexporterxml.cpp \
+ fileexporterxslt.cpp fileimporter.cpp fileimporterbibtex.cpp fileimporterbibutils.cpp \
+ fileimporterexternal.cpp fileimporterris.cpp idsuggestions.cpp idsuggestionswidget.cpp \
+ kbibtex_part.cpp macro.cpp macrowidget.cpp mergeelements.cpp preamble.cpp webqueryieeexplore.cpp \
+ preamblewidget.cpp searchbar.cpp settings.cpp settingsdlg.cpp settingsediting.cpp \
+ settingsfileio.cpp settingsidsuggestions.cpp settingskeyword.cpp settingssearchurl.cpp \
+ settingsuserdefinedinput.cpp sidebar.cpp value.cpp valuewidget.cpp webquery.cpp webqueryamatex.cpp \
+ webqueryarxiv.cpp webqueryciteseerx.cpp webquerybibsonomy.cpp webquerycsb.cpp webquerycitebase.cpp webquerydblp.cpp webqueryz3950.cpp \
+ webquerygooglescholar.cpp webquerypubmed.cpp webqueryspireshep.cpp webqueryzmath.cpp \
+ xsltransform.cpp webquerysciencedirect.cpp findduplicates.cpp settingsz3950.cpp \
+ messagehandler.cpp iso6937converter.cpp iso5426converter.cpp webquerymathscinet.cpp
+
+libkbibtexpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries)
+libkbibtexpart_la_LIBADD = $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KUTILS) $(LIBXSLT_LIBS) $(LIBXML_LIBS) $(LIBYAZ_LIBS) $(LIBBIBUTILS_LIBS) -lkatepartinterfaces
+
+# this is where the desktop file will go
+partdesktopdir = $(kde_servicesdir)
+partdesktop_DATA = kbibtex_part.desktop
+
+# this is where the XML-GUI resource fileis go
+partrcdir = ${kde_datadir}/kbibtexpart
+partrc_DATA = kbibtex_part.rc
+shellrcdir = ${kde_datadir}/kbibtex
+shellrc_DATA = kbibtex_shell.rc
+appdir = $(kde_datadir)/kbibtex
+app_DATA = z3950-servers.cfg
+#>- all: all-am
+#>+ 1
+all: docs-am all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+#>- @for dep in $?; do \
+#>- case '$(am__configure_deps)' in \
+#>- *$$dep*) \
+#>- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+#>- && exit 0; \
+#>- exit 1;; \
+#>- esac; \
+#>- done; \
+#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+#>- cd $(top_srcdir) && \
+#>- $(AUTOMAKE) --gnu src/Makefile
+#>+ 12
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+ cd $(top_srcdir) && perl admin/am_edit src/Makefile.in
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+install-kde_moduleLTLIBRARIES: $(kde_module_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(kde_moduledir)" || $(mkdir_p) "$(DESTDIR)$(kde_moduledir)"
+ @list='$(kde_module_LTLIBRARIES)'; for p in $$list; do \
+ if test -f $$p; then \
+ f=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=install $(kde_moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(kde_moduledir)/$$f'"; \
+ $(LIBTOOL) --mode=install $(kde_moduleLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(kde_moduledir)/$$f"; \
+ else :; fi; \
+ done
+
+uninstall-kde_moduleLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @set -x; list='$(kde_module_LTLIBRARIES)'; for p in $$list; do \
+ p=$(am__strip_dir) \
+ echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(kde_moduledir)/$$p'"; \
+ $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(kde_moduledir)/$$p"; \
+ done
+
+clean-kde_moduleLTLIBRARIES:
+ -test -z "$(kde_module_LTLIBRARIES)" || rm -f $(kde_module_LTLIBRARIES)
+ @list='$(kde_module_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+#>- libkbibtexpart.la: $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_DEPENDENCIES)
+#>+ 2
+@KDE_USE_CLOSURE_TRUE@libkbibtexpart.la: libkbibtexpart.la.closure $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_DEPENDENCIES)
+@KDE_USE_CLOSURE_FALSE@libkbibtexpart.la: $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_DEPENDENCIES)
+ $(CXXLINK) -rpath $(kde_moduledir) $(libkbibtexpart_la_LDFLAGS) $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ if test -f $$p \
+ || test -f $$p1 \
+ ; then \
+ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
+ else :; fi; \
+ done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
+ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
+ rm -f "$(DESTDIR)$(bindir)/$$f"; \
+ done
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; for p in $$list; do \
+ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f $$p $$f"; \
+ rm -f $$p $$f ; \
+ done
+kbibtex$(EXEEXT): $(kbibtex_OBJECTS) $(kbibtex_DEPENDENCIES)
+ @rm -f kbibtex$(EXEEXT)
+ $(CXXLINK) $(kbibtex_LDFLAGS) $(kbibtex_OBJECTS) $(kbibtex_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/comment.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/commentwidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/documentlistview.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/documentlistviewitem.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/documentsourceview.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/documentwidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/element.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoderlatex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/encoderxml.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entry.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entryfield.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetauthor.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetexternal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetkeyword.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetmisc.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetother.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetpublication.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetsource.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgettab.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgettitle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetuserdefined.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entrywidgetwarningsitem.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fieldlineedit.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fieldlistview.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterbibtex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterbibutils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterdocbook5.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterexternal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterpdf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterps.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterris.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterrtf.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexportertoolchain.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterxml.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileexporterxslt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileimporter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileimporterbibtex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileimporterbibutils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileimporterexternal.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fileimporterris.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/findduplicates.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idsuggestions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idsuggestionswidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iso5426converter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iso6937converter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbibtex_part.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kbibtexshell.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/macro.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/macrowidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mergeelements.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/messagehandler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/preamble.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/preamblewidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/searchbar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settings.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsdlg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsediting.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsfileio.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsidsuggestions.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingskeyword.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingssearchurl.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsuserdefinedinput.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/settingsz3950.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sidebar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/value.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/valuewidget.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquery.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryamatex.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryarxiv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerybibsonomy.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerycitebase.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryciteseerx.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerycsb.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerydblp.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerygooglescholar.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryieeexplore.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerymathscinet.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerypubmed.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webquerysciencedirect.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryspireshep.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryz3950.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/webqueryzmath.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xsltransform.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/z3950connection.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+distclean-libtool:
+ -rm -f libtool
+uninstall-info-am:
+install-appDATA: $(app_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(appdir)" || $(mkdir_p) "$(DESTDIR)$(appdir)"
+ @list='$(app_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(appDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(appdir)/$$f'"; \
+ $(appDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(appdir)/$$f"; \
+ done
+
+uninstall-appDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(app_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(appdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(appdir)/$$f"; \
+ done
+install-partdesktopDATA: $(partdesktop_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(partdesktopdir)" || $(mkdir_p) "$(DESTDIR)$(partdesktopdir)"
+ @list='$(partdesktop_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(partdesktopDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(partdesktopdir)/$$f'"; \
+ $(partdesktopDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(partdesktopdir)/$$f"; \
+ done
+
+uninstall-partdesktopDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(partdesktop_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(partdesktopdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(partdesktopdir)/$$f"; \
+ done
+install-partrcDATA: $(partrc_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(partrcdir)" || $(mkdir_p) "$(DESTDIR)$(partrcdir)"
+ @list='$(partrc_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(partrcDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(partrcdir)/$$f'"; \
+ $(partrcDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(partrcdir)/$$f"; \
+ done
+
+uninstall-partrcDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(partrc_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(partrcdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(partrcdir)/$$f"; \
+ done
+install-shelldesktopDATA: $(shelldesktop_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(shelldesktopdir)" || $(mkdir_p) "$(DESTDIR)$(shelldesktopdir)"
+ @list='$(shelldesktop_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(shelldesktopDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(shelldesktopdir)/$$f'"; \
+ $(shelldesktopDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(shelldesktopdir)/$$f"; \
+ done
+
+uninstall-shelldesktopDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(shelldesktop_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(shelldesktopdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(shelldesktopdir)/$$f"; \
+ done
+install-shellrcDATA: $(shellrc_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(shellrcdir)" || $(mkdir_p) "$(DESTDIR)$(shellrcdir)"
+ @list='$(shellrc_DATA)'; for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ f=$(am__strip_dir) \
+ echo " $(shellrcDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(shellrcdir)/$$f'"; \
+ $(shellrcDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(shellrcdir)/$$f"; \
+ done
+
+uninstall-shellrcDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(shellrc_DATA)'; for p in $$list; do \
+ f=$(am__strip_dir) \
+ echo " rm -f '$(DESTDIR)$(shellrcdir)/$$f'"; \
+ rm -f "$(DESTDIR)$(shellrcdir)/$$f"; \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$tags $$unique; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ tags=; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) ' { files[$$0] = 1; } \
+ END { for (i in files) print i; }'`; \
+ test -z "$(CTAGS_ARGS)$$tags$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$tags $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && cd $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+ list='$(DISTFILES)'; for file in $$list; do \
+ case $$file in \
+ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+ esac; \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+ dir="/$$dir"; \
+ $(mkdir_p) "$(distdir)$$dir"; \
+ else \
+ dir=''; \
+ fi; \
+ if test -d $$d/$$file; then \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+ fi; \
+ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+ else \
+ test -f $(distdir)/$$file \
+ || cp -p $$d/$$file $(distdir)/$$file \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(DATA) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(kde_moduledir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(appdir)" "$(DESTDIR)$(partdesktopdir)" "$(DESTDIR)$(partrcdir)" "$(DESTDIR)$(shelldesktopdir)" "$(DESTDIR)$(shellrcdir)"; do \
+ test -z "$$dir" || $(mkdir_p) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+#>- clean: clean-am
+#>+ 1
+clean: kde-rpo-clean clean-am
+
+#>- clean-am: clean-binPROGRAMS clean-generic clean-kde_moduleLTLIBRARIES \
+#>- clean-libtool mostlyclean-am
+#>+ 2
+clean-am: clean-metasources clean-closures clean-bcheck clean-final clean-binPROGRAMS clean-generic clean-kde_moduleLTLIBRARIES \
+ clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+#>- install-data-am: install-appDATA install-kde_moduleLTLIBRARIES \
+#>- install-partdesktopDATA install-partrcDATA \
+#>- install-shelldesktopDATA install-shellrcDATA
+#>+ 3
+install-data-am: install-kde-icons install-appDATA \
+ install-partdesktopDATA install-partrcDATA \
+ install-shelldesktopDATA install-shellrcDATA
+
+#>- install-exec-am: install-binPROGRAMS
+#>+ 1
+install-exec-am: install-binPROGRAMS install-kde_moduleLTLIBRARIES
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+#>- uninstall-am: uninstall-appDATA uninstall-binPROGRAMS \
+#>- uninstall-info-am uninstall-kde_moduleLTLIBRARIES \
+#>- uninstall-partdesktopDATA uninstall-partrcDATA \
+#>- uninstall-shelldesktopDATA uninstall-shellrcDATA
+#>+ 4
+uninstall-am: uninstall-kde-icons uninstall-appDATA uninstall-binPROGRAMS \
+ uninstall-info-am uninstall-kde_moduleLTLIBRARIES \
+ uninstall-partdesktopDATA uninstall-partrcDATA \
+ uninstall-shelldesktopDATA uninstall-shellrcDATA
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+ clean-generic clean-kde_moduleLTLIBRARIES clean-libtool ctags \
+ distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-appDATA \
+ install-binPROGRAMS install-data install-data-am install-exec \
+ install-exec-am install-info install-info-am \
+ install-kde_moduleLTLIBRARIES install-man \
+ install-partdesktopDATA install-partrcDATA \
+ install-shelldesktopDATA install-shellrcDATA install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-appDATA \
+ uninstall-binPROGRAMS uninstall-info-am \
+ uninstall-kde_moduleLTLIBRARIES uninstall-partdesktopDATA \
+ uninstall-partrcDATA uninstall-shelldesktopDATA \
+ uninstall-shellrcDATA
+
+
+messages: rc.cpp
+ $(EXTRACTRC) *.rc >>rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kbibtex.pot
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
+
+#>+ 8
+libkbibtexpart.la.closure: $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_DEPENDENCIES)
+ @echo "int main() {return 0;}" > libkbibtexpart_la_closure.cpp
+ @$(LTCXXCOMPILE) -c libkbibtexpart_la_closure.cpp
+ $(CXXLINK) libkbibtexpart_la_closure.lo $(libkbibtexpart_la_LDFLAGS) $(libkbibtexpart_la_OBJECTS) $(libkbibtexpart_la_LIBADD) $(LIBS)
+ @rm -f libkbibtexpart_la_closure.* libkbibtexpart.la.closure
+ @echo "timestamp" > libkbibtexpart.la.closure
+
+
+#>+ 3
+entrywidgetuserdefined.moc: $(srcdir)/entrywidgetuserdefined.h
+ $(MOC) $(srcdir)/entrywidgetuserdefined.h -o entrywidgetuserdefined.moc
+
+#>+ 2
+mocs: entrywidgetuserdefined.moc
+
+#>+ 3
+documentlistview.moc: $(srcdir)/documentlistview.h
+ $(MOC) $(srcdir)/documentlistview.h -o documentlistview.moc
+
+#>+ 2
+mocs: documentlistview.moc
+
+#>+ 3
+file.moc: $(srcdir)/file.h
+ $(MOC) $(srcdir)/file.h -o file.moc
+
+#>+ 2
+mocs: file.moc
+
+#>+ 3
+documentsourceview.moc: $(srcdir)/documentsourceview.h
+ $(MOC) $(srcdir)/documentsourceview.h -o documentsourceview.moc
+
+#>+ 2
+mocs: documentsourceview.moc
+
+#>+ 3
+webqueryamatex.moc: $(srcdir)/webqueryamatex.h
+ $(MOC) $(srcdir)/webqueryamatex.h -o webqueryamatex.moc
+
+#>+ 2
+mocs: webqueryamatex.moc
+
+#>+ 3
+fileimporterbibutils.moc: $(srcdir)/fileimporterbibutils.h
+ $(MOC) $(srcdir)/fileimporterbibutils.h -o fileimporterbibutils.moc
+
+#>+ 2
+mocs: fileimporterbibutils.moc
+
+#>+ 3
+fieldlineedit.moc: $(srcdir)/fieldlineedit.h
+ $(MOC) $(srcdir)/fieldlineedit.h -o fieldlineedit.moc
+
+#>+ 2
+mocs: fieldlineedit.moc
+
+#>+ 3
+webquerymathscinet.moc: $(srcdir)/webquerymathscinet.h
+ $(MOC) $(srcdir)/webquerymathscinet.h -o webquerymathscinet.moc
+
+#>+ 2
+mocs: webquerymathscinet.moc
+
+#>+ 3
+webqueryciteseerx.moc: $(srcdir)/webqueryciteseerx.h
+ $(MOC) $(srcdir)/webqueryciteseerx.h -o webqueryciteseerx.moc
+
+#>+ 2
+mocs: webqueryciteseerx.moc
+
+#>+ 3
+webquerygooglescholar.moc: $(srcdir)/webquerygooglescholar.h
+ $(MOC) $(srcdir)/webquerygooglescholar.h -o webquerygooglescholar.moc
+
+#>+ 2
+mocs: webquerygooglescholar.moc
+
+#>+ 3
+entrywidget.moc: $(srcdir)/entrywidget.h
+ $(MOC) $(srcdir)/entrywidget.h -o entrywidget.moc
+
+#>+ 2
+mocs: entrywidget.moc
+
+#>+ 3
+webquerypubmed.moc: $(srcdir)/webquerypubmed.h
+ $(MOC) $(srcdir)/webquerypubmed.h -o webquerypubmed.moc
+
+#>+ 2
+mocs: webquerypubmed.moc
+
+#>+ 3
+webqueryz3950.moc: $(srcdir)/webqueryz3950.h
+ $(MOC) $(srcdir)/webqueryz3950.h -o webqueryz3950.moc
+
+#>+ 2
+mocs: webqueryz3950.moc
+
+#>+ 3
+fileexporterbibutils.moc: $(srcdir)/fileexporterbibutils.h
+ $(MOC) $(srcdir)/fileexporterbibutils.h -o fileexporterbibutils.moc
+
+#>+ 2
+mocs: fileexporterbibutils.moc
+
+#>+ 3
+entrywidgetmisc.moc: $(srcdir)/entrywidgetmisc.h
+ $(MOC) $(srcdir)/entrywidgetmisc.h -o entrywidgetmisc.moc
+
+#>+ 2
+mocs: entrywidgetmisc.moc
+
+#>+ 3
+entrywidgetexternal.moc: $(srcdir)/entrywidgetexternal.h
+ $(MOC) $(srcdir)/entrywidgetexternal.h -o entrywidgetexternal.moc
+
+#>+ 2
+mocs: entrywidgetexternal.moc
+
+#>+ 3
+kbibtex_part.moc: $(srcdir)/kbibtex_part.h
+ $(MOC) $(srcdir)/kbibtex_part.h -o kbibtex_part.moc
+
+#>+ 2
+mocs: kbibtex_part.moc
+
+#>+ 3
+webqueryzmath.moc: $(srcdir)/webqueryzmath.h
+ $(MOC) $(srcdir)/webqueryzmath.h -o webqueryzmath.moc
+
+#>+ 2
+mocs: webqueryzmath.moc
+
+#>+ 3
+webqueryspireshep.moc: $(srcdir)/webqueryspireshep.h
+ $(MOC) $(srcdir)/webqueryspireshep.h -o webqueryspireshep.moc
+
+#>+ 2
+mocs: webqueryspireshep.moc
+
+#>+ 3
+entrywidgetother.moc: $(srcdir)/entrywidgetother.h
+ $(MOC) $(srcdir)/entrywidgetother.h -o entrywidgetother.moc
+
+#>+ 2
+mocs: entrywidgetother.moc
+
+#>+ 3
+settingsediting.moc: $(srcdir)/settingsediting.h
+ $(MOC) $(srcdir)/settingsediting.h -o settingsediting.moc
+
+#>+ 2
+mocs: settingsediting.moc
+
+#>+ 3
+webqueryieeexplore.moc: $(srcdir)/webqueryieeexplore.h
+ $(MOC) $(srcdir)/webqueryieeexplore.h -o webqueryieeexplore.moc
+
+#>+ 2
+mocs: webqueryieeexplore.moc
+
+#>+ 3
+settingssearchurl.moc: $(srcdir)/settingssearchurl.h
+ $(MOC) $(srcdir)/settingssearchurl.h -o settingssearchurl.moc
+
+#>+ 2
+mocs: settingssearchurl.moc
+
+#>+ 3
+webquerycitebase.moc: $(srcdir)/webquerycitebase.h
+ $(MOC) $(srcdir)/webquerycitebase.h -o webquerycitebase.moc
+
+#>+ 2
+mocs: webquerycitebase.moc
+
+#>+ 3
+webquerydblp.moc: $(srcdir)/webquerydblp.h
+ $(MOC) $(srcdir)/webquerydblp.h -o webquerydblp.moc
+
+#>+ 2
+mocs: webquerydblp.moc
+
+#>+ 3
+preamblewidget.moc: $(srcdir)/preamblewidget.h
+ $(MOC) $(srcdir)/preamblewidget.h -o preamblewidget.moc
+
+#>+ 2
+mocs: preamblewidget.moc
+
+#>+ 3
+commentwidget.moc: $(srcdir)/commentwidget.h
+ $(MOC) $(srcdir)/commentwidget.h -o commentwidget.moc
+
+#>+ 2
+mocs: commentwidget.moc
+
+#>+ 3
+mergeelements.moc: $(srcdir)/mergeelements.h
+ $(MOC) $(srcdir)/mergeelements.h -o mergeelements.moc
+
+#>+ 2
+mocs: mergeelements.moc
+
+#>+ 3
+fileimporterexternal.moc: $(srcdir)/fileimporterexternal.h
+ $(MOC) $(srcdir)/fileimporterexternal.h -o fileimporterexternal.moc
+
+#>+ 2
+mocs: fileimporterexternal.moc
+
+#>+ 3
+settingskeyword.moc: $(srcdir)/settingskeyword.h
+ $(MOC) $(srcdir)/settingskeyword.h -o settingskeyword.moc
+
+#>+ 2
+mocs: settingskeyword.moc
+
+#>+ 3
+webquerybibsonomy.moc: $(srcdir)/webquerybibsonomy.h
+ $(MOC) $(srcdir)/webquerybibsonomy.h -o webquerybibsonomy.moc
+
+#>+ 2
+mocs: webquerybibsonomy.moc
+
+#>+ 3
+findduplicates.moc: $(srcdir)/findduplicates.h
+ $(MOC) $(srcdir)/findduplicates.h -o findduplicates.moc
+
+#>+ 2
+mocs: findduplicates.moc
+
+#>+ 3
+entrywidgettitle.moc: $(srcdir)/entrywidgettitle.h
+ $(MOC) $(srcdir)/entrywidgettitle.h -o entrywidgettitle.moc
+
+#>+ 2
+mocs: entrywidgettitle.moc
+
+#>+ 3
+entrywidgetkeyword.moc: $(srcdir)/entrywidgetkeyword.h
+ $(MOC) $(srcdir)/entrywidgetkeyword.h -o entrywidgetkeyword.moc
+
+#>+ 2
+mocs: entrywidgetkeyword.moc
+
+#>+ 3
+entrywidgetsource.moc: $(srcdir)/entrywidgetsource.h
+ $(MOC) $(srcdir)/entrywidgetsource.h -o entrywidgetsource.moc
+
+#>+ 2
+mocs: entrywidgetsource.moc
+
+#>+ 3
+fileexporter.moc: $(srcdir)/fileexporter.h
+ $(MOC) $(srcdir)/fileexporter.h -o fileexporter.moc
+
+#>+ 2
+mocs: fileexporter.moc
+
+#>+ 3
+fileimporter.moc: $(srcdir)/fileimporter.h
+ $(MOC) $(srcdir)/fileimporter.h -o fileimporter.moc
+
+#>+ 2
+mocs: fileimporter.moc
+
+#>+ 3
+searchbar.moc: $(srcdir)/searchbar.h
+ $(MOC) $(srcdir)/searchbar.h -o searchbar.moc
+
+#>+ 2
+mocs: searchbar.moc
+
+#>+ 3
+settingsz3950.moc: $(srcdir)/settingsz3950.h
+ $(MOC) $(srcdir)/settingsz3950.h -o settingsz3950.moc
+
+#>+ 2
+mocs: settingsz3950.moc
+
+#>+ 3
+idsuggestionswidget.moc: $(srcdir)/idsuggestionswidget.h
+ $(MOC) $(srcdir)/idsuggestionswidget.h -o idsuggestionswidget.moc
+
+#>+ 2
+mocs: idsuggestionswidget.moc
+
+#>+ 3
+entrywidgettab.moc: $(srcdir)/entrywidgettab.h
+ $(MOC) $(srcdir)/entrywidgettab.h -o entrywidgettab.moc
+
+#>+ 2
+mocs: entrywidgettab.moc
+
+#>+ 3
+entrywidgetpublication.moc: $(srcdir)/entrywidgetpublication.h
+ $(MOC) $(srcdir)/entrywidgetpublication.h -o entrywidgetpublication.moc
+
+#>+ 2
+mocs: entrywidgetpublication.moc
+
+#>+ 3
+kbibtexshell.moc: $(srcdir)/kbibtexshell.h
+ $(MOC) $(srcdir)/kbibtexshell.h -o kbibtexshell.moc
+
+#>+ 2
+mocs: kbibtexshell.moc
+
+#>+ 3
+fileexportertoolchain.moc: $(srcdir)/fileexportertoolchain.h
+ $(MOC) $(srcdir)/fileexportertoolchain.h -o fileexportertoolchain.moc
+
+#>+ 2
+mocs: fileexportertoolchain.moc
+
+#>+ 3
+settingsidsuggestions.moc: $(srcdir)/settingsidsuggestions.h
+ $(MOC) $(srcdir)/settingsidsuggestions.h -o settingsidsuggestions.moc
+
+#>+ 2
+mocs: settingsidsuggestions.moc
+
+#>+ 3
+webquerysciencedirect.moc: $(srcdir)/webquerysciencedirect.h
+ $(MOC) $(srcdir)/webquerysciencedirect.h -o webquerysciencedirect.moc
+
+#>+ 2
+mocs: webquerysciencedirect.moc
+
+#>+ 3
+settingsfileio.moc: $(srcdir)/settingsfileio.h
+ $(MOC) $(srcdir)/settingsfileio.h -o settingsfileio.moc
+
+#>+ 2
+mocs: settingsfileio.moc
+
+#>+ 3
+entrywidgetauthor.moc: $(srcdir)/entrywidgetauthor.h
+ $(MOC) $(srcdir)/entrywidgetauthor.h -o entrywidgetauthor.moc
+
+#>+ 2
+mocs: entrywidgetauthor.moc
+
+#>+ 3
+settingsuserdefinedinput.moc: $(srcdir)/settingsuserdefinedinput.h
+ $(MOC) $(srcdir)/settingsuserdefinedinput.h -o settingsuserdefinedinput.moc
+
+#>+ 2
+mocs: settingsuserdefinedinput.moc
+
+#>+ 3
+settingsdlg.moc: $(srcdir)/settingsdlg.h
+ $(MOC) $(srcdir)/settingsdlg.h -o settingsdlg.moc
+
+#>+ 2
+mocs: settingsdlg.moc
+
+#>+ 3
+sidebar.moc: $(srcdir)/sidebar.h
+ $(MOC) $(srcdir)/sidebar.h -o sidebar.moc
+
+#>+ 2
+mocs: sidebar.moc
+
+#>+ 3
+webqueryarxiv.moc: $(srcdir)/webqueryarxiv.h
+ $(MOC) $(srcdir)/webqueryarxiv.h -o webqueryarxiv.moc
+
+#>+ 2
+mocs: webqueryarxiv.moc
+
+#>+ 3
+webquery.moc: $(srcdir)/webquery.h
+ $(MOC) $(srcdir)/webquery.h -o webquery.moc
+
+#>+ 2
+mocs: webquery.moc
+
+#>+ 3
+fileexporterexternal.moc: $(srcdir)/fileexporterexternal.h
+ $(MOC) $(srcdir)/fileexporterexternal.h -o fileexporterexternal.moc
+
+#>+ 2
+mocs: fileexporterexternal.moc
+
+#>+ 3
+valuewidget.moc: $(srcdir)/valuewidget.h
+ $(MOC) $(srcdir)/valuewidget.h -o valuewidget.moc
+
+#>+ 2
+mocs: valuewidget.moc
+
+#>+ 3
+fieldlistview.moc: $(srcdir)/fieldlistview.h
+ $(MOC) $(srcdir)/fieldlistview.h -o fieldlistview.moc
+
+#>+ 2
+mocs: fieldlistview.moc
+
+#>+ 3
+macrowidget.moc: $(srcdir)/macrowidget.h
+ $(MOC) $(srcdir)/macrowidget.h -o macrowidget.moc
+
+#>+ 2
+mocs: macrowidget.moc
+
+#>+ 3
+webquerycsb.moc: $(srcdir)/webquerycsb.h
+ $(MOC) $(srcdir)/webquerycsb.h -o webquerycsb.moc
+
+#>+ 2
+mocs: webquerycsb.moc
+
+#>+ 3
+documentwidget.moc: $(srcdir)/documentwidget.h
+ $(MOC) $(srcdir)/documentwidget.h -o documentwidget.moc
+
+#>+ 2
+mocs: documentwidget.moc
+
+#>+ 3
+clean-metasources:
+ -rm -f entrywidgetuserdefined.moc documentlistview.moc file.moc documentsourceview.moc webqueryamatex.moc fileimporterbibutils.moc fieldlineedit.moc webquerymathscinet.moc webqueryciteseerx.moc webquerygooglescholar.moc entrywidget.moc webquerypubmed.moc webqueryz3950.moc fileexporterbibutils.moc entrywidgetmisc.moc entrywidgetexternal.moc kbibtex_part.moc webqueryzmath.moc webqueryspireshep.moc entrywidgetother.moc settingsediting.moc webqueryieeexplore.moc settingssearchurl.moc webquerycitebase.moc webquerydblp.moc preamblewidget.moc commentwidget.moc mergeelements.moc fileimporterexternal.moc settingskeyword.moc webquerybibsonomy.moc findduplicates.moc entrywidgettitle.moc entrywidgetkeyword.moc entrywidgetsource.moc fileexporter.moc fileimporter.moc searchbar.moc settingsz3950.moc idsuggestionswidget.moc entrywidgettab.moc entrywidgetpublication.moc kbibtexshell.moc fileexportertoolchain.moc settingsidsuggestions.moc webquerysciencedirect.moc settingsfileio.moc entrywidgetauthor.moc settingsuserdefinedinput.moc settingsdlg.moc sidebar.moc webqueryarxiv.moc webquery.moc fileexporterexternal.moc valuewidget.moc fieldlistview.moc macrowidget.moc webquerycsb.moc documentwidget.moc
+
+#>+ 2
+KDE_DIST=hi64-app-kbibtex.png Makefile.in z3950-servers.cfg kbibtex_shell.rc hi48-app-kbibtex.png kbibtex_part.rc hi128-app-kbibtex.png kbibtex.desktop hi16-app-kbibtex.png hi22-app-kbibtex.png hi32-app-kbibtex.png kbibtex.lsm Makefile.am kbibtex_part.desktop
+
+#>+ 3
+clean-closures:
+ -rm -f libkbibtexpart.la.closure
+
+#>+ 2
+docs-am:
+
+#>+ 22
+install-kde-icons:
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/22x22/apps
+ $(INSTALL_DATA) $(srcdir)/hi22-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/22x22/apps/kbibtex.png
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/128x128/apps
+ $(INSTALL_DATA) $(srcdir)/hi128-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/128x128/apps/kbibtex.png
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/64x64/apps
+ $(INSTALL_DATA) $(srcdir)/hi64-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/64x64/apps/kbibtex.png
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/16x16/apps
+ $(INSTALL_DATA) $(srcdir)/hi16-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/16x16/apps/kbibtex.png
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/48x48/apps
+ $(INSTALL_DATA) $(srcdir)/hi48-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/48x48/apps/kbibtex.png
+ $(mkinstalldirs) $(DESTDIR)$(kde_icondir)/hicolor/32x32/apps
+ $(INSTALL_DATA) $(srcdir)/hi32-app-kbibtex.png $(DESTDIR)$(kde_icondir)/hicolor/32x32/apps/kbibtex.png
+
+uninstall-kde-icons:
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/22x22/apps/kbibtex.png
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/128x128/apps/kbibtex.png
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/64x64/apps/kbibtex.png
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/16x16/apps/kbibtex.png
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/48x48/apps/kbibtex.png
+ -rm -f $(DESTDIR)$(kde_icondir)/hicolor/32x32/apps/kbibtex.png
+
+#>+ 15
+force-reedit:
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
+ cd $(top_srcdir) && \
+ $(AUTOMAKE) --gnu src/Makefile
+ cd $(top_srcdir) && perl admin/am_edit src/Makefile.in
+
+
+#>+ 21
+clean-bcheck:
+ rm -f *.bchecktest.cc *.bchecktest.cc.class a.out
+
+bcheck: bcheck-am
+
+bcheck-am:
+ @for i in ; do \
+ if test $(srcdir)/$$i -nt $$i.bchecktest.cc; then \
+ echo "int main() {return 0;}" > $$i.bchecktest.cc ; \
+ echo "#include \"$$i\"" >> $$i.bchecktest.cc ; \
+ echo "$$i"; \
+ if ! $(CXXCOMPILE) --dump-class-hierarchy -c $$i.bchecktest.cc; then \
+ rm -f $$i.bchecktest.cc; exit 1; \
+ fi ; \
+ echo "" >> $$i.bchecktest.cc.class; \
+ perl $(top_srcdir)/admin/bcheck.pl $$i.bchecktest.cc.class || { rm -f $$i.bchecktest.cc; exit 1; }; \
+ rm -f a.out; \
+ fi ; \
+ done
+
+
+#>+ 11
+libkbibtexpart_la.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/comment.cpp $(srcdir)/fileexporterdocbook5.cpp $(srcdir)/commentwidget.cpp $(srcdir)/documentlistview.cpp $(srcdir)/documentlistviewitem.cpp $(srcdir)/documentsourceview.cpp $(srcdir)/documentwidget.cpp $(srcdir)/element.cpp $(srcdir)/encoder.cpp $(srcdir)/encoderlatex.cpp $(srcdir)/encoderxml.cpp $(srcdir)/entry.cpp $(srcdir)/entryfield.cpp $(srcdir)/entrywidget.cpp $(srcdir)/entrywidgetauthor.cpp $(srcdir)/entrywidgetexternal.cpp $(srcdir)/entrywidgetkeyword.cpp $(srcdir)/entrywidgetmisc.cpp $(srcdir)/entrywidgetother.cpp $(srcdir)/entrywidgetpublication.cpp $(srcdir)/entrywidgetsource.cpp $(srcdir)/entrywidgettab.cpp $(srcdir)/entrywidgettitle.cpp $(srcdir)/entrywidgetuserdefined.cpp $(srcdir)/entrywidgetwarningsitem.cpp $(srcdir)/z3950connection.cpp $(srcdir)/fieldlineedit.cpp $(srcdir)/fieldlistview.cpp $(srcdir)/file.cpp $(srcdir)/fileexporter.cpp $(srcdir)/fileexporterbibtex.cpp $(srcdir)/fileexporterris.cpp $(srcdir)/fileexporterbibutils.cpp $(srcdir)/fileexporterexternal.cpp $(srcdir)/fileexporterpdf.cpp $(srcdir)/fileexporterps.cpp $(srcdir)/fileexporterrtf.cpp $(srcdir)/fileexportertoolchain.cpp $(srcdir)/fileexporterxml.cpp $(srcdir)/fileexporterxslt.cpp $(srcdir)/fileimporter.cpp $(srcdir)/fileimporterbibtex.cpp $(srcdir)/fileimporterbibutils.cpp $(srcdir)/fileimporterexternal.cpp $(srcdir)/fileimporterris.cpp $(srcdir)/idsuggestions.cpp $(srcdir)/idsuggestionswidget.cpp $(srcdir)/kbibtex_part.cpp $(srcdir)/macro.cpp $(srcdir)/macrowidget.cpp $(srcdir)/mergeelements.cpp $(srcdir)/preamble.cpp $(srcdir)/webqueryieeexplore.cpp $(srcdir)/preamblewidget.cpp $(srcdir)/searchbar.cpp $(srcdir)/settings.cpp $(srcdir)/settingsdlg.cpp $(srcdir)/settingsediting.cpp $(srcdir)/settingsfileio.cpp $(srcdir)/settingsidsuggestions.cpp $(srcdir)/settingskeyword.cpp $(srcdir)/settingssearchurl.cpp $(srcdir)/settingsuserdefinedinput.cpp $(srcdir)/sidebar.cpp $(srcdir)/value.cpp $(srcdir)/valuewidget.cpp $(srcdir)/webquery.cpp $(srcdir)/webqueryamatex.cpp $(srcdir)/webqueryarxiv.cpp $(srcdir)/webqueryciteseerx.cpp $(srcdir)/webquerybibsonomy.cpp $(srcdir)/webquerycsb.cpp $(srcdir)/webquerycitebase.cpp $(srcdir)/webquerydblp.cpp $(srcdir)/webqueryz3950.cpp $(srcdir)/webquerygooglescholar.cpp $(srcdir)/webquerypubmed.cpp $(srcdir)/webqueryspireshep.cpp $(srcdir)/webqueryzmath.cpp $(srcdir)/xsltransform.cpp $(srcdir)/webquerysciencedirect.cpp $(srcdir)/findduplicates.cpp $(srcdir)/settingsz3950.cpp $(srcdir)/messagehandler.cpp $(srcdir)/iso6937converter.cpp $(srcdir)/iso5426converter.cpp $(srcdir)/webquerymathscinet.cpp documentsourceview.moc file.moc documentlistview.moc entrywidgetuserdefined.moc webqueryamatex.moc fileimporterbibutils.moc webquerymathscinet.moc fieldlineedit.moc webqueryciteseerx.moc webquerygooglescholar.moc webquerypubmed.moc entrywidget.moc webqueryz3950.moc fileexporterbibutils.moc entrywidgetmisc.moc entrywidgetexternal.moc kbibtex_part.moc webqueryspireshep.moc webqueryzmath.moc settingsediting.moc entrywidgetother.moc settingssearchurl.moc webqueryieeexplore.moc webquerycitebase.moc webquerydblp.moc preamblewidget.moc commentwidget.moc mergeelements.moc fileimporterexternal.moc settingskeyword.moc webquerybibsonomy.moc findduplicates.moc entrywidgetkeyword.moc entrywidgettitle.moc fileexporter.moc entrywidgetsource.moc fileimporter.moc searchbar.moc idsuggestionswidget.moc settingsz3950.moc entrywidgettab.moc entrywidgetpublication.moc fileexportertoolchain.moc settingsidsuggestions.moc settingsuserdefinedinput.moc entrywidgetauthor.moc settingsfileio.moc webquerysciencedirect.moc settingsdlg.moc webqueryarxiv.moc sidebar.moc fileexporterexternal.moc webquery.moc valuewidget.moc fieldlistview.moc documentwidget.moc webquerycsb.moc macrowidget.moc
+ @echo 'creating libkbibtexpart_la.all_cpp.cpp ...'; \
+ rm -f libkbibtexpart_la.all_cpp.files libkbibtexpart_la.all_cpp.final; \
+ echo "#define KDE_USE_FINAL 1" >> libkbibtexpart_la.all_cpp.final; \
+ for file in comment.cpp fileexporterdocbook5.cpp commentwidget.cpp documentlistview.cpp documentlistviewitem.cpp documentsourceview.cpp documentwidget.cpp element.cpp encoder.cpp encoderlatex.cpp encoderxml.cpp entry.cpp entryfield.cpp entrywidget.cpp entrywidgetauthor.cpp entrywidgetexternal.cpp entrywidgetkeyword.cpp entrywidgetmisc.cpp entrywidgetother.cpp entrywidgetpublication.cpp entrywidgetsource.cpp entrywidgettab.cpp entrywidgettitle.cpp entrywidgetuserdefined.cpp entrywidgetwarningsitem.cpp z3950connection.cpp fieldlineedit.cpp fieldlistview.cpp file.cpp fileexporter.cpp fileexporterbibtex.cpp fileexporterris.cpp fileexporterbibutils.cpp fileexporterexternal.cpp fileexporterpdf.cpp fileexporterps.cpp fileexporterrtf.cpp fileexportertoolchain.cpp fileexporterxml.cpp fileexporterxslt.cpp fileimporter.cpp fileimporterbibtex.cpp fileimporterbibutils.cpp fileimporterexternal.cpp fileimporterris.cpp idsuggestions.cpp idsuggestionswidget.cpp kbibtex_part.cpp macro.cpp macrowidget.cpp mergeelements.cpp preamble.cpp webqueryieeexplore.cpp preamblewidget.cpp searchbar.cpp settings.cpp settingsdlg.cpp settingsediting.cpp settingsfileio.cpp settingsidsuggestions.cpp settingskeyword.cpp settingssearchurl.cpp settingsuserdefinedinput.cpp sidebar.cpp value.cpp valuewidget.cpp webquery.cpp webqueryamatex.cpp webqueryarxiv.cpp webqueryciteseerx.cpp webquerybibsonomy.cpp webquerycsb.cpp webquerycitebase.cpp webquerydblp.cpp webqueryz3950.cpp webquerygooglescholar.cpp webquerypubmed.cpp webqueryspireshep.cpp webqueryzmath.cpp xsltransform.cpp webquerysciencedirect.cpp findduplicates.cpp settingsz3950.cpp messagehandler.cpp iso6937converter.cpp iso5426converter.cpp webquerymathscinet.cpp ; do \
+ echo "#include \"$$file\"" >> libkbibtexpart_la.all_cpp.files; \
+ test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> libkbibtexpart_la.all_cpp.final; \
+ done; \
+ cat libkbibtexpart_la.all_cpp.final libkbibtexpart_la.all_cpp.files > libkbibtexpart_la.all_cpp.cpp; \
+ rm -f libkbibtexpart_la.all_cpp.final libkbibtexpart_la.all_cpp.files
+
+#>+ 11
+kbibtex.all_cpp.cpp: $(srcdir)/Makefile.in $(srcdir)/kbibtexshell.cpp $(srcdir)/main.cpp kbibtexshell.moc
+ @echo 'creating kbibtex.all_cpp.cpp ...'; \
+ rm -f kbibtex.all_cpp.files kbibtex.all_cpp.final; \
+ echo "#define KDE_USE_FINAL 1" >> kbibtex.all_cpp.final; \
+ for file in kbibtexshell.cpp main.cpp ; do \
+ echo "#include \"$$file\"" >> kbibtex.all_cpp.files; \
+ test ! -f $(srcdir)/$$file || egrep '^#pragma +implementation' $(srcdir)/$$file >> kbibtex.all_cpp.final; \
+ done; \
+ cat kbibtex.all_cpp.final kbibtex.all_cpp.files > kbibtex.all_cpp.cpp; \
+ rm -f kbibtex.all_cpp.final kbibtex.all_cpp.files
+
+#>+ 3
+clean-final:
+ -rm -f libkbibtexpart_la.all_cpp.cpp kbibtex.all_cpp.cpp
+
+#>+ 3
+final:
+ $(MAKE) libkbibtexpart_la_OBJECTS="$(libkbibtexpart_la_final_OBJECTS)" kbibtex_OBJECTS="$(kbibtex_final_OBJECTS)" all-am
+
+#>+ 3
+final-install:
+ $(MAKE) libkbibtexpart_la_OBJECTS="$(libkbibtexpart_la_final_OBJECTS)" kbibtex_OBJECTS="$(kbibtex_final_OBJECTS)" install-am
+
+#>+ 3
+no-final:
+ $(MAKE) libkbibtexpart_la_OBJECTS="$(libkbibtexpart_la_nofinal_OBJECTS)" kbibtex_OBJECTS="$(kbibtex_nofinal_OBJECTS)" all-am
+
+#>+ 3
+no-final-install:
+ $(MAKE) libkbibtexpart_la_OBJECTS="$(libkbibtexpart_la_nofinal_OBJECTS)" kbibtex_OBJECTS="$(kbibtex_nofinal_OBJECTS)" install-am
+
+#>+ 3
+kde-rpo-clean:
+ -rm -f *.rpo
+
+#>+ 121
+idsuggestionswidget.lo: idsuggestionswidget.moc
+idsuggestionswidget.o: idsuggestionswidget.moc
+settingskeyword.lo: settingskeyword.moc
+sidebar.o: sidebar.moc
+kbibtex_part.lo: kbibtex_part.moc
+settingssearchurl.lo: settingssearchurl.moc
+sidebar.lo: sidebar.moc
+settingsidsuggestions.lo: settingsidsuggestions.moc
+fieldlistview.o: fieldlistview.moc
+webqueryz3950.o: webqueryz3950.moc
+webquerybibsonomy.lo: webquerybibsonomy.moc
+kbibtex_part.o: kbibtex_part.moc
+webquerydblp.lo: webquerydblp.moc
+entrywidgetpublication.lo: entrywidgetpublication.moc
+settingsuserdefinedinput.o: settingsuserdefinedinput.moc
+kbibtexshell.lo: kbibtexshell.moc
+documentwidget.o: documentwidget.moc
+findduplicates.o: findduplicates.moc
+nmcheck-am: nmcheck
+entrywidgetother.o: entrywidgetother.moc
+webquerypubmed.lo: webquerypubmed.moc
+fileexportertoolchain.lo: fileexportertoolchain.moc
+entrywidgetother.lo: entrywidgetother.moc
+fileexportertoolchain.o: fileexportertoolchain.moc
+settingsz3950.lo: settingsz3950.moc
+mergeelements.lo: mergeelements.moc
+webqueryzmath.lo: webqueryzmath.moc
+fieldlineedit.lo: fieldlineedit.moc
+file.o: file.moc
+entrywidgetexternal.o: entrywidgetexternal.moc
+valuewidget.lo: valuewidget.moc
+commentwidget.o: commentwidget.moc
+entrywidgetsource.lo: entrywidgetsource.moc
+entrywidgetpublication.o: entrywidgetpublication.moc
+entrywidgetmisc.o: entrywidgetmisc.moc
+settingsfileio.lo: settingsfileio.moc
+entrywidget.o: entrywidget.moc
+webqueryieeexplore.o: webqueryieeexplore.moc
+webqueryciteseerx.o: webqueryciteseerx.moc
+documentsourceview.lo: documentsourceview.moc
+settingssearchurl.o: settingssearchurl.moc
+fieldlistview.lo: fieldlistview.moc
+webqueryamatex.o: webqueryamatex.moc
+webqueryz3950.lo: webqueryz3950.moc
+fileexporter.lo: fileexporter.moc
+entrywidgetuserdefined.o: entrywidgetuserdefined.moc
+entrywidget.lo: entrywidget.moc
+webquerymathscinet.lo: webquerymathscinet.moc
+fileimporterbibutils.lo: fileimporterbibutils.moc
+searchbar.lo: searchbar.moc
+kbibtexshell.o: kbibtexshell.moc
+fileexporterbibutils.o: fileexporterbibutils.moc
+entrywidgetkeyword.lo: entrywidgetkeyword.moc
+fieldlineedit.o: fieldlineedit.moc
+mergeelements.o: mergeelements.moc
+webqueryieeexplore.lo: webqueryieeexplore.moc
+webquerycsb.lo: webquerycsb.moc
+webquerysciencedirect.o: webquerysciencedirect.moc
+macrowidget.o: macrowidget.moc
+webqueryspireshep.o: webqueryspireshep.moc
+webquerycitebase.o: webquerycitebase.moc
+webqueryspireshep.lo: webqueryspireshep.moc
+webquerydblp.o: webquerydblp.moc
+entrywidgettitle.o: entrywidgettitle.moc
+webqueryciteseerx.lo: webqueryciteseerx.moc
+webquerysciencedirect.lo: webquerysciencedirect.moc
+entrywidgetmisc.lo: entrywidgetmisc.moc
+webquerycsb.o: webquerycsb.moc
+webquerygooglescholar.o: webquerygooglescholar.moc
+fileexporter.o: fileexporter.moc
+preamblewidget.lo: preamblewidget.moc
+fileimporterexternal.o: fileimporterexternal.moc
+settingsdlg.o: settingsdlg.moc
+documentsourceview.o: documentsourceview.moc
+documentlistview.o: documentlistview.moc
+findduplicates.lo: findduplicates.moc
+fileimporter.lo: fileimporter.moc
+settingsediting.lo: settingsediting.moc
+settingsuserdefinedinput.lo: settingsuserdefinedinput.moc
+settingsidsuggestions.o: settingsidsuggestions.moc
+entrywidgetkeyword.o: entrywidgetkeyword.moc
+preamblewidget.o: preamblewidget.moc
+settingsediting.o: settingsediting.moc
+fileimporterexternal.lo: fileimporterexternal.moc
+entrywidgetauthor.lo: entrywidgetauthor.moc
+entrywidgetsource.o: entrywidgetsource.moc
+documentwidget.lo: documentwidget.moc
+macrowidget.lo: macrowidget.moc
+webquerypubmed.o: webquerypubmed.moc
+webqueryamatex.lo: webqueryamatex.moc
+entrywidgetuserdefined.lo: entrywidgetuserdefined.moc
+webquery.lo: webquery.moc
+fileimporter.o: fileimporter.moc
+webquery.o: webquery.moc
+settingsz3950.o: settingsz3950.moc
+webquerymathscinet.o: webquerymathscinet.moc
+documentlistview.lo: documentlistview.moc
+settingsfileio.o: settingsfileio.moc
+fileexporterexternal.lo: fileexporterexternal.moc
+entrywidgettitle.lo: entrywidgettitle.moc
+file.lo: file.moc
+webquerygooglescholar.lo: webquerygooglescholar.moc
+webquerybibsonomy.o: webquerybibsonomy.moc
+nmcheck:
+entrywidgetauthor.o: entrywidgetauthor.moc
+fileimporterbibutils.o: fileimporterbibutils.moc
+fileexporterexternal.o: fileexporterexternal.moc
+settingsdlg.lo: settingsdlg.moc
+entrywidgettab.o: entrywidgettab.moc
+entrywidgettab.lo: entrywidgettab.moc
+settingskeyword.o: settingskeyword.moc
+webqueryarxiv.lo: webqueryarxiv.moc
+fileexporterbibutils.lo: fileexporterbibutils.moc
+searchbar.o: searchbar.moc
+entrywidgetexternal.lo: entrywidgetexternal.moc
+valuewidget.o: valuewidget.moc
+webquerycitebase.lo: webquerycitebase.moc
+webqueryarxiv.o: webqueryarxiv.moc
+webqueryzmath.o: webqueryzmath.moc
+commentwidget.lo: commentwidget.moc
diff --git a/src/comment.cpp b/src/comment.cpp
new file mode 100644
index 0000000..dcf0a58
--- /dev/null
+++ b/src/comment.cpp
@@ -0,0 +1,93 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qregexp.h>
+#include <qstringlist.h>
+
+#include <comment.h>
+#include <xsltransform.h>
+
+namespace BibTeX
+{
+
+ Comment::Comment( const QString& text, bool useCommand ) : Element(), m_text( text ), m_useCommand( useCommand )
+ {
+ // nothing
+ }
+
+ Comment::Comment( Comment *other )
+ {
+ m_text = other->m_text;
+ m_useCommand = other->m_useCommand;
+ }
+
+ Comment::~Comment()
+ {
+ // nothing
+ }
+
+ QString Comment::text() const
+ {
+ return m_text;
+ }
+
+ void Comment::setText( const QString &text )
+ {
+ m_text = text;
+ }
+
+ bool Comment::useCommand() const
+ {
+ return m_useCommand;
+ }
+
+ void Comment::setUseCommand( bool useCommand )
+ {
+ m_useCommand = useCommand;
+ }
+
+ bool Comment::containsPattern( const QString& pattern, EntryField::FieldType fieldType, FilterType filterType, bool caseSensitive ) const
+ {
+ if ( filterType == ftExact )
+ {
+ /** check for exact match */
+ return fieldType == EntryField::ftUnknown && m_text.contains( pattern, caseSensitive );
+ }
+ else
+ {
+ /** for each word in the search pattern ... */
+ QStringList words = QStringList::split( QRegExp( "\\s+" ), pattern );
+ unsigned int hits = 0;
+ for ( QStringList::Iterator it = words.begin(); it != words.end(); ++it )
+ {
+ /** check if word is contained in text */
+ if ( fieldType == EntryField::ftUnknown && m_text.contains( *it, caseSensitive ) )
+ ++hits;
+ }
+
+ /** return success depending on filter type and number of hits */
+ return ( ( filterType == ftAnyWord && hits > 0 ) || ( filterType == ftEveryWord && hits == words.count() ) );
+ }
+ }
+
+ Element* Comment::clone()
+ {
+ return new Comment( this );
+ }
+}
diff --git a/src/comment.h b/src/comment.h
new file mode 100644
index 0000000..f259daf
--- /dev/null
+++ b/src/comment.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXCOMMENT_H
+#define BIBTEXCOMMENT_H
+
+#include <element.h>
+
+namespace BibTeX
+{
+
+ class Comment : public Element
+ {
+ public:
+ Comment( const QString &text, bool useCommand = false );
+ Comment( Comment *other );
+ virtual ~Comment();
+
+ QString text() const;
+ void setText( const QString &text );
+ bool useCommand() const;
+ void setUseCommand( bool useCommand );
+
+ bool containsPattern( const QString& pattern, EntryField::FieldType fieldType = EntryField::ftUnknown, FilterType filterType = BibTeX::Element::ftExact, bool caseSensitive = FALSE ) const;
+ Element* clone();
+
+ private:
+ QString m_text;
+ bool m_useCommand;
+ };
+
+}
+#endif
diff --git a/src/commentwidget.cpp b/src/commentwidget.cpp
new file mode 100644
index 0000000..09d371f
--- /dev/null
+++ b/src/commentwidget.cpp
@@ -0,0 +1,98 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlabel.h>
+#include <qmultilineedit.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <kdialogbase.h>
+#include <kglobalsettings.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include <comment.h>
+#include <element.h>
+
+#include "commentwidget.h"
+
+namespace KBibTeX
+{
+ CommentWidget::CommentWidget( BibTeX::Comment *comment, bool isReadOnly, QWidget *parent, const char *name )
+ : QWidget( parent, name ), m_comment( comment ), m_isReadOnly( isReadOnly )
+ {
+ setupGUI();
+ getCommentData();
+ m_multiLineEdit->setReadOnly( isReadOnly );
+ }
+
+
+ CommentWidget::~CommentWidget()
+ {
+ // nothing
+ }
+
+ void CommentWidget::setupGUI()
+ {
+ setMinimumWidth( 384 );
+ QVBoxLayout * layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
+
+ QLabel *label = new QLabel( i18n( "Co&mment:" ), this );
+ layout->addWidget( label );
+
+ m_multiLineEdit = new QMultiLineEdit( this );
+ m_multiLineEdit->setFont( KGlobalSettings::fixedFont() );
+ layout->addWidget( m_multiLineEdit );
+ label->setBuddy( m_multiLineEdit );
+ m_multiLineEdit->setReadOnly( m_isReadOnly );
+
+ m_checkboxUseCommand = new QCheckBox( i18n( "&Use @Comment for comment instead of plain text" ), this );
+ layout->addWidget( m_checkboxUseCommand );
+ }
+
+ void CommentWidget::getCommentData()
+ {
+ m_multiLineEdit->setText( m_comment->text() );
+ m_checkboxUseCommand->setChecked( m_comment->useCommand() );
+ }
+
+ void CommentWidget::setCommentData()
+ {
+ m_comment->setText( m_multiLineEdit->text() );
+ m_comment->setUseCommand( m_checkboxUseCommand->isChecked() );
+ }
+
+ QDialog::DialogCode CommentWidget::execute( BibTeX::Comment *comment, bool isReadOnly, QWidget *parent, const char *name )
+ {
+ KDialogBase * dlg = new KDialogBase( parent, name, true, i18n( "Edit BibTeX Comment" ), KDialogBase::Ok | KDialogBase::Cancel );
+ CommentWidget* ui = new CommentWidget( comment, isReadOnly, dlg, "kbibtex::commentwidget" );
+ dlg->setMainWidget( ui );
+
+ QDialog::DialogCode result = ( QDialog::DialogCode ) dlg->exec();
+ if ( !isReadOnly && result == QDialog::Accepted )
+ ui->setCommentData();
+
+ delete( ui );
+ delete( dlg );
+
+ return result;
+ }
+}
+
+#include "commentwidget.moc"
+
diff --git a/src/commentwidget.h b/src/commentwidget.h
new file mode 100644
index 0000000..16ac051
--- /dev/null
+++ b/src/commentwidget.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef COMMENTWIDGET_H
+#define COMMENTWIDGET_H
+
+#include <qwidget.h>
+#include <qdialog.h>
+
+#include <comment.h>
+
+class QMultiLineEdit;
+class QCheckBox;
+
+namespace KBibTeX
+{
+ class CommentWidget : public QWidget
+ {
+ Q_OBJECT
+ public:
+ CommentWidget( BibTeX::Comment *comment, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~CommentWidget();
+
+ static QDialog::DialogCode execute( BibTeX::Comment *comment, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+
+ private:
+ BibTeX::Comment* m_comment;
+ QCheckBox *m_checkboxUseCommand;
+ QMultiLineEdit *m_multiLineEdit;
+ bool m_isReadOnly;
+
+ void setupGUI();
+ void setCommentData();
+ void getCommentData();
+ };
+
+}
+
+#endif
diff --git a/src/documentlistview.cpp b/src/documentlistview.cpp
new file mode 100644
index 0000000..61ff980
--- /dev/null
+++ b/src/documentlistview.cpp
@@ -0,0 +1,768 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qevent.h>
+#include <qdragobject.h>
+#include <qfile.h>
+#include <qvaluelist.h>
+#include <qcursor.h>
+#include <qbuffer.h>
+#include <qlistview.h>
+#include <qclipboard.h>
+#include <qheader.h>
+#include <qtextstream.h>
+#include <qtimer.h>
+
+#include <kapplication.h>
+#include <kio/netaccess.h>
+#include <ktempfile.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kurldrag.h>
+#include <kactionclasses.h>
+#include <kaction.h>
+#include <kpopupmenu.h>
+#include <kmessagebox.h>
+#include <kprogress.h>
+#include <kiconloader.h>
+
+#include <kbibtex_part.h>
+#include <documentlistviewitem.h>
+#include <file.h>
+#include <fileimporterbibutils.h>
+#include <fileimporterris.h>
+#include <fileimporterbibtex.h>
+#include <fileexporterbibtex.h>
+#include <element.h>
+#include <entry.h>
+#include <macro.h>
+#include <comment.h>
+#include <preamblewidget.h>
+#include <preamble.h>
+#include <entrywidget.h>
+#include <commentwidget.h>
+#include <macrowidget.h>
+#include <settings.h>
+#include <encoderlatex.h>
+
+#include "documentlistview.h"
+
+namespace KBibTeX
+{
+ DocumentListView::DocumentListView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, QWidget *parent, const char *name )
+ : KListView( parent, name ), m_docWidget( docWidget ), m_bibtexFile( NULL ), m_contextMenu( NULL ), m_headerMenu( NULL ), m_isReadOnly( isReadOnly ), m_newElementCounter( 1 )
+ {
+ setAllColumnsShowFocus( true );
+ setShowSortIndicator( true );
+ setSelectionMode( QListView::Extended );
+ header() ->setClickEnabled( TRUE );
+ header() ->setMovingEnabled( TRUE );
+ buildColumns();
+
+ setDragEnabled( true );
+ // setDragAutoScroll( true );
+ setAcceptDrops( TRUE );
+ setDropVisualizer( TRUE );
+
+ connect( header(), SIGNAL( clicked( int ) ), this, SLOT( setSortingColumn( int ) ) );
+ connect( this, SIGNAL( contextMenu( KListView *, QListViewItem *, const QPoint & ) ), this, SLOT( showBibtexListContextMenu( KListView *, QListViewItem *, const QPoint & ) ) );
+ connect( this, SIGNAL( doubleClicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( slotDoubleClick( QListViewItem* ) ) );
+ connect( this, SIGNAL( dropped( QDropEvent*, QListViewItem* ) ), this, SLOT( slotDropped( QDropEvent*, QListViewItem* ) ) );
+ }
+
+ DocumentListView::~DocumentListView()
+ {
+ // nothing
+ }
+
+ void DocumentListView::setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client )
+ {
+ m_contextMenu = static_cast<KPopupMenu*>( factory -> container( "popup_bibtexlist", client ) );
+ }
+
+ bool DocumentListView::setBibTeXFile( BibTeX::File *bibtexFile )
+ {
+ m_bibtexFile = bibtexFile;
+ setItems();
+
+ return TRUE;
+ }
+
+ BibTeX::File* DocumentListView::getBibTeXFile( )
+ {
+ return m_bibtexFile;
+ }
+
+ void DocumentListView::setItems()
+ {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ KProgressDialog *prgDlg = new KProgressDialog( this, "prgDlg", i18n( "List View" ), i18n( "Updating main view ..." ), TRUE );
+ prgDlg->show();
+ KProgress *progress = prgDlg->progressBar();
+ progress->setTotalSteps( m_bibtexFile->count() );
+
+ bool update = viewport()->isUpdatesEnabled();
+ viewport()->setUpdatesEnabled( FALSE );
+ int sortCol = sortColumn();
+ setSortColumn( -1 );
+
+ clear();
+ for ( unsigned int i = 0; i < m_bibtexFile->count(); i++ )
+ {
+ BibTeX::Element *element = m_bibtexFile->at( i );
+ new DocumentListViewItem( m_bibtexFile, element, this );
+ progress->setProgress( i );
+
+ if ( i % 43 == 23 )
+ kapp->processEvents();
+ }
+
+ viewport()->setUpdatesEnabled( update );
+ setSortColumn( sortCol );
+ triggerUpdate();
+ delete prgDlg;
+
+ updateVisiblity();
+
+ QApplication::restoreOverrideCursor();
+ }
+
+ void DocumentListView::insertItems( BibTeX::File *items, KBibTeX::DocumentListViewItem *after )
+ {
+ for ( BibTeX::File::ElementList::iterator it = items->begin(); it != items->end(); it++ )
+ after = insertItem( *it, after );
+ }
+
+ KBibTeX::DocumentListViewItem * DocumentListView::insertItem( BibTeX::Element *item, KBibTeX::DocumentListViewItem *after )
+ {
+ if ( m_bibtexFile == NULL )
+ m_bibtexFile = new BibTeX::File();
+
+ BibTeX::Element *element = NULL;
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry *>( item );
+ if ( entry != NULL )
+ {
+ BibTeX::Entry *newEntry = new BibTeX::Entry( entry );
+ if ( m_bibtexFile->containsKey( newEntry->id() ) )
+ {
+ int counter = 0;
+ QString newId = QString( newEntry->id() ).append( '_' ).append( QString::number( ++counter ) );
+ while ( m_bibtexFile->containsKey( newId ) )
+ newId = QString( newEntry->id() ).append( '_' ).append( QString::number( ++counter ) );
+ newEntry->setId( newId );
+ }
+ element = newEntry;
+ }
+ else
+ element = item->clone();
+
+
+ m_bibtexFile->appendElement( element, after == NULL ? NULL : after->element() );
+ after = new DocumentListViewItem( m_bibtexFile, element, this, after );
+ after->setUnreadStatus( TRUE );
+ updateVisiblity( after );
+ m_unreadItems.append( after );
+
+ emit modified();
+ QTimer::singleShot( 3500, this, SLOT( makeNewItemsUnread() ) );
+
+ return after;
+ }
+
+ void DocumentListView::insertItem( BibTeX::Element *item )
+ {
+ insertItem( item, NULL );
+ }
+
+ void DocumentListView::updateVisiblity()
+ {
+ QListViewItemIterator it( this );
+ while ( it.current() )
+ {
+ DocumentListViewItem * kblvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ updateVisiblity( kblvi );
+ it++;
+ }
+ }
+
+ void DocumentListView::updateVisiblity( KBibTeX::DocumentListViewItem *item )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ BibTeX::Element *element = item->element();
+ bool notFiltered = m_filter.isEmpty() || element ->containsPattern( m_filter, m_filterFieldType, m_filterType );
+
+ BibTeX::Macro *macro = dynamic_cast<BibTeX::Macro*>( element );
+ if ( macro != NULL )
+ item->setVisible( notFiltered && settings->editing_ShowMacros );
+ else
+ {
+ BibTeX::Comment *comment = dynamic_cast<BibTeX::Comment*>( element );
+ if ( comment != NULL )
+ item->setVisible( notFiltered && settings->editing_ShowComments );
+ else
+ item->setVisible( notFiltered );
+ }
+ }
+
+ void DocumentListView::deferredInitialization()
+ {
+ connect( header(), SIGNAL( sizeChange( int, int, int ) ), this, SLOT( saveColumnWidths() ) );
+ connect( header(), SIGNAL( indexChange( int, int, int ) ), this, SLOT( saveColumnIndex() ) );
+ }
+
+ void DocumentListView::restoreState()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ if ( settings->editing_UseSpecialFont )
+ setFont( settings->editing_SpecialFont );
+ else
+ setFont( KGlobalSettings::generalFont() );
+ header() ->setFont( KGlobalSettings::generalFont() );
+
+ restoreColumnIndex();
+ restoreColumnWidths();
+ restoreSortingColumn();
+ }
+
+ void DocumentListView::setViewShowColumnsMenu( KActionMenu *actionMenu )
+ {
+ if ( m_headerMenu == NULL )
+ {
+ m_headerMenu = actionMenu->popupMenu();
+ m_headerMenu->insertTitle( i18n( "Show Columns" ) );
+ m_headerMenu->setCheckable( TRUE );
+ connect( m_headerMenu, SIGNAL( activated( int ) ), this, SLOT( activateShowColumnMenu( int ) ) );
+
+ Settings * settings = Settings::self( m_bibtexFile );
+
+ int item = m_headerMenu->insertItem( i18n( "Element Type" ), 0 );
+ m_headerMenu->setItemChecked( item, settings->editing_MainListColumnsWidth[ 0 ] > 0 );
+ m_headerMenu->insertSeparator();
+
+ for ( int i = 0; i <= ( int ) BibTeX::EntryField::ftYear - ( int ) BibTeX::EntryField::ftAbstract; i++ )
+ {
+ BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType )( i + ( int ) BibTeX::EntryField::ftAbstract );
+ QString label = Settings::fieldTypeToI18NString( fieldType );
+ item = m_headerMenu->insertItem( label, ( int ) fieldType + 2 );
+ m_headerMenu->setItemChecked( item, settings->editing_MainListColumnsWidth[ i + 2 ] > 0 );
+ }
+ }
+ }
+
+ void DocumentListView::deleteSelected()
+ {
+ QListViewItemIterator it( this, QListViewItemIterator::Selected | QListViewItemIterator::Visible );
+ if ( it.current() == NULL ) return;
+
+ QListViewItem *above = it.current() ->itemAbove();
+ QValueList<DocumentListViewItem*> toBeDeleted;
+ while ( it.current() )
+ {
+ DocumentListViewItem * kblvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ toBeDeleted.append( kblvi );
+ it++;
+ }
+
+ for ( QValueList<DocumentListViewItem*>::Iterator it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it )
+ {
+ m_bibtexFile->deleteElement(( *it )->element() );
+ takeItem( *it );
+ delete( *it );
+ }
+
+ if ( above )
+ ensureItemVisible( above );
+
+ emit modified();
+ }
+
+ const QValueList<BibTeX::Element*> DocumentListView::selectedItems()
+ {
+ QValueList<BibTeX::Element*> result;
+
+ QListViewItemIterator it( this, QListViewItemIterator::Selected );
+ while ( it.current() )
+ {
+ DocumentListViewItem * kblvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ if ( kblvi->isVisible() )
+ result.append( kblvi->element() );
+ it++;
+ }
+
+ return result;
+ }
+
+ QString DocumentListView::selectedToBibTeXText()
+ {
+ BibTeX::FileExporterBibTeX *exporter = new BibTeX::FileExporterBibTeX();
+ exporter->setEncoding( "latex" );
+
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ QValueList<BibTeX::Element*> selectedElements = selectedItems();
+ for ( QValueList<BibTeX::Element*>::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it )
+ exporter->save( &buffer, *it );
+ buffer.close();
+ delete exporter;
+
+ buffer.open( IO_ReadOnly );
+ QTextStream in( &buffer );
+ in.setEncoding( QTextStream::UnicodeUTF8 );
+ QString result = in.read();
+ buffer.close();
+
+ return result;
+ }
+
+ QString DocumentListView::selectedToBibTeXRefs()
+ {
+ QString refs;
+ QValueList<BibTeX::Element*> selectedElements = selectedItems();
+ for ( QValueList<BibTeX::Element*>::iterator it = selectedElements.begin(); it != selectedElements.end(); ++it )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( *it );
+ if ( entry == NULL ) continue;
+
+ if ( !refs.isEmpty() )
+ refs.append( "," );
+ refs.append( entry->id() );
+ }
+ return QString( "\\cite{%1}" ).arg( refs );
+ }
+
+ void DocumentListView::copy()
+ {
+ kapp->clipboard() ->setText( selectedToBibTeXText() );
+ }
+
+ void DocumentListView::copyReferences()
+ {
+ kapp->clipboard() ->setText( selectedToBibTeXRefs() );
+ }
+
+ void DocumentListView::cut()
+ {
+ copy();
+ deleteSelected();
+ }
+
+ bool DocumentListView::paste()
+ {
+ DocumentListViewItem * dlvi = dynamic_cast<KBibTeX::DocumentListViewItem *>( selectedItem() );
+ if ( dlvi == NULL )
+ dlvi = dynamic_cast<KBibTeX::DocumentListViewItem *>( currentItem() );
+
+ QString clipboardText = kapp->clipboard() ->text();
+ return paste( clipboardText, dlvi );
+ }
+
+ bool DocumentListView::paste( const QString& text, DocumentListViewItem *at )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+
+ /** check if clipboard contains BibTeX content */
+ if ( BibTeX::FileImporterBibTeX::guessCanDecode( text ) )
+ {
+ BibTeX::FileImporter *importer = new BibTeX::FileImporterBibTeX( settings->editing_FirstNameFirst );
+ BibTeX::File *clipboardData = importer->load( text );
+ delete importer;
+
+ if ( clipboardData != NULL )
+ {
+ insertItems( clipboardData, at );
+ delete clipboardData;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && BibTeX::FileImporterBibUtils::guessCanDecode( text ) )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ BibTeX::File::FileFormat inputFormat = BibTeX::FileImporterBibUtils::guessInputFormat( text );
+ BibTeX::FileImporter *importer = NULL;
+ if ( inputFormat == BibTeX::File::formatRIS && !settings->fileIO_useBibUtils )
+ importer = new BibTeX::FileImporterRIS();
+ else
+ importer = new BibTeX::FileImporterBibUtils( inputFormat );
+ BibTeX::File *clipboardData = importer->load( text );
+ delete importer;
+
+ if ( clipboardData != NULL )
+ {
+ insertItems( clipboardData, at );
+ delete clipboardData;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else if ( BibTeX::FileImporterRIS::guessCanDecode( text ) )
+ {
+ BibTeX::FileImporter *importer = new BibTeX::FileImporterRIS( );
+ BibTeX::File *clipboardData = importer->load( text );
+ delete importer;
+
+ if ( clipboardData != NULL )
+ {
+ insertItems( clipboardData, at );
+ delete clipboardData;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+ else
+ {
+ /** Decoding the paste text as bibtex failed. Maybe the user wants
+ to paste the text as link address, abstract, etc... */
+ if ( !at ) // no list view item selected to add data to
+ return FALSE;
+
+ // fetch BibTeX element from current list view item
+ BibTeX::Entry * element = dynamic_cast<BibTeX::Entry*>( at->element() );
+ if ( ! element )
+ return FALSE;
+
+ // build popup menu
+ KPopupMenu * popup = new KPopupMenu( this, "pastePopup" );
+ popup->insertTitle( i18n( "Paste text as..." ) );
+ for ( int i = ( int ) BibTeX::EntryField::ftAuthor; i <= ( int ) BibTeX::EntryField::ftYear; i++ )
+ {
+ BibTeX::EntryField::FieldType ft = ( BibTeX::EntryField::FieldType ) i;
+ popup->insertItem( Settings::fieldTypeToI18NString( ft ), i );
+ }
+ popup->insertSeparator();
+ QIconSet cancelPixmap = KGlobal::iconLoader() ->loadIconSet( "cancel", KIcon::Small );
+ int cancelId = popup->insertItem( cancelPixmap, i18n( "Cancel" ) );
+
+ // show popup menu
+ int selectedId = popup->exec( QCursor::pos() );
+ if ( selectedId == cancelId || selectedId == -1 )
+ return FALSE; // cancel menu
+
+ // determine field to add clipboard value to
+ BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType ) selectedId;
+ BibTeX::EntryField * field = element->getField( fieldType );
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( fieldType );
+ element->addField( field );
+ }
+ else if ( field->value() != NULL )
+ delete field->value();
+
+ QString encodedText = BibTeX::EncoderLaTeX::currentEncoderLaTeX() ->encode( text );
+
+ // create new value from clipboard's content
+ BibTeX::Value * value = new BibTeX::Value();
+ if ( fieldType == BibTeX::EntryField::ftAuthor || fieldType == BibTeX::EntryField::ftEditor )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ value->items.append( new BibTeX::PersonContainer( encodedText, settings->editing_FirstNameFirst ) );
+ }
+ else if ( fieldType == BibTeX::EntryField::ftKeywords )
+ value->items.append( new BibTeX::KeywordContainer( encodedText ) );
+ else
+ value->items.append( new BibTeX::PlainText( encodedText ) );
+
+ field->setValue( value );
+
+ return TRUE;
+ }
+ }
+
+ void DocumentListView::selectAll()
+ {
+ QListView::selectAll( true );
+ }
+
+ /* void DocumentListView::sendSelectedToLyx()
+ {
+ QStringList refsToSend;
+ QListViewItemIterator it( this, QListViewItemIterator::Selected );
+ while ( it.current() )
+ {
+ DocumentListViewItem * kblvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( kblvi->element() );
+ if ( entry != NULL && kblvi->isVisible() )
+ refsToSend.append( entry->id() );
+ it++;
+ }
+
+ Settings * settings = Settings::self( m_bibtexFile );
+ QString lyxPipeFilename = settings->detectLyXInPipe();
+ kdDebug() << "sendSelectedToLyx: lyxPipeFilename= " << lyxPipeFilename << endl;
+ QFile pipe( lyxPipeFilename );
+ if ( pipe.exists() && pipe.open( IO_WriteOnly ) )
+ {
+ QTextStream * writer = new QTextStream( &pipe );
+ QString msg = "LYXCMD:kbibtex:citation-insert:" + refsToSend.join( "," );
+ *writer << msg << endl;
+ delete writer;
+ pipe.close();
+ }
+ else
+ KMessageBox::error( this, ( lyxPipeFilename.isEmpty() ? i18n( "Cannot establish a link to LyX" ) : QString( i18n( "Cannot establish a link to LyX using the pipe \"%1\"" ) ).arg( lyxPipeFilename ) ) + i18n( "\nMaybe LyX is not running?" ), i18n( "Error communicating with LyX" ) );
+ }*/
+
+ void DocumentListView::slotDoubleClick( QListViewItem *item )
+ {
+ DocumentListViewItem *dlvi = dynamic_cast<DocumentListViewItem*>( item );
+ if ( dlvi != NULL ) emit executed( dlvi );
+ }
+
+ void DocumentListView::filter( const QString & text, BibTeX::Element::FilterType filterType, BibTeX::EntryField::FieldType fieldType )
+ {
+ m_filter = text;
+ m_filterType = filterType;
+ m_filterFieldType = fieldType;
+ updateVisiblity();
+ }
+
+ void DocumentListView::setReadOnly( bool isReadOnly )
+ {
+ m_isReadOnly = isReadOnly;
+ }
+
+ void DocumentListView::activateShowColumnMenu( int id )
+ {
+ if ( id >= 0 )
+ {
+ if ( columnWidth( id ) > 0 )
+ {
+ hideColumn( id );
+ m_headerMenu->setItemChecked( id, FALSE );
+ }
+ else
+ {
+ showColumn( id );
+ m_headerMenu->setItemChecked( id, TRUE );
+ }
+ }
+ }
+
+ void DocumentListView::showBibtexListContextMenu( KListView *, QListViewItem *, const QPoint & p )
+ {
+ if ( m_contextMenu != NULL )
+ {
+ emit selectionChanged();
+ m_contextMenu->popup( p );
+ }
+ }
+
+ void DocumentListView::setSortingColumn( int column )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ settings->editing_MainListSortingColumn = column;
+ settings->editing_MainListSortingOrder = ( sortOrder() == Qt::Ascending ) ? 1 : -1;
+ }
+
+ bool DocumentListView::acceptDrag( QDropEvent * event ) const
+ {
+ if ( event->source() == this ) return false;
+ return QTextDrag::canDecode( event ) || QUriDrag::canDecode( event );
+ }
+
+ void DocumentListView::startDrag()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ QDragObject *d = new QTextDrag( settings->editing_DragAction == Settings::COPYREFERENCE ? selectedToBibTeXRefs() : selectedToBibTeXText(), this );
+ d->dragCopy();
+ }
+ void DocumentListView::saveColumnIndex()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ QHeader *hdr = header();
+
+ for ( int i = 0; i < columns(); i++ )
+ settings->editing_MainListColumnsIndex[ i ] = hdr->mapToIndex( i );
+ }
+
+ void DocumentListView::restoreColumnIndex()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ QHeader *hdr = header();
+
+ for ( int i = 0; i < columns(); i++ )
+ hdr->moveSection( i, settings->editing_MainListColumnsIndex[ i ] );
+ }
+
+ void DocumentListView::saveColumnWidths( int col )
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+
+ int from = col == -1 ? 0 : col, to = col == -1 ? columns() : ( col + 1 );
+
+ for ( int i = from; i < to; i++ )
+ {
+ if ( columnWidthMode( i ) == QListView::Manual )
+ settings->editing_MainListColumnsWidth[ i ] = columnWidth( i );
+ else
+ settings->editing_MainListColumnsWidth[ i ] = 0xffff;
+ }
+ }
+
+ void DocumentListView::restoreColumnWidths()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+
+ for ( int col = 0; col < columns(); col++ )
+ {
+ int colWidth = settings->editing_MainListColumnsWidth[ col ];
+ showColumn( col, colWidth );
+ }
+ }
+
+ void DocumentListView::restoreSortingColumn()
+ {
+ Settings * settings = Settings::self( m_bibtexFile );
+ setSortColumn( settings->editing_MainListSortingColumn );
+ setSortOrder( settings->editing_MainListSortingOrder > 0 ? Qt::Ascending : Qt::Descending );
+ }
+
+ void DocumentListView::makeNewItemsUnread()
+ {
+ for ( QValueList<DocumentListViewItem*>::ConstIterator it = m_unreadItems.begin() ; it != m_unreadItems.end(); ++it )
+ {
+ ( *it ) ->setUnreadStatus( FALSE );
+ ( *it ) ->repaint();
+ }
+
+ m_unreadItems.clear();
+ }
+
+ void DocumentListView::slotDropped( QDropEvent * event, QListViewItem * item )
+ {
+ QString text;
+ QStrList urlList;
+
+ if ( QTextDrag::decode( event, text ) && KURL( text ).isValid() )
+ urlList.append( text );
+
+ if ( !urlList.isEmpty() || QUriDrag::decode( event, urlList ) )
+ {
+ QString url = urlList.at( 0 );
+ QString tmpFile;
+ if ( ! KIO::NetAccess::download( url, tmpFile, 0 ) )
+ {
+ KMessageBox::error( this, KIO::NetAccess::lastErrorString() );
+ return ;
+ }
+ QFile f( tmpFile );
+ if ( ! f.open( IO_ReadOnly ) )
+ {
+ KMessageBox::error( this, f.errorString() );
+ KIO::NetAccess::removeTempFile( tmpFile );
+ return ;
+ }
+ QByteArray ba = f.readAll();
+ text = QString( ba );
+ f.close();
+ KIO::NetAccess::removeTempFile( tmpFile );
+ }
+ else if ( !QTextDrag::decode( event, text ) )
+ return;
+
+ event->accept( TRUE );
+ DocumentListViewItem * dlvi = dynamic_cast<KBibTeX::DocumentListViewItem *>( item );
+
+ paste( text, dlvi );
+ }
+
+ bool DocumentListView::eventFilter( QObject * watched, QEvent * e )
+ {
+ if ( watched == header() )
+ {
+ switch ( e->type() )
+ {
+ case QEvent::MouseButtonPress:
+ {
+ if ( static_cast<QMouseEvent *>( e ) ->button() == RightButton && m_headerMenu != NULL )
+ m_headerMenu->popup( QCursor::pos() );
+
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ return KListView::eventFilter( watched, e );
+ }
+
+ void DocumentListView::keyPressEvent( QKeyEvent *e )
+ {
+ if ( e->key() == QKeyEvent::Key_Enter || e->key() == QKeyEvent::Key_Return )
+ {
+ DocumentListViewItem *item = dynamic_cast<DocumentListViewItem*>( selectedItem() );
+ if ( item == NULL )
+ item = dynamic_cast<DocumentListViewItem*>( currentItem() );
+ if ( item != NULL )
+ emit executed( item );
+ }
+ else
+ KListView::keyPressEvent( e );
+ }
+
+ void DocumentListView::showColumn( int col, int colWidth )
+ {
+ if ( colWidth == 0xffff )
+ {
+ adjustColumn( col );
+ if ( columnWidth( col ) > width() / 3 )
+ colWidth = width() / 4;
+ if ( columnWidth( col ) < width() / 12 )
+ colWidth = width() / 8;
+ }
+
+ if ( colWidth < 0xffff )
+ setColumnWidth( col, colWidth );
+
+ header() ->setResizeEnabled( colWidth > 0, col );
+ setColumnWidthMode( col, colWidth < 0xffff ? QListView::Manual : QListView::Maximum );
+ saveColumnWidths( col );
+ }
+
+ void DocumentListView::hideColumn( int col )
+ {
+ showColumn( col, 0 );
+ }
+
+ void DocumentListView::buildColumns()
+ {
+ addColumn( i18n( "Element Type" ) );
+ addColumn( i18n( "Entry Id" ) );
+
+ for ( int i = 0; i <= ( int ) BibTeX::EntryField::ftYear - ( int ) BibTeX::EntryField::ftAbstract; i++ )
+ {
+ BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType )( i + ( int ) BibTeX::EntryField::ftAbstract );
+ QString label = Settings::fieldTypeToI18NString( fieldType );
+ addColumn( label );
+ }
+ }
+}
+
+#include "documentlistview.moc"
diff --git a/src/documentlistview.h b/src/documentlistview.h
new file mode 100644
index 0000000..da2c6c5
--- /dev/null
+++ b/src/documentlistview.h
@@ -0,0 +1,127 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXDOCUMENTLISTVIEW_H
+#define KBIBTEXDOCUMENTLISTVIEW_H
+
+#include <klistview.h>
+#include <kxmlguifactory.h>
+
+#include <fileimporter.h>
+#include <settings.h>
+#include <file.h>
+
+class QString;
+class KURL;
+class KActionMenu;
+class KPopupMenu;
+
+namespace KBibTeX
+{
+ class DocumentWidget;
+ class DocumentListViewItem;
+
+ class DocumentListView : public KListView
+ {
+ Q_OBJECT
+ public:
+ DocumentListView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~DocumentListView();
+
+ void setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client );
+ void setViewShowColumnsMenu( KActionMenu *actionMenu );
+
+ bool setBibTeXFile( BibTeX::File *bibtexFile );
+ BibTeX::File* getBibTeXFile( );
+ KBibTeX::DocumentListViewItem *insertItem( BibTeX::Element *item, KBibTeX::DocumentListViewItem *after );
+
+ void deleteSelected();
+ const QValueList<BibTeX::Element*> selectedItems();
+// void sendSelectedToLyx();
+
+ void updateVisiblity();
+ void updateVisiblity( KBibTeX::DocumentListViewItem *item );
+
+ void deferredInitialization();
+ void restoreState();
+
+ signals:
+ void modified();
+ void executed( DocumentListViewItem* );
+
+ public slots:
+ void copy();
+ void copyReferences();
+ void cut();
+ bool paste();
+ bool paste( const QString& text, DocumentListViewItem *at );
+ void selectAll();
+ void filter( const QString& text, BibTeX::Element::FilterType filterType, BibTeX::EntryField::FieldType fieldType );
+ void setReadOnly( bool isReadOnly );
+ void activateShowColumnMenu( int id );
+
+ void insertItems( BibTeX::File *items, KBibTeX::DocumentListViewItem *after = NULL );
+ void insertItem( BibTeX::Element *item );
+
+ private slots:
+ void slotDoubleClick( QListViewItem * item = NULL );
+ void setSortingColumn( int column );
+ void showBibtexListContextMenu( KListView *, QListViewItem *, const QPoint &p );
+ void slotDropped( QDropEvent* event, QListViewItem* item );
+ void saveColumnIndex();
+ void restoreColumnIndex();
+ void saveColumnWidths( int col = -1 );
+ void restoreColumnWidths();
+ void restoreSortingColumn();
+ void makeNewItemsUnread();
+
+ protected:
+ bool acceptDrag( QDropEvent* e ) const;
+ void startDrag();
+
+ virtual bool eventFilter( QObject *watched, QEvent *e );
+
+ virtual void keyPressEvent( QKeyEvent *e );
+
+ private:
+ static const int maxColumns = 256;
+ KBibTeX::DocumentWidget *m_docWidget;
+ BibTeX::File *m_bibtexFile;
+ KPopupMenu *m_contextMenu;
+ KPopupMenu *m_headerMenu;
+ KActionMenu *m_columnVisibleAction;
+ bool m_isReadOnly;
+ QValueList<DocumentListViewItem*> m_unreadItems;
+
+ QString m_filter;
+ BibTeX::Element::FilterType m_filterType;
+ BibTeX::EntryField::FieldType m_filterFieldType;
+ int m_newElementCounter;
+
+ void setItems();
+ QString selectedToBibTeXText();
+ QString selectedToBibTeXRefs();
+
+ void showColumn( int col, int colWidth = 0xffff );
+ void hideColumn( int col );
+ void buildColumns();
+ };
+}
+
+#endif
diff --git a/src/documentlistviewitem.cpp b/src/documentlistviewitem.cpp
new file mode 100644
index 0000000..7a71873
--- /dev/null
+++ b/src/documentlistviewitem.cpp
@@ -0,0 +1,151 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlistview.h>
+#include <qpainter.h>
+#include <qpen.h>
+
+#include <klocale.h>
+
+#include "documentlistviewitem.h"
+#include "entry.h"
+#include "comment.h"
+#include <preamble.h>
+#include "macro.h"
+
+namespace KBibTeX
+{
+ DocumentListViewItem::DocumentListViewItem( BibTeX::File *file, BibTeX::Element *element, DocumentListView *parent ) : KListViewItem( parent, parent->lastItem() ), m_element( element ), m_bibtexFile( file ), m_parent( parent ), m_unreadStatus( FALSE )
+ {
+ setTexts();
+ }
+
+ DocumentListViewItem::DocumentListViewItem( BibTeX::File *file, BibTeX::Element *element, DocumentListView *parent, QListViewItem *after ) : KListViewItem( parent, after ), m_element( element ), m_bibtexFile( file ), m_parent( parent )
+ {
+ setTexts();
+ }
+
+ DocumentListViewItem::~DocumentListViewItem()
+ {
+ // nothing
+ }
+
+ BibTeX::Element* DocumentListViewItem::element()
+ {
+ return m_element;
+ }
+
+ void DocumentListViewItem::updateItem()
+ {
+ setTexts();
+ }
+
+ void DocumentListViewItem::setUnreadStatus( bool unread )
+ {
+ m_unreadStatus = unread;
+ }
+
+ void DocumentListViewItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align )
+ {
+ if ( !p )
+ return ;
+
+ // make unread items bold
+ if ( m_unreadStatus )
+ {
+ QFont f = p->font();
+ f.setBold( TRUE );
+ p->setFont( f );
+ }
+
+ KListViewItem::paintCell( p, cg, column, width, align );
+ }
+
+
+ void DocumentListViewItem::setTexts()
+ {
+ BibTeX::Entry * entry = dynamic_cast<BibTeX::Entry*>( m_element );
+
+ if ( entry )
+ {
+ entry = new BibTeX::Entry( entry );
+ m_bibtexFile->completeReferencedFields( entry );
+
+ if ( entry->entryType() != BibTeX::Entry::etUnknown )
+ setText( 0, BibTeX::Entry::entryTypeToString( entry->entryType() ) );
+ else
+ setText( 0, entry->entryTypeString() );
+ setText( 1, entry->id() );
+
+ for ( int i = 2; i < m_parent->columns(); i++ )
+ {
+ BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType )( i - 2 + ( int ) BibTeX::EntryField::ftAbstract );
+ BibTeX::EntryField *field = entry->getField( fieldType );
+ BibTeX::Value *value = NULL;
+ if ( field != NULL && (( value = field->value() ) != NULL ) )
+ setText( i, value->text().replace( '{', "" ).replace( '}', "" ).replace( '~', "" ) );
+ else
+ setText( i, "" );
+ }
+
+ delete entry;
+ }
+ else
+ {
+ BibTeX::Comment *comment = dynamic_cast<BibTeX::Comment*>( m_element );
+ if ( comment )
+ {
+ setText( 0, i18n( "Comment" ) );
+ QString text = comment->text();
+ text.replace( '\n', ' ' );
+ setText(( int ) BibTeX::EntryField::ftTitle - ( int ) BibTeX::EntryField::ftAbstract + 2, text );
+ }
+ else
+ {
+ BibTeX::Macro * macro = dynamic_cast<BibTeX::Macro*>( m_element );
+ if ( macro )
+ {
+ setText( 0, i18n( "Macro" ) );
+ setText( 1, macro->key() );
+ BibTeX::Value *value = macro->value();
+ int i = ( int ) BibTeX::EntryField::ftTitle - ( int ) BibTeX::EntryField::ftAbstract + 2;
+ if ( value )
+ setText( i, macro->value() ->text() );
+ else
+ setText( i, "" );
+ }
+ else
+ {
+ BibTeX::Preamble *preamble = dynamic_cast<BibTeX::Preamble*>( m_element );
+ if ( preamble )
+ {
+ setText( 0, i18n( "Preamble" ) );
+ BibTeX::Value *value = preamble->value();
+ int i = ( int ) BibTeX::EntryField::ftTitle - ( int ) BibTeX::EntryField::ftAbstract + 2;
+ if ( value )
+ setText( i, preamble->value() ->text() );
+ else
+ setText( i, "" );
+ }
+
+ }
+ }
+ }
+ }
+}
diff --git a/src/documentlistviewitem.h b/src/documentlistviewitem.h
new file mode 100644
index 0000000..3462fd6
--- /dev/null
+++ b/src/documentlistviewitem.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef DOCUMENTLISTVIEWITEM_H
+#define DOCUMENTLISTVIEWITEM_H
+
+#include <klistview.h>
+
+#include <element.h>
+#include "documentlistview.h"
+
+namespace KBibTeX
+{
+ class DocumentListViewItem : public KListViewItem
+ {
+ public:
+ DocumentListViewItem( BibTeX::File *file, BibTeX::Element *element, DocumentListView *parent );
+ DocumentListViewItem( BibTeX::File *file, BibTeX::Element *element, DocumentListView *parent, QListViewItem *after );
+
+ ~DocumentListViewItem();
+
+ BibTeX::Element* element();
+ void updateItem();
+ void setUnreadStatus( bool unread );
+
+ protected:
+ void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int align );
+
+ private:
+ BibTeX::Element *m_element;
+ BibTeX::File *m_bibtexFile;
+ DocumentListView *m_parent;
+ bool m_unreadStatus;
+
+ void setTexts();
+ };
+}
+
+#endif // DOCUMENTLISTVIEWITEM_H
diff --git a/src/documentsourceview.cpp b/src/documentsourceview.cpp
new file mode 100644
index 0000000..0edce91
--- /dev/null
+++ b/src/documentsourceview.cpp
@@ -0,0 +1,380 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qbuffer.h>
+#include <qlayout.h>
+#include <qfile.h>
+
+#include <klibloader.h>
+#include <kxmlguifactory.h>
+#include <kapplication.h>
+#include <klibloader.h>
+#include <kfinddialog.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <ktrader.h>
+#include <kmimetype.h>
+#include <kservice.h>
+#include <kprogress.h>
+#include <kparts/componentfactory.h>
+#include <ktexteditor/configinterface.h>
+#include <ktexteditor/editorchooser.h>
+#include <ktexteditor/undointerface.h>
+
+#include <fileexporterbibtex.h>
+#include <fileimporterbibtex.h>
+#include <settings.h>
+#include "documentsourceview.h"
+
+namespace KBibTeX
+{
+
+ DocumentSourceView::DocumentSourceView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, QWidget *parent, const char *name )
+ : QWidget( parent, name ), m_isReadOnly( isReadOnly ), m_docWidget( docWidget ), m_bibtexFile( NULL ), m_document( NULL ), m_view( NULL ), m_progDlg( NULL )
+ {
+ setupGUI();
+
+ readConfig();
+ }
+
+ DocumentSourceView::~DocumentSourceView()
+ {
+ kapp->config() ->sync();
+ }
+
+ /**
+ * Copy the selected text to the clipboard
+ */
+ void DocumentSourceView::copy()
+ {
+ KTextEditor::ClipboardInterface * clip = dynamic_cast<KTextEditor::ClipboardInterface*>( m_view );
+ if ( clip )
+ clip->copy();
+ }
+
+ /**
+ * Cut the selected text to the clipboard
+ */
+ void DocumentSourceView::cut()
+ {
+ KTextEditor::ClipboardInterface * clip = dynamic_cast<KTextEditor::ClipboardInterface*>( m_view );
+ if ( clip )
+ clip->cut();
+ }
+
+ /**
+ * Paste the clipboard's content into the document
+ */
+ bool DocumentSourceView::paste()
+ {
+ KTextEditor::ClipboardInterface * clip = dynamic_cast<KTextEditor::ClipboardInterface*>( m_view );
+ if ( clip )
+ {
+ clip->paste();
+ return TRUE;
+ }
+ else
+ return FALSE;
+ }
+
+ /**
+ * Paste a line of text into the document at the designated position
+ */
+ void DocumentSourceView::insertLines( const QString& text, int line )
+ {
+ m_editInterface->insertLine( line < 0 ? m_editInterface->numLines() : ( uint ) line, text );
+
+ KTextEditor::ViewCursorInterface * cursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>( m_view );
+ if ( cursorIf )
+ cursorIf->setCursorPosition( line < 0 ? m_editInterface->numLines() - 1 : ( uint ) line, 0 );
+ }
+
+ void DocumentSourceView::selectAll()
+ {
+ KTextEditor::SelectionInterface * selI = dynamic_cast<KTextEditor::SelectionInterface*>( m_view );
+ if ( selI )
+ selI->selectAll();
+ }
+
+ void DocumentSourceView::setReadOnly( bool isReadOnly )
+ {
+ m_isReadOnly = isReadOnly;
+ m_document->setReadWrite( !m_isReadOnly );
+ }
+
+ void DocumentSourceView::setFactory( KXMLGUIFactory *factory, KXMLGUIClient * client )
+ {
+ KTextEditor::PopupMenuInterface * popupInterface = dynamic_cast<KTextEditor::PopupMenuInterface*>( m_view );
+ popupInterface->installPopup(( QPopupMenu* )( factory ->container( "ktexteditor_popup", client ) ) );
+ }
+
+ void DocumentSourceView::configureEditor()
+ {
+ KTextEditor::ConfigInterface * conf = KTextEditor::configInterface( m_document );
+ if ( !conf )
+ {
+ kdDebug() << "*** No KTextEditor::ConfigInterface for part!" << endl;
+ return ;
+ }
+
+ // show the modal config dialog for this part if it has a ConfigInterface
+ conf->configDialog();
+ conf->writeConfig();
+ }
+
+ void DocumentSourceView::undo()
+ {
+ KTextEditor::UndoInterface * undoIf = dynamic_cast<KTextEditor::UndoInterface*>( m_document );
+ if ( undoIf != NULL )
+ undoIf->undo();
+ else
+ kdDebug() << "Cannot determine undo interface" << endl;
+ }
+
+ void DocumentSourceView::find()
+ {
+ KFindDialog dlg( TRUE, this );
+ dlg.setFindHistory( m_findHistory );
+ dlg.setHasSelection( FALSE );
+#if KDE_IS_VERSION(3,4,0)
+ dlg.setSupportsWholeWordsFind( FALSE );
+ dlg.setSupportsBackwardsFind( FALSE );
+ dlg.setSupportsCaseSensitiveFind( FALSE );
+ dlg.setSupportsRegularExpressionFind( FALSE );
+#endif
+ if ( dlg.exec() == QDialog::Accepted )
+ {
+ m_lastSearchTerm = dlg.pattern();
+ m_findHistory = dlg.findHistory();
+
+
+
+ KTextEditor::ViewCursorInterface * cursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>( m_view );
+
+ if ( cursorIf )
+ {
+ unsigned int fromLine = 0;
+ unsigned int fromCol = 0;
+ if ( dlg.options() && KFindDialog::FromCursor )
+ {
+ cursorIf->cursorPosition( &fromLine, &fromCol );
+ fromCol++;
+ }
+
+ search( fromLine, fromCol );
+ }
+ else
+ kdDebug() << "Failed to instantiate ViewCursorInterface, SearchInterface, or SelectionInterface" << endl;
+ }
+ }
+
+ void DocumentSourceView::findNext()
+ {
+ if ( m_lastSearchTerm.isEmpty() )
+ find();
+ else
+ {
+ KTextEditor::ViewCursorInterface * cursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>( m_view );
+
+ if ( cursorIf )
+ {
+ unsigned int fromLine = 0;
+ unsigned int fromCol = 0;
+ cursorIf->cursorPosition( &fromLine, &fromCol );
+
+ search( fromLine, fromCol );
+ }
+ else
+ kdDebug() << "Failed to instantiate ViewCursorInterface, SearchInterface, or SelectionInterface" << endl;
+ }
+ }
+
+ bool DocumentSourceView::setBibTeXFile( BibTeX::File *bibtexFile )
+ {
+ Settings * settings = Settings::self();
+
+ bool result = FALSE;
+ m_progDlg = new KProgressDialog( this, NULL, i18n( "Source View" ), i18n( "Converting BibTeX document to plain text ..." ), true );
+ m_progDlg->setAllowCancel( false );
+ kapp->processEvents();
+
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ BibTeX::FileExporterBibTeX * exporter = new BibTeX::FileExporterBibTeX();
+ connect( exporter, SIGNAL( progress( int, int ) ), this, SLOT( updateProgress( int, int ) ) );
+ exporter->setStringDelimiter( settings->fileIO_BibtexStringOpenDelimiter, settings->fileIO_BibtexStringCloseDelimiter );
+ exporter->setKeywordCasing( settings->fileIO_KeywordCasing );
+ exporter->setEncoding( "latex" );
+ exporter->setEnclosingCurlyBrackets( settings->fileIO_EnclosingCurlyBrackets );
+ result = exporter->save( &buffer, bibtexFile );
+ delete exporter;
+ buffer.close();
+
+ if ( result )
+ {
+ kapp->processEvents();
+ buffer.open( IO_ReadOnly );
+ QTextStream in( &buffer );
+ in.setEncoding( QTextStream::UnicodeUTF8 );
+ QString text = in.read();
+ buffer.close();
+
+ if ( m_editInterface )
+ {
+ kapp->processEvents();
+ // very strange: to set the text, you have to set
+ // readwrite to TRUE...
+ m_document->setReadWrite( TRUE );
+ m_editInterface->setText( text );
+ m_document->setReadWrite( !m_isReadOnly );
+ }
+
+ m_bibtexFile = bibtexFile;
+ }
+
+ kapp->processEvents();
+ delete m_progDlg;
+
+ return result;
+ }
+
+ BibTeX::File* DocumentSourceView::getBibTeXFile()
+ {
+ if ( m_editInterface )
+ {
+ QBuffer buffer;
+
+ buffer.open( IO_WriteOnly );
+ QTextStream stream( &buffer );
+ stream.setEncoding( QTextStream::UnicodeUTF8 );
+ stream << m_editInterface->text();
+ buffer.close();
+
+ Settings * settings = Settings::self( m_bibtexFile );
+
+ buffer.open( IO_ReadOnly );
+ BibTeX::FileImporter *importer = new BibTeX::FileImporterBibTeX( settings->editing_FirstNameFirst );
+ BibTeX::File *result = importer->load( &buffer );
+ delete importer;
+ buffer.close();
+
+ return result;
+ }
+
+ return NULL;
+ }
+
+ void DocumentSourceView::focusInEvent( QFocusEvent* /*event*/ )
+ {
+ if ( m_view != NULL )
+ m_view->setFocus();
+ }
+
+ void DocumentSourceView::setupGUI()
+ {
+ // create the Kate::Document
+ m_document = Kate::createDocument( this, "Kate::Document" );
+
+ m_view = ( Kate::View * ) m_document->createView( this, 0L );
+ m_editInterface = editInterface( m_document );
+ m_document->setReadWrite( !m_isReadOnly );
+ if ( !m_isReadOnly )
+ connect( m_document, SIGNAL( textChanged() ), this, SIGNAL( modified() ) );
+ QBoxLayout * layout = new QVBoxLayout( this );
+ layout->addWidget( static_cast<QWidget*>( m_view ) );
+
+ int c = m_document->hlModeCount() ;
+ int hlIdx = -1;
+ for ( int i = 0; i < c; i++ )
+ if ( m_document->hlModeName( i ) .compare( "BibTeX" ) == 0 )
+ {
+ hlIdx = i;
+ break;
+ }
+ if ( hlIdx > -1 )
+ m_document-> setHlMode( hlIdx );
+ }
+
+ void DocumentSourceView::readConfig()
+ {
+ KConfig * config = kapp->config();
+ readConfig( config );
+ }
+
+ void DocumentSourceView::writeConfig()
+ {
+ KConfig * config = kapp->config();
+ writeConfig( config );
+ }
+
+ void DocumentSourceView::readConfig( KConfig *config )
+ {
+ if ( m_view )
+ {
+ KTextEditor::ConfigInterface * conf = KTextEditor::configInterface( m_document );
+ if ( conf )
+ conf->readConfig( config );
+ }
+ }
+
+ void DocumentSourceView::writeConfig( KConfig *config )
+ {
+ if ( m_view )
+ {
+ KTextEditor::ConfigInterface * conf = KTextEditor::configInterface( m_document );
+ if ( conf )
+ conf->writeConfig( config );
+ }
+ config->sync();
+ }
+
+ void DocumentSourceView::search( int fromLine, int fromCol )
+ {
+ unsigned int foundAtLine, foundAtCol, matchLen;
+
+ KTextEditor::SearchInterface * searchIf = KTextEditor::searchInterface( m_document );
+ KTextEditor::SelectionInterface *selectionIf = KTextEditor::selectionInterface( m_document );
+ KTextEditor::ViewCursorInterface * cursorIf = dynamic_cast<KTextEditor::ViewCursorInterface*>( m_view );
+
+ do
+ {
+ bool result = searchIf->searchText( fromLine, fromCol, m_lastSearchTerm, &foundAtLine, &foundAtCol, &matchLen, FALSE );
+ if ( result )
+ {
+ selectionIf->setSelection( foundAtLine, foundAtCol, foundAtLine, foundAtCol + matchLen );
+ cursorIf->setCursorPositionReal( foundAtLine, foundAtCol + matchLen );
+ break;
+ }
+
+ fromLine = 0;
+ fromCol = 0;
+ }
+ while ( KMessageBox::questionYesNo( this, QString( i18n( "Could not find text '%1' in the document.\nStart from the beginning?" ) ).arg( m_lastSearchTerm ), i18n( "Find text in source view" ), KGuiItem( i18n( "Restart search" ) ) ) == KMessageBox::Yes );
+ }
+
+ void DocumentSourceView::updateProgress( int current, int total )
+ {
+ m_progDlg->progressBar()->setTotalSteps( total );
+ m_progDlg->progressBar()->setValue( current );
+ kapp->processEvents();
+ }
+
+}
+#include "documentsourceview.moc"
diff --git a/src/documentsourceview.h b/src/documentsourceview.h
new file mode 100644
index 0000000..8edb23a
--- /dev/null
+++ b/src/documentsourceview.h
@@ -0,0 +1,96 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXDOCUMENTSOURCEVIEW_H
+#define KBIBTEXDOCUMENTSOURCEVIEW_H
+
+#include <qwidget.h>
+
+#include <file.h>
+
+#include <ktexteditor/editinterface.h>
+#include <kate/view.h>
+#include <kate/document.h>
+
+class KProgressDialog;
+
+namespace KBibTeX
+{
+ class DocumentWidget;
+
+ /**
+ * @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class DocumentSourceView : public QWidget
+ {
+ Q_OBJECT
+ public:
+ DocumentSourceView( KBibTeX::DocumentWidget *docWidget, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~DocumentSourceView();
+
+ bool setBibTeXFile( BibTeX::File *bibtexFile );
+ BibTeX::File* getBibTeXFile( );
+
+ void copy();
+ void cut();
+ bool paste();
+ void insertLines( const QString& text, int line = -1 );
+ void selectAll();
+
+ void setReadOnly( bool isReadOnly );
+ void setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client );
+
+ public slots:
+ void configureEditor();
+ void undo();
+ void find();
+ void findNext();
+
+ signals:
+ void modified();
+
+ protected:
+ virtual void focusInEvent( QFocusEvent* event );
+
+ private:
+ bool m_isReadOnly;
+ KBibTeX::DocumentWidget *m_docWidget;
+ BibTeX::File *m_bibtexFile;
+ Kate::Document* m_document;
+ Kate::View* m_view;
+ KTextEditor::EditInterface* m_editInterface;
+ QString m_lastSearchTerm;
+ QStringList m_findHistory;
+ KProgressDialog *m_progDlg;
+
+ void setupGUI();
+ void readConfig();
+ void writeConfig();
+ void readConfig( KConfig *config );
+ void writeConfig( KConfig *config );
+
+ void search( int fromLine, int fromCol );
+
+ private slots:
+ void updateProgress(int current, int total);
+ };
+
+}
+
+#endif
diff --git a/src/documentwidget.cpp b/src/documentwidget.cpp
new file mode 100644
index 0000000..1a59434
--- /dev/null
+++ b/src/documentwidget.cpp
@@ -0,0 +1,1740 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <cmath>
+
+#include <qlayout.h>
+#include <qfile.h>
+#include <qdragobject.h>
+#include <qregexp.h>
+#include <qsplitter.h>
+#include <qurl.h>
+#include <qtextedit.h>
+#include <qprogressdialog.h>
+#include <qbuffer.h>
+#include <qtooltip.h>
+#include <qapplication.h>
+#include <qpushbutton.h>
+#include <qfileinfo.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <ktempfile.h>
+#include <kglobalsettings.h>
+#include <kurl.h>
+#include <kinputdialog.h>
+#include <kpopupmenu.h>
+#include <kiconloader.h>
+#include <kio/netaccess.h>
+#include <kstandarddirs.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include <klineedit.h>
+#include <kdebug.h>
+#include <ktextedit.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <searchbar.h>
+#include <sidebar.h>
+#include <documentlistview.h>
+#include <documentlistviewitem.h>
+#include <documentsourceview.h>
+#include <macrowidget.h>
+#include <preamblewidget.h>
+#include <commentwidget.h>
+#include <entrywidget.h>
+#include <fileimporterbibtex.h>
+#include <fileimporterbibutils.h>
+#include <fileimporterris.h>
+#include <fileexporterbibtex.h>
+#include <fileexporterbibutils.h>
+#include <fileexporterris.h>
+#include <fileexporterxml.h>
+#include <fileexporterrtf.h>
+#include <fileexporterdocbook5.h>
+#include <fileexporterpdf.h>
+#include <fileexporterps.h>
+#include <fileexporterxslt.h>
+#include <fileimporterexternal.h>
+#include <fileexporterexternal.h>
+#include <xsltransform.h>
+#include <entry.h>
+#include <entryfield.h>
+#include <comment.h>
+#include <macro.h>
+#include <preamble.h>
+#include <settings.h>
+#include <webquery.h>
+#include <mergeelements.h>
+#include <idsuggestions.h>
+
+#include "documentwidget.h"
+
+namespace KBibTeX
+{
+
+ DocumentWidget::DocumentWidget( bool isReadOnly, QWidget *parent, const char *name )
+ : QTabWidget( parent, name ), m_lineEditNewKeyword( NULL ), m_isReadOnly( isReadOnly ), m_filename( QString::null ), m_progressDialog( NULL ), m_newElementCounter( 1 ), m_editMode( emList ), m_viewDocumentActionMenu( NULL ), m_assignKeywordsActionMenu( NULL ), m_searchWebsitesActionMenu( NULL ), m_actionEditCut( NULL ), m_actionEditCopy( NULL ), m_actionEditCopyRef( NULL ), m_actionEditPaste( NULL ), m_actionEditSelectAll( NULL ), m_actionEditFind( NULL ), m_actionEditFindNext( NULL ), m_dirWatch( this )
+ {
+ m_bibtexfile = new BibTeX::File();
+
+ setupGUI();
+
+ m_listViewElements->setBibTeXFile( m_bibtexfile );
+ m_sourceView->setBibTeXFile( m_bibtexfile );
+ }
+
+ DocumentWidget::~DocumentWidget()
+ {
+ delete m_bibtexfile;
+ }
+
+ void DocumentWidget::setupGUI()
+ {
+ setAcceptDrops( TRUE );
+ setFocusPolicy( QWidget::ClickFocus );
+
+ // List view tab widget ===============================
+
+ m_container = new QWidget( this );
+ QVBoxLayout *layout = new QVBoxLayout( m_container, 0, 0 );
+ addTab( m_container, i18n( "L&ist view" ) );
+
+ m_searchBar = new SearchBar( m_container );
+ layout->addWidget( m_searchBar );
+
+ m_horSplitter = new QSplitter( Qt::Horizontal, m_container );
+ layout->addWidget( m_horSplitter );
+ m_horSplitter->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
+
+ m_sideBar = new SideBar( m_isReadOnly, m_horSplitter );
+ m_vertSplitter = new QSplitter( Qt::Vertical, m_horSplitter );
+ m_vertSplitter->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
+
+ m_listViewElements = new DocumentListView( this, m_isReadOnly, m_vertSplitter );
+
+ m_preview = new KTextEdit( m_vertSplitter );
+ m_preview->setReadOnly( TRUE );
+ m_preview->setAlignment( Qt::AlignTop && Qt::AlignLeft );
+
+ // Source view tab widget =============================
+
+ m_sourceView = new DocumentSourceView( this, m_isReadOnly, this , "source_view" );
+ addTab( m_sourceView, i18n( "So&urce view" ) );
+ m_sourceView->setFont( KGlobalSettings::fixedFont() );
+
+ // Setup actions
+ connect( m_searchBar, SIGNAL( onlineSearch() ), this, SLOT( onlineSearch() ) );
+ connect( m_searchBar, SIGNAL( doSearch( const QString&, BibTeX::Element::FilterType, BibTeX::EntryField::FieldType ) ), m_listViewElements, SLOT( filter( const QString&, BibTeX::Element::FilterType, BibTeX::EntryField::FieldType ) ) );
+ connect( m_listViewElements, SIGNAL( executed( DocumentListViewItem* ) ), this, SLOT( executeElement( DocumentListViewItem* ) ) );
+ connect( m_listViewElements, SIGNAL( selectionChanged() ), this, SLOT( slotSelectionChanged() ) );
+ connect( m_listViewElements, SIGNAL( currentChanged( QListViewItem* ) ), this, SLOT( slotPreviewElement( QListViewItem* ) ) );
+ connect( m_listViewElements, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( slotPreviewElement( QListViewItem* ) ) );
+ connect( this, SIGNAL( currentChanged( QWidget * ) ), this, SLOT( slotTabChanged( QWidget* ) ) );
+ connect( m_sourceView, SIGNAL( modified() ), this, SLOT( slotModified() ) );
+ connect( m_listViewElements, SIGNAL( modified() ), this, SLOT( slotModified() ) );
+ connect( m_sideBar, SIGNAL( valueRenamed() ), this, SLOT( slotModified() ) );
+ connect( m_sideBar, SIGNAL( valueRenamed() ), this, SLOT( refreshBibTeXFile() ) );
+ connect( m_sideBar, SIGNAL( selected( const QString&, BibTeX::Element::FilterType, BibTeX::EntryField::FieldType ) ), m_searchBar, SLOT( setSearch( const QString&, BibTeX::Element::FilterType, BibTeX::EntryField::FieldType ) ) );
+ connect( &m_dirWatch, SIGNAL( dirty( const QString& ) ), this, SLOT( slotFileGotDirty( const QString & ) ) );
+ }
+
+
+ bool DocumentWidget::open( const QString &fileName, bool mergeOnly )
+ {
+ bool result = FALSE;
+ if ( !mergeOnly )
+ m_dirWatch.removeFile( m_filename );
+
+ BibTeX::FileImporter *importer = fileImporterFactory( fileName );
+ if ( importer != NULL )
+ {
+ QFile file( fileName );
+ if ( file.open( IO_ReadOnly ) )
+ {
+ result = open( &file, mergeOnly, QString( i18n( "<qt>Loading file <b>%1</b></qt>" ) ).arg( fileName ), importer );
+ if ( result )
+ {
+ m_bibtexfile->fileName = fileName;
+ m_filename = fileName;
+ }
+ file.close();
+ }
+ else
+ kdDebug() << "Cannot open file " << fileName << endl;
+
+ delete importer;
+ }
+
+
+ if ( !mergeOnly )
+ m_dirWatch.addFile( m_filename );
+
+ return result;
+ }
+
+ bool DocumentWidget::open( QIODevice *iodevice, bool mergeOnly, const QString &label, BibTeX::FileImporter *importer )
+ {
+ bool result = FALSE;
+ setEnabled( FALSE );
+
+ bool usingDefaultImporter = importer == NULL;
+ if ( usingDefaultImporter )
+ {
+ Settings * settings = Settings::self( NULL );
+ importer = new BibTeX::FileImporterBibTeX( settings->editing_FirstNameFirst, settings->fileIO_Encoding );
+ }
+
+ startProgress( label, importer );
+ BibTeX::File *newFile = importer->load( iodevice );
+ endProgress( importer );
+
+ if ( usingDefaultImporter )
+ delete importer;
+
+ if ( newFile != NULL )
+ {
+ if ( mergeOnly )
+ {
+ for ( QValueList<BibTeX::Element*>::ConstIterator eit = newFile->constBegin(); eit != newFile->constEnd(); ++eit )
+ m_bibtexfile->appendElement(( *eit )->clone() );
+
+ if ( KMessageBox::questionYesNo( this, i18n( "Do you want to search for duplicates in the merged document?" ), i18n( "Find duplicates?" ), KGuiItem( i18n( "Find Duplicates" ) ) ) == KMessageBox::Yes )
+ {
+ MergeElements *me = new MergeElements( this );
+ me->mergeDuplicates( m_bibtexfile );
+ delete me;
+ }
+ delete newFile;
+ }
+ else
+ {
+ delete m_bibtexfile;
+ m_bibtexfile = newFile;
+ }
+
+ if ( currentPage() == m_sourceView )
+ m_sourceView->setBibTeXFile( m_bibtexfile );
+ else if ( currentPage() == m_container )
+ m_listViewElements->setBibTeXFile( m_bibtexfile );
+
+ Settings * settings = Settings::self( m_bibtexfile );
+ settings->addToCompletion( m_bibtexfile );
+ m_sideBar->refreshLists( m_bibtexfile );
+
+ result = TRUE;
+ }
+ else
+ {
+ kdDebug() << "Could not load bibliography file from io device" << endl;
+ result = FALSE;
+ }
+
+ setEnabled( TRUE );
+ return result;
+ }
+
+ bool DocumentWidget::save( const QString &fileName, QStringList *errorLog )
+ {
+ bool result = FALSE;
+ m_dirWatch.removeFile( m_filename );
+ Settings * settings = Settings::self( NULL );
+
+ BibTeX::File::FileFormat format = BibTeX::File::formatUndefined;
+ if ( fileName.endsWith( ".rtf", FALSE ) )
+ format = BibTeX::File::formatRTF;
+ else if ( fileName.endsWith( ".pdf", FALSE ) )
+ format = BibTeX::File::formatPDF;
+ else if ( fileName.endsWith( ".bib", FALSE ) )
+ format = BibTeX::File::formatBibTeX;
+ else if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && ( fileName.endsWith( ".ref", FALSE ) || fileName.endsWith( ".refer", FALSE ) || fileName.endsWith( ".txt", FALSE ) || fileName.endsWith( ".rfr", FALSE ) ) )
+ format = BibTeX::File::formatEndNote;
+ else if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && ( fileName.endsWith( ".isi", FALSE ) || fileName.endsWith( ".cgi", FALSE ) ) )
+ format = BibTeX::File::formatISI;
+ else if ( fileName.endsWith( ".ris", FALSE ) )
+ format = BibTeX::File::formatRIS;
+ else if ( fileName.endsWith( ".ps", FALSE ) )
+ format = BibTeX::File::formatPS;
+ else if ( fileName.endsWith( ".xml", FALSE ) )
+ {
+ QStringList options = QStringList::split( '|', ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable ? "DocBook5|MODS|internal XML" : "DocBook5|internal XML" ) );
+ bool ok = false;
+ QString answer = KInputDialog::getItem( i18n( "Choose file format" ), QString( i18n( "Choose file format of file '%1':" ) ).arg( fileName ), options, 0, false, &ok, this );
+ if ( ok && !answer.isNull() && answer == "DocBook5" )
+ format = BibTeX::File::formatDocBook5;
+ else if ( ok && !answer.isNull() && answer == "MODS" )
+ format = BibTeX::File::formatMODS;
+ else if ( ok && !answer.isNull() && answer == "internal XML" )
+ format = BibTeX::File::formatXML;
+ }
+ else if ( fileName.endsWith( ".html", FALSE ) || fileName.endsWith( ".xhtml", FALSE ) || fileName.endsWith( ".htm", FALSE ) )
+ format = BibTeX::File::formatHTML;
+
+ if ( format != BibTeX::File::formatUndefined )
+ {
+ QString usedFileName = fileName;
+ QFileInfo fi( fileName );
+ if ( !fi.readLink().isNull() && KMessageBox::questionYesNo( this, QString( i18n( "The selected filename \"%1\" is a symbolic link pointing to \"%2\".\nReplace the link with a new file or overwrite the existing file the link points to?" ) ).arg( usedFileName ).arg( Settings::resolveLink( fileName, fi.readLink() ) ), i18n( "Symbolic Link" ), KGuiItem( i18n( "Replace link" ) ), KGuiItem( i18n( "Overwrite file the link points to" ) ) ) == KMessageBox::No )
+ usedFileName = Settings::resolveLink( fileName, fi.readLink() );
+ QFile file( usedFileName );
+ if ( file.open( IO_WriteOnly ) )
+ {
+ result = save( &file, format, QString( i18n( "<qt>Writing file <b>%1</b></qt>" ) ).arg( fileName ), errorLog );
+ if ( result )
+ {
+ m_bibtexfile->fileName = fileName;
+ m_filename = fileName;
+ }
+ file.close();
+ }
+ else
+ kdDebug() << "Cannot write to file " << fileName << endl;
+ }
+ else
+ kdDebug() << "Unknown file format to save to (filename is " << fileName << ")" << endl;
+
+ m_dirWatch.addFile( m_filename );
+ return result;
+ }
+
+ bool DocumentWidget::save( QIODevice *iodevice, BibTeX::File::FileFormat format, const QString &label, QStringList *errorLog )
+ {
+ Settings * settings = Settings::self( m_bibtexfile );
+
+ bool result = FALSE;
+ setEnabled( FALSE );
+
+ updateFromGUI();
+
+ BibTeX::XSLTransform *transform = NULL;
+
+ BibTeX::FileExporter * exporter = NULL;
+ switch ( format )
+ {
+ case BibTeX::File::formatBibTeX:
+ {
+ BibTeX::FileExporterBibTeX * bibtexExporter = new BibTeX::FileExporterBibTeX();
+ bibtexExporter->setStringDelimiter( settings->fileIO_BibtexStringOpenDelimiter, settings->fileIO_BibtexStringCloseDelimiter );
+ bibtexExporter->setKeywordCasing( settings->fileIO_KeywordCasing );
+ bibtexExporter->setEncoding( settings->fileIO_Encoding );
+ bibtexExporter->setEnclosingCurlyBrackets( settings->fileIO_EnclosingCurlyBrackets );
+ exporter = bibtexExporter;
+ }
+ break;
+ case BibTeX::File::formatRIS:
+ if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && settings->fileIO_useBibUtils )
+ exporter = new BibTeX::FileExporterBibUtils( BibTeX::File::formatRIS );
+ else
+ exporter = new BibTeX::FileExporterRIS( );
+ break;
+ case BibTeX::File::formatEndNote:
+ case BibTeX::File::formatEndNoteXML:
+ case BibTeX::File::formatMODS:
+ case BibTeX::File::formatISI:
+ if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable )
+ exporter = new BibTeX::FileExporterBibUtils( format );
+ break;
+ case BibTeX::File::formatXML:
+ exporter = new BibTeX::FileExporterXML();
+ break;
+ case BibTeX::File::formatHTML:
+ switch ( settings->fileIO_ExporterHTML )
+ {
+ case BibTeX::FileExporterExternal::exporterNone:
+ case BibTeX::FileExporterExternal::exporterXSLT:
+ {
+ KStandardDirs * kstd = KGlobal::dirs();
+ QString resPath = kstd->findResource( "data", "kbibtexpart/xslt/html.xsl" );
+ if ( resPath != NULL )
+ transform = new BibTeX::XSLTransform( resPath );
+
+ if ( transform != NULL )
+ exporter = new BibTeX::FileExporterXSLT( transform );
+ else
+ {
+ kdDebug() << "XSLT for HTML export is not available" << endl;
+ }
+ }
+ break;
+ default:
+ {
+ exporter = new BibTeX::FileExporterExternal( settings->fileIO_ExporterHTML, BibTeX::File::formatHTML );
+ }
+ }
+ break;
+ case BibTeX::File::formatRTF:
+ {
+ if ( !settings->external_latex2rtfAvailable )
+ {
+ QString msg = i18n( "To export a BibTeX document to the Rich Text Format (RTF) KBibTeX requires the program 'latex2rtf'." ) ;
+ KMessageBox::information( this, msg );
+ errorLog->append( msg );
+ }
+ else
+ {
+ BibTeX::FileExporterRTF *rtfExporter = new BibTeX::FileExporterRTF();
+ rtfExporter->setLaTeXLanguage( settings->fileIO_ExportLanguage );
+ rtfExporter->setLaTeXBibliographyStyle( settings->fileIO_ExportBibliographyStyle );
+ exporter = rtfExporter;
+ }
+ }
+ break;
+ case BibTeX::File::formatDocBook5:
+ {
+ if ( settings->fileIO_bib2db5ClassPath == QString::null )
+ {
+ QString msg = i18n( "To export a BibTeX document to the DocBook5 format KBibTeX requires the program 'bib2db5'." ) ;
+ KMessageBox::information( this, msg );
+ errorLog->append( msg );
+ }
+ else
+ {
+ BibTeX::FileExporterDocBook5 *db5Exporter = new BibTeX::FileExporterDocBook5( settings->fileIO_bib2db5ClassPath );
+ exporter = db5Exporter;
+ }
+ }
+ break;
+ case BibTeX::File::formatPDF:
+ {
+ if ( settings->fileIO_EmbedFiles && !Settings::kpsewhich( "embedfile.sty" ) )
+ {
+ KMessageBox::sorry( this, i18n( "Embedding files into the PDF file is enabled, but the required file 'embedfile.sty' was not found. Embedding files will be disabled." ), i18n( "Embedding files disabled" ) );
+ settings->fileIO_EmbedFiles = FALSE;
+ }
+
+ BibTeX::FileExporterPDF *pdfExporter = new BibTeX::FileExporterPDF( settings->fileIO_EmbedFiles );
+ pdfExporter->setLaTeXLanguage( settings->fileIO_ExportLanguage );
+ pdfExporter->setLaTeXBibliographyStyle( settings->fileIO_ExportBibliographyStyle );
+ QStringList searchPaths;
+ for ( QStringList::Iterator it = settings->editing_DocumentSearchPaths.begin(); it != settings->editing_DocumentSearchPaths.end(); ++it )
+ searchPaths.append( *it );
+ if ( m_bibtexfile->fileName != QString::null )
+ searchPaths.append( KURL( m_bibtexfile->fileName ).directory( FALSE, FALSE ) );
+ pdfExporter->setDocumentSearchPaths( searchPaths );
+ exporter = pdfExporter;
+ }
+ break;
+ case BibTeX::File::formatPS:
+ {
+ BibTeX::FileExporterPS *psExporter = new BibTeX::FileExporterPS();
+ psExporter->setLaTeXLanguage( settings->fileIO_ExportLanguage );
+ psExporter->setLaTeXBibliographyStyle( settings->fileIO_ExportBibliographyStyle );
+ exporter = psExporter;
+ }
+ break;
+ default:
+ kdDebug() << "Unsupported export format selected" << endl;
+ }
+
+ if ( exporter != NULL )
+ {
+ startProgress( label, exporter );
+ result = exporter->save( iodevice, m_bibtexfile, errorLog );
+ endProgress( exporter );
+
+ if ( transform != NULL )
+ delete transform;
+ delete exporter;
+ }
+
+ setEnabled( TRUE );
+ return result;
+ }
+
+ bool DocumentWidget::newElement( const QString& elementType )
+ {
+ Settings * settings = Settings::self( m_bibtexfile );
+
+ if ( m_editMode == emList )
+ {
+ if ( elementType.lower() == "macro" )
+ {
+ QString name = QString( i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewMacro%1" ) ).arg( m_newElementCounter++ );
+ BibTeX::Macro *macro = new BibTeX::Macro( name );
+ if ( MacroWidget::execute( macro, m_isReadOnly ) == QDialog::Accepted )
+ {
+ new DocumentListViewItem( m_bibtexfile, macro, m_listViewElements );
+ m_bibtexfile->appendElement( macro );
+ settings->addToCompletion( macro );
+ m_sideBar->refreshLists( m_bibtexfile );
+ return TRUE;
+ }
+ else
+ {
+ delete macro;
+ return FALSE;
+ }
+ }
+ else if ( elementType.lower() == "comment" )
+ {
+ BibTeX::Comment * comment = new BibTeX::Comment( i18n( "Put your comment here..." ) );
+ if ( CommentWidget::execute( comment, m_isReadOnly ) == QDialog::Accepted )
+ {
+ new DocumentListViewItem( m_bibtexfile, comment, m_listViewElements );
+ m_bibtexfile->appendElement( comment );
+ return TRUE;
+ }
+ else
+ {
+ delete comment;
+ return FALSE;
+ }
+ }
+ else if ( elementType.lower() == "preamble" )
+ {
+ BibTeX::Preamble * preamble = new BibTeX::Preamble( );
+ if ( PreambleWidget::execute( preamble, m_isReadOnly ) == QDialog::Accepted )
+ {
+ new DocumentListViewItem( m_bibtexfile, preamble, m_listViewElements );
+ m_bibtexfile->appendElement( preamble );
+ return TRUE;
+ }
+ else
+ {
+ delete preamble;
+ return FALSE;
+ }
+ }
+ else
+ {
+ QString name = nextNewEntry();
+ BibTeX::Entry *entry = new BibTeX::Entry( elementType, name );
+ m_dirWatch.stopScan();
+ if ( EntryWidget::execute( entry, m_bibtexfile, m_isReadOnly, TRUE ) == QDialog::Accepted )
+ {
+ new DocumentListViewItem( m_bibtexfile, entry, m_listViewElements );
+ m_bibtexfile->appendElement( entry );
+ settings->addToCompletion( entry );
+ m_sideBar->refreshLists( m_bibtexfile );
+ m_dirWatch.startScan();
+ return TRUE;
+ }
+ else
+ {
+ delete entry;
+ m_dirWatch.startScan();
+ return FALSE;
+ }
+ }
+ }
+ else if ( m_editMode == emSource )
+ {
+ if ( elementType.lower() == "macro" )
+ {
+ QString name = QString( i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewString%1" ) ).arg( m_newElementCounter++ );
+ m_sourceView->insertLines( QString( "@string{ %1 = \"%2\" }" ).arg( name ).arg( i18n( "No text yet" ) ) );
+ }
+ else if ( elementType.lower() == "comment" )
+ {
+ m_sourceView->insertLines( i18n( "@comment{ Put your comment here... }" ) );
+ }
+ else if ( elementType.lower() == "preamble" )
+ {
+ m_sourceView->insertLines( i18n( "@preamble{\"Put your preamble here using double quotes...\"}" ), 0 );
+ }
+ else
+ {
+ QString name = nextNewEntry();
+ BibTeX::Entry *entry = new BibTeX::Entry( elementType, name );
+
+ for ( int t = 0; t < 2; t++ )
+ for ( int i = ( int ) BibTeX::EntryField::ftAbstract; i <= ( int ) BibTeX::EntryField::ftYear; i++ )
+ {
+ BibTeX::EntryField::FieldType fieldType = ( BibTeX::EntryField::FieldType ) i;
+ BibTeX::Entry::FieldRequireStatus fieldRequireStatus = BibTeX::Entry::getRequireStatus( entry->entryType(), fieldType );
+
+ if (( t == 0 && fieldRequireStatus == BibTeX::Entry::frsRequired ) || ( t == 1 && fieldRequireStatus == BibTeX::Entry::frsOptional ) )
+ {
+ BibTeX::Value * value = new BibTeX::Value();
+ value->items.append( new BibTeX::PlainText( fieldRequireStatus == BibTeX::Entry::frsRequired ? i18n( "REQUIRED" ) : i18n( "optional" ) ) );
+ BibTeX::EntryField *field = new BibTeX::EntryField( fieldType );
+ field->setValue( value );
+ entry->addField( field );
+ }
+ }
+
+ BibTeX::FileExporter * exporter = new BibTeX::FileExporterBibTeX( );
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ bool result = exporter->save( &buffer, entry );
+ buffer.close();
+
+ if ( result )
+ {
+ buffer.open( IO_ReadOnly );
+ QTextStream textStream( &buffer );
+ textStream.setEncoding( QTextStream::UnicodeUTF8 );
+ QString text = textStream.read();
+ buffer.close();
+ QStringList lines = QStringList::split( '\n', text );
+ for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
+ m_sourceView->insertLines( *it );
+ }
+
+ delete exporter;
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ void DocumentWidget::updateViews()
+ {
+ m_listViewElements->updateVisiblity();
+ }
+
+ void DocumentWidget::showStatistics()
+ {
+ int n = m_bibtexfile->count();
+ KMessageBox::information( this, i18n( "This BibTeX file contains 1 element.", "This BibTeX file contains %n elements.", n ), i18n( "File Statistics" ) );
+ }
+
+ void DocumentWidget::refreshBibTeXFile()
+ {
+ if ( currentPage() == m_sourceView )
+ m_sourceView->setBibTeXFile( m_bibtexfile );
+ else if ( currentPage() == m_container )
+ m_listViewElements->setBibTeXFile( m_bibtexfile );
+ }
+
+ void DocumentWidget::setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client )
+ {
+ m_searchBar->setFactory( factory, client );
+ m_listViewElements->setFactory( factory, client );
+ m_sourceView->setFactory( factory, client );
+
+ m_viewDocumentActionMenu = dynamic_cast<KActionMenu*>( client->action( "view_document" ) );
+ if ( m_viewDocumentActionMenu != NULL )
+ connect( m_viewDocumentActionMenu->popupMenu(), SIGNAL( activated( int ) ), this, SLOT( slotViewDocument( int ) ) );
+ m_assignKeywordsActionMenu = dynamic_cast<KActionMenu*>( client->action( "assign_keywords" ) );
+ if ( m_assignKeywordsActionMenu != NULL )
+ connect( m_assignKeywordsActionMenu->popupMenu(), SIGNAL( activated( int ) ), this, SLOT( slotAssignKeywords( int ) ) );
+
+ m_actionEditCut = client->action( "edit_cut" );
+ m_actionEditCopy = client->action( "edit_copy" );
+ m_actionEditCopyRef = client->action( "edit_copyref" );
+ m_actionEditPaste = client->action( "edit_paste" );
+ m_actionEditSelectAll = client->action( "edit_select_all" );
+ m_actionEditFind = client->action( "edit_find" );
+ m_actionEditFindNext = client->action( "edit_find_next" );
+ m_listViewElements->setViewShowColumnsMenu( dynamic_cast<KActionMenu*>( client->action( "view_showcolumns" ) ) );
+ m_searchWebsitesActionMenu = dynamic_cast<KActionMenu*>( client->action( "search_document_online" ) );
+ }
+
+ void DocumentWidget::updateViewDocumentMenu( )
+ {
+ if ( m_viewDocumentActionMenu == NULL )
+ {
+ kdDebug() << "FIXME: m_viewDocumentActionMenu is not set" << endl;
+ return;
+ }
+
+ KPopupMenu * popup = m_viewDocumentActionMenu->popupMenu();
+ popup->clear();
+ m_viewDocumentActionMenuURLs.clear();
+
+ BibTeX::Element * currentElement = NULL;
+
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( item == NULL )
+ item = m_listViewElements->currentItem();
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( item );
+ if ( dlvi )
+ currentElement = dlvi->element();
+
+ BibTeX::Entry *entry = NULL;
+ if ( currentElement != NULL )
+ entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+
+ m_viewDocumentActionMenu->setEnabled( FALSE );
+ if ( entry != NULL )
+ {
+ KURL::List documentURLs = getEntryURLs( entry );
+ if ( !documentURLs.isEmpty() )
+ {
+ for ( KURL::List::Iterator i = documentURLs.begin(); i != documentURLs.end(); ++i )
+ {
+ QString prettyURL = ( *i ).prettyURL();
+ if ( prettyURL.endsWith( ".pdf", FALSE ) || prettyURL.find( "/pdf/" ) > 0 )
+ popup->insertItem( SmallIcon( "pdf" ), prettyURL );
+ else if ( prettyURL.endsWith( ".ps", FALSE ) )
+ popup->insertItem( SmallIcon( "postscript" ), prettyURL );
+ else if ( prettyURL.endsWith( ".html", FALSE ) || prettyURL.startsWith( "http://", FALSE ) )
+ popup->insertItem( SmallIcon( "html" ), prettyURL );
+ else
+ popup->insertItem( prettyURL );
+ m_viewDocumentActionMenuURLs.append( prettyURL );
+ }
+ m_viewDocumentActionMenu->setEnabled( TRUE );
+ }
+ }
+ }
+
+ void DocumentWidget::updateAssignKeywords()
+ {
+ if ( m_assignKeywordsActionMenu == NULL )
+ {
+ kdDebug() << "FIXME: m_assignKeywordsActionMenu is not set" << endl;
+ return;
+ }
+
+ KPopupMenu * popup = m_assignKeywordsActionMenu->popupMenu();
+ popup->clear();
+ m_assignKeywordsActionMenuURLs.clear();
+ QStringList entryKeywords;
+ QStringList fileKeywords;
+
+ /**
+ * Fetch keywords from selected entries into entryKeywords list
+ */
+ QValueList<BibTeX::Entry*> entryList;
+ for ( QListViewItemIterator it( m_listViewElements, QListViewItemIterator::Selected ); it.current(); ++it )
+ {
+ BibTeX::Element * currentElement = NULL;
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ if ( dlvi && (( currentElement = dlvi->element() ) != NULL ) )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+ if ( entry != NULL )
+ entryList << entry;
+ }
+ }
+
+ for ( QValueList<BibTeX::Entry*>::Iterator it = entryList.begin(); it != entryList.end(); ++it )
+ {
+ BibTeX::Entry *entry = *it;
+ BibTeX::EntryField *field = NULL;
+ BibTeX::Value *valueKeywords = NULL;
+ if (( field = entry->getField( BibTeX::EntryField::ftKeywords ) ) != NULL && ( valueKeywords = field->value() ) != NULL )
+ for ( QValueList<BibTeX::ValueItem*>::ConstIterator it = valueKeywords->items.begin();it != valueKeywords->items.end();++it )
+ {
+ BibTeX::KeywordContainer *container = dynamic_cast<BibTeX::KeywordContainer*>( *it );
+ if ( container != NULL )
+ for ( QValueList<BibTeX::Keyword*>::ConstIterator kit = container->keywords.begin();kit != container->keywords.end();++kit )
+ entryKeywords.append(( *kit )->text() );
+ }
+ }
+
+ /**
+ * Fetch all keywords from current file into fileKeywords
+ */
+ for ( QValueList<BibTeX::Element*>::ConstIterator eit = m_bibtexfile->constBegin(); eit != m_bibtexfile->constEnd(); ++eit )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( *eit );
+ BibTeX::EntryField *field = NULL;
+ BibTeX::Value *value = NULL;
+ if ( entry != NULL && (( field = entry->getField( BibTeX::EntryField::ftKeywords ) ) != NULL ) && (( value = field->value() ) != NULL ) )
+ {
+ for ( QValueList<BibTeX::ValueItem*>::ConstIterator vit = value->items.constBegin(); vit != value->items.constEnd();++vit )
+ {
+ BibTeX::KeywordContainer *container = dynamic_cast<BibTeX::KeywordContainer *>( *vit );
+ for ( QValueList<BibTeX::Keyword*>::ConstIterator kit = container->keywords.constBegin(); kit != container->keywords.constEnd();++kit )
+ {
+ QString text = ( *kit )->text();
+ if ( !fileKeywords.contains( text ) )
+ fileKeywords.append( text );
+ }
+ }
+ }
+ }
+
+ /**
+ * Merge keyword lists
+ */
+ Settings * settings = Settings::self( m_bibtexfile );
+ QStringList allKeywords = QStringList( fileKeywords );
+ for ( QStringList::Iterator it = settings->keyword_GlobalList.begin(); it != settings->keyword_GlobalList.end(); ++it )
+ if ( !allKeywords.contains( *it ) )
+ allKeywords.append( *it );
+ allKeywords.sort();
+
+ /**
+ * Build menu
+ */
+ bool popupEmpty = FALSE;
+ if ( allKeywords.isEmpty() )
+ popupEmpty = TRUE;
+ else if ( allKeywords.count() < 24 )
+ {
+ for ( QStringList::Iterator it = allKeywords.begin(); it != allKeywords.end(); ++it )
+ {
+ int i = popup->insertItem( *it );
+ popup->setItemChecked( i, entryKeywords.contains( *it ) );
+ m_assignKeywordsActionMenuURLs[i] = *it;
+ }
+ }
+ else
+ {
+ int maxCountPerSubMenu = ( int )sqrt( allKeywords.count() ) + 1;
+ int countPerSubMenu = 0;
+ KPopupMenu *subMenu = new KPopupMenu( popup );
+ connect( subMenu, SIGNAL( activated( int ) ), this, SLOT( slotAssignKeywords( int ) ) );
+ QString startWord, endWord;
+ for ( QStringList::Iterator it = allKeywords.begin(); it != allKeywords.end(); ++it )
+ {
+ if ( countPerSubMenu == 0 )
+ startWord = *it;
+ endWord = *it;
+ int i = subMenu->insertItem( *it );
+ subMenu->setItemChecked( i, entryKeywords.contains( *it ) );
+ m_assignKeywordsActionMenuURLs[i] = *it;
+
+ ++countPerSubMenu;
+ if ( countPerSubMenu >= maxCountPerSubMenu )
+ {
+ popup->insertItem( QString( i18n( "%1 ... %2" ) ).arg( startWord ).arg( endWord ), subMenu );
+ subMenu = new KPopupMenu( popup );
+ connect( subMenu, SIGNAL( activated( int ) ), this, SLOT( slotAssignKeywords( int ) ) );
+ countPerSubMenu = 0;
+ }
+ }
+
+ if ( countPerSubMenu > 0 )
+ {
+ popup->insertItem( QString( i18n( "%1 ... %2" ) ).arg( startWord ).arg( endWord ), subMenu );
+ }
+ else
+ delete subMenu;
+ }
+
+ if ( !popupEmpty )
+ popup->insertSeparator();
+
+ QWidget *container = new QWidget( popup );
+ container->setBackgroundColor( KGlobalSettings::baseColor() );
+ QHBoxLayout *layout = new QHBoxLayout( container, 1, 1 );
+ QLabel *label = new QLabel( i18n( "New keyword:" ), container );
+ label->setBackgroundColor( KGlobalSettings::baseColor() );
+ layout->addWidget( label );
+ m_lineEditNewKeyword = new KLineEdit( container );
+ layout->addWidget( m_lineEditNewKeyword );
+ container->setFocusProxy( m_lineEditNewKeyword );
+ container->setFocusPolicy( QWidget::ClickFocus );
+ popup->insertItem( container );
+
+ connect( m_lineEditNewKeyword, SIGNAL( returnPressed() ), this, SLOT( slotAddKeyword() ) );
+ }
+
+ void DocumentWidget::deferredInitialization()
+ {
+ restoreState();
+ m_listViewElements->deferredInitialization();
+ }
+
+ void DocumentWidget::saveState()
+ {
+ Settings * settings = Settings::self( m_bibtexfile );
+ settings->editing_HorSplitterSizes = m_horSplitter->sizes();
+ settings->editing_VertSplitterSizes = m_vertSplitter->sizes();
+ }
+
+ void DocumentWidget::restoreState()
+ {
+ m_listViewElements->restoreState();
+ m_searchBar->restoreState();
+ m_sideBar->restoreState();
+
+ Settings * settings = Settings::self( m_bibtexfile );
+ m_horSplitter->setSizes( settings->editing_HorSplitterSizes );
+ m_vertSplitter->setSizes( settings->editing_VertSplitterSizes );
+
+ if ( m_searchWebsitesActionMenu != NULL )
+ {
+ KPopupMenu * popup = m_searchWebsitesActionMenu->popupMenu();
+ popup->clear();
+ int i = 0;
+ for ( QValueList<Settings::SearchURL*>::ConstIterator it = settings->searchURLs.begin(); it != settings->searchURLs.end(); ++it )
+ popup->insertItem(( *it ) ->description, ++i );
+ }
+
+ if ( settings->editing_UseSpecialFont )
+ m_preview->setFont( settings->editing_SpecialFont );
+ else
+ m_preview->setFont( KGlobalSettings::generalFont() );
+
+ }
+
+ void DocumentWidget::executeElement( DocumentListViewItem* item )
+ {
+ Settings * settings = Settings::self( m_bibtexfile );
+ bool openingDocumentOK = FALSE;
+
+ if ( settings->editing_MainListDoubleClickAction == 1 )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( item->element() );
+ if ( entry != NULL )
+ {
+ /** prefer local urls over remote urls, so first check for file:// and use other protocols only if no file:// was found */
+ QString protocol = "file";
+ KURL::List urls = getEntryURLs( entry );
+ KURL selected = KURL();
+ while ( !selected.isValid() && protocol != QString::null )
+ {
+ for ( KURL::List::Iterator it = urls.begin(); !selected.isValid() && it != urls.end(); ++it )
+ {
+ KURL url = *it;
+ if ( url.isValid() && ( !url.isLocalFile() || QFile::exists( url.path() ) ) && url.protocol().startsWith( protocol ) )
+ selected = url;
+ }
+ /** little trick setting protocol prefix in the first round to "file://", then to "", and setting to null to quit the loop */
+ if ( !protocol.isEmpty() ) protocol = "";
+ else protocol = QString::null;
+ }
+
+ if ( selected.isValid() )
+ openingDocumentOK = Settings::openUrl( selected, this );
+ }
+ }
+
+ if ( !openingDocumentOK )
+ editElement( item );
+ }
+
+ bool DocumentWidget::editElement()
+ {
+ bool result = false;
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( item == NULL )
+ item = m_listViewElements->currentItem();
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( item );
+ if ( dlvi )
+ result = editElement( dlvi );
+ return result;
+ }
+
+ bool DocumentWidget::editElement( DocumentListViewItem*item )
+ {
+ BibTeX::Element * element = item->element();
+ bool result = editElement( element );
+ if ( result )
+ {
+ item->updateItem();
+ slotPreviewElement( item );
+ }
+ return result;
+ }
+
+ bool DocumentWidget::editElement( BibTeX::Element*element )
+ {
+ m_dirWatch.stopScan();
+ bool result = editElementDialog( element );
+ m_dirWatch.startScan( );
+
+ Settings * settings = Settings::self( m_bibtexfile );
+ settings->addToCompletion( element );
+ m_sideBar->refreshLists( m_bibtexfile );
+
+ return result;
+ }
+
+ bool DocumentWidget::editElementDialog( BibTeX::Element *element )
+ {
+ QDialog::DialogCode dialogResult = QDialog::Rejected;
+ BibTeX::Entry * entry = dynamic_cast<BibTeX::Entry*>( element );
+ if ( entry )
+ dialogResult = KBibTeX::EntryWidget::execute( entry, m_bibtexfile, m_isReadOnly, FALSE );
+ else
+ {
+ BibTeX::Comment * comment = dynamic_cast<BibTeX::Comment*>( element );
+ if ( comment )
+ dialogResult = KBibTeX::CommentWidget::execute( comment, m_isReadOnly );
+ else
+ {
+ BibTeX::Macro* macro = dynamic_cast<BibTeX::Macro*>( element );
+ if ( macro )
+ dialogResult = KBibTeX::MacroWidget::execute( macro, m_isReadOnly );
+ else
+ {
+ BibTeX::Preamble* preamble = dynamic_cast<BibTeX::Preamble*>( element );
+ if ( preamble )
+ dialogResult = KBibTeX::PreambleWidget::execute( preamble, m_isReadOnly );
+ }
+ }
+ }
+
+ if ( dialogResult == QDialog::Accepted )
+ slotModified();
+
+ return dialogResult == QDialog::Accepted;
+ }
+
+ void DocumentWidget::deleteElements()
+ {
+ if ( !m_isReadOnly )
+ {
+ if ( m_editMode == emList )
+ {
+ m_listViewElements->deleteSelected();
+ slotModified();
+ }
+ }
+ }
+
+ void DocumentWidget::sendSelectedToLyx()
+ {
+ if ( m_editMode == emList )
+ {
+ QValueList<BibTeX::Element*> elements = m_listViewElements->selectedItems();
+ QString genericMsg = i18n( "\n\nEither LyX is not running or has not been correctly configured to send references to." );
+ QString title = i18n( "Error communicating with LyX" );
+
+ Settings * settings = Settings::self( m_bibtexfile );
+ QString lyxPipeFilename = settings->detectLyXInPipe();
+ kdDebug() << "sendSelectedToLyx: lyxPipeFilename= " << lyxPipeFilename << endl;
+
+ if ( lyxPipeFilename.isNull() )
+ KMessageBox::error( this, i18n( "Cannot determine how to send references to LyX." ).append( genericMsg ), title );
+ else
+ {
+ QFile pipe( lyxPipeFilename );
+ if ( !pipe.exists() )
+ KMessageBox::error( this, i18n( "The inpipe as configured in LyX does not exist." ).append( genericMsg ), title );
+ else
+ {
+ if ( !pipe.open( IO_WriteOnly ) )
+ KMessageBox::error( this, i18n( "Cannot open the inpipe as configured in LyX." ).append( genericMsg ), title );
+ else
+ {
+ QStringList refsToSend;
+ for ( QValueList<BibTeX::Element*>::Iterator it = elements.begin(); it != elements.end(); ++it )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( *it );
+ if ( entry != NULL ) refsToSend.append( entry->id() );
+ }
+
+ QTextStream * writer = new QTextStream( &pipe );
+ QString msg = "LYXCMD:kbibtex:citation-insert:" + refsToSend.join( "," );
+ *writer << msg << endl;
+ delete writer;
+ pipe.close();
+ }
+ }
+ }
+ }
+ }
+
+ void DocumentWidget::cutElements()
+ {
+ if ( !m_isReadOnly )
+ {
+ if ( m_editMode == emList )
+ {
+ m_listViewElements->cut();
+ }
+ else if ( m_editMode == emSource )
+ {
+ m_sourceView->cut();
+ }
+ slotModified();
+ }
+ }
+
+ void DocumentWidget::copyElements()
+ {
+ if ( m_editMode == emList )
+ {
+ m_listViewElements->copy();
+ }
+ else if ( m_editMode == emSource )
+ {
+ m_sourceView->copy();
+ }
+ }
+
+ void DocumentWidget::copyRefElements()
+ {
+ if ( m_editMode == emList )
+ {
+ m_listViewElements->copyReferences();
+ }
+ else if ( m_editMode == emSource )
+ {
+// TODO: Get selected text, parse text into BibTeX::File and join list of entries' ids
+ }
+ }
+
+ void DocumentWidget::pasteElements()
+ {
+ if ( !m_isReadOnly )
+ {
+ if ( m_editMode == emList )
+ {
+ if ( m_listViewElements->paste() )
+ slotModified();
+ }
+ else if ( m_editMode == emSource )
+ {
+ if ( m_sourceView->paste() )
+ slotModified();
+ }
+ }
+ }
+
+ void DocumentWidget::selectAll()
+ {
+ if ( m_editMode == emList )
+ m_listViewElements->selectAll();
+ else if ( m_editMode == emSource )
+ m_sourceView->selectAll();
+ }
+
+ void DocumentWidget::setReadOnly( bool isReadOnly )
+ {
+ m_isReadOnly = isReadOnly;
+ m_listViewElements->setReadOnly( m_isReadOnly );
+ m_sourceView->setReadOnly( m_isReadOnly );
+ m_sideBar->setReadOnly( m_isReadOnly );
+ }
+
+ void DocumentWidget::configureEditor()
+ {
+ m_sourceView->configureEditor();
+ }
+
+ void DocumentWidget::undoEditor()
+ {
+ m_sourceView->undo();
+ }
+
+ void DocumentWidget::find()
+ {
+ if ( m_editMode == emSource )
+ m_sourceView->find();
+ }
+ void DocumentWidget::findNext()
+ {
+ if ( m_editMode == emSource )
+ m_sourceView->findNext();
+ }
+
+ void DocumentWidget::slotShowProgress( int current, int total )
+ {
+ if ( m_progressDialog != NULL )
+ {
+ m_progressDialog->setProgress( current, total );
+ qApp->processEvents();
+ }
+ }
+
+ void DocumentWidget::startProgress( const QString & label, QObject * progressFrom )
+ {
+ m_progressDialog = new QProgressDialog( this );
+ m_progressDialog->setLabelText( label );
+ connect( progressFrom, SIGNAL( progress( int, int ) ), this, SLOT( slotShowProgress( int, int ) ) );
+ connect( m_progressDialog, SIGNAL( canceled() ), progressFrom, SLOT( cancel( ) ) );
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ }
+
+ void DocumentWidget::endProgress( QObject * progressFrom )
+ {
+ disconnect( progressFrom, SIGNAL( progress( int, int ) ), this, SLOT( slotShowProgress( int, int ) ) );
+ disconnect( m_progressDialog, SIGNAL( canceled() ), progressFrom, SLOT( cancel( ) ) );
+ delete m_progressDialog;
+ m_progressDialog = NULL;
+ QApplication::restoreOverrideCursor();
+ }
+
+ void DocumentWidget::searchWebsites( const QString& searchURL, bool includeAuthor )
+ {
+ DocumentListViewItem * item = dynamic_cast<DocumentListViewItem*>( m_listViewElements->selectedItem() );
+ if ( item == NULL )
+ item = dynamic_cast<DocumentListViewItem*>( m_listViewElements->currentItem() );
+
+ if ( item != NULL )
+ searchWebsites( item->element(), searchURL, includeAuthor );
+ }
+
+ void DocumentWidget::searchWebsites( BibTeX::Element * element, const QString& searchURL, bool includeAuthor )
+ {
+ QString queryString = QString::null;
+
+ BibTeX::Entry* entry = dynamic_cast<BibTeX::Entry*>( element );
+ if ( entry != NULL )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftTitle );
+ if ( field && field->value() )
+ queryString = field->value() ->text();
+ if ( includeAuthor )
+ {
+ field = entry->getField( BibTeX::EntryField::ftAuthor );
+ if ( field && field->value() )
+ {
+ BibTeX::PersonContainer *personContainer = dynamic_cast<BibTeX::PersonContainer*>( field->value()->items.first() );
+ if ( personContainer != NULL )
+ {
+ QValueList<BibTeX::Person*> list = personContainer->persons;
+ for ( QValueList<BibTeX::Person*>::ConstIterator it = list.begin(); it != list.end(); ++it )
+ queryString = queryString.append( " " ).append(( *it )->lastName() );
+
+ }
+ }
+ }
+ }
+ else
+ {
+ BibTeX::Comment * comment = dynamic_cast<BibTeX::Comment*>( element );
+ if ( comment != NULL )
+ queryString = comment->text();
+ else
+ {
+ BibTeX::Macro * macro = dynamic_cast<BibTeX::Macro*>( element );
+ if ( macro != NULL && macro->value() )
+ queryString = macro->value() ->text();
+ else
+ kdDebug() << "Not yet supported" << endl;
+ }
+ }
+
+ if ( queryString != QString::null )
+ {
+ queryString = queryString.stripWhiteSpace().replace( '$', "" ).replace( "%", "%25" ).replace( "+", "%2B" ).replace( " ", "%20" ).replace( "#", "%23" ).replace( "&", "%26" ).replace( "?", "%3F" ).replace( '{', "" ).replace( '}', "" );
+ KURL url( QString( searchURL ).arg( queryString ) );
+ Settings::openUrl( url, this );
+ }
+ }
+
+ void DocumentWidget::onlineSearch()
+ {
+ if ( !m_isReadOnly )
+ {
+ BibTeX::FileExporter * exporter = new BibTeX::FileExporterBibTeX( );
+ QValueList<BibTeX::Entry*> list;
+ if ( WebQueryWizard::execute( this, list ) == QDialog::Accepted )
+ {
+ Settings * settings = Settings::self( m_bibtexfile );
+ for ( QValueList<BibTeX::Entry*>::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ ( *it )->setId( IdSuggestions::resolveConflict( m_bibtexfile, ( *it )->id() ) );
+ if ( m_editMode == emList )
+ m_listViewElements->insertItem( new BibTeX::Entry( *it ) );
+ else
+ {
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ bool result = exporter->save( &buffer, *it );
+ buffer.close();
+ if ( result )
+ {
+ buffer.open( IO_ReadOnly );
+ QTextStream textStream( &buffer );
+ textStream.setEncoding( QTextStream::UnicodeUTF8 );
+ QString text = textStream.read();
+ buffer.close();
+ QStringList lines = QStringList::split( '\n', text );
+ for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it )
+ m_sourceView->insertLines( *it );
+ m_sourceView->insertLines( "" );
+ }
+
+ }
+ settings->addToCompletion( *it );
+ }
+
+ slotModified();
+ }
+ delete exporter;
+ }
+ }
+
+ void DocumentWidget::findDuplicates()
+ {
+ MergeElements *me = new MergeElements( this );
+ if ( me->mergeDuplicates( m_bibtexfile ) == QDialog::Accepted )
+ {
+ refreshBibTeXFile();
+ slotModified();
+ }
+ delete me;
+ }
+
+ void DocumentWidget::updateFromGUI()
+ {
+ BibTeX::File * file = NULL;
+ if ( currentPage() == m_sourceView )
+ file = m_sourceView->getBibTeXFile();
+ else if ( currentPage() == m_container )
+ file = m_listViewElements->getBibTeXFile();
+
+ if ( file != NULL && file != m_bibtexfile )
+ {
+ delete m_bibtexfile;
+ m_bibtexfile = file;
+ }
+ }
+
+ QString DocumentWidget::nextNewEntry()
+ {
+ QString name = QString( i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewEntry%1" ) ).arg( m_newElementCounter++ );
+
+ while ( m_bibtexfile->containsKey( name ) != NULL )
+ {
+ ++m_newElementCounter;
+ name = QString( i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewEntry%1" ) ).arg( m_newElementCounter++ );
+ }
+
+ return name;
+ }
+
+ KURL::List DocumentWidget::getEntryURLs( BibTeX::Entry *entry )
+ {
+ QStringList urls = entry->urls();
+ KURL::List result;
+
+ for ( QStringList::Iterator it = urls.begin(); it != urls.end(); ++it )
+ {
+ KURL url = Settings::locateFile( *it, m_bibtexfile->fileName, this );
+ if ( url.isValid() )
+ result.append( url );
+ }
+
+ return result;
+ }
+
+ void DocumentWidget::slotSelectionChanged()
+ {
+ int numSelected = 0;
+ QListViewItemIterator it( m_listViewElements, QListViewItemIterator::Selected );
+ while ( it.current() && numSelected < 3 )
+ {
+ numSelected++;
+ it++;
+ }
+
+ emit listViewSelectionChanged( numSelected );
+ }
+
+ BibTeX::FileImporter *DocumentWidget::fileImporterFactory( const QString &fileName )
+ {
+ Settings * settings = Settings::self( NULL );
+ BibTeX::FileImporter * importer = NULL;
+ BibTeX::File::FileFormat format = BibTeX::File::formatUndefined;
+
+ if ( fileName.endsWith( ".bib", FALSE ) )
+ format = BibTeX::File::formatBibTeX;
+ else if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && ( fileName.endsWith( ".ref", FALSE ) || fileName.endsWith( ".refer", FALSE ) || fileName.endsWith( ".txt", FALSE ) || fileName.endsWith( ".rfr", FALSE ) ) )
+ format = BibTeX::File::formatEndNote;
+ else if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && ( fileName.endsWith( ".isi", FALSE ) || fileName.endsWith( ".cgi", FALSE ) ) )
+ format = BibTeX::File::formatISI;
+ else if ( fileName.endsWith( ".ris", FALSE ) )
+ format = BibTeX::File::formatRIS;
+ else if ( fileName.endsWith( ".xml", FALSE ) )
+ {
+ QStringList options = QStringList::split( '|', ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable ? "MODS|EndNote XML|internal XML" : "internal XML" ) );
+ bool ok = false;
+ QString answer = KInputDialog::getItem( i18n( "Choose file format" ), QString( i18n( "Choose file format of file '%1':" ) ).arg( fileName ), options, 0, false, &ok, this );
+ if ( ok && !answer.isNull() && answer == "DocBook5" )
+ format = BibTeX::File::formatDocBook5;
+ else if ( ok && !answer.isNull() && answer == "MODS" )
+ format = BibTeX::File::formatMODS;
+ else if ( ok && !answer.isNull() && answer == "EndNote XML" )
+ format = BibTeX::File::formatEndNoteXML;
+ else if ( ok && !answer.isNull() && answer == "internal XML" )
+ format = BibTeX::File::formatXML;
+ }
+ else
+ {
+ QStringList options = QStringList::split( '|', ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable ? "BibTeX|EndNote|ISI|RIS" : "BibTeX|RIS" ) );
+ bool ok = false;
+ QString answer = KInputDialog::getItem( i18n( "Choose file format" ), QString( i18n( "Choose file format of file '%1':" ) ).arg( fileName ), options, 0, false, &ok, this );
+ if ( ok && !answer.isNull() && answer == "BibTeX" )
+ format = BibTeX::File::formatBibTeX;
+ else if ( ok && !answer.isNull() && answer == "EndNote" )
+ format = BibTeX::File::formatEndNote;
+ else if ( ok && !answer.isNull() && answer == "ISI" )
+ format = BibTeX::File::formatISI;
+ else if ( ok && !answer.isNull() && answer == "RIS" )
+ format = BibTeX::File::formatRIS;
+ }
+
+ if ( format != BibTeX::File::formatUndefined )
+ {
+ Settings * settings = Settings::self( NULL );
+ switch ( format )
+ {
+ case BibTeX::File::formatBibTeX:
+ {
+ Settings * settings = Settings::self( NULL );
+ importer = new BibTeX::FileImporterBibTeX( settings->editing_FirstNameFirst, settings->fileIO_Encoding );
+ }
+ break;
+ case BibTeX::File::formatRIS:
+ {
+ if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable && settings->fileIO_useBibUtils )
+ importer = new BibTeX::FileImporterBibUtils( BibTeX::File::formatRIS );
+ else
+ importer = new BibTeX::FileImporterRIS( );
+ break;
+ }
+ case BibTeX::File::formatEndNote:
+ case BibTeX::File::formatEndNoteXML:
+ case BibTeX::File::formatISI:
+ case BibTeX::File::formatMODS:
+ if ( settings->external_xml2bibAvailable && settings->external_end2xmlAvailable )
+ importer = new BibTeX::FileImporterBibUtils( format );
+ break;
+ default:
+ {
+ KMessageBox::sorry( this, QString( i18n( "The file '%1' does not contain a known type of bibliography." ) ).arg( fileName ), i18n( "Unknown file format" ) );
+ }
+ }
+ }
+
+ return importer;
+ }
+
+ void DocumentWidget::slotPreviewElement( QListViewItem * item )
+ {
+ if ( item == NULL )
+ item = m_listViewElements->selectedItem();
+ if ( item == NULL )
+ item = m_listViewElements->currentItem();
+ if ( item != NULL )
+ {
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( item );
+ if ( dlvi != NULL && m_listViewElements->isEnabled() )
+ {
+ BibTeX::Element *currentElement = dlvi->element()->clone();
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+ if ( entry != NULL )
+ m_bibtexfile->completeReferencedFields( entry );
+
+ KStandardDirs * kstd = KGlobal::dirs();
+
+ BibTeX::XSLTransform *transform = new BibTeX::XSLTransform( kstd->findResource( "data", "kbibtexpart/xslt/html.xsl" ) );
+ if ( transform != NULL )
+ {
+ BibTeX::FileExporterXSLT * exporter = new BibTeX::FileExporterXSLT( transform );
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ bool result = exporter->save( &buffer, currentElement );
+ buffer.close();
+
+ if ( result )
+ {
+ buffer.open( IO_ReadOnly );
+ QTextStream htmlTS( &buffer );
+ htmlTS.setEncoding( QTextStream::UnicodeUTF8 );
+ QString htmlText = htmlTS.read();
+ buffer.close();
+ QString text = htmlText.remove( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" ).append( "</qt>" ).prepend( "<qt>" ).replace( QRegExp( "\\\\emph\\{([^}]+)\\}" ), "<em>\\1</em>" ).replace( QRegExp( "\\\\[A-Za-z0-9]+" ), "" ).replace( '{', "" ).replace( '}', "" );
+ m_preview->setText( text );
+ }
+ else
+ {
+ int i = ( int ) BibTeX::EntryField::ftTitle - ( int ) BibTeX::EntryField::ftAbstract + 2;
+ m_preview->setText( m_listViewElements->currentItem()->text( i ) );
+ }
+
+ delete exporter;
+ delete transform;
+ }
+ else
+ m_preview->setText( i18n( "No preview available" ) );
+
+ delete currentElement;
+ }
+ }
+ }
+
+ void DocumentWidget::slotTabChanged( QWidget *tab )
+ {
+ setEnabled( FALSE );
+ QApplication::setOverrideCursor( Qt::waitCursor );
+
+ BibTeX::File *bibTeXFile = NULL;
+ if ( m_editMode == emSource )
+ bibTeXFile = m_sourceView->getBibTeXFile();
+ else if ( m_editMode == emList )
+ bibTeXFile = m_listViewElements->getBibTeXFile();
+
+ if ( tab == m_sourceView && m_editMode != emSource )
+ {
+ // switching from list view to source view
+ if ( bibTeXFile != NULL )
+ {
+ // check whether the selected widget has changed the bibtex file
+ if ( bibTeXFile != m_bibtexfile )
+ {
+ delete m_bibtexfile;
+ m_bibtexfile = bibTeXFile;
+ }
+ m_sourceView->setBibTeXFile( m_bibtexfile );
+ }
+ m_editMode = emSource;
+
+ if ( m_actionEditCut && m_actionEditCopy && m_actionEditPaste )
+ {
+ m_actionEditCut->setEnabled( TRUE );
+ m_actionEditCopy->setEnabled( TRUE );
+ m_actionEditPaste->setEnabled( TRUE );
+ }
+ }
+ else if ( tab == m_container && m_editMode != emList )
+ {
+ // switching from source view to list view
+ if ( bibTeXFile != NULL )
+ {
+ // check whether the selected widget has changed the bibtex file
+ if ( bibTeXFile != m_bibtexfile )
+ {
+ delete m_bibtexfile;
+ m_bibtexfile = bibTeXFile;
+
+ Settings * settings = Settings::self( m_bibtexfile );
+ settings->addToCompletion( m_bibtexfile );
+ m_sideBar->refreshLists( m_bibtexfile );
+ }
+ m_listViewElements->setBibTeXFile( m_bibtexfile );
+ emit listViewSelectionChanged( 0 );
+ }
+ m_editMode = emList;
+ }
+
+ setEnabled( TRUE );
+
+ if ( tab == m_sourceView )
+ m_sourceView->setFocus();
+ else if ( tab == m_container )
+ m_listViewElements->setFocus();
+
+ if ( m_actionEditFind && m_actionEditFindNext )
+ {
+ m_actionEditFind->setEnabled( m_editMode == emSource );
+ m_actionEditFindNext->setEnabled( m_editMode == emSource );
+ }
+ if ( m_actionEditCopyRef )
+ m_actionEditCopyRef->setEnabled( m_editMode == emList );
+
+ QApplication::restoreOverrideCursor();
+
+ emit undoChanged( m_editMode == emSource );
+ }
+
+ void DocumentWidget::slotModified()
+ {
+ if ( isEnabled() )
+ {
+ m_sideBar->refreshLists( m_bibtexfile );
+ emit modified( );
+ }
+ }
+
+ void DocumentWidget::slotFileGotDirty( const QString& path )
+ {
+ if ( path == m_filename )
+ {
+ m_dirWatch.removeFile( m_filename );
+ QTimer::singleShot( 100, this, SLOT( slotRefreshDirtyFile( ) ) );
+ }
+ }
+
+ void DocumentWidget::slotRefreshDirtyFile()
+ {
+ if ( KMessageBox::questionYesNo( this, QString( i18n( "File '%1' has been modified. Reload file to import changes or ignore changes?" ) ).arg( m_filename ), i18n( "Reload file?" ), KGuiItem( i18n( "Reload" ), "reload" ), KGuiItem( i18n( "Ignore" ), "ignore" ) ) == KMessageBox::Yes )
+ open( m_filename, FALSE );
+ else
+ m_dirWatch.addFile( m_filename );
+ }
+
+ void DocumentWidget::slotViewDocument( int id )
+ {
+ Settings::openUrl( m_viewDocumentActionMenuURLs[ m_viewDocumentActionMenu->popupMenu() ->indexOf( id )], this );
+ }
+
+ void DocumentWidget::slotViewFirstDocument()
+ {
+ for ( QStringList::Iterator it = m_viewDocumentActionMenuURLs.begin(); it != m_viewDocumentActionMenuURLs.end(); ++it )
+ if (( *it ).endsWith( ".pdf" ) || ( *it ).endsWith( ".ps" ) || ( *it ).endsWith( ".djv" ) )
+ {
+ Settings::openUrl( *it, this );
+ break;
+ }
+ }
+
+ void DocumentWidget::slotViewFirstDocumentsOnlineRef()
+ {
+ for ( QStringList::Iterator it = m_viewDocumentActionMenuURLs.begin(); it != m_viewDocumentActionMenuURLs.end(); ++it )
+ if (( *it ).contains( "dx.doi.org" ) )
+ {
+ Settings::openUrl( *it, this );
+ break;
+ }
+ }
+
+ void DocumentWidget::slotAssignKeywords( int id )
+ {
+ QValueList<BibTeX::Entry*> entryList;
+
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( item == NULL )
+ item = m_listViewElements->currentItem();
+ for ( QListViewItemIterator it( m_listViewElements, QListViewItemIterator::Selected ); it.current(); ++it )
+ {
+ BibTeX::Element * currentElement = NULL;
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ if ( dlvi && (( currentElement = dlvi->element() ) != NULL ) )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+ if ( entry != NULL )
+ entryList << entry;
+ }
+ }
+
+ for ( QValueList<BibTeX::Entry*>::Iterator it = entryList.begin(); it != entryList.end(); ++it )
+ {
+ BibTeX::Entry *entry = *it;
+ BibTeX::EntryField *field = NULL;
+ BibTeX::KeywordContainer *keywordContainer = NULL;
+ if (( field = entry->getField( BibTeX::EntryField::ftKeywords ) ) == NULL )
+ {
+ entry->addField( field = new BibTeX::EntryField( BibTeX::EntryField::ftKeywords ) );
+ }
+
+ BibTeX::Value *value = field->value();
+
+ if ( !value->items.isEmpty() )
+ keywordContainer = dynamic_cast<BibTeX::KeywordContainer*>( value->items.first() );
+
+ if ( keywordContainer == NULL )
+ value->items.append( keywordContainer = new BibTeX::KeywordContainer() );
+
+ if ( m_assignKeywordsActionMenu->popupMenu() ->isItemChecked( id ) )
+ keywordContainer->remove( m_assignKeywordsActionMenuURLs[ id ] );
+ else
+ keywordContainer->append( m_assignKeywordsActionMenuURLs[ id ] );
+
+ slotModified();
+ }
+ }
+
+ void DocumentWidget::slotAddKeyword()
+ {
+ QString newKeyword = m_lineEditNewKeyword->text();
+
+ QValueList<BibTeX::Entry*> entryList;
+ for ( QListViewItemIterator it( m_listViewElements, QListViewItemIterator::Selected ); it.current(); ++it )
+ {
+ BibTeX::Element * currentElement = NULL;
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ if ( dlvi && (( currentElement = dlvi->element() ) != NULL ) )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+ if ( entry != NULL )
+ entryList << entry;
+ }
+ }
+
+ for ( QValueList<BibTeX::Entry*>::Iterator it = entryList.begin(); it != entryList.end(); ++it )
+ {
+ BibTeX::Entry *entry = *it;
+ BibTeX::EntryField *field = entry->getField( BibTeX::EntryField::ftKeywords );
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( BibTeX::EntryField::ftKeywords );
+ entry->addField( field );
+ }
+
+ BibTeX::Value *value = field->value();
+ BibTeX::KeywordContainer *keywordContainer = NULL;
+
+ if ( !value->items.isEmpty() )
+ keywordContainer = dynamic_cast<BibTeX::KeywordContainer*>( value->items.first() );
+
+ if ( keywordContainer == NULL )
+ value->items.append( keywordContainer = new BibTeX::KeywordContainer() );
+
+ keywordContainer->append( newKeyword );
+ }
+
+ if ( !entryList.isEmpty() )
+ {
+ if ( m_lineEditNewKeyword->isVisible() &&
+ m_lineEditNewKeyword->parentWidget() &&
+ m_lineEditNewKeyword->parentWidget()->parentWidget() &&
+ m_lineEditNewKeyword->parentWidget()->parentWidget()->inherits( "QPopupMenu" ) )
+ m_lineEditNewKeyword->parentWidget()->parentWidget()->close();
+
+ slotModified();
+ }
+ }
+
+ void DocumentWidget::slotNormalizeIds()
+ {
+ Settings * settings = Settings::self();
+ QMap<BibTeX::Entry*, QString> entryToNewId;
+ QMap<BibTeX::Entry*, DocumentListViewItem*> entryToItem;
+ QStringList msgList;
+
+ if ( settings->idSuggestions_default < 0 )
+ {
+ KMessageBox::sorry( this, i18n( "You must set a default id suggestion in the settings dialog." ) );
+ return;
+ }
+
+ for ( QListViewItemIterator it( m_listViewElements, QListViewItemIterator::Selected ); it.current(); ++it )
+ {
+ BibTeX::Element * currentElement = NULL;
+ DocumentListViewItem * dlvi = dynamic_cast<DocumentListViewItem*>( it.current() );
+ if ( dlvi && (( currentElement = dlvi->element() ) != NULL ) )
+ {
+ BibTeX::Entry *entry = dynamic_cast<BibTeX::Entry*>( currentElement );
+ if ( entry != NULL )
+ {
+ QString newEntryId = IdSuggestions::createDefaultSuggestion( m_bibtexfile, entry );
+ entryToNewId[entry] = newEntryId;
+ entryToItem[entry] = dlvi;
+ msgList << "Replacing id of entry \"" + entry->id() + "\" with new id \"" + newEntryId + "\"";
+ }
+ }
+ }
+
+ if ( entryToNewId.isEmpty() )
+ KMessageBox::information( this, i18n( "No entries were selected." ) );
+ else if ( KMessageBox::questionYesNoList( this, i18n( "The following changes will be applied to the currently selected elements.\nConflicts with duplicate entry ids will be resolved when applying the new ids." ), msgList, i18n( "Normalize Entry Ids" ), KGuiItem( i18n( "Replace Entry Ids" ), "run" ), KGuiItem( i18n( "Cancel" ), "cancel" ) ) == KMessageBox::Yes )
+ {
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ QMap<BibTeX::Entry*, DocumentListViewItem*>::Iterator itItem = entryToItem.begin();
+ for ( QMap<BibTeX::Entry*, QString>::Iterator it = entryToNewId.begin(); it != entryToNewId.end(); ++it, ++itItem )
+ {
+ BibTeX::Entry *entry = it.key();
+ QString newEntryId = it.data();
+ newEntryId = IdSuggestions::resolveConflict( m_bibtexfile, newEntryId, entry );
+ qDebug( "Replacing id of entry \"%s\" with new id \"%s\"", entry->id().latin1(), newEntryId.latin1() );
+ entry->setId( newEntryId );
+ itItem.data()->updateItem();
+ }
+ slotModified();
+ m_sideBar->refreshLists( m_bibtexfile );
+ QApplication::restoreOverrideCursor();
+ }
+ }
+
+ KDirWatch &DocumentWidget::dirWatch()
+ {
+ return m_dirWatch;
+ }
+
+}
+
+#include "documentwidget.moc"
diff --git a/src/documentwidget.h b/src/documentwidget.h
new file mode 100644
index 0000000..cc6e344
--- /dev/null
+++ b/src/documentwidget.h
@@ -0,0 +1,174 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXDOCUMENTWIDGET_H
+#define KBIBTEXDOCUMENTWIDGET_H
+
+#include <qtabwidget.h>
+
+#include <kdirwatch.h>
+
+#include <fileimporter.h>
+#include <file.h>
+#include <settings.h>
+
+class QIODevice;
+class QProgressDialog;
+class QListViewItem;
+class QWidget;
+class QSplitter;
+
+class KPopupMenu;
+class KActionMenu;
+class KURL;
+class KTextEdit;
+class KLineEdit;
+
+namespace KBibTeX
+{
+ class DocumentListView;
+ class DocumentListViewItem;
+ class DocumentSourceView;
+ class SearchBar;
+ class SideBar;
+ class WebQuery;
+
+ class DocumentWidget : public QTabWidget
+ {
+ Q_OBJECT
+ public:
+ DocumentWidget( bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~DocumentWidget();
+
+ bool open( const QString &fileName, bool mergeOnly = FALSE );
+ bool open( QIODevice *iodevice, bool mergeOnly = FALSE, const QString &label = QString::null, BibTeX::FileImporter *importer = NULL );
+ bool save( const QString &fileName, QStringList *errorLog = NULL );
+ bool save( QIODevice *iodevice, BibTeX::File::FileFormat format = BibTeX::File::formatBibTeX, const QString &label = QString::null, QStringList *errorLog = NULL );
+
+ bool newElement( const QString& elementType );
+ void searchWebsites( const QString& searchURL, bool includeAuthor );
+ void updateViews();
+ void showStatistics();
+
+ void setFactory( KXMLGUIFactory *factory, KXMLGUIClient *client );
+ void updateViewDocumentMenu( );
+ void updateAssignKeywords( );
+
+ void deferredInitialization();
+ void saveState();
+ void restoreState();
+
+ KDirWatch &dirWatch();
+
+ signals:
+ void modified();
+ void listViewSelectionChanged( int numSelected );
+ void undoChanged( bool undoAvailable );
+
+ public slots:
+ void executeElement( DocumentListViewItem* );
+ bool editElement();
+ bool editElement( DocumentListViewItem* );
+ bool editElement( BibTeX::Element* );
+ void deleteElements();
+ void sendSelectedToLyx();
+ void cutElements();
+ void copyElements();
+ void copyRefElements();
+ void pasteElements();
+ void selectAll();
+ void setReadOnly( bool isReadOnly );
+ void configureEditor();
+ void undoEditor();
+ void find();
+ void findNext();
+ void refreshBibTeXFile();
+ void onlineSearch();
+ void findDuplicates();
+ void slotViewFirstDocument();
+ void slotViewFirstDocumentsOnlineRef();
+ void slotNormalizeIds();
+
+ private:
+ enum EditMode
+ {
+ emList, emSource
+ };
+
+ KLineEdit *m_lineEditNewKeyword;
+ bool m_isReadOnly;
+ QSplitter *m_horSplitter;
+ QSplitter *m_vertSplitter;
+ QWidget *m_container;
+ SearchBar *m_searchBar;
+ DocumentListView *m_listViewElements;
+ KTextEdit * m_preview;
+ DocumentSourceView *m_sourceView;
+ SideBar* m_sideBar;
+ BibTeX::File *m_bibtexfile;
+ QString m_filename;
+ QProgressDialog *m_progressDialog;
+ int m_newElementCounter;
+ EditMode m_editMode;
+ KActionMenu *m_viewDocumentActionMenu;
+ KActionMenu *m_assignKeywordsActionMenu;
+ QStringList m_viewDocumentActionMenuURLs;
+ QMap<int, QString> m_assignKeywordsActionMenuURLs;
+ KActionMenu *m_searchWebsitesActionMenu;
+ KAction *m_actionEditCut;
+ KAction *m_actionEditCopy;
+ KAction *m_actionEditCopyRef;
+ KAction *m_actionEditPaste;
+ KAction *m_actionEditSelectAll;
+ KAction *m_actionEditFind;
+ KAction *m_actionEditFindNext;
+ KAction *m_actionNormalizeIds;
+ KDirWatch m_dirWatch;
+
+ void setupGUI();
+
+ void startProgress( const QString &label, QObject *progressFrom );
+ void endProgress( QObject *progressFrom );
+
+ void searchWebsites( BibTeX::Element *element, const QString& searchURL, bool includeAuthor );
+
+ bool editElementDialog( BibTeX::Element *element );
+ void updateFromGUI();
+ QString nextNewEntry();
+
+ KURL::List getEntryURLs( BibTeX::Entry *entry );
+
+ BibTeX::FileImporter *fileImporterFactory( const QString &fileName );
+
+ private slots:
+ void slotShowProgress( int current, int total );
+ void slotSelectionChanged();
+ void slotPreviewElement( QListViewItem * item = NULL );
+ void slotTabChanged( QWidget *tab );
+ void slotModified();
+ void slotFileGotDirty( const QString& path );
+ void slotRefreshDirtyFile();
+ void slotViewDocument( int id );
+ void slotAssignKeywords( int id );
+ void slotAddKeyword();
+ };
+
+}
+
+#endif
diff --git a/src/element.cpp b/src/element.cpp
new file mode 100644
index 0000000..73b3178
--- /dev/null
+++ b/src/element.cpp
@@ -0,0 +1,50 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qstring.h>
+
+#include <xsltransform.h>
+#include "element.h"
+
+namespace BibTeX
+{
+
+
+ Element::Element( )
+ {
+ // nothing
+ }
+
+ Element::~Element()
+ {
+ // nothing
+ }
+
+ bool Element::isSimpleString( const QString &text )
+ {
+ bool result = TRUE;
+ const QString goodChars = "abcdefghijklmnopqrstuvwxyz0123456789-_";
+
+ for ( unsigned int i = 0; result && i < text.length(); i++ )
+ result &= goodChars.contains( text.at( i ), FALSE );
+
+ return result;
+ }
+
+}
diff --git a/src/element.h b/src/element.h
new file mode 100644
index 0000000..1955383
--- /dev/null
+++ b/src/element.h
@@ -0,0 +1,49 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXELEMENT_H
+#define BIBTEXELEMENT_H
+
+#include <file.h>
+#include <entryfield.h>
+
+class QString;
+
+namespace BibTeX
+{
+
+ class Element
+ {
+ public:
+ enum FilterType {ftExact, ftEveryWord, ftAnyWord};
+
+ Element();
+ virtual ~Element();
+
+ virtual bool containsPattern( const QString& /* pattern */, BibTeX::EntryField::FieldType /* fieldType */, FilterType /* filterType */ = BibTeX::Element::ftExact, bool /* caseSensitive */ = false ) const = 0;
+ virtual Element* clone() = 0;
+ virtual QString text() const = 0;
+
+ static bool isSimpleString( const QString &text );
+
+ };
+
+}
+
+#endif
diff --git a/src/encoder.cpp b/src/encoder.cpp
new file mode 100644
index 0000000..394e7d0
--- /dev/null
+++ b/src/encoder.cpp
@@ -0,0 +1,25 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "encoder.h"
+
+namespace BibTeX
+{
+// nothing
+}
diff --git a/src/encoder.h b/src/encoder.h
new file mode 100644
index 0000000..7997b8e
--- /dev/null
+++ b/src/encoder.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXENCODER_H
+#define BIBTEXENCODER_H
+
+#include <entryfield.h>
+
+class QString;
+
+namespace BibTeX
+{
+
+ /**
+ @author Thomas Fischer
+ */
+ class Encoder
+ {
+ public:
+ virtual ~Encoder() { /* nothing */};
+
+ virtual QString decode( const QString & /*text*/ )
+ {
+ return QString::null;
+ };
+ virtual QString encode( const QString & /*text*/ )
+ {
+ return QString::null;
+ };
+ virtual QString encodeSpecialized( const QString & /*text*/, const EntryField::FieldType /*fieldType*/ = EntryField::ftUnknown )
+ {
+ return QString::null;
+ };
+ };
+
+}
+
+#endif
diff --git a/src/encoderlatex.cpp b/src/encoderlatex.cpp
new file mode 100644
index 0000000..f111848
--- /dev/null
+++ b/src/encoderlatex.cpp
@@ -0,0 +1,876 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qstring.h>
+#include <qapplication.h>
+#include <qregexp.h>
+
+#include "encoderlatex.h"
+
+namespace BibTeX
+{
+ EncoderLaTeX *EncoderLaTeX::encoderLaTeX = NULL;
+
+ static struct Decomposition
+ {
+ const char *latexCommand;
+ unsigned int unicode;
+ }
+ decompositions[] =
+ {
+ {"`", 0x0300},
+ {"'", 0x0301},
+ {"^", 0x0302},
+ {"~", 0x0303},
+ {"=", 0x0304},
+ /*{"x", 0x0305}, OVERLINE */
+ {"u", 0x0306},
+ {".", 0x0307},
+ /*{"x", 0x0309}, HOOK ABOVE */
+ {"r", 0x030a},
+ {"H", 0x030b},
+ {"v", 0x030c},
+ /*{"x", 0x030d}, VERTICAL LINE ABOVE */
+ /*{"x", 0x030e}, DOUBLE VERTICAL LINE ABOVE */
+ /*{"x", 0x030f}, DOUBLE GRAVE ACCENT */
+ /*{"x", 0x0310}, CANDRABINDU */
+ /*{"x", 0x0311}, INVERTED BREVE */
+ /*{"x", 0x0312}, TURNED COMMA ABOVE */
+ /*{"x", 0x0313}, COMMA ABOVE */
+ /*{"x", 0x0314}, REVERSED COMMA ABOVE */
+ /*{"x", 0x0315}, */
+ /*{"x", 0x0316}, */
+ /*{"x", 0x0317}, */
+ /*{"x", 0x0318}, */
+ /*{"x", 0x0319}, */
+ /*{"x", 0x031a}, */
+ /*{"x", 0x031b}, */
+ /*{"x", 0x031c}, */
+ /*{"x", 0x031d}, */
+ /*{"x", 0x031e}, */
+ /*{"x", 0x031f}, */
+ /*{"x", 0x0320}, */
+ /*{"x", 0x0321}, */
+ /*{"x", 0x0322}, */
+ {"d", 0x0323},
+ /*{"x", 0x0324}, */
+ /*{"x", 0x0325}, */
+ /*{"x", 0x0326}, */
+ {"d", 0x0327},
+ {"k", 0x0328},
+ /*{"x", 0x0329}, */
+ /*{"x", 0x032a}, */
+ /*{"x", 0x032b}, */
+ /*{"x", 0x032c}, */
+ /*{"x", 0x032d}, */
+ /*{"x", 0x032e}, */
+ /*{"x", 0x032f}, */
+ {"b", 0x0331},
+ {"t", 0x0361}
+ };
+
+ static const int decompositionscount = sizeof( decompositions ) / sizeof( decompositions[ 0 ] ) ;
+
+ static const struct EncoderLaTeXCommandMapping
+ {
+ const char *letters;
+ unsigned int unicode;
+ }
+ commandmappingdatalatex[] =
+ {
+ {"AA", 0x00C5},
+ {"AE", 0x00C6},
+ {"ss", 0x00DF},
+ {"aa", 0x00E5},
+ {"ae", 0x00E6},
+ {"OE", 0x0152},
+ {"oe", 0x0153},
+ {"ldots", 0x2026},
+ {"L", 0x0141},
+ {"l", 0x0142},
+ {"grqq", 0x201C},
+ {"glqq", 0x201E},
+ {"frqq", 0x00BB},
+ {"flqq", 0x00AB},
+
+// awk -F '[{}\\\\]+' '/DeclareUnicodeCharacter/ { print "{\""$4"\", 0x"$3"},"}' /usr/share/texmf-dist/tex/latex/base/t2aenc.dfu | grep '0x04' | sort -r -f
+ {"cyrzhdsc", 0x0497},
+ {"CYRZHDSC", 0x0496},
+ {"cyrzh", 0x0436},
+ {"CYRZH", 0x0416},
+ {"cyrzdsc", 0x0499},
+ {"CYRZDSC", 0x0498},
+ {"cyrz", 0x0437},
+ {"CYRZ", 0x0417},
+ {"cyryu", 0x044E},
+ {"CYRYU", 0x042E},
+ {"cyryo", 0x0451},
+ {"CYRYO", 0x0401},
+ {"cyryi", 0x0457},
+ {"CYRYI", 0x0407},
+ {"cyryhcrs", 0x04B1},
+ {"CYRYHCRS", 0x04B0},
+ {"cyrya", 0x044F},
+ {"CYRYA", 0x042F},
+ {"cyry", 0x04AF},
+ {"CYRY", 0x04AE},
+ {"cyrv", 0x0432},
+ {"CYRV", 0x0412},
+ {"cyrushrt", 0x045E},
+ {"CYRUSHRT", 0x040E},
+ {"cyru", 0x0443},
+ {"CYRU", 0x0423},
+ {"cyrtshe", 0x045B},
+ {"CYRTSHE", 0x040B},
+ {"cyrtdsc", 0x04AD},
+ {"CYRTDSC", 0x04AC},
+ {"cyrt", 0x0442},
+ {"CYRT", 0x0422},
+ {"cyrshha", 0x04BB},
+ {"CYRSHHA", 0x04BA},
+ {"cyrshch", 0x0449},
+ {"CYRSHCH", 0x0429},
+ {"cyrsh", 0x0448},
+ {"CYRSH", 0x0428},
+ {"cyrsftsn", 0x044C},
+ {"CYRSFTSN", 0x042C},
+ {"cyrsdsc", 0x04AB},
+ {"CYRSDSC", 0x04AA},
+ {"cyrschwa", 0x04D9},
+ {"CYRSCHWA", 0x04D8},
+ {"cyrs", 0x0441},
+ {"CYRS", 0x0421},
+ {"cyrr", 0x0440},
+ {"CYRR", 0x0420},
+ {"CYRpalochka", 0x04C0},
+ {"cyrp", 0x043F},
+ {"CYRP", 0x041F},
+ {"cyrotld", 0x04E9},
+ {"CYROTLD", 0x04E8},
+ {"cyro", 0x043E},
+ {"CYRO", 0x041E},
+ {"cyrnje", 0x045A},
+ {"CYRNJE", 0x040A},
+ {"cyrng", 0x04A5},
+ {"CYRNG", 0x04A4},
+ {"cyrndsc", 0x04A3},
+ {"CYRNDSC", 0x04A2},
+ {"cyrn", 0x043D},
+ {"CYRN", 0x041D},
+ {"cyrm", 0x043C},
+ {"CYRM", 0x041C},
+ {"cyrlje", 0x0459},
+ {"CYRLJE", 0x0409},
+ {"cyrl", 0x043B},
+ {"CYRL", 0x041B},
+ {"cyrkvcrs", 0x049D},
+ {"CYRKVCRS", 0x049C},
+ {"cyrkdsc", 0x049B},
+ {"CYRKDSC", 0x049A},
+ {"cyrk", 0x043A},
+ {"CYRK", 0x041A},
+ {"cyrje", 0x0458},
+ {"CYRJE", 0x0408},
+ {"cyrishrt", 0x0439},
+ {"CYRISHRT", 0x0419},
+ {"cyrii", 0x0456},
+ {"CYRII", 0x0406},
+ {"cyrie", 0x0454},
+ {"CYRIE", 0x0404},
+ {"cyri", 0x0438},
+ {"CYRI", 0x0418},
+ {"cyrhrdsn", 0x044A},
+ {"CYRHRDSN", 0x042A},
+ {"cyrhdsc", 0x04B3},
+ {"CYRHDSC", 0x04B2},
+ {"cyrh", 0x0445},
+ {"CYRH", 0x0425},
+ {"cyrgup", 0x0491},
+ {"CYRGUP", 0x0490},
+ {"cyrghcrs", 0x0493},
+ {"CYRGHCRS", 0x0492},
+ {"cyrg", 0x0433},
+ {"CYRG", 0x0413},
+ {"cyrf", 0x0444},
+ {"CYRF", 0x0424},
+ {"cyrery", 0x044B},
+ {"CYRERY", 0x042B},
+ {"cyrerev", 0x044D},
+ {"CYREREV", 0x042D},
+ {"cyre", 0x0435},
+ {"CYRE", 0x0415},
+ {"cyrdzhe", 0x045F},
+ {"CYRDZHE", 0x040F},
+ {"cyrdze", 0x0455},
+ {"CYRDZE", 0x0405},
+ {"cyrdje", 0x0452},
+ {"CYRDJE", 0x0402},
+ {"cyrd", 0x0434},
+ {"CYRD", 0x0414},
+ {"cyrchvcrs", 0x04B9},
+ {"CYRCHVCRS", 0x04B8},
+ {"cyrchrdsc", 0x04B7},
+ {"CYRCHRDSC", 0x04B6},
+ {"cyrch", 0x0447},
+ {"CYRCH", 0x0427},
+ {"cyrc", 0x0446},
+ {"CYRC", 0x0426},
+ {"cyrb", 0x0431},
+ {"CYRB", 0x0411},
+ {"cyrae", 0x04D5},
+ {"CYRAE", 0x04D4},
+ {"cyra", 0x0430},
+ {"CYRA", 0x0410}
+ };
+
+ static const int commandmappingdatalatexcount = sizeof( commandmappingdatalatex ) / sizeof( commandmappingdatalatex[ 0 ] ) ;
+
+ /** Command can be either
+ (1) {embraced}
+ (2) delimited by {},
+ (3) <space>, line end,
+ (4) \following_command (including \<space>, which must be maintained!),
+ (5) } (end of entry or group)
+ **/
+ const char *expansionsCmd[] = {"\\{\\\\%1\\}", "\\\\%1\\{\\}", "\\\\%1(\\n|\\r|\\\\|\\})", "\\\\%1\\s"};
+ static const int expansionscmdcount = sizeof( expansionsCmd ) / sizeof( expansionsCmd[0] );
+
+ static const struct EncoderLaTeXModCharMapping
+ {
+ const char *modifier;
+ const char *letter;
+ unsigned int unicode;
+ }
+ modcharmappingdatalatex[] =
+ {
+ {"\\\\`", "A", 0x00C0},
+ {"\\\\'", "A", 0x00C1},
+ {"\\\\\\^", "A", 0x00C2},
+ {"\\\\~", "A", 0x00C3},
+ {"\\\\\"", "A", 0x00C4},
+ {"\\\\r", "A", 0x00C5},
+ /** 0x00C6 */
+ {"\\\\c", "C", 0x00C7},
+ {"\\\\`", "E", 0x00C8},
+ {"\\\\'", "E", 0x00C9},
+ {"\\\\\\^", "E", 0x00CA},
+ {"\\\\\"", "E", 0x00CB},
+ {"\\\\`", "I", 0x00CC},
+ {"\\\\'", "I", 0x00CD},
+ {"\\\\\\^", "I", 0x00CE},
+ {"\\\\\"", "I", 0x00CF},
+ /** 0x00D0 */
+ {"\\\\~", "N", 0x00D1},
+ {"\\\\`", "O", 0x00D2},
+ {"\\\\'", "O", 0x00D3},
+ {"\\\\\\^", "O", 0x00D4},
+ /** 0x00D5 */
+ {"\\\\\"", "O", 0x00D6},
+ /** 0x00D7 */
+ {"\\\\", "O", 0x00D8},
+ {"\\\\`", "U", 0x00D9},
+ {"\\\\'", "U", 0x00DA},
+ {"\\\\\\^", "U", 0x00DB},
+ {"\\\\\"", "U", 0x00DC},
+ {"\\\\'", "Y", 0x00DD},
+ /** 0x00DE */
+ {"\\\\\"", "s", 0x00DF},
+ {"\\\\`", "a", 0x00E0},
+ {"\\\\'", "a", 0x00E1},
+ {"\\\\\\^", "a", 0x00E2},
+ {"\\\\~", "a", 0x00E3},
+ {"\\\\\"", "a", 0x00E4},
+ {"\\\\r", "a", 0x00E5},
+ /** 0x00E6 */
+ {"\\\\c", "c", 0x00E7},
+ {"\\\\`", "e", 0x00E8},
+ {"\\\\'", "e", 0x00E9},
+ {"\\\\\\^", "e", 0x00EA},
+ {"\\\\\"", "e", 0x00EB},
+ {"\\\\`", "i", 0x00EC},
+ {"\\\\'", "i", 0x00ED},
+ {"\\\\'", "\\\\i", 0x00ED},
+ {"\\\\\\^", "i", 0x00EE},
+ /** 0x00EF */
+ /** 0x00F0 */
+ {"\\\\~", "n", 0x00F1},
+ {"\\\\`", "o", 0x00F2},
+ {"\\\\'", "o", 0x00F3},
+ {"\\\\\\^", "o", 0x00F4},
+ /** 0x00F5 */
+ {"\\\\\"", "o", 0x00F6},
+ /** 0x00F7 */
+ {"\\\\", "o", 0x00F8},
+ {"\\\\`", "u", 0x00F9},
+ {"\\\\'", "u", 0x00FA},
+ {"\\\\\\^", "u", 0x00FB},
+ {"\\\\\"", "u", 0x00FC},
+ {"\\\\'", "y", 0x00FD},
+ /** 0x00FE */
+ /** 0x00FF */
+ /** 0x0100 */
+ /** 0x0101 */
+ {"\\\\u", "A", 0x0102},
+ {"\\\\u", "a", 0x0103},
+ /** 0x0104 */
+ /** 0x0105 */
+ {"\\\\'", "C", 0x0106},
+ {"\\\\'", "c", 0x0107},
+ /** 0x0108 */
+ /** 0x0109 */
+ /** 0x010A */
+ /** 0x010B */
+ {"\\\\v", "C", 0x010C},
+ {"\\\\v", "c", 0x010D},
+ {"\\\\v", "D", 0x010E},
+ /** 0x010F */
+ /** 0x0110 */
+ /** 0x0111 */
+ /** 0x0112 */
+ /** 0x0113 */
+ /** 0x0114 */
+ /** 0x0115 */
+ /** 0x0116 */
+ /** 0x0117 */
+ {"\\\\c", "E", 0x0118},
+ {"\\\\c", "e", 0x0119},
+ {"\\\\v", "E", 0x011A},
+ {"\\\\v", "e", 0x011B},
+ /** 0x011C */
+ /** 0x011D */
+ {"\\\\u", "G", 0x011E},
+ {"\\\\u", "g", 0x011F},
+ /** 0x0120 */
+ /** 0x0121 */
+ /** 0x0122 */
+ /** 0x0123 */
+ /** 0x0124 */
+ /** 0x0125 */
+ /** 0x0126 */
+ /** 0x0127 */
+ /** 0x0128 */
+ /** 0x0129 */
+ /** 0x012A */
+ /** 0x012B */
+ {"\\\\u", "I", 0x012C},
+ {"\\\\u", "i", 0x012D},
+ /** 0x012E */
+ /** 0x012F */
+ /** 0x0130 */
+ /** 0x0131 */
+ /** 0x0132 */
+ /** 0x0133 */
+ /** 0x0134 */
+ /** 0x0135 */
+ /** 0x0136 */
+ /** 0x0137 */
+ /** 0x0138 */
+ {"\\\\'", "L", 0x0139},
+ {"\\\\'", "l", 0x013A},
+ /** 0x013B */
+ /** 0x013C */
+ /** 0x013D */
+ /** 0x013E */
+ /** 0x013F */
+ /** 0x0140 */
+ /** 0x0141 */
+ /** 0x0142 */
+ {"\\\\'", "N", 0x0143},
+ {"\\\\'", "n", 0x0144},
+ /** 0x0145 */
+ /** 0x0146 */
+ {"\\\\v", "N", 0x0147},
+ {"\\\\v", "n", 0x0148},
+ /** 0x0149 */
+ /** 0x014A */
+ /** 0x014B */
+ /** 0x014C */
+ /** 0x014D */
+ {"\\\\u", "O", 0x014E},
+ {"\\\\u", "o", 0x014F},
+ {"\\\\H", "O", 0x0150},
+ {"\\\\H", "o", 0x0151},
+ /** 0x0152 */
+ /** 0x0153 */
+ {"\\\\'", "R", 0x0154},
+ {"\\\\'", "r", 0x0155},
+ /** 0x0156 */
+ /** 0x0157 */
+ {"\\\\v", "R", 0x0158},
+ {"\\\\v", "r", 0x0159},
+ {"\\\\'", "S", 0x015A},
+ {"\\\\'", "s", 0x015B},
+ /** 0x015C */
+ /** 0x015D */
+ {"\\\\c", "S", 0x015E},
+ {"\\\\c", "s", 0x015F},
+ {"\\\\v", "S", 0x0160},
+ {"\\\\v", "s", 0x0161},
+ /** 0x0162 */
+ /** 0x0163 */
+ {"\\\\v", "T", 0x0164},
+ /** 0x0165 */
+ /** 0x0166 */
+ /** 0x0167 */
+ /** 0x0168 */
+ /** 0x0169 */
+ /** 0x016A */
+ /** 0x016B */
+ {"\\\\u", "U", 0x016C},
+ {"\\\\u", "u", 0x016D},
+ {"\\\\r", "U", 0x016E},
+ {"\\\\r", "u", 0x016F},
+ /** 0x0170 */
+ /** 0x0171 */
+ /** 0x0172 */
+ /** 0x0173 */
+ /** 0x0174 */
+ /** 0x0175 */
+ /** 0x0176 */
+ /** 0x0177 */
+ {"\\\\\"", "Y", 0x0178},
+ {"\\\\'", "Z", 0x0179},
+ {"\\\\'", "z", 0x017A},
+ /** 0x017B */
+ /** 0x017C */
+ {"\\\\v", "Z", 0x017D},
+ {"\\\\v", "z", 0x017E},
+ /** 0x017F */
+ /** 0x0180 */
+ {"\\\\v", "A", 0x01CD},
+ {"\\\\v", "a", 0x01CE},
+ {"\\\\v", "G", 0x01E6},
+ {"\\\\v", "g", 0x01E7}
+ };
+
+ const char *expansionsMod1[] = {"\\{%1\\{%2\\}\\}", "\\{%1 %2\\}", "%1\\{%2\\}"};
+ static const int expansionsmod1count = sizeof( expansionsMod1 ) / sizeof( expansionsMod1[0] );
+ const char *expansionsMod2[] = {"\\{%1%2\\}", "%1%2\\{\\}", "%1%2"};
+ static const int expansionsmod2count = sizeof( expansionsMod2 ) / sizeof( expansionsMod2[0] );
+
+ static const int modcharmappingdatalatexcount = sizeof( modcharmappingdatalatex ) / sizeof( modcharmappingdatalatex[ 0 ] ) ;
+
+ static const struct EncoderLaTeXCharMapping
+ {
+ const char *regexp;
+ unsigned int unicode;
+ const char *latex;
+ }
+ charmappingdatalatex[] =
+ {
+ {"\\\\#", 0x0023, "\\#"},
+ {"\\\\&", 0x0026, "\\&"},
+ {"\\\\_", 0x005F, "\\_"},
+ {"!`", 0x00A1, "!`"},
+ {"\"<", 0x00AB, "\"<"},
+ {"\">", 0x00BB, "\">"},
+ {"[?]`", 0x00BF, "?`"},
+ {"--", 0x2013, "--"}
+ };
+
+ static const int charmappingdatalatexcount = sizeof( charmappingdatalatex ) / sizeof( charmappingdatalatex[ 0 ] ) ;
+
+ EncoderLaTeX::EncoderLaTeX()
+ {
+ buildCharMapping();
+ buildCombinedMapping();
+ }
+
+ EncoderLaTeX::~EncoderLaTeX()
+ {
+ // nothing
+ }
+
+ QString EncoderLaTeX::decode( const QString & text )
+ {
+ const QString splitMarker = "|KBIBTEX|";
+
+ /** start-stop marker ensures that each text starts and stops
+ * with plain text and not with an inline math environment.
+ * This invariant is exploited implicitly in the code below. */
+ const QString startStopMarker="|STARTSTOP|";
+ QString result = startStopMarker + text + startStopMarker;
+
+ /** Collect (all?) urls from the BibTeX file and store them in urls */
+ /** Problem is that the replace function below will replace
+ * character sequences in the URL rendering the URL invalid.
+ * Later, all URLs will be replaced back to their original
+ * in the hope nothing breaks ... */
+ QStringList urls;
+ QRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" );
+ httpRegExp.setMinimal( false );
+ int pos = 0;
+ while ( pos >= 0 )
+ {
+ pos = httpRegExp.search( result, pos );
+ if ( pos >= 0 )
+ {
+ ++pos;
+ QString url = httpRegExp.cap( 0 );
+ urls << url;
+ }
+ }
+
+ decomposedUTF8toLaTeX( result );
+
+ /** split text into math and non-math regions */
+ QStringList intermediate = QStringList::split( '$', result, true );
+ QStringList::Iterator it = intermediate.begin();
+ while ( it != intermediate.end() )
+ {
+ /**
+ * Sometimes we split strings like "\$", which is not intended.
+ * So, we have to manually fix things by checking for strings
+ * ending with "\" and append both the removed dollar sign and
+ * the following string (which was never supposed to be an
+ * independent string). Finally, we remove the unnecessary
+ * string and continue.
+ */
+ if (( *it ).endsWith( "\\" ) )
+ {
+ QStringList::Iterator cur = it;
+ ++it;
+ ( *cur ).append( '$' ).append( *it );
+ intermediate.remove( it );
+ it = cur;
+ }
+ else
+ ++it;
+ }
+
+ qApp->processEvents();
+
+ result = "";
+ for ( QStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it )
+ {
+ if ( !result.isEmpty() ) result.append( splitMarker );
+ result.append( *it );
+
+ ++it;
+ if ( it == intermediate.end() )
+ break;
+
+ if (( *it ).length() > 256 )
+ qDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() );
+ }
+
+ qApp->processEvents();
+
+ for ( QValueList<CharMappingItem>::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit )
+ result.replace(( *cmit ).regExp, ( *cmit ).unicode );
+
+ qApp->processEvents();
+
+ QStringList transformed = QStringList::split( splitMarker, result, true );
+
+ qApp->processEvents();
+
+ result = "";
+ for ( QStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti )
+ {
+ result.append( *itt );
+
+ ++iti;
+ if ( iti == intermediate.end() )
+ break;
+
+ result.append( "$" ).append( *iti ).append( "$" );
+ }
+
+ qApp->processEvents();
+
+ /** Reinserting original URLs as explained above */
+ pos = 0;
+ int idx = 0;
+ while ( pos >= 0 )
+ {
+ pos = httpRegExp.search( result, pos );
+ if ( pos >= 0 )
+ {
+ ++pos;
+ int len = httpRegExp.cap( 0 ).length();
+ result = result.left( pos - 1 ).append( urls[idx++] ).append( result.mid( pos + len - 1 ) );
+ }
+ }
+
+ return result.replace( startStopMarker,"" );
+ }
+
+ QString EncoderLaTeX::encode( const QString & text )
+ {
+ const QString splitMarker = "|KBIBTEX|";
+
+ /** start-stop marker ensures that each text starts and stops
+ * with plain text and not with an inline math environment.
+ * This invariant is exploited implicitly in the code below. */
+ const QString startStopMarker="|STARTSTOP|";
+ QString result = startStopMarker + text + startStopMarker;
+
+ /** Collect (all?) urls from the BibTeX file and store them in urls */
+ /** Problem is that the replace function below will replace
+ * character sequences in the URL rendering the URL invalid.
+ * Later, all URLs will be replaced back to their original
+ * in the hope nothing breaks ... */
+ QStringList urls;
+ QRegExp httpRegExp( "(ht|f)tp://[^\"} ]+" );
+ httpRegExp.setMinimal( false );
+ int pos = 0;
+ while ( pos >= 0 )
+ {
+ pos = httpRegExp.search( result, pos );
+ if ( pos >= 0 )
+ {
+ ++pos;
+ QString url = httpRegExp.cap( 0 );
+ urls << url;
+ }
+ }
+
+ /** split text into math and non-math regions */
+ QStringList intermediate = QStringList::split( '$', result, true );
+ QStringList::Iterator it = intermediate.begin();
+ while ( it != intermediate.end() )
+ {
+ /**
+ * Sometimes we split strings like "\$", which is not intended.
+ * So, we have to manually fix things by checking for strings
+ * ending with "\" and append both the removed dollar sign and
+ * the following string (which was never supposed to be an
+ * independent string). Finally, we remove the unnecessary
+ * string and continue.
+ */
+ if (( *it ).endsWith( "\\" ) )
+ {
+ QStringList::Iterator cur = it;
+ ++it;
+ ( *cur ).append( '$' ).append( *it );
+ intermediate.remove( it );
+ it = cur;
+ }
+ else
+ ++it;
+ }
+
+ qApp->processEvents();
+
+ result = "";
+ for ( QStringList::Iterator it = intermediate.begin(); it != intermediate.end(); ++it )
+ {
+ if ( !result.isEmpty() ) result.append( splitMarker );
+ result.append( *it );
+
+ ++it;
+ if ( it == intermediate.end() )
+ break;
+
+ if (( *it ).length() > 256 )
+ qDebug( "Very long math equation using $ found, maybe due to broken inline math: %s", ( *it ).left( 48 ).latin1() );
+ }
+
+ qApp->processEvents();
+
+ for ( QValueList<CharMappingItem>::ConstIterator cmit = m_charMapping.begin(); cmit != m_charMapping.end(); ++cmit )
+ result.replace(( *cmit ).unicode, ( *cmit ).latex );
+
+ qApp->processEvents();
+
+ QStringList transformed = QStringList::split( splitMarker, result, true );
+
+ qApp->processEvents();
+
+ result = "";
+ for ( QStringList::Iterator itt = transformed.begin(), iti = intermediate.begin(); itt != transformed.end() && iti != intermediate.end(); ++itt, ++iti )
+ {
+ result.append( *itt );
+
+ ++iti;
+ if ( iti == intermediate.end() )
+ break;
+
+ result.append( "$" ).append( *iti ).append( "$" );
+ }
+
+ qApp->processEvents();
+
+ /** \url accepts unquotet & and _
+ May introduce new problem tough */
+ if ( result.contains( "\\url{" ) )
+ result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( QChar( 0x2013 ), "--" ).replace( "\\#", "#" );
+
+ decomposedUTF8toLaTeX( result );
+
+ /** Reinserting original URLs as explained above */
+ pos = 0;
+ int idx = 0;
+ while ( pos >= 0 )
+ {
+ pos = httpRegExp.search( result, pos );
+ if ( pos >= 0 )
+ {
+ ++pos;
+ int len = httpRegExp.cap( 0 ).length();
+ result = result.left( pos - 1 ).append( urls[idx++] ).append( result.mid( pos + len - 1 ) );
+ }
+ }
+
+ return result.replace( startStopMarker,"" );
+ }
+
+ QString EncoderLaTeX::encode( const QString &text, const QChar &replace )
+ {
+ QString result = text;
+ for ( QValueList<CharMappingItem>::ConstIterator it = m_charMapping.begin(); it != m_charMapping.end(); ++it )
+ if (( *it ).unicode == replace )
+ result.replace(( *it ).unicode, ( *it ).latex );
+ return result;
+ }
+
+ QString EncoderLaTeX::encodeSpecialized( const QString & text, const EntryField::FieldType fieldType )
+ {
+ QString result = encode( text );
+
+ switch ( fieldType )
+ {
+ case EntryField::ftPages:
+ result.replace( QChar( 0x2013 ), "--" );
+ break;
+
+ case EntryField::ftURL:
+ result.replace( "\\&", "&" ).replace( "\\_", "_" ).replace( QChar( 0x2013 ), "--" ).replace( "\\#", "#" );
+ break;
+
+ default:
+ break;
+ }
+
+ return result;
+ }
+
+ QString& EncoderLaTeX::decomposedUTF8toLaTeX( QString &text )
+ {
+ for ( QValueList<CombinedMappingItem>::Iterator it = m_combinedMapping.begin(); it != m_combinedMapping.end(); ++it )
+ {
+ int i = ( *it ).regExp.search( text );
+ while ( i >= 0 )
+ {
+ QString a = ( *it ).regExp.cap( 1 );
+ text = text.left( i ) + "\\" + ( *it ).latex + "{" + a + "}" + text.mid( i + 2 );
+ i = ( *it ).regExp.search( text, i + 1 );
+ }
+ }
+
+ return text;
+ }
+
+ void EncoderLaTeX::buildCombinedMapping()
+ {
+ for ( int i = 0; i < decompositionscount; i++ )
+ {
+ CombinedMappingItem item;
+ item.regExp = QRegExp( "(.)" + QString( QChar( decompositions[i].unicode ) ) );
+ item.latex = decompositions[i].latexCommand;
+ m_combinedMapping.append( item );
+ }
+ }
+
+ void EncoderLaTeX::buildCharMapping()
+ {
+ /** encoding and decoding for digraphs such as -- or ?` */
+ for ( int i = 0; i < charmappingdatalatexcount; i++ )
+ {
+ CharMappingItem charMappingItem;
+ charMappingItem.regExp = QRegExp( charmappingdatalatex[ i ].regexp );
+ charMappingItem.unicode = QChar( charmappingdatalatex[ i ].unicode );
+ charMappingItem.latex = QString( charmappingdatalatex[ i ].latex );
+ m_charMapping.append( charMappingItem );
+ }
+
+ /** encoding and decoding for commands such as \AA or \ss */
+ for ( int i = 0; i < commandmappingdatalatexcount; ++i )
+ {
+ /** different types of writing such as {\AA} or \AA{} possible */
+ for ( int j = 0; j < expansionscmdcount; ++j )
+ {
+ CharMappingItem charMappingItem;
+ charMappingItem.regExp = QRegExp( QString( expansionsCmd[j] ).arg( commandmappingdatalatex[i].letters ) );
+ charMappingItem.unicode = QChar( commandmappingdatalatex[i].unicode );
+ if ( charMappingItem.regExp.numCaptures() > 0 )
+ charMappingItem.unicode += QString( "\\1" );
+ charMappingItem.latex = QString( "{\\%1}" ).arg( commandmappingdatalatex[i].letters );
+ m_charMapping.append( charMappingItem );
+ }
+ }
+
+ /** encoding and decoding for letters such as \"a */
+ for ( int i = 0; i < modcharmappingdatalatexcount; ++i )
+ {
+ QString modifierRegExp = QString( modcharmappingdatalatex[i].modifier );
+ QString modifier = modifierRegExp;
+ modifier.replace( "\\^", "^" ).replace( "\\\\", "\\" );
+
+ /** first batch of replacement rules, where no separator is required between modifier and character (e.g. \"a) */
+ if ( !modifierRegExp.at( modifierRegExp.length() - 1 ).isLetter() )
+ for ( int j = 0; j < expansionsmod2count; ++j )
+ {
+ CharMappingItem charMappingItem;
+ charMappingItem.regExp = QRegExp( QString( expansionsMod2[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) );
+ charMappingItem.unicode = QChar( modcharmappingdatalatex[i].unicode );
+ charMappingItem.latex = QString( "{%1%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter );
+ m_charMapping.append( charMappingItem );
+ }
+
+ /** second batch of replacement rules, where a separator is required between modifier and character (e.g. \v{g}) */
+ for ( int j = 0; j < expansionsmod1count; ++j )
+ {
+ CharMappingItem charMappingItem;
+ charMappingItem.regExp = QRegExp( QString( expansionsMod1[j] ).arg( modifierRegExp ).arg( modcharmappingdatalatex[i].letter ) );
+ charMappingItem.unicode = QChar( modcharmappingdatalatex[i].unicode );
+ charMappingItem.latex = QString( "%1{%2}" ).arg( modifier ).arg( modcharmappingdatalatex[i].letter );
+ m_charMapping.append( charMappingItem );
+ }
+ }
+ }
+
+ EncoderLaTeX* EncoderLaTeX::currentEncoderLaTeX()
+ {
+ if ( encoderLaTeX == NULL )
+ encoderLaTeX = new EncoderLaTeX();
+
+ return encoderLaTeX;
+ }
+
+ void EncoderLaTeX::deleteCurrentEncoderLaTeX()
+ {
+ if ( encoderLaTeX != NULL )
+ {
+ delete encoderLaTeX;
+ encoderLaTeX = NULL;
+ }
+ }
+
+ char EncoderLaTeX::unicodeToASCII( unsigned int unicode )
+ {
+ if ( unicode < 128 ) return ( char )unicode;
+ for ( int i = 0; i < modcharmappingdatalatexcount; ++i )
+ if ( modcharmappingdatalatex[i].unicode == unicode )
+ return *modcharmappingdatalatex[i].letter;
+ return '?';
+ }
+
+}
diff --git a/src/encoderlatex.h b/src/encoderlatex.h
new file mode 100644
index 0000000..d301652
--- /dev/null
+++ b/src/encoderlatex.h
@@ -0,0 +1,78 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef ENCODERLATEX_H
+#define ENCODERLATEX_H
+
+#include <qvaluelist.h>
+#include <qregexp.h>
+
+#include <encoder.h>
+#include <entry.h>
+
+class QString;
+
+namespace BibTeX
+{
+
+ class EncoderLaTeX: public Encoder
+ {
+ public:
+ EncoderLaTeX();
+ ~EncoderLaTeX();
+
+ QString decode( const QString &text );
+ QString encode( const QString &text );
+ QString encode( const QString &text, const QChar &replace );
+ QString encodeSpecialized( const QString &text, const EntryField::FieldType fieldType = EntryField::ftUnknown );
+ QString& decomposedUTF8toLaTeX( QString &text );
+
+ static EncoderLaTeX *currentEncoderLaTeX();
+ static void deleteCurrentEncoderLaTeX();
+
+ static char unicodeToASCII( unsigned int unicode );
+
+ private:
+ static EncoderLaTeX *encoderLaTeX;
+
+ struct CombinedMappingItem
+ {
+ QRegExp regExp;
+ QString latex;
+ };
+
+ QValueList<CombinedMappingItem> m_combinedMapping;
+
+ void buildCombinedMapping();
+
+ struct CharMappingItem
+ {
+ QRegExp regExp;
+ QString unicode;
+ QString latex;
+ };
+
+ QValueList<CharMappingItem> m_charMapping;
+
+ void buildCharMapping();
+ };
+
+}
+
+#endif // ENCODERLATEX_H
diff --git a/src/encoderxml.cpp b/src/encoderxml.cpp
new file mode 100644
index 0000000..bbb76dd
--- /dev/null
+++ b/src/encoderxml.cpp
@@ -0,0 +1,127 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qregexp.h>
+
+#include "encoderxml.h"
+
+namespace BibTeX
+{
+ EncoderXML *encoderXML = NULL;
+
+ static const struct EncoderXMLCharMapping
+ {
+ const char *regexp;
+ unsigned int unicode;
+ const char *latex;
+ }
+ charmappingdataxml[] =
+ {
+ {"&amp;", 0x0026, "&amp;"},
+ {"&lt;", 0x003C, "&lt;"},
+ {"&gt;", 0x003E, "&gt;"}
+ };
+ static const int charmappingdataxmlcount = sizeof( charmappingdataxml ) / sizeof( charmappingdataxml[ 0 ] ) ;
+
+ EncoderXML::EncoderXML()
+ : Encoder()
+ {
+ buildCharMapping();
+ }
+
+
+ EncoderXML::~EncoderXML()
+ {
+ // nothing
+ }
+
+ QString EncoderXML::decode( const QString &text )
+ {
+ QString result = text;
+
+ for ( QValueList<CharMappingItem>::ConstIterator it = m_charMapping.begin(); it != m_charMapping.end(); ++it )
+ result.replace(( *it ).regExp, ( *it ).unicode );
+
+ /**
+ * Find and replace all characters written as hexadecimal number
+ */
+ int p = -1;
+ while (( p = result.find( "&#x", p + 1 ) ) >= 0 )
+ {
+ int p2 = result.find( ";", p + 1 );
+ if ( p2 < 0 ) break;
+ bool ok = FALSE;
+ int hex = result.mid( p + 3, p2 - p - 3 ).toInt( &ok, 16 );
+ if ( ok && hex > 0 )
+ result.replace( result.mid( p, p2 - p + 1 ), QChar( hex ) );
+ }
+
+ /**
+ * Find and replace all characters written as decimal number
+ */
+ p = -1;
+ while (( p = result.find( "&#", p + 1 ) ) >= 0 )
+ {
+ int p2 = result.find( ";", p + 1 );
+ if ( p2 < 0 ) break;
+ bool ok = FALSE;
+ int dec = result.mid( p + 2, p2 - p - 2 ).toInt( &ok, 10 );
+ if ( ok && dec > 0 )
+ result.replace( result.mid( p, p2 - p + 1 ), QChar( dec ) );
+ }
+
+ return result;
+ }
+
+ QString EncoderXML::encode( const QString &text )
+ {
+ QString result = text;
+
+ for ( QValueList<CharMappingItem>::ConstIterator it = m_charMapping.begin(); it != m_charMapping.end(); ++it )
+ result.replace(( *it ).unicode, ( *it ).latex );
+
+ return result;
+ }
+
+ QString EncoderXML::encodeSpecialized( const QString &text, const EntryField::FieldType /* fieldType */ )
+ {
+ return encode( text );
+ }
+
+ void EncoderXML::buildCharMapping()
+ {
+ for ( int i = 0; i < charmappingdataxmlcount; i++ )
+ {
+ CharMappingItem charMappingItem;
+ charMappingItem.regExp = QRegExp( charmappingdataxml[ i ].regexp );
+ charMappingItem.unicode = QChar( charmappingdataxml[ i ].unicode );
+ charMappingItem.latex = QString( charmappingdataxml[ i ].latex );
+ m_charMapping.append( charMappingItem );
+ }
+ }
+
+ EncoderXML *EncoderXML::currentEncoderXML()
+ {
+ if ( encoderXML == NULL )
+ encoderXML = new EncoderXML();
+
+ return encoderXML;
+ }
+
+}
diff --git a/src/encoderxml.h b/src/encoderxml.h
new file mode 100644
index 0000000..89e1be1
--- /dev/null
+++ b/src/encoderxml.h
@@ -0,0 +1,64 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXENCODERXML_H
+#define BIBTEXENCODERXML_H
+
+#include <qptrlist.h>
+#include <qregexp.h>
+
+#include <encoder.h>
+
+class QString;
+class QRegExp;
+
+namespace BibTeX
+{
+
+ /**
+ @author Thomas Fischer
+ */
+ class EncoderXML : public Encoder
+ {
+ public:
+ EncoderXML();
+ ~EncoderXML();
+
+ QString decode( const QString &text );
+ QString encode( const QString &text );
+ QString encodeSpecialized( const QString &text, const EntryField::FieldType fieldType = EntryField::ftUnknown );
+
+ static EncoderXML *currentEncoderXML();
+
+ private:
+ struct CharMappingItem
+ {
+ QRegExp regExp;
+ QChar unicode;
+ QString latex;
+ };
+
+ QValueList<CharMappingItem> m_charMapping;
+
+ void buildCharMapping();
+ };
+
+}
+
+#endif
diff --git a/src/entry.cpp b/src/entry.cpp
new file mode 100644
index 0000000..fcd81fd
--- /dev/null
+++ b/src/entry.cpp
@@ -0,0 +1,714 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qregexp.h>
+
+#include <entry.h>
+#include <file.h>
+#include <xsltransform.h>
+#include <entryfield.h>
+
+#define max(a,b) ((a)>(b)?(a):(b))
+
+namespace BibTeX
+{
+
+ Entry::Entry( )
+ : Element(), m_entryType( etUnknown ), m_entryTypeString( QString::null ), m_id( QString::null )
+ {
+ // nothing
+ }
+
+ Entry::Entry( const EntryType entryType, const QString &id )
+ : Element( ), m_entryType( entryType ), m_id( id )
+ {
+ m_entryTypeString = entryTypeToString( entryType );
+ }
+
+ Entry::Entry( const QString& entryTypeString, const QString& id ) : Element( ), m_entryTypeString( entryTypeString ), m_id( id )
+ {
+ m_entryType = entryTypeFromString( entryTypeString );
+ if ( m_entryType != etUnknown )
+ m_entryTypeString = entryTypeToString( m_entryType );
+ }
+
+ Entry::Entry( const Entry *other )
+ {
+ copyFrom( other );
+ }
+
+ Entry::~Entry()
+ {
+ for ( EntryFields::iterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ {
+ delete( *it );
+ }
+ }
+
+ Element* Entry::clone()
+ {
+ return new Entry( this );
+ }
+
+ bool Entry::equals( const Entry &other )
+ {
+ if ( other.id().compare( id() ) != 0 )
+ return false;
+
+ for ( EntryFields::iterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ {
+ EntryField *field1 = *it;
+ EntryField *field2 = other.getField( field1->fieldTypeName() );
+
+ if ( field2 == NULL || field1->value() == NULL || field2->value() == NULL || field1->value()->text().compare( field2->value()->text() ) != 0 )
+ return false;
+ }
+
+ return true;
+ }
+
+ QString Entry::text() const
+ {
+ QString result = "Id: ";
+ result.append( m_id ).append( " (" ).append( entryTypeString() ).append( ")\n" );
+
+ for ( EntryFields::ConstIterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ {
+ result.append(( *it )->fieldTypeName() ).append( ": " );
+ result.append(( *it )->value()->text() ).append( "\n" );
+ }
+
+ return result;
+ }
+
+ void Entry::setEntryType( const EntryType entryType )
+ {
+ m_entryType = entryType;
+ m_entryTypeString = entryTypeToString( entryType );
+ }
+
+ void Entry::setEntryTypeString( const QString& entryTypeString )
+ {
+ m_entryTypeString = entryTypeString;
+ m_entryType = entryTypeFromString( entryTypeString );
+ }
+
+ Entry::EntryType Entry::entryType() const
+ {
+ return m_entryType;
+ }
+
+ QString Entry::entryTypeString() const
+ {
+ return m_entryTypeString;
+ }
+
+ void Entry::setId( const QString& id )
+ {
+ m_id = id;
+ }
+
+ QString Entry::id() const
+ {
+ return m_id;
+ }
+
+ bool Entry::containsPattern( const QString & pattern, EntryField::FieldType fieldType, BibTeX::Element::FilterType filterType, bool caseSensitive ) const
+ {
+ if ( filterType == ftExact )
+ {
+ /** check for exact match */
+ bool result = fieldType == EntryField::ftUnknown && m_id.contains( pattern, caseSensitive );
+
+ for ( EntryFields::ConstIterator it = m_fields.begin(); !result && it != m_fields.end(); it++ )
+ if ( fieldType == EntryField::ftUnknown || ( *it ) ->fieldType() == fieldType )
+ result |= ( *it ) ->value() ->containsPattern( pattern, caseSensitive );
+
+ return result;
+ }
+ else
+ {
+ /** for each word in the search pattern ... */
+ QStringList words = QStringList::split( QRegExp( "\\s+" ), pattern );
+ bool *hits = new bool[words.count()];
+ int i = 0;
+ for ( QStringList::Iterator wit = words.begin(); wit != words.end(); ++wit, ++i )
+ {
+ hits[i] = fieldType == EntryField::ftUnknown && m_id.contains( *wit, caseSensitive );
+
+ /** check if word is contained in any field */
+ for ( EntryFields::ConstIterator fit = m_fields.begin(); fit != m_fields.end(); ++fit )
+ if ( fieldType == EntryField::ftUnknown || ( *fit ) ->fieldType() == fieldType )
+ hits[i] |= ( *fit ) ->value() ->containsPattern( *wit, caseSensitive );
+ }
+
+ unsigned int hitCount = 0;
+ for ( i = words.count() - 1; i >= 0; --i )
+ if ( hits[i] ) ++hitCount;
+ delete[] hits;
+
+ /** return success depending on filter type and number of hits */
+ return (( filterType == ftAnyWord && hitCount > 0 ) || ( filterType == ftEveryWord && hitCount == words.count() ) );
+ }
+ }
+
+ QStringList Entry::urls() const
+ {
+ QStringList result;
+ const QString fieldNames[] = {"localfile", "pdf", "ps", "postscript", "doi", "url", "howpublished", "ee", "biburl", "note"};
+ const int fieldNamesCount = sizeof( fieldNames ) / sizeof( fieldNames[0] );
+
+ for ( int j = 1; j < 5 ; ++j ) /** there may be variants such as url3 or doi2 */
+ for ( int i = 0; i < fieldNamesCount; i++ )
+ {
+ QString fieldName = fieldNames[i];
+ /** field names should be like url, url2, url3, ... */
+ if ( j > 1 ) fieldName.append( QString::number( j ) );
+
+ EntryField * field = getField( fieldName );
+ if (( field && !field->value()->items.isEmpty() ) )
+ {
+ PlainText *plainText = dynamic_cast<PlainText*>( field->value()->items.first() );
+ if ( plainText != NULL )
+ {
+ QString plain = plainText->text();
+ int urlPos = plain.find( "\\url{", 0, FALSE );
+ if ( urlPos > -1 )
+ {
+ plain = plain.mid( urlPos + 5 );
+ urlPos = plain.find( "}", 0, FALSE );
+ if ( urlPos > 0 )
+ plain = plain.left( urlPos - 1 );
+ }
+
+ if ( fieldNames[ i ] == "doi" && !plain.startsWith( "http", FALSE ) )
+ plain.prepend( "http://dx.doi.org/" );
+
+ result.append( plain );
+ }
+ }
+ }
+
+ return result;
+ }
+
+ bool Entry::addField( EntryField * field )
+ {
+ m_fields.append( field );
+ return TRUE;
+ }
+
+ EntryField* Entry::getField( const EntryField::FieldType fieldType ) const
+ {
+ EntryField * result = NULL;
+
+ for ( EntryFields::ConstIterator it = m_fields.begin(); ( it != m_fields.end() ) && ( result == NULL ); it++ )
+ if (( *it ) ->fieldType() == fieldType ) result = *it;
+
+ return result;
+ }
+
+ EntryField* Entry::getField( const QString & fieldName ) const
+ {
+ EntryField * result = NULL;
+
+ for ( EntryFields::ConstIterator it = m_fields.begin(); ( it != m_fields.end() ) && ( result == NULL ); it++ )
+ if (( *it ) ->fieldTypeName().lower() == fieldName.lower() )
+ result = *it;
+
+ return result;
+ }
+
+ bool Entry::deleteField( const QString & fieldName )
+ {
+ for ( EntryFields::ConstIterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ if (( *it ) ->fieldTypeName().lower() == fieldName.lower() )
+ {
+ delete( *it );
+ m_fields.remove( *it );
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ bool Entry::deleteField( const EntryField::FieldType fieldType )
+ {
+ for ( EntryFields::iterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ if (( *it ) ->fieldType() == fieldType )
+ {
+ delete( *it );
+ m_fields.remove( it );
+ return TRUE;
+ }
+
+ return FALSE;
+ }
+
+ Entry::EntryFields::ConstIterator Entry::begin() const
+ {
+ return m_fields.constBegin();
+ }
+
+ Entry::EntryFields::ConstIterator Entry::end() const
+ {
+ return m_fields.constEnd();
+ }
+
+ int Entry::getFieldCount() const
+ {
+ return m_fields.count();
+ }
+
+ void Entry::clearFields()
+ {
+ for ( EntryFields::iterator it = m_fields.begin(); it != m_fields.end(); it++ )
+ delete( *it );
+ m_fields.clear();
+ }
+
+ void Entry::copyFrom( const Entry *other )
+ {
+ if ( other == NULL ) return;
+
+ m_entryType = other->m_entryType;
+ m_entryTypeString = other->m_entryTypeString;
+ m_id = other->m_id;
+ clearFields();
+ for ( EntryFields::ConstIterator it = other->m_fields.begin(); it != other->m_fields.end(); it++ )
+ m_fields.append( new EntryField( *it ) );
+ }
+
+ void Entry::merge( BibTeX::Entry *other, MergeSemantics mergeSemantics )
+ {
+ for ( EntryFields::iterator it = other->m_fields.begin(); it != other->m_fields.end(); it++ )
+ {
+ EntryField *otherField = new EntryField( *it );
+ EntryField::FieldType otherFieldType = otherField->fieldType();
+ QString otherFieldTypeName = otherField->fieldTypeName();
+ EntryField *thisField = otherFieldType != EntryField::ftUnknown ? getField( otherFieldType ) : getField( otherFieldTypeName );
+
+ if ( thisField == NULL )
+ {
+ m_fields.append( otherField );
+ }
+ else if ( otherField->value()->text() == thisField->value()->text() && mergeSemantics == msForceAdding )
+ {
+ otherFieldTypeName.prepend( "OPT" );
+ otherField->setFieldType( EntryField::ftUnknown, otherFieldTypeName );
+ m_fields.append( otherField );
+ }
+ }
+ }
+
+ QString Entry::entryTypeToString( const EntryType entryType )
+ {
+ switch ( entryType )
+ {
+ case etArticle:
+ return QString( "Article" );
+ case etBook:
+ return QString( "Book" );
+ case etBooklet:
+ return QString( "Booklet" );
+ case etCollection:
+ return QString( "Collection" );
+ case etElectronic:
+ return QString( "Electronic" );
+ case etInBook:
+ return QString( "InBook" );
+ case etInCollection:
+ return QString( "InCollection" );
+ case etInProceedings:
+ return QString( "InProceedings" );
+ case etManual:
+ return QString( "Manual" );
+ case etMastersThesis:
+ return QString( "MastersThesis" );
+ case etMisc:
+ return QString( "Misc" );
+ case etPhDThesis:
+ return QString( "PhDThesis" );
+ case etProceedings:
+ return QString( "Proceedings" );
+ case etTechReport:
+ return QString( "TechReport" );
+ case etUnpublished:
+ return QString( "Unpublished" );
+ default:
+ return QString( "Unknown" );
+ }
+ }
+
+ Entry::EntryType Entry::entryTypeFromString( const QString & entryTypeString )
+ {
+ QString entryTypeStringLower = entryTypeString.lower();
+ if ( entryTypeStringLower == "article" )
+ return etArticle;
+ else if ( entryTypeStringLower == "book" )
+ return etBook;
+ else if ( entryTypeStringLower == "booklet" )
+ return etBooklet;
+ else if ( entryTypeStringLower == "collection" )
+ return etCollection;
+ else if (( entryTypeStringLower == "electronic" ) || ( entryTypeStringLower == "online" ) || ( entryTypeStringLower == "internet" ) || ( entryTypeStringLower == "webpage" ) )
+ return etElectronic;
+ else if ( entryTypeStringLower == "inbook" )
+ return etInBook;
+ else if ( entryTypeStringLower == "incollection" )
+ return etInCollection;
+ else if (( entryTypeStringLower == "inproceedings" ) || ( entryTypeStringLower == "conference" ) )
+ return etInProceedings;
+ else if ( entryTypeStringLower == "manual" )
+ return etManual;
+ else if ( entryTypeStringLower == "mastersthesis" )
+ return etMastersThesis;
+ else if ( entryTypeStringLower == "misc" )
+ return etMisc;
+ else if ( entryTypeStringLower == "phdthesis" )
+ return etPhDThesis;
+ else if ( entryTypeStringLower == "proceedings" )
+ return etProceedings;
+ else if ( entryTypeStringLower == "techreport" )
+ return etTechReport;
+ else if ( entryTypeStringLower == "unpublished" )
+ return etUnpublished;
+ else
+ return etUnknown;
+ }
+
+ Entry::FieldRequireStatus Entry::getRequireStatus( Entry::EntryType entryType, EntryField::FieldType fieldType )
+ {
+ switch ( entryType )
+ {
+ case etArticle:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftJournal:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftVolume:
+ case EntryField::ftMonth:
+ case EntryField::ftDoi:
+ case EntryField::ftNumber:
+ case EntryField::ftPages:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftISSN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etBook:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftEditor:
+ case EntryField::ftTitle:
+ case EntryField::ftPublisher:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftVolume:
+ case EntryField::ftNumber:
+ case EntryField::ftSeries:
+ case EntryField::ftAddress:
+ case EntryField::ftDoi:
+ case EntryField::ftEdition:
+ case EntryField::ftMonth:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etBooklet:
+ switch ( fieldType )
+ {
+ case EntryField::ftTitle:
+ return Entry::frsRequired;
+ case EntryField::ftAuthor:
+ case EntryField::ftHowPublished:
+ case EntryField::ftAddress:
+ case EntryField::ftDoi:
+ case EntryField::ftMonth:
+ case EntryField::ftYear:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etElectronic:
+ switch ( fieldType )
+ {
+ case EntryField::ftTitle:
+ case EntryField::ftURL:
+ return Entry::frsRequired;
+ case EntryField::ftAuthor:
+ case EntryField::ftHowPublished:
+ case EntryField::ftDoi:
+ case EntryField::ftMonth:
+ case EntryField::ftYear:
+ case EntryField::ftKey:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etInBook:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftEditor:
+ case EntryField::ftTitle:
+ case EntryField::ftPages:
+ case EntryField::ftChapter:
+ case EntryField::ftPublisher:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftVolume:
+ case EntryField::ftSeries:
+ case EntryField::ftAddress:
+ case EntryField::ftDoi:
+ case EntryField::ftEdition:
+ case EntryField::ftMonth:
+ case EntryField::ftNote:
+ case EntryField::ftCrossRef:
+ case EntryField::ftKey:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etInCollection:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftBookTitle:
+ case EntryField::ftPublisher:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftEditor:
+ case EntryField::ftPages:
+ case EntryField::ftOrganization:
+ case EntryField::ftAddress:
+ case EntryField::ftMonth:
+ case EntryField::ftLocation:
+ case EntryField::ftNote:
+ case EntryField::ftCrossRef:
+ case EntryField::ftDoi:
+ case EntryField::ftKey:
+ case EntryField::ftType:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etInProceedings:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftYear:
+ case EntryField::ftBookTitle:
+ return Entry::frsRequired;
+ case EntryField::ftPages:
+ case EntryField::ftEditor:
+ case EntryField::ftVolume:
+ case EntryField::ftNumber:
+ case EntryField::ftSeries:
+ case EntryField::ftType:
+ case EntryField::ftChapter:
+ case EntryField::ftAddress:
+ case EntryField::ftDoi:
+ case EntryField::ftEdition:
+ case EntryField::ftLocation:
+ case EntryField::ftMonth:
+ case EntryField::ftNote:
+ case EntryField::ftCrossRef:
+ case EntryField::ftPublisher:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etManual:
+ switch ( fieldType )
+ {
+ case EntryField::ftTitle:
+ return Entry::frsRequired;
+ case EntryField::ftAuthor:
+ case EntryField::ftOrganization:
+ case EntryField::ftAddress:
+ case EntryField::ftDoi:
+ case EntryField::ftEdition:
+ case EntryField::ftMonth:
+ case EntryField::ftYear:
+ case EntryField::ftNote:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etMastersThesis:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftSchool:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftAddress:
+ case EntryField::ftMonth:
+ case EntryField::ftDoi:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etMisc:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftHowPublished:
+ case EntryField::ftMonth:
+ case EntryField::ftYear:
+ case EntryField::ftDoi:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etPhDThesis:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftSchool:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftAddress:
+ case EntryField::ftMonth:
+ case EntryField::ftNote:
+ case EntryField::ftDoi:
+ case EntryField::ftKey:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etCollection:
+ case etProceedings:
+ switch ( fieldType )
+ {
+ case EntryField::ftTitle:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftEditor:
+ case EntryField::ftPublisher:
+ case EntryField::ftOrganization:
+ case EntryField::ftAddress:
+ case EntryField::ftMonth:
+ case EntryField::ftLocation:
+ case EntryField::ftNote:
+ case EntryField::ftDoi:
+ case EntryField::ftKey:
+ case EntryField::ftSeries:
+ case EntryField::ftBookTitle:
+ case EntryField::ftISBN:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etTechReport:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftInstitution:
+ case EntryField::ftYear:
+ return Entry::frsRequired;
+ case EntryField::ftType:
+ case EntryField::ftDoi:
+ case EntryField::ftNumber:
+ case EntryField::ftAddress:
+ case EntryField::ftMonth:
+ case EntryField::ftNote:
+ case EntryField::ftKey:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ case EntryField::ftISSN:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ case etUnpublished:
+ switch ( fieldType )
+ {
+ case EntryField::ftAuthor:
+ case EntryField::ftTitle:
+ case EntryField::ftNote:
+ return Entry::frsRequired;
+ case EntryField::ftMonth:
+ case EntryField::ftYear:
+ case EntryField::ftDoi:
+ case EntryField::ftKey:
+ case EntryField::ftURL:
+ case EntryField::ftLocalFile:
+ return Entry::frsOptional;
+ default:
+ return Entry::frsIgnored;
+ }
+ default:
+ return Entry::frsOptional;
+ }
+ }
+}
diff --git a/src/entry.h b/src/entry.h
new file mode 100644
index 0000000..6a8633c
--- /dev/null
+++ b/src/entry.h
@@ -0,0 +1,92 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXBIBTEXENTRY_H
+#define BIBTEXBIBTEXENTRY_H
+
+#include <qvaluelist.h>
+#include <qstringlist.h>
+
+#include <element.h>
+#include <entryfield.h>
+
+class QString;
+class QStringList;
+
+namespace BibTeX
+{
+
+ class Entry : public Element
+ {
+ public:
+ typedef QValueList<BibTeX::EntryField*> EntryFields;
+
+ enum EntryType {etArticle, etBook, etBooklet, etCollection, etElectronic, etInBook, etInCollection, etInProceedings, etManual, etMastersThesis, etMisc, etPhDThesis, etProceedings, etTechReport, etUnpublished, etUnknown};
+
+ enum FieldRequireStatus {frsRequired, frsOptional, frsIgnored};
+
+ enum MergeSemantics {msAddNew, msForceAdding};
+
+ Entry( );
+ Entry( const EntryType entryType, const QString &id );
+ Entry( const QString& entryTypeString, const QString& id );
+ Entry( const Entry *other );
+ virtual ~Entry();
+ Element* clone();
+ bool equals( const Entry &other );
+ QString text() const;
+
+ void setEntryType( const EntryType elementType );
+ void setEntryTypeString( const QString& elementTypeString );
+ EntryType entryType() const;
+ QString entryTypeString() const;
+ void setId( const QString& id );
+ QString id() const;
+
+ bool containsPattern( const QString& pattern, EntryField::FieldType fieldType = EntryField::ftUnknown, BibTeX::Element::FilterType filterType = BibTeX::Element::ftExact, bool caseSensitive = FALSE ) const;
+ QStringList urls() const;
+
+ bool addField( EntryField *field );
+ BibTeX::EntryField* getField( const EntryField::FieldType fieldType ) const;
+ BibTeX::EntryField* getField( const QString& fieldName ) const;
+ bool deleteField( const BibTeX::EntryField::FieldType fieldType );
+ bool deleteField( const QString &fieldName );
+
+ EntryFields::const_iterator begin() const;
+ EntryFields::const_iterator end() const;
+ int getFieldCount() const;
+ void clearFields();
+
+ void copyFrom( const BibTeX::Entry *other );
+ void merge( BibTeX::Entry *other, MergeSemantics mergeSemantics );
+
+ static QString entryTypeToString( const EntryType entryType );
+ static EntryType entryTypeFromString( const QString &entryTypeString );
+ static Entry::FieldRequireStatus getRequireStatus( Entry::EntryType entryType, EntryField::FieldType fieldType );
+
+ private:
+ EntryType m_entryType;
+ QString m_entryTypeString;
+ QString m_id;
+ EntryFields m_fields;
+ };
+
+}
+
+#endif
diff --git a/src/entryfield.cpp b/src/entryfield.cpp
new file mode 100644
index 0000000..bb7cb9d
--- /dev/null
+++ b/src/entryfield.cpp
@@ -0,0 +1,227 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include "entryfield.h"
+
+namespace BibTeX
+{
+
+ EntryField::EntryField( FieldType fieldType ) : m_fieldType( fieldType )
+ {
+ m_fieldTypeName = fieldTypeToString( m_fieldType );
+ m_value = new Value();
+ }
+
+ EntryField::EntryField( const QString &fieldTypeName ) : m_fieldTypeName( fieldTypeName )
+ {
+ m_fieldType = fieldTypeFromString( m_fieldTypeName );
+ m_value = new Value();
+ }
+
+ EntryField::EntryField( BibTeX::EntryField *other ) : m_fieldType( other->m_fieldType ), m_fieldTypeName( other->m_fieldTypeName ), m_value( NULL )
+ {
+ setValue( other->m_value );
+ }
+
+ EntryField::~EntryField()
+ {
+ delete m_value;
+ }
+
+ QString EntryField::fieldTypeName() const
+ {
+ return m_fieldTypeName;
+ }
+
+ void EntryField::setFieldType( FieldType fieldType, const QString& fieldTypeName )
+ {
+ m_fieldType = fieldType;
+ m_fieldTypeName = fieldTypeName;
+ }
+
+ EntryField::FieldType EntryField::fieldType() const
+ {
+ return m_fieldType;
+ }
+
+ QString EntryField::fieldTypeToString( const FieldType fieldType )
+ {
+ switch ( fieldType )
+ {
+ case ftAbstract:
+ return QString( "abstract" );
+ case ftAddress:
+ return QString( "address" );
+ case ftAnnote:
+ return QString( "annote" );
+ case ftAuthor:
+ return QString( "author" );
+ case ftBookTitle:
+ return QString( "booktitle" );
+ case ftChapter:
+ return QString( "chapter" );
+ case ftCrossRef:
+ return QString( "crossref" );
+ case ftDoi:
+ return QString( "doi" );
+ case ftEdition:
+ return QString( "edition" );
+ case ftEditor:
+ return QString( "editor" );
+ case ftHowPublished:
+ return QString( "howpublished" );
+ case ftInstitution:
+ return QString( "institution" );
+ case ftISBN:
+ return QString( "isbn" );
+ case ftISSN:
+ return QString( "issn" );
+ case ftJournal:
+ return QString( "journal" );
+ case ftKey:
+ return QString( "key" );
+ case ftKeywords:
+ return QString( "keywords" );
+ case ftLocalFile:
+ return QString( "localfile" );
+ case ftLocation:
+ return QString( "location" );
+ case ftMonth:
+ return QString( "month" );
+ case ftNote:
+ return QString( "note" );
+ case ftNumber:
+ return QString( "number" );
+ case ftOrganization:
+ return QString( "organization" );
+ case ftPages:
+ return QString( "pages" );
+ case ftPublisher:
+ return QString( "publisher" );
+ case ftSeries:
+ return QString( "series" );
+ case ftSchool:
+ return QString( "school" );
+ case ftTitle:
+ return QString( "title" );
+ case ftType:
+ return QString( "type" );
+ case ftURL:
+ return QString( "url" );
+ case ftVolume:
+ return QString( "volume" );
+ case ftYear:
+ return QString( "year" );
+ default:
+ return QString( "unknown" );
+ }
+ }
+
+ EntryField::FieldType EntryField::fieldTypeFromString( const QString & fieldTypeString )
+ {
+ QString fieldTypeStringLower = fieldTypeString.lower();
+
+ if ( fieldTypeStringLower == "abstract" )
+ return ftAbstract;
+ else if ( fieldTypeStringLower == "address" )
+ return ftAddress;
+ else if ( fieldTypeStringLower == "annote" )
+ return ftAnnote;
+ else if ( fieldTypeStringLower == "author" )
+ return ftAuthor;
+ else if ( fieldTypeStringLower == "booktitle" )
+ return ftBookTitle;
+ else if ( fieldTypeStringLower == "chapter" )
+ return ftChapter;
+ else if ( fieldTypeStringLower == "crossref" )
+ return ftCrossRef;
+ else if ( fieldTypeStringLower == "doi" )
+ return ftDoi;
+ else if ( fieldTypeStringLower == "edition" )
+ return ftEdition;
+ else if ( fieldTypeStringLower == "editor" )
+ return ftEditor;
+ else if ( fieldTypeStringLower == "howpublished" )
+ return ftHowPublished;
+ else if ( fieldTypeStringLower == "institution" )
+ return ftInstitution;
+ else if ( fieldTypeStringLower == "isbn" )
+ return ftISBN;
+ else if ( fieldTypeStringLower == "issn" )
+ return ftISSN;
+ else if ( fieldTypeStringLower == "journal" )
+ return ftJournal;
+ else if ( fieldTypeStringLower == "key" )
+ return ftKey;
+ else if ( fieldTypeStringLower == "keywords" )
+ return ftKeywords;
+ else if ( fieldTypeStringLower == "localfile" )
+ return ftLocalFile;
+ else if ( fieldTypeStringLower == "location" )
+ return ftLocation;
+ else if ( fieldTypeStringLower == "month" )
+ return ftMonth;
+ else if ( fieldTypeStringLower == "note" )
+ return ftNote;
+ else if ( fieldTypeStringLower == "number" )
+ return ftNumber;
+ else if ( fieldTypeStringLower == "organization" )
+ return ftOrganization;
+ else if ( fieldTypeStringLower == "pages" )
+ return ftPages;
+ else if ( fieldTypeStringLower == "publisher" )
+ return ftPublisher;
+ else if ( fieldTypeStringLower == "series" )
+ return ftSeries;
+ else if ( fieldTypeStringLower == "school" )
+ return ftSchool;
+ else if ( fieldTypeStringLower == "title" )
+ return ftTitle;
+ else if ( fieldTypeStringLower == "type" )
+ return ftType;
+ else if ( fieldTypeStringLower == "url" )
+ return ftURL;
+ else if ( fieldTypeStringLower == "volume" )
+ return ftVolume;
+ else if ( fieldTypeStringLower == "year" )
+ return ftYear;
+ else
+ return ftUnknown;
+ }
+
+ Value *EntryField::value()
+ {
+ return m_value;
+ }
+
+ void EntryField::setValue( const Value *value )
+ {
+ if ( value != m_value )
+ {
+ delete m_value;
+
+ if ( value != NULL )
+ {
+ m_value = new Value( value );
+ }
+ else
+ m_value = new Value();
+ }
+ }
+}
diff --git a/src/entryfield.h b/src/entryfield.h
new file mode 100644
index 0000000..6b3af30
--- /dev/null
+++ b/src/entryfield.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXBIBTEXENTRYFIELD_H
+#define BIBTEXBIBTEXENTRYFIELD_H
+
+#include <qstring.h>
+
+#include <value.h>
+
+namespace BibTeX
+{
+ class EntryField
+ {
+ public:
+ enum FieldType {ftAbstract, ftAddress, ftAnnote, ftAuthor, ftBookTitle, ftChapter, ftCrossRef, ftDoi, ftEdition, ftEditor, ftHowPublished, ftInstitution, ftISBN, ftISSN, ftJournal, ftKey, ftKeywords, ftLocalFile, ftLocation, ftMonth, ftNote, ftNumber, ftOrganization, ftPages, ftPublisher, ftSchool, ftSeries, ftTitle, ftType, ftURL, ftVolume, ftYear, ftUnknown = -1};
+
+ EntryField( FieldType fieldType );
+ EntryField( const QString &fieldTypeName );
+ EntryField( BibTeX::EntryField *other );
+ ~EntryField();
+
+ QString fieldTypeName() const;
+ FieldType fieldType() const;
+ void setFieldType( FieldType fieldType, const QString& fieldTypeName );
+
+ static QString fieldTypeToString( const FieldType fieldType );
+ static FieldType fieldTypeFromString( const QString &fieldTypeString );
+
+ BibTeX::Value *value();
+ void setValue( const BibTeX::Value *value );
+
+ private:
+ FieldType m_fieldType;
+ QString m_fieldTypeName;
+ Value *m_value;
+ };
+
+}
+
+#endif
diff --git a/src/entrywidget.cpp b/src/entrywidget.cpp
new file mode 100644
index 0000000..cb4c7ff
--- /dev/null
+++ b/src/entrywidget.cpp
@@ -0,0 +1,677 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qlistview.h>
+#include <qlabel.h>
+#include <qregexp.h>
+#include <qpushbutton.h>
+#include <qpopupmenu.h>
+#include <qtabwidget.h>
+#include <qcombobox.h>
+#include <qtimer.h>
+#include <qlineedit.h>
+
+#include <klocale.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+#include <kmessagebox.h>
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kwin.h>
+
+#include <entry.h>
+#include <entryfield.h>
+#include <file.h>
+#include <settings.h>
+#include <entrywidgettab.h>
+#include <entrywidgettitle.h>
+#include <entrywidgetauthor.h>
+#include <entrywidgetkeyword.h>
+#include <entrywidgetpublication.h>
+#include <entrywidgetmisc.h>
+#include <entrywidgetexternal.h>
+#include <entrywidgetuserdefined.h>
+#include <entrywidgetother.h>
+#include <entrywidgetwarningsitem.h>
+#include <fieldlistview.h>
+#include <idsuggestions.h>
+#include <webqueryarxiv.h>
+#include "entrywidget.h"
+
+namespace KBibTeX
+{
+ QDialog::DialogCode EntryWidget::execute( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QWidget *parent, const char *name )
+ {
+ EntryWidgetDialog *dlg = new EntryWidgetDialog( parent, name, TRUE, i18n( "Edit BibTeX Entry" ), KDialogBase::Ok | KDialogBase::Cancel );
+ EntryWidget *entryWidget = new EntryWidget( entry, bibtexfile, isReadOnly, isNew, dlg, "entryWidget" );
+ dlg->setMainWidget( entryWidget );
+
+ QDialog::DialogCode result = ( QDialog::DialogCode ) dlg->exec();
+
+ delete entryWidget;
+ delete dlg;
+
+ return result;
+ }
+
+ EntryWidget::EntryWidget( BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name )
+ : QWidget( parent, name ), m_originalEntry( NULL ), m_bibtexfile( bibtexfile ), m_isReadOnly( isReadOnly ), m_isNew( isNew ), m_lastPage( NULL ), m_dlgParent( parent ), m_wqa( new WebQueryArXiv( NULL ) )
+ {
+ setupGUI( parent, FALSE );
+
+ Settings * settings = Settings::self();
+ m_checkBoxEnableAll->setChecked( settings->editing_EnableAllFields );
+ m_defaultIdSuggestionAvailable = settings->idSuggestions_default >= 0;
+ m_pushButtonForceDefaultIdSuggestion->setEnabled( !m_isReadOnly && m_defaultIdSuggestionAvailable );
+ m_pushButtonIdSuggestions->setEnabled( !m_isReadOnly );
+
+ connect( m_wqa, SIGNAL( foundEntry( BibTeX::Entry*, bool ) ), this, SLOT( useExternalEntry( BibTeX::Entry*, bool ) ) );
+ connect( m_wqa, SIGNAL( endSearch( WebQuery::Status ) ), this, SLOT( endExternalSearch( WebQuery::Status ) ) );
+ }
+
+ EntryWidget::EntryWidget( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name )
+ : QWidget( parent, name ), m_originalEntry( entry ), m_bibtexfile( bibtexfile ), m_isReadOnly( isReadOnly ), m_isNew( isNew ), m_lastPage( NULL ), m_dlgParent( parent ), m_wqa( new WebQueryArXiv( NULL ) )
+ {
+ setupGUI( parent );
+
+ Settings * settings = Settings::self();
+ m_checkBoxEnableAll->setChecked( settings->editing_EnableAllFields );
+ m_defaultIdSuggestionAvailable = settings->idSuggestions_default >= 0;
+ m_pushButtonForceDefaultIdSuggestion->setEnabled( !m_isReadOnly && m_defaultIdSuggestionAvailable );
+ m_pushButtonIdSuggestions->setEnabled( !m_isReadOnly );
+
+ reset();
+
+ connect( m_wqa, SIGNAL( foundEntry( BibTeX::Entry*, bool ) ), this, SLOT( useExternalEntry( BibTeX::Entry*, bool ) ) );
+ connect( m_wqa, SIGNAL( endSearch( WebQuery::Status ) ), this, SLOT( endExternalSearch( WebQuery::Status ) ) );
+ }
+
+ EntryWidget::~EntryWidget()
+ {
+ m_updateWarningsTimer->stop();
+ delete m_updateWarningsTimer;
+
+ delete m_wqa;
+
+ KConfig * config = kapp->config();
+ config->setGroup( "EntryWidget" );
+ saveWindowSize( config );
+ }
+
+ void EntryWidget::showEvent( QShowEvent *showev )
+ {
+ QWidget::showEvent( showev );
+ EntryWidgetTitle *ewt = dynamic_cast<EntryWidgetTitle*>( m_tabWidget->page( 0 ) );
+ if ( ewt != NULL )
+ ewt->m_fieldLineEditTitle->setFocus();
+
+ KConfig * config = kapp->config();
+ config->setGroup( "EntryWidget" );
+ restoreWindowSize( config );
+ }
+
+ bool EntryWidget::queryClose()
+ {
+ bool isModified = m_lineEditID->isModified();
+
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); !isModified && it != m_internalEntryWidgets.end(); ++it )
+ isModified = ( *it ) ->isModified();
+ isModified |= m_sourcePage->isModified();
+
+ KGuiItem discardBtn = KGuiItem( i18n( "Discard" ), "editshred" );
+ return !isModified || KMessageBox::warningContinueCancel( this, i18n( "The current entry has been modified. Do you want do discard your changes?" ), i18n( "Discard changes" ), discardBtn ) == KMessageBox::Continue;
+ }
+
+ void EntryWidget::apply()
+ {
+ if ( !m_isReadOnly )
+ {
+ apply( m_originalEntry );
+ m_originalEntry->setId( IdSuggestions::resolveConflict( m_bibtexfile, m_originalEntry->id(), m_originalEntry ) );
+
+ Settings * settings = Settings::self();
+ settings->addToCompletion( m_originalEntry );
+ }
+ }
+
+ void EntryWidget::apply( BibTeX::Entry *entry )
+ {
+ internalApply( entry );
+ if ( m_tabWidget->currentPage() == m_sourcePage )
+ m_sourcePage->apply( entry );
+ else
+ {
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->apply( entry );
+ }
+ }
+
+ void EntryWidget::internalApply( BibTeX::Entry *entry )
+ {
+ BibTeX::Entry::EntryType entryType = BibTeX::Entry::entryTypeFromString( m_comboBoxEntryType->currentText() );
+ if ( entryType == BibTeX::Entry::etUnknown )
+ entry->setEntryTypeString( m_comboBoxEntryType->currentText() );
+ else
+ entry->setEntryType( entryType );
+
+ entry->setId( m_lineEditID->text() );
+ }
+
+ void EntryWidget::reset()
+ {
+ reset( m_originalEntry );
+ }
+
+ void EntryWidget::reset( BibTeX::Entry *entry )
+ {
+ internalReset( entry );
+ m_sourcePage->reset( entry );
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->reset( entry );
+
+ updateGUI();
+ }
+
+ void EntryWidget::internalReset( BibTeX::Entry *entry )
+ {
+ m_lineEditID->setText( entry->id() );
+ Settings * settings = Settings::self();
+ m_pushButtonForceDefaultIdSuggestion->setOn( m_defaultIdSuggestionAvailable && settings->idSuggestions_forceDefault && m_isNew );
+ m_pushButtonForceDefaultIdSuggestion->setEnabled( !m_isReadOnly && m_defaultIdSuggestionAvailable );
+
+ bool foundEntryType = FALSE;
+ for ( int i = 0; !foundEntryType && i < m_comboBoxEntryType->count(); i++ )
+ if (( BibTeX::Entry::EntryType ) i + BibTeX::Entry::etArticle == entry->entryType() )
+ {
+ m_comboBoxEntryType->setCurrentItem( i );
+ foundEntryType = TRUE;
+ }
+ if ( !foundEntryType )
+ m_comboBoxEntryType->setCurrentText( entry->entryTypeString() );
+ }
+
+ void EntryWidget::slotEnableAllFields( )
+ {
+ updateGUI();
+ }
+
+ void EntryWidget::slotForceDefaultIdSuggestion()
+ {
+ m_isNew = FALSE;
+ m_lineEditID->setEnabled( !m_pushButtonForceDefaultIdSuggestion->isOn() );
+ m_pushButtonIdSuggestions->setEnabled( !m_pushButtonForceDefaultIdSuggestion->isOn() && !m_isReadOnly );
+ updateWarnings();
+ }
+
+ void EntryWidget::slotEntryTypeChanged( )
+ {
+ updateGUI();
+ }
+
+ void EntryWidget::slotCurrentPageChanged( QWidget* newPage )
+ {
+ BibTeX::Entry temporaryEntry;
+
+ if ( newPage == m_sourcePage )
+ {
+ // switching to source tab
+ m_updateWarningsTimer->stop();
+ internalApply( &temporaryEntry );
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->apply( &temporaryEntry );
+ m_sourcePage->reset( &temporaryEntry );
+
+ m_comboBoxEntryType->setEnabled( FALSE );
+ m_lineEditID->setEnabled( FALSE );
+ m_pushButtonIdSuggestions->setEnabled( FALSE );
+ m_pushButtonForceDefaultIdSuggestion->setEnabled( FALSE );
+ }
+ else if ( m_lastPage == m_sourcePage )
+ {
+ // switching from source tab away
+ bool doApply = true;
+ bool doChange = true;
+ if ( !m_sourcePage->containsValidText() )
+ {
+ if ( KMessageBox::warningYesNo( this, i18n( "The source code does not contain valid BibTeX code.\n\nRestore previous version or continue editing?" ), i18n( "Invalid BibTeX code" ), KGuiItem( i18n( "Restore" ) ), KGuiItem( i18n( "Edit" ) ) ) == KMessageBox::No )
+ {
+ QString text = m_sourcePage->text();
+ m_tabWidget->showPage( m_sourcePage );
+ m_sourcePage->setText( text );
+ doChange = false;
+ newPage = m_sourcePage;
+ }
+ else
+ doApply = false;
+ }
+
+ if ( doChange )
+ {
+ if ( doApply )
+ {
+ m_sourcePage->apply( &temporaryEntry );
+ internalReset( &temporaryEntry );
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->reset( &temporaryEntry );
+ updateWarnings();
+ }
+
+ m_comboBoxEntryType->setEnabled( TRUE );
+ m_lineEditID->setEnabled( !m_defaultIdSuggestionAvailable || !m_pushButtonForceDefaultIdSuggestion->isOn() );
+ m_pushButtonIdSuggestions->setEnabled(( !m_defaultIdSuggestionAvailable || !m_pushButtonForceDefaultIdSuggestion->isOn() ) && !m_isReadOnly );
+ m_pushButtonForceDefaultIdSuggestion->setEnabled( !m_isReadOnly && m_defaultIdSuggestionAvailable );
+ if ( !m_isReadOnly )
+ m_updateWarningsTimer->start( 500 );
+ }
+ }
+
+ m_lastPage = newPage;
+ }
+
+ void EntryWidget::warningsExecute( QListViewItem* item )
+ {
+ EntryWidgetWarningsItem * ewwi = dynamic_cast<KBibTeX::EntryWidgetWarningsItem*>( item );
+ if ( ewwi != NULL && ewwi->widget() != NULL )
+ {
+ ewwi->widget() ->setFocus();
+ // find and activate corresponding tab page
+ QObject *parent = ewwi->widget();
+ KBibTeX::EntryWidgetTab *ewt = dynamic_cast<KBibTeX::EntryWidgetTab*>( parent );
+ while ( ewt == NULL && parent != NULL )
+ {
+ parent = parent->parent();
+ ewt = dynamic_cast<KBibTeX::EntryWidgetTab*>( parent );
+ }
+ m_tabWidget->setCurrentPage( m_tabWidget-> indexOf( ewt ) );
+ }
+ }
+
+ void EntryWidget::setupGUI( QWidget *parent, bool showWarnings )
+ {
+ QGridLayout * layout = new QGridLayout( this, 4, 6, 0, KDialog::spacingHint() );
+
+ // in the top row on the left, put an entry type label and combobox
+ QLabel *label = new QLabel( i18n( "E&ntry Type:" ), this );
+ layout->addWidget( label, 0, 0 );
+ m_comboBoxEntryType = new QComboBox( TRUE, this, "m_comboBoxEntryType" );
+ label->setBuddy( m_comboBoxEntryType );
+ m_comboBoxEntryType->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
+ m_comboBoxEntryType->setEnabled( !m_isReadOnly );
+ layout->addWidget( m_comboBoxEntryType, 0, 1 );
+ setupEntryTypes();
+
+ // in the top row on the left, put an identifier label and combobox
+ label = new QLabel( i18n( "&Identifier" ), this );
+ layout->addWidget( label, 0, 2 );
+ m_lineEditID = new QLineEdit( this, "m_lineEditID" );
+ label->setBuddy( m_lineEditID );
+ m_lineEditID->setReadOnly( m_isReadOnly );
+ m_lineEditID->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
+ layout->addWidget( m_lineEditID, 0, 3 );
+
+ m_pushButtonIdSuggestions = new QPushButton( QIconSet( BarIcon( "wizard" ) ), "", this, "m_pushButtonIdSuggestions" );
+ m_menuIdSuggestions = new QPopupMenu( m_pushButtonIdSuggestions );
+ connect( m_menuIdSuggestions, SIGNAL( activated( int ) ), this, SLOT( insertIdSuggestion( int ) ) );
+ m_pushButtonIdSuggestions->setPopup( m_menuIdSuggestions );
+ layout->addWidget( m_pushButtonIdSuggestions, 0, 4 );
+
+ m_pushButtonForceDefaultIdSuggestion = new QPushButton( QIconSet( BarIcon( "favorites" ) ), "", this, "m_pushButtonForceDefaultIdSuggestion" );
+ m_pushButtonForceDefaultIdSuggestion->setToggleButton( TRUE );
+ layout->addWidget( m_pushButtonForceDefaultIdSuggestion, 0, 5 );
+ QToolTip::add( m_pushButtonForceDefaultIdSuggestion, i18n( "Use the default id suggestion to set the entry id" ) );
+ QWhatsThis::add( m_pushButtonForceDefaultIdSuggestion, i18n( "Use the default id suggestion to set the entry id.\nYou can edit and select the default id suggestion in the configuration dialog." ) );
+
+ // central tab widget for all the tabs
+ m_tabWidget = new QTabWidget( this );
+ layout->addMultiCellWidget( m_tabWidget, 1, 1, 0, 5 );
+ addTabWidgets();
+
+ // a check box if the user want to edit all fields
+ m_checkBoxEnableAll = new QCheckBox( i18n( "Enable all &fields for editing" ), this );
+ layout->addMultiCellWidget( m_checkBoxEnableAll, 2, 2, 0, 4 );
+
+ m_pushButtonRefetch = new QPushButton( KGlobal::iconLoader() ->loadIconSet( "reload", KIcon::Small ), i18n( "Refetch" ), this );
+ layout->addWidget( m_pushButtonRefetch, 2, 5 );
+ connect( m_pushButtonRefetch, SIGNAL( clicked() ), this, SLOT( refreshFromURL() ) );
+
+ if ( showWarnings )
+ {
+ // list view for warnings, errors and suggestions
+ m_listViewWarnings = new QListView( this );
+ m_listViewWarnings->addColumn( i18n( "Message" ) );
+ m_listViewWarnings->setAllColumnsShowFocus( true );
+ layout->addMultiCellWidget( m_listViewWarnings, 3, 3, 0, 5 );
+ connect( m_listViewWarnings, SIGNAL( doubleClicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( warningsExecute( QListViewItem* ) ) );
+ }
+ else
+ m_listViewWarnings = NULL;
+
+ connect( m_checkBoxEnableAll, SIGNAL( toggled( bool ) ), this, SLOT( slotEnableAllFields( ) ) );
+ connect( m_comboBoxEntryType, SIGNAL( activated( int ) ), this, SLOT( slotEntryTypeChanged( ) ) );
+ connect( m_pushButtonForceDefaultIdSuggestion, SIGNAL( toggled( bool ) ), this, SLOT( slotForceDefaultIdSuggestion() ) );
+ connect( m_comboBoxEntryType, SIGNAL( textChanged( const QString & ) ), this, SLOT( slotEntryTypeChanged() ) );
+ connect( m_tabWidget, SIGNAL( currentChanged( QWidget* ) ), this, SLOT( slotCurrentPageChanged( QWidget* ) ) );
+ connect( parent, SIGNAL( okClicked() ), this, SLOT( apply() ) );
+ connect( m_menuIdSuggestions, SIGNAL( aboutToShow() ), this, SLOT( updateIdSuggestionsMenu() ) );
+
+ m_updateWarningsTimer = new QTimer( this );
+ connect( m_updateWarningsTimer, SIGNAL( timeout() ), this, SLOT( updateWarnings() ) );
+ if ( !m_isReadOnly )
+ m_updateWarningsTimer->start( 500 );
+ }
+
+ void EntryWidget::addTabWidgets()
+ {
+ addTabWidget( new KBibTeX::EntryWidgetTitle( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetTitle" ), i18n( "Title" ) );
+ addTabWidget( new KBibTeX::EntryWidgetAuthor( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetAuthor" ), i18n( "Author/Editor" ) );
+ addTabWidget( new KBibTeX::EntryWidgetPublication( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetPublication" ), i18n( "Publication" ) );
+ addTabWidget( new KBibTeX::EntryWidgetMisc( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetMisc" ), i18n( "Misc" ) );
+ addTabWidget( new KBibTeX::EntryWidgetKeyword( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetKeyword" ), i18n( "Keywords" ) );
+ addTabWidget( new KBibTeX::EntryWidgetExternal( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetExternal" ), i18n( "External" ) );
+ addTabWidget( new KBibTeX::EntryWidgetUserDefined( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetUserDefined" ), i18n( "User Defined" ) );
+ addTabWidget( new KBibTeX::EntryWidgetOther( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetOther" ), i18n( "Other Fields" ) );
+
+ m_sourcePage = new KBibTeX::EntryWidgetSource( m_bibtexfile, m_isReadOnly, m_tabWidget, "EntryWidgetSource" );
+ m_tabWidget->insertTab( m_sourcePage, i18n( "Source" ) );
+ }
+
+ void EntryWidget::addTabWidget( EntryWidgetTab *widget, const QString& title )
+ {
+ m_tabWidget->insertTab( widget, title );
+ m_internalEntryWidgets.append( widget );
+ }
+
+ void EntryWidget::setupEntryTypes()
+ {
+ int i = ( int ) BibTeX::Entry::etArticle;
+ BibTeX::Entry::EntryType entryType = ( BibTeX::Entry::EntryType ) i;
+ while ( entryType != BibTeX::Entry::etUnknown )
+ {
+ QString currentString = BibTeX::Entry::entryTypeToString( entryType );
+ m_comboBoxEntryType->insertItem( currentString );
+ entryType = ( BibTeX::Entry::EntryType ) ++i;
+ }
+ }
+
+ void EntryWidget::updateGUI()
+ {
+ BibTeX::Entry::EntryType entryType = BibTeX::Entry::entryTypeFromString( m_comboBoxEntryType->currentText() );
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->updateGUI( entryType, m_checkBoxEnableAll->isChecked() );
+ updateWarnings( );
+ }
+
+ void EntryWidget::updateWarnings()
+ {
+ if ( m_listViewWarnings == NULL )
+ return;
+
+ m_listViewWarnings->clear();
+
+ int p = 0;
+ if ( m_defaultIdSuggestionAvailable && m_pushButtonForceDefaultIdSuggestion->isOn() )
+ {
+ BibTeX::Entry temporaryEntry;
+ apply( &temporaryEntry );
+ QString id = IdSuggestions::createDefaultSuggestion( m_bibtexfile, &temporaryEntry );
+ if ( id.isNull() || id.isEmpty() )
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, i18n( "Please supply more fields to use the default id" ), m_pushButtonForceDefaultIdSuggestion, m_listViewWarnings );
+ else
+ {
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlInformation, QString( i18n( "Using '%1' as entry id" ) ).arg( id ), m_pushButtonForceDefaultIdSuggestion, m_listViewWarnings );
+ m_lineEditID->setText( id );
+ }
+ }
+ else if ( m_lineEditID->text().isEmpty() )
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlError, i18n( "An entry has to have an identifier" ), m_lineEditID, m_listViewWarnings );
+ else if (( p = m_lineEditID->text().find( Settings::noIdChars ) ) > 0 )
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlError, QString( i18n( "The identifier contains invalid characters at position %1" ) ).arg( p + 1 ), m_lineEditID, m_listViewWarnings );
+
+ BibTeX::Entry::EntryType entryType = BibTeX::Entry::entryTypeFromString( m_comboBoxEntryType->currentText() );
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->updateWarnings( entryType, m_listViewWarnings );
+
+ QString text = m_lineEditID->text();
+ for ( unsigned int i = 0; i < text.length(); i++ )
+ if ( text.at( i ).unicode() > 127 )
+ {
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, QString( i18n( "The identifier contains non-ascii characters, first one is '%1'" ) ).arg( text.at( i ) ), m_lineEditID, m_listViewWarnings );
+ break;
+ }
+
+ BibTeX::Entry temporaryEntry;
+ /** fetch data from GUI elements */
+ for ( QValueList<KBibTeX::EntryWidgetTab*>::iterator it( m_internalEntryWidgets.begin() ); it != m_internalEntryWidgets.end(); ++it )
+ ( *it ) ->apply( &temporaryEntry );
+ internalApply( &temporaryEntry );
+
+ /** check if entry with same id already exists */
+ QString id = temporaryEntry.id();
+ if ( m_bibtexfile != NULL && !id.isEmpty() )
+ {
+ BibTeX::Entry *nameMatched = dynamic_cast<BibTeX::Entry*>( m_bibtexfile->containsKey( id ) );
+ if ( nameMatched != NULL && nameMatched != m_originalEntry )
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlError, QString( i18n( "This BibTeX file already contains an entry with id '%1'." ) ).arg( id ), m_lineEditID, m_listViewWarnings );
+ }
+
+ BibTeX::Entry *crossRefEntry = NULL;
+ QString crossRefText = "";
+ BibTeX::EntryField *crossRef = temporaryEntry.getField( BibTeX::EntryField::ftCrossRef );
+ if ( crossRef != NULL && m_bibtexfile != NULL )
+ {
+ crossRefText = crossRef->value()->text();
+ crossRefEntry = dynamic_cast<BibTeX::Entry*>( m_bibtexfile->containsKey( crossRefText ) );
+ }
+
+ switch ( temporaryEntry.entryType() )
+ {
+ case BibTeX::Entry::etProceedings:
+ if ( temporaryEntry.getField( BibTeX::EntryField::ftEditor ) == NULL && temporaryEntry.getField( BibTeX::EntryField::ftOrganization ) == NULL && temporaryEntry.getField( BibTeX::EntryField::ftKey ) == NULL )
+ {
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, i18n( "Require either 'Editor', 'Organization', or 'Key'" ), NULL, m_listViewWarnings );
+ }
+ break;
+ case BibTeX::Entry::etInProceedings:
+ {
+ if ( crossRefEntry != NULL )
+ {
+ if ( crossRefEntry->getField( BibTeX::EntryField::ftEditor ) == NULL && crossRefEntry->getField( BibTeX::EntryField::ftKey ) == NULL && crossRefEntry->getField( BibTeX::EntryField::ftBookTitle ) == NULL )
+ {
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, QString( i18n( "Cross referenced entry '%1' must contain either 'Editor', 'Key', or 'Book Title'" ) ).arg( crossRefText ), NULL, m_listViewWarnings );
+ }
+ }
+ }
+ break;
+ case BibTeX::Entry::etInBook:
+ {
+ if ( crossRefEntry != NULL )
+ {
+ if ( crossRefEntry->getField( BibTeX::EntryField::ftVolume ) == NULL )
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, QString( i18n( "Cross referenced entry '%1' must contain 'Volume'" ) ).arg( crossRefText ), NULL, m_listViewWarnings );
+ if ( crossRefEntry->getField( BibTeX::EntryField::ftEditor ) == NULL && crossRefEntry->getField( BibTeX::EntryField::ftKey ) == NULL && crossRefEntry->getField( BibTeX::EntryField::ftSeries ) == NULL )
+ {
+ new KBibTeX::EntryWidgetWarningsItem( KBibTeX::EntryWidgetWarningsItem::wlWarning, QString( i18n( "Cross referenced entry '%1' must contain either 'Editor', 'Key', or 'Series'" ) ).arg( crossRefText ), NULL, m_listViewWarnings );
+ }
+ }
+ }
+ break;
+ default:
+ {
+// nothing
+ }
+ }
+ }
+
+ void EntryWidget::updateIdSuggestionsMenu()
+ {
+ BibTeX::Entry temporaryEntry;
+ m_menuIdSuggestions->clear();
+ m_idToSuggestion.clear();
+
+ apply( &temporaryEntry );
+ QStringList suggestions = IdSuggestions::createSuggestions( m_bibtexfile, &temporaryEntry );
+ for ( QStringList::ConstIterator it = suggestions.begin(); it != suggestions.end(); ++it )
+ m_idToSuggestion.insert( m_menuIdSuggestions->insertItem( *it ), *it );
+
+ if ( m_idToSuggestion.count() == 0 )
+ m_menuIdSuggestions->setItemEnabled( m_menuIdSuggestions->insertItem( i18n( "No suggestions available" ) ), FALSE );
+ }
+
+ void EntryWidget::insertIdSuggestion( int id )
+ {
+ m_lineEditID->setText( m_idToSuggestion[id] );
+ }
+
+ /* This function was taken form KMainWindow of KDE 3.5 and modified to fit KBibTeX */
+ void EntryWidget::saveWindowSize( KConfig *config ) const
+ {
+ int scnum = QApplication::desktop()->screenNumber( parentWidget() );
+ QRect desk = QApplication::desktop()->screenGeometry( scnum );
+ int w, h;
+#if defined Q_WS_X11
+ // save maximalization as desktop size + 1 in that direction
+ KWin::WindowInfo info = KWin::windowInfo( m_dlgParent->winId(), NET::WMState );
+ w = info.state() & NET::MaxHoriz ? desk.width() + 1 : m_dlgParent->width();
+ h = info.state() & NET::MaxVert ? desk.height() + 1 : m_dlgParent->height();
+#else
+ if ( isMaximized() )
+ {
+ w = desk.width() + 1;
+ h = desk.height() + 1;
+ }
+ //TODO: add "Maximized" property instead "+1" hack
+#endif
+ QRect size( desk.width(), w, desk.height(), h );
+ bool defaultSize = false;//( size == d->defaultWindowSize );
+ QString widthString = QString::fromLatin1( "Width %1" ).arg( desk.width() );
+ QString heightString = QString::fromLatin1( "Height %1" ).arg( desk.height() );
+ if ( !config->hasDefault( widthString ) && defaultSize )
+ config->revertToDefault( widthString );
+ else
+ config->writeEntry( widthString, w );
+
+ if ( !config->hasDefault( heightString ) && defaultSize )
+ config->revertToDefault( heightString );
+ else
+ config->writeEntry( heightString, h );
+ }
+
+ /* This function was taken form KMainWindow of KDE 3.5 and modified to fit KBibTeX */
+ void EntryWidget::restoreWindowSize( KConfig *config )
+ {
+ // restore the size
+ int scnum = QApplication::desktop()->screenNumber( parentWidget() );
+ QRect desk = QApplication::desktop()->screenGeometry( scnum );
+// if ( d->defaultWindowSize.isNull() ) // only once
+// d->defaultWindowSize = QRect( desk.width(), width(), desk.height(), height() ); // store default values
+ QSize size( config->readNumEntry( QString::fromLatin1( "Width %1" ).arg( desk.width() ), 0 ),
+ config->readNumEntry( QString::fromLatin1( "Height %1" ).arg( desk.height() ), 0 ) );
+ if ( size.isEmpty() )
+ {
+ // try the KDE 2.0 way
+ size = QSize( config->readNumEntry( QString::fromLatin1( "Width" ), 0 ),
+ config->readNumEntry( QString::fromLatin1( "Height" ), 0 ) );
+ if ( !size.isEmpty() )
+ {
+ // make sure the other resolutions don't get old settings
+ config->writeEntry( QString::fromLatin1( "Width" ), 0 );
+ config->writeEntry( QString::fromLatin1( "Height" ), 0 );
+ }
+ }
+ if ( !size.isEmpty() )
+ {
+#ifdef Q_WS_X11
+ int state = ( size.width() > desk.width() ? NET::MaxHoriz : 0 )
+ | ( size.height() > desk.height() ? NET::MaxVert : 0 );
+ if (( state & NET::Max ) == NET::Max )
+ ; // no resize
+ else if (( state & NET::MaxHoriz ) == NET::MaxHoriz )
+ m_dlgParent->resize( width(), size.height() );
+ else if (( state & NET::MaxVert ) == NET::MaxVert )
+ m_dlgParent->resize( size.width(), height() );
+ else
+ m_dlgParent->resize( size );
+ // QWidget::showMaximized() is both insufficient and broken
+ KWin::setState( m_dlgParent->winId(), state );
+#else
+ if ( size.width() > desk.width() || size.height() > desk.height() )
+ m_dlgParent->setWindowState( WindowMaximized );
+ else
+ m_dlgParent->resize( size );
+#endif
+ }
+ }
+
+ void EntryWidget::refreshFromURL()
+ {
+ BibTeX::Entry *entry = new BibTeX::Entry();
+ apply( entry );
+ m_oldId = entry->id();
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftURL );
+ KURL url = field != NULL ? KURL( field->value()->text().lower() ) : KURL();
+
+ if ( url.isValid() && url.prettyURL().contains( "arxiv.org/abs/" ) )
+ {
+ m_pushButtonRefetch->setEnabled( false );
+ qDebug( "Refetching from url %s", url.prettyURL().latin1() );
+ m_wqa->fetchFromAbstract( url );
+ }
+ else
+ {
+ KMessageBox::information( this, i18n( "Currently only refetching from ArXiv sources is supported.\n\nThis requires that the URL field points to an \"abstract\" page (i.e. the URL contains \"arxiv.org/abs/\")." ), i18n( "Refetching entry" ) );
+ m_pushButtonRefetch->setEnabled( true );
+ }
+ }
+
+ void EntryWidget::useExternalEntry( BibTeX::Entry* entry, bool )
+ {
+ if ( entry != NULL )
+ {
+ BibTeX::Entry *oldEntry = new BibTeX::Entry();
+ apply( oldEntry );
+
+ entry->setId( m_oldId );
+ for ( BibTeX::Entry::EntryFields::ConstIterator it = oldEntry->begin(); it != oldEntry->end(); ++it )
+ {
+ BibTeX::EntryField *oldField = *it;
+ BibTeX::EntryField *field = entry->getField( oldField->fieldTypeName() );
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( oldField->fieldTypeName() );
+ entry->addField( field );
+ field->setValue( new BibTeX::Value( oldField->value() ) );
+ }
+ }
+ reset( entry );
+ }
+ else
+ KMessageBox::error( this, i18n( "Fetching updated bibliographic data failed." ), i18n( "Refetching entry" ) );
+ }
+
+ void EntryWidget::endExternalSearch( WebQuery::Status )
+ {
+ m_pushButtonRefetch->setEnabled( true );
+ }
+
+}
+#include "entrywidget.moc"
diff --git a/src/entrywidget.h b/src/entrywidget.h
new file mode 100644
index 0000000..10dfd13
--- /dev/null
+++ b/src/entrywidget.h
@@ -0,0 +1,158 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGET_H
+#define KBIBTEXENTRYWIDGET_H
+
+#include <qwidget.h>
+#include <qdialog.h>
+#include <qvaluelist.h>
+#include <qmap.h>
+
+#include <kdialogbase.h>
+
+#include <entry.h>
+#include <entrywidgetsource.h>
+#include <webquery.h>
+
+class QComboBox;
+class QLineEdit;
+class QCheckBox;
+class QTabWidget;
+class QString;
+class QTimer;
+class QListView;
+
+class KConfig;
+
+namespace KBibTeX
+{
+ class EntryWidgetTab;
+ class WebQueryArXiv;
+
+ class EntryWidget : public QWidget
+ {
+ Q_OBJECT
+
+ friend class EntryWidgetDialog;
+
+ public:
+ ~EntryWidget();
+
+ static QDialog::DialogCode execute( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QWidget *parent = 0, const char *name = 0 );
+
+ protected:
+ EntryWidget( BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name = 0 );
+ void showEvent( QShowEvent * );
+ bool queryClose();
+
+ private slots:
+ void apply();
+ void reset();
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void slotEnableAllFields();
+ void slotForceDefaultIdSuggestion();
+ void slotEntryTypeChanged();
+ void slotCurrentPageChanged( QWidget* newPage );
+ void warningsExecute( QListViewItem* item );
+ void updateWarnings();
+ void insertIdSuggestion( int id );
+ void updateIdSuggestionsMenu();
+ void refreshFromURL();
+ void useExternalEntry( BibTeX::Entry*, bool );
+ void endExternalSearch( WebQuery::Status );
+
+ signals:
+ void updateTabs( BibTeX::Entry::EntryType entryType, bool enableAll, bool isReadOnly );
+
+ private:
+ EntryWidget( BibTeX::Entry *entry, BibTeX::File *bibtexfile, bool isReadOnly, bool isNew, QDialog *parent, const char *name = 0 );
+ BibTeX::Entry *m_originalEntry;
+ BibTeX::File *m_bibtexfile;
+ bool m_isReadOnly;
+ bool m_isNew;
+ bool m_defaultIdSuggestionAvailable;
+
+ QComboBox *m_comboBoxEntryType;
+ QLineEdit *m_lineEditID;
+ QPushButton *m_pushButtonForceDefaultIdSuggestion;
+ QPushButton *m_pushButtonIdSuggestions;
+ QPopupMenu *m_menuIdSuggestions;
+ QMap<int, QString> m_idToSuggestion;
+ QCheckBox *m_checkBoxEnableAll;
+ QPushButton *m_pushButtonRefetch;
+ QListView *m_listViewWarnings;
+ QTabWidget *m_tabWidget;
+ KBibTeX::EntryWidgetSource *m_sourcePage;
+ QValueList<KBibTeX::EntryWidgetTab*> m_internalEntryWidgets;
+ QWidget *m_lastPage;
+ QTimer *m_updateWarningsTimer;
+ QDialog *m_dlgParent;
+ WebQueryArXiv *m_wqa;
+ QString m_oldId;
+
+ void setupGUI( QWidget *parent, bool showWarnings = TRUE );
+ void addTabWidgets();
+ void addTabWidget( EntryWidgetTab *widget, const QString& title );
+ void setupEntryTypes();
+ void updateGUI();
+ void internalApply( BibTeX::Entry *entry );
+ void internalReset( BibTeX::Entry *entry );
+ void restoreWindowSize( KConfig *config );
+ void saveWindowSize( KConfig *config ) const;
+ };
+
+ class EntryWidgetDialog: public KDialogBase
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetDialog( QWidget *parent = 0, const char *name = 0, bool modal = true, const QString &caption = QString::null, int buttonMask = Ok | Apply | Cancel ) : KDialogBase( parent, name, modal, caption, buttonMask ) {/* nothing */};
+ ~EntryWidgetDialog() {/* nothing */};
+ void setMainWidget( EntryWidget *widget )
+ {
+ KDialogBase::setMainWidget( widget );
+ m_widget = widget;
+ };
+
+ protected:
+ void closeEvent( QCloseEvent * e )
+ {
+ if ( m_widget->queryClose() ) e->accept();
+ else e->ignore();
+ }
+
+ protected slots:
+ void slotCancel()
+ {
+ if ( m_widget->queryClose() ) QDialog::done( Cancel );
+ }
+
+ void slotClose()
+ {
+ if ( m_widget->queryClose() ) QDialog::done( Cancel );
+ }
+
+ private:
+ EntryWidget *m_widget;
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetauthor.cpp b/src/entrywidgetauthor.cpp
new file mode 100644
index 0000000..32e2e18
--- /dev/null
+++ b/src/entrywidgetauthor.cpp
@@ -0,0 +1,114 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <kdialog.h>
+#include <klocale.h>
+
+#include <fieldlistview.h>
+#include <entrywidgetwarningsitem.h>
+#include "entrywidgetauthor.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetAuthor::EntryWidgetAuthor( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetAuthor::~EntryWidgetAuthor()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetAuthor::isModified()
+ {
+ return m_fieldListViewAuthor->isModified() || m_fieldListViewEditor->isModified();
+ }
+
+ void EntryWidgetAuthor::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
+ {
+ bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftAuthor ) != BibTeX::Entry::frsIgnored;
+ m_fieldListViewAuthor->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftEditor ) != BibTeX::Entry::frsIgnored;
+ m_fieldListViewEditor->setEnabled( enableWidget );
+ }
+
+ void EntryWidgetAuthor::apply( BibTeX::Entry *entry )
+ {
+ BibTeX::Value * value = m_fieldListViewAuthor->value();
+ setValue( entry, BibTeX::EntryField::ftAuthor, value );
+ if ( value != NULL ) delete value;
+
+ value = m_fieldListViewEditor->value();
+ setValue( entry, BibTeX::EntryField::ftEditor, value );
+ if ( value != NULL ) delete value;
+ }
+
+ void EntryWidgetAuthor::reset( BibTeX::Entry *entry )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftAuthor );
+ m_fieldListViewAuthor->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftEditor );
+ m_fieldListViewEditor->setValue( field != NULL ? field->value() : NULL );
+ }
+
+ void EntryWidgetAuthor::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
+ {
+ if ( entryType == BibTeX::Entry::etBook || entryType == BibTeX::Entry::etInBook )
+ {
+ if ( m_fieldListViewAuthor->isEmpty() && m_fieldListViewEditor->isEmpty() )
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlWarning, i18n( "The fields 'Author' or 'Editor' are required, but both are missing" ), m_fieldListViewAuthor, listViewWarnings, "warning" );
+ }
+ else
+ {
+ addMissingWarning( entryType, BibTeX::EntryField::ftAuthor, m_fieldListViewAuthor->caption(), !m_fieldListViewAuthor->isEmpty(), m_fieldListViewAuthor, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftEditor, m_fieldListViewEditor->caption(), !m_fieldListViewEditor->isEmpty(), m_fieldListViewEditor, listViewWarnings );
+ }
+ }
+
+ void EntryWidgetAuthor::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 2, 3, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setColSpacing( 1, KDialog::spacingHint() * 4 );
+
+ QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "Author" ) ), this );
+ gridLayout->addWidget( label, 0, 0 );
+ m_fieldListViewAuthor = new KBibTeX::FieldListView( i18n( "Author" ), i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewAuthor" ), m_isReadOnly, this );
+ m_fieldListViewAuthor->setFieldType( BibTeX::EntryField::ftAuthor );
+ gridLayout->addWidget( m_fieldListViewAuthor, 1, 0 );
+ label->setBuddy( m_fieldListViewAuthor );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Editor" ) ), this );
+ gridLayout->addWidget( label, 0, 2 );
+ m_fieldListViewEditor = new KBibTeX::FieldListView( i18n( "Editor" ), i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewEditor" ), m_isReadOnly, this );
+ m_fieldListViewEditor->setFieldType( BibTeX::EntryField::ftEditor );
+ gridLayout->addWidget( m_fieldListViewEditor, 1, 2 );
+ label->setBuddy( m_fieldListViewEditor );
+ }
+
+}
+#include "entrywidgetauthor.moc"
diff --git a/src/entrywidgetauthor.h b/src/entrywidgetauthor.h
new file mode 100644
index 0000000..1986614
--- /dev/null
+++ b/src/entrywidgetauthor.h
@@ -0,0 +1,60 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETAUTHOR_H
+#define KBIBTEXENTRYWIDGETAUTHOR_H
+
+#include <entrywidgettab.h>
+
+class QWidget;
+class QScrollView;
+
+namespace KBibTeX
+{
+ class FieldListView;
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetAuthor : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetAuthor( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetAuthor();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private:
+ FieldListView *m_fieldListViewAuthor;
+ FieldListView *m_fieldListViewEditor;
+
+ void setupGUI();
+
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetexternal.cpp b/src/entrywidgetexternal.cpp
new file mode 100644
index 0000000..a672e25
--- /dev/null
+++ b/src/entrywidgetexternal.cpp
@@ -0,0 +1,297 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+
+#include <kpushbutton.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <kfiledialog.h>
+#include <kurl.h>
+#include <kurllabel.h>
+#include <kiconloader.h>
+#include <kpopupmenu.h>
+
+#include <fieldlineedit.h>
+#include <settings.h>
+#include "entrywidgetexternal.h"
+
+namespace KBibTeX
+{
+
+ const int EntryWidgetExternal::m_menuIdCurrentDirectory = 8192;
+ const int EntryWidgetExternal::m_menuIdPreviousDirectory = 8191;
+ QString EntryWidgetExternal::m_previousDirectory = QString::null;
+
+ EntryWidgetExternal::EntryWidgetExternal( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetExternal::~EntryWidgetExternal()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetExternal::isModified()
+ {
+ return m_fieldLineEditURL->isModified() || m_fieldLineEditDoi->isModified() || m_fieldLineEditLocalFile->isModified();
+ }
+
+ void EntryWidgetExternal::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
+ {
+ bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftURL ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditURL->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftDoi ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditDoi->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftLocalFile ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditLocalFile->setEnabled( enableWidget );
+ m_pushButtonBrowseLocalFile->setEnabled( !m_isReadOnly && enableWidget );
+
+ updateGUI();
+ }
+
+ void EntryWidgetExternal::apply( BibTeX::Entry *entry )
+ {
+ BibTeX::Value * value = m_fieldLineEditURL->value();
+ setValue( entry, BibTeX::EntryField::ftURL, value );
+ delete value;
+
+ value = m_fieldLineEditDoi->value();
+ setValue( entry, BibTeX::EntryField::ftDoi, value );
+ delete value;
+
+ value = m_fieldLineEditLocalFile->value();
+ setValue( entry, BibTeX::EntryField::ftLocalFile, value );
+ delete value;
+ }
+
+ void EntryWidgetExternal::reset( BibTeX::Entry *entry )
+ {
+ disconnect( m_fieldLineEditURL, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ disconnect( m_fieldLineEditDoi, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ disconnect( m_fieldLineEditLocalFile, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+
+
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftURL );
+ m_fieldLineEditURL->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftDoi );
+ m_fieldLineEditDoi->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftLocalFile );
+ m_fieldLineEditLocalFile->setValue( field != NULL ? field->value() : NULL );
+
+ updateGUI();
+
+ connect( m_fieldLineEditURL, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ connect( m_fieldLineEditDoi, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ connect( m_fieldLineEditLocalFile, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ }
+
+ void EntryWidgetExternal::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
+ {
+ addMissingWarning( entryType, BibTeX::EntryField::ftURL, m_fieldLineEditURL->caption(), !m_fieldLineEditURL->isEmpty(), m_fieldLineEditURL, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftDoi, m_fieldLineEditDoi->caption(), !m_fieldLineEditDoi->isEmpty(), m_fieldLineEditDoi, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftLocalFile, m_fieldLineEditDoi->caption(), !m_fieldLineEditDoi->isEmpty(), m_fieldLineEditLocalFile, listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditURL, m_fieldLineEditURL->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditDoi, m_fieldLineEditDoi->caption(), listViewWarnings );
+
+ updateGUI();
+ }
+
+ void EntryWidgetExternal::openURL()
+ {
+ BibTeX::Value * value = m_fieldLineEditURL->value();
+ KURL url = Settings::locateFile( value->text(), m_bibtexfile->fileName, this );
+ if ( url.isValid() )
+ Settings::openUrl( url, this );
+ else
+ m_pushButtonOpenURL->setEnabled( FALSE );
+ }
+
+ void EntryWidgetExternal::openURL( const QString &url )
+ {
+ Settings::openUrl( KURL( url ), this );
+ }
+
+ void EntryWidgetExternal::openDoi()
+ {
+ BibTeX::Value * value = m_fieldLineEditDoi->value();
+ KURL url = Settings::doiURL( value->text() );
+ if ( url.isValid() )
+ Settings::openUrl( url, this );
+ else
+ m_pushButtonOpenDoi->setEnabled( FALSE );
+ }
+
+ void EntryWidgetExternal::openLocalFile()
+ {
+ BibTeX::Value * value = m_fieldLineEditLocalFile->value();
+ KURL url = Settings::locateFile( value->text(), m_bibtexfile->fileName, this );
+ if ( url.isValid() )
+ Settings::openUrl( url, this );
+ else
+ m_pushButtonOpenLocalFile->setEnabled( FALSE );
+ }
+
+ void EntryWidgetExternal::browseLocalFile( int id )
+ {
+ Settings * settings = Settings::self();
+ QString startDir = QString::null;
+ if ( id == m_menuIdPreviousDirectory && m_previousDirectory != QString::null )
+ startDir = m_previousDirectory;
+ else if ( settings->editing_DocumentSearchPaths.size() > ( unsigned int )id )
+ startDir = *settings->editing_DocumentSearchPaths.at( id );
+ else
+ startDir = QDir::currentDirPath();
+ QString filename = KFileDialog::getOpenFileName( startDir );
+
+ if ( !filename.isEmpty() )
+ {
+ /** if the user started browsing for files from a search path,
+ * remove this search path prefix from the absolute path returned
+ * by the file open dialog. */
+ if ( id >= 0 && filename.startsWith( startDir ) )
+ {
+ int len = startDir.length();
+ if ( startDir == "/" )
+ len = 0;
+ else if ( !startDir.endsWith( "/" ) )
+ ++len;
+ filename = filename.mid( len );
+ }
+
+ BibTeX::Value * value = new BibTeX::Value();
+ value->items.append( new BibTeX::PlainText( filename ) );
+ m_fieldLineEditLocalFile->setValue( value );
+
+ if ( m_previousDirectory == QString::null )
+ {
+ QPopupMenu *menu = m_pushButtonBrowseLocalFile->popup();
+ menu->insertItem( QIconSet( SmallIcon( "favorite" ) ), i18n( "Previously used directory" ), m_menuIdPreviousDirectory, 2 );
+ }
+ QFileInfo fileInfo( filename );
+ m_previousDirectory = fileInfo.dirPath( true );
+ }
+ }
+
+ void EntryWidgetExternal::updateGUI()
+ {
+ BibTeX::Value * value = m_fieldLineEditURL->value();
+ m_pushButtonOpenURL->setEnabled( value != NULL && Settings::locateFile( value->text(), m_bibtexfile->fileName, this ).isValid() );
+
+ value = m_fieldLineEditLocalFile->value();
+ m_pushButtonOpenLocalFile->setEnabled( value != NULL && Settings::locateFile( value->text(), m_bibtexfile->fileName, this ).isValid() );
+
+ value = m_fieldLineEditDoi->value();
+ m_pushButtonOpenDoi->setEnabled( value != NULL && Settings::doiURL( value->text() ).isValid() );
+ }
+
+ void EntryWidgetExternal::setupGUI()
+ {
+ Settings * settings = Settings::self();
+
+ QGridLayout * gridLayout = new QGridLayout( this, 5, 3, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setRowStretch( 4, 10 );
+
+ QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "URL" ) ), this );
+ gridLayout->addWidget( label, 0, 0 );
+ m_fieldLineEditURL = new KBibTeX::FieldLineEdit( i18n( "URL" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditURL" );
+ m_fieldLineEditURL->setFieldType( BibTeX::EntryField::ftURL );
+ gridLayout->addWidget( m_fieldLineEditURL, 0, 1 );
+ label->setBuddy( m_fieldLineEditURL );
+ connect( m_fieldLineEditURL, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+
+ m_pushButtonOpenURL = new KPushButton( this );
+ gridLayout->addWidget( m_pushButtonOpenURL, 0, 2 );
+ m_pushButtonOpenURL->setIconSet( QIconSet( SmallIcon( "fileopen" ) ) );
+ m_pushButtonOpenURL->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ QToolTip::add( m_pushButtonOpenURL, QString( i18n( "Open %1" ) ).arg( i18n( "URL" ) ) );
+ connect( m_pushButtonOpenURL, SIGNAL( clicked() ), this, SLOT( openURL() ) );
+
+ KURLLabel *urllabel = new KURLLabel( "http://www.doi.org/", QString( "%1:" ).arg( i18n( "DOI" ) ), this );
+ QToolTip::add( urllabel, i18n( "Digital Object Identifier" ) );
+ urllabel->setFocusPolicy( QWidget::NoFocus );
+ gridLayout->addWidget( urllabel, 1, 0 );
+ m_fieldLineEditDoi = new KBibTeX::FieldLineEdit( i18n( "DOI" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditDoi" );
+ m_fieldLineEditDoi->setFieldType( BibTeX::EntryField::ftDoi );
+ gridLayout->addWidget( m_fieldLineEditDoi, 1, 1 );
+ urllabel->setBuddy( m_fieldLineEditDoi );
+ connect( m_fieldLineEditDoi, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+ connect( urllabel, SIGNAL( leftClickedURL( const QString& ) ), this, SLOT( openURL( const QString& ) ) );
+
+ m_pushButtonOpenDoi = new KPushButton( this );
+ gridLayout->addWidget( m_pushButtonOpenDoi, 1, 2 );
+ m_pushButtonOpenDoi->setIconSet( QIconSet( SmallIcon( "fileopen" ) ) );
+ m_pushButtonOpenDoi->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ QToolTip::add( m_pushButtonOpenDoi, i18n( "Open DOI" ) );
+ connect( m_pushButtonOpenDoi, SIGNAL( clicked() ), this, SLOT( openDoi() ) );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Local File" ) ), this );
+ gridLayout->addWidget( label, 2, 0 );
+ m_fieldLineEditLocalFile = new KBibTeX::FieldLineEdit( i18n( "Local File" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditLocalFile" );
+ m_fieldLineEditLocalFile->setFieldType( BibTeX::EntryField::ftLocalFile );
+ gridLayout->addWidget( m_fieldLineEditLocalFile, 2, 1 );
+ label->setBuddy( m_fieldLineEditLocalFile );
+ connect( m_fieldLineEditLocalFile, SIGNAL( textChanged() ), this, SLOT( updateGUI() ) );
+
+ m_pushButtonOpenLocalFile = new KPushButton( this );
+ gridLayout->addWidget( m_pushButtonOpenLocalFile, 2, 2 );
+ m_pushButtonOpenLocalFile->setIconSet( QIconSet( SmallIcon( "fileopen" ) ) );
+ m_pushButtonOpenLocalFile->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ QToolTip::add( m_pushButtonOpenLocalFile, QString( i18n( "Open %1" ) ).arg( i18n( "Local File" ) ) );
+ connect( m_pushButtonOpenLocalFile, SIGNAL( clicked() ), this, SLOT( openLocalFile() ) );
+
+ QWidget *container = new QWidget( this );
+ QHBoxLayout *containerLayout = new QHBoxLayout( container );
+ gridLayout->addWidget( container, 3, 1 );
+ m_pushButtonBrowseLocalFile = new KPushButton( i18n( "&Browse..." ), container );
+ QToolTip::add( m_pushButtonBrowseLocalFile, i18n( "Browse for a local file" ) );
+ m_pushButtonBrowseLocalFile->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ containerLayout->addWidget( m_pushButtonBrowseLocalFile );
+ containerLayout->addStretch( 10 );
+ m_pushButtonBrowseLocalFile->setIconSet( QIconSet( SmallIcon( "fileopen" ) ) );
+
+ KPopupMenu *menu = new KPopupMenu( m_pushButtonBrowseLocalFile );
+ menu->insertTitle( i18n( "Select base directory" ) );
+ menu->insertItem( QIconSet( SmallIcon( "favorite" ) ), i18n( "Current directory" ), m_menuIdCurrentDirectory );
+ if ( m_previousDirectory != QString::null )
+ menu->insertItem( QIconSet( SmallIcon( "favorite" ) ), i18n( "Previously used directory" ), m_menuIdPreviousDirectory );
+ if ( !settings->editing_DocumentSearchPaths.isEmpty() )
+ {
+ menu->insertSeparator();
+ int i = 0;
+ for ( QStringList::Iterator it = settings->editing_DocumentSearchPaths.begin(); it != settings->editing_DocumentSearchPaths.end(); ++it, ++i )
+ menu->insertItem( QIconSet( SmallIcon( "folder" ) ), *it, i );
+ }
+ m_pushButtonBrowseLocalFile->setPopup( menu );
+ connect( menu, SIGNAL( activated( int ) ), this, SLOT( browseLocalFile( int ) ) );
+ }
+}
+#include "entrywidgetexternal.moc"
diff --git a/src/entrywidgetexternal.h b/src/entrywidgetexternal.h
new file mode 100644
index 0000000..16cb608
--- /dev/null
+++ b/src/entrywidgetexternal.h
@@ -0,0 +1,76 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETEXTERNAL_H
+#define KBIBTEXENTRYWIDGETEXTERNAL_H
+
+#include <entrywidgettab.h>
+
+class KPushButton;
+class KURL;
+
+namespace KBibTeX
+{
+
+ class FieldLineEdit;
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetExternal : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetExternal( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetExternal();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private slots:
+ void openURL();
+ void openURL( const QString & );
+ void openDoi();
+ void openLocalFile();
+ void browseLocalFile( int id );
+ void updateGUI();
+
+ private:
+ FieldLineEdit *m_fieldLineEditURL;
+ KPushButton *m_pushButtonOpenURL;
+ FieldLineEdit *m_fieldLineEditDoi;
+ KPushButton *m_pushButtonOpenDoi;
+ FieldLineEdit *m_fieldLineEditLocalFile;
+ KPushButton *m_pushButtonOpenLocalFile;
+ KPushButton *m_pushButtonBrowseLocalFile;
+
+ static QString m_previousDirectory;
+ static const int m_menuIdCurrentDirectory, m_menuIdPreviousDirectory;
+
+ void setupGUI();
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetkeyword.cpp b/src/entrywidgetkeyword.cpp
new file mode 100644
index 0000000..b61acc0
--- /dev/null
+++ b/src/entrywidgetkeyword.cpp
@@ -0,0 +1,283 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qregexp.h>
+#include <qpushbutton.h>
+#include <qtooltip.h>
+#include <qtimer.h>
+#include <qlabel.h>
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kdialogbase.h>
+#include <kmessagebox.h>
+#include <klistview.h>
+#include <kguiitem.h>
+#include <kdebug.h>
+
+#include <settings.h>
+#include "entrywidgetkeyword.h"
+
+namespace KBibTeX
+{
+ KeywordListViewItem::KeywordListViewItem( KListView * parent, const QString & text, bool global ) : QCheckListItem( parent, text, QCheckListItem::CheckBox )
+ {
+ setGlobal( global );
+ }
+
+ KeywordListViewItem::~KeywordListViewItem()
+ {
+// nothing
+ }
+
+ void KeywordListViewItem::setGlobal( bool global )
+ {
+ m_isGlobal = global;
+ if ( m_isGlobal )
+ {
+ setText( 1, i18n( "Global" ) );
+ setPixmap( 1, SmallIcon( "package" ) );
+ }
+ else
+ {
+ setText( 1, i18n( "In this file only" ) );
+ setPixmap( 1, SmallIcon( "editcopy" ) );
+ }
+ }
+
+ EntryWidgetKeyword::EntryWidgetKeyword( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name ) : EntryWidgetTab( bibtexfile, isReadOnly, parent, name ), m_bibtexfile( bibtexfile ), m_isModified( FALSE ), m_numKeywords( 0 )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetKeyword::~EntryWidgetKeyword()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetKeyword::isModified()
+ {
+ return m_isModified;
+ }
+
+ void EntryWidgetKeyword::updateGUI( BibTeX::Entry::EntryType /*entryType*/, bool /*enableAll*/ )
+ {
+ // nothing
+ }
+
+ void EntryWidgetKeyword::apply( BibTeX::Entry *entry )
+ {
+ readListView();
+
+ /**
+ * Update entry
+ */
+ if ( m_usedKeywords.empty() )
+ entry->deleteField( BibTeX::EntryField::ftKeywords );
+ else
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftKeywords );
+ BibTeX::Value *value = NULL;
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( BibTeX::EntryField::ftKeywords );
+ entry->addField( field );
+ }
+ value = field->value();
+ value->items.clear();
+ BibTeX::KeywordContainer *keywordContainer = new BibTeX::KeywordContainer( m_usedKeywords );
+ value->items.append( keywordContainer );
+ }
+
+ /**
+ * Update global keyword list
+ */
+ KBibTeX::Settings * settings = KBibTeX::Settings::self();
+ settings->keyword_GlobalList = m_globalKeywords;
+ }
+
+ void EntryWidgetKeyword::reset( BibTeX::Entry *entry )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftKeywords );
+ BibTeX::KeywordContainer *keywordContainer = NULL;
+ if ( field != NULL && ( keywordContainer = dynamic_cast<BibTeX::KeywordContainer*>( field->value()->items.first() ) ) != NULL )
+ for ( QValueList<BibTeX::Keyword*>::Iterator it = keywordContainer->keywords.begin(); it != keywordContainer->keywords.end(); ++it )
+ m_usedKeywords.append(( *it )->text() );
+
+ if ( m_bibtexfile != NULL )
+ m_fileKeywords = m_bibtexfile->getAllValuesAsStringList( BibTeX::EntryField::ftKeywords );
+
+ KBibTeX::Settings * settings = KBibTeX::Settings::self();
+ m_globalKeywords = settings->keyword_GlobalList;
+
+ m_availableKeywords = QStringList( m_globalKeywords );
+ for ( QStringList::Iterator it = m_fileKeywords.begin(); it != m_fileKeywords.end(); ++it )
+ if ( !m_availableKeywords.contains( *it ) )
+ m_availableKeywords.append( *it );
+ for ( QStringList::Iterator it = m_usedKeywords.begin(); it != m_usedKeywords.end(); ++it )
+ if ( !m_availableKeywords.contains( *it ) )
+ m_availableKeywords.append( *it );
+
+ setListView();
+ }
+
+ void EntryWidgetKeyword::updateWarnings( BibTeX::Entry::EntryType /*entryType*/, QListView */*listViewWarnings*/ )
+ {
+ // nothing
+ }
+
+ void EntryWidgetKeyword::slotSelectionChanged()
+ {
+ bool hasCurrent = m_listviewKeywords->selectedItem() != NULL;
+
+ m_buttonEdit->setEnabled( hasCurrent );
+ m_buttonToggleGlobal->setEnabled( hasCurrent );
+ }
+
+ void EntryWidgetKeyword::slotKeywordRenamed( QListViewItem * item, const QString & text, int /*col*/ )
+ {
+ KeywordListViewItem *kwlvi = dynamic_cast<KeywordListViewItem*>( item );
+ if ( text.isEmpty() )
+ {
+ item->setText( 0, m_beforeRenaming );
+ kwlvi->setOn( FALSE );
+ }
+ else if ( text != m_beforeRenaming )
+ {
+ if ( m_availableKeywords.contains( text ) )
+ {
+ item->setText( 0, m_beforeRenaming );
+ KMessageBox::error( this, QString( i18n( "The keyword '%1' does already exist in the list of keywords.\nThe old name has been restored." ) ).arg( text ), i18n( "Renaming keyword failed" ) );
+ }
+ else
+ {
+ m_availableKeywords.remove( m_beforeRenaming );
+ m_availableKeywords.append( text );
+ if ( kwlvi->isGlobal() )
+ {
+ m_globalKeywords.remove( m_beforeRenaming );
+ m_globalKeywords.append( text );
+ }
+ else
+ {
+ m_fileKeywords.remove( m_beforeRenaming );
+ m_fileKeywords.append( text );
+ }
+ QCheckListItem *checkedItem = dynamic_cast<QCheckListItem*>( item );
+ if ( checkedItem != NULL )
+ checkedItem->setOn( TRUE );
+ }
+ }
+ }
+
+ void EntryWidgetKeyword::slotNewKeyword()
+ {
+ KeywordListViewItem * item = new KeywordListViewItem( m_listviewKeywords, QString( i18n( "May only contain ASCII characters, in case of doubt keep English form", "NewKeyword%1" ) ).arg( ++m_numKeywords ), FALSE );
+ m_listviewKeywords->setSelected( item, TRUE );
+ QTimer::singleShot( 100, this, SLOT( slotEditKeyword() ) );
+ }
+
+ void EntryWidgetKeyword::slotEditKeyword()
+ {
+ QListViewItem * item = m_listviewKeywords->selectedItem();
+ if ( item != NULL )
+ {
+ m_beforeRenaming = item->text( 0 );
+ m_listviewKeywords->rename( item, 0 );
+ }
+ }
+
+ void EntryWidgetKeyword::slotToggleGlobal()
+ {
+ KeywordListViewItem *item = dynamic_cast<KeywordListViewItem*>( m_listviewKeywords->selectedItem() );
+ if ( item != NULL )
+ {
+ bool isGlobal = item->isGlobal();
+ if ( isGlobal )
+ m_globalKeywords.remove( item->text( 0 ) );
+ else
+ m_globalKeywords.append( item->text( 0 ) );
+
+ item->setGlobal( !isGlobal );
+ }
+ }
+
+ void EntryWidgetKeyword::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 6, 2, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setRowStretch( 4, 1 );
+
+ m_listviewKeywords = new KListView( this );
+ m_listviewKeywords->setEnabled( !m_isReadOnly );
+ m_listviewKeywords->addColumn( i18n( "Keyword" ) );
+ m_listviewKeywords->addColumn( i18n( "Origin" ) );
+ gridLayout->addMultiCellWidget( m_listviewKeywords, 0, 4, 0, 0 );
+ m_listviewKeywords->setAllColumnsShowFocus( TRUE );
+ connect( m_listviewKeywords, SIGNAL( currentChanged( QListViewItem* ) ), this, SLOT( slotSelectionChanged() ) );
+ connect( m_listviewKeywords, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( slotSelectionChanged() ) );
+ connect( m_listviewKeywords, SIGNAL( itemRenamed( QListViewItem*, const QString&, int ) ), this, SLOT( slotKeywordRenamed( QListViewItem*, const QString&, int ) ) );
+
+ m_buttonNew = new QPushButton( i18n( "keyword", "New" ), this );
+ m_buttonNew->setEnabled( !m_isReadOnly );
+ m_buttonNew->setIconSet( QIconSet( SmallIcon( "add" ) ) );
+ QToolTip::add( m_buttonNew, i18n( "Add a new keyword to the list" ) );
+ gridLayout->addWidget( m_buttonNew, 0, 1 );
+ connect( m_buttonNew, SIGNAL( clicked() ), this, SLOT( slotNewKeyword() ) );
+
+ m_buttonEdit = new QPushButton( i18n( "keyword", "Edit" ), this );
+ m_buttonEdit->setIconSet( QIconSet( SmallIcon( "edit" ) ) );
+ QToolTip::add( m_buttonEdit, i18n( "Edit the selected keyword" ) );
+ gridLayout->addWidget( m_buttonEdit, 1, 1 );
+ m_buttonEdit->setEnabled( FALSE );
+ connect( m_buttonEdit, SIGNAL( clicked() ), this, SLOT( slotEditKeyword() ) );
+
+ m_buttonToggleGlobal = new QPushButton( i18n( "keyword", "Toggle &global" ), this );
+ m_buttonToggleGlobal->setIconSet( QIconSet( SmallIcon( "package" ) ) );
+ QToolTip::add( m_buttonToggleGlobal, i18n( "Add or remove the selected keyword to or from the global list" ) );
+ gridLayout->addWidget( m_buttonToggleGlobal, 2, 1 );
+ m_buttonToggleGlobal->setEnabled( FALSE );
+ connect( m_buttonToggleGlobal, SIGNAL( clicked() ), this, SLOT( slotToggleGlobal() ) );
+
+ QLabel *label = new QLabel( i18n( "There is no need to delete keywords. Simply uncheck unwanted keywords and make them non-global.\nGlobal keywords can also be edited in the settings dialog." ), this );
+ label->setAlignment( QLabel::WordBreak | QLabel::AlignTop );
+ gridLayout->addMultiCellWidget( label, 5, 5, 0, 1 );
+ }
+
+ void EntryWidgetKeyword::setListView()
+ {
+ m_availableKeywords.sort();
+ m_listviewKeywords->clear();
+ for ( QStringList::Iterator it = m_availableKeywords.begin(); it != m_availableKeywords.end(); ++it )
+ {
+ KeywordListViewItem *item = new KeywordListViewItem( m_listviewKeywords, *it, m_globalKeywords.contains( *it ) );
+ if ( m_usedKeywords.contains( *it ) )
+ item->setOn( TRUE );
+ }
+ }
+
+ void EntryWidgetKeyword::readListView()
+ {
+ m_usedKeywords.clear();
+ for ( QListViewItemIterator it = QListViewItemIterator( m_listviewKeywords, QListViewItemIterator::Checked ); it.current() != NULL; ++it )
+ m_usedKeywords.append(( *it ) ->text( 0 ) );
+ }
+}
+#include "entrywidgetkeyword.moc"
diff --git a/src/entrywidgetkeyword.h b/src/entrywidgetkeyword.h
new file mode 100644
index 0000000..88eae61
--- /dev/null
+++ b/src/entrywidgetkeyword.h
@@ -0,0 +1,93 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETKEYWORD_H
+#define KBIBTEXENTRYWIDGETKEYWORD_H
+
+#include <entrywidgettab.h>
+
+class QPushButton;
+class KListView;
+
+namespace KBibTeX
+{
+ class KeywordListViewItem: public QCheckListItem
+ {
+ public:
+ KeywordListViewItem( KListView * parent, const QString & text, bool isGlobal );
+ ~KeywordListViewItem();
+
+ bool isGlobal()
+ {
+ return m_isGlobal;
+ };
+ void setGlobal( bool global );
+
+ protected:
+ bool m_isGlobal;
+ };
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetKeyword : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetKeyword( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetKeyword();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private slots:
+ void slotSelectionChanged();
+ void slotKeywordRenamed( QListViewItem * item, const QString & text, int col );
+ void slotNewKeyword();
+ void slotEditKeyword();
+ void slotToggleGlobal();
+
+ private:
+ BibTeX::File *m_bibtexfile;
+ QStringList m_availableKeywords;
+ QStringList m_globalKeywords;
+ QStringList m_fileKeywords;
+ QStringList m_usedKeywords;
+ bool m_isModified;
+ KListView *m_listviewKeywords;
+ QPushButton *m_buttonNew;
+ QPushButton *m_buttonEdit;
+ QPushButton *m_buttonToggleGlobal;
+ int m_numKeywords;
+ QString m_beforeRenaming;
+
+ void setupGUI();
+ void setListView();
+ void readListView();
+ bool editKeywords( QStringList *keywords );
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetmisc.cpp b/src/entrywidgetmisc.cpp
new file mode 100644
index 0000000..f2e4f5e
--- /dev/null
+++ b/src/entrywidgetmisc.cpp
@@ -0,0 +1,172 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <kdialog.h>
+#include <klocale.h>
+
+#include <fieldlineedit.h>
+#include <value.h>
+#include <entryfield.h>
+#include "entrywidgetmisc.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetMisc::EntryWidgetMisc( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetMisc::~EntryWidgetMisc()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetMisc::isModified()
+ {
+ return m_fieldLineEditType->isModified() || m_fieldLineEditKey->isModified() || m_fieldLineEditNote->isModified() || m_fieldLineEditAnnote->isModified() || m_fieldLineEditAbstract->isModified();
+ }
+
+ void EntryWidgetMisc::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
+ {
+ bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftType ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditType->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftKey ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditKey->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftNote ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditNote->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftAnnote ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditAnnote->setEnabled( enableWidget );
+ }
+
+ void EntryWidgetMisc::apply( BibTeX::Entry *entry )
+ {
+ BibTeX::Value * value = m_fieldLineEditType->value();
+ setValue( entry, BibTeX::EntryField::ftType, value );
+ delete value;
+
+ value = m_fieldLineEditKey-> value();
+ setValue( entry, BibTeX::EntryField::ftKey, value );
+ delete value;
+
+ value = m_fieldLineEditNote-> value();
+ setValue( entry, BibTeX::EntryField::ftNote, value );
+ delete value;
+
+ value = m_fieldLineEditAnnote-> value();
+ setValue( entry, BibTeX::EntryField::ftAnnote, value );
+ delete value;
+
+ value = m_fieldLineEditAbstract-> value();
+ setValue( entry, BibTeX::EntryField::ftAbstract, value );
+ delete value;
+ }
+
+ void EntryWidgetMisc::reset( BibTeX::Entry *entry )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftType );
+ m_fieldLineEditType->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftKey );
+ m_fieldLineEditKey->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftNote );
+ m_fieldLineEditNote->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftAnnote );
+ m_fieldLineEditAnnote->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftAbstract );
+ m_fieldLineEditAbstract->setValue( field != NULL ? field->value() : NULL );
+ }
+
+ void EntryWidgetMisc::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
+ {
+ addMissingWarning( entryType, BibTeX::EntryField::ftType, m_fieldLineEditType->caption(), !m_fieldLineEditType->isEmpty(), m_fieldLineEditType, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftKey, m_fieldLineEditKey->caption(), !m_fieldLineEditKey->isEmpty(), m_fieldLineEditKey, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftNote, m_fieldLineEditNote->caption(), !m_fieldLineEditNote->isEmpty(), m_fieldLineEditNote, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftAnnote, m_fieldLineEditAnnote->caption(), !m_fieldLineEditAnnote->isEmpty(), m_fieldLineEditAnnote, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftAbstract, m_fieldLineEditAbstract->caption(), !m_fieldLineEditAbstract->isEmpty(), m_fieldLineEditAbstract, listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditType, m_fieldLineEditType->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditKey, m_fieldLineEditKey->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditNote, m_fieldLineEditNote->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditAnnote, m_fieldLineEditAnnote->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditAbstract, m_fieldLineEditAbstract->caption(), listViewWarnings );
+ }
+
+ void EntryWidgetMisc::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 5, 5, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setColSpacing( 2, KDialog::spacingHint() * 4 );
+ gridLayout->setRowStretch( 4, 1 );
+
+ QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "Type" ) ), this );
+ gridLayout->addWidget( label, 0, 0 );
+ m_fieldLineEditType = new KBibTeX::FieldLineEdit( i18n( "Type" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditType" );
+ m_fieldLineEditType->setFieldType( BibTeX::EntryField::ftType );
+ label->setBuddy( m_fieldLineEditType );
+ gridLayout->addWidget( m_fieldLineEditType, 0, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Key" ) ), this );
+ gridLayout->addWidget( label, 0, 3 );
+ m_fieldLineEditKey = new KBibTeX::FieldLineEdit( i18n( "Key" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditKey" );
+ m_fieldLineEditKey->setFieldType( BibTeX::EntryField::ftKey );
+ label->setBuddy( m_fieldLineEditKey );
+ gridLayout->addWidget( m_fieldLineEditKey, 0, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Note" ) ), this );
+ gridLayout->addWidget( label, 1, 0 );
+ m_fieldLineEditNote = new KBibTeX::FieldLineEdit( i18n( "Note" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditNote" );
+ m_fieldLineEditNote->setFieldType( BibTeX::EntryField::ftNote );
+ label->setBuddy( m_fieldLineEditNote );
+ gridLayout->addMultiCellWidget( m_fieldLineEditNote, 1, 1, 1, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Annote" ) ), this );
+ gridLayout->addWidget( label, 2, 0 );
+ m_fieldLineEditAnnote = new KBibTeX::FieldLineEdit( i18n( "Annote" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditAnnote" );
+ m_fieldLineEditAnnote->setFieldType( BibTeX::EntryField::ftAnnote );
+ label->setBuddy( m_fieldLineEditAnnote );
+ gridLayout->addMultiCellWidget( m_fieldLineEditAnnote, 2, 2, 1, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Abstract" ) ), this );
+ gridLayout->addWidget( label, 3, 0 );
+ m_fieldLineEditAbstract = new KBibTeX::FieldLineEdit( i18n( "Abstract" ), KBibTeX::FieldLineEdit::itMultiLine, m_isReadOnly, this, "m_fieldLineEditAbstract" );
+ m_fieldLineEditAbstract->setFieldType( BibTeX::EntryField::ftAbstract );
+ label->setBuddy( m_fieldLineEditAbstract );
+ gridLayout->addMultiCellWidget( m_fieldLineEditAbstract, 3, 4, 1, 4 );
+ }
+
+}
+#include "entrywidgetmisc.moc"
diff --git a/src/entrywidgetmisc.h b/src/entrywidgetmisc.h
new file mode 100644
index 0000000..5cb99b2
--- /dev/null
+++ b/src/entrywidgetmisc.h
@@ -0,0 +1,57 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETMISC_H
+#define KBIBTEXENTRYWIDGETMISC_H
+
+#include <entrywidgettab.h>
+
+namespace KBibTeX
+{
+ class FieldLineEdit;
+
+ class EntryWidgetMisc : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetMisc( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetMisc();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private:
+ FieldLineEdit *m_fieldLineEditType;
+ FieldLineEdit *m_fieldLineEditKey;
+ FieldLineEdit *m_fieldLineEditNote;
+ FieldLineEdit *m_fieldLineEditAnnote;
+ FieldLineEdit *m_fieldLineEditAbstract;
+
+ void setupGUI();
+
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetother.cpp b/src/entrywidgetother.cpp
new file mode 100644
index 0000000..1c5d13b
--- /dev/null
+++ b/src/entrywidgetother.cpp
@@ -0,0 +1,319 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qstringlist.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qlabel.h>
+#include <qwhatsthis.h>
+
+#include <kdialog.h>
+#include <kapplication.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kio/netaccess.h>
+#include <kpushbutton.h>
+#include <klineedit.h>
+
+#include <fieldlineedit.h>
+#include <settings.h>
+#include "entrywidgetother.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetOther::EntryWidgetOther( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name ), m_isModified( FALSE )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetOther::~EntryWidgetOther()
+ {
+ m_listViewFields->clear();
+ }
+
+ bool EntryWidgetOther::isModified()
+ {
+ return m_isModified;
+ }
+
+ void EntryWidgetOther::updateGUI( BibTeX::Entry::EntryType /*entryType*/, bool /*enableAll*/ )
+ {
+ // nothing
+ }
+
+ void EntryWidgetOther::apply( BibTeX::Entry *entry )
+ {
+ Settings * settings = Settings::self();
+ QStringList toBeDeleted;
+ for ( QValueList<BibTeX::EntryField*>::ConstIterator it = entry->begin(); it != entry->end(); it++ )
+ {
+ BibTeX::EntryField *field = *it;
+ bool doDel = field->fieldType() == BibTeX::EntryField::ftUnknown;
+ if ( !doDel ) continue;
+
+ QString ftn = field->fieldTypeName().lower();
+ for ( unsigned int i = 0; doDel && i < settings->userDefinedInputFields.count(); ++i )
+ doDel &= settings->userDefinedInputFields[i]->name.lower() != ftn;
+
+ if ( doDel )
+ toBeDeleted.append( ftn );
+ }
+ for ( QStringList::ConstIterator it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it )
+ entry->deleteField( *it );
+
+ for ( QListViewItemIterator it( m_listViewFields ); it.current(); it++ )
+ {
+ ValueListViewItem *vlvi = dynamic_cast<KBibTeX::ValueListViewItem*>( it.current() );
+ if ( vlvi != NULL )
+ {
+ BibTeX::EntryField * field = new BibTeX::EntryField( vlvi->title() );
+ field->setValue( vlvi->value() );
+ entry->addField( field );
+ }
+ }
+
+ m_isModified = FALSE;
+ }
+
+ void EntryWidgetOther::reset( BibTeX::Entry *entry )
+ {
+ m_listViewFields->clear();
+
+ Settings * settings = Settings::self();
+ for ( QValueList<BibTeX::EntryField*>::ConstIterator it = entry->begin(); it != entry->end(); it++ )
+ {
+ BibTeX::EntryField *field = *it;
+ bool doAdd = field->fieldType() == BibTeX::EntryField::ftUnknown;
+ if ( !doAdd ) continue;
+
+ QString ftn = field->fieldTypeName().lower();
+ for ( unsigned int i = 0; doAdd && i < settings->userDefinedInputFields.count(); ++i )
+ doAdd &= settings->userDefinedInputFields[i]->name.lower() != ftn;
+
+ if ( doAdd )
+ new ValueListViewItem( field->fieldTypeName(), field->value(), m_listViewFields );
+ }
+
+ m_isModified = FALSE;
+ }
+
+ void EntryWidgetOther::updateWarnings( BibTeX::Entry::EntryType /*entryType*/, QListView * /*listViewWarnings*/ )
+ {
+ // no warnings neccessary for user fields
+ }
+
+ void EntryWidgetOther::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 5, 3, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+
+ m_lineEditKey = new KLineEdit( this, "m_lineEditKey" );
+ m_lineEditKey->setReadOnly( m_isReadOnly );
+ gridLayout->addWidget( m_lineEditKey, 0, 1 );
+ QToolTip::add( m_lineEditKey, i18n( "Name of the user-defined field" ) );
+ QWhatsThis::add( m_lineEditKey, i18n( "The name of the user-defined field. Should only contain letters and numbers." ) );
+ QLabel *label = new QLabel( i18n( "&Name:" ), this );
+ label->setBuddy( m_lineEditKey );
+ gridLayout->addWidget( label, 0, 0 );
+
+ m_pushButtonAdd = new KPushButton( i18n( "&Add" ), this, "m_pushButtonAdd" );
+ gridLayout->addWidget( m_pushButtonAdd, 0, 2 );
+ m_pushButtonAdd->setIconSet( QIconSet( SmallIcon( "add" ) ) );
+
+ m_fieldLineEditValue = new KBibTeX::FieldLineEdit( i18n( "Value" ), KBibTeX::FieldLineEdit::itMultiLine, m_isReadOnly, this, "m_fieldLineEditValue" );
+ gridLayout->addMultiCellWidget( m_fieldLineEditValue, 1, 2, 1, 2 );
+ QToolTip::add( m_fieldLineEditValue, i18n( "Content of the user-defined field" ) );
+ QWhatsThis::add( m_fieldLineEditValue, i18n( "The content of the user-defined field. May contain any text." ) );
+ label = new QLabel( i18n( "&Content:" ), this );
+ label->setBuddy( m_fieldLineEditValue );
+ gridLayout->addWidget( label, 1, 0 );
+
+ QSpacerItem* spacer = new QSpacerItem( 20, 110, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ gridLayout->addItem( spacer, 2, 0 );
+
+ m_listViewFields = new KListView( this, "m_listViewFields" );
+ m_listViewFields->addColumn( i18n( "Key" ) );
+ m_listViewFields->addColumn( i18n( "Value" ) );
+ m_listViewFields->setAllColumnsShowFocus( true );
+ m_listViewFields->setFullWidth( TRUE );
+ gridLayout->addMultiCellWidget( m_listViewFields, 3, 5, 1, 1 );
+
+ label = new QLabel( i18n( "&List:" ), this );
+ label->setBuddy( m_listViewFields );
+ label->setAlignment( Qt::AlignTop );
+ gridLayout->addWidget( label, 3, 0 );
+
+ m_pushButtonDelete = new KPushButton( i18n( "&Delete" ), this, "m_pushButtonDelete" );
+ gridLayout->addWidget( m_pushButtonDelete, 3, 2 );
+ m_pushButtonDelete->setIconSet( QIconSet( SmallIcon( "delete" ) ) );
+
+ m_pushButtonOpen = new KPushButton( i18n( "Op&en" ), this, "m_pushButtonOpen" );
+ gridLayout->addWidget( m_pushButtonOpen, 4, 2 );
+ m_pushButtonOpen->setIconSet( QIconSet( SmallIcon( "fileopen" ) ) );
+
+ spacer = new QSpacerItem( 20, 110, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ gridLayout->addItem( spacer, 5, 2 );
+
+ m_pushButtonOpen->setEnabled( FALSE );
+ m_pushButtonAdd->setEnabled( FALSE );
+ m_pushButtonDelete->setEnabled( FALSE );
+
+ connect( m_listViewFields, SIGNAL( clicked( QListViewItem*, const QPoint&, int ) ), this, SLOT( fieldExecute( QListViewItem* ) ) );
+ connect( m_lineEditKey, SIGNAL( textChanged( const QString& ) ), this, SLOT( updateGUI() ) );
+ connect( m_fieldLineEditValue, SIGNAL( textChanged( ) ), this, SLOT( updateGUI() ) );
+ connect( m_pushButtonAdd, SIGNAL( clicked( ) ), this, SLOT( addClicked( ) ) );
+ connect( m_pushButtonDelete, SIGNAL( clicked( ) ), this, SLOT( deleteClicked( ) ) );
+ connect( m_pushButtonOpen, SIGNAL( clicked() ), this, SLOT( openClicked() ) );
+ }
+
+ void EntryWidgetOther::updateGUI()
+ {
+ QString text = m_lineEditKey->text();
+ QListViewItem * item = m_listViewFields->findItem( text, 0 ) ;
+ bool contains = item != NULL;
+ bool isUnknown = BibTeX::EntryField::fieldTypeFromString( text ) == BibTeX::EntryField::ftUnknown;
+
+ if ( contains )
+ m_listViewFields->setSelected( item, TRUE );
+ else
+ m_listViewFields->clearSelection();
+
+ m_pushButtonDelete->setEnabled( !m_isReadOnly && contains );
+ m_pushButtonAdd->setEnabled( !m_isReadOnly && !text.isEmpty() && !m_fieldLineEditValue->isEmpty() && isUnknown );
+ m_pushButtonAdd->setText( contains ? i18n( "&Apply" ) : i18n( "&Add" ) );
+ m_pushButtonAdd->setIconSet( QIconSet( SmallIcon( contains ? "apply" : "fileopen" ) ) );
+
+ bool validURL = FALSE;
+ if ( contains )
+ {
+ KURL url = Settings::locateFile( item->text( 1 ), m_bibtexfile->fileName, this );
+ validURL = url.isValid();
+ m_internalURL = url;
+ }
+ m_pushButtonOpen->setEnabled( validURL );
+ }
+
+ void EntryWidgetOther::fieldExecute( QListViewItem * item )
+ {
+ ValueListViewItem * vlvi = dynamic_cast<KBibTeX::ValueListViewItem*>( item );
+ if ( vlvi != NULL )
+ {
+ m_lineEditKey->setText( vlvi->title() );
+ m_fieldLineEditValue->setValue( vlvi->value() );
+ }
+ }
+
+ void EntryWidgetOther::addClicked()
+ {
+ QString key = m_lineEditKey->text();
+ QListViewItem * item = m_listViewFields->findItem( key, 0 ) ;
+ ValueListViewItem * vlvi = item != NULL ? dynamic_cast<KBibTeX::ValueListViewItem*>( item ) : NULL;
+
+ if ( vlvi != NULL )
+ vlvi->setValue( m_fieldLineEditValue->value() );
+ else
+ new ValueListViewItem( key, m_fieldLineEditValue->value(), m_listViewFields );
+
+ updateGUI();
+
+ m_isModified = TRUE;
+ }
+
+ void EntryWidgetOther::deleteClicked()
+ {
+ QListViewItem * item = m_listViewFields->findItem( m_lineEditKey->text(), 0 );
+
+ if ( item != NULL )
+ {
+ delete item;
+ m_lineEditKey->setText( "" );
+ m_fieldLineEditValue->setValue( new BibTeX::Value() );
+ updateGUI();
+ }
+
+ m_isModified = TRUE;
+ }
+
+ void EntryWidgetOther::openClicked()
+ {
+ if ( m_internalURL.isValid() )
+ {
+ BibTeX::Value * value = m_fieldLineEditValue->value();
+ Settings::openUrl( m_internalURL, this );
+ delete value;
+ }
+ else
+ m_fieldLineEditValue->setEnabled( FALSE );
+ }
+
+ ValueListViewItem::ValueListViewItem( const QString& title, BibTeX::Value *value, QListView *parent )
+ : QListViewItem( parent ), m_title( title )
+ {
+ m_value = new BibTeX::Value( value );
+ setTexts( m_title );
+ }
+
+ ValueListViewItem::~ValueListViewItem()
+ {
+ delete m_value;
+ }
+
+ const BibTeX::Value *ValueListViewItem::value()
+ {
+ return m_value;
+ }
+
+ QString ValueListViewItem::title()
+ {
+ return m_title;
+ }
+
+ void ValueListViewItem::setValue( BibTeX::Value *value )
+ {
+ if ( value != m_value )
+ {
+ if ( m_value != NULL )
+ delete m_value;
+
+ if ( value != NULL )
+ m_value = new BibTeX::Value( value );
+ else
+ m_value = new BibTeX::Value();
+
+ }
+ setTexts( m_title );
+ }
+
+ void ValueListViewItem::setTitle( const QString &title )
+ {
+ m_title = title;
+ setTexts( title );
+ }
+
+ void ValueListViewItem::setTexts( const QString& title )
+ {
+ setText( 0, title );
+ if ( m_value != NULL )
+ setText( 1, m_value->text() );
+ }
+
+}
+#include "entrywidgetother.moc"
diff --git a/src/entrywidgetother.h b/src/entrywidgetother.h
new file mode 100644
index 0000000..1119214
--- /dev/null
+++ b/src/entrywidgetother.h
@@ -0,0 +1,96 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETOTHER_H
+#define KBIBTEXENTRYWIDGETOTHER_H
+
+#include <kurl.h>
+
+#include <entrywidgettab.h>
+
+class QPushButton;
+class KListView;
+class QLineEdit;
+
+namespace KBibTeX
+{
+
+ class ValueListViewItem;
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetOther : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetOther( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetOther();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType /*entryType*/, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView * /*listViewWarnings*/ );
+
+ private:
+ bool m_isModified;
+
+ QPushButton *m_pushButtonAdd;
+ QPushButton *m_pushButtonDelete;
+ QPushButton *m_pushButtonOpen;
+ QLineEdit *m_lineEditKey;
+ FieldLineEdit *m_fieldLineEditValue;
+ KListView *m_listViewFields;
+ KURL m_internalURL;
+
+ void setupGUI();
+
+ private slots:
+ void updateGUI();
+ void fieldExecute( QListViewItem * item );
+ void addClicked();
+ void deleteClicked();
+ void openClicked();
+
+ };
+
+ class ValueListViewItem : public QListViewItem
+ {
+ public:
+ ValueListViewItem( const QString& title, BibTeX::Value *value, QListView *parent );
+ ~ValueListViewItem();
+
+ const BibTeX::Value *value();
+ QString title();
+ void setValue( BibTeX::Value *value );
+ void setTitle( const QString &title );
+
+ private:
+ QString m_title;
+ BibTeX::Value *m_value;
+
+ void setTexts( const QString& title );
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetpublication.cpp b/src/entrywidgetpublication.cpp
new file mode 100644
index 0000000..d1dfd14
--- /dev/null
+++ b/src/entrywidgetpublication.cpp
@@ -0,0 +1,563 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qregexp.h>
+#include <qpushbutton.h>
+#include <qpopupmenu.h>
+#include <qtooltip.h>
+
+#include <kurl.h>
+#include <kiconloader.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include <settings.h>
+#include <fieldlineedit.h>
+#include <entrywidgetwarningsitem.h>
+#include "entrywidgetpublication.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetPublication::EntryWidgetPublication( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+
+ EntryWidgetPublication::~EntryWidgetPublication()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetPublication::isModified()
+ {
+ return m_fieldLineEditOrganization->isModified() || m_fieldLineEditPublisher->isModified() || m_fieldLineEditSchool->isModified() || m_fieldLineEditInstitution->isModified() || m_fieldLineEditLocation->isModified() || m_fieldLineEditAddress->isModified() || m_fieldLineEditJournal->isModified() || m_fieldLineEditPages->isModified() || m_fieldLineEditEdition->isModified() || m_fieldLineEditChapter->isModified() || m_fieldLineEditVolume->isModified() || m_fieldLineEditNumber->isModified() || m_fieldLineEditMonth->isModified() || m_fieldLineEditYear->isModified() || m_fieldLineEditISBN->isModified() || m_fieldLineEditISSN->isModified() || m_fieldLineEditCrossRef->isModified() || m_fieldLineEditHowPublished->isModified();
+ }
+
+ void EntryWidgetPublication::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
+ {
+ bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftOrganization ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditOrganization->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftPublisher ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditPublisher->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftSchool ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditSchool->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftInstitution ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditInstitution->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftLocation ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditLocation->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftAddress ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditAddress->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftJournal ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditJournal->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftEdition ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditEdition->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftVolume ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditVolume->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftNumber ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditNumber->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftMonth ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditMonth->setEnabled( enableWidget );
+ m_pushButtonMonths->setEnabled( enableWidget && !m_isReadOnly );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftYear ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditYear->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftISBN ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditISBN->setEnabled( enableWidget );
+ int len = isbn().length();
+ m_pushButtonISBN->setEnabled( len == 10 || len == 13 );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftISSN ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditISSN->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftCrossRef ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditCrossRef->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftHowPublished ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditHowPublished->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftChapter ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditChapter->setEnabled( enableWidget );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftPages ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditPages->setEnabled( enableWidget );
+ }
+
+ void EntryWidgetPublication::apply( BibTeX::Entry *entry )
+ {
+ BibTeX::Value * value = m_fieldLineEditHowPublished->value();
+ setValue( entry, BibTeX::EntryField::ftHowPublished, value );
+ delete value;
+
+ value = m_fieldLineEditPublisher->value();
+ setValue( entry, BibTeX::EntryField::ftPublisher, value );
+ delete value;
+
+ value = m_fieldLineEditOrganization->value();
+ setValue( entry, BibTeX::EntryField::ftOrganization, value );
+ delete value;
+
+ value = m_fieldLineEditInstitution->value();
+ setValue( entry, BibTeX::EntryField::ftInstitution, value );
+ delete value;
+
+ value = m_fieldLineEditSchool->value();
+ setValue( entry, BibTeX::EntryField::ftSchool, value );
+ delete value;
+
+ value = m_fieldLineEditLocation->value();
+ setValue( entry, BibTeX::EntryField::ftLocation, value );
+ delete value;
+
+ value = m_fieldLineEditAddress->value();
+ setValue( entry, BibTeX::EntryField::ftAddress, value );
+ delete value;
+
+ value = m_fieldLineEditJournal->value();
+ setValue( entry, BibTeX::EntryField::ftJournal, value );
+ delete value;
+
+ value = m_fieldLineEditPages->value();
+ if ( value != NULL && value->items.first() != NULL )
+ {
+ BibTeX::PlainText *plainText = dynamic_cast<BibTeX::PlainText*>( value->items.first() );
+ if ( plainText != NULL )
+ plainText->setText( plainText->text().replace( QRegExp( "\\s*--?\\s*" ), QChar( 0x2013 ) ) );
+ }
+ setValue( entry, BibTeX::EntryField::ftPages, value );
+ delete value;
+
+ value = m_fieldLineEditEdition->value();
+ setValue( entry, BibTeX::EntryField::ftEdition, value );
+ delete value;
+
+ value = m_fieldLineEditChapter->value();
+ setValue( entry, BibTeX::EntryField::ftChapter, value );
+ delete value;
+
+ value = m_fieldLineEditVolume->value();
+ setValue( entry, BibTeX::EntryField::ftVolume, value );
+ delete value;
+
+ value = m_fieldLineEditNumber->value();
+ setValue( entry, BibTeX::EntryField::ftNumber, value );
+ delete value;
+
+ value = m_fieldLineEditMonth->value();
+ setValue( entry, BibTeX::EntryField::ftMonth, value );
+ delete value;
+
+ value = m_fieldLineEditYear->value();
+ setValue( entry, BibTeX::EntryField::ftYear, value );
+ delete value;
+
+ value = m_fieldLineEditISBN->value();
+ setValue( entry, BibTeX::EntryField::ftISBN, value );
+ delete value;
+
+ value = m_fieldLineEditISSN->value();
+ setValue( entry, BibTeX::EntryField::ftISSN, value );
+ delete value;
+
+ value = m_fieldLineEditCrossRef->value();
+ setValue( entry, BibTeX::EntryField::ftCrossRef, value );
+ delete value;
+ }
+
+ void EntryWidgetPublication::reset( BibTeX::Entry *entry )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftHowPublished );
+ m_fieldLineEditHowPublished->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftPublisher );
+ m_fieldLineEditPublisher->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftOrganization );
+ m_fieldLineEditOrganization->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftInstitution );
+ m_fieldLineEditInstitution->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftSchool );
+ m_fieldLineEditSchool->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftLocation );
+ m_fieldLineEditLocation->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftAddress );
+ m_fieldLineEditAddress->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftJournal );
+ m_fieldLineEditJournal->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftPages );
+ m_fieldLineEditPages->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftEdition );
+ m_fieldLineEditEdition->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftChapter );
+ m_fieldLineEditChapter->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftVolume );
+ m_fieldLineEditVolume->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftNumber );
+ m_fieldLineEditNumber->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftMonth );
+ m_fieldLineEditMonth->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftYear );
+ m_fieldLineEditYear->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftISBN );
+ m_fieldLineEditISBN->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftISSN );
+ m_fieldLineEditISSN->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftCrossRef );
+ m_fieldLineEditCrossRef->setValue( field != NULL ? field->value() : NULL );
+ slotSetCrossRefEntry();
+ }
+
+ void EntryWidgetPublication::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
+ {
+ bool crossRefValid = FALSE;
+ BibTeX::Value *value = NULL;
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftHowPublished, m_fieldLineEditHowPublished->caption(), !m_fieldLineEditHowPublished->isEmpty(), m_fieldLineEditHowPublished, listViewWarnings );
+
+ crossRefValid = m_crossRefEntry != NULL && m_crossRefEntry->getField( BibTeX::EntryField::ftPublisher ) != NULL;
+ addMissingWarning( entryType, BibTeX::EntryField::ftPublisher, m_fieldLineEditPublisher->caption(), !m_fieldLineEditPublisher->isEmpty() || crossRefValid, m_fieldLineEditPublisher, listViewWarnings );
+ if ( crossRefValid && m_fieldLineEditPublisher->isEmpty() )
+ addCrossRefInfo( m_fieldLineEditPublisher->caption(), m_fieldLineEditPublisher, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftOrganization, m_fieldLineEditOrganization->caption(), !m_fieldLineEditOrganization->isEmpty(), m_fieldLineEditOrganization, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftInstitution, m_fieldLineEditInstitution->caption(), !m_fieldLineEditInstitution->isEmpty(), m_fieldLineEditInstitution, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftSchool, m_fieldLineEditSchool->caption(), !m_fieldLineEditSchool->isEmpty(), m_fieldLineEditSchool, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftLocation, m_fieldLineEditLocation->caption(), !m_fieldLineEditLocation->isEmpty(), m_fieldLineEditLocation, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftAddress, m_fieldLineEditAddress->caption(), !m_fieldLineEditAddress->isEmpty(), m_fieldLineEditAddress, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftJournal, m_fieldLineEditJournal->caption(), !m_fieldLineEditJournal->isEmpty(), m_fieldLineEditJournal, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftEdition, m_fieldLineEditEdition->caption(), !m_fieldLineEditEdition->isEmpty(), m_fieldLineEditEdition, listViewWarnings );
+
+ crossRefValid = m_crossRefEntry != NULL && m_crossRefEntry->getField( BibTeX::EntryField::ftVolume ) != NULL;
+ addMissingWarning( entryType, BibTeX::EntryField::ftVolume, m_fieldLineEditVolume->caption(), !m_fieldLineEditVolume->isEmpty() || crossRefValid, m_fieldLineEditVolume, listViewWarnings );
+ if ( crossRefValid && m_fieldLineEditVolume->isEmpty() )
+ addCrossRefInfo( m_fieldLineEditVolume->caption(), m_fieldLineEditVolume, listViewWarnings );
+
+ crossRefValid = m_crossRefEntry != NULL && m_crossRefEntry->getField( BibTeX::EntryField::ftNumber ) != NULL;
+ addMissingWarning( entryType, BibTeX::EntryField::ftNumber, m_fieldLineEditNumber->caption(), !m_fieldLineEditNumber->isEmpty() || crossRefValid, m_fieldLineEditNumber, listViewWarnings );
+ if ( crossRefValid && m_fieldLineEditNumber->isEmpty() )
+ addCrossRefInfo( m_fieldLineEditNumber->caption(), m_fieldLineEditNumber, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftMonth, m_fieldLineEditMonth->caption(), !m_fieldLineEditMonth->isEmpty(), m_fieldLineEditMonth, listViewWarnings );
+
+ crossRefValid = m_crossRefEntry != NULL && m_crossRefEntry->getField( BibTeX::EntryField::ftYear ) != NULL;
+ addMissingWarning( entryType, BibTeX::EntryField::ftYear, m_fieldLineEditYear->caption(), !m_fieldLineEditYear->isEmpty() || crossRefValid, m_fieldLineEditYear, listViewWarnings );
+ if ( crossRefValid && m_fieldLineEditYear->isEmpty() )
+ addCrossRefInfo( m_fieldLineEditYear->caption(), m_fieldLineEditYear, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftISBN, m_fieldLineEditISBN->caption(), !m_fieldLineEditISBN->isEmpty(), m_fieldLineEditISBN, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftISSN, m_fieldLineEditISSN->caption(), !m_fieldLineEditISSN->isEmpty(), m_fieldLineEditISSN, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftCrossRef, m_fieldLineEditCrossRef->caption(), !m_fieldLineEditCrossRef->isEmpty(), m_fieldLineEditCrossRef, listViewWarnings );
+
+ if ( entryType == BibTeX::Entry::etInBook )
+ {
+ if ( m_fieldLineEditChapter->isEmpty() && m_fieldLineEditPages->isEmpty() )
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlWarning, i18n( "The fields 'Chapter' or 'Pages' are required, but both are missing" ), m_fieldLineEditPages, listViewWarnings, "warning" );
+ }
+ else
+ {
+ addMissingWarning( entryType, BibTeX::EntryField::ftPages, m_fieldLineEditPages->caption(), !m_fieldLineEditPages->isEmpty(), m_fieldLineEditPages, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftChapter, m_fieldLineEditChapter->caption(), !m_fieldLineEditChapter->isEmpty(), m_fieldLineEditChapter, listViewWarnings );
+ }
+
+ value = m_fieldLineEditJournal->value();
+ if ( value != NULL && !value->items.isEmpty() )
+ {
+ BibTeX::MacroKey *key = dynamic_cast<BibTeX::MacroKey*>( value->items[0] );
+ if ( key != NULL )
+ {
+ QString jourText = key->text();
+ if ( !jourText.isEmpty() && !m_bibtexfile->containsKey( jourText ) )
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlWarning, i18n( "The field 'Journal' refers to a not existing entry" ), m_fieldLineEditJournal, listViewWarnings, "warning" );
+ }
+ }
+
+ addFieldLineEditWarning( m_fieldLineEditHowPublished, m_fieldLineEditHowPublished->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditPublisher, m_fieldLineEditPublisher->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditOrganization, m_fieldLineEditOrganization->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditInstitution, m_fieldLineEditInstitution->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditSchool, m_fieldLineEditSchool->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditLocation, m_fieldLineEditLocation->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditAddress, m_fieldLineEditAddress->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditJournal, m_fieldLineEditJournal->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditPages, m_fieldLineEditPages->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditEdition, m_fieldLineEditEdition->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditChapter, m_fieldLineEditChapter->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditVolume, m_fieldLineEditVolume->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditNumber, m_fieldLineEditNumber->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditMonth, m_fieldLineEditMonth->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditYear, m_fieldLineEditYear->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditISBN, m_fieldLineEditISBN->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditISSN, m_fieldLineEditISSN->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditCrossRef, m_fieldLineEditCrossRef->caption(), listViewWarnings );
+
+ /** misusing this function to enable/disable ISBN button */
+ int len = isbn().length();
+ m_pushButtonISBN->setEnabled( len == 10 || len == 13 );
+ }
+
+ void EntryWidgetPublication::slotSetMonth( int month )
+ {
+ BibTeX::MacroKey *item = new BibTeX::MacroKey( BibTeX::MonthsTriple[ month ] );
+ BibTeX::Value * value = new BibTeX::Value();
+ value->items.append( item );
+ m_fieldLineEditMonth->setValue( value );
+ delete value;
+ }
+
+ void EntryWidgetPublication::slotSetCrossRefEntry()
+ {
+ m_crossRefEntry = NULL;
+ if ( m_fieldLineEditCrossRef->value() != NULL && m_bibtexfile != NULL )
+ {
+ QString crossRefText = m_fieldLineEditCrossRef->value() ->text();
+ if ( !crossRefText.isEmpty() )
+ m_crossRefEntry = dynamic_cast<BibTeX::Entry*>( m_bibtexfile->containsKey( crossRefText ) );
+ }
+ }
+
+ void EntryWidgetPublication::slotOpenISBN()
+ {
+ KURL url = KURL( QString( i18n( "http://en.wikipedia.org/w/index.php?title=Special:Booksources&isbn=%1" ) ).arg( isbn() ) );
+ Settings::openUrl( url, this );
+ }
+
+ /**
+ *
+ */
+ void EntryWidgetPublication::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 10, 5, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setColSpacing( 2, KDialog::spacingHint() * 4 );
+ gridLayout->setRowStretch( 9, 1 );
+
+ QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "Journal" ) ), this );
+ gridLayout->addWidget( label, 0, 0 );
+ m_fieldLineEditJournal = new KBibTeX::FieldLineEdit( i18n( "Journal" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditJournal" );
+ m_fieldLineEditJournal ->setFieldType( BibTeX::EntryField::ftJournal );
+ label->setBuddy( m_fieldLineEditJournal );
+ gridLayout->addWidget( m_fieldLineEditJournal, 0, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Volume" ) ), this );
+ gridLayout->addWidget( label, 1, 0 );
+ m_fieldLineEditVolume = new KBibTeX::FieldLineEdit( i18n( "Volume" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditVolume" );
+ m_fieldLineEditVolume->setFieldType( BibTeX::EntryField::ftVolume );
+ label->setBuddy( m_fieldLineEditVolume );
+ gridLayout->addWidget( m_fieldLineEditVolume, 1, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Number" ) ), this );
+ gridLayout->addWidget( label, 2, 0 );
+ m_fieldLineEditNumber = new KBibTeX::FieldLineEdit( i18n( "Number" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditNumber" );
+ m_fieldLineEditNumber ->setFieldType( BibTeX::EntryField::ftNumber );
+ label->setBuddy( m_fieldLineEditNumber );
+ gridLayout->addWidget( m_fieldLineEditNumber, 2, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Month" ) ), this );
+ gridLayout->addWidget( label, 3, 0 );
+ QHBoxLayout *innerLayout = new QHBoxLayout();
+ gridLayout->addLayout( innerLayout, 3, 1 );
+ m_pushButtonMonths = new QPushButton( this, "m_pushButtonMonths" );
+ m_pushButtonMonths->setIconSet( QIconSet( SmallIcon( "vcalendar" ) ) );
+ m_pushButtonMonths->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
+ m_pushButtonMonths->setEnabled( !m_isReadOnly );
+ innerLayout->addWidget( m_pushButtonMonths );
+ m_fieldLineEditMonth = new KBibTeX::FieldLineEdit( i18n( "Month" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditMonth" );
+ m_fieldLineEditMonth->setFieldType( BibTeX::EntryField::ftMonth );
+ label->setBuddy( m_fieldLineEditMonth );
+ innerLayout->addWidget( m_fieldLineEditMonth );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Year" ) ), this );
+ gridLayout->addWidget( label, 4, 0 );
+ m_fieldLineEditYear = new KBibTeX::FieldLineEdit( i18n( "Year" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditYear" );
+ m_fieldLineEditYear->setFieldType( BibTeX::EntryField::ftYear );
+ label->setBuddy( m_fieldLineEditYear );
+ gridLayout->addWidget( m_fieldLineEditYear, 4, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Pages" ) ), this );
+ gridLayout->addWidget( label, 5, 0 );
+ m_fieldLineEditPages = new KBibTeX::FieldLineEdit( i18n( "Pages" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditPages" );
+ m_fieldLineEditPages->setFieldType( BibTeX::EntryField::ftPages );
+ label->setBuddy( m_fieldLineEditPages );
+ gridLayout->addWidget( m_fieldLineEditPages, 5, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Edition" ) ), this );
+ gridLayout->addWidget( label, 6, 0 );
+ m_fieldLineEditEdition = new KBibTeX::FieldLineEdit( i18n( "Edition" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditEdition" );
+ m_fieldLineEditEdition->setFieldType( BibTeX::EntryField::ftEdition );
+ label->setBuddy( m_fieldLineEditEdition );
+ gridLayout->addWidget( m_fieldLineEditEdition, 6, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Chapter" ) ), this );
+ gridLayout->addWidget( label, 7, 0 );
+ m_fieldLineEditChapter = new KBibTeX::FieldLineEdit( i18n( "Chapter" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditChapter" );
+ m_fieldLineEditChapter ->setFieldType( BibTeX::EntryField::ftChapter );
+ label->setBuddy( m_fieldLineEditChapter );
+ gridLayout->addWidget( m_fieldLineEditChapter, 7, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Cross Reference" ) ), this );
+ gridLayout->addWidget( label, 8, 0 );
+ m_fieldLineEditCrossRef = new KBibTeX::FieldLineEdit( i18n( "Cross Reference" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditCrossRef" );
+ m_fieldLineEditCrossRef->setFieldType( BibTeX::EntryField::ftCrossRef );
+ label->setBuddy( m_fieldLineEditCrossRef );
+ gridLayout->addWidget( m_fieldLineEditCrossRef, 8, 1 );
+ connect( m_fieldLineEditCrossRef, SIGNAL( textChanged() ), this, SLOT( slotSetCrossRefEntry() ) );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Organization" ) ), this );
+ gridLayout->addWidget( label, 0, 3 );
+ m_fieldLineEditOrganization = new KBibTeX::FieldLineEdit( i18n( "Organization" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditOrganization" );
+ m_fieldLineEditOrganization->setFieldType( BibTeX::EntryField::ftOrganization );
+ label->setBuddy( m_fieldLineEditOrganization );
+ gridLayout->addWidget( m_fieldLineEditOrganization, 0, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Publisher" ) ), this );
+ gridLayout->addWidget( label, 1, 3 );
+ m_fieldLineEditPublisher = new KBibTeX::FieldLineEdit( i18n( "Publisher" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditPublisher" );
+ m_fieldLineEditPublisher->setFieldType( BibTeX::EntryField::ftPublisher );
+ label->setBuddy( m_fieldLineEditPublisher );
+ gridLayout->addWidget( m_fieldLineEditPublisher, 1, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "School" ) ), this );
+ gridLayout->addWidget( label, 2, 3 );
+ m_fieldLineEditSchool = new KBibTeX::FieldLineEdit( i18n( "School" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditSchool" );
+ m_fieldLineEditSchool->setFieldType( BibTeX::EntryField::ftSchool );
+ label->setBuddy( m_fieldLineEditSchool );
+ gridLayout->addWidget( m_fieldLineEditSchool, 2, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Institution" ) ), this );
+ gridLayout->addWidget( label, 3, 3 );
+ m_fieldLineEditInstitution = new KBibTeX::FieldLineEdit( i18n( "Institution" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditInstitution" );
+ m_fieldLineEditInstitution->setFieldType( BibTeX::EntryField::ftInstitution );
+ label->setBuddy( m_fieldLineEditInstitution );
+ gridLayout->addWidget( m_fieldLineEditInstitution, 3, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Location" ) ), this );
+ gridLayout->addWidget( label, 4, 3 );
+ m_fieldLineEditLocation = new KBibTeX::FieldLineEdit( i18n( "Location" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditLocation" );
+ m_fieldLineEditLocation->setFieldType( BibTeX::EntryField::ftLocation );
+ label->setBuddy( m_fieldLineEditLocation );
+ gridLayout->addWidget( m_fieldLineEditLocation, 4, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Address" ) ), this );
+ gridLayout->addWidget( label, 5, 3 );
+ m_fieldLineEditAddress = new KBibTeX::FieldLineEdit( i18n( "Address" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditAddress" );
+ m_fieldLineEditAddress->setFieldType( BibTeX::EntryField::ftAddress );
+ label->setBuddy( m_fieldLineEditAddress );
+ gridLayout->addWidget( m_fieldLineEditAddress, 5, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "ISBN" ) ), this );
+ gridLayout->addWidget( label, 6, 3 );
+ innerLayout = new QHBoxLayout();
+ gridLayout->addLayout( innerLayout, 6, 4 );
+ m_pushButtonISBN = new QPushButton( this, "m_pushButtonMonths" );
+ m_pushButtonISBN->setIconSet( QIconSet( SmallIcon( "find" ) ) );
+ m_pushButtonISBN->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
+ QToolTip::add( m_pushButtonISBN, i18n( "Lookup ISBN number in Wikipedia" ) );
+ innerLayout->addWidget( m_pushButtonISBN );
+ m_fieldLineEditISBN = new KBibTeX::FieldLineEdit( i18n( "ISBN" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditISBN" );
+ m_fieldLineEditISBN ->setFieldType( BibTeX::EntryField::ftISBN );
+ label->setBuddy( m_fieldLineEditISBN );
+ innerLayout->addWidget( m_fieldLineEditISBN );
+ connect( m_pushButtonISBN, SIGNAL( clicked() ), this, SLOT( slotOpenISBN() ) );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "ISSN" ) ), this );
+ gridLayout->addWidget( label, 7, 3 );
+ m_fieldLineEditISSN = new KBibTeX::FieldLineEdit( i18n( "ISSN" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditISSN" );
+ m_fieldLineEditISSN->setFieldType( BibTeX::EntryField::ftISSN );
+ label->setBuddy( m_fieldLineEditISSN );
+ gridLayout->addWidget( m_fieldLineEditISSN, 7, 4 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "How Published" ) ), this );
+ gridLayout->addWidget( label, 8, 3 );
+ m_fieldLineEditHowPublished = new KBibTeX::FieldLineEdit( i18n( "How Published" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditHowPublished" );
+ m_fieldLineEditHowPublished->setFieldType( BibTeX::EntryField::ftHowPublished );
+ label->setBuddy( m_fieldLineEditHowPublished );
+ gridLayout->addWidget( m_fieldLineEditHowPublished, 8, 4 );
+
+ QPopupMenu *menuMonths = new QPopupMenu( this, "menuMonths" );
+ for ( int i = 0; i < 12; i++ )
+ menuMonths->insertItem( BibTeX::Months[ i ], i );
+ m_pushButtonMonths->setPopup( menuMonths );
+ connect( menuMonths, SIGNAL( activated( int ) ), this, SLOT( slotSetMonth( int ) ) );
+ }
+
+ QString EntryWidgetPublication::isbn() const
+ {
+ BibTeX::Value *value = m_fieldLineEditISBN->value();
+ if ( value == NULL )
+ return "";
+
+ return value->text().replace( QRegExp( "[^0-9X]" ), "" );
+ }
+}
+#include "entrywidgetpublication.moc"
diff --git a/src/entrywidgetpublication.h b/src/entrywidgetpublication.h
new file mode 100644
index 0000000..e0e21ca
--- /dev/null
+++ b/src/entrywidgetpublication.h
@@ -0,0 +1,80 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETPUBLICATION_H
+#define KBIBTEXENTRYWIDGETPUBLICATION_H
+
+#include <entrywidgettab.h>
+
+class QPushButton;
+
+namespace KBibTeX
+{
+ class FieldLineEdit;
+
+ class EntryWidgetPublication : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetPublication( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetPublication();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private slots:
+ void slotSetMonth( int month );
+ void slotSetCrossRefEntry();
+ void slotOpenISBN();
+
+ private:
+ KBibTeX::FieldLineEdit *m_fieldLineEditOrganization;
+ KBibTeX::FieldLineEdit *m_fieldLineEditPublisher;
+ KBibTeX::FieldLineEdit *m_fieldLineEditSchool;
+ KBibTeX::FieldLineEdit *m_fieldLineEditInstitution;
+ KBibTeX::FieldLineEdit *m_fieldLineEditLocation;
+ KBibTeX::FieldLineEdit *m_fieldLineEditAddress;
+ KBibTeX::FieldLineEdit *m_fieldLineEditJournal;
+ KBibTeX::FieldLineEdit *m_fieldLineEditPages;
+ KBibTeX::FieldLineEdit *m_fieldLineEditEdition;
+ KBibTeX::FieldLineEdit *m_fieldLineEditChapter;
+ KBibTeX::FieldLineEdit *m_fieldLineEditVolume;
+ KBibTeX::FieldLineEdit *m_fieldLineEditNumber;
+ KBibTeX::FieldLineEdit *m_fieldLineEditMonth;
+ QPushButton *m_pushButtonMonths;
+ KBibTeX::FieldLineEdit *m_fieldLineEditYear;
+ KBibTeX::FieldLineEdit *m_fieldLineEditISBN;
+ QPushButton *m_pushButtonISBN;
+ KBibTeX::FieldLineEdit *m_fieldLineEditISSN;
+ KBibTeX::FieldLineEdit *m_fieldLineEditCrossRef;
+ KBibTeX::FieldLineEdit *m_fieldLineEditHowPublished;
+
+ void setupGUI();
+ QString isbn() const;
+
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetsource.cpp b/src/entrywidgetsource.cpp
new file mode 100644
index 0000000..27d95a6
--- /dev/null
+++ b/src/entrywidgetsource.cpp
@@ -0,0 +1,161 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qtextedit.h>
+#include <qbuffer.h>
+
+#include <kdialog.h>
+#include <kpushbutton.h>
+#include <klocale.h>
+#include <kglobalsettings.h>
+
+#include <fileexporterbibtex.h>
+#include <fileimporterbibtex.h>
+#include <entry.h>
+#include <settings.h>
+#include "entrywidgetsource.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetSource::EntryWidgetSource( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name ), m_entry( NULL )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetSource::~EntryWidgetSource()
+ {
+ if ( m_entry != NULL ) delete m_entry;
+ }
+
+ bool EntryWidgetSource::isModified()
+ {
+ return m_textEditSource->isModified();
+ }
+
+ bool EntryWidgetSource::containsValidText()
+ {
+ BibTeX::Entry dummy( BibTeX::Entry::etArticle, "iaKWjDMVuB2vQDuYRK49Y85tyxa9" );
+ apply( &dummy );
+ return dummy.id().compare( "iaKWjDMVuB2vQDuYRK49Y85tyxa9" ) != 0;
+ }
+
+ QString EntryWidgetSource::text()
+ {
+ return m_textEditSource->text();
+ }
+
+ void EntryWidgetSource::setText( const QString& text )
+ {
+ m_textEditSource->setText( text );
+ }
+
+ void EntryWidgetSource::updateGUI( BibTeX::Entry::EntryType /*entryType*/, bool /*enableAll*/ )
+ {
+ // nothing
+ }
+
+ void EntryWidgetSource::apply( BibTeX::Entry *entry )
+ {
+ Settings * settings = Settings::self();
+ QBuffer buffer;
+ BibTeX::FileImporterBibTeX importer( settings->editing_FirstNameFirst );
+
+ buffer.open( IO_WriteOnly );
+ QTextStream ts( &buffer );
+ ts.setEncoding( QTextStream::UnicodeUTF8 );
+ ts << m_textEditSource->text() << endl;
+ buffer.close();
+
+ buffer.open( IO_ReadOnly );
+ BibTeX::File *bibtexFile = importer.load( &buffer );
+ buffer.close();
+
+ if ( bibtexFile != NULL )
+ {
+ if ( bibtexFile->count() == 1 )
+ {
+ BibTeX::Entry * parsedEntry = dynamic_cast<BibTeX::Entry*>( bibtexFile->at( 0 ) );
+ if ( parsedEntry != NULL )
+ {
+ entry->copyFrom( parsedEntry );
+ settings->addToCompletion( parsedEntry );
+ }
+ }
+ delete bibtexFile;
+ }
+ }
+
+ void EntryWidgetSource::reset( BibTeX::Entry *entry )
+ {
+ if ( m_entry != entry )
+ {
+ if ( m_entry != NULL ) m_entry->copyFrom( entry ); else m_entry = new BibTeX::Entry( entry );
+ }
+
+ Settings * settings = Settings::self();
+
+ QBuffer buffer;
+ BibTeX::FileExporterBibTeX exporter;
+ exporter.setEncoding( "latex" );
+ exporter.setStringDelimiter( settings->fileIO_BibtexStringOpenDelimiter, settings->fileIO_BibtexStringCloseDelimiter );
+ exporter.setKeywordCasing( settings->fileIO_KeywordCasing );
+ exporter.setEnclosingCurlyBrackets( settings->fileIO_EnclosingCurlyBrackets );
+
+ buffer.open( IO_WriteOnly );
+ exporter.save( &buffer, entry );
+ buffer.close();
+
+ buffer.open( IO_ReadOnly );
+ QTextStream ts( &buffer );
+ ts.setEncoding( QTextStream::UnicodeUTF8 );
+ m_textEditSource->setText( ts.read() );
+ buffer.close();
+ }
+
+ void EntryWidgetSource::restore()
+ {
+ reset( m_entry );
+ }
+
+ void EntryWidgetSource::updateWarnings( BibTeX::Entry::EntryType /*entryType*/, QListView * /*listViewWarnings*/ )
+ {
+ // nothing
+ }
+
+ void EntryWidgetSource::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 2, 2, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setRowStretch( 0, 5 );
+ gridLayout->setColStretch( 0, 5 );
+
+ m_textEditSource = new QTextEdit( this );
+ gridLayout->addMultiCellWidget( m_textEditSource, 0, 0, 0, 1 );
+ m_textEditSource->setFont( KGlobalSettings::fixedFont() );
+ m_textEditSource->setReadOnly( m_isReadOnly );
+
+ KPushButton *btnReset = new KPushButton( i18n( "Restore" ), this );
+ gridLayout->addWidget( btnReset, 1, 1 );
+ connect( btnReset, SIGNAL( clicked() ), this, SLOT( restore() ) );
+ }
+
+}
+#include "entrywidgetsource.moc"
diff --git a/src/entrywidgetsource.h b/src/entrywidgetsource.h
new file mode 100644
index 0000000..77b98e2
--- /dev/null
+++ b/src/entrywidgetsource.h
@@ -0,0 +1,61 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETSOURCE_H
+#define KBIBTEXENTRYWIDGETSOURCE_H
+
+#include <entrywidgettab.h>
+
+class QTextEdit;
+
+namespace KBibTeX
+{
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetSource : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetSource( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetSource();
+
+ bool isModified();
+ bool containsValidText();
+ QString text();
+ void setText( const QString& text );
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void restore();
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private:
+ QTextEdit *m_textEditSource;
+ BibTeX::Entry *m_entry;
+
+ void setupGUI();
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgettab.cpp b/src/entrywidgettab.cpp
new file mode 100644
index 0000000..c4efc51
--- /dev/null
+++ b/src/entrywidgettab.cpp
@@ -0,0 +1,91 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <klocale.h>
+
+#include <entry.h>
+#include <entrywidgetwarningsitem.h>
+#include <fieldlineedit.h>
+#include "entrywidgettab.h"
+
+namespace KBibTeX
+{
+ BibTeX::Entry *EntryWidgetTab::m_crossRefEntry = NULL;
+
+ EntryWidgetTab::EntryWidgetTab(BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : QWidget( parent, name ), m_isReadOnly( isReadOnly ), m_bibtexfile( bibtexfile )
+ {
+ // nothing
+ }
+
+ EntryWidgetTab::~EntryWidgetTab()
+ {
+ // nothing
+ }
+
+ void EntryWidgetTab::setValue( BibTeX::Entry *entry, const BibTeX::EntryField::FieldType fieldType, BibTeX::Value *value )
+ {
+ BibTeX::EntryField * field = entry->getField( fieldType );
+
+ if ( value != NULL )
+ {
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( fieldType );
+ entry->addField( field );
+ }
+ field->setValue( value );
+ }
+ else
+ {
+ if ( field != NULL )
+ entry->deleteField( fieldType );
+ }
+ }
+
+ void EntryWidgetTab::addMissingWarning( BibTeX::Entry::EntryType entryType, BibTeX::EntryField::FieldType fieldType, const QString& label, bool valid, QWidget *widget, QListView *listView )
+ {
+ if ( BibTeX::Entry::getRequireStatus( entryType, fieldType ) == BibTeX::Entry::frsRequired && !valid )
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlWarning, QString( i18n( "The field '%1' is required, but missing" ) ).arg( label ), widget, listView, "warning" );
+ }
+
+ void EntryWidgetTab::addCrossRefInfo( const QString& label, QWidget *widget, QListView *listView )
+ {
+ QString crossRefId = m_crossRefEntry != NULL ? m_crossRefEntry->id() : "???";
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlInformation, QString( i18n( "Using cross referenced entry '%1' for field '%2'" ) ).arg( crossRefId ).arg( label ), widget, listView, "information" );
+ }
+
+ void EntryWidgetTab::addFieldLineEditWarning( FieldLineEdit *fieldLineEdit, const QString& label, QListView *listView )
+ {
+ switch ( fieldLineEdit->error() )
+ {
+ case FieldLineEdit::etInvalidStringKey:
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlError, QString( i18n( "The field '%1' contains string keys with invalid characters" ) ).arg( label ), fieldLineEdit, listView, "error" );
+ break;
+ case FieldLineEdit::etNoError:
+ {
+ // nothing
+ }
+ break;
+ default:
+ new EntryWidgetWarningsItem( EntryWidgetWarningsItem::wlError, QString( i18n( "The field '%1' contains some unknown error" ) ).arg( label ), fieldLineEdit, listView, "error" );
+ }
+ }
+}
+#include "entrywidgettab.moc"
diff --git a/src/entrywidgettab.h b/src/entrywidgettab.h
new file mode 100644
index 0000000..8e63252
--- /dev/null
+++ b/src/entrywidgettab.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETTAB_H
+#define KBIBTEXENTRYWIDGETTAB_H
+
+#include <qwidget.h>
+
+#include <entry.h>
+#include <file.h>
+
+class QListView;
+
+namespace KBibTeX
+{
+ class FieldLineEdit;
+
+ class EntryWidgetTab : public QWidget
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetTab( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetTab();
+
+ virtual bool isModified() = 0;
+
+ public slots:
+ virtual void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll ) = 0;
+ virtual void apply( BibTeX::Entry *entry ) = 0;
+ virtual void reset( BibTeX::Entry *entry ) = 0;
+ virtual void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings ) = 0;
+
+ protected:
+ void setValue( BibTeX::Entry *entry, const BibTeX::EntryField::FieldType fieldType, BibTeX::Value *value );
+ void addMissingWarning( BibTeX::Entry::EntryType entryType, BibTeX::EntryField::FieldType fieldType, const QString& label, bool valid, QWidget *widget, QListView *listView );
+ void addCrossRefInfo( const QString& label, QWidget *widget, QListView *listView );
+ void addFieldLineEditWarning( FieldLineEdit *fieldLineEdit, const QString& label, QListView *listView );
+
+ bool m_isReadOnly;
+ static BibTeX::Entry *m_crossRefEntry;
+ BibTeX::File *m_bibtexfile;
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgettitle.cpp b/src/entrywidgettitle.cpp
new file mode 100644
index 0000000..f72bb71
--- /dev/null
+++ b/src/entrywidgettitle.cpp
@@ -0,0 +1,136 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include <fieldlineedit.h>
+#include <value.h>
+#include <entryfield.h>
+#include "entrywidgettitle.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetTitle::EntryWidgetTitle( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name )
+ : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetTitle::~EntryWidgetTitle()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetTitle::isModified()
+ {
+ return m_fieldLineEditTitle->isModified() || m_fieldLineEditBookTitle->isModified() || m_fieldLineEditSeries->isModified();
+ }
+
+ void EntryWidgetTitle::updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll )
+ {
+ bool enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftTitle ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditTitle->setEnabled( enableWidget );
+ m_fieldLineEditTitle->setFieldType( BibTeX::EntryField::ftTitle );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftBookTitle ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditBookTitle->setEnabled( enableWidget );
+ m_fieldLineEditBookTitle->setFieldType( BibTeX::EntryField::ftBookTitle );
+
+ enableWidget = enableAll || BibTeX::Entry::getRequireStatus( entryType, BibTeX::EntryField::ftSeries ) != BibTeX::Entry::frsIgnored;
+ m_fieldLineEditSeries->setEnabled( enableWidget );
+ m_fieldLineEditSeries->setFieldType( BibTeX::EntryField::ftSeries );
+ }
+
+ void EntryWidgetTitle::apply(BibTeX::Entry *entry )
+ {
+ BibTeX::Value * value = m_fieldLineEditTitle->value();
+ setValue( entry, BibTeX::EntryField::ftTitle, value );
+ delete value;
+
+ value = m_fieldLineEditBookTitle->value();
+ setValue( entry, BibTeX::EntryField::ftBookTitle, value );
+ delete value;
+
+ value = m_fieldLineEditSeries->value();
+ setValue( entry, BibTeX::EntryField::ftSeries, value );
+ delete value;
+ }
+
+ void EntryWidgetTitle::reset(BibTeX::Entry *entry )
+ {
+ BibTeX::EntryField * field = entry->getField( BibTeX::EntryField::ftTitle );
+ m_fieldLineEditTitle->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftBookTitle );
+ m_fieldLineEditBookTitle->setValue( field != NULL ? field->value() : NULL );
+
+ field = entry->getField( BibTeX::EntryField::ftSeries );
+ m_fieldLineEditSeries->setValue( field != NULL ? field->value() : NULL );
+ }
+
+ void EntryWidgetTitle::updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings )
+ {
+ bool crossRefValid = FALSE;
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftTitle, m_fieldLineEditTitle->caption(), !m_fieldLineEditTitle->isEmpty(), m_fieldLineEditTitle, listViewWarnings );
+
+ crossRefValid = m_crossRefEntry != NULL && m_crossRefEntry->getField( BibTeX::EntryField::ftTitle ) != NULL;
+ addMissingWarning( entryType, BibTeX::EntryField::ftBookTitle, m_fieldLineEditBookTitle->caption(), !m_fieldLineEditBookTitle->isEmpty() || crossRefValid, m_fieldLineEditBookTitle, listViewWarnings );
+ if ( crossRefValid && m_fieldLineEditBookTitle->isEmpty() )
+ addCrossRefInfo( m_fieldLineEditBookTitle->caption(), m_fieldLineEditBookTitle, listViewWarnings );
+
+ addMissingWarning( entryType, BibTeX::EntryField::ftSeries, m_fieldLineEditSeries->caption(), !m_fieldLineEditSeries->isEmpty(), m_fieldLineEditSeries, listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditTitle, m_fieldLineEditTitle->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditBookTitle, m_fieldLineEditBookTitle->caption(), listViewWarnings );
+
+ addFieldLineEditWarning( m_fieldLineEditSeries, m_fieldLineEditSeries->caption(), listViewWarnings );
+ }
+
+ void EntryWidgetTitle::setupGUI()
+ {
+ QGridLayout * gridLayout = new QGridLayout( this, 4, 2, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setRowStretch( 3, 1 );
+
+ QLabel *label = new QLabel( QString( "%1:" ).arg( i18n( "Title" ) ), this );
+ gridLayout->addWidget( label, 0, 0 );
+ m_fieldLineEditTitle = new KBibTeX::FieldLineEdit( i18n( "Title" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditTitle" );
+ label->setBuddy( m_fieldLineEditTitle );
+ gridLayout->addWidget( m_fieldLineEditTitle, 0, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Book Title" ) ), this );
+ gridLayout->addWidget( label, 1, 0 );
+ m_fieldLineEditBookTitle = new KBibTeX::FieldLineEdit( i18n( "Book Title" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditBookTitle" );
+ label->setBuddy( m_fieldLineEditBookTitle );
+ gridLayout->addWidget( m_fieldLineEditBookTitle, 1, 1 );
+
+ label = new QLabel( QString( "%1:" ).arg( i18n( "Series" ) ), this );
+ gridLayout->addWidget( label, 2, 0 );
+ m_fieldLineEditSeries = new KBibTeX::FieldLineEdit( i18n( "Series" ), KBibTeX::FieldLineEdit::itSingleLine, m_isReadOnly, this, "m_fieldLineEditSeries" );
+ label->setBuddy( m_fieldLineEditSeries );
+ gridLayout->addWidget( m_fieldLineEditSeries, 2, 1 );
+ }
+
+}
+#include "entrywidgettitle.moc"
diff --git a/src/entrywidgettitle.h b/src/entrywidgettitle.h
new file mode 100644
index 0000000..c43bb57
--- /dev/null
+++ b/src/entrywidgettitle.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETTITLE_H
+#define KBIBTEXENTRYWIDGETTITLE_H
+
+#include <entrywidgettab.h>
+
+namespace KBibTeX
+{
+ class FieldLineEdit;
+
+ class EntryWidgetTitle : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetTitle( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetTitle();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply( BibTeX::Entry *entry );
+ void reset( BibTeX::Entry *entry );
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private:
+ friend class EntryWidget;
+ KBibTeX::FieldLineEdit *m_fieldLineEditTitle;
+ KBibTeX::FieldLineEdit *m_fieldLineEditBookTitle;
+ KBibTeX::FieldLineEdit *m_fieldLineEditSeries;
+
+ void setupGUI();
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetuserdefined.cpp b/src/entrywidgetuserdefined.cpp
new file mode 100644
index 0000000..6479f73
--- /dev/null
+++ b/src/entrywidgetuserdefined.cpp
@@ -0,0 +1,144 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <kdebug.h>
+#include <kdialog.h>
+#include <kiconloader.h>
+#include <klocale.h>
+
+#include <settings.h>
+#include "entrywidgetuserdefined.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetUserDefined::EntryWidgetUserDefined( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent, const char *name ) : EntryWidgetTab( bibtexfile, isReadOnly, parent, name )
+ {
+ setupGUI();
+ }
+
+ EntryWidgetUserDefined::~EntryWidgetUserDefined()
+ {
+ // nothing
+ }
+
+ bool EntryWidgetUserDefined::isModified()
+ {
+ bool result = FALSE;
+ for ( QValueList<FieldLineEdit*>::iterator it = m_widgets.begin(); !FALSE && it != m_widgets.end(); ++it )
+ result |= ( *it )->isModified();
+ return result;
+ }
+
+ void EntryWidgetUserDefined::updateGUI( BibTeX::Entry::EntryType /*entryType*/, bool /*enableAll*/ )
+ {
+// nothing
+ }
+
+ void EntryWidgetUserDefined::apply( BibTeX::Entry *entry )
+ {
+ Settings * settings = Settings::self();
+ for ( unsigned int i = 0; i < settings->userDefinedInputFields.count(); ++i )
+ {
+ FieldLineEdit *widget = m_widgets[i];
+ Settings::UserDefinedInputFields *udif = settings->userDefinedInputFields[i];
+
+ BibTeX::Value * value = widget->value();
+ if ( value == NULL )
+ entry->deleteField( udif->name );
+ else
+ {
+ if ( value->text().isEmpty() )
+ entry->deleteField( udif->name );
+ else
+ {
+ BibTeX::EntryField * field = entry->getField( udif->name );
+ if ( field == NULL )
+ {
+ field = new BibTeX::EntryField( udif->name );
+ entry->addField( field );
+ }
+ field->setValue( value );
+ }
+ delete value;
+ }
+ }
+ }
+
+ void EntryWidgetUserDefined::reset( BibTeX::Entry *entry )
+ {
+ Settings * settings = Settings::self();
+ for ( unsigned int i = 0; i < settings->userDefinedInputFields.count(); ++i )
+ {
+ FieldLineEdit *widget = m_widgets[i];
+ Settings::UserDefinedInputFields *udif = settings->userDefinedInputFields[i];
+
+ BibTeX::EntryField * field = entry->getField( udif->name );
+ widget->setValue( field != NULL ? field->value() : NULL );
+ }
+ }
+
+ void EntryWidgetUserDefined::updateWarnings( BibTeX::Entry::EntryType /*entryType*/, QListView */*listViewWarnings*/ )
+ {
+// nothing
+ }
+
+ void EntryWidgetUserDefined::setupGUI()
+ {
+ Settings * settings = Settings::self();
+ int rows = settings->userDefinedInputFields.count() + 1;
+ if ( rows < 2 ) rows = 2;
+ QGridLayout *gridLayout = new QGridLayout( this, rows, 2, KDialog::marginHint(), KDialog::spacingHint(), "gridLayout" );
+ gridLayout->setRowStretch( rows - 1, 1 );
+
+ if ( settings->userDefinedInputFields.count() > 0 )
+ for ( unsigned int i = 0; i < settings->userDefinedInputFields.count(); ++i )
+ {
+ QLabel *label = new QLabel( settings->userDefinedInputFields[i]->label, this );
+ gridLayout->addWidget( label, i, 0 );
+ if ( settings->userDefinedInputFields[i]->inputType == FieldLineEdit::itMultiLine )
+ label->setAlignment( Qt::AlignTop );
+
+ FieldLineEdit *widget = new FieldLineEdit( settings->userDefinedInputFields[i]->label, settings->userDefinedInputFields[i]->inputType, m_isReadOnly, this );
+ gridLayout->addWidget( widget, i, 1 );
+
+ label->setBuddy( widget );
+ m_widgets << widget;
+ }
+ else
+ {
+ gridLayout->setColStretch( 0, 0 );
+ gridLayout->setColStretch( 1, 1 );
+
+ QLabel *label = new QLabel( this );
+ gridLayout->addWidget( label, 0, 0 );
+ label->setPixmap( BarIcon( "messagebox_info" ) );
+ label->setAlignment( Qt::AlignVCenter | Qt::AlignLeft | Qt::WordBreak );
+
+ label = new QLabel( i18n( "Please use the settings dialog to add user-defined fields here." ), this );
+ label->setAlignment( Qt::AlignVCenter | Qt::AlignLeft | Qt::WordBreak );
+ gridLayout->addWidget( label, 0, 1 );
+ }
+ }
+
+}
+#include "entrywidgetuserdefined.moc"
diff --git a/src/entrywidgetuserdefined.h b/src/entrywidgetuserdefined.h
new file mode 100644
index 0000000..bc5e238
--- /dev/null
+++ b/src/entrywidgetuserdefined.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETUSERDEFINED_H
+#define KBIBTEXENTRYWIDGETUSERDEFINED_H
+
+#include <entrywidgettab.h>
+
+namespace KBibTeX
+{
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class EntryWidgetUserDefined : public EntryWidgetTab
+ {
+ Q_OBJECT
+ public:
+ EntryWidgetUserDefined( BibTeX::File *bibtexfile, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~EntryWidgetUserDefined();
+
+ bool isModified();
+
+ public slots:
+ void updateGUI( BibTeX::Entry::EntryType entryType, bool enableAll );
+ void apply(BibTeX::Entry *entry);
+ void reset(BibTeX::Entry *entry);
+ void updateWarnings( BibTeX::Entry::EntryType entryType, QListView *listViewWarnings );
+
+ private:
+ QValueList<FieldLineEdit*> m_widgets;
+ void setupGUI();
+
+ };
+
+}
+
+#endif
diff --git a/src/entrywidgetwarningsitem.cpp b/src/entrywidgetwarningsitem.cpp
new file mode 100644
index 0000000..741d1a0
--- /dev/null
+++ b/src/entrywidgetwarningsitem.cpp
@@ -0,0 +1,62 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <kiconloader.h>
+#include <klocale.h>
+
+#include "entrywidgetwarningsitem.h"
+
+namespace KBibTeX
+{
+
+ EntryWidgetWarningsItem::EntryWidgetWarningsItem( WarningLevel level, const QString &message, QWidget *widget, QListView *parent, const char* name )
+ : QListViewItem( parent, name ), m_widget( widget )
+ {
+ KIconLoader * loader = KGlobal::instance() ->iconLoader();
+ switch ( level )
+ {
+ case wlInformation:
+ setPixmap( 0, loader->loadIcon( "messagebox_info", KIcon::NoGroup, KIcon::SizeSmall ) );
+ break;
+ case wlWarning:
+ setPixmap( 0, loader->loadIcon( "messagebox_warning", KIcon::NoGroup, KIcon::SizeSmall ) );
+ break;
+ case wlError:
+ setPixmap( 0, loader->loadIcon( "messagebox_critical", KIcon::NoGroup, KIcon::SizeSmall ) );
+ break;
+ default:
+ {
+ // nothing
+ }
+ }
+ setText( 0, message );
+ }
+
+
+ EntryWidgetWarningsItem::~EntryWidgetWarningsItem()
+ {
+ // nothing
+ }
+
+ QWidget *EntryWidgetWarningsItem::widget()
+ {
+ return m_widget;
+ }
+
+}
diff --git a/src/entrywidgetwarningsitem.h b/src/entrywidgetwarningsitem.h
new file mode 100644
index 0000000..2aa2044
--- /dev/null
+++ b/src/entrywidgetwarningsitem.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXENTRYWIDGETWARNINGSITEM_H
+#define KBIBTEXENTRYWIDGETWARNINGSITEM_H
+
+#include <qlistview.h>
+
+class QString;
+
+namespace KBibTeX
+{
+
+ class EntryWidgetWarningsItem : public QListViewItem
+ {
+ public:
+ enum WarningLevel {wlInformation = 1, wlWarning = 2, wlError = 3};
+
+ EntryWidgetWarningsItem( WarningLevel level, const QString &message, QWidget *widget, QListView *parent, const char* name = NULL );
+ ~EntryWidgetWarningsItem();
+
+ QWidget *widget();
+
+ private:
+ QWidget *m_widget;
+ };
+
+}
+
+#endif
diff --git a/src/fieldlineedit.cpp b/src/fieldlineedit.cpp
new file mode 100644
index 0000000..ba36fe7
--- /dev/null
+++ b/src/fieldlineedit.cpp
@@ -0,0 +1,369 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qtextedit.h>
+
+#include <kdialog.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <klineedit.h>
+
+#include <element.h>
+#include <entry.h>
+#include <settings.h>
+#include <value.h>
+#include <valuewidget.h>
+#include "fieldlineedit.h"
+
+namespace KBibTeX
+{
+ FieldLineEdit::FieldLineEdit( const QString& caption, InputType inputType, bool isReadOnly, QWidget *parent, const char *name )
+ : QWidget( parent, name ), m_value( new BibTeX::Value() ), m_caption( caption ), m_lineEdit( NULL ), m_textEdit( NULL ), m_isReadOnly( isReadOnly ), m_enabled( TRUE ), m_inputType( inputType ), m_isModified( FALSE ), m_fieldType( BibTeX::EntryField::ftUnknown ), m_completion( NULL )
+ {
+ setupGUI( name );
+ }
+
+
+ FieldLineEdit::~FieldLineEdit()
+ {
+ delete m_value;
+ }
+
+ void FieldLineEdit::setValue( const BibTeX::Value *value )
+ {
+ delete m_value;
+
+ if ( value != NULL )
+ m_value = new BibTeX::Value( value );
+ else
+ m_value = new BibTeX::Value();
+
+ updateGUI();
+ m_isModified = FALSE;
+ }
+
+ BibTeX::Value *FieldLineEdit::value()
+ {
+ if ( m_value->items.isEmpty() )
+ return NULL;
+ else
+ return new BibTeX::Value( m_value );
+ }
+
+ void FieldLineEdit::setEnabled( bool enabled )
+ {
+ m_enabled = enabled;
+ updateGUI();
+ }
+
+ void FieldLineEdit::setFieldType( BibTeX::EntryField::FieldType fieldType )
+ {
+ m_fieldType = fieldType;
+ Settings * settings = Settings::self();
+ m_completion = settings->completion( m_fieldType );
+
+ if ( m_lineEdit != NULL )
+ {
+ if ( !m_pushButtonString->isOn() )
+ m_lineEdit->setCompletionObject( m_completion );
+ else
+ m_lineEdit->setCompletionObject( settings->completionMacro );
+ QToolTip::add( m_lineEdit, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+ QWhatsThis::add( m_lineEdit, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+ }
+ else if ( m_textEdit != NULL )
+ {
+ QToolTip::add( m_textEdit, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+ QWhatsThis::add( m_textEdit, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+ }
+
+ }
+
+ QString FieldLineEdit::caption()
+ {
+ return m_caption;
+ }
+
+ bool FieldLineEdit::isEmpty()
+ {
+ return m_value->items.isEmpty();
+ }
+
+ bool FieldLineEdit::isModified()
+ {
+ return m_isModified;
+ }
+
+ FieldLineEdit::ErrorType FieldLineEdit::error()
+ {
+ ErrorType result = etNoError;
+ for ( QValueList<BibTeX::ValueItem*>::ConstIterator it = m_value->items.begin(); result == etNoError && it != m_value->items.end(); ++it )
+ {
+ BibTeX::MacroKey *macroKey = dynamic_cast<BibTeX::MacroKey*>( *it );
+ result = ( macroKey != NULL && !macroKey->isValid() ) ? etInvalidStringKey : etNoError;
+ }
+
+ return result;
+ }
+
+ void FieldLineEdit::slotTextChanged( )
+ {
+ QString text;
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ text = m_lineEdit->text();
+ break;
+ case itMultiLine:
+ text = m_textEdit->text();
+ break;
+ }
+
+ if ( m_value->items.count() <= 1 )
+ {
+ m_value->items.clear();
+ if ( !text.isEmpty() )
+ {
+ if ( m_pushButtonString->isOn() )
+ m_value->items.append( new BibTeX::MacroKey( text ) );
+ else
+ m_value->items.append( new BibTeX::PlainText( text ) );
+ }
+ m_isModified = TRUE;
+ }
+
+ updateGUI();
+
+ emit textChanged();
+ }
+
+ void FieldLineEdit::slotStringToggled()
+ {
+ if ( m_value->items.count() == 1 )
+ {
+ QString text = m_value->items.first()->text();
+ if ( m_pushButtonString->isOn() )
+ {
+ BibTeX::PlainText *plainText = dynamic_cast<BibTeX::PlainText*>( m_value->items.first() );
+ if ( plainText != NULL )
+ {
+ m_value->items.clear();
+ m_value->items.append( new BibTeX::MacroKey( text ) );
+ }
+ }
+ else
+ {
+ BibTeX::MacroKey *macroKey = dynamic_cast<BibTeX::MacroKey*>( m_value->items.first() );
+ if ( macroKey != NULL )
+ {
+ m_value->items.clear();
+ m_value->items.append( new BibTeX::PlainText( text ) );
+ }
+ }
+ }
+
+ if ( m_lineEdit != NULL )
+ {
+ if ( m_pushButtonString->isOn() )
+ {
+ Settings * settings = Settings::self();
+ m_lineEdit->setCompletionObject( settings->completionMacro );
+ }
+ else
+ m_lineEdit->setCompletionObject( m_completion );
+ }
+
+ updateGUI();
+ emit textChanged();
+ m_isModified = TRUE;
+ }
+
+ void FieldLineEdit::slotComplexClicked()
+ {
+ if ( ValueWidget::execute( m_caption, m_fieldType, m_value, m_isReadOnly, this ) == QDialog::Accepted )
+ {
+ updateGUI();
+ emit textChanged();
+ m_isModified = TRUE;
+ }
+ }
+
+ void FieldLineEdit::setupGUI( const char *name )
+ {
+ Settings * settings = Settings::self();
+
+ char * subname = NULL;
+ if ( name != NULL )
+ subname = new char[ strlen( name ) + 20 ];
+
+ if ( subname != NULL )
+ {
+ strcpy( subname, name );
+ strcat( subname, "_pbstring" );
+ }
+ m_pushButtonString = new QPushButton( this, subname );
+ m_pushButtonString->setIconSet( QIconSet( SmallIcon( "flag" ) ) );
+ m_pushButtonString->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ m_pushButtonString->setToggleButton( TRUE );
+ QToolTip::add( m_pushButtonString, QString( i18n( "Set '%1' to be a string key" ) ).arg( m_caption ) );
+ m_pushButtonString->setEnabled( !m_isReadOnly );
+ connect( m_pushButtonString, SIGNAL( clicked() ), this, SLOT( slotStringToggled() ) );
+
+ if ( subname != NULL )
+ {
+ strcpy( subname, name );
+ strcat( subname, "_pbcomplex" );
+ }
+ m_pushButtonComplex = new QPushButton( this, subname );
+ m_pushButtonComplex->setIconSet( QIconSet( SmallIcon( "leftjust" ) ) );
+ m_pushButtonComplex->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
+ QToolTip::add( m_pushButtonComplex, QString( i18n( "Edit '%1' as a concatenated value" ) ).arg( m_caption ) );
+ connect( m_pushButtonComplex, SIGNAL( clicked() ), this, SLOT( slotComplexClicked() ) );
+
+ QGridLayout * layout = NULL;
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ {
+ layout = new QGridLayout( this, 2, 3, 0, KDialog::spacingHint() );
+ if ( subname != NULL )
+ {
+ strcpy( subname, name );
+ strcat( subname, "_lineedit" );
+ }
+ m_lineEdit = new KLineEdit( this, subname );
+ m_lineEdit->setReadOnly( m_isReadOnly );
+ if ( settings->editing_UseSpecialFont )
+ m_lineEdit->setFont( settings->editing_SpecialFont );
+ layout->addWidget( m_lineEdit, 0, 0 );
+ setFocusProxy( m_lineEdit );
+ layout->addWidget( m_pushButtonString, 0, 1 );
+ layout->addWidget( m_pushButtonComplex, 0, 2 );
+ QWidget::setTabOrder( m_lineEdit, m_pushButtonString );
+ }
+ break;
+ case itMultiLine:
+ {
+ layout = new QGridLayout( this, 3, 2, 0, KDialog::spacingHint() );
+ layout->setRowStretch( 2, 1 );
+ if ( subname != NULL )
+ {
+ strcpy( subname, name );
+ strcat( subname, "_textedit" );
+ }
+ m_textEdit = new QTextEdit( this, subname );
+ m_textEdit->setReadOnly( m_isReadOnly );
+ if ( settings->editing_UseSpecialFont )
+ m_textEdit->setFont( settings->editing_SpecialFont );
+ layout->addMultiCellWidget( m_textEdit, 0, 2, 0, 0 );
+ setFocusProxy( m_textEdit );
+ layout->addWidget( m_pushButtonString, 0, 1 );
+ layout->addWidget( m_pushButtonComplex, 1, 1 );
+ QWidget::setTabOrder( m_textEdit, m_pushButtonString );
+ }
+ break;
+ }
+
+ QWidget::setTabOrder( m_pushButtonString, m_pushButtonComplex );
+ layout->setRowStretch( layout->numRows() - 1, 1 );
+
+ if ( subname != NULL )
+ delete[] subname;
+
+ enableSignals( TRUE );
+ }
+
+ void FieldLineEdit::updateGUI()
+ {
+ enableSignals( FALSE );
+
+ bool inputEnable = ( m_value->items.count() <= 1 ) && m_enabled;
+ m_pushButtonString->setEnabled( inputEnable && !m_isReadOnly );
+ bool isComplex = !inputEnable && m_value->items.count() > 1;
+
+ if ( m_value->items.count() == 1 )
+ {
+ BibTeX::ValueItem * item = m_value->items.first();
+ m_pushButtonString->setOn( dynamic_cast<BibTeX::MacroKey*>( m_value->items.first() ) != NULL );
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ if ( QString::compare( m_lineEdit->text(), item->text() ) != 0 )
+ m_lineEdit->setText( item->text() );
+ break;
+ case itMultiLine:
+ if ( QString::compare( m_textEdit->text(), item->text() ) != 0 )
+ m_textEdit->setText( item->text() );
+ break;
+ }
+ }
+ else
+ {
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ m_lineEdit->setText( isComplex ? i18n( "Concatenated value" ) : "" );
+ break;
+ case itMultiLine:
+ m_textEdit->setText( isComplex ? i18n( "Concatenated value" ) : "" );
+ break;
+ }
+ }
+
+ m_pushButtonComplex->setEnabled( m_enabled );
+
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ m_lineEdit->setEnabled( inputEnable );
+ m_lineEdit->setReadOnly( m_isReadOnly );
+ break;
+ case itMultiLine:
+ m_textEdit->setEnabled( inputEnable );
+ m_textEdit->setReadOnly( m_isReadOnly );
+ break;
+ }
+
+ enableSignals( TRUE );
+ }
+
+ void FieldLineEdit::enableSignals( bool enabled )
+ {
+ switch ( m_inputType )
+ {
+ case itSingleLine:
+ if ( enabled )
+ connect( m_lineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotTextChanged( ) ) );
+ else
+ disconnect( m_lineEdit, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotTextChanged( ) ) );
+ break;
+ case itMultiLine:
+ if ( enabled )
+ connect( m_textEdit, SIGNAL( textChanged( ) ), this, SLOT( slotTextChanged( ) ) );
+ else
+ disconnect( m_textEdit, SIGNAL( textChanged( ) ), this, SLOT( slotTextChanged( ) ) );
+ break;
+ }
+ }
+}
+#include "fieldlineedit.moc"
diff --git a/src/fieldlineedit.h b/src/fieldlineedit.h
new file mode 100644
index 0000000..e17dde1
--- /dev/null
+++ b/src/fieldlineedit.h
@@ -0,0 +1,106 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXFIELDLINEEDIT_H
+#define KBIBTEXFIELDLINEEDIT_H
+
+#include <qwidget.h>
+
+#include <entryfield.h>
+#include <value.h>
+
+class KLineEdit;
+class QTextEdit;
+class QPushButton;
+class KCompletion;
+
+namespace KBibTeX
+{
+ class FieldLineEdit : public QWidget
+ {
+ Q_OBJECT
+ public:
+ enum InputType {itSingleLine, itMultiLine};
+ enum ErrorType {etNoError, etInvalidStringKey};
+
+ FieldLineEdit( const QString& caption, InputType inputType = itSingleLine, bool readOnly = FALSE, QWidget *parent = 0, const char *name = 0 );
+ ~FieldLineEdit();
+
+ /**
+ * Set the widget to use this value. The widget will make
+ * a deep copy internally and not modify the parameter.
+ * If NULL is passed to this function, the widget will be
+ * initialized with an empty BibTeXValue internally.
+ */
+ void setValue( const BibTeX::Value *value );
+
+ /**
+ * Return the BibTeXValue of this widget. The returned
+ * variable is a deep copy of the widget's internal state.
+ * The returned variable must be delete later by the
+ * function caller.
+ * The function will return NULL if no data is set by the
+ * user for this widget.
+ */
+ BibTeX::Value *value();
+
+ void setEnabled( bool enabled );
+
+ void setFieldType( BibTeX::EntryField::FieldType fieldType );
+
+ QString caption();
+
+ bool isEmpty();
+
+ bool isModified();
+
+ ErrorType error();
+
+ signals:
+ void textChanged( );
+
+ protected slots:
+ void updateGUI();
+
+ private slots:
+ void slotTextChanged();
+ void slotStringToggled();
+ void slotComplexClicked();
+
+ private:
+ BibTeX::Value *m_value;
+ QString m_caption;
+ KLineEdit *m_lineEdit;
+ QTextEdit *m_textEdit;
+ QPushButton *m_pushButtonString;
+ QPushButton *m_pushButtonComplex;
+ bool m_isReadOnly;
+ bool m_enabled;
+ InputType m_inputType;
+ bool m_isModified;
+ BibTeX::EntryField::FieldType m_fieldType;
+ KCompletion *m_completion;
+
+ void setupGUI( const char *name );
+ void enableSignals( bool enabled );
+ };
+
+}
+
+#endif
diff --git a/src/fieldlistview.cpp b/src/fieldlistview.cpp
new file mode 100644
index 0000000..62ba8a6
--- /dev/null
+++ b/src/fieldlistview.cpp
@@ -0,0 +1,455 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qstring.h>
+#include <qregexp.h>
+#include <qlayout.h>
+#include <qheader.h>
+#include <qtimer.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+
+#include <klistview.h>
+#include <klineedit.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kiconloader.h>
+
+#include <value.h>
+#include <valuewidget.h>
+#include <settings.h>
+#include "fieldlistview.h"
+
+namespace KBibTeX
+{
+
+ FieldListView::FieldListView( const QString& caption, const QString& prefixNew, bool isReadOnly, QWidget *parent, const char *name )
+ : QWidget( parent, name ), m_value( new BibTeX::Value() ), m_caption( caption ), m_prefixNew( prefixNew ), m_isReadOnly( isReadOnly ), m_enabled( TRUE ), m_isComplex( FALSE ), m_isModified( FALSE ), m_newValueCounter( 0 ), m_fieldType( BibTeX::EntryField::ftUnknown )
+ {
+ setupGUI();
+ m_listViewElements->installEventFilter( this );
+ m_listViewElements->renameLineEdit() ->installEventFilter( this );
+
+ m_value = new BibTeX::Value();
+ }
+
+
+ FieldListView::~FieldListView()
+ {
+ delete m_value;
+ }
+
+ void FieldListView::setValue( const BibTeX::Value *value )
+ {
+ if ( value != m_value )
+ {
+ if ( m_value != NULL )
+ delete m_value;
+
+ if ( value != NULL )
+ m_value = new BibTeX::Value( value );
+ else
+ m_value = new BibTeX::Value( );
+
+ reset();
+ updateGUI();
+
+ m_isModified = FALSE;
+ }
+ }
+
+ BibTeX::Value *FieldListView::value()
+ {
+ if ( m_value->items.isEmpty() )
+ return NULL;
+ else
+ return new BibTeX::Value( m_value );
+ }
+
+ void FieldListView::setEnabled( bool enabled )
+ {
+ m_enabled = enabled;
+ updateGUI();
+ }
+
+ void FieldListView::setFieldType( BibTeX::EntryField::FieldType fieldType )
+ {
+ m_fieldType = fieldType;
+
+ Settings * settings = Settings::self();
+ m_listViewElements->renameLineEdit() ->setCompletionObject( settings->completion( m_fieldType ) );
+ QToolTip::add( m_listViewElements, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+ QWhatsThis::add( m_listViewElements, QString( i18n( "BibTeX field '%1'" ) ).arg( BibTeX::EntryField::fieldTypeToString( fieldType ) ) );
+
+ m_value->items.clear();
+ }
+
+ QString FieldListView::caption()
+ {
+ return m_caption;
+ }
+
+ bool FieldListView::isEmpty()
+ {
+ return m_value != NULL ? m_value->items.isEmpty() : TRUE;
+ }
+
+ bool FieldListView::isModified()
+ {
+ return m_isModified;
+ }
+
+ bool FieldListView::eventFilter( QObject *o, QEvent * e )
+ {
+ if ( o == m_listViewElements->renameLineEdit() )
+ {
+ if ( e->type() == QEvent::Hide )
+ itemRenameDone();
+ }
+ else if ( e->type() == QEvent::AccelOverride )
+ {
+ QKeyEvent * ke = static_cast<QKeyEvent*>( e );
+ //override delete action
+ if ( ke->key() == Key_Delete && ke->state() == NoButton )
+ {
+ slotDelete();
+ ke->accept();
+ return true;
+ }
+ else if ( ke->key() == Key_F2 && ke->state() == NoButton )
+ {
+ slotEdit();
+ ke->accept();
+ return true;
+ }
+ else if ( ke->key() == Key_A && ke->state() == ControlButton )
+ {
+ slotAdd();
+ ke->accept();
+ return true;
+ }
+ else if ( ke->key() == Key_Up && ke->state() == ControlButton )
+ {
+ slotUp();
+ ke->accept();
+ return true;
+ }
+ else if ( ke->key() == Key_Down && ke->state() == ControlButton )
+ {
+ slotDown();
+ ke->accept();
+ return true;
+ }
+ else if ( ke->key() == Key_C && ke->state() == ( ControlButton | AltButton ) )
+ {
+ slotComplex();
+ ke->accept();
+ return true;
+ }
+ }
+ return false;
+ }
+
+
+ void FieldListView::updateGUI()
+ {
+ disconnect( m_checkBoxEtAl, SIGNAL( toggled( bool ) ), this, SLOT( apply() ) );
+ if ( m_value != NULL && !m_isComplex )
+ {
+ bool isElementSelected = m_listViewElements->selectedItem() != NULL;
+ m_pushButtonAdd->setEnabled( !m_isReadOnly );
+ m_pushButtonEdit->setEnabled( !m_isReadOnly && isElementSelected );
+ m_pushButtonDelete->setEnabled( !m_isReadOnly && isElementSelected );
+ m_pushButtonUp->setEnabled( !m_isReadOnly && isElementSelected && m_listViewElements->selectedItem() != m_listViewElements->firstChild() );
+ m_pushButtonDown->setEnabled( !m_isReadOnly && isElementSelected && m_listViewElements->selectedItem() != m_listViewElements->lastItem() );
+ m_listViewElements->setEnabled( !m_isReadOnly );
+ m_checkBoxEtAl->setEnabled( !m_isReadOnly );
+ }
+ else
+ {
+ m_pushButtonAdd->setEnabled( FALSE );
+ m_pushButtonEdit->setEnabled( FALSE );
+ m_pushButtonDelete->setEnabled( FALSE );
+ m_pushButtonUp->setEnabled( FALSE );
+ m_pushButtonDown->setEnabled( FALSE );
+ m_listViewElements->setEnabled( FALSE );
+ m_checkBoxEtAl->setEnabled( FALSE );
+ }
+ connect( m_checkBoxEtAl, SIGNAL( toggled( bool ) ), this, SLOT( apply() ) );
+ }
+
+ void FieldListView::slotAdd()
+ {
+ if ( isSimple() )
+ {
+ KListViewItem * item = new KListViewItem( m_listViewElements, m_listViewElements->lastItem(), QString( "%1%2" ).arg( m_prefixNew ).arg( ++m_newValueCounter ) );
+ m_listViewElements->setSelected( item, TRUE );
+ updateGUI();
+ QTimer::singleShot( 100, this, SLOT( slotEdit() ) );
+ }
+ }
+
+ void FieldListView::slotEdit()
+ {
+ if ( isSimple() )
+ {
+ KListViewItem * item = static_cast<KListViewItem*>( m_listViewElements->selectedItem() );
+ if ( item != NULL )
+ m_listViewElements->rename( item, 0 );
+ }
+ }
+
+ void FieldListView::slotDelete()
+ {
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( isSimple() && item != NULL )
+ {
+ delete item;
+ apply();
+ updateGUI();
+
+ m_isModified = TRUE;
+ }
+ }
+
+ void FieldListView::slotUp()
+ {
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( isSimple() && !m_listViewElements->isRenaming() && item != NULL && item -> itemAbove() != NULL )
+ {
+ item->itemAbove() ->moveItem( item );
+ apply();
+ updateGUI();
+
+ m_isModified = TRUE;
+ }
+ }
+
+ void FieldListView::slotDown()
+ {
+ QListViewItem * item = m_listViewElements->selectedItem();
+ if ( isSimple() && !m_listViewElements->isRenaming() && item != NULL && item -> itemBelow() != NULL )
+ {
+ item->moveItem( item->itemBelow() );
+ apply();
+ updateGUI();
+
+ m_isModified = TRUE;
+ }
+ }
+
+ void FieldListView::slotComplex()
+ {
+ if ( !m_listViewElements->isRenaming() && ValueWidget::execute( m_caption, m_fieldType, m_value, m_isReadOnly, this ) == QDialog::Accepted )
+ {
+ reset();
+ updateGUI();
+
+ m_isModified = TRUE;
+ }
+ }
+
+ void FieldListView::slotListViewDoubleClicked( QListViewItem * lvi )
+ {
+ if ( lvi == NULL )
+ slotAdd();
+ }
+
+ void FieldListView::slotItemRenamed( QListViewItem * item, int /*col*/, const QString & text )
+ {
+ if ( text.isEmpty() && isSimple() && item != NULL )
+ {
+ delete item;
+ updateGUI();
+ }
+
+ apply();
+ m_isModified = TRUE;
+ }
+
+ void FieldListView::setupGUI()
+ {
+ Settings * settings = Settings::self();
+
+ QGridLayout * layout = new QGridLayout( this, 8, 2, 0, KDialog::spacingHint() );
+ layout->setRowStretch( 5, 1 );
+
+ m_listViewElements = new KListView( this );
+ layout->addMultiCellWidget( m_listViewElements, 0, 6, 0, 0 );
+ m_listViewElements->renameLineEdit() ->setCompletionObject( settings->completion( m_fieldType ) );
+ m_listViewElements->renameLineEdit() ->setCompletionMode( KGlobalSettings::CompletionPopup );
+ m_listViewElements->renameLineEdit() ->completionObject() ->setIgnoreCase( true );
+ m_listViewElements->setDefaultRenameAction( QListView::Accept );
+ m_listViewElements->addColumn( m_caption );
+ m_listViewElements->setSorting( -1, TRUE );
+ m_listViewElements->setItemsRenameable( TRUE );
+ if ( settings->editing_UseSpecialFont )
+ m_listViewElements->setFont( settings->editing_SpecialFont );
+ m_listViewElements->header() ->setFont( KGlobalSettings::generalFont() );
+
+ m_listViewElements->header() ->setClickEnabled( FALSE );
+ m_listViewElements->header() ->setStretchEnabled( TRUE, 0 );
+ connect( m_listViewElements, SIGNAL( selectionChanged() ), this, SLOT( updateGUI() ) );
+ connect( m_listViewElements, SIGNAL( clicked( QListViewItem * ) ), this, SLOT( updateGUI() ) );
+ connect( m_listViewElements, SIGNAL( doubleClicked( QListViewItem * ) ), this, SLOT( slotListViewDoubleClicked( QListViewItem * ) ) );
+ connect( m_listViewElements, SIGNAL( currentChanged( QListViewItem * ) ), this, SLOT( updateGUI() ) );
+ connect( m_listViewElements, SIGNAL( itemRenamed( QListViewItem*, int, const QString& ) ), this, SLOT( slotItemRenamed( QListViewItem*, int, const QString& ) ) );
+
+ m_pushButtonAdd = new QPushButton( i18n( "Add" ), this );
+ layout->addWidget( m_pushButtonAdd, 0, 1 );
+ m_pushButtonAdd->setIconSet( QIconSet( SmallIcon( "add" ) ) );
+ connect( m_pushButtonAdd, SIGNAL( clicked() ), this, SLOT( slotAdd() ) );
+ QToolTip::add( m_pushButtonAdd, QString( i18n( "Add new '%1' item (Ctrl+A)" ) ).arg( m_caption ) );
+
+ m_pushButtonEdit = new QPushButton( i18n( "Edit" ), this );
+ layout->addWidget( m_pushButtonEdit, 1, 1 );
+ m_pushButtonEdit->setIconSet( QIconSet( SmallIcon( "edit" ) ) );
+ connect( m_pushButtonEdit, SIGNAL( clicked() ), this, SLOT( slotEdit() ) );
+ QToolTip::add( m_pushButtonEdit, QString( i18n( "Edit current '%1' item (F2)" ) ).arg( m_caption ) );
+
+ m_pushButtonDelete = new QPushButton( i18n( "Delete" ), this );
+ layout->addWidget( m_pushButtonDelete, 2, 1 );
+ m_pushButtonDelete->setIconSet( QIconSet( SmallIcon( "editdelete" ) ) );
+ connect( m_pushButtonDelete, SIGNAL( clicked() ), this, SLOT( slotDelete() ) );
+ QToolTip::add( m_pushButtonDelete, QString( i18n( "Delete current '%1' item (Del)" ) ).arg( m_caption ) );
+
+ m_pushButtonUp = new QPushButton( i18n( "Up" ), this );
+ layout->addWidget( m_pushButtonUp, 3, 1 );
+ m_pushButtonUp->setIconSet( QIconSet( SmallIcon( "up" ) ) );
+ connect( m_pushButtonUp, SIGNAL( clicked() ), this, SLOT( slotUp() ) );
+ QToolTip::add( m_pushButtonUp, QString( i18n( "Move current '%1' item up (Ctrl+Up)" ) ).arg( m_caption ) );
+
+ m_pushButtonDown = new QPushButton( i18n( "Down" ), this );
+ layout->addWidget( m_pushButtonDown, 4, 1 );
+ m_pushButtonDown->setIconSet( QIconSet( SmallIcon( "down" ) ) );
+ connect( m_pushButtonDown, SIGNAL( clicked() ), this, SLOT( slotDown() ) );
+ QToolTip::add( m_pushButtonDown, QString( i18n( "Move current '%1' item down (Ctrl+Down)" ) ).arg( m_caption ) );
+
+ m_pushButtonComplexEdit = new QPushButton( i18n( "Complex..." ), this );
+ layout->addWidget( m_pushButtonComplexEdit, 6, 1 );
+ m_pushButtonComplexEdit->setIconSet( QIconSet( SmallIcon( "leftjust" ) ) );
+ connect( m_pushButtonComplexEdit, SIGNAL( clicked() ), this, SLOT( slotComplex() ) );
+ QToolTip::add( m_pushButtonComplexEdit, QString( i18n( "Edit current '%1' item as a concatenated string (Ctrl+Alt+C)" ) ).arg( m_caption ) );
+
+ m_checkBoxEtAl = new QCheckBox( i18n( "... and others (et al.)" ), this );
+ layout->addMultiCellWidget( m_checkBoxEtAl, 7, 7, 0, 1 );
+ connect( m_checkBoxEtAl, SIGNAL( toggled( bool ) ), this, SLOT( apply() ) );
+ }
+
+ void FieldListView::apply()
+ {
+ QStringList elements;
+ Settings * settings = Settings::self();
+
+ m_value->items.clear();
+
+ for ( QListViewItemIterator it( m_listViewElements ); it.current(); it++ )
+ {
+ QString text = it.current() ->text( 0 );
+ elements.append( text );
+ }
+
+ if ( elements.count() > 0 )
+ {
+ m_value->items.clear();
+ BibTeX::PersonContainer *container = new BibTeX::PersonContainer( settings->editing_FirstNameFirst );
+
+ switch ( m_fieldType )
+ {
+ case BibTeX::EntryField::ftAuthor:
+ case BibTeX::EntryField::ftEditor:
+ {
+ for ( QStringList::ConstIterator it = elements.constBegin(); it != elements.constEnd(); ++it )
+ {
+ BibTeX::Person *person = new BibTeX::Person( *it, settings->editing_FirstNameFirst );
+ container->persons.append( person );
+ }
+ }
+ break;
+ default:
+ kdDebug() << "Don't know how to handle entries of type " << BibTeX::EntryField::fieldTypeToString( m_fieldType ) << endl;
+ }
+
+ if ( m_checkBoxEtAl->isChecked() )
+ container->persons.append( new BibTeX::Person( "others", settings->editing_FirstNameFirst ) );
+
+ if ( !container->persons.isEmpty() )
+ m_value->items.append( container );
+ else
+ delete container;
+
+ settings->addToCompletion( m_value, m_fieldType );
+ }
+ }
+
+ void FieldListView::reset()
+ {
+ disconnect( m_checkBoxEtAl, SIGNAL( toggled( bool ) ), this, SLOT( apply() ) );
+ m_listViewElements->clear();
+ m_checkBoxEtAl->setChecked( FALSE );
+
+ m_isComplex = FALSE;
+ for ( QValueList<BibTeX::ValueItem*>::ConstIterator it = m_value->items.constBegin(); !m_isComplex && it != m_value->items.constEnd(); ++it )
+ {
+ BibTeX::MacroKey *macroKey = dynamic_cast<BibTeX::MacroKey *>( *it );
+ m_isComplex = macroKey != NULL;
+ }
+
+ if ( !m_isComplex )
+ switch ( m_fieldType )
+ {
+ case BibTeX::EntryField::ftAuthor:
+ case BibTeX::EntryField::ftEditor:
+ {
+ for ( QValueList<BibTeX::ValueItem*>::ConstIterator it = m_value->items.constBegin(); it != m_value->items.constEnd(); ++it )
+ {
+ BibTeX::PersonContainer *container = dynamic_cast<BibTeX::PersonContainer *>( *it );
+ if ( container != NULL )
+ for ( QValueList<BibTeX::Person*>::ConstIterator pit = container->persons.constBegin(); pit != container->persons.constEnd(); ++pit )
+ {
+ QString text = ( *pit )->text();
+ if ( text == "others" )
+ m_checkBoxEtAl->setChecked( TRUE );
+ else
+ new QListViewItem( m_listViewElements, m_listViewElements->lastItem(), text );
+ }
+ }
+ }
+ break;
+ default:
+ kdDebug() << "Don't know how to handle entries of type " << BibTeX::EntryField::fieldTypeToString( m_fieldType ) << endl;
+ }
+
+ connect( m_checkBoxEtAl, SIGNAL( toggled( bool ) ), this, SLOT( apply() ) );
+ }
+
+ bool FieldListView::isSimple()
+ {
+ return m_value->items.count() == 0 || ( m_value->items.count() == 1 && dynamic_cast<BibTeX::MacroKey*>( m_value->items.first() ) == NULL );
+ }
+
+ void FieldListView::itemRenameDone()
+ {
+ apply();
+ }
+}
+#include "fieldlistview.moc"
diff --git a/src/fieldlistview.h b/src/fieldlistview.h
new file mode 100644
index 0000000..f8a3baa
--- /dev/null
+++ b/src/fieldlistview.h
@@ -0,0 +1,101 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef KBIBTEXFIELDLISTVIEW_H
+#define KBIBTEXFIELDLISTVIEW_H
+
+#include <qwidget.h>
+
+#include <value.h>
+#include <entryfield.h>
+
+class QString;
+class KListView;
+class QListViewItem;
+class QPushButton;
+class QCheckBox;
+
+namespace KBibTeX
+{
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class FieldListView : public QWidget
+ {
+ Q_OBJECT
+ public:
+ FieldListView( const QString& caption, const QString& prefixNew, bool isReadOnly, QWidget *parent = 0, const char *name = 0 );
+ ~FieldListView();
+
+ void setValue( const BibTeX::Value *value );
+ BibTeX::Value *value();
+
+ void setEnabled( bool enabled );
+
+ void setFieldType( BibTeX::EntryField::FieldType fieldType );
+
+ QString caption();
+
+ bool isEmpty();
+
+ bool isModified();
+
+ virtual bool eventFilter( QObject *o, QEvent * e );
+
+ private slots:
+ void updateGUI();
+ void slotAdd();
+ void slotEdit();
+ void slotDelete();
+ void slotUp();
+ void slotDown();
+ void slotComplex();
+ void slotListViewDoubleClicked( QListViewItem * );
+ void slotItemRenamed( QListViewItem * item, int col, const QString & text );
+ void apply();
+
+ private:
+ BibTeX::Value *m_value;
+ QString m_caption;
+ QString m_prefixNew;
+ bool m_isReadOnly;
+ bool m_enabled;
+ bool m_isComplex;
+ bool m_isModified;
+ int m_newValueCounter;
+ BibTeX::EntryField::FieldType m_fieldType;
+ KListView *m_listViewElements;
+ QPushButton *m_pushButtonAdd;
+ QPushButton *m_pushButtonEdit;
+ QPushButton *m_pushButtonDelete;
+ QPushButton *m_pushButtonUp;
+ QPushButton *m_pushButtonDown;
+ QPushButton *m_pushButtonComplexEdit;
+ QCheckBox *m_checkBoxEtAl;
+
+ void setupGUI();
+ void reset();
+ void itemRenameDone();
+ bool isSimple();
+ };
+
+}
+
+#endif
diff --git a/src/file.cpp b/src/file.cpp
new file mode 100644
index 0000000..8b6106e
--- /dev/null
+++ b/src/file.cpp
@@ -0,0 +1,402 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qiodevice.h>
+#include <qstringlist.h>
+#include <qregexp.h>
+
+#include <settings.h>
+#include <file.h>
+#include <entry.h>
+#include <element.h>
+#include <macro.h>
+#include <comment.h>
+#include <fileexporter.h>
+
+namespace BibTeX
+{
+
+ File::File( ) : QObject( ), fileName( QString::null )
+ {
+ // nothing
+ }
+
+ File::~File()
+ {
+ for ( ElementList::iterator it = elements.begin(); it != elements.end(); it++ )
+ delete * it;
+ }
+
+ unsigned int File::count() const
+ {
+ return elements.count();
+ }
+
+ Element* File::at( const unsigned int index )
+ {
+ return *( elements.at( index ) );
+ }
+
+ void File::append( const File *other, const Element *after )
+ {
+ for ( ElementList::ConstIterator it = other->constBegin(); it != other->constEnd(); it++ )
+ appendElement( cloneElement( *it ), after );
+ }
+
+ void File::appendElement( Element *element, const Element *after )
+ {
+ if ( after == NULL )
+ elements.append( element );
+ else
+ {
+ for ( ElementList::iterator it = elements.begin() ; it != elements.end(); it++ )
+ if (( *it ) == after )
+ {
+ elements.insert( ++it, element );
+ break;
+ }
+ }
+ }
+
+ void File::deleteElement( Element *element )
+ {
+ bool found = false;
+ for ( ElementList::iterator it = elements.begin(); it != elements.end(); it++ )
+ if ( ( found = ( *it == element ) ) )
+ {
+ elements.remove( it );
+ delete element;
+ break;
+ }
+
+ if ( !found )
+ qDebug( "BibTeX::File got told to delete an element which is not in this file." );
+ }
+
+ Element* File::cloneElement( Element *element )
+ {
+ Entry * entry = dynamic_cast<Entry*>( element );
+ if ( entry )
+ return new Entry( entry );
+ else
+ {
+ Macro *macro = dynamic_cast<Macro*>( element );
+ if ( macro )
+ return new Macro( macro );
+ else
+ {
+ Comment *comment = dynamic_cast<Comment*>( element );
+ if ( comment )
+ return new Comment( comment );
+ else
+ return NULL;
+ }
+ }
+ }
+
+ Element *File::containsKey( const QString &key )
+ {
+ for ( ElementList::iterator it = elements.begin(); it != elements.end(); it++ )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *it );
+ if ( entry != NULL )
+ {
+ if ( entry->id() == key )
+ return entry;
+ }
+ else
+ {
+ Macro* macro = dynamic_cast<Macro*>( *it );
+ if ( macro != NULL )
+ {
+ if ( macro->key() == key )
+ return macro;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ const Element *File::containsKeyConst( const QString &key ) const
+ {
+ for ( ElementList::const_iterator it = elements.begin(); it != elements.end(); it++ )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *it );
+ if ( entry != NULL )
+ {
+ if ( entry->id() == key )
+ return entry;
+ }
+ else
+ {
+ Macro* macro = dynamic_cast<Macro*>( *it );
+ if ( macro != NULL )
+ {
+ if ( macro->key() == key )
+ return macro;
+ }
+ }
+ }
+
+ return NULL;
+ }
+
+ QStringList File::allKeys()
+ {
+ QStringList result;
+
+ for ( ElementList::iterator it = elements.begin(); it != elements.end(); it++ )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *it );
+ if ( entry != NULL )
+ result.append( entry->id() );
+ else
+ {
+ Macro* macro = dynamic_cast<Macro*>( *it );
+ if ( macro != NULL )
+ result.append( macro->key() );
+ }
+ }
+
+ return result;
+ }
+
+ QString File::text()
+ {
+ QString result;
+
+ for ( ElementList::iterator it = elements.begin(); it != elements.end(); it++ )
+ {
+ result.append(( *it )->text() );
+ result.append( "\n" );
+ }
+
+ return result;
+ }
+
+ File::ElementList::iterator File::begin()
+ {
+ return elements.begin();
+ }
+
+ File::ElementList::iterator File::end()
+ {
+ return elements.end();
+ }
+
+ File::ElementList::ConstIterator File::constBegin() const
+ {
+ return elements.constBegin();
+ }
+
+ File::ElementList::ConstIterator File::constEnd() const
+ {
+ return elements.constEnd();
+ }
+
+ QStringList File::getAllValuesAsStringList( const EntryField::FieldType fieldType ) const
+ {
+ QStringList result;
+ for ( ElementList::ConstIterator eit = elements.constBegin(); eit != elements.constEnd(); ++eit )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *eit );
+ EntryField * field = NULL;
+ if ( entry != NULL && ( field = entry->getField( fieldType ) ) != NULL )
+ {
+ QValueList<ValueItem*> valueItems = field->value()->items;
+ for ( QValueList<ValueItem*>::ConstIterator vit = valueItems.begin(); vit != valueItems.end(); ++vit )
+ {
+ switch ( fieldType )
+ {
+ case EntryField::ftKeywords :
+ {
+ KeywordContainer *container = dynamic_cast<KeywordContainer*>( *vit );
+ if ( container != NULL )
+ for ( QValueList<Keyword*>::ConstIterator kit = container->keywords.constBegin(); kit != container->keywords.constEnd(); ++kit )
+ {
+ QString text = ( *kit )->text();
+ if ( !result.contains( text ) )
+ result.append( text );
+ }
+ }
+ break;
+ case EntryField::ftEditor :
+ case EntryField::ftAuthor :
+ {
+ PersonContainer *container = dynamic_cast<PersonContainer*>( *vit );
+ if ( container != NULL )
+ for ( QValueList<Person*>::ConstIterator pit = container->persons.constBegin(); pit != container->persons.constEnd(); ++pit )
+ {
+ QString text = ( *pit )->text();
+ if ( !result.contains( text ) )
+ result.append( text );
+ }
+ }
+ break;
+ default:
+ {
+ QString text = ( *vit )->text();
+ if ( !result.contains( text ) )
+ result.append( text );
+ }
+ }
+ }
+ }
+ }
+
+ result.sort();
+ return result;
+ }
+
+ QMap<QString, int> File::getAllValuesAsStringListWithCount( const EntryField::FieldType fieldType ) const
+ {
+ QMap<QString, int> result;
+ for ( ElementList::ConstIterator eit = elements.begin(); eit != elements.end(); ++eit )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *eit );
+ EntryField * field = NULL;
+ if ( entry != NULL && ( field = entry->getField( fieldType ) ) != NULL )
+ {
+ QValueList<ValueItem*> valueItems = field->value()->items;
+ for ( QValueList<ValueItem*>::ConstIterator vit = valueItems.begin(); vit != valueItems.end(); ++vit )
+ {
+ switch ( fieldType )
+ {
+ case EntryField::ftKeywords :
+ {
+ KeywordContainer *container = dynamic_cast<KeywordContainer*>( *vit );
+ if ( container != NULL )
+ for ( QValueList<Keyword*>::ConstIterator kit = container->keywords.constBegin(); kit != container->keywords.constEnd(); ++kit )
+ {
+ QString text = ( *kit )->text();
+ if ( !result.contains( text ) )
+ result[text] = 1;
+ else
+ result[text] += 1;
+ }
+ }
+ break;
+ case EntryField::ftEditor :
+ case EntryField::ftAuthor :
+ {
+ PersonContainer *container = dynamic_cast<PersonContainer*>( *vit );
+ if ( container != NULL )
+ for ( QValueList<Person*>::ConstIterator pit = container->persons.constBegin(); pit != container->persons.constEnd(); ++pit )
+ {
+ QString text = ( *pit )->text();
+ if ( !result.contains( text ) )
+ result[text] = 1;
+ else
+ result[text] += 1;
+ }
+ }
+ break;
+ default:
+ {
+ QString text = ( *vit )->text();
+ if ( !result.contains( text ) )
+ result[text] = 1;
+ else
+ result[text] += 1;
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ void File::replaceValue( const QString& oldText, const QString& newText, const EntryField::FieldType fieldType )
+ {
+ qDebug( "Renaming all occurrences of '%s' to '%s' for fields of type '%s'", oldText.latin1(), newText.latin1(), EntryField::fieldTypeToString( fieldType ).latin1() );
+
+ for ( ElementList::ConstIterator it = elements.begin(); it != elements.end(); it++ )
+ {
+ Entry* entry = dynamic_cast<Entry*>( *it );
+ if ( entry != NULL )
+ {
+ if ( fieldType != EntryField::ftUnknown )
+ {
+ EntryField * field = entry->getField( fieldType );
+ if ( field != NULL )
+ field->value() ->replace( oldText, newText );
+ }
+ }
+ }
+ }
+
+ BibTeX::Entry *File::completeReferencedFieldsConst( const BibTeX::Entry *entry ) const
+ {
+ BibTeX::Entry *myEntry = new BibTeX::Entry( entry );
+ completeReferencedFields( myEntry );
+ return myEntry;
+ }
+
+ void File::completeReferencedFields( BibTeX::Entry *entry ) const
+ {
+ BibTeX::EntryField *crossRefField = entry->getField( BibTeX::EntryField::ftCrossRef );
+ const BibTeX::Entry *parent = NULL;
+ if ( crossRefField != NULL && ( parent = dynamic_cast<const BibTeX::Entry*>( containsKeyConst( crossRefField->value()->text() ) ) ) != NULL )
+ {
+ for ( int ef = ( int )BibTeX::EntryField::ftAbstract; ef <= ( int )BibTeX::EntryField::ftYear; ++ef )
+ {
+ BibTeX::EntryField *entryField = entry->getField(( BibTeX::EntryField::FieldType ) ef );
+ if ( entryField == NULL )
+ {
+ BibTeX::EntryField *parentEntryField = parent->getField(( BibTeX::EntryField::FieldType ) ef );
+ if ( parentEntryField != NULL )
+ {
+ entryField = new BibTeX::EntryField(( BibTeX::EntryField::FieldType )ef );
+ entryField->setValue( parentEntryField->value() );
+ entry->addField( entryField );
+ }
+ }
+ }
+
+ BibTeX::EntryField *entryField = entry->getField( EntryField::ftBookTitle );
+ BibTeX::EntryField *parentEntryField = parent->getField( EntryField::ftTitle );
+ if (( entry->entryType() == Entry::etInProceedings || entry->entryType() == Entry::etInBook ) && entryField == NULL && parentEntryField != NULL )
+ {
+ entryField = new BibTeX::EntryField( EntryField::ftBookTitle );
+ entryField->setValue( parentEntryField->value() );
+ entry->addField( entryField );
+ }
+ }
+
+ for ( int ef = ( int )BibTeX::EntryField::ftAbstract; ef <= ( int )BibTeX::EntryField::ftYear; ++ef )
+ {
+ BibTeX::EntryField *entryField = entry->getField(( BibTeX::EntryField::FieldType ) ef );
+ if ( entryField != NULL && entryField->value() != NULL && !entryField->value()->items.isEmpty() )
+ {
+ MacroKey *macroKey = dynamic_cast<MacroKey*>( entryField->value()->items.first() );
+ const Macro *macro = NULL;
+ if ( macroKey != NULL && ( macro = dynamic_cast<const Macro*>( containsKeyConst( macroKey->text() ) ) ) != NULL )
+ entryField->setValue( macro->value() );
+ }
+ }
+ }
+
+}
+
+#include "file.moc"
+
diff --git a/src/file.h b/src/file.h
new file mode 100644
index 0000000..fcb797a
--- /dev/null
+++ b/src/file.h
@@ -0,0 +1,108 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXFILE_H
+#define BIBTEXFILE_H
+
+#include <qobject.h>
+#include <qvaluelist.h>
+
+#include <entryfield.h>
+
+class QDir;
+class QString;
+class QChar;
+class QStringList;
+class QWaitCondition;
+class QProcess;
+class QIODevice;
+
+namespace BibTeX
+{
+ class Element;
+ class Entry;
+ class String;
+ class FileExporter;
+
+ static const QString Months[] =
+ {
+ QString( "January" ), QString( "February" ), QString( "March" ), QString( "April" ), QString( "May" ), QString( "June" ), QString( "July" ), QString( "August" ), QString( "September" ), QString( "October" ), QString( "November" ), QString( "December" )
+ };
+
+ static const QString MonthsTriple[] =
+ {
+ QString( "jan" ), QString( "feb" ), QString( "mar" ), QString( "apr" ), QString( "may" ), QString( "jun" ), QString( "jul" ), QString( "aug" ), QString( "sep" ), QString( "oct" ), QString( "nov" ), QString( "dec" )
+ };
+
+ class File : public QObject
+ {
+ Q_OBJECT
+
+ friend class FileExporterXML;
+ friend class FileExporterBibTeX;
+ friend class FileExporterRIS;
+ friend class FileExporter;
+ friend class FileParser;
+
+ public:
+ typedef QValueList<Element*> ElementList;
+
+ enum FileFormat { formatUndefined = 0, formatBibTeX = 1, formatXML = 2, formatHTML = 3, formatPDF = 4, formatPS = 5, formatRTF = 6, formatRIS = 7, formatEndNote = 8, formatISI = 9, formatDocBook5 = 10, formatMODS = 11, formatWordBib = 12, formatAds = 13, formatEndNoteXML = 14 };
+ enum Encoding {encImplicit = 0, encLaTeX = 1, encUTF8 = 2};
+ enum StringProtection { spNone, spParanthesis, spQuote, spBoth };
+
+ File( );
+ ~File();
+
+ unsigned int count() const;
+ Element* at( const unsigned int index );
+ void append( const File *other, const Element *after = NULL );
+ void appendElement( Element *element, const Element *after = NULL );
+ void deleteElement( Element *element );
+ static Element* cloneElement( Element *element );
+
+ Element *containsKey( const QString &key );
+ const Element *containsKeyConst( const QString &key ) const;
+ QStringList allKeys();
+ QString text();
+
+ ElementList::iterator begin();
+ ElementList::iterator end();
+ ElementList::const_iterator constBegin() const;
+ ElementList::const_iterator constEnd() const;
+
+ QStringList getAllValuesAsStringList( const EntryField::FieldType fieldType ) const;
+ QMap<QString, int> getAllValuesAsStringListWithCount( const EntryField::FieldType fieldType ) const;
+ void replaceValue( const QString& oldText, const QString& newText, const EntryField::FieldType fieldType );
+ BibTeX::Entry *completeReferencedFieldsConst( const BibTeX::Entry *entry ) const;
+ void completeReferencedFields( BibTeX::Entry *entry ) const;
+
+ QString fileName;
+
+ protected:
+ ElementList elements;
+
+ private:
+ void clearElements();
+
+ };
+
+}
+
+#endif
diff --git a/src/fileexporter.cpp b/src/fileexporter.cpp
new file mode 100644
index 0000000..b5fe73b
--- /dev/null
+++ b/src/fileexporter.cpp
@@ -0,0 +1,36 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include "fileexporter.h"
+
+namespace BibTeX
+{
+
+ FileExporter::FileExporter() : QObject()
+ {
+ // nothing
+ }
+
+ FileExporter::~FileExporter()
+ {
+ // nothing
+ }
+
+}
+#include "fileexporter.moc"
diff --git a/src/fileexporter.h b/src/fileexporter.h
new file mode 100644
index 0000000..cc60ac0
--- /dev/null
+++ b/src/fileexporter.h
@@ -0,0 +1,63 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXFILEEXPORTER_H
+#define BIBTEXFILEEXPORTER_H
+
+#include <qobject.h>
+#include <qmutex.h>
+
+#include <file.h>
+
+class QIODevice;
+
+namespace BibTeX
+{
+ class File;
+ class Element;
+
+ /**
+ @author Thomas Fischer
+ */
+ class FileExporter : public QObject
+ {
+ Q_OBJECT
+ public:
+ FileExporter();
+ ~FileExporter();
+
+ virtual bool save( QIODevice *iodevice, const File *bibtexfile, QStringList *errorLog = NULL ) = 0;
+ virtual bool save( QIODevice *iodevice, const Element* element, QStringList *errorLog = NULL ) = 0;
+
+ signals:
+ void progress( int current, int total );
+
+ public slots:
+ virtual void cancel()
+ {
+ // nothing
+ };
+
+ protected:
+ QMutex m_mutex;
+ };
+
+}
+
+#endif
diff --git a/src/fileexporterbibtex.cpp b/src/fileexporterbibtex.cpp
new file mode 100644
index 0000000..240754d
--- /dev/null
+++ b/src/fileexporterbibtex.cpp
@@ -0,0 +1,491 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <file.h>
+#include <element.h>
+#include <entry.h>
+#include <macro.h>
+#include <preamble.h>
+#include <value.h>
+#include <comment.h>
+#include <encoderlatex.h>
+
+#include "fileexporterbibtex.h"
+
+namespace BibTeX
+{
+
+ FileExporterBibTeX::FileExporterBibTeX() : FileExporter(),
+ m_iconvBufferSize( 16384 ), m_stringOpenDelimiter( '"' ), m_stringCloseDelimiter( '"' ), m_keywordCasing( kcCamelCase ), m_encoding( "latex" ), m_protectCasing( FALSE ), cancelFlag( FALSE )
+ {
+ m_iconvBuffer = new char[m_iconvBufferSize];
+ }
+
+ FileExporterBibTeX::~FileExporterBibTeX()
+ {
+ delete[] m_iconvBuffer;
+ }
+
+ bool FileExporterBibTeX::save( QIODevice* iodevice, const File* bibtexfile, QStringList * /*errorLog*/ )
+ {
+ m_mutex.lock();
+ bool result = TRUE;
+
+ /**
+ * Categorize elements from the bib file into four groups,
+ * to ensure that BibTeX finds all connected elements
+ * in the correct order.
+ */
+
+ QValueList<Comment*> parameterCommentsList;
+ QValueList<Preamble*> preambleList;
+ QValueList<Macro*> macroList;
+ QValueList<Entry*> crossRefingEntryList;
+ QValueList<Element*> remainingList;
+
+ for ( File::ElementList::const_iterator it = bibtexfile->elements.begin(); it != bibtexfile->elements.end() && result && !cancelFlag; it++ )
+ {
+ Preamble *preamble = dynamic_cast<Preamble*>( *it );
+ if ( preamble != NULL )
+ preambleList.append( preamble );
+ else
+ {
+ Macro *macro = dynamic_cast<Macro*>( *it );
+ if ( macro != NULL )
+ macroList.append( macro );
+ else
+ {
+ Entry *entry = dynamic_cast<Entry*>( *it );
+ if (( entry != NULL ) && ( entry->getField( EntryField::ftCrossRef ) != NULL ) )
+ crossRefingEntryList.append( entry );
+ else
+ {
+ Comment *comment = dynamic_cast<Comment*>( *it );
+ QString commentText = QString::null;
+ /** check if this file requests a special encoding */
+ if ( comment != NULL && comment->useCommand() && (( commentText = comment->text().lower() ) ).startsWith( "x-kbibtex-encoding=" ) )
+ {
+ m_encoding = commentText.mid( 19 );
+ qDebug( "Switching encoding to <%s>", m_encoding.latin1() );
+ parameterCommentsList.append( comment );
+ }
+ else
+ remainingList.append( *it );
+ }
+ }
+ }
+ }
+
+ int totalElements = ( int ) bibtexfile->count();
+ int currentPos = 0;
+
+ const char *encodingTo = m_encoding == "latex" ? "utf-8\0" : m_encoding.append( "\0" ).ascii();
+ m_iconvHandle = iconv_open( encodingTo, "utf-8" );
+
+ /** before anything else, write parameter comments */
+ for ( QValueList<Comment*>::iterator it = parameterCommentsList.begin(); it != parameterCommentsList.end() && result && !cancelFlag; it++ )
+ {
+ result &= writeComment( *iodevice, *it );
+ emit progress( ++currentPos, totalElements );
+ }
+
+ /** first, write preambles and strings (macros) at the beginning */
+ for ( QValueList<Preamble*>::iterator it = preambleList.begin(); it != preambleList.end() && result && !cancelFlag; it++ )
+ {
+ result &= writePreamble( *iodevice, *it );
+ emit progress( ++currentPos, totalElements );
+ }
+
+ for ( QValueList<Macro*>::iterator it = macroList.begin(); it != macroList.end() && result && !cancelFlag; it++ )
+ {
+ result &= writeMacro( *iodevice, *it );
+ emit progress( ++currentPos, totalElements );
+ }
+
+ /** second, write cross-referencing elements */
+ for ( QValueList<Entry*>::iterator it = crossRefingEntryList.begin(); it != crossRefingEntryList.end() && result && !cancelFlag; it++ )
+ {
+ result &= writeEntry( *iodevice, *it );
+ emit progress( ++currentPos, totalElements );
+ }
+
+ /** third, write remaining elements */
+ for ( QValueList<Element*>::iterator it = remainingList.begin(); it != remainingList.end() && result && !cancelFlag; it++ )
+ {
+ Entry *entry = dynamic_cast<Entry*>( *it );
+ if ( entry != NULL )
+ result &= writeEntry( *iodevice, entry );
+ else
+ {
+ Comment *comment = dynamic_cast<Comment*>( *it );
+ if ( comment != NULL )
+ result &= writeComment( *iodevice, comment );
+ }
+ emit progress( ++currentPos, totalElements );
+ }
+
+ iconv_close( m_iconvHandle );
+ m_mutex.unlock();
+ return result && !cancelFlag;
+ }
+
+ bool FileExporterBibTeX::save( QIODevice* iodevice, const Element* element, QStringList * /*errorLog*/ )
+ {
+ m_mutex.lock();
+ bool result = FALSE;
+
+ const char *encodingTo = m_encoding == "latex" ? "utf-8\0" : m_encoding.append( "\0" ).ascii();
+ m_iconvHandle = iconv_open( encodingTo, "utf-8" );
+
+ const Entry *entry = dynamic_cast<const Entry*>( element );
+ if ( entry != NULL )
+ result |= writeEntry( *iodevice, entry );
+ else
+ {
+ const Macro * macro = dynamic_cast<const Macro*>( element );
+ if ( macro != NULL )
+ result |= writeMacro( *iodevice, macro );
+ else
+ {
+ const Comment * comment = dynamic_cast<const Comment*>( element );
+ if ( comment != NULL )
+ result |= writeComment( *iodevice, comment );
+ else
+ {
+ const Preamble * preamble = dynamic_cast<const Preamble*>( element );
+ if ( preamble != NULL )
+ result |= writePreamble( *iodevice, preamble );
+ }
+ }
+ }
+
+ iconv_close( m_iconvHandle );
+ m_mutex.unlock();
+ return result && !cancelFlag;
+ }
+
+ void FileExporterBibTeX::cancel()
+ {
+ cancelFlag = TRUE;
+ }
+
+ bool FileExporterBibTeX::writeEntry( QIODevice &device, const Entry* entry )
+ {
+ writeString( device, QString( "@%1{ %2" ).arg( applyKeywordCasing( entry->entryTypeString() ) ).arg( entry->id() ) );
+
+ for ( Entry::EntryFields::ConstIterator it = entry->begin(); it != entry->end(); ++it )
+ {
+ EntryField *field = *it;
+ QString text = valueToString( field->value(), field->fieldType(), field->fieldTypeName() );
+ if ( m_protectCasing && dynamic_cast<BibTeX::PlainText*>( field->value()->items.first() ) != NULL && ( field->fieldType() == EntryField::ftTitle || field->fieldType() == EntryField::ftBookTitle || field->fieldType() == EntryField::ftSeries ) )
+ addProtectiveCasing( text );
+ writeString( device, QString( ",\n\t%1 = %2" ).arg( field->fieldTypeName() ).arg( text ) );
+ }
+ writeString( device, "\n}\n\n" );
+ return TRUE;
+ }
+
+ bool FileExporterBibTeX::writeMacro( QIODevice &device, const Macro *macro )
+ {
+ QString text = valueToString( macro->value() );
+ if ( m_protectCasing )
+ addProtectiveCasing( text );
+
+ writeString( device, QString( "@%1{ %2 = %3 }\n\n" ).arg( applyKeywordCasing( "String" ) ).arg( macro->key() ).arg( text ) );
+
+ return TRUE;
+ }
+
+ bool FileExporterBibTeX::writeComment( QIODevice &device, const Comment *comment )
+ {
+ if ( !comment->useCommand() )
+ {
+ QString text = comment->text() ;
+
+ if ( m_encoding == "latex" )
+ text = EncoderLaTeX::currentEncoderLaTeX() ->encode( text );
+
+ QStringList commentLines = QStringList::split( '\n', text );
+ for ( QStringList::Iterator it = commentLines.begin(); it != commentLines.end(); it++ )
+ {
+ writeString( device, ( *it ).append( "\n" ) );
+ }
+ writeString( device, "\n" );
+ }
+ else
+ {
+ QString text = comment->text() ;
+
+ if ( m_encoding == "latex" )
+ text = EncoderLaTeX::currentEncoderLaTeX() ->encode( text );
+
+ writeString( device, QString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Comment" ) ).arg( text ) );
+ }
+ return TRUE;
+ }
+
+ bool FileExporterBibTeX::writePreamble( QIODevice &device, const Preamble* preamble )
+ {
+ writeString( device, QString( "@%1{%2}\n\n" ).arg( applyKeywordCasing( "Preamble" ) ).arg( valueToString( preamble->value() ) ) );
+
+ return TRUE;
+ }
+
+ bool FileExporterBibTeX::writeString( QIODevice &device, const QString& text )
+ {
+ size_t utf8datasize = 1;
+ QCString utf8 = text.utf8();
+ char *utf8data = utf8.data();
+ utf8datasize = utf8.length();
+ char *outputdata = m_iconvBuffer;
+ size_t outputdatasize = m_iconvBufferSize;
+
+ size_t result = iconv( m_iconvHandle, &utf8data, &utf8datasize, &outputdata, &outputdatasize );
+ if ( result != 0 )
+ {
+ qWarning( "Cannot convert string using iconv" );
+ return false;
+ }
+
+ if ( device.writeBlock( m_iconvBuffer, m_iconvBufferSize - outputdatasize ) != ( int )( m_iconvBufferSize - outputdatasize ) )
+ {
+ qWarning( "Cannot write string to device" );
+ return false;
+ }
+
+ return true;
+ }
+
+ void FileExporterBibTeX::setStringDelimiter( const QChar& stringOpenDelimiter, const QChar& stringCloseDelimiter )
+ {
+ m_stringOpenDelimiter = stringOpenDelimiter;
+ m_stringCloseDelimiter = stringCloseDelimiter;
+ }
+
+ void FileExporterBibTeX::setKeywordCasing( const KeywordCasing keywordCasing )
+ {
+ m_keywordCasing = keywordCasing;
+ }
+
+ void FileExporterBibTeX::setEncoding( const QString& encoding )
+ {
+ m_encoding = encoding;
+ }
+
+ void FileExporterBibTeX::setEnclosingCurlyBrackets( bool protectCasing )
+ {
+ m_protectCasing = protectCasing;
+ }
+
+ QString FileExporterBibTeX::valueToString( const Value *value, const EntryField::FieldType fieldType, const QString &fieldTypeName )
+ {
+ if ( value == NULL )
+ return "";
+
+ QString result;
+ bool isFirst = TRUE;
+ EncoderLaTeX *encoder = EncoderLaTeX::currentEncoderLaTeX();
+
+ for ( QValueList<ValueItem*>::ConstIterator it = value->items.begin(); it != value->items.end(); ++it )
+ {
+ if ( !isFirst )
+ result.append( " # " );
+ else
+ isFirst = FALSE;
+
+ MacroKey *macroKey = dynamic_cast<MacroKey*>( *it );
+ if ( macroKey != NULL )
+ result.append( macroKey->text() );
+ else
+ {
+ QString text;
+ BibTeX::PersonContainer *personContainer = dynamic_cast<BibTeX::PersonContainer*>( *it );
+ BibTeX::PlainText *plainText = dynamic_cast<BibTeX::PlainText*>( *it );
+ BibTeX::KeywordContainer *keywordContainer = dynamic_cast<BibTeX::KeywordContainer*>( *it );
+
+ if ( plainText != NULL )
+ text = plainText->text();
+ else if ( keywordContainer != NULL )
+ {
+ bool first = TRUE;
+ for ( QValueList<Keyword*>::Iterator it = keywordContainer->keywords.begin(); it != keywordContainer->keywords.end(); ++it )
+ {
+ if ( !first )
+ text.append( ", " );
+ else
+ first = FALSE;
+ text.append(( *it )->text() );
+ }
+ }
+ else if ( personContainer != NULL )
+ {
+ bool first = TRUE;
+ for ( QValueList<Person*>::Iterator it = personContainer->persons.begin(); it != personContainer->persons.end(); ++it )
+ {
+ if ( !first )
+ text.append( " and " );
+ else
+ first = FALSE;
+
+ QString v = ( *it )->firstName();
+ if ( !v.isEmpty() )
+ {
+ bool requiresQuoting = requiresPersonQuoting( v, FALSE );
+ if ( requiresQuoting ) text.append( "{" );
+ text.append( v );
+ if ( requiresQuoting ) text.append( "}" );
+ text.append( " " );
+ }
+
+ v = ( *it )->lastName();
+ if ( !v.isEmpty() )
+ {
+ /** Multi-part surnames (such as "Garcia Marquez") have to be enquoted.
+ * However, "von"-Parts (as in "von Hofmannsthal") must _not_ be enquoted.
+ * Examples:
+ * -- Robson de Souza
+ * -- Hartmann von der Tann
+ * -- Ronaldo de {Assis Moreira} ("Ronaldo de Assis Moreira" works as well)
+ * -- Ailton {Goncalves da Silva}
+ * -- Gloria von {Thurn und Taxis}
+ * Thus we split the von-Parts from the surname (= everything after the first upcase char).
+ * FIXME: Make the personContainer aware of von-Parts and jr-Parts, instead.
+ */
+ QStringList list = QStringList::split( " ", v );
+ QString von;
+ for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ QString str = *it;
+ if ( str != "others" && str[0].category() == QChar::Letter_Lowercase )
+ {
+ von += *it;
+ von += " ";
+ }
+ else
+ break;
+ }
+ if ( !von.isEmpty() )
+ {
+ text.append( von );
+ v = v.right( v.length() - von.length() );
+ }
+ bool requiresQuoting = requiresPersonQuoting( v, TRUE );
+ if ( requiresQuoting ) text.append( "{" );
+ text.append( v );
+ if ( requiresQuoting ) text.append( "}" );
+ }
+ }
+ }
+
+ if ( m_encoding == "latex" )
+ text = encoder->encodeSpecialized( text, fieldType );
+
+ if ( fieldType == EntryField::ftURL || fieldType == EntryField::ftDoi || ( fieldType == EntryField::ftUnknown && fieldTypeName.lower() == "slaccitation" ) )
+ removeBackslashQuoting( text );
+
+ /** if the text to save contains a quote char ("),
+ * force string delimiters to be curly brackets,
+ * as quote chars as string delimiters would result
+ * in parser failures
+ */
+ QChar stringOpenDelimiter = m_stringOpenDelimiter;
+ QChar stringCloseDelimiter = m_stringCloseDelimiter;
+ if ( text.contains( '"' ) && ( m_stringOpenDelimiter == '"' || m_stringCloseDelimiter == '"' ) )
+ {
+ stringOpenDelimiter = '{';
+ stringCloseDelimiter = '}';
+ }
+
+ result.append( stringOpenDelimiter ).append( text ).append( stringCloseDelimiter );
+ }
+ }
+
+ return result;
+ }
+
+ void FileExporterBibTeX::removeBackslashQuoting( QString &text )
+ {
+ text.replace( "\\&", "&" ).replace( "\\#", "#" ).replace( "\\_", "_" ).replace( "\\%", "%" );
+ }
+
+ QString FileExporterBibTeX::applyKeywordCasing( const QString &keyword )
+ {
+ switch ( m_keywordCasing )
+ {
+ case kcLowerCase: return keyword.lower();
+ case kcInitialCapital: return keyword.at( 0 ) + keyword.lower().mid( 1 );
+ case kcCapital: return keyword.upper();
+ default: return keyword;
+ }
+ }
+
+ bool FileExporterBibTeX::requiresPersonQuoting( const QString &text, bool isLastName )
+ {
+ if ( isLastName && !text.contains( " " ) )
+ /** Last name contains NO spaces, no quoting necessary */
+ return FALSE;
+ else if ( isLastName && text[0].category() == QChar::Letter_Lowercase )
+ /** Last name starts with lower case character (e.g. as in "van der Linden") */
+ return FALSE;
+ else if ( !isLastName && !text.contains( " and " ) )
+ /** First name contains no " and " no quoting necessary */
+ return FALSE;
+ else if ( text[0] != '{' || text[text.length()-1] != '}' )
+ /** as either last name contains spaces or first name contains " and " and there is no protective quoting yet, there must be a protective quoting added */
+ return TRUE;
+
+ /** check for cases like "{..}..{..}", which must be surrounded with a protective quoting, too */
+ int bracketCounter = 0;
+ for ( int i = text.length() - 1; i >= 0; --i )
+ {
+ if ( text[i] == '{' )
+ ++bracketCounter;
+ else if ( text[i] == '}' )
+ --bracketCounter;
+ if ( bracketCounter == 0 && i > 0 )
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ void FileExporterBibTeX::addProtectiveCasing( QString &text )
+ {
+ if (( text[0] != '"' || text[text.length()-1] != '"' ) && ( text[0] != '{' || text[text.length()-1] != '}' ) )
+ {
+ /** nothing to protect, as this is no text string */
+ return;
+ }
+
+ bool addBrackets = TRUE;
+
+ if ( text[1] == '{' && text[text.length() - 2] == '}' )
+ {
+ addBrackets = FALSE;
+ int count = 0;
+ for ( int i = text.length() - 2; !addBrackets && i >= 1; --i )
+ if ( text[i] == '{' )++count;
+ else if ( text[i] == '}' )--count;
+ else if ( count == 0 ) addBrackets = TRUE;
+ }
+
+ if ( addBrackets )
+ text.insert( 1, '{' ).insert( text.length(), '}' );
+ }
+
+}
diff --git a/src/fileexporterbibtex.h b/src/fileexporterbibtex.h
new file mode 100644
index 0000000..6606283
--- /dev/null
+++ b/src/fileexporterbibtex.h
@@ -0,0 +1,88 @@
+/***************************************************************************
+* Copyright (C) 2004-2006 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#ifndef BIBTEXFILEEXPORTERBIBTEX_H
+#define BIBTEXFILEEXPORTERBIBTEX_H
+
+#include <iconv.h>
+
+#include <element.h>
+#include <entryfield.h>
+#include <fileexporter.h>
+
+class QChar;
+
+namespace BibTeX
+{
+ class Comment;
+ class Preamble;
+ class Macro;
+
+ /**
+ @author Thomas Fischer
+ */
+
+ class FileExporterBibTeX : public FileExporter
+ {
+ public:
+ enum KeywordCasing {kcLowerCase, kcInitialCapital, kcCamelCase, kcCapital};
+
+ FileExporterBibTeX();
+ ~FileExporterBibTeX();
+
+ bool save( QIODevice* iodevice, const File* bibtexfile, QStringList *errorLog = NULL );
+ bool save( QIODevice* iodevice, const Element* element, QStringList *errorLog = NULL );
+
+ void setStringDelimiter( const QChar& stringOpenDelimiter, const QChar& stringCloseDelimiter );
+ void setKeywordCasing( const KeywordCasing keywordCasing );
+ void setEncoding( const QString& encoding );
+ void setEnclosingCurlyBrackets( bool protectCasing );
+
+ public slots:
+ void cancel();
+
+ private:
+ iconv_t m_iconvHandle;
+ char *m_iconvBuffer;
+ const int m_iconvBufferSize;
+
+ QChar m_stringOpenDelimiter;
+ QChar m_stringCloseDelimiter;
+ KeywordCasing m_keywordCasing;
+ QString m_encoding;
+ bool m_protectCasing;
+ bool cancelFlag;
+
+ bool writeEntry( QIODevice &device, const Entry* entry );
+ bool writeMacro( QIODevice &device, const Macro *macro );
+ bool writeComment( QIODevice &device, const Comment *comment );
+ bool writePreamble( QIODevice &device, const Preamble* preamble );
+ bool writeString( QIODevice &device, const QString& text );
+
+ QString valueToString( const Value *value, const EntryField::FieldType fieldType = EntryField::ftUnknown, const QString &fieldTypeName = QString::null );
+
+ void removeBackslashQuoting( QString &text );
+ QString applyKeywordCasing( const QString &keyword );
+ bool requiresPersonQuoting( const QString &text, bool isLastName );
+ void addProtectiveCasing( QString &text );
+ };
+
+}
+
+#endif
diff --git a/src/fileexporterbibutils.cpp b/src/fileexporterbibutils.cpp
new file mode 100644
index 0000000..4de7aeb
--- /dev/null
+++ b/src/fileexporterbibutils.cpp
@@ -0,0 +1,259 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <qfile.h>
+#include <qdir.h>
+#include <qstringlist.h>
+#include <qapplication.h>
+#include <qbuffer.h>
+#include <qprocess.h>
+#include <qwaitcondition.h>
+
+#include <fileexporterbibtex.h>
+#include "fileexporterbibutils.h"
+
+namespace BibTeX
+{
+
+ FileExporterBibUtils::FileExporterBibUtils( BibTeX::File::FileFormat outputFormat )
+ : FileExporter(), m_outputFormat( outputFormat ), m_bibTeXExporter( new FileExporterBibTeX() )
+ {
+ m_bibTeXExporter->setEncoding( "utf-8" );
+ m_processBuffer = new QBuffer();
+ }
+
+ FileExporterBibUtils::~FileExporterBibUtils()
+ {
+ delete m_processBuffer;
+ delete m_bibTeXExporter;
+ }
+
+ bool FileExporterBibUtils::save( QIODevice* iodevice, const Element* element, QStringList* errorLog )
+ {
+ m_cancelFlag = false;
+ QBuffer bibBuffer;
+ if ( !toBuffer( element, &bibBuffer, errorLog ) )
+ return false;
+ if ( !bufferToXMLbuffer( &bibBuffer ) || m_cancelFlag )
+ return false;
+ return !m_cancelFlag && xmlBufferToIOdevice( iodevice );
+ }
+
+ bool FileExporterBibUtils::save( QIODevice* iodevice, const File* bibtexfile, QStringList* errorLog )
+ {
+ emit progress( 0, 3 );
+ m_cancelFlag = false;
+ QBuffer bibBuffer;
+ if ( !toBuffer( bibtexfile, &bibBuffer, errorLog ) )
+ return false;
+ emit progress( 1, 3 );
+ if ( m_cancelFlag || !bufferToXMLbuffer( &bibBuffer ) )
+ return false;
+ emit progress( 2, 3 );
+ if ( m_cancelFlag || !xmlBufferToIOdevice( iodevice ) )
+ return false;
+ emit progress( 3, 3 );
+ return !m_cancelFlag;
+ }
+
+ void FileExporterBibUtils::cancel()
+ {
+ m_bibTeXExporter->cancel();
+ m_cancelFlag = true;
+ }
+
+ bool FileExporterBibUtils::toBuffer( const File *bibFile, QBuffer *buffer, QStringList* errorLog )
+ {
+ buffer->open( IO_WriteOnly );
+ bool result = m_bibTeXExporter->save( buffer, bibFile, errorLog );
+ buffer->close();
+ return result;
+ }
+
+ bool FileExporterBibUtils::toBuffer( const Element *bibElement, QBuffer *buffer, QStringList* errorLog )
+ {
+ buffer->open( IO_WriteOnly );
+ bool result = m_bibTeXExporter->save( buffer, bibElement, errorLog );
+ buffer->close();
+ return result;
+ }
+
+ bool FileExporterBibUtils::bufferToXMLbuffer( QBuffer *bibBuffer )
+ {
+ QWaitCondition wc;
+
+ m_processBuffer->open( IO_WriteOnly );
+ m_waiting = true;
+ m_process = new QProcess( QStringList::split( ' ', "bib2xml -i utf8" ) );
+ connect( m_process, SIGNAL( processExited() ), this, SLOT( wakeUp() ) );
+ connect( m_process, SIGNAL( readyReadStdout() ), this, SLOT( slotReadyStdout() ) );
+ connect( m_process, SIGNAL( readyReadStderr() ), this, SLOT( slotReadyStderr() ) );
+
+ m_process->start();
+ if ( m_process->isRunning() )
+ {
+ bibBuffer->open( IO_ReadOnly );
+ m_process->writeToStdin( bibBuffer->readAll() );
+ qApp->processEvents();
+ m_process->closeStdin();
+ bibBuffer->close();
+
+ int nothingHappens = 20;
+ while ( m_waiting )
+ {
+ wc.wait( 250 );
+ qApp->processEvents();
+ --nothingHappens;
+ }
+
+ if ( nothingHappens <= 0 )
+ m_process->kill();
+
+ if ( !m_process->normalExit() )
+ {
+ qDebug( "%s did not exit in a clean fashion", m_process->arguments()[0].latin1() );
+ delete m_process;
+ return false;
+ }
+ }
+ else
+ {
+ qDebug( "%s did not start", m_process->arguments()[0].latin1() );
+ delete m_process;
+ return false;
+ }
+
+ m_processBuffer->close();
+
+ delete m_process;
+ return true;
+ }
+
+ bool FileExporterBibUtils::xmlBufferToIOdevice( QIODevice *iodevice )
+ {
+ QWaitCondition wc;
+ m_waiting = true;
+
+ m_process = NULL;
+ switch ( m_outputFormat )
+ {
+ case BibTeX::File::formatISI:
+ m_process = new QProcess( QStringList::split( ' ', "xml2isi" ) );
+ break;
+ case BibTeX::File::formatWordBib:
+ m_process = new QProcess( QStringList::split( ' ', "xml2wordbib" ) );
+ break;
+ case BibTeX::File::formatAds:
+ m_process = new QProcess( QStringList::split( ' ', "xml2ads" ) );
+ break;
+ case BibTeX::File::formatEndNote:
+ m_process = new QProcess( QStringList::split( ' ', "xml2end" ) );
+ break;
+ case BibTeX::File::formatRIS:
+ m_process = new QProcess( QStringList::split( ' ', "xml2ris" ) );
+ break;
+ case BibTeX::File::formatMODS:
+ /* m_process = NULL; */
+ break;
+ default:
+ qDebug( "Cannot handle output format %i", m_outputFormat );
+ return false;
+ }
+
+ if ( m_process != NULL )
+ {
+ connect( m_process, SIGNAL( processExited() ), this, SLOT( wakeUp() ) );
+ connect( m_process, SIGNAL( readyReadStdout() ), this, SLOT( slotReadyStdout() ) );
+ connect( m_process, SIGNAL( readyReadStderr() ), this, SLOT( slotReadyStderr() ) );
+
+ if ( m_process->start() )
+ {
+ QBuffer *tempBuffer = m_processBuffer;
+ m_processBuffer = new QBuffer();
+
+ tempBuffer->open( IO_ReadOnly );
+ m_process->writeToStdin( tempBuffer->readAll() );
+ qApp->processEvents();
+ m_process->closeStdin();
+ tempBuffer->close();
+
+ m_processBuffer->open( IO_WriteOnly );
+ int nothingHappens = 20;
+ while ( m_waiting )
+ {
+ wc.wait( 250 );
+ qApp->processEvents();
+ --nothingHappens;
+ }
+ m_processBuffer->close();
+
+ delete tempBuffer;
+
+ if ( nothingHappens <= 0 )
+ m_process->kill();
+
+ if ( ! m_process->normalExit() )
+ {
+ delete m_process;
+ return false;
+ }
+
+ m_processBuffer->open( IO_ReadOnly );
+ iodevice->writeBlock( m_processBuffer->buffer() );
+ m_processBuffer->close();
+
+ delete m_process;
+ }
+ else
+ {
+ qDebug( "%s did not start", m_process->arguments()[0].latin1() );
+ delete m_process;
+ return false;
+ }
+ }
+ else
+ {
+ m_processBuffer->open( IO_ReadOnly );
+ iodevice->writeBlock( m_processBuffer->buffer() );
+ m_processBuffer->close();
+ }
+
+ return true;
+ }
+
+ void FileExporterBibUtils::wakeUp()
+ {
+ m_waiting = false;
+ }
+
+ void FileExporterBibUtils::slotReadyStdout()
+ {
+ m_processBuffer->writeBlock( m_process->readStdout() );
+ }
+
+ void FileExporterBibUtils::slotReadyStderr()
+ {
+ QByteArray ba = m_process->readStderr();
+ QTextStream bats( ba, IO_ReadOnly );
+ bats.setEncoding( QTextStream::UnicodeUTF8 );
+ qDebug( "%s", bats.read().latin1() );
+ }
+
+}
+#include "fileexporterbibutils.moc"
diff --git a/src/fileexporterbibutils.h b/src/fileexporterbibutils.h
new file mode 100644
index 0000000..978a92d
--- /dev/null
+++ b/src/fileexporterbibutils.h
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef BIBTEXFILEEXPORTERBIBUTILS_H
+#define BIBTEXFILEEXPORTERBIBUTILS_H
+
+#include <fileexporter.h>
+
+class QProcess;
+class QBuffer;
+
+namespace BibTeX
+{
+ class FileExporterBibTeX;
+
+ /**
+ @author Thomas Fischer <fischer@unix-ag.uni-kl.de>
+ */
+ class FileExporterBibUtils : public FileExporter
+ {
+ Q_OBJECT
+ public:
+ FileExporterBibUtils( BibTeX::File::FileFormat outputFormat );
+ ~FileExporterBibUtils();
+
+ bool save( QIODevice* iodevice, const Element* element, QStringList* errorLog = NULL );
+ bool save( QIODevice* iodevice, const File* bibtexfile, QStringList* errorLog = NULL );
+
+ public slots:
+ void cancel();
+
+ private:
+ bool m_cancelFlag;
+ BibTeX::File::FileFormat m_outputFormat;
+ FileExporterBibTeX *m_bibTeXExporter;
+
+ bool m_waiting;
+ QProcess *m_process;
+ QBuffer *m_processBuffer;
+
+ bool toBuffer( const File *bibFile, QBuffer *buffer, QStringList* errorLog);
+ bool toBuffer( const Element *bibFile, QBuffer *buffer, QStringList* errorLog);
+ bool bufferToXMLbuffer( QBuffer *buffer );
+ bool xmlBufferToIOdevice( QIODevice *iodevice );
+
+ private slots:
+ void wakeUp();
+ void slotReadyStdout();
+ void slotReadyStderr();
+ };
+
+}
+
+#endif // BIBTEXFILEEXPORTERBIBUTILS_H
diff --git a/src/fileexporterdocbook5.cpp b/src/fileexporterdocbook5.cpp
new file mode 100644
index 0000000..7a962b6
--- /dev/null
+++ b/src/fileexporterdocbook5.cpp
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <qfile.h>
+#include <qstringlist.h>
+
+#include <file.h>
+#include <fileexporterbibtex.h>
+#include "fileexporterdocbook5.h"
+
+namespace BibTeX
+{
+
+ FileExporterDocBook5::FileExporterDocBook5( const QString& classPath )
+ : FileExporterToolchain(), m_classPath( classPath )
+ {
+ bibTeXFilename = QString( workingDir ).append( "/bibtex-to-docbook5.bib" );
+ outputFilename = QString( workingDir ).append( "/bibtex-to-docbook5.bib.xml" );
+ }
+
+
+ FileExporterDocBook5::~FileExporterDocBook5()
+ {
+ // nothing
+ }
+
+ bool FileExporterDocBook5::save( QIODevice* iodevice, const File* bibtexfile, QStringList *errorLog )
+ {
+ m_mutex.lock();
+ bool result = FALSE;
+
+ QFile bibtexFile( bibTeXFilename );
+ if ( bibtexFile.open( IO_WriteOnly ) )
+ {
+ FileExporter * bibtexExporter = new FileExporterBibTeX();
+ result = bibtexExporter->save( &bibtexFile, bibtexfile, errorLog );
+ bibtexFile.close();
+ delete bibtexExporter;
+ }
+
+ if ( result )
+ result = runBib2Db5( iodevice, errorLog );
+
+ m_mutex.unlock();
+ return result;
+ }
+
+ bool FileExporterDocBook5::save( QIODevice* iodevice, const Element* element, QStringList *errorLog )
+ {
+ m_mutex.lock();
+ bool result = FALSE;
+
+ QFile bibtexFile( bibTeXFilename );
+ if ( bibtexFile.open( IO_WriteOnly ) )
+ {
+ FileExporter * bibtexExporter = new FileExporterBibTeX();
+ result = bibtexExporter->save( &bibtexFile, element, errorLog );
+ bibtexFile.close();
+ delete bibtexExporter;
+ }
+
+ if ( result )
+ result = runBib2Db5( iodevice, errorLog );
+
+ m_mutex.unlock();
+ return result;
+ }
+
+ bool FileExporterDocBook5::runBib2Db5( QIODevice* iodevice, QStringList *errorLog )
+ {
+ QStringList cmdLine;
+ cmdLine << "java" << "-cp" << m_classPath << "net.sf.bib2db5.DB5Converter" << "-O" << "." << "bibtex-to-docbook5.bib";
+
+ if ( runProcess( cmdLine, errorLog ) && writeFileToIODevice( outputFilename, iodevice ) )
+ return TRUE;
+ else
+ return FALSE;
+ }
+
+}
diff --git a/src/fileexporterdocbook5.h b/src/fileexporterdocbook5.h
new file mode 100644
index 0000000..7b5f812
--- /dev/null
+++ b/src/fileexporterdocbook5.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2004-2009 by Thomas Fischer *
+ * fischer@unix-ag.uni-kl.de *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef BIBTEXFILEEXPORTERDOCBOOK5_H
+#define BIBTEXFILEEXPORTERDOCBOOK5_H
+
+#include <fileexportertoolchain.h>
+
+namespace BibTeX
+{
+
+ /**
+ @author Thomas Fischer
+ */
+ class FileExporterDocBook5 : public FileExporterToolchain
+ {
+ public:
+ FileExporterDocBook5(const QString& classPath);
+ ~FileExporterDocBook5();
+
+ bool save( QIODevice* iodevice, const File* bibtexfile, QStringList *errorLog = NULL );
+ bool save( QIODevice* iodevice, const Element* element, QStringList *errorLog = NULL );
+
+ void setLaTeXLanguage( const QString& language );
+ void setLaTeXBibliographyStyle( const QString& bibStyle );
+
+ private:
+QString m_classPath;
+ QString bibTeXFilename;
+ QString outputFilename;
+
+ bool runBib2Db5( QIODevice* iodevice, QStringList *errorLog );
+ };
+
+
+}
+
+#endif
diff --git a/src/fileexporterexternal.cpp b/src/fileexporterexternal.cpp
new file mode 100644
index 0000000..6b7e449
--- /dev/null
+++ b/src/fileexporterexternal.cpp
@@ -0,0 +1,179 @@
+/***************************************************************************
+* Copyright (C) 2004-2009 by Thomas Fischer *
+* fischer@unix-ag.uni-kl.de *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, *
+* but WITHOUT ANY WARRANTY; without even the implied warranty of *
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+* GNU General Public License for more details. *
+* *
+* You should have received a copy of the GNU General Public License *
+* along with this program; if not, write to the *
+* Free Software Foundation, Inc., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+#include <qprocess.h>
+#include <qwaitcondition.h>
+#include <qapplication.h>
+#include <qbuffer.h>
+
+#include <fileexporterbibtex.h>
+#include <settings.h>
+#include "fileexporterexternal.h"
+
+namespace BibTeX
+{
+
+ FileExporterExternal::FileExporterExternal( Exporter exporter, File::FileFormat fileformat )
+ : FileExporter(), writeTo( NULL ), m_exporter( exporter ), m_fileformat( fileformat )
+ {
+ wc = new QWaitCondition();
+ }
+
+ FileExporterExternal::~FileExporterExternal()
+ {
+ delete wc;
+ }
+
+ bool FileExporterExternal::save( QIODevice* iodevice, const File* bibtexfile, QStringList *errorLog )
+ {
+ m_mutex.lock();
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ FileExporter * bibtexExporter = new FileExporterBibTeX();
+ bool result = bibtexExporter->save( &buffer, bibtexfile, errorLog );
+ buffer.close();
+ delete bibtexExporter;
+
+ if ( result )
+ result = generateOutput( buffer, iodevice );
+
+ m_mutex.unlock();
+ return result;
+ }
+
+ bool FileExporterExternal::save( QIODevice* iodevice, const Element* element, QStringList *errorLog )
+ {
+ m_mutex.lock();
+ QBuffer buffer;
+ buffer.open( IO_WriteOnly );
+ FileExporter * bibtexExporter = new FileExporterBibTeX();
+ bool result = bibtexExporter->save( &buffer, ele