mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-08 22:07:53 +00: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
@ -43,7 +43,7 @@
|
||||
#include "misc.h"
|
||||
|
||||
// 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};
|
||||
|
||||
class PropListDelegate: public QItemDelegate {
|
||||
|
@ -65,7 +65,6 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transfer
|
||||
// Set Properties list model
|
||||
PropListModel = new TorrentFilesModel();
|
||||
filesList->setModel(PropListModel);
|
||||
filesList->hideColumn(INDEX);
|
||||
PropDelegate = new PropListDelegate(0);
|
||||
filesList->setItemDelegate(PropDelegate);
|
||||
|
||||
@ -217,7 +216,7 @@ void PropertiesWidget::saveSettings() {
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
settings.setValue("TorrentProperties/Visible", state==VISIBLE);
|
||||
QVariantList contentColsWidths;
|
||||
for(int i=0; i<PropListModel->columnCount()-1; ++i) {
|
||||
for(int i=0; i<PropListModel->columnCount(); ++i) {
|
||||
contentColsWidths.append(filesList->columnWidth(i));
|
||||
}
|
||||
settings.setValue(QString::fromUtf8("TorrentProperties/filesColsWidth"), contentColsWidths);
|
||||
|
@ -74,7 +74,6 @@ public:
|
||||
PropListModel = new TorrentFilesModel();
|
||||
torrentContentList->setModel(PropListModel);
|
||||
torrentContentList->hideColumn(PROGRESS);
|
||||
torrentContentList->hideColumn(INDEX);
|
||||
PropDelegate = new PropListDelegate();
|
||||
torrentContentList->setItemDelegate(PropDelegate);
|
||||
connect(torrentContentList, SIGNAL(clicked(const QModelIndex&)), torrentContentList, SLOT(edit(const QModelIndex&)));
|
||||
@ -85,8 +84,8 @@ public:
|
||||
connect(actionMaximum, SIGNAL(triggered()), this, SLOT(maximumSelection()));
|
||||
connect(collapseAllButton, SIGNAL(clicked()), torrentContentList, SLOT(collapseAll()));
|
||||
connect(expandAllButton, SIGNAL(clicked()), torrentContentList, SLOT(expandAll()));
|
||||
// FIXME: Remember columns width
|
||||
torrentContentList->header()->resizeSection(0, 200);
|
||||
// Remember columns width
|
||||
readSettings();
|
||||
//torrentContentList->header()->setResizeMode(0, QHeaderView::Stretch);
|
||||
QString home = QDir::homePath();
|
||||
if(home[home.length()-1] != QDir::separator()){
|
||||
@ -101,10 +100,33 @@ public:
|
||||
}
|
||||
|
||||
~torrentAdditionDialog() {
|
||||
saveSettings();
|
||||
delete PropDelegate;
|
||||
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){
|
||||
if(!QFile::exists(filePath)) {
|
||||
close();
|
||||
|
Loading…
Reference in New Issue
Block a user