2003-10-06 18:31:25 +00:00
|
|
|
// vim: set ts=4 sts=4 sw=4 et:
|
2003-01-21 16:16:53 +00:00
|
|
|
/* This file is part of the KDE project
|
|
|
|
Copyright (C) 2000 David Faure <faure@kde.org>
|
|
|
|
Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License version 2 as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
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; see the file COPYING. If not, write to
|
2005-10-05 08:44:32 +00:00
|
|
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2005-07-04 19:02:09 +00:00
|
|
|
Boston, MA 02110-1301, USA.
|
2003-01-21 16:16:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __importers_h
|
|
|
|
#define __importers_h
|
|
|
|
|
2005-06-15 14:41:18 +00:00
|
|
|
#include "commands.h"
|
2003-01-21 16:16:53 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
|
|
|
|
#include <kcommand.h>
|
|
|
|
|
|
|
|
#include <qobject.h>
|
2005-10-04 20:42:32 +00:00
|
|
|
#include <QString>
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2005-11-29 13:56:41 +00:00
|
|
|
class KBookmark;
|
|
|
|
|
2003-02-05 21:07:30 +00:00
|
|
|
// part pure
|
2005-06-15 14:41:18 +00:00
|
|
|
class ImportCommand : public QObject, public KCommand, public IKEBCommand
|
2003-01-21 16:16:53 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2003-02-05 21:29:31 +00:00
|
|
|
ImportCommand()
|
2003-06-18 09:21:06 +00:00
|
|
|
: KCommand(), m_utf8(false), m_folder(false), m_cleanUpCmd(0L)
|
2003-02-05 21:29:31 +00:00
|
|
|
{ ; }
|
|
|
|
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) = 0;
|
2003-02-05 21:57:34 +00:00
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
virtual QString name() const;
|
2003-02-05 22:48:28 +00:00
|
|
|
virtual QString visibleName() const { return m_visibleName; }
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2005-10-04 20:42:32 +00:00
|
|
|
static ImportCommand* performImport(const QString &, QWidget *);
|
|
|
|
static ImportCommand* importerFactory(const QString &);
|
2003-02-05 22:15:04 +00:00
|
|
|
|
2003-01-22 20:01:44 +00:00
|
|
|
virtual ~ImportCommand()
|
2003-01-21 16:16:53 +00:00
|
|
|
{ ; }
|
|
|
|
|
|
|
|
virtual void execute();
|
|
|
|
virtual void unexecute();
|
2005-07-14 01:10:15 +00:00
|
|
|
virtual QString affectedBookmarks() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-02-05 21:29:31 +00:00
|
|
|
QString groupAddress() const { return m_group; }
|
|
|
|
QString folder() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
|
|
|
protected:
|
2003-02-05 22:19:13 +00:00
|
|
|
/**
|
|
|
|
* @param fileName HTML file to import
|
|
|
|
* @param folder name of the folder to create. Empty for no creation (root()).
|
|
|
|
* @param icon icon for the new folder, if @p folder isn't empty
|
|
|
|
* @param utf8 true if the HTML is in utf-8 encoding
|
|
|
|
*/
|
|
|
|
void init(const QString &fileName, bool folder, const QString &icon, bool utf8)
|
|
|
|
{
|
|
|
|
m_fileName = fileName;
|
|
|
|
m_folder = folder;
|
|
|
|
m_icon = icon;
|
|
|
|
m_utf8 = utf8;
|
|
|
|
}
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
|
2003-03-06 14:52:20 +00:00
|
|
|
virtual void doExecute(const KBookmarkGroup &) = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
|
2003-06-18 09:21:06 +00:00
|
|
|
protected:
|
|
|
|
QString m_visibleName;
|
2003-01-21 16:16:53 +00:00
|
|
|
QString m_fileName;
|
|
|
|
QString m_icon;
|
|
|
|
QString m_group;
|
|
|
|
bool m_utf8;
|
2003-06-18 09:21:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_folder;
|
|
|
|
KMacroCommand *m_cleanUpCmd;
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
2003-02-05 21:07:30 +00:00
|
|
|
// part pure
|
2003-01-21 16:16:53 +00:00
|
|
|
class XBELImportCommand : public ImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 21:49:29 +00:00
|
|
|
XBELImportCommand() : ImportCommand() { ; }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) = 0;
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
private:
|
|
|
|
virtual void doCreateHoldingFolder(KBookmarkGroup &bkGroup);
|
2003-03-06 14:52:20 +00:00
|
|
|
virtual void doExecute(const KBookmarkGroup &);
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class GaleonImportCommand : public XBELImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 22:48:28 +00:00
|
|
|
GaleonImportCommand() : XBELImportCommand() { m_visibleName = i18n("Galeon"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 22:48:28 +00:00
|
|
|
init(fileName, folder, "", false);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class KDE2ImportCommand : public XBELImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2005-06-27 15:45:36 +00:00
|
|
|
KDE2ImportCommand() : XBELImportCommand() { m_visibleName = i18n("KDE"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 22:48:28 +00:00
|
|
|
init(fileName, folder, "", false);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
2003-02-05 21:07:30 +00:00
|
|
|
// part pure
|
2003-01-21 16:16:53 +00:00
|
|
|
class HTMLImportCommand : public ImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 21:49:29 +00:00
|
|
|
HTMLImportCommand() : ImportCommand() { ; }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) = 0;
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const = 0;
|
2003-01-21 16:16:53 +00:00
|
|
|
private:
|
2003-03-06 14:52:20 +00:00
|
|
|
virtual void doExecute(const KBookmarkGroup &);
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class NSImportCommand : public HTMLImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 22:48:28 +00:00
|
|
|
NSImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Netscape"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 22:25:19 +00:00
|
|
|
init(fileName, folder, "netscape", false);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class MozImportCommand : public HTMLImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 22:48:28 +00:00
|
|
|
MozImportCommand() : HTMLImportCommand() { m_visibleName = i18n("Mozilla"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 22:25:19 +00:00
|
|
|
init(fileName, folder, "mozilla", true);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class IEImportCommand : public ImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 22:48:28 +00:00
|
|
|
IEImportCommand() : ImportCommand() { m_visibleName = i18n("IE"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 21:29:31 +00:00
|
|
|
init(fileName, folder, "", false);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
private:
|
2003-03-06 14:52:20 +00:00
|
|
|
virtual void doExecute(const KBookmarkGroup &);
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class OperaImportCommand : public ImportCommand
|
|
|
|
{
|
|
|
|
public:
|
2003-02-05 22:48:28 +00:00
|
|
|
OperaImportCommand() : ImportCommand() { m_visibleName = i18n("Opera"); }
|
2003-02-05 22:26:26 +00:00
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-02-05 21:29:31 +00:00
|
|
|
init(fileName, folder, "opera", false);
|
2003-02-05 21:18:09 +00:00
|
|
|
}
|
2003-02-05 21:07:30 +00:00
|
|
|
virtual QString requestFilename() const;
|
2003-01-21 16:16:53 +00:00
|
|
|
private:
|
2003-03-06 14:52:20 +00:00
|
|
|
virtual void doExecute(const KBookmarkGroup &);
|
2003-01-21 16:16:53 +00:00
|
|
|
};
|
|
|
|
|
2003-07-05 10:01:16 +00:00
|
|
|
class CrashesImportCommand : public ImportCommand
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CrashesImportCommand() : ImportCommand() { m_visibleName = i18n("Crashes"); }
|
|
|
|
virtual void import(const QString &fileName, bool folder) {
|
2003-07-30 11:43:45 +00:00
|
|
|
init(fileName, folder, "core", false);
|
2003-07-05 10:01:16 +00:00
|
|
|
}
|
|
|
|
virtual QString requestFilename() const;
|
|
|
|
private:
|
|
|
|
virtual void doExecute(const KBookmarkGroup &);
|
|
|
|
};
|
|
|
|
|
2003-01-21 16:16:53 +00:00
|
|
|
#endif
|