mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 09:26:18 -05: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 USE_THREAD
|
||||
|
||||
/** Constructor */
|
||||
ChannelFeed::ChannelFeed(QWidget *parent)
|
||||
: RsAutoUpdatePage(1000,parent)
|
||||
@ -528,6 +530,7 @@ void ChannelFeed::updateChannelMsgs()
|
||||
actionEnable_Auto_Download->setEnabled(false);
|
||||
}
|
||||
|
||||
#ifdef USE_THREAD
|
||||
progressLabel->show();
|
||||
progressBar->reset();
|
||||
progressBar->show();
|
||||
@ -537,21 +540,33 @@ void ChannelFeed::updateChannelMsgs()
|
||||
|
||||
// connect thread
|
||||
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)), this, SLOT(fillThreadAddMsg(QString,QString)), Qt::BlockingQueuedConnection);
|
||||
connect(fillThread, SIGNAL(addMsg(QString,QString,int,int)), this, SLOT(fillThreadAddMsg(QString,QString,int,int)), Qt::BlockingQueuedConnection);
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::updateChannelMsgs() Start fill thread" << std::endl;
|
||||
#endif
|
||||
|
||||
// start thread
|
||||
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()
|
||||
{
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "ChannelFeed::fillThreadFinished" << std::endl;
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::fillThreadFinished()" << std::endl;
|
||||
#endif
|
||||
|
||||
// thread has finished
|
||||
@ -564,40 +579,37 @@ void ChannelFeed::fillThreadFinished()
|
||||
fillThread = NULL;
|
||||
}
|
||||
|
||||
#ifdef CHAN_DEBUG
|
||||
if (thread->wasStopped()) {
|
||||
// thread was stopped
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "ChannelFeed::fillThreadFinished Thread was stopped" << std::endl;
|
||||
#endif
|
||||
std::cerr << "ChannelFeed::fillThreadFinished() Thread was stopped" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "ChannelFeed::fillThreadFinished Delete thread" << std::endl;
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::fillThreadFinished() Delete thread" << std::endl;
|
||||
#endif
|
||||
|
||||
thread->deleteLater();
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FORUMS
|
||||
std::cerr << "ChannelFeed::fillThreadFinished done" << std::endl;
|
||||
#ifdef CHAN_DEBUG
|
||||
std::cerr << "ChannelFeed::fillThreadFinished done()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ChannelFeed::fillThreadProgress(int current, int count)
|
||||
void ChannelFeed::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count)
|
||||
{
|
||||
if (sender() == fillThread) {
|
||||
// show fill progress
|
||||
if (count) {
|
||||
progressBar->setValue(current * progressBar->maximum() / count);
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelFeed::fillThreadAddMsg(const QString &channelId, const QString &channelMsgId)
|
||||
{
|
||||
if (sender() == fillThread) {
|
||||
ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true);
|
||||
mChanMsgItems.push_back(cmi);
|
||||
verticalLayout_2->addWidget(cmi);
|
||||
verticalLayout->addWidget(cmi);
|
||||
}
|
||||
}
|
||||
|
||||
@ -808,8 +820,7 @@ void ChannelFillThread::run()
|
||||
break;
|
||||
}
|
||||
|
||||
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId));
|
||||
emit progress(++pos, count);
|
||||
emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId), ++pos, count);
|
||||
}
|
||||
|
||||
#ifdef CHAN_DEBUG
|
||||
|
@ -80,8 +80,7 @@ private slots:
|
||||
void generateMassData();
|
||||
|
||||
void fillThreadFinished();
|
||||
void fillThreadProgress(int current, int count);
|
||||
void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId);
|
||||
void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||
|
||||
private:
|
||||
void updateChannelList();
|
||||
@ -121,8 +120,7 @@ public:
|
||||
bool wasStopped() { return stopped; }
|
||||
|
||||
signals:
|
||||
void progress(int current, int count);
|
||||
void addMsg(const QString &channelId, const QString &channelMsgId);
|
||||
void addMsg(const QString &channelId, const QString &channelMsgId, int current, int count);
|
||||
|
||||
public:
|
||||
std::string channelId;
|
||||
|
@ -513,18 +513,21 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
||||
<property name="widgetResizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
|
||||
</property>
|
||||
<widget class="QWidget" name="scrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>304</height>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QWidget#scrollAreaWidgetContents{border: none;}</string>
|
||||
</property>
|
||||
@ -535,25 +538,6 @@ border-image: url(:/images/btn_26_pressed.png) 4;
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</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>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -182,7 +182,9 @@ QString formatText(const QString &text, unsigned int flag)
|
||||
if (flag & RSHTML_FORMATTEXT_REMOVE_COLOR) {
|
||||
optimizeFlag |= RSHTML_OPTIMIZEHTML_REMOVE_COLOR;
|
||||
}
|
||||
if (optimizeFlag) {
|
||||
optimizeHtml(formattedText, optimizeFlag);
|
||||
}
|
||||
|
||||
return formattedText;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user