Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[nemo-qml-plugin-calendar] Port to Qt 5
  • Loading branch information
martinjones committed May 22, 2013
1 parent 4b92ec2 commit 79acf2e
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 11 deletions.
58 changes: 58 additions & 0 deletions rpm/nemo-qml-plugin-calendar-qt5.spec
@@ -0,0 +1,58 @@
#
# Do NOT Edit the Auto-generated Part!
# Generated by: spectacle version 0.26
#

Name: nemo-qml-plugin-calendar-qt5

# >> macros
# << macros

Summary: Calendar plugin for Nemo Mobile
Version: 0.0.0
Release: 1
Group: System/Libraries
License: BSD
URL: https://github.com/nemomobile/nemo-qml-plugin-calendar
Source0: %{name}-%{version}.tar.bz2
Source100: nemo-qml-plugin-calendar-qt5.yaml
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Qml)
BuildRequires: pkgconfig(libmkcal-qt5)
BuildRequires: pkgconfig(libkcalcoren-qt5)

%description
%{summary}.

%prep
%setup -q -n %{name}-%{version}

# >> setup
# << setup

%build
# >> build pre
# << build pre

%qmake5

make %{?jobs:-j%jobs}

# >> build post
# << build post

%install
rm -rf %{buildroot}
# >> install pre
# << install pre
%qmake_install

# >> install post
# << install post

%files
%defattr(-,root,root,-)
%{_libdir}/qt5/qml/org/nemomobile/calendar/libnemocalendar.so
%{_libdir}/qt5/qml/org/nemomobile/calendar/qmldir
# >> files
# << files
20 changes: 20 additions & 0 deletions rpm/nemo-qml-plugin-calendar-qt5.yaml
@@ -0,0 +1,20 @@
Name: nemo-qml-plugin-calendar-qt5
Summary: Calendar plugin for Nemo Mobile
URL: https://github.com/nemomobile/nemo-qml-plugin-calendar
Group: System/Libraries
Description: "%{summary}."
Version: 0.0.0
Release: 1
Sources:
- "%{name}-%{version}.tar.bz2"
License: BSD
Configure: none
Builder: qmake5
PkgConfigBR:
- Qt5Core
- Qt5Qml
- libmkcal-qt5
- libkcalcoren-qt5
Files:
- "%{_libdir}/qt5/qml/org/nemomobile/calendar/libnemocalendar.so"
- "%{_libdir}/qt5/qml/org/nemomobile/calendar/qmldir"
19 changes: 14 additions & 5 deletions src/calendaragendamodel.cpp
Expand Up @@ -44,11 +44,13 @@
NemoCalendarAgendaModel::NemoCalendarAgendaModel(QObject *parent)
: NemoCalendarAbstractModel(parent)
{
QHash<int,QByteArray> roles;
roles[EventObjectRole] = "event";
roles[SectionBucketRole] = "sectionBucket";
roles[NotebookColorRole] = "notebookColor";
setRoleNames(roles);
mRoleNames[EventObjectRole] = "event";
mRoleNames[SectionBucketRole] = "sectionBucket";
mRoleNames[NotebookColorRole] = "notebookColor";

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
setRoleNames(mRoleNames);
#endif

connect(this, SIGNAL(startDateChanged()), this, SLOT(load()));
connect(NemoCalendarEventCache::instance(), SIGNAL(modelReset()), this, SLOT(load()));
Expand All @@ -59,6 +61,13 @@ NemoCalendarAgendaModel::~NemoCalendarAgendaModel()
qDeleteAll(mEvents);
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
QHash<int, QByteArray> NemoCalendarAgendaModel::roleNames() const
{
return mRoleNames;
}
#endif

QDate NemoCalendarAgendaModel::startDate() const
{
return mStartDate;
Expand Down
6 changes: 6 additions & 0 deletions src/calendaragendamodel.h
Expand Up @@ -62,12 +62,18 @@ class NemoCalendarAgendaModel : public NemoCalendarAbstractModel
signals:
void startDateChanged();

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
protected:
virtual QHash<int, QByteArray> roleNames() const;
#endif

private slots:
void load();

private:
QDate mStartDate;
QList<NemoCalendarEvent *> mEvents;
QHash<int,QByteArray> mRoleNames;
};

#endif // CALENDARAGENDAMODEL_H
23 changes: 21 additions & 2 deletions src/plugin.cpp
Expand Up @@ -30,14 +30,29 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/

#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/QDeclarativeExtensionPlugin>
#include <QtGlobal>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
# include <QtQml>
# include <QQmlEngine>
# include <QQmlExtensionPlugin>
# define QDeclarativeEngine QQmlEngine
# define QDeclarativeExtensionPlugin QQmlExtensionPlugin
#else
# include <QtDeclarative/qdeclarative.h>
# include <QtDeclarative/QDeclarativeExtensionPlugin>
#endif


#include "calendarevent.h"
#include "calendaragendamodel.h"

class Q_DECL_EXPORT NemoCalendarPlugin : public QDeclarativeExtensionPlugin
{
Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
Q_PLUGIN_METADATA(IID "org.nemomobile.calendar")
#endif
public:
void registerTypes(const char *uri)
{
Expand All @@ -47,4 +62,8 @@ class Q_DECL_EXPORT NemoCalendarPlugin : public QDeclarativeExtensionPlugin
}
};

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(nemocalendar, NemoCalendarPlugin);
#endif

#include "plugin.moc"
13 changes: 9 additions & 4 deletions src/src.pro
Expand Up @@ -3,17 +3,22 @@ PLUGIN_IMPORT_PATH = org/nemomobile/calendar

TEMPLATE = lib
CONFIG += qt plugin hide_symbols
QT += declarative
equals(QT_MAJOR_VERSION, 4): QT += declarative
equals(QT_MAJOR_VERSION, 5): QT += qml

target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
QT -= gui

equals(QT_MAJOR_VERSION, 4): target.path = $$[QT_INSTALL_IMPORTS]/$$PLUGIN_IMPORT_PATH
equals(QT_MAJOR_VERSION, 5): target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
INSTALLS += target

qmldir.files += $$_PRO_FILE_PWD_/qmldir
qmldir.path += $$[QT_INSTALL_IMPORTS]/$$$$PLUGIN_IMPORT_PATH
qmldir.path += $$target.path
INSTALLS += qmldir

CONFIG += link_pkgconfig
PKGCONFIG += libkcalcoren libmkcal
equals(QT_MAJOR_VERSION, 4): PKGCONFIG += libkcalcoren libmkcal
equals(QT_MAJOR_VERSION, 5): PKGCONFIG += libkcalcoren-qt5 libmkcal-qt5

SOURCES += \
plugin.cpp \
Expand Down

0 comments on commit 79acf2e

Please sign in to comment.