summaryrefslogtreecommitdiffstats
path: root/src/core/dcopinterface.h
blob: e0c6c73f17a19efbc3c0af3248468bfca6f18495 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************************************************************
    copyright            : (C) 2004-2006 by Robby Stephenson
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of version 2 of the GNU General Public License as  *
 *   published by the Free Software Foundation;                            *
 *                                                                         *
 ***************************************************************************/

#ifndef TELLICO_DCOPINTERFACE_H
#define TELLICO_DCOPINTERFACE_H

#include "../translators/translators.h"

#include <dcopobject.h>
#include <kurl.h>

#include <tqstringlist.h> // used in generated dcopinterface_skel.cpp

namespace Tellico {

class ApplicationInterface : public DCOPObject {
K_DCOP
k_dcop:
  bool importTellico(const TQString& file, const TQString& action)
    { return importFile(Import::TellicoXML, KURL::fromPathOrURL(file), actionType(action)); }
  bool importBibtex(const TQString& file, const TQString& action)
    { return importFile(Import::Bibtex, KURL::fromPathOrURL(file), actionType(action)); }
  bool importMODS(const TQString& file, const TQString& action)
    { return importFile(Import::MODS, KURL::fromPathOrURL(file), actionType(action)); }
  bool importRIS(const TQString& file, const TQString& action)
    { return importFile(Import::RIS, KURL::fromPathOrURL(file), actionType(action)); }

  bool exportXML(const TQString& file)
    { return exportCollection(Export::TellicoXML, KURL::fromPathOrURL(file)); }
  bool exportZip(const TQString& file)
    { return exportCollection(Export::TellicoZip, KURL::fromPathOrURL(file)); }
  bool exportBibtex(const TQString& file)
    { return exportCollection(Export::Bibtex, KURL::fromPathOrURL(file)); }
  bool exportHTML(const TQString& file)
    { return exportCollection(Export::HTML, KURL::fromPathOrURL(file)); }
  bool exportCSV(const TQString& file)
    { return exportCollection(Export::CSV, KURL::fromPathOrURL(file)); }
  bool exportPilotDB(const TQString& file)
    { return exportCollection(Export::PilotDB, KURL::fromPathOrURL(file)); }

  TQValueList<long> selectedEntries() const;
  TQValueList<long> filteredEntries() const;

  virtual void openFile(const TQString& file) = 0;
  virtual void setFilter(const TQString& text) = 0;
  virtual bool showEntry(long id) = 0;

protected:
  ApplicationInterface() : DCOPObject("tellico") {}
  virtual bool importFile(Import::Format format, const KURL& url, Import::Action action) = 0;
  virtual bool exportCollection(Export::Format format, const KURL& url) = 0;

private:
  Import::Action actionType(const TQString& actionName);
};

class CollectionInterface : public DCOPObject {
K_DCOP
k_dcop:
  long addEntry();
  bool removeEntry(long entryID);

  TQStringList values(const TQString& fieldName) const;
  TQStringList values(long entryID, const TQString& fieldName) const;
  TQStringList bibtexKeys() const;
  TQString bibtexKey(long entryID) const;

  bool setFieldValue(long entryID, const TQString& fieldName, const TQString& value);
  bool addFieldValue(long entryID, const TQString& fieldName, const TQString& value);

  friend class MainWindow;

protected:
  CollectionInterface() : DCOPObject("collection") {}
};

} // end namespace
#endif