- put FileTransferInfoWidget into DetailsDialog, in replacement of previous information display

- corrected bug with DetailsDialog auto-deleting itself when closed
- made TransferDialog a single tab widget. Gives more room to each of the tabs, especially search.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-ImprovedGUI@6135 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-02-20 23:09:05 +00:00
parent 130e7eb7d7
commit de8b10bd01
7 changed files with 292 additions and 899 deletions

View file

@ -20,11 +20,15 @@
****************************************************************/
#include <QStandardItemModel>
#include <QClipboard>
#include "DetailsDialog.h"
#include "TransfersDialog.h"
#include "retroshare/rsfiles.h"
#include "util/misc.h"
#include "FileTransferInfoWidget.h"
#include "RetroShareLink.h"
/** Default constructor */
DetailsDialog::DetailsDialog(QWidget *parent, Qt::WFlags flags)
@ -33,42 +37,52 @@ DetailsDialog::DetailsDialog(QWidget *parent, Qt::WFlags flags)
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
CommentsModel = new QStandardItemModel(0, 3);
CommentsModel->setHeaderData(0, Qt::Horizontal, tr("Rating"));
CommentsModel->setHeaderData(1, Qt::Horizontal, tr("Comments"));
CommentsModel->setHeaderData(2, Qt::Horizontal, tr("File Name"));
ui.commentsTreeView->setModel(CommentsModel);
ui.commentsTreeView->setSortingEnabled(true);
ui.commentsTreeView->setRootIsDecorated(false);
/* Set header resize modes and initial section sizes */
QHeaderView * _coheader = ui.commentsTreeView->header();
_coheader->setResizeMode ( 0, QHeaderView::Custom);
_coheader->resizeSection ( 0, 100 );
_coheader->resizeSection ( 1, 240 );
_coheader->resizeSection ( 2, 100 );
setAttribute ( Qt::WA_DeleteOnClose, true );
CommentsModel = new QStandardItemModel(0, 3);
CommentsModel->setHeaderData(0, Qt::Horizontal, tr("Rating"));
CommentsModel->setHeaderData(1, Qt::Horizontal, tr("Comments"));
CommentsModel->setHeaderData(2, Qt::Horizontal, tr("File Name"));
//ui.commentsTreeView->setModel(CommentsModel);
//ui.commentsTreeView->setSortingEnabled(true);
//ui.commentsTreeView->setRootIsDecorated(false);
/* Set header resize modes and initial section sizes */
//QHeaderView * _coheader = ui.commentsTreeView->header();
//_coheader->setResizeMode ( 0, QHeaderView::Custom);
//_coheader->resizeSection ( 0, 100 );
//_coheader->resizeSection ( 1, 240 );
//_coheader->resizeSection ( 2, 100 );
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
ui.fileTransferInfoWidget->setWidget(ftiw);
ui.fileTransferInfoWidget->setWidgetResizable(true);
ui.fileTransferInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui.fileTransferInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui.fileTransferInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
ui.fileTransferInfoWidget->setFrameStyle(QFrame::NoFrame);
ui.fileTransferInfoWidget->setFocusPolicy(Qt::NoFocus);
setAttribute(Qt::WA_DeleteOnClose,false) ;
connect(ui.copylinkdetailsButton,SIGNAL(clicked()),this,SLOT(copyLink())) ;
}
/** Destructor. */
DetailsDialog::~DetailsDialog()
void DetailsDialog::copyLink()
{
TransfersDialog::detailsdlg = NULL;
QApplication::clipboard()->setText( ui.Linktext->toPlainText() );
}
void DetailsDialog::on_ok_dButton_clicked()
{
QDialog::close();
QDialog::hide();
}
void DetailsDialog::on_cancel_dButton_clicked()
{
//reject();
QDialog::close();
QDialog::hide();
}
@ -85,101 +99,17 @@ DetailsDialog::show()
}
}
void DetailsDialog::closeEvent (QCloseEvent * event)
void DetailsDialog::setFileHash(const std::string & hash)
{
QWidget::closeEvent(event);
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash(hash) ;
FileInfo nfo ;
if(!rsFiles->FileDetails(hash, RS_FILE_HINTS_DOWNLOAD, nfo))
return ;
RetroShareLink link ;
link.createFile(QString::fromStdString(nfo.fname),nfo.size,QString::fromStdString(nfo.hash)) ;
ui.Linktext->setText(link.toString()) ;
}
void DetailsDialog::setFileName(const QString & filename)
{
int c;
QModelIndex index;
c = CommentsModel->rowCount();
CommentsModel->removeRows(0,c);
c = CommentsModel->rowCount();
CommentsModel->insertRow(c);
index = CommentsModel->index(c, 0);
CommentsModel->setData(index, tr("Not Rated"));
index = CommentsModel->index(c, 1);
CommentsModel->setData(index, tr("No Comments"));
index = CommentsModel->index(c, 2);
CommentsModel->setData(index, filename);
ui.name_label_2->setText(filename);
}
void DetailsDialog::setHash(const QString & hash)
{
ui.hash_label_2->setText(hash);
}
void DetailsDialog::setSize(const qulonglong & size)
{
ui.size_label_2->setText(misc::friendlyUnit(size) + " " + "(" + QString::number(size) + " " + "Bytes" + ")");
}
void DetailsDialog::setStatus(const QString & status)
{
ui.status_label_2->setText(status);
}
void DetailsDialog::setPriority(const QString & priority)
{
ui.priority_label_2->setText(priority);
}
void DetailsDialog::setType(const QString & type)
{
ui.type_label_2->setText(type);
}
void DetailsDialog::setSources(const QString & sources)
{
ui.sources_line->setText(sources);
}
void DetailsDialog::setDatarate(const double & datarate)
{
QString temp;
temp.clear();
temp.sprintf("%.2f", datarate/1024.);
temp += " KB/s";
ui.datarate_line->setText(temp);
}
void DetailsDialog::setCompleted(const QString & completed)
{
ui.completed_line->setText(completed);
}
void DetailsDialog::setRemaining(const QString & remaining)
{
ui.remaining_line->setText(remaining);
}
void DetailsDialog::setDownloadtime(const QString & downloadtime)
{
ui.downloadtime_line->setText(downloadtime);
}
void DetailsDialog::setLink(const QString & link)
{
ui.Linktext->setText(link);
}
void DetailsDialog::setChunkSize(uint32_t chunksize)
{
ui.chunksizelabel->setText(misc::friendlyUnit(chunksize));
}
void DetailsDialog::setNumberOfChunks(size_t numberofchunks)
{
ui.numberofchunkslabel->setText(QString::number(numberofchunks));
}

