[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdenetwork/kopete/kopete/contactlist
From: Roman Jarosz <kedgedev () gmail ! com>
Date: 2009-03-31 21:27:02
Message-ID: 1238534822.906615.30032.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 947606 by rjarosz:
Add contact tooltip.
M +30 -0 kopeteitemdelegate.cpp
M +5 -0 kopeteitemdelegate.h
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopeteitemdelegate.cpp \
#947605:947606 @@ -25,6 +25,8 @@
#include <QAbstractItemView>
#include <QApplication>
#include <QVector>
+#include <QHelpEvent>
+#include <QToolTip>
#include <qimageblitz.h>
@@ -110,6 +112,32 @@
return 0;
}
+bool KopeteItemDelegate::helpEvent( QHelpEvent* event, QAbstractItemView* view, \
const QStyleOptionViewItem& option, const QModelIndex& index ) +{
+ if ( !event || !view )
+ return false;
+
+ if ( event->type() == QEvent::ToolTip )
+ {
+ Kopete::Contact* contact = contactAt( option, index, event->pos() );
+ if ( contact )
+ {
+ QToolTip::showText( event->globalPos(), contact->toolTip(), view );
+ return true;
+ }
+
+ QVariant tooltip = index.data( Qt::ToolTipRole );
+ if ( qVariantCanConvert<QString>(tooltip) )
+ {
+ QToolTip::showText( event->globalPos(), tooltip.toString(), view );
+ return true;
+ }
+ return false;
+ }
+
+ return QStyledItemDelegate::helpEvent(event, view, option, index);
+}
+
void KopeteItemDelegate::paint( QPainter* painter,
const QStyleOptionViewItem& option,
const QModelIndex& index ) const
@@ -549,3 +577,5 @@
}
return rowHeight;
}
+
+#include "kopeteitemdelegate.moc"
--- trunk/KDE/kdenetwork/kopete/kopete/contactlist/kopeteitemdelegate.h \
#947605:947606 @@ -33,6 +33,7 @@
class KOPETE_CONTACT_LIST_EXPORT KopeteItemDelegate : public QStyledItemDelegate
{
+ Q_OBJECT
public:
KopeteItemDelegate( QAbstractItemView* parent = 0 );
~KopeteItemDelegate();
@@ -47,6 +48,10 @@
const QModelIndex & index ) const;
Kopete::Contact* contactAt( const QStyleOptionViewItem& option, const QModelIndex& \
index, const QPoint& point ) const; +
+public slots:
+ bool helpEvent( QHelpEvent* event, QAbstractItemView* view, const \
QStyleOptionViewItem& option, const QModelIndex& index ); +
private:
void paintItem( ContactList::LayoutItemConfig config, QPainter* painter,
const QStyleOptionViewItem& option, const QModelIndex& index,
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic