From: Jussi Laitinen Date: Wed, 5 May 2010 12:56:38 +0000 (+0300) Subject: Modified friendlistitem mouse events. X-Git-Tag: v0.4~35^2~14^2~2 X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=f79a751a3004c3ca03dd757419c177941f095933;p=situare Modified friendlistitem mouse events. --- diff --git a/images.qrc b/images.qrc index 9837038..141b8bc 100644 --- a/images.qrc +++ b/images.qrc @@ -19,5 +19,9 @@ res/images/led_red_g.png res/images/led_red_h.png res/images/led_red_s.png + res/images/list_item_bottom.png + res/images/list_item_middle.png + res/images/list_item_top.png + res/images/list_item2.png diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 605bc33..69956c2 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -44,8 +44,8 @@ SituareEngine::SituareEngine(QMainWindow *parent) connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool))); connect(m_situareService, SIGNAL(userDataChanged(User*,QList&)), this, SLOT(userDataChanged(User*,QList&))); - connect(this, SIGNAL(userLocationReady(User*)), m_ui, SIGNAL(userLocationReady(User*))); - connect(this, SIGNAL(friendsLocationsReady(QList&)), m_ui, SIGNAL(friendsLocationsReady(QList&))); + //connect(this, SIGNAL(userLocationReady(User*)), m_ui, SIGNAL(userLocationReady(User*))); + //connect(this, SIGNAL(friendsLocationsReady(QList&)), m_ui, SIGNAL(friendsLocationsReady(QList&))); connect(m_situareService, SIGNAL(error(QString)), this, SLOT(error(QString))); connect(m_situareService, SIGNAL(updateWasSuccessful()), this, SLOT(updateWasSuccessful())); diff --git a/src/src.pro b/src/src.pro index 62e816c..21d8e09 100644 --- a/src/src.pro +++ b/src/src.pro @@ -72,7 +72,7 @@ HEADERS += ui/mainwindow.h \ map/maptilerequest.h QT += network \ webkit -DEFINES += QT_NO_DEBUG_OUTPUT +#DEFINES += QT_NO_DEBUG_OUTPUT !maemo5 { message(QJson built in) message(Make sure you have QJson development headers installed) diff --git a/src/ui/friendlistitem.cpp b/src/ui/friendlistitem.cpp index b1a236c..f93c80e 100644 --- a/src/ui/friendlistitem.cpp +++ b/src/ui/friendlistitem.cpp @@ -28,11 +28,16 @@ #include #include #include +#include +#include #include "friendlistitem.h" #include "../user/user.h" const QString BACKGROUND_PATH = ":/res/images/list_item.png"; ///< Background image path +const QString BACKGROUND_TOP_PATH = ":/res/images/list_item_top.png"; ///< Background image path +const QString BACKGROUND_MIDDLE_PATH = ":/res/images/list_item_middle.png"; ///< Background image path +const QString BACKGROUND_BOTTOM_PATH = ":/res/images/list_item_bottom.png"; ///< Background image path const QString CLOCK_PATH = ":/res/images/clock.png"; ///< Clock image path const QString COMPASS_PATH = ":/res/images/compass.png"; ///< Compass image path const QString ENVELOPE_PATH = ":/res/images/envelope.png"; ///< Envelope image path @@ -45,7 +50,7 @@ const int ITEM_MAX_HEIGHT = 240; ///< Maximum height for item const int ITEM_MAX_WIDTH = 368; ///< Maximum width for item const int ITEM_MIN_HEIGHT = 141; ///< Minimum height for item const int ITEM_MIN_WIDTH = 368; ///< Minimum width for item -const int LABEL_MAX_WIDTH = 350; ///< Label maximum width +const int LABEL_MAX_WIDTH = 220; ///< Label maximum width FriendListItem::FriendListItem(QWidget *parent) : QWidget(parent) @@ -69,6 +74,12 @@ FriendListItem::FriendListItem(QWidget *parent) infoLayout->setMargin(0); infoLayout->setSpacing(0); + QPalette palette = this->palette(); + palette.setColor(QPalette::Foreground, QColor::fromRgb(152, 152, 152)); + setPalette(palette); + setFont(QFont( "Nokia Sans", 13, QFont::Normal)); + + QLabel *clockLabel = new QLabel(); clockLabel->setPixmap(QPixmap(CLOCK_PATH)); clockLabel->setContentsMargins(0, 0, ICON_MARGIN, 0); @@ -81,8 +92,14 @@ FriendListItem::FriendListItem(QWidget *parent) m_imageLabel = new QLabel(); m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT); + m_nameLabel = new QLabel(); m_nameLabel->setFixedHeight(IMAGE_HEIGHT); + QPalette namePalette = m_nameLabel->palette(); + namePalette.setColor(QPalette::Foreground, Qt::white); + m_nameLabel->setPalette(namePalette); + m_nameLabel->setFont(QFont( "Nokia Sans", 18, QFont::Normal)); + m_updatedLabel = new QLabel(); m_updatedLabel->setWordWrap(true); m_statusTextLabel = new QLabel(); @@ -106,13 +123,13 @@ FriendListItem::FriendListItem(QWidget *parent) setObjectName("listItem"); m_nameLabel->setObjectName("nameLabel"); - setStyleSheet("#listItem { border-image: url(:/res/images/list_item.png) 20%; " \ + setStyleSheet("QWidget#listItem { border-image: url(:/res/images/list_item.png) 20%; " \ "border-width: 20px 14px 16px 14px; } " \ "QLabel { font-size: 13pt; color: #989898; }" \ "#nameLabel { font-size: 18pt; color: #ffffff }"); setMinimumSize(ITEM_MIN_WIDTH, ITEM_MIN_HEIGHT); - setMaximumSize(ITEM_MAX_WIDTH, ITEM_MAX_HEIGHT); + setMaximumSize(ITEM_MIN_WIDTH, ITEM_MAX_HEIGHT); } void FriendListItem::setData(User *user) @@ -162,16 +179,16 @@ void FriendListItem::setText(bool expanded) void FriendListItem::mousePressEvent(QMouseEvent *event) { - qDebug() << __PRETTY_FUNCTION__; + qDebug() << __PRETTY_FUNCTION__ << " " << event->pos(); m_mousePosition = event->pos(); } void FriendListItem::mouseReleaseEvent(QMouseEvent *event) { - qDebug() << __PRETTY_FUNCTION__; + qDebug() << __PRETTY_FUNCTION__ << " " << event->pos(); - if (event->pos() == m_mousePosition) { + if (abs(m_mousePosition.y() - event->pos().y()) < 10) { if (m_expanded) { setText(false); m_expanded = false; @@ -183,13 +200,55 @@ void FriendListItem::mouseReleaseEvent(QMouseEvent *event) } } -void FriendListItem::paintEvent(QPaintEvent *) +void FriendListItem::paintEvent(QPaintEvent *event) { - qDebug() << __PRETTY_FUNCTION__; + qDebug() << __PRETTY_FUNCTION__ << " " << event->rect(); + +// QStyleOption option; +// option.init(this); + +// QStylePainter painter(this); +// style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); + +// QPainter painter(this); + +// painter.drawPixmap(event->rect(), QPixmap(BACKGROUND_PATH)); + +// painter.drawPixmap(event->rect(), QPixmap(BACKGROUND_PATH), event->rect()); + +// int topRectHeight = 20 - event->rect().top(); + +// QRect topRect; + +// if (topRectHeight > 0) { +// topRect = QRect(event->rect().left(), event->rect().top(), 368, +// topRectHeight); + +// painter.drawPixmap(topRect, QPixmap(BACKGROUND_TOP_PATH), QRect(0, event->rect().top(), 368, topRect.height())); +// } + +// int middleRectHeight = event->rect().height() - topRect.height(); + +// int bottomRectHeight = 15 - (148 - event->rect().height()); + +// if (bottomRectHeight > 0) +// middleRectHeight -= bottomRectHeight; + + +// QRect middleRect = QRect(event->rect().left(), topRect.bottom() + 1, 368, middleRectHeight); + +//// painter.drawPixmap(middleRect, QPixmap(BACKGROUND_MIDDLE_PATH)); + + +// if (bottomRectHeight > 0) { +// QRect bottomRect = QRect(event->rect().left(), middleRect.bottom() + 1, 368, +// bottomRectHeight); + +// painter.drawPixmap(bottomRect, QPixmap(BACKGROUND_BOTTOM_PATH), QRect(0, 0, 368, +// bottomRectHeight)); +// } - QStyleOption option; - option.init(this); +// qDebug() << __PRETTY_FUNCTION__ << " " << topRectHeight << " " << middleRectHeight << " " << +// bottomRectHeight; - QPainter painter(this); - style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); } diff --git a/src/ui/listviewscreen.cpp b/src/ui/listviewscreen.cpp index 065fe74..19df7af 100644 --- a/src/ui/listviewscreen.cpp +++ b/src/ui/listviewscreen.cpp @@ -104,12 +104,12 @@ ListViewScreen::ListViewScreen(QWidget *parent) scene->addItem(m_arrowLeft); //Friend list - QGraphicsProxyWidget *scrollProxy = new QGraphicsProxyWidget(); - scrollProxy->setWidget(friendListScroll); - scrollProxy->setZValue(m_personalInfoBackGround->zValue() - 3); - scrollProxy->setMinimumSize(790 - 400, 480 - 56); - scene->addItem(scrollProxy); - scrollProxy->setPos(410, 0); +// QGraphicsProxyWidget *scrollProxy = new QGraphicsProxyWidget(); +// scrollProxy->setWidget(friendListScroll); +// scrollProxy->setZValue(m_personalInfoBackGround->zValue() - 3); +// scrollProxy->setMinimumSize(790 - 400, 480 - 56); +// scene->addItem(scrollProxy); +// scrollProxy->setPos(410, 0); //Friend list m_leftSideBar->setPos(0,0); @@ -193,7 +193,8 @@ ListViewScreen::ListViewScreen(QWidget *parent) machine->start(); m_vbox = new QVBoxLayout(this); - m_vbox->addWidget(view); + //m_vbox->addWidget(view); + m_vbox->addWidget(friendListScroll); m_vbox->setMargin(0); connect(m_personalInfo,SIGNAL(launchMessageUpdate()), @@ -201,6 +202,22 @@ ListViewScreen::ListViewScreen(QWidget *parent) connect(m_personalInfo,SIGNAL(launchUpdateFriendsStatus()), this, SIGNAL(updateFriendsData())); setObjectName("List view"); + + //DEBUG + QList list; + User *user1 = new User(QString("Address address"), QPointF(12.22, 23.33), QString("Name"), + QString("Note note note note Note note note note Note note note note "), + QUrl(""), QString("2 days ago"),false, QString("")); + User *user2 = new User(QString("Address address Address address Address address Address address " \ + "Address address Address address Address address Address address " \ + "Address address Address address Address address Address address "), QPointF(12.22, 23.33), QString("Name"), + QString("Note note note note"), QUrl(""), QString("2 days ago"), + false, QString("")); + + list.append(user1); + list.append(user2); + + friendInfoReceived(list); } ListViewScreen::~ListViewScreen() @@ -245,11 +262,20 @@ void ListViewScreen::friendInfoReceived(QList &friendList) { qDebug() << __PRETTY_FUNCTION__; - m_friendListView->clear(); +// m_friendListView->clear(); foreach (User *user, friendList) { - FriendListItem *item = new FriendListItem(m_friendListView); - item->setData(user); - m_friendListView->addWidget(item); + FriendListItem *item1 = new FriendListItem(m_friendListView); + item1->setData(user); + m_friendListView->addWidget(item1); + FriendListItem *item2 = new FriendListItem(m_friendListView); + item2->setData(user); + m_friendListView->addWidget(item2); + FriendListItem *item3 = new FriendListItem(m_friendListView); + item3->setData(user); + m_friendListView->addWidget(item3); + FriendListItem *item4 = new FriendListItem(m_friendListView); + item4->setData(user); + m_friendListView->addWidget(item4); } }