QTfrontend/chatwidget.cpp
changeset 2847 cde320fd3122
parent 2846 1cb8b4c425ed
child 2948 3f21a9dc93d0
equal deleted inserted replaced
2846:1cb8b4c425ed 2847:cde320fd3122
    76 	chatNicks->setSortingEnabled(true);
    76 	chatNicks->setSortingEnabled(true);
    77 	chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    77 	chatNicks->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    78 	chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
    78 	chatNicks->setContextMenuPolicy(Qt::ActionsContextMenu);
    79 	connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
    79 	connect(chatNicks, SIGNAL(itemDoubleClicked(QListWidgetItem *)),
    80 		this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
    80 		this, SLOT(chatNickDoubleClicked(QListWidgetItem *)));
    81 	connect(chatNicks, SIGNAL(itemClicked(QListWidgetItem *)),
    81 	connect(chatNicks, SIGNAL(currentRowChanged(int)),
    82 		this, SLOT(chatNickClicked(QListWidgetItem *)));
    82 		this, SLOT(chatNickSelected(int)));
    83 
    83 
    84 	mainLayout.addWidget(chatNicks, 0, 1);
    84 	mainLayout.addWidget(chatNicks, 0, 1);
    85 
    85 
    86 	acInfo = new QAction(QAction::tr("Info"), chatNicks);
    86 	acInfo = new QAction(QAction::tr("Info"), chatNicks);
    87 	connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
    87 	connect(acInfo, SIGNAL(triggered(bool)), this, SLOT(onInfo()));
   301 	else // not on list - add
   301 	else // not on list - add
   302 	{
   302 	{
   303 		ignoreList << curritem->text().toLower();
   303 		ignoreList << curritem->text().toLower();
   304 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
   304 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your ignore list").arg('\x03').arg(curritem->text()));
   305 	}
   305 	}
   306 	updateIcon(curritem);
   306 	updateIcon(curritem); // update icon
       
   307 	chatNickSelected(0); // update context menu
   307 }
   308 }
   308 
   309 
   309 void HWChatWidget::onFriend()
   310 void HWChatWidget::onFriend()
   310 {
   311 {
   311 	QListWidgetItem * curritem = chatNicks->currentItem();
   312 	QListWidgetItem * curritem = chatNicks->currentItem();
   320 	else // not on list - add
   321 	else // not on list - add
   321 	{
   322 	{
   322 		friendsList << curritem->text().toLower();
   323 		friendsList << curritem->text().toLower();
   323 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text()));
   324 		onChatString(HWChatWidget::tr("%1 *** %2 has been added to your friends list").arg('\x03').arg(curritem->text()));
   324 	}
   325 	}
   325 	updateIcon(curritem);
   326 	updateIcon(curritem); // update icon
       
   327 	chatNickSelected(0); // update context menu
   326 }
   328 }
   327 
   329 
   328 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
   330 void HWChatWidget::chatNickDoubleClicked(QListWidgetItem * item)
   329 {
   331 {
   330 	if (item) onFollow();
   332 	if (item) onFollow();
   331 }
   333 }
   332 
   334 
   333 void HWChatWidget::chatNickClicked(QListWidgetItem * item)
   335 void HWChatWidget::chatNickSelected(int index)
   334 {
   336 {
       
   337 	QListWidgetItem* item = chatNicks->currentItem();
   335 	if (!item)
   338 	if (!item)
   336 		return;
   339 		return;
   337 
   340 
   338 	// update context menu labels according to possible action
   341 	// update context menu labels according to possible action
   339 	if(ignoreList.contains(item->text(), Qt::CaseInsensitive))
   342 	if(ignoreList.contains(item->text(), Qt::CaseInsensitive))