View file

@ -35,32 +35,14 @@ public:
/** Default constructor */
DetailsDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
~DetailsDialog();
~DetailsDialog() {}
void setFileHash(const std::string& hash) { _file_hash = hash ; }
void setFileHash(const std::string& hash) ;
public slots:
/** Overloaded QWidget.show */
void show();
void setFileName(const QString & filename);
void setHash(const QString & hash);
void setLink(const QString & link);
void setSize(const qulonglong & size);
void setStatus(const QString & status);
void setPriority(const QString & priority);
void setSources(const QString & sources);
void setDatarate(const double & datarate);
void setCompleted(const QString & completed);
void setRemaining(const QString & remaining) ;
void setDownloadtime(const QString & downloadtime);
void setType(const QString & type);
void setChunkSize(const uint32_t chunksize);
void setNumberOfChunks(const size_t numberofchunks);
protected:
void closeEvent (QCloseEvent * event);
void copyLink() ;
private slots:
void on_ok_dButton_clicked();

View file

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>477</height>
<width>787</width>
<height>644</height>
</rect>
</property>
<property name="windowTitle">
@ -21,348 +21,143 @@
<item row="0" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabGeneral">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/fileinfo.png</normaloff>:/images/fileinfo.png</iconset>
<normaloff>:/images/blockdevice.png</normaloff>:/images/blockdevice.png</iconset>
</attribute>
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QGroupBox" name="genralgroupBox">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="name_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>File Name:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="name_label_2">
<property name="text">
<string notr="true">Name Label</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="7">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>336</width>
<height>98</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="hash_label">
<property name="maximumSize">
<size>
<width>1677215</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Hash:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="size_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Size:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="size_label_2">
<property name="text">
<string notr="true">Size Label</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="status_label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Status:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="status_label_2">
<property name="text">
<string notr="true">Status Label</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="priority_label">
<property name="text">
<string>Priority:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="priority_label_2">
<property name="text">
<string notr="true">Priority Label</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="type_label_2">
<property name="text">
<string notr="true">Type Label</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="type_label">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="hash_label_2">
<property name="text">
<string notr="true">Hash Label</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Transfer</string>
<layout class="QGridLayout" name="_2">
<property name="margin">
<number>6</number>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="sources_label">
<property name="text">
<string>Sources:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="datarate_label">
<property name="text">
<string>Datarate:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="completed_label">
<property name="text">
<string>Completed:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="sources_line">
<property name="text">
<string notr="true">Source Label</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="datarate_line">
<property name="text">
<string notr="true">Datarate Label</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="completed_line">
<property name="text">
<string notr="true">Completed Label</string>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="7">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLabel" name="chunksizelabel">
<property name="text">
<string notr="true">Chunks Label</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Chunk size:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="numberofchunkslabel">
<property name="toolTip">
<string>Number of Chunks</string>
</property>
<property name="text">
<string notr="true">Chunks Number Label</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Number of Chunks</string>
</property>
<property name="text">
<string>Chunks:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="remaining_line">
<property name="text">
<string notr="true">Remaining Label</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="remaining_label">
<property name="text">
<string>Remaining:</string>
</property>
</widget>
</item>
</layout>
</widget>
<item row="0" column="0">
<layout class="QGridLayout" name="_3">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-downloaded.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout" name="_4">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-downloading.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<layout class="QGridLayout" name="_5">
<item row="0" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-notdownload.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Outstanding</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>368</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-checking.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Needs checking</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item row="2" column="0">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Date</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Download time:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="downloadtime_line">
<property name="text">
<string notr="true">Download Time Label</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>274</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabComments">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/filecomments.png</normaloff>:/images/filecomments.png</iconset>
</attribute>
<attribute name="title">
<string>Comments</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTreeView" name="commentsTreeView"/>
<widget class="QScrollArea" name="fileTransferInfoWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>747</width>
<height>505</height>
</rect>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
@ -374,35 +169,22 @@
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>retroshare link(s)</string>
<string>retroshare link</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QTextEdit" name="Linktext"/>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="copylinkdetailsButton">
<property name="text">
<string>Copy link to clipboard</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>351</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="copylinkdetailsButton">
<property name="text">
<string>Copy</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>

