mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Split Number of Files and Size in RemoteDirModel.
This commit is contained in:
parent
afc43d0ff7
commit
798ad15c3b
@ -19,39 +19,39 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <set>
|
||||
|
||||
#include <QString>
|
||||
#include <QTreeView>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QPainter>
|
||||
#include <QProcess>
|
||||
#include <QMessageBox>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStyledItemDelegate>
|
||||
#include "SharedFilesDialog.h"
|
||||
|
||||
#include "rshare.h"
|
||||
#include "SharedFilesDialog.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/MainWindow.h"
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/RemoteDirModel.h"
|
||||
#include "gui/RetroShareLink.h"
|
||||
#include "gui/ShareManager.h"
|
||||
#include "gui/common/PeerDefs.h"
|
||||
#include "gui/common/RsCollection.h"
|
||||
#include "gui/msgs/MessageComposer.h"
|
||||
#include "gui/settings/AddFileAssociationDialog.h"
|
||||
#include "gui/gxschannels/GxsChannelDialog.h"
|
||||
#include "gui/gxsforums/GxsForumsDialog.h"
|
||||
#include "gui/settings/AddFileAssociationDialog.h"
|
||||
#include "gui/settings/rsharesettings.h"
|
||||
#include "util/QtVersion.h"
|
||||
#include "util/RsAction.h"
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rsexpr.h>
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QProcess>
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QString>
|
||||
#include <QStyledItemDelegate>
|
||||
#include <QTreeView>
|
||||
|
||||
#include <set>
|
||||
|
||||
/* Images for context menu icons */
|
||||
#define IMAGE_DOWNLOAD ":/images/download16.png"
|
||||
@ -75,14 +75,6 @@
|
||||
#define IMAGE_EDITSHARE ":/images/edit_16.png"
|
||||
#define IMAGE_MYFILES ":/icons/svg/folders1.svg"
|
||||
|
||||
/*define dirTreeView Column */
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_SIZE 1
|
||||
#define COLUMN_AGE 2
|
||||
#define COLUMN_FRIEND 3
|
||||
#define COLUMN_DIR 4
|
||||
#define COLUMN_COUNT 5
|
||||
|
||||
/*define viewType_CB value */
|
||||
#define VIEW_TYPE_TREE 0
|
||||
#define VIEW_TYPE_FLAT 1
|
||||
@ -199,10 +191,11 @@ SharedFilesDialog::SharedFilesDialog(RetroshareDirModel *_tree_model,RetroshareD
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
|
||||
header->resizeSection ( COLUMN_NAME, 490 );
|
||||
header->resizeSection ( COLUMN_FILENB, 70 );
|
||||
header->resizeSection ( COLUMN_SIZE, 70 );
|
||||
header->resizeSection ( COLUMN_AGE, 100 );
|
||||
header->resizeSection ( COLUMN_FRIEND,100);
|
||||
header->resizeSection ( COLUMN_DIR, 100 );
|
||||
header->resizeSection ( COLUMN_FRIEND_ACCESS,100);
|
||||
header->resizeSection ( COLUMN_WN_VISU_DIR, 100 );
|
||||
|
||||
header->setStretchLastSection(false);
|
||||
|
||||
@ -231,7 +224,7 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(new TreeStyle_RDM(false),new FlatStyle_RDM(false),parent)
|
||||
{
|
||||
// Hide columns after loading the settings
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
ui.downloadButton->hide() ;
|
||||
|
||||
// load settings
|
||||
@ -250,14 +243,14 @@ LocalSharedFilesDialog::LocalSharedFilesDialog(QWidget *parent)
|
||||
|
||||
ui.titleBarPixmap->setPixmap(QPixmap(IMAGE_MYFILES)) ;
|
||||
|
||||
ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND,new ShareFlagsItemDelegate()) ;
|
||||
ui.dirTreeView->setItemDelegateForColumn(COLUMN_FRIEND_ACCESS,new ShareFlagsItemDelegate()) ;
|
||||
}
|
||||
|
||||
RemoteSharedFilesDialog::RemoteSharedFilesDialog(QWidget *parent)
|
||||
: SharedFilesDialog(new TreeStyle_RDM(true),new FlatStyle_RDM(true),parent)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
|
||||
ui.checkButton->hide() ;
|
||||
|
||||
connect(ui.downloadButton, SIGNAL(clicked()), this, SLOT(downloadRemoteSelected()));
|
||||
@ -413,7 +406,7 @@ void SharedFilesDialog::changeCurrentViewModel(int viewTypeIndex)
|
||||
QHeaderView * header = ui.dirTreeView->header () ;
|
||||
QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Interactive);
|
||||
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_DIR) ;
|
||||
ui.dirTreeView->header()->headerDataChanged(Qt::Horizontal, COLUMN_NAME, COLUMN_WN_VISU_DIR) ;
|
||||
|
||||
// recursRestoreExpandedItems(ui.dirTreeView->rootIndex(),expanded_indexes);
|
||||
FilterItems();
|
||||
@ -423,8 +416,9 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -434,8 +428,9 @@ void LocalSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -446,8 +441,9 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
{
|
||||
if(model == tree_model)
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, true) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->hide();
|
||||
ui.filterPatternLineEdit->hide();
|
||||
@ -457,8 +453,9 @@ void RemoteSharedFilesDialog::showProperColumns()
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_DIR, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FILENB, true) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_FRIEND_ACCESS, false) ;
|
||||
ui.dirTreeView->setColumnHidden(COLUMN_WN_VISU_DIR, false) ;
|
||||
#ifdef DONT_USE_SEARCH_IN_TREE_VIEW
|
||||
ui.filterLabel->show();
|
||||
ui.filterPatternLineEdit->show();
|
||||
@ -1254,12 +1251,12 @@ void SharedFilesDialog::filterRegExpChanged()
|
||||
ui.filterStartButton->show();
|
||||
}
|
||||
|
||||
bool valid = false ;
|
||||
QColor color ;
|
||||
//bool valid = false ;
|
||||
//QColor color ;
|
||||
|
||||
if(text.length() > 0 && text.length() < 3)
|
||||
{
|
||||
valid = false;
|
||||
//valid = false;
|
||||
|
||||
ui.filterStartButton->setEnabled(false) ;
|
||||
ui.filterPatternFrame->setToolTip(tr("Search string should be at least 3 characters long.")) ;
|
||||
|
@ -19,26 +19,26 @@
|
||||
* Boston, MA 02110-1301, USA.
|
||||
****************************************************************/
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
#include <QMimeData>
|
||||
#include <QTimer>
|
||||
|
||||
#include <retroshare-gui/RsAutoUpdatePage.h>
|
||||
#include <gui/common/RsCollection.h>
|
||||
#include <gui/common/RsUrlHandler.h>
|
||||
#include <gui/common/FilesDefs.h>
|
||||
#include <gui/common/GroupDefs.h>
|
||||
#include <gui/gxs/GxsIdDetails.h>
|
||||
#include "RemoteDirModel.h"
|
||||
#include <retroshare/rsfiles.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
||||
#include "RsAutoUpdatePage.h"
|
||||
#include "gui/common/FilesDefs.h"
|
||||
#include "gui/common/GroupDefs.h"
|
||||
#include "gui/common/RsCollection.h"
|
||||
#include "gui/common/RsUrlHandler.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "retroshare/rsfiles.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <set>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QTimer>
|
||||
#include <QUrl>
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <time.h>
|
||||
|
||||
/*****
|
||||
@ -212,11 +212,11 @@ int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
|
||||
}
|
||||
int TreeStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 5;
|
||||
return COLUMN_COUNT;
|
||||
}
|
||||
int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
|
||||
{
|
||||
return 5;
|
||||
return COLUMN_COUNT;
|
||||
}
|
||||
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
|
||||
{
|
||||
@ -324,7 +324,7 @@ const QIcon& RetroshareDirModel::getFlagsIcon(FileStorageFlags flags)
|
||||
|
||||
QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
if(coln == 3)
|
||||
if(coln == COLUMN_FRIEND_ACCESS)
|
||||
{
|
||||
if(details.type == DIR_TYPE_PERSON) return QVariant() ;
|
||||
|
||||
@ -392,7 +392,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0: {
|
||||
case COLUMN_NAME: {
|
||||
//SharedDirStats stats ;
|
||||
QString res ;
|
||||
|
||||
@ -406,29 +406,39 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
}
|
||||
return res ;
|
||||
}
|
||||
case 1: {
|
||||
case COLUMN_FILENB: {
|
||||
SharedDirStats stats ;
|
||||
QString res ;
|
||||
|
||||
if(RemoteMode)
|
||||
{
|
||||
//res = QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//res = tr("My files");
|
||||
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
||||
}
|
||||
|
||||
if(stats.total_number_of_files > 0)
|
||||
res += QString::number(stats.total_number_of_files) + " files, " + misc::friendlyUnit(stats.total_shared_size) ;
|
||||
|
||||
return res ;
|
||||
{
|
||||
if (stats.total_number_of_files > 1)
|
||||
return QString::number(stats.total_number_of_files) + " " + tr("Files");
|
||||
else
|
||||
return QString::number(stats.total_number_of_files) + " " + tr("File");
|
||||
}
|
||||
case 2: if(!isNewerThanEpoque(details.max_mtime))
|
||||
return QString();
|
||||
return tr("Empty");
|
||||
}
|
||||
case COLUMN_SIZE: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
||||
else
|
||||
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
||||
|
||||
if(stats.total_shared_size > 0)
|
||||
return misc::friendlyUnit(stats.total_shared_size) ;
|
||||
|
||||
return QString();
|
||||
}
|
||||
case COLUMN_AGE:
|
||||
if(!isNewerThanEpoque(details.max_mtime))
|
||||
return QString();
|
||||
else
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
|
||||
@ -440,15 +450,17 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case 1:
|
||||
return misc::friendlyUnit(details.count);
|
||||
case 2:
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
case 3:
|
||||
case COLUMN_FILENB:
|
||||
return QVariant();
|
||||
case 4:
|
||||
case COLUMN_SIZE:
|
||||
return misc::friendlyUnit(details.count);
|
||||
case COLUMN_AGE:
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
return QVariant();
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
return getGroupsString(details.flags,details.parent_groups) ;
|
||||
|
||||
default:
|
||||
@ -459,20 +471,22 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
break;
|
||||
case 1:
|
||||
case COLUMN_FILENB:
|
||||
if (details.count > 1)
|
||||
{
|
||||
return QString::number(details.count) + " " + tr("Files");
|
||||
}
|
||||
return QString::number(details.count) + " " + tr("File");
|
||||
case 2:
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
case 3:
|
||||
case COLUMN_SIZE:
|
||||
return QVariant();
|
||||
case 4:
|
||||
case COLUMN_AGE:
|
||||
return misc::timeRelativeToNow(details.max_mtime);
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
return QVariant();
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
return getGroupsString(details.flags,details.parent_groups) ;
|
||||
|
||||
default:
|
||||
@ -501,6 +515,7 @@ void FlatStyle_RDM::update()
|
||||
postMods() ;
|
||||
}
|
||||
}
|
||||
|
||||
QString FlatStyle_RDM::computeDirectoryPath(const DirDetails& details) const
|
||||
{
|
||||
QString dir ;
|
||||
@ -530,17 +545,19 @@ 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::timeRelativeToNow(details.max_mtime);
|
||||
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case 4: return computeDirectoryPath(details);
|
||||
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB: return QString();
|
||||
case COLUMN_SIZE: return misc::friendlyUnit(details.count);
|
||||
case COLUMN_AGE: return misc::timeRelativeToNow(details.max_mtime);
|
||||
case COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case COLUMN_WN_VISU_DIR: return computeDirectoryPath(details);
|
||||
default:
|
||||
return QVariant() ;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
} /* end of DisplayRole */
|
||||
|
||||
QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& details,int coln) const
|
||||
{
|
||||
/*
|
||||
@ -553,11 +570,29 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
return (RemoteMode)?(QString::fromUtf8(rsPeers->getPeerName(details.id).c_str())):tr("My files");
|
||||
case 1:
|
||||
return QString();
|
||||
case 2:
|
||||
case COLUMN_FILENB: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
||||
else
|
||||
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
||||
|
||||
return (qulonglong) stats.total_number_of_files;
|
||||
}
|
||||
case COLUMN_SIZE: {
|
||||
SharedDirStats stats ;
|
||||
|
||||
if(RemoteMode)
|
||||
rsFiles->getSharedDirStatistics(details.id,stats) ;
|
||||
else
|
||||
rsFiles->getSharedDirStatistics(rsPeers->getOwnId(),stats) ;
|
||||
|
||||
return (qulonglong) stats.total_shared_size;
|
||||
}
|
||||
case COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
default:
|
||||
return QString();
|
||||
@ -567,15 +602,17 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case 1:
|
||||
case COLUMN_FILENB:
|
||||
return (qulonglong) 0;
|
||||
case COLUMN_SIZE:
|
||||
return (qulonglong) details.count;
|
||||
case 2:
|
||||
case COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
case 3:
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
return getFlagsString(details.flags);
|
||||
case 4:
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
{
|
||||
QString ind("");
|
||||
if (ageIndicator != IND_ALWAYS)
|
||||
@ -590,13 +627,15 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
return QString::fromUtf8(details.name.c_str());
|
||||
case 1:
|
||||
case COLUMN_FILENB:
|
||||
return (qulonglong) details.count;
|
||||
case 2:
|
||||
case COLUMN_SIZE:
|
||||
return (qulonglong) 0;
|
||||
case COLUMN_AGE:
|
||||
return details.max_mtime;
|
||||
case 3:
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
return getFlagsString(details.flags);
|
||||
default:
|
||||
return tr("DIR");
|
||||
@ -604,6 +643,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails& details,int coln) const
|
||||
{
|
||||
/*
|
||||
@ -616,12 +656,12 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
|
||||
{
|
||||
switch(coln)
|
||||
{
|
||||
case 0: return QString::fromUtf8(details.name.c_str());
|
||||
case 1: return (qulonglong) details.count;
|
||||
case 2: return details.max_mtime;
|
||||
case 3: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
|
||||
case 4: {
|
||||
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
|
||||
case COLUMN_FILENB: return (qulonglong) 0;
|
||||
case COLUMN_SIZE: return (qulonglong) details.count;
|
||||
case COLUMN_AGE: return details.max_mtime;
|
||||
case COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
|
||||
case COLUMN_WN_VISU_DIR: {
|
||||
RS_STACK_MUTEX(_ref_mutex) ;
|
||||
|
||||
return computeDirectoryPath(details);
|
||||
@ -652,7 +692,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if (role == Qt::TextAlignmentRole)
|
||||
{
|
||||
if(coln == 1)
|
||||
if((coln == COLUMN_FILENB) || (coln == COLUMN_SIZE))
|
||||
return int( Qt::AlignRight | Qt::AlignVCenter);
|
||||
else
|
||||
return QVariant();
|
||||
@ -747,7 +787,7 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
int defw = QFontMetricsF(QWidget().font()).width(headerData(section,Qt::Horizontal,Qt::DisplayRole).toString()) ;
|
||||
int defh = QFontMetricsF(QWidget().font()).height();
|
||||
|
||||
if (section < 2)
|
||||
if (section < COLUMN_AGE)
|
||||
{
|
||||
defw = 200/16.0*defh;
|
||||
}
|
||||
@ -761,7 +801,7 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
if (RemoteMode)
|
||||
if(mUpdating)
|
||||
return tr("Friends Directories [updating...]");
|
||||
@ -772,25 +812,27 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
return tr("My Directories [updating...]");
|
||||
else
|
||||
return tr("My Directories");
|
||||
case 1:
|
||||
case COLUMN_FILENB:
|
||||
return tr("# Files");
|
||||
case COLUMN_SIZE:
|
||||
return tr("Size");
|
||||
case 2:
|
||||
case COLUMN_AGE:
|
||||
return tr("Age");
|
||||
case 3:
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
if (RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Access");
|
||||
case 4:
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
if (RemoteMode)
|
||||
return tr("What's new");
|
||||
else
|
||||
return tr("Visibility");
|
||||
}
|
||||
return QString("Column %1").arg(section);
|
||||
return tr("Column %1").arg(section);
|
||||
}
|
||||
else
|
||||
return QString("Row %1").arg(section);
|
||||
return tr("Row %1").arg(section);
|
||||
}
|
||||
QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int role) const
|
||||
{
|
||||
@ -799,7 +841,7 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
int defw = QFontMetricsF(QWidget().font()).width(headerData(section,Qt::Horizontal,Qt::DisplayRole).toString()) ;
|
||||
int defh = QFontMetricsF(QWidget().font()).height();
|
||||
|
||||
if (section < 2)
|
||||
if (section < COLUMN_AGE)
|
||||
{
|
||||
defw = defh*200/16.0;
|
||||
}
|
||||
@ -813,28 +855,30 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
|
||||
{
|
||||
switch(section)
|
||||
{
|
||||
case 0:
|
||||
case COLUMN_NAME:
|
||||
if (RemoteMode)
|
||||
{
|
||||
return tr("Friends Directories");
|
||||
}
|
||||
return tr("My Directories");
|
||||
case 1:
|
||||
case COLUMN_FILENB:
|
||||
return tr("# Files");
|
||||
case COLUMN_SIZE:
|
||||
return tr("Size");
|
||||
case 2:
|
||||
case COLUMN_AGE:
|
||||
return tr("Age");
|
||||
case 3:
|
||||
case COLUMN_FRIEND_ACCESS:
|
||||
if(RemoteMode)
|
||||
return tr("Friend");
|
||||
else
|
||||
return tr("Share Flags");
|
||||
case 4:
|
||||
case COLUMN_WN_VISU_DIR:
|
||||
return tr("Directory");
|
||||
}
|
||||
return QString("Column %1").arg(section);
|
||||
return tr("Column %1").arg(section);
|
||||
}
|
||||
else
|
||||
return QString("Row %1").arg(section);
|
||||
return tr("Row %1").arg(section);
|
||||
}
|
||||
|
||||
QModelIndex TreeStyle_RDM::index(int row, int column, const QModelIndex & parent) const
|
||||
@ -939,7 +983,7 @@ QModelIndex TreeStyle_RDM::parent( const QModelIndex & index ) const
|
||||
|
||||
std::cerr << "Creating index 3 row=" << details.prow << ", column=" << 0 << ", ref=" << (void*)details.parent << std::endl;
|
||||
#endif
|
||||
return createIndex(details.prow, 0, details.parent);
|
||||
return createIndex(details.prow, COLUMN_NAME, details.parent);
|
||||
}
|
||||
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
|
||||
{
|
||||
@ -1070,7 +1114,7 @@ void RetroshareDirModel::createCollectionFile(QWidget *parent, const QModelIndex
|
||||
QString dir_name;
|
||||
if(!RemoteMode)
|
||||
{
|
||||
if(dirVec.size())
|
||||
if(!dirVec.empty())
|
||||
{
|
||||
const DirDetails& details = dirVec[0];
|
||||
dir_name = QDir(QString::fromUtf8(details.name.c_str())).dirName();
|
||||
@ -1171,7 +1215,7 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
|
||||
QModelIndexList::const_iterator it;
|
||||
for(it = list.begin(); it != list.end(); ++it)
|
||||
{
|
||||
if(it->column()==1)
|
||||
if(it->column()==COLUMN_FILENB)
|
||||
{
|
||||
void *ref = it -> internalPointer();
|
||||
|
||||
@ -1208,7 +1252,7 @@ void RetroshareDirModel::getFileInfoFromIndexList(const QModelIndexList& list, s
|
||||
std::set<std::string> already_in ;
|
||||
|
||||
for(QModelIndexList::const_iterator it(list.begin()); it != list.end(); ++it)
|
||||
if(it->column()==0)
|
||||
if(it->column()==COLUMN_NAME)
|
||||
{
|
||||
void *ref = it -> internalPointer();
|
||||
|
||||
@ -1258,8 +1302,6 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> dirs_to_open;
|
||||
|
||||
std::list<DirDetails> files_info;
|
||||
std::list<DirDetails>::iterator it;
|
||||
getFileInfoFromIndexList(qmil, files_info);
|
||||
@ -1268,9 +1310,6 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
||||
{
|
||||
if ((*it).type & DIR_TYPE_PERSON) continue;
|
||||
|
||||
//std::string path, name;
|
||||
//rsFiles->ConvertSharedFilePath((*it).path, path);
|
||||
|
||||
QDir dir(QString::fromUtf8((*it).path.c_str()));
|
||||
QString dest;
|
||||
if ((*it).type & DIR_TYPE_FILE) {
|
||||
@ -1291,7 +1330,7 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil)
|
||||
|
||||
void RetroshareDirModel::getFilePath(const QModelIndex& index, std::string& fullpath)
|
||||
{
|
||||
void *ref = index.sibling(index.row(),1).internalPointer();
|
||||
void *ref = index.sibling(index.row(),COLUMN_FILENB).internalPointer();
|
||||
|
||||
DirDetails details ;
|
||||
|
||||
|
@ -22,11 +22,21 @@
|
||||
#ifndef REMOTE_DIR_MODEL
|
||||
#define REMOTE_DIR_MODEL
|
||||
|
||||
#include <retroshare/rstypes.h>
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QIcon>
|
||||
#include <vector>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <retroshare/rstypes.h>
|
||||
#include <vector>
|
||||
|
||||
#define COLUMN_NAME 0
|
||||
#define COLUMN_FILENB 1
|
||||
#define COLUMN_SIZE 2
|
||||
#define COLUMN_AGE 3
|
||||
#define COLUMN_FRIEND_ACCESS 4
|
||||
#define COLUMN_WN_VISU_DIR 5
|
||||
#define COLUMN_COUNT 6
|
||||
|
||||
class DirDetails;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user