fixed conflict with master

This commit is contained in:
csoler 2021-01-19 22:34:44 +01:00
commit f491e3c20e
61 changed files with 1202 additions and 892 deletions

View File

@ -50,9 +50,10 @@ void GxsTokenQueue::checkRequests()
for(it = mQueue.begin(); it != mQueue.end();)
{
uint32_t token = it->mToken;
uint32_t status = mGenExchange->getTokenService()->requestStatus(token);
it->mStatus = mGenExchange->getTokenService()->requestStatus(token);
if (status == RsTokenService::COMPLETE)
if ( it->mStatus == RsTokenService::COMPLETE
|| it->mStatus == RsTokenService::CANCELLED )
{
toload.push_back(*it);
it = mQueue.erase(it);
@ -64,7 +65,7 @@ void GxsTokenQueue::checkRequests()
#endif
++it;
}
else if (status == RsTokenService::FAILED)
else if (it->mStatus == RsTokenService::FAILED)
{
// maybe we should do alternative callback?
std::cerr << __PRETTY_FUNCTION__ << " ERROR Request Failed! "
@ -87,7 +88,7 @@ void GxsTokenQueue::checkRequests()
{
for(it = toload.begin(); it != toload.end(); ++it)
{
handleResponse(it->mToken, it->mReqType);
handleResponse(it->mToken, it->mReqType, it->mStatus);
}
}
}

View File

@ -23,19 +23,22 @@
#define R_GXS_TOKEN_QUEUE_H
#include "gxs/rsgenexchange.h"
#include "retroshare/rsservicecontrol.h"
#include "util/rsthreads.h"
struct GxsTokenQueueItem
{
public:
GxsTokenQueueItem(const uint32_t token, const uint32_t req_type) :
mToken(token), mReqType(req_type) {}
mToken(token), mReqType(req_type), mStatus(RsTokenService::PENDING) {}
GxsTokenQueueItem(): mToken(0), mReqType(0) {}
GxsTokenQueueItem(): mToken(0), mReqType(0), mStatus(RsTokenService::PENDING) {}
uint32_t mToken;
uint32_t mReqType;
RsTokenService::GxsRequestStatus mStatus;
};
@ -54,7 +57,8 @@ public:
protected:
/// This must be overloaded to complete the functionality.
virtual void handleResponse(uint32_t token, uint32_t req_type) = 0;
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) = 0;
private:
RsGenExchange *mGenExchange;

View File

@ -693,10 +693,10 @@ bool RsGxsDataAccess::getServiceStatistic(const uint32_t &token, GxsServiceStati
}
GxsRequest* RsGxsDataAccess::locked_retrieveCompletedRequest(const uint32_t& token)
{
auto it = mCompletedRequests.find(token) ;
auto it = mCompletedRequests.find(token) ;
if(it == mCompletedRequests.end())
return nullptr;
if(it == mCompletedRequests.end())
return nullptr;
return it->second;
}
@ -720,6 +720,7 @@ void RsGxsDataAccess::processRequests()
{
if(now > mRequestQueue.begin()->second->reqTime + MAX_REQUEST_AGE)
{
mPublicToken[mRequestQueue.begin()->second->token] = CANCELLED;
delete mRequestQueue.begin()->second;
mRequestQueue.erase(mRequestQueue.begin());
continue;
@ -833,8 +834,8 @@ void RsGxsDataAccess::processRequests()
}
else
{
req->status = FAILED;
mPublicToken[req->token] = FAILED;
delete req;//req belongs to no one now
#ifdef DATA_DEBUG
RsDbg() << " Request failed. Marking as FAILED." << std::endl;
#endif
@ -1024,7 +1025,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(meta_it = result.begin(); meta_it != result.end(); ++meta_it)
{
const RsGxsGroupId& grpId = meta_it->first;
//const RsGxsGroupId& grpId = meta_it->first;
//auto& filter( metaFilter[grpId] ); // does the initialization of metaFilter[grpId] and avoids further O(log(n)) calls
@ -1122,8 +1123,7 @@ bool RsGxsDataAccess::getMsgMetaDataList( const GxsMsgReq& msgIds, const RsTokRe
for(uint32_t i=0;i<metaV.size();++i)
if(metaV[i] != nullptr)
{
const auto& msgMeta = metaV[i];
bool add = false;
const auto& msgMeta = metaV[i];
/* if we are grabbing thread Head... then parentId == empty. */
if (onlyThreadHeadMsgs && !msgMeta->mParentId.isNull())

View File

@ -137,11 +137,15 @@ void p3GxsTrans::registerGxsTransClient(
mServClients[serviceType] = service;
}
void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type)
void p3GxsTrans::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef DEBUG_GXSTRANS
std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ")" << std::endl;
std::cout << "p3GxsTrans::handleResponse(" << token << ", " << req_type << ", " << status << ")" << std::endl;
#endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
bool changed = false ;
switch (req_type)

View File

@ -159,7 +159,7 @@ public:
GxsTransClient* service );
/// @see RsGenExchange::getServiceInfo()
virtual RsServiceInfo getServiceInfo() { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); }
virtual RsServiceInfo getServiceInfo() override { return RsServiceInfo( RS_SERVICE_TYPE_GXS_TRANS, "GXS Mails", 0, 1, 0, 1 ); }
static const uint32_t GXS_STORAGE_PERIOD = 15*86400; // 15 days.
static const uint32_t GXS_SYNC_PERIOD = 15*86400;
@ -230,30 +230,32 @@ private:
inMap mIncomingQueue;
RsMutex mIngoingMutex;
/// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type)
virtual void handleResponse(uint32_t token, uint32_t req_type);
/// @see GxsTokenQueue::handleResponse(uint32_t token, uint32_t req_type
/// , RsTokenService::GxsRequestStatus status)
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
/// @see RsGenExchange::service_tick()
virtual void service_tick();
virtual void service_tick() override;
/// @see RsGenExchange::service_CreateGroup(...)
RsGenExchange::ServiceCreate_Return service_CreateGroup(
RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& );
RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& ) override;
/// @see RsGenExchange::notifyChanges(std::vector<RsGxsNotify *> &changes)
void notifyChanges(std::vector<RsGxsNotify *> &changes);
void notifyChanges(std::vector<RsGxsNotify *> &changes) override;
/// @see p3Config::setupSerialiser()
virtual RsSerialiser* setupSerialiser();
virtual RsSerialiser* setupSerialiser() override;
/// @see p3Config::saveList(bool &cleanup, std::list<RsItem *>&)
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList);
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
/// @see p3Config::saveDone()
void saveDone();
void saveDone() override;
/// @see p3Config::loadList(std::list<RsItem *>&)
virtual bool loadList(std::list<RsItem *>& loadList);
virtual bool loadList(std::list<RsItem *>& loadList) override;
/// Request groups list to GXS backend. Async method.
bool requestGroupsData(const std::list<RsGxsGroupId>* groupIds = NULL);
@ -325,9 +327,9 @@ private:
// Overloaded from RsGenExchange.
bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta, uint32_t size) ;
bool acceptNewMessage(const RsGxsMsgMetaData *msgMeta, uint32_t size) override;
GxsTransIntegrityCleanupThread *mCleanupThread ;
GxsTransIntegrityCleanupThread *mCleanupThread ;
// statistics of the load across all groups, per user.

View File

@ -1134,12 +1134,14 @@ void p3GxsChannels::handleUnprocessedPost(const RsGxsChannelPost &msg)
// Overloaded from GxsTokenQueue for Request callbacks.
void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type)
void p3GxsChannels::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef GXSCHANNELS_DEBUG
std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl;
std::cerr << "p3GxsChannels::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
#endif // GXSCHANNELS_DEBUG
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff.
switch(req_type)

View File

@ -178,15 +178,15 @@ virtual bool getChannelDownloadDirectory(const RsGxsGroupId &groupId, std::strin
// Overloaded from RsGxsIface.
virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe);
virtual bool subscribeToGroup(uint32_t &token, const RsGxsGroupId &groupId, bool subscribe) override;
// Set Statuses.
virtual void setMessageProcessedStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool processed);
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read);
virtual void setMessageReadStatus(uint32_t& token, const RsGxsGrpMsgIdPair& msgId, bool read) override;
// File Interface
virtual bool ExtraFileHash(const std::string& path);
virtual bool ExtraFileRemove(const RsFileHash &hash);
virtual bool ExtraFileHash(const std::string& path) override;
virtual bool ExtraFileRemove(const RsFileHash &hash) override;
/// Implementation of @see RsGxsChannels::getChannelsSummaries
@ -277,7 +277,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
bool subscribe ) override;
/// @see RsGxsChannels
virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read);
virtual bool markRead(const RsGxsGrpMsgIdPair& msgId, bool read) override;
/// @see RsGxsChannels
bool exportChannelLink(
@ -295,7 +295,7 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
) override;
virtual bool shareChannelKeys(
const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers );
const RsGxsGroupId& channelId, const std::set<RsPeerId>& peers ) override;
/// Implementation of @see RsGxsChannels::createChannel
RS_DEPRECATED_FOR(createChannelV2)
@ -316,7 +316,8 @@ virtual bool ExtraFileRemove(const RsFileHash &hash);
protected:
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type);
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
private:

View File

@ -434,13 +434,13 @@ bool p3GxsCircles::revokeIdsFromCircle( const std::set<RsGxsId>& identities, con
return false;
}
// /!\ AVOID calling circleGrp.mInvitedMembers.erase(identities.begin(),identities.end()), because it is not the same set. Consequently
// STL code would corrupt the structure of mInvitedMembers.
// /!\ AVOID calling circleGrp.mInvitedMembers.erase(identities.begin(),identities.end()), because it is not the same set. Consequently
// STL code would corrupt the structure of mInvitedMembers.
std::set<RsGxsId> new_invited_members;
for(auto& gxs_id: circleGrp.mInvitedMembers)
if(identities.find(gxs_id) == identities.end())
new_invited_members.insert(gxs_id);
std::set<RsGxsId> new_invited_members;
for(auto& gxs_id: circleGrp.mInvitedMembers)
if(identities.find(gxs_id) == identities.end())
new_invited_members.insert(gxs_id);
circleGrp.mInvitedMembers = new_invited_members;
@ -585,8 +585,8 @@ void p3GxsCircles::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << std::endl;
#endif
p3Notify *notify = RsServer::notify();
std::set<RsGxsCircleId> circles_to_reload;
//p3Notify *notify = RsServer::notify();
std::set<RsGxsCircleId> circles_to_reload;
for(auto it = changes.begin(); it != changes.end(); ++it)
{
@ -1505,8 +1505,8 @@ bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache&
{
rstime_t now = time(NULL) ;
if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false;
if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false;
if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now)
{
@ -1559,8 +1559,8 @@ bool p3GxsCircles::locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache& cac
return false;
}
if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false;
if(cache.mStatus < CircleEntryCacheStatus::UPDATING)
return false;
/* if we appear in the group - then autosubscribe, and mark as processed. This also applies if we're the group admin */
@ -1702,12 +1702,15 @@ bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
//====================================================================================//
// Overloaded from GxsTokenQueue for Request callbacks.
void p3GxsCircles::handleResponse(uint32_t token, uint32_t req_type)
void p3GxsCircles::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef DEBUG_CIRCLES
std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl;
std::cerr << "p3GxsCircles::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
#endif // DEBUG_CIRCLES
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff.
switch(req_type)

View File

@ -250,10 +250,10 @@ public:
bool revokeIdsFromCircle( const std::set<RsGxsId>& identities,
const RsGxsCircleId& circleId ) override;
/// @see RsGxsCircles
/// @see RsGxsCircles
bool getCircleRequest(const RsGxsGroupId& circleId,
const RsGxsMessageId& msgId,
RsGxsCircleMsg& msg) override;
const RsGxsMessageId& msgId,
RsGxsCircleMsg& msg) override;
/// @see RsGxsCircles
bool exportCircleLink(
@ -270,58 +270,59 @@ public:
std::string& errMsg = RS_DEFAULT_STORAGE_PARAM(std::string)
) override;
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override;
virtual bool getCircleExternalIdList(std::set<RsGxsCircleId> &circleIds) override;
virtual bool getCircleDetails(const RsGxsCircleId &id, RsGxsCircleDetails &details) override;
virtual bool getCircleExternalIdList(std::set<RsGxsCircleId> &circleIds) override;
virtual bool isLoaded(const RsGxsCircleId &circleId) override;
virtual bool loadCircle(const RsGxsCircleId &circleId) override;
virtual bool isLoaded(const RsGxsCircleId &circleId) override;
virtual bool loadCircle(const RsGxsCircleId &circleId) override;
virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool &should_encrypt) override;
virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override;
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist) override;
virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list<RsGxsId> &gxs_ids) override;
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override;
virtual int canSend(const RsGxsCircleId &circleId, const RsPgpId &id, bool &should_encrypt) override;
virtual int canReceive(const RsGxsCircleId &circleId, const RsPgpId &id) override;
virtual bool recipients(const RsGxsCircleId &circleId, std::list<RsPgpId> &friendlist) override;
virtual bool recipients(const RsGxsCircleId &circleId, const RsGxsGroupId& dest_group, std::list<RsGxsId> &gxs_ids) override;
virtual bool isRecipient(const RsGxsCircleId &circleId, const RsGxsGroupId& destination_group, const RsGxsId& id) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) override;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &msgs) override;
virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override;
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) override;
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsCircleGroup> &groups) override;
virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsCircleMsg> &msgs) override;
virtual void createGroup(uint32_t& token, RsGxsCircleGroup &group) override;
virtual void updateGroup(uint32_t &token, RsGxsCircleGroup &group) override;
virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override;
virtual bool service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta) override;
/* membership management for external circles */
virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override;
virtual bool cancelCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override;
/* membership management for external circles */
virtual bool requestCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override;
virtual bool cancelCircleMembership(const RsGxsId &own_gxsid, const RsGxsCircleId& circle_id) override;
/**********************************************/
// needed for background processing.
virtual void service_tick() override;
// needed for background processing.
virtual void service_tick() override;
protected:
// overloads p3Config
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
virtual bool loadList(std::list<RsItem *>& loadList) override;
virtual RsSerialiser *setupSerialiser() override;
// overloads p3Config
virtual bool saveList(bool &cleanup, std::list<RsItem *>&saveList) override;
virtual bool loadList(std::list<RsItem *>& loadList) override;
virtual RsSerialiser *setupSerialiser() override;
bool pushCircleMembershipRequest(const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, RsGxsCircleSubscriptionType request_type) ;
bool pushCircleMembershipRequest(const RsGxsId& own_gxsid, const RsGxsCircleId& circle_id, RsGxsCircleSubscriptionType request_type) ;
static uint32_t circleAuthenPolicy();
/** Notifications **/
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
/** Overloaded to add PgpIdHash to Group Definition **/
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override;
virtual ServiceCreate_Return service_CreateGroup(RsGxsGrpItem* grpItem, RsTlvSecurityKeySet& keySet) override;
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type) override;
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
// Overloaded from RsTickEvent.
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
private:

