From 834c630f54fd72d923882a2fb333fae677f8c35d Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 1 Sep 2014 10:28:48 +0200 Subject: [PATCH] added new QgsDateTimeEdit to custom widgets --- src/customwidgets/CMakeLists.txt | 3 + src/customwidgets/CMakeLists.txt.user | 63 +++++++++++++ src/customwidgets/qgsdatetimeeditplugin.cpp | 97 +++++++++++++++++++++ src/customwidgets/qgsdatetimeeditplugin.h | 48 ++++++++++ 4 files changed, 211 insertions(+) create mode 100644 src/customwidgets/CMakeLists.txt.user create mode 100644 src/customwidgets/qgsdatetimeeditplugin.cpp create mode 100644 src/customwidgets/qgsdatetimeeditplugin.h diff --git a/src/customwidgets/CMakeLists.txt b/src/customwidgets/CMakeLists.txt index 4ffe42a86a9..c6a02a91763 100644 --- a/src/customwidgets/CMakeLists.txt +++ b/src/customwidgets/CMakeLists.txt @@ -18,6 +18,7 @@ SET (QGIS_CUSTOMWIDGETS_SRCS qgscollapsiblegroupboxplugin.cpp qgscolorbuttonplugin.cpp qgscolorbuttonv2plugin.cpp + qgsdatetimeeditplugin.cpp qgsdatadefinedbuttonplugin.cpp qgsfieldcomboboxplugin.cpp qgsfieldexpressionwidgetplugin.cpp @@ -32,6 +33,7 @@ SET (QGIS_CUSTOMWIDGETS_MOC_HDRS qgscollapsiblegroupboxplugin.h qgscolorbuttonplugin.h qgscolorbuttonv2plugin.h + qgsdatetimeeditplugin.h qgsdatadefinedbuttonplugin.h qgsfieldcomboboxplugin.h qgsfieldexpressionwidgetplugin.h @@ -54,6 +56,7 @@ SET(QGIS_CUSTOMWIDGETS_HDRS qgscollapsiblegroupboxplugin.h qgscolorbuttonplugin.h qgscolorbuttonv2plugin.h + qgsdatetimeeditplugin.h qgsdatadefinedbuttonplugin.h qgsfieldcomboboxplugin.h qgsfieldexpressionwidgetplugin.h diff --git a/src/customwidgets/CMakeLists.txt.user b/src/customwidgets/CMakeLists.txt.user new file mode 100644 index 00000000000..84e2acc6420 --- /dev/null +++ b/src/customwidgets/CMakeLists.txt.user @@ -0,0 +1,63 @@ + + + + + + ProjectExplorer.Project.ActiveTarget + -1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + true + 1 + true + 0 + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.TargetCount + 0 + + + ProjectExplorer.Project.Updater.EnvironmentId + {316279e7-c793-4c38-a9aa-b021b7d95d28} + + + ProjectExplorer.Project.Updater.FileVersion + 15 + + diff --git a/src/customwidgets/qgsdatetimeeditplugin.cpp b/src/customwidgets/qgsdatetimeeditplugin.cpp new file mode 100644 index 00000000000..4a0bfddea3f --- /dev/null +++ b/src/customwidgets/qgsdatetimeeditplugin.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + qgsdatetimeeditplugin.cpp + -------------------------------------- + Date : 01.09.2014 + Copyright : (C) 2014 Denis Rouzaud + Email : denis.rouzaud@gmail.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 "qgiscustomwidgets.h" +#include "qgsdatetimeeditplugin.h" +#include "qgsdatetimeedit.h" + + +QgsDateTimeEditPlugin::QgsDateTimeEditPlugin( QObject *parent ) + : QObject( parent ) + , mInitialized( false ) +{ +} + + +QString QgsDateTimeEditPlugin::name() const +{ + return "QgsDateTimeEdit"; +} + +QString QgsDateTimeEditPlugin::group() const +{ + return QgisCustomWidgets::groupName(); +} + +QString QgsDateTimeEditPlugin::includeFile() const +{ + return "qgsdatetimeedit.h"; +} + +QIcon QgsDateTimeEditPlugin::icon() const +{ + return QIcon(); +} + +bool QgsDateTimeEditPlugin::isContainer() const +{ + return false; +} + +QWidget *QgsDateTimeEditPlugin::createWidget( QWidget *parent ) +{ + return new QgsDateTimeEdit( parent ); +} + +bool QgsDateTimeEditPlugin::isInitialized() const +{ + return mInitialized; +} + +void QgsDateTimeEditPlugin::initialize( QDesignerFormEditorInterface *core ) +{ + Q_UNUSED( core ); + if ( mInitialized ) + return; + mInitialized = true; +} + + +QString QgsDateTimeEditPlugin::toolTip() const +{ + return tr( "Define date" ); +} + +QString QgsDateTimeEditPlugin::whatsThis() const +{ + return ""; +} + +QString QgsDateTimeEditPlugin::domXml() const +{ + return QString( "\n" + " \n" + " \n" + " \n" + " 0\n" + " 0\n" + " 90\n" + " 27\n" + " \n" + " \n" + " \n" + "\n" ) + .arg( name() ); +} diff --git a/src/customwidgets/qgsdatetimeeditplugin.h b/src/customwidgets/qgsdatetimeeditplugin.h new file mode 100644 index 00000000000..b87be063d59 --- /dev/null +++ b/src/customwidgets/qgsdatetimeeditplugin.h @@ -0,0 +1,48 @@ +/*************************************************************************** + qgsdatetimeeditplugin.h + -------------------------------------- + Date : 01.09.2014 + Copyright : (C) 2014 Denis Rouzaud + Email : denis.rouzaud@gmail.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 QGSDATETIMEEDITPLUGIN_H +#define QGSDATETIMEEDITPLUGIN_H + +#include +#include + + +class CUSTOMWIDGETS_EXPORT QgsDateTimeEditPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES( QDesignerCustomWidgetInterface ) + + public: + explicit QgsDateTimeEditPlugin( QObject *parent = 0 ); + + private: + bool mInitialized; + + // QDesignerCustomWidgetInterface interface + public: + QString name() const; + QString group() const; + QString includeFile() const; + QIcon icon() const; + bool isContainer() const; + QWidget *createWidget( QWidget *parent ); + bool isInitialized() const; + void initialize( QDesignerFormEditorInterface *core ); + QString toolTip() const; + QString whatsThis() const; + QString domXml() const; +}; +#endif // QGSDATETIMEEDITPLUGIN_H