mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
- implemented an optional flat view for shared files that allows sorting by date/peer/name
- restored the search for flat view only (very slow for tree view) - cleaned the code a bit: made two subclasses of RetroshareDirModel: TreeStyle_RDM and FlatStyle_RDM git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4117 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c22a0c79e7
commit
f634331442
@ -28,6 +28,7 @@
|
||||
#include "RemoteDirModel.h"
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <set>
|
||||
@ -38,7 +39,7 @@
|
||||
* #define RDM_DEBUG
|
||||
****/
|
||||
|
||||
RemoteDirModel::RemoteDirModel(bool mode, QObject *parent)
|
||||
RetroshareDirModel::RetroshareDirModel(bool mode, QObject *parent)
|
||||
: QAbstractItemModel(parent),
|
||||
ageIndicator(IND_ALWAYS),
|
||||
RemoteMode(mode), nIndex(1), indexSet(1) /* ass zero index cant be used */
|
||||
@ -47,7 +48,7 @@ RemoteDirModel::RemoteDirModel(bool mode, QObject *parent)
|
||||
treeStyle();
|
||||
}
|
||||
|
||||
void RemoteDirModel::treeStyle()
|
||||
void RetroshareDirModel::treeStyle()
|
||||
{
|
||||
categoryIcon.addPixmap(QPixmap(":/images/folder16.png"),
|
||||
QIcon::Normal, QIcon::Off);
|
||||
@ -56,11 +57,11 @@ void RemoteDirModel::treeStyle()
|
||||
peerIcon = QIcon(":/images/user/identity16.png");
|
||||
}
|
||||
|
||||
bool RemoteDirModel::hasChildren(const QModelIndex &parent) const
|
||||
bool TreeStyle_RDM::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::hasChildren() :" << parent.internalPointer();
|
||||
std::cerr << "RetroshareDirModel::hasChildren() :" << parent.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
@ -107,12 +108,30 @@ void RemoteDirModel::treeStyle()
|
||||
#endif
|
||||
return (details.count > 0); /* do we have children? */
|
||||
}
|
||||
bool FlatStyle_RDM::hasChildren(const QModelIndex &parent) const
|
||||
{
|
||||
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::hasChildren() :" << parent.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
int RemoteDirModel::rowCount(const QModelIndex &parent) const
|
||||
if (!parent.isValid())
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::rowCount(): " << parent.internalPointer();
|
||||
std::cerr << "root -> true ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false ;
|
||||
}
|
||||
|
||||
int TreeStyle_RDM::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::rowCount(): " << parent.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
@ -150,11 +169,24 @@ void RemoteDirModel::treeStyle()
|
||||
return details.count;
|
||||
}
|
||||
|
||||
int RemoteDirModel::columnCount(const QModelIndex &parent) const
|
||||
int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::rowCount(): " << parent.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
return _ref_entries.size() ;
|
||||
}
|
||||
int TreeStyle_RDM::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
QString RemoteDirModel::getFlagsString(uint32_t flags)
|
||||
int FlatStyle_RDM::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
QString RetroshareDirModel::getFlagsString(uint32_t flags)
|
||||
{
|
||||
switch(flags & (DIR_FLAGS_NETWORK_WIDE|DIR_FLAGS_BROWSABLE))
|
||||
{
|
||||
@ -166,7 +198,7 @@ QString RemoteDirModel::getFlagsString(uint32_t flags)
|
||||
}
|
||||
}
|
||||
|
||||
QString RemoteDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
QString RetroshareDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
{
|
||||
QString ret("");
|
||||
QString nind = tr("NEW");
|
||||
@ -195,192 +227,75 @@ QString RemoteDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
return ret;
|
||||
}
|
||||
|
||||
QVariant RemoteDirModel::data(const QModelIndex &index, int role) const
|
||||
QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::data(): " << index.internalPointer();
|
||||
std::cerr << ": ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (!index.isValid())
|
||||
if(coln > 0)
|
||||
return QVariant() ;
|
||||
|
||||
/* get the data from the index */
|
||||
void *ref = index.internalPointer();
|
||||
int coln = index.column();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
|
||||
|
||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if (role == RemoteDirModel::FileNameRole)
|
||||
{
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
} /* end of FileNameRole */
|
||||
|
||||
if (role == Qt::TextColorRole)
|
||||
{
|
||||
if(details.min_age > ageIndicator)
|
||||
return Qt::gray ;
|
||||
else
|
||||
return Qt::black ;
|
||||
} /* end of TextColorRole */
|
||||
|
||||
|
||||
if (role == Qt::DecorationRole)
|
||||
{
|
||||
if (details.type == DIR_TYPE_PERSON)
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
if(details.min_age > ageIndicator)
|
||||
{
|
||||
return QIcon(":/images/folder_grey.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_DAY )
|
||||
{
|
||||
return QIcon(":/images/folder_green.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_WEEK )
|
||||
{
|
||||
return QIcon(":/images/folder_yellow.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_MONTH )
|
||||
{
|
||||
return QIcon(":/images/folder_red.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
return (QIcon(peerIcon));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (details.type == DIR_TYPE_DIR)
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
if(details.min_age > ageIndicator)
|
||||
{
|
||||
return QIcon(":/images/folder_grey.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_DAY )
|
||||
{
|
||||
return QIcon(":/images/folder_green.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_WEEK )
|
||||
{
|
||||
return QIcon(":/images/folder_yellow.png");
|
||||
}
|
||||
else if (ageIndicator == IND_LAST_MONTH )
|
||||
{
|
||||
return QIcon(":/images/folder_red.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
return QIcon(categoryIcon);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (details.type == DIR_TYPE_FILE) /* File */
|
||||
{
|
||||
// extensions predefined
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
QString ext = QFileInfo(QString::fromUtf8(details.name.c_str())).suffix();
|
||||
if (ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif"
|
||||
|| ext == "bmp" || ext == "ico" || ext == "svg")
|
||||
{
|
||||
return QIcon(":/images/FileTypePicture.png");
|
||||
}
|
||||
else if (ext == "avi" || ext == "AVI" || ext == "mpg" || ext == "mpeg" || ext == "wmv" || ext == "ogm"
|
||||
|| ext == "mkv" || ext == "mp4" || ext == "flv" || ext == "mov"
|
||||
|| ext == "vob" || ext == "qt" || ext == "rm" || ext == "3gp")
|
||||
{
|
||||
return QIcon(":/images/FileTypeVideo.png");
|
||||
}
|
||||
else if (ext == "ogg" || ext == "mp3" || ext == "wav" || ext == "wma" || ext == "xpm")
|
||||
{
|
||||
return QIcon(":/images/FileTypeAudio.png");
|
||||
}
|
||||
else if (ext == "tar" || ext == "bz2" || ext == "zip" || ext == "gz" || ext == "7z"
|
||||
|| ext == "rar" || ext == "rpm" || ext == "deb")
|
||||
{
|
||||
return QIcon(":/images/FileTypeArchive.png");
|
||||
}
|
||||
else if (ext == "app" || ext == "bat" || ext == "cgi" || ext == "com"
|
||||
|| ext == "bin" || ext == "exe" || ext == "js" || ext == "pif"
|
||||
|| ext == "py" || ext == "pl" || ext == "sh" || ext == "vb" || ext == "ws")
|
||||
{
|
||||
return QIcon(":/images/FileTypeProgram.png");
|
||||
}
|
||||
else if (ext == "iso" || ext == "nrg" || ext == "mdf" )
|
||||
{
|
||||
return QIcon(":/images/FileTypeCDImage.png");
|
||||
}
|
||||
else if (ext == "txt" || ext == "cpp" || ext == "c" || ext == "h")
|
||||
{
|
||||
return QIcon(":/images/FileTypeDocument.png");
|
||||
}
|
||||
else if (ext == "doc" || ext == "rtf" || ext == "sxw" || ext == "xls"
|
||||
|| ext == "sxc" || ext == "odt" || ext == "ods")
|
||||
{
|
||||
return QIcon(":/images/FileTypeDocument.png");
|
||||
}
|
||||
else if (ext == "html" || ext == "htm" || ext == "php")
|
||||
{
|
||||
return QIcon(":/images/FileTypeDocument.png");
|
||||
}
|
||||
else
|
||||
{
|
||||
return QIcon(":/images/FileTypeAny.png");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
} /* end of DecorationRole */
|
||||
|
||||
/*****************
|
||||
Qt::EditRole
|
||||
Qt::ToolTipRole
|
||||
Qt::StatusTipRole
|
||||
Qt::WhatsThisRole
|
||||
Qt::SizeHintRole
|
||||
****************/
|
||||
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
return QSize(18, 18);
|
||||
} /* end of SizeHintRole */
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if(coln == 1)
|
||||
{
|
||||
return int( Qt::AlignRight | Qt::AlignVCenter);
|
||||
}
|
||||
return QVariant();
|
||||
} /* end of TextAlignmentRole */
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
|
||||
/*
|
||||
@ -449,16 +364,30 @@ QString RemoteDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
return QVariant();
|
||||
} /* end of DisplayRole */
|
||||
|
||||
if (role == SortRole)
|
||||
QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
if (details.type == DIR_TYPE_FILE) /* File */
|
||||
switch(coln)
|
||||
{
|
||||
case 0: return QString::fromUtf8(details.name.c_str());
|
||||
case 1: return misc::friendlyUnit(details.count);
|
||||
case 2: return misc::userFriendlyDuration(details.age);
|
||||
case 3: return QString::fromStdString(rsPeers->getPeerName(details.id));
|
||||
default:
|
||||
return QVariant() ;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
} /* end of DisplayRole */
|
||||
|
||||
QVariant RetroshareDirModel::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_PERSON) /* Person */
|
||||
{
|
||||
switch(coln)
|
||||
@ -513,10 +442,81 @@ QString RemoteDirModel::getAgeIndicatorString(const DirDetails &details) const
|
||||
return QVariant();
|
||||
} /* end of SortRole */
|
||||
|
||||
|
||||
|
||||
|
||||
QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::data(): " << index.internalPointer();
|
||||
std::cerr << ": ";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (!index.isValid())
|
||||
return QVariant();
|
||||
|
||||
/* get the data from the index */
|
||||
void *ref = index.internalPointer();
|
||||
int coln = index.column();
|
||||
|
||||
DirDetails details;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
if (RemoteMode)
|
||||
flags |= DIR_FLAGS_REMOTE;
|
||||
else
|
||||
flags |= DIR_FLAGS_LOCAL;
|
||||
|
||||
if (!rsFiles->RequestDirDetails(ref, details, flags))
|
||||
return QVariant();
|
||||
|
||||
if (role == RetroshareDirModel::FileNameRole) /* end of FileNameRole */
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
|
||||
if (role == Qt::TextColorRole)
|
||||
{
|
||||
if(details.min_age > ageIndicator)
|
||||
return Qt::gray ;
|
||||
else
|
||||
return Qt::black ;
|
||||
} /* end of TextColorRole */
|
||||
|
||||
|
||||
if(role == Qt::DecorationRole)
|
||||
return decorationRole(details,coln) ;
|
||||
|
||||
/*****************
|
||||
Qt::EditRole
|
||||
Qt::ToolTipRole
|
||||
Qt::StatusTipRole
|
||||
Qt::WhatsThisRole
|
||||
Qt::SizeHintRole
|
||||
****************/
|
||||
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
return QSize(18, 18);
|
||||
} /* end of SizeHintRole */
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if(coln == 1)
|
||||
{
|
||||
return int( Qt::AlignRight | Qt::AlignVCenter);
|
||||
}
|
||||
return QVariant();
|
||||
} /* end of TextAlignmentRole */
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return displayRole(details,coln) ;
|
||||
|
||||
if (role == SortRole)
|
||||
return sortRole(details,coln) ;
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void RemoteDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) const {
|
||||
void RetroshareDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) const {
|
||||
if (details.type == DIR_TYPE_FILE) {
|
||||
ret = getAgeIndicatorString(details);
|
||||
return;
|
||||
@ -538,8 +538,49 @@ void RemoteDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) const
|
||||
}
|
||||
}
|
||||
|
||||
QVariant RemoteDirModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
int defw = 50;
|
||||
int defh = 21;
|
||||
if (section < 2)
|
||||
{
|
||||
defw = 200;
|
||||
}
|
||||
return QSize(defw, defh);
|
||||
}
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
|
||||
if (orientation == Qt::Horizontal)
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
if (RemoteMode)
|
||||
return tr("Friends Directories");
|
||||
else
|
||||
return tr("My Directories");
|
||||
case 1:
|
||||
return tr("Size");
|
||||
case 2:
|
||||
return tr("Age");
|
||||
case 3:
|
||||
if (RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Share Type");
|
||||
case 4:
|
||||
return tr("What's new");
|
||||
}
|
||||
return QString("Column %1").arg(section);
|
||||
}
|
||||
else
|
||||
return QString("Row %1").arg(section);
|
||||
}
|
||||
QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
if (role == Qt::SizeHintRole)
|
||||
{
|
||||
@ -570,6 +611,9 @@ void RemoteDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) const
|
||||
case 2:
|
||||
return tr("Age");
|
||||
case 3:
|
||||
if(RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Share Type");
|
||||
case 4:
|
||||
return tr("What's new");
|
||||
@ -580,10 +624,10 @@ void RemoteDirModel::getAgeIndicatorRec(DirDetails &details, QString &ret) const
|
||||
return QString("Row %1").arg(section);
|
||||
}
|
||||
|
||||
QModelIndex RemoteDirModel::index(int row, int column, const QModelIndex & parent) const
|
||||
QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::index(): " << parent.internalPointer();
|
||||
std::cerr << "RetroshareDirModel::index(): " << parent.internalPointer();
|
||||
std::cerr << ": row:" << row << " col:" << column << " ";
|
||||
#endif
|
||||
|
||||
@ -642,12 +686,30 @@ QModelIndex RemoteDirModel::index(int row, int column, const QModelIndex & paren
|
||||
|
||||
return createIndex(row, column, it->ref);
|
||||
}
|
||||
|
||||
|
||||
QModelIndex RemoteDirModel::parent( const QModelIndex & index ) const
|
||||
QModelIndex FlatStyle_RDM::index(int row, int column, const QModelIndex & parent) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::parent(): " << index.internalPointer();
|
||||
std::cerr << "RetroshareDirModel::index(): " << parent.internalPointer();
|
||||
std::cerr << ": row:" << row << " col:" << column << " ";
|
||||
#endif
|
||||
|
||||
if(row < 0)
|
||||
return QModelIndex() ;
|
||||
|
||||
if(row < _ref_entries.size())
|
||||
{
|
||||
void *ref = _ref_entries[row] ;
|
||||
|
||||
return createIndex(row, column, ref);
|
||||
}
|
||||
else
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::parent(): " << index.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
@ -691,11 +753,19 @@ QModelIndex RemoteDirModel::parent( const QModelIndex & index ) const
|
||||
#endif
|
||||
return createIndex(details.prow, 0, details.parent);
|
||||
}
|
||||
|
||||
Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
|
||||
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::flags()";
|
||||
std::cerr << "RetroshareDirModel::parent(): " << index.internalPointer();
|
||||
std::cerr << ": ";
|
||||
#endif
|
||||
|
||||
return QModelIndex();
|
||||
}
|
||||
Qt::ItemFlags RetroshareDirModel::flags( const QModelIndex & index ) const
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RetroshareDirModel::flags()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
@ -733,10 +803,10 @@ Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
|
||||
|
||||
|
||||
/* Callback from */
|
||||
void RemoteDirModel::preMods()
|
||||
void RetroshareDirModel::preMods()
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::preMods()" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::preMods()" << std::endl;
|
||||
#endif
|
||||
//modelAboutToBeReset();
|
||||
// reset();
|
||||
@ -747,21 +817,20 @@ Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
|
||||
}
|
||||
|
||||
/* Callback from */
|
||||
void RemoteDirModel::postMods()
|
||||
void RetroshareDirModel::postMods()
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::postMods()" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::postMods()" << std::endl;
|
||||
#endif
|
||||
//modelReset();
|
||||
layoutChanged();
|
||||
//reset();
|
||||
#if QT_VERSION >= 0x040600
|
||||
endResetModel();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//void RemoteDirModel::update (const QModelIndex &index )
|
||||
//void RetroshareDirModel::update (const QModelIndex &index )
|
||||
//{
|
||||
//#ifdef RDM_DEBUG
|
||||
// //std::cerr << "Directory Request(" << id << ") : ";
|
||||
@ -770,7 +839,7 @@ Qt::ItemFlags RemoteDirModel::flags( const QModelIndex & index ) const
|
||||
// //rsFiles -> RequestDirectories(id, path, 1);
|
||||
//}
|
||||
|
||||
void RemoteDirModel::downloadSelected(const QModelIndexList &list)
|
||||
void RetroshareDirModel::downloadSelected(const QModelIndexList &list)
|
||||
{
|
||||
if (!RemoteMode)
|
||||
{
|
||||
@ -800,7 +869,7 @@ void RemoteDirModel::downloadSelected(const QModelIndexList &list)
|
||||
/* if it is a file */
|
||||
if (details.type == DIR_TYPE_FILE)
|
||||
{
|
||||
std::cerr << "RemoteDirModel::downloadSelected() Calling File Request";
|
||||
std::cerr << "RetroshareDirModel::downloadSelected() Calling File Request";
|
||||
std::cerr << std::endl;
|
||||
std::list<std::string> srcIds;
|
||||
srcIds.push_back(details.id);
|
||||
@ -818,7 +887,7 @@ void RemoteDirModel::downloadSelected(const QModelIndexList &list)
|
||||
}
|
||||
|
||||
/* recursively download a directory */
|
||||
void RemoteDirModel::downloadDirectory(const DirDetails & dirDetails, int prefixLen)
|
||||
void RetroshareDirModel::downloadDirectory(const DirDetails & dirDetails, int prefixLen)
|
||||
{
|
||||
if (dirDetails.type & DIR_TYPE_FILE)
|
||||
{
|
||||
@ -850,7 +919,7 @@ void RemoteDirModel::downloadDirectory(const DirDetails & dirDetails, int prefix
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteDirModel::getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec)
|
||||
void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec)
|
||||
{
|
||||
dirVec.clear();
|
||||
|
||||
@ -888,7 +957,7 @@ void RemoteDirModel::getDirDetailsFromSelect (const QModelIndexList &list, std::
|
||||
*
|
||||
*/
|
||||
|
||||
void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& file_details)
|
||||
void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& file_details)
|
||||
{
|
||||
file_details.clear() ;
|
||||
|
||||
@ -949,10 +1018,10 @@ void RemoteDirModel::getFileInfoFromIndexList(const QModelIndexList& list, std::
|
||||
* OLD RECOMMEND SYSTEM - DISABLED
|
||||
******/
|
||||
|
||||
void RemoteDirModel::openSelected(const QModelIndexList &qmil)
|
||||
void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::openSelected()" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::openSelected()" << std::endl;
|
||||
#endif
|
||||
|
||||
if (RemoteMode) {
|
||||
@ -989,14 +1058,14 @@ void RemoteDirModel::openSelected(const QModelIndexList &qmil)
|
||||
}
|
||||
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "::::::::::::Done RemoteDirModel::openSelected()" << std::endl;
|
||||
std::cerr << "::::::::::::Done RetroshareDirModel::openSelected()" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RemoteDirModel::getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths)
|
||||
void RetroshareDirModel::getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths)
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::getFilePaths()" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::getFilePaths()" << std::endl;
|
||||
#endif
|
||||
if (RemoteMode)
|
||||
{
|
||||
@ -1056,7 +1125,7 @@ void RemoteDirModel::getFilePaths(const QModelIndexList &list, std::list<std::st
|
||||
}
|
||||
|
||||
/* Drag and Drop Functionality */
|
||||
QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
QMimeData * RetroshareDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
{
|
||||
/* extract from each the member text */
|
||||
std::string text;
|
||||
@ -1095,7 +1164,7 @@ QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
if (details.type != DIR_TYPE_FILE)
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::mimeData() Not File" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::mimeData() Not File" << std::endl;
|
||||
#endif
|
||||
continue; /* not file! */
|
||||
}
|
||||
@ -1103,7 +1172,7 @@ QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
if (drags.end() != (dit = drags.find(details.hash)))
|
||||
{
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "RemoteDirModel::mimeData() Duplicate" << std::endl;
|
||||
std::cerr << "RetroshareDirModel::mimeData() Duplicate" << std::endl;
|
||||
#endif
|
||||
continue; /* duplicate */
|
||||
}
|
||||
@ -1151,7 +1220,7 @@ QMimeData * RemoteDirModel::mimeData ( const QModelIndexList & indexes ) const
|
||||
|
||||
}
|
||||
|
||||
QStringList RemoteDirModel::mimeTypes () const
|
||||
QStringList RetroshareDirModel::mimeTypes () const
|
||||
{
|
||||
QStringList list;
|
||||
list.push_back("application/x-rsfilelist");
|
||||
@ -1161,7 +1230,7 @@ QStringList RemoteDirModel::mimeTypes () const
|
||||
|
||||
//============================================================================
|
||||
|
||||
int RemoteDirModel::getType ( const QModelIndex & index ) const
|
||||
int RetroshareDirModel::getType ( const QModelIndex & index ) const
|
||||
{
|
||||
//if (RemoteMode) // only local files can be opened
|
||||
// return ;
|
||||
@ -1183,3 +1252,45 @@ int RemoteDirModel::getType ( const QModelIndex & index ) const
|
||||
|
||||
return details.type;
|
||||
}
|
||||
|
||||
FlatStyle_RDM::~FlatStyle_RDM()
|
||||
{
|
||||
}
|
||||
|
||||
TreeStyle_RDM::~TreeStyle_RDM()
|
||||
{
|
||||
}
|
||||
void FlatStyle_RDM::postMods()
|
||||
{
|
||||
_ref_entries.clear() ;
|
||||
|
||||
std::cerr << "FlatStyle_RDM::postMods(): cleared ref entries" << std::endl;
|
||||
|
||||
std::vector<void *> stack(1,(void *)NULL) ;
|
||||
|
||||
while(!stack.empty())
|
||||
{
|
||||
void *ref = stack.back() ;
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "FlatStyle_RDM::postMods(): poped ref " << ref << std::endl;
|
||||
#endif
|
||||
stack.pop_back() ;
|
||||
uint32_t flags = DIR_FLAGS_DETAILS;
|
||||
DirDetails details ;
|
||||
|
||||
if (rsFiles->RequestDirDetails(ref, details, flags))
|
||||
{
|
||||
if(details.type == DIR_TYPE_FILE) // only push files, not directories nor persons.
|
||||
_ref_entries.push_back(ref);
|
||||
#ifdef RDM_DEBUG
|
||||
std::cerr << "FlatStyle_RDM::postMods(): addign ref " << ref << std::endl;
|
||||
#endif
|
||||
for(std::list<DirStub>::iterator it = details.children.begin(); it != details.children.end(); it++)
|
||||
stack.push_back(it->ref) ;
|
||||
}
|
||||
}
|
||||
std::cerr << "reference tab contains " << _ref_entries.size() << " files" << std::endl;
|
||||
|
||||
RetroshareDirModel::postMods() ;
|
||||
}
|
||||
|
||||
|
@ -34,33 +34,21 @@ static const uint32_t IND_LAST_WEEK = 3600*24*7 ;
|
||||
static const uint32_t IND_LAST_MONTH = 3600*24*31 ; // I know, this is approximate
|
||||
static const uint32_t IND_ALWAYS = ~(uint32_t)0 ;
|
||||
|
||||
class RemoteDirModel : public QAbstractItemModel
|
||||
class RetroshareDirModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Roles{ FileNameRole = Qt::UserRole+1, SortRole = Qt::UserRole+2 };
|
||||
|
||||
RemoteDirModel(bool mode, QObject *parent = 0);
|
||||
|
||||
/* These are all overloaded Virtual Functions */
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
|
||||
QModelIndex index(int row, int column,
|
||||
const QModelIndex & parent = QModelIndex() ) const;
|
||||
QModelIndex parent ( const QModelIndex & index ) const;
|
||||
RetroshareDirModel(bool mode, QObject *parent = 0);
|
||||
virtual ~RetroshareDirModel() {}
|
||||
|
||||
Qt::ItemFlags flags ( const QModelIndex & index ) const;
|
||||
bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
||||
|
||||
/* Callback from Core */
|
||||
void preMods();
|
||||
void postMods();
|
||||
virtual void preMods();
|
||||
virtual void postMods();
|
||||
|
||||
/* Callback from GUI */
|
||||
void downloadSelected(const QModelIndexList &list);
|
||||
@ -68,36 +56,29 @@ class RemoteDirModel : public QAbstractItemModel
|
||||
void getDirDetailsFromSelect (const QModelIndexList &list, std::vector <DirDetails>& dirVec);
|
||||
|
||||
int getType ( const QModelIndex & index ) const ;
|
||||
//void openFile(QModelIndex fileIndex, const QString command);
|
||||
|
||||
void getFileInfoFromIndexList(const QModelIndexList& list, std::list<DirDetails>& files_info) ;
|
||||
|
||||
void openSelected(const QModelIndexList &list);
|
||||
|
||||
void getFilePaths(const QModelIndexList &list, std::list<std::string> &fullpaths);
|
||||
|
||||
void changeAgeIndicator(uint32_t indicator) { ageIndicator = indicator; }
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
// void collapsed ( const QModelIndex & index ) { update(index); }
|
||||
// void expanded ( const QModelIndex & index ) { update(index); }
|
||||
|
||||
/* Drag and Drop Functionality */
|
||||
public:
|
||||
|
||||
virtual QMimeData * mimeData ( const QModelIndexList & indexes ) const;
|
||||
virtual QStringList mimeTypes () const;
|
||||
virtual QVariant data(const QModelIndex &index, int role) const;
|
||||
|
||||
private:
|
||||
// void update (const QModelIndex &index );
|
||||
protected:
|
||||
void treeStyle();
|
||||
void downloadDirectory(const DirDetails & details, int prefixLen);
|
||||
static QString getFlagsString(uint32_t) ;
|
||||
QString getAgeIndicatorString(const DirDetails &) const;
|
||||
void getAgeIndicatorRec(DirDetails &details, QString &ret) const;
|
||||
|
||||
virtual QVariant displayRole(const DirDetails&,int) const = 0 ;
|
||||
|
||||
QVariant decorationRole(const DirDetails&,int) const ;
|
||||
QVariant sortRole(const DirDetails&,int) const ;
|
||||
|
||||
uint32_t ageIndicator;
|
||||
|
||||
QIcon categoryIcon;
|
||||
@ -146,4 +127,62 @@ class RemoteDirModel : public QAbstractItemModel
|
||||
|
||||
};
|
||||
|
||||
// This class shows the classical hierarchical directory view of shared files
|
||||
// Columns are:
|
||||
// file name | Size | Age
|
||||
//
|
||||
class TreeStyle_RDM: public RetroshareDirModel
|
||||
{
|
||||
public:
|
||||
TreeStyle_RDM(bool mode)
|
||||
: RetroshareDirModel(mode)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~TreeStyle_RDM() ;
|
||||
|
||||
protected:
|
||||
/* These are all overloaded Virtual Functions */
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
virtual QVariant displayRole(const DirDetails&,int) const ;
|
||||
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
||||
};
|
||||
|
||||
// This class shows a flat list of all shared files
|
||||
// Columns are:
|
||||
// file name | Owner | Size | Age
|
||||
//
|
||||
class FlatStyle_RDM: public RetroshareDirModel
|
||||
{
|
||||
public:
|
||||
FlatStyle_RDM(bool mode)
|
||||
: RetroshareDirModel(mode)
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~FlatStyle_RDM() ;
|
||||
|
||||
protected:
|
||||
virtual void postMods();
|
||||
|
||||
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
|
||||
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
virtual QVariant displayRole(const DirDetails&,int) const ;
|
||||
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex() ) const;
|
||||
virtual QModelIndex parent ( const QModelIndex & index ) const;
|
||||
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const;
|
||||
|
||||
std::vector<void *> _ref_entries ;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -60,7 +60,7 @@ const QString Image_AddNewAssotiationForFile = ":/images/kcmsystem24.png";
|
||||
class SFDSortFilterProxyModel : public QSortFilterProxyModel
|
||||
{
|
||||
public:
|
||||
SFDSortFilterProxyModel(RemoteDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
||||
SFDSortFilterProxyModel(RetroshareDirModel *dirModel, QObject *parent) : QSortFilterProxyModel(parent)
|
||||
{
|
||||
m_dirModel = dirModel;
|
||||
};
|
||||
@ -79,7 +79,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
RemoteDirModel *m_dirModel;
|
||||
RetroshareDirModel *m_dirModel;
|
||||
};
|
||||
|
||||
/** Constructor */
|
||||
@ -89,13 +89,11 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
|
||||
|
||||
connect(ui.checkButton, SIGNAL(clicked()), this, SLOT(forceCheck()));
|
||||
|
||||
connect(ui.localButton, SIGNAL(toggled(bool)), this, SLOT(showFrame(bool)));
|
||||
connect(ui.remoteButton, SIGNAL(toggled(bool)), this, SLOT(showFrameRemote(bool)));
|
||||
connect(ui.splittedButton, SIGNAL(toggled(bool)), this, SLOT(showFrameSplitted(bool)));
|
||||
connect(ui.viewType_CB, SIGNAL(currentIndexChanged(int)), this, SLOT(changeCurrentViewModel(int)));
|
||||
|
||||
connect( ui.localDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( sharedDirTreeWidgetContextMenu( QPoint ) ) );
|
||||
connect( ui.remoteDirTreeView, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( shareddirtreeviewCostumPopupMenu( QPoint ) ) );
|
||||
@ -114,35 +112,34 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||
*/
|
||||
|
||||
|
||||
model = new RemoteDirModel(true);
|
||||
tree_model = new TreeStyle_RDM(true);
|
||||
flat_model = new FlatStyle_RDM(true);
|
||||
|
||||
proxyModel = new SFDSortFilterProxyModel(model, this);
|
||||
proxyModel->setDynamicSortFilter(true);
|
||||
proxyModel->setSourceModel(model);
|
||||
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
proxyModel->setSortRole(RemoteDirModel::SortRole);
|
||||
proxyModel->sort(0);
|
||||
tree_proxyModel = new SFDSortFilterProxyModel(tree_model, this);
|
||||
tree_proxyModel->setDynamicSortFilter(true);
|
||||
tree_proxyModel->setSourceModel(tree_model);
|
||||
tree_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
tree_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
tree_proxyModel->sort(0);
|
||||
|
||||
ui.remoteDirTreeView->setModel(proxyModel);
|
||||
flat_proxyModel = new SFDSortFilterProxyModel(flat_model, this);
|
||||
flat_proxyModel->setDynamicSortFilter(true);
|
||||
flat_proxyModel->setSourceModel(flat_model);
|
||||
flat_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
flat_proxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
flat_proxyModel->sort(0);
|
||||
|
||||
localModel = new RemoteDirModel(false);
|
||||
localModel = new TreeStyle_RDM(false);
|
||||
|
||||
localProxyModel = new SFDSortFilterProxyModel(localModel, this);
|
||||
localProxyModel->setDynamicSortFilter(true);
|
||||
localProxyModel->setSourceModel(localModel);
|
||||
localProxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||
localProxyModel->setSortRole(RemoteDirModel::SortRole);
|
||||
localProxyModel->setSortRole(RetroshareDirModel::SortRole);
|
||||
localProxyModel->sort(0);
|
||||
|
||||
ui.localDirTreeView->setModel(localProxyModel);
|
||||
|
||||
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
||||
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
||||
ui.localDirTreeView->setColumnHidden(4,true) ;
|
||||
|
||||
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
||||
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
||||
|
||||
connect( ui.localDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), localModel, SLOT( collapsed(const QModelIndex & ) ) );
|
||||
connect( ui.localDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), localModel, SLOT( expanded(const QModelIndex & ) ) );
|
||||
|
||||
@ -154,6 +151,13 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(returnPressed()), this, SLOT(startFilter()));
|
||||
connect(ui.filterPatternLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(filterRegExpChanged()));
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||
ui.remoteDirTreeView->setColumnHidden(4,true) ;
|
||||
ui.localDirTreeView->setColumnHidden(4,true) ;
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * l_header = ui.localDirTreeView->header () ;
|
||||
// l_header->setResizeMode (0, QHeaderView::Interactive);
|
||||
@ -173,6 +177,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||
|
||||
r_header->setResizeMode (0, QHeaderView::Interactive);
|
||||
r_header->setStretchLastSection(false);
|
||||
l_header->setStretchLastSection(false);
|
||||
|
||||
// r_header->setResizeMode (1, QHeaderView::Fixed);
|
||||
// // r_header->setResizeMode (2, QHeaderView::Interactive);
|
||||
@ -182,28 +187,30 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
|
||||
|
||||
r_header->resizeSection ( 0, 490 );
|
||||
r_header->resizeSection ( 1, 70 );
|
||||
// r_header->resizeSection ( 2, 0 );
|
||||
r_header->resizeSection ( 2, 80 );
|
||||
r_header->resizeSection ( 3, 100 );
|
||||
// r_header->resizeSection ( 4, 0 );
|
||||
r_header->resizeSection ( 4, 80 );
|
||||
|
||||
l_header->setHighlightSections(false);
|
||||
r_header->setHighlightSections(false);
|
||||
// l_header->setHighlightSections(false);
|
||||
// r_header->setHighlightSections(false);
|
||||
|
||||
|
||||
/* Set Multi Selection */
|
||||
ui.remoteDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
ui.localDirTreeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
|
||||
#ifdef RS_RELEASE_VERSION
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
#endif
|
||||
//#ifdef RS_RELEASE_VERSION
|
||||
// ui.filterLabel->hide();
|
||||
// ui.filterPatternLineEdit->hide();
|
||||
//#endif
|
||||
|
||||
// Setup the current view model.
|
||||
//
|
||||
changeCurrentViewModel(ui.viewType_CB->currentIndex()) ;
|
||||
|
||||
ui.filterStartButton->hide();
|
||||
ui.filterClearButton->hide();
|
||||
|
||||
// load settings
|
||||
processSettings(true);
|
||||
|
||||
/* Hide platform specific features */
|
||||
#ifdef Q_WS_WIN
|
||||
|
||||
@ -261,6 +268,43 @@ void SharedFilesDialog::processSettings(bool bLoad)
|
||||
Settings->endGroup();
|
||||
}
|
||||
|
||||
void SharedFilesDialog::changeCurrentViewModel(int c)
|
||||
{
|
||||
disconnect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), 0, 0 );
|
||||
disconnect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), 0, 0 );
|
||||
|
||||
if(c == 0)
|
||||
{
|
||||
model = tree_model ;
|
||||
proxyModel = tree_proxyModel ;
|
||||
ui.remoteDirTreeView->setColumnHidden(3,true) ;
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
model = flat_model ;
|
||||
proxyModel = flat_proxyModel ;
|
||||
ui.remoteDirTreeView->setColumnHidden(3,false) ;
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
}
|
||||
|
||||
model->preMods();
|
||||
model->postMods();
|
||||
|
||||
connect( ui.remoteDirTreeView, SIGNAL( collapsed(const QModelIndex & ) ), model, SLOT( collapsed(const QModelIndex & ) ) );
|
||||
connect( ui.remoteDirTreeView, SIGNAL( expanded(const QModelIndex & ) ), model, SLOT( expanded(const QModelIndex & ) ) );
|
||||
|
||||
ui.remoteDirTreeView->setModel(proxyModel);
|
||||
ui.remoteDirTreeView->update();
|
||||
|
||||
ui.remoteDirTreeView->header()->headerDataChanged(Qt::Horizontal,0,4) ;
|
||||
|
||||
if(c == 1)
|
||||
FilterItems();
|
||||
}
|
||||
|
||||
void SharedFilesDialog::checkUpdate()
|
||||
{
|
||||
/* update */
|
||||
@ -667,7 +711,7 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
|
||||
if (!midx.isValid())
|
||||
return;
|
||||
|
||||
currentFile = localModel->data(midx, RemoteDirModel::FileNameRole).toString();
|
||||
currentFile = localModel->data(midx, RetroshareDirModel::FileNameRole).toString();
|
||||
|
||||
int type = localModel->getType(midx);
|
||||
|
||||
@ -873,24 +917,40 @@ void SharedFilesDialog::FilterItems()
|
||||
QString text = ui.filterPatternLineEdit->text();
|
||||
|
||||
setCursor(Qt::WaitCursor);
|
||||
QCoreApplication::processEvents() ;
|
||||
|
||||
int rowCount = ui.remoteDirTreeView->model()->rowCount();
|
||||
for (int row = 0; row < rowCount; row++) {
|
||||
/* Filter name */
|
||||
FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||
}
|
||||
for (int row = 0; row < rowCount; row++)
|
||||
if(proxyModel == tree_proxyModel)
|
||||
tree_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||
else
|
||||
flat_FilterItem(ui.remoteDirTreeView->model()->index(row, 0), text, 0);
|
||||
|
||||
setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||
bool SharedFilesDialog::flat_FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||
{
|
||||
if(index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive))
|
||||
{
|
||||
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), false);
|
||||
return false ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.remoteDirTreeView->setRowHidden(index.row(), index.parent(), true);
|
||||
return true ;
|
||||
}
|
||||
}
|
||||
|
||||
bool SharedFilesDialog::tree_FilterItem(const QModelIndex &index, const QString &text, int level)
|
||||
{
|
||||
bool visible = true;
|
||||
|
||||
if (text.isEmpty() == false) {
|
||||
// better use RemoteDirModel::getType, but its slow enough
|
||||
// better use RetroshareDirModel::getType, but its slow enough
|
||||
if (/*index.parent().isValid()*/ level >= 1) {
|
||||
if (index.data(RemoteDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
||||
if (index.data(RetroshareDirModel::FileNameRole).toString().contains(text, Qt::CaseInsensitive) == false) {
|
||||
visible = false;
|
||||
}
|
||||
} else {
|
||||
@ -901,7 +961,7 @@ bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text
|
||||
int visibleChildCount = 0;
|
||||
int rowCount = ui.remoteDirTreeView->model()->rowCount(index);
|
||||
for (int row = 0; row < rowCount; row++) {
|
||||
if (FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
||||
if (tree_FilterItem(ui.remoteDirTreeView->model()->index(row, index.column(), index), text, level + 1)) {
|
||||
visibleChildCount++;
|
||||
}
|
||||
}
|
||||
@ -914,3 +974,4 @@ bool SharedFilesDialog::FilterItem(const QModelIndex &index, const QString &text
|
||||
|
||||
return (visible || visibleChildCount);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "ui_SharedFilesDialog.h"
|
||||
|
||||
class RemoteDirModel;
|
||||
class RetroshareDirModel;
|
||||
class QSortFilterProxyModel;
|
||||
|
||||
class SharedFilesDialog : public RsAutoUpdatePage
|
||||
@ -87,6 +87,8 @@ private slots:
|
||||
void clearFilter();
|
||||
void startFilter();
|
||||
|
||||
public slots:
|
||||
void changeCurrentViewModel(int) ;
|
||||
signals:
|
||||
void playFiles(QStringList files);
|
||||
|
||||
@ -103,7 +105,8 @@ private:
|
||||
void copyLink (const QModelIndexList& lst, bool remote);
|
||||
|
||||
void FilterItems();
|
||||
bool FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||
bool tree_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||
bool flat_FilterItem(const QModelIndex &index, const QString &text, int level);
|
||||
|
||||
QModelIndexList getRemoteSelected();
|
||||
QModelIndexList getLocalSelected();
|
||||
@ -125,10 +128,15 @@ private:
|
||||
/** Qt Designer generated object */
|
||||
Ui::SharedFilesDialog ui;
|
||||
|
||||
/* RemoteDirModel */
|
||||
RemoteDirModel *model;
|
||||
/* RetroshareDirModel */
|
||||
RetroshareDirModel *tree_model;
|
||||
RetroshareDirModel *flat_model;
|
||||
RetroshareDirModel *model;
|
||||
QSortFilterProxyModel *tree_proxyModel;
|
||||
QSortFilterProxyModel *flat_proxyModel;
|
||||
QSortFilterProxyModel *proxyModel;
|
||||
RemoteDirModel *localModel;
|
||||
|
||||
RetroshareDirModel *localModel;
|
||||
QSortFilterProxyModel *localProxyModel;
|
||||
|
||||
QString currentCommand;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>525</width>
|
||||
<height>297</height>
|
||||
<width>934</width>
|
||||
<height>402</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -584,7 +584,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="splittedButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -616,7 +616,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="remoteButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -648,7 +648,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<item row="0" column="8">
|
||||
<widget class="QPushButton" name="localButton">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
@ -680,7 +680,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<item row="0" column="5">
|
||||
<widget class="QComboBox" name="indicatorCBox">
|
||||
<item>
|
||||
<property name="text">
|
||||
@ -823,6 +823,20 @@ border-image: url(:/images/closepressed.png)
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<widget class="QComboBox" name="viewType_CB">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Tree view</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat view</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -878,6 +892,12 @@ background: white;}</string>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -926,6 +946,12 @@ background: white;}</string>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user