[meego-commits] 8132: Changes to Trunk:Handset/meego-handset-sms
Emma Kuo
no_reply at build.meego.com
Wed Oct 6 18:21:51 UTC 2010
Hi,
I have made the following changes to meego-handset-sms in project Trunk:Handset. Please review and accept ASAP.
Thank You,
Emma Kuo
[This message was auto-generated]
---
Request #8132:
submit: devel:ux:handset/meego-handset-sms(r41) -> Trunk:Handset/meego-handset-sms
Message:
Fixes: BMC#2635 multiline sms messages do not expand correctly
State: new 2010-10-06T11:21:50 ekuo
Comment: None
changes files:
--------------
--- meego-handset-sms.changes
+++ meego-handset-sms.changes
@@ -0,0 +1,3 @@
+* Tue Oct 5 2010 Emma Kuo <emma.kuo at intel.com> 0.0.27
+- Fixes: BMC#2635 multiline sms messages do not expand correctly
+
old:
----
meego-handset-sms-0.0.26.tar.bz2
new:
----
meego-handset-sms-0.0.27.tar.bz2
spec files:
-----------
--- meego-handset-sms.spec
+++ meego-handset-sms.spec
@@ -7,7 +7,7 @@
Name: meego-handset-sms
Summary: MeeGo Touch Framework based SMS Application
-Version: 0.0.26
+Version: 0.0.27
Release: 1
Group: System/GUI/Other
License: Apache License, Version 2.0
other changes:
--------------
++++++ meego-handset-sms-0.0.26.tar.bz2 -> meego-handset-sms-0.0.27.tar.bz2
--- src/dialogitem.cpp
+++ src/dialogitem.cpp
@@ -26,9 +26,34 @@
DialogItem::DialogItem(MWidget *parent)
:MStylableWidget(parent)
{
+ init();
+}
+
+DialogItem::DialogItem(SmsData &dat, MWidget *parent)
+ :MStylableWidget(parent)
+{
+ init();
+
+ mPosition = DialogItem::POSITION_FIRST;
+ mSender = dat.sender;
+ mMessage = dat.message;
+ mDatetime = dat.datetime;
+ mCalltype = dat.calltype;
+ if (mCalltype == SmsData::INCOMING) {
+ setObjectName("dialogItemIncoming");
+ } else {
+ setObjectName("dialogItem");
+ }
+ mStatus = dat.status;
+ createContent();
+}
+
+void DialogItem::init()
+{
setObjectName("dialogItem");
mLayout = new QGraphicsGridLayout();
setLayout(mLayout);
+ setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
mChatbubble = new MStylableWidget();
QGraphicsGridLayout *bubbleLayout = new QGraphicsGridLayout();
--- src/dialogitem.h
+++ src/dialogitem.h
@@ -36,6 +36,7 @@
};
DialogItem(MWidget *parent = NULL);
+ DialogItem(SmsData&, MWidget *parent = NULL);
virtual ~DialogItem() {}
void setSender(QString);
@@ -51,6 +52,8 @@
virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
virtual void cancelEvent(MCancelEvent*);
+private:
+ void init();
signals:
void clicked();
--- src/dialogitemcreator.cpp
+++ src/dialogitemcreator.cpp
-/*
- * meego-handset-sms - Meego Handset SMS application
- *
- * Copyright (c) 2010, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#include "dialogitemcreator.h"
-#include "dialogitem.h"
-#include "smsdata.h"
-
-DialogItemCreator::DialogItemCreator()
-{}
-
-void DialogItemCreator::updateCell(const QModelIndex &index, MWidget *cell) const
-{
- if (!index.isValid() || !cell)
- return;
- DialogItem *item = qobject_cast<DialogItem *>(cell);
- QVariant data = index.data(Qt::DisplayRole);
- SmsData rowData = data.value<SmsData>();
- QModelIndex prev = index.sibling(index.row() - 1, index.column());
- item->setPosition(DialogItem::POSITION_FIRST);
- if (prev.isValid()) {
- QVariant tmp = prev.data(Qt::DisplayRole);
- SmsData prevData = tmp.value<SmsData>();
- if (prevData.calltype == rowData.calltype)
- item->setPosition(DialogItem::POSITION_MIDDLE);
- }
- item->setSender(rowData.sender);
- item->setMessage(rowData.message);
- item->setDatetime(rowData.datetime);
- item->setCalltype(rowData.calltype);
- item->setStatus(rowData.status);
-}
--- src/dialogitemcreator.h
+++ src/dialogitemcreator.h
-/*
- * meego-handset-sms - Meego Handset SMS application
- *
- * Copyright (c) 2010, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#include <mabstractcellcreator.h>
-
-#include "dialogitem.h"
-
-class DialogItemCreator : public MAbstractCellCreator<DialogItem>
-{
-public:
- DialogItemCreator();
- void updateCell(const QModelIndex &index, MWidget *cell) const;
-};
--- src/dialogitemmodel.cpp
+++ src/dialogitemmodel.cpp
-/*
- * meego-handset-sms - Meego Handset SMS application
- *
- * Copyright (c) 2010, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-
-#include "dialogitemmodel.h"
-
-DialogItemModel::DialogItemModel(Backend *backend, const QString &phone) :
- mBackend(backend),
- mPhone(phone)
-{
- SmsData dat;
- //beginInsertRows(QModelIndex(), 0, mModel.size()-1);
- foreach (dat, mBackend->getSmsHistory()) {
- if (mPhone == dat.sender && !dat.draft) {
- mModel.append(dat);
- }
- }
- qSort(mModel);
- //endInsertRows();
- //emit dataUpdated();
- connect(mBackend, SIGNAL(smsAdded(QList<SmsData>)), this, SLOT(sms_added(QList<SmsData>)));
- connect(mBackend, SIGNAL(smsModified(QList<SmsData>)), this, SLOT(sms_modified(QList<SmsData>)));
- connect(mBackend, SIGNAL(smsRemoved(QList<unsigned int>)), this, SLOT(sms_removed(QList<unsigned int>)));
-}
-
-DialogItemModel::~DialogItemModel()
-{
- mBackend->markRead(mPhone);
-}
-
-void DialogItemModel::sms_added(QList<SmsData> messages)
-{
- SmsData dat;
- foreach (dat, messages) {
- // filter by sender/receiver
- if (mPhone == dat.sender && !dat.draft) {
- // find point to insert, starting from end
- int i;
- for (i = mModel.size(); i > 0; i--) {
- if (mModel[i-1] < dat)
- break;
- }
- beginInsertRows(QModelIndex(), i, i);
- mModel.insert(i, dat);
- endInsertRows();
- emit dataUpdated();
- }
- }
-}
-
-void DialogItemModel::sms_modified(QList<SmsData> messages)
-{
- SmsData dat;
- foreach (dat, messages) {
- int i;
- for (i = 0; i < mModel.size(); i++) {
- if (mModel[i].id == dat.id) {
- mModel[i] = dat;
- emit dataChanged(index(i), index(i));
- break;
- }
- }
- }
-}
-
-void DialogItemModel::sms_removed(QList<unsigned int> ids)
-{
- unsigned int id;
- foreach (id, ids) {
- int i;
- for (i = 0; i < mModel.size(); i++) {
- if (mModel[i].id == id) {
- beginRemoveRows(QModelIndex(), i, i);
- mModel.removeAt(i);
- endRemoveRows();
- break;
- }
- }
- }
-}
-
-int DialogItemModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent);
- return mModel.size();
-}
-
-QVariant DialogItemModel::data(const QModelIndex &index, int role) const
-{
- if (role == Qt::DisplayRole) {
- if (index.isValid() && index.row() < mModel.size()) {
- return QVariant::fromValue<SmsData>(mModel.at(index.row()));
- }
- }
- return QVariant();
-}
-
--- src/dialogitemmodel.h
+++ src/dialogitemmodel.h
-/*
- * meego-handset-sms - Meego Handset SMS application
- *
- * Copyright (c) 2010, Intel Corporation.
- *
- * This program is licensed under the terms and conditions of the
- * Apache License, version 2.0. The full text of the Apache License is at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- */
-
-#ifndef DIALOGITEMMODEL_H
-#define DIALOGITEMMODEL_H
-
-#include <QAbstractListModel>
-
-#include "backend.h"
-#include "smsdata.h"
-
-class DialogItemModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- DialogItemModel(Backend*, const QString&);
- ~DialogItemModel();
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-public slots:
- void sms_added(QList<SmsData>);
- void sms_modified(QList<SmsData>);
- void sms_removed(QList<unsigned int>);
-signals:
- void dataUpdated();
-private:
- Backend *mBackend;
- QString mPhone;
- QList<SmsData> mModel;
-};
-
-#endif // DIALOGITEMMODEL_H
--- src/dialoglist.cpp
+++ src/dialoglist.cpp
+/*
+ * meego-handset-sms - Meego Handset SMS application
+ *
+ * Copyright (c) 2010, Intel Corporation.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+#include <MWidgetCreator>
+
+#include "dialoglist.h"
+
+M_REGISTER_WIDGET(DialogList)
+
+DialogList::DialogList(MWidget *parent)
+ :MStylableWidget(parent)
+{
+ setObjectName("dialogList");
+ mLayout = new MLayout();
+ mPolicy = new MLinearLayoutPolicy(mLayout, Qt::Vertical);
+ mLayout->setPolicy(mPolicy);
+ setLayout(mLayout);
+}
+
+void DialogList::addItem(QGraphicsLayoutItem *item)
+{
+ mPolicy->addItem(item);
+}
+
+void DialogList::insertItem(int index, QGraphicsLayoutItem *item)
+{
+ mPolicy->insertItem(index, item);
+}
+
+void DialogList::removeAt(int index)
+{
+ mPolicy->removeAt(index);
+}
--- src/dialoglist.h
+++ src/dialoglist.h
+/*
+ * meego-handset-sms - Meego Handset SMS application
+ *
+ * Copyright (c) 2010, Intel Corporation.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+#ifndef DIALOGLIST_H
+#define DIALOGLIST_H
+
+#include <MStylableWidget>
+#include <MLayout>
+#include <MLinearLayoutPolicy>
+
+#include "dialogliststyle.h"
+
+
+class M_EXPORT DialogList : public MStylableWidget
+{
+ Q_OBJECT
+public:
+ DialogList(MWidget *parent = NULL);
+ virtual ~DialogList() {}
+
+ void addItem(QGraphicsLayoutItem *item);
+ void insertItem(int index, QGraphicsLayoutItem *item);
+ void removeAt(int index);
+
+private:
+ MLayout *mLayout;
+ MLinearLayoutPolicy *mPolicy;
+
+ M_STYLABLE_WIDGET(DialogListStyle)
+};
+
+#endif // DIALOGLIST_H
+
--- src/dialogliststyle.h
+++ src/dialogliststyle.h
+/*
+ * meego-handset-sms - Meego Handset SMS application
+ *
+ * Copyright (c) 2010, Intel Corporation.
+ *
+ * This program is licensed under the terms and conditions of the
+ * Apache License, version 2.0. The full text of the Apache License is at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ */
+
+#ifndef DIALOGLISTSTYLE_H
+#define DIALOGLISTSTYLE_H
+
+#include <MWidgetStyle>
+
+class M_EXPORT DialogListStyle : public MWidgetStyle
+{
+ Q_OBJECT
+ M_STYLE(DialogListStyle)
+};
+
+class M_EXPORT DialogListStyleContainer: public MWidgetStyleContainer
+{
+ M_STYLE_CONTAINER(DialogListStyle)
+};
+
+#endif // DIALOGLISTSTYLE_H
--- src/dialogpage.cpp
+++ src/dialogpage.cpp
@@ -23,14 +23,14 @@
#include <MWidgetCreator>
#include "dialogpage.h"
-#include "dialogitemcreator.h"
+#include "dialogitem.h"
#include "contactitemcreator.h"
#include "util.h"
#define SMS_LIMIT 160
DialogPage::DialogPage(Backend *backend, QString phone, QString message) :
- mBackend(backend), mModel(0)
+ mBackend(backend)
{
setPannable(false);
@@ -149,8 +149,7 @@
mDialogViewport = new MPannableViewport();
{
- mDialogList = new MList();
- mDialogList->setCellCreator(new DialogItemCreator());
+ mDialogList = new DialogList();
mDialogViewport->setObjectName("dialogViewport");
mDialogViewport->setWidget(mDialogList);
mDialogViewport->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -170,7 +169,6 @@
setTitle(qtTrId("newmessagepage_title"));
mLayout->setPolicy(mNewMessagePolicy);
}
-
}
DialogPage::~DialogPage()
@@ -180,9 +178,10 @@
(!mPhone.isEmpty() || isValidPhone(mAddressEntry->text()))) {
mBackend->saveDraft(mPhone.isEmpty() ? stripPhone(mAddressEntry->text()) : mPhone, mEntry->text());
}
+ if (!mPhone.isEmpty())
+ mBackend->markRead(mPhone);
delete mOverlay;
- delete mModel;
}
void DialogPage::createContent()
@@ -202,9 +201,28 @@
//mName->setText(SmsApplication::instance()->backend()->getName(mPhone));
setTitle(SmsApplication::instance()->backend()->getName(mPhone));
//mAvatar->setPixmap(SmsApplication::instance()->backend()->getAvatar(mPhone));
- mModel = new DialogItemModel(mBackend, mPhone);
- mDialogList->setItemModel(mModel);
- connect(mModel, SIGNAL(dataUpdated()), this, SLOT(dialogUpdated()));
+
+ // populate dialog from history
+ SmsData dat;
+ //beginInsertRows(QModelIndex(), 0, mModel.size()-1);
+ foreach (dat, mBackend->getSmsHistory()) {
+ if (mPhone == dat.sender && !dat.draft) {
+ mModel.append(dat);
+ }
+ }
+ qSort(mModel);
+ int i;
+ for (i = 0; i < mModel.size(); i++) {
+ DialogItem *item = new DialogItem(mModel[i]);
+ if (i > 0 && mModel[i-1].calltype == mModel[i].calltype)
+ item->setPosition(DialogItem::POSITION_MIDDLE);
+ mDialogList->addItem(item);
+ }
+
+ connect(mBackend, SIGNAL(smsAdded(QList<SmsData>)), this, SLOT(sms_added(QList<SmsData>)));
+ connect(mBackend, SIGNAL(smsModified(QList<SmsData>)), this, SLOT(sms_modified(QList<SmsData>)));
+ connect(mBackend, SIGNAL(smsRemoved(QList<unsigned int>)), this, SLOT(sms_removed(QList<unsigned int>)));
+
mLayout->setPolicy(mConversationPolicy);
}
@@ -252,8 +270,11 @@
void DialogPage::scrollToBottom()
{
// No need to scroll to bottom if the list is not covering the viewport area.
- if(mDialogViewport->positionIndicator()->viewportSize().height() < mDialogViewport->positionIndicator()->range().height()) {
- mDialogList->scrollTo(mModel->index(mModel->rowCount() - 1, 0));
+ qreal size, range;
+ size = mDialogViewport->positionIndicator()->viewportSize().height();
+ range = mDialogViewport->positionIndicator()->range().height();
+ if(size < range) {
+ mDialogViewport->setPosition(QPointF(0.0, range - size));
}
}
@@ -269,3 +290,55 @@
customizedComplete(rowData.phone);
mAddressEntry->setText(rowData.phone);
}
+
+void DialogPage::sms_added(QList<SmsData> messages)
+{
+ SmsData dat;
+ foreach (dat, messages) {
+ // filter by sender/receiver
+ if (mPhone == dat.sender && !dat.draft) {
+ int i;
+ i = mModel.size();
+ mModel.insert(i, dat);
+ DialogItem *item = new DialogItem(dat);
+ if (i > 0 && mModel[i-1].calltype == dat.calltype)
+ item->setPosition(DialogItem::POSITION_MIDDLE);
+ mDialogList->addItem(item);
+ dialogUpdated();
+ }
+ }
+}
+
+void DialogPage::sms_modified(QList<SmsData> messages)
+{
+ SmsData dat;
+ foreach (dat, messages) {
+ int i;
+ for (i = 0; i < mModel.size(); i++) {
+ if (mModel[i].id == dat.id) {
+ DialogItem *item = new DialogItem(dat);
+ if (i > 0 && mModel[i-1].calltype == dat.calltype)
+ item->setPosition(DialogItem::POSITION_MIDDLE);
+ mModel[i] = dat;
+ mDialogList->removeAt(i);
+ mDialogList->insertItem(i, item);
+ break;
+ }
+ }
+ }
+}
+
+void DialogPage::sms_removed(QList<unsigned int> ids)
+{
+ unsigned int id;
+ foreach (id, ids) {
+ int i;
+ for (i = 0; i < mModel.size(); i++) {
+ if (mModel[i].id == id) {
+ mModel.removeAt(i);
+ mDialogList->removeAt(i);
+ break;
+ }
+ }
+ }
+}
--- src/dialogpage.h
+++ src/dialogpage.h
@@ -18,14 +18,16 @@
#include <MList>
#include <MLabel>
#include <MTextEdit>
+#include <QList>
#include <QString>
#include <QStringList>
+#include <QGraphicsLinearLayout>
#include <MImageWidget>
#include <MOverlay>
#include <MCompleter>
#include <MStylableWidget>
-#include "dialogitemmodel.h"
+#include "dialoglist.h"
#include "contactitemmodel.h"
#include "contactsortfiltermodel.h"
@@ -47,9 +49,13 @@
void scrollToBottom();
void customizedComplete(const QString&);
void contactItemClicked(const QModelIndex&);
+
+ void sms_added(QList<SmsData>);
+ void sms_modified(QList<SmsData>);
+ void sms_removed(QList<unsigned int>);
private:
Backend *mBackend;
- DialogItemModel *mModel;
+ QList<SmsData> mModel;
ContactItemModel *mContactModel;
ContactSortFilterModel *mContactFilterModel;
QString mPhone;
@@ -60,7 +66,7 @@
*mConversationPolicy;
MTextEdit *mAddressEntry;
- MList *mDialogList;
+ DialogList *mDialogList;
MTextEdit *mEntry;
MOverlay *mOverlay;
MLabel *mCountdownlabel;
--- src/src.pro
+++ src/src.pro
@@ -25,7 +25,8 @@
STYLE_HEADERS += contactitemstyle.h \
inboxitemstyle.h \
- dialogitemstyle.h
+ dialogitemstyle.h \
+ dialogliststyle.h
SOURCES += main.cpp \
smsapplication.cpp \
@@ -48,8 +49,7 @@
inboxitemmodel.cpp \
inboxitemcreator.cpp \
dialogitem.cpp \
- dialogitemmodel.cpp \
- dialogitemcreator.cpp \
+ dialoglist.cpp \
util.cpp
HEADERS += smsapplication.h \
@@ -72,8 +72,7 @@
inboxitemmodel.h \
inboxitemcreator.h \
dialogitem.h \
- dialogitemmodel.h \
- dialogitemcreator.h \
+ dialoglist.h \
util.h \
$$STYLE_HEADERS
++++++ meego-handset-sms.yaml
--- meego-handset-sms.yaml
+++ meego-handset-sms.yaml
@@ -1,6 +1,6 @@
Name: meego-handset-sms
Summary: MeeGo Touch Framework based SMS Application
-Version: 0.0.26
+Version: 0.0.27
Release: 1
Group: System/GUI/Other
License: Apache License, Version 2.0
More information about the MeeGo-commits
mailing list