View File

@ -199,7 +199,7 @@ bool p3GxsCommentService::getGxsCommentData(const uint32_t &token, std::vector<R
for(; mit != msgData.end(); ++mit)
{
RsGxsGroupId grpId = mit->first;
//RsGxsGroupId grpId = mit->first;
std::vector<RsGxsMsgItem*>& msgItems = mit->second;
std::vector<RsGxsMsgItem*>::iterator vit = msgItems.begin();
@ -697,12 +697,15 @@ bool p3GxsCommentService::acknowledgeVote(const uint32_t& token, RsGxsGrpMsgIdPa
// Overloaded from GxsTokenQueue for Request callbacks.
void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type)
void p3GxsCommentService::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef DEBUG_GXSCOMMON
std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl;
std::cerr << "p3GxsCommentService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
#endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff.
switch(req_type)

View File

@ -82,7 +82,8 @@ static double calculateBestScore(int upVotes, int downVotes);
protected:
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type);
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
private:

View File

@ -151,27 +151,26 @@ RsIdentity* rsIdentity = nullptr;
/******************* Startup / Tick ******************************************/
/********************************************************************************/
p3IdService::p3IdService(
RsGeneralDataService *gds, RsNetworkExchangeService *nes,
PgpAuxUtils *pgpUtils ) :
RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(),
RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() ),
RsIdentity(static_cast<RsGxsIface&>(*this)), GxsTokenQueue(this),
RsTickEvent(), mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache"),
mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils)
p3IdService::p3IdService( RsGeneralDataService *gds
, RsNetworkExchangeService *nes
, PgpAuxUtils *pgpUtils )
: RsGxsIdExchange( gds, nes, new RsGxsIdSerialiser(),
RS_SERVICE_GXS_TYPE_GXSID, idAuthenPolicy() )
, RsIdentity(static_cast<RsGxsIface&>(*this))
, GxsTokenQueue(this), RsTickEvent(), p3Config()
, mKeyCache(GXSID_MAX_CACHE_SIZE, "GxsIdKeyCache")
, mBgSchedule_Active(false), mBgSchedule_Mode(0)
, mIdMtx("p3IdService"), mNes(nes), mPgpUtils(pgpUtils)
, mLastConfigUpdate(0), mOwnIdsLoaded(false)
, mAutoAddFriendsIdentitiesAsContacts(true) /*default*/
, mMaxKeepKeysBanned(MAX_KEEP_KEYS_BANNED_DEFAULT)
{
mBgSchedule_Mode = 0;
mBgSchedule_Active = false;
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
mLastConfigUpdate = 0 ;
mOwnIdsLoaded = false ;
mAutoAddFriendsIdentitiesAsContacts = true; // default
mMaxKeepKeysBanned = MAX_KEEP_KEYS_BANNED_DEFAULT;
mLastKeyCleaningTime = time(NULL) - int(MAX_DELAY_BEFORE_CLEANING * 0.9) ;
// Kick off Cache Testing, + Others.
RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);//First Thing to do
RsTickEvent::schedule_in(GXSID_EVENT_PGPHASH, PGPHASH_PERIOD);
RsTickEvent::schedule_in(GXSID_EVENT_REPUTATION, REPUTATION_PERIOD);
RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);
//RsTickEvent::schedule_in(GXSID_EVENT_CACHETEST, CACHETEST_PERIOD);
@ -4478,7 +4477,7 @@ void p3IdService::generateDummy_OwnIds()
/* grab all the gpg ids... and make some ids */
RsPgpId ownId = mPgpUtils->getPGPOwnId();
/*RsPgpId ownId = */mPgpUtils->getPGPOwnId();
#if 0
// generate some ownIds.
@ -4694,36 +4693,37 @@ void p3IdService::checkPeerForIdentities()
// Overloaded from GxsTokenQueue for Request callbacks.
void p3IdService::handleResponse(uint32_t token, uint32_t req_type)
void p3IdService::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef DEBUG_IDS
std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl;
std::cerr << "p3IdService::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
#endif // DEBUG_IDS
// stuff.
switch(req_type)
{
case GXSIDREQ_CACHEOWNIDS:
cache_load_ownids(token);
if (status == RsTokenService::COMPLETE) cache_load_ownids(token);
if (status == RsTokenService::CANCELLED) RsTickEvent::schedule_now(GXSID_EVENT_CACHEOWNIDS);//Cancelled by time-out so ask a new time
break;
case GXSIDREQ_CACHELOAD:
cache_load_for_token(token);
if (status == RsTokenService::COMPLETE) cache_load_for_token(token);
break;
case GXSIDREQ_PGPHASH:
pgphash_handlerequest(token);
if (status == RsTokenService::COMPLETE) pgphash_handlerequest(token);
break;
case GXSIDREQ_RECOGN:
recogn_handlerequest(token);
if (status == RsTokenService::COMPLETE) recogn_handlerequest(token);
break;
case GXSIDREQ_CACHETEST:
cachetest_handlerequest(token);
if (status == RsTokenService::COMPLETE) cachetest_handlerequest(token);
break;
case GXSIDREQ_OPINION:
opinion_handlerequest(token);
if (status == RsTokenService::COMPLETE) opinion_handlerequest(token);
break;
case GXSIDREQ_SERIALIZE_TO_MEMORY:
handle_get_serialized_grp(token);
if (status == RsTokenService::COMPLETE) handle_get_serialized_grp(token);
break;
default:
std::cerr << "p3IdService::handleResponse() Unknown Request Type: "

View File

@ -404,8 +404,9 @@ protected:
// Overloads RsGxsGenExchange
virtual bool acceptNewGroup(const RsGxsGrpMetaData *grpMeta) override ;
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type) override;
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
// Overloaded from RsTickEvent.
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
@ -558,7 +559,7 @@ private:
void cleanUnusedKeys() ;
void slowIndicateConfigChanged() ;
virtual void timeStampKey(const RsGxsId& id, const RsIdentityUsage& reason) ;
virtual void timeStampKey(const RsGxsId& id, const RsIdentityUsage& reason) override;
rstime_t locked_getLastUsageTS(const RsGxsId& gxs_id);
std::string genRandomId(int len = 20);

View File

@ -322,7 +322,7 @@ bool p3PhotoService::createAlbum(RsPhotoAlbum &album)
return submitAlbumDetails(token, album) && waitToken(token) == RsTokenService::COMPLETE;
}
bool p3PhotoService::updateAlbum(const RsPhotoAlbum &album)
bool p3PhotoService::updateAlbum(const RsPhotoAlbum &/*album*/)
{
// TODO
return false;

View File

@ -31,7 +31,7 @@ class p3PhotoService : public RsGenExchange, public RsPhoto
public:
p3PhotoService(RsGeneralDataService* gds, RsNetworkExchangeService* nes, RsGixs* gixs);
virtual RsServiceInfo getServiceInfo();
virtual RsServiceInfo getServiceInfo() override;
static uint32_t photoAuthenPolicy();
@ -40,38 +40,38 @@ public:
/*!
* @return true if a change has occured
*/
bool updated();
bool updated() override;
/*!
*
*/
void service_tick();
void service_tick() override;
protected:
void notifyChanges(std::vector<RsGxsNotify*>& changes);
void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
public:
/** Requests **/
void groupsChanged(std::list<RsGxsGroupId>& grpIds);
void groupsChanged(std::list<RsGxsGroupId>& grpIds) override;
void msgsChanged(GxsMsgIdResult& msgs);
void msgsChanged(GxsMsgIdResult& msgs) override;
RsTokenService* getTokenService();
RsTokenService* getTokenService() override;
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds);
bool getMsgList(const uint32_t &token, GxsMsgIdResult& msgIds);
bool getGroupList(const uint32_t &token, std::list<RsGxsGroupId> &groupIds) override;
bool getMsgList(const uint32_t &token, GxsMsgIdResult& msgIds) override;
/* Generic Summary */
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo);
bool getGroupSummary(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo) override;
bool getMsgSummary(const uint32_t &token, MsgMetaResult &msgInfo);
bool getMsgSummary(const uint32_t &token, MsgMetaResult &msgInfo) override;
/* Specific Service Data */
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums);
bool getPhoto(const uint32_t &token, PhotoResult &photos);
bool getAlbum(const uint32_t &token, std::vector<RsPhotoAlbum> &albums) override;
bool getPhoto(const uint32_t &token, PhotoResult &photos) override;
public:
/* Comment service - Provide RsGxsCommentService - redirect to p3GxsCommentService */
@ -109,6 +109,13 @@ public:
return acknowledgeMsg(token, msgId);
}
//Not currently used
virtual bool setCommentAsRead(uint32_t& /*token*/,const RsGxsGroupId& /*gid*/,const RsGxsMessageId& /*comment_msg_id*/) override
{
return true;
}
// Blocking versions.
virtual bool createComment(RsGxsComment &msg) override
{
@ -126,7 +133,7 @@ public:
* @param token token to redeem for acknowledgement
* @param album album to be submitted
*/
bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album);
bool submitAlbumDetails(uint32_t& token, RsPhotoAlbum &album) override;
/*!
* submits photo, which returns a token that needs
@ -134,7 +141,7 @@ public:
* @param token token to redeem for acknowledgement
* @param photo photo to be submitted
*/
bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo);
bool submitPhoto(uint32_t& token, RsPhotoPhoto &photo) override;
/*!
* submits photo comment, which returns a token that needs
@ -152,7 +159,7 @@ public:
* @param token token to redeem for acknowledgement
* @param grpId the id of the group to subscribe to
*/
bool subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe);
bool subscribeToAlbum(uint32_t& token, const RsGxsGroupId& grpId, bool subscribe) override;
/*!
* This allows the client service to acknowledge that their msgs has
@ -161,7 +168,7 @@ public:
* @param msgIds map of grpid->msgIds of message created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId);
bool acknowledgeMsg(const uint32_t& token, std::pair<RsGxsGroupId, RsGxsMessageId>& msgId) override;
/*!
* This allows the client service to acknowledge that their grps has
@ -170,7 +177,7 @@ public:
* @param msgIds vector of ids of groups created/modified
* @return true if token exists false otherwise
*/
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId);
bool acknowledgeGrp(const uint32_t& token, RsGxsGroupId& grpId) override;
// Blocking versions.
/*!

View File

@ -849,12 +849,14 @@ bool p3PostBase::background_cleanup()
// Overloaded from GxsTokenQueue for Request callbacks.
void p3PostBase::handleResponse(uint32_t token, uint32_t req_type)
void p3PostBase::handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status)
{
#ifdef POSTBASE_DEBUG
std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << ")";
std::cerr << std::endl;
std::cerr << "p3PostBase::handleResponse(" << token << "," << req_type << "," << status << ")" << std::endl;
#endif
if (status != RsTokenService::COMPLETE)
return; //For now, only manage Complete request
// stuff.
switch(req_type)

View File

@ -70,17 +70,18 @@ public:
p3PostBase(RsGeneralDataService *gds, RsNetworkExchangeService *nes, RsGixs* gixs,
RsSerialType* serviceSerialiser, uint16_t serviceType);
virtual void service_tick() override;
virtual void service_tick() override;
protected:
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
virtual void notifyChanges(std::vector<RsGxsNotify*>& changes) override;
// Overloaded from GxsTokenQueue for Request callbacks.
virtual void handleResponse(uint32_t token, uint32_t req_type) override;
virtual void handleResponse(uint32_t token, uint32_t req_type
, RsTokenService::GxsRequestStatus status) override;
// Overloaded from RsTickEvent.
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
virtual void handle_event(uint32_t event_type, const std::string &elabel) override;
// overloads p3Config
virtual RsSerialiser* setupSerialiser() override; // @see p3Config::setupSerialiser()

View File

@ -110,6 +110,6 @@ android-* {
}
################################### Pkg-Config Stuff #############################
LIBS *= $$system(pkg-config --libs $$PKGCONFIG)
!isEmpty(PKGCONFIG) {
LIBS *= $$system(pkg-config --libs $$PKGCONFIG)
}

View File

@ -377,7 +377,9 @@ MainWindow::~MainWindow()
delete sysTrayStatus;
delete trayIcon;
delete trayMenu;
// delete notifyMenu; // already deleted by the deletion of trayMenu
// delete notifyMenu; // already deleted by the deletion of trayMenu
StatisticsWindow::releaseInstance();
#ifdef MESSENGER_WINDOW
MessengerWindow::releaseInstance();
#endif

View File

@ -69,6 +69,7 @@ PeopleDialog::PeopleDialog(QWidget *parent)
tabWidget->removeTab(1);
//hide circle flow widget not functional yet
pictureFlowWidgetExternal->hide();
widgetExternal->hide();
//need erase QtCreator Layout first(for Win)
delete idExternal->layout();

View File

@ -20,76 +20,25 @@
<string/>
</property>
<layout class="QGridLayout" name="titleBarLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/identity/identities_32.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="StyledLabel" name="titleBarLabel">
<property name="text">
<string>People</string>
</property>
</widget>
</item>
<item>
<spacer name="titleBarSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabExternal">
<property name="sizePolicy">
@ -129,7 +78,7 @@
<layout class="QVBoxLayout"/>
</widget>
</widget>
<widget class="QWidget" name="widgetExternal">
<widget class="QFrame" name="widgetExternal">
<layout class="QGridLayout" name="layoutExternal">
<item row="0" column="0">
<widget class="QLabel" name="label_External">
@ -234,11 +183,6 @@
</layout>
</widget>
<customwidgets>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
<customwidget>
<class>PictureFlow</class>
<extends>QWidget</extends>

View File

@ -365,6 +365,9 @@
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>

View File

@ -72,55 +72,57 @@ void RsPostedPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEvent>
switch(e->mPostedEventCode)
{
case RsPostedEventCode::UPDATED_MESSAGE:
case RsPostedEventCode::READ_STATUS_CHANGED:
case RsPostedEventCode::MESSAGE_VOTES_UPDATED:
case RsPostedEventCode::NEW_MESSAGE:
{
// Normally we should just emit dataChanged() on the index of the data that has changed:
//
// We need to update the data!
case RsPostedEventCode::UPDATED_MESSAGE:
case RsPostedEventCode::READ_STATUS_CHANGED:
case RsPostedEventCode::MESSAGE_VOTES_UPDATED:
case RsPostedEventCode::NEW_MESSAGE:
{
// Normally we should just emit dataChanged() on the index of the data that has changed:
//
// We need to update the data!
if(e->mPostedGroupId == mPostedGroup.mMeta.mGroupId)
RsThread::async([this, e]()
{
// 1 - get message data from p3GxsChannels
RsGxsPostedEvent E(*e);
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
std::vector<RsGxsVote> votes;
if(!rsPosted->getBoardContent(mPostedGroup.mMeta.mGroupId,std::set<RsGxsMessageId>{ e->mPostedMsgId }, posts,comments,votes))
if(E.mPostedGroupId == mPostedGroup.mMeta.mGroupId)
RsThread::async([this, E]()
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve channel message data for channel/msg " << e->mPostedGroupId << "/" << e->mPostedMsgId << std::endl;
return;
}
// 1 - get message data from p3GxsChannels
// 2 - update the model in the UI thread.
std::vector<RsPostedPost> posts;
std::vector<RsGxsComment> comments;
std::vector<RsGxsVote> votes;
RsQThreadUtils::postToObject( [posts,comments,votes,this]()
{
for(uint32_t i=0;i<posts.size();++i)
if(!rsPosted->getBoardContent(mPostedGroup.mMeta.mGroupId,std::set<RsGxsMessageId>{ E.mPostedMsgId }, posts,comments,votes))
{
// linear search. Not good at all, but normally this is for a single post.
for(uint32_t j=0;j<mPosts.size();++j)
if(mPosts[j].mMeta.mMsgId == posts[i].mMeta.mMsgId)
{
mPosts[j] = posts[i];
//emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL));
preMods();
postMods();
}
RS_ERR(" failed to retrieve channel message data for channel/msg ", E.mPostedGroupId, "/", E.mPostedMsgId);
return;
}
},this);
});
default:
break;
// 2 - update the model in the UI thread.
RsQThreadUtils::postToObject( [posts,comments,votes,this]()
{
for(uint32_t i=0;i<posts.size();++i)
{
// linear search. Not good at all, but normally this is for a single post.
for(uint32_t j=0;j<mPosts.size();++j)
if(mPosts[j].mMeta.mMsgId == posts[i].mMeta.mMsgId)
{
mPosts[j] = posts[i];
//emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredPosts.size(),0,(void*)NULL));
preMods();
postMods();
}
}
},this);
});
}
default:
break;
}
}
@ -138,42 +140,38 @@ void RsPostedPostsModel::initEmptyHierarchy()
void RsPostedPostsModel::preMods()
{
beginResetModel();
emit layoutAboutToBeChanged();
}
void RsPostedPostsModel::postMods()
{
endResetModel();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
update();
emit layoutChanged();
}
void RsPostedPostsModel::update()
{
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mDisplayedNbPosts,0,(void*)NULL));
}
void RsPostedPostsModel::triggerRedraw()
{
preMods();
postMods();
preMods();
postMods();
}
void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
{
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
beginResetModel();
mFilteredPosts.clear();
endResetModel();
if(strings.empty())
{
mFilteredPosts.clear();
for(int i=0;i<(int)(mPosts.size());++i)
mFilteredPosts.push_back(i);
}
else
{
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
for(int i=0;i<static_cast<int>(mPosts.size());++i)
{
bool passes_strings = true;
@ -197,8 +195,11 @@ void RsPostedPostsModel::setFilter(const QStringList& strings, uint32_t& count)
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
}
@ -208,11 +209,11 @@ int RsPostedPostsModel::rowCount(const QModelIndex& parent) const
if(parent.column() > 0)
return 0;
if(mFilteredPosts.empty()) // security. Should never happen.
if(mFilteredPosts.empty()) // rowCount is called by internal Qt so maybe before posts are populated.
return 0;
if(!parent.isValid())
return mDisplayedNbPosts;
return mDisplayedNbPosts;
RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl;
return 0;
@ -471,7 +472,7 @@ private:
Qt::ItemFlags RsPostedPostsModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
return Qt::ItemFlags();
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
@ -493,16 +494,16 @@ void RsPostedPostsModel::setPostsInterval(int start,int nb_posts)
preMods();
uint32_t old_nb_rows = rowCount() ;
uint32_t old_nb_rows = rowCount() ;
mDisplayedNbPosts = (uint32_t)std::min(nb_posts,(int)mFilteredPosts.size() - (start+1));
mDisplayedStartIndex = start;
mDisplayedNbPosts = (uint32_t)std::min(nb_posts,(int)mFilteredPosts.size() - (start+1));
mDisplayedStartIndex = start;
beginRemoveRows(QModelIndex(),mDisplayedNbPosts,old_nb_rows);
endRemoveRows();
endRemoveRows();
beginInsertRows(QModelIndex(),old_nb_rows,mDisplayedNbPosts);
endInsertRows();
endInsertRows();
postMods();
}
@ -515,26 +516,30 @@ void RsPostedPostsModel::deepUpdate()
void RsPostedPostsModel::setPosts(const RsPostedGroup& group, std::vector<RsPostedPost>& posts)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
beginResetModel();
mPosts.clear();
mPostedGroup = group;
mPosts.clear();
mPostedGroup = group;
createPostsArray(posts);
endResetModel();
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
createPostsArray(posts);
uint32_t tmpval;
setFilter(QStringList(),tmpval);
std::sort(mPosts.begin(),mPosts.end(), PostSorter(mSortingStrategy));
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
mDisplayedStartIndex = 0;
uint32_t tmpval;
setFilter(QStringList(),tmpval);
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
mDisplayedNbPosts = std::min((uint32_t)mFilteredPosts.size(),DEFAULT_DISPLAYED_NB_POSTS);
mDisplayedStartIndex = 0;
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
@ -597,8 +602,6 @@ void RsPostedPostsModel::update_posts(const RsGxsGroupId& group_id)
});
}
//static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
void RsPostedPostsModel::createPostsArray(std::vector<RsPostedPost>& posts)
{
#ifdef TODO

View File

@ -224,14 +224,22 @@ void AvatarWidget::refreshStatus()
status = statusInfo.status ;
}
else if(mId.isDistantChatId())
{
DistantChatPeerInfo dcpinfo ;
{
DistantChatPeerInfo dcpinfo ;
if(rsMsgs->getDistantChatStatus(mId.toDistantChatId(),dcpinfo))
status = dcpinfo.status ;
else
std::cerr << "(EE) cannot get distant chat status for ID=" << mId.toDistantChatId() << std::endl;
}
if(rsMsgs->getDistantChatStatus(mId.toDistantChatId(),dcpinfo))
{
switch (dcpinfo.status)
{
case RS_DISTANT_CHAT_STATUS_CAN_TALK : status = RS_STATUS_ONLINE ; break;
case RS_DISTANT_CHAT_STATUS_UNKNOWN : // Fall-through
case RS_DISTANT_CHAT_STATUS_TUNNEL_DN : // Fall-through
case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED : status = RS_STATUS_OFFLINE;
}
}
else
std::cerr << "(EE) cannot get distant chat status for ID=" << mId.toDistantChatId() << std::endl;
}
else
{
std::cerr << "Unhandled chat id type in AvatarWidget::refreshStatus()" << std::endl;

View File

@ -152,93 +152,95 @@ void RsFriendListModel::setDisplayGroups(bool b)
}
void RsFriendListModel::preMods()
{
beginResetModel();
emit layoutAboutToBeChanged();
}
void RsFriendListModel::postMods()
{
endResetModel();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL));
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,columnCount()-1,(void*)NULL));
emit layoutChanged();
}
int RsFriendListModel::rowCount(const QModelIndex& parent) const
{
if(parent.column() >= COLUMN_THREAD_NB_COLUMNS)
return 0;
if(parent.column() >= COLUMN_THREAD_NB_COLUMNS)
return 0;
if(parent.internalId() == 0)
return mTopLevel.size();
EntryIndex index;
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),index))
return 0;
EntryIndex index;
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),index))
return 0;
if(index.type == ENTRY_TYPE_GROUP)
return mGroups[index.group_index].child_profile_indices.size();
if(index.type == ENTRY_TYPE_GROUP)
return mGroups[index.group_index].child_profile_indices.size();
if(index.type == ENTRY_TYPE_PROFILE)
if(index.type == ENTRY_TYPE_PROFILE)
{
if(index.group_index < UNDEFINED_GROUP_INDEX_VALUE)
return mProfiles[mGroups[index.group_index].child_profile_indices[index.profile_index]].child_node_indices.size();
else
return mProfiles[index.profile_index].child_node_indices.size();
else
return mProfiles[index.profile_index].child_node_indices.size();
}
else //if(index.type == ENTRY_TYPE_NODE)
return 0;
return 0;
}
int RsFriendListModel::columnCount(const QModelIndex &parent) const
int RsFriendListModel::columnCount(const QModelIndex &/*parent*/) const
{
return COLUMN_THREAD_NB_COLUMNS ;
}
bool RsFriendListModel::hasChildren(const QModelIndex &parent) const
{
if(!parent.isValid())
return true;
if(!parent.isValid())
return true;
EntryIndex parent_index ;
convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),parent_index);
convertInternalIdToIndex<sizeof(uintptr_t)>(parent.internalId(),parent_index);
if(parent_index.type == ENTRY_TYPE_NODE)
return false;
if(parent_index.type == ENTRY_TYPE_NODE)
return false;
if(parent_index.type == ENTRY_TYPE_PROFILE)
if(parent_index.type == ENTRY_TYPE_PROFILE)
{
if(parent_index.group_index < UNDEFINED_GROUP_INDEX_VALUE)
return !mProfiles[mGroups[parent_index.group_index].child_profile_indices[parent_index.profile_index]].child_node_indices.empty();
else
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
if(parent_index.type == ENTRY_TYPE_GROUP)
return !mGroups[parent_index.group_index].child_profile_indices.empty();
else
return !mProfiles[parent_index.profile_index].child_node_indices.empty();
}
if(parent_index.type == ENTRY_TYPE_GROUP)
return !mGroups[parent_index.group_index].child_profile_indices.empty();
return false;
}
RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::parent() const
{
EntryIndex i(*this);
EntryIndex i(*this);
switch(type)
{
case ENTRY_TYPE_GROUP: return EntryIndex();
switch(type)
{
case ENTRY_TYPE_GROUP: return EntryIndex();
case ENTRY_TYPE_PROFILE:
if(i.group_index==UNDEFINED_GROUP_INDEX_VALUE)
return EntryIndex();
else
{
i.type = ENTRY_TYPE_GROUP;
i.profile_index = UNDEFINED_PROFILE_INDEX_VALUE;
}
break;
case ENTRY_TYPE_PROFILE:
if(i.group_index==UNDEFINED_GROUP_INDEX_VALUE)
return EntryIndex();
else
{
i.type = ENTRY_TYPE_GROUP;
i.profile_index = UNDEFINED_PROFILE_INDEX_VALUE;
}
break;
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
break;
}
case ENTRY_TYPE_NODE: i.type = ENTRY_TYPE_PROFILE;
i.node_index = UNDEFINED_NODE_INDEX_VALUE;
break;
case ENTRY_TYPE_UNKNOWN:
RS_ERR("Unknown Entry type for parent.");
}
return i;
return i;
}
RsFriendListModel::EntryIndex RsFriendListModel::EntryIndex::child(int row,const std::vector<EntryIndex>& top_level) const
@ -310,32 +312,32 @@ QModelIndex RsFriendListModel::index(int row, int column, const QModelIndex& par
QModelIndex RsFriendListModel::parent(const QModelIndex& index) const
{
if(!index.isValid())
return QModelIndex();
if(!index.isValid())
return QModelIndex();
EntryIndex I ;
convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),I);
convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),I);
EntryIndex p = I.parent();
EntryIndex p = I.parent();
if(p.type == ENTRY_TYPE_UNKNOWN)
return QModelIndex();
if(p.type == ENTRY_TYPE_UNKNOWN)
return QModelIndex();
quintptr i;
convertIndexToInternalId<sizeof(uintptr_t)>(p,i);
quintptr i;
convertIndexToInternalId<sizeof(uintptr_t)>(p,i);
return createIndex(I.parentRow(mGroups.size()),0,i);
}
Qt::ItemFlags RsFriendListModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
if (!index.isValid())
return Qt::ItemFlags();
return QAbstractItemModel::flags(index);
return QAbstractItemModel::flags(index);
}
QVariant RsFriendListModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant RsFriendListModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
{
if(role == Qt::DisplayRole)
switch(section)
@ -414,17 +416,17 @@ QVariant RsFriendListModel::textColorRole(const EntryIndex& fmpe,int column) con
}
}
QVariant RsFriendListModel::statusRole(const EntryIndex& fmpe,int column) const
QVariant RsFriendListModel::statusRole(const EntryIndex& /*fmpe*/,int /*column*/) const
{
return QVariant();//fmpe.mMsgStatus);
}
bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
bool RsFriendListModel::passesFilter(const EntryIndex& e,int /*column*/) const
{
QString s ;
bool passes_strings = true ;
if(e.type == ENTRY_TYPE_PROFILE && !mFilterStrings.empty())
if(e.type == ENTRY_TYPE_PROFILE && !mFilterStrings.empty())
{
switch(mFilterType)
{
@ -435,6 +437,8 @@ bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
if(s.isNull())
passes_strings = false;
break;
case FILTER_TYPE_NONE:
RS_ERR("None Type for Filter.");
};
}
@ -447,18 +451,15 @@ bool RsFriendListModel::passesFilter(const EntryIndex& e,int column) const
QVariant RsFriendListModel::filterRole(const EntryIndex& e,int column) const
{
if(passesFilter(e,column))
return QVariant(FilterString);
if(passesFilter(e,column))
return QVariant(FilterString);
return QVariant(QString());
}
uint32_t RsFriendListModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
uint32_t RsFriendListModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/,const QStringList& /*strings*/)
{
QString s ;
uint32_t count = 0;
return count;
return 0;
}
@ -479,7 +480,7 @@ void RsFriendListModel::setFilter(FilterType filter_type, const QStringList& str
postMods();
}
QVariant RsFriendListModel::toolTipRole(const EntryIndex& fmpe,int column) const
QVariant RsFriendListModel::toolTipRole(const EntryIndex& /*fmpe*/,int /*column*/) const
{
return QVariant();
}
@ -489,14 +490,14 @@ QVariant RsFriendListModel::sizeHintRole(const EntryIndex& e,int col) const
float x_factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
float y_factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
if(e.type == ENTRY_TYPE_NODE)
y_factor *= 3.0;
if(e.type == ENTRY_TYPE_NODE)
y_factor *= 3.0;
if((e.type == ENTRY_TYPE_PROFILE) && !isProfileExpanded(e))
y_factor *= 3.0;
if((e.type == ENTRY_TYPE_PROFILE) && !isProfileExpanded(e))
y_factor *= 3.0;
if(e.type == ENTRY_TYPE_GROUP)
y_factor = std::max(y_factor, 24.0f / 14.0f ); // allows to fit the 24 pixels icon for groups in the line
if(e.type == ENTRY_TYPE_GROUP)
y_factor = std::max(y_factor, 24.0f / 14.0f ); // allows to fit the 24 pixels icon for groups in the line
switch(col)
{
@ -542,7 +543,7 @@ QVariant RsFriendListModel::sortRole(const EntryIndex& entry,int column) const
}
}
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int col) const
QVariant RsFriendListModel::onlineRole(const EntryIndex& e, int /*col*/) const
{
switch(e.type)
{
@ -698,7 +699,7 @@ QVariant RsFriendListModel::displayRole(const EntryIndex& e, int col) const
if(col == COLUMN_THREAD_IP) return QVariant(most_recent_ip);
}
}
}// Fall-through
default:
return QVariant();
}
@ -826,7 +827,6 @@ const RsFriendListModel::HierarchicalNodeInformation *RsFriendListModel::getNode
if(e.node_index >= mProfiles[pindex].child_node_indices.size())
return NULL ;
time_t now = time(NULL);
HierarchicalNodeInformation& node(mLocations[mProfiles[pindex].child_node_indices[e.node_index]]);
return &node;
@ -895,8 +895,6 @@ void RsFriendListModel::clear()
emit friendListChanged();
}
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
void RsFriendListModel::debug_dump() const
{
std::cerr << "==== FriendListModel Debug dump ====" << std::endl;
@ -1084,14 +1082,14 @@ void RsFriendListModel::updateInternalData()
{
preMods();
beginRemoveRows(QModelIndex(),0,mTopLevel.size()-1);
beginResetModel();
mGroups.clear();
mProfiles.clear();
mLocations.clear();
mTopLevel.clear();
endRemoveRows();
endResetModel();
auto TL = mTopLevel ; // This allows to fill TL without touching mTopLevel outside of [begin/end]InsertRows().
@ -1218,17 +1216,19 @@ void RsFriendListModel::updateInternalData()
TL.push_back(e);
}
// finally, tell the model client that layout has changed.
// finally, tell the model client that layout has changed.
beginInsertRows(QModelIndex(),0,TL.size()-1);
mTopLevel = TL;
mTopLevel = TL;
if (TL.size()>0)
{
beginInsertRows(QModelIndex(),0,TL.size()-1);
endInsertRows();
}
endInsertRows();
postMods();
postMods();
mLastInternalDataUpdate = time(NULL);
mLastInternalDataUpdate = time(NULL);
}
QModelIndex RsFriendListModel::getIndexOfGroup(const RsNodeGroupId& mid) const
@ -1251,7 +1251,7 @@ void RsFriendListModel::collapseItem(const QModelIndex& index)
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),entry))
return;
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
const HierarchicalGroupInformation *hg = getGroupInfo(entry);
std::string s ;
@ -1276,7 +1276,7 @@ void RsFriendListModel::expandItem(const QModelIndex& index)
if(!convertInternalIdToIndex<sizeof(uintptr_t)>(index.internalId(),entry))
return;
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
const HierarchicalProfileInformation *hp = getProfileInfo(entry);
const HierarchicalGroupInformation *hg = getGroupInfo(entry);
std::string s ;

