Ensure that at least one column in the tranferlist is always visible. Closes #1165.

This commit is contained in:
sledgehammer999 2014-01-02 20:49:35 +02:00
parent fce950b788
commit ed54f0f7c3

View file

@ -127,6 +127,17 @@ TransferListWidget::TransferListWidget(QWidget *parent, MainWindow *main_window,
setColumnHidden(TorrentModelItem::TR_SAVE_PATH, true);
}
//Ensure that at least one column is visible at all times
bool atLeastOne = false;
for (unsigned int i=0; i<TorrentModelItem::NB_COLUMNS; i++) {
if (!isColumnHidden(i)) {
atLeastOne = true;
break;
}
}
if (!atLeastOne)
setColumnHidden(TorrentModelItem::TR_NAME, false);
//When adding/removing columns between versions some may
//end up being size 0 when the new version is launched with
//a conf file from the previous version.
@ -558,11 +569,23 @@ void TransferListWidget::displayDLHoSMenu(const QPoint&) {
myAct->setChecked(!isColumnHidden(i));
actions.append(myAct);
}
int visibleCols = 0;
for (unsigned int i=0; i<TorrentModelItem::NB_COLUMNS; i++) {
if (!isColumnHidden(i))
visibleCols++;
if (visibleCols > 1)
break;
}
// Call menu
QAction *act = hideshowColumn.exec(QCursor::pos());
if (act) {
int col = actions.indexOf(act);
Q_ASSERT(col >= 0);
Q_ASSERT(visibleCols > 0);
if (!isColumnHidden(col) && visibleCols == 1)
return;
qDebug("Toggling column %d visibility", col);
setColumnHidden(col, !isColumnHidden(col));
if (!isColumnHidden(col) && columnWidth(col) <= 5)