Skip to content
Permalink
Browse files

Minor refactor of temporal controller dock widget

- Split widget from dock widget for flexibility
- Move dock widget class to app and only expose QgsTemporalControllWidget in public api
  • Loading branch information
nyalldawson committed Mar 12, 2020
1 parent 7d58725 commit c040952354d7ba3b4e0152b92280bfbf229fc1cf
@@ -1,7 +1,7 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgstemporalcontrollerdockwidget.h *
* src/gui/qgstemporalcontrollerwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -11,22 +11,22 @@



class QgsTemporalControllerDockWidget : QgsDockWidget
class QgsTemporalControllerWidget : QgsPanelWidget
{
%Docstring
The QgsTemporalControllerDockWidget class
A widget for controlling playback properties of a QgsTemporalController.

.. versionadded:: 3.14
%End

%TypeHeaderCode
#include "qgstemporalcontrollerdockwidget.h"
#include "qgstemporalcontrollerwidget.h"
%End
public:

QgsTemporalControllerDockWidget( const QString &name, QWidget *parent /TransferThis/ = 0 );
QgsTemporalControllerWidget( QWidget *parent /TransferThis/ = 0 );
%Docstring
Constructor for QgsTemporalControllerDockWidget, with the specified ``parent`` widget.
Constructor for QgsTemporalControllerWidget, with the specified ``parent`` widget.
%End

QgsTemporalController *temporalController();
@@ -41,7 +41,7 @@ The dock widget retains ownership of the returned object.
/************************************************************************
* This file has been generated automatically from *
* *
* src/gui/qgstemporalcontrollerdockwidget.h *
* src/gui/qgstemporalcontrollerwidget.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -197,7 +197,7 @@
%Include auto_generated/qgstablewidgetitem.sip
%Include auto_generated/qgstabwidget.sip
%Include auto_generated/qgstaskmanagerwidget.sip
%Include auto_generated/qgstemporalcontrollerdockwidget.sip
%Include auto_generated/qgstemporalcontrollerwidget.sip
%Include auto_generated/qgstextformatwidget.sip
%Include auto_generated/qgstextpreview.sip
%Include auto_generated/qgstreewidgetitem.sip
@@ -61,6 +61,7 @@ SET(QGIS_APP_SRCS
qgsstatusbarmagnifierwidget.cpp
qgsstatusbarscalewidget.cpp
qgstemplateprojectsmodel.cpp
qgstemporalcontrollerdockwidget.cpp
qgsversioninfo.cpp
qgsrecentprojectsitemsmodel.cpp
qgsvectorlayerdigitizingproperties.cpp
@@ -0,0 +1,33 @@
/***************************************************************************
qgstemporalcontrollerdockwidget.cpp
------------------------------
begin : February 2020
copyright : (C) 2020 by Samweli Mwakisambwe
email : samweli at kartoza dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgstemporalcontrollerdockwidget.h"
#include "qgstemporalcontrollerwidget.h"

QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString &name, QWidget *parent )
: QgsDockWidget( parent )
{
setWindowTitle( name );
mControllerWidget = new QgsTemporalControllerWidget();

setWidget( mControllerWidget );
}

QgsTemporalController *QgsTemporalControllerDockWidget::temporalController()
{
return mControllerWidget->temporalController();
}
@@ -0,0 +1,57 @@
/***************************************************************************
qgstemporalcontrollerdockwidget.h
---------------
begin : February 2020
copyright : (C) 2020 by Samweli Mwakisambwe
email : samweli at kartoza dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSTEMPORALCONTROLLERDOCKWIDGET_H
#define QGSTEMPORALCONTROLLERDOCKWIDGET_H

#include "qgsdockwidget.h"
#include "qgis_app.h"

class QgsTemporalControllerWidget;
class QgsTemporalController;

/**
* \ingroup app
* The QgsTemporalControllerDockWidget class
*
* \since QGIS 3.14
*/
class APP_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget
{
Q_OBJECT
public:

/**
* Constructor for QgsTemporalControllerDockWidget, with the specified \a parent widget.
*/
QgsTemporalControllerDockWidget( const QString &name, QWidget *parent SIP_TRANSFERTHIS = nullptr );

/**
* Returns the temporal controller object used by this object in navigation.
*
* The dock widget retains ownership of the returned object.
*/
QgsTemporalController *temporalController();

private:

QgsTemporalControllerWidget *mControllerWidget = nullptr;


};

#endif // QGSTEMPORALCONTROLLERDOCKWIDGET_H
@@ -507,7 +507,7 @@ SET(QGIS_GUI_SRCS
qgstaskmanagerwidget.cpp
qgstemporalmapsettingsdialog.cpp
qgstemporalmapsettingswidget.cpp
qgstemporalcontrollerdockwidget.cpp
qgstemporalcontrollerwidget.cpp
qgstextformatwidget.cpp
qgstextpreview.cpp
qgstreewidgetitem.cpp
@@ -731,7 +731,7 @@ SET(QGIS_GUI_HDRS
qgstaskmanagerwidget.h
qgstemporalmapsettingsdialog.h
qgstemporalmapsettingswidget.h
qgstemporalcontrollerdockwidget.h
qgstemporalcontrollerwidget.h
qgstextformatwidget.h
qgstextpreview.h
qgstreewidgetitem.h
@@ -1,5 +1,5 @@
/***************************************************************************
qgstemporalcontrollerdockwidget.cpp
qgstemporalcontrollerwidget.cpp
------------------------------
begin : February 2020
copyright : (C) 2020 by Samweli Mwakisambwe
@@ -15,7 +15,7 @@
* *
***************************************************************************/

#include "qgstemporalcontrollerdockwidget.h"
#include "qgstemporalcontrollerwidget.h"
#include "qgsgui.h"
#include "qgsproject.h"
#include "qgsprojecttimesettings.h"
@@ -24,11 +24,10 @@

#include "qgstemporalmapsettingsdialog.h"

QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString &name, QWidget *parent )
: QgsDockWidget( parent )
QgsTemporalControllerWidget::QgsTemporalControllerWidget( QWidget *parent )
: QgsPanelWidget( parent )
{
setupUi( this );
setWindowTitle( name );

mNavigationObject = new QgsTemporalNavigationObject( this );

@@ -48,16 +47,16 @@ QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString
mStopButton->setChecked( state == QgsTemporalNavigationObject::Idle );
} );

connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerDockWidget::updateTemporalExtent );
connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerDockWidget::updateTemporalExtent );
connect( mSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsTemporalControllerDockWidget::updateFrameDuration );
connect( mTimeStepsComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsTemporalControllerDockWidget::updateFrameDuration );
connect( mSlider, &QSlider::valueChanged, this, &QgsTemporalControllerDockWidget::timeSlider_valueChanged );
connect( mStartDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerWidget::updateTemporalExtent );
connect( mEndDateTime, &QDateTimeEdit::dateTimeChanged, this, &QgsTemporalControllerWidget::updateTemporalExtent );
connect( mSpinBox, qgis::overload<double>::of( &QDoubleSpinBox::valueChanged ), this, &QgsTemporalControllerWidget::updateFrameDuration );
connect( mTimeStepsComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsTemporalControllerWidget::updateFrameDuration );
connect( mSlider, &QSlider::valueChanged, this, &QgsTemporalControllerWidget::timeSlider_valueChanged );

