mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- FEATURE: Resizing a column in a search results tab affects all tabs
- FEATURE: Search results tab columns are now remembered upon startup
This commit is contained in:
parent
1421f1450c
commit
a2bcfa9192
@ -1,6 +1,8 @@
|
|||||||
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.4.0
|
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.4.0
|
||||||
- FEATURE: Allow to define temporary download folder
|
- FEATURE: Allow to define temporary download folder
|
||||||
- FEATURE: Display total amount of uploaded data in finished list
|
- FEATURE: Display total amount of uploaded data in finished list
|
||||||
|
- FEATURE: Resizing a column in a search results tab affects all tabs
|
||||||
|
- FEATURE: Search results tab columns are now remembered upon startup
|
||||||
- COSMETIC: Redesigned program preferences
|
- COSMETIC: Redesigned program preferences
|
||||||
- COSMETIC: Updated icons set
|
- COSMETIC: Updated icons set
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ void FinishedTorrents::saveColWidthFinishedList() const{
|
|||||||
width_list = line.split(' ');
|
width_list = line.split(' ');
|
||||||
}
|
}
|
||||||
for(short i=0; i<nbColumns; ++i){
|
for(short i=0; i<nbColumns; ++i){
|
||||||
if(finishedList->columnWidth(i)<1 && width_list.size() == finishedListModel->columnCount()-1 && width_list.at(i).toInt()>=1) {
|
if(finishedList->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
|
||||||
// load the former width
|
// load the former width
|
||||||
new_width_list << width_list.at(i);
|
new_width_list << width_list.at(i);
|
||||||
} else if(finishedList->columnWidth(i)>=1) {
|
} else if(finishedList->columnWidth(i)>=1) {
|
||||||
|
@ -65,19 +65,36 @@ SearchTab::SearchTab(SearchEngine *parent) : QWidget()
|
|||||||
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
|
connect(resultsBrowser->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortSearchList(int)));
|
||||||
|
|
||||||
// Load last columns width for search results list
|
// Load last columns width for search results list
|
||||||
if(!loadColWidthSearchList()){
|
if(!loadColWidthResultsList()){
|
||||||
resultsBrowser->header()->resizeSection(0, 275);
|
resultsBrowser->header()->resizeSection(0, 275);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchTab::~SearchTab()
|
SearchTab::~SearchTab() {
|
||||||
{
|
|
||||||
saveColWidthSearchList();
|
|
||||||
delete resultsBrowser;
|
delete resultsBrowser;
|
||||||
delete SearchListModel;
|
delete SearchListModel;
|
||||||
delete SearchDelegate;
|
delete SearchDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHeaderView* SearchTab::header() const {
|
||||||
|
return resultsBrowser->header();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SearchTab::loadColWidthResultsList() {
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
QString line = settings.value("SearchResultsColsWidth", QString()).toString();
|
||||||
|
if(line.isEmpty())
|
||||||
|
return false;
|
||||||
|
QStringList width_list = line.split(' ');
|
||||||
|
if(width_list.size() < SearchListModel->columnCount())
|
||||||
|
return false;
|
||||||
|
unsigned int listSize = width_list.size();
|
||||||
|
for(unsigned int i=0; i<listSize; ++i){
|
||||||
|
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QLabel* SearchTab::getCurrentLabel()
|
QLabel* SearchTab::getCurrentLabel()
|
||||||
{
|
{
|
||||||
return results_lbl;
|
return results_lbl;
|
||||||
@ -157,33 +174,3 @@ void SearchTab::sortSearchListString(int index, Qt::SortOrder sortOrder){
|
|||||||
SearchListModel->removeRows(0, nbRows_old);
|
SearchListModel->removeRows(0, nbRows_old);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save columns width in a file to remember them
|
|
||||||
// (download list)
|
|
||||||
void SearchTab::saveColWidthSearchList() const{
|
|
||||||
qDebug("Saving columns width in search list");
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QStringList width_list;
|
|
||||||
for(int i=0; i<SearchListModel->columnCount(); ++i){
|
|
||||||
width_list << misc::toQString(resultsBrowser->columnWidth(i));
|
|
||||||
}
|
|
||||||
settings.setValue("SearchListColsWidth", width_list.join(" "));
|
|
||||||
qDebug("Search list columns width saved");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load columns width in a file that were saved previously
|
|
||||||
// (search list)
|
|
||||||
bool SearchTab::loadColWidthSearchList(){
|
|
||||||
qDebug("Loading columns width for search list");
|
|
||||||
QSettings settings("qBittorrent", "qBittorrent");
|
|
||||||
QString line = settings.value("SearchListColsWidth", QString()).toString();
|
|
||||||
if(line.isEmpty())
|
|
||||||
return false;
|
|
||||||
QStringList width_list = line.split(' ');
|
|
||||||
if(width_list.size() != SearchListModel->columnCount())
|
|
||||||
return false;
|
|
||||||
for(int i=0; i<width_list.size(); ++i){
|
|
||||||
resultsBrowser->header()->resizeSection(i, width_list.at(i).toInt());
|
|
||||||
}
|
|
||||||
qDebug("Search list columns width loaded");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -42,16 +42,17 @@ class SearchTab : public QWidget, public Ui::search_engine
|
|||||||
public:
|
public:
|
||||||
SearchTab(SearchEngine *parent);
|
SearchTab(SearchEngine *parent);
|
||||||
~SearchTab();
|
~SearchTab();
|
||||||
bool loadColWidthSearchList();
|
bool loadColWidthResultsList();
|
||||||
QLabel * getCurrentLabel();
|
QLabel * getCurrentLabel();
|
||||||
QStandardItemModel * getCurrentSearchListModel();
|
QStandardItemModel * getCurrentSearchListModel();
|
||||||
QTreeView * getCurrentTreeView();
|
QTreeView * getCurrentTreeView();
|
||||||
void setRowColor(int row, QString color);
|
void setRowColor(int row, QString color);
|
||||||
|
QHeaderView* header() const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void sortSearchList(int index);
|
void sortSearchList(int index);
|
||||||
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
|
void sortSearchListInt(int index, Qt::SortOrder sortOrder);
|
||||||
void sortSearchListString(int index, Qt::SortOrder sortOrder);
|
void sortSearchListString(int index, Qt::SortOrder sortOrder);
|
||||||
void saveColWidthSearchList() const;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -152,6 +152,7 @@ void SearchEngine::on_search_button_clicked(){
|
|||||||
}
|
}
|
||||||
// Tab Addition
|
// Tab Addition
|
||||||
currentSearchTab=new SearchTab(this);
|
currentSearchTab=new SearchTab(this);
|
||||||
|
connect(currentSearchTab->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(propagateSectionResized(int,int,int)));
|
||||||
all_tab.append(currentSearchTab);
|
all_tab.append(currentSearchTab);
|
||||||
tabWidget->addTab(currentSearchTab, pattern);
|
tabWidget->addTab(currentSearchTab, pattern);
|
||||||
tabWidget->setCurrentWidget(currentSearchTab);
|
tabWidget->setCurrentWidget(currentSearchTab);
|
||||||
@ -188,6 +189,42 @@ void SearchEngine::on_search_button_clicked(){
|
|||||||
searchTimeout->start(180000); // 3min
|
searchTimeout->start(180000); // 3min
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SearchEngine::propagateSectionResized(int index, int , int newsize) {
|
||||||
|
foreach(SearchTab * tab, all_tab) {
|
||||||
|
tab->getCurrentTreeView()->setColumnWidth(index, newsize);
|
||||||
|
}
|
||||||
|
saveResultsColumnsWidth();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SearchEngine::saveResultsColumnsWidth() {
|
||||||
|
if(all_tab.size() > 0) {
|
||||||
|
QTreeView* treeview = all_tab.first()->getCurrentTreeView();
|
||||||
|
QSettings settings("qBittorrent", "qBittorrent");
|
||||||
|
QStringList width_list;
|
||||||
|
QStringList new_width_list;
|
||||||
|
short nbColumns = all_tab.first()->getCurrentSearchListModel()->columnCount();
|
||||||
|
|
||||||
|
QString line = settings.value("SearchResultsColsWidth", QString()).toString();
|
||||||
|
if(!line.isEmpty()) {
|
||||||
|
width_list = line.split(' ');
|
||||||
|
}
|
||||||
|
for(short i=0; i<nbColumns; ++i){
|
||||||
|
if(treeview->columnWidth(i)<1 && width_list.size() == nbColumns && width_list.at(i).toInt()>=1) {
|
||||||
|
// load the former width
|
||||||
|
new_width_list << width_list.at(i);
|
||||||
|
} else if(treeview->columnWidth(i)>=1) {
|
||||||
|
// usual case, save the current width
|
||||||
|
new_width_list << QString::fromUtf8(misc::toString(treeview->columnWidth(i)).c_str());
|
||||||
|
} else {
|
||||||
|
// default width
|
||||||
|
treeview->resizeColumnToContents(i);
|
||||||
|
new_width_list << QString::fromUtf8(misc::toString(treeview->columnWidth(i)).c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settings.setValue("SearchResultsColsWidth", new_width_list.join(" "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SearchEngine::searchStarted(){
|
void SearchEngine::searchStarted(){
|
||||||
// Update SearchEngine widgets
|
// Update SearchEngine widgets
|
||||||
search_status->setText(tr("Searching..."));
|
search_status->setText(tr("Searching..."));
|
||||||
|
@ -81,6 +81,8 @@ class SearchEngine : public QWidget, public Ui::search_engine{
|
|||||||
void saveSearchHistory();
|
void saveSearchHistory();
|
||||||
void on_enginesButton_clicked();
|
void on_enginesButton_clicked();
|
||||||
void on_clearPatternButton_clicked();
|
void on_clearPatternButton_clicked();
|
||||||
|
void propagateSectionResized(int index, int oldsize , int newsize);
|
||||||
|
void saveResultsColumnsWidth();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user