~pali/kubuntu-packaging/kopete

« back to all changes in this revision

Viewing changes to debian/patches/0001-Show-emoticons-in-contactlist.patch

  • Committer: Pali Rohár
  • Date: 2014-10-28 18:03:50 UTC
  • Revision ID: pali.rohar@gmail.com-20141028180350-flj1z0i645q1r00h
Fix patch 0001-Show-emoticons-in-contactlist.patch and add 0001-Fix-condition.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
From 41df4e6e804636de4449b6f5ba4acc8d99d09bac Mon Sep 17 00:00:00 2001
 
1
From dbc853171d3d2c5a72e98eab1cfe42151c8f5937 Mon Sep 17 00:00:00 2001
2
2
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
3
 
Date: Wed, 17 Sep 2014 22:34:38 +0200
 
3
Date: Tue, 28 Oct 2014 19:00:09 +0100
4
4
Subject: [PATCH] Show emoticons in contactlist
5
5
 
6
6
The contactlist no longer shows emoticons in recent kopete versions. This patch
7
 
re-enables this feature for both the contacts their display name and status message.
 
7
re-enables this feature for both status title and status message.
8
8
 
9
9
Thanks Stefan Geuns for patch!
10
10
 
11
11
REVIEW: 2542
12
12
CC: bitrain@gmail.com
13
13
---
14
 
 kopete/contactlist/contactlistmodel.cpp   |   22 +++++++++++--
15
 
 kopete/contactlist/contactlistmodel.h     |    2 ++
16
 
 kopete/contactlist/kopeteitemdelegate.cpp |   49 ++++++++++++++++++++++++-----
17
 
 3 files changed, 63 insertions(+), 10 deletions(-)
 
14
 kopete/contactlist/contactlistmodel.cpp   |   20 ++++++++-
 
15
 kopete/contactlist/contactlistmodel.h     |    2 +
 
16
 kopete/contactlist/kopeteitemdelegate.cpp |   67 ++++++++++++++++++++++++++---
 
17
 3 files changed, 81 insertions(+), 8 deletions(-)
18
18
 
19
19
diff --git a/kopete/contactlist/contactlistmodel.cpp b/kopete/contactlist/contactlistmodel.cpp
20
 
index e62e9bb..462e78e 100644
 
20
index e62e9bb..ba86811 100644
21
21
--- a/kopete/contactlist/contactlistmodel.cpp
22
22
+++ b/kopete/contactlist/contactlistmodel.cpp
23
 
