TorrentInfo::origFilePath will return the very original path from
.torrent file, not the most recent file path before the rename operation
and thus the code would not be working as we expected.
Starting from QT 5.10.1 Content widget is messed up and its settings are
lost while restarting.
Setting StretchLastSection property to false seems to solve the issue.
(Closes#8439).
It prevents detachments:
To illustrate:
QMap<QString, QString> map;
/* code compiles and works fine but find() returns the non-const
QMap::iterator that detaches!
*/
QMap<QString, QString>::const_iterator it = map.find("girish");
but also some subtle bugs:
QHash<int, int> wrong;
if (wrong.find(1) == wrong.cend()) {
qDebug() << "Not found";
} else {
/* find() detached the container before cend() was called, so it
prints "Found"
*/
qDebug() << "Found";
}
QHash<int, int> right;
if (right.constFind(1) == right.cend()) {
qDebug() << "Not found"; // This is correct now !
} else {
qDebug() << "Found";
}
Enforced by QT_STRICT_ITERATORS definition.
Change project directory structure according to application structure.
Change 'nox' configuration option to something more meaningful 'nogui'.
Rename 'Icons' folder to 'icons' (similar to other folders).
Partially add 'nowebui' option support.
Remove QConf project file.
Definitions:
Selection in QTreeView consist of two things:
currentIndex -- is a (dotted) cell where user clicked last time. Note
that it is a cell
selectedIndexes -- is a set of cells (blue) of current selection.
Checkboxes in torrent content lists are belong to COL_NAME column.
Problem:
The problem is that spacebar toggled checkbox only in currentIndex
index. This has two consequences:
1. It is impossible to toggle checkboxes on multiple rows
simultaneously.
2. If currentIndex is not in COL_NAME column a space key doesn't work
at all. This problem is amplifyed by the fact that SelectionBehavior
is set to SelectRows. So visually it is impossible to tell which
column does it belong to. For end user it looks like "space doesn't
work sometimes".
This patch addresses the problem by implementing TorrentContentTreeView
derived from QTreeView and overridding keyPressEvent(QKeyEvent*).
The code of TorrentContentTreeView::keyPressEvent is written under
inspiration from QAbstractItemView::keyPressEvent and
QItemDelegate::editorEvent.
As we never use {push,pop}_front std::vector works here perfectly.
Also reserve memory for std::vector out of lock.
This could be considered as an optimization, but in reality this is just
using right container in right place. According to my measurements total
speedup is under 0.2%.
libtorrent allows setting a custom dispatch handler that is invoked in
libtorrent thread when new alerts are incoming. QAlertDispatcher is a
class that allows to translate these alerts to UI thread.
The concept is very simple:
1. On initialization QAlertDispatcher constructor calls set_alert_dispatch() passing
QAlertDispatcher::dispatch as argument.
2. On deinitialization destructor calls set_alert_dispatch() passing a empty
function. (line 25) libtorrent handles thos and switches back to queuing
alerts in queue.
3. QAlertDispatcher::dispatch() adds alert to queue and notifies UI thread that new
alerts are incoming. Enqueuing is done in function enqueueToMainThread().
The invariant of class is the following:
if alert queue is not empty, in message loop of UI thread contains a queued
invocation of deliverSignal().
4. When message loop is pumped UI thread execute deliverSignal() function.
It emit appropriate signal and if queue is still not empty (for example
if slot doesn't grab alerts) rewind enqueuing to main thread.
This is a idea. But here is some details.
1. When QAlertDispatcher is destoyed, libtorrent still can call
QAlertDispatcher::dispatch a few times after destruction. This is
handled by passing a "tag". A tag is a object that references QAlertDispatch.
Tag could be invalidated. So on destruction QAlertDispatcher invalidates a tag
and then unsubscribes from alerts. When QAlertDispatcher::dispatch is called
with invalid tag it simply discard an alert.
Therefore we could drop a few alerts during unsubscription. So we unsubscribe
only at exit when missing some alerts is not a problem.
2. Another problem is in QBtSession::saveFastResumeData(). It pumps alert
queue synchronously. My first attempt was to destroy QAlertDispatcher
and then pump libtorrent queue. But as I was afraid of losing alerts I
supported synchronous querying of alerts in QAlertDispatcher.
(QAlertDispatcher::getPendingAlerts)
Conflicts:
src/qtlibtorrent/qbtsession.cpp