2010-01-05 19:10:15 -05:00
|
|
|
/****************************************************************
|
|
|
|
* 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 <QPixmap>
|
|
|
|
#include <QHeaderView>
|
|
|
|
#include <QModelIndex>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
|
|
|
|
#include "util/misc.h"
|
2010-05-03 18:44:53 -04:00
|
|
|
|
|
|
|
#include "TransfersDialog.h"
|
2010-01-05 19:10:15 -05:00
|
|
|
|
|
|
|
/** Default constructor */
|
|
|
|
DetailsDialog::DetailsDialog(QWidget *parent, Qt::WFlags flags)
|
|
|
|
: QDialog(parent, flags)
|
|
|
|
{
|
|
|
|
/* Invoke Qt Designer generated QObject setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
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 );
|
2010-01-26 09:57:05 -05:00
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Destructor. */
|
|
|
|
DetailsDialog::~DetailsDialog()
|
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
TransfersDialog::detailsdlg = NULL;
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::on_ok_dButton_clicked()
|
|
|
|
{
|
|
|
|
QDialog::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::on_cancel_dButton_clicked()
|
|
|
|
{
|
|
|
|
//reject();
|
|
|
|
QDialog::close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
DetailsDialog::show()
|
|
|
|
{
|
2010-01-26 09:57:05 -05:00
|
|
|
ui.tabWidget->setCurrentIndex(0);
|
2010-01-05 19:10:15 -05:00
|
|
|
if (!this->isVisible()) {
|
2010-05-03 18:44:53 -04:00
|
|
|
QDialog::show();
|
|
|
|
} else {
|
|
|
|
QDialog::activateWindow();
|
|
|
|
setWindowState((windowState() & ~Qt::WindowMinimized) | Qt::WindowActive);
|
|
|
|
QDialog::raise();
|
|
|
|
}
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::closeEvent (QCloseEvent * event)
|
|
|
|
{
|
2010-01-05 21:40:06 -05:00
|
|
|
QWidget::closeEvent(event);
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::setFileName(const QString & filename)
|
|
|
|
{
|
2010-01-05 21:40:06 -05:00
|
|
|
int c;
|
|
|
|
QModelIndex index;
|
|
|
|
|
2010-01-06 18:03:54 -05:00
|
|
|
c = CommentsModel->rowCount();
|
|
|
|
CommentsModel->removeRows(0,c);
|
|
|
|
|
2010-01-05 21:40:06 -05:00
|
|
|
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);
|
|
|
|
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::setHash(const QString & hash)
|
|
|
|
{
|
|
|
|
ui.hash_label_2->setText(hash);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::setSize(const qulonglong & size)
|
|
|
|
{
|
2010-03-24 09:35:26 -04:00
|
|
|
ui.size_label_2->setText(misc::friendlyUnit(size) + " " + "(" + QString::number(size) + " " + "Bytes" + ")");
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2010-01-05 19:19:20 -05:00
|
|
|
QString temp;
|
|
|
|
temp.clear();
|
|
|
|
temp.sprintf("%.2f", datarate/1024.);
|
|
|
|
temp += " KB/s";
|
|
|
|
|
|
|
|
ui.datarate_line->setText(temp);
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
void DetailsDialog::setCompleted(const QString & completed)
|
2010-01-05 19:10:15 -05:00
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
ui.completed_line->setText(completed);
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
void DetailsDialog::setRemaining(const QString & remaining)
|
2010-01-05 19:10:15 -05:00
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
ui.remaining_line->setText(remaining);
|
2010-03-01 17:47:48 -05:00
|
|
|
}
|
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
void DetailsDialog::setDownloadtime(const QString & downloadtime)
|
2010-03-01 17:47:48 -05:00
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
ui.downloadtime_line->setText(downloadtime);
|
2010-01-05 19:10:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DetailsDialog::setLink(const QString & link)
|
|
|
|
{
|
|
|
|
ui.Linktext->setText(link);
|
|
|
|
}
|
2010-01-26 09:57:05 -05:00
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
void DetailsDialog::setChunkSize(uint32_t chunksize)
|
2010-01-26 09:57:05 -05:00
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
ui.chunksizelabel->setText(misc::friendlyUnit(chunksize));
|
2010-01-26 09:57:05 -05:00
|
|
|
}
|
|
|
|
|
2010-05-03 18:44:53 -04:00
|
|
|
void DetailsDialog::setNumberOfChunks(size_t numberofchunks)
|
2010-01-26 09:57:05 -05:00
|
|
|
{
|
2010-05-03 18:44:53 -04:00
|
|
|
ui.numberofchunkslabel->setText(QString::number(numberofchunks));
|
|
|
|
}
|