mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -05:00
added channel search to channelfeed ui
fixed timestamp not being set in p3distrib and also removed memory look in channel ui (fillchannelList) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3677 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
af8ad4e862
commit
884f0e7a22
@ -692,6 +692,10 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
|
||||
/* accept message */
|
||||
(git->second).msgs[msg->msgId] = msg;
|
||||
|
||||
// update the time stamp of group for last post
|
||||
if((git->second.lastPost < msg->timestamp))
|
||||
git->second.lastPost = msg->timestamp;
|
||||
|
||||
/* now update parents TS */
|
||||
locked_updateChildTS(git->second, msg);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <QMenu>
|
||||
#include <QTimer>
|
||||
#include <QStandardItemModel>
|
||||
#include <QDateTime>
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
@ -48,6 +49,8 @@
|
||||
|
||||
#define ROLE_ID Qt::UserRole
|
||||
#define ROLE_CHANNEL_TITLE Qt::UserRole + 1
|
||||
#define ROLE_CHANNEL_DESC Qt::UserRole + 2
|
||||
#define ROLE_CHANNEL_TS Qt::UserRole + 3
|
||||
|
||||
/****
|
||||
* #define CHAN_DEBUG
|
||||
@ -65,6 +68,9 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
connect(subscribeButton, SIGNAL( clicked( void ) ), this, SLOT( subscribeChannel ( void ) ) );
|
||||
connect(unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
|
||||
connect(setAllAsReadButton, SIGNAL(clicked()), this, SLOT(setAllAsReadClicked()));
|
||||
connect(searchLine, SIGNAL(returnPressed()), this, SLOT(searchChannels( void )));
|
||||
connect(pushButtonSearch, SIGNAL(clicked()), this, SLOT(searchChannels( void )));
|
||||
connect(resetButton, SIGNAL(clicked()), this, SLOT(finishSearching( void )));
|
||||
|
||||
connect(NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
||||
|
||||
@ -130,6 +136,7 @@ ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
channelmenu->addAction(actionCreate_Channel);
|
||||
channelmenu->addSeparator();
|
||||
channelpushButton->setMenu(channelmenu);
|
||||
resetButton->setVisible(false);
|
||||
|
||||
updateChannelMsgs();
|
||||
}
|
||||
@ -288,6 +295,45 @@ void ChannelFeed::updateDisplay()
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelFeed::searchChannels(){
|
||||
|
||||
// do not allow update of page (new items to be added)
|
||||
RsAutoUpdatePage::lockAllEvents();
|
||||
|
||||
if(searchLine->text().isEmpty())
|
||||
finishSearching();
|
||||
|
||||
resetButton->setVisible(true);
|
||||
|
||||
QChannelItem::setSearchText(searchLine->text());
|
||||
|
||||
model->item(OWN)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
model->item(SUBSCRIBED)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
model->item(POPULAR)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
model->item(OTHER)->sortChildren(COLUMN_NAME, Qt::DescendingOrder);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ChannelFeed::finishSearching(){
|
||||
|
||||
// unlock channel page update if user is done searching
|
||||
RsAutoUpdatePage::unlockAllEvents();
|
||||
|
||||
searchLine->clear();
|
||||
|
||||
resetButton->setVisible(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void ChannelFeed::searchMessages(){
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ChannelFeed::updateChannelList()
|
||||
{
|
||||
if (!rsChannels) {
|
||||
@ -310,7 +356,8 @@ void ChannelFeed::updateChannelList()
|
||||
/* sort it into Publish (Own), Subscribed, Popular and Other */
|
||||
uint32_t flags = it->channelFlags;
|
||||
|
||||
if ((flags & RS_DISTRIB_ADMIN) && (flags & RS_DISTRIB_SUBSCRIBED)) {
|
||||
if ((flags & (RS_DISTRIB_ADMIN | RS_DISTRIB_PUBLISH)) && (flags & RS_DISTRIB_SUBSCRIBED)
|
||||
) {
|
||||
adminList.push_back(*it);
|
||||
} else if (flags & RS_DISTRIB_SUBSCRIBED) {
|
||||
subList.push_back(*it);
|
||||
@ -376,14 +423,14 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
||||
}
|
||||
}
|
||||
|
||||
QStandardItem *chNameItem = new QStandardItem();
|
||||
QStandardItem *chPopItem = new QStandardItem();
|
||||
QStandardItem *chNameItem = NULL;//new QChannelItem(); // use channel item to enable channel specific sorting
|
||||
QStandardItem *chPopItem = NULL;// new QStandardItem();
|
||||
if (row < rowCount) {
|
||||
chNameItem = groupItem->child(row, COLUMN_NAME);
|
||||
chPopItem = groupItem->child(row, COLUMN_POPULARITY);
|
||||
} else {
|
||||
QList<QStandardItem*> channel;
|
||||
chNameItem = new QStandardItem();
|
||||
chNameItem = new QChannelItem();
|
||||
chPopItem = new QStandardItem();
|
||||
|
||||
chNameItem->setSizeHint(QSize(22, 22));
|
||||
@ -397,6 +444,11 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
||||
|
||||
chNameItem->setText(QString::fromStdWString(ci.channelName));
|
||||
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QString::fromStdWString(ci.channelName), ROLE_CHANNEL_TITLE);
|
||||
|
||||
// important for searching channels
|
||||
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QString::fromStdWString(ci.channelDesc), ROLE_CHANNEL_DESC);
|
||||
groupItem->child(chNameItem->index().row(), COLUMN_DATA)->setData(QDateTime::fromTime_t(ci.lastPost), ROLE_CHANNEL_TS);
|
||||
|
||||
chNameItem->setToolTip(tr("Popularity: %1\nFetches: %2\nAvailable: %3").arg(QString::number(ci.pop)).arg(9999).arg(9999));
|
||||
|
||||
QPixmap chanImage;
|
||||
@ -443,6 +495,7 @@ void ChannelFeed::fillChannelList(int channelItem, std::list<ChannelInfo> &chann
|
||||
row++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChannelFeed::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
|
||||
@ -651,3 +704,47 @@ void ChannelFeed::setAllAsReadClicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString QChannelItem::searchText = "";
|
||||
|
||||
QChannelItem::QChannelItem()
|
||||
: QStandardItem(){
|
||||
}
|
||||
|
||||
|
||||
QChannelItem::~QChannelItem(){
|
||||
|
||||
}
|
||||
|
||||
bool QChannelItem::operator<(const QStandardItem& other) const {
|
||||
|
||||
// calculate *this/other search scores
|
||||
int otherCount = other.data(ROLE_CHANNEL_TITLE).toString().count(searchText,Qt::CaseInsensitive);
|
||||
otherCount += other.data(ROLE_CHANNEL_DESC).toString().count(searchText,Qt::CaseInsensitive);
|
||||
int thisCount = this->data(ROLE_CHANNEL_TITLE).toString().count(searchText, Qt:: CaseInsensitive);
|
||||
thisCount += this->data(ROLE_CHANNEL_DESC).toString().count(searchText, Qt:: CaseInsensitive);
|
||||
|
||||
uint otherChanTs = other.data(ROLE_CHANNEL_TS).toDateTime().toTime_t();
|
||||
uint thisChanTs = this->data(ROLE_CHANNEL_TS).toDateTime().toTime_t();
|
||||
|
||||
|
||||
// if counts are equal then determine by who has the most recent post
|
||||
if(otherCount == thisCount){
|
||||
if(otherChanTs < thisChanTs)
|
||||
return true;
|
||||
}
|
||||
|
||||
// choose the item where the string occurs the most
|
||||
if(thisCount < otherCount)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QChannelItem::setSearchText(const QString& sText){
|
||||
|
||||
searchText = sText;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define _CHANNEL_FEED_DIALOG_H
|
||||
|
||||
#include <retroshare/rschannels.h>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
#include "mainpage.h"
|
||||
#include "RsAutoUpdatePage.h"
|
||||
@ -31,6 +32,8 @@
|
||||
|
||||
#include "gui/feeds/FeedHolder.h"
|
||||
|
||||
|
||||
|
||||
#define OWN 0
|
||||
#define SUBSCRIBED 1
|
||||
#define POPULAR 2
|
||||
@ -78,6 +81,9 @@ private slots:
|
||||
void shareKey();
|
||||
|
||||
void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status);
|
||||
void searchChannels();
|
||||
void searchMessages();
|
||||
void finishSearching();
|
||||
|
||||
private:
|
||||
void updateChannelList();
|
||||
@ -99,6 +105,30 @@ private:
|
||||
QFont itemFont;
|
||||
};
|
||||
|
||||
class QChannelItem : public QStandardItem
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
QChannelItem();
|
||||
virtual ~QChannelItem();
|
||||
|
||||
/**
|
||||
* Allows users to set the search text for QChannel items
|
||||
* @param
|
||||
*/
|
||||
static void setSearchText(const QString& sText);
|
||||
|
||||
/**
|
||||
* reimplementing comparison operator so QChannelItems can be ordered in terms
|
||||
* of occurences of property searchText in its data columns
|
||||
*/
|
||||
bool operator<(const QStandardItem& other) const;
|
||||
|
||||
private:
|
||||
|
||||
static QString searchText;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -68,13 +68,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="chheaderframe">
|
||||
<property name="minimumSize">
|
||||
@ -110,10 +104,7 @@ border: 1px solid #CCCCCC;}
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="margin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="_2">
|
||||
<property name="verticalSpacing">
|
||||
@ -151,50 +142,6 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="channelpushButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add</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="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<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>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
@ -246,10 +193,198 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QPushButton" name="channelpushButton">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Add</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="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<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>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>channelpushButton</zorder>
|
||||
<zorder>postButton</zorder>
|
||||
<zorder>treeView</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="searchlineframe">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>22</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border: 2px solid #079E00;
|
||||
background: white;</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_6">
|
||||
<property name="horizontalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="resetButton">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton
|
||||
{
|
||||
border-image: url(:/images/closenormal.png)
|
||||
}
|
||||
|
||||
QPushButton:hover
|
||||
{
|
||||
border-image: url(:/images/closehover.png)
|
||||
}
|
||||
|
||||
QPushButton:pressed {
|
||||
border-image: url(:/images/closepressed.png)
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLineEdit" name="searchLine">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1677777</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Enter a Keyword here</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QLineEdit#lineEdit{background: transparent;
|
||||
border: none;}
|
||||
</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonSearch">
|
||||
<property name="toolTip">
|
||||
<string>Start Search</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QPushButton {
|
||||
border-image: url(:/images/btn1.png) 4;
|
||||
border-width: 4;
|
||||
padding: 0px 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
*{
|
||||
color: black;
|
||||
}
|
||||
|
||||
QPushButton:hover {
|
||||
border-image: url(:/images/btn2.png) 4;
|
||||
}
|
||||
|
||||
QPushButton:pressed{
|
||||
border-image: url(:/images/btn3.png) 4;
|
||||
}</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QTreeView" name="treeView">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
@ -269,12 +404,6 @@ p, li { white-space: pre-wrap; }
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerVisible">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -564,8 +693,8 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>412</width>
|
||||
<height>331</height>
|
||||
<width>411</width>
|
||||
<height>330</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
|
@ -100,17 +100,9 @@ void ChannelDetails::loadChannel()
|
||||
}
|
||||
uint32_t flags = 0;
|
||||
|
||||
std::list<ChannelInfo> channelList;
|
||||
std::list<ChannelInfo>::iterator it;
|
||||
|
||||
ChannelInfo ci;
|
||||
rsChannels->getChannelInfo(cId, ci);
|
||||
|
||||
rsChannels->getChannelList(channelList);
|
||||
|
||||
|
||||
for(it = channelList.begin(); it != channelList.end(); it++)
|
||||
{
|
||||
flags = ci.channelFlags;
|
||||
|
||||
// Set Channel Name
|
||||
ui.nameline->setText(QString::fromStdWString(ci.channelName));
|
||||
@ -118,14 +110,14 @@ void ChannelDetails::loadChannel()
|
||||
// Set Channel Popularity
|
||||
{
|
||||
std::ostringstream out;
|
||||
out << it->pop;
|
||||
out << ci.pop;
|
||||
ui.popline -> setText(QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
// Set Last Channel Post Date
|
||||
{
|
||||
QDateTime qtime;
|
||||
qtime.setTime_t(it->lastPost);
|
||||
qtime.setTime_t(ci.lastPost);
|
||||
QString timestamp = qtime.toString("yyyy-MM-dd hh:mm:ss");
|
||||
ui.postline -> setText(timestamp);
|
||||
}
|
||||
@ -146,10 +138,6 @@ void ChannelDetails::loadChannel()
|
||||
ui.typeEncrypted->setChecked(true);
|
||||
ui.typePrivate->setChecked(false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user