krita

kis_filter.cc

00001 /*
00002  *  Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 #include "kis_filter.h"
00019 
00020 #include <qstring.h>
00021 
00022 #include "kis_types.h"
00023 #include "kis_filter_configuration.h"
00024 
00025 KisFilter::KisFilter(const KisID& id, const QString & category, const QString & entry)
00026     : KisProgressSubject(0, id.id().latin1())
00027     , m_id(id)
00028     , m_progressDisplay(0)
00029     , m_category(category)
00030     , m_entry(entry)
00031 {
00032 }
00033 
00034 KisFilterConfiguration * KisFilter::configuration(QWidget*)
00035 {
00036     return new KisFilterConfiguration(m_id.id(), 0);
00037 }
00038 
00039 KisFilterConfiguration * KisFilter::configuration()
00040 {
00041     return new KisFilterConfiguration(m_id.id(), 0);
00042 }
00043 
00044 KisFilterConfigWidget * KisFilter::createConfigurationWidget(QWidget *, KisPaintDeviceSP)
00045 {
00046     return 0;
00047 }
00048 
00049 void KisFilter::setProgressDisplay(KisProgressDisplayInterface * progressDisplay)
00050 {
00051     m_progressDisplay = progressDisplay;
00052 }
00053 
00054 
00055 void KisFilter::enableProgress() {
00056     m_progressEnabled = true;
00057     m_cancelRequested = false;
00058 }
00059 
00060 void KisFilter::disableProgress() {
00061     m_progressEnabled = false;
00062     m_cancelRequested = false;
00063 }
00064 
00065 void KisFilter::setProgressTotalSteps(Q_INT32 totalSteps)
00066 {
00067     if (m_progressEnabled) {
00068 
00069         m_progressTotalSteps = totalSteps;
00070         m_lastProgressPerCent = 0;
00071         m_progressSteps = 0;
00072         emit notifyProgress(0);
00073     }
00074 }
00075 
00076 void KisFilter::setProgress(Q_INT32 progress)
00077 {
00078     if (m_progressEnabled) {
00079         Q_INT32 progressPerCent = (progress * 100) / m_progressTotalSteps;
00080         m_progressSteps = progress;
00081 
00082         if (progressPerCent != m_lastProgressPerCent) {
00083 
00084             m_lastProgressPerCent = progressPerCent;
00085             emit notifyProgress(progressPerCent);
00086         }
00087     }
00088 }
00089 
00090 void KisFilter::incProgress()
00091 {
00092     setProgress(++m_progressSteps);
00093 
00094 }
00095 
00096 void KisFilter::setProgressStage(const QString& stage, Q_INT32 progress)
00097 {
00098     if (m_progressEnabled) {
00099 
00100         Q_INT32 progressPerCent = (progress * 100) / m_progressTotalSteps;
00101 
00102         m_lastProgressPerCent = progressPerCent;
00103         emit notifyProgressStage(stage, progressPerCent);
00104     }
00105 }
00106 
00107 void KisFilter::setProgressDone()
00108 {
00109     if (m_progressEnabled) {
00110         emit notifyProgressDone();
00111     }
00112 }
00113 
00114 
00115 bool KisFilter::autoUpdate() {
00116     return m_autoUpdate;
00117 }
00118 
00119 void KisFilter::setAutoUpdate(bool set) {
00120     m_autoUpdate = set;
00121 }
00122 
00123 
00124 #include "kis_filter.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys