24 #ifndef __KPIM_PROGRESSMANAGER_H__
25 #define __KPIM_PROGRESSMANAGER_H__
31 #include <tdemacros.h>
36 class ProgressManager;
37 typedef TQMap<ProgressItem*, bool> ProgressItemMap;
39 class TDE_EXPORT ProgressItem :
public TQObject
43 friend class ProgressManager;
44 friend class TQDict< ProgressItem >;
52 const TQString& id()
const {
return mId; }
57 ProgressItem *parent()
const {
return mParent; }
62 const TQString& label()
const {
return mLabel; }
68 void setLabel(
const TQString& v );
73 const TQString& status()
const {
return mStatus; }
79 void setStatus(
const TQString& v );
84 bool canBeCanceled()
const {
return mCanBeCanceled; }
90 bool usesCrypto()
const {
return mUsesCrypto; }
97 void setUsesCrypto(
bool v );
102 bool usesBusyIndicator()
const {
return mUsesBusyIndicator; }
109 void setUsesBusyIndicator(
bool useBusyIndicator );
114 unsigned int progress()
const {
return mProgress; }
120 void setProgress(
unsigned int v );
135 void reset() { setProgress( 0 ); setStatus( TQString() ); mCompleted = 0; }
140 void setTotalItems(
unsigned int v ) { mTotal = v; }
141 unsigned int totalItems()
const {
return mTotal; }
142 void setCompletedItems(
unsigned int v ) { mCompleted = v; }
143 void incCompletedItems(
unsigned int v = 1 ) { mCompleted += v; }
144 unsigned int completedItems()
const {
return mCompleted; }
149 void updateProgress() { setProgress( mTotal? mCompleted*100/mTotal: 0 ); }
151 void addChild( ProgressItem *kiddo );
152 void removeChild( ProgressItem *kiddo );
154 bool canceled()
const {
return mCanceled; }
161 void progressItemAdded( KPIM::ProgressItem* );
167 void progressItemProgress( KPIM::ProgressItem*,
unsigned int );
174 void progressItemCompleted( KPIM::ProgressItem* );
185 void progressItemCanceled( KPIM::ProgressItem* );
192 void progressItemStatus( KPIM::ProgressItem*,
const TQString& );
199 void progressItemLabel( KPIM::ProgressItem*,
const TQString& );
206 void progressItemUsesCrypto( KPIM::ProgressItem*,
bool );
215 void progressItemUsesBusyIndicator( KPIM::ProgressItem *item,
bool value );
220 ProgressItem( ProgressItem* parent,
222 const TQString& label,
223 const TQString& status,
226 virtual ~ProgressItem();
233 ProgressItem* mParent;
235 unsigned int mProgress;
236 ProgressItemMap mChildren;
238 unsigned int mCompleted;
239 bool mWaitingForKids;
242 bool mUsesBusyIndicator;
286 static TQString
getUniqueID() {
return TQString::number( ++uID ); }
297 return instance()->createProgressItemImpl( 0, getUniqueID(), label,
298 TQString(),
true,
false );
319 const TQString& label,
320 const TQString& status = TQString(),
321 bool canBeCanceled =
true,
322 bool usesCrypto =
false ) {
323 return instance()->createProgressItemImpl( parent,
id, label, status,
324 canBeCanceled, usesCrypto );
333 const TQString& label,
334 const TQString& status = TQString(),
335 bool canBeCanceled =
true,
336 bool usesCrypto =
false ) {
337 return instance()->createProgressItemImpl( parent,
id, label,
338 status, canBeCanceled, usesCrypto );
345 const TQString& label,
346 const TQString& status = TQString(),
347 bool canBeCanceled =
true,
348 bool usesCrypto =
false ) {
349 return instance()->createProgressItemImpl( 0,
id, label, status,
350 canBeCanceled, usesCrypto );
357 bool isEmpty()
const {
return mTransactions.isEmpty(); }
366 ProgressItem* singleItem()
const;
373 instance()->emitShowProgressDialogImpl();
406 void slotStandardCancelHandler( KPIM::ProgressItem* item );
414 void slotTransactionCompleted( KPIM::ProgressItem *item );
421 virtual ProgressItem* createProgressItemImpl(
422 ProgressItem* parent,
const TQString&
id,
423 const TQString& label,
const TQString& status,
424 bool cancellable,
bool usesCrypto );
425 virtual ProgressItem* createProgressItemImpl(
426 const TQString& parent,
const TQString&
id,
427 const TQString& label,
const TQString& status,
428 bool cancellable,
bool usesCrypto );
429 void emitShowProgressDialogImpl();
431 TQDict< ProgressItem > mTransactions;
433 static unsigned int uID;
The ProgressManager singleton keeps track of all ongoing transactions and notifies observers (progres...
static void emitShowProgressDialog()
Ask all listeners to show the progress dialog, because there is something that wants to be shown.
static ProgressItem * createProgressItem(ProgressItem *parent, const TQString &id, const TQString &label, const TQString &status=TQString(), bool canBeCanceled=true, bool usesCrypto=false)
Creates a new progressItem with the given parent, id, label and initial status.
void progressItemAdded(KPIM::ProgressItem *)
static TQString getUniqueID()
Use this to acquire a unique id number which can be used to discern an operation from all others goin...
static ProgressItem * createProgressItem(const TQString &label)
Creates a ProgressItem with a unique id and the given label.
void progressItemCanceled(KPIM::ProgressItem *)
static ProgressItem * createProgressItem(const TQString &parent, const TQString &id, const TQString &label, const TQString &status=TQString(), bool canBeCanceled=true, bool usesCrypto=false)
Use this version if you have the id string of the parent and want to add a subjob to it.
void progressItemLabel(KPIM::ProgressItem *, const TQString &)
static ProgressItem * createProgressItem(const TQString &id, const TQString &label, const TQString &status=TQString(), bool canBeCanceled=true, bool usesCrypto=false)
Version without a parent.
void progressItemUsesBusyIndicator(KPIM::ProgressItem *, bool)
void progressItemStatus(KPIM::ProgressItem *, const TQString &)
void progressItemProgress(KPIM::ProgressItem *, unsigned int)
void progressItemCompleted(KPIM::ProgressItem *)
void showProgressDialog()
Emitted when an operation requests the listeners to be shown.
void progressItemUsesCrypto(KPIM::ProgressItem *, bool)
TDEPIM classes for drag and drop of mails.