Added DetailsDialog for Transfers

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1978 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-06 00:10:15 +00:00
parent c9e5e72edd
commit 5008cfdf25
6 changed files with 680 additions and 12 deletions

View File

@ -118,6 +118,7 @@ HEADERS += rshare.h \
gui/notifyqt.h \
control/bandwidthevent.h \
control/eventtype.h \
gui/DetailsDialog.h \
gui/DLListDelegate.h \
gui/ULListDelegate.h \
gui/StartDialog.h \
@ -260,6 +261,7 @@ FORMS += gui/StartDialog.ui \
gui/help/browser/helpbrowser.ui \
gui/HelpDialog.ui \
gui/InfoDialog.ui \
gui/DetailsDialog.ui \
gui/bwgraph/bwgraph.ui \
gui/profile/ProfileView.ui \
gui/profile/ProfileEdit.ui \
@ -295,6 +297,7 @@ SOURCES += main.cpp \
rshare.cpp \
gui/notifyqt.cpp \
gui/AboutDialog.cpp \
gui/DetailsDialog.cpp \
gui/DLListDelegate.cpp \
gui/ULListDelegate.cpp \
gui/StartDialog.cpp \

View File

@ -0,0 +1,155 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006-2010, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#include "DetailsDialog.h"
#include <QAction>
#include <QTreeView>
#include <QList>
#include <QtDebug>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
#include <QPoint>
#include <QMouseEvent>
#include <QPixmap>
#include <QHeaderView>
#include <QModelIndex>
#include <QStandardItemModel>
#include "util/misc.h"
/** Default constructor */
DetailsDialog::DetailsDialog(QWidget *parent, Qt::WFlags flags)
: QDialog(parent, flags)
{
/* Invoke Qt Designer generated QObject setup routine */
ui.setupUi(this);
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 );
}
/** Destructor. */
DetailsDialog::~DetailsDialog()
{
}
void DetailsDialog::on_ok_dButton_clicked()
{
QDialog::close();
}
void DetailsDialog::on_cancel_dButton_clicked()
{
//reject();
QDialog::close();
}
void
DetailsDialog::show()
{
if (!this->isVisible()) {
QDialog::show();
} else {
QDialog::activateWindow();
setWindowState(windowState() & ~Qt::WindowMinimized | Qt::WindowActive);
QDialog::raise();
}
}
void DetailsDialog::closeEvent (QCloseEvent * event)
{
QWidget::closeEvent(event);
}
void DetailsDialog::setFileName(const QString & 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));
}
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)
{
ui.datarate_line->setText(QString::number(datarate));
}
void DetailsDialog::setCompleted(const qulonglong & completed)
{
ui.completed_line->setText(misc::friendlyUnit(completed));
}
void DetailsDialog::setRemaining(const qulonglong & remaining)
{
ui.remaining_line->setText(misc::userFriendlyDuration(remaining));
}
void DetailsDialog::setLink(const QString & link)
{
ui.Linktext->setText(link);
}

View File

@ -0,0 +1,78 @@
/****************************************************************
* RetroShare is distributed under the following license:
*
* Copyright (C) 2006-2010, RetroShare Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
****************************************************************/
#ifndef _DETAILSDIALOG_H
#define _DETAILSDIALOG_H
#include <QtGui>
#include <QObject>
#include <QModelIndex>
#include <QVariant>
#include "ui_DetailsDialog.h"
class DetailsDialog : public QDialog
{
Q_OBJECT
public:
/** Default constructor */
DetailsDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
~DetailsDialog();
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 qulonglong & completed);
void setRemaining(const qulonglong & remaining) ;
void setType(const QString & type);
protected:
void closeEvent (QCloseEvent * event);
private slots:
void on_ok_dButton_clicked();
void on_cancel_dButton_clicked();
private:
class QStandardItemModel *CommentsModel;
/** Qt Designer generated object */
Ui::DetailsDialog ui;
};
#endif

View File

@ -0,0 +1,365 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DetailsDialog</class>
<widget class="QDialog" name="DetailsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>525</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>Details</string>
</property>
<property name="windowIcon">
<iconset resource="images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout">
<item row="0" column="0" colspan="3">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabgeneral">
<attribute name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/fileinfo.png</normaloff>:/images/fileinfo.png</iconset>
</attribute>
<attribute name="title">
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QGroupBox" name="genralgroupBox">
<property name="title">
<string>General</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<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>Name Label</string>
</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="1" column="1">
<widget class="QLabel" name="hash_label_2">
<property name="text">
<string>Hash Label</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>Size Label</string>
</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>Status Label</string>
</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>Priority Label</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="type_label_2">
<property name="text">
<string>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>
</layout>
</widget>
</item>
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Transfer</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<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="3" column="0">
<widget class="QLabel" name="remaining_label">
<property name="text">
<string>Remaining:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="sources_line">
<property name="text">
<string>Source Label</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="datarate_line">
<property name="text">
<string>Datarate Label</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="completed_line">
<property name="text">
<string>Completed Label</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="remaining_line">
<property name="text">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;Remaining Label&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="2" rowspan="4">
<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>
</layout>
</widget>
</item>
<item row="2" 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"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabcomments">
<attribute name="title">
<string>retroshare link(s)</string>
</attribute>
<layout class="QGridLayout">
<item row="0" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>retroshare link(s)</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QTextEdit" name="Linktext"/>
</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>
</item>
<item row="1" column="0">
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>321</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="ok_dButton">
<property name="text">
<string>OK</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="cancel_dButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="images.qrc"/>
</resources>
<connections/>
</ui>

