SVN_SILENT made messages (after extraction)
[kdepim.git] / storageservicemanager / storageservicenavigationbuttons.cpp
blob42fddcf56b3fe54cbde3fd7d89b31d47b28ce3cb
1 /*
2 Copyright (c) 2014-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
17 02110-1301, USA.
21 #include "storageservicenavigationbuttons.h"
23 #include <KLocalizedString>
24 #include <QIcon>
25 #include <KStandardShortcut>
27 #include <QAction>
29 StorageServiceNavigationButtons::StorageServiceNavigationButtons(QWidget *parent)
30 : QToolBar(parent)
32 mHome = addAction(QIcon::fromTheme(QStringLiteral("go-home")), i18n("Home"), this, SIGNAL(goHome()));
34 mGoBack = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), i18n("Back"), this);
35 addAction(mGoBack);
36 connect(mGoBack, &QAction::triggered, this, &StorageServiceNavigationButtons::slotGoBackClicked);
37 mGoBack->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Back));
38 mGoBack->setEnabled(false);
40 mGoForward = new QAction(QIcon::fromTheme(QStringLiteral("go-next")), i18n("Forward"), this);
41 mGoForward->setShortcuts(KStandardShortcut::shortcut(KStandardShortcut::Forward));
42 connect(mGoForward, &QAction::triggered, this, &StorageServiceNavigationButtons::slotGoForwardClicked);
43 addAction(mGoForward);
44 mGoForward->setEnabled(false);
47 QAction *StorageServiceNavigationButtons::goBack() const
49 return mGoBack;
52 QAction *StorageServiceNavigationButtons::goForward() const
54 return mGoForward;
57 QAction *StorageServiceNavigationButtons::home() const
59 return mHome;
62 void StorageServiceNavigationButtons::addNewUrl(const InformationUrl &info)
64 if (info.isValid()) {
65 mBackUrls.prepend(info);
66 updateButtons();
70 void StorageServiceNavigationButtons::addBackUrl(const InformationUrl &info)
72 if (info.isValid()) {
73 mBackUrls.prepend(info);
74 updateButtons();
78 void StorageServiceNavigationButtons::addForwadUrl(const InformationUrl &info)
80 if (info.isValid()) {
81 mForwardUrls.prepend(info);
82 updateButtons();
86 QList<InformationUrl> StorageServiceNavigationButtons::backUrls() const
88 return mBackUrls;
91 void StorageServiceNavigationButtons::setBackUrls(const QList<InformationUrl> &value)
93 if (mBackUrls != value) {
94 mBackUrls = value;
95 updateButtons();
99 QList<InformationUrl> StorageServiceNavigationButtons::forwardUrls() const
101 return mForwardUrls;
104 void StorageServiceNavigationButtons::setForwardUrls(const QList<InformationUrl> &value)
106 if (mForwardUrls != value) {
107 mForwardUrls = value;
108 updateButtons();
112 void StorageServiceNavigationButtons::clear()
114 mBackUrls.clear();
115 mForwardUrls.clear();
116 updateButtons();
119 void StorageServiceNavigationButtons::updateButtons()
121 mGoForward->setEnabled(!mForwardUrls.isEmpty());
122 mGoBack->setEnabled(!mBackUrls.isEmpty());
125 void StorageServiceNavigationButtons::slotGoBackClicked()
127 if (!mBackUrls.isEmpty()) {
128 InformationUrl url = mBackUrls.takeFirst();
129 qCDebug(STORAGESERVICEMANAGER_LOG) << " back clicked" << url;
130 Q_EMIT changeUrl(url);
131 mForwardUrls.prepend(url);
132 updateButtons();
136 void StorageServiceNavigationButtons::slotGoForwardClicked()
138 if (!mForwardUrls.isEmpty()) {
139 InformationUrl url = mForwardUrls.takeFirst();
140 qCDebug(STORAGESERVICEMANAGER_LOG) << " forward clicked" << url;
141 Q_EMIT changeUrl(url);
142 mBackUrls.prepend(url);
143 updateButtons();