mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Add Icon in Peer name in DL/UL List
And don't show upload item if no peer.
This commit is contained in:
parent
d9298dcf49
commit
b13d985e58
@ -216,17 +216,33 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
painter->drawText(option.rect, Qt::AlignCenter, temp);
|
||||||
break;
|
break;
|
||||||
case COLUMN_NAME:
|
case COLUMN_NAME:
|
||||||
|
{
|
||||||
// decoration
|
// decoration
|
||||||
|
int pixOffset = 0;
|
||||||
|
value = index.data(Qt::StatusTipRole);
|
||||||
|
temp = index.data().toString();
|
||||||
|
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);
|
||||||
|
pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
||||||
|
if (pixmapRect.isValid()){
|
||||||
|
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
||||||
|
p.setX( p.x() + pixOffset);
|
||||||
|
painter->drawPixmap(p, pixmap);
|
||||||
|
temp = " " + temp;
|
||||||
|
pixOffset += pixmap.size().width();
|
||||||
|
}
|
||||||
value = index.data(Qt::DecorationRole);
|
value = index.data(Qt::DecorationRole);
|
||||||
temp = index.data().toString();
|
temp = index.data().toString();
|
||||||
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);
|
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);
|
||||||
pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
pixmapRect = (pixmap.isNull() ? QRect(0, 0, 0, 0): QRect(QPoint(0, 0), option.decorationSize));
|
||||||
if (pixmapRect.isValid()){
|
if (pixmapRect.isValid()){
|
||||||
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
QPoint p = QStyle::alignedRect(option.direction, Qt::AlignLeft, pixmap.size(), option.rect).topLeft();
|
||||||
|
p.setX( p.x() + pixOffset);
|
||||||
painter->drawPixmap(p, pixmap);
|
painter->drawPixmap(p, pixmap);
|
||||||
temp = " " + temp;
|
temp = " " + temp;
|
||||||
|
pixOffset += pixmap.size().width();
|
||||||
|
}
|
||||||
|
painter->drawText(option.rect.translated(pixOffset, 0), Qt::AlignLeft, temp);
|
||||||
}
|
}
|
||||||
painter->drawText(option.rect.translated(pixmap.size().width(), 0), Qt::AlignLeft, temp);
|
|
||||||
break;
|
break;
|
||||||
case COLUMN_LASTDL:
|
case COLUMN_LASTDL:
|
||||||
if (index.data().value<QString>().isEmpty())
|
if (index.data().value<QString>().isEmpty())
|
||||||
|
@ -90,6 +90,9 @@
|
|||||||
#define IMAGE_MYFILES ":icons/svg/folders1.svg"
|
#define IMAGE_MYFILES ":icons/svg/folders1.svg"
|
||||||
#define IMAGE_RENAMEFILE ":images/filecomments.png"
|
#define IMAGE_RENAMEFILE ":images/filecomments.png"
|
||||||
#define IMAGE_STREAMING ":images/streaming.png"
|
#define IMAGE_STREAMING ":images/streaming.png"
|
||||||
|
#define IMAGE_TUNNEL_ANON_E2E ":/images/blue_lock.png"
|
||||||
|
#define IMAGE_TUNNEL_ANON ":/images/blue_lock_open.png"
|
||||||
|
#define IMAGE_TUNNEL_FRIEND ":/icons/avatar_128.png"
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(FileProgressInfo)
|
Q_DECLARE_METATYPE(FileProgressInfo)
|
||||||
|
|
||||||
@ -1016,7 +1019,6 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
|
|||||||
{
|
{
|
||||||
const TransferInfo &transferInfo = *pit;
|
const TransferInfo &transferInfo = *pit;
|
||||||
|
|
||||||
QString peerName = getPeerName(transferInfo.peerId);
|
|
||||||
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
//unique combination: fileHash + peerId, variant: hash + peerName (too long)
|
||||||
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
|
QString hashFileAndPeerId = fileHash + QString::fromStdString(transferInfo.peerId.toStdString());
|
||||||
|
|
||||||
@ -1030,7 +1032,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
|
|||||||
peerpinfo.progress = 0.0; // we don't display completion for sources.
|
peerpinfo.progress = 0.0; // we don't display completion for sources.
|
||||||
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
|
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
|
||||||
|
|
||||||
int row_id = addPeerToDLItem(dlItem, peerName, hashFileAndPeerId, peerDlspeed, transferInfo.status, peerpinfo);
|
int row_id = addPeerToDLItem(dlItem, transferInfo.peerId, hashFileAndPeerId, peerDlspeed, transferInfo.status, peerpinfo);
|
||||||
|
|
||||||
used_rows.insert(row_id);
|
used_rows.insert(row_id);
|
||||||
|
|
||||||
@ -1055,7 +1057,7 @@ int TransfersDialog::addDLItem(int row, const FileInfo &fileInfo)
|
|||||||
return row;
|
return row;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo)
|
int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const RsPeerId& peer_ID, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo)
|
||||||
{
|
{
|
||||||
// try to find the item
|
// try to find the item
|
||||||
int childRow = -1;
|
int childRow = -1;
|
||||||
@ -1095,7 +1097,11 @@ int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const QString& name,
|
|||||||
siStatus = iStatus;
|
siStatus = iStatus;
|
||||||
|
|
||||||
QList<QStandardItem*> items;
|
QList<QStandardItem*> items;
|
||||||
iName->setData(QVariant(" " + name), Qt::DisplayRole);
|
QString iconName;
|
||||||
|
QString tooltip;
|
||||||
|
iName->setData(QVariant(getPeerName(peer_ID, iconName, tooltip)), Qt::DisplayRole);
|
||||||
|
iName->setData(QIcon(iconName), Qt::DecorationRole);
|
||||||
|
iName->setData(QVariant(tooltip), Qt::ToolTipRole);
|
||||||
iSize->setData(QVariant(QString()), Qt::DisplayRole);
|
iSize->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
iCompleted->setData(QVariant(QString()), Qt::DisplayRole);
|
iCompleted->setData(QVariant(QString()), Qt::DisplayRole);
|
||||||
iDlSpeed->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
iDlSpeed->setData(QVariant((double)dlspeed), Qt::DisplayRole);
|
||||||
@ -1140,27 +1146,27 @@ int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const QString& name,
|
|||||||
switch (status) {
|
switch (status) {
|
||||||
case FT_STATE_FAILED:
|
case FT_STATE_FAILED:
|
||||||
siStatus->setData(QVariant(tr("Failed"))) ;
|
siStatus->setData(QVariant(tr("Failed"))) ;
|
||||||
siName->setData(QIcon(":/images/Client1.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client1.png"), Qt::StatusTipRole);
|
||||||
break ;
|
break ;
|
||||||
case FT_STATE_OKAY:
|
case FT_STATE_OKAY:
|
||||||
siStatus->setData(QVariant(tr("Okay")));
|
siStatus->setData(QVariant(tr("Okay")));
|
||||||
siName->setData(QIcon(":/images/Client2.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client2.png"), Qt::StatusTipRole);
|
||||||
break ;
|
break ;
|
||||||
case FT_STATE_WAITING:
|
case FT_STATE_WAITING:
|
||||||
siStatus->setData(QVariant(tr("")));
|
siStatus->setData(QVariant(tr("")));
|
||||||
siName->setData(QIcon(":/images/Client3.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client3.png"), Qt::StatusTipRole);
|
||||||
break ;
|
break ;
|
||||||
case FT_STATE_DOWNLOADING:
|
case FT_STATE_DOWNLOADING:
|
||||||
siStatus->setData(QVariant(tr("Transferring")));
|
siStatus->setData(QVariant(tr("Transferring")));
|
||||||
siName->setData(QIcon(":/images/Client0.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client0.png"), Qt::StatusTipRole);
|
||||||
break ;
|
break ;
|
||||||
case FT_STATE_COMPLETE:
|
case FT_STATE_COMPLETE:
|
||||||
siStatus->setData(QVariant(tr("Complete")));
|
siStatus->setData(QVariant(tr("Complete")));
|
||||||
siName->setData(QIcon(":/images/Client0.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client0.png"), Qt::StatusTipRole);
|
||||||
break ;
|
break ;
|
||||||
default:
|
default:
|
||||||
siStatus->setData(QVariant(tr("")));
|
siStatus->setData(QVariant(tr("")));
|
||||||
siName->setData(QIcon(":/images/Client4.png"), Qt::DecorationRole);
|
siName->setData(QIcon(":/images/Client4.png"), Qt::StatusTipRole);
|
||||||
}
|
}
|
||||||
|
|
||||||
return childRow;
|
return childRow;
|
||||||
@ -1168,6 +1174,9 @@ int TransfersDialog::addPeerToDLItem(QStandardItem *dlItem, const QString& name,
|
|||||||
|
|
||||||
int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
||||||
{
|
{
|
||||||
|
if (fileInfo.peers.empty())
|
||||||
|
return -1; //No Peers, nothing to do.
|
||||||
|
|
||||||
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
QString fileHash = QString::fromStdString(fileInfo.hash.toStdString());
|
||||||
|
|
||||||
RsPeerId ownId = rsPeers->getOwnId();
|
RsPeerId ownId = rsPeers->getOwnId();
|
||||||
@ -1192,7 +1201,9 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
|||||||
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
ULListModel->setData(ULListModel->index(row, COLUMN_USIZE), QVariant((qlonglong)fileSize));
|
||||||
|
|
||||||
//Reset Parent info if child present
|
//Reset Parent info if child present
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(QString::number(fileInfo.peers.size())));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(QString(tr("%1 tunnels").arg(fileInfo.peers.size()))) );
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(), Qt::DecorationRole);
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(), Qt::ToolTipRole);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant());
|
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant());
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant());
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant());
|
||||||
|
|
||||||
@ -1243,7 +1254,11 @@ int TransfersDialog::addULItem(int row, const FileInfo &fileInfo)
|
|||||||
if (bOnlyOne)
|
if (bOnlyOne)
|
||||||
{
|
{
|
||||||
//Only one peer so update parent
|
//Only one peer so update parent
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId)));
|
QString iconName;
|
||||||
|
QString tooltip;
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(getPeerName(transferInfo.peerId, iconName, tooltip)));
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QIcon(iconName), Qt::DecorationRole);
|
||||||
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPEER), QVariant(tooltip), Qt::ToolTipRole);
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant(completed));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UTRANSFERRED), QVariant(completed));
|
||||||
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
|
ULListModel->setData(ULListModel->index(row, COLUMN_UPROGRESS), QVariant::fromValue(peerpinfo));
|
||||||
} else {
|
} else {
|
||||||
@ -1300,7 +1315,11 @@ int TransfersDialog::addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer
|
|||||||
|
|
||||||
QList<QStandardItem*> items;
|
QList<QStandardItem*> items;
|
||||||
iName->setData( QVariant(QString()), Qt::DisplayRole);
|
iName->setData( QVariant(QString()), Qt::DisplayRole);
|
||||||
iPeer->setData( QVariant(getPeerName(peer_ID)), Qt::DisplayRole);
|
QString iconName;
|
||||||
|
QString tooltip;
|
||||||
|
iPeer->setData( QVariant(getPeerName(peer_ID, iconName, tooltip)), Qt::DisplayRole);
|
||||||
|
iPeer->setData( QIcon(iconName), Qt::DecorationRole);
|
||||||
|
iPeer->setData( QVariant(tooltip), Qt::ToolTipRole);
|
||||||
iSize->setData( QVariant(QString()), Qt::DisplayRole);
|
iSize->setData( QVariant(QString()), Qt::DisplayRole);
|
||||||
iTransferred->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
iTransferred->setData(QVariant((qlonglong)completed), Qt::DisplayRole);
|
||||||
iULSpeed->setData( QVariant((double)ulspeed), Qt::DisplayRole);
|
iULSpeed->setData( QVariant((double)ulspeed), Qt::DisplayRole);
|
||||||
@ -1472,21 +1491,29 @@ void TransfersDialog::insertTransfers()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TransfersDialog::getPeerName(const RsPeerId& id) const
|
QString TransfersDialog::getPeerName(const RsPeerId& id, QString &iconName, QString &tooltip) const
|
||||||
{
|
{
|
||||||
QString res = QString::fromUtf8(rsPeers->getPeerName(id).c_str()) ;
|
QString res = QString::fromUtf8(rsPeers->getPeerName(id).c_str()) ;
|
||||||
|
|
||||||
// This is because turtle tunnels have no name (I didn't want to bother with
|
// csoler 2009-06-03: This is because turtle tunnels have no name (I didn't want to bother with
|
||||||
// connect mgr). In such a case their id can suitably hold for a name.
|
// connect mgr). In such a case their id can suitably hold for a name.
|
||||||
//
|
//
|
||||||
if(res == "")
|
if(res == "")
|
||||||
{
|
{
|
||||||
if(rsFiles->isEncryptedSource(id))
|
if(rsFiles->isEncryptedSource(id))
|
||||||
return tr("Anonymous end-to-end encrypted tunnel 0x")+QString::fromStdString(id.toStdString()).left(8) ;
|
{
|
||||||
else
|
iconName = IMAGE_TUNNEL_ANON_E2E;
|
||||||
return tr("Anonymous tunnel 0x")+QString::fromStdString(id.toStdString()).left(8) ;
|
tooltip = tr("Anonymous end-to-end encrypted tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
|
||||||
|
return tr("Tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
iconName = IMAGE_TUNNEL_ANON;
|
||||||
|
tooltip = tr("Anonymous tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
|
||||||
|
return tr("Tunnel 0x")+QString::fromStdString(id.toStdString()).left(8);
|
||||||
|
}
|
||||||
|
|
||||||
|
iconName = IMAGE_TUNNEL_FRIEND;
|
||||||
|
tooltip = res;
|
||||||
return res ;
|
return res ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ signals:
|
|||||||
void playFiles(QStringList files);
|
void playFiles(QStringList files);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getPeerName(const RsPeerId &peer_id) const ;
|
QString getPeerName(const RsPeerId &peer_id, QString &iconName, QString &tooltip) const ;
|
||||||
|
|
||||||
QStandardItemModel *DLListModel;
|
QStandardItemModel *DLListModel;
|
||||||
QSortFilterProxyModel *DLLFilterModel;
|
QSortFilterProxyModel *DLLFilterModel;
|
||||||
@ -261,9 +261,9 @@ private:
|
|||||||
public slots:
|
public slots:
|
||||||
// these four functions add entries to the transfers dialog, and return the row id of the entry modified/added
|
// these four functions add entries to the transfers dialog, and return the row id of the entry modified/added
|
||||||
int addDLItem(int row, const FileInfo &fileInfo);
|
int addDLItem(int row, const FileInfo &fileInfo);
|
||||||
int addPeerToDLItem(QStandardItem *dlItem, const QString& name, const QString& coreID, double dlspeed, uint32_t status, const FileProgressInfo& peerInfo);
|
int addPeerToDLItem(QStandardItem* dlItem, const RsPeerId &peer_ID, const QString &coreID, double dlspeed, uint32_t status, const FileProgressInfo &peerInfo);
|
||||||
int addULItem(int row, const FileInfo &fileInfo);
|
int addULItem(int row, const FileInfo &fileInfo);
|
||||||
int addPeerToULItem(QStandardItem *ulItem, const RsPeerId& peer_ID, const QString &coreID, qlonglong completed, double ulspeed, const FileProgressInfo& peerInfo);
|
int addPeerToULItem(QStandardItem* ulItem, const RsPeerId &peer_ID, const QString &coreID, qlonglong completed, double ulspeed, const FileProgressInfo &peerInfo);
|
||||||
|
|
||||||
void showFileDetails() ;
|
void showFileDetails() ;
|
||||||
|
|
||||||
|
@ -159,6 +159,7 @@ void ULListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti
|
|||||||
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
painter->drawText(option.rect, Qt::AlignCenter, newopt.text);
|
||||||
break;
|
break;
|
||||||
case COLUMN_UNAME:
|
case COLUMN_UNAME:
|
||||||
|
case COLUMN_UPEER:
|
||||||
// decoration
|
// decoration
|
||||||
value = index.data(Qt::DecorationRole);
|
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);
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user