SVN_SILENT made messages (.desktop file)
[kdepim.git] / storageservicemanager / storageservicetabwidget.cpp
blobd57fb89592a212a658c468f0ea599511afae8c41
1 /*
2 Copyright (c) 2013-2015 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 "storageservicetabwidget.h"
22 #include "storageservicepage.h"
23 #include "pimcommon/storageserviceabstract.h"
25 #include <QMap>
27 StorageServiceTabWidget::StorageServiceTabWidget(QWidget *parent)
28 : QTabWidget(parent)
30 setMovable(true);
33 StorageServiceTabWidget::~StorageServiceTabWidget()
38 void StorageServiceTabWidget::updateListService(const QMap<QString, PimCommon::StorageServiceAbstract *> &list)
40 QMapIterator<QString, PimCommon::StorageServiceAbstract *> i(list);
41 while (i.hasNext()) {
42 i.next();
43 bool foundPage = false;
44 StorageServicePage *page = 0;
45 for (int nbPage = 0; nbPage < count(); ++nbPage) {
46 page = static_cast<StorageServicePage *>(widget(nbPage));
47 if (i.value()->storageServiceName() == page->serviceName()) {
48 foundPage = true;
49 break;
52 if (!foundPage) {
53 createPage(i.key(), i.value());
54 } else {
55 if (page) {
56 page->refreshList();
60 Q_EMIT tabCountChanged(count() > 0);
63 void StorageServiceTabWidget::setListStorageService(const QMap<QString, PimCommon::StorageServiceAbstract *> &list)
65 QMapIterator<QString, PimCommon::StorageServiceAbstract *> i(list);
66 while (i.hasNext()) {
67 i.next();
68 createPage(i.key(), i.value());
70 Q_EMIT tabCountChanged(count() > 0);
73 void StorageServiceTabWidget::createPage(const QString &name, PimCommon::StorageServiceAbstract *service)
75 StorageServicePage *page = new StorageServicePage(name, service);
76 connect(page, &StorageServicePage::updateIcon, this, &StorageServiceTabWidget::slotUpdateIcon);
77 connect(page, &StorageServicePage::updateStatusBarMessage, this, &StorageServiceTabWidget::updateStatusBarMessage);
78 connect(page, &StorageServicePage::listFileWasInitialized, this, &StorageServiceTabWidget::listFileWasInitialized);
79 connect(page, &StorageServicePage::selectionChanged, this, &StorageServiceTabWidget::selectionChanged);
80 addTab(page, name);
83 void StorageServiceTabWidget::slotUpdateIcon(const QIcon &icon, StorageServicePage *page)
85 if (page) {
86 const int index = indexOf(page);
87 if (index != -1) {
88 setTabIcon(index, icon);
93 void StorageServiceTabWidget::slotAuthenticate()
95 if (currentWidget()) {
96 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
97 if (page) {
98 page->authenticate();
103 void StorageServiceTabWidget::slotCreateFolder()
105 if (currentWidget()) {
106 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
107 if (page) {
108 page->createFolder();
113 void StorageServiceTabWidget::slotRefreshList()
115 if (currentWidget()) {
116 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
117 if (page) {
118 page->refreshList();
123 void StorageServiceTabWidget::slotAccountInfo()
125 if (currentWidget()) {
126 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
127 if (page) {
128 page->accountInfo();
133 void StorageServiceTabWidget::slotUploadFile()
135 if (currentWidget()) {
136 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
137 if (page) {
138 page->slotUploadFile();
143 void StorageServiceTabWidget::slotDelete()
145 if (currentWidget()) {
146 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
147 if (page) {
148 page->deleteItem();
153 void StorageServiceTabWidget::slotDownloadFile()
155 if (currentWidget()) {
156 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
157 if (page) {
158 page->downloadFile();
163 PimCommon::StorageServiceAbstract::Capabilities StorageServiceTabWidget::capabilities() const
165 if (currentWidget()) {
166 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
167 if (page) {
168 return page->capabilities();
171 return PimCommon::StorageServiceAbstract::NoCapability;
174 bool StorageServiceTabWidget::listFolderWasLoaded() const
176 if (currentWidget()) {
177 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
178 if (page) {
179 return page->listFolderWasLoaded();
182 return false;
185 bool StorageServiceTabWidget::hasUploadDownloadProgress() const
187 for (int i = 0; i < count(); ++i) {
188 StorageServicePage *page = static_cast<StorageServicePage *>(widget(i));
189 if (page) {
190 if (page->hasUploadDownloadProgress()) {
191 return true;
195 return false;
198 void StorageServiceTabWidget::serviceRemoved(const QString &serviceName)
200 for (int nbPage = 0; nbPage < count(); ++nbPage) {
201 StorageServicePage *page = static_cast<StorageServicePage *>(widget(nbPage));
202 if (page->serviceName() == serviceName) {
203 //removeTab(nbPage);
204 delete widget(nbPage);
205 Q_EMIT tabCountChanged(count() > 0);
206 break;
211 void StorageServiceTabWidget::setNetworkIsDown(bool state)
213 for (int i = 0; i < count(); ++i) {
214 StorageServicePage *page = static_cast<StorageServicePage *>(widget(i));
215 if (page) {
216 page->setNetworkIsDown(state);
221 void StorageServiceTabWidget::slotShowLog()
223 if (currentWidget()) {
224 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
225 if (page) {
226 page->showLog();
231 void StorageServiceTabWidget::logout()
233 if (currentWidget()) {
234 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
235 if (page) {
236 page->logout();
241 void StorageServiceTabWidget::shutdownAllServices()
243 for (int i = 0; i < count(); ++i) {
244 StorageServicePage *page = static_cast<StorageServicePage *>(widget(i));
245 if (page) {
246 page->logout();
251 void StorageServiceTabWidget::refreshAll()
253 for (int i = 0; i < count(); ++i) {
254 StorageServicePage *page = static_cast<StorageServicePage *>(widget(i));
255 if (page) {
256 page->refreshList();
261 PimCommon::StorageServiceTreeWidget::ItemType StorageServiceTabWidget::itemTypeSelected() const
263 if (currentWidget()) {
264 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
265 if (page) {
266 return page->itemTypeSelected();
269 return PimCommon::StorageServiceTreeWidget::UnKnown;
272 void StorageServiceTabWidget::slotRename()
274 if (currentWidget()) {
275 StorageServicePage *page = static_cast<StorageServicePage *>(currentWidget());
276 if (page) {
277 page->renameItem();