View file

@ -28,6 +28,7 @@
#include <retroshare/rstypes.h>
#include "util/misc.h"
#include "FileTransferInfoWidget.h"
#include "RetroShareLink.h"
// Variables to decide of display behaviour. Should be adapted to window size.
//
@ -110,7 +111,7 @@ void FileTransferInfoWidget::paintEvent(QPaintEvent */*event*/)
void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info,QPainter *painter)
{
x=0;
y=0;
y=5;
int blocks = info.chunks.size() ;
uint64_t fileSize = info.file_size ;
uint32_t blockSize = info.chunk_size ;
@ -240,10 +241,11 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info
// various info:
//
painter->setPen(QColor::fromRgb(0,0,0)) ;
y += text_height ; painter->drawText(0,y,tr("File info") + ":") ;
y += block_sep ;
y += text_height ; painter->drawText(20,y,tr("File name") + ":") ; painter->drawText(tab_size,y,QString::fromStdString(nfo.fname)) ;
y += block_sep ;
y += text_height ; painter->drawText(20,y,tr("File hash") + ":") ; painter->drawText(tab_size,y,QString::fromStdString(nfo.hash)) ;
y += block_sep ;
y += text_height ; painter->drawText(20,y,tr("File size") + ":") ; painter->drawText(tab_size,y,QString::number(info.file_size) + " " + tr("bytes") + " " + "(" + misc::friendlyUnit(info.file_size) + ")") ;

View file

@ -66,6 +66,7 @@
/* Images for context menu icons */
#define IMAGE_INFO ":/images/fileinfo.png"
#define IMAGE_CANCEL ":/images/delete.png"
#define IMAGE_LIBRARY ":/images/library.png"
#define IMAGE_CLEARCOMPLETED ":/images/deleteall.png"
#define IMAGE_PLAY ":/images/player_play.png"
#define IMAGE_COPYLINK ":/images/copyrslink.png"
@ -85,8 +86,6 @@
Q_DECLARE_METATYPE(FileProgressInfo)
DetailsDialog *TransfersDialog::detailsdlg = NULL;
class SortByNameItem : public QStandardItem
{
public:
@ -293,19 +292,19 @@ TransfersDialog::TransfersDialog(QWidget *parent)
// set default column and sort order for upload
ui.uploadsList->sortByColumn(UNAME, Qt::AscendingOrder);
FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
ui.fileTransferInfoWidget->setWidget(ftiw);
ui.fileTransferInfoWidget->setWidgetResizable(true);
ui.fileTransferInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui.fileTransferInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
ui.fileTransferInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
ui.fileTransferInfoWidget->setFrameStyle(QFrame::NoFrame);
ui.fileTransferInfoWidget->setFocusPolicy(Qt::NoFocus);
// FileTransferInfoWidget *ftiw = new FileTransferInfoWidget();
// ui.fileTransferInfoWidget->setWidget(ftiw);
// ui.fileTransferInfoWidget->setWidgetResizable(true);
// ui.fileTransferInfoWidget->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// ui.fileTransferInfoWidget->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
// ui.fileTransferInfoWidget->viewport()->setBackgroundRole(QPalette::NoRole);
// ui.fileTransferInfoWidget->setFrameStyle(QFrame::NoFrame);
// ui.fileTransferInfoWidget->setFocusPolicy(Qt::NoFocus);
QObject::connect(ui.downloadList->selectionModel(),SIGNAL(selectionChanged (const QItemSelection&, const QItemSelection&)),this,SLOT(showFileDetails())) ;
ui.tabWidget->insertTab(0,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ;
ui.tabWidget->insertTab(1,remoteSharedFiles = new RemoteSharedFilesDialog(), QIcon(IMAGE_SEARCH), tr("Friends files")) ;
ui.tabWidget->insertTab(2,searchDialog = new SearchDialog(), QIcon(IMAGE_SEARCH), tr("Search")) ;
ui.tabWidget->insertTab(3,remoteSharedFiles = new RemoteSharedFilesDialog(), QIcon(IMAGE_SEARCH), tr("Friends files")) ;
ui.tabWidget->addTab(localSharedFiles = new LocalSharedFilesDialog(), QIcon(IMAGE_SEARCH), tr("Your files")) ;
@ -332,10 +331,14 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif
QObject::connect(ui._showCacheTransfers_CB,SIGNAL(toggled(bool)),this,SLOT(insertTransfers())) ;
QObject::connect(ui.openCollection, SIGNAL(clicked()), this, SLOT(openCollection()));
toggleShowCacheTransfersAct = new QAction(tr( "Show cache transfers" ), this );
toggleShowCacheTransfersAct->setCheckable(true) ;
connect(toggleShowCacheTransfersAct,SIGNAL(triggered()),this,SLOT(toggleShowCacheTransfers())) ;
// Actions. Only need to be defined once.
openCollectionAct = new QAction(QIcon(IMAGE_LIBRARY), tr( "Download from collection file..." ), this );
connect(openCollectionAct, SIGNAL(triggered()), this, SLOT(openCollection()));
// Actions. Only need to be defined once.
pauseAct = new QAction(QIcon(IMAGE_PAUSE), tr("Pause"), this);
connect(pauseAct, SIGNAL(triggered()), this, SLOT(pauseFileTransfer()));
@ -410,6 +413,12 @@ UserNotify *TransfersDialog::getUserNotify(QObject *parent)
return new TransferUserNotify(parent);
}
void TransfersDialog::toggleShowCacheTransfers()
{
_show_cache_transfers = !_show_cache_transfers ;
insertTransfers() ;
}
void TransfersDialog::processSettings(bool bLoad)
{
m_bProcessSettings = true;
@ -423,14 +432,14 @@ void TransfersDialog::processSettings(bool bLoad)
// load settings
// state of checks
ui._showCacheTransfers_CB->setChecked(Settings->value("showCacheTransfers", false).toBool());
_show_cache_transfers = Settings->value("showCacheTransfers", false).toBool();
// state of the lists
DLHeader->restoreState(Settings->value("downloadList").toByteArray());
ULHeader->restoreState(Settings->value("uploadList").toByteArray());
// state of splitter
ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
// ui.splitter->restoreState(Settings->value("Splitter").toByteArray());
// selected tab
ui.tabWidget->setCurrentIndex(Settings->value("selectedTab").toInt());
@ -438,14 +447,14 @@ void TransfersDialog::processSettings(bool bLoad)
// save settings
// state of checks
Settings->setValue("showCacheTransfers", ui._showCacheTransfers_CB->isChecked());
Settings->setValue("showCacheTransfers", _show_cache_transfers);
// state of the lists
Settings->setValue("downloadList", DLHeader->saveState());
Settings->setValue("uploadList", ULHeader->saveState());
// state of splitter
Settings->setValue("Splitter", ui.splitter->saveState());
// Settings->setValue("Splitter", ui.splitter->saveState());
// selected tab
Settings->setValue("selectedTab", ui.tabWidget->currentIndex());
@ -611,6 +620,12 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint /*point*/ )
contextMnu.addSeparator();
contextMnu.addAction( toggleShowCacheTransfersAct ) ;
toggleShowCacheTransfersAct->setChecked(_show_cache_transfers) ;
contextMnu.addAction( openCollectionAct ) ;
contextMnu.addSeparator();
contextMnu.exec(QCursor::pos());
}
@ -913,8 +928,6 @@ void TransfersDialog::insertTransfers()
std::list<std::string> downHashes;
rsFiles->FileDownloads(downHashes);
bool showCacheTransfers = ui._showCacheTransfers_CB->isChecked();
/* get only once */
std::map<std::string, std::string> versions;
rsDisc->getDiscVersions(versions);
@ -950,7 +963,7 @@ void TransfersDialog::insertTransfers()
continue;
}
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !_show_cache_transfers) {
// if file transfer is a cache file index file, don't show it
DLListModel->removeRow(row);
rowCount = DLListModel->rowCount();
@ -976,7 +989,7 @@ void TransfersDialog::insertTransfers()
continue;
}
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !showCacheTransfers) {
if ((fileInfo.transfer_info_flags & RS_FILE_REQ_CACHE) && !_show_cache_transfers) {
//if file transfer is a cache file index file, don't show it
continue;
}
@ -1003,7 +1016,7 @@ void TransfersDialog::insertTransfers()
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info))
continue;
if((info.transfer_info_flags & RS_FILE_REQ_CACHE) && showCacheTransfers)
if((info.transfer_info_flags & RS_FILE_REQ_CACHE) && _show_cache_transfers)
continue ;
std::list<TransferInfo>::iterator pit;
@ -1175,39 +1188,23 @@ void TransfersDialog::copyLink ()
RSLinkClipboard::copyLinks(links) ;
}
DetailsDialog *TransfersDialog::detailsDialog()
{
static DetailsDialog *detailsdlg = new DetailsDialog ;
return detailsdlg ;
}
void TransfersDialog::showDetailsDialog()
{
if (detailsdlg == NULL) {
// create window
detailsdlg = new DetailsDialog ();
}
updateDetailsDialog ();
detailsdlg->show();
detailsDialog()->show();
}
void TransfersDialog::updateDetailsDialog()
{
if (detailsdlg == NULL) {
return;
}
std::string file_hash ;
QString fhash;
QString fsize;
QString fname;
QString fstatus;
QString fpriority;
QString fsources;
qulonglong filesize = 0;
double fdatarate = 0;
qulonglong fcompleted = 0;
qulonglong fremaining = 0;
qulonglong fdownloadtime = 0;
std::set<int> rows;
std::set<int>::iterator it;
getSelectedItems(NULL, &rows);
@ -1215,84 +1212,10 @@ void TransfersDialog::updateDetailsDialog()
if (rows.size()) {
int row = *rows.begin();
fhash = getID(row, DLListModel);
fsize = getFileSize(row, DLListModel);
fname = getFileName(row, DLListModel);
fstatus = getStatus(row, DLListModel);
fpriority = getPriority(row, DLListModel);
fsources = getSources(row, DLListModel);
filesize = getFileSize(row, DLListModel);
fdatarate = getSpeed(row, DLListModel);
fcompleted = getTransfered(row, DLListModel);
fremaining = getRemainingTime(row, DLListModel);
fdownloadtime = getDownloadTime(row, DLListModel);
// maybe show all links in retroshare link(s) Tab
// int nb_select = 0 ;
//
// for(int i = 0; i <= DLListModel->rowCount(); i++)
// if(selection->isRowSelected(i, QModelIndex()))
// {
// file_hash = getID(i, DLListModel).toStdString();
// ++nb_select ;
// }
file_hash = getID(row, DLListModel).toStdString();
}
detailsdlg->setFileHash(file_hash);
// Set Details.. Window Title
detailsdlg->setWindowTitle(tr("Details:") + fname);
// General GroupBox
detailsdlg->setHash(fhash);
detailsdlg->setFileName(fname);
detailsdlg->setSize(filesize);
detailsdlg->setStatus(fstatus);
detailsdlg->setPriority(fpriority);
detailsdlg->setType(QFileInfo(fname).suffix());
// Transfer GroupBox
detailsdlg->setSources(fsources);
detailsdlg->setDatarate(fdatarate);
if (fname.isEmpty()) {
detailsdlg->setCompleted(misc::friendlyUnit(-1));
detailsdlg->setRemaining(misc::friendlyUnit(-1));
} else {
detailsdlg->setCompleted(misc::friendlyUnit(fcompleted));
detailsdlg->setRemaining(misc::friendlyUnit(fremaining));
}
//Date GroupBox
if (fname.isEmpty()) {
detailsdlg->setDownloadtime(misc::userFriendlyDuration(-1));
} else {
detailsdlg->setDownloadtime(misc::userFriendlyDuration(fdownloadtime));
}
// retroshare link(s) Tab
if (fname.isEmpty()) {
detailsdlg->setLink("");
} else {
RetroShareLink link;
if (link.createFile(fname, filesize, fhash)) {
detailsdlg->setLink(link.toString());
} else {
detailsdlg->setLink("");
}
}
FileChunksInfo info ;
if (fhash.isEmpty() == false && rsFiles->FileDownloadChunksDetails(fhash.toStdString(), info)) {
detailsdlg->setChunkSize(info.chunk_size);
detailsdlg->setNumberOfChunks(info.chunks.size());
} else {
detailsdlg->setChunkSize(0);
detailsdlg->setNumberOfChunks(0);
}
detailsDialog()->setFileHash(file_hash);
}
void TransfersDialog::pasteLink()
@ -1598,15 +1521,11 @@ void TransfersDialog::showFileDetails()
++nb_select ;
}
if(nb_select != 1)
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash("") ;
detailsDialog()->setFileHash("") ;
else
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->setFileHash(file_hash) ;
detailsDialog()->setFileHash(file_hash) ;
std::cout << "calling update " << std::endl ;
dynamic_cast<FileTransferInfoWidget*>(ui.fileTransferInfoWidget->widget())->updateDisplay() ;
std::cout << "done" << std::endl ;
updateDetailsDialog ();
updateDetailsDialog ();
}
double TransfersDialog::getProgress(int , QStandardItemModel *)

