diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index e490af1b8..1f7b20ac6 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -2,7 +2,7 @@ * * RetroShare is distributed under the following license: * - * Copyright (C) 2011, csoler + * Copyright (C) 2011, csoler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -16,7 +16,7 @@ * * 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, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * ****************************************************************/ @@ -87,7 +87,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi ui.participantsList->setColumnWidth(COLUMN_ICON, 1.7*S); ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true); ui.participantsList->setColumnHidden(COLUMN_ID,true); - + /* Set header resize modes and initial section sizes */ QHeaderView * header = ui.participantsList->header(); QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch); @@ -99,16 +99,16 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi 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); showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); - + QActionGroup *sortgrp = new QActionGroup(this); actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this); actionSortByName->setCheckable(true); - actionSortByName->setChecked(true); + actionSortByName->setChecked(true); actionSortByName->setActionGroup(sortgrp); actionSortByActivity = new QAction(QIcon(), tr("Sort by Activity"), this); actionSortByActivity->setCheckable(true); - actionSortByActivity->setChecked(false); + actionSortByActivity->setChecked(false); actionSortByActivity->setActionGroup(sortgrp); @@ -122,7 +122,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(actionSortByName, 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 ); @@ -163,7 +163,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi } ownIdChooser = new GxsIdChooser() ; ownIdChooser->loadIds(idChooserFlag, current_id) ; - + QWidgetAction *checkableAction = new QWidgetAction(this); checkableAction->setDefaultWidget(ownIdChooser); @@ -246,8 +246,8 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint) void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/) { - if (anchorForPosition.startsWith(PERSONID)){ - QString strId = anchorForPosition.replace(PERSONID,""); + if (anchorForPosition.startsWith(PERSONID)) { + QString strId = anchorForPosition.replace(PERSONID, ""); if (strId.contains(" ")) strId.truncate(strId.indexOf(" ")); @@ -263,6 +263,8 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListaddAction(distantChatAct); contextMnu->addAction(sendMessageAct); @@ -281,7 +283,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListsetEnabled(false); voteNeutralAct->setEnabled(false); voteNegativeAct->setEnabled(false); - showInPeopleAct->setEnabled(idList.count()==1); + showInPeopleAct->setEnabled(idList.count() == 1); distantChatAct->setData(QVariant::fromValue(idList)); sendMessageAct->setData(QVariant::fromValue(idList)); @@ -291,19 +293,16 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListsetData(QVariant::fromValue(idList)); showInPeopleAct->setData(QVariant::fromValue(idList)); - if(idList.count()==1) - { - RsGxsId gxsid = idList.at(0); + RsGxsId gxsid = idList.at(0); - if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) - { - distantChatAct->setEnabled(true); - votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); - voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); - voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); - muteAct->setEnabled(true); - muteAct->setChecked(isParticipantMuted(gxsid)); - } + if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) + { + distantChatAct->setEnabled(true); + votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); + voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); + voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); + muteAct->setEnabled(true); + muteAct->setChecked(isParticipantMuted(gxsid)); } } @@ -443,17 +442,17 @@ void ChatLobbyDialog::processSettings(bool load) // state of splitter ui.splitter->restoreState(Settings->value("splitter").toByteArray()); - + // load sorting actionSortByActivity->setChecked(Settings->value("sortbyActivity", QVariant(false)).toBool()); actionSortByName->setChecked(Settings->value("sortbyName", QVariant(true)).toBool()); - + } else { // save settings // state of splitter Settings->setValue("splitter", ui.splitter->saveState()); - + //save sorting Settings->setValue("sortbyActivity", actionSortByActivity->isChecked()); Settings->setValue("sortbyName", actionSortByName->isChecked()); @@ -464,7 +463,7 @@ void ChatLobbyDialog::processSettings(bool load) /** * Change your Nickname - * + * * - send a Message to all Members => later: send hidden message to clients, so they can actualize there mutedParticipants list */ void ChatLobbyDialog::setIdentity(const RsGxsId& gxs_id) @@ -500,7 +499,7 @@ void ChatLobbyDialog::changeNickname() /** * We get a new Message from a chat participant - * + * * - Ignore Messages from muted chat participants */ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) @@ -509,7 +508,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QString message = QString::fromUtf8(msg.msg.c_str()); RsGxsId gxs_id = msg.lobby_peer_gxs_id ; - + if(!isParticipantMuted(gxs_id)) { // We could change addChatMsg to display the peers icon, passing a ChatId @@ -551,7 +550,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) /** * Regenerate the QTreeWidget participant list of a Chat Lobby - * + * * Show yellow icon for muted Participants */ void ChatLobbyDialog::updateParticipantsList() @@ -602,7 +601,7 @@ void ChatLobbyDialog::updateParticipantsList() time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt(); time_t now = time(NULL); - + widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20)); @@ -619,7 +618,7 @@ void ChatLobbyDialog::updateParticipantsList() if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, bullet_yellow_128); widgetitem->updateBannedState(); - + QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct); widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants
Double click to address this person
") +tr("This participant is not active since:") @@ -635,7 +634,7 @@ void ChatLobbyDialog::updateParticipantsList() /** * Called when a Participant get Clicked / Changed - * + * * Check if the Checkbox altered and Mute User */ void ChatLobbyDialog::changeParticipationState() @@ -787,15 +786,15 @@ bool ChatLobbyDialog::isNicknameInLobby(const RsGxsId& nickname) return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ; } -/** +/** * Should Messages from this Nickname be muted? - * + * * At the moment it is not possible to 100% know which peer sendet the message, and only - * the nickname is available. So this couldn't work for 100%. So, for example, if a peer - * change his name to the name of a other peer, we couldn't block him. A real implementation + * the nickname is available. So this couldn't work for 100%. So, for example, if a peer + * change his name to the name of a other peer, we couldn't block him. A real implementation * will be possible if we transfer a temporary Session ID from the sending Retroshare client * version 0.6 - * + * * @param QString nickname to check */ bool ChatLobbyDialog::isParticipantMuted(const RsGxsId& participant) @@ -901,7 +900,7 @@ bool ChatLobbyDialog::canClose() void ChatLobbyDialog::showDialog(uint chatflags) { - if (chatflags & RS_CHAT_FOCUS) + if (chatflags & RS_CHAT_FOCUS) { MainWindow::showWindow(MainWindow::ChatLobby); dynamic_cast(MainWindow::getPage(MainWindow::ChatLobby))->setCurrentChatPage(this) ; @@ -916,7 +915,7 @@ void ChatLobbyDialog::sortParcipants() } else if (actionSortByName->isChecked()) { ui.participantsList->sortItems(COLUMN_NAME, Qt::AscendingOrder); } - + } void ChatLobbyDialog::filterChanged(const QString& /*text*/)