mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-01 18:56:23 -04:00
minor code cleaning in p3GxsTrans (struct->class for consistency, sendMail->sendData), added popularity+subscribed status display in statistics
This commit is contained in:
parent
6da8b2a04d
commit
eea63ac217
8 changed files with 103 additions and 111 deletions
|
@ -57,6 +57,8 @@
|
|||
#define COL_GROUP_GRP_ID 0
|
||||
#define COL_GROUP_NUM_MSGS 1
|
||||
#define COL_GROUP_SIZE_MSGS 2
|
||||
#define COL_GROUP_SUBSCRIBED 3
|
||||
#define COL_GROUP_POPULARITY 4
|
||||
|
||||
static const int PARTIAL_VIEW_SIZE = 9 ;
|
||||
static const int MAX_TUNNEL_REQUESTS_DISPLAY = 10 ;
|
||||
|
@ -66,14 +68,6 @@ static const int GXSTRANS_STATISTICS_DELAY_BETWEEN_GROUP_REQ = 30 ; // never req
|
|||
#define GXSTRANS_GROUP_DATA 0x02
|
||||
#define GXSTRANS_GROUP_STAT 0x03
|
||||
|
||||
// static QColor colorScale(float f)
|
||||
// {
|
||||
// if(f == 0)
|
||||
// return QColor::fromHsv(0,0,192) ;
|
||||
// else
|
||||
// return QColor::fromHsv((int)((1.0-f)*280),200,255) ;
|
||||
// }
|
||||
|
||||
GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
|
||||
: RsAutoUpdatePage(2000,parent)
|
||||
{
|
||||
|
@ -87,8 +81,6 @@ GxsTransportStatistics::GxsTransportStatistics(QWidget *parent)
|
|||
m_bProcessSettings = false;
|
||||
mLastGroupReqTS = 0 ;
|
||||
|
||||
//_router_F->setWidget( _tst_CW = new GxsTransportStatisticsWidget() ) ;
|
||||
|
||||
/* Set header resize modes and initial section sizes Uploads TreeView*/
|
||||
QHeaderView_setSectionResizeMode(treeWidget->header(), QHeaderView::ResizeToContents);
|
||||
|
||||
|
@ -238,9 +230,9 @@ void GxsTransportStatistics::updateContent()
|
|||
|
||||
groupTreeWidget->clear();
|
||||
|
||||
for(std::map<RsGxsGroupId,GxsGroupStatistic>::const_iterator it(mGroupStats.begin());it!=mGroupStats.end();++it)
|
||||
for(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>::const_iterator it(mGroupStats.begin());it!=mGroupStats.end();++it)
|
||||
{
|
||||
const GxsGroupStatistic& stat(it->second) ;
|
||||
const RsGxsTransGroupStatistics& stat(it->second) ;
|
||||
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem();
|
||||
groupTreeWidget->addTopLevelItem(item);
|
||||
|
@ -248,6 +240,8 @@ void GxsTransportStatistics::updateContent()
|
|||
item->setData(COL_GROUP_GRP_ID, Qt::DisplayRole, QString::fromStdString(stat.mGrpId.toStdString())) ;
|
||||
item->setData(COL_GROUP_NUM_MSGS, Qt::DisplayRole, QString::number(stat.mNumMsgs)) ;
|
||||
item->setData(COL_GROUP_SIZE_MSGS,Qt::DisplayRole, QString::number(stat.mTotalSizeOfMsgs)) ;
|
||||
item->setData(COL_GROUP_SUBSCRIBED,Qt::DisplayRole, stat.subscribed?tr("Yes"):tr("No")) ;
|
||||
item->setData(COL_GROUP_POPULARITY,Qt::DisplayRole, QString::number(stat.popularity)) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +260,9 @@ void GxsTransportStatistics::personDetails()
|
|||
|
||||
void GxsTransportStatistics::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
#ifdef DEBUG_GXSTRANS_STATS
|
||||
std::cerr << "GxsTransportStatistics::loadRequest() UserType: " << req.mUserType << std::endl;
|
||||
#endif
|
||||
|
||||
if (queue != mTransQueue)
|
||||
{
|
||||
|
@ -280,9 +276,6 @@ void GxsTransportStatistics::loadRequest(const TokenQueue *queue, const TokenReq
|
|||
case GXSTRANS_GROUP_META: loadGroupMeta(req.mToken);
|
||||
break;
|
||||
|
||||
case GXSTRANS_GROUP_DATA: loadGroupData(req.mToken);
|
||||
break;
|
||||
|
||||
case GXSTRANS_GROUP_STAT: loadGroupStat(req.mToken);
|
||||
break;
|
||||
|
||||
|
@ -297,8 +290,10 @@ void GxsTransportStatistics::requestGroupMeta()
|
|||
{
|
||||
mStateHelper->setLoading(GXSTRANS_GROUP_META, true);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS_STATS
|
||||
std::cerr << "GxsTransportStatisticsWidget::requestGroupMeta()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
mTransQueue->cancelActiveRequestTokens(GXSTRANS_GROUP_META);
|
||||
|
||||
|
@ -318,21 +313,23 @@ void GxsTransportStatistics::requestGroupStat(const RsGxsGroupId &groupId)
|
|||
|
||||
void GxsTransportStatistics::loadGroupStat(const uint32_t &token)
|
||||
{
|
||||
#ifdef DEBUG_GXSTRANS_STATS
|
||||
std::cerr << "GxsTransportStatistics::loadGroupStat." << std::endl;
|
||||
#endif
|
||||
GxsGroupStatistic stats;
|
||||
rsGxsTrans->getGroupStatistic(token, stats);
|
||||
|
||||
mGroupStats[stats.mGrpId] = stats ;
|
||||
dynamic_cast<GxsGroupStatistic&>(mGroupStats[stats.mGrpId]) = stats ;
|
||||
}
|
||||
|
||||
void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
|
||||
{
|
||||
mStateHelper->setLoading(GXSTRANS_GROUP_META, false);
|
||||
|
||||
#ifdef DEBUG_GXSTRANS_STATS
|
||||
std::cerr << "GxsTransportStatisticsWidget::loadGroupMeta()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
// ui.treeWidget_membership->clear();
|
||||
#endif
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
std::list<RsGroupMetaData>::iterator vit;
|
||||
|
@ -347,45 +344,29 @@ void GxsTransportStatistics::loadGroupMeta(const uint32_t& token)
|
|||
|
||||
mStateHelper->setActive(GXSTRANS_GROUP_META, true);
|
||||
|
||||
// /* add the top level item */
|
||||
// QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem();
|
||||
// personalCirclesItem->setText(0, tr("Personal Circles"));
|
||||
// ui.treeWidget_membership->addTopLevelItem(personalCirclesItem);
|
||||
//
|
||||
// QTreeWidgetItem *externalAdminCirclesItem = new QTreeWidgetItem();
|
||||
// externalAdminCirclesItem->setText(0, tr("External Circles (Admin)"));
|
||||
// ui.treeWidget_membership->addTopLevelItem(externalAdminCirclesItem);
|
||||
//
|
||||
// QTreeWidgetItem *externalSubCirclesItem = new QTreeWidgetItem();
|
||||
// externalSubCirclesItem->setText(0, tr("External Circles (Subscribed)"));
|
||||
// ui.treeWidget_membership->addTopLevelItem(externalSubCirclesItem);
|
||||
//
|
||||
// QTreeWidgetItem *externalOtherCirclesItem = new QTreeWidgetItem();
|
||||
// externalOtherCirclesItem->setText(0, tr("External Circles (Other)"));
|
||||
// ui.treeWidget_membership->addTopLevelItem(externalOtherCirclesItem);
|
||||
|
||||
std::set<RsGxsGroupId> existing_groups ;
|
||||
std::set<RsGxsGroupId> existing_groups ;
|
||||
|
||||
for(vit = groupInfo.begin(); vit != groupInfo.end(); ++vit)
|
||||
{
|
||||
existing_groups.insert(vit->mGroupId) ;
|
||||
|
||||
/* Add Widget, and request Pages */
|
||||
#ifdef DEBUG_GXSTRANS_STATS
|
||||
std::cerr << "GxsTransportStatisticsWidget::loadGroupMeta() GroupId: " << vit->mGroupId << " Group: " << vit->mGroupName << std::endl;
|
||||
#endif
|
||||
|
||||
requestGroupStat(vit->mGroupId) ;
|
||||
|
||||
RsGxsTransGroupStatistics& s(mGroupStats[vit->mGroupId]);
|
||||
s.popularity = vit->mPop ;
|
||||
s.subscribed = IS_GROUP_SUBSCRIBED(vit->mSubscribeFlags) ;
|
||||
}
|
||||
|
||||
// remove group stats for group that do not exist anymore
|
||||
|
||||
for(std::map<RsGxsGroupId,GxsGroupStatistic>::iterator it(mGroupStats.begin());it!=mGroupStats.end();)
|
||||
for(std::map<RsGxsGroupId,RsGxsTransGroupStatistics>::iterator it(mGroupStats.begin());it!=mGroupStats.end();)
|
||||
if(existing_groups.find(it->first) == existing_groups.end())
|
||||
it = mGroupStats.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
void GxsTransportStatistics::loadGroupData(const uint32_t& token)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented." << std::endl;
|
||||
}
|
||||
|
|
|
@ -34,72 +34,53 @@
|
|||
class GxsTransportStatisticsWidget ;
|
||||
class UIStateHelper;
|
||||
|
||||
class RsGxsTransGroupStatistics: public GxsGroupStatistic
|
||||
{
|
||||
public:
|
||||
RsGxsTransGroupStatistics() {}
|
||||
|
||||
bool subscribed ;
|
||||
int popularity ;
|
||||
};
|
||||
|
||||
class GxsTransportStatistics: public RsAutoUpdatePage, public TokenResponse, public Ui::GxsTransportStatistics
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GxsTransportStatistics(QWidget *parent = NULL) ;
|
||||
~GxsTransportStatistics();
|
||||
|
||||
// Cache for peer names.
|
||||
static QString getPeerName(const RsPeerId& peer_id) ;
|
||||
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req) ;
|
||||
public:
|
||||
GxsTransportStatistics(QWidget *parent = NULL) ;
|
||||
~GxsTransportStatistics();
|
||||
|
||||
// Cache for peer names.
|
||||
static QString getPeerName(const RsPeerId& peer_id) ;
|
||||
|
||||
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req) ;
|
||||
|
||||
void updateContent() ;
|
||||
|
||||
void updateContent() ;
|
||||
|
||||
private slots:
|
||||
/** Create the context popup menu and it's submenus */
|
||||
void CustomPopupMenu( QPoint point );
|
||||
void personDetails();
|
||||
|
||||
private:
|
||||
void loadGroupData(const uint32_t& token);
|
||||
void loadGroupMeta(const uint32_t& token);
|
||||
void loadGroupStat(const uint32_t& token);
|
||||
|
||||
void requestGroupData();
|
||||
void requestGroupMeta();
|
||||
void requestGroupStat(const RsGxsGroupId &groupId);
|
||||
private:
|
||||
void loadGroupMeta(const uint32_t& token);
|
||||
void loadGroupStat(const uint32_t& token);
|
||||
|
||||
void processSettings(bool bLoad);
|
||||
bool m_bProcessSettings;
|
||||
void requestGroupMeta();
|
||||
void requestGroupStat(const RsGxsGroupId &groupId);
|
||||
|
||||
virtual void updateDisplay() ;
|
||||
void processSettings(bool bLoad);
|
||||
bool m_bProcessSettings;
|
||||
|
||||
GxsTransportStatisticsWidget *_tst_CW ;
|
||||
TokenQueue *mTransQueue ;
|
||||
UIStateHelper *mStateHelper;
|
||||
uint32_t mLastGroupReqTS ;
|
||||
virtual void updateDisplay() ;
|
||||
|
||||
// temporary storage of retrieved data, for display (useful because this is obtained from the async token system)
|
||||
GxsTransportStatisticsWidget *_tst_CW ;
|
||||
TokenQueue *mTransQueue ;
|
||||
UIStateHelper *mStateHelper;
|
||||
uint32_t mLastGroupReqTS ;
|
||||
|
||||
std::map<RsGxsGroupId,GxsGroupStatistic> mGroupStats ; // stores the list of active groups and statistics about each of them.
|
||||
// temporary storage of retrieved data, for display (useful because this is obtained from the async token system)
|
||||
|
||||
std::map<RsGxsGroupId,RsGxsTransGroupStatistics> mGroupStats ; // stores the list of active groups and statistics about each of them.
|
||||
} ;
|
||||
|
||||
// class GxsTransportStatisticsWidget: public QWidget
|
||||
// {
|
||||
// Q_OBJECT
|
||||
//
|
||||
// public:
|
||||
// GxsTransportStatisticsWidget(QWidget *parent = NULL) ;
|
||||
//
|
||||
// virtual void paintEvent(QPaintEvent *event) ;
|
||||
// virtual void resizeEvent(QResizeEvent *event);
|
||||
// virtual void wheelEvent(QWheelEvent *event);
|
||||
//
|
||||
// void updateContent() ;
|
||||
// private:
|
||||
// static QString speedString(float f) ;
|
||||
//
|
||||
// QPixmap pixmap ;
|
||||
// int maxWidth,maxHeight ;
|
||||
// int mCurrentN ;
|
||||
// int mNumberOfKnownKeys ;
|
||||
// int mMinWheelZoneX ;
|
||||
// int mMinWheelZoneY ;
|
||||
// int mMaxWheelZoneX ;
|
||||
// int mMaxWheelZoneY ;
|
||||
// };
|
||||
|
||||
|
|
|
@ -41,6 +41,16 @@
|
|||
<string>Total size of messages</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Subscribed</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Popularity</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -61,6 +71,9 @@
|
|||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerShowSortIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>ID</string>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue