2018-08-16 16:22:47 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
* retroshare-gui/src/gui/FileTransfer/BannedFilesDialog.cpp *
|
|
|
|
* *
|
2018-11-11 14:42:48 -05:00
|
|
|
* Copyright 2018 by Retroshare Team <retroshare.project@gmail.com> *
|
2018-08-16 16:22:47 -04:00
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2018-08-16 17:18:29 -04:00
|
|
|
#include <QMenu>
|
2018-08-19 09:09:43 -04:00
|
|
|
#include <QDateTime>
|
2018-08-16 17:18:29 -04:00
|
|
|
|
2018-08-16 16:22:47 -04:00
|
|
|
#include "retroshare/rsfiles.h"
|
|
|
|
|
|
|
|
#include "BannedFilesDialog.h"
|
|
|
|
|
2018-08-16 17:18:29 -04:00
|
|
|
#define COLUMN_FILE_NAME 0
|
|
|
|
#define COLUMN_FILE_HASH 1
|
|
|
|
#define COLUMN_FILE_SIZE 2
|
|
|
|
#define COLUMN_FILE_TIME 3
|
|
|
|
|
2018-08-16 16:22:47 -04:00
|
|
|
BannedFilesDialog::BannedFilesDialog(QWidget *parent)
|
|
|
|
: QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
2018-08-16 17:18:29 -04:00
|
|
|
|
|
|
|
fillFilesList() ;
|
|
|
|
|
|
|
|
connect(ui.bannedFiles_TW, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(bannedFilesContextMenu(QPoint)));
|
2018-08-16 16:22:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BannedFilesDialog::~BannedFilesDialog() {}
|
|
|
|
|
|
|
|
void BannedFilesDialog::unbanFile()
|
|
|
|
{
|
2018-08-19 09:09:43 -04:00
|
|
|
int row = ui.bannedFiles_TW->currentRow();
|
|
|
|
|
|
|
|
QTableWidgetItem *item = ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH);
|
|
|
|
|
2018-09-06 16:14:17 -04:00
|
|
|
if(!item)
|
|
|
|
return ;
|
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
RsFileHash hash(item->data(Qt::UserRole).toString().toStdString()) ;
|
|
|
|
rsFiles->unbanFile(hash) ;
|
|
|
|
|
|
|
|
fillFilesList();
|
2018-08-16 16:22:47 -04:00
|
|
|
}
|
2018-08-16 17:18:29 -04:00
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
void BannedFilesDialog::bannedFilesContextMenu(QPoint)
|
2018-08-16 17:18:29 -04:00
|
|
|
{
|
|
|
|
QMenu menu(this);
|
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
menu.addAction(QIcon(":/images/FeedAdd.png"), tr("Remove"), this, SLOT(unbanFile()));
|
2018-08-16 17:18:29 -04:00
|
|
|
|
|
|
|
menu.exec(QCursor::pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
void BannedFilesDialog::fillFilesList()
|
|
|
|
{
|
|
|
|
std::map<RsFileHash,BannedFileEntry> banned_files ;
|
|
|
|
|
|
|
|
rsFiles->getPrimaryBannedFilesList(banned_files);
|
|
|
|
int row=0;
|
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
ui.bannedFiles_TW->setRowCount(banned_files.size()) ;
|
|
|
|
|
2018-08-16 17:18:29 -04:00
|
|
|
for(auto it(banned_files.begin());it!=banned_files.end();++it)
|
|
|
|
{
|
2018-10-08 18:55:32 -04:00
|
|
|
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.mFilename.c_str()),0));
|
2018-08-16 17:18:29 -04:00
|
|
|
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0));
|
2018-10-08 18:55:32 -04:00
|
|
|
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.mSize),0));
|
|
|
|
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.mBanTimeStamp).toString(),0));
|
2018-08-16 17:18:29 -04:00
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString()));
|
2018-08-16 17:18:29 -04:00
|
|
|
|
2018-08-19 09:09:43 -04:00
|
|
|
row++;
|
2018-08-16 17:18:29 -04:00
|
|
|
}
|
|
|
|
}
|