it launches applications. it's an application launcher.
[kdebase.git] / apps / keditbookmarks / importers.h
blob7c07c61b360834f72585d7710528cde54ee62c18
1 // vim: set ts=4 sts=4 sw=4 et:
2 /* This file is part of the KDE project
3 Copyright (C) 2000 David Faure <faure@kde.org>
4 Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License as
8 published by the Free Software Foundation; either version 2 of
9 the License, or (at your option) version 3.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>
20 #ifndef __importers_h
21 #define __importers_h
23 #include "commands.h"
24 #include <klocale.h>
26 #include <k3command.h>
28 #include <QtCore/QObject>
31 class KBookmark;
33 // part pure
34 class ImportCommand : public QObject, public K3Command, public IKEBCommand
36 Q_OBJECT
37 public:
38 ImportCommand()
39 : K3Command(), m_utf8(false), m_folder(false), m_cleanUpCmd(0L)
42 virtual void import(const QString &fileName, bool folder) = 0;
44 virtual QString name() const;
45 virtual QString visibleName() const { return m_visibleName; }
46 virtual QString requestFilename() const = 0;
48 static ImportCommand* performImport(const QString &, QWidget *);
49 static ImportCommand* importerFactory(const QString &);
51 virtual ~ImportCommand()
54 virtual void execute();
55 virtual void unexecute();
56 virtual QString affectedBookmarks() const;
58 QString groupAddress() const { return m_group; }
59 QString folder() const;
61 protected:
62 /**
63 * @param fileName HTML file to import
64 * @param folder name of the folder to create. Empty for no creation (root()).
65 * @param icon icon for the new folder, if @p folder isn't empty
66 * @param utf8 true if the HTML is in utf-8 encoding
68 void init(const QString &fileName, bool folder, const QString &icon, bool utf8)
70 m_fileName = fileName;
71 m_folder = folder;
72 m_icon = icon;
73 m_utf8 = utf8;
76 virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
77 virtual void doExecute(const KBookmarkGroup &) = 0;
79 protected:
80 QString m_visibleName;
81 QString m_fileName;
82 QString m_icon;
83 QString m_group;
84 bool m_utf8;
86 private:
87 bool m_folder;
88 K3MacroCommand *m_cleanUpCmd;
91 // part pure
92 class XBELImportCommand : public ImportCommand
94 public:
95 XBELImportCommand() : ImportCommand() {}
96 virtual void import(const QString &fileName, bool folder) = 0;
97 virtual QString requestFilename() const = 0;
98 private:
99 virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
100 virtual void doExecute(const KBookmarkGroup &);
103 class GaleonImportCommand : public XBELImportCommand
105 public:
106 GaleonImportCommand() : XBELImportCommand() { m_visibleName = i18n("Galeon"); }
107 virtual void import(const QString &fileName, bool folder) {
108 init(fileName, folder, "", false);
110 virtual QString requestFilename() const;
113 class KDE2ImportCommand : public XBELImportCommand
115 public:
116 KDE2ImportCommand() : XBELImportCommand() { m_visibleName = i18n("KDE"); }
117 virtual void import(const QString &fileName, bool folder) {
118 init(fileName, folder, "", false);
120 virtual QString requestFilename() const;
123 // part pure
124 class HTMLImportCommand : public ImportCommand
126 public:
127 HTMLImportCommand() : ImportCommand() {}
128 virtual void import(const QString &fileName, bool folder) = 0;
129 virtual QString requestFilename() const = 0;
130 private:
131 virtual void doExecute(const KBookmarkGroup &);
134 class NSImportCommand : public HTMLImportCommand
136 public:
137 NSImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Netscape"); }
138 virtual void import(const QString &fileName, bool folder) {
139 init(fileName, folder, "netscape", false);
141 virtual QString requestFilename() const;
144 class MozImportCommand : public HTMLImportCommand
146 public:
147 MozImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Mozilla"); }
148 virtual void import(const QString &fileName, bool folder) {
149 init(fileName, folder, "mozilla", true);
151 virtual QString requestFilename() const;
154 class IEImportCommand : public ImportCommand
156 public:
157 IEImportCommand() : ImportCommand() { m_visibleName = i18n("IE"); }
158 virtual void import(const QString &fileName, bool folder) {
159 init(fileName, folder, "", false);
161 virtual QString requestFilename() const;
162 private:
163 virtual void doExecute(const KBookmarkGroup &);
166 class OperaImportCommand : public ImportCommand
168 public:
169 OperaImportCommand() : ImportCommand() { m_visibleName = i18n("Opera"); }
170 virtual void import(const QString &fileName, bool folder) {
171 init(fileName, folder, "opera", false);
173 virtual QString requestFilename() const;
174 private:
175 virtual void doExecute(const KBookmarkGroup &);
178 class CrashesImportCommand : public ImportCommand
180 public:
181 CrashesImportCommand() : ImportCommand() { m_visibleName = i18n("Crashes"); }
182 virtual void import(const QString &fileName, bool folder) {
183 init(fileName, folder, "core", false);
185 virtual QString requestFilename() const;
186 private:
187 virtual void doExecute(const KBookmarkGroup &);
190 #endif