added context menu and removal feature for banned files

This commit is contained in:
csoler 2018-08-19 15:09:43 +02:00
parent a7ee85495d
commit a2804a70ec
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
3 changed files with 41 additions and 13 deletions

View File

@ -19,6 +19,7 @@
*******************************************************************************/
#include <QMenu>
#include <QDateTime>
#include "retroshare/rsfiles.h"
@ -43,14 +44,21 @@ BannedFilesDialog::~BannedFilesDialog() {}
void BannedFilesDialog::unbanFile()
{
#warning Code missing here
int row = ui.bannedFiles_TW->currentRow();
QTableWidgetItem *item = ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH);
RsFileHash hash(item->data(Qt::UserRole).toString().toStdString()) ;
rsFiles->unbanFile(hash) ;
fillFilesList();
}
void BannedFilesDialog::bannedFilesContextMenu()
void BannedFilesDialog::bannedFilesContextMenu(QPoint)
{
QMenu menu(this);
QAction *action = menu.addAction(QIcon(":/images/FeedAdd.png"), tr("Remove"), this, SLOT(unbanFile()));
menu.addAction(QIcon(":/images/FeedAdd.png"), tr("Remove"), this, SLOT(unbanFile()));
menu.exec(QCursor::pos());
}
@ -62,16 +70,17 @@ void BannedFilesDialog::fillFilesList()
rsFiles->getPrimaryBannedFilesList(banned_files);
int row=0;
ui.bannedFiles_TW->setRowCount(banned_files.size()) ;
for(auto it(banned_files.begin());it!=banned_files.end();++it)
{
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_NAME, new QTableWidgetItem(QIcon(),QString::fromUtf8(it->second.filename.c_str()),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_HASH, new QTableWidgetItem(QIcon(),QString::fromStdString(it->first.toStdString()),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_SIZE, new QTableWidgetItem(QIcon(),QString::number(it->second.size),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QString::number(it->second.ban_time_stamp),0));
ui.bannedFiles_TW->setItem(row, COLUMN_FILE_TIME, new QTableWidgetItem(QIcon(),QDateTime::fromTime_t(it->second.ban_time_stamp).toString(),0));
ui.bannedFiles_TW->item(row, COLUMN_FILE_HASH)->setData(Qt::UserRole, QString::fromStdString(it->first.toStdString()));
row++;
// ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_ID, QString::fromStdString(id));
// ui.recipientWidget->item(row, COLUMN_RECIPIENT_DATA)->setData(ROLE_RECIPIENT_TYPE, dest_type);
}
}

View File

@ -38,7 +38,7 @@ private slots:
/** management of the adv search dialog object when switching search modes */
//void hideEvent(QHideEvent * event);
void bannedFilesContextMenu();
void bannedFilesContextMenu(QPoint);
private:
void fillFilesList();

View File

@ -10,12 +10,34 @@
<height>810</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The list below contains files you have chosen to ban from your local network. You will not forward search results for these files nor forward data from these files to your friends. This list is securely shared with your friends, unless they uncheck option &amp;quot;Trust my friends for banning unwanted content&amp;quot;.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignJustify|Qt::AlignVCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="bannedFiles_TW">
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column>
<property name="text">
<string>Filename</string>
@ -40,9 +62,6 @@
</item>
</layout>
</widget>
<resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/>
</resources>
<resources/>
<connections/>
</ui>