mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
- Added columns width saving to torrent addition dialog
- Fixed column width saving in torrent properties - Code Cleanup
This commit is contained in:
parent
5d09f89a0f
commit
743d54a745
3 changed files with 27 additions and 6 deletions
|
@ -43,7 +43,7 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
// Defines for properties list columns
|
// Defines for properties list columns
|
||||||
enum PropColumn {NAME, SIZE, PROGRESS, PRIORITY, INDEX};
|
enum PropColumn {NAME, SIZE, PROGRESS, PRIORITY};
|
||||||
enum PropPriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7};
|
enum PropPriority {IGNORED=0, NORMAL=1, HIGH=2, MAXIMUM=7};
|
||||||
|
|
||||||
class PropListDelegate: public QItemDelegate {
|
class PropListDelegate: public QItemDelegate {
|
||||||
|
|
|
@ -65,7 +65,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
||||||
// Set Properties list model
|
// Set Properties list model
|
||||||
PropListModel = new TorrentFilesModel();
|
PropListModel = new TorrentFilesModel();
|
||||||
filesList->setModel(PropListModel);
|
filesList->setModel(PropListModel);
|
||||||
filesList->hideColumn(INDEX);
|
|
||||||
PropDelegate = new PropListDelegate(0);
|
PropDelegate = new PropListDelegate(0);
|
||||||
filesList->setItemDelegate(PropDelegate);
|
filesList->setItemDelegate(PropDelegate);
|
||||||
|
|
||||||
|
@ -217,7 +216,7 @@ void PropertiesWidget::saveSettings() {
|
||||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
||||||
QVariantList contentColsWidths;
|
QVariantList contentColsWidths;
|
||||||
for(int i=0; i<PropListModel->columnCount()-1; ++i) {
|
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
||||||
contentColsWidths.append(filesList->columnWidth(i));
|
contentColsWidths.append(filesList->columnWidth(i));
|
||||||
}
|
}
|
||||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
||||||
|
|
|
@ -74,7 +74,6 @@ public:
|
||||||
PropListModel = new TorrentFilesModel();
|
PropListModel = new TorrentFilesModel();
|
||||||
torrentContentList->setModel(PropListModel);
|
torrentContentList->setModel(PropListModel);
|
||||||
torrentContentList->hideColumn(PROGRESS);
|
torrentContentList->hideColumn(PROGRESS);
|
||||||
torrentContentList->hideColumn(INDEX);
|
|
||||||
PropDelegate = new PropListDelegate();
|
PropDelegate = new PropListDelegate();
|
||||||
torrentContentList->setItemDelegate(PropDelegate);
|
torrentContentList->setItemDelegate(PropDelegate);
|
||||||
connect(torrentContentList, SIGNAL(clicked(const QModelIndex&)), torrentContentList, SLOT(edit(const QModelIndex&)));
|
connect(torrentContentList, SIGNAL(clicked(const QModelIndex&)), torrentContentList, SLOT(edit(const QModelIndex&)));
|
||||||
|
@ -85,8 +84,8 @@ public:
|
||||||
connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection()));
|
connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection()));
|
||||||
connect(collapseAllButton, SIGNAL(clicked()), torrentContentList, SLOT(collapseAll()));
|
connect(collapseAllButton, SIGNAL(clicked()), torrentContentList, SLOT(collapseAll()));
|
||||||
connect(expandAllButton, SIGNAL(clicked()), torrentContentList, SLOT(expandAll()));
|
connect(expandAllButton, SIGNAL(clicked()), torrentContentList, SLOT(expandAll()));
|
||||||
// FIXME: Remember columns width
|
// Remember columns width
|
||||||
torrentContentList->header()->resizeSection(0, 200);
|
readSettings();
|
||||||
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
|
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
|
||||||
QString home = QDir::homePath();
|
QString home = QDir::homePath();
|
||||||
if(home[home.length()-1] != QDir::separator()){
|
if(home[home.length()-1] != QDir::separator()){
|
||||||
|
@ -101,10 +100,33 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
~torrentAdditionDialog() {
|
~torrentAdditionDialog() {
|
||||||
|
saveSettings();
|
||||||
delete PropDelegate;
|
delete PropDelegate;
|
||||||
delete PropListModel;
|
delete PropListModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readSettings() {
|
||||||
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
QVariantList contentColsWidths = settings.value(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), QVariantList()).toList();
|
||||||
|
if(contentColsWidths.empty()) {
|
||||||
|
torrentContentList->header()->resizeSection(0, 200);
|
||||||
|
} else {
|
||||||
|
for(int i=0; i<contentColsWidths.size(); ++i) {
|
||||||
|
torrentContentList->setColumnWidth(i, contentColsWidths.at(i).toInt());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void saveSettings() {
|
||||||
|
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||||
|
QVariantList contentColsWidths;
|
||||||
|
// -1 because we hid PROGRESS column
|
||||||
|
for(int i=0; i<PropListModel->columnCount()-1; ++i) {
|
||||||
|
contentColsWidths.append(torrentContentList->columnWidth(i));
|
||||||
|
}
|
||||||
|
settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), contentColsWidths);
|
||||||
|
}
|
||||||
|
|
||||||
void showLoad(QString filePath, QString from_url=QString::null){
|
void showLoad(QString filePath, QString from_url=QString::null){
|
||||||
if(!QFile::exists(filePath)) {
|
if(!QFile::exists(filePath)) {
|
||||||
close();
|
close();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue