Browse Source

feature : allow to hide/show columns

adaptive-webui-19844
Arnaud Demaiziere 17 years ago
parent
commit
b8200fd7b2
  1. 1
      Changelog
  2. 187
      src/FinishedTorrents.cpp
  3. 11
      src/FinishedTorrents.h
  4. 45
      src/download.ui
  5. 197
      src/downloadingTorrents.cpp
  6. 13
      src/downloadingTorrents.h
  7. 35
      src/seeding.ui

1
Changelog

@ -1,4 +1,5 @@
* Tuesday October 06 2007 - Christophe Dumez <chris@qbittorrent.org> - v1.1.0 * Tuesday October 06 2007 - Christophe Dumez <chris@qbittorrent.org> - v1.1.0
- FEATURE: Allow to hide/show some columns in download and seeding lists
- FEATURE: Option to start qBittorrent minimized in systray - FEATURE: Option to start qBittorrent minimized in systray
- FEATURE: Allow to define double-click actions in torrents lists - FEATURE: Allow to define double-click actions in torrents lists
- FEATURE: Allow to open torrent destination folder - FEATURE: Allow to open torrent destination folder

187
src/FinishedTorrents.cpp

@ -45,6 +45,7 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
finishedListModel->setHeaderData(F_SEEDSLEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources")); finishedListModel->setHeaderData(F_SEEDSLEECH, Qt::Horizontal, tr("Leechers", "i.e: full/partial sources"));
finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio")); finishedListModel->setHeaderData(F_RATIO, Qt::Horizontal, tr("Ratio"));
finishedList->setModel(finishedListModel); finishedList->setModel(finishedListModel);
loadHiddenColumns();
// Hide ETA & hash column // Hide ETA & hash column
finishedList->hideColumn(F_HASH); finishedList->hideColumn(F_HASH);
// Load last columns width for download list // Load last columns width for download list
@ -71,10 +72,19 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered())); connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder())); connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder()));
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection())); connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
connect(actionHOSColProgress, SIGNAL(triggered()), this, SLOT(hideOrShowColumnProgress()));
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
connect(actionHOSColLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnLeechers()));
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
connect(actionResizeAllColumns, SIGNAL(triggered()), this, SLOT(resetAllColumns()));
} }
FinishedTorrents::~FinishedTorrents(){ FinishedTorrents::~FinishedTorrents(){
saveColWidthFinishedList(); saveColWidthFinishedList();
saveHiddenColumns();
delete finishedListDelegate; delete finishedListDelegate;
delete finishedListModel; delete finishedListModel;
} }
@ -157,7 +167,7 @@ bool FinishedTorrents::loadColWidthFinishedList(){
if(line.isEmpty()) if(line.isEmpty())
return false; return false;
QStringList width_list = line.split(' '); QStringList width_list = line.split(' ');
if(width_list.size() != finishedListModel->columnCount()-1) if(width_list.size() < finishedListModel->columnCount()-1)
return false; return false;
unsigned int listSize = width_list.size(); unsigned int listSize = width_list.size();
for(unsigned int i=0; i<listSize; ++i){ for(unsigned int i=0; i<listSize; ++i){
@ -173,11 +183,27 @@ void FinishedTorrents::saveColWidthFinishedList() const{
qDebug("Saving columns width in finished list"); qDebug("Saving columns width in finished list");
QSettings settings("qBittorrent", "qBittorrent"); QSettings settings("qBittorrent", "qBittorrent");
QStringList width_list; QStringList width_list;
unsigned int nbColumns = finishedListModel->columnCount()-1; QStringList new_width_list;
for(unsigned int i=0; i<nbColumns; ++i){ short nbColumns = finishedListModel->columnCount()-1;
width_list << QString::fromUtf8(misc::toString(finishedList->columnWidth(i)).c_str());
QString line = settings.value("FinishedListColsWidth", QString()).toString();
if(!line.isEmpty()) {
width_list = line.split(' ');
}
for(short i=0; i<nbColumns; ++i){
if(finishedList->columnWidth(i)<1 && width_list.size() == finishedListModel->columnCount()-1 && width_list.at(i).toInt()>=1) {
// load the former width
new_width_list << width_list.at(i);
} else if(finishedList->columnWidth(i)>=1) {
// usual case, save the current width
new_width_list << QString::fromUtf8(misc::toString(finishedList->columnWidth(i)).c_str());
} else {
// default width
finishedList->resizeColumnToContents(i);
new_width_list << QString::fromUtf8(misc::toString(finishedList->columnWidth(i)).c_str());
}
} }
settings.setValue("FinishedListColsWidth", width_list.join(" ")); settings.setValue("FinishedListColsWidth", new_width_list.join(" "));
qDebug("Finished list columns width saved"); qDebug("Finished list columns width saved");
} }
@ -355,11 +381,162 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
myFinishedListMenu.addSeparator(); myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionOpen_destination_folder); myFinishedListMenu.addAction(actionOpen_destination_folder);
myFinishedListMenu.addAction(actionTorrent_Properties); myFinishedListMenu.addAction(actionTorrent_Properties);
// hide/show columns menu
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column"));
for(int i=0; i<=F_RATIO; i++) {
hideshowColumn.addAction(getActionHoSCol(i));
}
hideshowColumn.addAction(actionResizeAllColumns);
myFinishedListMenu.addMenu(&hideshowColumn);
// Call menu // Call menu
// XXX: why mapToGlobal() is not enough? // XXX: why mapToGlobal() is not enough?
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55)); myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
} }
/*
* Hiding Columns functions
*/
// toggle hide/show a column
void FinishedTorrents::hideOrShowColumn(int index) {
if(!finishedList->isColumnHidden(index)) {
unsigned short i=0, nbColDisplayed = 0;
while(i<finishedListModel->columnCount()-1 && nbColDisplayed<=1) {
if(!finishedList->isColumnHidden(i))
nbColDisplayed++;
i++;
}
// can't hide a lonely column
if(nbColDisplayed>1) {
finishedList->setColumnHidden(index, true);
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
}
} else {
//short buf_width = finishedList->columnWidth(index);
short nbColumns = 0;
finishedList->setColumnHidden(index, false);
/*finishedList->resizeColumnToContents(index);
if(finishedList->columnWidth(index)<buf_width)
finishedList->setColumnWidth(index, buf_width);*/
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
//resize all others non-hidden columns
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(finishedList->isColumnHidden(i))
nbColumns++;
}
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(i != index) {
finishedList->setColumnWidth(i, floor(finishedList->columnWidth(i)-(finishedList->columnWidth(index)/(nbColumns-1))));
}
}
}
}
void FinishedTorrents::hideOrShowColumnName() {
hideOrShowColumn(F_NAME);
}
void FinishedTorrents::hideOrShowColumnSize() {
hideOrShowColumn(F_SIZE);
}
void FinishedTorrents::hideOrShowColumnProgress() {
hideOrShowColumn(F_PROGRESS);
}
void FinishedTorrents::hideOrShowColumnUpSpeed() {
hideOrShowColumn(F_UPSPEED);
}
void FinishedTorrents::hideOrShowColumnLeechers() {
hideOrShowColumn(F_SEEDSLEECH);
}
void FinishedTorrents::hideOrShowColumnRatio() {
hideOrShowColumn(F_RATIO);
}
void FinishedTorrents::resetAllColumns() {
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
finishedList->setColumnHidden(i, false);
finishedList->resizeColumnToContents(i);
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
}
finishedList->setColumnWidth(F_NAME,270);
}
// load the previous settings, and hide the columns
bool FinishedTorrents::loadHiddenColumns() {
bool loaded = false;
QSettings settings("qBittorrent", "qBittorrent");
QString line = settings.value("FinishedListColsHoS", QString()).toString();
QStringList ishidden_list;
if(!line.isEmpty()) {
ishidden_list = line.split(' ');
if(ishidden_list.size() == finishedListModel->columnCount()-1) {
unsigned int listSize = ishidden_list.size();
for(unsigned int i=0; i<listSize; ++i){
finishedList->header()->resizeSection(i, ishidden_list.at(i).toInt());
}
loaded = true;
}
}
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(loaded && ishidden_list.at(i) == "0") {
finishedList->setColumnHidden(i, true);
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
} else {
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
}
}
return loaded;
}
// save the hidden columns in settings
void FinishedTorrents::saveHiddenColumns() {
QSettings settings("qBittorrent", "qBittorrent");
QStringList ishidden_list;
short nbColumns = finishedListModel->columnCount()-1;
for(short i=0; i<nbColumns; ++i){
if(finishedList->isColumnHidden(i)) {
ishidden_list << QString::fromUtf8(misc::toString(0).c_str());
} else {
ishidden_list << QString::fromUtf8(misc::toString(1).c_str());
}
}
settings.setValue("FinishedListColsHoS", ishidden_list.join(" "));
}
// getter, return the action hide or show whose id is index
QAction* FinishedTorrents::getActionHoSCol(int index) {
switch(index) {
case F_NAME :
return actionHOSColName;
break;
case F_SIZE :
return actionHOSColSize;
break;
case F_PROGRESS :
return actionHOSColProgress;
break;
case F_UPSPEED :
return actionHOSColUpSpeed;
break;
case F_SEEDSLEECH :
return actionHOSColLeechers;
break;
case F_RATIO :
return actionHOSColRatio;
break;
default :
return NULL;
}
}
/* /*
* Sorting functions * Sorting functions
*/ */

