mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 17:21:05 -04: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
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue