summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtFileTransferListWidget.cpp')
-rw-r--r--Swift/QtUI/QtFileTransferListWidget.cpp44
1 files changed, 37 insertions, 7 deletions
diff --git a/Swift/QtUI/QtFileTransferListWidget.cpp b/Swift/QtUI/QtFileTransferListWidget.cpp
index fb2b4de..729c95f 100644
--- a/Swift/QtUI/QtFileTransferListWidget.cpp
+++ b/Swift/QtUI/QtFileTransferListWidget.cpp
@@ -4,14 +4,24 @@
* See Documentation/Licenses/BSD-simplified.txt for more information.
*/
-#include "QtFileTransferListWidget.h"
+/*
+ * Copyright (c) 2015 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file for more information.
+ */
-#include <Swift/QtUI/QtFileTransferListItemModel.h>
+#include <Swift/QtUI/QtFileTransferListWidget.h>
+
+#include <boost/bind.hpp>
-#include <QVBoxLayout>
#include <QHBoxLayout>
-#include <QWidget>
#include <QPushButton>
+#include <QVBoxLayout>
+#include <QWidget>
+
+#include <Swift/Controllers/FileTransfer/FileTransferOverview.h>
+
+#include <Swift/QtUI/QtFileTransferListItemModel.h>
namespace Swift {
@@ -36,9 +46,9 @@ QtFileTransferListWidget::QtFileTransferListWidget() : fileTransferOverview(0) {
buttonLayout->setContentsMargins(10,0,20,0);
buttonLayout->setSpacing(0);
- QPushButton* clearFinished = new QPushButton(tr("Clear Finished Transfers"), bottom);
+ clearFinished = new QPushButton(tr("Clear Inactive Transfers"), bottom);
clearFinished->setEnabled(false);
- //connect(clearButton, SIGNAL(clicked()), textEdit, SLOT(clear()));
+ connect(clearFinished, SIGNAL(clicked()), this, SLOT(clearInactiveTransfers()));
buttonLayout->addWidget(clearFinished);
setWindowTitle(tr("File Transfer List"));
@@ -46,6 +56,10 @@ QtFileTransferListWidget::QtFileTransferListWidget() : fileTransferOverview(0) {
}
QtFileTransferListWidget::~QtFileTransferListWidget() {
+ if (fileTransferOverview) {
+ fileTransferOverview->onFileTransferListChanged.disconnect(boost::bind(&QtFileTransferListWidget::handleFileTransferListChanged, this));
+ fileTransferOverview = NULL;
+ }
delete itemModel;
}
@@ -55,6 +69,14 @@ void QtFileTransferListWidget::showEvent(QShowEvent* event) {
QWidget::showEvent(event);
}
+void QtFileTransferListWidget::handleFileTransferListChanged() {
+ clearFinished->setEnabled(fileTransferOverview->isClearable());
+}
+
+void QtFileTransferListWidget::clearInactiveTransfers() {
+ fileTransferOverview->clearFinished();
+}
+
void QtFileTransferListWidget::show() {
QWidget::show();
emit windowOpening();
@@ -65,7 +87,15 @@ void QtFileTransferListWidget::activate() {
}
void QtFileTransferListWidget::setFileTransferOverview(FileTransferOverview *overview) {
- fileTransferOverview = overview;
+ if (fileTransferOverview) {
+ fileTransferOverview->onFileTransferListChanged.disconnect(boost::bind(&QtFileTransferListWidget::handleFileTransferListChanged, this));
+ fileTransferOverview = NULL;
+ }
+ if (overview) {
+ fileTransferOverview = overview;
+ fileTransferOverview->onFileTransferListChanged.connect(boost::bind(&QtFileTransferListWidget::handleFileTransferListChanged, this));
+ clearFinished->setEnabled(fileTransferOverview->isClearable());
+ }
itemModel->setFileTransferOverview(overview);
}