kbookmarkimporter_ns.h

00001 //  -*- c-basic-offset:4; indent-tabs-mode:nil -*-
00002 // vim: set ts=4 sts=4 sw=4 et:
00003 /* This file is part of the KDE libraries
00004    Copyright (C) 2000 David Faure <faure@kde.org>
00005 
00006    This library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Library General Public
00008    License version 2 as published by the Free Software Foundation.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef __kbookmarkimporter_ns_h
00022 #define __kbookmarkimporter_ns_h
00023 
00024 #include <qdom.h>
00025 #include <qcstring.h>
00026 #include <qstringlist.h>
00027 #include <ksimpleconfig.h>
00028 #include <kdemacros.h>
00029 
00030 #include "kbookmarkimporter.h"
00031 #include "kbookmarkexporter.h"
00032 
00037 class KIO_EXPORT_DEPRECATED KNSBookmarkImporter : public QObject
00038 {
00039     Q_OBJECT
00040 public:
00041     KNSBookmarkImporter( const QString & fileName ) : m_fileName(fileName) {}
00042     ~KNSBookmarkImporter() {}
00043 
00044     // for compat reasons only
00045     void parseNSBookmarks() { parseNSBookmarks(false); }
00046     // go for it. Set utf8 to true for Mozilla, false for Netscape.
00047     void parseNSBookmarks( bool utf8 );
00048 
00049     static QString netscapeBookmarksFile( bool forSaving=false );
00050     static QString mozillaBookmarksFile( bool forSaving=false );
00051 
00052 signals:
00053     void newBookmark( const QString & text, const QCString & url, const QString & additionalInfo );
00054     void newFolder( const QString & text, bool open, const QString & additionalInfo );
00055     void newSeparator();
00056     void endFolder();
00057 
00058 protected:
00059     QString m_fileName;
00060 };
00061 
00067 class KIO_EXPORT KNSBookmarkImporterImpl : public KBookmarkImporterBase
00068 {
00069 public:
00070     KNSBookmarkImporterImpl() : m_utf8(false) { }
00071     void setUtf8(bool utf8) { m_utf8 = utf8; }
00072     virtual void parse();
00073     virtual QString findDefaultLocation(bool forSaving = false) const;
00074 private:
00075     bool m_utf8;
00076     class KNSBookmarkImporterImplPrivate *d;
00077 };
00078 
00084 class KIO_EXPORT KMozillaBookmarkImporterImpl : public KNSBookmarkImporterImpl
00085 {
00086 public:
00087     KMozillaBookmarkImporterImpl() { setUtf8(true); }
00088 private:
00089     class KMozillaBookmarkImporterImplPrivate *d;
00090 };
00091 
00097 class KIO_EXPORT_DEPRECATED KNSBookmarkExporter
00098 {
00099 public:
00100     KNSBookmarkExporter(KBookmarkManager* mgr, const QString & fileName)
00101       : m_fileName(fileName), m_pManager(mgr) { }
00102     ~KNSBookmarkExporter() {}
00103 
00104     void write() { write(false); } // deprecated
00105     void write( bool utf8 );
00106 
00107 protected:
00108     void writeFolder(QTextStream &stream, KBookmarkGroup parent);
00109     QString m_fileName;
00110     KBookmarkManager* m_pManager;
00111 };
00112 
00116 class KIO_EXPORT KNSBookmarkExporterImpl : public KBookmarkExporterBase
00117 {
00118 public:
00119     KNSBookmarkExporterImpl(KBookmarkManager* mgr, const QString & fileName)
00120       : KBookmarkExporterBase(mgr, fileName) 
00121     { ; }
00122     virtual ~KNSBookmarkExporterImpl() {}
00123     virtual void write(KBookmarkGroup);
00124     void setUtf8(bool);
00125 protected:
00126     QString folderAsString(KBookmarkGroup) const;
00127 private:
00128     bool m_utf8;
00129     class KNSBookmarkExporterImplPrivate *d;
00130 };
00131 
00132 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys