Marble

CloudRoutesDialog.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Utku Aydın <utkuaydin34@gmail.com>
4//
5
6#include "CloudRoutesDialog.h"
7#include "ui_CloudRoutesDialog.h"
8
9#include "CloudRouteModel.h"
10#include "RouteItemDelegate.h"
11
12#include <QTimer>
13
14namespace Marble
15{
16
17class Q_DECL_HIDDEN CloudRoutesDialog::Private : public Ui::CloudRoutesDialog
18{
19public:
20 explicit Private(CloudRouteModel *model);
21 CloudRouteModel *const m_model;
22};
23
24CloudRoutesDialog::Private::Private(CloudRouteModel *model)
25 : Ui::CloudRoutesDialog()
26 , m_model(model)
27{
28}
29
30CloudRoutesDialog::CloudRoutesDialog(CloudRouteModel *model, QWidget *parent)
31 : QDialog(parent)
32 , d(new Private(model))
33{
34 d->setupUi(this);
35
36 auto delegate = new RouteItemDelegate(d->listView, d->m_model);
37 connect(delegate, &RouteItemDelegate::downloadButtonClicked, this, &CloudRoutesDialog::downloadButtonClicked);
38 connect(delegate, &RouteItemDelegate::openButtonClicked, this, &CloudRoutesDialog::openButtonClicked);
39 connect(delegate, &RouteItemDelegate::deleteButtonClicked, this, &CloudRoutesDialog::deleteButtonClicked);
40 connect(delegate, &RouteItemDelegate::removeFromCacheButtonClicked, this, &CloudRoutesDialog::removeFromCacheButtonClicked);
41 connect(delegate, &RouteItemDelegate::uploadToCloudButtonClicked, this, &CloudRoutesDialog::uploadToCloudButtonClicked);
42 connect(d->m_model, &QAbstractItemModel::modelReset, this, &CloudRoutesDialog::updateNoRouteLabel);
43
44 d->progressBar->setHidden(true);
45 d->labelNoRoute->setHidden(true);
46
47 d->listView->setItemDelegate(delegate);
48 d->listView->setModel(d->m_model);
49}
50
51CloudRoutesDialog::~CloudRoutesDialog()
52{
53 delete d;
54}
55
56CloudRouteModel *CloudRoutesDialog::model()
57{
58 return d->m_model;
59}
60
61void CloudRoutesDialog::updateListDownloadProgressbar(qint64 received, qint64 total)
62{
63 d->progressBar->setHidden(false);
64 d->progressBar->setValue(qRound(100.0 * qreal(received) / total));
65 if (received == total) {
66 QTimer::singleShot(1000, d->progressBar, &CloudRoutesDialog::hide);
67 }
68}
69
70void CloudRoutesDialog::updateNoRouteLabel()
71{
72 bool const isEmpty = d->listView->model()->rowCount() == 0;
73 d->listView->setHidden(isEmpty);
74 d->labelNoRoute->setVisible(isEmpty);
75}
76
77}
78
79#include "moc_CloudRoutesDialog.cpp"
Binds a QML item to a specific geodetic location in screen coordinates.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
void setupUi(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:45 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.