- Columns width are now remembered on restart for the finished torrent list

This commit is contained in:
Christophe Dumez 2007-04-11 13:10:13 +00:00
parent 4a57037c47
commit 762df4b914
3 changed files with 42 additions and 1 deletions

3
TODO
View file

@ -46,4 +46,5 @@
- Get upload/download limit per torrent (uncomment some code)
- Improve ratio display / calculation / saving / per torrent...
- Use buttonboxes when possible
- Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list
- Display the sum of the size of the selected files in the torrent instead of the whole torrent size in download list
- Support column sorting in finished list

View file

@ -43,6 +43,10 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
finishedList->setModel(finishedListModel);
// Hide hash column
finishedList->hideColumn(HASH);
// Load last columns width for download list
if(!loadColWidthFinishedList()){
finishedList->header()->resizeSection(0, 200);
}
finishedListDelegate = new DLListDelegate();
finishedList->setItemDelegate(finishedListDelegate);
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
@ -58,6 +62,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){
}
FinishedTorrents::~FinishedTorrents(){
saveColWidthFinishedList();
delete finishedListDelegate;
delete finishedListModel;
}
@ -106,6 +111,39 @@ void FinishedTorrents::setRowColor(int row, const QString& color){
}
}
// Load columns width in a file that were saved previously
// (finished list)
bool FinishedTorrents::loadColWidthFinishedList(){
qDebug("Loading columns width for finished list");
QSettings settings("qBittorrent", "qBittorrent");
QString line = settings.value("FinishedListColsWidth", QString()).toString();
if(line.isEmpty())
return false;
QStringList width_list = line.split(' ');
if(width_list.size() != finishedListModel->columnCount())
return false;
unsigned int listSize = width_list.size();
for(unsigned int i=0; i<listSize; ++i){
finishedList->header()->resizeSection(i, width_list.at(i).toInt());
}
qDebug("Finished list columns width loaded");
return true;
}
// Save columns width in a file to remember them
// (finished list)
void FinishedTorrents::saveColWidthFinishedList() const{
qDebug("Saving columns width in finished list");
QSettings settings("qBittorrent", "qBittorrent");
QStringList width_list;
unsigned int nbColumns = finishedListModel->columnCount();
for(unsigned int i=0; i<nbColumns; ++i){
width_list << QString(misc::toString(finishedList->columnWidth(i)).c_str());
}
settings.setValue("FinishedListColsWidth", width_list.join(" "));
qDebug("Finished list columns width saved");
}
void FinishedTorrents::on_actionSet_upload_limit_triggered(){
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes();
QModelIndex index;

View file

@ -44,6 +44,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
QStringList getFinishedSHAs();
QTreeView* getFinishedList();
QStandardItemModel* getFinishedListModel();
bool loadColWidthFinishedList();
public slots:
void addFinishedSHA(QString sha);
@ -53,6 +54,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{
void propertiesSelection();
void displayFinishedListMenu(const QPoint&);
void setRowColor(int row, const QString& color);
void saveColWidthFinishedList() const;
protected slots:
void on_actionSet_upload_limit_triggered();