Added search filter for participants list.

This commit is contained in:
defnax 2016-08-12 22:19:44 +02:00
parent ab82c4a73c
commit 0e1c0c2eb3
3 changed files with 83 additions and 5 deletions

View File

@ -76,6 +76,8 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint))); connect(ui.participantsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(participantsTreeWidgetCustomPopupMenu(QPoint)));
connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int))); connect(ui.participantsList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(participantsTreeWidgetDoubleClicked(QTreeWidgetItem*,int)));
connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString)));
int S = QFontMetricsF(font()).height() ; int S = QFontMetricsF(font()).height() ;
ui.participantsList->setIconSize(QSize(1.3*S,1.3*S)); ui.participantsList->setIconSize(QSize(1.3*S,1.3*S));
@ -108,6 +110,11 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi
connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants())); connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants()));
connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants())); connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants()));
/* Add filter actions */
QTreeWidgetItem *headerItem = ui.participantsList->headerItem();
QString headerText = headerItem->text(COLUMN_NAME );
ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText));
// Add a button to invite friends. // Add a button to invite friends.
// //
@ -557,6 +564,7 @@ void ChatLobbyDialog::updateParticipantsList()
} }
ui.participantsList->setSortingEnabled(true); ui.participantsList->setSortingEnabled(true);
sortParcipants(); sortParcipants();
filterIds();
} }
/** /**
@ -857,3 +865,16 @@ void ChatLobbyDialog::sortParcipants()
} }
} }
void ChatLobbyDialog::filterChanged(const QString& /*text*/)
{
filterIds();
}
void ChatLobbyDialog::filterIds()
{
int filterColumn = ui.filterLineEdit->currentFilter();
QString text = ui.filterLineEdit->text();
ui.participantsList->filterItems(filterColumn, text);
}

View File

@ -53,6 +53,7 @@ private slots:
void participantsTreeWidgetCustomPopupMenu( QPoint point ); void participantsTreeWidgetCustomPopupMenu( QPoint point );
void inviteFriends() ; void inviteFriends() ;
void leaveLobby() ; void leaveLobby() ;
void filterChanged(const QString &text);
signals: signals:
void lobbyLeave(ChatLobbyId) ; void lobbyLeave(ChatLobbyId) ;
@ -83,6 +84,8 @@ protected slots:
private: private:
void updateParticipantsList(); void updateParticipantsList();
void filterIds();
QString getParticipantName(const RsGxsId& id) const; QString getParticipantName(const RsGxsId& id) const;
void muteParticipant(const RsGxsId& id); void muteParticipant(const RsGxsId& id);

View File

@ -14,7 +14,16 @@
<string notr="true">MainWindow</string> <string notr="true">MainWindow</string>
</property> </property>
<layout class="QHBoxLayout" name="ChatLobbyDialogHLayout"> <layout class="QHBoxLayout" name="ChatLobbyDialogHLayout">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
@ -57,16 +66,43 @@
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin"> <property name="topMargin">
<number>3</number> <number>0</number>
</property> </property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>3</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="QTreeWidget" name="participantsList"> <widget class="QFrame" name="toolBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="toolBarFrameHLayout">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="LineEditClear" name="filterLineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="RSTreeWidget" name="participantsList">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -114,6 +150,11 @@
<string>Participants</string> <string>Participants</string>
</property> </property>
</column> </column>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -128,13 +169,26 @@
</action> </action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget>
<class>LineEditClear</class>
<extends>QLineEdit</extends>
<header location="global">gui/common/LineEditClear.h</header>
</customwidget>
<customwidget> <customwidget>
<class>ChatWidget</class> <class>ChatWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header location="global">gui/chat/ChatWidget.h</header> <header location="global">gui/chat/ChatWidget.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>RSTreeWidget</class>
<extends>QTreeWidget</extends>
<header>gui/common/RSTreeWidget.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../icons.qrc"/>
<include location="../images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>