KTutorial
0.5.1
|
00001 /*************************************************************************** 00002 * Copyright (C) 2011 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00003 * Copyright (C) 2012 by Daniel Calviño Sánchez <danxuliu@gmail.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program; If not, see <http://www.gnu.org/licenses/>. * 00017 ***************************************************************************/ 00018 00019 #include "WaitForStepActivation.h" 00020 #include "WaitForStepActivation_p.h" 00021 00022 #include <QEvent> 00023 00024 #include <KDebug> 00025 00026 #include "Tutorial.h" 00027 00028 namespace ktutorial { 00029 extern int debugArea(); 00030 } 00031 00032 namespace ktutorial { 00033 00034 //public: 00035 00036 WaitForStepActivation::WaitForStepActivation(): WaitFor(), 00037 d(new WaitForStepActivationPrivate()) { 00038 d->mDuringStepActivation = false; 00039 } 00040 00041 WaitForStepActivation::WaitForStepActivation(const Tutorial* tutorial, 00042 const Step* step): WaitFor(), 00043 d(new WaitForStepActivationPrivate()) { 00044 d->mDuringStepActivation = false; 00045 setStep(tutorial, step); 00046 } 00047 00048 WaitForStepActivation::~WaitForStepActivation() { 00049 delete d; 00050 } 00051 00052 void WaitForStepActivation::setStep(const Tutorial* tutorial, 00053 const Step* step) { 00054 if (!tutorial) { 00055 kWarning(debugArea()) << "The tutorial that contains the step to wait" 00056 << "for its activation is null!"; 00057 return; 00058 } 00059 00060 if (!step) { 00061 kWarning(debugArea()) << "The step to wait for its activation is null!"; 00062 return; 00063 } 00064 00065 connect(tutorial, SIGNAL(stepActivated(Step*)), 00066 this, SLOT(checkStepActivatedToEndTheWait(Step*))); 00067 } 00068 00069 bool WaitForStepActivation::conditionMet() const { 00070 return d->mDuringStepActivation; 00071 } 00072 00073 //private slots: 00074 00075 void WaitForStepActivation::checkStepActivatedToEndTheWait(Step* step) { 00076 Q_UNUSED(step); 00077 00078 if (!isActive()) { 00079 return; 00080 } 00081 00082 d->mDuringStepActivation = true; 00083 emit waitEnded(this); 00084 d->mDuringStepActivation = false; 00085 } 00086 00087 }