mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-09 22:37:59 +00:00
remember sorted columns in download list
This commit is contained in:
parent
9808e5a37a
commit
2985fa921a
44
src/GUI.cpp
44
src/GUI.cpp
@ -131,10 +131,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
downloadList->setItemDelegate(DLDelegate);
|
downloadList->setItemDelegate(DLDelegate);
|
||||||
// Hide hash column
|
// Hide hash column
|
||||||
downloadList->hideColumn(HASH);
|
downloadList->hideColumn(HASH);
|
||||||
// Load last columns width for download list
|
|
||||||
if(!loadColWidthDLList()){
|
|
||||||
downloadList->header()->resizeSection(0, 200);
|
|
||||||
}
|
|
||||||
#ifndef NO_UPNP
|
#ifndef NO_UPNP
|
||||||
connect(&BTSession, SIGNAL(noWanServiceDetected()), this, SLOT(displayNoUPnPWanServiceDetected()));
|
connect(&BTSession, SIGNAL(noWanServiceDetected()), this, SLOT(displayNoUPnPWanServiceDetected()));
|
||||||
connect(&BTSession, SIGNAL(wanServiceDetected()), this, SLOT(displayUPnPWanServiceDetected()));
|
connect(&BTSession, SIGNAL(wanServiceDetected()), this, SLOT(displayUPnPWanServiceDetected()));
|
||||||
@ -159,6 +156,10 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent){
|
|||||||
connect(&BTSession, SIGNAL(updateFileSize(QString)), this, SLOT(updateFileSize(QString)));
|
connect(&BTSession, SIGNAL(updateFileSize(QString)), this, SLOT(updateFileSize(QString)));
|
||||||
// Resume unfinished torrents
|
// Resume unfinished torrents
|
||||||
BTSession.resumeUnfinishedTorrents();
|
BTSession.resumeUnfinishedTorrents();
|
||||||
|
// Load last columns width for download list
|
||||||
|
if(!loadColWidthDLList()){
|
||||||
|
downloadList->header()->resizeSection(0, 200);
|
||||||
|
}
|
||||||
// Add torrent given on command line
|
// Add torrent given on command line
|
||||||
processParams(torrentCmdLine);
|
processParams(torrentCmdLine);
|
||||||
// Make download list header clickable for sorting
|
// Make download list header clickable for sorting
|
||||||
@ -631,16 +632,29 @@ void GUI::sortDownloadListString(int index, Qt::SortOrder sortOrder){
|
|||||||
DLListModel->removeRows(0, nbRows_old);
|
DLListModel->removeRows(0, nbRows_old);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::sortDownloadList(int index){
|
void GUI::sortDownloadList(int index, Qt::SortOrder startSortOrder, bool fromLoadColWidth){
|
||||||
static Qt::SortOrder sortOrder = Qt::AscendingOrder;
|
static Qt::SortOrder sortOrder = startSortOrder;
|
||||||
if(downloadList->header()->sortIndicatorSection() == index){
|
if(!fromLoadColWidth && downloadList->header()->sortIndicatorSection() == index){
|
||||||
if(sortOrder == Qt::AscendingOrder){
|
if(sortOrder == Qt::AscendingOrder){
|
||||||
sortOrder = Qt::DescendingOrder;
|
sortOrder = Qt::DescendingOrder;
|
||||||
}else{
|
}else{
|
||||||
sortOrder = Qt::AscendingOrder;
|
sortOrder = Qt::AscendingOrder;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
downloadList->header()->setSortIndicator(index, sortOrder);
|
QString sortOrderLetter;
|
||||||
|
if(sortOrder == Qt::AscendingOrder)
|
||||||
|
sortOrderLetter = "a";
|
||||||
|
else
|
||||||
|
sortOrderLetter = "d";
|
||||||
|
if(fromLoadColWidth) {
|
||||||
|
// XXX: Why is this needed?
|
||||||
|
if(sortOrder == Qt::DescendingOrder)
|
||||||
|
downloadList->header()->setSortIndicator(index, Qt::AscendingOrder);
|
||||||
|
else
|
||||||
|
downloadList->header()->setSortIndicator(index, Qt::DescendingOrder);
|
||||||
|
} else {
|
||||||
|
downloadList->header()->setSortIndicator(index, sortOrder);
|
||||||
|
}
|
||||||
switch(index){
|
switch(index){
|
||||||
case SIZE:
|
case SIZE:
|
||||||
case ETA:
|
case ETA:
|
||||||
@ -652,6 +666,8 @@ void GUI::sortDownloadList(int index){
|
|||||||
default:
|
default:
|
||||||
sortDownloadListString(index, sortOrder);
|
sortDownloadListString(index, sortOrder);
|
||||||
}
|
}
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
settings.setValue("DownloadListSortedCol", QString(misc::toString(index).c_str())+sortOrderLetter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle Main window visibility
|
// Toggle Main window visibility
|
||||||
@ -719,6 +735,18 @@ bool GUI::loadColWidthDLList(){
|
|||||||
for(unsigned int i=0; i<listSize; ++i){
|
for(unsigned int i=0; i<listSize; ++i){
|
||||||
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
|
downloadList->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
}
|
}
|
||||||
|
// Loading last sorted column
|
||||||
|
QString sortedCol = settings.value("DownloadListSortedCol", QString()).toString();
|
||||||
|
if(!sortedCol.isEmpty()){
|
||||||
|
Qt::SortOrder sortOrder;
|
||||||
|
if(sortedCol.endsWith("d"))
|
||||||
|
sortOrder = Qt::DescendingOrder;
|
||||||
|
else
|
||||||
|
sortOrder = Qt::AscendingOrder;
|
||||||
|
sortedCol = sortedCol.left(sortedCol.size()-1);
|
||||||
|
int index = sortedCol.toInt();
|
||||||
|
sortDownloadList(index, sortOrder, true);
|
||||||
|
}
|
||||||
qDebug("Download list columns width loaded");
|
qDebug("Download list columns width loaded");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{
|
|||||||
void acceptConnection();
|
void acceptConnection();
|
||||||
void saveColWidthDLList() const;
|
void saveColWidthDLList() const;
|
||||||
bool loadColWidthDLList();
|
bool loadColWidthDLList();
|
||||||
void sortDownloadList(int index);
|
void sortDownloadList(int index, Qt::SortOrder startSortOrder=Qt::AscendingOrder, bool fromLoadColWidth=false);
|
||||||
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
|
void sortDownloadListFloat(int index, Qt::SortOrder sortOrder);
|
||||||
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
|
void sortDownloadListString(int index, Qt::SortOrder sortOrder);
|
||||||
void displayDLListMenu(const QPoint& pos);
|
void displayDLListMenu(const QPoint& pos);
|
||||||
|
Loading…
Reference in New Issue
Block a user