View file

@ -55,7 +55,7 @@ public:
// virtual void keyPressEvent(QKeyEvent *) ;
virtual void updateDisplay() ; // derived from RsAutoUpdateWidget
static DetailsDialog *detailsdlg;
static DetailsDialog *detailsDialog() ;
SearchDialog *searchDialog ;
LocalSharedFilesDialog *localSharedFiles ;
@ -157,6 +157,8 @@ private:
QAction *chunkRandomAct;
QAction *chunkStreamingAct;
QAction *detailsfileAct;
QAction *toggleShowCacheTransfersAct;
QAction *openCollectionAct;
bool m_bProcessSettings;
void processSettings(bool bLoad);
@ -174,6 +176,7 @@ private:
/** Qt Designer generated object */
Ui::TransfersDialog ui;
bool _show_cache_transfers ;
public slots:
// these two functions add entries to the transfers dialog, and return the row id of the entry modified/added
//
@ -183,6 +186,7 @@ public slots:
int addUploadItem(const QString& symbol, const QString& name, const QString& coreID, qlonglong size, const FileProgressInfo& pinfo, double dlspeed, const QString& sources,const QString& source_id, const QString& status, qlonglong completed, qlonglong remaining);
void showFileDetails() ;
void toggleShowCacheTransfers() ;
double getProgress(int row, QStandardItemModel *model);
double getSpeed(int row, QStandardItemModel *model);

