diff --git a/retroshare-gui/src/gui/ChannelFeed.cpp b/retroshare-gui/src/gui/ChannelFeed.cpp index 7dde23188..6a461c20c 100644 --- a/retroshare-gui/src/gui/ChannelFeed.cpp +++ b/retroshare-gui/src/gui/ChannelFeed.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -91,6 +92,11 @@ ChannelFeed::ChannelFeed(QWidget *parent) channeloptsmenu->addAction(actionEnable_Auto_Download); channeloptions_Button->setMenu(channeloptsmenu); + progressLabel->hide(); + progressBar->hide(); + + fillThread = NULL; + //added from ahead updateChannelList(); @@ -105,6 +111,12 @@ ChannelFeed::ChannelFeed(QWidget *parent) ChannelFeed::~ChannelFeed() { + if (fillThread) { + fillThread->stop(); + delete(fillThread); + fillThread = NULL; + } + // save settings processSettings(false); } @@ -188,6 +200,12 @@ void ChannelFeed::channelListCustomPopupMenu( QPoint /*point*/ ) QAction *action = contextMnu.addAction(QIcon(":/images/copyrslink.png"), tr("Copy RetroShare Link"), this, SLOT(copyChannelLink())); action->setEnabled(!mChannelId.empty()); +#ifdef CHAN_DEBUG + contextMnu.addSeparator(); + action = contextMnu.addAction("Generate mass data", this, SLOT(generateMassData())); + action->setEnabled (!mChannelId.empty() && (ci.channelFlags & RS_DISTRIB_PUBLISH)); +#endif + contextMnu.exec(QCursor::pos()); } @@ -424,12 +442,25 @@ static bool sortChannelMsgSummary(const ChannelMsgSummary &msg1, const ChannelMs void ChannelFeed::updateChannelMsgs() { + if (fillThread) { +#ifdef CHAN_DEBUG + std::cerr << "ChannelFeed::updateChannelMsgs() stop current fill thread" << std::endl; +#endif + // stop current fill thread + fillThread->stop(); + delete(fillThread); + fillThread = NULL; + + progressLabel->hide(); + progressBar->hide(); + } + if (!rsChannels) { return; } /* replace all the messages with new ones */ - std::list::iterator mit; + QList::iterator mit; for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) { delete (*mit); } @@ -463,8 +494,7 @@ void ChannelFeed::updateChannelMsgs() iconLabel->setEnabled(true); /* set textcolor for Channel name */ - QString channelStr("%1"); + QString channelStr("%1"); /* set Channel name */ QString cname = QString::fromStdWString(ci.channelName); @@ -498,17 +528,74 @@ void ChannelFeed::updateChannelMsgs() actionEnable_Auto_Download->setEnabled(false); } - std::list msgs; - std::list::iterator it; - rsChannels->getChannelMsgList(mChannelId, msgs); + progressLabel->show(); + progressBar->reset(); + progressBar->show(); - msgs.sort(sortChannelMsgSummary); + // create fill thread + fillThread = new ChannelFillThread(this, mChannelId); + // 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); - for(it = msgs.begin(); it != msgs.end(); it++) { - ChanMsgItem *cmi = new ChanMsgItem(this, 0, mChannelId, it->msgId, true); +#ifdef DEBUG_FORUMS + std::cerr << "ChannelFeed::updateChannelMsgs() Start fill thread" << std::endl; +#endif + // start thread + fillThread->start(); +} +void ChannelFeed::fillThreadFinished() +{ +#ifdef DEBUG_FORUMS + std::cerr << "ChannelFeed::fillThreadFinished" << std::endl; +#endif + + // thread has finished + ChannelFillThread *thread = dynamic_cast(sender()); + if (thread) { + if (thread == fillThread) { + // current thread has finished, hide progressbar and release thread + progressBar->hide(); + progressLabel->hide(); + fillThread = NULL; + } + + if (thread->wasStopped()) { + // thread was stopped +#ifdef DEBUG_FORUMS + std::cerr << "ChannelFeed::fillThreadFinished Thread was stopped" << std::endl; +#endif + } + +#ifdef DEBUG_FORUMS + std::cerr << "ChannelFeed::fillThreadFinished Delete thread" << std::endl; +#endif + + thread->deleteLater(); + thread = NULL; + } + +#ifdef DEBUG_FORUMS + std::cerr << "ChannelFeed::fillThreadFinished done" << std::endl; +#endif +} + +void ChannelFeed::fillThreadProgress(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) { + ChanMsgItem *cmi = new ChanMsgItem(this, 0, channelId.toStdString(), channelMsgId.toStdString(), true); mChanMsgItems.push_back(cmi); verticalLayout_2->addWidget(cmi); } @@ -629,7 +716,7 @@ bool ChannelFeed::navigate(const std::string& channelId, const std::string& msgI } /* Search exisiting item */ - std::list::iterator mit; + QList::iterator mit; for (mit = mChanMsgItems.begin(); mit != mChanMsgItems.end(); mit++) { ChanMsgItem *item = *mit; if (item->msgId() == msgId) { @@ -653,3 +740,79 @@ void ChannelFeed::setAutoDownloadButton(bool autoDl) actionEnable_Auto_Download->setText(tr("Enable Auto-Download")); } } + +void ChannelFeed::generateMassData() +{ +#ifdef CHAN_DEBUG + if (mChannelId.empty ()) { + return; + } + + if (QMessageBox::question(this, "Generate mass data", "Do you really want to generate mass data ?", QMessageBox::Yes|QMessageBox::No, QMessageBox::No) == QMessageBox::No) { + return; + } + + for (int thread = 1; thread < 1000; thread++) { + ChannelMsgInfo msgInfo; + msgInfo.channelId = mChannelId; + msgInfo.subject = QString("Test %1").arg(thread, 3, 10, QChar('0')).toStdWString(); + msgInfo.msg = QString("That is only a test").toStdWString(); + + if (rsChannels->ChannelMessageSend(msgInfo) == false) { + return; + } + } +#endif +} + +// ForumsFillThread +ChannelFillThread::ChannelFillThread(ChannelFeed *parent, const std::string &channelId) + : QThread(parent) +{ + stopped = false; + this->channelId = channelId; +} + +ChannelFillThread::~ChannelFillThread() +{ +#ifdef CHAN_DEBUG + std::cerr << "ChannelFillThread::~ChannelFillThread" << std::endl; +#endif +} + +void ChannelFillThread::stop() +{ + disconnect(); + stopped = true; + QApplication::processEvents(); + wait(); +} + +void ChannelFillThread::run() +{ +#ifdef CHAN_DEBUG + std::cerr << "ChannelFillThread::run()" << std::endl; +#endif + + std::list msgs; + std::list::iterator it; + rsChannels->getChannelMsgList(channelId, msgs); + + msgs.sort(sortChannelMsgSummary); + + int count = msgs.size(); + int pos = 0; + + for (it = msgs.begin(); it != msgs.end(); it++) { + if (stopped) { + break; + } + + emit addMsg(QString::fromStdString(channelId), QString::fromStdString(it->msgId)); + emit progress(++pos, count); + } + +#ifdef CHAN_DEBUG + std::cerr << "ChannelFillThread::run() stopped: " << (wasStopped() ? "yes" : "no") << std::endl; +#endif +} diff --git a/retroshare-gui/src/gui/ChannelFeed.h b/retroshare-gui/src/gui/ChannelFeed.h index 607db5cc5..dac3f2217 100644 --- a/retroshare-gui/src/gui/ChannelFeed.h +++ b/retroshare-gui/src/gui/ChannelFeed.h @@ -24,6 +24,7 @@ #include #include +#include #include #include "mainpage.h" @@ -35,6 +36,7 @@ class ChanMsgItem; class QTreeWidgetItem; +class ChannelFillThread; class ChannelFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::ChannelFeed { @@ -75,6 +77,12 @@ private slots: void channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status); + void generateMassData(); + + void fillThreadFinished(); + void fillThreadProgress(int current, int count); + void fillThreadAddMsg(const QString &channelId, const QString &channelMsgId); + private: void updateChannelList(); void updateChannelMsgs(); @@ -89,14 +97,38 @@ private: /* Layout Pointers */ QBoxLayout *mMsgLayout; - std::list mChanMsgItems; + QList mChanMsgItems; std::map mChanSearchScore; //chanId, score QTreeWidgetItem *ownChannels; QTreeWidgetItem *subcribedChannels; QTreeWidgetItem *popularChannels; QTreeWidgetItem *otherChannels; + + ChannelFillThread *fillThread; +}; + +class ChannelFillThread : public QThread +{ + Q_OBJECT + +public: + ChannelFillThread(ChannelFeed *parent, const std::string &channelId); + ~ChannelFillThread(); + + void run(); + void stop(); + bool wasStopped() { return stopped; } + +signals: + void progress(int current, int count); + void addMsg(const QString &channelId, const QString &channelMsgId); + +public: + std::string channelId; + +private: + volatile bool stopped; }; #endif - diff --git a/retroshare-gui/src/gui/ChannelFeed.ui b/retroshare-gui/src/gui/ChannelFeed.ui index 9d88dd6ac..3599bb4a0 100644 --- a/retroshare-gui/src/gui/ChannelFeed.ui +++ b/retroshare-gui/src/gui/ChannelFeed.ui @@ -508,7 +508,7 @@ border-image: url(:/images/btn_26_pressed.png) 4; - + true @@ -521,8 +521,8 @@ border-image: url(:/images/btn_26_pressed.png) 4; 0 0 - 392 - 333 + 400 + 304 @@ -558,6 +558,27 @@ border-image: url(:/images/btn_26_pressed.png) 4; + + + + + + Loading + + + + + + + 1000 + + + 24 + + + + + diff --git a/retroshare-gui/src/gui/ForumsDialog.cpp b/retroshare-gui/src/gui/ForumsDialog.cpp index 11d4b8224..850d60928 100644 --- a/retroshare-gui/src/gui/ForumsDialog.cpp +++ b/retroshare-gui/src/gui/ForumsDialog.cpp @@ -208,12 +208,10 @@ ForumsDialog::ForumsDialog(QWidget *parent) ttheader->setResizeMode (COLUMN_THREAD_READ, QHeaderView::Fixed); ttheader->hideSection (COLUMN_THREAD_CONTENT); - ui.progressBar->setTextVisible(true); ui.progressBar->hide(); ui.progLayOutTxt->hide(); ui.progressBarLayOut->setEnabled(false); - fillThread = NULL; insertThreads(); @@ -495,15 +493,15 @@ void ForumsDialog::updateDisplay() } } -static void CleanupItems (QList &Items) +static void CleanupItems (QList &items) { - QList::iterator Item; - for (Item = Items.begin (); Item != Items.end (); Item++) { - if (*Item) { - delete (*Item); + QList::iterator item; + for (item = items.begin (); item != items.end (); item++) { + if (*item) { + delete (*item); } } - Items.clear(); + items.clear(); } void ForumsDialog::forumInfoToGroupItemInfo(const ForumInfo &forumInfo, GroupItemInfo &groupItemInfo) @@ -844,7 +842,6 @@ void ForumsDialog::fillThreadProgress(int current, int count) if (count) { ui.progressBar->setValue(current * ui.progressBar->maximum() / count); } - } void ForumsDialog::insertThreads() @@ -858,15 +855,13 @@ void ForumsDialog::insertThreads() #ifdef DEBUG_FORUMS std::cerr << "ForumsDialog::insertThreads() stop current fill thread" << std::endl; #endif - // stop and disconnect current fill thread - ForumsFillThread *thread = fillThread; + // stop current fill thread + fillThread->stop(); + delete(fillThread); fillThread = NULL; - // disconnect only the signal "progress", the signal "finished" is needed to delete the thread - thread->disconnect(this, SIGNAL(progress(int,int))); - thread->stop(); - ui.progressBar->hide(); + ui.progLayOutTxt->hide(); } subscribeFlags = 0; @@ -905,6 +900,7 @@ void ForumsDialog::insertThreads() ui.progressBarLayOut->setEnabled(true); ui.progLayOutTxt->show(); + ui.progressBar->reset(); ui.progressBar->show(); // create fill thread @@ -1761,7 +1757,10 @@ ForumsFillThread::~ForumsFillThread() void ForumsFillThread::stop() { + disconnect(); stopped = true; + QApplication::processEvents(); + wait(); } void ForumsFillThread::run() diff --git a/retroshare-gui/src/gui/ForumsDialog.ui b/retroshare-gui/src/gui/ForumsDialog.ui index 920f42f7c..b5c872c36 100644 --- a/retroshare-gui/src/gui/ForumsDialog.ui +++ b/retroshare-gui/src/gui/ForumsDialog.ui @@ -1192,9 +1192,6 @@ border: 1px solid #CCCCCC;} 0 - - false - @@ -1230,6 +1227,12 @@ border: 1px solid #CCCCCC;} + + GroupTreeWidget + QWidget +
gui/common/GroupTreeWidget.h
+ 1 +
LineEditClear QLineEdit @@ -1240,12 +1243,6 @@ border: 1px solid #CCCCCC;} QTextBrowser
gui/common/LinkTextBrowser.h
- - GroupTreeWidget - QWidget -
gui/common/GroupTreeWidget.h
- 1 -
diff --git a/retroshare-gui/src/lang/retroshare_de.qm b/retroshare-gui/src/lang/retroshare_de.qm index cd3bd203c..6d706f6e2 100644 Binary files a/retroshare-gui/src/lang/retroshare_de.qm and b/retroshare-gui/src/lang/retroshare_de.qm differ diff --git a/retroshare-gui/src/lang/retroshare_de.ts b/retroshare-gui/src/lang/retroshare_de.ts index 1006ff900..befccb56d 100644 --- a/retroshare-gui/src/lang/retroshare_de.ts +++ b/retroshare-gui/src/lang/retroshare_de.ts @@ -1006,18 +1006,23 @@ p, li { white-space: pre-wrap; } Abonnieren - + + Loading + Lade + + + Set all as read Alle als gelesen markieren - + Unsubcribe To Channel Kanal abbestellen - + Own Channels Meine Kanäle @@ -1038,7 +1043,7 @@ p, li { white-space: pre-wrap; } - + Post to Channel Kanalbeitrag erstellen @@ -1073,24 +1078,24 @@ p, li { white-space: pre-wrap; } Kopiere RetroShare Link - + No Channel Selected Keinen Kanal gewählt - + Disable Auto-Download Deaktiviere Auto-Download - + Enable Auto-Download Aktiviere Auto-Download - + Edit Channel Details Kanal-Details bearbeiten @@ -1620,17 +1625,17 @@ p, li { white-space: pre-wrap; } Schriftart auf den Standard setzen - + Paste RetroShare Link RetroShare Link einfügen - + is typing... tippt... - + Do you really want to physically delete the history? Möchtest du wirklich den Nachrichtenverlauf physisch löschen? @@ -1911,7 +1916,7 @@ p, li { white-space: pre-wrap; } Übernehmen und Schliessen - + RetroShare @@ -4433,7 +4438,7 @@ p, li { white-space: pre-wrap; } ForumsDialog - + Subscribe to Forum Forum abonnieren @@ -4519,7 +4524,7 @@ p, li { white-space: pre-wrap; } - + [ ... Missing Message ... ] [ ... Fehlende Nachricht ... ] @@ -4545,7 +4550,7 @@ p, li { white-space: pre-wrap; } Du kannst einem anonymen Autor nicht antworten - + Your Forums Deine Foren @@ -4700,7 +4705,7 @@ p, li { white-space: pre-wrap; } Forum erstellen - + Print Drucken @@ -4710,8 +4715,8 @@ p, li { white-space: pre-wrap; } Druckvorschau - - + + Start New Thread Erstelle neues Thema @@ -4732,12 +4737,12 @@ p, li { white-space: pre-wrap; } Zurücksetzen - + Content Inhalt - + Mark as read Als gelesen markieren @@ -5515,7 +5520,7 @@ p, li { white-space: pre-wrap; } Löscht den gespeicherten und angezeigten Chat Verlauf - + Chat lobbies Chat Lobbies @@ -5530,7 +5535,7 @@ p, li { white-space: pre-wrap; } Neuigkeiten - + Welcome to RetroShare's group chat. Willkommen bei RetroShare's Gruppenchat. @@ -5648,7 +5653,7 @@ p, li { white-space: pre-wrap; } Möchtest du diesen Freund entfernen? - + is typing... tippt... @@ -5659,7 +5664,7 @@ p, li { white-space: pre-wrap; } Neuer Gruppenchat - + Do you really want to physically delete the history? Möchtest du wirklich den Nachrichtenverlauf physisch löschen? @@ -9570,7 +9575,7 @@ p, li { white-space: pre-wrap; } NotifyQt - + GPG key passphrase GPG Schlüssel Passwort @@ -10040,7 +10045,7 @@ p, li { white-space: pre-wrap; } Formular - + Status: Status: @@ -10050,7 +10055,7 @@ p, li { white-space: pre-wrap; } Datei Prüfsumme: - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } @@ -10063,7 +10068,7 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="more"><span style=" text-decoration: underline; color:#0000ff;">mehr...</span></a></p></body></html> - + File name: Dateiname: @@ -10842,7 +10847,7 @@ p, li { white-space: pre-wrap; } QObject - + RetroShare RetroShare @@ -11943,7 +11948,7 @@ p, li { white-space: pre-wrap; } - + Download Herunterladen @@ -11979,13 +11984,13 @@ p, li { white-space: pre-wrap; } Alle entfernen - - + + Folder Ordner - + New RetroShare Link(s) Neu(e) RetroShare Link(s) @@ -12039,7 +12044,7 @@ p, li { white-space: pre-wrap; } Such ID - + Download Notice Download @@ -12195,7 +12200,7 @@ p, li { white-space: pre-wrap; } SecurityItem - + Expand Erweitern @@ -12298,7 +12303,7 @@ p, li { white-space: pre-wrap; } Nachricht schreiben - + Connect Attempt Verbindungsversuch @@ -12338,7 +12343,7 @@ p, li { white-space: pre-wrap; } Unbekannter Nachbar - + Hide Verbergen