diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-10-13 11:56:14 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2024-10-29 21:58:42 +0900 |
commit | 2879ff70be9271550477982a1a6371714db38562 (patch) | |
tree | c2054149dba923ab080fe7093432c7663a990111 /src/backends/progressinterface.cpp | |
parent | 3eb38d2556f676d1027746f20bf12a1dd74451ef (diff) | |
download | krecipes-2879ff70be9271550477982a1a6371714db38562.tar.gz krecipes-2879ff70be9271550477982a1a6371714db38562.zip |
Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
(cherry picked from commit 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502)
Diffstat (limited to 'src/backends/progressinterface.cpp')
-rw-r--r-- | src/backends/progressinterface.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/backends/progressinterface.cpp b/src/backends/progressinterface.cpp new file mode 100644 index 0000000..ea5ce08 --- /dev/null +++ b/src/backends/progressinterface.cpp @@ -0,0 +1,79 @@ +/*************************************************************************** +* Copyright (C) 2005 by * +* Jason Kivlighn (jkivlighn@gmail.com) * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +***************************************************************************/ + +#include "progressinterface.h" + +#include <tqapplication.h> + +#include <kprogress.h> + +#include "recipedb.h" + +ProgressInterface::ProgressInterface( TQWidget *parent ) : progress_dlg(0), database(0), m_rate(1), m_rate_at(0) +{ + slot_obj = new ProgressSlotObject(parent,this); +} + +ProgressInterface::~ProgressInterface() +{ + listenOn(0); + delete slot_obj; +} + +void ProgressInterface::progressBegin( int steps, const TQString &caption, const TQString &text, int rate ) +{ + m_rate = rate; + + progress_dlg = new KProgressDialog((TQWidget*)slot_obj->parent(),0,caption,text,true); + + if ( steps == 0 ) + progress_dlg->progressBar()->setPercentageVisible(false); + progress_dlg->progressBar()->setTotalSteps( steps ); +} + +void ProgressInterface::progressDone() +{ + delete progress_dlg; + progress_dlg = 0; + + m_rate_at = 0; +} + +void ProgressInterface::progress() +{ + if ( progress_dlg->wasCancelled() ) { + database->cancelOperation(); + } + else { + ++m_rate_at; + + if ( m_rate_at % m_rate == 0 ) { + progress_dlg->progressBar()->advance(1); + m_rate_at = 0; + } + tqApp->processEvents(); + } +} + +void ProgressInterface::listenOn( RecipeDB *db ) +{ + if ( database) + database->disconnect(slot_obj); + + if ( db ) { + slot_obj->connect( db, TQ_SIGNAL(progressBegin(int,const TQString&,const TQString&,int)), slot_obj, TQ_SLOT(progressBegin(int,const TQString&,const TQString&,int)) ); + slot_obj->connect( db, TQ_SIGNAL(progressDone()), slot_obj, TQ_SLOT(progressDone()) ); + slot_obj->connect( db, TQ_SIGNAL(progress()), slot_obj, TQ_SLOT(progress()) ); + } + + database = db; +} + +#include "progressinterface.moc" |