I have made the following changes intended for : CE:MW:Shared / libcommhistory
Please review and accept or decline. BOSS has already run some checks on this request. See the "Messages from BOSS" section below. https://build.pub.meego.com//request/show/7119 Thank You, John Brooks [This message was auto-generated] --- Request # 7119: Messages from BOSS: State: review at 2012-10-23T14:17:32 by bossbot Reviews: accepted by bossbot : Prechecks succeeded. new for CE-maintainers : Please replace this text with a review and approve/reject the review (not the SR). BOSS will take care of the rest Changes: submit: home:special:branches:CE:MW:Shared / libcommhistory -> CE:MW:Shared / libcommhistory changes files: -------------- --- libcommhistory.changes +++ libcommhistory.changes @@ -0,0 +1,5 @@ +* Tue Oct 23 2012 John Brooks <[email protected]> - 1.4.3 +- Added group objects to the declarative API +- Changed GroupModel to provide basic QML API +- Upstreamed libcommhistory-1.4.0-build-against-tracker-0-14.patch + old: ---- libcommhistory-1.4.0-build-against-tracker-0-14.patch libcommhistory-1.4.2.tar.gz new: ---- libcommhistory-1.4.3.tar.gz spec files: ----------- --- libcommhistory.spec +++ libcommhistory.spec @@ -1,13 +1,12 @@ Name: libcommhistory Summary: Communications event history database API -Version: 1.4.2 +Version: 1.4.3 Release: 1 Group: System/Libraries License: LGPL URL: https://github.com/nemomobile/libcommhistory Source0: %{name}-%{version}.tar.gz Patch0: libcommhistory-1.3.12.6-fix-shared-static-lib-build-order.patch -Patch1: libcommhistory-1.4.0-build-against-tracker-0-14.patch BuildRequires: libqtcontacts-tracker-extensions-devel BuildRequires: pkgconfig(QtCore) >= 4.7.0 BuildRequires: pkgconfig(QtContacts) @@ -62,7 +61,6 @@ %setup -q -n %{name}-%{version} %patch0 -p1 -%patch1 -p1 %build unset LD_AS_NEEDED other changes: -------------- ++++++ libcommhistory-1.4.2.tar.gz -> libcommhistory-1.4.3.tar.gz --- declarative/declarative.pro +++ declarative/declarative.pro @@ -10,10 +10,14 @@ INCLUDEPATH += ../src SOURCES += src/plugin.cpp \ - src/callproxymodel.cpp + src/callproxymodel.cpp \ + src/groupobject.cpp \ + src/groupproxymodel.cpp HEADERS += src/constants.h \ - src/callproxymodel.h + src/callproxymodel.h \ + src/groupobject.h \ + src/groupproxymodel.h # do not edit below here, move this to a shared .pri? TEMPLATE = lib --- declarative/src/groupobject.cpp +++ declarative/src/groupobject.cpp @@ -0,0 +1,112 @@ +/* Copyright (C) 2012 John Brooks <[email protected]> + * + * You may use this file under the terms of the BSD license as follows: + * + * "Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + */ + +#include "groupobject.h" +#include "groupmodel.h" + +using namespace CommHistory; + +GroupObject::GroupObject(QObject *parent) + : QObject(parent), model(0) +{ +} + +GroupObject::GroupObject(const Group &group, QAbstractItemModel *parent) + : QObject(parent), Group(group), model(parent) +{ + connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), + SLOT(modelDataChanged(QModelIndex,QModelIndex))); + connect(model, SIGNAL(rowsRemoved(QModelIndex,int,int)), + SLOT(modelRowsRemoved(QModelIndex,int,int))); +} + +void GroupObject::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +{ + Q_ASSERT(topLeft.parent() == bottomRight.parent()); + + for (int r = topLeft.row(); r <= bottomRight.row(); r++) { + const Group &g = model->index(r, 0, topLeft.parent()).data(GroupModel::GroupRole).value<Group>(); + + if (g.id() != id()) + continue; + + Group old(static_cast<Group&>(*this)); + Group::operator=(g); + + if (old.localUid() != localUid()) + emit localUidChanged(); + if (old.remoteUids() != remoteUids()) + emit remoteUidsChanged(); + if (old.chatType() != chatType()) + emit chatTypeChanged(); + if (old.chatName() != chatName()) + emit chatNameChanged(); + if (old.startTime() != startTime()) + emit startTimeChanged(); + if (old.endTime() != endTime()) + emit endTimeChanged(); + if (old.totalMessages() != totalMessages()) + emit totalMessagesChanged(); + if (old.unreadMessages() != unreadMessages()) + emit unreadMessagesChanged(); + if (old.sentMessages() != sentMessages()) + emit sentMessagesChanged(); + if (old.lastEventId() != lastEventId()) + emit lastEventIdChanged(); + if (old.contacts() != contacts()) + emit contactsChanged(); + if (old.lastMessageText() != lastMessageText()) + emit lastMessageTextChanged(); + if (old.lastVCardFileName() != lastVCardFileName()) + emit lastVCardFileNameChanged(); + if (old.lastVCardLabel() != lastVCardLabel()) + emit lastVCardLabelChanged(); + if (old.lastEventStatus() != lastEventStatus()) + emit lastEventStatusChanged(); + if (old.lastModified() != lastModified()) + emit lastModifiedChanged(); + + break; + } +} + +void GroupObject::modelRowsRemoved(const QModelIndex &parent, int start, int end) +{ + for (int r = start; r <= end; r++) { + QModelIndex index = model->index(r, GroupModel::GroupId, parent); + if (index.data().toInt() != id()) + continue; + + qDebug() << Q_FUNC_INFO << "group removed"; + emit groupRemoved(); + break; + } +} + --- declarative/src/groupobject.h +++ declarative/src/groupobject.h @@ -0,0 +1,123 @@ +/* Copyright (C) 2012 John Brooks <[email protected]> + * + * You may use this file under the terms of the BSD license as follows: + * + * "Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + */ + +#ifndef COMMHISTORY_DECLARATIVE_GROUP_H +#define COMMHISTORY_DECLARATIVE_GROUP_H + +#include <QObject> +#include "group.h" + +class QAbstractItemModel; +class QModelIndex; + +class GroupObject : public QObject, CommHistory::Group +{ + Q_OBJECT + Q_ENUMS(ChatType) + +public: + GroupObject(QObject *parent = 0); + GroupObject(const CommHistory::Group &group, QAbstractItemModel *parent = 0); + + Q_PROPERTY(bool isValid READ isValid CONSTANT); + Q_PROPERTY(int id READ id CONSTANT); + Q_PROPERTY(QString localUid READ localUid NOTIFY localUidChanged); + Q_PROPERTY(QStringList remoteUids READ remoteUids NOTIFY remoteUidsChanged); + Q_PROPERTY(int chatType READ chatType NOTIFY chatTypeChanged); + Q_PROPERTY(QString chatName READ chatName NOTIFY chatNameChanged); + Q_PROPERTY(QDateTime startTime READ startTime NOTIFY startTimeChanged); + Q_PROPERTY(QDateTime endTime READ endTime NOTIFY endTimeChanged); + Q_PROPERTY(int totalMessages READ totalMessages NOTIFY totalMessagesChanged); + Q_PROPERTY(int unreadMessages READ unreadMessages NOTIFY unreadMessagesChanged); + Q_PROPERTY(int sentMessages READ sentMessages NOTIFY sentMessagesChanged); + Q_PROPERTY(int lastEventId READ lastEventId NOTIFY lastEventIdChanged); + Q_PROPERTY(int contactId READ contactId NOTIFY contactsChanged); + Q_PROPERTY(QString contactName READ contactName NOTIFY contactsChanged); + Q_PROPERTY(QString lastMessageText READ lastMessageText NOTIFY lastMessageTextChanged); + Q_PROPERTY(QString lastVCardFileName READ lastVCardFileName NOTIFY lastVCardFileNameChanged); + Q_PROPERTY(QString lastVCardLabel READ lastVCardLabel NOTIFY lastVCardLabelChanged); + Q_PROPERTY(int lastEventType READ lastEventType NOTIFY lastEventTypeChanged); + Q_PROPERTY(int lastEventStatus READ lastEventStatus NOTIFY lastEventStatusChanged); + Q_PROPERTY(QDateTime lastModified READ lastModified NOTIFY lastModifiedChanged); + + using Group::isValid; + using Group::id; + using Group::localUid; + using Group::remoteUids; + int chatType() const { return static_cast<int>(Group::chatType()); } + using Group::chatName; + using Group::startTime; + using Group::endTime; + using Group::totalMessages; + using Group::unreadMessages; + using Group::sentMessages; + using Group::contacts; + using Group::lastEventId; + using Group::lastMessageText; + using Group::lastVCardFileName; + using Group::lastVCardLabel; + int lastEventType() const { return static_cast<int>(Group::lastEventType()); } + int lastEventStatus() const { return static_cast<int>(Group::lastEventStatus()); } + using Group::lastModified; + + using Group::contactId; + using Group::contactName; + +signals: + void localUidChanged(); + void remoteUidsChanged(); + void chatTypeChanged(); + void chatNameChanged(); + void startTimeChanged(); + void endTimeChanged(); + void totalMessagesChanged(); + void unreadMessagesChanged(); + void sentMessagesChanged(); + void lastEventIdChanged(); + void contactsChanged(); + void lastMessageTextChanged(); + void lastVCardFileNameChanged(); + void lastVCardLabelChanged(); + void lastEventTypeChanged(); + void lastEventStatusChanged(); + void lastModifiedChanged(); + + void groupRemoved(); + +private slots: + void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight); + void modelRowsRemoved(const QModelIndex &parent, int start, int end); + +private: + QAbstractItemModel *model; +}; + +#endif + --- declarative/src/groupproxymodel.cpp +++ declarative/src/groupproxymodel.cpp @@ -0,0 +1,89 @@ +/* Copyright (C) 2012 John Brooks <[email protected]> + * + * You may use this file under the terms of the BSD license as follows: + * + * "Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + */ + +#include "groupproxymodel.h" +#include "groupobject.h" + +#include "groupmodel.h" + +using namespace CommHistory; + +GroupProxyModel::GroupProxyModel(QObject *parent) + : QIdentityProxyModel(parent) +{ +} + +void GroupProxyModel::setSourceModel(QAbstractItemModel *model) +{ + if (model == sourceModel()) + return; + + GroupModel *g = qobject_cast<GroupModel*>(model); + if (model && !g) { + qWarning() << Q_FUNC_INFO << "Model must be a CommHistory::GroupModel"; + model = 0; + } + + groupModel = g; + QIdentityProxyModel::setSourceModel(model); + emit sourceModelChanged(); +} + +GroupObject *GroupProxyModel::group(int row) +{ + if (!groupModel) { + qWarning() << Q_FUNC_INFO << "No group model instance"; + return 0; + } + + Group g = groupModel->group(mapToSource(index(row, 0))); + if (!g.isValid()) + return 0; + + // Should we keep a list and return the same instances? + return new GroupObject(g, this); +} + +GroupObject *GroupProxyModel::groupById(int id) +{ + if (!groupModel) { + qWarning() << Q_FUNC_INFO << "No group model instance"; + return 0; + } + + for (int r = 0; r < groupModel->rowCount(); r++) { + Group g = groupModel->group(groupModel->index(r, 0)); + if (g.isValid() && g.id() == id) + return new GroupObject(g, this); + } + + return 0; +} + --- declarative/src/groupproxymodel.h +++ declarative/src/groupproxymodel.h @@ -0,0 +1,66 @@ +/* Copyright (C) 2012 John Brooks <[email protected]> + * + * You may use this file under the terms of the BSD license as follows: + * + * "Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Nemo Mobile nor the names of its contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + */ + +#ifndef COMMHISTORY_DECLARATIVE_GROUPPROXYMODEL_H +#define COMMHISTORY_DECLARATIVE_GROUPPROXYMODEL_H + +#include <QIdentityProxyModel> + +class GroupObject; + +namespace CommHistory { + class GroupModel; +} + +class GroupProxyModel : public QIdentityProxyModel +{ + Q_OBJECT + +public: + GroupProxyModel(QObject *parent = 0); + + Q_PROPERTY(QObject* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged) + virtual void setSourceModel(QAbstractItemModel *sourceModel); + void setSourceModel(QObject *model) + { + setSourceModel(qobject_cast<QAbstractItemModel*>(model)); + } + + Q_INVOKABLE GroupObject *group(int row); + Q_INVOKABLE GroupObject *groupById(int id); + +signals: + void sourceModelChanged(); + +private: + CommHistory::GroupModel *groupModel; +}; + +#endif --- declarative/src/plugin.cpp +++ declarative/src/plugin.cpp @@ -33,9 +33,10 @@ #include <QDeclarativeEngine> #include <QDeclarativeExtensionPlugin> #include "constants.h" +#include "groupobject.h" #include "eventmodel.h" -#include "groupmodel.h" #include "callproxymodel.h" +#include "groupproxymodel.h" #include "conversationmodel.h" class Q_DECL_EXPORT CommHistoryPlugin : public QDeclarativeExtensionPlugin @@ -56,9 +57,10 @@ qmlRegisterUncreatableType<CommHistoryConstants>(uri, 1, 0, "CommHistory", "Constants-only type"); qmlRegisterType<CommHistory::EventModel>(uri, 1, 0, "CommEventModel"); - qmlRegisterType<CommHistory::GroupModel>(uri, 1, 0, "CommGroupModel"); + qmlRegisterType<GroupProxyModel>(uri, 1, 0, "CommGroupModel"); qmlRegisterType<CallProxyModel>(uri, 1, 0, "CommCallModel"); qmlRegisterType<CommHistory::ConversationModel>(uri, 1, 0, "CommConversationModel"); + qmlRegisterUncreatableType<GroupObject>(uri, 1, 0, "Group", "Uncreatable data type"); } }; --- makedist +++ makedist @@ -0,0 +1,49 @@ +#!/bin/bash + +# Determine project name based on current directory +PROJECT=$(basename $PWD) +# +# NOTE: Don't like this? Then uncomment one of the following as appropriate +# +# Just set it explictly to whatever you like: +# PROJECT=libseaside +# +# Parse it from any Qt *.pro or *.pri files in CWD: +# PROJECT=$(grep -E "TARGET ?= ?" *.pr[io]|cut -d' ' -f3) + +# Grab most recent tag from git +TAG=$(git describe --tags --abbrev=0) + +# If arg1 is provided, use it as commit/tag/tree-ish id to start +# the archive creation from... +[ "${1}z" != "z" ] && { + TAG=${1} + echo "Creating release starting from: ${TAG}" +} + +VERSION=$(git describe --tags ${1}) +VERSION=${VERSION//version-/} +VERSION=${VERSION//-g/.} +VERSION=${VERSION//-/+git} + +# Set name of toplevel directory for the archive +BASE_PREFIX="${PROJECT}-${VERSION}/" + +# Set name of resulting release archive file +BASE_ARCHIVE=${PROJECT}-${VERSION}.tar.gz + +# Clean up any existing base package for this version +[ -e ${BASE_ARCHIVE} ] && rm -rf ${BASE_ARCHIVE} && + echo "Removed: ${BASE_ARCHIVE}" + +# Generate the base package release tar ball +# NOTE: Becuase I used a git attribute that ignores the meego theme dir +# this archive will not include it... that's intentional! +git archive --prefix=${BASE_PREFIX} HEAD | gzip -c -- > ${BASE_ARCHIVE} && { + echo "Created: ${BASE_ARCHIVE}" +} || { + echo "Creation of release archive ${BASE_ARCHIVE} failed. Reason unknown." +} + +# Generate custom .spec file with newest version tag. +#sed "s/%version%/$VERSION/" "packaging/$PROJECT.spec.in" > packaging/$PROJECT.spec --- src/commhistory.pc +++ src/commhistory.pc @@ -10,5 +10,5 @@ Libs: -L${libdir} -lcommhistory Libs.private: -L/usr/lib Cflags: -I${includedir} -Requires: QtCore, QtSparql, tracker-sparql-0.10 +Requires: QtCore, QtSparql, tracker-sparql-0.14 --- src/shared.pro +++ src/shared.pro @@ -42,7 +42,7 @@ qtsparql \ qtcontacts_extensions_tracker MOBILITY += contacts -PKGCONFIG += tracker-sparql-0.10 +PKGCONFIG += tracker-sparql-0.14 DEFINES += LIBCOMMHISTORY_SHARED QMAKE_CXXFLAGS += -fvisibility=hidden --- src/static.pro +++ src/static.pro @@ -25,7 +25,7 @@ TEMPLATE = lib CONFIG += qdbus static mobility debug qtsparql qtcontacts_extensions_tracker -PKGCONFIG += tracker-sparql-0.10 +PKGCONFIG += tracker-sparql-0.14 MOBILITY += contacts VERSION = $$LIBRARY_VERSION TARGET = commhistory ++++++ deleted files: --- libcommhistory-1.4.0-build-against-tracker-0-14.patch
