mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Optimized channel loading and layout.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5118 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3678766a93
commit
3dca71330c
@ -51,6 +51,8 @@
|
|||||||
* #define CHAN_DEBUG
|
* #define CHAN_DEBUG
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
#define USE_THREAD
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
ChannelFeed::ChannelFeed(QWidget *parent)
|
ChannelFeed::ChannelFeed(QWidget *parent)
|
||||||
: RsAutoUpdatePage(1000,parent)
|
: RsAutoUpdatePage(1000,parent)
|
||||||
@ -528,6 +530,7 @@ void ChannelFeed::updateChannelMsgs()
|
|||||||
actionEnable_Auto_Download->setEnabled(false);
|
actionEnable_Auto_Download->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_THREAD
|
||||||
progressLabel->show();
|
progressLabel->show();
|
||||||
progressBar->reset();
|
progressBar->reset();
|
||||||
progressBar->show();
|
progressBar->show();
|
||||||
@ -537,21 +540,33 @@ void ChannelFeed::updateChannelMsgs()
|
|||||||
|
|
||||||
// connect thread
|
// connect thread
|
||||||
connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
|
connect(fillThread, SIGNAL(finished()), this, SLOT(fillThreadFinished()), Qt::BlockingQueuedConnection);
|
||||||
connect(fillThread, SIGNAL(progress(int,int)), this, SLOT(fillThreadProgress(int,int)));
|
connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection);
|
||||||
connect(fillThread, SIGNAL(addMsg(QString,QString)), this, SLOT(fillThreadAddMsg(QString,QString)), Qt::BlockingQueuedConnection);
|
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef CHAN_DEBUG
|
||||||
std::cerr << "ChannelFeed::updateChannelMsgs() Start fill thread" << std::endl;
|
std::cerr << "ChannelFeed::updateChannelMsgs() Start fill thread" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// start thread
|
// start thread
|
||||||
fillThread->start();
|
fillThread->start();
|
||||||
|
#else
|
||||||
|
std::list<ChannelMsgSummary> msgs;
|
||||||
|
std::list<ChannelMsgSummary>::iterator it;
|
||||||
|
rsChannels->getChannelMsgList(mChannelId, msgs);
|
||||||
|
|
||||||
|
msgs.sort(sortChannelMsgSummary);
|
||||||
|
|
||||||
|
for (it = msgs.begin(); it != msgs.end(); it++) {
|
||||||
|
ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true);
|
||||||
|
mChanMsgItems.push_back(cmi);
|
||||||
|
verticalLayout_2->addWidget(cmi);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelFeed::fillThreadFinished()
|
void ChannelFeed::fillThreadFinished()
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef CHAN_DEBUG
|
||||||
std::cerr << "ChannelFeed::fillThreadFinished" << std::endl;
|
std::cerr << "ChannelFeed::fillThreadFinished()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// thread has finished
|
// thread has finished
|
||||||
@ -564,40 +579,37 @@ void ChannelFeed::fillThreadFinished()
|
|||||||
fillThread = NULL;
|
fillThread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CHAN_DEBUG
|
||||||
if (thread->wasStopped()) {
|
if (thread->wasStopped()) {
|
||||||
// thread was stopped
|
// thread was stopped
|
||||||
#ifdef DEBUG_FORUMS
|
std::cerr << "ChannelFeed::fillThreadFinished() Thread was stopped" << std::endl;
|
||||||
std::cerr << "ChannelFeed::fillThreadFinished Thread was stopped" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef CHAN_DEBUG
|
||||||
std::cerr << "ChannelFeed::fillThreadFinished Delete thread" << std::endl;
|
std::cerr << "ChannelFeed::fillThreadFinished() Delete thread" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
thread->deleteLater();
|
thread->deleteLater();
|
||||||
thread = NULL;
|
thread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_FORUMS
|
#ifdef CHAN_DEBUG
|
||||||
std::cerr << "ChannelFeed::fillThreadFinished done" << std::endl;
|
std::cerr << "ChannelFeed::fillThreadFinished done()" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelFeed::fillThreadProgress(int current, int count)
|
void ChannelFeed::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count)
|
||||||
{
|
|
||||||
// show fill progress
|
|
||||||
if (count) {
|
|
||||||
progressBar->setValue(current * progressBar->maximum() / count);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChannelFeed::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId)
|
|
||||||
{
|
{
|
||||||
if (sender() == fillThread) {
|
if (sender() == fillThread) {
|
||||||
|
// show fill progress
|
||||||
|
if (count) {
|
||||||
|
progressBar->setValue(current * progressBar->maximum() / count);
|
||||||
|
}
|
||||||
|
|
||||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
|
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
|
||||||
mChanMsgItems.push_back(cmi);
|
mChanMsgItems.push_back(cmi);
|
||||||
verticalLayout_2->addWidget(cmi);
|
verticalLayout->addWidget(cmi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -808,8 +820,7 @@ void ChannelFillThread::run()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId));
|
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId), ++pos, count);
|
||||||
emit progress(++pos, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CHAN_DEBUG
|
#ifdef CHAN_DEBUG
|
||||||
|
@ -80,8 +80,7 @@ private slots:
|
|||||||
void generateMassData();
|
void generateMassData();
|
||||||
|
|
||||||
void fillThreadFinished();
|
void fillThreadFinished();
|
||||||
void fillThreadProgress(int current, int count);
|
void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||||
void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateChannelList();
|
void updateChannelList();
|
||||||
@ -121,8 +120,7 @@ public:
|
|||||||
bool wasStopped() { return stopped; }
|
bool wasStopped() { return stopped; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void progress(int current, int count);
|
void addMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||||
void addMsg(const QString &channelId, const QString &channelMsgId);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::string channelId;
|
std::string channelId;
|
||||||
|
@ -513,18 +513,21 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
|||||||
<property name="widgetResizable">
|
<property name="widgetResizable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
|
||||||
</property>
|
|
||||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>304</height>
|
<height>16</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
|
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
|
||||||
</property>
|
</property>
|
||||||
@ -535,25 +538,6 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
|||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -182,7 +182,9 @@ QString formatText(const QString &text, unsigned int flag)
|
|||||||
if (flag & RSHTML_FORMATTEXT_REMOVE_COLOR) {
|
if (flag & RSHTML_FORMATTEXT_REMOVE_COLOR) {
|
||||||
optimizeFlag |= RSHTML_OPTIMIZEHTML_REMOVE_COLOR;
|
optimizeFlag |= RSHTML_OPTIMIZEHTML_REMOVE_COLOR;
|
||||||
}
|
}
|
||||||
optimizeHtml(formattedText, optimizeFlag);
|
if (optimizeFlag) {
|
||||||
|
optimizeHtml(formattedText, optimizeFlag);
|
||||||
|
}
|
||||||
|
|
||||||
return formattedText;
|
return formattedText;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user