View File

@ -202,7 +202,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
moOption.decorationPosition = QStyleOptionViewItem::Left;
moOption.decorationSize = QSize();
moOption.displayAlignment = Qt::AlignLeft | Qt::AlignTop;
moOption.features=0;
moOption.features=QStyleOptionViewItem::ViewItemFeatures();
moOption.font = QFont();
moOption.icon = QIcon();
moOption.index = QModelIndex();
@ -217,7 +217,8 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
moOption.palette = QPalette();
moOption.styleObject = nullptr;
}
QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex());
//QStyledItemDelegate::paint(&moPnt, moOption, QModelIndex(index));//This update option now.
ownStyle->drawControl(QStyle::CE_ItemViewItem, &moOption, &moPnt, widget);
//// But these lines doesn't works.
{
@ -300,9 +301,9 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
{
QStyleOptionViewItem tstOption = option;
// Reduce rect to get this item bg color external and base internal
tstOption.rect.adjust(3,3,-6,-6);
tstOption.rect.adjust(2,2,-2,-2);
// To draw with base for debug purpose
QStyledItemDelegate::paint(painter, tstOption, index);
RSStyledItemDelegate::paint(painter, tstOption, index);
}
#endif
@ -379,6 +380,10 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
QTextLayout textLayout(ownOption.text, painter->font());
QTextOption to = textLayout.textOption();
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
StyledElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode()&QTextOption::WordWrap,mPaintRoundedRect);
}
painter->restore();
@ -393,7 +398,9 @@ bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
QMouseEvent *ev = static_cast<QMouseEvent *>(event);
if (ev) {
if (ev->buttons()==Qt::LeftButton) {
#ifdef DEBUG_EID_PAINT
QVariant var = index.data();
#endif
if (index.data().type() == QVariant::String) {
QString text = index.data().toString();
if (!text.isEmpty()) {
@ -417,6 +424,9 @@ bool RSElidedItemDelegate::editorEvent(QEvent *event, QAbstractItemModel *model,
ownOption.fontMetrics = QFontMetrics(font);
}
QRect textRect = ownStyle->subElementRect(QStyle::SE_ItemViewItemText, &ownOption, widget);
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
QTextLayout textLayout(text, ownOption.font);
QTextOption to = textLayout.textOption();

View File

@ -345,7 +345,11 @@ void RSGraphWidget::paintEvent(QPaintEvent *)
_painter->setRenderHint(QPainter::TextAntialiasing);
/* Fill in the background */
_painter->fillRect(_rec, QBrush(BACK_COLOR));
if (_flags & RSGRAPH_FLAGS_DARK_STYLE){
_painter->fillRect(_rec, QBrush(BACK_COLOR_DARK));
}else {
_painter->fillRect(_rec, QBrush(BACK_COLOR));
}
_painter->drawRect(_rec);
/* Paint the scale */
@ -649,10 +653,17 @@ void RSGraphWidget::paintScale1()
QString text = _source->displayValue(scale) ;
_painter->setPen(SCALE_COLOR);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text);
_painter->setPen(GRID_COLOR);
_painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos));
if (_flags & RSGRAPH_FLAGS_DARK_STYLE){
_painter->setPen(SCALE_COLOR_DARK);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text);
_painter->setPen(GRID_COLOR_DARK);
_painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos));
}else{
_painter->setPen(SCALE_COLOR);
_painter->drawText(QPointF(SCALE_WIDTH*fact - QFontMetricsF(font()).width(text) - 4*fact, pos+0.4*FS), text);
_painter->setPen(GRID_COLOR);
_painter->drawLine(QPointF(SCALE_WIDTH*fact, pos), QPointF(_rec.width(), pos));
}
}
/* Draw vertical separator */
@ -675,8 +686,10 @@ void RSGraphWidget::paintScale2()
int seconds = (_rec.width()-i)/_time_scale ; // pixels / (pixels per second) => seconds
QString text = QString::number(seconds)+ " secs";
_painter->setPen(SCALE_COLOR);
if (_flags & RSGRAPH_FLAGS_DARK_STYLE)
_painter->setPen(SCALE_COLOR_DARK);
else
_painter->setPen(SCALE_COLOR);
_painter->drawText(QPointF(i, _rec.height()-0.5*FS), text);
}
}
@ -743,8 +756,10 @@ void RSGraphWidget::paintLegend()
_painter->setPen(pen);
_painter->drawLine(QPointF(SCALE_WIDTH*fact+10.0*fact, pos+FS/3), QPointF(SCALE_WIDTH*fact+30.0*fact, pos+FS/3));
_painter->setPen(oldPen);
_painter->setPen(SCALE_COLOR);
if (_flags & RSGRAPH_FLAGS_DARK_STYLE)
_painter->setPen(SCALE_COLOR_DARK);
else
_painter->setPen(SCALE_COLOR);
_painter->drawText(QPointF(SCALE_WIDTH *fact+ 40*fact,pos + 0.5*FS), text) ;
++j ;

View File

@ -36,11 +36,14 @@
#define MINUSER_SCALE 2000 /** 2000 users is the minimum scale */
#define SCROLL_STEP 4 /** Horizontal change on graph update */
#define BACK_COLOR Qt::white
#define SCALE_COLOR Qt::black
#define GRID_COLOR Qt::lightGray
#define RSDHT_COLOR Qt::magenta
#define ALLDHT_COLOR Qt::yellow
#define BACK_COLOR Qt::white
#define SCALE_COLOR Qt::black
#define GRID_COLOR Qt::lightGray
#define BACK_COLOR_DARK Qt::black
#define SCALE_COLOR_DARK Qt::green
#define GRID_COLOR_DARK Qt::darkGreen
#define RSDHT_COLOR Qt::magenta
#define ALLDHT_COLOR Qt::yellow
struct ZeroInitFloat
{
@ -145,6 +148,7 @@ public:
static const uint32_t RSGRAPH_FLAGS_LEGEND_CUMULATED = 0x0040 ;// show the total in the legend rather than current values
static const uint32_t RSGRAPH_FLAGS_PAINT_STYLE_DOTS = 0x0080 ;// use dots
static const uint32_t RSGRAPH_FLAGS_LEGEND_INTEGER = 0x0100 ;// use integer number in the legend, and move the lines to match integers
static const uint32_t RSGRAPH_FLAGS_DARK_STYLE = 0x0200 ;// darkstyle graph
/** Bandwidth graph style. */
enum GraphStyle

View File

@ -37,7 +37,9 @@
Q_DECLARE_METATYPE(ChannelPostFileInfo)
#ifdef DEBUG_CHANNEL_MODEL
static std::ostream& operator<<(std::ostream& o, const QModelIndex& i);// defined elsewhere
#endif
RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
: QAbstractItemModel(parent)
@ -50,45 +52,43 @@ RsGxsChannelPostFilesModel::RsGxsChannelPostFilesModel(QObject *parent)
void RsGxsChannelPostFilesModel::initEmptyHierarchy()
{
preMods();
beginResetModel();
mFiles.clear();
mFilteredFiles.clear();
mFiles.clear();
mFilteredFiles.clear();
postMods();
endResetModel();
}
void RsGxsChannelPostFilesModel::preMods()
{
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
beginResetModel();
emit layoutAboutToBeChanged();
}
void RsGxsChannelPostFilesModel::postMods()
{
endResetModel();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
emit QAbstractItemModel::dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
emit layoutChanged();
}
void RsGxsChannelPostFilesModel::update()
{
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mFilteredFiles.size(),COLUMN_FILES_NB_COLUMNS-1,(void*)NULL));
preMods();
postMods();
}
int RsGxsChannelPostFilesModel::rowCount(const QModelIndex& parent) const
{
if(parent.column() > 0)
return 0;
if(parent.column() > 0)
return 0;
if(mFilteredFiles.empty()) // security. Should never happen.
return 0;
if(mFilteredFiles.empty()) // security. Should never happen.
return 0;
if(!parent.isValid())
if(!parent.isValid())
return mFilteredFiles.size(); // mFilteredPosts always has an item at 0, so size()>=1, and mColumn>=1
RsErr() << __PRETTY_FUNCTION__ << " rowCount cannot figure out the porper number of rows." << std::endl;
return 0;
RS_ERR(" rowCount cannot figure out the proper number of rows.");
return 0;
}
int RsGxsChannelPostFilesModel::columnCount(const QModelIndex &/*parent*/) const
@ -99,15 +99,15 @@ int RsGxsChannelPostFilesModel::columnCount(const QModelIndex &/*parent*/) const
bool RsGxsChannelPostFilesModel::getFileData(const QModelIndex& i,ChannelPostFileInfo& fmpe) const
{
if(!i.isValid())
return true;
return true;
quintptr ref = i.internalId();
quintptr ref = i.internalId();
uint32_t entry = 0;
if(!convertRefPointerToTabEntry(ref,entry) || entry >= mFiles.size())
return false ;
fmpe = mFiles[mFilteredFiles[entry]];
fmpe = mFiles[mFilteredFiles[entry]];
return true;
@ -115,8 +115,8 @@ bool RsGxsChannelPostFilesModel::getFileData(const QModelIndex& i,ChannelPostFil
bool RsGxsChannelPostFilesModel::hasChildren(const QModelIndex &parent) const
{
if(!parent.isValid())
return true;
if(!parent.isValid())
return true;
return false; // by default, no channel post has children
}
@ -167,22 +167,19 @@ QModelIndex RsGxsChannelPostFilesModel::index(int row, int column, const QModelI
return createIndex(row,column,ref) ;
}
QModelIndex RsGxsChannelPostFilesModel::parent(const QModelIndex& index) const
QModelIndex RsGxsChannelPostFilesModel::parent(const QModelIndex& /*index*/) const
{
if(!index.isValid())
return QModelIndex();
return QModelIndex(); // there's no hierarchy here. So nothing to do!
}
Qt::ItemFlags RsGxsChannelPostFilesModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
if (!index.isValid())
return Qt::ItemFlag();
if(index.column() == COLUMN_FILES_FILE)
if(index.column() == COLUMN_FILES_FILE)
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
else
else
return QAbstractItemModel::flags(index);
}
@ -191,7 +188,7 @@ quintptr RsGxsChannelPostFilesModel::getChildRef(quintptr ref,int index) const
if (index < 0)
return 0;
if(ref == quintptr(0))
if(ref == quintptr(0))
{
quintptr new_ref;
convertTabEntryToRefPointer(index,new_ref);
@ -221,15 +218,13 @@ quintptr RsGxsChannelPostFilesModel::getParentRow(quintptr ref,int& row) const
int RsGxsChannelPostFilesModel::getChildrenCount(quintptr ref) const
{
uint32_t entry = 0 ;
if(ref == quintptr(0))
return rowCount()-1;
if(ref == quintptr(0))
return rowCount()-1;
return 0;
}
QVariant RsGxsChannelPostFilesModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant RsGxsChannelPostFilesModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
{
if (role != Qt::DisplayRole)
return QVariant();
@ -298,39 +293,37 @@ QVariant RsGxsChannelPostFilesModel::data(const QModelIndex &index, int role) co
void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t& count)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
initEmptyHierarchy();
if(strings.empty())
{
mFilteredFiles.clear();
for(uint32_t i=0;i<mFiles.size();++i)
mFilteredFiles.push_back(i);
}
{
for(uint32_t i=0;i<mFiles.size();++i)
mFilteredFiles.push_back(i);
}
else
{
mFilteredFiles.clear();
//mFilteredPosts.push_back(0);
for(uint32_t i=0;i<mFiles.size();++i)
{
bool passes_strings = true;
{
for(uint32_t i=0;i<mFiles.size();++i)
{
bool passes_strings = true;
for(auto& s:strings)
passes_strings = passes_strings && QString::fromStdString(mFiles[i].mName).contains(s,Qt::CaseInsensitive);
if(passes_strings)
mFilteredFiles.push_back(i);
}
}
count = mFilteredFiles.size();
if(passes_strings)
mFilteredFiles.push_back(i);
}
}
count = mFilteredFiles.size();
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
}
@ -372,7 +365,7 @@ void RsGxsChannelPostFilesModel::sort(int column, Qt::SortOrder order)
update();
}
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int col) const
QVariant RsGxsChannelPostFilesModel::sizeHintRole(int /*col*/) const
{
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
@ -435,42 +428,40 @@ QVariant RsGxsChannelPostFilesModel::userRole(const ChannelPostFileInfo& fmpe,in
void RsGxsChannelPostFilesModel::clear()
{
preMods();
initEmptyHierarchy();
initEmptyHierarchy();
postMods();
emit channelLoaded();
}
void RsGxsChannelPostFilesModel::setFiles(const std::list<ChannelPostFileInfo> &files)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,mFilteredFiles.size()-1);
endRemoveRows();
initEmptyHierarchy();
initEmptyHierarchy();
for(auto& file:files)
mFiles.push_back(file);
for(auto& file:files)
mFiles.push_back(file);
for(uint32_t i=0;i<mFiles.size();++i)
mFilteredFiles.push_back(i);
for(uint32_t i=0;i<mFiles.size();++i)
mFilteredFiles.push_back(i);
#ifdef DEBUG_CHANNEL_MODEL
// debug_dump();
// debug_dump();
#endif
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
endInsertRows();
postMods();
if (mFilteredFiles.size()>0)
{
beginInsertRows(QModelIndex(),0,mFilteredFiles.size()-1);
endInsertRows();
}
emit channelLoaded();
if(!files.empty())
mTimer->start(5000);
else
mTimer->stop();
if(!files.empty())
mTimer->start(5000);
else
mTimer->stop();
postMods();
}

View File

