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/>
26 #include <k3command.h>
28 #include <QtCore/QObject>
34 class ImportCommand
: public QObject
, public K3Command
, public IKEBCommand
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;
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
;
76 virtual void doCreateHoldingFolder(KBookmarkGroup
&bkGroup
);
77 virtual void doExecute(const KBookmarkGroup
&) = 0;
80 QString m_visibleName
;
88 K3MacroCommand
*m_cleanUpCmd
;
92 class XBELImportCommand
: public ImportCommand
95 XBELImportCommand() : ImportCommand() {}
96 virtual void import(const QString
&fileName
, bool folder
) = 0;
97 virtual QString
requestFilename() const = 0;
99 virtual void doCreateHoldingFolder(KBookmarkGroup
&bkGroup
);
100 virtual void doExecute(const KBookmarkGroup
&);
103 class GaleonImportCommand
: public XBELImportCommand
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
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;
124 class HTMLImportCommand
: public ImportCommand
127 HTMLImportCommand() : ImportCommand() {}
128 virtual void import(const QString
&fileName
, bool folder
) = 0;
129 virtual QString
requestFilename() const = 0;
131 virtual void doExecute(const KBookmarkGroup
&);
134 class NSImportCommand
: public HTMLImportCommand
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
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
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;
163 virtual void doExecute(const KBookmarkGroup
&);
166 class OperaImportCommand
: public ImportCommand
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;
175 virtual void doExecute(const KBookmarkGroup
&);
178 class CrashesImportCommand
: public ImportCommand
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;
187 virtual void doExecute(const KBookmarkGroup
&);