11
src/FinishedTorrents.h

@ -39,6 +39,10 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
FinishedListDelegate *finishedListDelegate; FinishedListDelegate *finishedListDelegate;
QStandardItemModel *finishedListModel; QStandardItemModel *finishedListModel;
unsigned int nbFinished; unsigned int nbFinished;
void hideOrShowColumn(int index);
bool loadHiddenColumns();
void saveHiddenColumns();
QAction* getActionHoSCol(int index);
public: public:
FinishedTorrents(QObject *parent, bittorrent *BTSession); FinishedTorrents(QObject *parent, bittorrent *BTSession);
@ -71,6 +75,13 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void propertiesSelection(); void propertiesSelection();
void deleteTorrent(QString hash); void deleteTorrent(QString hash);
void showPropertiesFromHash(QString hash); void showPropertiesFromHash(QString hash);
void hideOrShowColumnName();
void hideOrShowColumnSize();
void hideOrShowColumnProgress();
void hideOrShowColumnUpSpeed();
void hideOrShowColumnLeechers();
void hideOrShowColumnRatio();
void resetAllColumns();
signals: signals:
void torrentMovedFromFinishedList(QString); void torrentMovedFromFinishedList(QString);

45
src/download.ui

@ -388,6 +388,51 @@
<string>Open destination folder</string> <string>Open destination folder</string>
</property> </property>
</action> </action>
<action name="actionHOSColName" >
<property name="text" >
<string>Name</string>
</property>
</action>
<action name="actionHOSColSize" >
<property name="text" >
<string>Size</string>
</property>
</action>
<action name="actionHOSColProgress" >
<property name="text" >
<string>Progress</string>
</property>
</action>
<action name="actionHOSColDownSpeed" >
<property name="text" >
<string>DLSpeed</string>
</property>
</action>
<action name="actionHOSColUpSpeed" >
<property name="text" >
<string>UpSpeed</string>
</property>
</action>
<action name="actionHOSColSeedersLeechers" >
<property name="text" >
<string>Seeds/Leechs</string>
</property>
</action>
<action name="actionHOSColRatio" >
<property name="text" >
<string>Ratio</string>
</property>
</action>
<action name="actionHOSColEta" >
<property name="text" >
<string>ETA</string>
</property>
</action>
<action name="actionResizeAllColumns" >
<property name="text" >
<string>Resize all</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc" /> <include location="icons.qrc" />