connect( mNavigationObject, &QgsTemporalNavigationObject::updateTemporalRange, this, &QgsTemporalControllerDockWidget::updateSlider );
connect( mNavigationObject, &QgsTemporalNavigationObject::updateTemporalRange, this, &QgsTemporalControllerWidget::updateSlider );

connect( mSettings, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::settings_clicked );
connect( mSetToProjectTimeButton, &QPushButton::clicked, this, &QgsTemporalControllerDockWidget::setDatesToProjectTime );
connect( mSettings, &QPushButton::clicked, this, &QgsTemporalControllerWidget::settings_clicked );
connect( mSetToProjectTimeButton, &QPushButton::clicked, this, &QgsTemporalControllerWidget::setDatesToProjectTime );

QgsDateTimeRange range;

@@ -110,10 +109,10 @@ QgsTemporalControllerDockWidget::QgsTemporalControllerDockWidget( const QString

updateFrameDuration();

connect( QgsProject::instance(), &QgsProject::readProject, this, &QgsTemporalControllerDockWidget::setWidgetStateFromProject );
connect( QgsProject::instance(), &QgsProject::readProject, this, &QgsTemporalControllerWidget::setWidgetStateFromProject );
}

void QgsTemporalControllerDockWidget::updateTemporalExtent()
void QgsTemporalControllerWidget::updateTemporalExtent()
{
QgsDateTimeRange temporalExtent = QgsDateTimeRange( mStartDateTime->dateTime(),
mEndDateTime->dateTime() );
@@ -122,7 +121,7 @@ void QgsTemporalControllerDockWidget::updateTemporalExtent()
mSlider->setValue( 0 );
}

void QgsTemporalControllerDockWidget::updateFrameDuration()
void QgsTemporalControllerWidget::updateFrameDuration()
{
if ( mBlockSettingUpdates )
return;
@@ -136,7 +135,7 @@ void QgsTemporalControllerDockWidget::updateFrameDuration()
mSlider->setRange( 0, mNavigationObject->totalFrameCount() - 1 );
}

void QgsTemporalControllerDockWidget::setWidgetStateFromProject()
void QgsTemporalControllerWidget::setWidgetStateFromProject()
{
mBlockSettingUpdates++;
mTimeStepsComboBox->setCurrentIndex( mTimeStepsComboBox->findData( QgsProject::instance()->timeSettings()->timeStepUnit() ) );
@@ -147,26 +146,26 @@ void QgsTemporalControllerDockWidget::setWidgetStateFromProject()
mNavigationObject->setFramesPerSecond( QgsProject::instance()->timeSettings()->framesPerSecond() );
}

void QgsTemporalControllerDockWidget::updateSlider( const QgsDateTimeRange &range )
void QgsTemporalControllerWidget::updateSlider( const QgsDateTimeRange &range )
{
whileBlocking( mSlider )->setValue( mNavigationObject->currentFrameNumber() );
updateRangeLabel( range );
}

void QgsTemporalControllerDockWidget::updateRangeLabel( const QgsDateTimeRange &range )
void QgsTemporalControllerWidget::updateRangeLabel( const QgsDateTimeRange &range )
{
QLocale locale;
mCurrentRangeLabel->setText( tr( "%1 to %2" ).arg(
range.begin().toString( locale.dateTimeFormat( QLocale::NarrowFormat ) ),
range.end().toString( locale.dateTimeFormat( QLocale::NarrowFormat ) ) ) );
}

QgsTemporalController *QgsTemporalControllerDockWidget::temporalController()
QgsTemporalController *QgsTemporalControllerWidget::temporalController()
{
return mNavigationObject;
}

void QgsTemporalControllerDockWidget::settings_clicked()
void QgsTemporalControllerWidget::settings_clicked()
{
QgsTemporalMapSettingsDialog dialog( this );
dialog.mapSettingsWidget()->setFrameRateValue( mNavigationObject->framesPerSecond() );
@@ -180,12 +179,12 @@ void QgsTemporalControllerDockWidget::settings_clicked()
}
}

void QgsTemporalControllerDockWidget::timeSlider_valueChanged( int value )
void QgsTemporalControllerWidget::timeSlider_valueChanged( int value )
{
mNavigationObject->setCurrentFrameNumber( value );
}

void QgsTemporalControllerDockWidget::setDatesToProjectTime()
void QgsTemporalControllerWidget::setDatesToProjectTime()
{
QgsDateTimeRange range;
if ( QgsProject::instance()->timeSettings() )
@@ -198,13 +197,13 @@ void QgsTemporalControllerDockWidget::setDatesToProjectTime()
}
}

void QgsTemporalControllerDockWidget::setDateInputsEnable( bool enabled )
void QgsTemporalControllerWidget::setDateInputsEnable( bool enabled )
{
mStartDateTime->setEnabled( enabled );
mEndDateTime->setEnabled( enabled );
}

void QgsTemporalControllerDockWidget::updateButtonsEnable( bool enabled )
void QgsTemporalControllerWidget::updateButtonsEnable( bool enabled )
{
mPreviousButton->setEnabled( enabled );
mNextButton->setEnabled( enabled );
@@ -1,5 +1,5 @@
/***************************************************************************
qgstemporalcontrollerdockwidget.h
qgstemporalcontrollerwidget.h
---------------
begin : February 2020
copyright : (C) 2020 by Samweli Mwakisambwe
@@ -15,37 +15,34 @@
* *
***************************************************************************/

#ifndef QGSTEMPORALCONTROLLERDOCKWIDGET_H
#define QGSTEMPORALCONTROLLERDOCKWIDGET_H
#ifndef QGSTEMPORALCONTROLLERWIDGET_H
#define QGSTEMPORALCONTROLLERWIDGET_H

#include "ui_qgstemporalcontrollerdockwidgetbase.h"
#include "ui_qgstemporalcontrollerwidgetbase.h"

#include "qgsdockwidget.h"
#include "qgis_gui.h"
#include "qgsrange.h"

class QgsMapLayer;
class QgsTemporalNavigationObject;
class QgsTemporalMapSettingsWidget;
class QgsTemporalMapSettingsDialog;
class QgsTemporalController;
class QgsInterval;

/**
* \ingroup gui
* The QgsTemporalControllerDockWidget class
* A widget for controlling playback properties of a QgsTemporalController.
*
* \since QGIS 3.14
*/
class GUI_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget, private Ui::QgsTemporalControllerDockWidgetBase
class GUI_EXPORT QgsTemporalControllerWidget : public QgsPanelWidget, private Ui::QgsTemporalControllerWidgetBase
{
Q_OBJECT
public:

/**
* Constructor for QgsTemporalControllerDockWidget, with the specified \a parent widget.
* Constructor for QgsTemporalControllerWidget, with the specified \a parent widget.
*/
QgsTemporalControllerDockWidget( const QString &name, QWidget *parent SIP_TRANSFERTHIS = nullptr );
QgsTemporalControllerWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr );

/**
* Returns the temporal controller object used by this object in navigation.
@@ -110,8 +107,6 @@ class GUI_EXPORT QgsTemporalControllerDockWidget : public QgsDockWidget, private
void updateFrameDuration();

void setWidgetStateFromProject();


};

#endif // QGSTEMPORALCONTROLLERDOCKWIDGET_H
#endif // QGSTEMPORALCONTROLLERWIDGET_H

0 comments on commit c040952

Please sign in to comment.
You can’t perform that action at this time.