Browse Source

bufixes on hidden columns in transfert lists

adaptive-webui-19844
Arnaud Demaiziere 17 years ago
parent
commit
0d90ad8f7c
  1. 43
      src/FinishedTorrents.cpp
  2. 15
      src/FinishedTorrents.h
  3. 39
      src/downloadingTorrents.cpp
  4. 20
      src/downloadingTorrents.h

43
src/FinishedTorrents.cpp

@ -59,6 +59,9 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par @@ -59,6 +59,9 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession) : par
finishedListDelegate = new FinishedListDelegate(finishedList);
finishedList->setItemDelegate(finishedListDelegate);
connect(finishedList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedListMenu(const QPoint&)));
finishedList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(finishedList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFinishedHoSMenu(const QPoint&)));
connect(finishedList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
actionDelete->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete.png")));
actionPreview_file->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/preview.png")));
@ -377,26 +380,32 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){ @@ -377,26 +380,32 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){
myFinishedListMenu.addSeparator();
myFinishedListMenu.addAction(actionOpen_destination_folder);
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
// XXX: why mapToGlobal() is not enough?
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55));
}
/*
* Hiding Columns functions
*/
// hide/show columns menu
void FinishedTorrents::displayFinishedHoSMenu(const QPoint& pos){
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);
// Call menu
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
}
// toggle hide/show a column
void FinishedTorrents::hideOrShowColumn(int index) {
short nbColumns = 0;
if(!finishedList->isColumnHidden(index)) {
unsigned short i=0, nbColDisplayed = 0;
while(i<finishedListModel->columnCount()-1 && nbColDisplayed<=1) {
@ -406,25 +415,31 @@ void FinishedTorrents::hideOrShowColumn(int index) { @@ -406,25 +415,31 @@ void FinishedTorrents::hideOrShowColumn(int index) {
}
// can't hide a lonely column
if(nbColDisplayed>1) {
//resize all others non-hidden columns
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(finishedList->isColumnHidden(i) == false)
nbColumns++;
}
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(i != index) {
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)+(finishedList->columnWidth(index)/(nbColumns-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))
if(finishedList->isColumnHidden(i) == false)
nbColumns++;
}
for(int i=0; i<finishedListModel->columnCount()-1; i++) {
if(i != index) {
finishedList->setColumnWidth(i, (int)floor(finishedList->columnWidth(i)-(finishedList->columnWidth(index)/(nbColumns-1))));
finishedList->setColumnWidth(i, (int)ceil(finishedList->columnWidth(i)-(finishedList->columnWidth(index)/(nbColumns-1))));
}
}
}

15
src/FinishedTorrents.h

@ -57,6 +57,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -57,6 +57,7 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
protected slots:
void showProperties(const QModelIndex &index);
void displayFinishedListMenu(const QPoint&);
void displayFinishedHoSMenu(const QPoint&);
void setRowColor(int row, QString color);
void saveColWidthFinishedList() const;
void sortFinishedList(int index);
@ -66,6 +67,13 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -66,6 +67,13 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void torrentAdded(QString path, QTorrentHandle& h, bool fastResume);
void on_actionSet_upload_limit_triggered();
void notifyTorrentDoubleClicked(const QModelIndex& index);
void hideOrShowColumnName();
void hideOrShowColumnSize();
void hideOrShowColumnProgress();
void hideOrShowColumnUpSpeed();
void hideOrShowColumnLeechers();
void hideOrShowColumnRatio();
void resetAllColumns();
public slots:
void addTorrent(QString hash);
@ -75,13 +83,6 @@ class FinishedTorrents : public QWidget, public Ui::seeding { @@ -75,13 +83,6 @@ class FinishedTorrents : public QWidget, public Ui::seeding {
void propertiesSelection();
void deleteTorrent(QString hash);
void showPropertiesFromHash(QString hash);
void hideOrShowColumnName();
void hideOrShowColumnSize();
void hideOrShowColumnProgress();
void hideOrShowColumnUpSpeed();
void hideOrShowColumnLeechers();
void hideOrShowColumnRatio();
void resetAllColumns();
signals:
void torrentMovedFromFinishedList(QString);

39
src/downloadingTorrents.cpp

@ -87,6 +87,8 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession) @@ -87,6 +87,8 @@ DownloadingTorrents::DownloadingTorrents(QObject *parent, bittorrent *BTSession)
connect(downloadList, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(notifyTorrentDoubleClicked(const QModelIndex&)));
connect(downloadList->header(), SIGNAL(sectionPressed(int)), this, SLOT(sortDownloadList(int)));
connect(downloadList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLListMenu(const QPoint&)));
downloadList->header()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(downloadList->header(), SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayDLHoSMenu(const QPoint&)));
connect(infoBar, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoBarMenu(const QPoint&)));
// Actions
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered()));
@ -297,14 +299,6 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) { @@ -297,14 +299,6 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
myDLLlistMenu.addSeparator();
myDLLlistMenu.addAction(actionOpen_destination_folder);
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
// XXX: why mapToGlobal() is not enough?
myDLLlistMenu.exec(mapToGlobal(pos)+QPoint(10,60));
@ -315,8 +309,21 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) { @@ -315,8 +309,21 @@ void DownloadingTorrents::displayDLListMenu(const QPoint& pos) {
* Hiding Columns functions
*/
// hide/show columns menu
void DownloadingTorrents::displayDLHoSMenu(const QPoint& pos){
QMenu hideshowColumn(this);
hideshowColumn.setTitle(tr("Hide or Show Column"));
for(int i=0; i<=ETA; i++) {
hideshowColumn.addAction(getActionHoSCol(i));
}
hideshowColumn.addAction(actionResizeAllColumns);
// Call menu
hideshowColumn.exec(mapToGlobal(pos)+QPoint(10,55));
}
// toggle hide/show a column
void DownloadingTorrents::hideOrShowColumn(int index) {
short nbColumns = 0;
if(!downloadList->isColumnHidden(index)) {
unsigned short i=0, nbColDisplayed = 0;
while(i<DLListModel->columnCount()-1 && nbColDisplayed<=1) {
@ -326,21 +333,31 @@ void DownloadingTorrents::hideOrShowColumn(int index) { @@ -326,21 +333,31 @@ void DownloadingTorrents::hideOrShowColumn(int index) {
}
// can't hide a lonely column
if(nbColDisplayed>1) {
//resize all others non-hidden columns
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(downloadList->isColumnHidden(i) == false)
nbColumns++;
}
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(i != index) {
downloadList->setColumnWidth(i, (int)ceil(downloadList->columnWidth(i)+(downloadList->columnWidth(index)/(nbColumns-1))));
}
}
downloadList->setColumnHidden(index, true);
getActionHoSCol(index)->setIcon(QIcon(QString::fromUtf8(":/Icons/button_cancel.png")));
}
} else {
short nbColumns = 0;
//short buf_width = finishedList->columnWidth(index);
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))
if(downloadList->isColumnHidden(i) == false)
nbColumns++;
}
for(int i=0; i<DLListModel->columnCount()-1; i++) {
if(i != index) {
downloadList->setColumnWidth(i, (int)floor(downloadList->columnWidth(i)-(downloadList->columnWidth(index)/(nbColumns-1))));
downloadList->setColumnWidth(i, (int)ceil(downloadList->columnWidth(i)-(downloadList->columnWidth(index)/(nbColumns-1))));
}
}
}

20
src/downloadingTorrents.h

@ -69,6 +69,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -69,6 +69,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void notifyTorrentDoubleClicked(const QModelIndex& index);
void on_actionSet_upload_limit_triggered();
void displayDLListMenu(const QPoint& pos);
void displayDLHoSMenu(const QPoint&);
void on_actionClearLog_triggered();
void displayInfoBarMenu(const QPoint& pos);
void addTorrent(QString hash);
@ -83,6 +84,15 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -83,6 +84,15 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void setRowColor(int row, QColor color);
void displayDownloadingUrlInfos(QString url);
void showProperties(const QModelIndex &index);
void hideOrShowColumnName();
void hideOrShowColumnSize();
void hideOrShowColumnProgress();
void hideOrShowColumnDownSpeed();
void hideOrShowColumnUpSpeed();
void hideOrShowColumnSeedersLeechers();
void hideOrShowColumnRatio();
void hideOrShowColumnEta();
void resetAllColumns();
public slots:
void updateDlList();
@ -96,15 +106,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{ @@ -96,15 +106,7 @@ class DownloadingTorrents : public QWidget, public Ui::downloading{
void sortProgressColumnDelayed();
void updateFileSizeAndProgress(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

Loading…
Cancel
Save