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
21 #include "storageservicetabwidget.h"
22 #include "storageservicepage.h"
23 #include "pimcommon/storageserviceabstract.h"
27 StorageServiceTabWidget::StorageServiceTabWidget(QWidget
*parent
)
33 StorageServiceTabWidget::~StorageServiceTabWidget()
38 void StorageServiceTabWidget::updateListService(const QMap
<QString
, PimCommon::StorageServiceAbstract
*> &list
)
40 QMapIterator
<QString
, PimCommon::StorageServiceAbstract
*> i(list
);
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()) {
53 createPage(i
.key(), i
.value());
60 Q_EMIT
tabCountChanged(count() > 0);
63 void StorageServiceTabWidget::setListStorageService(const QMap
<QString
, PimCommon::StorageServiceAbstract
*> &list
)
65 QMapIterator
<QString
, PimCommon::StorageServiceAbstract
*> i(list
);
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
);
83 void StorageServiceTabWidget::slotUpdateIcon(const QIcon
&icon
, StorageServicePage
*page
)
86 const int index
= indexOf(page
);
88 setTabIcon(index
, icon
);
93 void StorageServiceTabWidget::slotAuthenticate()
95 if (currentWidget()) {
96 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
103 void StorageServiceTabWidget::slotCreateFolder()
105 if (currentWidget()) {
106 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
108 page
->createFolder();
113 void StorageServiceTabWidget::slotRefreshList()
115 if (currentWidget()) {
116 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
123 void StorageServiceTabWidget::slotAccountInfo()
125 if (currentWidget()) {
126 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
133 void StorageServiceTabWidget::slotUploadFile()
135 if (currentWidget()) {
136 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
138 page
->slotUploadFile();
143 void StorageServiceTabWidget::slotDelete()
145 if (currentWidget()) {
146 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
153 void StorageServiceTabWidget::slotDownloadFile()
155 if (currentWidget()) {
156 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
158 page
->downloadFile();
163 PimCommon::StorageServiceAbstract::Capabilities
StorageServiceTabWidget::capabilities() const
165 if (currentWidget()) {
166 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
168 return page
->capabilities();
171 return PimCommon::StorageServiceAbstract::NoCapability
;
174 bool StorageServiceTabWidget::listFolderWasLoaded() const
176 if (currentWidget()) {
177 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
179 return page
->listFolderWasLoaded();
185 bool StorageServiceTabWidget::hasUploadDownloadProgress() const
187 for (int i
= 0; i
< count(); ++i
) {
188 StorageServicePage
*page
= static_cast<StorageServicePage
*>(widget(i
));
190 if (page
->hasUploadDownloadProgress()) {
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
) {
204 delete widget(nbPage
);
205 Q_EMIT
tabCountChanged(count() > 0);
211 void StorageServiceTabWidget::setNetworkIsDown(bool state
)
213 for (int i
= 0; i
< count(); ++i
) {
214 StorageServicePage
*page
= static_cast<StorageServicePage
*>(widget(i
));
216 page
->setNetworkIsDown(state
);
221 void StorageServiceTabWidget::slotShowLog()
223 if (currentWidget()) {
224 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
231 void StorageServiceTabWidget::logout()
233 if (currentWidget()) {
234 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
241 void StorageServiceTabWidget::shutdownAllServices()
243 for (int i
= 0; i
< count(); ++i
) {
244 StorageServicePage
*page
= static_cast<StorageServicePage
*>(widget(i
));
251 void StorageServiceTabWidget::refreshAll()
253 for (int i
= 0; i
< count(); ++i
) {
254 StorageServicePage
*page
= static_cast<StorageServicePage
*>(widget(i
));
261 PimCommon::StorageServiceTreeWidget::ItemType
StorageServiceTabWidget::itemTypeSelected() const
263 if (currentWidget()) {
264 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());
266 return page
->itemTypeSelected();
269 return PimCommon::StorageServiceTreeWidget::UnKnown
;
272 void StorageServiceTabWidget::slotRename()
274 if (currentWidget()) {
275 StorageServicePage
*page
= static_cast<StorageServicePage
*>(currentWidget());