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
16class Q_DECL_HIDDEN CloudRoutesDialog::Private : public Ui::CloudRoutesDialog {
17 public:
18 explicit Private( CloudRouteModel *model );
19 CloudRouteModel *m_model;
20};
21
22CloudRoutesDialog::Private::Private( CloudRouteModel *model ) : Ui::CloudRoutesDialog(),
23 m_model( model )
24{
25}
26
27CloudRoutesDialog::CloudRoutesDialog( CloudRouteModel *model, QWidget *parent ) : QDialog( parent ),
28 d( new Private( model ) )
29{
30 d->setupUi( this );
31
32 RouteItemDelegate *delegate = new RouteItemDelegate( d->listView, d->m_model );
33 connect( delegate, SIGNAL(downloadButtonClicked(QString)), this, SIGNAL(downloadButtonClicked(QString)) );
34 connect( delegate, SIGNAL(openButtonClicked(QString)), this, SIGNAL(openButtonClicked(QString)) );
35 connect( delegate, SIGNAL(deleteButtonClicked(QString)), this, SIGNAL(deleteButtonClicked(QString)) );
36 connect( delegate, SIGNAL(removeFromCacheButtonClicked(QString)), this, SIGNAL(removeFromCacheButtonClicked(QString)) );
37 connect( delegate, SIGNAL(uploadToCloudButtonClicked(QString)), this, SIGNAL(uploadToCloudButtonClicked(QString)) );
38 connect( d->m_model, SIGNAL(modelReset()), this, SLOT(updateNoRouteLabel()) );
39
40 d->progressBar->setHidden( true );
41 d->labelNoRoute->setHidden( true );
42
43 d->listView->setItemDelegate( delegate );
44 d->listView->setModel( d->m_model );
45}
46
47CloudRoutesDialog::~CloudRoutesDialog()
48{
49 delete d;
50}
51
52CloudRouteModel* CloudRoutesDialog::model()
53{
54 return d->m_model;
55}
56
57void CloudRoutesDialog::updateListDownloadProgressbar( qint64 received, qint64 total )
58{
59 d->progressBar->setHidden( false );
60 d->progressBar->setValue( qRound( 100.0 * qreal( received ) / total ) );
61 if( received == total ) {
62 QTimer::singleShot( 1000, d->progressBar, SLOT(hide()) );
63 }
64}
65
66void CloudRoutesDialog::updateNoRouteLabel() {
67 bool const isEmpty = d->listView->model()->rowCount() == 0;
68 d->listView->setHidden( isEmpty );
69 d->labelNoRoute->setVisible( isEmpty );
70}
71
72}
73
74#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 Fri May 17 2024 11:49:23 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.