mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-18 05:44:14 -05: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
@ -27,6 +27,7 @@
|
||||
#include <retroshare/rsgxschannels.h>
|
||||
#include "gui/gxs/GxsFeedItem.h"
|
||||
#include <stdint.h>
|
||||
#include "util/HandleRichText.h"
|
||||
|
||||
namespace Ui {
|
||||
class GxsChannelPostItem;
|
||||
@ -48,7 +49,11 @@ public:
|
||||
void setFileCleanUpWarning(uint32_t time_left);
|
||||
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);
|
||||
|
||||
private slots:
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "gui/feeds/GxsChannelPostItem.h"
|
||||
#include "gui/gxschannels/CreateGxsChannelMsg.h"
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "gui/feeds/SubFileItem.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -40,6 +42,12 @@
|
||||
#define TOKEN_TYPE_POSTS 7
|
||||
#define TOKEN_TYPE_RELATEDPOSTS 8
|
||||
|
||||
/* Filters */
|
||||
#define FILTER_TITLE 1
|
||||
#define FILTER_MSG 2
|
||||
#define FILTER_FILE_NAME 3
|
||||
#define FILTER_COUNT 3
|
||||
|
||||
/** Constructor */
|
||||
GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWidget *parent) :
|
||||
GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||
@ -65,6 +73,13 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||
|
||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
|
||||
// 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) ****************/
|
||||
|
||||
@ -74,6 +89,8 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
|
||||
|
||||
ui->nameLabel->setMinimumWidth(20);
|
||||
|
||||
mInProcessSettings = false;
|
||||
|
||||
/* load settings */
|
||||
processSettings(true);
|
||||
|
||||
@ -121,6 +138,7 @@ void GxsChannelPostsWidget::updateDisplay(bool complete)
|
||||
|
||||
void GxsChannelPostsWidget::processSettings(bool load)
|
||||
{
|
||||
mInProcessSettings = true;
|
||||
// Settings->beginGroup(QString("GxsChannelDialog"));
|
||||
//
|
||||
// if (load) {
|
||||
@ -130,6 +148,7 @@ void GxsChannelPostsWidget::processSettings(bool load)
|
||||
// }
|
||||
//
|
||||
// Settings->endGroup();
|
||||
mInProcessSettings = false;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
std::vector<RsGxsChannelPost>::const_iterator it;
|
||||
@ -281,6 +357,9 @@ void GxsChannelPostsWidget::insertChannelPosts(std::vector<RsGxsChannelPost> &po
|
||||
//TODO: Sort timestamp
|
||||
} else {
|
||||
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);
|
||||
if (related) {
|
||||
ui->verticalLayout->insertWidget(0, item);
|
||||
|
@ -71,6 +71,8 @@ protected:
|
||||
|
||||
private slots:
|
||||
void createMsg();
|
||||
void filterChanged(int filter);
|
||||
void filterItems(const QString& text);
|
||||
|
||||
//void fillThreadFinished();
|
||||
//void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||
@ -96,6 +98,8 @@ private:
|
||||
|
||||
void acknowledgeMessageUpdate(const uint32_t &token);
|
||||
|
||||
bool filterItem(GxsChannelPostItem *pItem, const QString &text, const int filter);
|
||||
|
||||
RsGxsGroupId mChannelId; /* current Channel */
|
||||
TokenQueue *mChannelQueue;
|
||||
|
||||
@ -109,6 +113,8 @@ private:
|
||||
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
bool mInProcessSettings;
|
||||
|
||||
/* UI - from Designer */
|
||||
Ui::GxsChannelPostsWidget *ui;
|
||||
};
|
||||
|
@ -7,20 +7,14 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>681</width>
|
||||
<height>476</height>
|
||||
<height>465</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -32,16 +26,7 @@
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -158,6 +143,34 @@
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
</widget>
|
||||
</item>
|
||||
@ -206,16 +219,7 @@
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</layout>
|
||||
@ -241,9 +245,15 @@
|
||||
</action>
|
||||
<zorder>toolBarFrame</zorder>
|
||||
<zorder>scrollArea</zorder>
|
||||
<zorder></zorder>
|
||||
<zorder>headFrame</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LineEditClear</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">gui/common/LineEditClear.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user