@ -203,23 +203,22 @@ void RsGxsChannelPostsModel::handleEvent_main_thread(std::shared_ptr<const RsEve
void RsGxsChannelPostsModel::initEmptyHierarchy()
{
preMods();
beginResetModel();
mPosts.clear();
mFilteredPosts.clear();
mPosts.clear();
mFilteredPosts.clear();
postMods();
endResetModel();
}
void RsGxsChannelPostsModel::preMods()
{
beginResetModel();
emit layoutAboutToBeChanged();
}
void RsGxsChannelPostsModel::postMods()
{
endResetModel();
triggerViewUpdate();
triggerViewUpdate();
emit layoutChanged();
}
void RsGxsChannelPostsModel::triggerViewUpdate()
{
@ -244,13 +243,13 @@ void RsGxsChannelPostsModel::getFilesList(std::list<ChannelPostFileInfo>& files)
void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unread, uint32_t& count)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
beginResetModel();
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
mFilteredPosts.clear();
//mFilteredPosts.push_back(0);
endResetModel();
for(size_t i=0;i<mPosts.size();++i)
{
@ -268,8 +267,11 @@ void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unre
count = mFilteredPosts.size();
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
}
@ -321,8 +323,8 @@ bool RsGxsChannelPostsModel::getPostData(const QModelIndex& i,RsGxsChannelPost&
bool RsGxsChannelPostsModel::hasChildren(const QModelIndex &parent) const
{
if(!parent.isValid())
return true;
if(!parent.isValid())
return true;
return false; // by default, no channel post has children
}
@ -374,45 +376,45 @@ QModelIndex RsGxsChannelPostsModel::index(int row, int column, const QModelIndex
return createIndex(row,column,ref) ;
}
QModelIndex RsGxsChannelPostsModel::parent(const QModelIndex& index) const
QModelIndex RsGxsChannelPostsModel::parent(const QModelIndex& /*index*/) const
{
if(!index.isValid())
return QModelIndex();
return QModelIndex(); // there's no hierarchy here. So nothing to do!
}
Qt::ItemFlags RsGxsChannelPostsModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
return Qt::ItemFlags();
return QAbstractItemModel::flags(index);
}
bool RsGxsChannelPostsModel::setNumColumns(int n)
{
if(n < 1)
{
RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl;
return false;
}
if((int)mColumns == n)
return false;
if(n < 1)
{
RsErr() << __PRETTY_FUNCTION__ << " Attempt to set a number of column of 0. This is wrong." << std::endl;
return false;
}
if((int)mColumns == n)
return false;
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
beginResetModel();
endResetModel();
mColumns = n;
mColumns = n;
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
return true;
return true;
}
quintptr RsGxsChannelPostsModel::getChildRef(quintptr ref,int index) const
@ -450,8 +452,8 @@ quintptr RsGxsChannelPostsModel::getParentRow(quintptr ref,int& row) const
int RsGxsChannelPostsModel::getChildrenCount(quintptr ref) const
{
if(ref == quintptr(0))
return rowCount()-1;
if(ref == quintptr(0))
return rowCount()-1;
return 0;
}
@ -549,10 +551,9 @@ void RsGxsChannelPostsModel::updateChannel(const RsGxsGroupId& channel_group_id)
void RsGxsChannelPostsModel::clear()
{
preMods();
preMods();
mPosts.clear();
initEmptyHierarchy();
initEmptyHierarchy();
postMods();
emit channelPostsLoaded();
@ -565,28 +566,27 @@ bool operator<(const RsGxsChannelPost& p1,const RsGxsChannelPost& p2)
void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vector<RsGxsChannelPost>& posts)
{
preMods();
preMods();
beginRemoveRows(QModelIndex(),0,rowCount()-1);
endRemoveRows();
initEmptyHierarchy();
mChannelGroup = group;
mPosts.clear();
mChannelGroup = group;
createPostsArray(posts);
createPostsArray(posts);
std::sort(mPosts.begin(),mPosts.end());
std::sort(mPosts.begin(),mPosts.end());
mFilteredPosts.clear();
for(uint32_t i=0;i<mPosts.size();++i)
mFilteredPosts.push_back(i);
for(uint32_t i=0;i<mPosts.size();++i)
mFilteredPosts.push_back(i);
#ifdef DEBUG_CHANNEL_MODEL
// debug_dump();
// debug_dump();
#endif
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
if (rowCount()>0)
{
beginInsertRows(QModelIndex(),0,rowCount()-1);
endInsertRows();
}
postMods();
@ -595,8 +595,8 @@ void RsGxsChannelPostsModel::setPosts(const RsGxsChannelGroup& group, std::vecto
void RsGxsChannelPostsModel::update_posts(const RsGxsGroupId& group_id)
{
if(group_id.isNull())
return;
if(group_id.isNull())
return;
RsThread::async([this, group_id]()
{

View File

@ -238,7 +238,7 @@ void ChannelPostDelegate::paint(QPainter * painter, const QStyleOptionViewItem &
info_text += ", " + QString::number(post.mAttachmentCount)+ " " +((post.mAttachmentCount>1)?tr("files"):tr("file")) + " (" + misc::friendlyUnit(qulonglong(post.mSize)) + ")" ;
painter->drawText(QPoint(p.x()+0.5*font_height,y),info_text);
y += font_height;
//y += font_height;
painter->restore();
}
@ -400,21 +400,21 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
ui->channelPostFiles_TV->setItemDelegate(new ChannelPostFilesDelegate(this));
ui->channelPostFiles_TV->setPlaceholderText(tr("No files in this post, or no post selected"));
ui->channelPostFiles_TV->setSortingEnabled(true);
ui->channelPostFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time
ui->channelPostFiles_TV->sortByColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_DATE, Qt::DescendingOrder); // sort by time
ui->channelPostFiles_TV->setAlternatingRowColors(false);
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate(this));
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
ui->channelFiles_TV->setSortingEnabled(true);
ui->channelFiles_TV->sortByColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_DATE, Qt::DescendingOrder); // sort by time
connect(ui->channelPostFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnPostFiles(int,Qt::SortOrder)));
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
connect(ui->channelPostFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
connect(ui->channelFiles_TV,SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showChannelFilesContextMenu(QPoint)));
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
ui->channelFiles_TV->setItemDelegate(mFilesDelegate = new ChannelPostFilesDelegate(this));
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
ui->channelFiles_TV->setSortingEnabled(true);
ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder); // sort by time
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
@ -666,7 +666,7 @@ void GxsChannelPostsWidgetWithModel::download()
std::string destination;
rsGxsChannels->getChannelDownloadDirectory(mGroup.mMeta.mGroupId,destination);
for(auto file:post.mFiles)
for(auto& file:post.mFiles)
{
std::list<RsPeerId> sources;
@ -939,8 +939,9 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
mChannelPostsModel->getFilesList(files);
mChannelFilesModel->setFiles(files);
ui->channelFiles_TV->setAutoSelect(true);
ui->channelFiles_TV->sortByColumn(3, Qt::AscendingOrder);
ui->channelFiles_TV->setAutoSelect(true);
ui->channelFiles_TV->sortByColumn(ui->channelFiles_TV->header()->sortIndicatorSection()
,ui->channelFiles_TV->header()->sortIndicatorOrder());
ui->infoPosts->setText(QString::number(mChannelPostsModel->getNumberOfPosts()) + " / " + QString::number(mGroup.mMeta.mVisibleMsgCount));
@ -1206,11 +1207,11 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
QString distrib_string ( "[unknown]" );
switch(group.mMeta.mCircleType)
switch((RsGxsCircleType)group.mMeta.mCircleType)
{
case GXS_CIRCLE_TYPE_PUBLIC: distrib_string = tr("Public") ;
case RsGxsCircleType::PUBLIC: distrib_string = tr("Public") ;
break ;
case GXS_CIRCLE_TYPE_EXTERNAL:
case RsGxsCircleType::EXTERNAL:
{
RsGxsCircleDetails det ;
@ -1222,9 +1223,9 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
distrib_string = tr("Restricted to members of circle ")+QString::fromStdString(group.mMeta.mCircleId.toStdString()) ;
}
break ;
case GXS_CIRCLE_TYPE_YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
case RsGxsCircleType::YOUR_EYES_ONLY: distrib_string = tr("Your eyes only");
break ;
case GXS_CIRCLE_TYPE_LOCAL: distrib_string = tr("You and your friend nodes");
case RsGxsCircleType::LOCAL: distrib_string = tr("You and your friend nodes");
break ;
default:
std::cerr << "(EE) badly initialised group distribution ID = " << group.mMeta.mCircleType << std::endl;
@ -1245,7 +1246,7 @@ void GxsChannelPostsWidgetWithModel::insertChannelDetails(const RsGxsChannelGrou
showPostDetails();
}
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint p)
void GxsChannelPostsWidgetWithModel::showChannelFilesContextMenu(QPoint /*p*/)
{
QMenu contextMnu(this) ;
@ -1316,7 +1317,7 @@ void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool)
}
void GxsChannelPostsWidgetWithModel::filterChanged(QString s)
{
QStringList ql = s.split(' ',QString::SkipEmptyParts);
QStringList ql = s.split(' ',Qt::SkipEmptyParts);
uint32_t count;
mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count);
mChannelFilesModel->setFilter(ql,count);
@ -1419,7 +1420,7 @@ void GxsChannelPostsWidgetWithModel::toggleAutoDownload()
class GxsChannelPostsReadData
{
public:
GxsChannelPostsReadData(bool read)
explicit GxsChannelPostsReadData(bool read)
{
mRead = read;
mLastToken = 0;

View File

@ -50,42 +50,32 @@ RsGxsForumModel::RsGxsForumModel(QObject *parent)
void RsGxsForumModel::preMods()
{
//emit layoutAboutToBeChanged(); //Generate SIGSEGV when click on button move next/prev.
beginResetModel();
emit layoutAboutToBeChanged();
}
void RsGxsForumModel::postMods()
{
endResetModel();
if(mTreeMode == TREE_MODE_FLAT)
if(mTreeMode == TREE_MODE_FLAT)
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
else
else
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mPosts[0].mChildren.size(),COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
emit layoutChanged();
}
void RsGxsForumModel::setTreeMode(TreeMode mode)
{
if(mode == mTreeMode)
return;
if(mode == mTreeMode)
return;
preMods();
preMods();
if(mode == TREE_MODE_TREE) // means we were in FLAT mode, so the last rows are removed.
{
beginRemoveRows(QModelIndex(),mPosts[0].mChildren.size(),mPosts.size()-1);
endRemoveRows();
}
beginResetModel();
mTreeMode = mode;
if(mode == TREE_MODE_FLAT) // means we were in tree mode, so the last rows are added.
{
beginInsertRows(QModelIndex(),mPosts[0].mChildren.size(),mPosts.size()-1);
endInsertRows();
}
endResetModel();
postMods();
postMods();
}
void RsGxsForumModel::setSortMode(SortMode mode)
@ -241,7 +231,7 @@ QModelIndex RsGxsForumModel::parent(const QModelIndex& index) const
Qt::ItemFlags RsGxsForumModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
return Qt::ItemFlags();
return QAbstractItemModel::flags(index);
}
@ -466,8 +456,8 @@ QVariant RsGxsForumModel::statusRole(const ForumModelPostEntry& fmpe,int column)
QVariant RsGxsForumModel::filterRole(const ForumModelPostEntry& fmpe,int /*column*/) const
{
if(!mFilteringEnabled || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_CHILDREN_PASSES_FILTER))
return QVariant(FilterString);
if(!mFilteringEnabled || (fmpe.mPostFlags & ForumModelPostEntry::FLAG_POST_CHILDREN_PASSES_FILTER))
return QVariant(FilterString);
return QVariant(QString());
}
@ -755,65 +745,68 @@ void RsGxsForumModel::clear()
void RsGxsForumModel::setPosts(const RsGxsForumGroup& group, const std::vector<ForumModelPostEntry>& posts,const std::map<RsGxsMessageId,std::vector<std::pair<time_t,RsGxsMessageId> > >& post_versions)
{
preMods();
preMods();
if(mTreeMode == TREE_MODE_FLAT)
beginRemoveRows(QModelIndex(),0,mPosts.size()-1);
else
beginRemoveRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
beginResetModel();
endResetModel();
endRemoveRows();
mForumGroup = group;
mPosts = posts;
mPostVersions = post_versions;
mForumGroup = group;
mPosts = posts;
mPostVersions = post_versions;
// now update prow for all posts
// now update prow for all posts
for(uint32_t i=0;i<mPosts.size();++i)
for(uint32_t j=0;j<mPosts[i].mChildren.size();++j)
mPosts[mPosts[i].mChildren[j]].prow = j;
for(uint32_t i=0;i<mPosts.size();++i)
for(uint32_t j=0;j<mPosts[i].mChildren.size();++j)
mPosts[mPosts[i].mChildren[j]].prow = j;
mPosts[0].prow = 0;
mPosts[0].prow = 0;
bool has_unread_below,has_read_below ;
bool has_unread_below,has_read_below ;
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below) ;
recursUpdateFilterStatus(0,0,QStringList());
recursUpdateReadStatusAndTimes(0,has_unread_below,has_read_below) ;
recursUpdateFilterStatus(0,0,QStringList());
#ifdef DEBUG_FORUMMODEL
debug_dump();
debug_dump();
#endif
if(mTreeMode == TREE_MODE_FLAT)
beginInsertRows(QModelIndex(),0,mPosts.size()-1);
else
beginInsertRows(QModelIndex(),0,mPosts[0].mChildren.size()-1);
endInsertRows();
int count = 0;
if(mTreeMode == TREE_MODE_FLAT)
count = mPosts.size();
else
count = mPosts[0].mChildren.size();
if(count>0)
{
beginInsertRows(QModelIndex(),0,count-1);
endInsertRows();
}
postMods();
emit forumLoaded();
}
void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
{
if(group_id.isNull())
return;
if(group_id.isNull())
return;
RsThread::async([this, group_id]()
{
// 1 - get message data from p3GxsForums
// 1 - get message data from p3GxsForums
std::list<RsGxsGroupId> forumIds;
std::list<RsGxsGroupId> forumIds;
std::vector<RsMsgMetaData> msg_metas;
std::vector<RsGxsForumGroup> groups;
forumIds.push_back(group_id);
forumIds.push_back(group_id);
if(!rsGxsForums->getForumsInfo(forumIds,groups) || groups.size() != 1)
{
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << group_id << std::endl;
return;
}
}
if(!rsGxsForums->getForumMsgMetaData(group_id,msg_metas))
{
@ -821,17 +814,17 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
return;
}
// 2 - sort the messages into a proper hierarchy
// 2 - sort the messages into a proper hierarchy
auto post_versions = new std::map<RsGxsMessageId,std::vector<std::pair<time_t, RsGxsMessageId> > >() ;
std::vector<ForumModelPostEntry> *vect = new std::vector<ForumModelPostEntry>();
RsGxsForumGroup group = groups[0];
auto post_versions = new std::map<RsGxsMessageId,std::vector<std::pair<time_t, RsGxsMessageId> > >() ;
std::vector<ForumModelPostEntry> *vect = new std::vector<ForumModelPostEntry>();
RsGxsForumGroup group = groups[0];
computeMessagesHierarchy(group,msg_metas,*vect,*post_versions);
computeMessagesHierarchy(group,msg_metas,*vect,*post_versions);
// 3 - update the model in the UI thread.
// 3 - update the model in the UI thread.
RsQThreadUtils::postToObject( [group,vect,post_versions,this]()
RsQThreadUtils::postToObject( [group,vect,post_versions,this]()
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread, for example to update the data model with new information
@ -839,15 +832,15 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
* Qt::QueuedConnection is important!
*/
setPosts(group,*vect,*post_versions) ;
setPosts(group,*vect,*post_versions) ;
delete vect;
delete post_versions;
delete vect;
delete post_versions;
}, this );
});
});
}
ForumModelIndex RsGxsForumModel::addEntry(std::vector<ForumModelPostEntry>& posts,const ForumModelPostEntry& entry,ForumModelIndex parent)
@ -895,26 +888,25 @@ void RsGxsForumModel::convertMsgToPostEntry(const RsGxsForumGroup& mForumGroup,c
void RsGxsForumModel::computeReputationLevel(uint32_t forum_sign_flags,ForumModelPostEntry& fentry)
{
uint32_t idflags =0;
uint32_t idflags =0;
RsReputationLevel reputation_level =
rsReputations->overallReputationLevel(fentry.mAuthorId, &idflags);
bool redacted = false;
if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
else
fentry.mPostFlags &= ~ForumModelPostEntry::FLAG_POST_IS_REDACTED;
fentry.mPostFlags |= ForumModelPostEntry::FLAG_POST_IS_REDACTED;
else
fentry.mPostFlags &= ~ForumModelPostEntry::FLAG_POST_IS_REDACTED;
// We use a specific item model for forums in order to handle the post pinning.
// We use a specific item model for forums in order to handle the post pinning.
if(reputation_level == RsReputationLevel::UNKNOWN)
fentry.mReputationWarningLevel = 3 ;
fentry.mReputationWarningLevel = 3 ;
else if(reputation_level == RsReputationLevel::LOCALLY_NEGATIVE)
fentry.mReputationWarningLevel = 2 ;
else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(forum_sign_flags,idflags))
fentry.mReputationWarningLevel = 1 ;
else
fentry.mReputationWarningLevel = 0 ;
fentry.mReputationWarningLevel = 2 ;
else if(reputation_level < rsGxsForums->minReputationForForwardingMessages(forum_sign_flags,idflags))
fentry.mReputationWarningLevel = 1 ;
else
fentry.mReputationWarningLevel = 0 ;
}
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }

View File

@ -1,7 +1,7 @@
<!--/****************************************************************
* This file is distributed under the following license:
*
* Copyright (c) 2008, defnax
* This file is distributed under the following license:
*
* Copyright (c) 2008, defnax
* Copyright (c) 2008, edmanm
*
* This program is free software; you can redistribute it and/or
@ -33,48 +33,48 @@
<td>&nbsp;&nbsp;&nbsp;</td>
<td>Homepage</td>
<td>
<a href="http://retroshare.sourceforge.net">
http://retroshare.sourceforge.net</a>
<a href="https://retroshare.cc/">
https://retroshare.cc/</a>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;</td>
<td>RetroShare Forum</td>
<td>Blog</td>
<td>
<a href="http://retroshare.sourceforge.net/forum">
http://retroshare.sourceforge.net/forum</a>
<a href="https://retroshareteam.wordpress.com/">
https://retroshareteam.wordpress.com/</a>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;</td>
<td>RetroShare Wiki</td>
<td>
<a href="http://retroshare.sourceforge.net/wiki">
http://retroshare.sourceforge.net/wiki</a>
<a href="https://retroshare.readthedocs.io/en/latest/">
https://retroshare.readthedocs.io/en/latest/</a>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;</td>
<td>Project Page</td>
<td>
<a href="http://sourceforge.net/projects/retroshare">
http://sourceforge.net/projects/retroshare</a>
<a href="https://github.com/RetroShare/RetroShare">
https://github.com/RetroShare/RetroShare</a>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;</td>
<td>Bugtracker</td>
<td>
<a href="http://sourceforge.net/tracker/?group_id=178712&atid=886239">
http://sourceforge.net/tracker/?group_id=178712&atid=886239</a>
<a href="https://github.com/RetroShare/RetroShare/issues">
https://github.com/RetroShare/RetroShare/issues</a>
</td>
</tr>
<tr>
<td>&nbsp;&nbsp;&nbsp;</td>
<td>Translation</td>
<td>
<a href="http://retroshare.sourceforge.net/wiki/index.php/Translation">
http://retroshare.sourceforge.net/wiki/index.php/Translation</a>
<a href="https://www.transifex.com/beluga/retroshare/">
https://www.transifex.com/beluga/retroshare/</a>
</td>
</tr>
</table>

View File

@ -53,6 +53,7 @@
<file>icons/gmail.png</file>
<file>icons/help_128.png</file>
<file>icons/help_64.png</file>
<file>icons/identities.png</file>
<file>icons/information_128.png</file>
<file>icons/internet_128.png</file>
<file>icons/invite64.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -22,6 +22,7 @@
#include <QMessageBox>
#include <QCloseEvent>
#include <QClipboard>
#include <QLabel>
#include <QTextCodec>
#include <QPrintDialog>
#include <QPrinter>
@ -94,6 +95,8 @@
#define STYLE_NORMAL "QLineEdit#%1 { border : none; }"
#define STYLE_FAIL "QLineEdit#%1 { border : none; color : red; }"
static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000;
class MessageItemDelegate : public QItemDelegate
{
public:
@ -213,6 +216,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
connect(ui.friendSelectionWidget, SIGNAL(doubleClicked(int,QString)), this, SLOT(addTo()));
connect(ui.friendSelectionWidget, SIGNAL(itemSelectionChanged()), this, SLOT(friendSelectionChanged()));
connect(ui.msgText, SIGNAL(textChanged()), this, SLOT(checkLength()));
/* hide the Tree +/- */
ui.msgFileList -> setRootIsDecorated( false );
@ -352,6 +357,15 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
/* set focus to subject */
ui.titleEdit->setFocus();
infoLabel = new QLabel( "", this );
statusBar()->addPermanentWidget(infoLabel);
lineLabel = new QLabel( "", this );
statusBar()->addPermanentWidget(lineLabel);
lengthLabel = new QLabel( "", this );
statusBar()->addPermanentWidget(lengthLabel);
// create tag menu
TagsMenu *menu = new TagsMenu (tr("Tags"), this);
connect(menu, SIGNAL(aboutToShow()), this, SLOT(tagAboutToShow()));
@ -379,7 +393,7 @@ void MessageComposer::updateCells(int,int)
{
int rowCount = ui.recipientWidget->rowCount();
int row;
bool has_gxs = false ;
has_gxs = false ;
for (row = 0; row < rowCount; ++row)
{
@ -396,6 +410,7 @@ void MessageComposer::updateCells(int,int)
ui.respond_to_CB->show();
ui.distantFrame->show();
ui.fromLabel->show();
checkLength();
}
else
{
@ -2853,3 +2868,30 @@ void MessageComposer::sendInvite(const RsGxsId &to, bool autoSend)
/* window will destroy itself! */
}
void MessageComposer::checkLength()
{
QString text;
RsHtml::optimizeHtml(ui.msgText, text);
std::wstring msg = text.toStdWString();
int charlength = msg.length();
int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length();
text = tr("Message Size: %1").arg(misc::friendlyUnit(charlength));
lengthLabel->setText(text);
lineLabel->setText("|");
if(has_gxs) {
if(charRemains >= 0) {
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
}else{
text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains));
}
ui.actionSend->setEnabled(charRemains>=0);
infoLabel->setText(text);
}
else {
infoLabel->setText("");
ui.actionSend->setEnabled(true);
}
}

View File

@ -168,6 +168,8 @@ private slots:
static QString inviteMessage();
void checkLength();
private:
static QString buildReplyHeader(const MessageInfo &msgInfo);
@ -257,6 +259,12 @@ private:
RSTreeWidgetItemCompareRole *m_compareRole;
QCompleter *m_completer;
QLabel *infoLabel;
QLabel *lengthLabel;
QLabel *lineLabel;
bool has_gxs;
/** Qt Designer generated object */
Ui::MessageComposer ui;

View File

@ -61,31 +61,32 @@ RsMessageModel::RsMessageModel(QObject *parent)
void RsMessageModel::preMods()
{
emit layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
}
void RsMessageModel::postMods()
{
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(mMessages.size()-1,COLUMN_THREAD_NB_COLUMNS-1,(void*)NULL));
emit layoutChanged();
}
int RsMessageModel::rowCount(const QModelIndex& parent) const
{
if(!parent.isValid())
return 0;
return 0;
if(parent.column() > 0)
return 0;
if(parent.column() > 0)
return 0;
if(mMessages.empty()) // security. Should never happen.
return 0;
if(mMessages.empty()) // security. Should never happen.
return 0;
if(parent.internalPointer() == NULL)
return mMessages.size();
return 0;
return 0;
}
int RsMessageModel::columnCount(const QModelIndex &parent) const
int RsMessageModel::columnCount(const QModelIndex &/*parent*/) const
{
return COLUMN_THREAD_NB_COLUMNS ;
}
@ -145,8 +146,8 @@ QModelIndex RsMessageModel::index(int row, int column, const QModelIndex & paren
QModelIndex RsMessageModel::parent(const QModelIndex& index) const
{
if(!index.isValid())
return QModelIndex();
if(!index.isValid())
return QModelIndex();
return QModelIndex();
}
@ -154,12 +155,12 @@ QModelIndex RsMessageModel::parent(const QModelIndex& index) const
Qt::ItemFlags RsMessageModel::flags(const QModelIndex& index) const
{
if (!index.isValid())
return 0;
return Qt::ItemFlags();
return QAbstractItemModel::flags(index);
}
QVariant RsMessageModel::headerData(int section, Qt::Orientation orientation, int role) const
QVariant RsMessageModel::headerData(int section, Qt::Orientation /*orientation*/, int role) const
{
if(role == Qt::DisplayRole)
switch(section)
@ -274,20 +275,20 @@ QVariant RsMessageModel::data(const QModelIndex &index, int role) const
}
}
QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
QVariant RsMessageModel::textColorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int /*column*/) const
{
Rs::Msgs::MsgTagType tags;
rsMsgs->getMessageTagTypes(tags);
for(auto it(fmpe.msgtags.begin());it!=fmpe.msgtags.end();++it)
for(auto it2(tags.types.begin());it2!=tags.types.end();++it2)
if(it2->first == *it)
return QColor(it2->second.second);
for(auto it(fmpe.msgtags.begin());it!=fmpe.msgtags.end();++it)
for(auto it2(tags.types.begin());it2!=tags.types.end();++it2)
if(it2->first == *it)
return QColor(it2->second.second);
return QVariant();
}
QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& /*fmpe*/,int /*column*/) const
{
// if(column != COLUMN_THREAD_DATA)
// return QVariant();
@ -295,12 +296,12 @@ QVariant RsMessageModel::statusRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col
return QVariant();//fmpe.mMsgStatus);
}
bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int /*column*/) const
{
QString s ;
bool passes_strings = true ;
QString s ;
bool passes_strings = true ;
if(!mFilterStrings.empty())
if(!mFilterStrings.empty())
{
switch(mFilterType)
{
@ -308,9 +309,9 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
break;
case FILTER_TYPE_FROM: s = sortRole(fmpe,COLUMN_THREAD_AUTHOR).toString();
if(s.isNull())
passes_strings = false;
break;
if(s.isNull())
passes_strings = false;
break;
case FILTER_TYPE_DATE: s = displayRole(fmpe,COLUMN_THREAD_DATE).toString();
break;
case FILTER_TYPE_CONTENT: {
@ -330,6 +331,9 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
for(auto it(minfo.files.begin());it!=minfo.files.end();++it)
s += QString::fromUtf8((*it).fname.c_str())+" ";
}
break;
case FILTER_TYPE_NONE:
RS_ERR("None Type for Filter.");
};
}
@ -355,18 +359,15 @@ bool RsMessageModel::passesFilter(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
QVariant RsMessageModel::filterRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
{
if(passesFilter(fmpe,column))
return QVariant(FilterString);
if(passesFilter(fmpe,column))
return QVariant(FilterString);
return QVariant(QString());
}
uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex i,int column,const QStringList& strings)
uint32_t RsMessageModel::updateFilterStatus(ForumModelIndex /*i*/,int /*column*/,const QStringList& /*strings*/)
{
QString s ;
uint32_t count = 0;
return count;
return 0;
}
@ -408,7 +409,7 @@ QVariant RsMessageModel::toolTipRole(const Rs::Msgs::MsgInfoSummary& fmpe,int co
return QVariant();
}
QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &fmpe, int column) const
QVariant RsMessageModel::backgroundRole(const Rs::Msgs::MsgInfoSummary &/*fmpe*/, int /*column*/) const
{
return QVariant();
}
@ -426,7 +427,7 @@ QVariant RsMessageModel::sizeHintRole(int col) const
}
}
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& fmpe,int column) const
QVariant RsMessageModel::authorRole(const Rs::Msgs::MsgInfoSummary& /*fmpe*/,int /*column*/) const
{
return QVariant();
}
@ -443,15 +444,16 @@ QVariant RsMessageModel::sortRole(const Rs::Msgs::MsgInfoSummary& fmpe,int colum
case COLUMN_THREAD_SPAM: return QVariant((fmpe.msgflags & RS_MSG_SPAM)? 1:0);
case COLUMN_THREAD_AUTHOR:{
QString name;
case COLUMN_THREAD_AUTHOR:{
QString name;
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
return name;
}
default:
return displayRole(fmpe,column);
}
if(GxsIdTreeItemDelegate::computeName(RsGxsId(fmpe.srcId.toStdString()),name))
return name;
return ""; //Not Found
}
default:
return displayRole(fmpe,column);
}
}
QVariant RsMessageModel::displayRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col) const
@ -572,9 +574,12 @@ QVariant RsMessageModel::decorationRole(const Rs::Msgs::MsgInfoSummary& fmpe,int
void RsMessageModel::clear()
{
preMods();
preMods();
mMessages.clear();
beginResetModel();
mMessages.clear();
mMessagesMap.clear();
endResetModel();
postMods();
@ -583,29 +588,26 @@ void RsMessageModel::clear()
void RsMessageModel::setMessages(const std::list<Rs::Msgs::MsgInfoSummary>& msgs)
{
preMods();
beginRemoveRows(QModelIndex(),0,mMessages.size()-1);
endRemoveRows();
clear();
mMessages.clear();
mMessagesMap.clear();
for(auto it(msgs.begin());it!=msgs.end();++it)
{
mMessagesMap[(*it).msgId] = mMessages.size();
mMessages.push_back(*it);
}
for(auto it(msgs.begin());it!=msgs.end();++it)
{
mMessagesMap[(*it).msgId] = mMessages.size();
mMessages.push_back(*it);
}
// now update prow for all posts
// now update prow for all posts
#ifdef DEBUG_MESSAGE_MODEL
debug_dump();
debug_dump();
#endif
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
endInsertRows();
postMods();
if (mMessages.size()>0)
{
beginInsertRows(QModelIndex(),0,mMessages.size()-1);
endInsertRows();
}
emit messagesLoaded();
}
@ -672,8 +674,6 @@ void RsMessageModel::updateMessages()
emit messagesLoaded();
}
static bool decreasing_time_comp(const std::pair<time_t,RsGxsMessageId>& e1,const std::pair<time_t,RsGxsMessageId>& e2) { return e2.first < e1.first ; }
void RsMessageModel::setMsgReadStatus(const QModelIndex& i,bool read_status)
{
if(!i.isValid())
@ -704,12 +704,12 @@ void RsMessageModel::setMsgJunk(const QModelIndex& i,bool junk)
QModelIndex RsMessageModel::getIndexOfMessage(const std::string& mid) const
{
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
// Brutal search. This is not so nice, so dont call that in a loop! If too costly, we'll use a map.
auto it = mMessagesMap.find(mid);
auto it = mMessagesMap.find(mid);
if(it == mMessagesMap.end() || it->second >= mMessages.size())
return QModelIndex();
if(it == mMessagesMap.end() || it->second >= mMessages.size())
return QModelIndex();
quintptr ref ;
convertMsgIndexToInternalId(it->second,ref);

View File

@ -509,6 +509,7 @@ void MessageWidget::fill(const std::string &msgId)
ui.msgText->resetImagesStatus(false);
clearTagLabels();
checkLength();
ui.inviteFrame->hide();
ui.expandFilesButton->setChecked(false);
@ -690,6 +691,7 @@ void MessageWidget::fill(const std::string &msgId)
ui.filesSize->setText(QString(misc::friendlyUnit(msgInfo.size)));
showTagLabels();
checkLength();
currMsgFlags = msgInfo.msgflags;
}
@ -903,3 +905,15 @@ void MessageWidget::viewSource()
delete dialog;
}
void MessageWidget::checkLength()
{
QString text;
RsHtml::optimizeHtml(ui.msgText, text);
std::wstring msg = text.toStdWString();
int charlength = msg.length();
text = tr("%1 (%2) ").arg(charlength).arg(misc::friendlyUnit(charlength));
ui.sizeLabel->setText(text);
}

View File

@ -86,6 +86,7 @@ private slots:
void loadImagesAlways();
void buttonStyle();
void viewSource();
void checkLength();
private:
void clearTagLabels();

View File

@ -621,7 +621,7 @@
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
<number>3</number>
</property>
<property name="bottomMargin">
<number>0</number>
@ -682,6 +682,27 @@
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Message Size:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="sizeLabel">
<property name="text">
<string>Size</string>
</property>
</widget>
</item>
<item>
<spacer name="filesHSpacer">
<property name="orientation">

View File

@ -18,7 +18,7 @@
</property>
<widget class="QWidget" name="tabFeed">
<attribute name="title">
<string>Log</string>
<string>Activity</string>
</attribute>
<layout class="QVBoxLayout" name="tabFeedVLayout">
<item>

View File

@ -602,6 +602,6 @@ BWGraph::BWGraph(QWidget *parent) : RSGraphWidget(parent)
BWGraph::~BWGraph()
{
delete _local_source ;
//delete _local_source ;//Will be deleted by RSGraphWidget destructor
}

View File

@ -34,10 +34,12 @@
#define SETTING_OPACITY "Opacity"
#define SETTING_ALWAYS_ON_TOP "AlwaysOnTop"
#define SETTING_STYLE "GraphStyle"
#define SETTING_GRAPHCOLOR "GraphColor"
#define DEFAULT_FILTER (BWGRAPH_LINE_SEND|BWGRAPH_LINE_RECV)
#define DEFAULT_ALWAYS_ON_TOP false
#define DEFAULT_OPACITY 100
#define DEFAULT_STYLE LineGraph
#define DEFAULT_GRAPHCOLOR DefaultColor
#define ADD_TO_FILTER(f,v,b) (f = ((b) ? ((f) | (v)) : ((f) & ~(v))))
@ -132,6 +134,19 @@ BandwidthGraph::loadSettings()
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
/* Set whether we are plotting bandwidth as area graphs or not */
int graphColor = getSetting(SETTING_GRAPHCOLOR, DEFAULT_GRAPHCOLOR).toInt();
if (graphColor < 0 || graphColor >= ui.cmbGraphColor->count()) {
graphColor = DEFAULT_GRAPHCOLOR;
}
ui.cmbGraphColor->setCurrentIndex(graphColor);
if(graphColor==0)
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
/* Set graph frame settings */
ui.frmGraph->setShowEntry(0,ui.chkReceiveRate->isChecked()) ;
@ -158,6 +173,7 @@ void BandwidthGraph::saveChanges()
/* Save the opacity and graph style */
saveSetting(SETTING_OPACITY, ui.sldrOpacity->value());
saveSetting(SETTING_STYLE, ui.cmbGraphStyle->currentIndex());
saveSetting(SETTING_GRAPHCOLOR, ui.cmbGraphColor->currentIndex());
/* Save the Always On Top setting */
saveSetting(SETTING_ALWAYS_ON_TOP, ui.chkAlwaysOnTop->isChecked());
@ -184,6 +200,11 @@ void BandwidthGraph::saveChanges()
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_PAINT_STYLE_PLAIN);
if(ui.cmbGraphColor->currentIndex()==0)
ui.frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
ui.frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
/* A change in window flags causes the window to disappear, so make sure
* it's still visible. */
showNormal();

View File

