ktutorial-commits Mailing List for KTutorial (Page 13)
Status: Alpha
Brought to you by:
danxuliu
You can subscribe to this list here.
2010 |
Jan
(1) |
Feb
(36) |
Mar
(117) |
Apr
(11) |
May
(8) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
(21) |
Oct
(16) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(1) |
Feb
|
Mar
(6) |
Apr
(6) |
May
(15) |
Jun
(15) |
Jul
(6) |
Aug
|
Sep
(1) |
Oct
(4) |
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(10) |
Jul
(4) |
Aug
(29) |
Sep
(4) |
Oct
|
Nov
|
Dec
(2) |
From: <dan...@us...> - 2010-02-10 18:29:56
|
Revision: 87 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=87&view=rev Author: danxuliu Date: 2010-02-10 18:29:49 +0000 (Wed, 10 Feb 2010) Log Message: ----------- Add tearDown() method to Tutorial to be executed after the tutorial finishes. Setup() is now executed when the tutorial is started even if there is no start step, to ensure that whenever a setup method is executed, a tearDown method will be executed, and whenever a tearDown method is executed, a setup method was executed. Modified Paths: -------------- trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/src/scripting/ScriptedTutorial.cpp trunk/ktutorial/src/scripting/ScriptedTutorial.h trunk/ktutorial/test/TutorialTest.cpp trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -41,14 +41,14 @@ } void Tutorial::start() { + setup(); + if (!mSteps.contains("start")) { kError() << "No start step found in tutorial " << mTutorialInformation->id(); - emit finished(); + finish(); return; } - setup(); - nextStep("start"); } @@ -89,5 +89,7 @@ mCurrentStep->setActive(false); } + tearDown(); + emit finished(); } Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/Tutorial.h 2010-02-10 18:29:49 UTC (rev 87) @@ -58,7 +58,8 @@ * information about the Tutorial and add all the Steps with their WaitFors and * Options. Add as many slots as needed to the class to connect them with the * WaitFors and Options when added to their Steps. If something must be set - * before starting the Tutorial redefine setup(), and you are done. + * before starting the Tutorial redefine setup(), if something must be cleaned + * after finishing the tutorial redefine tearDown(), and you are done. */ class KTUTORIAL_EXPORT Tutorial: public QObject { Q_OBJECT @@ -141,7 +142,8 @@ /** * Finishes this Tutorial. - * The current step is deactivated and finished signal is emitted. + * The current step is deactivated, this tutorial is cleaned, and finished + * signal is emitted. * * This slot is used internally. Do not call or connect to this slot * yourself. @@ -182,6 +184,14 @@ virtual void setup() { } + /** + * Sets up the Tutorial before activating start Step. + * Tutorial subclasses can redefine it if they need to set up something + * before start. + */ + virtual void tearDown() { + } + private: /** Modified: trunk/ktutorial/src/scripting/ScriptedTutorial.cpp =================================================================== --- trunk/ktutorial/src/scripting/ScriptedTutorial.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/scripting/ScriptedTutorial.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -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 * @@ -56,6 +56,10 @@ emit setup(this); } +void ScriptedTutorial::tearDown() { + emit tearDown(this); } +} + #include "ScriptedTutorial.moc" Modified: trunk/ktutorial/src/scripting/ScriptedTutorial.h =================================================================== --- trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-10 18:29:49 UTC (rev 87) @@ -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 * @@ -45,6 +45,9 @@ * in the script and connect it to setup(QObject*) signal. Note that, although * the argument in the signal is declared as QObject*, it is in fact the * ScriptedStep that emitted the signal. It is a Kross limitation. + * + * You can do the same if something has to be cleaned after the Tutorial + * finishes using tearDown(QObject*) signal. */ class ScriptedTutorial: public Tutorial { Q_OBJECT @@ -99,6 +102,17 @@ */ void setup(QObject* scriptedTutorial); + /** + * Emitted when this ScriptedTutorial has to be cleaned. + * + * @param scriptedTutorial A pointer to this ScriptedTutorial. + * @see Tutorial::tearDown() + * @todo Change argument type to scripting::ScriptedTutorial* once all major + * Kross scripting backends support classes wrapped through + * WrapperInterface + */ + void tearDown(QObject* scriptedTutorial); + protected: /** @@ -107,6 +121,12 @@ */ virtual void setup(); + /** + * Emits tearDown(scripting::ScriptedTutorial*) signal using this + * ScriptedTutorial as parameter. + */ + virtual void tearDown(); + private: /** Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -57,10 +57,12 @@ public: int mSetupCount; + int mTearDownCount; MockTutorial(TutorialInformation* tutorialInformation): Tutorial(tutorialInformation) { mSetupCount = 0; + mTearDownCount = 0; } protected: @@ -69,6 +71,10 @@ mSetupCount++; } + virtual void tearDown() { + mTearDownCount++; + } + }; void TutorialTest::testConstructor() { @@ -195,6 +201,7 @@ QCOMPARE(tutorial.mCurrentStep, stepStart); QVERIFY(stepStart->isActive()); QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(tutorial.mTearDownCount, 0); } void TutorialTest::testStartNoStartStep() { @@ -212,10 +219,11 @@ tutorial.start(); - QCOMPARE(tutorial.mSetupCount, 0); + QCOMPARE(tutorial.mSetupCount, 1); QCOMPARE(stepActivatedSpy.count(), 0); QCOMPARE(tutorial.mCurrentStep, (Step*)0); QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(tutorial.mTearDownCount, 1); } void TutorialTest::testNextStepId() { @@ -344,6 +352,7 @@ QVERIFY(!stepStart->isActive()); QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(tutorial.mTearDownCount, 1); } QTEST_MAIN(TutorialTest) Modified: trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp =================================================================== --- trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp 2010-02-10 18:06:14 UTC (rev 86) +++ trunk/ktutorial/test/scripting/ScriptedTutorialTest.cpp 2010-02-10 18:29:49 UTC (rev 87) @@ -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 * @@ -51,6 +51,9 @@ void testSetup(); void testSetupObjectArgument(); + void testTearDown(); + void testTearDownObjectArgument(); + private: KTemporaryFile* mTemporaryFile; @@ -161,8 +164,46 @@ QCOMPARE(qvariant_cast<QObject*>(argument), &scriptedTutorial); } +void ScriptedTutorialTest::testTearDown() { + QSKIP("Skipped until tearDown argument is set again to scripting::ScriptedTutorial*", SkipAll); + + ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); + + //ScriptedTutorial* must be registered in order to be used with QSignalSpy. + //The name must contain the namespace, as it needs the full name used in the + //signal (and the signal has to be declared using the full namespace so the + //spied argument can be converted using qvariant_cast). + int scriptedTutorialStarType = + qRegisterMetaType<ScriptedTutorial*>("scripting::ScriptedTutorial*"); + QSignalSpy tearDownSpy(&scriptedTutorial, + SIGNAL(tearDown(scripting::ScriptedTutorial*))); + + scriptedTutorial.tearDown(); + + QCOMPARE(tearDownSpy.count(), 1); + QVariant argument = tearDownSpy.at(0).at(0); + QCOMPARE(argument.userType(), scriptedTutorialStarType); + QCOMPARE(qvariant_cast<ScriptedTutorial*>(argument), &scriptedTutorial); } +void ScriptedTutorialTest::testTearDownObjectArgument() { + ScriptedTutorial scriptedTutorial(mTemporaryFile->fileName()); + + QSignalSpy tearDownSpy(&scriptedTutorial, SIGNAL(tearDown(QObject*))); + + scriptedTutorial.tearDown(); + + QCOMPARE(tearDownSpy.count(), 1); + QVariant argument = tearDownSpy.at(0).at(0); + //From QVariant::Type documentation + //"Although this function is declared as returning QVariant::Type, the + //return value should be interpreted as QMetaType::Type" + QCOMPARE((QMetaType::Type)argument.type(), QMetaType::QObjectStar); + QCOMPARE(qvariant_cast<QObject*>(argument), &scriptedTutorial); +} + +} + QTEST_MAIN(scripting::ScriptedTutorialTest) #include "ScriptedTutorialTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-10 18:06:22
|
Revision: 86 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=86&view=rev Author: danxuliu Date: 2010-02-10 18:06:14 +0000 (Wed, 10 Feb 2010) Log Message: ----------- Explicitly set the virtual property of setup() method. It isn't required due to being specified in the parent class and thus inherited, but it makes a clearer code. Modified Paths: -------------- trunk/ktutorial/src/scripting/ScriptedTutorial.h Modified: trunk/ktutorial/src/scripting/ScriptedTutorial.h =================================================================== --- trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-09 02:15:30 UTC (rev 85) +++ trunk/ktutorial/src/scripting/ScriptedTutorial.h 2010-02-10 18:06:14 UTC (rev 86) @@ -105,7 +105,7 @@ * Emits setup(scripting::ScriptedTutorial*) signal using this * ScriptedTutorial as parameter. */ - void setup(); + virtual void setup(); private: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-09 02:15:36
|
Revision: 85 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=85&view=rev Author: danxuliu Date: 2010-02-09 02:15:30 +0000 (Tue, 09 Feb 2010) Log Message: ----------- Since commit 83 no GUI is needed to start a tutorial. Modified Paths: -------------- trunk/ktutorial/test/TutorialManagerTest.cpp trunk/ktutorial/test/TutorialTest.cpp trunk/ktutorial/test/scripting/ScriptManagerTest.cpp trunk/ktutorial/test/scripting/ScriptingTest.cpp Modified: trunk/ktutorial/test/TutorialManagerTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-09 01:57:11 UTC (rev 84) +++ trunk/ktutorial/test/TutorialManagerTest.cpp 2010-02-09 02:15:30 UTC (rev 85) @@ -222,6 +222,6 @@ QCOMPARE(finishedSpy.count(), 1); } -QTEST_KDEMAIN(TutorialManagerTest, GUI) +QTEST_MAIN(TutorialManagerTest) #include "TutorialManagerTest.moc" Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-09 01:57:11 UTC (rev 84) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-09 02:15:30 UTC (rev 85) @@ -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 * @@ -346,6 +346,6 @@ QCOMPARE(finishedSpy.count(), 1); } -QTEST_KDEMAIN(TutorialTest, GUI) +QTEST_MAIN(TutorialTest) #include "TutorialTest.moc" Modified: trunk/ktutorial/test/scripting/ScriptManagerTest.cpp =================================================================== --- trunk/ktutorial/test/scripting/ScriptManagerTest.cpp 2010-02-09 01:57:11 UTC (rev 84) +++ trunk/ktutorial/test/scripting/ScriptManagerTest.cpp 2010-02-09 02:15:30 UTC (rev 85) @@ -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 * @@ -138,6 +138,6 @@ } -QTEST_KDEMAIN(scripting::ScriptManagerTest, NoGUI) +QTEST_MAIN(scripting::ScriptManagerTest) #include "ScriptManagerTest.moc" Modified: trunk/ktutorial/test/scripting/ScriptingTest.cpp =================================================================== --- trunk/ktutorial/test/scripting/ScriptingTest.cpp 2010-02-09 01:57:11 UTC (rev 84) +++ trunk/ktutorial/test/scripting/ScriptingTest.cpp 2010-02-09 02:15:30 UTC (rev 85) @@ -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 * @@ -390,7 +390,6 @@ } -//A GUI is needed because tutorials create and show StepWidgets when started -QTEST_KDEMAIN(scripting::ScriptingTest, GUI) +QTEST_MAIN(scripting::ScriptingTest) #include "ScriptingTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-09 01:57:18
|
Revision: 84 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=84&view=rev Author: danxuliu Date: 2010-02-09 01:57:11 +0000 (Tue, 09 Feb 2010) Log Message: ----------- Ensure that the current step is deactivated when the tutorial finishes. Modified Paths: -------------- trunk/ktutorial/src/KTutorial.cpp trunk/ktutorial/src/Tutorial.cpp trunk/ktutorial/src/Tutorial.h trunk/ktutorial/test/TutorialTest.cpp Modified: trunk/ktutorial/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/KTutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -89,7 +89,7 @@ StepWidget* stepWidget = new StepWidget(tutorialName, mParent); connect(tutorial, SIGNAL(stepActivated(Step*)), stepWidget, SLOT(setStep(Step*))); - connect(stepWidget, SIGNAL(finished()), tutorial, SIGNAL(finished())); + connect(stepWidget, SIGNAL(finished()), tutorial, SLOT(finish())); } void KTutorial::disableTutorialsAction() { Modified: trunk/ktutorial/src/Tutorial.cpp =================================================================== --- trunk/ktutorial/src/Tutorial.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -81,3 +81,13 @@ mCurrentStep = step; mCurrentStep->setActive(true); } + +//public slots: + +void Tutorial::finish() { + if (mCurrentStep != 0) { + mCurrentStep->setActive(false); + } + + emit finished(); +} Modified: trunk/ktutorial/src/Tutorial.h =================================================================== --- trunk/ktutorial/src/Tutorial.h 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/src/Tutorial.h 2010-02-09 01:57:11 UTC (rev 84) @@ -137,6 +137,17 @@ */ void nextStep(Step* step); +public slots: + + /** + * Finishes this Tutorial. + * The current step is deactivated and finished signal is emitted. + * + * This slot is used internally. Do not call or connect to this slot + * yourself. + */ + void finish(); + signals: /** Modified: trunk/ktutorial/test/TutorialTest.cpp =================================================================== --- trunk/ktutorial/test/TutorialTest.cpp 2010-02-08 20:03:32 UTC (rev 83) +++ trunk/ktutorial/test/TutorialTest.cpp 2010-02-09 01:57:11 UTC (rev 84) @@ -49,6 +49,8 @@ void testNextStepStep(); void testNextStepStepWithInvalidStep(); + void testFinish(); + }; class MockTutorial: public Tutorial { @@ -329,6 +331,21 @@ QVERIFY(step1->isActive()); } +void TutorialTest::testFinish() { + MockTutorial tutorial(new TutorialInformation("pearlOrientation")); + + Step* stepStart = new Step("start"); + tutorial.addStep(stepStart); + + QSignalSpy finishedSpy(&tutorial, SIGNAL(finished())); + + tutorial.start(); + tutorial.finish(); + + QVERIFY(!stepStart->isActive()); + QCOMPARE(finishedSpy.count(), 1); +} + QTEST_KDEMAIN(TutorialTest, GUI) #include "TutorialTest.moc" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <dan...@us...> - 2010-02-08 19:07:11
|
Revision: 82 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=82&view=rev Author: danxuliu Date: 2010-02-08 19:07:04 +0000 (Mon, 08 Feb 2010) Log Message: ----------- More appropriate visibility for showTutorialManagerDialog slot. Modified Paths: -------------- trunk/ktutorial/src/KTutorial.cpp trunk/ktutorial/src/KTutorial.h Modified: trunk/ktutorial/src/KTutorial.cpp =================================================================== --- trunk/ktutorial/src/KTutorial.cpp 2010-02-08 17:23:05 UTC (rev 81) +++ trunk/ktutorial/src/KTutorial.cpp 2010-02-08 19:07:04 UTC (rev 82) @@ -64,6 +64,10 @@ ScriptManager().loadTutorials(mTutorialmanager); } +//private: + +KTutorial* KTutorial::sSelf = new KTutorial(); + void KTutorial::showTutorialManagerDialog() const { QDialog* dialog = new TutorialManagerDialog(mTutorialmanager, mParent); dialog->setAttribute(Qt::WA_DeleteOnClose); @@ -72,10 +76,6 @@ dialog->show(); } -//private: - -KTutorial* KTutorial::sSelf = new KTutorial(); - void KTutorial::disableTutorialsAction() { mTutorialsAction->setEnabled(false); } Modified: trunk/ktutorial/src/KTutorial.h =================================================================== --- trunk/ktutorial/src/KTutorial.h 2010-02-08 17:23:05 UTC (rev 81) +++ trunk/ktutorial/src/KTutorial.h 2010-02-08 19:07:04 UTC (rev 82) @@ -134,14 +134,6 @@ return mParent->findChild<T>(name); } -public slots: - - /** - * Shows a modal TutorialManagerDialog. - * Called when the tutorials action is triggered. - */ - void showTutorialManagerDialog() const; - private: /** @@ -178,6 +170,12 @@ private slots: /** + * Shows a modal TutorialManagerDialog. + * Called when the tutorials action is triggered. + */ + void showTutorialManagerDialog() const; + + /** * Disables mTutorialsAction. * Just a wrapper to be connected with signals that can't pass false to the * setEnabled(bool) slot. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-08 17:23:12
|
Revision: 81 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=81&view=rev Author: danxuliu Date: 2010-02-08 17:23:05 +0000 (Mon, 08 Feb 2010) Log Message: ----------- According to Valgrind XML output documentation (docs/internals/xml-output-protocol4.txt), the information can be stored in xwhat or what elements, depending on whether it contains extra data or not. Modified Paths: -------------- trunk/ktutorial/test/runMemcheck.py Modified: trunk/ktutorial/test/runMemcheck.py =================================================================== --- trunk/ktutorial/test/runMemcheck.py 2010-02-07 00:28:25 UTC (rev 80) +++ trunk/ktutorial/test/runMemcheck.py 2010-02-08 17:23:05 UTC (rev 81) @@ -79,7 +79,9 @@ for frame in stack: if xml_child_data(frame, 'fn'): # filter anonymous frames out self.stack.append(Frame(frame)) - self.what = xml_child_data(self.dom.getElementsByTagName('xwhat')[0], 'text') + self.what = xml_child_data(self.dom, 'what') + if self.dom.getElementsByTagName('xwhat').length > 0: + self.what = xml_child_data(self.dom.getElementsByTagName('xwhat')[0], 'text') def is_definitely_lost(self): return self.kind == u'Leak_DefinitelyLost' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-07 00:48:54
|
Revision: 80 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=80&view=rev Author: danxuliu Date: 2010-02-07 00:28:25 +0000 (Sun, 07 Feb 2010) Log Message: ----------- Change KHTML information page link Modified Paths: -------------- trunk/web-src/pages/aboutWeb.xml Modified: trunk/web-src/pages/aboutWeb.xml =================================================================== --- trunk/web-src/pages/aboutWeb.xml 2010-02-07 00:27:12 UTC (rev 79) +++ trunk/web-src/pages/aboutWeb.xml 2010-02-07 00:28:25 UTC (rev 80) @@ -86,7 +86,7 @@ </h2> </div> <p>The website was tested successfully in <a href="http://www.mozilla.com/firefox/" title="Official Mozilla Firefox site">Mozilla Firefox</a> 1.0.6 to 3.5.7, <a href="http://www.konqueror.org/" title="Konqueror Homepage">Konqueror</a> 3.4.2 to 4.3.2, <a href="http://www.mozilla.org/products/mozilla1.x/" title="Official Mozilla Suite site">Mozilla Suite</a> 1.7.11 and <a href="http://lynx.browser.org/" title="Lynx browser information">Lynx</a> 2.8.5.</p> - <p>It's expected to fully work in any browser based either in <a href="http://www.mozilla.org/newlayout/" title="Mozilla Layout Engine page">Gecko</a> or <a href="http://khtml.info/" title="KHTML information wiki">KHTML</a> layout engine.</p> + <p>It's expected to fully work in any browser based either in <a href="http://www.mozilla.org/newlayout/" title="Mozilla Layout Engine page">Gecko</a> or <a href="http://en.wikipedia.org/wiki/KHTML" title="KHTML article at Wikipedia">KHTML</a> layout engine.</p> <p>Lynx is a text browser and has no support for ECMAScript, but all the pages can be viewed without any problem on it.</p> <p><a href="http://www.microsoft.com/windows/ie/" title="Internet Explorer Download Page">Internet Explorer</a> doesn't support any of the scripts, but the page can be viewed without problem apart of this and some minor appearance glitches. This is due to the lack of support in Internet Explorer for some ECMAScript bindings. At least, version 6, I don't know about version 7, but neither I care :P</p> <p>It's not a big problem, however, because being the website of a free project for GNU/Linux, hardly any of the visits to the page will be from Internet Explorer users. Most of the potential visitors will use one of the fully supported browsers.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-07 00:48:52
|
Revision: 79 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=79&view=rev Author: danxuliu Date: 2010-02-07 00:27:12 +0000 (Sun, 07 Feb 2010) Log Message: ----------- Use plain HTTP links to SourceForge.net instead of HTTPS links Modified Paths: -------------- trunk/web-src/pages/download.xml Modified: trunk/web-src/pages/download.xml =================================================================== --- trunk/web-src/pages/download.xml 2010-02-06 23:21:40 UTC (rev 78) +++ trunk/web-src/pages/download.xml 2010-02-07 00:27:12 UTC (rev 79) @@ -17,8 +17,8 @@ <div class="h2Rounded"> <h2><a id="releases" class="anchorLink">Releases</a></h2> </div> - <p>Current release is 0.2. You can download <a href="https://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/ktutorial-0.2.tar.gz/download" title="KTutorial 0.2 release in tar.gz">ktutorial-0.2.tar.gz</a> from <a href="https://sourceforge.net/projects/ktutorial/files/" title="KTutorial project files">project's file list</a>.</p> - <p>You can also see the <a href="https://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/Release%20notes/view" title="KTutorial 0.2 release notes">release notes</a> (although there isn't much to see ;) ).</p> + <p>Current release is 0.2. You can download <a href="http://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/ktutorial-0.2.tar.gz/download" title="KTutorial 0.2 release in tar.gz">ktutorial-0.2.tar.gz</a> from <a href="http://sourceforge.net/projects/ktutorial/files/" title="KTutorial project files">project's file list</a>.</p> + <p>You can also see the <a href="http://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/Release%20notes/view" title="KTutorial 0.2 release notes">release notes</a> (although there isn't much to see ;) ).</p> <p>See below for build instructions, in <a href="#build" title="Build instructions">building section</a>.</p> <p>If you do know what you are doing ;) , you can also checkout KTutorial sources from <acronym title="Subversion">SVN</acronym> repository. Go on reading to know how to do it.</p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 23:21:46
|
Revision: 78 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=78&view=rev Author: danxuliu Date: 2010-02-06 23:21:40 +0000 (Sat, 06 Feb 2010) Log Message: ----------- When webpage is built, remove backup files from src directory Modified Paths: -------------- trunk/web-src/cybertron.sh Modified: trunk/web-src/cybertron.sh =================================================================== --- trunk/web-src/cybertron.sh 2010-02-06 22:56:59 UTC (rev 77) +++ trunk/web-src/cybertron.sh 2010-02-06 23:21:40 UTC (rev 78) @@ -149,6 +149,7 @@ # Copies the source dir to the output dir. function copySrcDir() { cp -r . $outputDir/src; + find $outputDir/src -name "*~" -exec rm {} \; rm -fr $outputDir/src/data/apidocs; rm -fr $outputDir/src/data/doc; rm -fr $outputDir/src/data/files; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 22:57:05
|
Revision: 77 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=77&view=rev Author: danxuliu Date: 2010-02-06 22:56:59 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Update base URL Modified Paths: -------------- trunk/web-src/cybertron.sh trunk/web-src/news-toAtom.xsl trunk/web-src/pages/index.xml trunk/web-src/transformers/header.xsl Modified: trunk/web-src/cybertron.sh =================================================================== --- trunk/web-src/cybertron.sh 2010-02-06 22:54:43 UTC (rev 76) +++ trunk/web-src/cybertron.sh 2010-02-06 22:56:59 UTC (rev 77) @@ -169,7 +169,7 @@ encoding="utf-8"; outputDir=../build/; -baseURL="http://csl2-ktutorial.forja.rediris.es/"; +baseURL="http://ktutorial.sourceforge.net/"; while getopts e:o:u: o do @@ -180,7 +180,7 @@ [?]) echo "Usage: $0 [-e encoding] [-o outputDir] [-u baseURL]"; echo " Default encoding: utf-8"; echo " Default output directory: ../build/"; - echo " Default baseURL: http://csl2-ktutorial.forja.rediris.es/"; + echo " Default baseURL: http://ktutorial.sourceforge.net/"; exit 1;; esac done Modified: trunk/web-src/news-toAtom.xsl =================================================================== --- trunk/web-src/news-toAtom.xsl 2010-02-06 22:54:43 UTC (rev 76) +++ trunk/web-src/news-toAtom.xsl 2010-02-06 22:56:59 UTC (rev 77) @@ -39,7 +39,7 @@ <!-- The base URL of the feed site. Must include ending slash. --> - <xsl:param name="baseURL" select="'http://csl2-ktutorial.forja.rediris.es/'"/> + <xsl:param name="baseURL" select="'http://ktutorial.sourceforge.net/'"/> <!-- The URL to the HTML news page from the base URL. Modified: trunk/web-src/pages/index.xml =================================================================== --- trunk/web-src/pages/index.xml 2010-02-06 22:54:43 UTC (rev 76) +++ trunk/web-src/pages/index.xml 2010-02-06 22:56:59 UTC (rev 77) @@ -7,7 +7,7 @@ </headElements> <validationButtons> <p xmlns="http://www.w3.org/1999/xhtml"> - <a href="http://feedvalidator.org/check.cgi?url=http%3A//csl2-ktutorial.forja.rediris.es/feed/atom/news.xml" title="Check Atom feed"> + <a href="http://feedvalidator.org/check.cgi?url=http%3A//ktutorial.sourceforge.net/feed/atom/news.xml" title="Check Atom feed"> <img src="images/valid-atom.png" alt="Valid Atom 1.0!" height="15" width="80"/> </a> </p> Modified: trunk/web-src/transformers/header.xsl =================================================================== --- trunk/web-src/transformers/header.xsl 2010-02-06 22:54:43 UTC (rev 76) +++ trunk/web-src/transformers/header.xsl 2010-02-06 22:56:59 UTC (rev 77) @@ -17,7 +17,7 @@ <div id="header"> <div id="logo"> <div id="logoName"> - <a href="http://forja.rediris.es/projects/csl2-ktutorial/" title="KTutorial project page">KTutorial</a> + <a href="http://sourceforge.net/projects/ktutorial/" title="KTutorial project page">KTutorial</a> </div> <p id="logoCompleteName">Library for KDE interactive tutorials</p> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 22:54:49
|
Revision: 76 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=76&view=rev Author: danxuliu Date: 2010-02-06 22:54:43 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Release 0.2 new and download information Modified Paths: -------------- trunk/web-src/newsList.xml trunk/web-src/pages/download.xml trunk/web-src/pages/index.xml trunk/web-src/pages/news.xml Modified: trunk/web-src/newsList.xml =================================================================== --- trunk/web-src/newsList.xml 2010-02-06 18:03:24 UTC (rev 75) +++ trunk/web-src/newsList.xml 2010-02-06 22:54:43 UTC (rev 76) @@ -12,4 +12,16 @@ <date>2010-01-30</date> </fullDate> </new> + + <new> + <title>KTutorial 0.2 released!</title> + <summary> + <div xmlns="http://www.w3.org/1999/xhtml"> + <p>Check <a href="download.html" title="Download page in KTutorial web">download page</a> for further information.</p> + </div> + </summary> + <fullDate> + <date>2010-02-06</date> + </fullDate> + </new> </news> \ No newline at end of file Modified: trunk/web-src/pages/download.xml =================================================================== --- trunk/web-src/pages/download.xml 2010-02-06 18:03:24 UTC (rev 75) +++ trunk/web-src/pages/download.xml 2010-02-06 22:54:43 UTC (rev 76) @@ -17,9 +17,8 @@ <div class="h2Rounded"> <h2><a id="releases" class="anchorLink">Releases</a></h2> </div> - <p><strong>Important:</strong> Note that the instructions in this page are outdated and refer to release 0.1, which is hosted in the forge previously used by KTutorial. Release 0.2, hosted at SourceForge.net, will be out soon.</p> - <p>Current release is 0.1. You can download <a href="https://forja.rediris.es/frs/download.php/654/ktutorial-0.1.tar.gz" title="KTutorial 0.1 release in tar.gz">ktutorial-0.1.tar.gz</a> from <a href="https://forja.rediris.es/frs/?group_id=280" title="KTutorial project files">project's file list</a>.</p> - <p>You can also see the <a href="https://forja.rediris.es/frs/shownotes.php?release_id=405" title="KTutorial 0.1 release notes">release notes</a> (although there isn't much to see ;) ).</p> + <p>Current release is 0.2. You can download <a href="https://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/ktutorial-0.2.tar.gz/download" title="KTutorial 0.2 release in tar.gz">ktutorial-0.2.tar.gz</a> from <a href="https://sourceforge.net/projects/ktutorial/files/" title="KTutorial project files">project's file list</a>.</p> + <p>You can also see the <a href="https://sourceforge.net/projects/ktutorial/files/ktutorial-0.2/Release%20notes/view" title="KTutorial 0.2 release notes">release notes</a> (although there isn't much to see ;) ).</p> <p>See below for build instructions, in <a href="#build" title="Build instructions">building section</a>.</p> <p>If you do know what you are doing ;) , you can also checkout KTutorial sources from <acronym title="Subversion">SVN</acronym> repository. Go on reading to know how to do it.</p> @@ -38,10 +37,10 @@ <h2><a id="build" class="anchorLink">Building</a></h2> </div> <p>In order to build KTutorial, it doesn't matter if you downloaded it from a release or from <acronym title="Subversion">SVN</acronym>.</p> - <p>You will need <a href="http://www.cmake.org" title="CMake project web">CMake</a> and KDE 4 kdelibs development packages installed in your system. It can be built like any other KDE 4 library or application.</p> + <p>You will need <a href="http://www.cmake.org" title="CMake project web">CMake</a>, and Qt >= 4.5.3 and KDE 4 kdelibs development packages installed in your system. It can be built like any other KDE 4 library or application.</p> <p>Create a <em>build</em> subdirectory in <em>ktutorial</em> directory, and change to it. Now, in a terminal, just run <strong>cmake ../ && make</strong> and it will configure and build KTutorial in the <em>build</em> directory. Once built, execute <strong>make install</strong> and you are done (you will likely need to change to root user, as default KDE installation is usually only root writable).</p> <p>If you want to specify a prefix to install KTutorial to, instead of using KDE default installation directory, call CMake using the parameter <strong>-DCMAKE_INSTALL_PREFIX=/installation/prefix</strong>. For debugging purposes, use <strong>-DCMAKE_BUILD_TYPE=debugfull</strong>. To automatically build the unit tests when the library is built, use <strong>-DKDE4_BUILD_TESTS=ON</strong>.</p> - <p class="lastUpdated">Last updated: 2010-01-30</p> + <p class="lastUpdated">Last updated: 2010-02-06</p> </page:content> </page> Modified: trunk/web-src/pages/index.xml =================================================================== --- trunk/web-src/pages/index.xml 2010-02-06 18:03:24 UTC (rev 75) +++ trunk/web-src/pages/index.xml 2010-02-06 22:54:43 UTC (rev 76) @@ -26,6 +26,19 @@ <div id="news"> <div class="new"> <h2 class="newTitle"> + <a id="newId2" class="anchorLink">KTutorial 0.2 released!</a> + </h2> + <div class="newBody"> + <p class="newDate">2010-02-06</p> + <div class="newContent"> + <div> + <p>Check <a href="download.html" title="Download page in KTutorial web">download page</a> for further information.</p> + </div> + </div> + </div> + </div> + <div class="new"> + <h2 class="newTitle"> <a id="newId1" class="anchorLink">Moved to SourceForge.net</a> </h2> <div class="newBody"> Modified: trunk/web-src/pages/news.xml =================================================================== --- trunk/web-src/pages/news.xml 2010-02-06 18:03:24 UTC (rev 75) +++ trunk/web-src/pages/news.xml 2010-02-06 22:54:43 UTC (rev 76) @@ -23,6 +23,19 @@ <div id="news"> <div class="new"> <h2 class="newTitle"> + <a id="newId2" class="anchorLink">KTutorial 0.2 released!</a> + </h2> + <div class="newBody"> + <p class="newDate">2010-02-06</p> + <div class="newContent"> + <div> + <p>Check <a href="download.html" title="Download page in KTutorial web">download page</a> for further information.</p> + </div> + </div> + </div> + </div> + <div class="new"> + <h2 class="newTitle"> <a id="newId1" class="anchorLink">Moved to SourceForge.net</a> </h2> <div class="newBody"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 18:03:31
|
Revision: 75 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=75&view=rev Author: danxuliu Date: 2010-02-06 18:03:24 +0000 (Sat, 06 Feb 2010) Log Message: ----------- 0.2 release tagged Added Paths: ----------- tags/ktutorial-0.2/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 17:34:15
|
Revision: 74 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=74&view=rev Author: danxuliu Date: 2010-02-06 17:34:09 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Update translation files and bug address for l10n issues. Modified Paths: -------------- trunk/ktutorial/po/ktutorial/Messages.sh trunk/ktutorial/po/ktutorial/es.po trunk/ktutorial/po/ktutorial/ktutorial.pot trunk/ktutorial/po/test-app/Messages.sh trunk/ktutorial/po/test-app/es.po trunk/ktutorial/po/test-app/ktutorial-test-app.pot Modified: trunk/ktutorial/po/ktutorial/Messages.sh =================================================================== --- trunk/ktutorial/po/ktutorial/Messages.sh 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/ktutorial/Messages.sh 2010-02-06 17:34:09 UTC (rev 74) @@ -2,7 +2,7 @@ BASEDIR="../../src/" # root of translatable sources PROJECT="ktutorial" # project name -BUGADDR="https://forja.rediris.es/tracker/?atid=1080&group_id=280" # MSGID-Bugs +BUGADDR="http://sourceforge.net/tracker/?group_id=301227&atid=1270278" # MSGID-Bugs WDIR=`pwd` # working dir echo "Preparing rc files" Modified: trunk/ktutorial/po/ktutorial/es.po =================================================================== --- trunk/ktutorial/po/ktutorial/es.po 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/ktutorial/es.po 2010-02-06 17:34:09 UTC (rev 74) @@ -6,9 +6,9 @@ msgid "" msgstr "" "Project-Id-Version: es\n" -"Report-Msgid-Bugs-To: https://forja.rediris.es/tracker/?" -"atid=1080&group_id=280\n" -"POT-Creation-Date: 2008-03-16 19:30+0100\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" +"group_id=301227&atid=1270278\n" +"POT-Creation-Date: 2010-02-06 17:57+0100\n" "PO-Revision-Date: 2008-03-16 19:00+0100\n" "Last-Translator: Daniel Calviño Sánchez <dan...@gm...>\n" "Language-Team: Español\n" @@ -17,7 +17,7 @@ "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.11.4\n" -#: KTutorial.cpp:42 +#: KTutorial.cpp:52 msgctxt "@action:inmenu" msgid "Tutorials..." msgstr "Tutoriales..." @@ -27,27 +27,27 @@ msgid "Tutorial: %1" msgstr "Tutorial: %1" -#: view/TutorialListModel.cpp:53 +#: view/TutorialListModel.cpp:57 msgctxt "@title:column" msgid "Tutorials name" msgstr "Nombres de los tutoriales" -#: view/TutorialManagerDialog.cpp:37 rc.cpp:15 +#: view/TutorialManagerDialog.cpp:39 rc.cpp:15 msgctxt "@title:window" msgid "Tutorial manager" msgstr "Gestor de tutoriales" -#: view/TutorialManagerDialog.cpp:43 +#: view/TutorialManagerDialog.cpp:45 msgctxt "@action:button" msgid "Start" msgstr "Empezar" -#: view/TutorialManagerDialog.cpp:44 +#: view/TutorialManagerDialog.cpp:46 msgctxt "@info:tooltip" msgid "Start the selected tutorial" msgstr "Empezar el tutorial seleccionado" -#: view/TutorialManagerDialog.cpp:45 +#: view/TutorialManagerDialog.cpp:47 msgctxt "@info:whatsthis" msgid "Start the selected tutorial" msgstr "Empezar el tutorial seleccionado" Modified: trunk/ktutorial/po/ktutorial/ktutorial.pot =================================================================== --- trunk/ktutorial/po/ktutorial/ktutorial.pot 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/ktutorial/ktutorial.pot 2010-02-06 17:34:09 UTC (rev 74) @@ -7,9 +7,9 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: https://forja.rediris.es/tracker/?" -"atid=1080&group_id=280\n" -"POT-Creation-Date: 2008-03-16 19:30+0100\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" +"group_id=301227&atid=1270278\n" +"POT-Creation-Date: 2010-02-06 17:57+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" @@ -17,7 +17,7 @@ "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: KTutorial.cpp:42 +#: KTutorial.cpp:52 msgctxt "@action:inmenu" msgid "Tutorials..." msgstr "" @@ -27,27 +27,27 @@ msgid "Tutorial: %1" msgstr "" -#: view/TutorialListModel.cpp:53 +#: view/TutorialListModel.cpp:57 msgctxt "@title:column" msgid "Tutorials name" msgstr "" -#: view/TutorialManagerDialog.cpp:37 rc.cpp:15 +#: view/TutorialManagerDialog.cpp:39 rc.cpp:15 msgctxt "@title:window" msgid "Tutorial manager" msgstr "" -#: view/TutorialManagerDialog.cpp:43 +#: view/TutorialManagerDialog.cpp:45 msgctxt "@action:button" msgid "Start" msgstr "" -#: view/TutorialManagerDialog.cpp:44 +#: view/TutorialManagerDialog.cpp:46 msgctxt "@info:tooltip" msgid "Start the selected tutorial" msgstr "" -#: view/TutorialManagerDialog.cpp:45 +#: view/TutorialManagerDialog.cpp:47 msgctxt "@info:whatsthis" msgid "Start the selected tutorial" msgstr "" Modified: trunk/ktutorial/po/test-app/Messages.sh =================================================================== --- trunk/ktutorial/po/test-app/Messages.sh 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/test-app/Messages.sh 2010-02-06 17:34:09 UTC (rev 74) @@ -2,7 +2,7 @@ BASEDIR="../../test-app/" # root of translatable sources PROJECT="ktutorial-test-app" # project name -BUGADDR="https://forja.rediris.es/tracker/?atid=1080&group_id=280" # MSGID-Bugs +BUGADDR="http://sourceforge.net/tracker/?group_id=301227&atid=1270278" # MSGID-Bugs WDIR=`pwd` # working dir echo "Preparing rc files" Modified: trunk/ktutorial/po/test-app/es.po =================================================================== --- trunk/ktutorial/po/test-app/es.po 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/test-app/es.po 2010-02-06 17:34:09 UTC (rev 74) @@ -2,20 +2,21 @@ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # -# Daniel Calviño Sánchez <dan...@gm...>, 2008. +# Daniel Calviño Sánchez <dan...@gm...>, 2008, 2010. msgid "" msgstr "" "Project-Id-Version: es\n" -"Report-Msgid-Bugs-To: https://forja.rediris.es/tracker/?" -"atid=1080&group_id=280\n" -"POT-Creation-Date: 2010-01-04 17:13+0100\n" -"PO-Revision-Date: 2008-03-28 17:41+0100\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" +"group_id=301227&atid=1270278\n" +"POT-Creation-Date: 2010-02-06 17:57+0100\n" +"PO-Revision-Date: 2010-02-06 18:09+0100\n" "Last-Translator: Daniel Calviño Sánchez <dan...@gm...>\n" "Language-Team: Español\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: KBabel 1.11.4\n" +"X-Generator: Lokalize 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: main.cpp:27 msgctxt "@title" @@ -67,7 +68,8 @@ #: TutorialClearText.cpp:37 TutorialClearText.cpp:67 TutorialClearText.js:26 #: TutorialClearText.js:35 TutorialClearText.py:29 TutorialClearText.py:38 -#: TutorialMoveText.cpp:57 TutorialMoveText.cpp:163 +#: TutorialMoveText.cpp:57 TutorialMoveText.cpp:163 TutorialMoveText.py:84 +#: TutorialMoveText.py:91 msgid "Hello world" msgstr "Hola mundo" @@ -96,15 +98,15 @@ msgid "And that's all.<nl/>Now you can close the tutorial." msgstr "Y eso es todo.<nl/>Ahora puedes cerrar el tutorial." -#: TutorialMoveText.cpp:38 +#: TutorialMoveText.cpp:38 TutorialMoveText.py:24 msgid "Move text in the text area" msgstr "Mover texto en el área de texto" -#: TutorialMoveText.cpp:39 +#: TutorialMoveText.cpp:39 TutorialMoveText.py:25 msgid "This tutorial shows how to move text in the text area" msgstr "Este tutorial muestra cómo mover texto en el área de texto" -#: TutorialMoveText.cpp:48 +#: TutorialMoveText.cpp:48 TutorialMoveText.py:66 msgctxt "@info" msgid "" "In this tutorial you will learn how to move text in the test application.<nl/" @@ -113,30 +115,31 @@ "En este tutorial aprenderás cómo mover texto en la aplicación de prueba.<nl/" ">El texto puede moverse utilizando el ratón o el teclado. ¿Qué prefieres?" -#: TutorialMoveText.cpp:50 +#: TutorialMoveText.cpp:50 TutorialMoveText.py:68 msgid "Mouse" msgstr "Ratón" -#: TutorialMoveText.cpp:51 +#: TutorialMoveText.cpp:51 TutorialMoveText.py:74 msgid "Keyboard" msgstr "Teclado" -#: TutorialMoveText.cpp:57 +#: TutorialMoveText.cpp:57 TutorialMoveText.py:84 msgctxt "@info" msgid "First of all, clean the text area and write \"%1\" (without quotes)" msgstr "" "Lo primero de todo, limpia el área de texto y escribe \"%1\" (sin comillas)" -#: TutorialMoveText.cpp:66 TutorialMoveText.cpp:170 +#: TutorialMoveText.cpp:66 TutorialMoveText.cpp:170 TutorialMoveText.py:98 +#: TutorialMoveText.py:105 msgid "world" msgstr "mundo" -#: TutorialMoveText.cpp:66 +#: TutorialMoveText.cpp:66 TutorialMoveText.py:98 msgctxt "@info" msgid "Now, select the text \"%1\" in the text area" msgstr "Ahora, selecciona el texto \"%1\" en el área de texto" -#: TutorialMoveText.cpp:75 +#: TutorialMoveText.cpp:75 TutorialMoveText.py:115 msgctxt "@info" msgid "" "The next thing to do is cut the selected text. Cutting it will remove it " @@ -149,16 +152,16 @@ "cortar el texto seleccionado, haz click en <interface>Editar->Cortar</" "interface> o en el botón de la barra de tareas" -#: TutorialMoveText.cpp:85 +#: TutorialMoveText.cpp:85 TutorialMoveText.py:129 msgid "Hello" msgstr "Hola" -#: TutorialMoveText.cpp:85 +#: TutorialMoveText.cpp:85 TutorialMoveText.py:129 msgctxt "@info" msgid "Move the cursor to the beginning of the document, before \"%1\" text" msgstr "Mueve el cursor al principio del documento, antes del texto \"%1\"" -#: TutorialMoveText.cpp:94 +#: TutorialMoveText.cpp:94 TutorialMoveText.py:143 msgctxt "@info" msgid "" "Finally, paste the text you have cut previously. To do this, click in " @@ -179,7 +182,7 @@ "pulsar sobre él, o la selección cambiará, y deberás seleccionarlo de nuevo. " "No sueltes el botón aún." -#: TutorialMoveText.cpp:113 +#: TutorialMoveText.cpp:113 TutorialMoveText.py:175 msgctxt "@info" msgid "" "Without releasing the mouse button, move the cursor to the desired position, " @@ -190,7 +193,7 @@ "ejemplo el principio del texto.<nl/>Una vez que el cursor esté ahí, puedes " "soltar el botón del ratón, y el texto será movido." -#: TutorialMoveText.cpp:122 +#: TutorialMoveText.cpp:122 TutorialMoveText.py:191 msgctxt "@info" msgid "" "As explained, there are two ways to move text in a text area: using the " @@ -199,19 +202,44 @@ "Como se dijo, existen dos formas de mover el texto en un área de texto: " "usando el ratón y usando el teclado. ¿Quieres ver la otra forma?" -#: TutorialMoveText.cpp:124 +#: TutorialMoveText.cpp:124 TutorialMoveText.py:193 msgid "Yes, please" msgstr "Sí, por favor" -#: TutorialMoveText.cpp:125 +#: TutorialMoveText.cpp:125 TutorialMoveText.py:203 msgid "No, thanks" msgstr "No, gracias" -#: TutorialMoveText.cpp:131 +#: TutorialMoveText.cpp:131 TutorialMoveText.py:212 msgctxt "@info" msgid "That's all.<nl/>Now you can close the tutorial." msgstr "Y eso es todo.<nl/>Ahora puedes cerrar el tutorial." +#: TutorialMoveText.py:160 +msgctxt "@info" +msgid "" +"<para><emphasis>Warning:</emphasis> due to <link url=\"https://bugs.kde.org/" +"show_bug.cgi?id=219787\">Kross bug 219787</link>, this step will crash " +"KTutorial test app. Hopefully, soon the patch given in the bug will be " +"applied and there will be no more crashes ;)</para><para>If you are " +"wondering why a tutorial that crashes was included in KTutorial test app, " +"the answer is because although it crashes, it also contains examples of " +"advanced tutorial scripting using Python.</para><para>Press with the left " +"button of the mouse on the selected text. You must press on it, or the " +"selection will change, and you will have to select it again. Don't release " +"the button yet.</para>" +msgstr "" +"<para><emphasis>Atención:</emphasis> debido al <link url=\"https://bugs.kde." +"org/show_bug.cgi?id=219787\">bug 219787 de Kross</link>, este paso hará que " +"la aplicación de prueba de KTutorial casque. Con suerte, pronto se aplicará " +"el parche indicado en el bug y dejará de cascar ;)</para><para>Si te " +"preguntas por qué se incluyó un tutorial que casca en la aplicación de " +"prueba de KTutorial, la respuesta es porque aunque casca, también contiene " +"ejemplos de tutoriales en script avanzados usando Python.</para><para>Pulsa " +"con el botón izquierdo del ratón en el texto seleccionado. Debes pulsar " +"sobre él, o la selección cambiará, y deberás seleccionarlo de nuevo. No " +"sueltes el botón aún.</para>" + #: rc.cpp:3 msgid "Main Toolbar" msgstr "Barra de herramientas principal" Modified: trunk/ktutorial/po/test-app/ktutorial-test-app.pot =================================================================== --- trunk/ktutorial/po/test-app/ktutorial-test-app.pot 2010-02-06 16:56:10 UTC (rev 73) +++ trunk/ktutorial/po/test-app/ktutorial-test-app.pot 2010-02-06 17:34:09 UTC (rev 74) @@ -7,9 +7,9 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: https://forja.rediris.es/tracker/?" -"atid=1080&group_id=280\n" -"POT-Creation-Date: 2010-01-04 17:13+0100\n" +"Report-Msgid-Bugs-To: http://sourceforge.net/tracker/?" +"group_id=301227&atid=1270278\n" +"POT-Creation-Date: 2010-02-06 17:57+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL...@li...>\n" @@ -64,7 +64,8 @@ #: TutorialClearText.cpp:37 TutorialClearText.cpp:67 TutorialClearText.js:26 #: TutorialClearText.js:35 TutorialClearText.py:29 TutorialClearText.py:38 -#: TutorialMoveText.cpp:57 TutorialMoveText.cpp:163 +#: TutorialMoveText.cpp:57 TutorialMoveText.cpp:163 TutorialMoveText.py:84 +#: TutorialMoveText.py:91 msgid "Hello world" msgstr "" @@ -88,44 +89,45 @@ msgid "And that's all.<nl/>Now you can close the tutorial." msgstr "" -#: TutorialMoveText.cpp:38 +#: TutorialMoveText.cpp:38 TutorialMoveText.py:24 msgid "Move text in the text area" msgstr "" -#: TutorialMoveText.cpp:39 +#: TutorialMoveText.cpp:39 TutorialMoveText.py:25 msgid "This tutorial shows how to move text in the text area" msgstr "" -#: TutorialMoveText.cpp:48 +#: TutorialMoveText.cpp:48 TutorialMoveText.py:66 msgctxt "@info" msgid "" "In this tutorial you will learn how to move text in the test application.<nl/" ">Text can be moved using the mouse or the keyboard. What do you prefer?" msgstr "" -#: TutorialMoveText.cpp:50 +#: TutorialMoveText.cpp:50 TutorialMoveText.py:68 msgid "Mouse" msgstr "" -#: TutorialMoveText.cpp:51 +#: TutorialMoveText.cpp:51 TutorialMoveText.py:74 msgid "Keyboard" msgstr "" -#: TutorialMoveText.cpp:57 +#: TutorialMoveText.cpp:57 TutorialMoveText.py:84 msgctxt "@info" msgid "First of all, clean the text area and write \"%1\" (without quotes)" msgstr "" -#: TutorialMoveText.cpp:66 TutorialMoveText.cpp:170 +#: TutorialMoveText.cpp:66 TutorialMoveText.cpp:170 TutorialMoveText.py:98 +#: TutorialMoveText.py:105 msgid "world" msgstr "" -#: TutorialMoveText.cpp:66 +#: TutorialMoveText.cpp:66 TutorialMoveText.py:98 msgctxt "@info" msgid "Now, select the text \"%1\" in the text area" msgstr "" -#: TutorialMoveText.cpp:75 +#: TutorialMoveText.cpp:75 TutorialMoveText.py:115 msgctxt "@info" msgid "" "The next thing to do is cut the selected text. Cutting it will remove it " @@ -134,16 +136,16 @@ "button of the toolbar" msgstr "" -#: TutorialMoveText.cpp:85 +#: TutorialMoveText.cpp:85 TutorialMoveText.py:129 msgid "Hello" msgstr "" -#: TutorialMoveText.cpp:85 +#: TutorialMoveText.cpp:85 TutorialMoveText.py:129 msgctxt "@info" msgid "Move the cursor to the beginning of the document, before \"%1\" text" msgstr "" -#: TutorialMoveText.cpp:94 +#: TutorialMoveText.cpp:94 TutorialMoveText.py:143 msgctxt "@info" msgid "" "Finally, paste the text you have cut previously. To do this, click in " @@ -158,7 +160,7 @@ "Don't release the button yet." msgstr "" -#: TutorialMoveText.cpp:113 +#: TutorialMoveText.cpp:113 TutorialMoveText.py:175 msgctxt "@info" msgid "" "Without releasing the mouse button, move the cursor to the desired position, " @@ -166,26 +168,41 @@ "release the mouse button, and the text will be moved." msgstr "" -#: TutorialMoveText.cpp:122 +#: TutorialMoveText.cpp:122 TutorialMoveText.py:191 msgctxt "@info" msgid "" "As explained, there are two ways to move text in a text area: using the " "mouse and using the keyboard. Do you want to see the other way?" msgstr "" -#: TutorialMoveText.cpp:124 +#: TutorialMoveText.cpp:124 TutorialMoveText.py:193 msgid "Yes, please" msgstr "" -#: TutorialMoveText.cpp:125 +#: TutorialMoveText.cpp:125 TutorialMoveText.py:203 msgid "No, thanks" msgstr "" -#: TutorialMoveText.cpp:131 +#: TutorialMoveText.cpp:131 TutorialMoveText.py:212 msgctxt "@info" msgid "That's all.<nl/>Now you can close the tutorial." msgstr "" +#: TutorialMoveText.py:160 +msgctxt "@info" +msgid "" +"<para><emphasis>Warning:</emphasis> due to <link url=\"https://bugs.kde.org/" +"show_bug.cgi?id=219787\">Kross bug 219787</link>, this step will crash " +"KTutorial test app. Hopefully, soon the patch given in the bug will be " +"applied and there will be no more crashes ;)</para><para>If you are " +"wondering why a tutorial that crashes was included in KTutorial test app, " +"the answer is because although it crashes, it also contains examples of " +"advanced tutorial scripting using Python.</para><para>Press with the left " +"button of the mouse on the selected text. You must press on it, or the " +"selection will change, and you will have to select it again. Don't release " +"the button yet.</para>" +msgstr "" + #: rc.cpp:3 msgid "Main Toolbar" msgstr "" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-02-06 16:56:21
|
Revision: 73 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=73&view=rev Author: danxuliu Date: 2010-02-06 16:56:10 +0000 (Sat, 06 Feb 2010) Log Message: ----------- Example of advanced tutorial scripting using Python. Modified Paths: -------------- trunk/ktutorial/test-app/CMakeLists.txt Added Paths: ----------- trunk/ktutorial/test-app/TutorialMoveText.py Modified: trunk/ktutorial/test-app/CMakeLists.txt =================================================================== --- trunk/ktutorial/test-app/CMakeLists.txt 2010-01-31 16:15:52 UTC (rev 72) +++ trunk/ktutorial/test-app/CMakeLists.txt 2010-02-06 16:56:10 UTC (rev 73) @@ -16,4 +16,4 @@ install(TARGETS ktutorial-test-app DESTINATION ${BIN_INSTALL_DIR}) install(FILES ktutorial-test-appui.rc DESTINATION ${DATA_INSTALL_DIR}/ktutorial-test-app) -install(FILES TutorialClearText.js TutorialClearText.py DESTINATION ${DATA_INSTALL_DIR}/ktutorial-test-app/tutorials) +install(FILES TutorialClearText.js TutorialClearText.py TutorialMoveText.py DESTINATION ${DATA_INSTALL_DIR}/ktutorial-test-app/tutorials) Added: trunk/ktutorial/test-app/TutorialMoveText.py =================================================================== --- trunk/ktutorial/test-app/TutorialMoveText.py (rev 0) +++ trunk/ktutorial/test-app/TutorialMoveText.py 2010-02-06 16:56:10 UTC (rev 73) @@ -0,0 +1,214 @@ +# -*- coding: utf-8 -*- + +########################################################################### +# Copyright (C) 2010 by Daniel Calviño Sánchez # +# dan...@gm... # +# # +# 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 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program; If not, see <http://www.gnu.org/licenses/>. # +########################################################################### + +import Kross +t = Kross.module("kdetranslation") + +tutorial.tutorialInformationAsObject().setName(t.i18n("Move text in the text area") + " (Python)") +tutorial.tutorialInformationAsObject().setDescription(t.i18n("This tutorial shows how to move text in the text area")) + +textArea = ktutorial.findObject("textArea") + +import sip +from PyQt4 import QtCore, Qt +textAreaPyQt = sip.wrapinstance(textArea.__toPointer__(), Qt.QTextEdit) + +import string +version = string.split(QtCore.PYQT_VERSION_STR, ".") +if map(int, version) < [4, 5]: + raise ImportWarning('PyQt version is lower than 4.5, can not load "Move text in the text area (Python)" tutorial') + +class MouseFilter(Qt.QObject): + mousePressed = QtCore.pyqtSignal() + mouseReleased = QtCore.pyqtSignal() + + def eventFilter(self, object, event): + if event.type() == QtCore.QEvent.MouseButtonPress: + if event.button() == QtCore.Qt.LeftButton: + self.mousePressed.emit() + elif event.type() == QtCore.QEvent.Drop: + self.mouseReleased.emit() + return False + +mouseFilter = MouseFilter() +textAreaPyQt.viewport().installEventFilter(mouseFilter) + +# Dictionaries are mutable, so they can be used in functions without declaring +# them as global. Boolean values, instead, need to be declared inside the +# function before being used (global variableName) +flags = { "secondPath":False, "mousePathSelected":False } + +def tutorialSetup(tutorial): + flags["secondPath"] = False + flags["mousePathSelected"] = False + +tutorial.connect("setup(QObject*)", tutorialSetup) + +#Step start +startStep = ktutorial.newStep("start") +startStep.setText(t.i18nc("@info", "In this tutorial you will learn how to move text in the test application.<nl/>Text can be moved using the mouse or the keyboard. What do you prefer?")) + +startStep.addOption(ktutorial.newOption(t.i18n("Mouse")), self, "startMouseMove()") + +def startMouseMove(): + flags["mousePathSelected"] = True + tutorial.nextStep("write") + +startStep.addOption(ktutorial.newOption(t.i18n("Keyboard")), self, "startKeyboardMove()") + +def startKeyboardMove(): + flags["mousePathSelected"] = False + tutorial.nextStep("write") + +tutorial.addStep(startStep) + +#Step write +writeStep = ktutorial.newStep("write") +writeStep.setText(t.i18nc("@info", "First of all, clean the text area and write \"%1\" (without quotes)", [t.i18n("Hello world")])) + +waitForTextChanged = ktutorial.newWaitFor("WaitForSignal") +waitForTextChanged.setSignal(textArea, "textChanged()") +writeStep.addWaitFor(waitForTextChanged, self, "write()") + +def write(): + if textArea.plainText.lower() == t.i18n("Hello world").lower(): + tutorial.nextStep("select") + +tutorial.addStep(writeStep) + +#Step select +selectStep = ktutorial.newStep("select") +selectStep.setText(t.i18nc("@info", "Now, select the text \"%1\" in the text area", [t.i18n("world")])) + +waitForSelectionChanged = ktutorial.newWaitFor("WaitForSignal") +waitForSelectionChanged.setSignal(textArea, "selectionChanged()") +selectStep.addWaitFor(waitForSelectionChanged, self, "select()") + +def select(): + if textAreaPyQt.textCursor().selectedText().toLower() == t.i18n("world").lower(): + if flags["mousePathSelected"]: + tutorial.nextStep("mousePress") + else: + tutorial.nextStep("keyboardCut") + +tutorial.addStep(selectStep) + +#Step keyboardCut +keyboardCutStep = ktutorial.newStep("keyboardCut") +keyboardCutStep.setText(t.i18nc("@info", "The next thing to do is cut the selected text. Cutting it will remove it from the text area, but in some Steps we will make it appear again. To cut the selected text, click in <interface>Edit->Cut</interface> or in the button of the toolbar")) + +cutAction = ktutorial.findObject("edit_cut") +waitForCutTriggered = ktutorial.newWaitFor("WaitForSignal") +waitForCutTriggered.setSignal(cutAction, "triggered(bool)") +keyboardCutStep.addWaitFor(waitForCutTriggered, self, "keyboardCut()") + +def keyboardCut(): + tutorial.nextStep("keyboardMoveCursor") + +tutorial.addStep(keyboardCutStep) + +#Step keyboardMoveCursor +keyboardMoveCursorStep = ktutorial.newStep("keyboardMoveCursor") +keyboardMoveCursorStep.setText(t.i18nc("@info", "Move the cursor to the beginning of the document, before \"%1\" text", [t.i18n("Hello")])) + +waitForCursorPositionChanged = ktutorial.newWaitFor("WaitForSignal") +waitForCursorPositionChanged.setSignal(textArea, "cursorPositionChanged()") +keyboardMoveCursorStep.addWaitFor(waitForCursorPositionChanged, self, "keyboardMoveCursor()") + +def keyboardMoveCursor(): + if textAreaPyQt.textCursor().position() == 0: + tutorial.nextStep("keyboardPaste") + +tutorial.addStep(keyboardMoveCursorStep) + +#Step keyboardPaste +keyboardPasteStep = ktutorial.newStep("keyboardPaste") +keyboardPasteStep.setText(t.i18nc("@info", "Finally, paste the text you have cut previously. To do this, click in <interface>Edit->Paste</interface> or in the button in the toolbar")) + +pasteAction = ktutorial.findObject("edit_paste") +waitForPasteTriggered = ktutorial.newWaitFor("WaitForSignal") +waitForPasteTriggered.setSignal(pasteAction, "triggered(bool)") +keyboardPasteStep.addWaitFor(waitForPasteTriggered, self, "keyboardPaste()") + +def keyboardPaste(): + if flags["secondPath"]: + tutorial.nextStep("end") + else: + tutorial.nextStep("showOtherWay") + +tutorial.addStep(keyboardPasteStep) + +#Step mousePress +mousePressStep = ktutorial.newStep("mousePress") +mousePressStep.setText(t.i18nc("@info", "<para><emphasis>Warning:</emphasis> due to <link url=\"https://bugs.kde.org/show_bug.cgi?id=219787\">Kross bug 219787</link>, this step will crash KTutorial test app. Hopefully, soon the patch given in the bug will be applied and there will be no more crashes ;)</para>\ +<para>If you are wondering why a tutorial that crashes was included in KTutorial test app, the answer is because although it crashes, it also contains examples of advanced tutorial scripting using Python.</para>\ +<para>Press with the left button of the mouse on the selected text. You must press on it, or the selection will change, and you will have to select it again. Don't release the button yet.</para>")) + +waitForMousePressed = ktutorial.newWaitFor("WaitForSignal") +waitForMousePressed.setSignal(mouseFilter, "mousePressed()") +mousePressStep.addWaitFor(waitForMousePressed, self, "mousePress()") + +def mousePress(): + tutorial.nextStep("mouseRelease") + +tutorial.addStep(mousePressStep) + +#Step mouseRelease +mouseReleaseStep = ktutorial.newStep("mouseRelease") +mouseReleaseStep.setText(t.i18nc("@info", "Without releasing the mouse button, move the cursor to the desired position, for example the beginning of the text.<nl/>Once the cursor is there, you can release the mouse button, and the text will be moved.")) + +waitForMouseReleased = ktutorial.newWaitFor("WaitForSignal") +waitForMouseReleased.setSignal(mouseFilter, "mouseReleased()") +mouseReleaseStep.addWaitFor(waitForMouseReleased, self, "mouseRelease()") + +def mouseRelease(): + if flags["secondPath"]: + tutorial.nextStep("end") + else: + tutorial.nextStep("showOtherWay") + +tutorial.addStep(mouseReleaseStep) + +#Step showOtherWay +showOtherWayStep = ktutorial.newStep("showOtherWay") +showOtherWayStep.setText(t.i18nc("@info", "As explained, there are two ways to move text in a text area: using the mouse and using the keyboard. Do you want to see the other way?")) + +showOtherWayStep.addOption(ktutorial.newOption(t.i18n("Yes, please")), self, "showOtherWay()") + +def showOtherWay(): + flags["secondPath"] = True + + textArea.clear() + + flags["mousePathSelected"] = not flags["mousePathSelected"] + tutorial.nextStep("write") + +showOtherWayStep.addOption(ktutorial.newOption(t.i18n("No, thanks")), self, "end()") + +def end(): + tutorial.nextStep("end") + +tutorial.addStep(showOtherWayStep) + +#Step end +endStep = ktutorial.newStep("end") +endStep.setText(t.i18nc("@info", "That's all.<nl/>Now you can close the tutorial.")) + +tutorial.addStep(endStep) Property changes on: trunk/ktutorial/test-app/TutorialMoveText.py ___________________________________________________________________ Added: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dan...@us...> - 2010-01-31 16:15:59
|
Revision: 72 http://ktutorial.svn.sourceforge.net/ktutorial/?rev=72&view=rev Author: danxuliu Date: 2010-01-31 16:15:52 +0000 (Sun, 31 Jan 2010) Log Message: ----------- Add web sources to SVN (except apidocs and doc). Added Paths: ----------- trunk/web-src/ trunk/web-src/cybertron.sh trunk/web-src/data/ trunk/web-src/data/files/ trunk/web-src/data/files/cortado.jar trunk/web-src/data/files/ktutorial-l10n.ogg trunk/web-src/data/files/ktutorial-l10n.png trunk/web-src/data/files/ktutorial-limpiar.ogg trunk/web-src/data/files/ktutorial-limpiar.png trunk/web-src/data/files/ktutorial-mover.ogg trunk/web-src/data/files/ktutorial-mover.png trunk/web-src/data/images/ trunk/web-src/data/images/icon-atom.png trunk/web-src/data/images/icon-atom.svg trunk/web-src/data/images/icon-rss.png trunk/web-src/data/images/play.png trunk/web-src/data/images/screenshots/ trunk/web-src/data/images/valid-a.png trunk/web-src/data/images/valid-aa.png trunk/web-src/data/images/valid-aaa.png trunk/web-src/data/images/valid-atom.png trunk/web-src/data/images/valid-css.png trunk/web-src/data/images/valid-rss.png trunk/web-src/data/images/valid-xhtml11.png trunk/web-src/data/script/ trunk/web-src/data/script/foldableList.js trunk/web-src/data/script/galleryGenerator.js trunk/web-src/data/script/ogg.js trunk/web-src/data/script/roundedCorners.js trunk/web-src/data/script/videoEmbedder.js trunk/web-src/data/style/ trunk/web-src/data/style/style.css trunk/web-src/news-toAtom.xsl trunk/web-src/news-toHTML.xsl trunk/web-src/newsList.xml trunk/web-src/newsList.xsd trunk/web-src/pages/ trunk/web-src/pages/about.xml trunk/web-src/pages/aboutWeb.xml trunk/web-src/pages/development.xml trunk/web-src/pages/documentation.xml trunk/web-src/pages/download.xml trunk/web-src/pages/faq.xml trunk/web-src/pages/index.xml trunk/web-src/pages/news.xml trunk/web-src/pages/page.xsd trunk/web-src/pages/screenshots.xml trunk/web-src/pages/screenshotsGallery.xml trunk/web-src/screenshotsList.dtd trunk/web-src/screenshotsList.xml trunk/web-src/transformers/ trunk/web-src/transformers/footer.xsl trunk/web-src/transformers/head.xsl trunk/web-src/transformers/header.xsl trunk/web-src/transformers/menu.xml trunk/web-src/transformers/menu.xsl trunk/web-src/transformers/optimusPrime.xsl trunk/web-src/updateNewsInPage.xsl trunk/web-src/updateScreenshotsInPage.xsl Added: trunk/web-src/cybertron.sh =================================================================== --- trunk/web-src/cybertron.sh (rev 0) +++ trunk/web-src/cybertron.sh 2010-01-31 16:15:52 UTC (rev 72) @@ -0,0 +1,236 @@ +#!/bin/bash +# +# This script creates the website from the XML documents and data dirs. +# It can be invoked with -e, -o and -u options. +# -e is the output XHTML files encoding to be used. Default is utf-8. +# -o is the output directory to be used. Default is "../build/" +# -u is the base URL where the website will be. +# +# It needs xsltproc, xmllint (with support for XML Schema) and, if other +# encoding than utf-8 is used, recode. +# +# Cybertron name was used as an easter egg for Transformers animation series, +# as Cybertron was the planet where all the Transformers lived... This script +# prepares everything needed by the XSL "Transformers" and creates and +# environment to be executed... so that's why it's called cybertron :) +# +# TODO +# -create XHTML files only when they were changed since the last execution. +# -change this script into a Makefile? + + +# Validates all the XML files under pages directory using XML Schema. +# The XML Schema is located at pages/page.xsd +function validateXmlPages() { + returnValue=0; + + for i in `find pages -iname "*.xml"` + do + xmllint --noout --schema pages/page.xsd $i; + let "returnValue = $returnValue || $?"; + done + + return $returnValue; +} + +# Validates the XML newsList.xml file using XML Schema. +# The XML Schema is located at newsList.xsd +function validateNews() { + xmllint --noout --schema newsList.xsd newsList.xml; + return $?; +} + +# Validates the XML screenshotsList.xml file using DTD. +# The DTD is located at screenshotsList.dtd +function validateScreenshotsList() { + xmllint --noout --valid screenshotsList.xml \ + && echo "screenshotsList.xml validates"; + return $?; +} + +# Validates all the XML files which have a DTD oir XML Schema. +# Those files are pages files, news file and screenshotsList file. +function validate() { + validation=0; + + validateXmlPages; + let "validation = $validation || $?"; + + validateNews; + let "validation = $validation || $?"; + + validateScreenshotsList; + let "validation = $validation || $?"; + + return $validation; +} + +# Prepares the XML pages that need to be updated before transforming them to +# XHTML. +# The pages that needs update are index.xml, news.xml and screenshotsGallery.xml +# The first two have their news list updated, and the last its screenshots list. +function preparePages() { + xsltproc -o $newsHtmlTmpFile news-toHTML.xsl newsList.xml; + + # Prepares index.xml + xsltproc --stringparam newsHtmlFile $newsHtmlTmpFile -o pages/index.xml \ + updateNewsInPage.xsl pages/index.xml + xmllint --format -o pages/index.xml pages/index.xml; + + # Prepares news.xml + xsltproc --stringparam newsHtmlFile $newsHtmlTmpFile \ + --stringparam numberOfNews -1 -o pages/news.xml \ + updateNewsInPage.xsl pages/news.xml + xmllint --format -o pages/news.xml pages/news.xml; + + # Prepares screenshotsGallery.xml + xsltproc --stringparam screenshotsHtmlFile screenshotsList.xml \ + -o pages/screenshotsGallery.xml updateScreenshotsInPage.xsl \ + pages/screenshotsGallery.xml + xmllint --format -o pages/screenshotsGallery.xml \ + pages/screenshotsGallery.xml; +} + +# Transforms all the XML documents under pages directory. +# It creates all the XHTML pages using optimusPrime XSLT. +# The pages are copied to the output dir (using subdirectories if they +# existed under pages directory) and also reformatted (because xsltproc +# sometimes doesn't create well formatted documents). +# Before creating the XHTML pages, the output directory is created (if it +# existed already, it is removed first). If it isn't valid, it returns 1. +function createPages() { + if [ -e $outputDir ]; then + rm -fr $outputDir; + fi + + mkdir -p $outputDir; + if [ $? -ne 0 ]; then + return 1; + fi + + cd pages; + + for i in `find . -iname "*.xml"` + do + # Gets the extension of the file + fileExtension=`expr match "$i" '.*\(\.[^\.]*\)'`; + # Removes the extension of the file from the file name + fileName=${i%"$fileExtension"} + # Removes leading "./" from the file name + fileName=${fileName:2}; + + xsltproc -o ../$outputDir/$fileName.html ../transformers/optimusPrime.xsl $fileName.xml; + + xmllint --format -o ../$outputDir/$fileName.html ../$outputDir/$fileName.html; + + if [ $encoding != "utf-8" ]; then + recode utf-8..$encoding ../$outputDir/$fileName.html; + sed -e "s/utf-8/$encoding/g" ../$outputDir/$fileName.html > ../$outputDir/$fileName.html.tmp; + mv ../$outputDir/$fileName.html.tmp ../$outputDir/$fileName.html + fi + done + + cd ..; + + return 0; +} + +# Creates the news feed from newsList.xml +# The feed is copied to "feed/atom/news.xml" under output dir. +function createFeeds() { + xsltproc --stringparam baseURL $baseURL -o $outputDir/feed/atom/news.xml news-toAtom.xsl newsList.xml; +} + +# Copies the data dirs to the output dir. +function copyDataDirs() { + cp -r data/* $outputDir; +} + +# Copies the source dir to the output dir. +function copySrcDir() { + cp -r . $outputDir/src; + rm -fr $outputDir/src/data/apidocs; + rm -fr $outputDir/src/data/doc; + rm -fr $outputDir/src/data/files; +} + +# Removes all the .svn folders in the output directory. +function removeSvnFolders() { + find $outputDir -name ".svn" -print0 | xargs -0 rm -rf; +} + +# Packs the source dir and copies it to the files subdirectory of output dir. +function packSrcDir() { + # Tar removes leading "../" from filenames. It must be disabled with + # --absolute-names to ensure the name is transformed as expected. + tar --absolute-names --transform="s,$outputDir/src,src," -czf $outputDir/files/webSrc.tar.gz $outputDir/src; +} + + +encoding="utf-8"; +outputDir=../build/; +baseURL="http://csl2-ktutorial.forja.rediris.es/"; + +while getopts e:o:u: o +do + case "$o" in + e) encoding="$OPTARG";; + o) outputDir="$OPTARG";; + u) baseURL="$OPTARG";; + [?]) echo "Usage: $0 [-e encoding] [-o outputDir] [-u baseURL]"; + echo " Default encoding: utf-8"; + echo " Default output directory: ../build/"; + echo " Default baseURL: http://csl2-ktutorial.forja.rediris.es/"; + exit 1;; + esac +done +shift $(($OPTIND -1)) + +# Ensures baseURL ends with a "/" +if [ ${baseURL:`expr ${#baseURL} - 1`} != "/" ]; then + baseURL=$baseURL"/"; +fi + +export XMLLINT_INDENT=" "; + +newsHtmlTmpFile=news-html.xml; + + +echo "Validating XML files..." +validate; +if [ $? -ne 0 ]; then + echo "Validation failed. Aborting..."; + exit; +fi + +echo "Preparing pages..."; +preparePages; + +echo "Creating XHTML pages..."; +createPages; +if [ $? -ne 0 ]; then + echo "Output directory $outputDir isn't valid. Aborting..." + exit; +fi + +echo "Creating feeds..."; +createFeeds; + +echo "Copying data dirs..."; +copyDataDirs; + +if [ $outputDir != .. ]; then + echo "Copying source dir..."; + copySrcDir; +fi; + +echo "Removing SVN folders..."; +removeSvnFolders; + +echo "Packing source dir..."; +packSrcDir; + +echo "Cleaning up..."; +rm -f $newsHtmlTmpFile; + +echo "Done!"; Property changes on: trunk/web-src/cybertron.sh ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native Added: trunk/web-src/data/files/cortado.jar =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/cortado.jar ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/web-src/data/files/ktutorial-l10n.ogg =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-l10n.ogg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/web-src/data/files/ktutorial-l10n.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-l10n.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/files/ktutorial-limpiar.ogg =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-limpiar.ogg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/web-src/data/files/ktutorial-limpiar.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-limpiar.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/files/ktutorial-mover.ogg =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-mover.ogg ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/web-src/data/files/ktutorial-mover.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/files/ktutorial-mover.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/icon-atom.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/icon-atom.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/icon-atom.svg =================================================================== --- trunk/web-src/data/images/icon-atom.svg (rev 0) +++ trunk/web-src/data/images/icon-atom.svg 2010-01-31 16:15:52 UTC (rev 72) @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="128px" height="128px" id="RSSicon" viewBox="0 0 256 256"> +<defs> +<linearGradient x1="0.085" y1="0.085" x2="0.915" y2="0.915" id="RSSg"> +<stop offset="0.0" stop-color="#E3702D"/><stop offset="0.1071" stop-color="#EA7D31"/> +<stop offset="0.3503" stop-color="#F69537"/><stop offset="0.5" stop-color="#FB9E3A"/> +<stop offset="0.7016" stop-color="#EA7C31"/><stop offset="0.8866" stop-color="#DE642B"/> +<stop offset="1.0" stop-color="#D95B29"/> +</linearGradient> +</defs> +<rect width="256" height="256" rx="55" ry="55" x="0" y="0" fill="#CC5D15"/> +<rect width="246" height="246" rx="50" ry="50" x="5" y="5" fill="#F49C52"/> +<rect width="236" height="236" rx="47" ry="47" x="10" y="10" fill="url(#RSSg)"/> +<circle cx="68" cy="189" r="24" fill="#FFF"/> +<path d="M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z" fill="#FFF"/> +<path d="M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z" fill="#FFF"/> +</svg> Added: trunk/web-src/data/images/icon-rss.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/icon-rss.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/play.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/play.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-a.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-a.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-aa.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-aa.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-aaa.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-aaa.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-atom.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-atom.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-css.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-css.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-rss.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-rss.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/images/valid-xhtml11.png =================================================================== (Binary files differ) Property changes on: trunk/web-src/data/images/valid-xhtml11.png ___________________________________________________________________ Added: svn:mime-type + image/png Added: trunk/web-src/data/script/foldableList.js =================================================================== --- trunk/web-src/data/script/foldableList.js (rev 0) +++ trunk/web-src/data/script/foldableList.js 2010-01-31 16:15:52 UTC (rev 72) @@ -0,0 +1,404 @@ +/*************************************************************************** + * Copyright (C) 2006 by Daniel Calviño Sánchez * + * ka...@us... * + * * + * This library 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. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this library; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/****************************************************************************** + * * + * DESCRIPTION OF THIS SCRIPT * + * * + *****************************************************************************/ + +/* + +DESCRIPTION +----------- +Adds special links to compound lists so sublists can be folded and unfolded. + +Each sublist (a list in a list item) of the list with class "foldableList" are +made foldable. Every sublist is unfolded at the beginning. + +When the "fold" link (represented by a "-") in an unfolded list is clicked, all +the sublists are removed from the item list and the "fold" link changes to +"unfold". +When the "unfold" link (represented by a "+") in a folded list is clicked, all +the sublists are added again to the item list and the "unfold" link changes to +"fold". + +No style is applied to the generated elements. The only new elements added are +the fold/unfold links, which belong to "foldLink" class, so they can be styled +with CSS. + +Elements are added and removed instead of only shown or hidden using CSS, so it +works even when no stylesheets are used. + + +HOW DOES IT WORK? +----------------- +All the root lists with "foldableList" class are selected and made foldable. +Root list referes to class with "foldableList" class which aren't child (direct +or deep) of another list with "foldableList" class. + +When a list is made foldable, all its list item are checked to know if they can +be made foldable. A list item can be made foldable if it contains at least one +list (ordered or unordered). All the list items that can be made foldable are +made foldable recursively. In each foldable list item a link is inserted before +the first child. This link will fold or unfold the list, depending on the state. + +When a list item is folded, the list item is copied to an array of folded lists. +It's cloned, and all the child lists are removed from the clone. The original +list item is then substituted in the document by its clone. The link to fold in +the clone is also changed to unfold to reflect the new state. + +When a list item is unfolded, the previously saved original list item is put +again in the document replacing the folded clone. + + +LIST THAT CAN BE MADE FOLDABLE EXAMPLE +-------------------------------------- +The XML below shows an example of a list that can be made foldable. It's simply +a two levels list. + +<ul class="foldableList"> + <li>Item 1 + <ul> + <li>Item 1.1</li> + <li>Item 1.2</li> + </ul> + </li> + <li>Item 2</li> + <li>Item 3 + <ul> + <li>Item 3.1</li> + <li>Item 3.2 + <ul> + <li>Item 3.2.1</li> + </ul> + </li> + </ul> + </li> +</ul> + +The shown foldable list will be: +* -Item 1 + * Item 1.1 + * Item 1.2 +* Item 2 +* -Item 3 + * Item 3.1 + * -Item 3.2 + * Item 3.2.1 + + +TESTED WITH: +------------ +-Mozilla Firefox 1.0.2 (should work with all the Gecko based browsers) +-Konqueror 3.4 (should work with all the KHTML based browsers) + + +*/ + +/****************************************************************************** + * * + * PROTOYPES * + * * + *****************************************************************************/ + +/** + * Adds an item to the array in the first empty position and returns the + * position. + * If no empty position was found the item is appended. + * + * @param item The item to be added. + * @return The position where the item was added. + */ +Array.prototype.add = function(item) { + var i; + for (i=0; i<this.length; i++) { + if (this[i] == null) { + this[i] = item; + return i; + } + } + + this.push(item); + + return i; +} + + +/****************************************************************************** + * * + * FOLDABLE LISTS FUNCTIONS * + * * + *****************************************************************************/ + +/** + * A list containing all the folded lists. + */ +var foldedLists; + +/** + * Makes all the lists (ordered or unordered) with class "foldableList" + * foldables. + * A foldable list has a special link in each sublist so they can be hidden or + * shown. Every sublist of a foldable list is foldable, no matter how deep it + * is. Child lists can also have class "foldableList", but it's superfluous. + */ +function makeListsFoldable() { + if (!scriptCanBeHandled()) { + return; + } + + foldedLists = []; + + var selectedLists = getListsToMakeFoldable(); + + var i; + for (i=0; i<selectedLists.length; i++) { + makeListFoldable(selectedLists[i]); + } +} + +/** + * Checks if the browser implementes all the needed ECMAScript bindings for the + * script. + * This script uses DOM Level 2 Core and DOM Level 2 Events module. + * + * @return True if the browser conforms to the needed modules, false otherwise. + */ +function scriptCanBeHandled() { + if (!(document.implementation.hasFeature("Core", "2.0") && + document.implementation.hasFeature("Events", "2.0"))) { + return false; + } + + return true; +} + +/** + * Makes the specified list foldable. + * All the child nodes are checked and, if they can be foldable, are made + * foldable recursively. + * + * @param list The list to be made foldable. + */ +function makeListFoldable(list) { + var childNodes = list.childNodes; + + var i; + for (i=0; i<childNodes.length; i++) { + if (childNodes[i].nodeType == Node.ELEMENT_NODE && + childNodes[i].tagName.toLowerCase() == "li") { + + makeListElementFoldable(childNodes[i]); + } + } +} + +/** + * Checks if a list item should be made foldable and, if it should, makes it. + * A list item should be made foldable if it contains any list (ordered or + * unordered). When made foldable, a link is added in the list item before any + * other child. This link will fold or unfold the list depending on the state. + * An event listener is added to the link so it can handle click events. + * + * @param listItem The list item to be made foldable. + */ +function makeListElementFoldable(listItem) { + var childNodes = listItem.childNodes; + + var makeFoldable = false; + + var i; + for (i=0; i<childNodes.length; i++) { + if (childNodes[i].nodeType == Node.ELEMENT_NODE && + (childNodes[i].tagName.toLowerCase() == "ul" || + childNodes[i].tagName.toLowerCase() == "ol")) { + makeFoldable = true; + + makeListFoldable(childNodes[i]); + } + } + + if (makeFoldable) { + var foldLink = document.createElement("a"); + foldLink.setAttribute("class", "foldLink"); + foldLink.setAttribute("href", "#fold"); + foldLink.setAttribute("title", "Fold this menu"); + foldLink.appendChild(document.createTextNode("-")); + + foldLink.addEventListener("click", foldMenuHandler, false); + + listItem.insertBefore(foldLink, listItem.firstChild); + } +} + +/** + * Hanlder for click event in the fold link in an unfolded list. + * The list item is saved, and replaced by a copy of that list item with child + * list elements removed. The list item is saved in the first free position in + * the foldedLists array. This position is added to the href so it can be later + * (when unfolding) retrieved. + * The unfold link in the cloned (and folded) list is edited so it reflects its + * new function (unfold instead of fold). + */ +function foldMenuHandler(event) { + var listItem = event.currentTarget.parentNode; + + var position = foldedLists.add(listItem); + + var listItemClone = listItem.cloneNode(true); + var childNodes = listItemClone.childNodes; + + var i; + for (i=0; i<childNodes.length; i++) { + if (childNodes[i].nodeType == Node.ELEMENT_NODE && + (childNodes[i].tagName.toLowerCase() == "ul" || + childNodes[i].tagName.toLowerCase() == "ol")) { + listItemClone.removeChild(childNodes[i]); + } + } + + listItem.parentNode.replaceChild(listItemClone, listItem); + var foldLink = listItemClone.firstChild; + + foldLink.setAttribute("href", "#unfold" + position); + foldLink.setAttribute("title", "Unfold this menu"); + + foldLink.replaceChild(document.createTextNode("+"), foldLink.firstChild); + + foldLink.removeEventListener("click", foldMenuHandler, false); + foldLink.addEventListener("click", unfoldMenuHandler, false); +} + +/** + * Hanlder for click event in the unfold link in a folded list. + * The unfolded list item is get from the saved list items using the id in the + * href element of the link. The current list item is replaced by the saved (and + * unfolded) list item. + */ +function unfoldMenuHandler(event) { + var foldLink = event.currentTarget; + var listItem = foldLink.parentNode; + + //"#unfold" length is 7 + var position = foldLink.getAttribute("href").substring(7); + + listItem.parentNode.replaceChild(foldedLists[position], listItem); + foldedLists[position] = null; +} + + + +/****************************************************************************** + * * + * GET ELEMENTS * + * * + *****************************************************************************/ + +/** + * Returns an array with all the list to make foldable. + * All the root list elements of "foldableList" class are selected. Lists can be + * unordered or ordered. + * If two lists, A and B, have "foldableList" class, and B is child (direct or + * deep) of A, only A is returned. + * + * Any element other element of "foldableList" class is ignored. + * + * @return All the lists to make foldable. + */ +function getListsToMakeFoldable() { + var selectedElementsByClass = getRootElementsByClass( + document.documentElement, + "foldableList"); + var selectedElements = []; + + var i; + for (i=0; i<selectedElementsByClass.length; i++) { + if (selectedElementsByClass[i].tagName.toLowerCase() == "ul" || + selectedElementsByClass[i].tagName.toLowerCase() == "ol") { + selectedElements.push(selectedElementsByClass[i]); + } + } + + return selectedElements; +} + +/** + * Returns all the root child elements of "element" with the specified class + * name (or the element itself if it's from the specified class). + * All the root children are returned, not only direct root children. + * + * The term root child refers to an element which is from the specified class + * and hasn't an ancestor also from that class. That is, if two elements, A and + * B, have the specified class, and B is child (direct or deep) of A, only A is + * returned. + * + * @param element The element to get the elements from. + * @param className The class name of the elements to get. + * @return An array with all the root elements of the specified class. + */ +function getRootElementsByClass(element, className) { + var selectedElements = []; + + var added = false; + var elementClasses = element.className.split(" "); + var i; + for (i=0; !added && i<elementClasses.length; i++) { + if (elementClasses[i] == className) { + selectedElements.push(element); + added = true; + } + } + + if (added) { + return selectedElements; + } + + var directChildElements = []; + getDirectChildElements(element, directChildElements); + + for (i=0; i<directChildElements.length; i++) { + selectedElements = selectedElements.concat(getRootElementsByClass( + directChildElements[i], + className)); + } + + return selectedElements; +} + +/** + * Appends all the child elements of "element" in the array "elementsList". + * Children are added only if they're true elements, not if they're only nodes. + * + * Only direct children are appended. + * + * @param element The element to add its children. + * @param elementsList The list to append the elements to. + */ +function getDirectChildElements(element, elementsList) { + var childNodes = element.childNodes; + + var i; + for (i=0; i<childNodes.length; i++) { + if (childNodes[i].nodeType == Node.ELEMENT_NODE) { + elementsList.push(childNodes[i]); + } + } +} Added: trunk/web-src/data/script/galleryGenerator.js =================================================================== --- trunk/web-src/data/script/galleryGenerator.js (rev 0) +++ trunk/web-src/data/script/galleryGenerator.js 2010-01-31 16:15:52 UTC (rev 72) @@ -0,0 +1,656 @@ +/*************************************************************************** + * Copyright (C) 2006 by Daniel Calviño Sánchez * + * ka...@us... * + * * + * This library 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. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this library; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/****************************************************************************** + * * + * DESCRIPTION OF THIS SCRIPT * + * * + *****************************************************************************/ + +/* + +DESCRIPTION +----------- +Generates a screenshot gallery from a list of screenshots with a specific +structure. + +When an item of the list is clicked, it shows an individual screenshot with the +screenshot title, a screenshots counter and a navigation bar to go to the +previous and next screenshots, if any. The individual screenshots, when clicked +on them, show the full size screenshots. Individual screenshots also resize +themselves to fit in the window each time it is resized. + +No style is applied to the generated elements. However, they have specific ids, +so they can be styled with CSS. See the section "Generated screenshot structure" +for further information on the generated elements and theirs ids. + + +HOW DOES IT WORK? +----------------- +The screenshots list is read and stored in a variable. It's modified so each +thumbnail now is linked to the generated enlarged screenshot instead of the +full size screenshot. +Both enlarged screenshots and the screenshots list are child of the same +element: when the list is shown, the individual screenshot is removed; when an +individual screenshot is shown, the list (or another screenshot) is removed. + +The needed information for each individual screenshot is got from the +screenshots list. Screenshots are identified by the number they have in the +screenshots list. Each screenshot can be shown individually appending "#number" +to the url of the page. If there's no "#number", the whole list is shown. + +Resize event of the window is handled so, if there's any individual screenshot +being shown, it'll be resized every time the window is resized, so it can fit +in the available space. + +Default handlers for click events aren't prevented to be executed, so the +location of the page is updated to the specified new link. + + +SCREENSHOTS LIST STRUCTURE +-------------------------- +The XML below shows the structure the screenshots list must conform with to be +used with this script. Only one list item is shown, the others should follow the +same structure. + +<ul id="screenshotsList"> + <li> + <p>Screenshot title</p> + <a href="path/screenshotName.extension" title="Click for full size"> + <img src="path/screenshotName-widthOfThumbnail.extension" + alt="(Screenshot title) screenshot thumbnail"/> + </a> + </li> + ... +</ul> + + +GENERATED SCREENSHOT STRUCTURE +------------------------------ +The code below is an example of the XML elements created for every screenshot +shown. The things that change depending on each screenshot are the title of +the screenshot, the counter of screenshots, the pathname to the screenshot and +the links to the next and previous screenshots. + +<div id="screenshot"> + <p id="screenshotTitle">The title of the screenshot</p> + <p>2/3</p> + <p id="screenshotImageWrapper"> + <a id="screenshotImageLink" href="images/aScreenshot.jpg" + title="Click for full size"> + <img width="(a number that depends on window size)" id="screenshotImage" + src="images/aScreenshot.jpg" + alt="Current screenshot: images/aScreenshot.jpg"/> + </a> + </p> + <div id="navigationBar"> + <p id="nextWrapper"> + <a href="path/page.html#0" title="Next screenshot">< Previous</a> + </p> + <p id="upWrapper"> + <a href="path/page.html" title="Screenshots list">Up</a> + </p> + <p id="nextWrapper"> + <a href="path/page.html#2" title="Next screenshot">Next ></a> + </p> + </div> +</div> + + +LIMITATIONS: +------------ +If a screenshot or the screenshot list are currently loaded, changing the url +in the address bar from page.html#number to page.html#otherNumber (for example) +won't do anything. Once the url is changed, the page must be refreshed. + + +TESTED WITH: +------------ +-Mozilla Firefox 1.0.2 (should work with all the Gecko based browsers) +-Konqueror 3.4 (should work with all the KHTML based browsers) + + +*/ + + +/****************************************************************************** + * * + * GALLERY GENERATOR fUNCTIONS * + * * + *****************************************************************************/ + +/** + * The URL of the page with the list of screenshots. + */ +var screenshotsURL; + +/** + * The element to append screenshots and the screenshots list to. + */ +var screenshotsParent; + +/** + * The next sibling to the screenshots and the screenshots list. + */ +var screenshotsNextSibling; + +/** + * The list containing all the screenshots. + */ +var screenshotsList; + +/** + * The current screenshots being shown, if any. + */ +var currentScreenshot; + +/** + * The number of the current screenshots being shown, if any. + */ +var currentScreenshotNumber; + +/** + * The item in the screenshots list of the current screenshot being shown, if + * any. + */ +var currentScreenshotListItem; + +/** + * Generates the screenshots gallery, and shows it or a concrete screenshot + * depending on the URL. + * It modifies the default list to make links point to the enlarged screenshot + * instead of the full size screenshot. + * If the URL has the form "path/page.html#number", it shows the screenshot with + * that number (or first or last screenshot, if the number is out of range). + * Otherwise, it shows the screenshots list. + */ +function generateGallery() { + if (!scriptCanBeHandled()) { + return; + } + + screenshotsList = document.getElementById("screenshotsList"); + + if (document.URL.indexOf('#') < 0) { + screenshotsURL = document.URL; + } else { + screenshotsURL = document.URL.substring(0, document.URL.indexOf('#')); + } + + //Prepares the screenshots list + var linksList = screenshotsList.getElementsByTagName("a"); + var i; + for (i=0; i<linksList.length; i++) { + linksList[i].setAttribute("href", screenshotsURL + "#" + i); + linksList[i].setAttribute("title", "Click to enlarge"); + linksList[i].addEventListener("click", showScreenshotHandler, false); + } + + //No screenshot is currently being shown + currentScreenshot = null; + currentScreenshotNumber = -1; + currentScreenshotListItem = null; + + if (screenshotsList.getElementsByTagName("li")[0]) { + screenshotsNextSibling = screenshotsList.nextSibling; + screenshotsParent = screenshotsList.parentNode; + + var screenshotNumber = getScreenshotNumberFromURL(document.URL); + + if (screenshotNumber != -1) { + setNewScreenshot(screenshotNumber); + } else { + showScreenshotsList(); + } + + onresize = updateScreenshotSize; + } +} + +/** + * Checks if the browser implementes all the needed ECMAScript bindings for the + * script. + * This script uses DOM Level 2 Core, DOM Level 2 HTML module and DOM Level 2 + * Events module and DOM Level 2 CSS2 module. + * + * However, CSS2 module isn't truly checked. Instead, the needed objects + * availability is checked, as browsers like Konqueror which can handle all the + * needed objects doesn't fully support the binding. + * + * @return True if the browser conforms to the needed modules, false otherwise. + */ +function scriptCanBeHandled() { + if (!(document.implementation.hasFeature("Core", "2.0") && + document.implementation.hasFeature("Events", "2.0") && + document.implementation.hasFeature("HTML", "2.0") && + checkCSS2())) { + return false; + } + + return true; +} + +/** + * Checks if the browser can handle all the needed DOM Level 2 CSS2 module + * objects. + * hasFeature() isn't used because some browsers as Konqueror can handle all the + * needed objects but doesn't fully support the module. + * + * @return True if the browser can handle all the needed objects, false + * otherwise. + */ +function checkCSS2() { + if (!(document.defaultView && document.defaultView.getComputedStyle)) { + return false; + } + + return true; +} + +/** + * Shows the screenshosts list. + * If an enlarged screenshot is being shown, it's removed and the list shown + * instead. + */ +function showScreenshotsList() { + if (currentScreenshot !=null) { + screenshotsParent.removeChild(currentScreenshot); + + currentScreenshot = null; + currentScreenshotNumber = -1; + currentScreenshotListItem = null; + } + + screenshotsParent.appendChild(screenshotsList); +} + +/** + * Shows the screenshot clicked. + * Gets the number of screenshot from the link clicked and sets that screenshot. + */ +function showScreenshotHandler(event) { + var screenshotNumber = getScreenshotNumberFromURL(event.currentTarget.href); + + if (screenshotNumber != -1) { + setNewScreenshot(screenshotNumber); + } +} + +/** + * Returns the screenshot number from a URL in the form "path/page.html#number". + * If there's no number specified in the url, or it's not a valid number, it + * returns -1. + * + * @param url The url to get the screenshot number from. + * @return The screenshot number from the URL. + */ +function getScreenshotNumberFromURL(url) { + var screenshotNumber = -1; + + if (url.indexOf('#') >= 0) { + screenshotNumber = parseInt( + url.substr(url.indexOf('#') + 1)); + + if (isNaN(screenshotNumber)) { + screenshotNumber = -1; + } + } + + return screenshotNumber; +} + +/** + * Shows a new screenshot. + * The screenshot is specified by its number, indexed in 0. + * The already loaded screenshot or screenshot list is removed to show the new + * screenshot. + * + * @param screenshotNumber The number of the screenshot to show. + */ +function setNewScreenshot(screenshotNumber) { + if (currentScreenshot) { + screenshotsParent.removeChild(currentScreenshot); + } else { + screenshotsParent.removeChild(screenshotsList); + } + + screenshotsParent.insertBefore( + createScreenshot(screenshotNumber), + screenshotsNextSibling); + updateScreenshotSize(); +} + +/** + * Returns a div element containing the screenshot title, the screenshots + * counter, the screenshot image and the navigation bar. + * Screenshot number is indexed in 0. If the specified screenshot number is + * smaller or larger than 0 or the number of screenshots available, it's set to + * 0 or the number of the last screenshot. + * + * currentScreenshot, currentScreenshotNumber and currentScreenshotListItem + * are set to the needed values. + */ +function createScreenshot(screenshotNumber) { + var listItemElements = screenshotsList.getElementsByTagName("li"); + + if (screenshotNumber < 0) { + screenshotNumber = 0; + } else if (screenshotNumber >= listItemElements.length) { + screenshotNumber = listItemElements.length - 1; + } + + var listItemElement = listItemElements[screenshotNumber]; + + var divElement = document.createElement("div"); + divElement.setAttribute("id", "screenshot"); + + currentScreenshot = divElement; + currentScreenshotNumber = screenshotNumber; + currentScreenshotListItem = listItemElement; + + //Screenshot title + var pElement = listItemElement.getElementsByTagName("p")[0].cloneNode(true); + pElement.setAttribute("id", "screenshotTitle"); + divElement.appendChild(pElement); + + divElement.appendChild(createScreenshotCounter()); + + var thumbnailImageElement = listItemElement.getElementsByTagName("img")[0]; + divElement.appendChild(createImageLink(thumbnailImageElement)); + + divElement.appendChild(createNavigationBar(listItemElement)); + + return divElement; +} + +/** + * Returns a paragraph with the current number of the screenshot (indexed in 1) + * and the total number of screenshots. + * + * @return The paragraph with the numbers. + */ +function createScreenshotCounter() { + var screenshotCountText = (currentScreenshotNumber + 1) + "/" + + screenshotsList.getElementsByTagName("li").length; + + var screenshotCountElement = document.createElement("p"); + screenshotCountElement.appendChild( + document.createTextNode(screenshotCountText)); + + return screenshotCountElement; +} + +/** + * Returns a link to the full image containing also this image. + * The link uses the id "currentScreenshotImageLink" and the image uses the id + * "currentScreenshotImage". + * The link is wrapped in a paragraph. + * + * @param thumbnailImageElement The image in the screenshot thumbnail. + * @return The link element containing the image, wrapped in a paragraph. + */ +function createImageLink(thumbnailImageElement) { + var imageLinkWrapperElement = document.createElement("p"); + imageLinkWrapperElement.setAttribute("id", "screenshotImageWrapper"); + + var imageLinkElement = document.createElement("a"); + imageLinkElement.setAttribute("id", "screenshotImageLink"); + + var thumbnailImageSrc = thumbnailImageElement.getAttribute("src"); + var imageName = thumbnailImageSrc.substring(0, + thumbnailImageSrc.lastIndexOf("-")); + var imageExtension = thumbnailImageSrc.substr( + thumbnailImageSrc.lastIndexOf(".")); + var imageSrc = imageName + imageExtension; + imageLinkElement.setAttribute("href", imageSrc); + imageLinkElement.setAttribute("title", "Click for full size"); + + var imageElement = document.createElement("img"); + imageElement.setAttribute("id", "screenshotImage"); + imageElement.setAttribute("src", imageSrc); + imageElement.setAttribute("alt", "Current screenshot: " + imageSrc); + imageLinkElement.appendChild(imageElement); + + imageLinkWrapperElement.appendChild(imageLinkElement); + + return imageLinkWrapperElement; +} + +/** + * Returns the navigation bar. + * The navigation bar includes links to the previous and next elements, and to + * the list of screenshots. + * If the screenshot is the first, previous link isn't added. If the screenshot + * is the last, next link isn't added. + * + * @param listItemElement The list item element in the screenshots list for the + * current screenshot. + * @return The navigation bar. + */ +function createNavigationBar(listItemElement) { + var divElement = document.createElement("div"); + divElement.setAttribute("id", "navigationBar"); + + var previousElement = createNavigationBarPrevious(listItemElement); + if (previousElement) { + divElement.appendChild(previousElement); + } + + divElement.appendChild(createNavigationBarUp()); + + var nextElement = createNavigationBarNext(listItemElement); + if (nextElement) { + divElement.appendChild(nextElement); + } + + return divElement; +} + +/** + * Returns the "Previous" link for the navigation bar. + * If the list item is the first in the list, a null element is returned. + * The link handles clicks showing the previous screenshot in the list. + * The link is wrapped in a paragraph. + * + * @param listItemElement The list item element in the screenshots list for the + * current screenshot. + * @return The "Previous" link for the navigation bar, wrapped in a paragraph. + */ +function createNavigationBarPrevious(listItemElement) { + var previousLinkWrapperElement; + + var hasPrevious = (getPreviousSiblingElement(listItemElement) != null); + + if (hasPrevious) { + previousLinkWrapperElement = document.createElement("p"); + previousLinkWrapperElement.setAttribute("id", "previousWrapper"); + + var previousLinkElement = document.createElement("a"); + previousLinkElement.appendChild(document.createTextNode("< Previous")); + previousLinkElement.setAttribute("href", screenshotsURL + "#" + + (currentScreenshotNumber - 1)); + previousLinkElement.setAttribute("title", "Previous screenshot"); + previousLinkElement.addEventListener("click", previousScreenshotHandler, + false); + + previousLinkWrapperElement.appendChild(previousLinkElement); + } + + return previousLinkWrapperElement; +} + +/** + * Returns the "Up" link for the navigation bar. + * The link handles clicks showing the list of screenshots. + * The link is wrapped in a paragraph. + * + * @return The "Up" link for the navigation bar, wrapped in a paragraph. + */ +function createNavigationBarUp() { + var upLinkWrapperElement = document.createElement("p"); + upLinkWrapperElement.setAttribute("id", "upWrapper"); + + var upLinkElementHref = screenshotsURL; + var upLinkElement = document.createElement("a"); + upLinkElement.appendChild(document.createTextNode("Up")); + upLinkElement.setAttribute("href", upLinkElementHref); + upLinkElement.setAttribute("title", "Screenshots list"); + upLinkElement.addEventListener("click", upScreenshotHandler, false); + + upLinkWrapperElement.appendChild(upLinkElement); + + return upLinkWrapperElement; +} + +/** + * Returns the "Next" link for the navigation bar. + * If the list item is the last in the list, a null element is returned. + * The link handles clicks showing the next screenshot in the list. + * The link is wrapped in a paragraph. + * + * @param listItemElement The list item element in the screenshots list for the + * current screenshot. + * @return The "Next" link for the navigation bar, wrapped in a paragraph. + */ +function createNavigationBarNext(listItemElement) { + var nextLinkWrapperElement; + + var hasNext = (getNextSiblingElement(listItemElement) != null); + + if (hasNext) { + nextLinkWrapperElement = document.createElement("p"); + nextLinkWrapperElement.setAttribute("id", "nextWrapper"); + + var nextLinkElement = document.createElement("a"); + nextLinkElement.appendChild(document.createTextNode("Next >")); + nextLinkElement.setAttribute("href", screenshotsURL + "#" + + (currentScreenshotNumber + 1)); + nextLinkElement.setAttribute("title", "Next screenshot"); + nextLinkElement.addEventListener("click", nextScreenshotHandler, false); + + nextLinkWrapperElement.appendChild(nextLinkElement); + } + + return nextLinkWrapperElement; +} + +/** + * Handles clicks on "Previous" link. + * Sets the screenshot to the previous screenshot of the current one. + */ +function previousScreenshotHandler(event) { + setNewScreenshot(currentScreenshotNumber - 1); +} + +/** + * Handles clicks on "Up" link. + * Shows the list of screenshots. + */ +function upScreenshotHandler(event) { + showScreenshotsList(); +} + +/** + * Handles clicks on "Next" link. + * Sets the screenshot to the next screenshot of the current one. + */ +function nextScreenshotHandler(event) { + setNewScreenshot(currentScreenshotNumber + 1); +} + +/** + * Gets the previous sibling with "element" type of the specified element. + * This function is needed because browsers tend to add dummy text nodes between + * element nodes. + * + * @param element The element to get its previous sibling. + * @return The previous sibling of element type, or null if there is none. + */ +function getPreviousSiblingElement(element) { + var previousElement = null; + var previousSibling = element.previousSibling; + while (!previousElement && previousSibling) { + if (previousSibling.nodeType == Node.ELEMENT_NODE) { + previousElement = previousSibling; + } + previousSibling = previousSibling.previousSibling; + } + + return previousElement; +} + +/** + * Gets the next sibling with "element" type of the specified element. + * This function is needed because browsers tend to add dummy text nodes between + * element nodes. + * + * @param element The element to get its next sibling. + * @return The next sibling of element type, or null if there is none. + */ +function getNextSiblingElement(element) { + var nextElement = null; + var nextSibling = element.nextSibling; + while (!nextElement && nextSibling) { + if (nextSibling.nodeType == Node.ELEMENT_NODE) { + nextElement = nextSibling; + } + nextSibling = nextSibling.nextSibling; + } + + return nextElement; +} + +/** + * Updates the size of the screenshot shown to fit it in the window. + * The screenshot is set to a width equal to its parent width minus the double + * of its left and right padding. + * Once set the width, the browser resizes the height automatically. + * + * If no screenshot is being currently shown, it does nothing. + */ +function updateScreenshotSize() { + if (!currentScreenshot) { + return; + } + + var parentWidth = getPixelsNumber( + document.defaultView.getComputedStyle( + currentScreenshot.parentNode, null)["width"]); + var parentLeftPadding = getPixelsNumber( + document.defaultView.getComputedStyle( + currentScreenshot.parentNode, null)["paddingLeft"]); + var parentRightPadding = getPixelsNumber( + document.defaultView.getComputedStyle( + currentScreenshot.parentNode, null)["paddingRight"]); + + var currentScreenshotImage = document.getElementById("screenshotImage"); + var imageWidth = parentWidth - parentLeftPadding * 2 - parentRightPadding * 2; + currentScreenshotImage.setAttribute("width", imageWidth); +} + +/** + * Returns the number of pixels from a string in the form "3px", for example. + * + * @param pixelsString The string to get the number of pixels. + * @return The number of pixels. + */ +function getPixelsNumber(pixelsString) { + return pixelsString.replace("px", ""); +} \ No newline at end of file Added: trunk/web-src/data/script/ogg.js =================================================================== --- trunk/web-src/data/script/ogg.js (rev 0) +++ trunk/web-src/data/script/ogg.js 2010-01-31 16:15:52 UTC (rev 72) @@ -0,0 +1,756 @@ +// Copyright (c) Fluendo +// Copyright (c) Tim Starling + +// 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. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +// This is a global configuration object which can embed multiple video instances +var wgOggPlayer = { + 'detectionDone': false, + 'msie': false, + 'safari' : false, + 'opera' : false, + 'mozilla': false, + + // List of players in order of preference + // Downpreffed VLC because it crashes my browser all the damn time -- TS + 'players': ['cortado', 'quicktime-mozilla', 'quicktime-activex', 'vlc-mozilla', 'vlc-activex', 'totem', 'kmplayer', 'kaffeine', 'mplayerplug-in', 'oggPlugin', 'videoElement'], + + // Client support table + 'clientSupports': { 'thumbnail' : true }, + + // MIME type to be used to invoke a given plugin with <object> + // May be changed by detect() + 'mimeTypes' : { + 'quicktime-mozilla': 'video/quicktime', + 'quicktime-activex': 'video/quicktime', + 'vlc-mozilla': 'application/x-vlc-plugin', + 'oggPlugin': 'application/ogg', + 'totem': 'application/ogg', + 'kmplayer': 'application/ogg', + 'kaffeine': 'application/ogg', + 'mplayerplug-in': 'application/ogg' + }, + + 'savedThumbs': {}, + 'qtTimers' : {}, + // Text for new messages, to support cached HTML invocation + 'defaultMsg' : { + 'ogg-player-totem': 'Totem', + 'ogg-player-kmplayer': 'KMPlayer', + 'ogg-player-kaffeine': 'Kaffeine', + 'ogg-player-mplayerplug-in': 'mplayerplug-in' + }, + + // Configuration from MW + 'msg': {}, + 'cortadoUrl' : '', + 'extPathUrl' : '', + 'showPlayerSelect': true, + 'controlsHeightGuess': 20, + + /** + * Main entry point: initialise a video player + * Player will be created as a child of the given ID + * There may be multiple players in a document. + * Parameters are: id, videoUrl, width, height, length, linkUrl, isVideo + */ + 'init': function ( player, params ) { + elt = document.getElementById( params.id ); + + // Save still image HTML + if ( !(params.id in this.savedThumbs) ) { + var thumb = document.createDocumentFragment(); + for ( i = 0; i < elt.childNodes.length; i++ ) { + thumb.appendChild( elt.childNodes.item( i ).cloneNode( true ) ); + } + this.savedThumbs[params.id] = thumb; + } + + this.detect(); + + if ( !player ) { + // See if there is a cookie specifying a preferred player + var cookieVal = this.getCookie( 'ogg_player' ); + if ( cookieVal && cookieVal != 'thumbnail' ) { + player = cookieVal; + } + } + + if ( !this.clientSupports[player] ) { + player = false; + } + + if ( !player ) { + for ( var i = 0; i < this.players.length; i++ ) { + if ( this.clientSupports[this.players[i]] ) { + player = this.players[i]; + break; + } + } + } + + elt.innerHTML = ''; + switch ( player ) { + case 'videoElement': + this.embedVideoElement( elt, params ); + break; + case 'oggPlugin': + case 'kaffeine': + case 'totem': + case 'kmplayer': + case 'mplayerplug-in': + this.embedOggPlugin( elt, params, player ); + break; + case 'vlc-mozilla': + this.embedVlcPlugin( elt, params ); + break; + case 'vlc-activex': + this.embedVlcActiveX( elt, params ); + break; + case 'cortado': + this.embedCortado( elt, params ); + break; + case 'quicktime-mozilla': + case 'quicktime-activex': + this.embedQuicktimePlugin( elt, params, player ); + break; + case 'thumbnail': + default: + if ( params.id in this.savedThumbs ) { + elt.appendChild( this.savedThumbs[params.id].cloneNode( true ) ); + } else { + elt.appendChild( document.createTextNode( 'Missing saved thumbnail for ' + params.id ) ); + } + if ( player != 'thumbnail' ) { + var div = document.createElement( 'div' ); + div.className = 'ogg-player-options'; + div.style.cssText = 'width: ' + ( params.width - 10 ) + 'px;'; + div.innerHTML = this.msg['ogg-no-player']; + elt.appendChild( div ); + player = 'none'; + } + } + if ( player != 'thumbnail' ) { + var optionsBox = this.makeOptionsBox( player, params ); + var optionsLink = this.makeOptionsLink( params.id ); + var div = document.createElement( 'div' ); + div.appendChild( optionsBox ); + div.appendChild( optionsLink ); + elt.appendChild( div ); + } + }, + + 'debug': function( s ) { + //alert(s); + }, + + // Detect client capabilities + 'detect': function() { + if (this.detectionDone) { + return; + } + this.detectionDone = true; + + // First some browser detection + this.msie = ( navigator.appName == "Microsoft Internet Explorer" )... [truncated message content] |