|
|
@ -195,8 +195,10 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) |
|
|
|
//end up being size 0 when the new version is launched with
|
|
|
|
//end up being size 0 when the new version is launched with
|
|
|
|
//a conf file from the previous version.
|
|
|
|
//a conf file from the previous version.
|
|
|
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) |
|
|
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) |
|
|
|
|
|
|
|
{ |
|
|
|
if ((columnWidth(i) <= 0) && (!isColumnHidden(i))) |
|
|
|
if ((columnWidth(i) <= 0) && (!isColumnHidden(i))) |
|
|
|
resizeColumnToContents(i); |
|
|
|
resizeColumnToContents(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
|
|
|
|
|
|
|
@ -204,7 +206,7 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *mainWindow) |
|
|
|
connect(this, &QAbstractItemView::doubleClicked, this, &TransferListWidget::torrentDoubleClicked); |
|
|
|
connect(this, &QAbstractItemView::doubleClicked, this, &TransferListWidget::torrentDoubleClicked); |
|
|
|
connect(this, &QWidget::customContextMenuRequested, this, &TransferListWidget::displayListMenu); |
|
|
|
connect(this, &QWidget::customContextMenuRequested, this, &TransferListWidget::displayListMenu); |
|
|
|
header()->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
header()->setContextMenuPolicy(Qt::CustomContextMenu); |
|
|
|
connect(header(), &QWidget::customContextMenuRequested, this, &TransferListWidget::displayDLHoSMenu); |
|
|
|
connect(header(), &QWidget::customContextMenuRequested, this, &TransferListWidget::displayColumnHeaderMenu); |
|
|
|
connect(header(), &QHeaderView::sectionMoved, this, &TransferListWidget::saveSettings); |
|
|
|
connect(header(), &QHeaderView::sectionMoved, this, &TransferListWidget::saveSettings); |
|
|
|
connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings); |
|
|
|
connect(header(), &QHeaderView::sectionResized, this, &TransferListWidget::saveSettings); |
|
|
|
connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings); |
|
|
|
connect(header(), &QHeaderView::sortIndicatorChanged, this, &TransferListWidget::saveSettings); |
|
|
@ -623,48 +625,59 @@ void TransferListWidget::reannounceSelectedTorrents() |
|
|
|
torrent->forceReannounce(); |
|
|
|
torrent->forceReannounce(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int TransferListWidget::visibleColumnsCount() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int count = 0; |
|
|
|
|
|
|
|
for (int i = 0, iMax = header()->count(); i < iMax; ++i) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (!isColumnHidden(i)) |
|
|
|
|
|
|
|
++count; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return count; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// hide/show columns menu
|
|
|
|
// hide/show columns menu
|
|
|
|
void TransferListWidget::displayDLHoSMenu(const QPoint&) |
|
|
|
void TransferListWidget::displayColumnHeaderMenu() |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto menu = new QMenu(this); |
|
|
|
auto menu = new QMenu(this); |
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
menu->setTitle(tr("Column visibility")); |
|
|
|
menu->setTitle(tr("Column visibility")); |
|
|
|
|
|
|
|
menu->setToolTipsVisible(true); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < m_listModel->columnCount(); ++i) |
|
|
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TransferListModel::TR_QUEUE_POSITION)) |
|
|
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TransferListModel::TR_QUEUE_POSITION)) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
QAction *myAct = menu->addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString()); |
|
|
|
const auto columnName = m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString(); |
|
|
|
myAct->setCheckable(true); |
|
|
|
QAction *action = menu->addAction(columnName, this, [this, i](const bool checked) |
|
|
|
myAct->setChecked(!isColumnHidden(i)); |
|
|
|
{ |
|
|
|
myAct->setData(i); |
|
|
|
if (!checked && (visibleColumnsCount() <= 1)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setColumnHidden(i, !checked); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (checked && (columnWidth(i) <= 5)) |
|
|
|
|
|
|
|
resizeColumnToContents(i); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
action->setCheckable(true); |
|
|
|
|
|
|
|
action->setChecked(!isColumnHidden(i)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
connect(menu, &QMenu::triggered, this, [this](const QAction *action) |
|
|
|
menu->addSeparator(); |
|
|
|
|
|
|
|
QAction *resizeAction = menu->addAction(tr("Resize columns"), this, [this]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int visibleCols = 0; |
|
|
|
for (int i = 0, count = header()->count(); i < count; ++i) |
|
|
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!isColumnHidden(i)) |
|
|
|
if (!isColumnHidden(i)) |
|
|
|
++visibleCols; |
|
|
|
resizeColumnToContents(i); |
|
|
|
|
|
|
|
|
|
|
|
if (visibleCols > 1) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const int col = action->data().toInt(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isColumnHidden(col) && visibleCols == 1) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setColumnHidden(col, !isColumnHidden(col)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isColumnHidden(col) && columnWidth(col) <= 5) |
|
|
|
|
|
|
|
resizeColumnToContents(col); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
saveSettings(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
resizeAction->setToolTip(tr("Resize all non-hidden columns to the size of their contents")); |
|
|
|
|
|
|
|
|
|
|
|
menu->popup(QCursor::pos()); |
|
|
|
menu->popup(QCursor::pos()); |
|
|
|
} |
|
|
|
} |
|
|
@ -832,7 +845,7 @@ void TransferListWidget::clearSelectionTags() |
|
|
|
applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); }); |
|
|
|
applyToSelectedTorrents([](BitTorrent::Torrent *const torrent) { torrent->removeAllTags(); }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TransferListWidget::displayListMenu(const QPoint &) |
|
|
|
void TransferListWidget::displayListMenu() |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
const QModelIndexList selectedIndexes = selectionModel()->selectedRows(); |
|
|
|
if (selectedIndexes.isEmpty()) return; |
|
|
|
if (selectedIndexes.isEmpty()) return; |
|
|
|