mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
Added display menu in channels and forums to sort the group tree by name, popularity or last post.
Removed unnecessary loop over the forum messages in ForumDetails. Removed date and time when lastPost==0 in ForumDetails and ChannelDetails. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3950 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
28b4534fdf
commit
ff57befb1f
@ -32,6 +32,7 @@
|
||||
|
||||
#include "feeds/ChanMsgItem.h"
|
||||
#include "common/PopularityDefs.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
|
||||
#include "channels/CreateChannel.h"
|
||||
#include "channels/ChannelDetails.h"
|
||||
@ -70,10 +71,13 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
|
||||
mChannelId.clear();
|
||||
|
||||
ownChannels = treeWidget->addCategoryItem(tr("Own Channels"), QIcon(), true);
|
||||
subcribedChannels = treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(), true);
|
||||
popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(), false);
|
||||
otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(), false);
|
||||
/* Initialize group tree */
|
||||
treeWidget->initDisplayMenu(displayButton);
|
||||
|
||||
ownChannels = treeWidget->addCategoryItem(tr("Own Channels"), QIcon(), true);
|
||||
subcribedChannels = treeWidget->addCategoryItem(tr("Subscribed Channels"), QIcon(), true);
|
||||
popularChannels = treeWidget->addCategoryItem(tr("Popular Channels"), QIcon(), false);
|
||||
otherChannels = treeWidget->addCategoryItem(tr("Other Channels"), QIcon(), false);
|
||||
|
||||
//added from ahead
|
||||
updateChannelList();
|
||||
@ -87,9 +91,33 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
channelmenu->addSeparator();
|
||||
channelpushButton->setMenu(channelmenu);
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
|
||||
updateChannelMsgs();
|
||||
}
|
||||
|
||||
ChannelFeed::~ChannelFeed()
|
||||
{
|
||||
// save settings
|
||||
processSettings(false);
|
||||
}
|
||||
|
||||
void ChannelFeed::processSettings(bool load)
|
||||
{
|
||||
Settings->beginGroup(QString("ChannelFeed"));
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
} else {
|
||||
// save settings
|
||||
}
|
||||
|
||||
treeWidget->processSettings(Settings, load);
|
||||
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void ChannelFeed::channelListCustomPopupMenu( QPoint point )
|
||||
{
|
||||
ChannelInfo ci;
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
/** Default Constructor */
|
||||
ChannelFeed(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
~ChannelFeed();
|
||||
|
||||
virtual void deleteFeedItem(QWidget *item, uint32_t type);
|
||||
virtual void openChat(std::string peerId);
|
||||
@ -75,6 +76,8 @@ private:
|
||||
void updateChannelMsgs();
|
||||
void updateMessageSummaryList(const std::string &channelId);
|
||||
|
||||
void processSettings(bool load);
|
||||
|
||||
std::string mChannelId; /* current Channel */
|
||||
|
||||
/* Layout Pointers */
|
||||
|
@ -174,7 +174,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="channelpushButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
@ -204,12 +204,6 @@ p, li { white-space: pre-wrap; }
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -256,6 +250,35 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="displayButton">
|
||||
<property name="toolTip">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton::menu-indicator {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: bottom right;
|
||||
}
|
||||
|
||||
QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open {
|
||||
position: relative;
|
||||
top: 2px; left: 2px; /* shift the arrow by 2 px */
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
border: 1px solid #CCCCCC;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -551,7 +574,7 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>417</width>
|
||||
<width>412</width>
|
||||
<height>331</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -177,6 +177,9 @@ ForumsDialog::ForumsDialog(QWidget *parent)
|
||||
forummenu->addSeparator();
|
||||
ui.forumpushButton->setMenu(forummenu);
|
||||
|
||||
/* Initialize group tree */
|
||||
ui.forumTreeWidget->initDisplayMenu(ui.displayButton);
|
||||
|
||||
/* create forum tree */
|
||||
yourForums = ui.forumTreeWidget->addCategoryItem(tr("Your Forums"), QIcon(IMAGE_FOLDER), true);
|
||||
subscribedForums = ui.forumTreeWidget->addCategoryItem(tr("Subscribed Forums"), QIcon(IMAGE_FOLDERRED), true);
|
||||
@ -249,6 +252,8 @@ void ForumsDialog::processSettings(bool bLoad)
|
||||
Settings->setValue("threadSplitter", ui.threadSplitter->saveState());
|
||||
}
|
||||
|
||||
ui.forumTreeWidget->processSettings(Settings, bLoad);
|
||||
|
||||
Settings->endGroup();
|
||||
m_bProcessSettings = false;
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<item row="0" column="5">
|
||||
<widget class="QPushButton" name="forumpushButton">
|
||||
<property name="toolTip">
|
||||
<string>Add</string>
|
||||
@ -668,12 +668,6 @@ p, li { white-space: pre-wrap; }
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/edit_add24.png</normaloff>:/images/edit_add24.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
@ -682,7 +676,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="3">
|
||||
<widget class="QToolButton" name="newthreadButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -705,6 +699,35 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QPushButton" name="displayButton">
|
||||
<property name="toolTip">
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton::menu-indicator {
|
||||
subcontrol-origin: padding;
|
||||
subcontrol-position: bottom right;
|
||||
}
|
||||
|
||||
QPushButton::menu-indicator:pressed, QPushButton::menu-indicator:open {
|
||||
position: relative;
|
||||
top: 2px; left: 2px; /* shift the arrow by 2 px */
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
border: 1px solid #CCCCCC;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -608,11 +608,7 @@ p, li { white-space: pre-wrap; }
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="displayButton">
|
||||
<property name="toolTip">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Display</span></p></body></html></string>
|
||||
<string>Display</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton::menu-indicator {
|
||||
@ -629,9 +625,6 @@ p, li { white-space: pre-wrap; }
|
||||
border: 1px solid #CCCCCC;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="images.qrc">
|
||||
<normaloff>:/images/looknfeel.png</normaloff>:/images/looknfeel.png</iconset>
|
||||
|
@ -115,7 +115,7 @@ void ChannelDetails::loadChannel()
|
||||
}
|
||||
|
||||
// Set Last Channel Post Date
|
||||
{
|
||||
if (ci.lastPost) {
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(ci.lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
|
@ -19,11 +19,15 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QMenu>
|
||||
|
||||
#include "GroupTreeWidget.h"
|
||||
#include "ui_GroupTreeWidget.h"
|
||||
|
||||
#include "RSItemDelegate.h"
|
||||
#include "PopularityDefs.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "RSTreeWidgetItem.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -35,8 +39,9 @@
|
||||
#define ROLE_ID Qt::UserRole
|
||||
#define ROLE_NAME Qt::UserRole + 1
|
||||
#define ROLE_DESCRIPTION Qt::UserRole + 2
|
||||
#define ROLE_LASTPOST Qt::UserRole + 3
|
||||
#define ROLE_SEARCH_SCORE Qt::UserRole + 4
|
||||
#define ROLE_POPULARITY Qt::UserRole + 3
|
||||
#define ROLE_LASTPOST Qt::UserRole + 4
|
||||
#define ROLE_SEARCH_SCORE Qt::UserRole + 5
|
||||
|
||||
#define COMBO_NAME_INDEX 0
|
||||
#define COMBO_DESC_INDEX 1
|
||||
@ -46,6 +51,16 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
displayMenu = NULL;
|
||||
actionSortAscending = NULL;
|
||||
// actionSortDescending = NULL;
|
||||
actionSortByName = NULL;
|
||||
actionSortByPopularity = NULL;
|
||||
actionSortByLastPost = NULL;
|
||||
|
||||
compareRole = new RSTreeWidgetItemCompareRole;
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_NAME);
|
||||
|
||||
/* Connect signals */
|
||||
connect(ui->clearFilter, SIGNAL(clicked()), this, SLOT(clearFilter()));
|
||||
connect(ui->filterText, SIGNAL(textChanged(const QString &)), this, SLOT(filterChanged()));
|
||||
@ -91,6 +106,87 @@ void GroupTreeWidget::changeEvent(QEvent *e)
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::processSettings(RshareSettings *settings, bool load)
|
||||
{
|
||||
if (settings == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int SORTBY_NAME = 1;
|
||||
const int SORTBY_POPULRITY = 2;
|
||||
const int SORTBY_LASTPOST = 3;
|
||||
|
||||
if (load) {
|
||||
// load settings
|
||||
|
||||
// state of sort
|
||||
int sortby = settings->value("GroupSortBy").toInt();
|
||||
switch (sortby) {
|
||||
case SORTBY_NAME:
|
||||
if (actionSortByName) {
|
||||
actionSortByName->setChecked(true);
|
||||
}
|
||||
break;
|
||||
case SORTBY_POPULRITY:
|
||||
if (actionSortByPopularity) {
|
||||
actionSortByPopularity->setChecked(true);
|
||||
}
|
||||
break;
|
||||
case SORTBY_LASTPOST:
|
||||
if (actionSortByLastPost) {
|
||||
actionSortByLastPost->setChecked(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// save settings
|
||||
|
||||
// state of sort
|
||||
int sortby = SORTBY_NAME;
|
||||
if (actionSortByName && actionSortByName->isChecked()) {
|
||||
sortby = SORTBY_NAME;
|
||||
} else if (actionSortByPopularity && actionSortByPopularity->isChecked()) {
|
||||
sortby = SORTBY_POPULRITY;
|
||||
} else if (actionSortByLastPost && actionSortByLastPost->isChecked()) {
|
||||
sortby = SORTBY_LASTPOST;
|
||||
}
|
||||
settings->setValue("GroupSortBy", sortby);
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::initDisplayMenu(QPushButton *pushButton)
|
||||
{
|
||||
displayMenu = new QMenu();
|
||||
// QActionGroup *actionGroup = new QActionGroup(displayMenu);
|
||||
//
|
||||
// actionSortDescending = displayMenu->addAction(QIcon(":/images/sort_decrease.png"), tr("Sort Descending Order"), this, SLOT(sort()));
|
||||
// actionSortDescending->setCheckable(true);
|
||||
// actionSortDescending->setActionGroup(actionGroup);
|
||||
//
|
||||
// actionSortAscending = displayMenu->addAction(QIcon(":/images/sort_incr.png"), tr("Sort Ascending Order"), this, SLOT(sort()));
|
||||
// actionSortAscending->setCheckable(true);
|
||||
// actionSortAscending->setChecked(true); // set standard to sort ascending
|
||||
// actionSortAscending->setActionGroup(actionGroup);
|
||||
//
|
||||
// displayMenu->addSeparator();
|
||||
|
||||
QActionGroup *actionGroup = new QActionGroup(displayMenu);
|
||||
actionSortByName = displayMenu->addAction(QIcon(), tr("Sort by Name"), this, SLOT(sort()));
|
||||
actionSortByName->setCheckable(true);
|
||||
actionSortByName->setChecked(true); // set standard to sort by name
|
||||
actionSortByName->setActionGroup(actionGroup);
|
||||
|
||||
actionSortByPopularity = displayMenu->addAction(QIcon(), tr("Sort by Popularity"), this, SLOT(sort()));
|
||||
actionSortByPopularity->setCheckable(true);
|
||||
actionSortByPopularity->setActionGroup(actionGroup);
|
||||
|
||||
actionSortByLastPost = displayMenu->addAction(QIcon(), tr("Sort by Last Post"), this, SLOT(sort()));
|
||||
actionSortByLastPost->setCheckable(true);
|
||||
actionSortByLastPost->setActionGroup(actionGroup);
|
||||
|
||||
pushButton->setMenu(displayMenu);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::customContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
emit treeCustomContextMenuRequested(pos);
|
||||
@ -163,7 +259,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
}
|
||||
|
||||
if (item == NULL) {
|
||||
item = new GroupTreeWidgetItem();
|
||||
item = new RSTreeWidgetItem(compareRole);
|
||||
item->setData(COLUMN_DATA, ROLE_ID, itemInfo.id);
|
||||
categoryItem->addChild(item);
|
||||
}
|
||||
@ -173,7 +269,8 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
item->setData(COLUMN_DATA, ROLE_DESCRIPTION, itemInfo.description);
|
||||
|
||||
/* Set last post */
|
||||
item->setData(COLUMN_DATA, ROLE_LASTPOST, itemInfo.lastpost);
|
||||
qlonglong lastPost = itemInfo.lastpost.toTime_t();
|
||||
item->setData(COLUMN_DATA, ROLE_LASTPOST, -lastPost); // negative for correct sorting
|
||||
|
||||
/* Set icon */
|
||||
item->setIcon(COLUMN_NAME, itemInfo.icon);
|
||||
@ -181,6 +278,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
/* Set popularity */
|
||||
QString tooltip = PopularityDefs::tooltip(itemInfo.popularity);
|
||||
item->setIcon(COLUMN_POPULARITY, PopularityDefs::icon(itemInfo.popularity));
|
||||
item->setData(COLUMN_DATA, ROLE_POPULARITY, -itemInfo.popularity); // negative for correct sorting
|
||||
|
||||
/* Set tooltip */
|
||||
if (itemInfo.privatekey) {
|
||||
@ -220,7 +318,7 @@ void GroupTreeWidget::fillGroupItems(QTreeWidgetItem *categoryItem, const QList<
|
||||
}
|
||||
}
|
||||
|
||||
categoryItem->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
resort(categoryItem);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::setUnreadCount(QTreeWidgetItem *item, int unreadCount)
|
||||
@ -306,10 +404,7 @@ void GroupTreeWidget::filterChanged()
|
||||
/* Recalculate score */
|
||||
calculateScore(NULL);
|
||||
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
ui->treeWidget->topLevelItem(child)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
}
|
||||
resort(NULL);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::clearFilter()
|
||||
@ -321,10 +416,37 @@ void GroupTreeWidget::clearFilter()
|
||||
/* Recalculate score */
|
||||
calculateScore(NULL);
|
||||
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
ui->treeWidget->topLevelItem(child)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
resort(NULL);
|
||||
}
|
||||
|
||||
void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem)
|
||||
{
|
||||
Qt::SortOrder order = (actionSortAscending == NULL || actionSortAscending->isChecked()) ? Qt::AscendingOrder : Qt::DescendingOrder;
|
||||
|
||||
if (ui->filterText->text().isEmpty() == false) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_SEARCH_SCORE);
|
||||
compareRole->addRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
} else if (actionSortByName && actionSortByName->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_NAME);
|
||||
} else if (actionSortByPopularity && actionSortByPopularity->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_POPULARITY);
|
||||
} else if (actionSortByLastPost && actionSortByLastPost->isChecked()) {
|
||||
compareRole->setRole(COLUMN_DATA, ROLE_LASTPOST);
|
||||
}
|
||||
|
||||
if (categoryItem) {
|
||||
categoryItem->sortChildren(COLUMN_DATA, order);
|
||||
} else {
|
||||
int count = ui->treeWidget->topLevelItemCount();
|
||||
for (int child = 0; child < count; child++) {
|
||||
ui->treeWidget->topLevelItem(child)->sortChildren(COLUMN_DATA, order);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GroupTreeWidget::sort()
|
||||
{
|
||||
resort(NULL);
|
||||
}
|
||||
|
||||
GroupTreeWidgetItem::GroupTreeWidgetItem() : QTreeWidgetItem()
|
||||
@ -356,5 +478,5 @@ bool GroupTreeWidgetItem::operator<(const QTreeWidgetItem& other) const
|
||||
}
|
||||
|
||||
/* Compare name */
|
||||
return text(COLUMN_NAME) < other.text(COLUMN_NAME);
|
||||
return text(COLUMN_NAME) < other.text(COLUMN_NAME);
|
||||
}
|
||||
|
@ -27,6 +27,10 @@
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QDateTime>
|
||||
|
||||
class QPushButton;
|
||||
class RshareSettings;
|
||||
class RSTreeWidgetItemCompareRole;
|
||||
|
||||
namespace Ui {
|
||||
class GroupTreeWidget;
|
||||
}
|
||||
@ -58,6 +62,11 @@ public:
|
||||
GroupTreeWidget(QWidget *parent = 0);
|
||||
~GroupTreeWidget();
|
||||
|
||||
// Load and save settings (group must be startet from the caller)
|
||||
void processSettings(RshareSettings *settings, bool load);
|
||||
// Initialize the display menu for sorting
|
||||
void initDisplayMenu(QPushButton *pushButton);
|
||||
|
||||
// Add a new category item
|
||||
QTreeWidgetItem *addCategoryItem(const QString &name, const QIcon &icon, bool expand);
|
||||
// Get id of item
|
||||
@ -68,22 +77,34 @@ public:
|
||||
void setUnreadCount(QTreeWidgetItem *item, int unreadCount);
|
||||
|
||||
signals:
|
||||
void treeCustomContextMenuRequested(const QPoint &pos);
|
||||
void treeCurrentItemChanged(const QString &id);
|
||||
void treeCustomContextMenuRequested(const QPoint &pos);
|
||||
void treeCurrentItemChanged(const QString &id);
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *e);
|
||||
|
||||
private slots:
|
||||
void customContextMenuRequested(const QPoint &pos);
|
||||
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
|
||||
void filterChanged();
|
||||
void clearFilter();
|
||||
|
||||
private:
|
||||
void calculateScore(QTreeWidgetItem *item);
|
||||
void sort();
|
||||
|
||||
private:
|
||||
void calculateScore(QTreeWidgetItem *item);
|
||||
void resort(QTreeWidgetItem *categoryItem);
|
||||
|
||||
private:
|
||||
QMenu *displayMenu;
|
||||
QAction *actionSortAscending;
|
||||
// QAction *actionSortDescending;
|
||||
QAction *actionSortByName;
|
||||
QAction *actionSortByPopularity;
|
||||
QAction *actionSortByLastPost;
|
||||
|
||||
RSTreeWidgetItemCompareRole *compareRole;
|
||||
|
||||
Ui::GroupTreeWidget *ui;
|
||||
};
|
||||
|
||||
|
@ -27,17 +27,32 @@ RSTreeWidgetItemCompareRole::RSTreeWidgetItemCompareRole()
|
||||
|
||||
void RSTreeWidgetItemCompareRole::setRole(int column, int role)
|
||||
{
|
||||
insert(column, role);
|
||||
QList<int> roles;
|
||||
roles.push_back(role);
|
||||
insert(column, roles);
|
||||
}
|
||||
|
||||
int RSTreeWidgetItemCompareRole::findRole(const int column) const
|
||||
void RSTreeWidgetItemCompareRole::addRole(int column, int role)
|
||||
{
|
||||
RSTreeWidgetItemCompareRole::iterator it = find(column);
|
||||
if (it == end()) {
|
||||
setRole(column, role);
|
||||
return;
|
||||
}
|
||||
|
||||
it.value().push_back(role);
|
||||
}
|
||||
|
||||
void RSTreeWidgetItemCompareRole::findRoles(const int column, QList<int> &roles) const
|
||||
{
|
||||
RSTreeWidgetItemCompareRole::const_iterator it = find(column);
|
||||
if (it == end()) {
|
||||
return Qt::DisplayRole;
|
||||
roles.clear();
|
||||
roles.push_back(Qt::DisplayRole);
|
||||
return;
|
||||
}
|
||||
|
||||
return it.value();
|
||||
roles = it.value();
|
||||
}
|
||||
|
||||
RSTreeWidgetItem::RSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, int type) : QTreeWidgetItem(type)
|
||||
@ -102,28 +117,55 @@ static uint typeOfVariant(const QVariant &value)
|
||||
bool RSTreeWidgetItem::operator<(const QTreeWidgetItem &other) const
|
||||
{
|
||||
int column = treeWidget()->sortColumn();
|
||||
int role = Qt::DisplayRole;
|
||||
QList<int> roles;
|
||||
|
||||
/* Own role for sort defined ? */
|
||||
if (m_compareRole) {
|
||||
role = m_compareRole->findRole(column);
|
||||
m_compareRole->findRoles(column, roles);
|
||||
}
|
||||
|
||||
// taken from "bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const"
|
||||
const QVariant v1 = data(column, role);
|
||||
const QVariant v2 = other.data(column, role);
|
||||
QList<int>::iterator role;
|
||||
for (role = roles.begin(); role != roles.end(); role++) {
|
||||
// taken from "bool QTreeWidgetItem::operator<(const QTreeWidgetItem &other) const"
|
||||
const QVariant v1 = data(column, *role);
|
||||
const QVariant v2 = other.data(column, *role);
|
||||
|
||||
// taken from "bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVariant &v2)"
|
||||
switch(qMax(typeOfVariant(v1), typeOfVariant(v2)))
|
||||
{
|
||||
case 0: //integer type
|
||||
return v1.toLongLong() < v2.toLongLong();
|
||||
case 1: //floating point
|
||||
return v1.toDouble() < v2.toDouble();
|
||||
default:
|
||||
return (v1.toString().compare (v2.toString(), Qt::CaseInsensitive) < 0);
|
||||
// taken from "bool QAbstractItemModelPrivate::variantLessThan(const QVariant &v1, const QVariant &v2)"
|
||||
switch(qMax(typeOfVariant(v1), typeOfVariant(v2)))
|
||||
{
|
||||
case 0: //integer type
|
||||
{
|
||||
qlonglong value1 = v1.toLongLong();
|
||||
qlonglong value2 = v2.toLongLong();
|
||||
|
||||
if (value1 != value2) {
|
||||
return value1 < value2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1: //floating point
|
||||
{
|
||||
double value1 = v1.toDouble();
|
||||
double value2 = v2.toDouble();
|
||||
|
||||
if (value1 != value2) {
|
||||
return value1 < value2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
int compare = v1.toString().compare (v2.toString(), Qt::CaseInsensitive);
|
||||
if (compare) {
|
||||
return (compare < 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// let the standard do the sort, this code should not reached
|
||||
return QTreeWidgetItem::operator<(other);
|
||||
/* Compare DisplayRole */
|
||||
const QVariant v1 = data(column, Qt::DisplayRole);
|
||||
const QVariant v2 = other.data(column, Qt::DisplayRole);
|
||||
|
||||
return (v1.toString().compare (v2.toString(), Qt::CaseInsensitive) < 0);
|
||||
}
|
||||
|
@ -23,16 +23,19 @@
|
||||
#ifndef _RSTREEWIDGETITEM_H
|
||||
#define _RSTREEWIDGETITEM_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
#include <QTreeWidgetItem>
|
||||
|
||||
/* For definition of the UserRole for comparing */
|
||||
class RSTreeWidgetItemCompareRole : QMap<int, int>
|
||||
class RSTreeWidgetItemCompareRole : QMap<int, QList<int> >
|
||||
{
|
||||
public:
|
||||
RSTreeWidgetItemCompareRole();
|
||||
|
||||
void setRole(int column, int role);
|
||||
int findRole(const int column) const;
|
||||
void addRole(int column, int role);
|
||||
void findRoles(const int column, QList<int> &roles) const;
|
||||
};
|
||||
|
||||
class RSTreeWidgetItem : public QTreeWidgetItem
|
||||
|
@ -91,63 +91,44 @@ void ForumDetails::showDetails(std::string mCurrForumId)
|
||||
|
||||
void ForumDetails::loadDialog()
|
||||
{
|
||||
|
||||
std::list<ForumInfo> forumList;
|
||||
std::list<ForumInfo>::iterator it;
|
||||
|
||||
if (!rsForums)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ForumInfo fi;
|
||||
ForumInfo fi;
|
||||
rsForums->getForumInfo(fId, fi);
|
||||
|
||||
rsForums->getForumList(forumList);
|
||||
|
||||
for(it = forumList.begin(); it != forumList.end(); it++)
|
||||
{
|
||||
|
||||
// Set Forum Name
|
||||
ui.nameline->setText(QString::fromStdWString(fi.forumName));
|
||||
|
||||
// Set Popularity
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->pop;
|
||||
ui.popline -> setText(QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
// Set Last Post Date
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(it->lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
ui.postline -> setText(timestamp);
|
||||
}
|
||||
// Set Forum Name
|
||||
ui.nameline->setText(QString::fromStdWString(fi.forumName));
|
||||
|
||||
// Set Forum ID
|
||||
ui.IDline->setText(QString::fromStdString(fi.forumId));
|
||||
|
||||
// Set Forum Description
|
||||
ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc));
|
||||
|
||||
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(true);
|
||||
ui.radioButton_anonymous->setChecked(false);
|
||||
}
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_ANON)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(false);
|
||||
ui.radioButton_anonymous->setChecked(true);
|
||||
}
|
||||
// Set Popularity
|
||||
ui.popline->setText(QString::number(fi.pop));
|
||||
|
||||
|
||||
|
||||
// Set Last Post Date
|
||||
if (fi.lastPost) {
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(fi.lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
ui.postline->setText(timestamp);
|
||||
}
|
||||
|
||||
// Set Forum ID
|
||||
ui.IDline->setText(QString::fromStdString(fi.forumId));
|
||||
|
||||
// Set Forum Description
|
||||
ui.DescriptiontextEdit->setText(QString::fromStdWString(fi.forumDesc));
|
||||
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(true);
|
||||
ui.radioButton_anonymous->setChecked(false);
|
||||
}
|
||||
if (fi.forumFlags & RS_DISTRIB_AUTHEN_ANON)
|
||||
{
|
||||
ui.radioButton_authd->setChecked(false);
|
||||
ui.radioButton_anonymous->setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
void ForumDetails::applyDialog()
|
||||
@ -160,6 +141,3 @@ void ForumDetails::applyDialog()
|
||||
closeinfodlg();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -1016,7 +1016,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+319"/>
|
||||
<location line="+79"/>
|
||||
<source>Display</source>
|
||||
<translation type="unfinished">Anzeige</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+275"/>
|
||||
<source>Set all to read</source>
|
||||
<translation>Alle als gelesen markieren</translation>
|
||||
</message>
|
||||
@ -1046,7 +1051,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Kanal abbestellen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/ChannelFeed.cpp" line="+73"/>
|
||||
<location filename="../gui/ChannelFeed.cpp" line="+77"/>
|
||||
<source>Own Channels</source>
|
||||
<translation>Meine Kanäle</translation>
|
||||
</message>
|
||||
@ -1066,8 +1071,8 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Andere Kanäle</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/ChannelFeed.ui" line="-139"/>
|
||||
<location filename="../gui/ChannelFeed.cpp" line="+26"/>
|
||||
<location filename="../gui/ChannelFeed.ui" line="-174"/>
|
||||
<location filename="../gui/ChannelFeed.cpp" line="+50"/>
|
||||
<source>Post to Channel</source>
|
||||
<translation>Kanalbeitrag erstellen</translation>
|
||||
</message>
|
||||
@ -3497,7 +3502,7 @@ p, li { white-space: pre-wrap; }
|
||||
<context>
|
||||
<name>ForumsDialog</name>
|
||||
<message>
|
||||
<location filename="../gui/ForumsDialog.cpp" line="+260"/>
|
||||
<location filename="../gui/ForumsDialog.cpp" line="+265"/>
|
||||
<source>Subscribe to Forum</source>
|
||||
<translation>Forum abonnieren</translation>
|
||||
</message>
|
||||
@ -3601,7 +3606,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Du kannst einem anonymen Autor nicht antworten</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-1273"/>
|
||||
<location line="-1275"/>
|
||||
<source>Your Forums</source>
|
||||
<translation>Deine Foren</translation>
|
||||
</message>
|
||||
@ -3644,7 +3649,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Starte ein neues Thema im ausgewählten Forum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+82"/>
|
||||
<location line="+17"/>
|
||||
<source>Display</source>
|
||||
<translation type="unfinished">Anzeige</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+100"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
@ -3738,7 +3748,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Druckvorschau</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/ForumsDialog.cpp" line="+110"/>
|
||||
<location filename="../gui/ForumsDialog.cpp" line="+112"/>
|
||||
<location line="+1084"/>
|
||||
<source>Start New Thread</source>
|
||||
<translation>Erstelle neues Thema</translation>
|
||||
@ -4312,7 +4322,22 @@ Fill in your GPG password when asked, to sign your new key.</source>
|
||||
<translation>Zurücksetzen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/common/GroupTreeWidget.cpp" line="+187"/>
|
||||
<location filename="../gui/common/GroupTreeWidget.cpp" line="+174"/>
|
||||
<source>Sort by Name</source>
|
||||
<translation>Sortiere nach Name</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+5"/>
|
||||
<source>Sort by Popularity</source>
|
||||
<translation>Sortiere nach Popularität</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+4"/>
|
||||
<source>Sort by Last Post</source>
|
||||
<translation>Sortiere nach letztem Beitrag</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+102"/>
|
||||
<source>Private Key Available</source>
|
||||
<translation>Privater Schlüssel verfügbar</translation>
|
||||
</message>
|
||||
@ -7263,7 +7288,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Zertifikate (*.pqi)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.ui" line="+734"/>
|
||||
<location filename="../gui/PeersDialog.ui" line="+727"/>
|
||||
<source>Status</source>
|
||||
<translation>Status</translation>
|
||||
</message>
|
||||
@ -7421,7 +7446,7 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Unterstrichen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="-590"/>
|
||||
<location line="-583"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
@ -7439,7 +7464,12 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Hinzufügen</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+240"/>
|
||||
<location line="+54"/>
|
||||
<source>Display</source>
|
||||
<translation>Anzeige</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+179"/>
|
||||
<source>Add or Change your Avatar</source>
|
||||
<translation>Wähle oder ändere dein Avatar Bild</translation>
|
||||
</message>
|
||||
@ -7616,20 +7646,19 @@ p, li { white-space: pre-wrap; }
|
||||
<translation>Text Datei (*.txt );;Alle Dateien (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../gui/PeersDialog.ui" line="-878"/>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Display</span></p></body></html></source>
|
||||
<translation><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<translation type="obsolete"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Anzeige</span></p></body></html></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location line="+886"/>
|
||||
<location filename="../gui/PeersDialog.ui" line="+8"/>
|
||||
<source>Hide Offline Friends</source>
|
||||
<translation>Verstecke offline Freunde</translation>
|
||||
</message>
|
||||
|
Loading…
Reference in New Issue
Block a user