2 Copyright (c) 2015-2016 Montel Laurent <montel@kde.org>
4 This library is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at your
7 option) any later version.
9 This library is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12 License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to the
16 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "sieveeditorbookmarks.h"
22 #include "sieveeditormainwindow.h"
23 #include <QStandardPaths>
24 #include <kbookmarkmanager.h>
25 #include <KBookmarkMenu>
28 SieveEditorBookmarks::SieveEditorBookmarks(SieveEditorMainWindow
*mainWindow
, KActionCollection
*collection
, QMenu
*menu
, QObject
*parent
)
31 mBookmarkMenu(Q_NULLPTR
),
33 mMainWindow(mainWindow
)
35 QString bookmarkFile
= QStandardPaths::locate(QStandardPaths::GenericDataLocation
, QStringLiteral("sieveeditor/bookmarks.xml"));
37 if (bookmarkFile
.isEmpty()) {
38 bookmarkFile
= QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation
) + QStringLiteral("/sieveeditor");
39 QDir().mkpath(bookmarkFile
);
40 bookmarkFile
+= QStringLiteral("/bookmarks.xml");
43 KBookmarkManager
*manager
= KBookmarkManager::managerForFile(bookmarkFile
, QStringLiteral("sieveeditor"));
44 manager
->setUpdate(true);
46 mBookmarkMenu
= new KBookmarkMenu(manager
, this, mMenu
, collection
);
49 SieveEditorBookmarks::~SieveEditorBookmarks()
54 QMenu
*SieveEditorBookmarks::menu() const
59 void SieveEditorBookmarks::openBookmark(const KBookmark
&bm
, Qt::MouseButtons mb
, Qt::KeyboardModifiers km
)
63 Q_EMIT
openUrl(bm
.url());
66 QString
SieveEditorBookmarks::currentTitle() const
68 return mMainWindow
->currentHelpTitle();
71 QUrl
SieveEditorBookmarks::currentUrl() const
73 return mMainWindow
->currentHelpUrl();