diff --git a/Changelog b/Changelog
index e189b0c10..f00e93af4 100644
--- a/Changelog
+++ b/Changelog
@@ -5,6 +5,7 @@
- FEATURE: Add support for anonymous mode (libtorrent >= v0.16)
- FEATURE: Add quick "set as default save path" checkbox to torrent addition dialog (sledgehammer999)
- BUGFIX: Add tray menu entry for toggling window visibility
+ - BUGFIX: Fix execution log lines selection and copying
- COSMETIC: Display speed at the beginning of the Window title
- OTHER: Display libraries versions in about dialog (sledgehammer999)
diff --git a/src/executionlog.cpp b/src/executionlog.cpp
index 900ad1c09..8927f27ed 100644
--- a/src/executionlog.cpp
+++ b/src/executionlog.cpp
@@ -34,14 +34,21 @@
#include "ui_executionlog.h"
#include "qbtsession.h"
#include "iconprovider.h"
+#include "loglistwidget.h"
ExecutionLog::ExecutionLog(QWidget *parent) :
- QWidget(parent),
- ui(new Ui::ExecutionLog)
+ QWidget(parent),
+ ui(new Ui::ExecutionLog),
+ m_logList(new LogListWidget(MAX_LOG_MESSAGES)),
+ m_banList(new LogListWidget(MAX_LOG_MESSAGES))
{
ui->setupUi(this);
+
ui->tabConsole->setTabIcon(0, IconProvider::instance()->getIcon("view-calendar-journal"));
ui->tabConsole->setTabIcon(1, IconProvider::instance()->getIcon("view-filter"));
+ ui->tabGeneral->layout()->addWidget(m_logList);
+ ui->tabBan->layout()->addWidget(m_banList);
+
const QStringList log_msgs = QBtSession::instance()->getConsoleMessages();
foreach(const QString& msg, log_msgs)
addLogMessage(msg);
@@ -54,29 +61,17 @@ ExecutionLog::ExecutionLog(QWidget *parent) :
ExecutionLog::~ExecutionLog()
{
+ delete m_logList;
+ delete m_banList;
delete ui;
}
void ExecutionLog::addLogMessage(const QString &msg)
{
- QListWidgetItem *item = new QListWidgetItem;
- QLabel *lbl = new QLabel(msg);
- lbl->setContentsMargins(4, 2, 4, 2);
- item->setSizeHint(lbl->sizeHint());
- ui->logList->insertItem(0, item);
- ui->logList->setItemWidget(item, lbl);
- if(ui->logList->count() > MAX_LOG_MESSAGES)
- delete ui->logList->takeItem(ui->logList->count()-1);
+ m_logList->appendLine(msg);
}
void ExecutionLog::addBanMessage(const QString &msg)
{
- QListWidgetItem *item = new QListWidgetItem;
- QLabel *lbl = new QLabel(msg);
- lbl->setContentsMargins(4, 2, 4, 2);
- item->setSizeHint(lbl->sizeHint());
- ui->banList->insertItem(0, item);
- ui->banList->setItemWidget(item, lbl);
- if(ui->banList->count() > MAX_LOG_MESSAGES)
- delete ui->banList->takeItem(ui->banList->count()-1);
+ m_banList->appendLine(msg);
}
diff --git a/src/executionlog.h b/src/executionlog.h
index 6936a560f..f0eea0bda 100644
--- a/src/executionlog.h
+++ b/src/executionlog.h
@@ -37,6 +37,7 @@ QT_BEGIN_NAMESPACE
namespace Ui {
class ExecutionLog;
}
+class LogListWidget;
QT_END_NAMESPACE
class ExecutionLog : public QWidget
@@ -52,7 +53,11 @@ public slots:
void addBanMessage(const QString &msg);
private:
- Ui::ExecutionLog *ui;
+ Ui::ExecutionLog *ui;
+
+ LogListWidget *m_logList;
+ LogListWidget *m_banList;
+ int m_maxLines;
};
#endif // EXECUTIONLOG_H
diff --git a/src/executionlog.ui b/src/executionlog.ui
index e17e1e435..492eb8772 100644
--- a/src/executionlog.ui
+++ b/src/executionlog.ui
@@ -22,33 +22,17 @@
0
-
+
General
-
- -
-
-
- true
-
-
-
-
+
-
+
Blocked IPs
-
- -
-
-
- true
-
-
-
-
+
diff --git a/src/loglistwidget.cpp b/src/loglistwidget.cpp
new file mode 100644
index 000000000..1d3f5fd7b
--- /dev/null
+++ b/src/loglistwidget.cpp
@@ -0,0 +1,89 @@
+/*
+ * Bittorrent Client using Qt4 and libtorrent.
+ * Copyright (C) 2011 Christophe Dumez
+ *
+ * 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.
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link this program with the OpenSSL project's "OpenSSL" library (or with
+ * modified versions of it that use the same license as the "OpenSSL" library),
+ * and distribute the linked executables. You must obey the GNU General Public
+ * License in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s), you may extend this exception to your version of the file(s),
+ * but you are not obligated to do so. If you do not wish to do so, delete this
+ * exception statement from your version.
+ *
+ * Contact : chris@qbittorrent.org
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "loglistwidget.h"
+#include "iconprovider.h"
+
+LogListWidget::LogListWidget(int max_lines, QWidget *parent) :
+ QListWidget(parent),
+ m_maxLines(max_lines)
+{
+ // Allow multiple selections
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+ // Context menu
+ QAction *copyAct = new QAction(IconProvider::instance()->getIcon("edit-copy"), tr("Copy"), this);
+ connect(copyAct, SIGNAL(triggered()), SLOT(copySelection()));
+ addAction(copyAct);
+ setContextMenuPolicy(Qt::ActionsContextMenu);
+}
+
+void LogListWidget::keyPressEvent(QKeyEvent *event)
+{
+ if (event->matches(QKeySequence::Copy)) {
+ copySelection();
+ return;
+ }
+ if (event->matches(QKeySequence::SelectAll)) {
+ selectAll();
+ return;
+ }
+}
+
+void LogListWidget::appendLine(const QString &line)
+{
+ QListWidgetItem *item = new QListWidgetItem(this);
+ // We need to use QLabel here to support rich text
+ QLabel *lbl = new QLabel(line);
+ lbl->setContentsMargins(4, 2, 4, 2);
+ item->setSizeHint(lbl->sizeHint());
+ insertItem(0, item);
+ setItemWidget(item, lbl);
+ const int nbLines = count();
+ // Limit log size
+ if(nbLines > m_maxLines)
+ delete takeItem(nbLines - 1);
+}
+
+void LogListWidget::copySelection()
+{
+ static QRegExp html_tag("<[^>]+>");
+ QList items = selectedItems();
+ QStringList strings;
+ foreach(QListWidgetItem* it, items)
+ strings << static_cast(itemWidget(it))->text().replace(html_tag, "");
+
+ QApplication::clipboard()->setText(strings.join("\n"));
+}
diff --git a/src/loglistwidget.h b/src/loglistwidget.h
new file mode 100644
index 000000000..c22f9cd8a
--- /dev/null
+++ b/src/loglistwidget.h
@@ -0,0 +1,60 @@
+/*
+ * Bittorrent Client using Qt4 and libtorrent.
+ * Copyright (C) 2011 Christophe Dumez
+ *
+ * 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.
+ *
+ * In addition, as a special exception, the copyright holders give permission to
+ * link this program with the OpenSSL project's "OpenSSL" library (or with
+ * modified versions of it that use the same license as the "OpenSSL" library),
+ * and distribute the linked executables. You must obey the GNU General Public
+ * License in all respects for all of the code used other than "OpenSSL". If you
+ * modify file(s), you may extend this exception to your version of the file(s),
+ * but you are not obligated to do so. If you do not wish to do so, delete this
+ * exception statement from your version.
+ *
+ * Contact : chris@qbittorrent.org
+ */
+#ifndef LOGLISTWIDGET_H
+#define LOGLISTWIDGET_H
+
+#include
+
+QT_BEGIN_NAMESPACE
+class QKeyEvent;
+QT_END_NAMESPACE
+
+class LogListWidget : public QListWidget
+{
+ Q_OBJECT
+
+public:
+ explicit LogListWidget(int max_lines = 100, QWidget *parent = 0);
+
+public slots:
+ void appendLine(const QString &line);
+
+protected slots:
+ void copySelection();
+
+protected:
+ void keyPressEvent(QKeyEvent *event);
+
+private:
+ int m_maxLines;
+
+};
+
+#endif // LOGLISTWIDGET_H
diff --git a/src/src.pro b/src/src.pro
index d299d810c..db8269e2c 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -102,14 +102,15 @@ HEADERS += misc.h \
scannedfoldersmodel.h \
qinisettings.h \
smtp.h \
- dnsupdater.h
+ dnsupdater.h
+
SOURCES += main.cpp \
downloadthread.cpp \
scannedfoldersmodel.cpp \
misc.cpp \
smtp.cpp \
- dnsupdater.cpp
+ dnsupdater.cpp
nox {
HEADERS += headlessloader.h
@@ -135,7 +136,8 @@ nox {
torrentimportdlg.h \
executionlog.h \
iconprovider.h \
- updownratiodlg.h
+ updownratiodlg.h \
+ loglistwidget.h
SOURCES += mainwindow.cpp \
ico.cpp \
@@ -146,7 +148,8 @@ nox {
executionlog.cpp \
previewselect.cpp \
iconprovider.cpp \
- updownratiodlg.cpp
+ updownratiodlg.cpp \
+ loglistwidget.cpp
win32 {
HEADERS += programupdater.h