|
|
@ -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,46 @@ 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")); |
|
|
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connect(menu, &QMenu::triggered, this, [this](const QAction *action) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int visibleCols = 0; |
|
|
|
|
|
|
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!isColumnHidden(i)) |
|
|
|
if (!checked && (visibleColumnsCount() <= 1)) |
|
|
|
++visibleCols; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (visibleCols > 1) |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int col = action->data().toInt(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isColumnHidden(col) && visibleCols == 1) |
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
setColumnHidden(col, !isColumnHidden(col)); |
|
|
|
setColumnHidden(i, !checked); |
|
|
|
|
|
|
|
|
|
|
|
if (!isColumnHidden(col) && columnWidth(col) <= 5) |
|
|
|
if (checked && (columnWidth(i) <= 5)) |
|
|
|
resizeColumnToContents(col); |
|
|
|
resizeColumnToContents(i); |
|
|
|
|
|
|
|
|
|
|
|
saveSettings(); |
|
|
|
saveSettings(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
action->setCheckable(true); |
|
|
|
|
|
|
|
action->setChecked(!isColumnHidden(i)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
menu->popup(QCursor::pos()); |
|
|
|
menu->popup(QCursor::pos()); |
|
|
|
} |
|
|
|
} |
|
|
|