mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-12-16 17:13:58 -05:00
Added popularity column and removed hidden date column in forums tree.
Added new global class for working with popularity PopularityDefs. Changed the display of the popularity icons. 0 = icon 0 1-7 = icon 1 8-15 = icon 2 16-24 = icon 3 25-34 = icon 4 >34 = icon 5 This can be changed in PopularityDefs::icon. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3933 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
fd2955b28b
commit
404dfd0cbc
8 changed files with 228 additions and 151 deletions
|
|
@ -32,6 +32,7 @@
|
|||
#include "ChannelFeed.h"
|
||||
|
||||
#include "feeds/ChanMsgItem.h"
|
||||
#include "common/PopularityDefs.h"
|
||||
|
||||
#include "channels/CreateChannel.h"
|
||||
#include "channels/ChannelDetails.h"
|
||||
|
|
@ -530,7 +531,8 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
|||
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QDateTime::fromTime_t(ci.lastPost), ROLE_CHANNEL_TS);
|
||||
|
||||
|
||||
chNameItem->setToolTip(tr("Popularity: %1").arg(QString::number(ci.pop)));
|
||||
chNameItem->setToolTip(PopularityDefs::tooltip(ci.pop));
|
||||
chPopItem->setToolTip(PopularityDefs::tooltip(ci.pop));
|
||||
|
||||
QPixmap chanImage;
|
||||
if (ci.pngImageLen != 0) {
|
||||
|
|
@ -541,20 +543,7 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
|||
chNameItem->setIcon(QIcon(chanImage));
|
||||
|
||||
/* set Popularity icon */
|
||||
int popcount = ci.pop;
|
||||
if (popcount == 0) {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_0.png"));
|
||||
} else if (popcount < 2) {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_1.png"));
|
||||
} else if (popcount < 4) {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_2.png"));
|
||||
} else if (popcount < 8) {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_3.png"));
|
||||
} else if (popcount < 16) {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_4.png"));
|
||||
} else {
|
||||
chPopItem->setIcon(QIcon(":/images/hot_5.png"));
|
||||
}
|
||||
chPopItem->setIcon(PopularityDefs::icon(ci.pop));
|
||||
}
|
||||
|
||||
/* remove all items not in list */
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@
|
|||
#include "settings/rsharesettings.h"
|
||||
#include "common/Emoticons.h"
|
||||
#include "common/RSItemDelegate.h"
|
||||
#include "common/PopularityDefs.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsforums.h>
|
||||
|
||||
#include <sstream>
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
|
|
@ -66,9 +66,9 @@
|
|||
#define VIEW_FLAT 2
|
||||
|
||||
/* Forum constants */
|
||||
#define COLUMN_FORUM_COUNT 2
|
||||
#define COLUMN_FORUM_TITLE 0
|
||||
#define COLUMN_FORUM_DATE 1
|
||||
#define COLUMN_FORUM_COUNT 2
|
||||
#define COLUMN_FORUM_TITLE 0
|
||||
#define COLUMN_FORUM_POPULARITY 1
|
||||
|
||||
#define COLUMN_FORUM_DATA 0
|
||||
|
||||
|
|
@ -169,13 +169,17 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
|||
ui.threadTreeWidget->setItemDelegate(itemDelegate);
|
||||
|
||||
itemDelegate = new RSItemDelegate(this);
|
||||
itemDelegate->removeFocusRect(COLUMN_FORUM_POPULARITY);
|
||||
itemDelegate->setSpacing(QSize(0, 2));
|
||||
ui.forumTreeWidget->setItemDelegate(itemDelegate);
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * ftheader = ui.forumTreeWidget->header () ;
|
||||
ftheader->setResizeMode (COLUMN_FORUM_TITLE, QHeaderView::Interactive);
|
||||
ui.forumTreeWidget->setColumnCount(COLUMN_FORUM_COUNT);
|
||||
QHeaderView * ftheader = ui.forumTreeWidget->header ();
|
||||
ftheader->setResizeMode (COLUMN_FORUM_TITLE, QHeaderView::Stretch);
|
||||
ftheader->resizeSection (COLUMN_FORUM_TITLE, 170);
|
||||
ftheader->setResizeMode (COLUMN_FORUM_POPULARITY, QHeaderView::Fixed);
|
||||
ftheader->resizeSection (COLUMN_FORUM_POPULARITY, 25);
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * ttheader = ui.threadTreeWidget->header () ;
|
||||
|
|
@ -496,10 +500,10 @@ void ForumsDialog::insertForums()
|
|||
|
||||
rsForums->getForumList(forumList);
|
||||
|
||||
QList<QTreeWidgetItem *> AdminList;
|
||||
QList<QTreeWidgetItem *> SubList;
|
||||
QList<QTreeWidgetItem *> PopList;
|
||||
QList<QTreeWidgetItem *> OtherList;
|
||||
QList<QTreeWidgetItem *> AdminList;
|
||||
QList<QTreeWidgetItem *> SubList;
|
||||
QList<QTreeWidgetItem *> PopList;
|
||||
QList<QTreeWidgetItem *> OtherList;
|
||||
std::multimap<uint32_t, std::string> popMap;
|
||||
|
||||
for(it = forumList.begin(); it != forumList.end(); it++)
|
||||
|
|
@ -518,38 +522,29 @@ void ForumsDialog::insertForums()
|
|||
* ForumId,
|
||||
*/
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
QString name = QString::fromStdWString(it->forumName);
|
||||
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
name += " (AUTHD)";
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
}
|
||||
else
|
||||
{
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
}
|
||||
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
|
||||
/* (1) Popularity */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->pop;
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
||||
}
|
||||
item -> setIcon(COLUMN_FORUM_POPULARITY, PopularityDefs::icon(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, PopularityDefs::tooltip(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_POPULARITY, PopularityDefs::tooltip(it->pop));
|
||||
|
||||
// Date
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(it->lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
||||
}
|
||||
// Id.
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
AdminList.append(item);
|
||||
}
|
||||
else if (flags & RS_DISTRIB_SUBSCRIBED)
|
||||
|
|
@ -563,38 +558,29 @@ void ForumsDialog::insertForums()
|
|||
* ForumId,
|
||||
*/
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
QString name = QString::fromStdWString(it->forumName);
|
||||
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
name += " (AUTHD)";
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
}
|
||||
else
|
||||
{
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
}
|
||||
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
|
||||
/* (1) Popularity */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->pop;
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
||||
}
|
||||
item -> setIcon(COLUMN_FORUM_POPULARITY, PopularityDefs::icon(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, PopularityDefs::tooltip(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_POPULARITY, PopularityDefs::tooltip(it->pop));
|
||||
|
||||
// Date
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(it->lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
||||
}
|
||||
// Id.
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
SubList.append(item);
|
||||
}
|
||||
else
|
||||
|
|
@ -635,7 +621,7 @@ void ForumsDialog::insertForums()
|
|||
}
|
||||
else
|
||||
{
|
||||
/* popular forum */
|
||||
/* popular forum */
|
||||
|
||||
/* Name,
|
||||
* Type,
|
||||
|
|
@ -644,39 +630,30 @@ void ForumsDialog::insertForums()
|
|||
* ForumId,
|
||||
*/
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
QString name = QString::fromStdWString(it->forumName);
|
||||
if (it->forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
name += " (AUTHD)";
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUMAUTHD)));
|
||||
}
|
||||
else
|
||||
{
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
item -> setIcon(COLUMN_FORUM_TITLE,(QIcon(IMAGE_FORUM)));
|
||||
}
|
||||
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
item -> setText(COLUMN_FORUM_TITLE, name);
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_TITLE, name);
|
||||
|
||||
|
||||
/* (1) Popularity */
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->pop;
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, tr("Popularity:") + " " + QString::fromStdString(out.str()));
|
||||
}
|
||||
item -> setIcon(COLUMN_FORUM_POPULARITY, PopularityDefs::icon(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_TITLE, PopularityDefs::tooltip(it->pop));
|
||||
item -> setToolTip(COLUMN_FORUM_POPULARITY, PopularityDefs::tooltip(it->pop));
|
||||
|
||||
// Date
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(it->lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
item -> setText(COLUMN_FORUM_DATE, timestamp);
|
||||
}
|
||||
// Id.
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
item -> setData(COLUMN_FORUM_DATA, ROLE_FORUM_ID, QString::fromStdString(it->forumId));
|
||||
|
||||
if (it->pop < popLimit)
|
||||
{
|
||||
|
|
@ -690,18 +667,18 @@ void ForumsDialog::insertForums()
|
|||
}
|
||||
|
||||
/* now we can add them in as a tree! */
|
||||
FillForums (YourForums, AdminList);
|
||||
FillForums (SubscribedForums, SubList);
|
||||
FillForums (PopularForums, PopList);
|
||||
FillForums (OtherForums, OtherList);
|
||||
FillForums (YourForums, AdminList);
|
||||
FillForums (SubscribedForums, SubList);
|
||||
FillForums (PopularForums, PopList);
|
||||
FillForums (OtherForums, OtherList);
|
||||
|
||||
// cleanup
|
||||
CleanupItems (AdminList);
|
||||
CleanupItems (SubList);
|
||||
CleanupItems (PopList);
|
||||
CleanupItems (OtherList);
|
||||
// cleanup
|
||||
CleanupItems (AdminList);
|
||||
CleanupItems (SubList);
|
||||
CleanupItems (PopList);
|
||||
CleanupItems (OtherList);
|
||||
|
||||
updateMessageSummaryList("");
|
||||
updateMessageSummaryList("");
|
||||
}
|
||||
|
||||
void ForumsDialog::FillForums(QTreeWidgetItem *Forum, QList<QTreeWidgetItem *> &ChildList)
|
||||
|
|
|
|||
|
|
@ -745,9 +745,21 @@ p, li { white-space: pre-wrap; }
|
|||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
<property name="headerHidden">
|
||||
<bool>true</bool>
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>RetroShare Forums</string>
|
||||
|
|
|
|||
51
retroshare-gui/src/gui/common/PopularityDefs.cpp
Normal file
51
retroshare-gui/src/gui/common/PopularityDefs.cpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, 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 <QCoreApplication>
|
||||
|
||||
#include "PopularityDefs.h"
|
||||
|
||||
QIcon PopularityDefs::icon(int popularity)
|
||||
{
|
||||
if (popularity == 0) {
|
||||
return QIcon(":/images/hot_0.png");
|
||||
} else if (popularity <= 7) {
|
||||
/* 1-7 */
|
||||
return QIcon(":/images/hot_1.png");
|
||||
} else if (popularity <= 15) {
|
||||
/* 8-15 */
|
||||
return QIcon(":/images/hot_2.png");
|
||||
} else if (popularity <= 24) {
|
||||
/* 16-24 */
|
||||
return QIcon(":/images/hot_3.png");
|
||||
} else if (popularity <= 34) {
|
||||
/* 25-34 */
|
||||
return QIcon(":/images/hot_4.png");
|
||||
}
|
||||
|
||||
/* >34 */
|
||||
return QIcon(":/images/hot_5.png");
|
||||
}
|
||||
|
||||
QString PopularityDefs::tooltip(int popularity)
|
||||
{
|
||||
return QString("%1: %2").arg(qApp->translate("PopularityDefs", "Popularity")).arg(popularity);
|
||||
}
|
||||
36
retroshare-gui/src/gui/common/PopularityDefs.h
Normal file
36
retroshare-gui/src/gui/common/PopularityDefs.h
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/****************************************************************
|
||||
* This file is distributed under the following license:
|
||||
*
|
||||
* Copyright (c) 2010, 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 _POPULARITYDEFS_H
|
||||
#define _POPULARITYDEFS_H
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
class PopularityDefs
|
||||
{
|
||||
public:
|
||||
static QIcon icon(int popularity);
|
||||
static QString tooltip(int popularity);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue