[Ktutorial-commits] SF.net SVN: ktutorial:[83] trunk/ktutorial
Status: Alpha
Brought to you by:
danxuliu
|
From: <dan...@us...> - 2010-02-08 20:03:39
|
Revision: 83
http://ktutorial.svn.sourceforge.net/ktutorial/?rev=83&view=rev
Author: danxuliu
Date: 2010-02-08 20:03:32 +0000 (Mon, 08 Feb 2010)
Log Message:
-----------
Move StepWidget creation from Tutorial to KTutorial to keep the model GUI free.
Modified Paths:
--------------
trunk/ktutorial/src/KTutorial.cpp
trunk/ktutorial/src/KTutorial.h
trunk/ktutorial/src/Tutorial.cpp
trunk/ktutorial/src/Tutorial.h
trunk/ktutorial/src/TutorialManager.cpp
trunk/ktutorial/src/TutorialManager.h
trunk/ktutorial/test/TutorialManagerTest.cpp
Modified: trunk/ktutorial/src/KTutorial.cpp
===================================================================
--- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/KTutorial.cpp 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2009 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -21,12 +21,16 @@
#include <klocalizedstring.h>
#include "KTutorial.h"
+#include "Tutorial.h"
+#include "TutorialInformation.h"
#include "scripting/ScriptingModule.h"
#include "scripting/ScriptManager.h"
+#include "view/StepWidget.h"
#include "view/TutorialManagerDialog.h"
using scripting::ScriptingModule;
using scripting::ScriptManager;
+using view::StepWidget;
using view::TutorialManagerDialog;
//public:
@@ -54,7 +58,10 @@
connect(mTutorialsAction, SIGNAL(triggered(bool)),
this, SLOT(showTutorialManagerDialog()));
- connect(mTutorialmanager, SIGNAL(started(const QString&)),
+ connect(mTutorialmanager, SIGNAL(started(Tutorial*)),
+ this, SLOT(showStepWidget(Tutorial*)));
+
+ connect(mTutorialmanager, SIGNAL(started(Tutorial*)),
this, SLOT(disableTutorialsAction()));
connect(mTutorialmanager, SIGNAL(finished()),
this, SLOT(enableTutorialsAction()));
@@ -76,6 +83,15 @@
dialog->show();
}
+void KTutorial::showStepWidget(Tutorial* tutorial) const {
+ QString tutorialName = tutorial->tutorialInformation()->name();
+
+ StepWidget* stepWidget = new StepWidget(tutorialName, mParent);
+ connect(tutorial, SIGNAL(stepActivated(Step*)),
+ stepWidget, SLOT(setStep(Step*)));
+ connect(stepWidget, SIGNAL(finished()), tutorial, SIGNAL(finished()));
+}
+
void KTutorial::disableTutorialsAction() {
mTutorialsAction->setEnabled(false);
}
Modified: trunk/ktutorial/src/KTutorial.h
===================================================================
--- trunk/ktutorial/src/KTutorial.h 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/KTutorial.h 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008-2009 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -176,6 +176,14 @@
void showTutorialManagerDialog() const;
/**
+ * Shows the GUI for the given Tutorial.
+ * Called when the tutorial is about to be started.
+ *
+ * @param tutorial The tutorial to show its StepWidget.
+ */
+ void showStepWidget(Tutorial* tutorial) const;
+
+ /**
* Disables mTutorialsAction.
* Just a wrapper to be connected with signals that can't pass false to the
* setEnabled(bool) slot.
Modified: trunk/ktutorial/src/Tutorial.cpp
===================================================================
--- trunk/ktutorial/src/Tutorial.cpp 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/Tutorial.cpp 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -19,14 +19,9 @@
#include <kdebug.h>
#include "Tutorial.h"
-#include "KTutorial.h"
#include "Step.h"
#include "TutorialInformation.h"
-#include "view/StepWidget.h"
-
-using view::StepWidget;
-
//public:
Tutorial::~Tutorial() {
@@ -52,12 +47,6 @@
return;
}
- StepWidget* stepWidget = new StepWidget(tutorialInformation()->name(),
- KTutorial::self()->parentWidget());
- connect(this, SIGNAL(stepActivated(Step*)),
- stepWidget, SLOT(setStep(Step*)));
- connect(stepWidget, SIGNAL(finished()), this, SIGNAL(finished()));
-
setup();
nextStep("start");
Modified: trunk/ktutorial/src/Tutorial.h
===================================================================
--- trunk/ktutorial/src/Tutorial.h 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/Tutorial.h 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -109,7 +109,7 @@
/**
* Starts this Tutorial.
- * It creates the GUI for the Tutorial and activates the start step.
+ * It sets up the tutorial and activates the start step.
*
* This method is used internally. Do not call this method yourself.
*/
Modified: trunk/ktutorial/src/TutorialManager.cpp
===================================================================
--- trunk/ktutorial/src/TutorialManager.cpp 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/TutorialManager.cpp 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -49,14 +49,14 @@
return;
}
- emit started(id);
-
//TODO remove
kDebug() << "Started: " << id;
Tutorial* tutorial = mTutorials.value(mTutorialInformations.value(id));
connect(tutorial, SIGNAL(finished()), this, SLOT(finish()));
+ emit started(tutorial);
+
tutorial->start();
}
Modified: trunk/ktutorial/src/TutorialManager.h
===================================================================
--- trunk/ktutorial/src/TutorialManager.h 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/src/TutorialManager.h 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Daniel Calviño Sánchez *
+ * Copyright (C) 2008-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -87,10 +87,9 @@
signals:
/**
- * This signal is emitted when the tutorial with the specified id is
- * started.
+ * This signal is emitted when the given tutorial is about to be started.
*/
- void started(const QString& id);
+ void started(Tutorial* tutorial);
/**
* This signal is emitted when the started tutorial finishes, or if no
Modified: trunk/ktutorial/test/TutorialManagerTest.cpp
===================================================================
--- trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-08 19:07:04 UTC (rev 82)
+++ trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-08 20:03:32 UTC (rev 83)
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2009 by Daniel Calviño Sánchez *
+ * Copyright (C) 2009-2010 by Daniel Calviño Sánchez *
* dan...@gm... *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -176,6 +176,9 @@
mTutorialInformation2);
}
+//Tutorial* must be declared as a metatype to be used in qvariant_cast
+Q_DECLARE_METATYPE(Tutorial*);
+
void TutorialManagerTest::testStart() {
mTutorialManager->registerTutorial(mTutorial1);
@@ -187,12 +190,16 @@
Step* startStep = new Step("start");
tutorial2->addStep(startStep);
- QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(QString)));
+ //Tutorial* must be registered in order to be used with QSignalSpy
+ int tutorialStarType = qRegisterMetaType<Tutorial*>("Tutorial*");
+ QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(Tutorial*)));
mTutorialManager->start("secondIdentifier");
QCOMPARE(startedSpy.count(), 1);
- QCOMPARE(startedSpy.at(0).at(0).toString(), QString("secondIdentifier"));
+ QVariant argument = startedSpy.at(0).at(0);
+ QCOMPARE(argument.userType(), tutorialStarType);
+ QCOMPARE(qvariant_cast<Tutorial*>(argument), tutorial2);
QVERIFY(startStep->isActive());
QSignalSpy finishedSpy(mTutorialManager, SIGNAL(finished()));
@@ -206,7 +213,7 @@
mTutorialManager->registerTutorial(mTutorial1);
mTutorialManager->registerTutorial(mTutorial2);
- QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(QString)));
+ QSignalSpy startedSpy(mTutorialManager, SIGNAL(started(Tutorial*)));
QSignalSpy finishedSpy(mTutorialManager, SIGNAL(finished()));
mTutorialManager->start("identifierNotRegistered");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|