mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 00:19:30 -05:00
- Moved the created GxsIdRSTreeWidgetItem from the forum fill thread to the main thread so the signal to fill the id can be processed.
- Removed QTimer from GxsIdTreeWidgetItem and GxsIdRSTreeWidgetItem. - Added new tick signal (every second) on Rshare to fill the id. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6238 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c74a36fff8
commit
813a8fad34
@ -21,13 +21,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "GxsIdTreeWidgetItem.h"
|
#include "GxsIdTreeWidgetItem.h"
|
||||||
|
#include "rshare.h"
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#define MAX_ATTEMPTS 5
|
||||||
|
|
||||||
static bool MakeIdDesc(const RsGxsId &id, QString &str)
|
static bool MakeIdDesc(const RsGxsId &id, QString &str)
|
||||||
{
|
{
|
||||||
RsIdentityDetails details;
|
RsIdentityDetails details;
|
||||||
@ -74,26 +76,21 @@ static bool MakeIdDesc(const RsGxsId &id, QString &str)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent)
|
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidget *parent)
|
||||||
:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
|
: QObject(NULL), RSTreeWidgetItem(compareRole, parent), mCount(0), mColumn(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent)
|
GxsIdRSTreeWidgetItem::GxsIdRSTreeWidgetItem(const RSTreeWidgetItemCompareRole *compareRole, QTreeWidgetItem *parent)
|
||||||
:RSTreeWidgetItem(compareRole, parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
|
: QObject(NULL), RSTreeWidgetItem(compareRole, parent), mCount(0), mColumn(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::init()
|
void GxsIdRSTreeWidgetItem::init()
|
||||||
{
|
{
|
||||||
mTimer = new QTimer(this);
|
|
||||||
mTimer->setSingleShot(true);
|
|
||||||
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
|
void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column)
|
||||||
@ -119,11 +116,10 @@ bool GxsIdRSTreeWidgetItem::getId(RsGxsId &id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define MAX_ATTEMPTS 5
|
|
||||||
|
|
||||||
void GxsIdRSTreeWidgetItem::loadId()
|
void GxsIdRSTreeWidgetItem::loadId()
|
||||||
{
|
{
|
||||||
|
disconnect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
|
||||||
|
|
||||||
std::cerr << " GxsIdRSTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
|
std::cerr << " GxsIdRSTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
@ -148,31 +144,25 @@ void GxsIdRSTreeWidgetItem::loadId()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
/* timer event to try again */
|
/* timer event to try again */
|
||||||
mTimer->setInterval(mCount * 1000);
|
connect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
|
||||||
mTimer->start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent)
|
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidget *parent)
|
||||||
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
|
: QObject(NULL), QTreeWidgetItem(parent), mCount(0), mColumn(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent)
|
GxsIdTreeWidgetItem::GxsIdTreeWidgetItem(QTreeWidgetItem *parent)
|
||||||
:QTreeWidgetItem(parent), QObject(NULL), mTimer(NULL), mCount(0), mColumn(0)
|
: QObject(NULL), QTreeWidgetItem(parent), mCount(0), mColumn(0)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdTreeWidgetItem::init()
|
void GxsIdTreeWidgetItem::init()
|
||||||
{
|
{
|
||||||
mTimer = new QTimer(this);
|
|
||||||
mTimer->setSingleShot(true);
|
|
||||||
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column)
|
void GxsIdTreeWidgetItem::setId(const RsGxsId &id, int column)
|
||||||
@ -198,9 +188,10 @@ bool GxsIdTreeWidgetItem::getId(RsGxsId &id)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GxsIdTreeWidgetItem::loadId()
|
void GxsIdTreeWidgetItem::loadId()
|
||||||
{
|
{
|
||||||
|
disconnect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
|
||||||
|
|
||||||
std::cerr << " GxsIdTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
|
std::cerr << " GxsIdTreeWidgetItem::loadId() Id: " << mId << ", mCount: " << mCount;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
@ -225,7 +216,6 @@ void GxsIdTreeWidgetItem::loadId()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
/* timer event to try again */
|
/* timer event to try again */
|
||||||
mTimer->setInterval(mCount * 1000);
|
connect(rApp, SIGNAL(secondTick()), this, SLOT(loadId()));
|
||||||
mTimer->start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,20 +24,14 @@
|
|||||||
#ifndef _GXS_ID_TREEWIDGETITEM_H
|
#ifndef _GXS_ID_TREEWIDGETITEM_H
|
||||||
#define _GXS_ID_TREEWIDGETITEM_H
|
#define _GXS_ID_TREEWIDGETITEM_H
|
||||||
|
|
||||||
#include <QTimer>
|
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
|
|
||||||
#include "gui/common/RSTreeWidgetItem.h"
|
#include "gui/common/RSTreeWidgetItem.h"
|
||||||
|
|
||||||
/*****
|
/*****
|
||||||
* NOTE: I have investigated why the Timer doesn't work in GxsForums.
|
* NOTE: When the tree item is created within a thread you have to move the object
|
||||||
* It appears that the Timer events occur in the Thread they were created in.
|
* with "moveThreadTo()" QObject into the main thread.
|
||||||
* GxsForums uses a short term thread to fill the ForumThread - this finishes,
|
* The tick signal to fill the id cannot be processed when the thread is finished.
|
||||||
* and so the Timer Events don't happen.
|
|
||||||
*
|
|
||||||
* The Timer events work fine in Wiki and Comments Dialog.
|
|
||||||
* because they don't use an additional thread.
|
|
||||||
*
|
|
||||||
***/
|
***/
|
||||||
|
|
||||||
|
|
||||||
@ -58,14 +52,11 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QTimer *mTimer;
|
|
||||||
RsGxsId mId;
|
RsGxsId mId;
|
||||||
int mCount;
|
int mCount;
|
||||||
int mColumn;
|
int mColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem
|
class GxsIdTreeWidgetItem : public QObject, public QTreeWidgetItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -83,11 +74,9 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QTimer *mTimer;
|
|
||||||
RsGxsId mId;
|
RsGxsId mId;
|
||||||
int mCount;
|
int mCount;
|
||||||
int mColumn;
|
int mColumn;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -713,10 +713,10 @@ void GxsForumThreadWidget::fillThreadFinished()
|
|||||||
// clear list
|
// clear list
|
||||||
thread->mItems.clear();
|
thread->mItems.clear();
|
||||||
} else {
|
} else {
|
||||||
fillThreads (thread->mItems, thread->mExpandNewMessages, thread->mItemToExpand);
|
fillThreads(thread->mItems, thread->mExpandNewMessages, thread->mItemToExpand);
|
||||||
|
|
||||||
// cleanup list
|
// cleanup list
|
||||||
cleanupItems (thread->mItems);
|
cleanupItems(thread->mItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->threadTreeWidget->setSortingEnabled(true);
|
ui->threadTreeWidget->setSortingEnabled(true);
|
||||||
@ -792,6 +792,8 @@ void GxsForumThreadWidget::forceUpdateDisplay()
|
|||||||
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
|
QTreeWidgetItem *GxsForumThreadWidget::convertMsgToThreadWidget(const RsGxsForumMsg &msg, bool useChildTS, uint32_t filterColumn)
|
||||||
{
|
{
|
||||||
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
|
GxsIdRSTreeWidgetItem *item = new GxsIdRSTreeWidgetItem(mThreadCompareRole);
|
||||||
|
item->moveToThread(ui->threadTreeWidget->thread());
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
|
item->setText(COLUMN_THREAD_TITLE, QString::fromUtf8(msg.mMeta.mMsgName.c_str()));
|
||||||
|
@ -598,6 +598,11 @@ void Rshare::blinkTimer()
|
|||||||
{
|
{
|
||||||
mBlink = !mBlink;
|
mBlink = !mBlink;
|
||||||
emit blink(mBlink);
|
emit blink(mBlink);
|
||||||
|
|
||||||
|
if (mBlink) {
|
||||||
|
/* Tick every second (create an own timer when needed) */
|
||||||
|
emit secondTick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Rshare::loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId)
|
bool Rshare::loadCertificate(const std::string &accountId, bool autoLogin, std::string gpgId)
|
||||||
|
@ -139,6 +139,8 @@ signals:
|
|||||||
void shutdown();
|
void shutdown();
|
||||||
/** Global blink timer */
|
/** Global blink timer */
|
||||||
void blink(bool on);
|
void blink(bool on);
|
||||||
|
/** Global timer every second */
|
||||||
|
void secondTick();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
|
Loading…
Reference in New Issue
Block a user