From 10fe04128a5d848b22764989b4a0744d69efd903 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Fri, 6 May 2011 11:19:20 +0200 Subject: added new registerqtv2operation --- installerbuilder/installerbuilder.pro | 2 +- .../libinstaller/extractarchiveoperation.cpp | 4 +- installerbuilder/libinstaller/init.cpp | 2 + .../libinstaller/lazyplaintextedit.cpp | 12 +- installerbuilder/libinstaller/libinstaller.pro | 2 + .../libinstaller/registerqtv2operation.cpp | 188 +++++++++++++++++++++ .../libinstaller/registerqtv2operation.h | 48 ++++++ 7 files changed, 250 insertions(+), 8 deletions(-) create mode 100644 installerbuilder/libinstaller/registerqtv2operation.cpp create mode 100644 installerbuilder/libinstaller/registerqtv2operation.h (limited to 'installerbuilder') diff --git a/installerbuilder/installerbuilder.pro b/installerbuilder/installerbuilder.pro index 77499994c..09276ca4e 100644 --- a/installerbuilder/installerbuilder.pro +++ b/installerbuilder/installerbuilder.pro @@ -1,6 +1,6 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS += libinstaller installerbase binarycreator repogen archivegen tests +SUBDIRS += libinstaller installerbase binarycreator #repogen archivegen tests #test.commands=(cd tests && $(MAKE) test) diff --git a/installerbuilder/libinstaller/extractarchiveoperation.cpp b/installerbuilder/libinstaller/extractarchiveoperation.cpp index 9c2121f7b..0a6422f22 100644 --- a/installerbuilder/libinstaller/extractarchiveoperation.cpp +++ b/installerbuilder/libinstaller/extractarchiveoperation.cpp @@ -75,7 +75,8 @@ bool ExtractArchiveOperation::performOperation() Receiver receiver; Callback callback; - connect( &callback, SIGNAL(progressChanged(QString)), this, SLOT(slotProgressChanged(QString)), Qt::QueuedConnection ); + //usually we have to connect it as queued connection but then some blocking work is in the main thread + connect( &callback, SIGNAL(progressChanged(QString)), this, SLOT(slotProgressChanged(QString)), Qt::DirectConnection ); connect( &callback, SIGNAL(progressChanged(int)), this, SIGNAL(progressChanged(int)), Qt::QueuedConnection ); if(QInstaller::Installer *installer = this->value( QLatin1String( "installer" )).value()) { @@ -189,6 +190,7 @@ ExtractArchiveOperation* ExtractArchiveOperation::clone() const return new ExtractArchiveOperation(); } +//this slot is direct connected to the caller so please don't call it from another thread in the same time void ExtractArchiveOperation::slotProgressChanged( const QString& filename ) { QStringList m_files = value( QLatin1String( "files" ) ).toStringList(); diff --git a/installerbuilder/libinstaller/init.cpp b/installerbuilder/libinstaller/init.cpp index df4f89477..150a0bd65 100644 --- a/installerbuilder/libinstaller/init.cpp +++ b/installerbuilder/libinstaller/init.cpp @@ -55,6 +55,7 @@ #include "linereplaceoperation.h" #include "registerdocumentationoperation.h" #include "registerqtoperation.h" +#include "registerqtv2operation.h" #include "setqtcreatorvalueoperation.h" #include "simplemovefileoperation.h" #include "registertoolchainoperation.h" @@ -176,6 +177,7 @@ void QInstaller::init() KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::CopyDirectoryOperation >( QLatin1String( "CopyDirectory") ); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterDocumentationOperation >( QLatin1String( "RegisterDocumentation") ); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorOperation>( QLatin1String( "RegisterQtInCreator") ); + KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterQtInCreatorV2Operation>( QLatin1String( "RegisterQtInCreatorV2") ); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::RegisterToolChainOperation>( QLatin1String( "RegisterToolChain") ); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetDemosPathOnQtOperation>( QLatin1String( "SetDemosPathOnQt") ); KDUpdater::UpdateOperationFactory::instance().registerUpdateOperation< QInstaller::SetExamplesPathOnQtOperation>( QLatin1String( "SetExamplesPathOnQt") ); diff --git a/installerbuilder/libinstaller/lazyplaintextedit.cpp b/installerbuilder/libinstaller/lazyplaintextedit.cpp index 930e05ca8..40b8dcdf5 100644 --- a/installerbuilder/libinstaller/lazyplaintextedit.cpp +++ b/installerbuilder/libinstaller/lazyplaintextedit.cpp @@ -34,7 +34,7 @@ #include -#define TIMER_TIME 10 +#define TIMER_TIME 20 LazyPlainTextEdit::LazyPlainTextEdit(QWidget *parent) : QPlainTextEdit(parent), m_timerId(0) @@ -55,12 +55,12 @@ void LazyPlainTextEdit::timerEvent(QTimerEvent *event) void LazyPlainTextEdit::append(const QString &text) { - if (m_timerId) { - killTimer(m_timerId); - m_timerId = 0; - } + //if (m_timerId) { + // killTimer(m_timerId); + // m_timerId = 0; + //} m_chachedOutput.append(text + QLatin1String("\n")); - if (isVisible()) { + if (isVisible() && m_timerId == 0) { m_timerId = startTimer(TIMER_TIME); } } diff --git a/installerbuilder/libinstaller/libinstaller.pro b/installerbuilder/libinstaller/libinstaller.pro index c5f71fbc4..2440caa9f 100644 --- a/installerbuilder/libinstaller/libinstaller.pro +++ b/installerbuilder/libinstaller/libinstaller.pro @@ -58,6 +58,7 @@ HEADERS += $$PWD/qinstaller.h \ linereplaceoperation.h \ registerdocumentationoperation.h \ registerqtoperation.h \ + registerqtv2operation.h \ registertoolchainoperation.h \ setqtcreatorvalueoperation.h \ copydirectoryoperation.h \ @@ -121,6 +122,7 @@ SOURCES += $$PWD/qinstaller.cpp \ linereplaceoperation.cpp \ registerdocumentationoperation.cpp \ registerqtoperation.cpp \ + registerqtv2operation.cpp \ registertoolchainoperation.cpp \ setqtcreatorvalueoperation.cpp \ copydirectoryoperation.cpp \ diff --git a/installerbuilder/libinstaller/registerqtv2operation.cpp b/installerbuilder/libinstaller/registerqtv2operation.cpp new file mode 100644 index 000000000..42b1f28e1 --- /dev/null +++ b/installerbuilder/libinstaller/registerqtv2operation.cpp @@ -0,0 +1,188 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** No Commercial Usage +** +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#include "registerqtv2operation.h" +#include "qinstaller.h" + +#include +#include +#include +#include +#include + +using namespace QInstaller; + +#if defined ( Q_OS_MAC ) + static const char *QtCreatorSettingsSuffixPath = + "/Qt Creator.app/Contents/Resources/Nokia/QtCreator.ini"; +#else + static const char *QtCreatorSettingsSuffixPath = + "/QtCreator/share/qtcreator/Nokia/QtCreator.ini"; +#endif + +RegisterQtInCreatorV2Operation::RegisterQtInCreatorV2Operation() +{ + setName(QLatin1String("RegisterQtInCreatorV2")); +} + +RegisterQtInCreatorV2Operation::~RegisterQtInCreatorV2Operation() +{ +} + +void RegisterQtInCreatorV2Operation::backup() +{ +} + +bool RegisterQtInCreatorV2Operation::performOperation() +{ + const QStringList args = arguments(); + + if( args.count() < 2) { + setError( InvalidArguments ); + setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 2 expected.") + .arg(name()).arg( args.count() ) ); + return false; + } + + const Installer* const installer = qVariantValue< Installer* >( value( QLatin1String( "installer" ) ) ); + const QString &rootInstallPath = installer->value(QLatin1String("TargetDir")); + + int argCounter = 0; + const QString &versionName = args.value(argCounter++); + const QString &path = args.value(argCounter++); + QString qmakePath = QDir(path).absolutePath(); + if ( !qmakePath.endsWith(QLatin1String("qmake")) + || !qmakePath.endsWith(QLatin1String("qmake.exe"))) + { +#if defined ( Q_OS_WIN ) + qmakePath.append(QLatin1String("/bin/qmake.exe")); +#elif defined( Q_OS_UNIX ) + qmakePath.append(QLatin1String("/bin/qmake")); +#endif + } + + const QString &systemRoot = args.value(argCounter++); //Symbian SDK root for example + const QString &sbsPath = args.value(argCounter++); + + QSettings settings(rootInstallPath + QLatin1String(QtCreatorSettingsSuffixPath), + QSettings::IniFormat); + + QString newVersions; + QStringList oldNewQtVersions = settings.value(QLatin1String("NewQtVersions") + ).toString().split(QLatin1String(";")); + + //remove not existing Qt versions and the current new one(because its added after this) + if (!oldNewQtVersions.isEmpty()) { + foreach (const QString &qtVersion, oldNewQtVersions) { + QStringList splitedQtConfiguration = qtVersion.split(QLatin1String("=")); + if (splitedQtConfiguration.value(1).contains(QLatin1String("qmake"), + Qt::CaseInsensitive)) { + QString foundVersionName = splitedQtConfiguration.at(0); + QString foundQmakePath = splitedQtConfiguration.at(1); + if (qmakePath != foundQmakePath && versionName != foundVersionName + && QFile::exists(foundQmakePath)) { + newVersions.append(qtVersion + QLatin1String(";")); + } + } + } + } + + QString addedVersion = versionName; + + addedVersion += QLatin1Char('=') + qmakePath; + addedVersion += QLatin1Char('=') + systemRoot; + addedVersion += QLatin1Char('=') + sbsPath; + newVersions += addedVersion; + settings.setValue(QLatin1String("NewQtVersions"), newVersions); + + return true; +} + +bool RegisterQtInCreatorV2Operation::undoOperation() +{ + const QStringList args = arguments(); + + if( args.count() < 3) { + setError( InvalidArguments ); + setErrorString( tr("Invalid arguments in %0: %1 arguments given, minimum 3 expected.") + .arg(name()).arg( args.count() ) ); + return false; + } + + const QString &rootInstallPath = args.value(0); //for example "C:\\QtSDK\\" + const QString &versionName = args.value(1); + const QString &path = args.value(2); + QString qmakePath = QDir(path).absolutePath(); + if (!qmakePath.endsWith(QLatin1String("qmake")) + || !qmakePath.endsWith(QLatin1String("qmake.exe"))) { + #if defined ( Q_OS_WIN ) + qmakePath.append(QLatin1String("bin/qmake.exe")); + #elif defined( Q_OS_UNIX ) + qmakePath.append(QLatin1String("bin/qmake")); + #endif + } + + QSettings settings( rootInstallPath + QLatin1String(QtCreatorSettingsSuffixPath), + QSettings::IniFormat ); + + QString newVersions; + QStringList oldNewQtVersions = settings.value(QLatin1String("NewQtVersions") + ).toString().split(QLatin1String(";")); + + //remove the removed Qt version from "NewQtVersions" setting + if (!oldNewQtVersions.isEmpty()) { + foreach (const QString &qtVersion, oldNewQtVersions) { + QStringList splitedQtConfiguration = qtVersion.split(QLatin1String("=")); + if (splitedQtConfiguration.value(1).contains(QLatin1String("qmake"), + Qt::CaseInsensitive)) { + QString foundVersionName = splitedQtConfiguration.at(0); + QString foundQmakePath = splitedQtConfiguration.at(1); + if (qmakePath != foundQmakePath &&versionName != foundVersionName + && QFile::exists(foundQmakePath)) { + newVersions.append(qtVersion + QLatin1String(";")); + } + } + } + } + settings.setValue(QLatin1String("NewQtVersions"), newVersions); + return true; +} + +bool RegisterQtInCreatorV2Operation::testOperation() +{ + return true; +} + +KDUpdater::UpdateOperation* RegisterQtInCreatorV2Operation::clone() const +{ + return new RegisterQtInCreatorV2Operation(); +} diff --git a/installerbuilder/libinstaller/registerqtv2operation.h b/installerbuilder/libinstaller/registerqtv2operation.h new file mode 100644 index 000000000..86cb7a16a --- /dev/null +++ b/installerbuilder/libinstaller/registerqtv2operation.h @@ -0,0 +1,48 @@ +/************************************************************************** +** +** This file is part of Qt SDK** +** +** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).* +** +** Contact: Nokia Corporation qt-info@nokia.com** +** +** GNU Lesser General Public License Usage +** +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this file. +** Please review the following information to ensure the GNU Lesser General +** Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception version +** 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you are unsure which license is appropriate for your use, please contact +** (qt-info@nokia.com). +** +**************************************************************************/ +#ifndef REGISTERQTINCREATORV2OPERATION_H +#define REGISTERQTINCREATORV2OPERATION_H + +#include + +namespace QInstaller { + +class RegisterQtInCreatorV2Operation : public KDUpdater::UpdateOperation +{ +public: + RegisterQtInCreatorV2Operation(); + ~RegisterQtInCreatorV2Operation(); + + void backup(); + bool performOperation(); + bool undoOperation(); + bool testOperation(); + KDUpdater::UpdateOperation* clone() const; +}; + +}; // namespace + +#endif // REGISTERQTINCREATORV2OPERATION_H -- cgit v1.2.3