From 2b5600f4348172c9dfe3cdad1db732be926b05d1 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Wed, 9 Dec 2009 09:04:41 +0200 Subject: [PATCH] scan: add select/invert buttons. --- rc/scandlg.ui | 225 ++++++++++++++++++++++++++++++++++++-------------------- src/scandlg.cpp | 17 +++++ src/scandlg.h | 2 + src/util.cpp | 30 ++++++++ src/util.h | 11 +++ 5 files changed, 204 insertions(+), 81 deletions(-) diff --git a/rc/scandlg.ui b/rc/scandlg.ui index fccb6ee..742d54d 100644 --- a/rc/scandlg.ui +++ b/rc/scandlg.ui @@ -1,11 +1,12 @@ - + + Toni Gundogdu scanDialog - - + + Qt::ApplicationModal - + 0 0 @@ -13,42 +14,122 @@ 279 - + Scan - - + + :/edit-find.png:/edit-find.png - + true - - - + + + - - + + + false + + + true + + + + Found + + + + + Link + + + + + + + + + + S&elect all + + + + + + + &Invert + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + &Link: - + linkEdit - + - - + + + Have abby fetch video page titles for the found +video page links. This will cause the scan process +to take more time and bandwidth. + + + &Fetch video title + + + true + + + + + + &Scan - - + + :/edit-find.png:/edit-find.png - + 16 16 @@ -58,60 +139,6 @@ - - - - false - - - true - - - - Found - - - - - Link - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Options - - - - - - Have abby fetch video page titles for the found -video page links. This will cause the scan process -to take more time and bandwidth. - - - &Fetch video title - - - true - - - - - - @@ -119,10 +146,12 @@ to take more time and bandwidth. titlesBox scanButton itemsTree + selectallButton + invertButton buttonBox - + @@ -131,11 +160,11 @@ to take more time and bandwidth. scanDialog accept() - + 248 254 - + 157 274 @@ -147,11 +176,11 @@ to take more time and bandwidth. scanDialog reject() - + 316 260 - + 286 274 @@ -163,18 +192,52 @@ to take more time and bandwidth. scanDialog onScan() - + 462 23 - + 256 119 + + selectallButton + clicked() + scanDialog + onSelectAll() + + + 461 + 60 + + + 256 + 139 + + + + + invertButton + clicked() + scanDialog + onInvert() + + + 461 + 94 + + + 256 + 139 + + + onScan() + onSelectAll() + onInvert() diff --git a/src/scandlg.cpp b/src/scandlg.cpp index 6957e2e..2a9f522 100644 --- a/src/scandlg.cpp +++ b/src/scandlg.cpp @@ -21,6 +21,7 @@ #include #include +#include "util.h" #include "scandlg.h" ScanDialog::ScanDialog(QWidget *parent) @@ -55,6 +56,8 @@ ScanDialog::onScan() { scanButton->setEnabled (false); titlesBox->setEnabled (false); buttonBox->setEnabled (false); + selectallButton->setEnabled(false); + invertButton->setEnabled(false); mgr->get(QNetworkRequest(lnk)); } @@ -90,6 +93,8 @@ ScanDialog::replyFinished(QNetworkReply* reply) { scanButton->setEnabled (state); titlesBox->setEnabled (state); buttonBox->setEnabled (state); + selectallButton->setEnabled(state); + invertButton->setEnabled(state); } reply->deleteLater(); @@ -232,3 +237,15 @@ ScanDialog::readSettings() { resize( s.value("size", QSize(514,295)).toSize() ); s.endGroup(); } + +void +ScanDialog::onSelectAll() { + Util::checkAllItems(itemsTree, Qt::Checked); +} + +void +ScanDialog::onInvert() { + Util::invertAllCheckableItems(itemsTree); +} + + diff --git a/src/scandlg.h b/src/scandlg.h index 378335a..8a4eafa 100644 --- a/src/scandlg.h +++ b/src/scandlg.h @@ -34,6 +34,8 @@ public: ScanDialog(QWidget *parent); private slots: void onScan(); + void onSelectAll(); + void onInvert(); void replyFinished(QNetworkReply*); public: void writeSettings(); diff --git a/src/util.cpp b/src/util.cpp index 043f694..d44c91a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -22,6 +22,7 @@ #include #include #include +#include //#include #include "util.h" @@ -188,6 +189,35 @@ Util::verifyCclivePath( ); } +void +Util::checkAllItems( + const QTreeWidget *w, + const Qt::CheckState& st, + const int column/*=0*/) +{ + QTreeWidgetItemIterator iter(const_cast(w)); + while (*iter) { + (*iter)->setCheckState(column, st); + ++iter; + } +} + +void +Util::invertAllCheckableItems( + const QTreeWidget *w, + const int column/*=0*/) +{ + QTreeWidgetItemIterator iter(const_cast(w)); + while (*iter) { + (*iter)->setCheckState(column, + (*iter)->checkState(column) == Qt::Checked + ? Qt::Unchecked + : Qt::Checked + ); + ++iter; + } +} + NoCcliveException::NoCcliveException(const QString& errmsg) : errmsg(errmsg) { diff --git a/src/util.h b/src/util.h index f97f98c..7295385 100644 --- a/src/util.h +++ b/src/util.h @@ -19,6 +19,8 @@ #ifndef util_h #define util_h +class QTreeWidget; + class Util { public: static void detectCclive( @@ -35,6 +37,15 @@ public: QString& libName, bool *isCcliveFlag=NULL ); + static void checkAllItems( + const QTreeWidget *w, + const Qt::CheckState& st, + const int column=0 + ); + static void invertAllCheckableItems( + const QTreeWidget *w, + const int column=0 + ); }; class NoCcliveException { -- 2.11.4.GIT