mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
- added some optimization to RequestDirDetails internal functions
- improved sorting/selection in shared files flat mode *W* Needs full recompilation. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4121 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f9c896c3ac
commit
6c2bdbe214
@ -1237,6 +1237,12 @@ int FileIndexMonitor::RequestDirDetails(std::string uid, std::string path, DirDe
|
|||||||
return (uid == fi.root->id) ;
|
return (uid == fi.root->id) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t FileIndexMonitor::getType(void *ref) const
|
||||||
|
{
|
||||||
|
RsStackMutex mutex(fiMutex) ;
|
||||||
|
|
||||||
|
return fi.getType(ref) ;
|
||||||
|
}
|
||||||
int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const
|
int FileIndexMonitor::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const
|
||||||
{
|
{
|
||||||
RsStackMutex mutex(fiMutex) ;
|
RsStackMutex mutex(fiMutex) ;
|
||||||
|
@ -135,6 +135,7 @@ class FileIndexMonitor: public CacheSource, public RsThread
|
|||||||
|
|
||||||
// Interface for browsing dir hirarchy
|
// Interface for browsing dir hirarchy
|
||||||
int RequestDirDetails(void*, DirDetails&, uint32_t) const ;
|
int RequestDirDetails(void*, DirDetails&, uint32_t) const ;
|
||||||
|
uint32_t getType(void*) const ;
|
||||||
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const ;
|
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const ;
|
||||||
|
|
||||||
// set/update shared directories
|
// set/update shared directories
|
||||||
|
@ -1216,6 +1216,16 @@ int FileIndex::searchBoolExp(Expression * exp, std::list<FileEntry *> &results)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t FileIndex::getType(void *ref)
|
||||||
|
{
|
||||||
|
if(ref == NULL)
|
||||||
|
return DIR_TYPE_ROOT ;
|
||||||
|
|
||||||
|
if(!isValid(ref))
|
||||||
|
return DIR_TYPE_ROOT ;
|
||||||
|
|
||||||
|
return static_cast<FileEntry*>(ref)->type() ;
|
||||||
|
}
|
||||||
bool FileIndex::extractData(void *ref,DirDetails& details)
|
bool FileIndex::extractData(void *ref,DirDetails& details)
|
||||||
{
|
{
|
||||||
if(!isValid(ref))
|
if(!isValid(ref))
|
||||||
@ -1227,7 +1237,7 @@ bool FileIndex::extractData(void *ref,DirDetails& details)
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileEntry *file = static_cast<FileEntry *>(ref);
|
FileEntry *file = static_cast<FileEntry *>(ref);
|
||||||
DirEntry *dir = dynamic_cast<DirEntry *>(file);
|
DirEntry *dir = (file->hash.empty())?static_cast<DirEntry *>(file):NULL ; // This is a hack to avoid doing a dynamic_cast
|
||||||
|
|
||||||
details.children = std::list<DirStub>() ;
|
details.children = std::list<DirStub>() ;
|
||||||
time_t now = time(NULL) ;
|
time_t now = time(NULL) ;
|
||||||
@ -1304,7 +1314,7 @@ bool FileIndex::extractData(void *ref,DirDetails& details)
|
|||||||
FileEntry *f ;
|
FileEntry *f ;
|
||||||
for(f=file;f->parent!=NULL;f=f->parent) ;
|
for(f=file;f->parent!=NULL;f=f->parent) ;
|
||||||
|
|
||||||
details.id = dynamic_cast<PersonEntry*>(f)->id;
|
details.id = static_cast<PersonEntry*>(f)->id; // The topmost parent is necessarily a personEntrY, so we can avoid a dynamic_cast.
|
||||||
|
|
||||||
#ifdef FI_DEBUG
|
#ifdef FI_DEBUG
|
||||||
assert(details.parent != details.ref) ;
|
assert(details.parent != details.ref) ;
|
||||||
|
@ -83,7 +83,8 @@ class FileEntry
|
|||||||
: size(0), modtime(0), pop(0), updtime(0), parent(NULL), row(0)
|
: size(0), modtime(0), pop(0), updtime(0), parent(NULL), row(0)
|
||||||
{ return; }
|
{ return; }
|
||||||
|
|
||||||
virtual ~FileEntry() { return; }
|
virtual ~FileEntry() { return; }
|
||||||
|
virtual uint32_t type() const { return DIR_TYPE_FILE ; }
|
||||||
|
|
||||||
virtual int print(std::ostream &out);
|
virtual int print(std::ostream &out);
|
||||||
|
|
||||||
@ -118,6 +119,7 @@ DirEntry * updateDir(const FileEntry& fe, time_t updtime);
|
|||||||
FileEntry * updateFile(const FileEntry& fe, time_t updtime);
|
FileEntry * updateFile(const FileEntry& fe, time_t updtime);
|
||||||
|
|
||||||
|
|
||||||
|
virtual uint32_t type() const { return DIR_TYPE_DIR ; }
|
||||||
int checkParentPointers();
|
int checkParentPointers();
|
||||||
int updateChildRows();
|
int updateChildRows();
|
||||||
|
|
||||||
@ -179,6 +181,7 @@ DirEntry &operator=(DirEntry &src)
|
|||||||
(*pdest) = src;
|
(*pdest) = src;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
virtual uint32_t type() const { return DIR_TYPE_PERSON ; }
|
||||||
|
|
||||||
/* Data */
|
/* Data */
|
||||||
std::string id;
|
std::string id;
|
||||||
@ -248,6 +251,7 @@ class FileIndex
|
|||||||
/// Fills up details from the data contained in ref.
|
/// Fills up details from the data contained in ref.
|
||||||
//
|
//
|
||||||
static bool extractData(void *ref,DirDetails& details) ;
|
static bool extractData(void *ref,DirDetails& details) ;
|
||||||
|
static uint32_t getType(void *ref) ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +155,7 @@ int FileIndexStore::loadCache(const CacheData &data)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Search Interface - For Directory Access */
|
/* Search Interface - For Directory Access */
|
||||||
int FileIndexStore::RequestDirDetails(std::string uid, std::string path, DirDetails &details) const
|
int FileIndexStore::RequestDirDetails(std::string uid, std::string path, DirDetails &details) const
|
||||||
{
|
{
|
||||||
@ -247,7 +248,14 @@ int FileIndexStore::RequestDirDetails(void *ref, DirDetails &details, uint32_t f
|
|||||||
unlockData();
|
unlockData();
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
uint32_t FileIndexStore::getType(void *ref) const
|
||||||
|
{
|
||||||
|
lockData() ;
|
||||||
|
uint32_t b = FileIndex::getType(ref) ;
|
||||||
|
unlockData();
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results) const
|
int FileIndexStore::SearchHash(std::string hash, std::list<FileDetail> &results) const
|
||||||
{
|
{
|
||||||
|
@ -84,6 +84,7 @@ virtual int loadCache(const CacheData &data); /* actual load, once data availa
|
|||||||
/* Search Interface - For Directory Access */
|
/* Search Interface - For Directory Access */
|
||||||
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const;
|
int RequestDirDetails(std::string uid, std::string path, DirDetails &details) const;
|
||||||
int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const;
|
int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) const;
|
||||||
|
uint32_t getType(void *ref) const ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AboutToModify();
|
int AboutToModify();
|
||||||
|
@ -502,7 +502,25 @@ int ftServer::RequestDirDetails(void *ref, DirDetails &details, uint32_t flags)
|
|||||||
else
|
else
|
||||||
return mFiStore->RequestDirDetails(ref, details, flags);
|
return mFiStore->RequestDirDetails(ref, details, flags);
|
||||||
}
|
}
|
||||||
|
uint32_t ftServer::getType(void *ref, uint32_t flags)
|
||||||
|
{
|
||||||
|
#ifdef SERVER_DEBUG
|
||||||
|
std::cerr << "ftServer::RequestDirDetails(ref:" << ref;
|
||||||
|
std::cerr << ", flags:" << flags << ", ...) -> mFiStore";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
if (!mFiStore)
|
||||||
|
{
|
||||||
|
std::cerr << "mFiStore not SET yet = FAIL";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
if(flags & DIR_FLAGS_LOCAL)
|
||||||
|
return mFiMon->getType(ref);
|
||||||
|
else
|
||||||
|
return mFiStore->getType(ref);
|
||||||
|
}
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
/******************** Search Interface *************************/
|
/******************** Search Interface *************************/
|
||||||
/***************************************************************/
|
/***************************************************************/
|
||||||
|
@ -171,6 +171,7 @@ virtual bool ExtraFileMove(std::string fname, std::string hash, uint64_t size,
|
|||||||
***/
|
***/
|
||||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details);
|
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details);
|
||||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
|
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags);
|
||||||
|
virtual uint32_t getType(void *ref,uint32_t flags) ;
|
||||||
|
|
||||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags);
|
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags);
|
||||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags);
|
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags);
|
||||||
|
@ -159,7 +159,9 @@ class RsFiles
|
|||||||
* Directory Listing / Search Interface
|
* Directory Listing / Search Interface
|
||||||
*/
|
*/
|
||||||
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
|
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
|
||||||
|
|
||||||
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
virtual int RequestDirDetails(void *ref, DirDetails &details, uint32_t flags) = 0;
|
||||||
|
virtual uint32_t getType(void *ref,uint32_t flags) = 0;
|
||||||
|
|
||||||
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
|
virtual int SearchKeywords(std::list<std::string> keywords, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||||
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags) = 0;
|
virtual int SearchBoolExp(Expression * exp, std::list<DirDetails> &results,uint32_t flags) = 0;
|
||||||
|
@ -83,7 +83,7 @@ bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
/* error */
|
/* error */
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
@ -144,7 +144,7 @@ int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "lookup failed -> 0";
|
std::cerr << "lookup failed -> 0";
|
||||||
@ -379,8 +379,7 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
|||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
} /* end of DisplayRole */
|
} /* end of DisplayRole */
|
||||||
|
QVariant TreeStyle_RDM::sortRole(const DirDetails& details,int coln) const
|
||||||
QVariant RetroshareDirModel::sortRole(const DirDetails& details,int coln) const
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Person: name, id, 0, 0;
|
* Person: name, id, 0, 0;
|
||||||
@ -440,6 +439,27 @@ QVariant RetroshareDirModel::sortRole(const DirDetails& details,int coln) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
QVariant FlatStyle_RDM::sortRole(const DirDetails& details,int coln) const
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Person: name, id, 0, 0;
|
||||||
|
* File : name, size, rank, (0) ts
|
||||||
|
* Dir : name, (0) count, (0) path, (0) ts
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (details.type == DIR_TYPE_FILE) /* File */
|
||||||
|
{
|
||||||
|
switch(coln)
|
||||||
|
{
|
||||||
|
case 0: return QString::fromUtf8(details.name.c_str());
|
||||||
|
case 1: return (qulonglong) details.count;
|
||||||
|
case 2: return details.age;
|
||||||
|
case 3: return QString::fromStdString(rsPeers->getPeerName(details.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return QVariant();
|
||||||
} /* end of SortRole */
|
} /* end of SortRole */
|
||||||
|
|
||||||
|
|
||||||
@ -467,7 +487,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */
|
if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */
|
||||||
@ -532,7 +552,7 @@ void RetroshareDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) c
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (rsFiles->RequestDirDetails(ref, childDetails, flags) && ret == tr(""))
|
if (requestDirDetails(ref, childDetails, flags) && ret == tr(""))
|
||||||
getAgeIndicatorRec(childDetails, ret);
|
getAgeIndicatorRec(childDetails, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -650,7 +670,7 @@ QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "lookup failed -> invalid";
|
std::cerr << "lookup failed -> invalid";
|
||||||
@ -728,7 +748,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
|
|||||||
DirDetails details;
|
DirDetails details;
|
||||||
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
uint32_t flags = (RemoteMode)?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "Failed Lookup -> invalid";
|
std::cerr << "Failed Lookup -> invalid";
|
||||||
@ -781,7 +801,7 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
return Qt::ItemIsSelectable; // Error.
|
return Qt::ItemIsSelectable; // Error.
|
||||||
|
|
||||||
switch(details.type)
|
switch(details.type)
|
||||||
@ -829,15 +849,13 @@ Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RetroshareDirModel::requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const
|
||||||
|
{
|
||||||
|
// We should use a cache instead of calling RsFiles::RequestDirDetails(), which is very costly
|
||||||
|
// due to some pointer checking crap.
|
||||||
|
|
||||||
//void RetroshareDirModel::update (const QModelIndex &index )
|
return rsFiles->RequestDirDetails(ref, details, flags) ;
|
||||||
//{
|
}
|
||||||
//#ifdef RDM_DEBUG
|
|
||||||
// //std::cerr << "Directory Request(" << id << ") : ";
|
|
||||||
// //std::cerr << path << std::endl;
|
|
||||||
//#endif
|
|
||||||
// //rsFiles -> RequestDirectories(id, path, 1);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
||||||
{
|
{
|
||||||
@ -912,7 +930,7 @@ void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int pr
|
|||||||
DirDetails subDirDetails;
|
DirDetails subDirDetails;
|
||||||
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_REMOTE;
|
uint32_t flags = DIR_FLAGS_CHILDREN | DIR_FLAGS_REMOTE;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(it->ref, subDirDetails, flags)) continue;
|
if (!requestDirDetails(it->ref, subDirDetails, flags)) continue;
|
||||||
|
|
||||||
downloadDirectory(subDirDetails, prefixLen);
|
downloadDirectory(subDirDetails, prefixLen);
|
||||||
}
|
}
|
||||||
@ -942,7 +960,7 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
|
|||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -987,7 +1005,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
|||||||
else
|
else
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(details.type == DIR_TYPE_PERSON)
|
if(details.type == DIR_TYPE_PERSON)
|
||||||
@ -1084,7 +1102,7 @@ void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std
|
|||||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
#ifdef RDM_DEBUG
|
#ifdef RDM_DEBUG
|
||||||
std::cerr << "getFilePaths() Bad Request" << std::endl;
|
std::cerr << "getFilePaths() Bad Request" << std::endl;
|
||||||
@ -1148,7 +1166,7 @@ QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) con
|
|||||||
flags |= DIR_FLAGS_LOCAL;
|
flags |= DIR_FLAGS_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
if (!requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1232,25 +1250,12 @@ QStringList RetroshareDirModel::mimeTypes () const
|
|||||||
|
|
||||||
int RetroshareDirModel::getType ( const QModelIndex & index ) const
|
int RetroshareDirModel::getType ( const QModelIndex & index ) const
|
||||||
{
|
{
|
||||||
//if (RemoteMode) // only local files can be opened
|
//if (RemoteMode) // only local files can be opened
|
||||||
// return ;
|
// return ;
|
||||||
void *ref = index.internalPointer();
|
|
||||||
if (!ref)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
DirDetails details;
|
uint32_t flags = RemoteMode?DIR_FLAGS_REMOTE:DIR_FLAGS_LOCAL;
|
||||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
|
||||||
if (RemoteMode)
|
|
||||||
flags |= DIR_FLAGS_REMOTE;
|
|
||||||
else
|
|
||||||
flags |= DIR_FLAGS_LOCAL;
|
|
||||||
|
|
||||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
return rsFiles->getType(index.internalPointer(),flags);
|
||||||
{
|
|
||||||
return false;//not good, but....
|
|
||||||
}
|
|
||||||
|
|
||||||
return details.type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlatStyle_RDM::~FlatStyle_RDM()
|
FlatStyle_RDM::~FlatStyle_RDM()
|
||||||
@ -1278,7 +1283,7 @@ void FlatStyle_RDM::postMods()
|
|||||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||||
DirDetails details ;
|
DirDetails details ;
|
||||||
|
|
||||||
if (rsFiles->RequestDirDetails(ref, details, flags))
|
if (requestDirDetails(ref, details, flags))
|
||||||
{
|
{
|
||||||
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
|
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
|
||||||
_ref_entries.push_back(ref);
|
_ref_entries.push_back(ref);
|
||||||
|
@ -61,6 +61,7 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||||||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||||
|
|
||||||
|
bool requestDirDetails(void *ref,DirDetails& details,uint32_t flags) const;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
||||||
@ -75,9 +76,9 @@ class RetroshareDirModel : public QAbstractItemModel
|
|||||||
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
||||||
|
|
||||||
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
||||||
|
virtual QVariant sortRole(const DirDetails&,int) const =0;
|
||||||
|
|
||||||
QVariant decorationRole(const DirDetails&,int) const ;
|
QVariant decorationRole(const DirDetails&,int) const ;
|
||||||
QVariant sortRole(const DirDetails&,int) const ;
|
|
||||||
|
|
||||||
uint32_t ageIndicator;
|
uint32_t ageIndicator;
|
||||||
|
|
||||||
@ -148,6 +149,7 @@ class TreeStyle_RDM: public RetroshareDirModel
|
|||||||
|
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
virtual QVariant displayRole(const DirDetails&,int) const ;
|
virtual QVariant displayRole(const DirDetails&,int) const ;
|
||||||
|
virtual QVariant sortRole(const DirDetails&,int) const ;
|
||||||
|
|
||||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||||
@ -176,6 +178,7 @@ class FlatStyle_RDM: public RetroshareDirModel
|
|||||||
|
|
||||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||||
virtual QVariant displayRole(const DirDetails&,int) const ;
|
virtual QVariant displayRole(const DirDetails&,int) const ;
|
||||||
|
virtual QVariant sortRole(const DirDetails&,int) const ;
|
||||||
|
|
||||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||||
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||||
|
@ -55,6 +55,10 @@
|
|||||||
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
#define IMAGE_OPENFOLDER ":/images/folderopen.png"
|
||||||
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
#define IMAGE_OPENFILE ":/images/fileopen.png"
|
||||||
|
|
||||||
|
// Define to avoid using the search in treeview, because it is really slow for now.
|
||||||
|
//
|
||||||
|
#define DONT_USE_SEARCH_IN_TREE_VIEW 1
|
||||||
|
|
||||||
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
||||||
|
|
||||||
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
||||||
@ -208,9 +212,6 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
|||||||
//
|
//
|
||||||
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
||||||
|
|
||||||
ui.filterStartButton->hide();
|
|
||||||
ui.filterClearButton->hide();
|
|
||||||
|
|
||||||
/* Hide platform specific features */
|
/* Hide platform specific features */
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
|
|
||||||
@ -278,16 +279,22 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
|
|||||||
model = tree_model ;
|
model = tree_model ;
|
||||||
proxyModel = tree_proxyModel ;
|
proxyModel = tree_proxyModel ;
|
||||||
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
||||||
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||||
ui.filterLabel->hide();
|
ui.filterLabel->hide();
|
||||||
ui.filterPatternLineEdit->hide();
|
ui.filterPatternLineEdit->hide();
|
||||||
|
ui.filterStartButton->hide();
|
||||||
|
ui.filterClearButton->hide();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model = flat_model ;
|
model = flat_model ;
|
||||||
proxyModel = flat_proxyModel ;
|
proxyModel = flat_proxyModel ;
|
||||||
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||||
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||||
ui.filterLabel->show();
|
ui.filterLabel->show();
|
||||||
ui.filterPatternLineEdit->show();
|
ui.filterPatternLineEdit->show();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
model->preMods();
|
model->preMods();
|
||||||
@ -301,7 +308,9 @@ void SharedFilesDialog::changeCurrentViewModel(int c)
|
|||||||
|
|
||||||
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
||||||
|
|
||||||
|
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||||
if(c == 1)
|
if(c == 1)
|
||||||
|
#endif
|
||||||
FilterItems();
|
FilterItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user