@@ -502,13 +502,29 @@ bool ContactListModel::dropMetaContacts( int row, const QModelIndex &parent, Qt:
 
23
@@ -502,6 +502,22 @@ bool ContactListModel::dropMetaContacts( int row, const QModelIndex &parent, Qt:
24
24
        return false;
25
25
 }
26
26
 
43
43
 QVariant ContactListModel::metaContactData( const Kopete::MetaContact* mc, int role ) const
44
44
 {
45
45
        switch ( role )
46
 
        {
47
 
        case Qt::DisplayRole:
48
 
         case Qt::EditRole:
49
 
-               return mc->displayName();
50
 
+               return emoticonStringToList( mc->displayName() );
51
 
                break;
52
 
        case Qt::AccessibleTextRole:
53
 
                return i18nc("%1 is display name, %2 is status (connected/away/etc.)", "%1 (%2)", mc->displayName(), mc->statusString());
54
46
@@ -535,10 +551,10 @@ QVariant ContactListModel::metaContactData( const Kopete::MetaContact* mc, int r
55
47
                return mc->status();
56
48
                break;
78
70
        QVariant metaContactImage( const Kopete::MetaContact* mc ) const;
79
71
        QString metaContactTooltip( const Kopete::MetaContact* metaContact ) const;
80
72
diff --git a/kopete/contactlist/kopeteitemdelegate.cpp b/kopete/contactlist/kopeteitemdelegate.cpp
81
 
index fcefc89..905f58e 100644
 
73
index 674031b..371747e 100644
82
74
--- a/kopete/contactlist/kopeteitemdelegate.cpp
83
75
+++ b/kopete/contactlist/kopeteitemdelegate.cpp
84
 
@@ -397,7 +397,15 @@ void KopeteItemDelegate::paintItem( ContactList::LayoutItemConfig config, QPaint
 
76
@@ -397,7 +397,22 @@ void KopeteItemDelegate::paintItem( ContactList::LayoutItemConfig config, QPaint
85
77
                                else
86
78
                                {
87
79
                                        QFontMetricsF fm( dlItem.font );
88
80
-                                       idealWidth = fm.width( dlItem.text );
89
81
+                                       const int role = ContactList::LayoutManager::instance()->token( value ).mModelRole;
90
 
+                                       QList<QVariant> msgList = index.data( role ).toList();
91
 
+                                       foreach ( const QVariant &msg, msgList)
92
 
+                                       {
93
 
+                                               if ( msg.canConvert(QVariant::Icon) )
94
 
+                                                       idealWidth += IconSize;
95
 
+                                               else if (msg.canConvert(QVariant::String) )
96
 
+                                                       idealWidth += fm.width(msg.toString());
 
82
+                                       if ( role == Kopete::Items::StatusMessageRole || role == Kopete::Items::StatusTitleRole )
 
83
+                                       {
 
84
+                                               QList<QVariant> msgList = index.data( role ).toList();
 
85
+                                               foreach ( const QVariant &msg, msgList)
 
86
+                                               {
 
87
+                                                       if ( msg.canConvert(QVariant::Icon) )
 
88
+                                                               idealWidth += IconSize;
 
89
+                                                       else if (msg.canConvert(QVariant::String) )
 
90
+                                                               idealWidth += fm.width(msg.toString());
 
91
+                                               }
 
92
+                                       }
 
93
+                                       else
 
94
+                                       {
 
95
+                                               idealWidth = fm.width( dlItem.text );
97
96
+                                       }
98
97
                                        dlItem.type = LayoutNormal;
99
98
                                }
100
99
 
101
 
@@ -540,18 +548,45 @@ void KopeteItemDelegate::paintItem( ContactList::LayoutItemConfig config, QPaint
102
 
                                                }
103
 
                                        }
104
 
                                }
105
 
-                               else if ( ContactList::LayoutManager::PlaceHolder )
106
 
+                               else if ( value == ContactList::LayoutManager::PlaceHolder )
107
 
                                {
108
 
                                        // Do nothing
 
100
@@ -546,12 +561,52 @@ void KopeteItemDelegate::paintItem( ContactList::LayoutItemConfig config, QPaint
109
101
                                }
110
102
                                else
111
103
                                {
112
104
-                                       if ( painter )
113
 
+                                       const qreal IconMarginV = 1.0;
114
 
+                                       const qreal IconSize = rowHeight - 2 * IconMarginV;
115
 
+                                       QFontMetricsF fm( dlItem.font );
116
105
+                                       const int role = ContactList::LayoutManager::instance()->token( value ).mModelRole;
117
 
+                                       QList<QVariant> msgList = index.data( role ).toList();
118
 
+                                       qreal offsetX = 0;
119
 
+                                       foreach ( QVariant msg, msgList )
 
106
+                                       if ( role == Kopete::Items::StatusMessageRole || role == Kopete::Items::StatusTitleRole )
 
107
+                                       {
 
108
+                                               const qreal IconMarginV = 1.0;
 
109
+                                               const qreal IconSize = rowHeight - 2 * IconMarginV;
 
110
+                                               QFontMetricsF fm( dlItem.font );
 
111
+                                               QList<QVariant> msgList = index.data( role ).toList();
 
112
+                                               qreal offsetX = 0;
 
113
+                                               foreach ( QVariant msg, msgList )
 
114
+                                               {
 
115
+                                                       if ( msg.canConvert(QVariant::Icon) )
 
116
+                                                       {
 
117
+                                                               if ( painter )
 
118
+                                                               {
 
119
+                                                                       msg.convert(QVariant::Icon);
 
120
+                                                                       QPixmap emoticonPixmap = msg.value<QIcon>().pixmap(IconSize, IconSize);
 
121
+                                                                       QRectF pixmapRect(currentItemX + offsetX, rowOffsetY, IconSize, IconSize);
 
122
+                                                                       painter->setClipRect( pixmapRect );
 
123
+                                                                       painter->drawPixmap( pixmapRect.topLeft(), emoticonPixmap );
 
124
+                                                                       offsetX += IconSize;
 
125
+                                                               }
 
126
+                                                       }
 
127
+                                                       else if ( msg.canConvert(QVariant::String) )
 
128
+                                                       {
 
129
+                                                               if ( painter )
 
130
+                                                               {
 
131
+                                                                       const QString msgString = msg.toString();
 
132
+                                                                       qreal w = fm.width(msgString);
 
133
+                                                                       const QString text = QFontMetricsF( dlItem.font ).elidedText( msgString, Qt::ElideRight, w );
 
134
+                                                                       QRectF drawRect( currentItemX + offsetX, rowOffsetY, w, rowHeight );
 
135
+                                                                       painter->setClipRect( drawRect );
 
136
+                                                                       painter->drawText( drawRect, alignment, text );
 
137
+                                                                       offsetX += w;
 
138
+                                                               }
 
139
+                                                       }
 
140
+                                               }
 
141
+                                       }
 
142
+                                       else
120
143
                                        {
121
144
-                                               QString text = QFontMetricsF( dlItem.font ).elidedText( dlItem.text, Qt::ElideRight, itemWidth );
122
145
-                                               QRectF drawRect( currentItemX, rowOffsetY, itemWidth, rowHeight );
123
146
-                                               painter->setClipRect( drawRect );
124
147
-                                               painter->drawText( drawRect, alignment, text );
125
 
+                                               if ( msg.canConvert(QVariant::Icon) )
126
 
+                                               {
127
 
+                                                       if ( painter )
128
 
+                                                       {
129
 
+                                                               msg.convert(QVariant::Icon);
130
 
+                                                               QPixmap emoticonPixmap = msg.value<QIcon>().pixmap(IconSize, IconSize);
131
 
+                                                               QRectF pixmapRect(currentItemX + offsetX, rowOffsetY, IconSize, IconSize);
132
 
+                                                               painter->setClipRect( pixmapRect );
133
 
+                                                               painter->drawPixmap( pixmapRect.topLeft(), emoticonPixmap );
134
 
+                                                               offsetX += IconSize;
135
 
+                                                       }
136
 
+                                               }
137
 
+                                               else if ( msg.canConvert(QVariant::String) )
138
 
+                                               {
139
 
+                                                       const QString msgString = msg.toString();
140
 
+                                                       if ( painter )
141
 
+                                                       {
142
 
+                                                               qreal w = fm.width(msgString);
143
 
+                                                               const QString text = QFontMetricsF( dlItem.font ).elidedText( msgString, Qt::ElideRight, w );
144
 
+                                                               QRectF drawRect( currentItemX + offsetX, rowOffsetY, w, rowHeight );
145
 
+                                                               painter->setClipRect( drawRect );
146
 
+                                                               painter->drawText( drawRect, alignment, text );
147
 
+                                                               offsetX += w;
148
 
+                                                       }
 
148
+                                               if ( painter )
 
149
+                                               {
 
150
+                                                       QString text = QFontMetricsF( dlItem.font ).elidedText( dlItem.text, Qt::ElideRight, itemWidth );
 
151
+                                                       QRectF drawRect( currentItemX, rowOffsetY, itemWidth, rowHeight );
 
152
+                                                       painter->setClipRect( drawRect );
 
153
+                                                       painter->drawText( drawRect, alignment, text );
149
154
+                                               }
150
155
                                        }
151
156
                                }