[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise/kdepim/libkdepim
From: Thomas McGuire <mcguire () kde ! org>
Date: 2009-11-12 20:39:07
Message-ID: 1258058347.195504.14271.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1048160 by tmcguire:
Support progress items that show a busy indicator instead of real progress
M +18 -0 progressdialog.cpp
M +2 -0 progressdialog.h
M +15 -2 progressmanager.cpp
M +27 -0 progressmanager.h
M +11 -2 statusbarprogresswidget.cpp
M +1 -0 statusbarprogresswidget.h
--- branches/kdepim/enterprise/kdepim/libkdepim/progressdialog.cpp #1048159:1048160
@@ -224,6 +224,11 @@
mSSLLabel->setState( mSSLLabel->lastState() );
}
+void TransactionItem::setTotalSteps( int totalSteps )
+{
+ mProgress->setTotalSteps( totalSteps );
+}
+
void TransactionItem::slotItemCanceled()
{
if ( mItem )
@@ -279,6 +284,8 @@
this, SLOT( slotTransactionLabel( KPIM::ProgressItem*, const QString& \
) ) );
connect ( pm, SIGNAL( progressItemUsesCrypto(KPIM::ProgressItem*, bool) ),
this, SLOT( slotTransactionUsesCrypto( KPIM::ProgressItem*, bool ) ) \
); + connect ( pm, SIGNAL( progressItemUsesBusyIndicator(KPIM::ProgressItem*, \
bool) ), + this, SLOT( slotTransactionUsesBusyIndicator( \
KPIM::ProgressItem*, bool ) ) ); connect ( pm, SIGNAL( showProgressDialog() ),
this, SLOT( slotShow() ) );
}
@@ -374,6 +381,17 @@
}
}
+void ProgressDialog::slotTransactionUsesBusyIndicator( KPIM::ProgressItem *item, \
bool value ) +{
+ if ( mTransactionsToListviewItems.contains( item ) ) {
+ TransactionItem *ti = mTransactionsToListviewItems[ item ];
+ if ( value )
+ ti->setTotalSteps( 0 );
+ else
+ ti->setTotalSteps( 100 );
+ }
+}
+
void ProgressDialog::slotShow()
{
setVisible( true );
--- branches/kdepim/enterprise/kdepim/libkdepim/progressdialog.h #1048159:1048160
@@ -90,6 +90,7 @@
void setLabel( const QString& );
void setStatus( const QString& );
void setCrypto( bool );
+ void setTotalSteps( int totalSteps );
ProgressItem* item() const { return mItem; }
@@ -132,6 +133,7 @@
void slotTransactionStatus( KPIM::ProgressItem *item, const QString& );
void slotTransactionLabel( KPIM::ProgressItem *item, const QString& );
void slotTransactionUsesCrypto( KPIM::ProgressItem *item, bool );
+ void slotTransactionUsesBusyIndicator( KPIM::ProgressItem*, bool );
void slotClose();
void slotShow();
--- branches/kdepim/enterprise/kdepim/libkdepim/progressmanager.cpp #1048159:1048160
@@ -41,7 +41,7 @@
:mId( id ), mLabel( label ), mStatus( status ), mParent( parent ),
mCanBeCanceled( canBeCanceled ), mProgress( 0 ), mTotal( 0 ),
mCompleted( 0 ), mWaitingForKids( false ), mCanceled( false ),
- mUsesCrypto( usesCrypto )
+ mUsesCrypto( usesCrypto ), mUsesBusyIndicator( false )
{}
ProgressItem::~ProgressItem()
@@ -123,6 +123,12 @@
emit progressItemUsesCrypto( this, v );
}
+void ProgressItem::setUsesBusyIndicator( bool useBusyIndicator )
+{
+ mUsesBusyIndicator = useBusyIndicator;
+ emit progressItemUsesBusyIndicator( this, useBusyIndicator );
+}
+
// ======================================
ProgressManager::ProgressManager() :QObject() {
@@ -170,6 +176,8 @@
this, SIGNAL( progressItemLabel(KPIM::ProgressItem*, const QString&) \
) );
connect ( t, SIGNAL( progressItemUsesCrypto(KPIM::ProgressItem*, bool) ),
this, SIGNAL( progressItemUsesCrypto(KPIM::ProgressItem*, bool) ) );
+ connect ( t, SIGNAL( progressItemUsesBusyIndicator(KPIM::ProgressItem*, bool) \
), + this, SIGNAL( progressItemUsesBusyIndicator(KPIM::ProgressItem*, \
bool) ) );
emit progressItemAdded( t );
} else {
@@ -212,7 +220,12 @@
ProgressItem *item = 0;
QDictIterator< ProgressItem > it( mTransactions );
for ( ; it.current(); ++it ) {
- if ( !(*it)->parent() ) { // if it's a top level one, only those count
+
+ // No single item for progress possible, as one of them is a busy indicator one.
+ if ( (*it)->usesBusyIndicator() )
+ return 0;
+
+ if ( !(*it)->parent() ) { // if it's a top level one, only those \
count if ( item )
return 0; // we found more than one
else
--- branches/kdepim/enterprise/kdepim/libkdepim/progressmanager.h #1048159:1048160
@@ -96,6 +96,18 @@
void setUsesCrypto( bool v );
/**
+ * @return whether this item uses a busy indicator instead of real progress \
display + */
+ bool usesBusyIndicator() const { return mUsesBusyIndicator; }
+
+ /**
+ * Sets whether this item uses a busy indicator instead of real progress for its \
progress bar. + * If it uses a busy indicator, you are still responsible for \
calling setProgress() from time to + * time to update the busy indicator.
+ */
+ void setUsesBusyIndicator( bool useBusyIndicator );
+
+ /**
* @return The current progress value of this item in percent.
*/
unsigned int progress() const { return mProgress; }
@@ -192,7 +204,16 @@
*/
void progressItemUsesCrypto( KPIM::ProgressItem*, bool );
+ /**
+ * Emitted when the busy indicator state of an item changes. Should be used
+ * by progress dialogs so that they can adjust the display of the progress bar
+ * to the new mode.
+ * @param item The updated item
+ * @param value True if the item uses a busy indicator now, false otherwise
+ */
+ void progressItemUsesBusyIndicator( KPIM::ProgressItem *item, bool value );
+
protected:
/* Only to be used by our good friend the ProgressManager */
ProgressItem( ProgressItem* parent,
@@ -217,6 +238,7 @@
bool mWaitingForKids;
bool mCanceled;
bool mUsesCrypto;
+ bool mUsesBusyIndicator;
};
/**
@@ -335,6 +357,9 @@
/**
* @return the only top level progressitem when there's only one.
* Returns 0 if there is no item, or more than one top level item.
+ * Since this is used to calculate the overall progress, it will also return
+ * 0 if there is an item which uses a busy indicator, since that will invalidate
+ * the overall progress.
*/
ProgressItem* singleItem() const;
@@ -361,6 +386,8 @@
void progressItemLabel( KPIM::ProgressItem*, const QString& );
/** @see ProgressItem::progressItemUsesCrypto() */
void progressItemUsesCrypto( KPIM::ProgressItem*, bool );
+ /** @see ProgressItem::progressItemUsesBusyIndicator */
+ void progressItemUsesBusyIndicator( KPIM::ProgressItem*, bool );
/**
* Emitted when an operation requests the listeners to be shown.
--- branches/kdepim/enterprise/kdepim/libkdepim/statusbarprogresswidget.cpp \
#1048159:1048160 @@ -105,6 +105,8 @@
this, SLOT( slotProgressItemAdded( KPIM::ProgressItem * ) ) );
connect ( ProgressManager::instance(), SIGNAL( progressItemCompleted( \
KPIM::ProgressItem * ) ),
this, SLOT( slotProgressItemCompleted( KPIM::ProgressItem * ) ) );
+ connect ( ProgressManager::instance(), \
SIGNAL(progressItemUsesBusyIndicator(KPIM::ProgressItem*,bool)), + this, \
SLOT( updateBusyMode() ) );
connect ( progressDialog, SIGNAL( visibilityChanged( bool )),
this, SLOT( slotProgressDialogVisible( bool ) ) );
@@ -119,9 +121,8 @@
// In slot..Added we can only end up in 1 or N.
// In slot..Removed we can end up in 0, 1, or we can stay in N if we were already.
-void StatusbarProgressWidget::slotProgressItemAdded( ProgressItem *item )
+void StatusbarProgressWidget::updateBusyMode()
{
- if ( item->parent() ) return; // we are only interested in top level items
connectSingleItem(); // if going to 1 item
if ( mCurrentItem ) { // Exactly one item
delete mBusyTimer;
@@ -138,6 +139,14 @@
}
}
+void StatusbarProgressWidget::slotProgressItemAdded( ProgressItem *item )
+{
+ if ( item->parent() )
+ return; // we are only interested in top level items
+
+ updateBusyMode();
+}
+
void StatusbarProgressWidget::slotProgressItemCompleted( ProgressItem *item )
{
if ( item->parent() ) return; // we are only interested in top level items
--- branches/kdepim/enterprise/kdepim/libkdepim/statusbarprogresswidget.h \
#1048159:1048160 @@ -72,6 +72,7 @@
void slotProgressDialogVisible( bool );
void slotShowItemDelayed();
void slotBusyIndicator();
+ void updateBusyMode();
protected:
void setMode();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic