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