- Added columns width saving to torrent addition dialog

- Fixed column width saving in torrent properties
- Code Cleanup
This commit is contained in:
Christophe Dumez
2009-11-11 14:19:44 +00:00
parent 5d09f89a0f
commit 743d54a745
3 changed files with 27 additions and 6 deletions

View File

@@ -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();