mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-12 08:33:05 -04:00
Added Channel Item Filter from Phenom
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7381 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f93d41991e
commit
3a4a8f388d
4 changed files with 132 additions and 32 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <retroshare/rsgxschannels.h>
|
#include <retroshare/rsgxschannels.h>
|
||||||
#include "gui/gxs/GxsFeedItem.h"
|
#include "gui/gxs/GxsFeedItem.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "util/HandleRichText.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class GxsChannelPostItem;
|
class GxsChannelPostItem;
|
||||||
|
@ -48,7 +49,11 @@ public:
|
||||||
void setFileCleanUpWarning(uint32_t time_left);
|
void setFileCleanUpWarning(uint32_t time_left);
|
||||||
bool setPost(const RsGxsChannelPost &post);
|
bool setPost(const RsGxsChannelPost &post);
|
||||||
|
|
||||||
protected:
|
const QString getTitleLabel() {return QString::fromUtf8(mPost.mMeta.mMsgName.c_str()); }
|
||||||
|
const QString getMsgLabel() {return RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS); }
|
||||||
|
const std::list<SubFileItem *> &getFileItems() {return mFileItems; }
|
||||||
|
|
||||||
|
protected:
|
||||||
virtual void loadMessage(const uint32_t &token);
|
virtual void loadMessage(const uint32_t &token);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "gui/feeds/GxsChannelPostItem.h"
|
#include "gui/feeds/GxsChannelPostItem.h"
|
||||||
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
|
#include "gui/settings/rsharesettings.h"
|
||||||
|
#include "gui/feeds/SubFileItem.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -40,6 +42,12 @@
|
||||||
#define TOKEN_TYPE_POSTS 7
|
#define TOKEN_TYPE_POSTS 7
|
||||||
#define TOKEN_TYPE_RELATEDPOSTS 8
|
#define TOKEN_TYPE_RELATEDPOSTS 8
|
||||||
|
|
||||||
|
/* Filters */
|
||||||
|
#define FILTER_TITLE 1
|
||||||
|
#define FILTER_MSG 2
|
||||||
|
#define FILTER_FILE_NAME 3
|
||||||
|
#define FILTER_COUNT 3
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) :
|
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) :
|
||||||
GxsMessageFrameWidget(rsGxsChannels, parent),
|
GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||||
|
@ -65,6 +73,13 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||||
|
|
||||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||||
// connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
// connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
||||||
|
/* add filter actions */
|
||||||
|
ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title"));
|
||||||
|
ui->filterLineEdit->addFilter(QIcon(), tr("Message"), FILTER_MSG, tr("Search Message"));
|
||||||
|
ui->filterLineEdit->addFilter(QIcon(), tr("Filename"), FILTER_FILE_NAME, tr("Search Filename"));
|
||||||
|
ui->filterLineEdit->setCurrentFilter( Settings->valueFromGroup("ChannelFeed", "filter", FILTER_TITLE).toInt());
|
||||||
|
connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterItems(QString)));
|
||||||
|
connect(ui->filterLineEdit, SIGNAL(filterChanged(int)), this, SLOT(filterChanged(int)));
|
||||||
|
|
||||||
/*************** Setup Left Hand Side (List of Channels) ****************/
|
/*************** Setup Left Hand Side (List of Channels) ****************/
|
||||||
|
|
||||||
|
@ -74,6 +89,8 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||||
|
|
||||||
ui->nameLabel->setMinimumWidth(20);
|
ui->nameLabel->setMinimumWidth(20);
|
||||||
|
|
||||||
|
mInProcessSettings = false;
|
||||||
|
|
||||||
/* load settings */
|
/* load settings */
|
||||||
processSettings(true);
|
processSettings(true);
|
||||||
|
|
||||||
|
@ -121,6 +138,7 @@ void GxsChannelPostsWidget::updateDisplay(bool complete)
|
||||||
|
|
||||||
void GxsChannelPostsWidget::processSettings(bool load)
|
void GxsChannelPostsWidget::processSettings(bool load)
|
||||||
{
|
{
|
||||||
|
mInProcessSettings = true;
|
||||||
// Settings->beginGroup(QString("GxsChannelDialog"));
|
// Settings->beginGroup(QString("GxsChannelDialog"));
|
||||||
//
|
//
|
||||||
// if (load) {
|
// if (load) {
|
||||||
|
@ -130,6 +148,7 @@ void GxsChannelPostsWidget::processSettings(bool load)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Settings->endGroup();
|
// Settings->endGroup();
|
||||||
|
mInProcessSettings = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::setGroupId(const RsGxsGroupId &groupId)
|
void GxsChannelPostsWidget::setGroupId(const RsGxsGroupId &groupId)
|
||||||
|
@ -250,6 +269,63 @@ static bool sortChannelMsgSummaryDesc(const RsGxsChannelPost &msg1, const RsGxsC
|
||||||
return (msg1.mMeta.mPublishTs < msg2.mMeta.mPublishTs);
|
return (msg1.mMeta.mPublishTs < msg2.mMeta.mPublishTs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidget::filterChanged(int filter)
|
||||||
|
{
|
||||||
|
if (mInProcessSettings) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
filterItems(ui->filterLineEdit->text());
|
||||||
|
|
||||||
|
// save index
|
||||||
|
Settings->setValueToGroup("ChannelFeed", "filter", filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidget::filterItems(const QString& text)
|
||||||
|
{
|
||||||
|
int filter = ui->filterLineEdit->currentFilter();
|
||||||
|
|
||||||
|
/* Search exisiting item */
|
||||||
|
QList<GxsChannelPostItem*>::iterator lit;
|
||||||
|
for (lit = mChannelPostItems.begin(); lit != mChannelPostItems.end(); lit++)
|
||||||
|
{
|
||||||
|
GxsChannelPostItem *item = *lit;
|
||||||
|
filterItem(item,text,filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GxsChannelPostsWidget::filterItem(GxsChannelPostItem *pItem, const QString &text, const int filter)
|
||||||
|
{
|
||||||
|
bool bVisible = text.isEmpty();
|
||||||
|
|
||||||
|
switch(filter)
|
||||||
|
{
|
||||||
|
case FILTER_TITLE:
|
||||||
|
bVisible=pItem->getTitleLabel().contains(text,Qt::CaseInsensitive);
|
||||||
|
break;
|
||||||
|
case FILTER_MSG:
|
||||||
|
bVisible=pItem->getMsgLabel().contains(text,Qt::CaseInsensitive);
|
||||||
|
break;
|
||||||
|
case FILTER_FILE_NAME:
|
||||||
|
{
|
||||||
|
std::list<SubFileItem *> fileItems=pItem->getFileItems();
|
||||||
|
std::list<SubFileItem *>::iterator lit;
|
||||||
|
for(lit = fileItems.begin(); lit != fileItems.end(); lit++)
|
||||||
|
{
|
||||||
|
SubFileItem *fi = *lit;
|
||||||
|
QString fileName=QString::fromUtf8(fi->FileName().c_str());
|
||||||
|
bVisible=(bVisible || fileName.contains(text,Qt::CaseInsensitive));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bVisible=true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pItem->setVisible(bVisible);
|
||||||
|
|
||||||
|
return (bVisible);
|
||||||
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related)
|
void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &posts, bool related)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsChannelPost>::const_iterator it;
|
std::vector<RsGxsChannelPost>::const_iterator it;
|
||||||
|
@ -281,6 +357,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||||
//TODO: Sort timestamp
|
//TODO: Sort timestamp
|
||||||
} else {
|
} else {
|
||||||
item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true, false);
|
item = new GxsChannelPostItem(this, 0, *it, subscribeFlags, true, false);
|
||||||
|
if (!ui->filterLineEdit->text().isEmpty())
|
||||||
|
filterItem(item, ui->filterLineEdit->text(), ui->filterLineEdit->currentFilter());
|
||||||
|
|
||||||
mChannelPostItems.push_back(item);
|
mChannelPostItems.push_back(item);
|
||||||
if (related) {
|
if (related) {
|
||||||
ui->verticalLayout->insertWidget(0, item);
|
ui->verticalLayout->insertWidget(0, item);
|
||||||
|
|
|
@ -71,6 +71,8 @@ protected:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void createMsg();
|
void createMsg();
|
||||||
|
void filterChanged(int filter);
|
||||||
|
void filterItems(const QString& text);
|
||||||
|
|
||||||
//void fillThreadFinished();
|
//void fillThreadFinished();
|
||||||
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||||
|
@ -96,6 +98,8 @@ private:
|
||||||
|
|
||||||
void acknowledgeMessageUpdate(const uint32_t &token);
|
void acknowledgeMessageUpdate(const uint32_t &token);
|
||||||
|
|
||||||
|
bool filterItem(GxsChannelPostItem *pItem, const QString &text, const int filter);
|
||||||
|
|
||||||
RsGxsGroupId mChannelId; /* current Channel */
|
RsGxsGroupId mChannelId; /* current Channel */
|
||||||
TokenQueue *mChannelQueue;
|
TokenQueue *mChannelQueue;
|
||||||
|
|
||||||
|
@ -109,6 +113,8 @@ private:
|
||||||
|
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
|
bool mInProcessSettings;
|
||||||
|
|
||||||
/* UI - from Designer */
|
/* UI - from Designer */
|
||||||
Ui::GxsChannelPostsWidget *ui;
|
Ui::GxsChannelPostsWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,20 +7,14 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>681</width>
|
<width>681</width>
|
||||||
<height>476</height>
|
<height>465</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="leftMargin">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="margin">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -32,16 +26,7 @@
|
||||||
<enum>QFrame::Sunken</enum>
|
<enum>QFrame::Sunken</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>4</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>4</number>
|
<number>4</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
|
@ -158,6 +143,34 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="LineEditClear" name="filterLineEdit">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Search channels</string>
|
||||||
|
</property>
|
||||||
|
<property name="frame">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -206,16 +219,7 @@
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="margin">
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -241,9 +245,15 @@
|
||||||
</action>
|
</action>
|
||||||
<zorder>toolBarFrame</zorder>
|
<zorder>toolBarFrame</zorder>
|
||||||
<zorder>scrollArea</zorder>
|
<zorder>scrollArea</zorder>
|
||||||
<zorder></zorder>
|
|
||||||
<zorder>headFrame</zorder>
|
<zorder>headFrame</zorder>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>LineEditClear</class>
|
||||||
|
<extends>QLineEdit</extends>
|
||||||
|
<header location="global">gui/common/LineEditClear.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../images.qrc"/>
|
<include location="../images.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue