QTfrontend/chatwidget.cpp
changeset 1391 735f6d43780b
parent 1360 d3e285281c26
child 1405 ee4b28a1861d
--- a/QTfrontend/chatwidget.cpp	Tue Oct 21 13:39:34 2008 +0000
+++ b/QTfrontend/chatwidget.cpp	Tue Oct 21 16:53:34 2008 +0000
@@ -18,6 +18,7 @@
 
 #include <QListWidget>
 #include <QLineEdit>
+#include <QAction>
 
 #include "chatwidget.h"
 
@@ -46,7 +47,12 @@
   chatNicks->setMinimumHeight(10);
   chatNicks->setMinimumWidth(10);
   chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+  chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
   mainLayout.addWidget(chatNicks, 0, 1);
+
+  QAction * acBan = new QAction(QAction::tr("Kick"), chatNicks);
+  connect(acBan, SIGNAL(triggered(bool)), this, SLOT(onKick()));
+  chatNicks->insertAction(0, acBan);
 }
 
 void HWChatWidget::returnPressed()
@@ -65,12 +71,13 @@
 
 void HWChatWidget::nickAdded(const QString& nick)
 {
-  chatNicks->addItem(nick);
+	QListWidgetItem * item = new QListWidgetItem(nick);
+	chatNicks->addItem(item);
 }
 
 void HWChatWidget::nickRemoved(const QString& nick)
 {
-  QList<QListWidgetItem *> items=chatNicks->findItems(nick, Qt::MatchExactly);
+  QList<QListWidgetItem *> items = chatNicks->findItems(nick, Qt::MatchExactly);
   for(QList<QListWidgetItem *>::iterator it=items.begin(); it!=items.end();) {
     chatNicks->takeItem(chatNicks->row(*it));
     ++it;
@@ -82,3 +89,10 @@
 	chatText->clear();
 	chatNicks->clear();
 }
+
+void HWChatWidget::onKick()
+{
+	QListWidgetItem * curritem = chatNicks->currentItem();
+	if (curritem)
+		emit kick(curritem->text());
+}