Browse Source

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

adaptive-webui-19844
Christophe Dumez 18 years ago
parent
commit
762df4b914
  1. 3
      TODO
  2. 38
      src/FinishedTorrents.cpp
  3. 2
      src/FinishedTorrents.h

3
TODO

@ -46,4 +46,5 @@ @@ -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

38
src/FinishedTorrents.cpp

@ -43,6 +43,10 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ @@ -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){ @@ -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){ @@ -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;

2
src/FinishedTorrents.h

@ -44,6 +44,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding{ @@ -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{ @@ -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();

Loading…
Cancel
Save