@ -40,6 +40,7 @@ class BandwidthGraph : public RWindow
public:
enum { AreaGraph=0,LineGraph=1 } ;
enum { DefaultColor=0,DarkColor=1 } ;
/** Default constructor */
BandwidthGraph(QWidget *parent = 0, Qt::WindowFlags flags = 0);

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>414</width>
<width>418</width>
<height>305</height>
</rect>
</property>
@ -24,7 +24,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -69,13 +78,13 @@
</property>
<property name="minimumSize">
<size>
<width>355</width>
<width>400</width>
<height>82</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>355</width>
<width>400</width>
<height>82</height>
</size>
</property>
@ -88,19 +97,34 @@
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>9</number>
</property>
<item>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item row="0" column="0" rowspan="2">
<layout class="QVBoxLayout" name="_2">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>3</number>
</property>
<property name="topMargin">
<number>3</number>
</property>
<property name="rightMargin">
<number>3</number>
</property>
<property name="bottomMargin">
<number>3</number>
</property>
<item>
@ -166,12 +190,21 @@
</item>
</layout>
</item>
<item>
<item row="0" column="1" rowspan="2">
<layout class="QVBoxLayout" name="_3">
<property name="spacing">
<number>1</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -179,7 +212,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -224,6 +266,20 @@
</item>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbGraphColor">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Dark</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
@ -241,7 +297,16 @@
<property name="spacing">
<number>3</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -299,7 +364,16 @@
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -377,25 +451,21 @@
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<item row="0" column="4" rowspan="2">
<layout class="QVBoxLayout" name="_7">
<property name="spacing">
<number>1</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
@ -414,6 +484,19 @@
</item>
</layout>
</item>
<item row="0" column="3">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>21</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>

View File

@ -24,6 +24,7 @@
#include "retroshare/rspeers.h"
#include "retroshare/rsservicecontrol.h"
#include "retroshare-gui/RsAutoUpdatePage.h"
#include "gui/settings/rsharesettings.h"
#include "BandwidthStatsWidget.h"
BandwidthStatsWidget::BandwidthStatsWidget(QWidget *parent)
@ -31,6 +32,8 @@ BandwidthStatsWidget::BandwidthStatsWidget(QWidget *parent)
{
ui.setupUi(this) ;
m_bProcessSettings = false;
// now add one button per service
ui.friend_CB->addItem(tr("Sum")) ;
@ -49,6 +52,9 @@ BandwidthStatsWidget::BandwidthStatsWidget(QWidget *parent)
ui.bwgraph_BW->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_LEGEND_CUMULATED) ;
updateUnitSelection(0);
toggleLogScale(ui.logScale_CB->checkState() == Qt::Checked);//Update bwgraph_BW with default logScale_CB state defined in ui file.
// Setup connections
@ -58,6 +64,7 @@ BandwidthStatsWidget::BandwidthStatsWidget(QWidget *parent)
QObject::connect(ui.service_CB ,SIGNAL(currentIndexChanged(int )),this, SLOT(updateServiceSelection(int ))) ;
QObject::connect(ui.legend_CB ,SIGNAL(currentIndexChanged(int )),this, SLOT( updateLegendType(int ))) ;
QObject::connect(ui.logScale_CB,SIGNAL( toggled(bool)),this, SLOT( toggleLogScale(bool))) ;
QObject::connect(ui.cmbGraphColor,SIGNAL(currentIndexChanged(int )),this, SLOT( updateGraphSelection(int))) ;
// setup one timer for auto-update
@ -65,6 +72,45 @@ BandwidthStatsWidget::BandwidthStatsWidget(QWidget *parent)
connect(mTimer, SIGNAL(timeout()), this, SLOT(updateComboBoxes())) ;
mTimer->setSingleShot(false) ;
mTimer->start(2000) ;
// load settings
processSettings(true);
int graphColor = ui.cmbGraphColor->currentIndex();
if(graphColor==0)
ui.bwgraph_BW->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
ui.bwgraph_BW->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
}
BandwidthStatsWidget::~BandwidthStatsWidget ()
{
// save settings
processSettings(false);
}
void BandwidthStatsWidget::processSettings(bool bLoad)
{
m_bProcessSettings = true;
Settings->beginGroup(QString("BandwidthStatsWidget"));
if (bLoad) {
// load settings
// state of Graph Color combobox
int index = Settings->value("cmbGraphColor", 0).toInt();
ui.cmbGraphColor->setCurrentIndex(index);
} else {
// save settings
// state of Graph Color combobox
Settings->setValue("cmbGraphColor", ui.cmbGraphColor->currentIndex());
}
Settings->endGroup();
m_bProcessSettings = false;
}
void BandwidthStatsWidget::toggleLogScale(bool b)
@ -74,6 +120,7 @@ void BandwidthStatsWidget::toggleLogScale(bool b)
else
ui.bwgraph_BW->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_LOG_SCALE_Y) ;
}
void BandwidthStatsWidget::updateComboBoxes()
{
if(!isVisible())
@ -233,3 +280,11 @@ void BandwidthStatsWidget::updateUnitSelection(int n)
ui.legend_CB->setItemText(1,tr("Total"));
}
}
void BandwidthStatsWidget::updateGraphSelection(int n)
{
if(n==0)
ui.bwgraph_BW->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
ui.bwgraph_BW->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
}

View File

@ -26,7 +26,10 @@ class BandwidthStatsWidget: public QWidget
Q_OBJECT
public:
/** Default Constructor */
BandwidthStatsWidget(QWidget *parent) ;
/** Default Destructor */
~BandwidthStatsWidget ();
protected slots:
void updateFriendSelection(int n);
@ -36,8 +39,12 @@ protected slots:
void updateUnitSelection(int n);
void toggleLogScale(bool b);
void updateLegendType(int n);
void updateGraphSelection(int n);
private:
void processSettings(bool bLoad);
bool m_bProcessSettings;
Ui::BwStatsWidget ui;
QTimer *mTimer ;

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1148</width>
<width>800</width>
<height>385</height>
</rect>
</property>
@ -140,6 +140,20 @@
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbGraphColor">
<item>
<property name="text">
<string>Default</string>
</property>
</item>
<item>
<property name="text">
<string>Dark</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>760</width>
<height>603</height>
<height>500</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -84,6 +84,9 @@ GlobalRouterStatistics::GlobalRouterStatistics(QWidget *parent)
connect(treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CustomPopupMenu(QPoint)));
/* Set initial size the splitter */
splitter->setStretchFactor(1, 1);
splitter->setStretchFactor(0, 0);
// load settings
processSettings(true);
@ -106,12 +109,12 @@ void GlobalRouterStatistics::processSettings(bool bLoad)
// load settings
// state of splitter
//splitter->restoreState(Settings->value("Splitter").toByteArray());
splitter->restoreState(Settings->value("Splitter").toByteArray());
} else {
// save settings
// state of splitter
//Settings->setValue("Splitter", splitter->saveState());
Settings->setValue("Splitter", splitter->saveState());
}

View File

@ -6,19 +6,96 @@
<rect>
<x>0</x>
<y>0</y>
<width>1468</width>
<height>659</height>
<width>800</width>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
<string>Router Statistics</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Identity Name</string>
</property>
</column>
<column>
<property name="text">
<string>Destinaton</string>
</property>
</column>
<column>
<property name="text">
<string>Data status</string>
</property>
</column>
<column>
<property name="text">
<string>Tunnel status</string>
</property>
</column>
<column>
<property name="text">
<string>Stored data size</string>
</property>
</column>
<column>
<property name="text">
<string>Data hash</string>
</property>
</column>
<column>
<property name="text">
<string>Receive time</string>
</property>
</column>
<column>
<property name="text">
<string>Sending time</string>
</property>
</column>
<column>
<property name="text">
<string>Branching factor</string>
</property>
</column>
<column>
<property name="text">
<string>Receive time (secs ago)</string>
</property>
</column>
<column>
<property name="text">
<string>Sending time (secs ago)</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
<widget class="QScrollArea" name="_router_F">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
@ -34,93 +111,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>1450</width>
<height>317</height>
<width>782</width>
<height>69</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTreeWidget" name="treeWidget">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<column>
<property name="text">
<string>ID</string>
</property>
</column>
<column>
<property name="text">
<string>Identity Name</string>
</property>
</column>
<column>
<property name="text">
<string>Destinaton</string>
</property>
</column>
<column>
<property name="text">
<string>Data status</string>
</property>
</column>
<column>
<property name="text">
<string>Tunnel status</string>
</property>
</column>
<column>
<property name="text">
<string>Stored data size</string>
</property>
</column>
<column>
<property name="text">
<string>Data hash</string>
</property>
</column>
<column>
<property name="text">
<string>Receive time</string>
</property>
</column>
<column>
<property name="text">
<string>Sending time</string>
</property>
</column>
<column>
<property name="text">
<string>Branching factor</string>
</property>
</column>
<column>
<property name="text">
<string>Receive time (secs ago)</string>
</property>
</column>
<column>
<property name="text">
<string>Sending time (secs ago)</string>
</property>
</column>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1468</width>
<height>779</height>
<width>800</width>
<height>500</height>
</rect>
</property>
<property name="windowTitle">

View File

@ -131,4 +131,11 @@ RttStatisticsGraph::RttStatisticsGraph(QWidget *parent)
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
int graphColor = Settings->valueFromGroup("BandwidthStatsWidget", "cmbGraphColor", 0).toInt();
if(graphColor==0)
resetFlags(RSGraphWidget::RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
setFlags(RSGraphWidget::RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
}

View File

@ -54,7 +54,7 @@
#define IMAGE_DHT ":/icons/DHT128.png"
#define IMAGE_TURTLE ":/icons/turtle128.png"
#define IMAGE_IDENTITIES ":/icons/avatar_128.png"
#define IMAGE_IDENTITIES ":/icons/identities.png"
#define IMAGE_BWGRAPH ":/icons/bandwidth128.png"
#define IMAGE_GLOBALROUTER ":/icons/GRouter128.png"
#define IMAGE_GXSTRANSPORT ":/icons/transport128.png"

View File

@ -15,7 +15,16 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
@ -45,7 +54,6 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="separator"/>
</widget>
<action name="actionAdd_Friend">
<property name="icon">
@ -61,7 +69,7 @@
</action>
<action name="actionAdd_Share">
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/add-share24.png</normaloff>:/images/add-share24.png</iconset>
</property>
<property name="text">
@ -79,7 +87,7 @@
</action>
<action name="actionMessenger">
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/messenger.png</normaloff>:/images/messenger.png</iconset>
</property>
<property name="text">
@ -105,7 +113,7 @@
</action>
<action name="actionQuit">
<property name="icon">
<iconset resource="../images.qrc">
<iconset>
<normaloff>:/images/exit_24x24.png</normaloff>:/images/exit_24x24.png</iconset>
</property>
<property name="text">

View File

@ -202,7 +202,14 @@ TurtleRouterStatistics::TurtleRouterStatistics(QWidget *parent)
float fact = fontHeight/14.0;
frmGraph->setMinimumHeight(200*fact);
int graphColor = Settings->valueFromGroup("BandwidthStatsWidget", "cmbGraphColor", 0).toInt();
if(graphColor==0)
frmGraph->resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
frmGraph->setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
// load settings
processSettings(true);
}
@ -224,12 +231,12 @@ void TurtleRouterStatistics::processSettings(bool bLoad)
// load settings
// state of splitter
//splitter->restoreState(Settings->value("Splitter").toByteArray());
splitter->restoreState(Settings->value("Splitter").toByteArray());
} else {
// save settings
// state of splitter
//Settings->setValue("Splitter", splitter->saveState());
Settings->setValue("Splitter", splitter->saveState());
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>680</width>
<height>523</height>
<height>500</height>
</rect>
</property>
<property name="windowTitle">
@ -29,15 +29,15 @@
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="handleWidth">
<number>5</number>
</property>
<widget class="QScrollArea" name="_tunnel_statistics_F">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
@ -47,28 +47,23 @@
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>248</height>
<width>636</width>
<height>198</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</widget>
</widget>
</item>
<item row="1" column="0">
<widget class="TurtleGraph" name="frmGraph" native="true">
<property name="minimumSize">
<size>
<width>120</width>
<height>200</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
<widget class="TurtleGraph" name="frmGraph" native="true">
<property name="minimumSize">
<size>
<width>120</width>
<height>200</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum>
</property>
</widget>
</widget>
</item>
</layout>

View File

@ -26,6 +26,7 @@
#include <QApplication>
#include <gui/common/RSGraphWidget.h>
#include "gui/settings/rsharesettings.h"
#include <retroshare/rsdht.h>
#include <retroshare/rsconfig.h>
@ -74,5 +75,12 @@ class DhtGraph : public RSGraphWidget
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
setFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
int graphColor = Settings->valueFromGroup("BandwidthStatsWidget", "cmbGraphColor", 0).toInt();
if(graphColor==0)
resetFlags(RSGraphWidget::RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
setFlags(RSGraphWidget::RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
}
};

View File

@ -20,6 +20,8 @@
#pragma once
#include "gui/settings/rsharesettings.h"
#include "retroshare/rsturtle.h"
#include <gui/common/RSGraphWidget.h>
@ -68,7 +70,14 @@ class TurtleGraph: public RSGraphWidget
resetFlags(RSGRAPH_FLAGS_LOG_SCALE_Y) ;
resetFlags(RSGRAPH_FLAGS_PAINT_STYLE_PLAIN) ;
setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
setFlags(RSGRAPH_FLAGS_SHOW_LEGEND) ;
int graphColor = Settings->valueFromGroup("BandwidthStatsWidget", "cmbGraphColor", 0).toInt();
if(graphColor==0)
resetFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
else
setFlags(RSGraphWidget::RSGRAPH_FLAGS_DARK_STYLE);
}
};

View File

@ -37,7 +37,7 @@ GroupChatToaster::GroupChatToaster(const RsPeerId &peerId, const QString &messag
/* set informations */
ui.textLabel->setText(RsHtml().formatText(NULL, message, RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS | RSHTML_FORMATTEXT_CLEANSTYLE));
ui.toasterLabel->setText(QString::fromUtf8(rsPeers->getPeerName(peerId).c_str()));
ui.avatarWidget->setFrameType(AvatarWidget::STATUS_FRAME);
ui.avatarWidget->setFrameType(AvatarWidget::NO_FRAME);
ui.avatarWidget->setDefaultAvatar(":/images/user/personal64.png");
ui.avatarWidget->setId(ChatId(peerId));
}