View file

@ -10,18 +10,31 @@
<height>353</height>
</rect>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout">
<property name="spacing">
<property name="currentIndex">
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/down.png</normaloff>:/images/down.png</iconset>
</attribute>
<attribute name="title">
<string>Downloads</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item row="1" column="0">
<item>
<widget class="QTreeView" name="downloadList">
<property name="font">
<font>
@ -72,276 +85,37 @@
</attribute>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="titleBarFrame">
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</layout>
</widget>
<widget class="QWidget" name="uploadsTab">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
</attribute>
<attribute name="title">
<string>Uploads</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QTreeView" name="uploadsList">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>32</height>
</size>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/down.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Downloads</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>483</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="openCollection">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>Open Collection</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="_showCacheTransfers_CB">
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="text">
<string>Show cache transfers</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="uploadsTab">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/up.png</normaloff>:/images/up.png</iconset>
</attribute>
<attribute name="title">
<string>Uploads</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QTreeView" name="uploadsList">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="transferTab">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/blockdevice.png</normaloff>:/images/blockdevice.png</iconset>
</attribute>
<attribute name="title">
<string>Selected transfer</string>
</attribute>
<layout class="QGridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="horizontalSpacing">
<number>6</number>
</property>
<item row="0" column="0">
<widget class="QScrollArea" name="fileTransferInfoWidget">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>100</width>
<height>30</height>
</rect>
</property>
</widget>
</widget>
</item>
<item row="1" column="0">
<layout class="QGridLayout">
<property name="margin">
<number>6</number>
</property>
<item row="0" column="0">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-downloaded.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Done</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="1">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-downloading.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Active</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="3">
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-notdownload.png</pixmap>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Outstanding</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>368</width>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_10">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="images.qrc">:/images/graph-checking.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_9">
<property name="text">
<string>Needs checking</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</widget>
</item>
</layout>