mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Sort participants list in the chat lobby case insensitive.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5186 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
55b6211e7e
commit
50bc57b0fe
@ -340,6 +340,7 @@ HEADERS += rshare.h \
|
|||||||
gui/common/TagDefs.h \
|
gui/common/TagDefs.h \
|
||||||
gui/common/GroupDefs.h \
|
gui/common/GroupDefs.h \
|
||||||
gui/common/Emoticons.h \
|
gui/common/Emoticons.h \
|
||||||
|
gui/common/RSListWidgetItem.h \
|
||||||
gui/common/RSTreeWidgetItem.h \
|
gui/common/RSTreeWidgetItem.h \
|
||||||
gui/common/RSTabWidget.h \
|
gui/common/RSTabWidget.h \
|
||||||
gui/common/RSItemDelegate.h \
|
gui/common/RSItemDelegate.h \
|
||||||
@ -594,6 +595,7 @@ SOURCES += main.cpp \
|
|||||||
gui/common/TagDefs.cpp \
|
gui/common/TagDefs.cpp \
|
||||||
gui/common/GroupDefs.cpp \
|
gui/common/GroupDefs.cpp \
|
||||||
gui/common/Emoticons.cpp \
|
gui/common/Emoticons.cpp \
|
||||||
|
gui/common/RSListWidgetItem.cpp \
|
||||||
gui/common/RSTreeWidgetItem.cpp \
|
gui/common/RSTreeWidgetItem.cpp \
|
||||||
gui/common/RSTabWidget.cpp \
|
gui/common/RSTabWidget.cpp \
|
||||||
gui/common/RSItemDelegate.cpp \
|
gui/common/RSItemDelegate.cpp \
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include "gui/MainWindow.h"
|
#include "gui/MainWindow.h"
|
||||||
#include "gui/FriendsDialog.h"
|
#include "gui/FriendsDialog.h"
|
||||||
#include <gui/common/html.h>
|
#include <gui/common/html.h>
|
||||||
|
#include "gui/common/RSListWidgetItem.h"
|
||||||
|
|
||||||
#include <retroshare/rsnotify.h>
|
#include <retroshare/rsnotify.h>
|
||||||
|
|
||||||
@ -47,8 +48,6 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::WF
|
|||||||
|
|
||||||
// Mute a Participant
|
// Mute a Participant
|
||||||
connect(ui.participantsList, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(changePartipationState(QListWidgetItem *)));
|
connect(ui.participantsList, SIGNAL(itemClicked(QListWidgetItem *)), SLOT(changePartipationState(QListWidgetItem *)));
|
||||||
|
|
||||||
ui.participantsList->sortItems(Qt::AscendingOrder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
|
void ChatLobbyDialog::init(const std::string &peerId, const QString &title)
|
||||||
@ -205,6 +204,7 @@ void ChatLobbyDialog::addIncomingChatMsg(const ChatInfo& info)
|
|||||||
void ChatLobbyDialog::updateParticipantsList()
|
void ChatLobbyDialog::updateParticipantsList()
|
||||||
{
|
{
|
||||||
ui.participantsList->clear();
|
ui.participantsList->clear();
|
||||||
|
ui.participantsList->setSortingEnabled(false);
|
||||||
|
|
||||||
std::list<ChatLobbyInfo> linfos;
|
std::list<ChatLobbyInfo> linfos;
|
||||||
rsMsgs->getChatLobbyList(linfos);
|
rsMsgs->getChatLobbyList(linfos);
|
||||||
@ -219,7 +219,7 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||||||
QString participant = QString::fromUtf8( (it2->first).c_str() );
|
QString participant = QString::fromUtf8( (it2->first).c_str() );
|
||||||
|
|
||||||
// TE: Add Wigdet to participantsList with Checkbox, to mute Participant
|
// TE: Add Wigdet to participantsList with Checkbox, to mute Participant
|
||||||
QListWidgetItem *widgetitem = new QListWidgetItem(ui.participantsList);
|
QListWidgetItem *widgetitem = new RSListWidgetItem;
|
||||||
|
|
||||||
if (isParticipantMuted(participant)) {
|
if (isParticipantMuted(participant)) {
|
||||||
widgetitem->setCheckState(Qt::Unchecked);
|
widgetitem->setCheckState(Qt::Unchecked);
|
||||||
@ -232,6 +232,9 @@ void ChatLobbyDialog::updateParticipantsList()
|
|||||||
ui.participantsList->addItem(widgetitem);
|
ui.participantsList->addItem(widgetitem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.participantsList->setSortingEnabled(true);
|
||||||
|
ui.participantsList->sortItems(Qt::AscendingOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
76
retroshare-gui/src/gui/common/RSListWidgetItem.cpp
Normal file
76
retroshare-gui/src/gui/common/RSListWidgetItem.cpp
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* This file is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#include "RSListWidgetItem.h"
|
||||||
|
|
||||||
|
RSListWidgetItem::RSListWidgetItem(QListWidget *view, int type) : QListWidgetItem(view, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RSListWidgetItem::RSListWidgetItem(const QString &text, QListWidget *view, int type) : QListWidgetItem(text, view, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RSListWidgetItem::RSListWidgetItem(const QIcon &icon, const QString &text, QListWidget *view, int type) : QListWidgetItem(icon, text, view, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
RSListWidgetItem::RSListWidgetItem(const QListWidgetItem &other) : QListWidgetItem(other)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint typeOfVariant(const QVariant &value)
|
||||||
|
{
|
||||||
|
//return 0 for integer, 1 for floating point and 2 for other
|
||||||
|
switch (value.userType()) {
|
||||||
|
case QVariant::Bool:
|
||||||
|
case QVariant::Int:
|
||||||
|
case QVariant::UInt:
|
||||||
|
case QVariant::LongLong:
|
||||||
|
case QVariant::ULongLong:
|
||||||
|
case QVariant::Char:
|
||||||
|
case QMetaType::Short:
|
||||||
|
case QMetaType::UShort:
|
||||||
|
case QMetaType::UChar:
|
||||||
|
case QMetaType::ULong:
|
||||||
|
case QMetaType::Long:
|
||||||
|
return 0;
|
||||||
|
case QVariant::Double:
|
||||||
|
case QMetaType::Float:
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RSListWidgetItem::operator<(const QListWidgetItem &other) const
|
||||||
|
{
|
||||||
|
const QVariant v1 = data(Qt::DisplayRole);
|
||||||
|
const QVariant v2 = other.data(Qt::DisplayRole);
|
||||||
|
|
||||||
|
switch (qMax(typeOfVariant(v1), typeOfVariant(v2))) {
|
||||||
|
case 0: //integer type
|
||||||
|
return v1.toLongLong() < v2.toLongLong();
|
||||||
|
case 1: //floating point
|
||||||
|
return v1.toReal() < v2.toReal();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (v1.toString().compare (v2.toString(), Qt::CaseInsensitive) < 0);
|
||||||
|
}
|
39
retroshare-gui/src/gui/common/RSListWidgetItem.h
Normal file
39
retroshare-gui/src/gui/common/RSListWidgetItem.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/****************************************************************
|
||||||
|
* This file is distributed under the following license:
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012, RetroShare Team
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||||
|
* Boston, MA 02110-1301, USA.
|
||||||
|
****************************************************************/
|
||||||
|
|
||||||
|
#ifndef _RSLISTWIDGETITEM_H
|
||||||
|
#define _RSLISTWIDGETITEM_H
|
||||||
|
|
||||||
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
class RSListWidgetItem : public QListWidgetItem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RSListWidgetItem(QListWidget *view = 0, int type = Type);
|
||||||
|
RSListWidgetItem(const QString &text, QListWidget *view = 0, int type = Type);
|
||||||
|
RSListWidgetItem(const QIcon &icon, const QString &text, QListWidget *view = 0, int type = Type);
|
||||||
|
RSListWidgetItem(const QListWidgetItem &other);
|
||||||
|
|
||||||
|
bool operator<(const QListWidgetItem &other) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user