moved to cpp files some column defines that otherwise collapsed in .h files

This commit is contained in:
csoler 2022-03-26 20:55:10 +01:00
parent a0ac041582
commit dd653e5462
9 changed files with 174 additions and 179 deletions

View File

@ -32,6 +32,29 @@
Q_DECLARE_METATYPE(FileProgressInfo)
// Defines for download list list columns
#define DLLISTDELEGATE_COLUMN_NAME 0
#define DLLISTDELEGATE_COLUMN_SIZE 1
#define DLLISTDELEGATE_COLUMN_COMPLETED 2
#define DLLISTDELEGATE_COLUMN_DLSPEED 3
#define DLLISTDELEGATE_COLUMN_PROGRESS 4
#define DLLISTDELEGATE_COLUMN_SOURCES 5
#define DLLISTDELEGATE_COLUMN_STATUS 6
#define DLLISTDELEGATE_COLUMN_PRIORITY 7
#define DLLISTDELEGATE_COLUMN_REMAINING 8
#define DLLISTDELEGATE_COLUMN_DOWNLOADTIME 9
#define DLLISTDELEGATE_COLUMN_ID 10
#define DLLISTDELEGATE_COLUMN_LASTDL 11
#define DLLISTDELEGATE_COLUMN_PATH 12
#define DLLISTDELEGATE_COLUMN_COUNT 13
#define PRIORITY_NULL 0.0
#define PRIORITY_FASTER 0.1
#define PRIORITY_AVERAGE 0.2
#define PRIORITY_SLOWER 0.3
#define MAX_CHAR_TMP 128
DLListDelegate::DLListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
{
}
@ -69,7 +92,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
// draw the background color if not the progress column or if progress is not displayed
if(index.column() != COLUMN_PROGRESS) {
if(index.column() != DLLISTDELEGATE_COLUMN_PROGRESS) {
if(option.showDecorationSelected && (option.state & QStyle::State_Selected)) {
if(cg == QPalette::Normal && !(option.state & QStyle::State_Active)) {
cg = QPalette::Inactive;
@ -83,7 +106,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
}
switch(index.column()) {
case COLUMN_SIZE:
case DLLISTDELEGATE_COLUMN_SIZE:
fileSize = index.data().toLongLong();
if(fileSize <= 0){
temp = "";
@ -102,7 +125,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_REMAINING:
case DLLISTDELEGATE_COLUMN_REMAINING:
remaining = index.data().toLongLong();
if(remaining <= 0){
temp = "";
@ -121,7 +144,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_COMPLETED:
case DLLISTDELEGATE_COLUMN_COMPLETED:
completed = index.data().toLongLong();
if(completed <= 0){
temp = "";
@ -140,7 +163,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_DLSPEED:
case DLLISTDELEGATE_COLUMN_DLSPEED:
dlspeed = index.data().toDouble();
if (dlspeed <= 0) {
temp = "";
@ -151,7 +174,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_PROGRESS:
case DLLISTDELEGATE_COLUMN_PROGRESS:
{
// create a xProgressBar
FileProgressInfo pinfo = index.data(Qt::UserRole).value<FileProgressInfo>() ;
@ -180,7 +203,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
case COLUMN_SOURCES:
case DLLISTDELEGATE_COLUMN_SOURCES:
{
double dblValue = index.data().toDouble();
@ -188,7 +211,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect, Qt::AlignCenter, temp);
}
break;
case COLUMN_PRIORITY:
case DLLISTDELEGATE_COLUMN_PRIORITY:
{
double dblValue = index.data().toDouble();
if (dblValue == PRIORITY_NULL)
@ -205,7 +228,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect, Qt::AlignCenter, temp);
}
break;
case COLUMN_DOWNLOADTIME:
case DLLISTDELEGATE_COLUMN_DOWNLOADTIME:
downloadtime = index.data().toLongLong();
minutes = downloadtime / 60;
seconds = downloadtime % 60;
@ -225,7 +248,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
temp = "" ;
painter->drawText(option.rect, Qt::AlignCenter, temp);
break;
case COLUMN_NAME:
case DLLISTDELEGATE_COLUMN_NAME:
{
// decoration
int pixOffset = 0;
@ -254,7 +277,7 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->drawText(option.rect.translated(pixOffset, 0), Qt::AlignLeft, temp);
}
break;
case COLUMN_LASTDL:
case DLLISTDELEGATE_COLUMN_LASTDL:
if (index.data().value<QString>().isEmpty())
break;
qi64Value = index.data().value<qint64>();

View File

@ -24,30 +24,6 @@
#include <QAbstractItemDelegate>
#include "xprogressbar.h"
// Defines for download list list columns
#define COLUMN_NAME 0
#define COLUMN_SIZE 1
#define COLUMN_COMPLETED 2
#define COLUMN_DLSPEED 3
#define COLUMN_PROGRESS 4
#define COLUMN_SOURCES 5
#define COLUMN_STATUS 6
#define COLUMN_PRIORITY 7
#define COLUMN_REMAINING 8
#define COLUMN_DOWNLOADTIME 9
#define COLUMN_ID 10
#define COLUMN_LASTDL 11
#define COLUMN_PATH 12
#define COLUMN_COUNT 13
#define PRIORITY_NULL 0.0
#define PRIORITY_FASTER 0.1
#define PRIORITY_AVERAGE 0.2
#define PRIORITY_SLOWER 0.3
#define MAX_CHAR_TMP 128
class QModelIndex;
class QPainter;

View File

@ -25,6 +25,18 @@
Q_DECLARE_METATYPE(FileProgressInfo)
// Defines for upload list list columns
#define ULLISTDELEGATE_COLUMN_UNAME 0
#define ULLISTDELEGATE_COLUMN_UPEER 1
#define ULLISTDELEGATE_COLUMN_USIZE 2
#define ULLISTDELEGATE_COLUMN_UTRANSFERRED 3
#define ULLISTDELEGATE_COLUMN_ULSPEED 4
#define ULLISTDELEGATE_COLUMN_UPROGRESS 5
#define ULLISTDELEGATE_COLUMN_UHASH 6
#define ULLISTDELEGATE_COLUMN_UCOUNT 7
#define MAX_CHAR_TMP 128
ULListDelegate::ULListDelegate(QObject *parent) : QAbstractItemDelegate(parent)
{
;
@ -65,7 +77,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
// draw the background color
bool bDrawBackground = true;
if(index.column() == COLUMN_UPROGRESS) {
if(index.column() == ULLISTDELEGATE_COLUMN_UPROGRESS) {
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
bDrawBackground = (pinfo.type == FileProgressInfo::UNINIT);
}
@ -84,7 +96,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
switch(index.column()) {
case COLUMN_USIZE:
case ULLISTDELEGATE_COLUMN_USIZE:
fileSize = index.data().toLongLong();
if(fileSize <= 0){
temp = "";
@ -103,7 +115,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_UTRANSFERRED:
case ULLISTDELEGATE_COLUMN_UTRANSFERRED:
transferred = index.data().toLongLong();
if(transferred <= 0){
temp = "";
@ -122,7 +134,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_ULSPEED:
case ULLISTDELEGATE_COLUMN_ULSPEED:
ulspeed = index.data().toDouble();
if (ulspeed <= 0) {
temp = "";
@ -133,7 +145,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignRight, temp);
break;
case COLUMN_UPROGRESS:
case ULLISTDELEGATE_COLUMN_UPROGRESS:
{
FileProgressInfo pinfo = index.data().value<FileProgressInfo>() ;
if (pinfo.type == FileProgressInfo::UNINIT)
@ -143,7 +155,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
painter->save() ;
xProgressBar progressBar(pinfo,option.rect,painter,0);// the 3rd param is the color schema (0 is the default value)
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), COLUMN_UNAME).data().toString().toStdString())).suffix();;
QString ext = QFileInfo(QString::fromStdString(index.sibling(index.row(), ULLISTDELEGATE_COLUMN_UNAME).data().toString().toStdString())).suffix();;
if (ext == "rsfc" || ext == "rsrl" || ext == "dist" || ext == "rsfb")
progressBar.setColorSchema( 9);
else
@ -157,8 +169,8 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
}
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
break;
case COLUMN_UNAME:
case COLUMN_UPEER:
case ULLISTDELEGATE_COLUMN_UNAME:
case ULLISTDELEGATE_COLUMN_UPEER:
// decoration
value = index.data(Qt::DecorationRole);
pixmap = qvariant_cast<QIcon>(value).pixmap(option.decorationSize, option.state & QStyle::State_Enabled ? QIcon::Normal : QIcon::Disabled, option.state & QStyle::State_Open ? QIcon::On : QIcon::Off);

View File

@ -23,19 +23,6 @@
#include <QAbstractItemDelegate>
// Defines for upload list list columns
#define COLUMN_UNAME 0
#define COLUMN_UPEER 1
#define COLUMN_USIZE 2
#define COLUMN_UTRANSFERRED 3
#define COLUMN_ULSPEED 4
#define COLUMN_UPROGRESS 5
#define COLUMN_UHASH 6
#define COLUMN_UCOUNT 7
#define MAX_CHAR_TMP 128
class QModelIndex;
class QPainter;

View File

@ -24,6 +24,17 @@
#include <QIcon>
#include <QBrush>
#define IMAGE_AUTHED ":/images/accepted16.png"
#define IMAGE_DENIED ":/images/denied16.png"
#define IMAGE_TRUSTED ":/images/rs-2.png"
#define PGP_ITEM_MODEL_COLUMN_CHECK 0
#define PGP_ITEM_MODEL_COLUMN_PEERNAME 1
#define PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER 2
#define PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME 3
#define PGP_ITEM_MODEL_COLUMN_PEERID 4
#define PGP_ITEM_MODEL_COLUMN_LAST_USED 5
#define PGP_ITEM_MODEL_COLUMN_COUNT 6
/*TODO:
* using list here for internal data storage is not best option
@ -41,22 +52,22 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
{
switch(section)
{
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
return QString(tr(" Do you accept connections signed by this profile?"));
break;
case COLUMN_PEERNAME:
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
return QString(tr("Name of the profile"));
break;
case COLUMN_I_AUTH_PEER:
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
return QString(tr("This column indicates the trust level you indicated and whether you signed the profile PGP key"));
break;
case COLUMN_PEER_AUTH_ME:
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
return QString(tr("Did that peer sign your own profile PGP key"));
break;
case COLUMN_PEERID:
case PGP_ITEM_MODEL_COLUMN_PEERID:
return QString(tr("PGP Key Id of that profile"));
break;
case COLUMN_LAST_USED:
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
return QString(tr("Last time this key was used (received time, or to check connection)"));
break;
}
@ -65,22 +76,22 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
{
switch(section)
{
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
return QString(tr("Connections"));
break;
case COLUMN_PEERNAME:
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
return QString(tr("Profile"));
break;
case COLUMN_I_AUTH_PEER:
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
return QString(tr("Trust level"));
break;
case COLUMN_PEER_AUTH_ME:
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
return QString(tr("Has signed your key?"));
break;
case COLUMN_PEERID:
case PGP_ITEM_MODEL_COLUMN_PEERID:
return QString(tr("Id"));
break;
case COLUMN_LAST_USED:
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
return QString(tr("Last used"));
break;
}
@ -98,13 +109,13 @@ QVariant pgpid_item_model::headerData(int section, Qt::Orientation orientation,
{
switch(section)
{
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
return 25*font_height;
break;
case COLUMN_PEERNAME: case COLUMN_I_AUTH_PEER: case COLUMN_PEER_AUTH_ME:
case PGP_ITEM_MODEL_COLUMN_PEERNAME: case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER: case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
return 200*font_height;
break;
case COLUMN_LAST_USED:
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
return 75*font_height;
break;
}
@ -122,7 +133,7 @@ int pgpid_item_model::rowCount(const QModelIndex &/*parent*/) const
int pgpid_item_model::columnCount(const QModelIndex &/*parent*/) const
{
return COLUMN_COUNT;
return PGP_ITEM_MODEL_COLUMN_COUNT;
}
@ -148,20 +159,20 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
{
switch(index.column())
{
case COLUMN_LAST_USED:
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
return detail.lastUsed;
break;
case COLUMN_I_AUTH_PEER:
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
{
if (detail.ownsign)
return RS_TRUST_LVL_ULTIMATE;
return detail.trustLvl;
}
break;
case COLUMN_PEER_AUTH_ME:
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
return detail.hasSignedMe;
break;
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
return detail.accept_connection;
break;
default:
@ -174,13 +185,13 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
{
switch(index.column())
{
case COLUMN_PEERNAME:
case PGP_ITEM_MODEL_COLUMN_PEERNAME:
return QString::fromUtf8(detail.name.c_str());
break;
case COLUMN_PEERID:
case PGP_ITEM_MODEL_COLUMN_PEERID:
return QString::fromStdString(detail.gpg_id.toStdString());
break;
case COLUMN_I_AUTH_PEER:
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
{
if (detail.ownsign)
return tr("Personal signature");
@ -199,7 +210,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
}
}
break;
case COLUMN_PEER_AUTH_ME:
case PGP_ITEM_MODEL_COLUMN_PEER_AUTH_ME:
{
if (detail.hasSignedMe)
return tr("Yes");
@ -207,7 +218,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
return tr("No");
}
break;
case COLUMN_LAST_USED:
case PGP_ITEM_MODEL_COLUMN_LAST_USED:
{
time_t now = time(NULL);
uint64_t last_time_used = now - detail.lastUsed ;
@ -226,7 +237,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
return lst_used_str;
}
break;
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
{
if (detail.accept_connection || rsPeers->getGPGOwnId() == detail.gpg_id)
return tr("Accepted");
@ -242,7 +253,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
{
switch(index.column())
{
case COLUMN_I_AUTH_PEER:
case PGP_ITEM_MODEL_COLUMN_I_AUTH_PEER:
{
if (detail.ownsign)
return tr("PGP key signed by you");
@ -263,7 +274,7 @@ QVariant pgpid_item_model::data(const QModelIndex &index, int role) const
{
switch(index.column())
{
case COLUMN_CHECK:
case PGP_ITEM_MODEL_COLUMN_CHECK:
{
if (detail.accept_connection)
return QIcon(IMAGE_AUTHED);
@ -345,14 +356,14 @@ void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
break;
if(*i1 != *i2)
{
QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, COLUMN_COUNT-1);
QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, PGP_ITEM_MODEL_COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight);
}
}
}
if(new_size > old_size)
{
QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, COLUMN_COUNT-1);
QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, PGP_ITEM_MODEL_COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight);
}
//dirty solution for initial data fetch

View File

@ -25,20 +25,6 @@
#include <retroshare/rspeers.h>
#include <QColor>
#define IMAGE_AUTHED ":/images/accepted16.png"
#define IMAGE_DENIED ":/images/denied16.png"
#define IMAGE_TRUSTED ":/images/rs-2.png"
#define COLUMN_CHECK 0
#define COLUMN_PEERNAME 1
#define COLUMN_I_AUTH_PEER 2
#define COLUMN_PEER_AUTH_ME 3
#define COLUMN_PEERID 4
#define COLUMN_LAST_USED 5
#define COLUMN_COUNT 6
class pgpid_item_model : public QAbstractTableModel
{
Q_OBJECT

View File

@ -35,12 +35,12 @@ public:
pgpid_item_proxy(QObject *parent = nullptr);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
bool lessThan(const QModelIndex &left, const QModelIndex &right) const override
{
if(left.column() == COLUMN_LAST_USED)
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
else
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
return left.data(Qt::EditRole).toUInt() < right.data(Qt::EditRole).toUInt();
else
return left.data(Qt::DisplayRole).toString().toUpper() < right.data(Qt::DisplayRole).toString().toUpper();
}
public slots:

View File

@ -48,6 +48,15 @@
* #define RDM_SEARCH_DEBUG
****/
#define REMOTEDIRMODEL_COLUMN_NAME 0
#define REMOTEDIRMODEL_COLUMN_FILENB 1
#define REMOTEDIRMODEL_COLUMN_SIZE 2
#define REMOTEDIRMODEL_COLUMN_AGE 3
#define REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS 4
#define REMOTEDIRMODEL_COLUMN_WN_VISU_DIR 5
#define REMOTEDIRMODEL_COLUMN_COUNT 6
#define RETROSHARE_DIR_MODEL_FILTER_STRING "filtered"
static const uint32_t FLAT_VIEW_MAX_REFS_PER_SECOND = 2000 ;
static const size_t FLAT_VIEW_MAX_REFS_TABLE_SIZE = 10000 ; //
static const uint32_t FLAT_VIEW_MIN_DELAY_BETWEEN_UPDATES = 120 ; // dont rebuild ref list more than every 2 mins.
@ -295,11 +304,11 @@ int FlatStyle_RDM::rowCount(const QModelIndex &parent) const
int TreeStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
{
return COLUMN_COUNT;
return REMOTEDIRMODEL_COLUMN_COUNT;
}
int FlatStyle_RDM::columnCount(const QModelIndex &/*parent*/) const
{
return COLUMN_COUNT;
return REMOTEDIRMODEL_COLUMN_COUNT;
}
QString RetroshareDirModel::getFlagsString(FileStorageFlags flags)
@ -416,7 +425,7 @@ QVariant RetroshareDirModel::filterRole(const DirDetails& details, int /*coln*/)
QVariant RetroshareDirModel::decorationRole(const DirDetails& details,int coln) const
{
if(coln == COLUMN_FRIEND_ACCESS)
if(coln == REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS)
{
if(details.type == DIR_TYPE_PERSON) return QVariant() ;
@ -484,7 +493,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
{
switch(coln)
{
case COLUMN_NAME: {
case REMOTEDIRMODEL_COLUMN_NAME: {
//SharedDirStats stats ;
QString res ;
@ -497,7 +506,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return res ;
}
case COLUMN_FILENB: {
case REMOTEDIRMODEL_COLUMN_FILENB: {
SharedDirStats stats ;
if(RemoteMode)
@ -516,7 +525,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
}
return tr("Empty");
}
case COLUMN_SIZE: {
case REMOTEDIRMODEL_COLUMN_SIZE: {
SharedDirStats stats ;
if(RemoteMode)
@ -531,7 +540,7 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
return QString();
}
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
if(!isNewerThanEpoque(details.max_mtime))
return QString();
else if(details.id != rsPeers->getOwnId())
@ -547,13 +556,13 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
{
switch(coln)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
return QString::fromUtf8(details.name.c_str());
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
return QVariant();
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return misc::friendlyUnit(details.size);
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
{
if(details.type == DIR_TYPE_FILE)
return misc::timeRelativeToNow(details.max_mtime);
@ -567,9 +576,9 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
else
return QString();
}
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
return QVariant();
case COLUMN_WN_VISU_DIR:
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
return getGroupsString(details.flags,details.parent_groups) ;
default:
@ -580,22 +589,22 @@ QVariant TreeStyle_RDM::displayRole(const DirDetails& details,int coln) const
{
switch(coln)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
return QString::fromUtf8(details.name.c_str());
break;
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
if (details.children.size() > 1)
{
return QString::number(details.children.size()) + " " + tr("Files");
}
return QString::number(details.children.size()) + " " + tr("File");
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return misc::friendlyUnit(details.size);
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return misc::timeRelativeToNow(details.max_mtime);
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
return QVariant();
case COLUMN_WN_VISU_DIR:
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
return getGroupsString(details.flags,details.parent_groups) ;
default:
@ -650,12 +659,12 @@ QVariant FlatStyle_RDM::displayRole(const DirDetails& details,int coln) const
if (details.type == DIR_TYPE_FILE || details.type == DIR_TYPE_EXTRA_FILE) /* File */
switch(coln)
{
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
case COLUMN_FILENB: return QString();
case COLUMN_SIZE: return misc::friendlyUnit(details.size);
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);
case REMOTEDIRMODEL_COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
case REMOTEDIRMODEL_COLUMN_FILENB: return QString();
case REMOTEDIRMODEL_COLUMN_SIZE: return misc::friendlyUnit(details.size);
case REMOTEDIRMODEL_COLUMN_AGE: return misc::timeRelativeToNow(details.max_mtime);
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: return computeDirectoryPath(details);
default:
return QVariant() ;
}
@ -675,9 +684,9 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
{
switch(coln)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
return (RemoteMode)?(QString::fromUtf8(rsPeers->getPeerName(details.id).c_str())):tr("My files");
case COLUMN_FILENB: {
case REMOTEDIRMODEL_COLUMN_FILENB: {
SharedDirStats stats ;
if(RemoteMode)
@ -687,7 +696,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
return (qulonglong) stats.total_number_of_files;
}
case COLUMN_SIZE: {
case REMOTEDIRMODEL_COLUMN_SIZE: {
SharedDirStats stats ;
if(RemoteMode)
@ -697,7 +706,7 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
return (qulonglong) stats.total_shared_size;
}
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return details.max_mtime;
default:
return QString();
@ -707,17 +716,17 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
{
switch(coln)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
return QString::fromUtf8(details.name.c_str());
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
return (qulonglong) 0;
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return (qulonglong) details.size;
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return details.max_mtime;
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
return getFlagsString(details.flags);
case COLUMN_WN_VISU_DIR:
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
{
QString ind("");
if (ageIndicator != IND_ALWAYS)
@ -732,15 +741,15 @@ QVariant TreeStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
{
switch(coln)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
return QString::fromUtf8(details.name.c_str());
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
return (qulonglong) details.children.size();
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return (qulonglong) 0;
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return details.max_mtime;
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
return getFlagsString(details.flags);
default:
return tr("DIR");
@ -760,12 +769,12 @@ QVariant FlatStyle_RDM::sortRole(const QModelIndex& /*index*/,const DirDetails&
{
switch(coln)
{
case COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
case COLUMN_FILENB: return (qulonglong) 0;
case COLUMN_SIZE: return (qulonglong) details.size;
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: {
case REMOTEDIRMODEL_COLUMN_NAME: return QString::fromUtf8(details.name.c_str());
case REMOTEDIRMODEL_COLUMN_FILENB: return (qulonglong) 0;
case REMOTEDIRMODEL_COLUMN_SIZE: return (qulonglong) details.size;
case REMOTEDIRMODEL_COLUMN_AGE: return details.max_mtime;
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS: return QString::fromUtf8(rsPeers->getPeerName(details.id).c_str());
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR: {
RS_STACK_MUTEX(_ref_mutex) ;
return computeDirectoryPath(details);
@ -793,7 +802,7 @@ QVariant RetroshareDirModel::data(const QModelIndex &index, int role) const
if (role == Qt::TextAlignmentRole)
{
if((coln == COLUMN_FILENB) || (coln == COLUMN_SIZE))
if((coln == REMOTEDIRMODEL_COLUMN_FILENB) || (coln == REMOTEDIRMODEL_COLUMN_SIZE))
return int( Qt::AlignRight | Qt::AlignVCenter);
else
return QVariant();
@ -895,7 +904,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 < COLUMN_AGE)
if (section < REMOTEDIRMODEL_COLUMN_AGE)
{
defw = 200/16.0*defh;
}
@ -909,7 +918,7 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
{
switch(section)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
if (RemoteMode)
if(mUpdating)
return tr("Friends Directories [updating...]");
@ -920,18 +929,18 @@ QVariant TreeStyle_RDM::headerData(int section, Qt::Orientation orientation, int
return tr("My Directories [updating...]");
else
return tr("My Directories");
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
return tr("# Files");
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return tr("Size");
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return tr("Age");
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
if (RemoteMode)
return tr("Friend");
else
return tr("Access");
case COLUMN_WN_VISU_DIR:
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
if (RemoteMode)
return tr("What's new");
else
@ -949,7 +958,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 < COLUMN_AGE)
if (section < REMOTEDIRMODEL_COLUMN_AGE)
{
defw = defh*200/16.0;
}
@ -963,24 +972,24 @@ QVariant FlatStyle_RDM::headerData(int section, Qt::Orientation orientation, int
{
switch(section)
{
case COLUMN_NAME:
case REMOTEDIRMODEL_COLUMN_NAME:
if (RemoteMode)
{
return tr("Friends Directories");
}
return tr("My Directories");
case COLUMN_FILENB:
case REMOTEDIRMODEL_COLUMN_FILENB:
return tr("# Files");
case COLUMN_SIZE:
case REMOTEDIRMODEL_COLUMN_SIZE:
return tr("Size");
case COLUMN_AGE:
case REMOTEDIRMODEL_COLUMN_AGE:
return tr("Age");
case COLUMN_FRIEND_ACCESS:
case REMOTEDIRMODEL_COLUMN_FRIEND_ACCESS:
if(RemoteMode)
return tr("Friend");
else
return tr("Share Flags");
case COLUMN_WN_VISU_DIR:
case REMOTEDIRMODEL_COLUMN_WN_VISU_DIR:
return tr("Directory");
}
return tr("Column %1").arg(section);
@ -1096,7 +1105,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, COLUMN_NAME, details.parent);
return createIndex(details.prow, REMOTEDIRMODEL_COLUMN_NAME, details.parent);
}
QModelIndex FlatStyle_RDM::parent( const QModelIndex & index ) const
{
@ -1167,7 +1176,7 @@ void RetroshareDirModel::postMods()
endResetModel();
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,COLUMN_COUNT-1,(void*)NULL));
emit dataChanged(createIndex(0,0,(void*)NULL), createIndex(rowCount()-1,REMOTEDIRMODEL_COLUMN_COUNT-1,(void*)NULL));
}
void FlatStyle_RDM::postMods()
@ -1340,7 +1349,7 @@ void RetroshareDirModel::getDirDetailsFromSelect (const QModelIndexList &list, s
QModelIndexList::const_iterator it;
for(it = list.begin(); it != list.end(); ++it)
{
if(it->column()==COLUMN_FILENB)
if(it->column()==REMOTEDIRMODEL_COLUMN_FILENB)
{
void *ref = it -> internalPointer();
@ -1377,7 +1386,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()==COLUMN_NAME)
if(it->column()==REMOTEDIRMODEL_COLUMN_NAME)
{
void *ref = it -> internalPointer();
@ -1458,7 +1467,7 @@ void RetroshareDirModel::openSelected(const QModelIndexList &qmil, bool openDir)
void RetroshareDirModel::getFilePath(const QModelIndex& index, std::string& fullpath)
{
void *ref = index.sibling(index.row(),COLUMN_FILENB).internalPointer();
void *ref = index.sibling(index.row(),REMOTEDIRMODEL_COLUMN_FILENB).internalPointer();
DirDetails details ;

View File

@ -32,15 +32,6 @@
#include <stdint.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
#define RETROSHARE_DIR_MODEL_FILTER_STRING "filtered"
struct DirDetails;
class DirDetailsVector : public DirDetails