File indexing completed on 2022-11-29 20:24:09

0001 /* This file is part of the KDE project
0002    Copyright (C) 2000, 2010 David Faure <faure@kde.org>
0003    Copyright (C) 2002-2003 Alexander Kellett <lypanov@kde.org>
0004 
0005    This program is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU General Public License as
0007    published by the Free Software Foundation; either version 2 of
0008    the License, or (at your option) version 3.
0009 
0010    This program is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013    GNU General Public License for more details.
0014 
0015    You should have received a copy of the GNU General Public License
0016    along with this program.  If not, see <http://www.gnu.org/licenses/>
0017 */
0018 
0019 #ifndef GLOBALBOOKMARKMANAGER_H
0020 #define GLOBALBOOKMARKMANAGER_H
0021 
0022 #include <KBookmark>
0023 #include <QObject>
0024 
0025 class CommandHistory;
0026 class KBookmarkModel;
0027 class KBookmarkManager;
0028 
0029 class GlobalBookmarkManager : public QObject
0030 {
0031     Q_OBJECT
0032 public:
0033     typedef enum { HTMLExport, OperaExport, IEExport, MozillaExport, NetscapeExport } ExportType;
0034 
0035     // TODO port to K_GLOBAL_STATIC if we keep this class
0036     static GlobalBookmarkManager *self()
0037     {
0038         if (!s_mgr) {
0039             s_mgr = new GlobalBookmarkManager();
0040         }
0041         return s_mgr;
0042     }
0043     ~GlobalBookmarkManager() override;
0044     KBookmarkGroup root();
0045     static KBookmark bookmarkAt(const QString &a);
0046 
0047     KBookmarkModel *model() const
0048     {
0049         return m_model;
0050     }
0051     KBookmarkManager *mgr() const
0052     {
0053         return m_mgr;
0054     }
0055     QString path() const;
0056 
0057     void createManager(const QString &filename, const QString &dbusObjectName, CommandHistory *commandHistory);
0058     void notifyManagers(const KBookmarkGroup &grp);
0059     void notifyManagers();
0060     bool managerSave();
0061     void saveAs(const QString &fileName);
0062     void doExport(ExportType type, const QString &path = QString());
0063     void setUpdate(bool update);
0064 
0065     void reloadConfig();
0066 
0067     // TODO move out
0068     static QString makeTimeStr(const QString &);
0069     static QString makeTimeStr(int);
0070 
0071 private:
0072     GlobalBookmarkManager();
0073     KBookmarkManager *m_mgr;
0074     KBookmarkModel *m_model;
0075     static GlobalBookmarkManager *s_mgr;
0076 };
0077 
0078 #endif /* GLOBALBOOKMARKMANAGER_H */