kopete/kopete
chatmemberslistview.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <QToolTip>
00019 #include <QHelpEvent>
00020 #include <QDrag>
00021 #include <QMimeData>
00022
00023 #include "kdebug.h"
00024 #include "kmenu.h"
00025 #include "kopetecontact.h"
00026 #include "chatmemberslistview.h"
00027 #include "chatsessionmemberslistmodel.h"
00028
00029 using namespace Kopete;
00030
00031 ChatMembersListView::ChatMembersListView( QWidget *parent )
00032 : QListView( parent )
00033 {
00034 setContextMenuPolicy (Qt::CustomContextMenu);
00035 connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(slotContextMenuRequested(const QPoint &)));
00036 }
00037
00038 void ChatMembersListView::slotContextMenuRequested( const QPoint & pos )
00039 {
00040 kDebug() << "context menu requested";
00041 QModelIndex index = indexAt(pos);
00042 if ( model() )
00043 {
00044 ChatSessionMembersListModel *membermodel = dynamic_cast<ChatSessionMembersListModel *>(model());
00045 if ( membermodel )
00046 {
00047 Kopete::Contact *c = membermodel->contactAt(index);
00048
00049 if (!c)
00050 return;
00051
00052 KMenu *p = c->popupMenu( membermodel->session() );
00053 connect( p, SIGNAL( aboutToHide() ), p, SLOT( deleteLater() ) );
00054 p->popup( mapToGlobal(pos) );
00055 }
00056 }
00057 }
00058
00059 ChatMembersListView::~ChatMembersListView()
00060 {
00061 }
00062
00063 #include "chatmemberslistview.moc"
00064
00065
00066