Added Sorting Menu entry.

This commit is contained in:
defnax 2015-12-18 01:40:39 +01:00
parent 5b63762eef
commit 03896d7f8c
2 changed files with 33 additions and 1 deletions

View File

@ -81,10 +81,25 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
muteAct = new QAction(QIcon(), tr("Mute participant"), this); muteAct = new QAction(QIcon(), tr("Mute participant"), this);
distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this); distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this);
sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this); sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this);
QActionGroup *sortgrp = new QActionGroup(this);
actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this);
actionSortByName->setCheckable(true);
actionSortByName->setChecked(true);
actionSortByName->setActionGroup(sortgrp);
actionSortByActivity = new QAction(QIcon(), tr("Sort by Activity"), this);
actionSortByActivity->setCheckable(true);
actionSortByActivity->setChecked(false);
actionSortByActivity->setActionGroup(sortgrp);
connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState())); connect(muteAct, SIGNAL(triggered()), this, SLOT(changePartipationState()));
connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant())); connect(distantChatAct, SIGNAL(triggered()), this, SLOT(distantChatParticipant()));
connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage())); connect(sendMessageAct, SIGNAL(triggered()), this, SLOT(sendMessage()));
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
// Add a button to invite friends. // Add a button to invite friends.
// //
@ -181,6 +196,9 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint)
contextMnu.addAction(sendMessageAct); contextMnu.addAction(sendMessageAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
contextMnu.addAction(muteAct); contextMnu.addAction(muteAct);
contextMnu.addSeparator();
contextMnu.addAction(actionSortByActivity);
contextMnu.addAction(actionSortByName);
muteAct->setCheckable(true); muteAct->setCheckable(true);
@ -477,7 +495,7 @@ void ChatLobbyDialog::updateParticipantsList()
} }
} }
ui.participantsList->setSortingEnabled(true); ui.participantsList->setSortingEnabled(true);
ui.participantsList->sortItems(COLUMN_ACTIVITY, Qt::DescendingOrder); sortParcipants();
} }
/** /**
@ -767,3 +785,14 @@ void ChatLobbyDialog::showDialog(uint chatflags)
dynamic_cast<ChatLobbyWidget*>(MainWindow::getPage(MainWindow::ChatLobby))->setCurrentChatPage(this) ; dynamic_cast<ChatLobbyWidget*>(MainWindow::getPage(MainWindow::ChatLobby))->setCurrentChatPage(this) ;
} }
} }
void ChatLobbyDialog::sortParcipants()
{
if (actionSortByActivity->isChecked()) {
ui.participantsList->sortItems(COLUMN_ACTIVITY, Qt::DescendingOrder);
} else if (actionSortByName->isChecked()) {
ui.participantsList->sortItems(COLUMN_NAME, Qt::AscendingOrder);
}
}

View File

@ -47,6 +47,7 @@ public:
void setIdentity(const RsGxsId& gxs_id); void setIdentity(const RsGxsId& gxs_id);
bool isParticipantMuted(const RsGxsId &participant); bool isParticipantMuted(const RsGxsId &participant);
ChatLobbyId id() const { return lobbyId ;} ChatLobbyId id() const { return lobbyId ;}
void sortParcipants();
private slots: private slots:
void participantsTreeWidgetCustomPopupMenu( QPoint point ); void participantsTreeWidgetCustomPopupMenu( QPoint point );
@ -104,6 +105,8 @@ private:
QAction *muteAct; QAction *muteAct;
QAction *distantChatAct; QAction *distantChatAct;
QAction *actionSortByName;
QAction *actionSortByActivity;
QWidgetAction *checkableAction; QWidgetAction *checkableAction;
QAction *sendMessageAct; QAction *sendMessageAct;