View File

@ -27,6 +27,7 @@
#include "rshare.h"
#include "TransfersDialog.h"
#include "RetroShareLinkAnalyzer.h"
#include "DetailsDialog.h"
#include "DLListDelegate.h"
#include "ULListDelegate.h"
#include "FileTransferInfoWidget.h"
@ -215,8 +216,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
QMenu contextMnu( this );
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
//showdowninfoAct = new QAction(QIcon(IMAGE_INFO), tr( "Details..." ), this );
//connect( showdowninfoAct , SIGNAL( triggered() ), this, SLOT( showDownInfoWindow() ) );
/* check which item is selected
* - if it is completed - play should appear in menu
@ -262,6 +261,9 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
previewfileAct = new QAction(QIcon(IMAGE_PREVIEW), tr("Preview File"), this);
connect(previewfileAct, SIGNAL(triggered()), this, SLOT(previewTransfer()));
detailsfileAct = new QAction(QIcon(IMAGE_INFO), tr("Details..."), this);
connect(detailsfileAct, SIGNAL(triggered()), this, SLOT(showDetailsDialog()));
clearcompletedAct = new QAction(QIcon(IMAGE_CLEARCOMPLETED), tr( "Clear Completed" ), this );
connect( clearcompletedAct , SIGNAL( triggered() ), this, SLOT( clearcompleted() ) );
@ -328,6 +330,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
contextMnu.addAction( openfileAct);
contextMnu.addAction( previewfileAct);
contextMnu.addAction( openfolderAct);
contextMnu.addAction( detailsfileAct);
contextMnu.addSeparator();
contextMnu.addAction( clearcompletedAct);
contextMnu.addSeparator();
@ -337,7 +340,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
contextMnu.addAction( clearQueuedDwlAct);
contextMnu.addAction( clearQueueAct);
contextMnu.addSeparator();
contextMnu.addMenu( viewMenu);
contextMnu.addMenu( viewMenu);
contextMnu.exec( mevent->globalPos() );
}
@ -1037,6 +1040,69 @@ void TransfersDialog::copyLink ()
clipboard->setText(analyzer.getRetroShareLink ());
}
void TransfersDialog::showDetailsDialog()
{
static DetailsDialog *detailsdlg = new DetailsDialog();
QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes ();
RetroShareLinkAnalyzer analyzer;
for (int i = 0; i < lst.count (); i++)
{
if (lst[i].column () == 0)
{
QModelIndex& ind = lst[i];
QString fhash = ind.model ()->data (ind.model ()->index (ind.row (), ID )).toString() ;
QString fsize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toString() ;
QString fname = ind.model ()->data (ind.model ()->index (ind.row (), NAME)).toString() ;
QString fstatus = ind.model ()->data (ind.model ()->index (ind.row (), STATUS)).toString() ;
QString fpriority = ind.model ()->data (ind.model ()->index (ind.row (), PRIORITY)).toString() ;
QString fsources= ind.model ()->data (ind.model ()->index (ind.row (), SOURCES)).toString() ;
qulonglong filesize = ind.model ()->data (ind.model ()->index (ind.row (), SIZE)).toULongLong() ;
double fdatarate = ind.model ()->data (ind.model ()->index (ind.row (), DLSPEED)).toDouble() ;
qulonglong fcompleted = ind.model ()->data (ind.model ()->index (ind.row (), COMPLETED)).toULongLong() ;
qulonglong fremaining = ind.model ()->data (ind.model ()->index (ind.row (), REMAINING)).toULongLong() ;
// 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);
detailsdlg->setCompleted(fcompleted);
detailsdlg->setRemaining(fremaining);
// retroshare link(s) Tab
analyzer.setRetroShareLink (fname, fsize, fhash);
detailsdlg->setLink(analyzer.getRetroShareLink ());
detailsdlg->show();
break;
}
}
}
// display properties of selected items
/*void DownloadingTorrents::propertiesSelection(){
QModelIndexList selectedIndexes = downloadList->selectionModel()->selectedIndexes();
foreach(const QModelIndex &index, selectedIndexes){
if(index.column() == NAME){
showProperties(index);
}
}
}*/
void TransfersDialog::pasteLink()
{
QClipboard *clipboard = QApplication::clipboard();

View File

@ -87,18 +87,18 @@ class TransfersDialog : public RsAutoUpdatePage
/** modify download priority actions */
void priorityLow();
void priorityNormal();
void priorityHigh();
void priorityAuto();
void priorityNormal();
void priorityHigh();
void priorityAuto();
void chunkRandom();
void chunkStreaming();
void chunkRandom();
void chunkStreaming();
/** save sort indicators for next transfers display */
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
/** save sort indicators for next transfers display */
void saveSortIndicatorDwl(int logicalIndex, Qt::SortOrder order);
void saveSortIndicatorUpl(int logicalIndex, Qt::SortOrder order);
//void setTaskGraphPainterWidget (const QModelIndex& index);
void showDetailsDialog();
signals:
void playFiles(QStringList files);
@ -149,6 +149,7 @@ class TransfersDialog : public RsAutoUpdatePage
QAction *priorityAutoAct;
QAction *chunkRandomAct;
QAction *chunkStreamingAct;
QAction *detailsfileAct;
void getIdOfSelectedItems(QList<QStandardItem *>& items);
bool controlTransferFile(uint32_t flags);