197
src/downloadingTorrents.cpp

@ -65,6 +65,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
downloadList->setItemDelegate(DLDelegate); downloadList->setItemDelegate(DLDelegate);
// Hide hash column // Hide hash column
downloadList->hideColumn(HASH); downloadList->hideColumn(HASH);
loadHiddenColumns();
connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool))); connect(BTSession, SIGNAL(addedTorrent(QString, QTorrentHandle&, bool)), this, SLOT(torrentAdded(QString, QTorrentHandle&, bool)));
connect(BTSession, SIGNAL(duplicateTorrent(QString)), this, SLOT(torrentDuplicate(QString))); connect(BTSession, SIGNAL(duplicateTorrent(QString)), this, SLOT(torrentDuplicate(QString)));
@ -95,6 +96,17 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered())); connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered()));
connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder())); connect(actionOpen_destination_folder, SIGNAL(triggered()), (GUI*)parent, SLOT(openDestinationFolder()));
connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection())); connect(actionTorrent_Properties, SIGNAL(triggered()), this, SLOT(propertiesSelection()));
connect(actionHOSColName, SIGNAL(triggered()), this, SLOT(hideOrShowColumnName()));
connect(actionHOSColSize, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSize()));
connect(actionHOSColProgress, SIGNAL(triggered()), this, SLOT(hideOrShowColumnProgress()));
connect(actionHOSColDownSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnDownSpeed()));
connect(actionHOSColUpSpeed, SIGNAL(triggered()), this, SLOT(hideOrShowColumnUpSpeed()));
connect(actionHOSColSeedersLeechers, SIGNAL(triggered()), this, SLOT(hideOrShowColumnSeedersLeechers()));
connect(actionHOSColRatio, SIGNAL(triggered()), this, SLOT(hideOrShowColumnRatio()));
connect(actionHOSColEta, SIGNAL(triggered()), this, SLOT(hideOrShowColumnEta()));
connect(actionResizeAllColumns, SIGNAL(triggered()), this, SLOT(resetAllColumns()));
// Set info Bar infos // Set info Bar infos
setInfoBar(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString::fromUtf8(""VERSION))); setInfoBar(tr("qBittorrent %1 started.", "e.g: qBittorrent v0.x started.").arg(QString::fromUtf8(""VERSION)));
setInfoBar(tr("Be careful, sharing copyrighted material without permission is against the law."), QString::fromUtf8("red")); setInfoBar(tr("Be careful, sharing copyrighted material without permission is against the law."), QString::fromUtf8("red"));
@ -103,6 +115,7 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
DownloadingTorrents::~DownloadingTorrents() { DownloadingTorrents::~DownloadingTorrents() {
saveColWidthDLList(); saveColWidthDLList();
saveHiddenColumns();
delete DLDelegate; delete DLDelegate;
delete DLListModel; delete DLListModel;
} }
@ -289,15 +302,176 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
myDLLlistMenu.addSeparator(); myDLLlistMenu.addSeparator();
myDLLlistMenu.addAction(actionOpen_destination_folder); myDLLlistMenu.addAction(actionOpen_destination_folder);
myDLLlistMenu.addAction(actionTorrent_Properties); myDLLlistMenu.addAction(actionTorrent_Properties);
// hide/show columns menu
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column"));
for(int i=0; i<=ETA; i++) {
hideshowColumn.addAction(getActionHoSCol(i));
}
hideshowColumn.addAction(actionResizeAllColumns);
myDLLlistMenu.addMenu(&hideshowColumn);
// Call menu // Call menu
// XXX: why mapToGlobal() is not enough? // XXX: why mapToGlobal() is not enough?
myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,60)); myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,60));
} }
/*
* Hiding Columns functions
*/
// toggle hide/show a column
void DownloadingTorrents::hideOrShowColumn(int index) {
if(!downloadList->isColumnHidden(index)) {
unsigned short i=0, nbColDisplayed = 0;
while(i<DLListModel->columnCount()-1 && nbColDisplayed<=1) {
if(!downloadList->isColumnHidden(i))
nbColDisplayed++;
i++;
}
// can't hide a lonely column
if(nbColDisplayed>1) {
downloadList->setColumnHidden(index, true);
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
}
} else {
short nbColumns = 0;
downloadList->setColumnHidden(index, false);
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
//resize all others non-hidden columns
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(downloadList->isColumnHidden(i))
nbColumns++;
}
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(i != index) {
downloadList->setColumnWidth(i, floor(downloadList->columnWidth(i)-(downloadList->columnWidth(index)/(nbColumns-1))));
}
}
}
}
// save the hidden columns in settings
void DownloadingTorrents::saveHiddenColumns() {
QSettings settings("qBittorrent", "qBittorrent");
QStringList ishidden_list;
short nbColumns = DLListModel->columnCount()-1;
for(short i=0; i<nbColumns; ++i){
if(downloadList->isColumnHidden(i)) {
ishidden_list << QString::fromUtf8(misc::toString(0).c_str());
} else {
ishidden_list << QString::fromUtf8(misc::toString(1).c_str());
}
}
settings.setValue("DownloadListColsHoS", ishidden_list.join(" "));
}
// load the previous settings, and hide the columns
bool DownloadingTorrents::loadHiddenColumns() {
bool loaded = false;
QSettings settings("qBittorrent", "qBittorrent");
QString line = settings.value("DownloadListColsHoS", QString()).toString();
QStringList ishidden_list;
if(!line.isEmpty()) {
ishidden_list = line.split(' ');
if(ishidden_list.size() == DLListModel->columnCount()-1) {
unsigned int listSize = ishidden_list.size();
for(unsigned int i=0; i<listSize; ++i){
downloadList->header()->resizeSection(i, ishidden_list.at(i).toInt());
}
loaded = true;
}
}
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(loaded && ishidden_list.at(i) == "0") {
downloadList->setColumnHidden(i, true);
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
} else {
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
}
}
return loaded;
}
void DownloadingTorrents::hideOrShowColumnName() {
hideOrShowColumn(NAME);
}
void DownloadingTorrents::hideOrShowColumnSize() {
hideOrShowColumn(SIZE);
}
void DownloadingTorrents::hideOrShowColumnProgress() {
hideOrShowColumn(PROGRESS);
}
void DownloadingTorrents::hideOrShowColumnDownSpeed() {
hideOrShowColumn(DLSPEED);
}
void DownloadingTorrents::hideOrShowColumnUpSpeed() {
hideOrShowColumn(UPSPEED);
}
void DownloadingTorrents::hideOrShowColumnSeedersLeechers() {
hideOrShowColumn(SEEDSLEECH);
}
void DownloadingTorrents::hideOrShowColumnRatio() {
hideOrShowColumn(RATIO);
}
void DownloadingTorrents::hideOrShowColumnEta() {
hideOrShowColumn(ETA);
}
void DownloadingTorrents::on_actionClearLog_triggered() { void DownloadingTorrents::on_actionClearLog_triggered() {
infoBar->clear(); infoBar->clear();
} }
// getter, return the action hide or show whose id is index
QAction* DownloadingTorrents::getActionHoSCol(int index) {
switch(index) {
case NAME :
return actionHOSColName;
break;
case SIZE :
return actionHOSColSize;
break;
case PROGRESS :
return actionHOSColProgress;
break;
case DLSPEED :
return actionHOSColDownSpeed;
break;
case UPSPEED :
return actionHOSColUpSpeed;
break;
case SEEDSLEECH :
return actionHOSColSeedersLeechers;
break;
case RATIO :
return actionHOSColRatio;
break;
case ETA :
return actionHOSColEta;
break;
default :
return NULL;
}
}
void DownloadingTorrents::resetAllColumns() {
for(int i=0; i<DLListModel->columnCount()-1; i++) {
downloadList->setColumnHidden(i, false);
downloadList->resizeColumnToContents(i);
getActionHoSCol(i)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_ok.png")));
}
downloadList->setColumnWidth(NAME,270);
}
QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{ QStringList DownloadingTorrents::getSelectedTorrents(bool only_one) const{
QStringList res; QStringList res;
QModelIndex index; QModelIndex index;
@ -570,11 +744,26 @@ void DownloadingTorrents::saveColWidthDLList() const{
qDebug("Saving columns width in download list"); qDebug("Saving columns width in download list");
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList width_list; QStringList width_list;
unsigned int nbColumns = DLListModel->columnCount()-1; QStringList new_width_list;
for(unsigned int i=0; i<nbColumns; ++i) { short nbColumns = DLListModel->columnCount()-1;
width_list << misc::toQString(downloadList->columnWidth(i)); QString line = settings.value("DownloadListColsWidth", QString()).toString();
if(!line.isEmpty()) {
width_list = line.split(' ');
}
for(short i=0; i<nbColumns; ++i){
if(downloadList->columnWidth(i)<1 && width_list.size() == DLListModel->columnCount()-1 && width_list.at(i).toInt()>=1) {
// load the former width
new_width_list << width_list.at(i);
} else if(downloadList->columnWidth(i)>=1) {
// usual case, save the current width
new_width_list << QString::fromUtf8(misc::toString(downloadList->columnWidth(i)).c_str());
} else {
// default width
downloadList->resizeColumnToContents(i);
new_width_list << QString::fromUtf8(misc::toString(downloadList->columnWidth(i)).c_str());
}
} }
settings.setValue(QString::fromUtf8("DownloadListColsWidth"), width_list.join(QString::fromUtf8(" "))); settings.setValue(QString::fromUtf8("DownloadListColsWidth"), new_width_list.join(QString::fromUtf8(" ")));
qDebug("Download list columns width saved"); qDebug("Download list columns width saved");
} }

13
src/downloadingTorrents.h

@ -41,6 +41,10 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
bool delayedSorting; bool delayedSorting;
unsigned int nbTorrents; unsigned int nbTorrents;
Qt::SortOrder delayedSortingOrder; Qt::SortOrder delayedSortingOrder;
void hideOrShowColumn(int index);
bool loadHiddenColumns();
void saveHiddenColumns();
QAction* getActionHoSCol(int index);
public: public:
DownloadingTorrents(QObject *parent, bittorrent *BTSession); DownloadingTorrents(QObject *parent, bittorrent *BTSession);
@ -92,6 +96,15 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void sortProgressColumnDelayed(); void sortProgressColumnDelayed();
void updateFileSizeAndProgress(QString hash); void updateFileSizeAndProgress(QString hash);
void showPropertiesFromHash(QString hash); void showPropertiesFromHash(QString hash);
void hideOrShowColumnName();
void hideOrShowColumnSize();
void hideOrShowColumnProgress();
void hideOrShowColumnDownSpeed();
void hideOrShowColumnUpSpeed();
void hideOrShowColumnSeedersLeechers();
void hideOrShowColumnRatio();
void hideOrShowColumnEta();
void resetAllColumns();
}; };
#endif #endif

35
src/seeding.ui

@ -101,6 +101,41 @@
<string>Open destination folder</string> <string>Open destination folder</string>
</property> </property>
</action> </action>
<action name="actionHOSColName" >
<property name="text" >
<string>Name</string>
</property>
</action>
<action name="actionHOSColSize" >
<property name="text" >
<string>Size</string>
</property>
</action>
<action name="actionHOSColProgress" >
<property name="text" >
<string>Progress</string>
</property>
</action>
<action name="actionHOSColUpSpeed" >
<property name="text" >
<string>Upload Speed</string>
</property>
</action>
<action name="actionHOSColLeechers" >
<property name="text" >
<string>Leechers</string>
</property>
</action>
<action name="actionHOSColRatio" >
<property name="text" >
<string>Ratio</string>
</property>
</action>
<action name="actionResizeAllColumns" >
<property name="text" >
<string>Resize All</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc" /> <include location="icons.qrc" />

Loading…
Cancel
Save