|
|
|
@ -403,42 +403,31 @@ void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
@@ -403,42 +403,31 @@ void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
|
|
|
|
|
|
|
|
|
|
// toggle hide/show a column
|
|
|
|
|
void FinishedTorrents::hideOrShowColumn(int index) { |
|
|
|
|
short nbColumns = 0; |
|
|
|
|
unsigned int nbVisibleColumns = 0; |
|
|
|
|
unsigned int nbCols = finishedListModel->columnCount(); |
|
|
|
|
// Count visible columns
|
|
|
|
|
for(unsigned int i=0; i<nbCols; ++i) { |
|
|
|
|
if(!finishedList->isColumnHidden(i)) |
|
|
|
|
++nbVisibleColumns; |
|
|
|
|
} |
|
|
|
|
if(!finishedList->isColumnHidden(index)) { |
|
|
|
|
unsigned short i=0, nbColDisplayed = 0; |
|
|
|
|
while(i<finishedListModel->columnCount()-1 && nbColDisplayed<=1) { |
|
|
|
|
if(!finishedList->isColumnHidden(i)) |
|
|
|
|
nbColDisplayed++; |
|
|
|
|
i++; |
|
|
|
|
} |
|
|
|
|
// can't hide a lonely column
|
|
|
|
|
if(nbColDisplayed>1) { |
|
|
|
|
//resize all others non-hidden columns
|
|
|
|
|
for(int i=0; i<finishedListModel->columnCount()-1; i++) { |
|
|
|
|
if(finishedList->isColumnHidden(i) == false) |
|
|
|
|
nbColumns++; |
|
|
|
|
} |
|
|
|
|
for(int i=0; i<finishedListModel->columnCount()-1; i++) { |
|
|
|
|
if(i != index) { |
|
|
|
|
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)+(finishedList->columnWidth(index)/(nbColumns-1)))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
finishedList->setColumnHidden(index, true); |
|
|
|
|
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png"))); |
|
|
|
|
} |
|
|
|
|
// User wants to hide the column
|
|
|
|
|
// Is there at least one other visible column?
|
|
|
|
|
if(nbVisibleColumns <= 1) return; |
|
|
|
|
// User can hide the column, do it.
|
|
|
|
|
finishedList->setColumnHidden(index, true); |
|
|
|
|
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png"))); |
|
|
|
|
--nbVisibleColumns; |
|
|
|
|
} else { |
|
|
|
|
//short buf_width = finishedList->columnWidth(index);
|
|
|
|
|
// User want to display the column
|
|
|
|
|
finishedList->setColumnHidden(index, false); |
|
|
|
|
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png"))); |
|
|
|
|
//resize all others non-hidden columns
|
|
|
|
|
for(int i=0; i<finishedListModel->columnCount()-1; i++) { |
|
|
|
|
if(finishedList->isColumnHidden(i) == false) |
|
|
|
|
nbColumns++; |
|
|
|
|
} |
|
|
|
|
for(int i=0; i<finishedListModel->columnCount()-1; i++) { |
|
|
|
|
if(i != index) { |
|
|
|
|
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)-(finishedList->columnWidth(index)/(nbColumns-1)))); |
|
|
|
|
} |
|
|
|
|
++nbVisibleColumns; |
|
|
|
|
} |
|
|
|
|
//resize all others non-hidden columns
|
|
|
|
|
for(unsigned int i=0; i<nbCols; ++i) { |
|
|
|
|
if(!finishedList->isColumnHidden(i)) { |
|
|
|
|
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)+(finishedList->columnWidth(index)/nbVisibleColumns))); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|