mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
added notification when new extra file is shared, so that shared files updates
This commit is contained in:
parent
fd2eed8b24
commit
9533fc9c00
@ -129,6 +129,11 @@ void ftExtraList::hashAFile()
|
||||
mHashedList[details.info.path] = details.info.hash;
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_ADDED;
|
||||
if(rsEvents)
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,6 +200,12 @@ bool ftExtraList::removeExtraFile(const RsFileHash& hash)
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
if(rsEvents)
|
||||
{
|
||||
auto ev = std::make_shared<RsSharedDirectoriesEvent>();
|
||||
ev->mEventCode = RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_REMOVED;
|
||||
rsEvents->postEvent(ev);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -184,6 +184,8 @@ enum class RsSharedDirectoriesEventCode: uint8_t {
|
||||
HASHING_FILE = 0x02, // mMessage: full path and hashing speed of the file being hashed
|
||||
DIRECTORY_SWEEP_ENDED = 0x03, // (void)
|
||||
SAVING_FILE_INDEX = 0x04, // (void)
|
||||
EXTRA_LIST_FILE_ADDED = 0x05, // (void)
|
||||
EXTRA_LIST_FILE_REMOVED = 0x06, // (void)
|
||||
};
|
||||
|
||||
enum class RsFileTransferEventCode: uint8_t {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/misc.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "retroshare/rsexpr.h"
|
||||
|
||||
#include <QDir>
|
||||
@ -63,6 +64,37 @@ RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent)
|
||||
treeStyle();
|
||||
|
||||
mDirDetails.ref = (void*)intptr_t(0xffffffff) ;
|
||||
|
||||
rsEvents->registerEventsHandler(
|
||||
[this](std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); });
|
||||
},
|
||||
mEventHandlerId,
|
||||
RsEventType::SHARED_DIRECTORIES );
|
||||
}
|
||||
|
||||
RetroshareDirModel::~RetroshareDirModel()
|
||||
{
|
||||
rsEvents->unregisterEventsHandler(mEventHandlerId);
|
||||
}
|
||||
void RetroshareDirModel::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
|
||||
{
|
||||
if(event->mType != RsEventType::SHARED_DIRECTORIES) return;
|
||||
|
||||
const RsSharedDirectoriesEvent *fe = dynamic_cast<const RsSharedDirectoriesEvent*>(event.get());
|
||||
if(!fe)
|
||||
return;
|
||||
|
||||
switch (fe->mEventCode)
|
||||
{
|
||||
case RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_ADDED:
|
||||
case RsSharedDirectoriesEventCode::EXTRA_LIST_FILE_REMOVED:
|
||||
update();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TreeStyle_RDM::TreeStyle_RDM(bool mode)
|
||||
|
@ -22,6 +22,7 @@
|
||||
#define REMOTE_DIR_MODEL
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rsevents.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QAction>
|
||||
@ -63,7 +64,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
enum Roles{ FileNameRole = Qt::UserRole+1, SortRole = Qt::UserRole+2, FilterRole = Qt::UserRole+3 };
|
||||
|
||||
RetroshareDirModel(bool mode, QObject *parent = 0);
|
||||
virtual ~RetroshareDirModel() {}
|
||||
virtual ~RetroshareDirModel() ;
|
||||
|
||||
virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||
|
||||
@ -107,6 +108,8 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
protected:
|
||||
bool _visible ;
|
||||
|
||||
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
|
||||
|
||||
void treeStyle();
|
||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||
static QString getFlagsString(FileStorageFlags f) ;
|
||||
@ -176,6 +179,8 @@ class RetroshareDirModel : public QAbstractItemModel
|
||||
bool mUpdating ;
|
||||
|
||||
std::set<void*> mFilteredPointers ;
|
||||
|
||||
RsEventsHandlerId_t mEventHandlerId;
|
||||
};
|
||||
|
||||
// This class shows the classical hierarchical directory view of shared files
|
||||
|
Loading…
Reference in New Issue
Block a user