diff options
Diffstat (limited to 'src/plugins')
872 files changed, 11501 insertions, 41186 deletions
diff --git a/src/plugins/android/addnewavddialog.ui b/src/plugins/android/addnewavddialog.ui index f06986fa4c9..b5a0ba5ec75 100644 --- a/src/plugins/android/addnewavddialog.ui +++ b/src/plugins/android/addnewavddialog.ui @@ -95,13 +95,13 @@ <string> MiB</string> </property> <property name="minimum"> - <number>50</number> + <number>0</number> </property> <property name="maximum"> <number>9999999</number> </property> <property name="value"> - <number>200</number> + <number>0</number> </property> </widget> </item> diff --git a/src/plugins/android/android_dependencies.pri b/src/plugins/android/android_dependencies.pri index 94fa4d8f363..fad0a885abe 100644 --- a/src/plugins/android/android_dependencies.pri +++ b/src/plugins/android/android_dependencies.pri @@ -8,7 +8,6 @@ QTC_PLUGIN_DEPENDS += \ analyzerbase QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmldebug \ ssh \ diff --git a/src/plugins/android/androidconfigurations.cpp b/src/plugins/android/androidconfigurations.cpp index 1469afd7243..764a6586570 100644 --- a/src/plugins/android/androidconfigurations.cpp +++ b/src/plugins/android/androidconfigurations.cpp @@ -68,6 +68,8 @@ #include <QStringListModel> #include <QMessageBox> +#include <QTcpSocket> +#include <QHostAddress> #include <functional> @@ -129,6 +131,8 @@ namespace { return dev1.type == AndroidDeviceInfo::Hardware; if (dev1.sdk != dev2.sdk) return dev1.sdk < dev2.sdk; + if (dev1.avdname != dev2.avdname) + return dev1.avdname < dev2.avdname; return dev1.serialNumber < dev2.serialNumber; } @@ -522,15 +526,20 @@ FileName AndroidConfig::keytoolPath() const QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const { + return connectedDevices(adbToolPath().toString(), error); +} + +QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(const QString &adbToolPath, QString *error) +{ QVector<AndroidDeviceInfo> devices; QProcess adbProc; - adbProc.start(adbToolPath().toString(), QStringList() << QLatin1String("devices")); + adbProc.start(adbToolPath, QStringList() << QLatin1String("devices")); if (!adbProc.waitForFinished(10000)) { adbProc.kill(); if (error) *error = QApplication::translate("AndroidConfiguration", "Could not run: %1") - .arg(adbToolPath().toString() + QLatin1String(" devices")); + .arg(adbToolPath + QLatin1String(" devices")); return devices; } QList<QByteArray> adbDevs = adbProc.readAll().trimmed().split('\n'); @@ -546,19 +555,23 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const foreach (const QByteArray &device, adbDevs) { const QString serialNo = QString::fromLatin1(device.left(device.indexOf('\t')).trimmed()); const QString deviceType = QString::fromLatin1(device.mid(device.indexOf('\t'))).trimmed(); - if (isBootToQt(serialNo)) + if (isBootToQt(adbToolPath, serialNo)) continue; AndroidDeviceInfo dev; dev.serialNumber = serialNo; dev.type = serialNo.startsWith(QLatin1String("emulator")) ? AndroidDeviceInfo::Emulator : AndroidDeviceInfo::Hardware; - dev.sdk = getSDKVersion(dev.serialNumber); - dev.cpuAbi = getAbis(dev.serialNumber); + dev.sdk = getSDKVersion(adbToolPath, dev.serialNumber); + dev.cpuAbi = getAbis(adbToolPath, dev.serialNumber); if (deviceType == QLatin1String("unauthorized")) dev.state = AndroidDeviceInfo::UnAuthorizedState; else if (deviceType == QLatin1String("offline")) dev.state = AndroidDeviceInfo::OfflineState; else dev.state = AndroidDeviceInfo::OkState; + + if (dev.type == AndroidDeviceInfo::Emulator) + dev.avdname = getAvdName(dev.serialNumber); + devices.push_back(dev); } @@ -566,7 +579,7 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const if (devices.isEmpty() && error) *error = QApplication::translate("AndroidConfiguration", "No devices found in output of: %1") - .arg(adbToolPath().toString() + QLatin1String(" devices")); + .arg(adbToolPath + QLatin1String(" devices")); return devices; } @@ -597,8 +610,9 @@ AndroidConfig::CreateAvdInfo AndroidConfig::createAVDImpl(CreateAvdInfo info, Fi arguments << QLatin1String("create") << QLatin1String("avd") << QLatin1String("-t") << info.target << QLatin1String("-n") << info.name - << QLatin1String("-b") << info.abi - << QLatin1String("-c") << QString::fromLatin1("%1M").arg(info.sdcardSize); + << QLatin1String("-b") << info.abi; + if (info.sdcardSize > 0) + arguments << QLatin1String("-c") << QString::fromLatin1("%1M").arg(info.sdcardSize); proc.start(androidToolPath.toString(), arguments); if (!proc.waitForStarted()) { info.error = QApplication::translate("AndroidConfig", "Could not start process \"%1 %2\"") @@ -656,22 +670,17 @@ bool AndroidConfig::removeAVD(const QString &name) const QFuture<QVector<AndroidDeviceInfo>> AndroidConfig::androidVirtualDevicesFuture() { - return QtConcurrent::run(&AndroidConfig::androidVirtualDevicesImpl, androidToolPath(), androidToolEnvironment()); + return QtConcurrent::run(&AndroidConfig::androidVirtualDevices, androidToolPath().toString(), androidToolEnvironment()); } -QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevices() const -{ - return androidVirtualDevicesImpl(androidToolPath(), androidToolEnvironment()); -} - -QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevicesImpl(const FileName &androidTool, const Environment &environment) +QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevices(const QString &androidTool, const Environment &environment) { QVector<AndroidDeviceInfo> devices; QProcess proc; proc.setProcessEnvironment(environment.toProcessEnvironment()); - proc.start(androidTool.toString(), + proc.start(androidTool, QStringList() << QLatin1String("list") << QLatin1String("avd")); // list available AVDs - if (!proc.waitForFinished(10000)) { + if (!proc.waitForFinished(20000)) { proc.terminate(); return devices; } @@ -683,6 +692,8 @@ QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevicesImpl(const FileNa avds.removeFirst(); // remove the daemon logs avds.removeFirst(); // remove "List of devices attached" header line + bool nextLineIsTargetLine = false; + AndroidDeviceInfo dev; for (int i = 0; i < avds.size(); i++) { QString line = QLatin1String(avds.at(i)); @@ -692,7 +703,7 @@ QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevicesImpl(const FileNa int index = line.indexOf(QLatin1Char(':')) + 2; if (index >= line.size()) break; - dev.serialNumber = line.mid(index).trimmed(); + dev.avdname = line.mid(index).trimmed(); dev.sdk = -1; dev.cpuAbi.clear(); ++i; @@ -700,7 +711,15 @@ QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevicesImpl(const FileNa line = QLatin1String(avds[i]); if (line.contains(QLatin1String("---------"))) break; - if (line.contains(QLatin1String("Target:"))) { + + if (line.contains(QLatin1String("Target:")) || nextLineIsTargetLine) { + if (line.contains(QLatin1String("Google APIs"))) { + nextLineIsTargetLine = true; + continue; + } + + nextLineIsTargetLine = false; + int lastIndex = line.lastIndexOf(QLatin1Char(' ')); if (lastIndex == -1) // skip line break; @@ -736,10 +755,10 @@ QVector<AndroidDeviceInfo> AndroidConfig::androidVirtualDevicesImpl(const FileNa return devices; } -QString AndroidConfig::startAVD(const QString &name, int apiLevel, QString cpuAbi) const +QString AndroidConfig::startAVD(const QString &name) const { - if (!findAvd(apiLevel, cpuAbi).isEmpty() || startAVDAsync(name)) - return waitForAvd(apiLevel, cpuAbi); + if (!findAvd(name).isEmpty() || startAVDAsync(name)) + return waitForAvd(name); return QString(); } @@ -763,17 +782,14 @@ bool AndroidConfig::startAVDAsync(const QString &avdName) const return true; } -QString AndroidConfig::findAvd(int apiLevel, const QString &cpuAbi) const +QString AndroidConfig::findAvd(const QString &avdName) const { QVector<AndroidDeviceInfo> devices = connectedDevices(); foreach (AndroidDeviceInfo device, devices) { - if (!device.serialNumber.startsWith(QLatin1String("emulator"))) - continue; - if (!device.cpuAbi.contains(cpuAbi)) + if (device.type != AndroidDeviceInfo::Emulator) continue; - if (device.sdk != apiLevel) - continue; - return device.serialNumber; + if (device.avdname == avdName) + return device.serialNumber; } return QString(); } @@ -805,7 +821,7 @@ bool AndroidConfig::waitForBooted(const QString &serialNumber, const QFutureInte return false; } -QString AndroidConfig::waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi) const +QString AndroidConfig::waitForAvd(const QString &avdName, const QFutureInterface<bool> &fi) const { // we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running // 60 rounds of 2s sleeping, two minutes for the avd to start @@ -813,7 +829,7 @@ QString AndroidConfig::waitForAvd(int apiLevel, const QString &cpuAbi, const QFu for (int i = 0; i < 60; ++i) { if (fi.isCanceled()) return QString(); - serialNumber = findAvd(apiLevel, cpuAbi); + serialNumber = findAvd(avdName); if (!serialNumber.isEmpty()) return waitForBooted(serialNumber, fi) ? serialNumber : QString(); Utils::sleep(2000); @@ -823,13 +839,18 @@ QString AndroidConfig::waitForAvd(int apiLevel, const QString &cpuAbi, const QFu bool AndroidConfig::isBootToQt(const QString &device) const { + return isBootToQt(adbToolPath().toString(), device); +} + +bool AndroidConfig::isBootToQt(const QString &adbToolPath, const QString &device) +{ // workaround for '????????????' serial numbers QStringList arguments = AndroidDeviceInfo::adbSelector(device); arguments << QLatin1String("shell") << QLatin1String("ls -l /system/bin/appcontroller || ls -l /usr/bin/appcontroller && echo Boot2Qt"); QProcess adbProc; - adbProc.start(adbToolPath().toString(), arguments); + adbProc.start(adbToolPath, arguments); if (!adbProc.waitForFinished(10000)) { adbProc.kill(); return false; @@ -837,20 +858,87 @@ bool AndroidConfig::isBootToQt(const QString &device) const return adbProc.readAll().contains("Boot2Qt"); } -int AndroidConfig::getSDKVersion(const QString &device) const + +QString AndroidConfig::getDeviceProperty(const QString &adbToolPath, const QString &device, const QString &property) { // workaround for '????????????' serial numbers QStringList arguments = AndroidDeviceInfo::adbSelector(device); arguments << QLatin1String("shell") << QLatin1String("getprop") - << QLatin1String("ro.build.version.sdk"); + << property; QProcess adbProc; - adbProc.start(adbToolPath().toString(), arguments); + adbProc.start(adbToolPath, arguments); if (!adbProc.waitForFinished(10000)) { adbProc.kill(); + return QString(); + } + + return QString::fromLocal8Bit(adbProc.readAll()); +} + +int AndroidConfig::getSDKVersion(const QString &device) const +{ + return getSDKVersion(adbToolPath().toString(), device); +} + +int AndroidConfig::getSDKVersion(const QString &adbToolPath, const QString &device) +{ + QString tmp = getDeviceProperty(adbToolPath, device, QLatin1String("ro.build.version.sdk")); + if (tmp.isEmpty()) return -1; + return tmp.trimmed().toInt(); +} + +QString AndroidConfig::getAvdName(const QString &serialnumber) +{ + int index = serialnumber.indexOf(QLatin1String("-")); + if (index == -1) + return QString(); + bool ok; + int port = serialnumber.mid(index + 1).toInt(&ok); + if (!ok) + return QString(); + + QByteArray avdName = "avd name\n"; + + QTcpSocket tcpSocket; + tcpSocket.connectToHost(QHostAddress(QHostAddress::LocalHost), port); + tcpSocket.waitForConnected(); + tcpSocket.write(avdName + "exit\n"); + tcpSocket.waitForDisconnected(); + + QByteArray response = tcpSocket.readAll(); + int start = response.indexOf("OK\r\n"); + if (start == -1) + return QString(); + start = start + 4; + + int end = response.indexOf("\r\n", start); + if (end == -1) + return QString(); + return QString::fromLatin1(response.mid(start, end - start)); +} + +AndroidConfig::OpenGl AndroidConfig::getOpenGLEnabled(const QString &emulator) const +{ + QDir dir = QDir::home(); + if (!dir.cd(QLatin1String(".android"))) + return OpenGl::Unknown; + if (!dir.cd(QLatin1String("avd"))) + return OpenGl::Unknown; + if (!dir.cd(emulator + QLatin1String(".avd"))) + return OpenGl::Unknown; + QFile file(dir.filePath(QLatin1String("config.ini"))); + if (!file.exists()) + return OpenGl::Unknown; + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + return OpenGl::Unknown; + while (!file.atEnd()) { + QByteArray line = file.readLine(); + if (line.contains("hw.gpu.enabled") && line.contains("yes")) + return OpenGl::Enabled; } - return adbProc.readAll().trimmed().toInt(); + return OpenGl::Disabled; } //! @@ -862,20 +950,11 @@ QString AndroidConfig::getProductModel(const QString &device) const { if (m_serialNumberToDeviceName.contains(device)) return m_serialNumberToDeviceName.value(device); - // workaround for '????????????' serial numbers - QStringList arguments = AndroidDeviceInfo::adbSelector(device); - arguments << QLatin1String("shell") << QLatin1String("getprop") - << QLatin1String("ro.product.model"); - QProcess adbProc; - adbProc.start(adbToolPath().toString(), arguments); - if (!adbProc.waitForFinished(10000)) { - adbProc.kill(); - return device; - } - QString model = QString::fromLocal8Bit(adbProc.readAll().trimmed()); + QString model = getDeviceProperty(adbToolPath().toString(), device, QLatin1String("ro.product.model")).trimmed(); if (model.isEmpty()) return device; + if (!device.startsWith(QLatin1String("????"))) m_serialNumberToDeviceName.insert(device, model); return model; @@ -901,13 +980,18 @@ bool AndroidConfig::hasFinishedBooting(const QString &device) const QStringList AndroidConfig::getAbis(const QString &device) const { + return getAbis(adbToolPath().toString(), device); +} + +QStringList AndroidConfig::getAbis(const QString &adbToolPath, const QString &device) +{ QStringList result; // First try via ro.product.cpu.abilist QStringList arguments = AndroidDeviceInfo::adbSelector(device); arguments << QLatin1String("shell") << QLatin1String("getprop"); arguments << QLatin1String("ro.product.cpu.abilist"); QProcess adbProc; - adbProc.start(adbToolPath().toString(), arguments); + adbProc.start(adbToolPath, arguments); if (!adbProc.waitForFinished(10000)) { adbProc.kill(); return result; @@ -929,7 +1013,7 @@ QStringList AndroidConfig::getAbis(const QString &device) const arguments << QString::fromLatin1("ro.product.cpu.abi%1").arg(i); QProcess adbProc; - adbProc.start(adbToolPath().toString(), arguments); + adbProc.start(adbToolPath, arguments); if (!adbProc.waitForFinished(10000)) { adbProc.kill(); return result; @@ -1064,8 +1148,9 @@ void AndroidConfigurations::setConfig(const AndroidConfig &devConfigs) m_instance->save(); m_instance->updateAndroidDevice(); - m_instance->updateToolChainList(); + m_instance->registerNewToolChains(); m_instance->updateAutomaticKitList(); + m_instance->removeOldToolChains(); emit m_instance->updated(); } @@ -1074,25 +1159,14 @@ AndroidDeviceInfo AndroidConfigurations::showDeviceDialog(Project *project, Options options) { QString serialNumber = defaultDevice(project, abi); - if (!serialNumber.isEmpty()) { - // search for that device - foreach (const AndroidDeviceInfo &info, AndroidConfigurations::currentConfig().connectedDevices()) - if (info.serialNumber == serialNumber - && info.sdk >= apiLevel) - return info; - - foreach (const AndroidDeviceInfo &info, AndroidConfigurations::currentConfig().androidVirtualDevices()) - if (info.serialNumber == serialNumber - && info.sdk >= apiLevel) - return info; - } - - AndroidDeviceDialog dialog(apiLevel, abi, options, Core::ICore::mainWindow()); + AndroidDeviceDialog dialog(apiLevel, abi, options, serialNumber, Core::ICore::mainWindow()); if (dialog.exec() == QDialog::Accepted) { AndroidDeviceInfo info = dialog.device(); if (dialog.saveDeviceSelection()) { - if (!info.serialNumber.isEmpty()) - AndroidConfigurations::setDefaultDevice(project, abi, info.serialNumber); + const QString serialNumber = info.type == AndroidDeviceInfo::Hardware ? + info.serialNumber : info.avdname; + if (!serialNumber.isEmpty()) + AndroidConfigurations::setDefaultDevice(project, abi, serialNumber); } return info; } @@ -1122,11 +1196,25 @@ QString AndroidConfigurations::defaultDevice(Project *project, const QString &ab static bool equalKits(Kit *a, Kit *b) { - return ToolChainKitInformation::toolChain(a) == ToolChainKitInformation::toolChain(b) - && QtSupport::QtKitInformation::qtVersion(a) == QtSupport::QtKitInformation::qtVersion(b); + if (QtSupport::QtKitInformation::qtVersion(a) != QtSupport::QtKitInformation::qtVersion(b)) + return false; + ToolChain *atc = ToolChainKitInformation::toolChain(a); + ToolChain *btc = ToolChainKitInformation::toolChain(b); + if (atc == btc) + return true; + if (!atc || atc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) + return false; + if (!btc || btc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) + return false; + AndroidToolChain *aatc = static_cast<AndroidToolChain *>(atc); + AndroidToolChain *bbtc = static_cast<AndroidToolChain *>(btc); + if (aatc->ndkToolChainVersion() == bbtc->ndkToolChainVersion() + && aatc->targetAbi() == bbtc->targetAbi()) + return true; + return false; } -void AndroidConfigurations::updateToolChainList() +void AndroidConfigurations::registerNewToolChains() { QList<ToolChain *> existingToolChains = ToolChainManager::toolChains(); QList<ToolChain *> toolchains = AndroidToolChainFactory::createToolChainsForNdk(AndroidConfigurations::currentConfig().ndkLocation()); @@ -1143,8 +1231,11 @@ void AndroidConfigurations::updateToolChainList() else ToolChainManager::registerToolChain(tc); } +} - foreach (ToolChain *tc, existingToolChains) { +void AndroidConfigurations::removeOldToolChains() +{ + foreach (ToolChain *tc, ToolChainManager::toolChains()) { if (tc->type() == QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) { if (!tc->isValid()) ToolChainManager::deregisterToolChain(tc); @@ -1163,6 +1254,8 @@ void AndroidConfigurations::updateAutomaticKitList() continue; if (tc->type() != QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE)) continue; + if (!tc->isValid()) // going to be deleted + continue; toolchains << static_cast<AndroidToolChain *>(tc); } } @@ -1250,6 +1343,7 @@ void AndroidConfigurations::updateAutomaticKitList() newKits.removeAt(j); existingKits.at(i)->makeSticky(); existingKits.removeAt(i); + ToolChainKitInformation::setToolChain(existingKit, ToolChainKitInformation::toolChain(newKit)); KitManager::deleteKit(newKit); j = newKits.count(); } @@ -1260,6 +1354,7 @@ void AndroidConfigurations::updateAutomaticKitList() ToolChain *tc = ToolChainKitInformation::toolChain(k); QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k); if (tc && tc->type() == QLatin1String(Constants::ANDROID_TOOLCHAIN_TYPE) + && tc->isValid() && qtVersion && qtVersion->type() == QLatin1String(Constants::ANDROIDQT)) { k->makeUnSticky(); k->setAutoDetected(false); diff --git a/src/plugins/android/androidconfigurations.h b/src/plugins/android/androidconfigurations.h index f35cce897a1..906632bd2d0 100644 --- a/src/plugins/android/androidconfigurations.h +++ b/src/plugins/android/androidconfigurations.h @@ -60,6 +60,7 @@ class AndroidPlugin; struct AndroidDeviceInfo { QString serialNumber; + QString avdname; QStringList cpuAbi; int sdk; enum State { OkState, UnAuthorizedState, OfflineState }; @@ -148,14 +149,15 @@ public: bool removeAVD(const QString &name) const; QVector<AndroidDeviceInfo> connectedDevices(QString *error = 0) const; + static QVector<AndroidDeviceInfo> connectedDevices(const QString &adbToolPath, QString *error = 0); QFuture<QVector<AndroidDeviceInfo> > androidVirtualDevicesFuture(); - QVector<AndroidDeviceInfo> androidVirtualDevices() const; + static QVector<AndroidDeviceInfo> androidVirtualDevices(const QString &androidTool, const Utils::Environment &environment); - QString startAVD(const QString &name, int apiLevel, QString cpuAbi) const; + QString startAVD(const QString &name) const; bool startAVDAsync(const QString &avdName) const; - QString findAvd(int apiLevel, const QString &cpuAbi) const; - QString waitForAvd(int apiLevel, const QString &cpuAbi, const QFutureInterface<bool> &fi = QFutureInterface<bool>()) const; + QString findAvd(const QString &avdName) const; + QString waitForAvd(const QString &avdName, const QFutureInterface<bool> &fi = QFutureInterface<bool>()) const; QString bestNdkPlatformMatch(int target) const; static ProjectExplorer::Abi abiForToolChainPrefix(const QString &toolchainPrefix); @@ -164,6 +166,8 @@ public: static QLatin1String displayName(const ProjectExplorer::Abi &abi); QString getProductModel(const QString &device) const; + enum class OpenGl { Enabled, Disabled, Unknown }; + OpenGl getOpenGLEnabled(const QString &emulator) const; bool hasFinishedBooting(const QString &device) const; bool waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const; bool isConnected(const QString &serialNumber) const; @@ -171,13 +175,17 @@ public: SdkPlatform highestAndroidSdk() const; private: static CreateAvdInfo createAVDImpl(CreateAvdInfo info, Utils::FileName androidToolPath, Utils::Environment env); - static QVector<AndroidDeviceInfo> androidVirtualDevicesImpl(const Utils::FileName &androidTool, const Utils::Environment &environment); + static QString getDeviceProperty(const QString &adbToolPath, const QString &device, const QString &property); Utils::FileName toolPath(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion) const; Utils::FileName openJDKBinPath() const; int getSDKVersion(const QString &device) const; + static int getSDKVersion(const QString &adbToolPath, const QString &device); QStringList getAbis(const QString &device) const; + static QStringList getAbis(const QString &adbToolPath, const QString &device); + static bool isBootToQt(const QString &adbToolPath, const QString &device); bool isBootToQt(const QString &device) const; + static QString getAvdName(const QString &serialnumber); void updateAvailableSdkPlatforms() const; void updateNdkInformation() const; @@ -221,7 +229,8 @@ public: static QString defaultDevice(ProjectExplorer::Project *project, const QString &abi); // serial number or avd name public slots: static void clearDefaultDevices(ProjectExplorer::Project *project); - static void updateToolChainList(); + static void registerNewToolChains(); + static void removeOldToolChains(); static void updateAutomaticKitList(); static bool force32bitEmulator(); diff --git a/src/plugins/android/androiddebugsupport.cpp b/src/plugins/android/androiddebugsupport.cpp index 5fee5df7080..0b7f2122729 100644 --- a/src/plugins/android/androiddebugsupport.cpp +++ b/src/plugins/android/androiddebugsupport.cpp @@ -116,6 +116,12 @@ RunControl *AndroidDebugSupport::createDebugRunControl(AndroidRunConfiguration * params.remoteSetupNeeded = true; //TODO: Not sure if these are the right paths. params.projectSourceDirectory = target->project()->projectDirectory().toString(); + Kit *kit = target->kit(); + QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); + if (version) { + const QString qmlQtDir = version->versionInfo().value(QLatin1String("QT_INSTALL_QML")); + params.additionalSearchDirectories = QStringList(qmlQtDir); + } params.projectSourceFiles = target->project()->files(Project::ExcludeGeneratedFiles); params.projectBuildDirectory = target->activeBuildConfiguration()->buildDirectory().toString(); } diff --git a/src/plugins/android/androiddeployqtstep.cpp b/src/plugins/android/androiddeployqtstep.cpp index 24a02e511af..28ae428a91c 100644 --- a/src/plugins/android/androiddeployqtstep.cpp +++ b/src/plugins/android/androiddeployqtstep.cpp @@ -48,6 +48,7 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/project.h> #include <projectexplorer/target.h> +#include <projectexplorer/toolchain.h> #include <qtsupport/qtkitinformation.h> @@ -191,22 +192,25 @@ bool AndroidDeployQtStep::init() return false; } - m_deviceAPILevel = AndroidManager::minimumSDK(target()); + int deviceAPILevel = AndroidManager::minimumSDK(target()); AndroidConfigurations::Options options = AndroidConfigurations::None; if (androidBuildApkStep->deployAction() == AndroidBuildApkStep::DebugDeployment) options = AndroidConfigurations::FilterAndroid5; - AndroidDeviceInfo info = AndroidConfigurations::showDeviceDialog(project(), m_deviceAPILevel, m_targetArch, options); - if (info.serialNumber.isEmpty()) // aborted + AndroidDeviceInfo info = AndroidConfigurations::showDeviceDialog(project(), deviceAPILevel, m_targetArch, options); + if (info.serialNumber.isEmpty() && info.avdname.isEmpty()) // aborted return false; - if (info.type == AndroidDeviceInfo::Emulator) { - m_avdName = info.serialNumber; - m_serialNumber.clear(); - m_deviceAPILevel = info.sdk; - } else { - m_avdName.clear(); - m_serialNumber = info.serialNumber; + m_avdName = info.avdname; + m_serialNumber = info.serialNumber; + m_appProcess = QLatin1String("readlink -f -s /system/bin/app_process"); + if (info.cpuAbi.contains(QLatin1String("arm64-v8a"))) { + ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(target()->kit()); + if (tc && tc->targetAbi().wordWidth() == 64) + m_appProcess += QLatin1String("64"); + else + m_appProcess += QLatin1String("32"); } + AndroidManager::setDeviceSerialNumber(target(), m_serialNumber); ProjectExplorer::BuildConfiguration *bc = target()->activeBuildConfiguration(); @@ -278,7 +282,7 @@ bool AndroidDeployQtStep::init() m_adbPath = AndroidConfigurations::currentConfig().adbToolPath().toString(); - if (AndroidConfigurations::currentConfig().findAvd(m_deviceAPILevel, m_targetArch).isEmpty()) + if (AndroidConfigurations::currentConfig().findAvd(m_avdName).isEmpty()) AndroidConfigurations::currentConfig().startAVDAsync(m_avdName); return true; } @@ -400,7 +404,7 @@ void AndroidDeployQtStep::slotSetSerialNumber(const QString &serialNumber) void AndroidDeployQtStep::run(QFutureInterface<bool> &fi) { if (!m_avdName.isEmpty()) { - QString serialNumber = AndroidConfigurations::currentConfig().waitForAvd(m_deviceAPILevel, m_targetArch, fi); + QString serialNumber = AndroidConfigurations::currentConfig().waitForAvd(m_avdName, fi); if (serialNumber.isEmpty()) { fi.reportResult(false); emit finished(); @@ -421,17 +425,16 @@ void AndroidDeployQtStep::run(QFutureInterface<bool> &fi) emit addOutput(tr("Pulling files necessary for debugging."), MessageOutput); + const QString remoteAppProcessFile = systemAppProcessFilePath(); QString localAppProcessFile = QString::fromLatin1("%1/app_process").arg(m_buildDirectory); runCommand(m_adbPath, AndroidDeviceInfo::adbSelector(m_serialNumber) - << QLatin1String("pull") << QLatin1String("/system/bin/app_process") + << QLatin1String("pull") << remoteAppProcessFile << localAppProcessFile); - // Workaround for QTCREATORBUG-14201: /system/bin/app_process might be a link to asan/app_process if (!QFileInfo::exists(localAppProcessFile)) { - runCommand(m_adbPath, - AndroidDeviceInfo::adbSelector(m_serialNumber) - << QLatin1String("pull") << QLatin1String("/system/bin/asan/app_process") - << localAppProcessFile); + returnValue = Failure; + emit addOutput(tr("Package deploy: Failed to pull \"%1\" to \"%2\".") + .arg(remoteAppProcessFile).arg(localAppProcessFile), ErrorMessageOutput); } runCommand(m_adbPath, AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("pull") @@ -465,6 +468,17 @@ void AndroidDeployQtStep::runCommand(const QString &program, const QStringList & } } +QString AndroidDeployQtStep::systemAppProcessFilePath() const +{ + QProcess proc; + const QStringList args = + QStringList() << AndroidDeviceInfo::adbSelector(m_serialNumber) << QLatin1String("shell") + << m_appProcess; + proc.start(m_adbPath, args); + proc.waitForFinished(); + return QString::fromUtf8(proc.readAll()).trimmed(); +} + ProjectExplorer::BuildStepConfigWidget *AndroidDeployQtStep::createConfigWidget() { return new AndroidDeployQtWidget(this); diff --git a/src/plugins/android/androiddeployqtstep.h b/src/plugins/android/androiddeployqtstep.h index 00a675ebd39..5dbd493f40c 100644 --- a/src/plugins/android/androiddeployqtstep.h +++ b/src/plugins/android/androiddeployqtstep.h @@ -102,6 +102,7 @@ private: AndroidDeployQtStep *other); void ctor(); void runCommand(const QString &program, const QStringList &arguments); + QString systemAppProcessFilePath() const; bool init(); void run(QFutureInterface<bool> &fi); @@ -126,9 +127,9 @@ private: QString m_buildDirectory; QString m_avdName; QString m_apkPath; + QString m_appProcess; QString m_targetArch; - int m_deviceAPILevel; bool m_uninstallPreviousPackage; bool m_uninstallPreviousPackageRun; static const Core::Id Id; diff --git a/src/plugins/android/androiddevicedialog.cpp b/src/plugins/android/androiddevicedialog.cpp index 874d1a0b999..f26e7bc24d2 100644 --- a/src/plugins/android/androiddevicedialog.cpp +++ b/src/plugins/android/androiddevicedialog.cpp @@ -32,6 +32,10 @@ #include "androidmanager.h" #include "ui_androiddevicedialog.h" +#include <utils/environment.h> +#include <utils/progressindicator.h> +#include <utils/algorithm.h> + #include <QMessageBox> #include <QPainter> #include <QStyledItemDelegate> @@ -164,15 +168,35 @@ public: QFontMetrics fm(opt.font); // TopLeft - QString topLeft = device.serialNumber; + QString topLeft; if (device.type == AndroidDeviceInfo::Hardware) topLeft = AndroidConfigurations::currentConfig().getProductModel(device.serialNumber); + else + topLeft = device.avdname; painter->drawText(size + 12, 2 + opt.rect.top() + fm.ascent(), topLeft); - QString topRight = device.serialNumber; + // topRight - if (device.type == AndroidDeviceInfo::Hardware) // otherwise it's not very informative - painter->drawText(opt.rect.right() - fm.width(topRight) - 6 , 2 + opt.rect.top() + fm.ascent(), topRight); + auto drawTopRight = [&](const QString text, const QFontMetrics &fm) { + painter->drawText(opt.rect.right() - fm.width(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text); + }; + + if (device.type == AndroidDeviceInfo::Hardware) { + drawTopRight(device.serialNumber, fm); + } else { + AndroidConfig::OpenGl openGl = AndroidConfigurations::currentConfig().getOpenGLEnabled(device.avdname); + if (openGl == AndroidConfig::OpenGl::Enabled) { + drawTopRight(tr("OpenGL enabled"), fm); + } else if (openGl == AndroidConfig::OpenGl::Disabled) { + QFont font = painter->font(); + font.setBold(true); + painter->setFont(font); + QFontMetrics fmBold(font); + drawTopRight(tr("OpenGL disabled"), fmBold); + font.setBold(false); + painter->setFont(font); + } + } // Directory QColor mix; @@ -228,7 +252,7 @@ public: AndroidDeviceInfo device(QModelIndex index); void setDevices(const QVector<AndroidDeviceInfo> &devices); - QModelIndex indexFor(const QString &serial); + QModelIndex indexFor(AndroidDeviceInfo::AndroidDeviceType type, const QString &serial); private: int m_apiLevel; QString m_abi; @@ -364,12 +388,16 @@ void AndroidDeviceModel::setDevices(const QVector<AndroidDeviceInfo> &devices) endResetModel(); } -QModelIndex AndroidDeviceModel::indexFor(const QString &serial) +QModelIndex AndroidDeviceModel::indexFor(AndroidDeviceInfo::AndroidDeviceType type, const QString &serial) { foreach (AndroidDeviceModelNode *topLevelNode, m_root->children()) { QList<AndroidDeviceModelNode *> deviceNodes = topLevelNode->children(); for (int i = 0; i < deviceNodes.size(); ++i) { - if (deviceNodes.at(i)->deviceInfo().serialNumber == serial) + const AndroidDeviceInfo &info = deviceNodes.at(i)->deviceInfo(); + if (info.type != type) + continue; + if ((type == AndroidDeviceInfo::Hardware && serial == info.serialNumber) + || (type == AndroidDeviceInfo::Emulator && serial == info.avdname)) return createIndex(i, 0, deviceNodes.at(i)); } } @@ -392,12 +420,14 @@ static inline QString msgAdbListDevices() return AndroidDeviceDialog::tr("<p>The adb tool in the Android SDK lists all connected devices if run via "adb devices".</p>"); } -AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QString &abi, AndroidConfigurations::Options options, QWidget *parent) : +AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QString &abi, AndroidConfigurations::Options options, + const QString &serialNumber, QWidget *parent) : QDialog(parent), m_model(new AndroidDeviceModel(apiLevel, abi, options)), m_ui(new Ui::AndroidDeviceDialog), m_apiLevel(apiLevel), - m_abi(abi) + m_abi(abi), + m_defaultDevice(serialNumber) { m_ui->setupUi(this); m_ui->deviceView->setModel(m_model); @@ -424,16 +454,40 @@ AndroidDeviceDialog::AndroidDeviceDialog(int apiLevel, const QString &abi, Andro connect(m_ui->deviceView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(accept())); - connect(&m_futureWatcher, SIGNAL(finished()), + connect(&m_futureWatcherAddDevice, SIGNAL(finished()), this, SLOT(avdAdded())); + connect(&m_futureWatcherRefreshDevices, &QFutureWatcherBase::finished, + this, &AndroidDeviceDialog::devicesRefreshed); refreshDeviceList(); + + connect(m_ui->deviceView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &AndroidDeviceDialog::enableOkayButton); + + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); + + m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Large, this); + m_progressIndicator->attachToWidget(m_ui->deviceView); + + if (serialNumber.isEmpty()) { + m_ui->lookingForDevice->setVisible(false); + m_ui->lookingForDeviceCancel->setVisible(false); + } else { + m_ui->lookingForDevice->setVisible(true); + m_ui->lookingForDevice->setText(tr("Looking for default device <b>%1</b>.").arg(serialNumber)); + m_ui->lookingForDeviceCancel->setVisible(true); + } + + connect(m_ui->lookingForDeviceCancel, &QPushButton::clicked, + this, &AndroidDeviceDialog::defaultDeviceClear); + m_defaultDeviceTimer.start(); } AndroidDeviceDialog::~AndroidDeviceDialog() { + m_futureWatcherAddDevice.waitForFinished(); + m_futureWatcherRefreshDevices.waitForFinished(); delete m_ui; - m_futureWatcher.waitForFinished(); } AndroidDeviceInfo AndroidDeviceDialog::device() @@ -455,17 +509,43 @@ bool AndroidDeviceDialog::saveDeviceSelection() void AndroidDeviceDialog::refreshDeviceList() { + m_ui->refreshDevicesButton->setEnabled(false); + m_futureWatcherRefreshDevices.setFuture(QtConcurrent::run(&AndroidDeviceDialog::refreshDevices, + AndroidConfigurations::currentConfig().adbToolPath().toString(), + AndroidConfigurations::currentConfig().androidToolPath().toString(), + AndroidConfigurations::currentConfig().androidToolEnvironment())); +} + +QVector<AndroidDeviceInfo> AndroidDeviceDialog::refreshDevices(const QString &adbToolPath, + const QString &androidToolPath, + const Utils::Environment &environment) +{ + QVector<AndroidDeviceInfo> devices = AndroidConfig::connectedDevices(adbToolPath); + + QSet<QString> startedAvds = Utils::transform<QSet>(devices, + [] (const AndroidDeviceInfo &info) { + return info.avdname; + }); + + for (const AndroidDeviceInfo &dev : AndroidConfig::androidVirtualDevices(androidToolPath, environment)) + if (!startedAvds.contains(dev.avdname)) + devices << dev; + return devices; +} + +void AndroidDeviceDialog::devicesRefreshed() +{ + m_progressIndicator->hide(); QString serialNumber; + AndroidDeviceInfo::AndroidDeviceType deviceType; QModelIndex currentIndex = m_ui->deviceView->currentIndex(); - if (currentIndex.isValid()) - serialNumber = m_model->device(currentIndex).serialNumber; - - QVector<AndroidDeviceInfo> devices; - foreach (const AndroidDeviceInfo &info, AndroidConfigurations::currentConfig().connectedDevices()) - if (info.type == AndroidDeviceInfo::Hardware) - devices << info; + if (currentIndex.isValid()) { // save currently selected index + AndroidDeviceInfo info = m_model->device(currentIndex); + deviceType = info.type; + serialNumber = deviceType == AndroidDeviceInfo::Hardware ? info.serialNumber : info.avdname; + } - devices += AndroidConfigurations::currentConfig().androidVirtualDevices(); + QVector<AndroidDeviceInfo> devices = m_futureWatcherRefreshDevices.result(); m_model->setDevices(devices); m_ui->deviceView->expand(m_model->index(0, 0)); @@ -474,15 +554,53 @@ void AndroidDeviceDialog::refreshDeviceList() // Smartly select a index QModelIndex newIndex; - if (!serialNumber.isEmpty()) - newIndex = m_model->indexFor(serialNumber); + if (!m_defaultDevice.isEmpty()) { + newIndex = m_model->indexFor(AndroidDeviceInfo::Hardware, m_defaultDevice); + if (!newIndex.isValid()) + newIndex = m_model->indexFor(AndroidDeviceInfo::Emulator, m_defaultDevice); + if (!newIndex.isValid()) // not found the default device + defaultDeviceClear(); + } + + if (!newIndex.isValid() && !m_avdNameFromAdd.isEmpty()) { + newIndex = m_model->indexFor(AndroidDeviceInfo::Emulator, m_avdNameFromAdd); + m_avdNameFromAdd.clear(); + } + + if (!newIndex.isValid() && !serialNumber.isEmpty()) + newIndex = m_model->indexFor(deviceType, serialNumber); - if (!newIndex.isValid() && !devices.isEmpty()) - newIndex = m_model->indexFor(devices.first().serialNumber); + if (!newIndex.isValid() && !devices.isEmpty()) { + AndroidDeviceInfo info = devices.first(); + const QString &name = info.type == AndroidDeviceInfo::Hardware ? info.serialNumber : info.avdname; + newIndex = m_model->indexFor(info.type, name); + } m_ui->deviceView->setCurrentIndex(newIndex); m_ui->stackedWidget->setCurrentIndex(devices.isEmpty() ? 1 : 0); + + m_ui->refreshDevicesButton->setEnabled(true); + + if (!m_defaultDevice.isEmpty()) { + int elapsed = m_defaultDeviceTimer.elapsed(); + if (elapsed > 4000) + accept(); + else + QTimer::singleShot(4000 - elapsed, this, &AndroidDeviceDialog::useDefaultDevice); + } +} + +void AndroidDeviceDialog::useDefaultDevice() +{ + if (m_defaultDevice.isEmpty()) + return; + AndroidDeviceInfo info = m_model->device(m_ui->deviceView->currentIndex()); + if (info.serialNumber == m_defaultDevice + || info.avdname == m_defaultDevice) + accept(); + else // something different is selected + defaultDeviceClear(); } void AndroidDeviceDialog::createAvd() @@ -495,21 +613,27 @@ void AndroidDeviceDialog::createAvd() return; } - m_futureWatcher.setFuture(AndroidConfigurations::currentConfig().createAVD(info)); + m_futureWatcherAddDevice.setFuture(AndroidConfigurations::currentConfig().createAVD(info)); } void AndroidDeviceDialog::avdAdded() { m_ui->createAVDButton->setEnabled(true); - AndroidConfig::CreateAvdInfo info = m_futureWatcher.result(); + AndroidConfig::CreateAvdInfo info = m_futureWatcherAddDevice.result(); if (!info.error.isEmpty()) { QMessageBox::critical(this, QApplication::translate("AndroidConfig", "Error Creating AVD"), info.error); return; } + m_avdNameFromAdd = info.name; refreshDeviceList(); - QModelIndex index = m_model->indexFor(info.name); - m_ui->deviceView->setCurrentIndex(index); +} + +void AndroidDeviceDialog::enableOkayButton() +{ + AndroidDeviceModelNode *node = static_cast<AndroidDeviceModelNode *>(m_ui->deviceView->currentIndex().internalPointer()); + bool enable = node && (!node->deviceInfo().serialNumber.isEmpty() || !node->deviceInfo().avdname.isEmpty()); + m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(enable); } // Does not work. @@ -532,3 +656,10 @@ void AndroidDeviceDialog::showHelp() pos = m_ui->missingLabel->parentWidget()->mapToGlobal(pos); QToolTip::showText(pos, msgConnect() + msgAdbListDevices(), this); } + +void AndroidDeviceDialog::defaultDeviceClear() +{ + m_ui->lookingForDevice->setVisible(false); + m_ui->lookingForDeviceCancel->setVisible(false); + m_defaultDevice.clear(); +} diff --git a/src/plugins/android/androiddevicedialog.h b/src/plugins/android/androiddevicedialog.h index cae5d9c6b30..2317c4e2c23 100644 --- a/src/plugins/android/androiddevicedialog.h +++ b/src/plugins/android/androiddevicedialog.h @@ -36,11 +36,14 @@ #include <QVector> #include <QDialog> #include <QFutureWatcher> +#include <QTime> QT_BEGIN_NAMESPACE class QModelIndex; QT_END_NAMESPACE +namespace Utils { class ProgressIndicator; } + namespace Android { namespace Internal { @@ -52,7 +55,8 @@ class AndroidDeviceDialog : public QDialog Q_OBJECT public: - explicit AndroidDeviceDialog(int apiLevel, const QString &abi, AndroidConfigurations::Options opts, QWidget *parent = 0); + explicit AndroidDeviceDialog(int apiLevel, const QString &abi, AndroidConfigurations::Options opts, + const QString &serialNumber, QWidget *parent = 0); ~AndroidDeviceDialog(); AndroidDeviceInfo device(); @@ -67,11 +71,24 @@ private slots: void showHelp(); void avdAdded(); private: + static QVector<AndroidDeviceInfo> refreshDevices(const QString &adbToolPath, + const QString &androidToolPath, + const Utils::Environment &environment); + void devicesRefreshed(); + void enableOkayButton(); + void useDefaultDevice(); + void defaultDeviceClear(); + AndroidDeviceModel *m_model; Ui::AndroidDeviceDialog *m_ui; + Utils::ProgressIndicator *m_progressIndicator; int m_apiLevel; QString m_abi; - QFutureWatcher<AndroidConfig::CreateAvdInfo> m_futureWatcher; + QString m_avdNameFromAdd; + QString m_defaultDevice; + QTime m_defaultDeviceTimer; + QFutureWatcher<AndroidConfig::CreateAvdInfo> m_futureWatcherAddDevice; + QFutureWatcher<QVector<AndroidDeviceInfo>> m_futureWatcherRefreshDevices; }; } diff --git a/src/plugins/android/androiddevicedialog.ui b/src/plugins/android/androiddevicedialog.ui index f480a9d54ee..625d6657fc9 100644 --- a/src/plugins/android/androiddevicedialog.ui +++ b/src/plugins/android/androiddevicedialog.ui @@ -6,53 +6,54 @@ <rect> <x>0</x> <y>0</y> - <width>636</width> - <height>438</height> + <width>788</width> + <height>466</height> </rect> </property> <property name="windowTitle"> <string>Select Android Device</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="defaultDeviceCheckBox"> - <property name="text"> - <string>Always use this device for architecture %1</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QPushButton" name="createAVDButton"> - <property name="text"> - <string>Create Android Virtual Device</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QDialogButtonBox" name="buttonBox"> + <item row="6" column="2"> + <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> </property> - </widget> + </spacer> </item> - <item row="2" column="0"> - <widget class="QPushButton" name="refreshDevicesButton"> + <item row="2" column="0" colspan="2"> + <widget class="QCheckBox" name="defaultDeviceCheckBox"> <property name="text"> - <string>Refresh Device List</string> + <string>Always use this device for architecture %1</string> </property> </widget> </item> - <item row="0" column="0" colspan="3"> + <item row="0" column="0" colspan="4"> <widget class="QStackedWidget" name="stackedWidget"> <property name="currentIndex"> <number>0</number> </property> <widget class="QWidget" name="devicesPage"> <layout class="QGridLayout" name="gridLayout_3"> - <item row="1" column="0"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="1" column="0" colspan="2"> <widget class="QTreeView" name="deviceView"> <property name="minimumSize"> <size> @@ -62,7 +63,7 @@ </property> </widget> </item> - <item row="2" column="0"> + <item row="2" column="0" colspan="2"> <widget class="QLabel" name="missingLabel"> <property name="text"> <string><html><head/><body><p><a href="aaa"><span style=" text-decoration: underline; color:#0057ae;">My device is missing</span></a></p></body></html></string> @@ -72,10 +73,42 @@ </property> </widget> </item> + <item row="0" column="0"> + <widget class="QLabel" name="lookingForDevice"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QPushButton" name="lookingForDeviceCancel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> </layout> </widget> <widget class="QWidget" name="noDevicesPage"> <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> <item row="0" column="0"> <widget class="QLabel" name="noDeviceFoundLabel"> <property name="text"> @@ -96,6 +129,42 @@ </widget> </widget> </item> + <item row="8" column="0" colspan="4"> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QPushButton" name="createAVDButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Create Android Virtual Device</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QPushButton" name="refreshDevicesButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Refresh Device List</string> + </property> + </widget> + </item> </layout> </widget> <resources/> diff --git a/src/plugins/android/androidmanager.cpp b/src/plugins/android/androidmanager.cpp index ab071b70894..532f34f9181 100644 --- a/src/plugins/android/androidmanager.cpp +++ b/src/plugins/android/androidmanager.cpp @@ -323,6 +323,8 @@ QString AndroidManager::androidNameForApiLevel(int x) return QLatin1String("Android 4.4W"); case 21: return QLatin1String("Android 5.0"); + case 22: + return QLatin1String("Android 5.1"); default: return tr("Unknown Android version. API Level: %1").arg(QString::number(x)); } @@ -493,14 +495,14 @@ void AndroidManager::cleanLibsOnDevice(ProjectExplorer::Target *target) return; int deviceAPILevel = AndroidManager::minimumSDK(target); AndroidDeviceInfo info = AndroidConfigurations::showDeviceDialog(target->project(), deviceAPILevel, targetArch, AndroidConfigurations::None); - if (info.serialNumber.isEmpty()) // aborted + if (info.serialNumber.isEmpty() && info.avdname.isEmpty()) // aborted return; deviceAPILevel = info.sdk; QString deviceSerialNumber = info.serialNumber; if (info.type == AndroidDeviceInfo::Emulator) { - deviceSerialNumber = AndroidConfigurations::currentConfig().startAVD(deviceSerialNumber, deviceAPILevel, targetArch); + deviceSerialNumber = AndroidConfigurations::currentConfig().startAVD(info.avdname); if (deviceSerialNumber.isEmpty()) Core::MessageManager::write(tr("Starting Android virtual device failed.")); } @@ -523,13 +525,13 @@ void AndroidManager::installQASIPackage(ProjectExplorer::Target *target, const Q return; int deviceAPILevel = AndroidManager::minimumSDK(target); AndroidDeviceInfo info = AndroidConfigurations::showDeviceDialog(target->project(), deviceAPILevel, targetArch, AndroidConfigurations::None); - if (info.serialNumber.isEmpty()) // aborted + if (info.serialNumber.isEmpty() && info.avdname.isEmpty()) // aborted return; deviceAPILevel = info.sdk; QString deviceSerialNumber = info.serialNumber; if (info.type == AndroidDeviceInfo::Emulator) { - deviceSerialNumber = AndroidConfigurations::currentConfig().startAVD(deviceSerialNumber, deviceAPILevel, targetArch); + deviceSerialNumber = AndroidConfigurations::currentConfig().startAVD(info.avdname); if (deviceSerialNumber.isEmpty()) Core::MessageManager::write(tr("Starting Android virtual device failed.")); } @@ -559,9 +561,9 @@ bool AndroidManager::checkKeystorePassword(const QString &keystorePath, const QS << keystorePasswd; QProcess proc; proc.start(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments); - if (!proc.waitForStarted(4000)) + if (!proc.waitForStarted(10000)) return false; - if (!proc.waitForFinished(4000)) { + if (!proc.waitForFinished(10000)) { proc.kill(); proc.waitForFinished(); return false; @@ -588,9 +590,9 @@ bool AndroidManager::checkCertificatePassword(const QString &keystorePath, const QProcess proc; proc.start(AndroidConfigurations::currentConfig().keytoolPath().toString(), arguments); - if (!proc.waitForStarted(4000)) + if (!proc.waitForStarted(10000)) return false; - if (!proc.waitForFinished(4000)) { + if (!proc.waitForFinished(10000)) { proc.kill(); proc.waitForFinished(); return false; diff --git a/src/plugins/android/androidsettingswidget.cpp b/src/plugins/android/androidsettingswidget.cpp index f8748be2294..2cae8dc2c15 100644 --- a/src/plugins/android/androidsettingswidget.cpp +++ b/src/plugins/android/androidsettingswidget.cpp @@ -79,7 +79,7 @@ QModelIndex AvdModel::indexForAvdName(const QString &avdName) const QString AvdModel::avdName(const QModelIndex &index) const { - return m_list.at(index.row()).serialNumber; + return m_list.at(index.row()).avdname; } QVariant AvdModel::data(const QModelIndex &index, int role) const @@ -88,7 +88,7 @@ QVariant AvdModel::data(const QModelIndex &index, int role) const return QVariant(); switch (index.column()) { case 0: - return m_list[index.row()].serialNumber; + return m_list[index.row()].avdname; case 1: return QString::fromLatin1("API %1").arg(m_list[index.row()].sdk); case 2: { diff --git a/src/plugins/android/avddialog.cpp b/src/plugins/android/avddialog.cpp index cb8f411cd83..05236100a4d 100644 --- a/src/plugins/android/avddialog.cpp +++ b/src/plugins/android/avddialog.cpp @@ -30,17 +30,24 @@ #include "avddialog.h" #include "androidconfigurations.h" + #include <coreplugin/coreconstants.h> +#include <utils/tooltip/tooltip.h> +#include <QKeyEvent> #include <QMessageBox> +#include <QToolTip> using namespace Android; using namespace Android::Internal; AvdDialog::AvdDialog(int minApiLevel, const QString &targetArch, const AndroidConfig *config, QWidget *parent) : - QDialog(parent), m_config(config), m_minApiLevel(minApiLevel) + QDialog(parent), m_config(config), m_minApiLevel(minApiLevel), + m_allowedNameChars(QLatin1String("[a-z|A-Z|0-9|._-]*")) { m_avdDialog.setupUi(this); + m_hideTipTimer.setInterval(2000); + m_hideTipTimer.setSingleShot(true); if (targetArch.isEmpty()) m_avdDialog.abiComboBox->addItems(QStringList() @@ -51,15 +58,19 @@ AvdDialog::AvdDialog(int minApiLevel, const QString &targetArch, const AndroidCo else m_avdDialog.abiComboBox->addItems(QStringList(targetArch)); - QRegExp rx(QLatin1String("\\S+")); - QRegExpValidator v(rx, 0); - m_avdDialog.nameLineEdit->setValidator(&v); + QRegExpValidator *v = new QRegExpValidator(m_allowedNameChars, this); + m_avdDialog.nameLineEdit->setValidator(v); + m_avdDialog.nameLineEdit->installEventFilter(this); + m_avdDialog.warningIcon->setPixmap(QPixmap(QLatin1String(Core::Constants::ICON_WARNING))); updateApiLevelComboBox(); connect(m_avdDialog.abiComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateApiLevelComboBox())); + + connect(&m_hideTipTimer, &QTimer::timeout, + this, [](){Utils::ToolTip::hide();}); } bool AvdDialog::isValid() const @@ -115,3 +126,21 @@ void AvdDialog::updateApiLevelComboBox() m_avdDialog.warningText->setVisible(false); } } + +bool AvdDialog::eventFilter(QObject *obj, QEvent *event) +{ + if (obj == m_avdDialog.nameLineEdit && event->type() == QEvent::KeyPress) { + QKeyEvent *ke = static_cast<QKeyEvent *>(event); + const QString key = ke->text(); + if (!key.isEmpty() && !m_allowedNameChars.exactMatch(key)) { + QPoint position = m_avdDialog.nameLineEdit->parentWidget()->mapToGlobal(m_avdDialog.nameLineEdit->geometry().bottomLeft()); + position -= Utils::ToolTip::offsetFromPosition(); + Utils::ToolTip::show(position, tr("Allowed characters are: a-z A-Z 0-9 and . _ -"), m_avdDialog.nameLineEdit); + m_hideTipTimer.start(); + } else { + m_hideTipTimer.stop(); + Utils::ToolTip::hide(); + } + } + return QDialog::eventFilter(obj, event); +} diff --git a/src/plugins/android/avddialog.h b/src/plugins/android/avddialog.h index c81e179a7e3..c01bb0615e1 100644 --- a/src/plugins/android/avddialog.h +++ b/src/plugins/android/avddialog.h @@ -32,7 +32,9 @@ #define AVDDIALOG_H #include "ui_addnewavddialog.h" + #include <QDialog> +#include <QTimer> namespace Android { class AndroidConfig; @@ -51,12 +53,17 @@ public: QString abi() const; int sdcardSize() const; bool isValid() const; + private slots: void updateApiLevelComboBox(); private: + bool eventFilter(QObject *obj, QEvent *event); + Ui::AddNewAVDDialog m_avdDialog; const AndroidConfig *m_config; int m_minApiLevel; + QTimer m_hideTipTimer; + QRegExp m_allowedNameChars; }; } } diff --git a/src/plugins/android/javaparser.cpp b/src/plugins/android/javaparser.cpp index 65a979e2ddb..05673790b89 100644 --- a/src/plugins/android/javaparser.cpp +++ b/src/plugins/android/javaparser.cpp @@ -95,7 +95,7 @@ void JavaParser::parse(const QString &line) file /* filename */, lineno, Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp index f17b1d7f6c1..29d30951223 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp @@ -64,7 +64,11 @@ using namespace ProjectExplorer::Constants; ////////////////////////////////////// AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *parent) : BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID)) -{ } +{ + // /<foobar> is used so the un-changed check in setBuildDirectory() works correctly. + // The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory. + BuildConfiguration::setBuildDirectory(Utils::FileName::fromString(QString::fromLatin1("/<foobar>"))); +} NamedWidget *AutotoolsBuildConfiguration::createConfigWidget() { diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp index 0829666ef5a..4e7afec62fb 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp @@ -53,6 +53,8 @@ #include <cpptools/cppmodelmanager.h> #include <coreplugin/icore.h> #include <coreplugin/icontext.h> +#include <qtsupport/baseqtversion.h> +#include <qtsupport/qtkitinformation.h> #include <utils/qtcassert.h> #include <utils/filesystemwatcher.h> @@ -408,6 +410,16 @@ void AutotoolsProject::updateCppCodeModel() CppTools::ProjectInfo pInfo(this); CppTools::ProjectPartBuilder ppBuilder(pInfo); + CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt; + if (QtSupport::BaseQtVersion *qtVersion = + QtSupport::QtKitInformation::qtVersion(activeTarget()->kit())) { + if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0)) + activeQtVersion = CppTools::ProjectPart::Qt4; + else + activeQtVersion = CppTools::ProjectPart::Qt5; + } + + ppBuilder.setQtVersion(activeQtVersion); const QStringList cflags = m_makefileParserThread->cflags(); QStringList cxxflags = m_makefileParserThread->cxxflags(); if (cxxflags.isEmpty()) diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs index 89cec4467ae..af646ffa2ee 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs @@ -9,6 +9,7 @@ QtcPlugin { Depends { name: "Core" } Depends { name: "ProjectExplorer" } Depends { name: "CppTools" } + Depends { name: "QtSupport" } files: [ "autogenstep.cpp", diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager_dependencies.pri b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager_dependencies.pri index 03fe3176cfe..a7db905643d 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager_dependencies.pri +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager_dependencies.pri @@ -5,4 +5,5 @@ QTC_LIB_DEPENDS += \ QTC_PLUGIN_DEPENDS += \ projectexplorer \ coreplugin \ - cpptools + cpptools \ + qtsupport diff --git a/src/plugins/baremetal/baremetaldeploystepfactory.cpp b/src/plugins/baremetal/baremetaldeploystepfactory.cpp deleted file mode 100644 index 9fec9a0dbdd..00000000000 --- a/src/plugins/baremetal/baremetaldeploystepfactory.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 Tim Sander <tim@krieglstein.org> -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "baremetaldeploystepfactory.h" - -#include "baremetaldeployconfiguration.h" -#include "baremetalgdbcommandsdeploystep.h" - -#include <utils/qtcassert.h> - -using namespace ProjectExplorer; - -namespace BareMetal { -namespace Internal { -BareMetalDeployStepFactory::BareMetalDeployStepFactory(QObject *parent) : - IBuildStepFactory(parent) -{ -} - -QList<Core::Id> BareMetalDeployStepFactory::availableCreationIds(BuildStepList *parent) const -{ - QList<Core::Id> ids; - if (!qobject_cast<BareMetalDeployConfiguration *>(parent->parent())) - return ids; - ids << BareMetalGdbCommandsDeployStep::stepId(); - return ids; -} - -QString BareMetalDeployStepFactory::displayNameForId(const Core::Id id) const -{ - if (id == BareMetalGdbCommandsDeployStep::stepId()) - return BareMetalGdbCommandsDeployStep::displayName(); - return QString(); -} - -bool BareMetalDeployStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const -{ - return availableCreationIds(parent).contains(id); -} - -BuildStep *BareMetalDeployStepFactory::create(BuildStepList *parent, const Core::Id id) -{ - QTC_ASSERT(canCreate(parent, id), return 0); - if (id == BareMetalGdbCommandsDeployStep::stepId()) - return new BareMetalGdbCommandsDeployStep(parent, id); - return 0; -} - -bool BareMetalDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, idFromMap(map)); -} - -BuildStep *BareMetalDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map) -{ - QTC_ASSERT(canRestore(parent, map), return 0); - BuildStep * const step = create(parent, idFromMap(map)); - if (!step->fromMap(map)) { - delete step; - return 0; - } - return step; -} - -bool BareMetalDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - -BuildStep *BareMetalDeployStepFactory::clone(BuildStepList *parent, BuildStep *product) -{ - if (BareMetalGdbCommandsDeployStep * const other = qobject_cast<BareMetalGdbCommandsDeployStep *>(product)) - return new BareMetalGdbCommandsDeployStep(parent, other); - return 0; -} - -} // namespace Internal -} // namepsace BareMetal diff --git a/src/plugins/baremetal/gdbserverprovider.cpp b/src/plugins/baremetal/gdbserverprovider.cpp index f43504e9720..5f32c7efbf2 100644 --- a/src/plugins/baremetal/gdbserverprovider.cpp +++ b/src/plugins/baremetal/gdbserverprovider.cpp @@ -109,8 +109,6 @@ GdbServerProvider::StartupMode GdbServerProvider::startupMode() const void GdbServerProvider::setStartupMode(StartupMode m) { - if (m == m_startupMode) - return; m_startupMode = m; } @@ -121,8 +119,6 @@ QString GdbServerProvider::initCommands() const void GdbServerProvider::setInitCommands(const QString &cmds) { - if (cmds == m_initCommands) - return; m_initCommands = cmds; } @@ -133,8 +129,6 @@ QString GdbServerProvider::resetCommands() const void GdbServerProvider::setResetCommands(const QString &cmds) { - if (cmds == m_resetCommands) - return; m_resetCommands = cmds; } @@ -160,19 +154,18 @@ bool GdbServerProvider::operator==(const GdbServerProvider &other) const return thisId == otherId && m_startupMode == other.m_startupMode && m_initCommands == other.m_initCommands - && m_resetCommands == other.m_resetCommands - ; + && m_resetCommands == other.m_resetCommands; } QVariantMap GdbServerProvider::toMap() const { - QVariantMap result; - result.insert(QLatin1String(idKeyC), m_id); - result.insert(QLatin1String(displayNameKeyC), m_displayName); - result.insert(QLatin1String(startupModeKeyC), m_startupMode); - result.insert(QLatin1String(initCommandsKeyC), m_initCommands); - result.insert(QLatin1String(resetCommandsKeyC), m_resetCommands); - return result; + return { + { QLatin1String(idKeyC), m_id }, + { QLatin1String(displayNameKeyC), m_displayName }, + { QLatin1String(startupModeKeyC), m_startupMode }, + { QLatin1String(initCommandsKeyC), m_initCommands }, + { QLatin1String(resetCommandsKeyC), m_resetCommands } + }; } bool GdbServerProvider::isValid() const @@ -356,7 +349,7 @@ void GdbServerProviderConfigWidget::setFromProvider() QString GdbServerProviderConfigWidget::defaultInitCommandsTooltip() { return QCoreApplication::translate("BareMetal", - "Enter GDB commands to reset the board, " + "Enter GDB commands to reset the board " "and to write the nonvolatile memory."); } @@ -364,7 +357,7 @@ QString GdbServerProviderConfigWidget::defaultResetCommandsTooltip() { return QCoreApplication::translate("BareMetal", "Enter GDB commands to reset the hardware. " - "The MCU should be halted after this commands."); + "The MCU should be halted after these commands."); } HostWidget::HostWidget(QWidget *parent) diff --git a/src/plugins/baremetal/gdbserverprovider.h b/src/plugins/baremetal/gdbserverprovider.h index d3d7f5d9454..490348b2d4d 100644 --- a/src/plugins/baremetal/gdbserverprovider.h +++ b/src/plugins/baremetal/gdbserverprovider.h @@ -52,7 +52,6 @@ namespace BareMetal { namespace Internal { class GdbServerProviderConfigWidget; -class GdbServerProviderFactory; class GdbServerProviderManager; class GdbServerProvider diff --git a/src/plugins/baremetal/gdbserverprovidermanager.cpp b/src/plugins/baremetal/gdbserverprovidermanager.cpp index 16f0cbb54c9..5f0e8d88811 100644 --- a/src/plugins/baremetal/gdbserverprovidermanager.cpp +++ b/src/plugins/baremetal/gdbserverprovidermanager.cpp @@ -59,22 +59,14 @@ static Utils::FileName settingsFileName(const QString &path) return Utils::FileName::fromString(settingsLocation.absolutePath() + path); } -static QList<GdbServerProviderFactory *> createFactories() -{ - QList<GdbServerProviderFactory *> result; - result << new DefaultGdbServerProviderFactory - << new OpenOcdGdbServerProviderFactory - << new StLinkUtilGdbServerProviderFactory - ; - return result; -} - -GdbServerProviderManager *GdbServerProviderManager::m_instance = 0; +static GdbServerProviderManager *m_instance = 0; GdbServerProviderManager::GdbServerProviderManager(QObject *parent) : QObject(parent) , m_configFile(settingsFileName(QLatin1String(fileNameKeyC))) - , m_factories(createFactories()) + , m_factories({ new DefaultGdbServerProviderFactory, + new OpenOcdGdbServerProviderFactory, + new StLinkUtilGdbServerProviderFactory }) { m_writer = new Utils::PersistentSettingsWriter( m_configFile, QLatin1String("QtCreatorGdbServerProviders")); @@ -82,12 +74,12 @@ GdbServerProviderManager::GdbServerProviderManager(QObject *parent) connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested, this, &GdbServerProviderManager::saveProviders); - connect(this, SIGNAL(providerAdded(GdbServerProvider*)), - SIGNAL(providersChanged())); - connect(this, SIGNAL(providerRemoved(GdbServerProvider*)), - SIGNAL(providersChanged())); - connect(this, SIGNAL(providerUpdated(GdbServerProvider*)), - SIGNAL(providersChanged())); + connect(this, &GdbServerProviderManager::providerAdded, + this, &GdbServerProviderManager::providersChanged); + connect(this, &GdbServerProviderManager::providerRemoved, + this, &GdbServerProviderManager::providersChanged); + connect(this, &GdbServerProviderManager::providerUpdated, + this, &GdbServerProviderManager::providersChanged); } GdbServerProviderManager::~GdbServerProviderManager() diff --git a/src/plugins/baremetal/gdbserverprovidermanager.h b/src/plugins/baremetal/gdbserverprovidermanager.h index 9de36f21777..e510feed8f1 100644 --- a/src/plugins/baremetal/gdbserverprovidermanager.h +++ b/src/plugins/baremetal/gdbserverprovidermanager.h @@ -59,9 +59,6 @@ public: bool registerProvider(GdbServerProvider *); void deregisterProvider(GdbServerProvider *); -public slots: - void saveProviders(); - signals: void providerAdded(GdbServerProvider *); void providerRemoved(GdbServerProvider *); @@ -70,6 +67,7 @@ signals: void providersLoaded(); private: + void saveProviders(); explicit GdbServerProviderManager(QObject *parent = 0); void restoreProviders(); @@ -80,8 +78,6 @@ private: const Utils::FileName m_configFile; const QList<GdbServerProviderFactory *> m_factories; - static GdbServerProviderManager *m_instance; - friend class BareMetalPlugin; // for constructor friend class GdbServerProvider; }; diff --git a/src/plugins/baremetal/gdbserverproviderssettingspage.cpp b/src/plugins/baremetal/gdbserverproviderssettingspage.cpp index 043cc33c70e..7757bd7a91a 100644 --- a/src/plugins/baremetal/gdbserverproviderssettingspage.cpp +++ b/src/plugins/baremetal/gdbserverproviderssettingspage.cpp @@ -48,62 +48,61 @@ #include <QMenu> #include <QMessageBox> #include <QPushButton> -#include <QSignalMapper> #include <QSpacerItem> #include <QTextStream> #include <QTreeView> #include <QVBoxLayout> +using namespace Utils; + namespace BareMetal { namespace Internal { -class GdbServerProviderNode +class GdbServerProviderNode : public TreeItem { public: - explicit GdbServerProviderNode(GdbServerProviderNode *parent, - GdbServerProvider *provider = 0, - bool changed = false); - ~GdbServerProviderNode(); + GdbServerProviderNode(GdbServerProvider *provider, bool changed = false) + : provider(provider), changed(changed) + { + widget = provider ? provider->configurationWidget() : 0; + } - GdbServerProviderNode *parent; - QList<GdbServerProviderNode *> childNodes; - GdbServerProvider *provider; - GdbServerProviderConfigWidget *widget; - bool changed; -}; + Qt::ItemFlags flags(int) const override + { + return provider ? Qt::ItemIsEnabled|Qt::ItemIsSelectable : Qt::ItemIsEnabled; + } -GdbServerProviderNode::GdbServerProviderNode( - GdbServerProviderNode *parent, - GdbServerProvider *provider, - bool changed) - : parent(parent) - , provider(provider) - , changed(changed) -{ - if (parent) - parent->childNodes.append(this); + QVariant data(int column, int role) const override + { + if (!provider) + return QVariant(); - widget = provider ? provider->configurationWidget() : 0; -} + if (role == Qt::FontRole) { + QFont f = QApplication::font(); + if (changed) + f.setBold(true); + return f; + } -GdbServerProviderNode::~GdbServerProviderNode() -{ - // Do not delete provider, we do not own it. + if (role == Qt::DisplayRole) { + return column == 0 ? provider->displayName() : provider->typeDisplayName(); + } - for (int i = childNodes.size(); --i >= 0; ) { - GdbServerProviderNode *child = childNodes.at(i); - child->parent = 0; - delete child; + // FIXME: Need to handle ToolTipRole role? + return QVariant(); } - if (parent) - parent->childNodes.removeOne(this); -} + GdbServerProvider *provider; + GdbServerProviderConfigWidget *widget; + bool changed; +}; + GdbServerProviderModel::GdbServerProviderModel(QObject *parent) - : QAbstractItemModel(parent) - , m_root(new GdbServerProviderNode(0)) + : TreeModel(parent) { + setHeader({tr("Name"), tr("Type")}); + const GdbServerProviderManager *manager = GdbServerProviderManager::instance(); connect(manager, &GdbServerProviderManager::providerAdded, @@ -115,116 +114,13 @@ GdbServerProviderModel::GdbServerProviderModel(QObject *parent) addProvider(p); } -GdbServerProviderModel::~GdbServerProviderModel() -{ - delete m_root; -} - -QModelIndex GdbServerProviderModel::index( - int row, int column, const QModelIndex &parent) const -{ - if (!parent.isValid()) { - if (row >= 0 && row < m_root->childNodes.count()) - return createIndex(row, column, m_root->childNodes.at(row)); - } - - return QModelIndex(); -} - -QModelIndex GdbServerProviderModel::index( - const QModelIndex &topIdx, const GdbServerProvider *provider) const -{ - const GdbServerProviderNode *current = - topIdx.isValid() ? nodeFromIndex(topIdx) : m_root; - QTC_ASSERT(current, return QModelIndex()); - - if (current->provider == provider) - return topIdx; - - for (int i = 0; i < current->childNodes.count(); ++i) { - const QModelIndex idx = index(index(current->childNodes.at(i)), provider); - if (idx.isValid()) - return idx; - } - return QModelIndex(); -} - -QModelIndex GdbServerProviderModel::parent(const QModelIndex &idx) const -{ - const GdbServerProviderNode *n = nodeFromIndex(idx); - return (n->parent == m_root) ? QModelIndex() : index(n->parent); -} - -int GdbServerProviderModel::rowCount(const QModelIndex &parent) const -{ - if (!parent.isValid()) - return m_root->childNodes.count(); - - const GdbServerProviderNode *n = nodeFromIndex(parent); - return n->childNodes.count(); -} - -int GdbServerProviderModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return ColumnsCount; -} - -QVariant GdbServerProviderModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - const GdbServerProviderNode *n = nodeFromIndex(index); - QTC_ASSERT(n, return QVariant()); - - if (!n->provider) - return QVariant(); - - if (role == Qt::FontRole) { - QFont f = QApplication::font(); - if (n->changed) - f.setBold(true); - return f; - } else if (role == Qt::DisplayRole) { - return (index.column() == NameIndex) - ? n->provider->displayName() - : n->provider->typeDisplayName(); - } - - // FIXME: Need to handle also and ToolTipRole role? - - return QVariant(); -} - -Qt::ItemFlags GdbServerProviderModel::flags(const QModelIndex &index) const -{ - if (!index.isValid()) - return 0; - - const GdbServerProviderNode *n = nodeFromIndex(index); - Q_ASSERT(n); - return (n->provider) ? (Qt::ItemIsEnabled | Qt::ItemIsSelectable) - : Qt::ItemIsEnabled; -} - -QVariant GdbServerProviderModel::headerData( - int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - return section == NameIndex ? tr("Name") : tr("Type"); - return QVariant(); -} - GdbServerProvider *GdbServerProviderModel::provider( const QModelIndex &index) const { if (!index.isValid()) return 0; - const GdbServerProviderNode *n = nodeFromIndex(index); - Q_ASSERT(n); - return n->provider; + return static_cast<GdbServerProviderNode *>(itemForIndex(index))->provider; } GdbServerProviderConfigWidget *GdbServerProviderModel::widget( @@ -233,59 +129,30 @@ GdbServerProviderConfigWidget *GdbServerProviderModel::widget( if (!index.isValid()) return 0; - const GdbServerProviderNode *n = nodeFromIndex(index); - Q_ASSERT(n); - return n->widget; -} - -bool GdbServerProviderModel::isDirty() const -{ - return Utils::anyOf(m_root->childNodes, [](GdbServerProviderNode *n) { - return n->changed; - }); -} - -bool GdbServerProviderModel::isDirty(GdbServerProvider *p) const -{ - return Utils::anyOf(m_root->childNodes, [p](GdbServerProviderNode *n) { - return n->provider == p && n->changed; - }); -} - -void GdbServerProviderModel::setDirty() -{ - const auto w = qobject_cast<GdbServerProviderConfigWidget *>(sender()); - foreach (GdbServerProviderNode *n, m_root->childNodes) { - if (n->widget == w) { - n->changed = true; - emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex()))); - } - } + return static_cast<GdbServerProviderNode *>(itemForIndex(index))->widget; } void GdbServerProviderModel::apply() { // Remove unused providers - foreach (const GdbServerProviderNode *n, m_toRemoveNodes) { - Q_ASSERT(!n->parent); + foreach (TreeItem *item, rootItem()->children()) { + auto n = static_cast<GdbServerProviderNode *>(item); GdbServerProviderManager::instance()->deregisterProvider(n->provider); } - Q_ASSERT(m_toRemoveNodes.isEmpty()); + QTC_CHECK(m_toRemoveNodes.isEmpty()); // Update providers - foreach (GdbServerProviderNode *n, m_root->childNodes) { - Q_ASSERT(n); - + foreach (TreeItem *item, rootItem()->children()) { + auto n = static_cast<GdbServerProviderNode *>(item); if (!n->changed) continue; - Q_ASSERT(n->provider); + QTC_CHECK(n->provider); if (n->widget) n->widget->apply(); n->changed = false; - - emit dataChanged(index(n, 0), index(n, columnCount(QModelIndex()))); + n->update(); } // Add new (and already updated) providers @@ -315,15 +182,27 @@ void GdbServerProviderModel::apply() } } +template <class Container> +GdbServerProviderNode *findNode(const Container &container, const GdbServerProvider *provider) +{ + auto test = [provider](TreeItem *item) { + return static_cast<GdbServerProviderNode *>(item)->provider == provider; + }; + + return static_cast<GdbServerProviderNode *>(Utils::findOrDefault(container, test)); +} + +QModelIndex GdbServerProviderModel::indexForProvider(GdbServerProvider *provider) const +{ + GdbServerProviderNode *n = findNode(rootItem()->children(), provider); + return n ? indexForItem(n) : QModelIndex(); +} + void GdbServerProviderModel::markForRemoval(GdbServerProvider *provider) { - GdbServerProviderNode *n = findNode(m_root->childNodes, provider); + GdbServerProviderNode *n = findNode(rootItem()->children(), provider); QTC_ASSERT(n, return); - - const int row = m_root->childNodes.indexOf(n); - emit beginRemoveRows(index(m_root), row, row); - m_root->childNodes.removeOne(n); - n->parent = 0; + takeItem(n); if (m_toAddNodes.contains(n)) { delete n->provider; @@ -339,68 +218,40 @@ void GdbServerProviderModel::markForRemoval(GdbServerProvider *provider) void GdbServerProviderModel::markForAddition(GdbServerProvider *provider) { - const int pos = m_root->childNodes.size(); - emit beginInsertRows(index(m_root), pos, pos); - GdbServerProviderNode *n = createNode(m_root, provider, true); + GdbServerProviderNode *n = createNode(provider, true); + rootItem()->appendChild(n); m_toAddNodes.append(n); - emit endInsertRows(); -} - -QModelIndex GdbServerProviderModel::index( - GdbServerProviderNode *n, int column) const -{ - if (n == m_root) - return QModelIndex(); - - if (n->parent == m_root) - return index(m_root->childNodes.indexOf(n), column, QModelIndex()); - - return index(n->parent->childNodes.indexOf(n), - column, index(n->parent)); } GdbServerProviderNode *GdbServerProviderModel::createNode( - GdbServerProviderNode *parent, GdbServerProvider *provider, bool changed) { - auto n = new GdbServerProviderNode(parent, provider, changed); + auto n = new GdbServerProviderNode(provider, changed); if (n->widget) { - connect(n->widget, &GdbServerProviderConfigWidget::dirty, - this, &GdbServerProviderModel::setDirty); + connect(n->widget, &GdbServerProviderConfigWidget::dirty, this, [this, n] { + foreach (TreeItem *item, rootItem()->children()) { + auto nn = static_cast<GdbServerProviderNode *>(item); + if (nn->widget == n->widget) { + nn->changed = true; + nn->update(); + } + } + }); } return n; } -GdbServerProviderNode *GdbServerProviderModel::nodeFromIndex( - const QModelIndex &index) const -{ - return static_cast<GdbServerProviderNode *>(index.internalPointer()); -} - -GdbServerProviderNode *GdbServerProviderModel::findNode( - const QList<GdbServerProviderNode *> &container, - const GdbServerProvider *provider) -{ - return Utils::findOrDefault(container, [provider](GdbServerProviderNode *n) { - return n->provider == provider; - }); -} - void GdbServerProviderModel::addProvider(GdbServerProvider *provider) { - GdbServerProviderNode *n = findNode(m_toAddNodes, provider); - if (n) { - m_toAddNodes.removeOne(n); - // do not delete n: Still used elsewhere! - return; + foreach (TreeItem *item, rootItem()->children()) { + auto n = static_cast<GdbServerProviderNode *>(item); + if (n->provider == provider) { + m_toAddNodes.removeOne(n); + // do not delete n: Still used elsewhere! + return; + } } - - const int row = m_root->childNodes.count(); - - beginInsertRows(index(m_root), row, row); - createNode(m_root, provider, false); - endInsertRows(); - + rootItem()->appendChild(createNode(provider, false)); emit providerStateChanged(); } @@ -413,136 +264,111 @@ void GdbServerProviderModel::removeProvider(GdbServerProvider *provider) return; } - int row = 0; - foreach (GdbServerProviderNode *current, m_root->childNodes) { - if (current->provider == provider) { - n = current; - break; - } - ++row; - } - - beginRemoveRows(index(m_root), row, row); - m_root->childNodes.removeAt(row); + n = findNode(rootItem()->children(), provider); + takeItem(n); delete n; - endRemoveRows(); emit providerStateChanged(); } -GdbServerProvidersSettingsPage::GdbServerProvidersSettingsPage( - QObject *parent) - : Core::IOptionsPage(parent) +class GdbServerProvidersSettingsWidget : public QWidget { - setCategory(Constants::BAREMETAL_SETTINGS_CATEGORY); + Q_DECLARE_TR_FUNCTIONS(BareMetal::Internal::GdbServerProvidersSettingsPage) - setDisplayCategory(QCoreApplication::translate( - "BareMetal", Constants::BAREMETAL_SETTINGS_TR_CATEGORY)); +public: + GdbServerProvidersSettingsWidget(GdbServerProvidersSettingsPage *page); - setCategoryIcon(QLatin1String(Constants::BAREMETAL_SETTINGS_CATEGORY_ICON)); + void providerSelectionChanged(); + void removeProvider(); + void updateState(); - setId(Constants::GDB_PROVIDERS_SETTINGS_ID); - setDisplayName(tr("GDB Server Providers")); -} + void createProvider(GdbServerProviderFactory *f); + QModelIndex currentIndex() const; -QWidget *GdbServerProvidersSettingsPage::widget() +public: + GdbServerProvidersSettingsPage *m_page; + GdbServerProviderModel m_model; + QItemSelectionModel *m_selectionModel; + QTreeView *m_providerView; + Utils::DetailsWidget *m_container; + QPushButton *m_addButton; + QPushButton *m_cloneButton; + QPushButton *m_delButton; +}; + +GdbServerProvidersSettingsWidget::GdbServerProvidersSettingsWidget + (GdbServerProvidersSettingsPage *page) + : m_page(page) { - if (!m_configWidget) { - // Actual page setup: - m_configWidget = new QWidget; - - m_providerView = new QTreeView(m_configWidget); - m_providerView->setUniformRowHeights(true); - m_providerView->header()->setStretchLastSection(false); - - m_addButton = new QPushButton(tr("Add"), m_configWidget); - m_cloneButton = new QPushButton(tr("Clone"), m_configWidget); - m_delButton = new QPushButton(tr("Remove"), m_configWidget); - - m_container = new Utils::DetailsWidget(m_configWidget); - m_container->setState(Utils::DetailsWidget::NoSummary); - m_container->setMinimumWidth(500); - m_container->setVisible(false); - - auto buttonLayout = new QHBoxLayout(); - buttonLayout->setSpacing(6); - buttonLayout->setContentsMargins(0, 0, 0, 0); - buttonLayout->addWidget(m_addButton); - buttonLayout->addWidget(m_cloneButton); - buttonLayout->addWidget(m_delButton); - auto spacerItem = new QSpacerItem(40, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); - buttonLayout->addItem(spacerItem); - - auto verticalLayout = new QVBoxLayout(); - verticalLayout->addWidget(m_providerView); - verticalLayout->addLayout(buttonLayout); - - auto horizontalLayout = new QHBoxLayout(m_configWidget); - horizontalLayout->addLayout(verticalLayout); - horizontalLayout->addWidget(m_container); - Q_ASSERT(!m_model); - m_model = new GdbServerProviderModel(m_configWidget); - - connect(m_model.data(), &GdbServerProviderModel::providerStateChanged, - this, &GdbServerProvidersSettingsPage::updateState); - - m_providerView->setModel(m_model); - - auto headerView = m_providerView->header(); - headerView->setSectionResizeMode(0, QHeaderView::ResizeToContents); - headerView->setSectionResizeMode(1, QHeaderView::Stretch); - m_providerView->expandAll(); - - m_selectionModel = m_providerView->selectionModel(); - - connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), - SLOT(providerSelectionChanged())); - - connect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged, - this, &GdbServerProvidersSettingsPage::providerSelectionChanged); - - // Set up add menu: - auto addMenu = new QMenu(m_addButton); - auto mapper = new QSignalMapper(addMenu); - connect(mapper, SIGNAL(mapped(QObject*)), SLOT(createProvider(QObject*))); - - foreach (const auto f, GdbServerProviderManager::instance()->factories()) { - auto action = new QAction(addMenu); - action->setText(f->displayName()); - connect(action, SIGNAL(triggered()), mapper, SLOT(map())); - mapper->setMapping(action, static_cast<QObject *>(f)); - addMenu->addAction(action); - } + m_providerView = new QTreeView(this); + m_providerView->setUniformRowHeights(true); + m_providerView->header()->setStretchLastSection(false); + + m_addButton = new QPushButton(tr("Add"), this); + m_cloneButton = new QPushButton(tr("Clone"), this); + m_delButton = new QPushButton(tr("Remove"), this); + + m_container = new Utils::DetailsWidget(this); + m_container->setState(Utils::DetailsWidget::NoSummary); + m_container->setMinimumWidth(500); + m_container->setVisible(false); + + auto buttonLayout = new QHBoxLayout(); + buttonLayout->setSpacing(6); + buttonLayout->setContentsMargins(0, 0, 0, 0); + buttonLayout->addWidget(m_addButton); + buttonLayout->addWidget(m_cloneButton); + buttonLayout->addWidget(m_delButton); + auto spacerItem = new QSpacerItem(40, 10, QSizePolicy::Expanding, QSizePolicy::Minimum); + buttonLayout->addItem(spacerItem); - connect(m_cloneButton, SIGNAL(clicked()), mapper, SLOT(map())); - mapper->setMapping(m_cloneButton, static_cast<QObject *>(0)); + auto verticalLayout = new QVBoxLayout(); + verticalLayout->addWidget(m_providerView); + verticalLayout->addLayout(buttonLayout); - m_addButton->setMenu(addMenu); + auto horizontalLayout = new QHBoxLayout(this); + horizontalLayout->addLayout(verticalLayout); + horizontalLayout->addWidget(m_container); - connect(m_delButton.data(), &QPushButton::clicked, - this, &GdbServerProvidersSettingsPage::removeProvider); + connect(&m_model, &GdbServerProviderModel::providerStateChanged, + this, &GdbServerProvidersSettingsWidget::updateState); - updateState(); + m_providerView->setModel(&m_model); + + auto headerView = m_providerView->header(); + headerView->setSectionResizeMode(0, QHeaderView::ResizeToContents); + headerView->setSectionResizeMode(1, QHeaderView::Stretch); + m_providerView->expandAll(); + + m_selectionModel = m_providerView->selectionModel(); + + connect(m_selectionModel, &QItemSelectionModel::selectionChanged, + this, &GdbServerProvidersSettingsWidget::providerSelectionChanged); + + connect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged, + this, &GdbServerProvidersSettingsWidget::providerSelectionChanged); + + // Set up add menu: + auto addMenu = new QMenu(m_addButton); + + foreach (const auto f, GdbServerProviderManager::instance()->factories()) { + auto action = new QAction(addMenu); + action->setText(f->displayName()); + connect(action, &QAction::triggered, this, [this, f] { createProvider(f); }); + addMenu->addAction(action); } - return m_configWidget; -} + connect(m_cloneButton, &QAbstractButton::clicked, this, [this] { createProvider(0); }); -void GdbServerProvidersSettingsPage::apply() -{ - if (m_model) - m_model->apply(); -} + m_addButton->setMenu(addMenu); -void GdbServerProvidersSettingsPage::finish() -{ - disconnect(GdbServerProviderManager::instance(), SIGNAL(providersChanged()), - this, SLOT(providerSelectionChanged())); + connect(m_delButton, &QPushButton::clicked, + this, &GdbServerProvidersSettingsWidget::removeProvider); - delete m_configWidget; + updateState(); } -void GdbServerProvidersSettingsPage::providerSelectionChanged() +void GdbServerProvidersSettingsWidget::providerSelectionChanged() { if (!m_container) return; @@ -550,54 +376,49 @@ void GdbServerProvidersSettingsPage::providerSelectionChanged() QWidget *w = m_container->takeWidget(); // Prevent deletion. if (w) w->setVisible(false); - w = current.isValid() ? m_model->widget(current) : 0; + w = current.isValid() ? m_model.widget(current) : 0; m_container->setWidget(w); m_container->setVisible(w != 0); updateState(); } -void GdbServerProvidersSettingsPage::createProvider(QObject *factoryObject) +void GdbServerProvidersSettingsWidget::createProvider(GdbServerProviderFactory *f) { GdbServerProvider *provider = 0; - - auto f = static_cast<GdbServerProviderFactory *>(factoryObject); if (!f) { - GdbServerProvider *old = m_model->provider(currentIndex()); + GdbServerProvider *old = m_model.provider(currentIndex()); if (!old) return; provider = old->clone(); } else { provider = f->create(); - } if (!provider) { - return; } - m_model->markForAddition(provider); + if (!provider) + return; + + m_model.markForAddition(provider); - const QModelIndex newIdx = m_model->index(QModelIndex(), provider); - m_selectionModel->select(newIdx, + m_selectionModel->select(m_model.indexForProvider(provider), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); } -void GdbServerProvidersSettingsPage::removeProvider() +void GdbServerProvidersSettingsWidget::removeProvider() { - GdbServerProvider *p = m_model->provider(currentIndex()); - if (!p) - return; - m_model->markForRemoval(p); + if (GdbServerProvider *p = m_model.provider(currentIndex())) + m_model.markForRemoval(p); } -void GdbServerProvidersSettingsPage::updateState() +void GdbServerProvidersSettingsWidget::updateState() { if (!m_cloneButton) return; bool canCopy = false; bool canDelete = false; - const GdbServerProvider *p = m_model->provider(currentIndex()); - if (p) { + if (const GdbServerProvider *p = m_model.provider(currentIndex())) { canCopy = p->isValid(); canDelete = true; } @@ -606,7 +427,7 @@ void GdbServerProvidersSettingsPage::updateState() m_delButton->setEnabled(canDelete); } -QModelIndex GdbServerProvidersSettingsPage::currentIndex() const +QModelIndex GdbServerProvidersSettingsWidget::currentIndex() const { if (!m_selectionModel) return QModelIndex(); @@ -617,5 +438,39 @@ QModelIndex GdbServerProvidersSettingsPage::currentIndex() const return rows.at(0); } + +GdbServerProvidersSettingsPage::GdbServerProvidersSettingsPage(QObject *parent) + : Core::IOptionsPage(parent) +{ + setCategory(Constants::BAREMETAL_SETTINGS_CATEGORY); + setDisplayCategory(QCoreApplication::translate( + "BareMetal", Constants::BAREMETAL_SETTINGS_TR_CATEGORY)); + setCategoryIcon(QLatin1String(Constants::BAREMETAL_SETTINGS_CATEGORY_ICON)); + setId(Constants::GDB_PROVIDERS_SETTINGS_ID); + setDisplayName(tr("GDB Server Providers")); +} + +QWidget *GdbServerProvidersSettingsPage::widget() +{ + if (!m_configWidget) + m_configWidget = new GdbServerProvidersSettingsWidget(this); + return m_configWidget; +} + +void GdbServerProvidersSettingsPage::apply() +{ + if (m_configWidget) + m_configWidget->m_model.apply(); +} + +void GdbServerProvidersSettingsPage::finish() +{ + if (m_configWidget) + disconnect(GdbServerProviderManager::instance(), &GdbServerProviderManager::providersChanged, + m_configWidget.data(), &GdbServerProvidersSettingsWidget::providerSelectionChanged); + + delete m_configWidget.data(); +} + } // namespace Internal } // namespace BareMetal diff --git a/src/plugins/baremetal/gdbserverproviderssettingspage.h b/src/plugins/baremetal/gdbserverproviderssettingspage.h index cb912e8ed39..f9c825d9703 100644 --- a/src/plugins/baremetal/gdbserverproviderssettingspage.h +++ b/src/plugins/baremetal/gdbserverproviderssettingspage.h @@ -33,7 +33,8 @@ #include <coreplugin/dialogs/ioptionspage.h> -#include <QAbstractItemModel> +#include <utils/treemodel.h> + #include <QPointer> QT_BEGIN_NAMESPACE @@ -49,36 +50,20 @@ namespace Internal { class GdbServerProvider; class GdbServerProviderConfigWidget; +class GdbServerProviderFactory; class GdbServerProviderNode; +class GdbServerProvidersSettingsWidget; -class GdbServerProviderModel : public QAbstractItemModel +class GdbServerProviderModel : public Utils::TreeModel { Q_OBJECT public: explicit GdbServerProviderModel(QObject *parent = 0); - ~GdbServerProviderModel(); - - QModelIndex index(int row, int column, - const QModelIndex &parent = QModelIndex()) const; - - QModelIndex index(const QModelIndex &topIdx, const GdbServerProvider *) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - - QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; GdbServerProvider *provider(const QModelIndex &) const; - GdbServerProviderConfigWidget *widget(const QModelIndex &) const; - - bool isDirty() const; - bool isDirty(GdbServerProvider *) const; + QModelIndex indexForProvider(GdbServerProvider *provider) const; void apply(); @@ -88,26 +73,12 @@ public: signals: void providerStateChanged(); -private slots: +private: void addProvider(GdbServerProvider *); void removeProvider(GdbServerProvider *); - void setDirty(); - -private: - enum ColumnIndex { NameIndex = 0, TypeIndex, ColumnsCount }; - - QModelIndex index(GdbServerProviderNode *, int column = 0) const; - - GdbServerProviderNode *createNode(GdbServerProviderNode *parent, - GdbServerProvider *, bool changed); - GdbServerProviderNode *nodeFromIndex(const QModelIndex &) const; + GdbServerProviderNode *createNode(GdbServerProvider *, bool changed); - static GdbServerProviderNode *findNode( - const QList<GdbServerProviderNode *> &container, - const GdbServerProvider *); - - GdbServerProviderNode *m_root; QList<GdbServerProviderNode *> m_toAddNodes; QList<GdbServerProviderNode *> m_toRemoveNodes; }; @@ -119,28 +90,12 @@ class GdbServerProvidersSettingsPage : public Core::IOptionsPage public: explicit GdbServerProvidersSettingsPage(QObject *parent = 0); +private: QWidget *widget(); void apply(); void finish(); -private slots: - void providerSelectionChanged(); - void createProvider(QObject *); - void removeProvider(); - void updateState(); - -private: - QModelIndex currentIndex() const; - - QPointer<QWidget> m_configWidget; - - QPointer<GdbServerProviderModel> m_model; - QPointer<QItemSelectionModel> m_selectionModel; - QPointer<QTreeView> m_providerView; - QPointer<Utils::DetailsWidget> m_container; - QPointer<QPushButton> m_addButton; - QPointer<QPushButton> m_cloneButton; - QPointer<QPushButton> m_delButton; + QPointer<GdbServerProvidersSettingsWidget> m_configWidget; }; } // namespace Internal diff --git a/src/plugins/bazaar/bazaar.pro b/src/plugins/bazaar/bazaar.pro index f3a266221b4..cbb7f4429b2 100644 --- a/src/plugins/bazaar/bazaar.pro +++ b/src/plugins/bazaar/bazaar.pro @@ -11,9 +11,6 @@ SOURCES += \ annotationhighlighter.cpp \ pullorpushdialog.cpp \ branchinfo.cpp \ - clonewizardpage.cpp \ - clonewizard.cpp \ - cloneoptionspanel.cpp \ uncommitdialog.cpp HEADERS += \ bazaarclient.h \ @@ -28,15 +25,10 @@ HEADERS += \ annotationhighlighter.h \ pullorpushdialog.h \ branchinfo.h \ - clonewizard.h \ - clonewizardpage.h \ - cloneoptionspanel.h \ uncommitdialog.h FORMS += \ optionspage.ui \ revertdialog.ui \ bazaarcommitpanel.ui \ pullorpushdialog.ui \ - cloneoptionspanel.ui \ uncommitdialog.ui -RESOURCES += bazaar.qrc diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs index 45a59be37ce..06e0c27a534 100644 --- a/src/plugins/bazaar/bazaar.qbs +++ b/src/plugins/bazaar/bazaar.qbs @@ -13,7 +13,6 @@ QtcPlugin { files: [ "annotationhighlighter.cpp", "annotationhighlighter.h", - "bazaar.qrc", "bazaarclient.cpp", "bazaarclient.h", "bazaarcommitpanel.ui", @@ -29,13 +28,6 @@ QtcPlugin { "bazaarsettings.h", "branchinfo.cpp", "branchinfo.h", - "cloneoptionspanel.cpp", - "cloneoptionspanel.h", - "cloneoptionspanel.ui", - "clonewizard.cpp", - "clonewizard.h", - "clonewizardpage.cpp", - "clonewizardpage.h", "commiteditor.cpp", "commiteditor.h", "constants.h", @@ -49,7 +41,6 @@ QtcPlugin { "uncommitdialog.cpp", "uncommitdialog.h", "uncommitdialog.ui", - "images/bazaar.png", ] } diff --git a/src/plugins/bazaar/bazaar.qrc b/src/plugins/bazaar/bazaar.qrc deleted file mode 100644 index a10bfb31948..00000000000 --- a/src/plugins/bazaar/bazaar.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/bazaar" > - <file>images/bazaar.png</file> - </qresource> -</RCC> diff --git a/src/plugins/bazaar/bazaarclient.cpp b/src/plugins/bazaar/bazaarclient.cpp index 70f94c7bdb5..9cf40be7f79 100644 --- a/src/plugins/bazaar/bazaarclient.cpp +++ b/src/plugins/bazaar/bazaarclient.cpp @@ -68,13 +68,13 @@ class BazaarDiffParameterWidget : public VcsBaseEditorParameterWidget { Q_OBJECT public: - BazaarDiffParameterWidget(BazaarSettings *settings, QWidget *parent = 0) : + BazaarDiffParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")), - settings->boolPointer(BazaarSettings::diffIgnoreWhiteSpaceKey)); + settings.boolPointer(BazaarSettings::diffIgnoreWhiteSpaceKey)); mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")), - settings->boolPointer(BazaarSettings::diffIgnoreBlankLinesKey)); + settings.boolPointer(BazaarSettings::diffIgnoreBlankLinesKey)); } QStringList arguments() const @@ -95,47 +95,41 @@ class BazaarLogParameterWidget : public VcsBaseEditorParameterWidget { Q_OBJECT public: - BazaarLogParameterWidget(BazaarSettings *settings, QWidget *parent = 0) : + BazaarLogParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { mapSetting(addToggleButton(QLatin1String("--verbose"), tr("Verbose"), - tr("Show files changed in each revision")), - settings->boolPointer(BazaarSettings::logVerboseKey)); + tr("Show files changed in each revision.")), + settings.boolPointer(BazaarSettings::logVerboseKey)); mapSetting(addToggleButton(QLatin1String("--forward"), tr("Forward"), - tr("Show from oldest to newest")), - settings->boolPointer(BazaarSettings::logForwardKey)); - mapSetting(addToggleButton(QLatin1String("--include-merges"), tr("Include merges"), - tr("Show merged revisions")), - settings->boolPointer(BazaarSettings::logIncludeMergesKey)); + tr("Show from oldest to newest.")), + settings.boolPointer(BazaarSettings::logForwardKey)); + mapSetting(addToggleButton(QLatin1String("--include-merges"), tr("Include Merges"), + tr("Show merged revisions.")), + settings.boolPointer(BazaarSettings::logIncludeMergesKey)); QList<ComboBoxItem> logChoices; logChoices << ComboBoxItem(tr("Detailed"), QLatin1String("long")) - << ComboBoxItem(tr("Moderately short"), QLatin1String("short")) - << ComboBoxItem(tr("One line"), QLatin1String("line")) - << ComboBoxItem(tr("GNU ChangeLog"), QLatin1String("gnu-changelog")); + << ComboBoxItem(tr("Moderately Short"), QLatin1String("short")) + << ComboBoxItem(tr("One Line"), QLatin1String("line")) + << ComboBoxItem(tr("GNU Change Log"), QLatin1String("gnu-changelog")); mapSetting(addComboBox(QStringList(QLatin1String("--log-format=%1")), logChoices), - settings->stringPointer(BazaarSettings::logFormatKey)); + settings.stringPointer(BazaarSettings::logFormatKey)); } }; -BazaarClient::BazaarClient(BazaarSettings *settings) : - VcsBaseClient(settings) +BazaarClient::BazaarClient() : VcsBaseClient(new BazaarSettings) { - setDiffParameterWidgetCreator([=] { return new BazaarDiffParameterWidget(settings); }); - setLogParameterWidgetCreator([=] { return new BazaarLogParameterWidget(settings); }); -} - -BazaarSettings *BazaarClient::settings() const -{ - return dynamic_cast<BazaarSettings *>(VcsBaseClient::settings()); + setDiffParameterWidgetCreator([this] { return new BazaarDiffParameterWidget(settings()); }); + setLogParameterWidgetCreator([this] { return new BazaarLogParameterWidget(settings()); }); } bool BazaarClient::synchronousSetUserId() { QStringList args; args << QLatin1String("whoami") - << (settings()->stringValue(BazaarSettings::userNameKey) + QLatin1String(" <") - + settings()->stringValue(BazaarSettings::userEmailKey) + QLatin1Char('>')); + << (settings().stringValue(BazaarSettings::userNameKey) + QLatin1String(" <") + + settings().stringValue(BazaarSettings::userEmailKey) + QLatin1Char('>')); QByteArray stdOut; return vcsFullySynchronousExec(QDir::currentPath(), args, &stdOut); } @@ -278,7 +272,7 @@ BazaarClient::StatusItem BazaarClient::parseStatusLine(const QString &line) cons else if (flagVersion == QLatin1Char('-')) item.flags = QLatin1String("Unversioned"); else if (flagVersion == QLatin1Char('R')) - item.flags = QLatin1String("Renamed"); + item.flags = QLatin1String(Constants::FSTATUS_RENAMED); else if (flagVersion == QLatin1Char('?')) item.flags = QLatin1String("Unknown"); else if (flagVersion == QLatin1Char('X')) @@ -292,13 +286,13 @@ BazaarClient::StatusItem BazaarClient::parseStatusLine(const QString &line) cons if (lineLength >= 2) { const QChar flagContents = line[1]; if (flagContents == QLatin1Char('N')) - item.flags = QLatin1String("Created"); + item.flags = QLatin1String(Constants::FSTATUS_CREATED); else if (flagContents == QLatin1Char('D')) - item.flags = QLatin1String("Deleted"); + item.flags = QLatin1String(Constants::FSTATUS_DELETED); else if (flagContents == QLatin1Char('K')) item.flags = QLatin1String("KindChanged"); else if (flagContents == QLatin1Char('M')) - item.flags = QLatin1String("Modified"); + item.flags = QLatin1String(Constants::FSTATUS_MODIFIED); } if (lineLength >= 3) { const QChar flagExec = line[2]; diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h index acee6ba1f43..42005bd1662 100644 --- a/src/plugins/bazaar/bazaarclient.h +++ b/src/plugins/bazaar/bazaarclient.h @@ -38,15 +38,14 @@ namespace Bazaar { namespace Internal { class BazaarSettings; +class BazaarControl; class BazaarClient : public VcsBase::VcsBaseClient { Q_OBJECT public: - BazaarClient(BazaarSettings *settings); - - BazaarSettings *settings() const; + BazaarClient(); bool synchronousSetUserId(); BranchInfo synchronousBranchQuery(const QString &repositoryRoot) const; @@ -72,6 +71,7 @@ protected: private: friend class CloneWizard; + friend class BazaarControl; }; } // namespace Internal diff --git a/src/plugins/bazaar/bazaarcontrol.cpp b/src/plugins/bazaar/bazaarcontrol.cpp index c74ba8f0f93..54f098e6825 100644 --- a/src/plugins/bazaar/bazaarcontrol.cpp +++ b/src/plugins/bazaar/bazaarcontrol.cpp @@ -29,8 +29,11 @@ ****************************************************************************/ #include "bazaarcontrol.h" #include "bazaarclient.h" +#include "bazaarplugin.h" +#include <vcsbase/vcsbaseclientsettings.h> #include <vcsbase/vcsbaseconstants.h> +#include <vcsbase/vcscommand.h> #include <utils/fileutils.h> @@ -71,7 +74,7 @@ bool BazaarControl::managesFile(const QString &workingDirectory, const QString & bool BazaarControl::isConfigured() const { - const Utils::FileName binary = m_bazaarClient->settings()->binaryPath(); + const Utils::FileName binary = m_bazaarClient->vcsBinary(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -88,6 +91,7 @@ bool BazaarControl::supportsOperation(Operation operation) const case Core::IVersionControl::MoveOperation: case Core::IVersionControl::CreateRepositoryOperation: case Core::IVersionControl::AnnotateOperation: + case Core::IVersionControl::InitialCheckoutOperation: break; case Core::IVersionControl::SnapshotOperations: supported = false; @@ -135,6 +139,22 @@ bool BazaarControl::vcsAnnotate(const QString &file, int line) return true; } +Core::ShellCommand *BazaarControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + QStringList args; + args << m_bazaarClient->vcsCommandString(BazaarClient::CloneCommand) + << extraArgs << url << localName; + + QProcessEnvironment env = m_bazaarClient->processEnvironment(); + env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text")); + auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env); + command->addJob(m_bazaarClient->vcsBinary(), args, -1); + return command; +} + void BazaarControl::changed(const QVariant &v) { switch (v.type()) { @@ -148,8 +168,3 @@ void BazaarControl::changed(const QVariant &v) break; } } - -void BazaarControl::emitConfigurationChanged() -{ - emit configurationChanged(); -} diff --git a/src/plugins/bazaar/bazaarcontrol.h b/src/plugins/bazaar/bazaarcontrol.h index 0313e4fb879..f55ad73ca39 100644 --- a/src/plugins/bazaar/bazaarcontrol.h +++ b/src/plugins/bazaar/bazaarcontrol.h @@ -50,26 +50,30 @@ class BazaarControl: public Core::IVersionControl public: explicit BazaarControl(BazaarClient *bazaarClient); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &filename, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - bool vcsOpen(const QString &fileName); - bool vcsAdd(const QString &filename); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); - bool vcsAnnotate(const QString &file, int line); + bool managesDirectory(const QString &filename, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + bool vcsOpen(const QString &fileName) override; + bool vcsAdd(const QString &filename) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; + bool vcsAnnotate(const QString &file, int line) override; + + Core::ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) override; public slots: // To be connected to the VCSTask's success signal to emit the repository/ // files changed signals according to the variant's type: // String -> repository, StringList -> files void changed(const QVariant &); - void emitConfigurationChanged(); private: BazaarClient *m_bazaarClient; diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index 3d578557d6c..a41ce6856a3 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -38,7 +38,6 @@ #include "pullorpushdialog.h" #include "uncommitdialog.h" #include "commiteditor.h" -#include "clonewizard.h" #include "ui_revertdialog.h" @@ -165,15 +164,13 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag Context context(Constants::BAZAAR_CONTEXT); - m_client = new BazaarClient(&m_bazaarSettings); + m_client = new BazaarClient; auto vcsCtrl = new BazaarControl(m_client); initializeVcs(vcsCtrl, context); - - addAutoReleasedObject(new OptionsPage); - m_bazaarSettings.readSettings(ICore::settings()); - connect(m_client, &VcsBaseClient::changed, vcsCtrl, &BazaarControl::changed); + addAutoReleasedObject(new OptionsPage(vcsCtrl)); + static const char *describeSlot = SLOT(view(QString,QString)); const int editorCount = sizeof(editorParameters) / sizeof(VcsBaseEditorParameters); const auto widgetCreator = []() { return new BazaarEditorWidget; }; @@ -183,16 +180,6 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters, []() { return new CommitEditor(&submitEditorParameters); })); - auto cloneWizardFactory = new BaseCheckoutWizardFactory; - cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_BAZAAR)); - cloneWizardFactory->setIcon(QIcon(QLatin1String(":/bazaar/images/bazaar.png"))); - cloneWizardFactory->setDescription(tr("Clones a Bazaar branch and tries to load the contained project.")); - cloneWizardFactory->setDisplayName(tr("Bazaar Clone (Or Branch)")); - cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CloneWizard(path, parent); - }); - addAutoReleasedObject(cloneWizardFactory); - const QString prefix = QLatin1String("bzr"); m_commandLocator = new CommandLocator("Bazaar", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -214,22 +201,6 @@ BazaarClient *BazaarPlugin::client() const return m_client; } -const BazaarSettings &BazaarPlugin::settings() const -{ - return m_bazaarSettings; -} - -void BazaarPlugin::setSettings(const BazaarSettings &settings) -{ - if (settings != m_bazaarSettings) { - const bool userIdChanged = !m_bazaarSettings.sameUserId(settings); - m_bazaarSettings = settings; - if (userIdChanged) - client()->synchronousSetUserId(); - static_cast<BazaarControl *>(versionControl())->emitConfigurationChanged(); - } -} - void BazaarPlugin::createMenu(const Context &context) { // Create menu item for Bazaar @@ -402,7 +373,7 @@ void BazaarPlugin::logRepository() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); QStringList extraOptions; - extraOptions += QLatin1String("--limit=") + QString::number(settings().intValue(BazaarSettings::logCountKey)); + extraOptions += QLatin1String("--limit=") + QString::number(m_client->settings().intValue(BazaarSettings::logCountKey)); m_client->log(state.topLevel(), QStringList(), extraOptions); } @@ -606,9 +577,10 @@ void BazaarPlugin::showCommitWidget(const QList<VcsBaseClient::StatusItem> &stat commitEditor->document()->setPreferredDisplayName(msg); const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository); + const VcsBaseClientSettings &s = m_client->settings(); commitEditor->setFields(m_submitRepository, branch, - m_bazaarSettings.stringValue(BazaarSettings::userNameKey), - m_bazaarSettings.stringValue(BazaarSettings::userEmailKey), status); + s.stringValue(BazaarSettings::userNameKey), + s.stringValue(BazaarSettings::userEmailKey), status); } void BazaarPlugin::diffFromEditorSelected(const QStringList &files) diff --git a/src/plugins/bazaar/bazaarplugin.h b/src/plugins/bazaar/bazaarplugin.h index 8701264b14a..20b62f55f04 100644 --- a/src/plugins/bazaar/bazaarplugin.h +++ b/src/plugins/bazaar/bazaarplugin.h @@ -70,9 +70,6 @@ public: static BazaarPlugin *instance(); BazaarClient *client() const; - const BazaarSettings &settings() const; - void setSettings(const BazaarSettings &settings); - private slots: // File menu action slots void addCurrentFile(); diff --git a/src/plugins/bazaar/cloneoptionspanel.cpp b/src/plugins/bazaar/cloneoptionspanel.cpp deleted file mode 100644 index 98a7b35afd0..00000000000 --- a/src/plugins/bazaar/cloneoptionspanel.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#include "cloneoptionspanel.h" -#include "ui_cloneoptionspanel.h" - -#include <QDebug> - -namespace Bazaar { -namespace Internal { - -CloneOptionsPanel::CloneOptionsPanel(QWidget *parent) - : QWidget(parent), - m_ui(new Ui::CloneOptionsPanel) -{ - m_ui->setupUi(this); -} - -CloneOptionsPanel::~CloneOptionsPanel() -{ - delete m_ui; -} - -bool CloneOptionsPanel::isUseExistingDirectoryOptionEnabled() const -{ - return m_ui->useExistingDirCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isStackedOptionEnabled() const -{ - return m_ui->stackedCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isStandAloneOptionEnabled() const -{ - return m_ui->standAloneCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isBindOptionEnabled() const -{ - return m_ui->bindCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isSwitchOptionEnabled() const -{ - return m_ui->switchCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isHardLinkOptionEnabled() const -{ - return m_ui->hardlinkCheckBox->isChecked(); -} - -bool CloneOptionsPanel::isNoTreeOptionEnabled() const -{ - return m_ui->noTreeCheckBox->isChecked(); -} - -QString CloneOptionsPanel::revision() const -{ - return m_ui->revisionLineEdit->text().simplified(); -} - -} // namespace Internal -} // namespace Bazaar diff --git a/src/plugins/bazaar/cloneoptionspanel.h b/src/plugins/bazaar/cloneoptionspanel.h deleted file mode 100644 index b19faacb282..00000000000 --- a/src/plugins/bazaar/cloneoptionspanel.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#ifndef CLONEOPTIONSPANEL_H -#define CLONEOPTIONSPANEL_H - -#include <QWidget> - -namespace Bazaar { -namespace Internal { - -namespace Ui { class CloneOptionsPanel; } - -class CloneOptionsPanel : public QWidget -{ - Q_OBJECT - -public: - CloneOptionsPanel(QWidget *parent = 0); - ~CloneOptionsPanel(); - - bool isUseExistingDirectoryOptionEnabled() const; - bool isStackedOptionEnabled() const; - bool isStandAloneOptionEnabled() const; - bool isBindOptionEnabled() const; - bool isSwitchOptionEnabled() const; - bool isHardLinkOptionEnabled() const; - bool isNoTreeOptionEnabled() const; - QString revision() const; - -private: - Ui::CloneOptionsPanel *m_ui; -}; - -} // namespace Internal -} // namespace Bazaar - -#endif // CLONEOPTIONSPANEL_H diff --git a/src/plugins/bazaar/cloneoptionspanel.ui b/src/plugins/bazaar/cloneoptionspanel.ui deleted file mode 100644 index 4a9e6ea712f..00000000000 --- a/src/plugins/bazaar/cloneoptionspanel.ui +++ /dev/null @@ -1,137 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Bazaar::Internal::CloneOptionsPanel</class> - <widget class="QWidget" name="Bazaar::Internal::CloneOptionsPanel"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>283</width> - <height>278</height> - </rect> - </property> - <property name="windowTitle"> - <string notr="true"/> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="optionsGroupBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="title"> - <string>Options</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QCheckBox" name="useExistingDirCheckBox"> - <property name="toolTip"> - <string>By default, branch will fail if the target directory exists, but does not already have a control directory. -This flag will allow branch to proceed.</string> - </property> - <property name="text"> - <string>Use existing directory</string> - </property> - </widget> - </item> - <item row="1" column="0" colspan="2"> - <widget class="QCheckBox" name="stackedCheckBox"> - <property name="toolTip"> - <string>Creates a stacked branch referring to the source branch. -The new branch will depend on the availability of the source branch for all operations.</string> - </property> - <property name="text"> - <string>Stacked</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QCheckBox" name="standAloneCheckBox"> - <property name="toolTip"> - <string>Does not use a shared repository, even if available.</string> - </property> - <property name="text"> - <string>Standalone</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QCheckBox" name="bindCheckBox"> - <property name="text"> - <string>Bind new branch to source location</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QCheckBox" name="switchCheckBox"> - <property name="toolTip"> - <string>Switches the checkout in the current directory to the new branch.</string> - </property> - <property name="text"> - <string>Switch checkout</string> - </property> - </widget> - </item> - <item row="5" column="0" colspan="2"> - <widget class="QCheckBox" name="hardlinkCheckBox"> - <property name="toolTip"> - <string>Hard-links working tree files where possible.</string> - </property> - <property name="text"> - <string>Hardlink</string> - </property> - </widget> - </item> - <item row="6" column="0" colspan="2"> - <widget class="QCheckBox" name="noTreeCheckBox"> - <property name="toolTip"> - <string>Creates a branch without a working-tree.</string> - </property> - <property name="text"> - <string>No working-tree</string> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Revision:</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <widget class="QLineEdit" name="revisionLineEdit"/> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>4</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/bazaar/clonewizard.cpp b/src/plugins/bazaar/clonewizard.cpp deleted file mode 100644 index 29a743927d7..00000000000 --- a/src/plugins/bazaar/clonewizard.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizard.h" -#include "clonewizardpage.h" -#include "cloneoptionspanel.h" -#include "bazaarplugin.h" -#include "bazaarclient.h" -#include "bazaarsettings.h" - -#include <coreplugin/iversioncontrol.h> -#include <vcsbase/vcscommand.h> -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> - -#include <QDebug> - -using namespace VcsBase; - -namespace Bazaar { -namespace Internal { - -// -------------------------------------------------------------------- -// CloneWizard: -// -------------------------------------------------------------------- - -CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : - BaseCheckoutWizard(path, parent) -{ - setTitle(tr("Cloning")); - setStartedStatus(tr("Cloning started...")); - - const Core::IVersionControl *vc = BazaarPlugin::instance()->versionControl(); - if (!vc->isConfigured()) { - auto configPage = new VcsConfigurationPage; - configPage->setVersionControl(vc); - addPage(configPage); - } - auto page = new CloneWizardPage; - page->setPath(path.toString()); - addPage(page); -} - -VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) -{ - const CloneWizardPage *cwp = 0; - foreach (int pageId, pageIds()) { - if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId)))) - break; - } - - if (!cwp) - return 0; - - const BazaarSettings &settings = BazaarPlugin::instance()->settings(); - *checkoutDir = Utils::FileName::fromString(cwp->path() + QLatin1Char('/') + cwp->directory()); - - const CloneOptionsPanel *panel = cwp->cloneOptionsPanel(); - QStringList extraOptions; - if (panel->isUseExistingDirectoryOptionEnabled()) - extraOptions += QLatin1String("--use-existing-dir"); - if (panel->isStackedOptionEnabled()) - extraOptions += QLatin1String("--stacked"); - if (panel->isStandAloneOptionEnabled()) - extraOptions += QLatin1String("--standalone"); - if (panel->isBindOptionEnabled()) - extraOptions += QLatin1String("--bind"); - if (panel->isSwitchOptionEnabled()) - extraOptions += QLatin1String("--switch"); - if (panel->isHardLinkOptionEnabled()) - extraOptions += QLatin1String("--hardlink"); - if (panel->isNoTreeOptionEnabled()) - extraOptions += QLatin1String("--no-tree"); - if (!panel->revision().isEmpty()) - extraOptions << QLatin1String("-r") << panel->revision(); - const BazaarClient *client = BazaarPlugin::instance()->client(); - QStringList args; - args << client->vcsCommandString(BazaarClient::CloneCommand) - << extraOptions << cwp->repository() << cwp->directory(); - - auto command = new VcsCommand(settings.binaryPath(), cwp->path(), - client->processEnvironment()); - command->addJob(args, -1); - return command; -} - -} // namespace Internal -} // namespace Bazaar diff --git a/src/plugins/bazaar/clonewizard.h b/src/plugins/bazaar/clonewizard.h deleted file mode 100644 index db85db689aa..00000000000 --- a/src/plugins/bazaar/clonewizard.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARD_H -#define CLONEWIZARD_H - -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> - -namespace Bazaar { -namespace Internal { - -class CloneWizard : public VcsBase::BaseCheckoutWizard -{ - Q_OBJECT - -public: - CloneWizard(const Utils::FileName &path, QWidget *parent = 0); - -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir); -}; - -} // namespace Internal -} // namespace Bazaar - -#endif // CLONEWIZARD_H diff --git a/src/plugins/bazaar/clonewizardpage.cpp b/src/plugins/bazaar/clonewizardpage.cpp deleted file mode 100644 index febad62cc9f..00000000000 --- a/src/plugins/bazaar/clonewizardpage.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizardpage.h" -#include "cloneoptionspanel.h" - -using namespace Bazaar::Internal; - -CloneWizardPage::CloneWizardPage(QWidget *parent) - : VcsBase::BaseCheckoutWizardPage(parent), - m_optionsPanel(new CloneOptionsPanel) -{ - setTitle(tr("Location")); - setSubTitle(tr("Specify repository URL, clone directory and path.")); - setRepositoryLabel(tr("Clone URL:")); - setBranchSelectorVisible(false); - addLocalControl(m_optionsPanel); -} - -const CloneOptionsPanel *CloneWizardPage::cloneOptionsPanel() const -{ - return m_optionsPanel; -} - -QString CloneWizardPage::directoryFromRepository(const QString &repository) const -{ - // Bazaar repositories are generally of the form - // 'lp:project' or 'protocol://repositoryUrl/repository/' - // We are just looking for repository. - QString repo = repository.trimmed(); - if (repo.startsWith(QLatin1String("lp:"))) - return repo.mid(3); - const QChar slash = QLatin1Char('/'); - if (repo.endsWith(slash)) - repo.truncate(repo.size() - 1); - // Take the basename or the repository url - return repo.mid(repo.lastIndexOf(slash) + 1); -} diff --git a/src/plugins/bazaar/clonewizardpage.h b/src/plugins/bazaar/clonewizardpage.h deleted file mode 100644 index d7336d775b6..00000000000 --- a/src/plugins/bazaar/clonewizardpage.h +++ /dev/null @@ -1,58 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Hugues Delorme -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARDPAGE_H -#define CLONEWIZARDPAGE_H - -#include <vcsbase/basecheckoutwizardpage.h> - -namespace Bazaar { -namespace Internal { -class CloneOptionsPanel; - -class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage -{ - Q_OBJECT - -public: - CloneWizardPage(QWidget *parent = 0); - const CloneOptionsPanel *cloneOptionsPanel() const; - -protected: - QString directoryFromRepository(const QString &repository) const; - -private: - CloneOptionsPanel *m_optionsPanel; -}; - -} // namespace Internal -} // namespace Bazaar - -#endif // CLONEWIZARDPAGE_H diff --git a/src/plugins/bazaar/commiteditor.cpp b/src/plugins/bazaar/commiteditor.cpp index c2372d06f1a..8de83d10961 100644 --- a/src/plugins/bazaar/commiteditor.cpp +++ b/src/plugins/bazaar/commiteditor.cpp @@ -30,6 +30,7 @@ #include "commiteditor.h" #include "branchinfo.h" #include "bazaarcommitwidget.h" +#include "constants.h" #include <coreplugin/idocument.h> #include <vcsbase/submitfilemodel.h> @@ -62,6 +63,20 @@ void CommitEditor::setFields(const QString &repositoryRoot, m_fileModel = new VcsBase::SubmitFileModel(this); m_fileModel->setRepositoryRoot(repositoryRoot); + m_fileModel->setFileStatusQualifier([](const QString &status, const QVariant &) + -> VcsBase::SubmitFileModel::FileStatusHint + { + if (status == QLatin1String(Constants::FSTATUS_CREATED)) + return VcsBase::SubmitFileModel::FileAdded; + if (status == QLatin1String(Constants::FSTATUS_MODIFIED)) + return VcsBase::SubmitFileModel::FileModified; + if (status == QLatin1String(Constants::FSTATUS_DELETED)) + return VcsBase::SubmitFileModel::FileDeleted; + if (status == QLatin1String(Constants::FSTATUS_RENAMED)) + return VcsBase::SubmitFileModel::FileRenamed; + return VcsBase::SubmitFileModel::FileStatusUnknown; + } ); + foreach (const VcsBase::VcsBaseClient::StatusItem &item, repoStatus) if (item.flags != QLatin1String("Unknown")) m_fileModel->addFile(item.file, item.flags); diff --git a/src/plugins/bazaar/constants.h b/src/plugins/bazaar/constants.h index c7b5aa74648..fa7506d61c3 100644 --- a/src/plugins/bazaar/constants.h +++ b/src/plugins/bazaar/constants.h @@ -60,6 +60,12 @@ const char DIFFLOG_ID[] = "Bazaar Diff Editor"; const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Diff Editor"); const char DIFFAPP[] = "text/x-patch"; +// File status hint +const char FSTATUS_CREATED[] = "Created"; +const char FSTATUS_DELETED[] = "Deleted"; +const char FSTATUS_MODIFIED[] = "Modified"; +const char FSTATUS_RENAMED[] = "Renamed"; + } // namespace Constants } // namespace Bazaar diff --git a/src/plugins/bazaar/images/bazaar.png b/src/plugins/bazaar/images/bazaar.png Binary files differdeleted file mode 100644 index 19b6a8b29fe..00000000000 --- a/src/plugins/bazaar/images/bazaar.png +++ /dev/null diff --git a/src/plugins/bazaar/optionspage.cpp b/src/plugins/bazaar/optionspage.cpp index 7b3182970fe..844cabc78b8 100644 --- a/src/plugins/bazaar/optionspage.cpp +++ b/src/plugins/bazaar/optionspage.cpp @@ -28,6 +28,7 @@ ** ****************************************************************************/ #include "optionspage.h" +#include "bazaarclient.h" #include "bazaarsettings.h" #include "bazaarplugin.h" @@ -38,9 +39,9 @@ using namespace Bazaar::Internal; using namespace Bazaar; +using namespace VcsBase; -OptionsPageWidget::OptionsPageWidget(QWidget *parent) - : QWidget(parent) +OptionsPageWidget::OptionsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent) { m_ui.setupUi(this); m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); @@ -48,9 +49,9 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) m_ui.commandChooser->setHistoryCompleter(QLatin1String("Bazaar.Command.History")); } -BazaarSettings OptionsPageWidget::settings() const +VcsBaseClientSettings OptionsPageWidget::settings() const { - BazaarSettings s = BazaarPlugin::instance()->settings(); + VcsBaseClientSettings s = BazaarPlugin::instance()->client()->settings(); s.setValue(BazaarSettings::binaryPathKey, m_ui.commandChooser->rawPath()); s.setValue(BazaarSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed()); s.setValue(BazaarSettings::userEmailKey, m_ui.defaultEmailLineEdit->text().trimmed()); @@ -59,7 +60,7 @@ BazaarSettings OptionsPageWidget::settings() const return s; } -void OptionsPageWidget::setSettings(const BazaarSettings &s) +void OptionsPageWidget::setSettings(const VcsBaseClientSettings &s) { m_ui.commandChooser->setPath(s.stringValue(BazaarSettings::binaryPathKey)); m_ui.defaultUsernameLineEdit->setText(s.stringValue(BazaarSettings::userNameKey)); @@ -68,30 +69,10 @@ void OptionsPageWidget::setSettings(const BazaarSettings &s) m_ui.timeout->setValue(s.intValue(BazaarSettings::timeoutKey)); } -OptionsPage::OptionsPage() +OptionsPage::OptionsPage(Core::IVersionControl *control) : + VcsClientOptionsPage(control, BazaarPlugin::instance()->client()) { setId(VcsBase::Constants::VCS_ID_BAZAAR); setDisplayName(tr("Bazaar")); -} - -QWidget *OptionsPage::widget() -{ - if (!m_optionsPageWidget) - m_optionsPageWidget = new OptionsPageWidget; - m_optionsPageWidget->setSettings(BazaarPlugin::instance()->settings()); - return m_optionsPageWidget; -} - -void OptionsPage::apply() -{ - if (!m_optionsPageWidget) - return; - BazaarPlugin *plugin = BazaarPlugin::instance(); - const BazaarSettings newSettings = m_optionsPageWidget->settings(); - if (newSettings != plugin->settings()) { - //assume success and emit signal that settings are changed; - plugin->setSettings(newSettings); - newSettings.writeSettings(Core::ICore::settings()); - emit settingsChanged(); - } + setWidgetFactory([]() { return new OptionsPageWidget; }); } diff --git a/src/plugins/bazaar/optionspage.h b/src/plugins/bazaar/optionspage.h index 69ae1eb32e2..2711b3c4a42 100644 --- a/src/plugins/bazaar/optionspage.h +++ b/src/plugins/bazaar/optionspage.h @@ -37,42 +37,34 @@ #include <QWidget> #include <QPointer> +namespace VcsBase { +class VcsBaseClientSettings; +} // namespace VcsBase + namespace Bazaar { namespace Internal { -class BazaarSettings; - -class OptionsPageWidget : public QWidget +class OptionsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: explicit OptionsPageWidget(QWidget *parent = 0); - BazaarSettings settings() const; - void setSettings(const BazaarSettings &s); + VcsBase::VcsBaseClientSettings settings() const; + void setSettings(const VcsBase::VcsBaseClientSettings &s); private: Ui::OptionsPage m_ui; }; -class OptionsPage : public VcsBase::VcsBaseOptionsPage +class OptionsPage : public VcsBase::VcsClientOptionsPage { Q_OBJECT public: - OptionsPage(); - - QWidget *widget(); - void apply(); - void finish() { } - -signals: - void settingsChanged(); - -private: - QPointer<OptionsPageWidget> m_optionsPageWidget; + OptionsPage(Core::IVersionControl *control); }; } // namespace Internal diff --git a/src/plugins/beautifier/beautifier.pro b/src/plugins/beautifier/beautifier.pro index 1cb7463ba18..9b4b8ddcd25 100644 --- a/src/plugins/beautifier/beautifier.pro +++ b/src/plugins/beautifier/beautifier.pro @@ -1,7 +1,5 @@ include(../../qtcreatorplugin.pri) -QT += xml - HEADERS += \ abstractsettings.h \ beautifierabstracttool.h \ diff --git a/src/plugins/bineditor/bineditor.cpp b/src/plugins/bineditor/bineditor.cpp index d39995eaac7..72c71581061 100644 --- a/src/plugins/bineditor/bineditor.cpp +++ b/src/plugins/bineditor/bineditor.cpp @@ -56,18 +56,6 @@ #include <QToolTip> #include <QWheelEvent> -// QByteArray::toLower() is broken, it stops at the first \0 -static void lower(QByteArray &ba) -{ - char *data = ba.data(); - char *end = data + ba.size(); - while (data != end) { - if (*data >= 0x41 && *data <= 0x5A) - *data += 0x20; - ++data; - } -} - static QByteArray calculateHexPattern(const QByteArray &pattern) { QByteArray result; @@ -562,7 +550,7 @@ int BinEditorWidget::dataIndexOf(const QByteArray &pattern, int from, bool caseS ::memcpy(b + trailing, data.constData(), m_blockSize); if (!caseSensitive) - ::lower(buffer); + buffer = buffer.toLower(); int pos = matcher.indexIn(buffer, from - (block * m_blockSize) + trailing); if (pos >= 0) @@ -595,7 +583,7 @@ int BinEditorWidget::dataLastIndexOf(const QByteArray &pattern, int from, bool c ::memcpy(b, data.constData(), m_blockSize); if (!caseSensitive) - ::lower(buffer); + buffer = buffer.toLower(); int pos = buffer.lastIndexOf(pattern, from - (block * m_blockSize)); if (pos >= 0) @@ -618,7 +606,7 @@ int BinEditorWidget::find(const QByteArray &pattern_arg, int from, bool caseSensitiveSearch = (findFlags & QTextDocument::FindCaseSensitively); if (!caseSensitiveSearch) - ::lower(pattern); + pattern = pattern.toLower(); bool backwards = (findFlags & QTextDocument::FindBackward); int found = backwards ? dataLastIndexOf(pattern, from, caseSensitiveSearch) @@ -734,7 +722,7 @@ void BinEditorWidget::paintEvent(QPaintEvent *e) patternData = dataMid(patternOffset, m_numVisibleLines * m_bytesPerLine + (topLine*m_bytesPerLine - patternOffset)); patternDataHex = patternData; if (!m_caseSensitiveSearch) - ::lower(patternData); + patternData = patternData.toLower(); } int foundPatternAt = findPattern(patternData, patternDataHex, patternOffset, patternOffset, &matchLength); @@ -1412,7 +1400,7 @@ void BinEditorWidget::highlightSearchResults(const QByteArray &pattern, QTextDoc m_searchPattern = pattern; m_caseSensitiveSearch = (findFlags & QTextDocument::FindCaseSensitively); if (!m_caseSensitiveSearch) - ::lower(m_searchPattern); + m_searchPattern = m_searchPattern.toLower(); m_searchPatternHex = calculateHexPattern(pattern); viewport()->update(); } diff --git a/src/plugins/bineditor/bineditor.pro b/src/plugins/bineditor/bineditor.pro index 0dbd986b257..89a91bd621d 100644 --- a/src/plugins/bineditor/bineditor.pro +++ b/src/plugins/bineditor/bineditor.pro @@ -6,4 +6,5 @@ HEADERS += bineditorplugin.h \ markup.h SOURCES += bineditorplugin.cpp \ - bineditor.cpp + bineditor.cpp \ + markup.cpp diff --git a/src/plugins/bineditor/bineditor.qbs b/src/plugins/bineditor/bineditor.qbs index 72f906c384b..38d8ba5d30c 100644 --- a/src/plugins/bineditor/bineditor.qbs +++ b/src/plugins/bineditor/bineditor.qbs @@ -16,6 +16,7 @@ QtcPlugin { "bineditorconstants.h", "bineditorplugin.cpp", "bineditorplugin.h", + "markup.cpp", "markup.h", ] } diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index 533b4b7cd67..d22940666b5 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -464,7 +464,7 @@ IEditor *BinEditorFactory::createEditor() ///////////////////////////////// BinEditorPlugin ////////////////////////////////// -BinEditorPlugin::BinEditorPlugin() : m_factory(0) +BinEditorPlugin::BinEditorPlugin() { m_undoAction = m_redoAction = m_copyAction = m_selectAllAction = 0; } diff --git a/src/plugins/bineditor/bineditorplugin.h b/src/plugins/bineditor/bineditorplugin.h index f14f6e9bf4a..3b0e683ea4c 100644 --- a/src/plugins/bineditor/bineditorplugin.h +++ b/src/plugins/bineditor/bineditorplugin.h @@ -35,7 +35,6 @@ #include <coreplugin/editormanager/ieditorfactory.h> #include <coreplugin/icontext.h> -#include <QtPlugin> #include <QPointer> #include <QStringList> #include <QAction> @@ -80,10 +79,6 @@ private: QAction *m_copyAction; QAction *m_selectAllAction; - friend class BinEditorFactory; - Core::IEditor *createEditor(QWidget *parent); - - BinEditorFactory *m_factory; QPointer<BinEditorWidget> m_currentEditor; }; diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index 29c4d833280..70c0352d11c 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -30,6 +30,7 @@ #include "bookmark.h" #include "bookmarkmanager.h" +#include "bookmarks_global.h" #include <QDebug> #include <QFileInfo> @@ -38,7 +39,7 @@ using namespace Bookmarks::Internal; Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) : - TextMark(QString(), lineNumber), + TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY), m_manager(manager) { setPriority(TextEditor::TextMark::NormalPriority); diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index e4de592623c..1d7b08905ae 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -45,6 +45,7 @@ #include <utils/tooltip/tooltip.h> #include <utils/qtcassert.h> #include <utils/checkablemessagebox.h> +#include <utils/theme/theme.h> #include <QAction> #include <QContextMenuEvent> @@ -331,6 +332,8 @@ BookmarkManager::BookmarkManager() : this, &BookmarkManager::loadBookmarks); updateActionStatus(); + Bookmark::setCategoryColor(Constants::BOOKMARKS_TEXT_MARK_CATEGORY, + Theme::Bookmarks_TextMarkColor); } BookmarkManager::~BookmarkManager() diff --git a/src/plugins/bookmarks/bookmarks_global.h b/src/plugins/bookmarks/bookmarks_global.h index 9151937fc00..08d0fc6f741 100644 --- a/src/plugins/bookmarks/bookmarks_global.h +++ b/src/plugins/bookmarks/bookmarks_global.h @@ -44,6 +44,7 @@ const char BOOKMARKS_PREVDIR_ACTION[] = "Bookmarks.PreviousDirectory"; const char BOOKMARKS_NEXTDIR_ACTION[] = "Bookmarks.NextDirectory"; const char BOOKMARKS_PREVDOC_ACTION[] = "Bookmarks.PreviousDocument"; const char BOOKMARKS_NEXTDOC_ACTION[] = "Bookmarks.NextDocument"; +const char BOOKMARKS_TEXT_MARK_CATEGORY[] = "Bookmarks.TextMarkCategory"; const char BOOKMARKS_MENU[] = "Bookmarks.Menu"; const char BOOKMARKS_CONTEXT[] = "Bookmarks"; diff --git a/src/plugins/classview/classviewnavigationwidget.cpp b/src/plugins/classview/classviewnavigationwidget.cpp index 153c2e9c79f..c4d5ce44693 100644 --- a/src/plugins/classview/classviewnavigationwidget.cpp +++ b/src/plugins/classview/classviewnavigationwidget.cpp @@ -40,6 +40,7 @@ #include <utils/qtcassert.h> #include <QDebug> +#include <QVariant> #include <QVBoxLayout> enum { debug = false }; @@ -102,6 +103,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) : treeView->setDragEnabled(true); treeView->setDragDropMode(QAbstractItemView::DragOnly); treeView->setDefaultDropAction(Qt::MoveAction); + treeView->setExpandsOnDoubleClick(false); verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper( treeView, Core::ItemViewFind::DarkColored, Core::ItemViewFind::FetchMoreWhileSearching)); @@ -114,6 +116,9 @@ NavigationWidget::NavigationWidget(QWidget *parent) : // selected item connect(treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex))); + // double-clicked item + connect(treeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(onItemDoubleClicked(QModelIndex))); + // connections to the manager Manager *manager = Manager::instance(); @@ -237,6 +242,26 @@ void NavigationWidget::onItemActivated(const QModelIndex &index) } /*! + Expands/collapses the item given by \a index if it + refers to a project file (.pro/.pri) +*/ + +void NavigationWidget::onItemDoubleClicked(const QModelIndex &index) +{ + if (!index.isValid()) + return; + + const QVariant iconType = treeModel->data(index, Constants::IconTypeRole); + if (!iconType.isValid()) + return; + + bool ok = false; + const int type = iconType.toInt(&ok); + if (ok && type == INT_MIN) + treeView->setExpanded(index, !treeView->isExpanded(index)); +} + +/*! Receives new data for the tree. \a result is a pointer to the Class View model root item. The function does nothing if null is passed. */ diff --git a/src/plugins/classview/classviewnavigationwidget.h b/src/plugins/classview/classviewnavigationwidget.h index d830ded03b2..f1b38eecb22 100644 --- a/src/plugins/classview/classviewnavigationwidget.h +++ b/src/plugins/classview/classviewnavigationwidget.h @@ -72,6 +72,7 @@ signals: public slots: void onItemActivated(const QModelIndex &index); + void onItemDoubleClicked(const QModelIndex &index); void onDataUpdate(QSharedPointer<QStandardItem> result); diff --git a/src/plugins/clearcase/clearcasecontrol.cpp b/src/plugins/clearcase/clearcasecontrol.cpp index 686f782a92d..472d79a81b7 100644 --- a/src/plugins/clearcase/clearcasecontrol.cpp +++ b/src/plugins/clearcase/clearcasecontrol.cpp @@ -80,6 +80,7 @@ bool ClearCaseControl::supportsOperation(Operation operation) const break; case CreateRepositoryOperation: case SnapshotOperations: + case Core::IVersionControl::InitialCheckoutOperation: rc = false; break; } diff --git a/src/plugins/clearcase/clearcasecontrol.h b/src/plugins/clearcase/clearcasecontrol.h index 43864917efc..fb83b592637 100644 --- a/src/plugins/clearcase/clearcasecontrol.h +++ b/src/plugins/clearcase/clearcasecontrol.h @@ -45,28 +45,28 @@ class ClearCaseControl : public Core::IVersionControl Q_OBJECT public: explicit ClearCaseControl(ClearCasePlugin *plugin); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; + bool managesDirectory(const QString &directory, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; - bool isConfigured() const; + bool isConfigured() const override; - bool supportsOperation(Operation operation) const; - OpenSupportMode openSupportMode(const QString &fileName) const; - bool vcsOpen(const QString &fileName); - SettingsFlags settingsFlags() const; - bool vcsAdd(const QString &fileName); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); + bool supportsOperation(Operation operation) const override; + OpenSupportMode openSupportMode(const QString &fileName) const override; + bool vcsOpen(const QString &fileName) override; + SettingsFlags settingsFlags() const override; + bool vcsAdd(const QString &fileName) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; - bool vcsAnnotate(const QString &file, int line); + bool vcsAnnotate(const QString &file, int line) override; - QString vcsOpenText() const; - QString vcsMakeWritableText() const; - QString vcsTopic(const QString &directory); + QString vcsOpenText() const override; + QString vcsMakeWritableText() const override; + QString vcsTopic(const QString &directory) override; void emitRepositoryChanged(const QString &); void emitFilesChanged(const QStringList &); diff --git a/src/plugins/clearcase/clearcaseeditor.cpp b/src/plugins/clearcase/clearcaseeditor.cpp index db361a56242..17622062af8 100644 --- a/src/plugins/clearcase/clearcaseeditor.cpp +++ b/src/plugins/clearcase/clearcaseeditor.cpp @@ -35,7 +35,7 @@ #include "clearcaseplugin.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDir> #include <QFileInfo> diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index c20d63fa022..33a400b8da0 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -232,7 +232,7 @@ QStringList ClearCasePlugin::getVobList() const QStringList args(QLatin1String("lsvob")); args << QLatin1String("-s"); const ClearCaseResponse response = - runCleartool(currentState().topLevel(), args, m_settings.timeOutMS(), SilentRun); + runCleartool(currentState().topLevel(), args, m_settings.timeOutS, SilentRun); return response.stdOut.split(QLatin1Char('\n'), QString::SkipEmptyParts); } @@ -356,7 +356,7 @@ QString ClearCasePlugin::ccManagesDirectory(const QString &directory) const { QStringList args(QLatin1String("pwv")); const ClearCaseResponse response = - runCleartool(directory, args, m_settings.timeOutMS(), SilentRun); + runCleartool(directory, args, m_settings.timeOutS, SilentRun); if (response.error) return QString(); @@ -404,7 +404,7 @@ QString ClearCasePlugin::ccViewRoot(const QString &directory) const QStringList args(QLatin1String("pwv")); args << QLatin1String("-root"); const ClearCaseResponse response = - runCleartool(directory, args, m_settings.timeOutMS(), SilentRun); + runCleartool(directory, args, m_settings.timeOutS, SilentRun); QString root = response.stdOut.trimmed(); @@ -706,7 +706,7 @@ QString ClearCasePlugin::ccGetPredecessor(const QString &version) const QStringList args(QLatin1String("describe")); args << QLatin1String("-fmt") << QLatin1String("%En@@%PSn") << version; const ClearCaseResponse response = - runCleartool(currentState().topLevel(), args, m_settings.timeOutMS(), SilentRun); + runCleartool(currentState().topLevel(), args, m_settings.timeOutS, SilentRun); if (response.error || response.stdOut.endsWith(QLatin1Char('@'))) // <name-unknown>@@ return QString(); else @@ -722,7 +722,7 @@ QStringList ClearCasePlugin::ccGetActiveVobs() const const QString theViewRoot = viewRoot(); const ClearCaseResponse response = - runCleartool(theViewRoot, args, m_settings.timeOutMS(), SilentRun); + runCleartool(theViewRoot, args, m_settings.timeOutS, SilentRun); if (response.error) return res; @@ -774,7 +774,7 @@ QString ClearCasePlugin::ccGetFileActivity(const QString &workingDir, const QStr args << QLatin1String("-fmt") << QLatin1String("%[activity]p"); args << file; const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), SilentRun); + runCleartool(workingDir, args, m_settings.timeOutS, SilentRun); return response.stdOut; } @@ -911,7 +911,7 @@ void ClearCasePlugin::undoCheckOutCurrent() args << fileName; const ClearCaseResponse diffResponse = - runCleartool(state.currentFileTopLevel(), args, m_settings.timeOutMS(), 0); + runCleartool(state.currentFileTopLevel(), args, m_settings.timeOutS, 0); bool different = diffResponse.error; // return value is 1 if there is any difference bool keep = false; @@ -940,8 +940,8 @@ bool ClearCasePlugin::vcsUndoCheckOut(const QString &workingDir, const QString & args << QDir::toNativeSeparators(fileName); const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); if (!response.error) { const QString absPath = workingDir + QLatin1Char('/') + fileName; @@ -973,8 +973,8 @@ bool ClearCasePlugin::vcsUndoHijack(const QString &workingDir, const QString &fi args << QDir::toNativeSeparators(fileName); const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); if (!response.error && !m_settings.disableIndexer) { const QString absPath = workingDir + QLatin1Char('/') + fileName; setStatus(absPath, FileStatus::CheckedIn); @@ -1080,7 +1080,7 @@ QStringList ClearCasePlugin::ccGetActivityVersions(const QString &workingDir, co QStringList args(QLatin1String("lsactivity")); args << QLatin1String("-fmt") << QLatin1String("%[versions]Cp") << activity; const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), SilentRun); + runCleartool(workingDir, args, m_settings.timeOutS, SilentRun); if (response.error) return QStringList(); QStringList versions = response.stdOut.split(QLatin1String(", ")); @@ -1306,8 +1306,7 @@ void ClearCasePlugin::history(const QString &workingDir, args.append(QDir::toNativeSeparators(file)); const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), - 0, codec); + runCleartool(workingDir, args, m_settings.timeOutS, 0, codec); if (response.error) return; @@ -1367,7 +1366,8 @@ void ClearCasePlugin::ccUpdate(const QString &workingDir, const QStringList &rel if (!relativePaths.isEmpty()) args.append(relativePaths); const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.longTimeOutMS(), ShowStdOutInLogWindow); + runCleartool(workingDir, args, m_settings.longTimeOutS(), + VcsCommand::ShowStdOut); if (!response.error) clearCaseControl()->emitRepositoryChanged(workingDir); } @@ -1408,7 +1408,7 @@ void ClearCasePlugin::vcsAnnotate(const QString &workingDir, const QString &file args.append(QDir::toNativeSeparators(id)); const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), 0, codec); + runCleartool(workingDir, args, m_settings.timeOutS, 0, codec); if (response.error) return; @@ -1458,7 +1458,7 @@ void ClearCasePlugin::describe(const QString &source, const QString &changeNr) args.push_back(id); QTextCodec *codec = VcsBaseEditor::getCodec(source); const ClearCaseResponse response = - runCleartool(topLevel, args, m_settings.timeOutMS(), 0, codec); + runCleartool(topLevel, args, m_settings.timeOutS, 0, codec); description = response.stdOut; if (m_settings.extDiffAvailable) description += diffExternal(id); @@ -1486,13 +1486,13 @@ void ClearCasePlugin::checkInSelected() QString ClearCasePlugin::runCleartoolSync(const QString &workingDir, const QStringList &arguments) const { - return runCleartool(workingDir, arguments, m_settings.timeOutMS(), SilentRun).stdOut; + return runCleartool(workingDir, arguments, m_settings.timeOutS, SilentRun).stdOut; } ClearCaseResponse ClearCasePlugin::runCleartool(const QString &workingDir, const QStringList &arguments, - int timeOut, + int timeOutS, unsigned flags, QTextCodec *outputCodec) const { @@ -1506,12 +1506,12 @@ ClearCasePlugin::runCleartool(const QString &workingDir, const SynchronousProcessResponse sp_resp = VcsBasePlugin::runVcs(workingDir, FileName::fromUserInput(executable), - arguments, timeOut, + arguments, timeOutS, flags, outputCodec); response.error = sp_resp.result != SynchronousProcessResponse::Finished; if (response.error) - response.message = sp_resp.exitMessage(executable, timeOut); + response.message = sp_resp.exitMessage(executable, timeOutS); response.stdErr = sp_resp.stdErr; response.stdOut = sp_resp.stdOut; return response; @@ -1629,8 +1629,10 @@ bool ClearCasePlugin::vcsOpen(const QString &workingDir, const QString &fileName } args << file; ClearCaseResponse response = - runCleartool(topLevel, args, m_settings.timeOutMS(), ShowStdOutInLogWindow | - SuppressStdErrInLogWindow | FullySynchronously); + runCleartool(topLevel, args, m_settings.timeOutS, + VcsCommand::ShowStdOut + | VcsCommand::SuppressStdErr + | VcsCommand::FullySynchronously); if (response.error) { if (response.stdErr.contains(QLatin1String("Versions other than the selected version"))) { VersionSelector selector(file, response.stdErr); @@ -1639,8 +1641,9 @@ bool ClearCasePlugin::vcsOpen(const QString &workingDir, const QString &fileName ccUpdate(workingDir, QStringList() << file); else args.removeOne(QLatin1String("-query")); - response = runCleartool(topLevel, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + response = runCleartool(topLevel, args, m_settings.timeOutS, + VcsCommand::ShowStdOut + | VcsCommand::FullySynchronously); } } else { VcsOutputWindow::append(response.stdOut); @@ -1675,7 +1678,7 @@ bool ClearCasePlugin::vcsSetActivity(const QString &workingDir, const QString &t QStringList args; args << QLatin1String("setactivity") << activity; const ClearCaseResponse actResponse = - runCleartool(workingDir, args, m_settings.timeOutMS(), ShowStdOutInLogWindow); + runCleartool(workingDir, args, m_settings.timeOutS, VcsCommand::ShowStdOut); if (actResponse.error) { QMessageBox::warning(ICore::dialogParent(), title, tr("Set current activity failed: %1").arg(actResponse.message), QMessageBox::Ok); @@ -1719,7 +1722,8 @@ bool ClearCasePlugin::vcsCheckIn(const QString &messageFile, const QStringList & blockers.append(fcb); } const ClearCaseResponse response = - runCleartool(m_checkInView, args, m_settings.longTimeOutMS(), ShowStdOutInLogWindow); + runCleartool(m_checkInView, args, m_settings.longTimeOutS(), + VcsCommand::ShowStdOut); QRegExp checkedIn(QLatin1String("Checked in \\\"([^\"]*)\\\"")); bool anySucceeded = false; int offset = checkedIn.indexIn(response.stdOut); @@ -1785,8 +1789,8 @@ bool ClearCasePlugin::ccFileOp(const QString &workingDir, const QString &title, QStringList args; args << QLatin1String("checkout") << commentArg << dirName; const ClearCaseResponse coResponse = - runCleartool(workingDir, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); if (coResponse.error) { if (coResponse.stdErr.contains(QLatin1String("already checked out"))) noCheckout = true; @@ -1800,8 +1804,8 @@ bool ClearCasePlugin::ccFileOp(const QString &workingDir, const QString &title, if (!file2.isEmpty()) args << QDir::toNativeSeparators(file2); const ClearCaseResponse opResponse = - runCleartool(workingDir, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); if (opResponse.error) { // on failure - undo checkout for the directory if (!noCheckout) @@ -1814,8 +1818,8 @@ bool ClearCasePlugin::ccFileOp(const QString &workingDir, const QString &title, args.clear(); args << QLatin1String("checkin") << commentArg << dirName; const ClearCaseResponse ciResponse = - runCleartool(workingDir, args, m_settings.timeOutMS(), - ShowStdOutInLogWindow | FullySynchronously); + runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut | VcsCommand::FullySynchronously); return !ciResponse.error; } return true; @@ -1963,7 +1967,7 @@ bool ClearCasePlugin::newActivity() } const ClearCaseResponse response = - runCleartool(workingDir, args, m_settings.timeOutMS(), 0); + runCleartool(workingDir, args, m_settings.timeOutS, 0); if (!response.error) refreshActivities(); @@ -2103,7 +2107,7 @@ QString ClearCasePlugin::getFile(const QString &nativeFile, const QString &prefi QStringList args(QLatin1String("get")); args << QLatin1String("-to") << tempFile << nativeFile; const ClearCaseResponse response = - runCleartool(m_topLevel, args, m_settings.timeOutMS(), SilentRun); + runCleartool(m_topLevel, args, m_settings.timeOutS, SilentRun); if (response.error) return QString(); QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser | @@ -2146,8 +2150,7 @@ QString ClearCasePlugin::diffExternal(QString file1, QString file2, bool keep) } else { args << file2; } - const QString diffResponse = - runExtDiff(m_topLevel, args, m_settings.timeOutMS(), codec); + const QString diffResponse = runExtDiff(m_topLevel, args, m_settings.timeOutS, codec); if (!keep && !tempFile1.isEmpty()) { QFile::remove(tempFile1); QFileInfo(tempFile1).dir().rmpath(QLatin1String(".")); @@ -2179,10 +2182,8 @@ void ClearCasePlugin::diffGraphical(const QString &file1, const QString &file2) QProcess::startDetached(m_settings.ccBinaryPath, args, m_topLevel); } -QString ClearCasePlugin::runExtDiff(const QString &workingDir, - const QStringList &arguments, - int timeOut, - QTextCodec *outputCodec) +QString ClearCasePlugin::runExtDiff(const QString &workingDir, const QStringList &arguments, + int timeOutS, QTextCodec *outputCodec) { const QString executable(QLatin1String("diff")); QStringList args(m_settings.diffArgs.split(QLatin1Char(' '), QString::SkipEmptyParts)); @@ -2191,7 +2192,7 @@ QString ClearCasePlugin::runExtDiff(const QString &workingDir, QProcess process; process.setWorkingDirectory(workingDir); process.start(executable, args); - if (!process.waitForFinished(timeOut)) + if (!process.waitForFinished(timeOutS * 1000)) return QString(); QByteArray ba = process.readAll(); return outputCodec ? outputCodec->toUnicode(ba) : diff --git a/src/plugins/clearcase/clearcaseplugin.h b/src/plugins/clearcase/clearcaseplugin.h index 16ba8ce87dd..f23142546aa 100644 --- a/src/plugins/clearcase/clearcaseplugin.h +++ b/src/plugins/clearcase/clearcaseplugin.h @@ -36,6 +36,7 @@ #include <coreplugin/id.h> #include <vcsbase/vcsbaseplugin.h> +#include <vcsbase/vcscommand.h> #include <QFile> #include <QPair> @@ -119,7 +120,7 @@ class ClearCasePlugin : public VcsBase::VcsBasePlugin Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "ClearCase.json") - enum { SilentRun = NoOutput | FullySynchronously }; + enum { SilentRun = VcsBase::VcsCommand::NoOutput | VcsBase::VcsCommand::FullySynchronously }; public: ClearCasePlugin(); @@ -235,9 +236,8 @@ private: int editorType, const QString &source, QTextCodec *codec) const; QString runCleartoolSync(const QString &workingDir, const QStringList &arguments) const; - ClearCaseResponse runCleartool(const QString &workingDir, - const QStringList &arguments, int timeOut, - unsigned flags, QTextCodec *outputCodec = 0) const; + ClearCaseResponse runCleartool(const QString &workingDir, const QStringList &arguments, + int timeOutS, unsigned flags, QTextCodec *outputCodec = 0) const; static void sync(QFutureInterface<void> &future, QStringList files); void history(const QString &workingDir, @@ -255,8 +255,8 @@ private: QString diffExternal(QString file1, QString file2 = QString(), bool keep = false); QString getFile(const QString &nativeFile, const QString &prefix); static void rmdir(const QString &path); - QString runExtDiff(const QString &workingDir, const QStringList &arguments, - int timeOut, QTextCodec *outputCodec = 0); + QString runExtDiff(const QString &workingDir, const QStringList &arguments, int timeOutS, + QTextCodec *outputCodec = 0); static QString getDriveLetterOfPath(const QString &directory); FileStatus::Status getFileStatus(const QString &fileName) const; diff --git a/src/plugins/clearcase/clearcasesettings.cpp b/src/plugins/clearcase/clearcasesettings.cpp index abfdcf84c96..f02c354d334 100644 --- a/src/plugins/clearcase/clearcasesettings.cpp +++ b/src/plugins/clearcase/clearcasesettings.cpp @@ -63,17 +63,16 @@ using namespace ClearCase::Internal; ClearCaseSettings::ClearCaseSettings() : ccCommand(defaultCommand()), - historyCount(defaultHistoryCount), - timeOutS(defaultTimeOutS), diffType(GraphicalDiff), diffArgs(QLatin1String(defaultDiffArgs)), autoAssignActivityName(true), autoCheckOut(true), promptToCheckIn(false), disableIndexer(false), - extDiffAvailable(false) -{ -} + extDiffAvailable(false), + historyCount(defaultHistoryCount), + timeOutS(defaultTimeOutS) +{ } void ClearCaseSettings::fromSettings(QSettings *settings) { diff --git a/src/plugins/clearcase/clearcasesettings.h b/src/plugins/clearcase/clearcasesettings.h index 95cca0956ca..f8892985d5e 100644 --- a/src/plugins/clearcase/clearcasesettings.h +++ b/src/plugins/clearcase/clearcasesettings.h @@ -56,24 +56,23 @@ public: void fromSettings(QSettings *); void toSettings(QSettings *) const; - inline int timeOutMS() const { return timeOutS * 1000; } - inline int longTimeOutMS() const { return timeOutS * 10000; } + inline int longTimeOutS() const { return timeOutS * 10; } bool equals(const ClearCaseSettings &s) const; QString ccCommand; QString ccBinaryPath; - int historyCount; - int timeOutS; DiffType diffType; QString diffArgs; + QString indexOnlyVOBs; + QHash<QString, int> totalFiles; bool autoAssignActivityName; bool autoCheckOut; bool promptToCheckIn; bool disableIndexer; - QString indexOnlyVOBs; bool extDiffAvailable; - QHash<QString, int> totalFiles; + int historyCount; + int timeOutS; }; inline bool operator==(const ClearCaseSettings &p1, const ClearCaseSettings &p2) diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorsubwindow.cpp b/src/plugins/cmakeprojectmanager/cmake_global.h index 999d8c0ec80..5c22d41e930 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorsubwindow.cpp +++ b/src/plugins/cmakeprojectmanager/cmake_global.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Canonical Ltd. ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. @@ -27,13 +27,15 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#ifndef CMAKE_GLOBAL_H +#define CMAKE_GLOBAL_H -#include "formeditorsubwindow.h" +#include <QtGlobal> -namespace QmlDesigner { +#if defined(CMAKEPROJECTMANAGER_LIBRARY) +# define CMAKE_EXPORT Q_DECL_EXPORT +#else +# define CMAKE_EXPORT Q_DECL_IMPORT +#endif -FormEditorSubWindow::FormEditorSubWindow() -{ -} - -} // namespace QmlDesigner +#endif // CMAKE_GLOBAL_H diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 3cb11cd5ef9..36a9c9eb065 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -34,6 +34,9 @@ #include "cmakeopenprojectwizard.h" #include "cmakeproject.h" #include "cmakeprojectconstants.h" +#include "cmakebuildsettingswidget.h" +#include "cmakeprojectmanager.h" +#include "makestep.h" #include <coreplugin/documentmanager.h> #include <coreplugin/icore.h> @@ -62,7 +65,7 @@ static FileName shadowBuildDirectory(const FileName &projectFilePath, const Kit if (projectFilePath.isEmpty()) return FileName(); - const QString projectName = projectFilePath.fileName(); + const QString projectName = projectFilePath.parentDir().fileName(); ProjectMacroExpander expander(projectName, k, bcName); QDir projectDir = QDir(Project::projectDirectory(projectFilePath).toString()); QString buildPath = expander.expand(Core::DocumentManager::buildDirectory()); @@ -189,13 +192,14 @@ ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(Proj CMakeBuildInfo copy(*static_cast<const CMakeBuildInfo *>(info)); CMakeProject *project = static_cast<CMakeProject *>(parent->project()); + CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager()); if (copy.buildDirectory.isEmpty()) { copy.buildDirectory = shadowBuildDirectory(project->projectFilePath(), parent->kit(), copy.displayName); } - CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, ©); + CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), manager, CMakeOpenProjectWizard::ChangeDirectory, ©); if (copw.exec() != QDialog::Accepted) return 0; diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h index 5a94993e7cc..cfe3f3968a5 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.h @@ -38,9 +38,9 @@ namespace ProjectExplorer { class ToolChain; } namespace CMakeProjectManager { class CMakeBuildInfo; +class CMakeProject; namespace Internal { -class CMakeProject; class CMakeBuildConfigurationFactory; @@ -75,7 +75,7 @@ private: QString m_msvcVersion; bool m_useNinja; - friend class CMakeProject; + friend class CMakeProjectManager::CMakeProject; }; class CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp new file mode 100644 index 00000000000..596d12773ca --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.cpp @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakebuildsettingswidget.h" +#include "cmakeproject.h" +#include "cmakebuildconfiguration.h" +#include "cmakebuildinfo.h" +#include "cmakeopenprojectwizard.h" +#include "cmakeprojectmanager.h" + +#include <coreplugin/icore.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/target.h> + +#include <QFormLayout> + +namespace CMakeProjectManager { +namespace Internal { + +CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) : m_buildConfiguration(0) +{ + QFormLayout *fl = new QFormLayout(this); + fl->setContentsMargins(20, -1, 0, -1); + fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); + setLayout(fl); + + QPushButton *runCmakeButton = new QPushButton(tr("Run CMake...")); + connect(runCmakeButton, SIGNAL(clicked()), + this, SLOT(runCMake())); + fl->addRow(tr("Reconfigure project:"), runCmakeButton); + + m_pathLineEdit = new QLineEdit(this); + m_pathLineEdit->setReadOnly(true); + + QHBoxLayout *hbox = new QHBoxLayout(); + hbox->addWidget(m_pathLineEdit); + + m_changeButton = new QPushButton(this); + m_changeButton->setText(tr("&Change")); + connect(m_changeButton, SIGNAL(clicked()), this, SLOT(openChangeBuildDirectoryDialog())); + hbox->addWidget(m_changeButton); + + fl->addRow(tr("Build directory:"), hbox); + + m_buildConfiguration = bc; + m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); + if (m_buildConfiguration->buildDirectory() == bc->target()->project()->projectDirectory()) + m_changeButton->setEnabled(false); + else + m_changeButton->setEnabled(true); + + setDisplayName(tr("CMake")); +} + +void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() +{ + CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); + CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager()); + CMakeBuildInfo info(m_buildConfiguration); + CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), + manager, CMakeOpenProjectWizard::ChangeDirectory, + &info); + if (copw.exec() == QDialog::Accepted) { + project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory()); + m_buildConfiguration->setUseNinja(copw.useNinja()); + m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); + } +} + +void CMakeBuildSettingsWidget::runCMake() +{ + if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles()) + return; + CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); + CMakeManager *manager = static_cast<CMakeManager *>(project->projectManager()); + CMakeBuildInfo info(m_buildConfiguration); + CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), + manager, + CMakeOpenProjectWizard::WantToUpdate, &info); + if (copw.exec() == QDialog::Accepted) + project->parseCMakeLists(); +} +} // namespace Internal +} // namespace CMakeProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.h index 215286de5bb..e212fdabb48 100644 --- a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.h +++ b/src/plugins/cmakeprojectmanager/cmakebuildsettingswidget.h @@ -28,34 +28,35 @@ ** ****************************************************************************/ -#ifndef QMLAPPLICATIONWIZARDPAGES_H -#define QMLAPPLICATIONWIZARDPAGES_H +#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H +#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H -#include <QWizardPage> +#include <projectexplorer/namedwidget.h> -namespace QmlProjectManager { +QT_FORWARD_DECLARE_CLASS(QLineEdit) +QT_FORWARD_DECLARE_CLASS(QPushButton) + +namespace CMakeProjectManager { namespace Internal { -class TemplateInfo; +class CMakeBuildConfiguration; -class QmlComponentSetPage : public QWizardPage +class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget { Q_OBJECT - public: - explicit QmlComponentSetPage(QWidget *parent = 0); - ~QmlComponentSetPage(); - - TemplateInfo templateInfo() const; + CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc); private slots: - void updateDescription(int index); - + void openChangeBuildDirectoryDialog(); + void runCMake(); private: - class QmlComponentSetPagePrivate *d; + QLineEdit *m_pathLineEdit; + QPushButton *m_changeButton; + CMakeBuildConfiguration *m_buildConfiguration; }; } // namespace Internal -} // namespace QmlProjectManager +} // namespace CMakeProjectManager -#endif // QMLAPPLICATIONWIZARDPAGES_H +#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H diff --git a/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp new file mode 100644 index 00000000000..16d3336cd0d --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakecbpparser.cpp @@ -0,0 +1,501 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakecbpparser.h" +#include "cmakekitinformation.h" +#include "cmaketool.h" + +#include <utils/fileutils.h> +#include <utils/stringutils.h> +#include <utils/algorithm.h> +#include <projectexplorer/projectnodes.h> + +#include <QLoggingCategory> + +using namespace ProjectExplorer; +using namespace Utils; + +namespace CMakeProjectManager { +namespace Internal { + +///// +// CMakeCbpParser +//// + +namespace { +int distance(const QString &targetDirectory, const FileName &fileName) +{ + const QString commonParent = Utils::commonPath(QStringList() << targetDirectory << fileName.toString()); + return targetDirectory.mid(commonParent.size()).count(QLatin1Char('/')) + + fileName.toString().mid(commonParent.size()).count(QLatin1Char('/')); +} +} + +// called after everything is parsed +// this function tries to figure out to which CMakeBuildTarget +// each file belongs, so that it gets the appropriate defines and +// compiler flags +void CMakeCbpParser::sortFiles() +{ + QLoggingCategory log("qtc.cmakeprojectmanager.filetargetmapping"); + QList<FileName> fileNames = Utils::transform(m_fileList, [] (FileNode *node) { + return node->path(); + }); + + Utils::sort(fileNames); + + + CMakeBuildTarget *last = 0; + FileName parentDirectory; + + qCDebug(log) << "###############"; + qCDebug(log) << "# Pre Dump #"; + qCDebug(log) << "###############"; + foreach (const CMakeBuildTarget &target, m_buildTargets) + qCDebug(log) << target.title << target.sourceDirectory << + target.includeFiles << target.defines << target.files << "\n"; + + // find a good build target to fall back + int fallbackIndex = 0; + { + int bestIncludeCount = -1; + for (int i = 0; i < m_buildTargets.size(); ++i) { + const CMakeBuildTarget &target = m_buildTargets.at(i); + if (target.includeFiles.isEmpty()) + continue; + if (target.sourceDirectory == m_sourceDirectory + && target.includeFiles.count() > bestIncludeCount) { + bestIncludeCount = target.includeFiles.count(); + fallbackIndex = i; + } + } + } + + qCDebug(log) << "###############"; + qCDebug(log) << "# Sorting #"; + qCDebug(log) << "###############"; + + foreach (const FileName &fileName, fileNames) { + qCDebug(log) << fileName; + if (fileName.parentDir() == parentDirectory && last) { + // easy case, same parent directory as last file + last->files.append(fileName.toString()); + qCDebug(log) << " into" << last->title; + } else { + int bestDistance = std::numeric_limits<int>::max(); + int bestIndex = -1; + int bestIncludeCount = -1; + + for (int i = 0; i < m_buildTargets.size(); ++i) { + const CMakeBuildTarget &target = m_buildTargets.at(i); + if (target.includeFiles.isEmpty()) + continue; + int dist = distance(target.sourceDirectory, fileName); + qCDebug(log) << "distance to target" << target.title << dist; + if (dist < bestDistance || + (dist == bestDistance && + target.includeFiles.count() > bestIncludeCount)) { + bestDistance = dist; + bestIncludeCount = target.includeFiles.count(); + bestIndex = i; + } + } + + if (bestIndex == -1 && !m_buildTargets.isEmpty()) { + bestIndex = fallbackIndex; + qCDebug(log) << " using fallbackIndex"; + } + + if (bestIndex != -1) { + m_buildTargets[bestIndex].files.append(fileName.toString()); + last = &m_buildTargets[bestIndex]; + parentDirectory = fileName.parentDir(); + qCDebug(log) << " into" << last->title; + } + } + } + + qCDebug(log) << "###############"; + qCDebug(log) << "# After Dump #"; + qCDebug(log) << "###############"; + foreach (const CMakeBuildTarget &target, m_buildTargets) + qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles << target.defines << target.files << "\n"; +} + +bool CMakeCbpParser::parseCbpFile(Kit *kit, const QString &fileName, const QString &sourceDirectory) +{ + m_kit = kit; + m_buildDirectory = QFileInfo(fileName).absolutePath(); + m_sourceDirectory = sourceDirectory; + + QFile fi(fileName); + if (fi.exists() && fi.open(QFile::ReadOnly)) { + setDevice(&fi); + + while (!atEnd()) { + readNext(); + if (name() == QLatin1String("CodeBlocks_project_file")) + parseCodeBlocks_project_file(); + else if (isStartElement()) + parseUnknownElement(); + } + + sortFiles(); + + fi.close(); + return true; + } + return false; +} + +void CMakeCbpParser::parseCodeBlocks_project_file() +{ + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (name() == QLatin1String("Project")) + parseProject(); + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseProject() +{ + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (name() == QLatin1String("Option")) + parseOption(); + else if (name() == QLatin1String("Unit")) + parseUnit(); + else if (name() == QLatin1String("Build")) + parseBuild(); + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseBuild() +{ + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (name() == QLatin1String("Target")) + parseBuildTarget(); + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseBuildTarget() +{ + m_buildTarget.clear(); + + if (attributes().hasAttribute(QLatin1String("title"))) + m_buildTarget.title = attributes().value(QLatin1String("title")).toString(); + while (!atEnd()) { + readNext(); + if (isEndElement()) { + if (!m_buildTarget.title.endsWith(QLatin1String("/fast")) + && !m_buildTarget.title.endsWith(QLatin1String("_automoc")) + && !m_buildTarget.title.endsWith(QLatin1String("_unittest"))) + m_buildTargets.append(m_buildTarget); + return; + } else if (name() == QLatin1String("Compiler")) { + parseCompiler(); + } else if (name() == QLatin1String("Option")) { + parseBuildTargetOption(); + } else if (name() == QLatin1String("MakeCommands")) { + parseMakeCommands(); + } else if (isStartElement()) { + parseUnknownElement(); + } + } +} + +void CMakeCbpParser::parseBuildTargetOption() +{ + if (attributes().hasAttribute(QLatin1String("output"))) { + m_buildTarget.executable = attributes().value(QLatin1String("output")).toString(); + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + if (tool) + m_buildTarget.executable = tool->mapAllPaths(m_kit, m_buildTarget.executable); + } else if (attributes().hasAttribute(QLatin1String("type"))) { + const QStringRef value = attributes().value(QLatin1String("type")); + if (value == QLatin1String("2") || value == QLatin1String("3")) + m_buildTarget.targetType = TargetType(value.toInt()); + } else if (attributes().hasAttribute(QLatin1String("working_dir"))) { + m_buildTarget.workingDirectory = attributes().value(QLatin1String("working_dir")).toString(); + QDir dir(m_buildDirectory); + const QString relative = dir.relativeFilePath(m_buildTarget.workingDirectory); + m_buildTarget.sourceDirectory + = FileName::fromString(m_sourceDirectory).appendPath(relative).toString(); + } + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (isStartElement()) + parseUnknownElement(); + } +} + +QString CMakeCbpParser::projectName() const +{ + return m_projectName; +} + +void CMakeCbpParser::parseOption() +{ + if (attributes().hasAttribute(QLatin1String("title"))) + m_projectName = attributes().value(QLatin1String("title")).toString(); + + if (attributes().hasAttribute(QLatin1String("compiler"))) + m_compiler = attributes().value(QLatin1String("compiler")).toString(); + + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseMakeCommands() +{ + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (name() == QLatin1String("Build")) + parseBuildTargetBuild(); + else if (name() == QLatin1String("Clean")) + parseBuildTargetClean(); + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseBuildTargetBuild() +{ + if (attributes().hasAttribute(QLatin1String("command"))) { + m_buildTarget.makeCommand = attributes().value(QLatin1String("command")).toString(); + + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + if (tool) + m_buildTarget.makeCommand = tool->mapAllPaths(m_kit, m_buildTarget.makeCommand); + } + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseBuildTargetClean() +{ + if (attributes().hasAttribute(QLatin1String("command"))) { + m_buildTarget.makeCleanCommand = attributes().value(QLatin1String("command")).toString(); + + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + if (tool) + m_buildTarget.makeCleanCommand = tool->mapAllPaths(m_kit, m_buildTarget.makeCleanCommand); + } + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseCompiler() +{ + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (name() == QLatin1String("Add")) + parseAdd(); + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseAdd() +{ + // CMake only supports <Add option=\> and <Add directory=\> + const QXmlStreamAttributes addAttributes = attributes(); + + QString includeDirectory = addAttributes.value(QLatin1String("directory")).toString(); + + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + if (tool) + includeDirectory = tool->mapAllPaths(m_kit, includeDirectory); + + // allow adding multiple times because order happens + if (!includeDirectory.isEmpty()) + m_buildTarget.includeFiles.append(includeDirectory); + + QString compilerOption = addAttributes.value(QLatin1String("option")).toString(); + // defining multiple times a macro to the same value makes no sense + if (!compilerOption.isEmpty() && !m_buildTarget.compilerOptions.contains(compilerOption)) { + m_buildTarget.compilerOptions.append(compilerOption); + int macroNameIndex = compilerOption.indexOf(QLatin1String("-D")) + 2; + if (macroNameIndex != 1) { + int assignIndex = compilerOption.indexOf(QLatin1Char('='), macroNameIndex); + if (assignIndex != -1) + compilerOption[assignIndex] = ' '; + m_buildTarget.defines.append("#define "); + m_buildTarget.defines.append(compilerOption.mid(macroNameIndex).toUtf8()); + m_buildTarget.defines.append('\n'); + } + } + + while (!atEnd()) { + readNext(); + if (isEndElement()) + return; + else if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseUnit() +{ + //qDebug()<<stream.attributes().value("filename"); + FileName fileName = + FileName::fromUserInput(attributes().value(QLatin1String("filename")).toString()); + + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + if (tool) { + QString mappedFile = tool->mapAllPaths(m_kit, fileName.toString()); + fileName = FileName::fromUserInput(mappedFile); + } + + m_parsingCmakeUnit = false; + while (!atEnd()) { + readNext(); + if (isEndElement()) { + if (!fileName.endsWith(QLatin1String(".rule")) && !m_processedUnits.contains(fileName)) { + // Now check whether we found a virtual element beneath + if (m_parsingCmakeUnit) { + m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false)); + } else { + bool generated = false; + QString onlyFileName = fileName.fileName(); + if ( (onlyFileName.startsWith(QLatin1String("moc_")) && onlyFileName.endsWith(QLatin1String(".cxx"))) + || (onlyFileName.startsWith(QLatin1String("ui_")) && onlyFileName.endsWith(QLatin1String(".h"))) + || (onlyFileName.startsWith(QLatin1String("qrc_")) && onlyFileName.endsWith(QLatin1String(".cxx")))) + generated = true; + + if (fileName.endsWith(QLatin1String(".qrc"))) + m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ResourceType, generated)); + else + m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated)); + } + m_processedUnits.insert(fileName); + } + return; + } else if (name() == QLatin1String("Option")) { + parseUnitOption(); + } else if (isStartElement()) { + parseUnknownElement(); + } + } +} + +void CMakeCbpParser::parseUnitOption() +{ + if (attributes().hasAttribute(QLatin1String("virtualFolder"))) + m_parsingCmakeUnit = true; + + while (!atEnd()) { + readNext(); + + if (isEndElement()) + break; + + if (isStartElement()) + parseUnknownElement(); + } +} + +void CMakeCbpParser::parseUnknownElement() +{ + Q_ASSERT(isStartElement()); + + while (!atEnd()) { + readNext(); + + if (isEndElement()) + break; + + if (isStartElement()) + parseUnknownElement(); + } +} + +QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList() +{ + return m_fileList; +} + +QList<ProjectExplorer::FileNode *> CMakeCbpParser::cmakeFileList() +{ + return m_cmakeFileList; +} + +bool CMakeCbpParser::hasCMakeFiles() +{ + return !m_cmakeFileList.isEmpty(); +} + +QList<CMakeBuildTarget> CMakeCbpParser::buildTargets() +{ + return m_buildTargets; +} + +QString CMakeCbpParser::compilerName() const +{ + return m_compiler; +} + + +} // namespace Internal +} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakecbpparser.h b/src/plugins/cmakeprojectmanager/cmakecbpparser.h new file mode 100644 index 00000000000..f18ff846ffd --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakecbpparser.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H +#define CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H + +#include "cmakeproject.h" + +#include <QXmlStreamReader> + + +namespace ProjectExplorer { +class FileNode; +class Kit; +} + +namespace CMakeProjectManager { +namespace Internal { + +class CMakeCbpParser : public QXmlStreamReader +{ +public: + bool parseCbpFile(ProjectExplorer::Kit *kit, const QString &fileName, const QString &sourceDirectory); + QList<ProjectExplorer::FileNode *> fileList(); + QList<ProjectExplorer::FileNode *> cmakeFileList(); + QList<CMakeBuildTarget> buildTargets(); + QString projectName() const; + QString compilerName() const; + bool hasCMakeFiles(); + +private: + void parseCodeBlocks_project_file(); + void parseProject(); + void parseBuild(); + void parseOption(); + void parseBuildTarget(); + void parseBuildTargetOption(); + void parseMakeCommands(); + void parseBuildTargetBuild(); + void parseBuildTargetClean(); + void parseCompiler(); + void parseAdd(); + void parseUnit(); + void parseUnitOption(); + void parseUnknownElement(); + void sortFiles(); + + ProjectExplorer::Kit *m_kit; + QList<ProjectExplorer::FileNode *> m_fileList; + QList<ProjectExplorer::FileNode *> m_cmakeFileList; + QSet<Utils::FileName> m_processedUnits; + bool m_parsingCmakeUnit; + + CMakeBuildTarget m_buildTarget; + QList<CMakeBuildTarget> m_buildTargets; + QString m_projectName; + QString m_compiler; + QString m_sourceDirectory; + QString m_buildDirectory; +}; + +} // namespace Internal +} // namespace CMakeProjectManager + +#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp index 09907fff529..967f23946ce 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.cpp @@ -264,7 +264,7 @@ QString CMakeDocument::suggestedFileName() const // CMakeEditorFactory // -CMakeEditorFactory::CMakeEditorFactory(CMakeSettingsPage *settingsPage) +CMakeEditorFactory::CMakeEditorFactory() { setId(Constants::CMAKE_EDITOR_ID); setDisplayName(tr(Constants::CMAKE_EDITOR_DISPLAY_NAME)); @@ -278,7 +278,7 @@ CMakeEditorFactory::CMakeEditorFactory(CMakeSettingsPage *settingsPage) setCommentStyle(Utils::CommentDefinition::HashStyle); setCodeFoldingSupported(true); - setCompletionAssistProvider(new CMakeFileCompletionAssistProvider(settingsPage)); + setCompletionAssistProvider(new CMakeFileCompletionAssistProvider); setEditorActionHandlers(TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::JumpToFileUnderCursor); diff --git a/src/plugins/cmakeprojectmanager/cmakeeditor.h b/src/plugins/cmakeprojectmanager/cmakeeditor.h index d56d689b5a5..d8bdb289189 100644 --- a/src/plugins/cmakeprojectmanager/cmakeeditor.h +++ b/src/plugins/cmakeprojectmanager/cmakeeditor.h @@ -58,7 +58,7 @@ class CMakeEditorFactory : public TextEditor::TextEditorFactory Q_OBJECT public: - CMakeEditorFactory(CMakeSettingsPage *settingsPage); + CMakeEditorFactory(); }; } // namespace Internal diff --git a/src/plugins/qtsupport/simulatorqtversionfactory.h b/src/plugins/cmakeprojectmanager/cmakefile.cpp index 51f901cbc08..6812c3f2dfc 100644 --- a/src/plugins/qtsupport/simulatorqtversionfactory.h +++ b/src/plugins/cmakeprojectmanager/cmakefile.cpp @@ -28,28 +28,68 @@ ** ****************************************************************************/ -#ifndef SIMULATORQTVERSIONFACTORY_H -#define SIMULATORQTVERSIONFACTORY_H +#include "cmakefile.h" +#include "cmakeproject.h" +#include "cmakeprojectconstants.h" -#include "qtversionfactory.h" +#include <utils/fileutils.h> -namespace QtSupport { +using namespace Utils; + +namespace CMakeProjectManager { namespace Internal { -class SimulatorQtVersionFactory : public QtVersionFactory +CMakeFile::CMakeFile(CMakeProject *parent, const FileName &fileName) + : Core::IDocument(parent), m_project(parent) +{ + setId("Cmake.ProjectFile"); + setMimeType(QLatin1String(Constants::CMAKEPROJECTMIMETYPE)); + setFilePath(fileName); +} + +bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave) { -public: - explicit SimulatorQtVersionFactory(QObject *parent = 0); - ~SimulatorQtVersionFactory(); + // Once we have an texteditor open for this file, we probably do + // need to implement this, don't we. + Q_UNUSED(errorString) + Q_UNUSED(fileName) + Q_UNUSED(autoSave) + return false; +} - virtual bool canRestore(const QString &type); - virtual BaseQtVersion *restore(const QString &type, const QVariantMap &data); +QString CMakeFile::defaultPath() const +{ + return QString(); +} - virtual int priority() const; - virtual BaseQtVersion *create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); -}; +QString CMakeFile::suggestedFileName() const +{ + return QString(); +} -} // Internal -} // QtSupport +bool CMakeFile::isModified() const +{ + return false; +} -#endif // SIMULATORQTVERSIONFACTORY_H +bool CMakeFile::isSaveAsAllowed() const +{ + return false; +} + +Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const +{ + Q_UNUSED(state) + Q_UNUSED(type) + return BehaviorSilent; +} + +bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) +{ + Q_UNUSED(errorString) + Q_UNUSED(flag) + Q_UNUSED(type) + return true; +} +} // namespace Internal +} // namespace CMakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizardpages.h b/src/plugins/cmakeprojectmanager/cmakefile.h index 92ae1a1c454..19d9099e5d0 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizardpages.h +++ b/src/plugins/cmakeprojectmanager/cmakefile.h @@ -28,33 +28,38 @@ ** ****************************************************************************/ -#ifndef QTQUICKAPPWIZARDPAGES_H -#define QTQUICKAPPWIZARDPAGES_H +#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H +#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H -#include <QWizardPage> -#include "qtquickapp.h" +#include <coreplugin/idocument.h> + +namespace CMakeProjectManager { +class CMakeProject; -namespace QmakeProjectManager { namespace Internal { -class QtQuickComponentSetPage : public QWizardPage +class CMakeFile : public Core::IDocument { Q_OBJECT - public: - explicit QtQuickComponentSetPage(QWidget *parent = 0); - virtual ~QtQuickComponentSetPage(); + CMakeFile(CMakeProject *parent, const Utils::FileName &fileName); + + bool save(QString *errorString, const QString &fileName, bool autoSave); + + QString defaultPath() const; + QString suggestedFileName() const; - TemplateInfo templateInfo() const; + bool isModified() const; + bool isSaveAsAllowed() const; -private slots: - void updateDescription(int index); + ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; + bool reload(QString *errorString, ReloadFlag flag, ChangeType type); private: - class QtQuickComponentSetPagePrivate *d; + CMakeProject *m_project; }; } // namespace Internal -} // namespace QmakeProjectManager +} // namespace CMakeProjectManager -#endif // QTQUICKAPPWIZARDPAGES_H +#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp index f5bdc88cf33..2f1abb1f34a 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp @@ -32,17 +32,26 @@ #include "cmakeprojectconstants.h" #include "cmakeprojectmanager.h" #include "cmakesettingspage.h" +#include "cmaketoolmanager.h" +#include "cmakekitinformation.h" -#include <texteditor/codeassist/keywordscompletionassist.h> +#include <texteditor/codeassist/assistinterface.h> +#include <projectexplorer/projecttree.h> +#include <projectexplorer/project.h> +#include <projectexplorer/kit.h> +#include <projectexplorer/target.h> + +#include <coreplugin/editormanager/editormanager.h> +#include <projectexplorer/session.h> using namespace CMakeProjectManager::Internal; using namespace TextEditor; +using namespace ProjectExplorer; // ------------------------------- // CMakeFileCompletionAssistProvider // ------------------------------- -CMakeFileCompletionAssistProvider::CMakeFileCompletionAssistProvider(CMakeSettingsPage *settingsPage) - : m_settingsPage(settingsPage) +CMakeFileCompletionAssistProvider::CMakeFileCompletionAssistProvider() {} CMakeFileCompletionAssistProvider::~CMakeFileCompletionAssistProvider() @@ -55,5 +64,31 @@ bool CMakeFileCompletionAssistProvider::supportsEditor(Core::Id editorId) const IAssistProcessor *CMakeFileCompletionAssistProvider::createProcessor() const { - return new KeywordsCompletionAssistProcessor(m_settingsPage->keywords()); + return new CMakeFileCompletionAssist(); +} + + +CMakeFileCompletionAssist::CMakeFileCompletionAssist() : + KeywordsCompletionAssistProcessor(Keywords()) +{} + +IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *interface) +{ + TextEditor::Keywords keywords; + + QString fileName = interface->fileName(); + if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) { + Utils::FileName file = Utils::FileName::fromString(fileName); + if (Project *p = SessionManager::projectForFile(file)) { + if (Target *t = p->activeTarget()) { + if (CMakeTool *cmake = CMakeKitInformation::cmakeTool(t->kit())) { + if (cmake->isValid()) + keywords = cmake->keywords(); + } + } + } + } + + setKeywords(keywords); + return KeywordsCompletionAssistProcessor::perform(interface); } diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h index 6f1a4721047..4a0de7ff880 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.h @@ -32,25 +32,32 @@ #define CMAKEFILECOMPLETIONASSIST_H #include <texteditor/codeassist/completionassistprovider.h> +#include <texteditor/codeassist/keywordscompletionassist.h> namespace CMakeProjectManager { namespace Internal { class CMakeSettingsPage; +class CMakeFileCompletionAssist : public TextEditor::KeywordsCompletionAssistProcessor +{ +public: + CMakeFileCompletionAssist(); + + // IAssistProcessor interface + TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) Q_DECL_OVERRIDE; +}; + class CMakeFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider { Q_OBJECT public: - CMakeFileCompletionAssistProvider(CMakeSettingsPage *settingsPage); + CMakeFileCompletionAssistProvider(); ~CMakeFileCompletionAssistProvider(); bool supportsEditor(Core::Id editorId) const; TextEditor::IAssistProcessor *createProcessor() const; - -private: - CMakeSettingsPage *m_settingsPage; }; } // Internal diff --git a/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp new file mode 100644 index 00000000000..b949423a417 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmakeprojectconstants.h" +#include "cmakekitconfigwidget.h" +#include "cmakekitinformation.h" +#include "cmaketoolmanager.h" +#include "cmaketool.h" + +#include <utils/qtcassert.h> +#include <coreplugin/icore.h> +#include <projectexplorer/kit.h> +#include <projectexplorer/projectexplorerconstants.h> + +#include <QComboBox> +#include <QPushButton> + +namespace CMakeProjectManager { +namespace Internal { + +CMakeKitConfigWidget::CMakeKitConfigWidget(ProjectExplorer::Kit *kit, + const ProjectExplorer::KitInformation *ki) : + ProjectExplorer::KitConfigWidget(kit, ki), + m_removingItem(false) +{ + m_comboBox = new QComboBox; + m_comboBox->setEnabled(false); + m_comboBox->setToolTip(toolTip()); + + foreach (CMakeTool *tool, CMakeToolManager::cmakeTools()) + cmakeToolAdded(tool->id()); + + updateComboBox(); + + refresh(); + connect(m_comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &CMakeKitConfigWidget::currentCMakeToolChanged); + + m_manageButton = new QPushButton(KitConfigWidget::msgManage()); + m_manageButton->setContentsMargins(0, 0, 0, 0); + connect(m_manageButton, &QPushButton::clicked, + this, &CMakeKitConfigWidget::manageCMakeTools); + + CMakeToolManager *cmakeMgr = CMakeToolManager::instance(); + connect(cmakeMgr, &CMakeToolManager::cmakeAdded, + this, &CMakeKitConfigWidget::cmakeToolAdded); + connect(cmakeMgr, &CMakeToolManager::cmakeRemoved, + this, &CMakeKitConfigWidget::cmakeToolRemoved); + connect(cmakeMgr, &CMakeToolManager::cmakeUpdated, + this, &CMakeKitConfigWidget::cmakeToolUpdated); +} + +CMakeKitConfigWidget::~CMakeKitConfigWidget() +{ + delete m_comboBox; + delete m_manageButton; +} + +QString CMakeKitConfigWidget::displayName() const +{ + return tr("CMake Tool:"); +} + +void CMakeKitConfigWidget::makeReadOnly() +{ + m_comboBox->setEnabled(false); +} + +void CMakeKitConfigWidget::refresh() +{ + CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit); + m_comboBox->setCurrentIndex(tool == 0 ? -1 : indexOf(tool->id())); +} + +QWidget *CMakeKitConfigWidget::mainWidget() const +{ + return m_comboBox; +} + +QWidget *CMakeKitConfigWidget::buttonWidget() const +{ + return m_manageButton; +} + +QString CMakeKitConfigWidget::toolTip() const +{ + return tr("The CMake Tool to use when building a project with CMake.<br>" + "This setting is ignored when using other build systems."); +} + +int CMakeKitConfigWidget::indexOf(const Core::Id &id) +{ + for (int i = 0; i < m_comboBox->count(); ++i) { + if (id == Core::Id::fromSetting(m_comboBox->itemData(i))) + return i; + } + return -1; +} + +void CMakeKitConfigWidget::cmakeToolAdded(const Core::Id &id) +{ + const CMakeTool *tool = CMakeToolManager::findById(id); + QTC_ASSERT(tool, return); + + m_comboBox->addItem(tool->displayName(), tool->id().toSetting()); + updateComboBox(); + refresh(); +} + +void CMakeKitConfigWidget::cmakeToolUpdated(const Core::Id &id) +{ + const int pos = indexOf(id); + QTC_ASSERT(pos >= 0, return); + + const CMakeTool *tool = CMakeToolManager::findById(id); + QTC_ASSERT(tool, return); + + m_comboBox->setItemText(pos, tool->displayName()); +} + +void CMakeKitConfigWidget::cmakeToolRemoved(const Core::Id &id) +{ + const int pos = indexOf(id); + QTC_ASSERT(pos >= 0, return); + + // do not handle the current index changed signal + m_removingItem = true; + m_comboBox->removeItem(pos); + m_removingItem = false; + + // update the checkbox and set the current index + updateComboBox(); + refresh(); +} + +void CMakeKitConfigWidget::updateComboBox() +{ + // remove unavailable cmake tool: + int pos = indexOf(Core::Id()); + if (pos >= 0) + m_comboBox->removeItem(pos); + + if (m_comboBox->count() == 0) { + m_comboBox->addItem(tr("<No CMake Tool available>"), + Core::Id().toSetting()); + m_comboBox->setEnabled(false); + } else { + m_comboBox->setEnabled(true); + } +} + +void CMakeKitConfigWidget::currentCMakeToolChanged(int index) +{ + if (m_removingItem) + return; + + const Core::Id id = Core::Id::fromSetting(m_comboBox->itemData(index)); + CMakeKitInformation::setCMakeTool(m_kit, id); +} + +void CMakeKitConfigWidget::manageCMakeTools() +{ + Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID, + buttonWidget()); +} + +} // namespace Internal +} // namespace CMakeProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizard.h b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h index e17b21a0930..93fac8550ee 100644 --- a/src/plugins/qmlprojectmanager/qmlapplicationwizard.h +++ b/src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Canonical Ltd. ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. @@ -27,56 +27,56 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H +#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H -#ifndef QMLAPPLICATIONWIZARD_H -#define QMLAPPLICATIONWIZARD_H +#include <projectexplorer/kitconfigwidget.h> -#include <coreplugin/basefilewizardfactory.h> -#include <projectexplorer/baseprojectwizarddialog.h> +namespace ProjectExplorer { + class Kit; + class KitInformation; +} -namespace ExtensionSystem { class IPlugin; } +QT_FORWARD_DECLARE_CLASS(QComboBox) +QT_FORWARD_DECLARE_CLASS(QPushButton) -namespace QmlProjectManager { -namespace Internal { - -class QmlApp; -class TemplateInfo; -class QmlComponentSetPage; - -class QmlApplicationWizardDialog : public ProjectExplorer::BaseProjectWizardDialog -{ - Q_OBJECT -public: - QmlApplicationWizardDialog(QWidget *parent, - const Core::WizardDialogParameters ¶meters); +namespace CMakeProjectManager { - TemplateInfo templateInfo() const; - -private: - QmlComponentSetPage *m_componentSetPage; -}; +class CMakeTool; +namespace Internal { -class QmlApplicationWizard : public Core::BaseFileWizardFactory +class CMakeKitConfigWidget : public ProjectExplorer::KitConfigWidget { Q_OBJECT - public: - QmlApplicationWizard(); + CMakeKitConfigWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki); + virtual ~CMakeKitConfigWidget(); - static void createInstances(ExtensionSystem::IPlugin *plugin); + // KitConfigWidget interface + QString displayName() const Q_DECL_OVERRIDE; + void makeReadOnly() Q_DECL_OVERRIDE; + void refresh() Q_DECL_OVERRIDE; + QWidget *mainWidget() const Q_DECL_OVERRIDE; + QWidget *buttonWidget() const Q_DECL_OVERRIDE; + QString toolTip() const Q_DECL_OVERRIDE; private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; - void writeUserFile(const QString &fileName) const; - bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); + int indexOf(const Core::Id &id); + void updateComboBox(); + void cmakeToolAdded(const Core::Id &id); + void cmakeToolUpdated(const Core::Id &id); + void cmakeToolRemoved(const Core::Id &id); + void currentCMakeToolChanged(int index); + void manageCMakeTools(); private: - QmlApp *m_qmlApp; + bool m_removingItem; + QComboBox *m_comboBox; + QPushButton *m_manageButton; }; } // namespace Internal -} // namespace QmlProjectManager +} // namespace CMakeProjectManager -#endif // QMLAPPLICATIONWIZARD_H +#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H diff --git a/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp new file mode 100644 index 00000000000..b0ce2c96f58 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.cpp @@ -0,0 +1,135 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "cmakekitinformation.h" +#include "cmakekitconfigwidget.h" +#include "cmaketoolmanager.h" +#include "cmaketool.h" + +#include <utils/qtcassert.h> +#include <projectexplorer/task.h> +#include <projectexplorer/kit.h> +#include <projectexplorer/projectexplorerconstants.h> + +#include <QDebug> + +using namespace ProjectExplorer; + +namespace CMakeProjectManager { + +CMakeKitInformation::CMakeKitInformation() +{ + setObjectName(QLatin1String("CMakeKitInformation")); + setId(CMakeKitInformation::id()); + + //make sure the default value is set if a selected CMake is removed + connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved, + [this]() { foreach (Kit *k, KitManager::kits()) fix(k); }); + + //make sure the default value is set if a new default CMake is set + connect(CMakeToolManager::instance(), &CMakeToolManager::defaultCMakeChanged, + [this]() { foreach (Kit *k, KitManager::kits()) fix(k); }); +} + +Core::Id CMakeKitInformation::id() +{ + return "CMakeProjectManager.CMakeKitInformation"; +} + +CMakeTool *CMakeKitInformation::cmakeTool(const Kit *k) +{ + if (!k) + return 0; + + const QVariant id = k->value(CMakeKitInformation::id()); + return CMakeToolManager::findById(Core::Id::fromSetting(id)); +} + +void CMakeKitInformation::setCMakeTool(Kit *k, const Core::Id id) +{ + QTC_ASSERT(k, return); + + if (id.isValid()) { + // Only set cmake tools that are known to the manager + QTC_ASSERT(CMakeToolManager::findById(id), return); + k->setValue(CMakeKitInformation::id(), id.toSetting()); + } else { + //setting a empty Core::Id will reset to the default value + k->setValue(CMakeKitInformation::id(),defaultValue().toSetting()); + } +} + +Core::Id CMakeKitInformation::defaultValue() +{ + CMakeTool *defaultTool = CMakeToolManager::defaultCMakeTool(); + if (defaultTool) + return defaultTool->id(); + + return Core::Id(); +} + +QVariant CMakeKitInformation::defaultValue(Kit *) const +{ + return defaultValue().toSetting(); +} + +QList<Task> CMakeKitInformation::validate(const Kit *k) const +{ + Q_UNUSED(k); + return QList<Task>(); +} + +void CMakeKitInformation::setup(Kit *k) +{ + CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + if (tool) + return; + + setCMakeTool(k, defaultValue()); +} + +void CMakeKitInformation::fix(Kit *k) +{ + CMakeTool *tool = CMakeKitInformation::cmakeTool(k); + if (!tool) + setup(k); +} + +KitInformation::ItemList CMakeKitInformation::toUserOutput(const Kit *k) const +{ + CMakeTool *tool = cmakeTool(k); + return ItemList() << qMakePair(tr("CMake"), tool == 0 ? tr("Unconfigured") : tool->displayName()); +} + +KitConfigWidget *CMakeKitInformation::createConfigWidget(Kit *k) const +{ + return new Internal::CMakeKitConfigWidget(k, this); +} + +} // namespace CMakeProjectManager diff --git a/src/plugins/git/clonewizardpage.h b/src/plugins/cmakeprojectmanager/cmakekitinformation.h index 2decbf68e5c..8bfade71a5f 100644 --- a/src/plugins/git/clonewizardpage.h +++ b/src/plugins/cmakeprojectmanager/cmakekitinformation.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Canonical Ltd. ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. @@ -27,41 +27,38 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#ifndef CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H +#define CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H -#ifndef CLONEWIZARDPAGE_H -#define CLONEWIZARDPAGE_H +#include "cmake_global.h" -#include <vcsbase/basecheckoutwizardpage.h> +#include <projectexplorer/kitmanager.h> -#include <utils/fileutils.h> +namespace CMakeProjectManager { -namespace VcsBase { class VcsCommand; } +class CMakeTool; -namespace Git { - -struct CloneWizardPagePrivate; - -class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage +class CMAKE_EXPORT CMakeKitInformation : public ProjectExplorer::KitInformation { Q_OBJECT public: - explicit CloneWizardPage(QWidget *parent = 0); - ~CloneWizardPage(); + CMakeKitInformation(); - VcsBase::VcsCommand *createCheckoutJob(Utils::FileName *checkoutPath) const; + static Core::Id id(); -protected: - QString directoryFromRepository(const QString &r) const; - QStringList branches(const QString &repository, int *current); + static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k); + static void setCMakeTool(ProjectExplorer::Kit *k, const Core::Id id); + static Core::Id defaultValue(); -#ifdef WITH_TESTS -public: - void testDirectoryFromRepository(); -#endif - -private: - CloneWizardPagePrivate *d; + // KitInformation interface + QVariant defaultValue(ProjectExplorer::Kit *) const Q_DECL_OVERRIDE; + QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE; + void setup(ProjectExplorer::Kit *k) Q_DECL_OVERRIDE; + void fix(ProjectExplorer::Kit *k) Q_DECL_OVERRIDE; + virtual ItemList toUserOutput(const ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE; + virtual ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE; }; -} // namespace Git -#endif // CLONEWIZARDPAGE_H +} // namespace CMakeProjectManager + +#endif // CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp index 44c584ffb36..0e24b2e499f 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.cpp @@ -28,10 +28,14 @@ ** ****************************************************************************/ +#include "cmakeprojectconstants.h" #include "cmakeopenprojectwizard.h" #include "cmakeprojectmanager.h" +#include "cmaketoolmanager.h" #include "cmakebuildconfiguration.h" #include "cmakebuildinfo.h" +#include "cmakekitinformation.h" +#include "cmaketool.h" #include "generatorinfo.h" #include <coreplugin/icore.h> @@ -84,6 +88,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm m_useNinja(false), m_kit(0) { + if (CMakeToolManager::cmakeTools().isEmpty()) + addPage(new NoCMakePage(this)); + if (!compatibleKitExist()) addPage(new NoKitPage(this)); @@ -95,9 +102,6 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm addPage(new ShadowBuildPage(this)); } - if (!m_cmakeManager->isCMakeExecutableValid()) - addPage(new ChooseCMakePage(this)); - addPage(new CMakeRunPage(this)); init(); @@ -128,8 +132,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm m_buildDirectory = info->buildDirectory.toString(); addPage(new ShadowBuildPage(this, true)); } - if (!m_cmakeManager->isCMakeExecutableValid()) - addPage(new ChooseCMakePage(this)); + + if (CMakeToolManager::cmakeTools().isEmpty()) + addPage(new NoCMakePage(this)); addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString())); init(); @@ -152,13 +157,17 @@ bool CMakeOpenProjectWizard::hasInSourceBuild() const bool CMakeOpenProjectWizard::compatibleKitExist() const { - bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator(); - bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator(); bool preferNinja = m_cmakeManager->preferNinja(); - QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); foreach (ProjectExplorer::Kit *k, kitList) { + CMakeTool *cmake = CMakeKitInformation::cmakeTool(k); + if (!cmake) + continue; + + bool hasCodeBlocksGenerator = cmake->hasCodeBlocksMsvcGenerator(); + bool hasNinjaGenerator = cmake->hasCodeBlocksNinjaGenerator(); + // OfferNinja and ForceNinja differ in what they return // but not whether the list is empty or not, which is what we // are interested in here @@ -287,6 +296,12 @@ bool NoKitPage::isComplete() const return m_cmakeWizard->compatibleKitExist(); } +void NoKitPage::initializePage() +{ + //if the NoCMakePage was added, we need to recheck if kits exist + kitsChanged(); +} + void NoKitPage::showOptions() { Core::ICore::showOptionsDialog(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID, this); @@ -337,61 +352,60 @@ void ShadowBuildPage::buildDirectoryChanged() m_cmakeWizard->setBuildDirectory(m_pc->path()); } -ChooseCMakePage::ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard) - : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) +////// +// NoCMakePage +///// + +NoCMakePage::NoCMakePage(CMakeOpenProjectWizard *cmakeWizard) + : QWizardPage(cmakeWizard) { - QFormLayout *fl = new QFormLayout; - fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - setLayout(fl); + QVBoxLayout *layout = new QVBoxLayout; + setLayout(layout); + + m_descriptionLabel = new QLabel(this); + m_descriptionLabel->setWordWrap(true); + layout->addWidget(m_descriptionLabel); + + m_optionsButton = new QPushButton; + m_optionsButton->setText(Core::ICore::msgShowOptionsDialog()); + + connect(m_optionsButton, SIGNAL(clicked()), + this, SLOT(showOptions())); + + QHBoxLayout *hbox = new QHBoxLayout; + hbox->addWidget(m_optionsButton); + hbox->addStretch(); - m_cmakeLabel = new QLabel; - m_cmakeLabel->setWordWrap(true); - fl->addRow(m_cmakeLabel); - // Show a field for the user to enter - m_cmakeExecutable = new Utils::PathChooser(this); - m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_cmakeExecutable->setHistoryCompleter(QLatin1String("Cmake.Command.History")); - fl->addRow(tr("CMake Executable:"), m_cmakeExecutable); + layout->addLayout(hbox); + + setTitle(tr("Check CMake Tools")); - connect(m_cmakeExecutable, SIGNAL(editingFinished()), - this, SLOT(cmakeExecutableChanged())); - connect(m_cmakeExecutable, SIGNAL(browsingFinished()), - this, SLOT(cmakeExecutableChanged())); + connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeToolsChanged, + this, &NoCMakePage::cmakeToolsChanged); - setTitle(tr("Choose CMake Executable")); + cmakeToolsChanged(); } -void ChooseCMakePage::updateErrorText() +void NoCMakePage::cmakeToolsChanged() { - QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable(); - if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { - m_cmakeLabel->setText(tr("The CMake executable is valid.")); + if (isComplete()) { + m_descriptionLabel->setText(tr("There are CMake Tools registered.")); + m_optionsButton->setVisible(false); } else { - QString text = tr("Specify the path to the CMake executable. No CMake executable was found in the path."); - if (!cmakeExecutable.isEmpty()) { - text += QLatin1Char(' '); - QFileInfo fi(cmakeExecutable); - if (!fi.exists()) - text += tr("The CMake executable (%1) does not exist.").arg(cmakeExecutable); - else if (!fi.isExecutable()) - text += tr("The path %1 is not an executable.").arg(cmakeExecutable); - else - text += tr("The path %1 is not a valid CMake executable.").arg(cmakeExecutable); - } - m_cmakeLabel->setText(text); + m_descriptionLabel->setText(tr("Qt Creator has no CMake Tools that are required for CMake projects. Please configure at least one.")); + m_optionsButton->setVisible(true); } + emit completeChanged(); } -void ChooseCMakePage::cmakeExecutableChanged() +bool NoCMakePage::isComplete() const { - m_cmakeWizard->cmakeManager()->setCMakeExecutable(m_cmakeExecutable->path()); - updateErrorText(); - emit completeChanged(); + return !CMakeToolManager::cmakeTools().isEmpty(); } -bool ChooseCMakePage::isComplete() const +void NoCMakePage::showOptions() { - return m_cmakeWizard->cmakeManager()->isCMakeExecutableValid(); + Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID, this); } CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory) @@ -524,8 +538,6 @@ void CMakeRunPage::initializePage() // Build the list of generators/toolchains we want to offer m_generatorComboBox->clear(); - bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator(); - bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator(); bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja(); if (m_mode == Initial) { @@ -537,6 +549,13 @@ void CMakeRunPage::initializePage() int defaultIndex = 0; foreach (ProjectExplorer::Kit *k, kitList) { + CMakeTool *cmake = CMakeKitInformation::cmakeTool(k); + if (!cmake) + continue; + + bool hasCodeBlocksGenerator = cmake->hasCodeBlocksMsvcGenerator(); + bool hasNinjaGenerator = cmake->hasCodeBlocksNinjaGenerator(); + QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k, hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, preferNinja, @@ -561,22 +580,26 @@ void CMakeRunPage::initializePage() m_generatorComboBox->setCurrentIndex(defaultIndex); } else { - // Note: We don't compare the actually cached generator to what is set in the buildconfiguration - // We assume that the buildconfiguration is correct - GeneratorInfo::Ninja ninja; - if (m_mode == CMakeRunPage::NeedToUpdate || m_mode == CMakeRunPage::WantToUpdate) { - ninja = m_cmakeWizard->useNinja() ? GeneratorInfo::ForceNinja : GeneratorInfo::NoNinja; - } else { // Recreate, ChangeDirectory - // Note: ReCreate is technically just a removed .cbp file, we assume the cache - // got removed too. If the cache still exists the error message from cmake should - // be a good hint to change the generator - ninja = hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja; - } + QList<GeneratorInfo> infos; + CMakeTool *cmake = CMakeKitInformation::cmakeTool(m_cmakeWizard->kit()); + if (cmake) { + // Note: We don't compare the actually cached generator to what is set in the buildconfiguration + // We assume that the buildconfiguration is correct + GeneratorInfo::Ninja ninja; + if (m_mode == CMakeRunPage::NeedToUpdate || m_mode == CMakeRunPage::WantToUpdate) { + ninja = m_cmakeWizard->useNinja() ? GeneratorInfo::ForceNinja : GeneratorInfo::NoNinja; + } else { // Recreate, ChangeDirectory + // Note: ReCreate is technically just a removed .cbp file, we assume the cache + // got removed too. If the cache still exists the error message from cmake should + // be a good hint to change the generator + ninja = cmake->hasCodeBlocksNinjaGenerator() ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja; + } - QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(), - ninja, - preferNinja, - true); + infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(), + ninja, + preferNinja, + true); + } foreach (const GeneratorInfo &info, infos) m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info)); } @@ -619,19 +642,21 @@ void CMakeRunPage::runCMake() m_output->clear(); + CMakeTool *cmake = CMakeKitInformation::cmakeTool(generatorInfo.kit()); CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager(); - if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { + if (cmake && cmake->isValid()) { m_cmakeProcess = new Utils::QtcProcess(); connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput())); connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError())); connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); - cmakeManager->createXmlFile(m_cmakeProcess, m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(), - m_buildDirectory, env, QString::fromLatin1(generatorInfo.generatorArgument())); + cmakeManager->createXmlFile(m_cmakeProcess, cmake->cmakeExecutable().toString(), m_argumentsLineEdit->text(), + m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, + QString::fromLatin1(generatorInfo.generatorArgument())); } else { m_runCMake->setEnabled(true); m_argumentsLineEdit->setEnabled(true); m_generatorComboBox->setEnabled(true); - m_output->appendPlainText(tr("No valid CMake executable specified.")); + m_output->appendPlainText(tr("Selected Kit has no valid CMake executable specified.")); } } @@ -657,6 +682,7 @@ void CMakeRunPage::cmakeReadyReadStandardOutput() void CMakeRunPage::cmakeReadyReadStandardError() { QTextCursor cursor(m_output->document()); + cursor.movePosition(QTextCursor::End); QTextCharFormat tf; QFont font = m_output->font(); diff --git a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h index f8ac05c0a54..206c6ecd00f 100644 --- a/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h +++ b/src/plugins/cmakeprojectmanager/cmakeopenprojectwizard.h @@ -109,7 +109,8 @@ class NoKitPage : public QWizardPage Q_OBJECT public: NoKitPage(CMakeOpenProjectWizard *cmakeWizard); - bool isComplete() const; + bool isComplete() const Q_DECL_OVERRIDE; + void initializePage() Q_DECL_OVERRIDE; private slots: void kitsChanged(); void showOptions(); @@ -140,20 +141,18 @@ private: Utils::PathChooser *m_pc; }; -class ChooseCMakePage : public QWizardPage +class NoCMakePage : public QWizardPage { Q_OBJECT public: - ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard); - - virtual bool isComplete() const; -public slots: - void cmakeExecutableChanged(); + NoCMakePage(CMakeOpenProjectWizard *cmakeWizard); + bool isComplete() const; +private slots: + void cmakeToolsChanged(); + void showOptions(); private: - void updateErrorText(); - QLabel *m_cmakeLabel; - CMakeOpenProjectWizard *m_cmakeWizard; - Utils::PathChooser *m_cmakeExecutable; + QLabel *m_descriptionLabel; + QPushButton *m_optionsButton; }; class CMakeRunPage : public QWizardPage diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.cpp b/src/plugins/cmakeprojectmanager/cmakeparser.cpp index 354fb70681b..4802eef763a 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeparser.cpp @@ -71,15 +71,18 @@ void CMakeParser::stdError(const QString &line) if (m_commonError.indexIn(trimmedLine) != -1) { m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_commonError.cap(1)), m_commonError.cap(2).toInt(), Constants::TASK_CATEGORY_BUILDSYSTEM); + m_lines = 1; return; } else if (m_nextSubError.indexIn(trimmedLine) != -1) { m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_nextSubError.cap(1)), -1, Constants::TASK_CATEGORY_BUILDSYSTEM); + m_lines = 1; return; } else if (trimmedLine.startsWith(QLatin1String(" ")) && !m_lastTask.isNull()) { if (!m_lastTask.description.isEmpty()) m_lastTask.description.append(QLatin1Char(' ')); m_lastTask.description.append(trimmedLine.trimmed()); + ++m_lines; return; } @@ -92,7 +95,8 @@ void CMakeParser::doFlush() return; Task t = m_lastTask; m_lastTask.clear(); - emit addTask(t); + emit addTask(t, m_lines, 1); + m_lines = 0; } #ifdef WITH_TESTS diff --git a/src/plugins/cmakeprojectmanager/cmakeparser.h b/src/plugins/cmakeprojectmanager/cmakeparser.h index 48148609f93..f0432b93dae 100644 --- a/src/plugins/cmakeprojectmanager/cmakeparser.h +++ b/src/plugins/cmakeprojectmanager/cmakeparser.h @@ -53,6 +53,7 @@ private: QRegExp m_commonError; QRegExp m_nextSubError; bool m_skippedFirstEmptyLine; + int m_lines = 0; }; } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index a0392a8d00c..ef10812ffdf 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -36,9 +36,11 @@ #include "cmakerunconfiguration.h" #include "makestep.h" #include "cmakeopenprojectwizard.h" +#include "cmakecbpparser.h" +#include "cmakefile.h" +#include "cmakeprojectmanager.h" #include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/projectexplorer.h> #include <projectexplorer/headerpath.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildmanager.h> @@ -46,7 +48,7 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/kitmanager.h> #include <projectexplorer/toolchain.h> -#include <projectexplorer/target.h> + #include <projectexplorer/deployconfiguration.h> #include <projectexplorer/deploymentdata.h> #include <qtsupport/customexecutablerunconfiguration.h> @@ -65,7 +67,6 @@ #include <QDebug> #include <QDir> -#include <QFormLayout> #include <QFileSystemWatcher> using namespace CMakeProjectManager; @@ -255,12 +256,14 @@ bool CMakeProject::parseCMakeLists() return false; } + Kit *k = activeTarget()->kit(); + // setFolderName m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName()); CMakeCbpParser cbpparser; // Parsing //qDebug()<<"Parsing file "<<cbpFile; - if (!cbpparser.parseCbpFile(cbpFile, projectDirectory().toString())) { + if (!cbpparser.parseCbpFile(k,cbpFile, projectDirectory().toString())) { // TODO report error emit buildTargetsChanged(); return false; @@ -314,7 +317,6 @@ bool CMakeProject::parseCMakeLists() createUiCodeModelSupport(); - Kit *k = activeTarget()->kit(); ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if (!tc) { emit buildTargetsChanged(); @@ -326,6 +328,16 @@ bool CMakeProject::parseCMakeLists() CppTools::ProjectInfo pinfo(this); CppTools::ProjectPartBuilder ppBuilder(pinfo); + CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt; + if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k)) { + if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0)) + activeQtVersion = CppTools::ProjectPart::Qt4; + else + activeQtVersion = CppTools::ProjectPart::Qt5; + } + + ppBuilder.setQtVersion(activeQtVersion); + foreach (const CMakeBuildTarget &cbt, m_buildTargets) { // This explicitly adds -I. to the include paths QStringList includePaths = cbt.includeFiles; @@ -477,7 +489,7 @@ Core::IDocument *CMakeProject::document() const return m_file; } -CMakeManager *CMakeProject::projectManager() const +IProjectManager *CMakeProject::projectManager() const { return m_manager; } @@ -741,548 +753,6 @@ void CMakeProject::createUiCodeModelSupport() QtSupport::UiCodeModelManager::update(this, uiFileHash); } -// CMakeFile - -CMakeFile::CMakeFile(CMakeProject *parent, const FileName &fileName) - : Core::IDocument(parent), m_project(parent) -{ - setId("Cmake.ProjectFile"); - setMimeType(QLatin1String(Constants::CMAKEPROJECTMIMETYPE)); - setFilePath(fileName); -} - -bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave) -{ - // Once we have an texteditor open for this file, we probably do - // need to implement this, don't we. - Q_UNUSED(errorString) - Q_UNUSED(fileName) - Q_UNUSED(autoSave) - return false; -} - -QString CMakeFile::defaultPath() const -{ - return QString(); -} - -QString CMakeFile::suggestedFileName() const -{ - return QString(); -} - -bool CMakeFile::isModified() const -{ - return false; -} - -bool CMakeFile::isSaveAsAllowed() const -{ - return false; -} - -Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const -{ - Q_UNUSED(state) - Q_UNUSED(type) - return BehaviorSilent; -} - -bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) -{ - Q_UNUSED(errorString) - Q_UNUSED(flag) - Q_UNUSED(type) - return true; -} - -CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) : m_buildConfiguration(0) -{ - QFormLayout *fl = new QFormLayout(this); - fl->setContentsMargins(20, -1, 0, -1); - fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - setLayout(fl); - - QPushButton *runCmakeButton = new QPushButton(tr("Run CMake...")); - connect(runCmakeButton, SIGNAL(clicked()), - this, SLOT(runCMake())); - fl->addRow(tr("Reconfigure project:"), runCmakeButton); - - m_pathLineEdit = new QLineEdit(this); - m_pathLineEdit->setReadOnly(true); - - QHBoxLayout *hbox = new QHBoxLayout(); - hbox->addWidget(m_pathLineEdit); - - m_changeButton = new QPushButton(this); - m_changeButton->setText(tr("&Change")); - connect(m_changeButton, SIGNAL(clicked()), this, SLOT(openChangeBuildDirectoryDialog())); - hbox->addWidget(m_changeButton); - - fl->addRow(tr("Build directory:"), hbox); - - m_buildConfiguration = bc; - m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); - if (m_buildConfiguration->buildDirectory() == bc->target()->project()->projectDirectory()) - m_changeButton->setEnabled(false); - else - m_changeButton->setEnabled(true); - - setDisplayName(tr("CMake")); -} - -void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() -{ - CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); - CMakeBuildInfo info(m_buildConfiguration); - CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), - project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, - &info); - if (copw.exec() == QDialog::Accepted) { - project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory()); - m_buildConfiguration->setUseNinja(copw.useNinja()); - m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); - } -} - -void CMakeBuildSettingsWidget::runCMake() -{ - if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles()) - return; - CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project()); - CMakeBuildInfo info(m_buildConfiguration); - CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), - project->projectManager(), - CMakeOpenProjectWizard::WantToUpdate, &info); - if (copw.exec() == QDialog::Accepted) - project->parseCMakeLists(); -} - -///// -// CMakeCbpParser -//// - -namespace { -int distance(const QString &targetDirectory, const FileName &fileName) -{ - const QString commonParent = Utils::commonPath(QStringList() << targetDirectory << fileName.toString()); - return targetDirectory.mid(commonParent.size()).count(QLatin1Char('/')) - + fileName.toString().mid(commonParent.size()).count(QLatin1Char('/')); -} -} - -// called after everything is parsed -// this function tries to figure out to which CMakeBuildTarget -// each file belongs, so that it gets the appropriate defines and -// compiler flags -void CMakeCbpParser::sortFiles() -{ - QLoggingCategory log("qtc.cmakeprojectmanager.filetargetmapping"); - QList<FileName> fileNames = Utils::transform(m_fileList, [] (FileNode *node) { - return node->path(); - }); - - Utils::sort(fileNames); - - - CMakeBuildTarget *last = 0; - FileName parentDirectory; - - qCDebug(log) << "###############"; - qCDebug(log) << "# Pre Dump #"; - qCDebug(log) << "###############"; - foreach (const CMakeBuildTarget &target, m_buildTargets) - qCDebug(log) << target.title << target.sourceDirectory << - target.includeFiles << target.defines << target.files << "\n"; - - // find a good build target to fall back - int fallbackIndex = 0; - { - int bestIncludeCount = -1; - for (int i = 0; i < m_buildTargets.size(); ++i) { - const CMakeBuildTarget &target = m_buildTargets.at(i); - if (target.includeFiles.isEmpty()) - continue; - if (target.sourceDirectory == m_sourceDirectory - && target.includeFiles.count() > bestIncludeCount) { - bestIncludeCount = target.includeFiles.count(); - fallbackIndex = i; - } - } - } - - qCDebug(log) << "###############"; - qCDebug(log) << "# Sorting #"; - qCDebug(log) << "###############"; - - foreach (const FileName &fileName, fileNames) { - qCDebug(log) << fileName; - if (fileName.parentDir() == parentDirectory && last) { - // easy case, same parent directory as last file - last->files.append(fileName.toString()); - qCDebug(log) << " into" << last->title; - } else { - int bestDistance = std::numeric_limits<int>::max(); - int bestIndex = -1; - int bestIncludeCount = -1; - - for (int i = 0; i < m_buildTargets.size(); ++i) { - const CMakeBuildTarget &target = m_buildTargets.at(i); - if (target.includeFiles.isEmpty()) - continue; - int dist = distance(target.sourceDirectory, fileName); - qCDebug(log) << "distance to target" << target.title << dist; - if (dist < bestDistance || - (dist == bestDistance && - target.includeFiles.count() > bestIncludeCount)) { - bestDistance = dist; - bestIncludeCount = target.includeFiles.count(); - bestIndex = i; - } - } - - if (bestIndex == -1 && !m_buildTargets.isEmpty()) { - bestIndex = fallbackIndex; - qCDebug(log) << " using fallbackIndex"; - } - - if (bestIndex != -1) { - m_buildTargets[bestIndex].files.append(fileName.toString()); - last = &m_buildTargets[bestIndex]; - parentDirectory = fileName.parentDir(); - qCDebug(log) << " into" << last->title; - } - } - } - - qCDebug(log) << "###############"; - qCDebug(log) << "# After Dump #"; - qCDebug(log) << "###############"; - foreach (const CMakeBuildTarget &target, m_buildTargets) - qCDebug(log) << target.title << target.sourceDirectory << target.includeFiles << target.defines << target.files << "\n"; -} - -bool CMakeCbpParser::parseCbpFile(const QString &fileName, const QString &sourceDirectory) -{ - m_buildDirectory = QFileInfo(fileName).absolutePath(); - m_sourceDirectory = sourceDirectory; - - QFile fi(fileName); - if (fi.exists() && fi.open(QFile::ReadOnly)) { - setDevice(&fi); - - while (!atEnd()) { - readNext(); - if (name() == QLatin1String("CodeBlocks_project_file")) - parseCodeBlocks_project_file(); - else if (isStartElement()) - parseUnknownElement(); - } - - sortFiles(); - - fi.close(); - return true; - } - return false; -} - -void CMakeCbpParser::parseCodeBlocks_project_file() -{ - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (name() == QLatin1String("Project")) - parseProject(); - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseProject() -{ - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (name() == QLatin1String("Option")) - parseOption(); - else if (name() == QLatin1String("Unit")) - parseUnit(); - else if (name() == QLatin1String("Build")) - parseBuild(); - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseBuild() -{ - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (name() == QLatin1String("Target")) - parseBuildTarget(); - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseBuildTarget() -{ - m_buildTarget.clear(); - - if (attributes().hasAttribute(QLatin1String("title"))) - m_buildTarget.title = attributes().value(QLatin1String("title")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) { - if (!m_buildTarget.title.endsWith(QLatin1String("/fast")) - && !m_buildTarget.title.endsWith(QLatin1String("_automoc")) - && !m_buildTarget.title.endsWith(QLatin1String("_unittest"))) - m_buildTargets.append(m_buildTarget); - return; - } else if (name() == QLatin1String("Compiler")) { - parseCompiler(); - } else if (name() == QLatin1String("Option")) { - parseBuildTargetOption(); - } else if (name() == QLatin1String("MakeCommands")) { - parseMakeCommands(); - } else if (isStartElement()) { - parseUnknownElement(); - } - } -} - -void CMakeCbpParser::parseBuildTargetOption() -{ - if (attributes().hasAttribute(QLatin1String("output"))) { - m_buildTarget.executable = attributes().value(QLatin1String("output")).toString(); - } else if (attributes().hasAttribute(QLatin1String("type"))) { - const QStringRef value = attributes().value(QLatin1String("type")); - if (value == QLatin1String("2") || value == QLatin1String("3")) - m_buildTarget.targetType = TargetType(value.toInt()); - } else if (attributes().hasAttribute(QLatin1String("working_dir"))) { - m_buildTarget.workingDirectory = attributes().value(QLatin1String("working_dir")).toString(); - QDir dir(m_buildDirectory); - const QString relative = dir.relativeFilePath(m_buildTarget.workingDirectory); - m_buildTarget.sourceDirectory - = FileName::fromString(m_sourceDirectory).appendPath(relative).toString(); - } - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (isStartElement()) - parseUnknownElement(); - } -} - -QString CMakeCbpParser::projectName() const -{ - return m_projectName; -} - -void CMakeCbpParser::parseOption() -{ - if (attributes().hasAttribute(QLatin1String("title"))) - m_projectName = attributes().value(QLatin1String("title")).toString(); - - if (attributes().hasAttribute(QLatin1String("compiler"))) - m_compiler = attributes().value(QLatin1String("compiler")).toString(); - - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseMakeCommands() -{ - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (name() == QLatin1String("Build")) - parseBuildTargetBuild(); - else if (name() == QLatin1String("Clean")) - parseBuildTargetClean(); - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseBuildTargetBuild() -{ - if (attributes().hasAttribute(QLatin1String("command"))) - m_buildTarget.makeCommand = attributes().value(QLatin1String("command")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseBuildTargetClean() -{ - if (attributes().hasAttribute(QLatin1String("command"))) - m_buildTarget.makeCleanCommand = attributes().value(QLatin1String("command")).toString(); - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseCompiler() -{ - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (name() == QLatin1String("Add")) - parseAdd(); - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseAdd() -{ - // CMake only supports <Add option=\> and <Add directory=\> - const QXmlStreamAttributes addAttributes = attributes(); - - const QString includeDirectory = addAttributes.value(QLatin1String("directory")).toString(); - // allow adding multiple times because order happens - if (!includeDirectory.isEmpty()) - m_buildTarget.includeFiles.append(includeDirectory); - - QString compilerOption = addAttributes.value(QLatin1String("option")).toString(); - // defining multiple times a macro to the same value makes no sense - if (!compilerOption.isEmpty() && !m_buildTarget.compilerOptions.contains(compilerOption)) { - m_buildTarget.compilerOptions.append(compilerOption); - int macroNameIndex = compilerOption.indexOf(QLatin1String("-D")) + 2; - if (macroNameIndex != 1) { - int assignIndex = compilerOption.indexOf(QLatin1Char('='), macroNameIndex); - if (assignIndex != -1) - compilerOption[assignIndex] = ' '; - m_buildTarget.defines.append("#define "); - m_buildTarget.defines.append(compilerOption.mid(macroNameIndex).toUtf8()); - m_buildTarget.defines.append('\n'); - } - } - - while (!atEnd()) { - readNext(); - if (isEndElement()) - return; - else if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseUnit() -{ - //qDebug()<<stream.attributes().value("filename"); - FileName fileName = - FileName::fromUserInput(attributes().value(QLatin1String("filename")).toString()); - m_parsingCmakeUnit = false; - while (!atEnd()) { - readNext(); - if (isEndElement()) { - if (!fileName.endsWith(QLatin1String(".rule")) && !m_processedUnits.contains(fileName)) { - // Now check whether we found a virtual element beneath - if (m_parsingCmakeUnit) { - m_cmakeFileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ProjectFileType, false)); - } else { - bool generated = false; - QString onlyFileName = fileName.fileName(); - if ( (onlyFileName.startsWith(QLatin1String("moc_")) && onlyFileName.endsWith(QLatin1String(".cxx"))) - || (onlyFileName.startsWith(QLatin1String("ui_")) && onlyFileName.endsWith(QLatin1String(".h"))) - || (onlyFileName.startsWith(QLatin1String("qrc_")) && onlyFileName.endsWith(QLatin1String(".cxx")))) - generated = true; - - if (fileName.endsWith(QLatin1String(".qrc"))) - m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::ResourceType, generated)); - else - m_fileList.append( new ProjectExplorer::FileNode(fileName, ProjectExplorer::SourceType, generated)); - } - m_processedUnits.insert(fileName); - } - return; - } else if (name() == QLatin1String("Option")) { - parseUnitOption(); - } else if (isStartElement()) { - parseUnknownElement(); - } - } -} - -void CMakeCbpParser::parseUnitOption() -{ - if (attributes().hasAttribute(QLatin1String("virtualFolder"))) - m_parsingCmakeUnit = true; - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - parseUnknownElement(); - } -} - -void CMakeCbpParser::parseUnknownElement() -{ - Q_ASSERT(isStartElement()); - - while (!atEnd()) { - readNext(); - - if (isEndElement()) - break; - - if (isStartElement()) - parseUnknownElement(); - } -} - -QList<ProjectExplorer::FileNode *> CMakeCbpParser::fileList() -{ - return m_fileList; -} - -QList<ProjectExplorer::FileNode *> CMakeCbpParser::cmakeFileList() -{ - return m_cmakeFileList; -} - -bool CMakeCbpParser::hasCMakeFiles() -{ - return !m_cmakeFileList.isEmpty(); -} - -QList<CMakeBuildTarget> CMakeCbpParser::buildTargets() -{ - return m_buildTargets; -} - -QString CMakeCbpParser::compilerName() const -{ - return m_compiler; -} - void CMakeBuildTarget::clear() { executable.clear(); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.h b/src/plugins/cmakeprojectmanager/cmakeproject.h index f6e000fac9e..db58567df9b 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.h +++ b/src/plugins/cmakeprojectmanager/cmakeproject.h @@ -31,13 +31,10 @@ #ifndef CMAKEPROJECT_H #define CMAKEPROJECT_H -#include "cmakeprojectmanager.h" +#include "cmake_global.h" #include "cmakeprojectnodes.h" -#include "cmakebuildconfiguration.h" -#include "makestep.h" #include <projectexplorer/project.h> -#include <projectexplorer/projectnodes.h> #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/namedwidget.h> #include <coreplugin/idocument.h> @@ -55,13 +52,15 @@ QT_BEGIN_NAMESPACE class QFileSystemWatcher; QT_END_NAMESPACE -namespace ProjectExplorer { class Target; } - namespace CMakeProjectManager { -namespace Internal { +namespace Internal { class CMakeFile; class CMakeBuildSettingsWidget; +class CMakeBuildConfiguration; +class CMakeProjectNode; +class CMakeManager; +} enum TargetType { ExecutableType = 0, @@ -69,7 +68,7 @@ enum TargetType { DynamicLibraryType = 3 }; -struct CMakeBuildTarget +struct CMAKE_EXPORT CMakeBuildTarget { QString title; QString executable; // TODO: rename to output? @@ -88,18 +87,18 @@ struct CMakeBuildTarget void clear(); }; -class CMakeProject : public ProjectExplorer::Project +class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project { Q_OBJECT // for changeBuildDirectory - friend class CMakeBuildSettingsWidget; + friend class Internal::CMakeBuildSettingsWidget; public: - CMakeProject(CMakeManager *manager, const Utils::FileName &filename); + CMakeProject(Internal::CMakeManager *manager, const Utils::FileName &filename); ~CMakeProject(); QString displayName() const; Core::IDocument *document() const; - CMakeManager *projectManager() const; + ProjectExplorer::IProjectManager *projectManager() const; ProjectExplorer::ProjectNode *rootProjectNode() const; @@ -123,7 +122,7 @@ protected: bool setupTarget(ProjectExplorer::Target *t); // called by CMakeBuildSettingsWidget - void changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory); + void changeBuildDirectory(Internal::CMakeBuildConfiguration *bc, const QString &newBuildDirectory); private slots: void fileChanged(const QString &fileName); @@ -133,23 +132,23 @@ private slots: void updateRunConfigurations(); private: - void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list); + void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list); void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list); - ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory); + ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory); void createUiCodeModelSupport(); QString uiHeaderFile(const QString &uiFile); void updateRunConfigurations(ProjectExplorer::Target *t); void updateApplicationAndDeploymentTargets(); QStringList getCXXFlagsFor(const CMakeBuildTarget &buildTarget); - CMakeManager *m_manager; + Internal::CMakeManager *m_manager; ProjectExplorer::Target *m_activeTarget; Utils::FileName m_fileName; - CMakeFile *m_file; + Internal::CMakeFile *m_file; QString m_projectName; // TODO probably need a CMake specific node structure - CMakeProjectNode *m_rootNode; + Internal::CMakeProjectNode *m_rootNode; QStringList m_files; QList<CMakeBuildTarget> m_buildTargets; QFileSystemWatcher *m_watcher; @@ -157,84 +156,6 @@ private: QFuture<void> m_codeModelFuture; }; -class CMakeCbpParser : public QXmlStreamReader -{ -public: - bool parseCbpFile(const QString &fileName, const QString &sourceDirectory); - QList<ProjectExplorer::FileNode *> fileList(); - QList<ProjectExplorer::FileNode *> cmakeFileList(); - QList<CMakeBuildTarget> buildTargets(); - QString projectName() const; - QString compilerName() const; - bool hasCMakeFiles(); - -private: - void parseCodeBlocks_project_file(); - void parseProject(); - void parseBuild(); - void parseOption(); - void parseBuildTarget(); - void parseBuildTargetOption(); - void parseMakeCommands(); - void parseBuildTargetBuild(); - void parseBuildTargetClean(); - void parseCompiler(); - void parseAdd(); - void parseUnit(); - void parseUnitOption(); - void parseUnknownElement(); - void sortFiles(); - - QList<ProjectExplorer::FileNode *> m_fileList; - QList<ProjectExplorer::FileNode *> m_cmakeFileList; - QSet<Utils::FileName> m_processedUnits; - bool m_parsingCmakeUnit; - - CMakeBuildTarget m_buildTarget; - QList<CMakeBuildTarget> m_buildTargets; - QString m_projectName; - QString m_compiler; - QString m_sourceDirectory; - QString m_buildDirectory; -}; - -class CMakeFile : public Core::IDocument -{ - Q_OBJECT -public: - CMakeFile(CMakeProject *parent, const Utils::FileName &fileName); - - bool save(QString *errorString, const QString &fileName, bool autoSave); - - QString defaultPath() const; - QString suggestedFileName() const; - - bool isModified() const; - bool isSaveAsAllowed() const; - - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; - bool reload(QString *errorString, ReloadFlag flag, ChangeType type); - -private: - CMakeProject *m_project; -}; - -class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget -{ - Q_OBJECT -public: - CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc); - -private slots: - void openChangeBuildDirectoryDialog(); - void runCMake(); -private: - QLineEdit *m_pathLineEdit; - QPushButton *m_changeButton; - CMakeBuildConfiguration *m_buildConfiguration; -}; - -} // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEPROJECT_H diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h index 89101ad151b..2c0884605e4 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectconstants.h @@ -51,6 +51,9 @@ const char CMAKE_BC_ID[] = "CMakeProjectManager.CMakeBuildConfiguration"; // Menu const char M_CONTEXT[] = "CMakeEditor.ContextMenu"; +// Settings page +const char CMAKE_SETTINGSPAGE_ID[] = "Z.CMake"; + } // namespace Constants } // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp index 4749d34f399..476d3da3d94 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.cpp @@ -33,6 +33,7 @@ #include "cmakeprojectconstants.h" #include "cmakeproject.h" #include "cmakesettingspage.h" +#include "cmaketoolmanager.h" #include <coreplugin/icore.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -49,8 +50,7 @@ using namespace CMakeProjectManager::Internal; -CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) - : m_settingsPage(cmakeSettingsPage) +CMakeManager::CMakeManager() { ProjectExplorer::ProjectTree *tree = ProjectExplorer::ProjectTree::instance(); connect(tree, &ProjectExplorer::ProjectTree::aboutToShowContextMenu, @@ -130,41 +130,16 @@ QString CMakeManager::mimeType() const return QLatin1String(Constants::CMAKEPROJECTMIMETYPE); } -QString CMakeManager::cmakeExecutable() const -{ - return m_settingsPage->cmakeExecutable(); -} - -bool CMakeManager::isCMakeExecutableValid() const -{ - return m_settingsPage->isCMakeExecutableValid(); -} - -void CMakeManager::setCMakeExecutable(const QString &executable) -{ - m_settingsPage->setCMakeExecutable(executable); -} - -bool CMakeManager::hasCodeBlocksMsvcGenerator() const -{ - return m_settingsPage->hasCodeBlocksMsvcGenerator(); -} - -bool CMakeManager::hasCodeBlocksNinjaGenerator() const -{ - return m_settingsPage->hasCodeBlocksNinjaGenerator(); -} - bool CMakeManager::preferNinja() const { - return m_settingsPage->preferNinja(); + return CMakeToolManager::preferNinja(); } // need to refactor this out // we probably want the process instead of this function // cmakeproject then could even run the cmake process in the background, adding the files afterwards // sounds like a plan -void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &arguments, +void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executable, const QString &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const Utils::Environment &env, const QString &generator) { @@ -179,7 +154,7 @@ void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &argumen Utils::QtcProcess::addArg(&args, srcdir); Utils::QtcProcess::addArgs(&args, arguments); Utils::QtcProcess::addArg(&args, generator); - proc->setCommand(cmakeExecutable(), args); + proc->setCommand(executable, args); proc->start(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h index bd0bd527cac..6c50ea34cf9 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.h @@ -53,24 +53,18 @@ class CMakeManager : public ProjectExplorer::IProjectManager { Q_OBJECT public: - CMakeManager(CMakeSettingsPage *cmakeSettingsPage); + CMakeManager(); virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString); virtual QString mimeType() const; - QString cmakeExecutable() const; - bool isCMakeExecutableValid() const; - - void setCMakeExecutable(const QString &executable); - void createXmlFile(Utils::QtcProcess *process, + const QString &executable, const QString &arguments, const QString &sourceDirectory, const QDir &buildDirectory, const Utils::Environment &env, const QString &generator); - bool hasCodeBlocksMsvcGenerator() const; - bool hasCodeBlocksNinjaGenerator() const; bool preferNinja() const; static QString findCbpFile(const QDir &); diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro index 4f3eff9da54..355f996643d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.pro @@ -1,3 +1,4 @@ +DEFINES += CMAKEPROJECTMANAGER_LIBRARY include(../../qtcreatorplugin.pri) HEADERS = cmakebuildinfo.h \ @@ -16,7 +17,14 @@ HEADERS = cmakebuildinfo.h \ cmaketool.h \ cmakeparser.h \ generatorinfo.h \ - cmakesettingspage.h + cmakesettingspage.h \ + cmaketoolmanager.h \ + cmake_global.h \ + cmakekitinformation.h \ + cmakekitconfigwidget.h \ + cmakecbpparser.h \ + cmakefile.h \ + cmakebuildsettingswidget.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ @@ -32,7 +40,13 @@ SOURCES = cmakeproject.cpp \ cmaketool.cpp \ cmakeparser.cpp \ generatorinfo.cpp \ - cmakesettingspage.cpp + cmakesettingspage.cpp \ + cmaketoolmanager.cpp \ + cmakekitinformation.cpp \ + cmakekitconfigwidget.cpp \ + cmakecbpparser.cpp \ + cmakefile.cpp \ + cmakebuildsettingswidget.cpp RESOURCES += cmakeproject.qrc diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs index 2415f71e548..7679217062d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "CMakeProjectManager" Depends { name: "Qt.widgets" } - Depends { name: "Aggregation" } Depends { name: "Utils" } Depends { name: "Core" } @@ -18,13 +17,24 @@ QtcPlugin { ] files: [ + "cmake_global.h", "cmakebuildconfiguration.cpp", "cmakebuildconfiguration.h", "cmakebuildinfo.h", + "cmakebuildsettingswidget.cpp", + "cmakebuildsettingswidget.h", + "cmakecbpparser.cpp", + "cmakecbpparser.h", "cmakeeditor.cpp", "cmakeeditor.h", + "cmakefile.cpp", + "cmakefile.h", "cmakefilecompletionassist.cpp", "cmakefilecompletionassist.h", + "cmakekitconfigwidget.h", + "cmakekitconfigwidget.cpp", + "cmakekitinformation.h", + "cmakekitinformation.cpp", "cmakelocatorfilter.cpp", "cmakelocatorfilter.h", "cmakeopenprojectwizard.cpp", @@ -45,6 +55,8 @@ QtcPlugin { "cmakerunconfiguration.h", "cmaketool.cpp", "cmaketool.h", + "cmaketoolmanager.cpp", + "cmaketoolmanager.h", "makestep.cpp", "makestep.h", "cmakesettingspage.h", diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri index 123a3796acf..41e9b7e0301 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri +++ b/src/plugins/cmakeprojectmanager/cmakeprojectmanager_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = CMakeProjectManager QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ utils QTC_PLUGIN_DEPENDS += \ diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h index 1a9ff6a6385..e21e660608d 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectnodes.h @@ -34,6 +34,8 @@ #include <projectexplorer/projectnodes.h> namespace CMakeProjectManager { +class CMakeProject; + namespace Internal { class CMakeProjectNode : public ProjectExplorer::ProjectNode diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp index 7215e36a8bd..9aca653fc62 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.cpp @@ -37,11 +37,13 @@ #include "makestep.h" #include "cmakeprojectconstants.h" #include "cmakelocatorfilter.h" -#include "cmakefilecompletionassist.h" #include "cmakesettingspage.h" +#include "cmaketoolmanager.h" +#include "cmakekitinformation.h" #include <coreplugin/featureprovider.h> #include <utils/mimetypes/mimedatabase.h> +#include <projectexplorer/kitmanager.h> #include <QtPlugin> #include <QDebug> @@ -62,19 +64,23 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString * Q_UNUSED(errorMessage) Utils::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml")); - CMakeSettingsPage *cmp = new CMakeSettingsPage(); - addAutoReleasedObject(cmp); - addAutoReleasedObject(new CMakeManager(cmp)); + addAutoReleasedObject(new CMakeSettingsPage); + addAutoReleasedObject(new CMakeManager); addAutoReleasedObject(new MakeStepFactory); addAutoReleasedObject(new CMakeRunConfigurationFactory); addAutoReleasedObject(new CMakeBuildConfigurationFactory); - addAutoReleasedObject(new CMakeEditorFactory(cmp)); + addAutoReleasedObject(new CMakeEditorFactory); addAutoReleasedObject(new CMakeLocatorFilter); - addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp)); + + new CMakeToolManager(this); + + ProjectExplorer::KitManager::registerKitInformation(new CMakeKitInformation); return true; } void CMakeProjectPlugin::extensionsInitialized() { + //restore the cmake tools before loading the kits + CMakeToolManager::restoreCMakeTools(); } diff --git a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h index f8e5c74893b..11929d55f10 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h +++ b/src/plugins/cmakeprojectmanager/cmakeprojectplugin.h @@ -36,6 +36,9 @@ #include <QObject> namespace CMakeProjectManager { + +class CMakeToolManager; + namespace Internal { class CMakeProjectPlugin diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp index a4406166be5..70f0e278234 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.cpp @@ -38,6 +38,7 @@ #include <coreplugin/helpmanager.h> #include <qtsupport/qtkitinformation.h> #include <projectexplorer/localenvironmentaspect.h> +#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> #include <utils/pathchooser.h> @@ -62,33 +63,30 @@ namespace { const char CMAKE_RC_PREFIX[] = "CMakeProjectManager.CMakeRunConfiguration."; const char USER_WORKING_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"; -const char USE_TERMINAL_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UseTerminal"; const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title"; -const char ARGUMENTS_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.Arguments"; } // namespace CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, Core::Id id, const QString &target, const QString &workingDirectory, const QString &title) : LocalApplicationRunConfiguration(parent, id), - m_runMode(ProjectExplorer::ApplicationLauncher::Gui), m_buildTarget(target), m_workingDirectory(workingDirectory), m_title(title), m_enabled(true) { addExtraAspect(new LocalEnvironmentAspect(this)); + addExtraAspect(new ArgumentsAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.Arguments"))); + addExtraAspect(new TerminalAspect(this, QStringLiteral("CMakeProjectManager.CMakeRunConfiguration.UseTerminal"))); ctor(); } CMakeRunConfiguration::CMakeRunConfiguration(Target *parent, CMakeRunConfiguration *source) : LocalApplicationRunConfiguration(parent, source), - m_runMode(source->m_runMode), m_buildTarget(source->m_buildTarget), m_workingDirectory(source->m_workingDirectory), m_userWorkingDirectory(source->m_userWorkingDirectory), m_title(source->m_title), - m_arguments(source->m_arguments), m_enabled(source->m_enabled) { ctor(); @@ -110,12 +108,7 @@ QString CMakeRunConfiguration::executable() const ApplicationLauncher::Mode CMakeRunConfiguration::runMode() const { - return m_runMode; -} - -void CMakeRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) -{ - m_runMode = runMode; + return extraAspect<TerminalAspect>()->runMode(); } QString CMakeRunConfiguration::workingDirectory() const @@ -135,7 +128,7 @@ QString CMakeRunConfiguration::baseWorkingDirectory() const QString CMakeRunConfiguration::commandLineArguments() const { - return macroExpander()->expandProcessArgs(m_arguments); + return extraAspect<ArgumentsAspect>()->arguments(); } QString CMakeRunConfiguration::title() const @@ -175,9 +168,7 @@ QVariantMap CMakeRunConfiguration::toMap() const QVariantMap map(LocalApplicationRunConfiguration::toMap()); map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory); - map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console); map.insert(QLatin1String(TITLE_KEY), m_title); - map.insert(QLatin1String(ARGUMENTS_KEY), m_arguments); return map; } @@ -185,10 +176,7 @@ QVariantMap CMakeRunConfiguration::toMap() const bool CMakeRunConfiguration::fromMap(const QVariantMap &map) { m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString(); - m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? ApplicationLauncher::Console - : ApplicationLauncher::Gui; m_title = map.value(QLatin1String(TITLE_KEY)).toString(); - m_arguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString(); return RunConfiguration::fromMap(map); } @@ -210,11 +198,6 @@ QWidget *CMakeRunConfiguration::createConfigurationWidget() return new CMakeRunConfigurationWidget(this); } -void CMakeRunConfiguration::setCommandLineArguments(const QString &newText) -{ - m_arguments = newText; -} - void CMakeRunConfiguration::setEnabled(bool b) { if (m_enabled == b) @@ -243,10 +226,8 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration * QFormLayout *fl = new QFormLayout(); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - QLineEdit *argumentsLineEdit = new QLineEdit(); - argumentsLineEdit->setText(cmakeRunConfiguration->commandLineArguments()); - connect(argumentsLineEdit, &QLineEdit::textChanged, this, &CMakeRunConfigurationWidget::setArguments); - fl->addRow(tr("Arguments:"), argumentsLineEdit); + + cmakeRunConfiguration->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, fl); m_workingDirectoryEdit = new Utils::PathChooser(); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); @@ -272,8 +253,7 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration * fl->addRow(tr("Working directory:"), boxlayout); - QCheckBox *runInTerminal = new QCheckBox; - fl->addRow(tr("Run in Terminal"), runInTerminal); + m_cmakeRunConfiguration->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, fl); m_detailsContainer = new Utils::DetailsWidget(this); m_detailsContainer->setState(Utils::DetailsWidget::NoSummary); @@ -292,9 +272,6 @@ CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration * connect(resetButton, &QToolButton::clicked, this, &CMakeRunConfigurationWidget::resetWorkingDirectory); - connect(runInTerminal, &QCheckBox::toggled, - this, &CMakeRunConfigurationWidget::runInTerminalToggled); - connect(m_cmakeRunConfiguration, &CMakeRunConfiguration::baseWorkingDirectoryChanged, this, &CMakeRunConfigurationWidget::workingDirectoryChanged); @@ -326,22 +303,12 @@ void CMakeRunConfigurationWidget::resetWorkingDirectory() m_cmakeRunConfiguration->setUserWorkingDirectory(QString()); } -void CMakeRunConfigurationWidget::runInTerminalToggled(bool toggled) -{ - m_cmakeRunConfiguration->setRunMode(toggled ? ApplicationLauncher::Console - : ApplicationLauncher::Gui); -} - void CMakeRunConfigurationWidget::environmentWasChanged() { EnvironmentAspect *aspect = m_cmakeRunConfiguration->extraAspect<EnvironmentAspect>(); QTC_ASSERT(aspect, return); m_workingDirectoryEdit->setEnvironment(aspect->environment()); } -void CMakeRunConfigurationWidget::setArguments(const QString &args) -{ - m_cmakeRunConfiguration->setCommandLineArguments(args); -} // Factory CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) : diff --git a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h index 9e0017b71a9..48a2f234b1f 100644 --- a/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h +++ b/src/plugins/cmakeprojectmanager/cmakerunconfiguration.h @@ -61,7 +61,6 @@ public: QString executable() const; ProjectExplorer::ApplicationLauncher::Mode runMode() const; - void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode); QString workingDirectory() const; QString commandLineArguments() const; QWidget *createConfigurationWidget(); @@ -81,9 +80,6 @@ public: signals: void baseWorkingDirectoryChanged(const QString&); -private slots: - void setCommandLineArguments(const QString &newText); - protected: CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source); virtual bool fromMap(const QVariantMap &map); @@ -94,12 +90,10 @@ private: QString baseWorkingDirectory() const; void ctor(); - ProjectExplorer::ApplicationLauncher::Mode m_runMode; QString m_buildTarget; QString m_workingDirectory; QString m_userWorkingDirectory; QString m_title; - QString m_arguments; bool m_enabled; }; @@ -110,10 +104,8 @@ public: explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0); private slots: - void setArguments(const QString &args); void setWorkingDirectory(); void resetWorkingDirectory(); - void runInTerminalToggled(bool toggled); void environmentWasChanged(); void workingDirectoryChanged(const QString &workingDirectory); diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp index c32c07ddcbb..3436b87e5dc 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp @@ -27,162 +27,549 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#include "cmakeprojectconstants.h" #include "cmakesettingspage.h" +#include "cmaketoolmanager.h" #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/project.h> #include <coreplugin/icore.h> #include <utils/environment.h> +#include <utils/detailswidget.h> +#include <utils/pathchooser.h> +#include <utils/qtcassert.h> +#include <utils/treemodel.h> -#include <QSettings> -#include <QGroupBox> -#include <QSpacerItem> #include <QFormLayout> -#include <QBoxLayout> +#include <QHeaderView> +#include <QLabel> +#include <QLineEdit> +#include <QPushButton> +#include <QTreeView> +#include <QWidget> +#include <QUuid> #include <QCheckBox> +using namespace Utils; + namespace CMakeProjectManager { namespace Internal { -///// -// CMakeSettingsPage -//// +class CMakeToolTreeItem; +// -------------------------------------------------------------------------- +// CMakeToolItemModel +// -------------------------------------------------------------------------- -CMakeSettingsPage::CMakeSettingsPage() - : m_pathchooser(0), m_preferNinja(0) +class CMakeToolItemModel : public TreeModel { - setId("Z.CMake"); - setDisplayName(tr("CMake")); - setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY)); - setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON)); + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage) + +public: + CMakeToolItemModel(); + + CMakeToolTreeItem *cmakeToolItem(const Core::Id &id) const; + CMakeToolTreeItem *cmakeToolItem(const QModelIndex &index) const; + QModelIndex addCMakeTool(const QString &name, const FileName &executable, const bool isAutoDetected); + QModelIndex addCMakeTool(const CMakeTool *item, bool changed); + TreeItem *autoGroupItem() const; + TreeItem *manualGroupItem() const; + void reevaluateChangedFlag(CMakeToolTreeItem *item) const; + void updateCMakeTool(const Core::Id &id, const QString &displayName, const FileName &executable); + void removeCMakeTool(const Core::Id &id); + void apply(); + + Core::Id defaultItemId() const; + void setDefaultItemId(const Core::Id &id); + + QString uniqueDisplayName(const QString &base) const; +private: + Core::Id m_defaultItemId; + QList<Core::Id> m_removedItems; +}; + +class CMakeToolTreeItem : public TreeItem +{ + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage) + +public: + CMakeToolTreeItem(const CMakeTool *item, bool changed) : + m_id(item->id()), + m_name(item->displayName()), + m_executable(item->cmakeExecutable()), + m_autodetected(item->isAutoDetected()), + m_changed(changed) + {} + + CMakeToolTreeItem(const QString &name, const Utils::FileName &executable, bool autodetected) : + m_id(Core::Id::fromString(QUuid::createUuid().toString())), + m_name(name), + m_executable(executable), + m_autodetected(autodetected), + m_changed(true) + {} + + CMakeToolTreeItem() : m_autodetected(false), m_changed(true) {} - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String("CMakeSettings")); - m_cmakeValidatorForUser.setCMakeExecutable(settings->value(QLatin1String("cmakeExecutable")).toString()); - settings->endGroup(); + CMakeToolItemModel *model() const { return static_cast<CMakeToolItemModel *>(TreeItem::model()); } - m_cmakeValidatorForSystem.setCMakeExecutable(findCmakeExecutable()); + QVariant data(int column, int role) const + { + switch (role) { + case Qt::DisplayRole: + switch (column) { + case 0: { + QString name = m_name; + if (model()->defaultItemId() == m_id) + name += tr(" (Default)"); + return name; + } + case 1: return m_executable.toUserOutput(); + } + + case Qt::FontRole: { + QFont font; + font.setBold(m_changed); + font.setItalic(model()->defaultItemId() == m_id); + return font; + } + } + return QVariant(); + } + + Core::Id m_id; + QString m_name; + FileName m_executable; + bool m_autodetected; + bool m_changed; +}; + +CMakeToolItemModel::CMakeToolItemModel() +{ + setHeader(QStringList() << tr("Name") << tr("Location")); + rootItem()->appendChild(new TreeItem(QStringList() << tr("Auto-detected") << QString() << QString())); + rootItem()->appendChild(new TreeItem(QStringList() << tr("Manual") << QString() << QString())); + + foreach (const CMakeTool *item, CMakeToolManager::cmakeTools()) + addCMakeTool(item, false); + + CMakeTool *defTool = CMakeToolManager::defaultCMakeTool(); + m_defaultItemId = defTool ? defTool->id() : Core::Id(); } -bool CMakeSettingsPage::isCMakeExecutableValid() const +QModelIndex CMakeToolItemModel::addCMakeTool(const QString &name, const FileName &executable, const bool isAutoDetected) { - if (m_cmakeValidatorForUser.isValid()) - return true; + CMakeToolTreeItem *item = new CMakeToolTreeItem(name, executable, isAutoDetected); + if (isAutoDetected) + autoGroupItem()->appendChild(item); + else + manualGroupItem()->appendChild(item); - return m_cmakeValidatorForSystem.isValid(); + return item->index(); } -CMakeSettingsPage::~CMakeSettingsPage() +QModelIndex CMakeToolItemModel::addCMakeTool(const CMakeTool *item, bool changed) +{ + CMakeToolTreeItem *treeItem = new CMakeToolTreeItem(item, changed); + if (item->isAutoDetected()) + autoGroupItem()->appendChild(treeItem); + else + manualGroupItem()->appendChild(treeItem); + + return treeItem->index(); +} + +TreeItem *CMakeToolItemModel::autoGroupItem() const { - m_cmakeValidatorForUser.cancel(); - m_cmakeValidatorForSystem.cancel(); + return rootItem()->child(0); } -QString CMakeSettingsPage::findCmakeExecutable() const +TreeItem *CMakeToolItemModel::manualGroupItem() const { - return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake")).toString(); + return rootItem()->child(1); } -QWidget *CMakeSettingsPage::widget() +void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const { - if (!m_widget) { - m_widget = new QWidget; - QFormLayout *formLayout = new QFormLayout(m_widget); - formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); - m_pathchooser = new Utils::PathChooser; - m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand); - m_pathchooser->setHistoryCompleter(QLatin1String("Cmake.Command.History")); - formLayout->addRow(tr("Executable:"), m_pathchooser); - formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); - - m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)")); - formLayout->addRow(m_preferNinja); + CMakeTool *orig = CMakeToolManager::findById(item->m_id); + item->m_changed = !orig || orig->displayName() != item->m_name + || orig->cmakeExecutable() != item->m_executable; + + //make sure the item is marked as changed when the default cmake was changed + CMakeTool *origDefTool = CMakeToolManager::defaultCMakeTool(); + Core::Id origDefault = origDefTool ? origDefTool->id() : Core::Id(); + if (origDefault != m_defaultItemId) { + if (item->m_id == origDefault || item->m_id == m_defaultItemId) + item->m_changed = true; } - m_pathchooser->setPath(m_cmakeValidatorForUser.cmakeExecutable()); - m_preferNinja->setChecked(preferNinja()); - return m_widget; + + item->update(); // Notify views. +} + +void CMakeToolItemModel::updateCMakeTool(const Core::Id &id, const QString &displayName, + const FileName &executable) +{ + CMakeToolTreeItem *treeItem = cmakeToolItem(id); + QTC_ASSERT(treeItem, return); + + treeItem->m_name = displayName; + treeItem->m_executable = executable; + + reevaluateChangedFlag(treeItem); } -void CMakeSettingsPage::saveSettings() const +CMakeToolTreeItem *CMakeToolItemModel::cmakeToolItem(const Core::Id &id) const { - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String("CMakeSettings")); - settings->setValue(QLatin1String("cmakeExecutable"), m_cmakeValidatorForUser.cmakeExecutable()); - settings->setValue(QLatin1String("preferNinja"), m_preferNinja->isChecked()); - settings->endGroup(); + auto matcher = [id](CMakeToolTreeItem *n) { return n->m_id == id; }; + return findItemAtLevel<CMakeToolTreeItem *>(2, matcher); } -void CMakeSettingsPage::apply() +CMakeToolTreeItem *CMakeToolItemModel::cmakeToolItem(const QModelIndex &index) const +{ + TreeItem *item = itemForIndex(index); + if (item->level() == 2) + return static_cast<CMakeToolTreeItem *>(item); + return 0; +} + +void CMakeToolItemModel::removeCMakeTool(const Core::Id &id) +{ + CMakeToolTreeItem *treeItem = cmakeToolItem(id); + QTC_ASSERT(treeItem, return); + + takeItem(treeItem); + m_removedItems.append(id); + + delete treeItem; +} + +void CMakeToolItemModel::apply() +{ + foreach (const Core::Id &id, m_removedItems) + CMakeToolManager::deregisterCMakeTool(id); + + foreach (auto item, itemsAtLevel<CMakeToolTreeItem *>(2)) { + item->m_changed = false; + + bool isNew = false; + CMakeTool *cmake = CMakeToolManager::findById(item->m_id); + if (!cmake) { + isNew = true; + CMakeTool::Detection detection = item->m_autodetected ? CMakeTool::AutoDetection + : CMakeTool::ManualDetection; + cmake = new CMakeTool(detection, item->m_id); + } + + cmake->setDisplayName(item->m_name); + cmake->setCMakeExecutable(item->m_executable); + + if (isNew) { + if (!CMakeToolManager::registerCMakeTool(cmake)) { + delete cmake; + item->m_changed = true; + } + } + } + + CMakeToolManager::setDefaultCMakeTool(defaultItemId()); +} + +Core::Id CMakeToolItemModel::defaultItemId() const { - if (!m_pathchooser) // page was never shown + return m_defaultItemId; +} + +void CMakeToolItemModel::setDefaultItemId(const Core::Id &id) +{ + if (m_defaultItemId == id) return; - if (m_cmakeValidatorForUser.cmakeExecutable() != m_pathchooser->path()) - m_cmakeValidatorForUser.setCMakeExecutable(m_pathchooser->path()); - saveSettings(); + + Core::Id oldDefaultId = m_defaultItemId; + m_defaultItemId = id; + + CMakeToolTreeItem *newDefault = cmakeToolItem(id); + if (newDefault) + reevaluateChangedFlag(newDefault); + + CMakeToolTreeItem *oldDefault = cmakeToolItem(oldDefaultId); + if (oldDefault) + reevaluateChangedFlag(oldDefault); } -void CMakeSettingsPage::finish() + +QString CMakeToolItemModel::uniqueDisplayName(const QString &base) const { - delete m_widget; + QStringList names; + foreach (CMakeToolTreeItem *item, itemsAtLevel<CMakeToolTreeItem *>(2)) + names << item->m_name; + + return ProjectExplorer::Project::makeUnique(base, names); +} + +// ----------------------------------------------------------------------- +// CMakeToolItemConfigWidget +// ----------------------------------------------------------------------- + +class CMakeToolItemConfigWidget : public QWidget +{ + Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::CMakeSettingsPage) + +public: + explicit CMakeToolItemConfigWidget(CMakeToolItemModel *model); + void load(const CMakeToolTreeItem *item); + void store() const; + +private: + CMakeToolItemModel *m_model; + QLineEdit *m_displayNameLineEdit; + PathChooser *m_binaryChooser; + Core::Id m_id; + bool m_loadingItem; +}; + +CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model) + : m_model(model), m_loadingItem(false) +{ + m_displayNameLineEdit = new QLineEdit(this); + + m_binaryChooser = new PathChooser(this); + m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand); + m_binaryChooser->setMinimumWidth(400); + m_binaryChooser->setHistoryCompleter(QLatin1String("Cmake.Command.History")); + + QFormLayout *formLayout = new QFormLayout(this); + formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); + formLayout->addRow(new QLabel(tr("Name:")), m_displayNameLineEdit); + formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser); + + connect(m_binaryChooser, &PathChooser::changed, + this, &CMakeToolItemConfigWidget::store); + connect(m_displayNameLineEdit, &QLineEdit::textChanged, + this, &CMakeToolItemConfigWidget::store); +} + +void CMakeToolItemConfigWidget::store() const +{ + if (!m_loadingItem && m_id.isValid()) + m_model->updateCMakeTool(m_id, m_displayNameLineEdit->text(), m_binaryChooser->fileName()); +} + +void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item) +{ + m_loadingItem = true; // avoid intermediate signal handling + m_id = Core::Id(); + if (!item) { + m_loadingItem = false; + return; + } + + // Set values: + m_displayNameLineEdit->setEnabled(!item->m_autodetected); + m_displayNameLineEdit->setText(item->m_name); + + m_binaryChooser->setReadOnly(item->m_autodetected); + m_binaryChooser->setFileName(item->m_executable); + + m_id = item->m_id; + m_loadingItem = false; +} + +// -------------------------------------------------------------------------- +// CMakeToolConfigWidget +// -------------------------------------------------------------------------- + +class CMakeToolConfigWidget : public QWidget +{ +public: + CMakeToolConfigWidget() : m_currentItem(0) + { + m_addButton = new QPushButton(tr("Add"), this); + + m_cloneButton = new QPushButton(tr("Clone"), this); + m_cloneButton->setEnabled(false); + + m_delButton = new QPushButton(tr("Remove"), this); + m_delButton->setEnabled(false); + + m_makeDefButton = new QPushButton(tr("Make Default"), this); + m_makeDefButton->setEnabled(false); + m_makeDefButton->setToolTip(tr("Set as the default CMake Tool to use when creating a new Kit, or no value is set.")); + + m_preferNinjaCheckBox = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)")); + m_preferNinjaCheckBox->setChecked(CMakeToolManager::preferNinja()); + + m_container = new DetailsWidget(this); + m_container->setState(DetailsWidget::NoSummary); + m_container->setVisible(false); + + m_cmakeToolsView = new QTreeView(this); + m_cmakeToolsView->setModel(&m_model); + m_cmakeToolsView->setUniformRowHeights(true); + m_cmakeToolsView->setRootIsDecorated(false); + m_cmakeToolsView->setSelectionMode(QAbstractItemView::SingleSelection); + m_cmakeToolsView->setSelectionBehavior(QAbstractItemView::SelectRows); + m_cmakeToolsView->expandAll(); + + QHeaderView *header = m_cmakeToolsView->header(); + header->setStretchLastSection(false); + header->setSectionResizeMode(0, QHeaderView::ResizeToContents); + header->setSectionResizeMode(1, QHeaderView::Stretch); + + QVBoxLayout *buttonLayout = new QVBoxLayout(); + buttonLayout->setContentsMargins(0, 0, 0, 0); + buttonLayout->addWidget(m_addButton); + buttonLayout->addWidget(m_cloneButton); + buttonLayout->addWidget(m_delButton); + buttonLayout->addWidget(m_makeDefButton); + buttonLayout->addItem(new QSpacerItem(10, 40, QSizePolicy::Minimum, QSizePolicy::Expanding)); + + QVBoxLayout *verticalLayout = new QVBoxLayout(); + verticalLayout->addWidget(m_cmakeToolsView); + verticalLayout->addWidget(m_container); + verticalLayout->addWidget(m_preferNinjaCheckBox); + + QHBoxLayout *horizontalLayout = new QHBoxLayout(this); + horizontalLayout->addLayout(verticalLayout); + horizontalLayout->addLayout(buttonLayout); + + connect(m_cmakeToolsView->selectionModel(), &QItemSelectionModel::currentChanged, + this, &CMakeToolConfigWidget::currentCMakeToolChanged, Qt::QueuedConnection); + + connect(m_addButton, &QAbstractButton::clicked, + this, &CMakeToolConfigWidget::addCMakeTool); + connect(m_cloneButton, &QAbstractButton::clicked, + this, &CMakeToolConfigWidget::cloneCMakeTool); + connect(m_delButton, &QAbstractButton::clicked, + this, &CMakeToolConfigWidget::removeCMakeTool); + connect(m_makeDefButton, &QAbstractButton::clicked, + this, &CMakeToolConfigWidget::setDefaultCMakeTool); + + m_itemConfigWidget = new CMakeToolItemConfigWidget(&m_model); + m_container->setWidget(m_itemConfigWidget); + } + + void apply(); + void cloneCMakeTool(); + void addCMakeTool(); + void removeCMakeTool(); + void setDefaultCMakeTool(); + void currentCMakeToolChanged(const QModelIndex &newCurrent); + + CMakeToolItemModel m_model; + QTreeView *m_cmakeToolsView; + QPushButton *m_addButton; + QPushButton *m_cloneButton; + QPushButton *m_delButton; + QPushButton *m_makeDefButton; + QCheckBox *m_preferNinjaCheckBox; + DetailsWidget *m_container; + CMakeToolItemConfigWidget *m_itemConfigWidget; + CMakeToolTreeItem *m_currentItem; +}; + +void CMakeToolConfigWidget::apply() +{ + m_model.apply(); + CMakeToolManager::setPreferNinja(m_preferNinjaCheckBox->checkState() == Qt::Checked); +} + +void CMakeToolConfigWidget::cloneCMakeTool() +{ + if (!m_currentItem) + return; + + QModelIndex newItem = m_model.addCMakeTool(tr("Clone of %1").arg(m_currentItem->m_name), + m_currentItem->m_executable, + false); + + m_cmakeToolsView->setCurrentIndex(newItem); } -QString CMakeSettingsPage::cmakeExecutable() const +void CMakeToolConfigWidget::addCMakeTool() { - if (!isCMakeExecutableValid()) - return QString(); + QModelIndex newItem = m_model.addCMakeTool(m_model.uniqueDisplayName(tr("New CMake")), + FileName(), false); - if (m_cmakeValidatorForUser.isValid()) - return m_cmakeValidatorForUser.cmakeExecutable(); - if (m_cmakeValidatorForSystem.isValid()) - return m_cmakeValidatorForSystem.cmakeExecutable(); - return QString(); + m_cmakeToolsView->setCurrentIndex(newItem); } -void CMakeSettingsPage::setCMakeExecutable(const QString &executable) +void CMakeToolConfigWidget::removeCMakeTool() { - if (m_cmakeValidatorForUser.cmakeExecutable() == executable) + bool delDef = m_model.defaultItemId() == m_currentItem->m_id; + m_model.removeCMakeTool(m_currentItem->m_id); + m_currentItem = 0; + + if (delDef) { + CMakeToolTreeItem *it = static_cast<CMakeToolTreeItem *>(m_model.autoGroupItem()->firstChild()); + if (!it) + it = static_cast<CMakeToolTreeItem *>(m_model.manualGroupItem()->firstChild()); + if (it) + m_model.setDefaultItemId(it->m_id); + } + + TreeItem *newCurrent = m_model.manualGroupItem()->lastChild(); + if (!newCurrent) + newCurrent = m_model.autoGroupItem()->lastChild(); + + if (newCurrent) + m_cmakeToolsView->setCurrentIndex(newCurrent->index()); +} + +void CMakeToolConfigWidget::setDefaultCMakeTool() +{ + if (!m_currentItem) return; - m_cmakeValidatorForUser.setCMakeExecutable(executable); + + m_model.setDefaultItemId(m_currentItem->m_id); + m_makeDefButton->setEnabled(false); } -bool CMakeSettingsPage::hasCodeBlocksMsvcGenerator() const +void CMakeToolConfigWidget::currentCMakeToolChanged(const QModelIndex &newCurrent) { - if (m_cmakeValidatorForUser.isValid()) - return m_cmakeValidatorForUser.hasCodeBlocksMsvcGenerator(); - if (m_cmakeValidatorForSystem.isValid()) - return m_cmakeValidatorForSystem.hasCodeBlocksMsvcGenerator(); - return false; + m_currentItem = m_model.cmakeToolItem(newCurrent); + m_itemConfigWidget->load(m_currentItem); + m_container->setVisible(m_currentItem); + m_cloneButton->setEnabled(m_currentItem); + m_delButton->setEnabled(m_currentItem && !m_currentItem->m_autodetected); + m_makeDefButton->setEnabled(m_currentItem && (!m_model.defaultItemId().isValid() || m_currentItem->m_id != m_model.defaultItemId())); } -bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const +///// +// CMakeSettingsPage +//// + +CMakeSettingsPage::CMakeSettingsPage() : m_widget(0) { - if (m_cmakeValidatorForUser.isValid()) - return m_cmakeValidatorForUser.hasCodeBlocksNinjaGenerator(); - if (m_cmakeValidatorForSystem.isValid()) - return m_cmakeValidatorForSystem.hasCodeBlocksNinjaGenerator(); - return false; + setId(Constants::CMAKE_SETTINGSPAGE_ID); + setDisplayName(tr("CMake")); + setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY); + setDisplayCategory(QCoreApplication::translate("ProjectExplorer", + ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY)); + setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON)); } -bool CMakeSettingsPage::preferNinja() const +CMakeSettingsPage::~CMakeSettingsPage() { - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(QLatin1String("CMakeSettings")); - const bool r = settings->value(QLatin1String("preferNinja"), false).toBool(); - settings->endGroup(); - return r; } -TextEditor::Keywords CMakeSettingsPage::keywords() +QWidget *CMakeSettingsPage::widget() { - if (m_cmakeValidatorForUser.isValid()) - return m_cmakeValidatorForUser.keywords(); + if (!m_widget) + m_widget = new CMakeToolConfigWidget; + return m_widget; +} - if (m_cmakeValidatorForSystem.isValid()) - return m_cmakeValidatorForSystem.keywords(); +void CMakeSettingsPage::apply() +{ + QTC_ASSERT(m_widget, return); + m_widget->m_itemConfigWidget->store(); + m_widget->m_model.apply(); +} - return TextEditor::Keywords(QStringList(), QStringList(), QMap<QString, QStringList>()); +void CMakeSettingsPage::finish() +{ + delete m_widget; + m_widget = 0; } } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.h b/src/plugins/cmakeprojectmanager/cmakesettingspage.h index 813482169c4..1ff868f485c 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.h +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.h @@ -32,18 +32,16 @@ #include <coreplugin/dialogs/ioptionspage.h> #include <utils/pathchooser.h> -#include <texteditor/codeassist/keywordscompletionassist.h> #include <QPointer> #include "cmaketool.h" -QT_FORWARD_DECLARE_CLASS(QLabel) -QT_FORWARD_DECLARE_CLASS(QCheckBox) - namespace CMakeProjectManager { namespace Internal { +class CMakeToolConfigWidget; + class CMakeSettingsPage : public Core::IOptionsPage { Q_OBJECT @@ -56,24 +54,8 @@ public: void apply(); void finish(); - QString cmakeExecutable() const; - void setCMakeExecutable(const QString &executable); - bool isCMakeExecutableValid() const; - bool hasCodeBlocksMsvcGenerator() const; - bool hasCodeBlocksNinjaGenerator() const; - bool preferNinja() const; - - TextEditor::Keywords keywords(); - private: - void saveSettings() const; - QString findCmakeExecutable() const; - - QPointer<QWidget> m_widget; - Utils::PathChooser *m_pathchooser; - QCheckBox *m_preferNinja; - CMakeTool m_cmakeValidatorForUser; - CMakeTool m_cmakeValidatorForSystem; + CMakeToolConfigWidget *m_widget; }; } // namespace Internal diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 70206d46bf6..180baf97209 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -29,20 +29,51 @@ ****************************************************************************/ #include "cmaketool.h" +#include "cmaketoolmanager.h" + +#include <utils/qtcassert.h> #include <QProcess> #include <QFileInfo> #include <QTextDocument> +#include <QUuid> + +using namespace CMakeProjectManager; -using namespace CMakeProjectManager::Internal; +const char CMAKE_INFORMATION_ID[] = "Id"; +const char CMAKE_INFORMATION_COMMAND[] = "Binary"; +const char CMAKE_INFORMATION_DISPLAYNAME[] = "DisplayName"; +const char CMAKE_INFORMATION_AUTODETECTED[] = "AutoDetected"; /////////////////////////// // CMakeTool /////////////////////////// -CMakeTool::CMakeTool() - : m_state(Invalid), m_process(0), m_hasCodeBlocksMsvcGenerator(false), m_hasCodeBlocksNinjaGenerator(false) +CMakeTool::CMakeTool(Detection d, const Core::Id &id) + : m_state(Invalid), m_process(0), + m_isAutoDetected(d == AutoDetection), + m_hasCodeBlocksMsvcGenerator(false), + m_hasCodeBlocksNinjaGenerator(false), + m_id(id) +{ + //make sure every CMakeTool has a valid ID + if (!m_id.isValid()) + createId(); +} + +CMakeTool::CMakeTool(const QVariantMap &map, bool fromSdk) + : m_state(Invalid), m_process(0), + m_isAutoDetected(fromSdk), + m_hasCodeBlocksMsvcGenerator(false), + m_hasCodeBlocksNinjaGenerator(false) { + m_id = Core::Id::fromSetting(map.value(QLatin1String(CMAKE_INFORMATION_ID))); + m_displayName = map.value(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME)).toString(); + //loading a CMakeTool from SDK is always autodetection + if (!fromSdk) + m_isAutoDetected = map.value(QLatin1String(CMAKE_INFORMATION_AUTODETECTED), false).toBool(); + + setCMakeExecutable(Utils::FileName::fromUserInput(map.value(QLatin1String(CMAKE_INFORMATION_COMMAND)).toString())); } CMakeTool::~CMakeTool() @@ -54,20 +85,24 @@ void CMakeTool::cancel() { if (m_process) { disconnect(m_process, SIGNAL(finished(int))); + + if (m_process->state() != QProcess::NotRunning) + m_process->kill(); + m_process->waitForFinished(); delete m_process; m_process = 0; } } -void CMakeTool::setCMakeExecutable(const QString &executable) +void CMakeTool::setCMakeExecutable(const Utils::FileName &executable) { cancel(); m_process = new QProcess(); connect(m_process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this, &CMakeTool::finished); m_executable = executable; - QFileInfo fi(m_executable); + QFileInfo fi = m_executable.toFileInfo(); if (fi.exists() && fi.isExecutable()) { // Run it to find out more m_state = CMakeTool::RunningBasic; @@ -76,6 +111,8 @@ void CMakeTool::setCMakeExecutable(const QString &executable) } else { m_state = CMakeTool::Invalid; } + + CMakeToolManager::notifyAboutUpdate(this); } void CMakeTool::finished(int exitCode) @@ -121,20 +158,39 @@ void CMakeTool::finished(int exitCode) bool CMakeTool::isValid() const { - if (m_state == CMakeTool::Invalid) + if (m_state == CMakeTool::Invalid || !m_id.isValid()) return false; - if (m_state == CMakeTool::RunningBasic) - m_process->waitForFinished(); + if (m_state == CMakeTool::RunningBasic) { + if (!m_process->waitForFinished(10000)) { + return false; + } + } return (m_state != CMakeTool::Invalid); } +void CMakeTool::createId() +{ + QTC_ASSERT(!m_id.isValid(), return); + m_id = Core::Id::fromString(QUuid::createUuid().toString()); +} + +QVariantMap CMakeTool::toMap() const +{ + QVariantMap data; + data.insert(QLatin1String(CMAKE_INFORMATION_DISPLAYNAME), m_displayName); + data.insert(QLatin1String(CMAKE_INFORMATION_ID), m_id.toSetting()); + data.insert(QLatin1String(CMAKE_INFORMATION_COMMAND), m_executable.toString()); + data.insert(QLatin1String(CMAKE_INFORMATION_AUTODETECTED), m_isAutoDetected); + return data; +} + bool CMakeTool::startProcess(const QStringList &args) { - m_process->start(m_executable, args); + m_process->start(m_executable.toString(), args); return m_process->waitForStarted(2000); } -QString CMakeTool::cmakeExecutable() const +Utils::FileName CMakeTool::cmakeExecutable() const { return m_executable; } @@ -165,6 +221,11 @@ TextEditor::Keywords CMakeTool::keywords() return TextEditor::Keywords(m_variables, m_functions, m_functionArgs); } +bool CMakeTool::isAutoDetected() const +{ + return m_isAutoDetected; +} + static void extractKeywords(const QByteArray &input, QStringList *destination) { if (!destination) @@ -212,6 +273,29 @@ QString CMakeTool::formatFunctionDetails(const QString &command, const QString & .arg(command.toHtmlEscaped(), args.toHtmlEscaped()); } +QString CMakeTool::displayName() const +{ + return m_displayName; +} + +void CMakeTool::setDisplayName(const QString &displayName) +{ + m_displayName = displayName; + CMakeToolManager::notifyAboutUpdate(this); +} + +void CMakeTool::setPathMapper(const CMakeTool::PathMapper &pathMapper) +{ + m_pathMapper = pathMapper; +} + +QString CMakeTool::mapAllPaths(ProjectExplorer::Kit *kit, const QString &in) const +{ + if (m_pathMapper) + return m_pathMapper(kit, in); + return in; +} + void CMakeTool::parseFunctionDetailsOutput(const QByteArray &output) { QStringList cmakeFunctionsList = m_functions; diff --git a/src/plugins/cmakeprojectmanager/cmaketool.h b/src/plugins/cmakeprojectmanager/cmaketool.h index 1609d4407b9..9fcbf4ab1cd 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.h +++ b/src/plugins/cmakeprojectmanager/cmaketool.h @@ -31,21 +31,35 @@ #ifndef CMAKEVALIDATOR_H #define CMAKEVALIDATOR_H +#include "cmake_global.h" + +#include <texteditor/codeassist/keywordscompletionassist.h> +#include <utils/fileutils.h> +#include <coreplugin/id.h> + #include <QObject> #include <QString> #include <QStringList> -#include <texteditor/codeassist/keywordscompletionassist.h> QT_FORWARD_DECLARE_CLASS(QProcess) +namespace ProjectExplorer { class Kit; } + namespace CMakeProjectManager { -namespace Internal { -class CMakeTool : public QObject +class CMAKE_EXPORT CMakeTool : public QObject { Q_OBJECT public: - CMakeTool(); + enum Detection { + ManualDetection, + AutoDetection + }; + + typedef std::function<QString (ProjectExplorer::Kit *, const QString &)> PathMapper; + + explicit CMakeTool(Detection d, const Core::Id &id = Core::Id()); + explicit CMakeTool(const QVariantMap &map, bool fromSdk); ~CMakeTool(); enum State { Invalid, RunningBasic, RunningFunctionList, RunningFunctionDetails, @@ -53,15 +67,26 @@ public: void cancel(); bool isValid() const; - void setCMakeExecutable(const QString &executable); - QString cmakeExecutable() const; + Core::Id id() const { return m_id; } + QVariantMap toMap () const; + + void setCMakeExecutable(const Utils::FileName &executable); + Utils::FileName cmakeExecutable() const; bool hasCodeBlocksMsvcGenerator() const; bool hasCodeBlocksNinjaGenerator() const; TextEditor::Keywords keywords(); + bool isAutoDetected() const; + QString displayName() const; + void setDisplayName(const QString &displayName); + + void setPathMapper(const PathMapper &includePathMapper); + QString mapAllPaths(ProjectExplorer::Kit *kit, const QString &in) const; + private slots: void finished(int exitCode); private: + void createId(); void finishStep(); void startNextStep(); bool startProcess(const QStringList &args); @@ -73,16 +98,21 @@ private: State m_state; QProcess *m_process; + Utils::FileName m_executable; + + bool m_isAutoDetected; bool m_hasCodeBlocksMsvcGenerator; bool m_hasCodeBlocksNinjaGenerator; - QString m_executable; QMap<QString, QStringList> m_functionArgs; QStringList m_variables; QStringList m_functions; + + Core::Id m_id; + QString m_displayName; + PathMapper m_pathMapper; }; -} // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEVALIDATOR_H diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp new file mode 100644 index 00000000000..f157fccc5e9 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -0,0 +1,436 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "cmaketoolmanager.h" + +#include <coreplugin/icore.h> +#include <projectexplorer/toolchainmanager.h> +#include <utils/persistentsettings.h> +#include <utils/qtcassert.h> +#include <utils/environment.h> +#include <utils/algorithm.h> + +#include <QFileInfo> +#include <QDebug> +#include <QDir> + +using namespace Core; +using namespace Utils; +using namespace ProjectExplorer; + +namespace CMakeProjectManager { + +const char CMAKETOOL_COUNT_KEY[] = "CMakeTools.Count"; +const char CMAKETOOL_DEFAULT_KEY[] = "CMakeTools.Default"; +const char CMAKETOOL_PREFER_NINJA_KEY[] = "CMakeTools.PreferNinja"; +const char CMAKETOOL_DATA_KEY[] = "CMakeTools."; +const char CMAKETOOL_FILE_VERSION_KEY[] = "Version"; +const char CMAKETOOL_FILENAME[] = "/qtcreator/cmaketools.xml"; + +class CMakeToolManagerPrivate +{ + +public: + CMakeToolManagerPrivate() : + m_preferNinja(false), + m_writer(0) + {} + + bool m_preferNinja; + Id m_defaultCMake; + QList<CMakeTool *> m_cmakeTools; + PersistentSettingsWriter *m_writer; + QList<CMakeToolManager::AutodetectionHelper> m_autoDetectionHelpers; +}; +static CMakeToolManagerPrivate *d = 0; + +static void addCMakeTool(CMakeTool *item) +{ + QTC_ASSERT(item->id().isValid(), return); + + d->m_cmakeTools.append(item); + + //set the first registered cmake tool as default if there is not already one + if (!d->m_defaultCMake.isValid()) + CMakeToolManager::setDefaultCMakeTool(item->id()); +} + +static FileName userSettingsFileName() +{ + QFileInfo settingsLocation(ICore::settings()->fileName()); + return FileName::fromString(settingsLocation.absolutePath() + QLatin1String(CMAKETOOL_FILENAME)); +} + +static QList<CMakeTool *> readCMakeTools(const FileName &fileName, Core::Id *defaultId, bool fromSDK) +{ + PersistentSettingsReader reader; + if (!reader.load(fileName)) + return QList<CMakeTool *>(); + + QVariantMap data = reader.restoreValues(); + + // Check version + int version = data.value(QLatin1String(CMAKETOOL_FILE_VERSION_KEY), 0).toInt(); + if (version < 1) + return QList<CMakeTool *>(); + + QList<CMakeTool *> loaded; + + int count = data.value(QLatin1String(CMAKETOOL_COUNT_KEY), 0).toInt(); + for (int i = 0; i < count; ++i) { + const QString key = QString::fromLatin1(CMAKETOOL_DATA_KEY) + QString::number(i); + if (!data.contains(key)) + continue; + + const QVariantMap dbMap = data.value(key).toMap(); + CMakeTool *item = new CMakeTool(dbMap,fromSDK); + if (item->isAutoDetected()) { + if (!item->cmakeExecutable().toFileInfo().isExecutable()) { + qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) read from \"%3\" dropped since the command is not executable.") + .arg(item->cmakeExecutable().toUserOutput(), item->id().toString(), fileName.toUserOutput()); + delete item; + continue; + } + } + + loaded.append(item); + } + + *defaultId = Id::fromSetting(data.value(QLatin1String(CMAKETOOL_DEFAULT_KEY), defaultId->toSetting())); + d->m_preferNinja= data.value(QLatin1String(CMAKETOOL_PREFER_NINJA_KEY), d->m_preferNinja).toBool(); + + return loaded; +} + +static void readAndDeleteLegacyCMakeSettings () +{ + // restore the legacy cmake + QSettings *settings = ICore::settings(); + settings->beginGroup(QLatin1String("CMakeSettings")); + + FileName exec = FileName::fromUserInput(settings->value(QLatin1String("cmakeExecutable")).toString()); + if (exec.toFileInfo().isExecutable()) { + CMakeTool *item = CMakeToolManager::findByCommand(exec); + if (!item) { + item = new CMakeTool(CMakeTool::ManualDetection); + item->setCMakeExecutable(exec); + item->setDisplayName(CMakeToolManager::tr("CMake at %1").arg(item->cmakeExecutable().toUserOutput())); + + if (!CMakeToolManager::registerCMakeTool(item)) { + delete item; + item = 0; + } + } + + //this setting used to be the default cmake, make sure it is again + if (item) + d->m_defaultCMake = item->id(); + } + + //read the legacy ninja setting, if its not available use the current value + d->m_preferNinja = settings->value(QLatin1String("preferNinja"), d->m_preferNinja).toBool(); + + settings->remove(QString()); + settings->endGroup(); +} + +static QList<CMakeTool *> autoDetectCMakeTools() +{ + QStringList filters; + filters.append(QStringLiteral("cmake")); + + QList<FileName> suspects; + + QStringList path = Environment::systemEnvironment().path(); + path.removeDuplicates(); + QDir dir; + dir.setNameFilters(filters); + dir.setFilter(QDir::Files | QDir::Executable); + foreach (const QString &base, path) { + dir.setPath(base); + foreach (const QString &entry, dir.entryList()) + suspects.append(FileName::fromString(dir.absoluteFilePath(entry))); + } + + QList<CMakeTool *> found; + foreach (const FileName &command, suspects) { + CMakeTool *item = new CMakeTool(CMakeTool::AutoDetection); + item->setCMakeExecutable(command); + item->setDisplayName(CMakeToolManager::tr("System CMake at %1").arg(command.toUserOutput())); + + found.append(item); + } + + //execute custom helpers if available + foreach (CMakeToolManager::AutodetectionHelper source, d->m_autoDetectionHelpers) + found.append(source()); + + return found; +} + +CMakeToolManager *CMakeToolManager::m_instance = 0; + +CMakeToolManager::CMakeToolManager(QObject *parent) : + QObject(parent) +{ + QTC_ASSERT(!m_instance, return); + m_instance = this; + + d = new CMakeToolManagerPrivate; + d->m_writer = new PersistentSettingsWriter(userSettingsFileName(), QStringLiteral("QtCreatorCMakeTools")); + connect(ICore::instance(), &ICore::saveSettingsRequested, + this, &CMakeToolManager::saveCMakeTools); + + connect(this, &CMakeToolManager::cmakeAdded, this, &CMakeToolManager::cmakeToolsChanged); + connect(this, &CMakeToolManager::cmakeRemoved, this, &CMakeToolManager::cmakeToolsChanged); + connect(this, &CMakeToolManager::cmakeUpdated, this, &CMakeToolManager::cmakeToolsChanged); +} + +CMakeToolManager::~CMakeToolManager() +{ + delete d->m_writer; + delete d; + d = 0; +} + +CMakeToolManager *CMakeToolManager::instance() +{ + return m_instance; +} + +QList<CMakeTool *> CMakeToolManager::cmakeTools() +{ + return d->m_cmakeTools; +} + +void CMakeToolManager::setPreferNinja(bool set) +{ + d->m_preferNinja = set; +} + +bool CMakeToolManager::preferNinja() +{ + return d->m_preferNinja; +} + +Id CMakeToolManager::registerOrFindCMakeTool(const FileName &command) +{ + CMakeTool *cmake = findByCommand(command); + if (cmake) + return cmake->id(); + + cmake = new CMakeTool(CMakeTool::ManualDetection); + cmake->setCMakeExecutable(command); + cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput())); + + addCMakeTool(cmake); + emit m_instance->cmakeAdded(cmake->id()); + return cmake->id(); +} + +bool CMakeToolManager::registerCMakeTool(CMakeTool *tool) +{ + if (!tool || d->m_cmakeTools.contains(tool)) + return true; + + QTC_ASSERT(tool->id().isValid(),return false); + + //make sure the same id was not used before + foreach (CMakeTool *current, d->m_cmakeTools) { + if (tool->id() == current->id()) + return false; + } + + addCMakeTool(tool); + emit m_instance->cmakeAdded(tool->id()); + return true; +} + +void CMakeToolManager::deregisterCMakeTool(const Id &id) +{ + int idx = Utils::indexOf(d->m_cmakeTools, Utils::equal(&CMakeTool::id, id)); + if (idx >= 0) { + CMakeTool *toRemove = d->m_cmakeTools.takeAt(idx); + if (toRemove->id() == d->m_defaultCMake) { + if (d->m_cmakeTools.isEmpty()) + d->m_defaultCMake = Id(); + else + d->m_defaultCMake = d->m_cmakeTools.first()->id(); + + emit m_instance->defaultCMakeChanged(); + } + + emit m_instance->cmakeRemoved(id); + delete toRemove; + } +} + +CMakeTool *CMakeToolManager::defaultCMakeTool() +{ + CMakeTool *tool = findById(d->m_defaultCMake); + if (!tool) { + //if the id is not valid, we set the firstly registered one as default + if (!d->m_cmakeTools.isEmpty()) { + d->m_defaultCMake = d->m_cmakeTools.first()->id(); + emit m_instance->defaultCMakeChanged(); + + return d->m_cmakeTools.first(); + } + } + return tool; +} + +void CMakeToolManager::setDefaultCMakeTool(const Id &id) +{ + if (d->m_defaultCMake == id) + return; + + if (findById(id)) { + d->m_defaultCMake = id; + emit m_instance->defaultCMakeChanged(); + } +} + +CMakeTool *CMakeToolManager::findByCommand(const FileName &command) +{ + return Utils::findOrDefault(d->m_cmakeTools, Utils::equal(&CMakeTool::cmakeExecutable, command)); +} + +CMakeTool *CMakeToolManager::findById(const Id &id) +{ + return Utils::findOrDefault(d->m_cmakeTools, Utils::equal(&CMakeTool::id, id)); +} + +void CMakeToolManager::restoreCMakeTools() +{ + Core::Id defaultId; + + QFileInfo systemSettingsFile(ICore::settings(QSettings::SystemScope)->fileName()); + FileName sdkSettingsFile = FileName::fromString(systemSettingsFile.absolutePath() + + QLatin1String(CMAKETOOL_FILENAME)); + + QList<CMakeTool *> toolsToRegister = readCMakeTools(sdkSettingsFile, &defaultId, true); + + //read the tools from the user settings file + QList<CMakeTool *> readTools = readCMakeTools(userSettingsFileName(), &defaultId, false); + + //autodetect tools + QList<CMakeTool *> autoDetected = autoDetectCMakeTools(); + + //filter out the tools that were stored in SDK + for (int i = readTools.size() - 1; i >= 0; i--) { + CMakeTool *currTool = readTools.takeAt(i); + if (Utils::anyOf(toolsToRegister, Utils::equal(&CMakeTool::id, currTool->id()))) { + delete currTool; + } else { + //if the current tool is marked as autodetected and NOT in the autodetected list, + //it is a leftover SDK provided tool. The user will not be able to edit it, + //so we automatically drop it + if (currTool->isAutoDetected()) { + if (!Utils::anyOf(autoDetected, + Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) { + + qWarning() << QString::fromLatin1("Previously SDK provided CMakeTool \"%1\" (%2) dropped.") + .arg(currTool->cmakeExecutable().toUserOutput(), currTool->id().toString()); + + delete currTool; + continue; + } + } + toolsToRegister.append(currTool); + } + } + + //filter out the tools that are already known + while (autoDetected.size()) { + CMakeTool *currTool = autoDetected.takeFirst(); + if (Utils::anyOf(toolsToRegister, + Utils::equal(&CMakeTool::cmakeExecutable, currTool->cmakeExecutable()))) + delete currTool; + else + toolsToRegister.append(currTool); + } + + // Store all tools + foreach (CMakeTool *current, toolsToRegister) { + if (!registerCMakeTool(current)) { + //this should never happen, but lets make sure we do not leak memory + qWarning() << QString::fromLatin1("CMakeTool \"%1\" (%2) dropped.") + .arg(current->cmakeExecutable().toUserOutput(), current->id().toString()); + + delete current; + } + } + + if (CMakeToolManager::findById(defaultId)) + d->m_defaultCMake = defaultId; + + // restore the legacy cmake settings only once and keep them around + readAndDeleteLegacyCMakeSettings(); + emit m_instance->cmakeToolsLoaded(); +} + +void CMakeToolManager::registerAutodetectionHelper(CMakeToolManager::AutodetectionHelper helper) +{ + d->m_autoDetectionHelpers.append(helper); +} + +void CMakeToolManager::notifyAboutUpdate(CMakeTool *tool) +{ + if (!tool || !d->m_cmakeTools.contains(tool)) + return; + emit m_instance->cmakeUpdated(tool->id()); +} + +void CMakeToolManager::saveCMakeTools() +{ + QTC_ASSERT(d->m_writer, return); + QVariantMap data; + data.insert(QLatin1String(CMAKETOOL_FILE_VERSION_KEY), 1); + data.insert(QLatin1String(CMAKETOOL_DEFAULT_KEY), d->m_defaultCMake.toSetting()); + data.insert(QLatin1String(CMAKETOOL_PREFER_NINJA_KEY), d->m_preferNinja); + + int count = 0; + foreach (CMakeTool *item, d->m_cmakeTools) { + QFileInfo fi = item->cmakeExecutable().toFileInfo(); + + if (fi.isExecutable()) { + QVariantMap tmp = item->toMap(); + if (tmp.isEmpty()) + continue; + data.insert(QString::fromLatin1(CMAKETOOL_DATA_KEY) + QString::number(count), tmp); + ++count; + } + } + data.insert(QLatin1String(CMAKETOOL_COUNT_KEY), count); + d->m_writer->save(data, ICore::mainWindow()); +} + +} // namespace CMakeProjectManager diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.h b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h new file mode 100644 index 00000000000..6edf21618a0 --- /dev/null +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2015 Canonical Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H +#define CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H + +#include "cmake_global.h" +#include "cmaketool.h" + +#include <utils/fileutils.h> +#include <texteditor/codeassist/keywordscompletionassist.h> +#include <functional> + +#include <QObject> + +namespace CMakeProjectManager { + +class CMAKE_EXPORT CMakeToolManager : public QObject +{ + Q_OBJECT +public: + typedef std::function<QList<CMakeTool *> ()> AutodetectionHelper; + + CMakeToolManager(QObject *parent); + ~CMakeToolManager(); + + static CMakeToolManager *instance(); + + static QList<CMakeTool *> cmakeTools(); + static void setPreferNinja(bool set); + static bool preferNinja(); + + static Core::Id registerOrFindCMakeTool(const Utils::FileName &command); + static bool registerCMakeTool(CMakeTool *tool); + static void deregisterCMakeTool(const Core::Id &id); + + static CMakeTool *defaultCMakeTool(); + static void setDefaultCMakeTool(const Core::Id &id); + static CMakeTool *findByCommand(const Utils::FileName &command); + static CMakeTool *findById(const Core::Id &id); + static void registerAutodetectionHelper(AutodetectionHelper helper); + + static void notifyAboutUpdate(CMakeTool *); + static void restoreCMakeTools(); + +signals: + void cmakeAdded (const Core::Id &id); + void cmakeRemoved (const Core::Id &id); + void cmakeUpdated (const Core::Id &id); + void cmakeToolsChanged (); + void cmakeToolsLoaded (); + void defaultCMakeChanged (); + +private: + static void saveCMakeTools(); + + static CMakeToolManager *m_instance; +}; + +} // namespace CMakeProjectManager + +#endif // CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H diff --git a/src/plugins/cmakeprojectmanager/generatorinfo.cpp b/src/plugins/cmakeprojectmanager/generatorinfo.cpp index 2dfc57e358e..e3c5a38327b 100644 --- a/src/plugins/cmakeprojectmanager/generatorinfo.cpp +++ b/src/plugins/cmakeprojectmanager/generatorinfo.cpp @@ -130,8 +130,7 @@ QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, N if (deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE && deviceType != BareMetal::Constants::BareMetalOsType && deviceType != RemoteLinux::Constants::GenericLinuxOsType - && deviceType != Qnx::Constants::QNX_QNX_OS_TYPE - && deviceType != Qnx::Constants::QNX_BB_OS_TYPE) + && deviceType != Qnx::Constants::QNX_QNX_OS_TYPE) return results; ProjectExplorer::Abi targetAbi = tc->targetAbi(); if (n != ForceNinja) { diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp index a1aef0885fa..29182dc781e 100644 --- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp +++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp @@ -419,27 +419,11 @@ void MenuActionContainer::removeMenu(QMenu *menu) m_menu->removeAction(menu->menuAction()); } -static bool menuInMenuBar(const QMenu *menu) -{ - foreach (const QWidget *widget, menu->menuAction()->associatedWidgets()) { - if (qobject_cast<const QMenuBar *>(widget)) - return true; - } - return false; -} - bool MenuActionContainer::updateInternal() { if (onAllDisabledBehavior() == Show) return true; - if (Utils::HostOsInfo::isMacHost()) { - // work around QTBUG-25544 which makes menus in the menu bar stay at their enabled state at startup - // (so menus that are disabled at startup would stay disabled) - if (menuInMenuBar(m_menu)) - return true; - } - bool hasitems = false; QList<QAction *> actions = m_menu->actions(); diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp index 6f3b95088af..94cb436d6db 100644 --- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp +++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp @@ -33,7 +33,6 @@ #include <coreplugin/dialogs/shortcutsettings.h> -#include <utils/hostosinfo.h> #include <utils/headerviewstretcher.h> #include <utils/fancylineedit.h> #include <utils/qtcassert.h> @@ -54,34 +53,13 @@ using namespace Utils; namespace Core { namespace Internal { -class KeySequenceValidator : public FancyLineEdit -{ -public: - KeySequenceValidator(QWidget *parent, CommandMappings *mappings) - : FancyLineEdit(parent), m_mappings(mappings) - {} - - bool validate(const QString &, QString *) const - { - return !m_mappings->hasConflicts(); - } - - CommandMappings *m_mappings; -}; - class CommandMappingsPrivate { public: CommandMappingsPrivate(CommandMappings *parent) - : q(parent), m_widget(0) - {} - - void setupWidget() + : q(parent) { - QTC_CHECK(m_widget == 0); - m_widget = new QWidget; - - groupBox = new QGroupBox(m_widget); + groupBox = new QGroupBox(parent); groupBox->setTitle(CommandMappings::tr("Command Mappings")); filterEdit = new FancyLineEdit(groupBox); @@ -104,21 +82,6 @@ public: importButton = new QPushButton(CommandMappings::tr("Import..."), groupBox); exportButton = new QPushButton(CommandMappings::tr("Export..."), groupBox); - targetEditGroup = new QGroupBox(CommandMappings::tr("Target Identifier"), m_widget); - - targetEdit = new KeySequenceValidator(targetEditGroup, q); - targetEdit->setAutoHideButton(FancyLineEdit::Right, true); - targetEdit->setPlaceholderText(QString()); - targetEdit->installEventFilter(q); - targetEdit->setFiltering(true); - - resetButton = new QPushButton(targetEditGroup); - resetButton->setToolTip(CommandMappings::tr("Reset to default.")); - resetButton->setText(CommandMappings::tr("Reset")); - - QLabel *infoLabel = new QLabel(targetEditGroup); - infoLabel->setTextFormat(Qt::RichText); - QHBoxLayout *hboxLayout1 = new QHBoxLayout(); hboxLayout1->addWidget(defaultButton); hboxLayout1->addStretch(); @@ -133,48 +96,27 @@ public: vboxLayout1->addWidget(commandList); vboxLayout1->addLayout(hboxLayout1); - QHBoxLayout *hboxLayout2 = new QHBoxLayout(); - hboxLayout2->addWidget(new QLabel(CommandMappings::tr("Target:"), targetEditGroup)); - hboxLayout2->addWidget(targetEdit); - hboxLayout2->addWidget(resetButton); - - QVBoxLayout *vboxLayout2 = new QVBoxLayout(targetEditGroup); - vboxLayout2->addLayout(hboxLayout2); - vboxLayout2->addWidget(infoLabel); - - QVBoxLayout *vboxLayout = new QVBoxLayout(m_widget); + QVBoxLayout *vboxLayout = new QVBoxLayout(parent); vboxLayout->addWidget(groupBox); - vboxLayout->addWidget(targetEditGroup); - - q->connect(targetEdit, SIGNAL(buttonClicked(Utils::FancyLineEdit::Side)), - SLOT(removeTargetIdentifier())); - q->connect(resetButton, SIGNAL(clicked()), - SLOT(resetTargetIdentifier())); - q->connect(exportButton, SIGNAL(clicked()), - SLOT(exportAction())); - q->connect(importButton, SIGNAL(clicked()), - SLOT(importAction())); - q->connect(defaultButton, SIGNAL(clicked()), - SLOT(defaultAction())); - q->initialize(); + q->connect(exportButton, &QPushButton::clicked, + q, &CommandMappings::exportAction); + q->connect(importButton, &QPushButton::clicked, + q, &CommandMappings::importAction); + q->connect(defaultButton, &QPushButton::clicked, + q, &CommandMappings::defaultAction); commandList->sortByColumn(0, Qt::AscendingOrder); - q->connect(filterEdit, SIGNAL(textChanged(QString)), - SLOT(filterChanged(QString))); - q->connect(commandList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), - SLOT(commandChanged(QTreeWidgetItem*))); - q->connect(targetEdit, SIGNAL(textChanged(QString)), - SLOT(targetIdentifierChanged())); + q->connect(filterEdit, &FancyLineEdit::textChanged, + q, &CommandMappings::filterChanged); + q->connect(commandList, &QTreeWidget::currentItemChanged, + q, &CommandMappings::currentCommandChanged); new HeaderViewStretcher(commandList->header(), 1); - - q->commandChanged(0); } CommandMappings *q; - QPointer<QWidget> m_widget; QGroupBox *groupBox; FancyLineEdit *filterEdit; @@ -182,15 +124,12 @@ public: QPushButton *defaultButton; QPushButton *importButton; QPushButton *exportButton; - QGroupBox *targetEditGroup; - FancyLineEdit *targetEdit; - QPushButton *resetButton; }; } // namespace Internal -CommandMappings::CommandMappings(QObject *parent) - : IOptionsPage(parent), d(new Internal::CommandMappingsPrivate(this)) +CommandMappings::CommandMappings(QWidget *parent) + : QWidget(parent), d(new Internal::CommandMappingsPrivate(this)) { } @@ -199,13 +138,6 @@ CommandMappings::~CommandMappings() delete d; } -QWidget *CommandMappings::widget() -{ - if (!d->m_widget) - d->setupWidget(); - return d->m_widget; -} - void CommandMappings::setImportExportEnabled(bool enabled) { d->importButton->setVisible(enabled); @@ -217,46 +149,16 @@ QTreeWidget *CommandMappings::commandList() const return d->commandList; } -QLineEdit *CommandMappings::targetEdit() const -{ - return d->targetEdit; -} - void CommandMappings::setPageTitle(const QString &s) { d->groupBox->setTitle(s); } -void CommandMappings::setTargetLabelText(const QString &s) -{ - d->targetEdit->setText(s); -} - -void CommandMappings::setTargetEditTitle(const QString &s) -{ - d->targetEditGroup->setTitle(s); -} - void CommandMappings::setTargetHeader(const QString &s) { d->commandList->setHeaderLabels(QStringList() << tr("Command") << tr("Label") << s); } -void CommandMappings::finish() -{ - delete d->m_widget; -} - -void CommandMappings::commandChanged(QTreeWidgetItem *current) -{ - if (!current || !current->data(0, Qt::UserRole).isValid()) { - d->targetEdit->clear(); - d->targetEditGroup->setEnabled(false); - return; - } - d->targetEditGroup->setEnabled(true); -} - void CommandMappings::filterChanged(const QString &f) { for (int i = 0; i < d->commandList->topLevelItemCount(); ++i) { @@ -265,31 +167,12 @@ void CommandMappings::filterChanged(const QString &f) } } -bool CommandMappings::hasConflicts() const -{ - return true; -} - bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item) { bool visible = filterString.isEmpty(); int columnCount = item->columnCount(); - for (int i = 0; !visible && i < columnCount; ++i) { - QString text = item->text(i); - if (HostOsInfo::isMacHost()) { - // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd - if (i == columnCount - 1) { - QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText); - if (!key.isEmpty()) { - text = key.toString(QKeySequence::PortableText); - text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd")); - text.replace(QLatin1String("Meta"), QLatin1String("Ctrl")); - text.replace(QLatin1String("Alt"), QLatin1String("Opt")); - } - } - } - visible |= (bool)text.contains(filterString, Qt::CaseInsensitive); - } + for (int i = 0; !visible && i < columnCount; ++i) + visible |= !filterColumn(filterString, item, i); int childCount = item->childCount(); if (childCount > 0) { @@ -304,6 +187,12 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item) return !visible; } +bool CommandMappings::filterColumn(const QString &filterString, QTreeWidgetItem *item, + int column) const +{ + return !item->text(column).contains(filterString, Qt::CaseInsensitive); +} + void CommandMappings::setModified(QTreeWidgetItem *item , bool modified) { QFont f = item->font(0); @@ -316,7 +205,12 @@ void CommandMappings::setModified(QTreeWidgetItem *item , bool modified) QString CommandMappings::filterText() const { - return d->filterEdit ? d->filterEdit->text() : QString(); + return d->filterEdit->text(); +} + +void CommandMappings::setFilterText(const QString &text) +{ + d->filterEdit->setText(text); } } // namespace Core diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.h b/src/plugins/coreplugin/actionmanager/commandmappings.h index 00da4509018..4d7081d48ee 100644 --- a/src/plugins/coreplugin/actionmanager/commandmappings.h +++ b/src/plugins/coreplugin/actionmanager/commandmappings.h @@ -31,7 +31,9 @@ #ifndef COMMANDMAPPINGS_H #define COMMANDMAPPINGS_H -#include <coreplugin/dialogs/ioptionspage.h> +#include <coreplugin/core_global.h> + +#include <QWidget> QT_BEGIN_NAMESPACE class QLineEdit; @@ -45,43 +47,39 @@ namespace Core { namespace Internal { class CommandMappingsPrivate; } -class CORE_EXPORT CommandMappings : public IOptionsPage +class CORE_EXPORT CommandMappings : public QWidget { Q_OBJECT public: - CommandMappings(QObject *parent = 0); + CommandMappings(QWidget *parent = 0); ~CommandMappings(); - virtual bool hasConflicts() const; -protected slots: - void commandChanged(QTreeWidgetItem *current); - void filterChanged(const QString &f); - virtual void importAction() {} - virtual void exportAction() {} - virtual void defaultAction() = 0; +signals: + void currentCommandChanged(QTreeWidgetItem *current); protected: - // IOptionsPage - QWidget *widget(); - virtual void apply() {} - virtual void finish(); + virtual void defaultAction() = 0; - virtual void initialize() = 0; - bool filter(const QString &filterString, QTreeWidgetItem *item); + virtual void exportAction() {} + virtual void importAction() {} + + virtual bool filterColumn(const QString &filterString, QTreeWidgetItem *item, int column) const; + + void filterChanged(const QString &f); // access to m_page void setImportExportEnabled(bool enabled); QTreeWidget *commandList() const; - QLineEdit *targetEdit() const; QString filterText() const; + void setFilterText(const QString &text); void setPageTitle(const QString &s); - void setTargetLabelText(const QString &s); - void setTargetEditTitle(const QString &s); void setTargetHeader(const QString &s); void setModified(QTreeWidgetItem *item, bool modified); private: + bool filter(const QString &filterString, QTreeWidgetItem *item); + friend class Internal::CommandMappingsPrivate; Internal::CommandMappingsPrivate *d; }; diff --git a/src/plugins/coreplugin/core.qrc b/src/plugins/coreplugin/core.qrc index 549a1cdd550..3b20ee263c5 100644 --- a/src/plugins/coreplugin/core.qrc +++ b/src/plugins/coreplugin/core.qrc @@ -74,6 +74,12 @@ <file>images/darkarrowup@2x.png</file> <file>images/darkclose.png</file> <file>images/darkclose@2x.png</file> + <file>images/lightarrowdown.png</file> + <file>images/lightarrowdown@2x.png</file> + <file>images/lightarrowup.png</file> + <file>images/lightarrowup@2x.png</file> + <file>images/lightclose.png</file> + <file>images/lightclose@2x.png</file> <file>images/arrowdown.png</file> <file>images/arrowdown@2x.png</file> <file>images/arrowup.png</file> @@ -106,5 +112,6 @@ <file>images/info@2x.png</file> <file>images/dark_fileicon.png</file> <file>images/dark_foldericon.png</file> + <file>images/Desktop.png</file> </qresource> </RCC> diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h index e3d3ecb7857..15e33c247cc 100644 --- a/src/plugins/coreplugin/coreconstants.h +++ b/src/plugins/coreplugin/coreconstants.h @@ -226,7 +226,6 @@ const char WIZARD_CATEGORY_QT[] = "R.Qt"; const char WIZARD_TR_CATEGORY_QT[] = QT_TRANSLATE_NOOP("Core", "Qt"); const char WIZARD_KIND_UNKNOWN[] = "unknown"; const char WIZARD_KIND_PROJECT[] = "project"; -const char WIZARD_KIND_CLASS[] = "class"; const char WIZARD_KIND_FILE[] = "file"; const char SETTINGS_CATEGORY_CORE[] = "A.Core"; diff --git a/src/plugins/coreplugin/corejsextensions.cpp b/src/plugins/coreplugin/corejsextensions.cpp index 6924d877b6f..199b960893a 100644 --- a/src/plugins/coreplugin/corejsextensions.cpp +++ b/src/plugins/coreplugin/corejsextensions.cpp @@ -87,6 +87,21 @@ QString UtilsJsExtension::absoluteFilePath(const QString &in) const return fi.absoluteFilePath(); } +bool UtilsJsExtension::exists(const QString &in) const +{ + return QFileInfo::exists(in); +} + +bool UtilsJsExtension::isDirectory(const QString &in) const +{ + return QFileInfo(in).isDir(); +} + +bool UtilsJsExtension::isFile(const QString &in) const +{ + return QFileInfo(in).isFile(); +} + QString UtilsJsExtension::preferredSuffix(const QString &mimetype) const { Utils::MimeDatabase mdb; diff --git a/src/plugins/coreplugin/corejsextensions.h b/src/plugins/coreplugin/corejsextensions.h index 7e88589bf52..0f6ed1273cc 100644 --- a/src/plugins/coreplugin/corejsextensions.h +++ b/src/plugins/coreplugin/corejsextensions.h @@ -33,7 +33,7 @@ #include <utils/stringutils.h> -#include <QScriptEngine> +#include <QObject> #include <QSet> namespace Core { @@ -58,6 +58,11 @@ public: Q_INVOKABLE QString path(const QString &in) const; Q_INVOKABLE QString absoluteFilePath(const QString &in) const; + // File checks: + Q_INVOKABLE bool exists(const QString &in) const; + Q_INVOKABLE bool isDirectory(const QString &in) const; + Q_INVOKABLE bool isFile(const QString &in) const; + // MimeDB: Q_INVOKABLE QString preferredSuffix(const QString &mimetype) const; diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 9782866156e..e4ce23df18a 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -185,6 +185,8 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage) InfoBar::initializeGloballySuppressed(); } + IWizardFactory::initialize(); + // Make sure we respect the process's umask when creating new files SaveFile::initializeUmask(); @@ -239,7 +241,7 @@ QObject *CorePlugin::remoteCommand(const QStringList & /* options */, const QStringList &args) { IDocument *res = m_mainWindow->openFiles( - args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineNumbers), + args, ICore::OpenFilesFlags(ICore::SwitchMode | ICore::CanContainLineAndColumnNumbers), workingDirectory); m_mainWindow->raiseWindow(); return res; diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro index a868a4c2cc0..239b0dc74a0 100644 --- a/src/plugins/coreplugin/coreplugin.pro +++ b/src/plugins/coreplugin/coreplugin.pro @@ -2,7 +2,7 @@ DEFINES += CORE_LIBRARY QT += help \ network \ printsupport \ - script \ + qml \ sql # embedding build time information prevents repeatedly binary exact versions from same source code @@ -13,6 +13,7 @@ include(../../qtcreatorplugin.pri) win32-msvc*:QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250 SOURCES += corejsextensions.cpp \ mainwindow.cpp \ + shellcommand.cpp \ editmode.cpp \ iwizardfactory.cpp \ tabpositionindicator.cpp \ @@ -120,6 +121,7 @@ SOURCES += corejsextensions.cpp \ HEADERS += corejsextensions.h \ mainwindow.h \ + shellcommand.h \ editmode.h \ iwizardfactory.h \ tabpositionindicator.h \ diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs index 72e56c56939..f0a32893cea 100644 --- a/src/plugins/coreplugin/coreplugin.qbs +++ b/src/plugins/coreplugin/coreplugin.qbs @@ -7,7 +7,7 @@ QtcPlugin { Depends { name: "Qt" submodules: [ - "widgets", "xml", "network", "script", "sql", "help", "printsupport" + "widgets", "xml", "network", "qml", "sql", "help", "printsupport" ] } @@ -91,6 +91,7 @@ QtcPlugin { "removefiledialog.cpp", "removefiledialog.h", "removefiledialog.ui", "rightpane.cpp", "rightpane.h", "settingsdatabase.cpp", "settingsdatabase.h", + "shellcommand.cpp", "shellcommand.h", "sidebar.cpp", "sidebar.h", "sidebarwidget.cpp", "sidebarwidget.h", "statusbarmanager.cpp", "statusbarmanager.h", @@ -259,6 +260,8 @@ QtcPlugin { "directoryfilter.ui", "executefilter.cpp", "executefilter.h", + "externaltoolsfilter.cpp", + "externaltoolsfilter.h", "filesystemfilter.cpp", "filesystemfilter.h", "filesystemfilter.ui", @@ -287,6 +290,15 @@ QtcPlugin { } Group { + name: "Locator_mac" + condition: qbs.targetOS.contains("osx") + files: [ + "locator/spotlightlocatorfilter.h", + "locator/spotlightlocatorfilter.mm", + ] + } + + Group { name: "ThemeEditor" prefix: "themeeditor/" files: [ diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index b6a96270b7d..e4b49f734cc 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -244,7 +244,7 @@ static bool wizardFactoryLessThan(const IWizardFactory *f1, const IWizardFactory { if (const int cc = f1->category().compare(f2->category())) return cc < 0; - return f1->id().compare(f2->id()) < 0; + return f1->id().toString().compare(f2->id().toString()) < 0; } void NewDialog::setWizardFactories(QList<IWizardFactory *> factories, @@ -261,12 +261,12 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories, QStandardItem *projectKindItem = new QStandardItem(tr("Projects")); projectKindItem->setData(IWizardFactory::ProjectWizard, Qt::UserRole); projectKindItem->setFlags(0); // disable item to prevent focus - QStandardItem *filesClassesKindItem = new QStandardItem(tr("Files and Classes")); - filesClassesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole); - filesClassesKindItem->setFlags(0); // disable item to prevent focus + QStandardItem *filesKindItem = new QStandardItem(tr("Files and Classes")); + filesKindItem->setData(IWizardFactory::FileWizard, Qt::UserRole); + filesKindItem->setFlags(0); // disable item to prevent focus parentItem->appendRow(projectKindItem); - parentItem->appendRow(filesClassesKindItem); + parentItem->appendRow(filesKindItem); if (m_dummyIcon.isNull()) m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEWFILE)); @@ -290,10 +290,9 @@ void NewDialog::setWizardFactories(QList<IWizardFactory *> factories, case IWizardFactory::ProjectWizard: kindItem = projectKindItem; break; - case IWizardFactory::ClassWizard: case IWizardFactory::FileWizard: default: - kindItem = filesClassesKindItem; + kindItem = filesKindItem; break; } addItem(kindItem, factory); diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index fefce66e3b7..0b7c212aa11 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -46,6 +46,8 @@ #include <QListView> #include <QPointer> #include <QPushButton> +#include <QResizeEvent> +#include <QScrollArea> #include <QScrollBar> #include <QSettings> #include <QSortFilterProxyModel> @@ -278,8 +280,7 @@ public: virtual QSize sizeHint() const { int width = sizeHintForColumn(0) + frameWidth() * 2 + 5; - if (verticalScrollBar()->isVisible()) - width += verticalScrollBar()->width(); + width += verticalScrollBar()->width(); return QSize(width, 100); } @@ -294,6 +295,68 @@ public: } }; +// ----------- SmartScrollArea + +class SmartScrollArea : public QScrollArea +{ +public: + SmartScrollArea(QWidget *parent = 0) + : QScrollArea(parent) + { + setFrameStyle(QFrame::NoFrame | QFrame::Plain); + viewport()->setAutoFillBackground(false); + } +private: + void resizeEvent(QResizeEvent *event) override + { + QWidget *inner = widget(); + if (inner) { + int fw = frameWidth() * 2; + QSize innerSize = event->size() - QSize(fw, fw); + QSize innerSizeHint = inner->minimumSizeHint(); + + if (innerSizeHint.height() > innerSize.height()) { // Widget wants to be bigger than available space + innerSize.setWidth(innerSize.width() - scrollBarWidth()); + innerSize.setHeight(innerSizeHint.height()); + } + inner->resize(innerSize); + } + QScrollArea::resizeEvent(event); + } + + QSize minimumSizeHint() const override { + QWidget *inner = widget(); + if (inner) { + int fw = frameWidth() * 2; + + QSize minSize = inner->minimumSizeHint(); + minSize += QSize(fw, fw); + minSize += QSize(scrollBarWidth(), 0); + minSize.setHeight(qMin(minSize.height(), 450)); + minSize.setWidth(qMin(minSize.width(), 810)); + return minSize; + } + return QSize(0, 0); + } + + bool event(QEvent *event) override { + if (event->type() == QEvent::LayoutRequest) + updateGeometry(); + return QScrollArea::event(event); + } + + int scrollBarWidth() const + { + auto that = const_cast<SmartScrollArea *>(this); + QWidgetList list = that->scrollBarWidgets(Qt::AlignRight); + if (list.isEmpty()) + return 0; + return list.first()->sizeHint().width(); + } + +}; + + // ----------- SettingsDialog // Helpers to sort by category. id @@ -447,9 +510,7 @@ void SettingsDialog::createGui() buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); - setMinimumSize(1000, 550); - if (Utils::HostOsInfo::isMacHost()) - setMinimumHeight(minimumHeight() * 1.1); + mainGridLayout->setSizeConstraint(QLayout::SetMinimumSize); } SettingsDialog::~SettingsDialog() @@ -491,7 +552,10 @@ void SettingsDialog::ensureCategoryWidget(Category *category) for (int j = 0; j < category->pages.size(); ++j) { IOptionsPage *page = category->pages.at(j); QWidget *widget = page->widget(); - tabWidget->addTab(widget, page->displayName()); + SmartScrollArea *ssa = new SmartScrollArea(this); + ssa->setWidget(widget); + widget->setAutoFillBackground(false); + tabWidget->addTab(ssa, page->displayName()); } connect(tabWidget, &QTabWidget::currentChanged, diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp index 9d9b3546cc7..94f78cf5d50 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp @@ -39,163 +39,367 @@ #include <coreplugin/actionmanager/commandsfile.h> #include <utils/fancylineedit.h> +#include <utils/hostosinfo.h> +#include <utils/qtcassert.h> +#include <utils/theme/theme.h> #include <QKeyEvent> #include <QFileDialog> +#include <QGroupBox> +#include <QHBoxLayout> +#include <QLabel> #include <QLineEdit> #include <QTreeWidgetItem> -#include <QCoreApplication> +#include <QApplication> #include <QDebug> Q_DECLARE_METATYPE(Core::Internal::ShortcutItem*) -namespace Core { -namespace Internal { +static int translateModifiers(Qt::KeyboardModifiers state, + const QString &text) +{ + int result = 0; + // The shift modifier only counts when it is not used to type a symbol + // that is only reachable using the shift key anyway + if ((state & Qt::ShiftModifier) && (text.size() == 0 + || !text.at(0).isPrint() + || text.at(0).isLetterOrNumber() + || text.at(0).isSpace())) + result |= Qt::SHIFT; + if (state & Qt::ControlModifier) + result |= Qt::CTRL; + if (state & Qt::MetaModifier) + result |= Qt::META; + if (state & Qt::AltModifier) + result |= Qt::ALT; + return result; +} -ShortcutSettings::ShortcutSettings(QObject *parent) - : CommandMappings(parent), m_initialized(false) +static QString keySequenceToEditString(const QKeySequence &sequence) { - connect(ActionManager::instance(), SIGNAL(commandListChanged()), this, SLOT(initialize())); + QString text = sequence.toString(QKeySequence::PortableText); + if (Utils::HostOsInfo::isMacHost()) { + // adapt the modifier names + text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd"), Qt::CaseInsensitive); + text.replace(QLatin1String("Alt"), QLatin1String("Opt"), Qt::CaseInsensitive); + text.replace(QLatin1String("Meta"), QLatin1String("Ctrl"), Qt::CaseInsensitive); + } + return text; +} - setId(Constants::SETTINGS_ID_SHORTCUTS); - setDisplayName(tr("Keyboard")); - setCategory(Constants::SETTINGS_CATEGORY_CORE); - setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE)); - setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CORE_ICON)); +static QKeySequence keySequenceFromEditString(const QString &editString) +{ + QString text = editString; + if (Utils::HostOsInfo::isMacHost()) { + // adapt the modifier names + text.replace(QLatin1String("Opt"), QLatin1String("Alt"), Qt::CaseInsensitive); + text.replace(QLatin1String("Ctrl"), QLatin1String("Meta"), Qt::CaseInsensitive); + text.replace(QLatin1String("Cmd"), QLatin1String("Ctrl"), Qt::CaseInsensitive); + } + return QKeySequence::fromString(text, QKeySequence::PortableText); } -QWidget *ShortcutSettings::widget() +static bool keySequenceIsValid(const QKeySequence &sequence) { - m_initialized = true; - m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0; + if (sequence.isEmpty()) + return false; + for (int i = 0; i < sequence.count(); ++i) { + if (sequence[i] == Qt::Key_unknown) + return false; + } + return true; +} - QWidget *w = CommandMappings::widget(); +namespace Core { +namespace Internal { - const QString pageTitle = tr("Keyboard Shortcuts"); - const QString targetLabelText = tr("Key sequence:"); - const QString editTitle = tr("Shortcut"); +ShortcutButton::ShortcutButton(QWidget *parent) + : QPushButton(parent) + , m_key({{ 0, 0, 0, 0 }}) +{ + setToolTip(tr("Click and type the new key sequence.")); + setCheckable(true); + m_checkedText = tr("Stop Recording"); + m_uncheckedText = tr("Record"); + updateText(); + connect(this, &ShortcutButton::toggled, this, &ShortcutButton::handleToggleChange); +} - setPageTitle(pageTitle); - setTargetLabelText(targetLabelText); - setTargetEditTitle(editTitle); - setTargetHeader(editTitle); - targetEdit()->setPlaceholderText(tr("Type to set shortcut")); +QSize ShortcutButton::sizeHint() const +{ + if (m_preferredWidth < 0) { // initialize size hint + const QString originalText = text(); + ShortcutButton *that = const_cast<ShortcutButton *>(this); + that->setText(m_checkedText); + m_preferredWidth = QPushButton::sizeHint().width(); + that->setText(m_uncheckedText); + int otherWidth = QPushButton::sizeHint().width(); + if (otherWidth > m_preferredWidth) + m_preferredWidth = otherWidth; + that->setText(originalText); + } + return QSize(m_preferredWidth, QPushButton::sizeHint().height()); +} - return w; +bool ShortcutButton::eventFilter(QObject *obj, QEvent *evt) +{ + if (evt->type() == QEvent::ShortcutOverride) { + evt->accept(); + return true; + } + if (evt->type() == QEvent::KeyRelease + || evt->type() == QEvent::Shortcut + || evt->type() == QEvent::Close/*Escape tries to close dialog*/) { + return true; + } + if (evt->type() == QEvent::MouseButtonPress && isChecked()) { + setChecked(false); + return true; + } + if (evt->type() == QEvent::KeyPress) { + QKeyEvent *k = static_cast<QKeyEvent*>(evt); + int nextKey = k->key(); + if (m_keyNum > 3 + || nextKey == Qt::Key_Control + || nextKey == Qt::Key_Shift + || nextKey == Qt::Key_Meta + || nextKey == Qt::Key_Alt) { + return false; + } + + nextKey |= translateModifiers(k->modifiers(), k->text()); + switch (m_keyNum) { + case 0: + m_key[0] = nextKey; + break; + case 1: + m_key[1] = nextKey; + break; + case 2: + m_key[2] = nextKey; + break; + case 3: + m_key[3] = nextKey; + break; + default: + break; + } + m_keyNum++; + k->accept(); + emit keySequenceChanged(QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3])); + if (m_keyNum > 3) + setChecked(false); + return true; + } + return QPushButton::eventFilter(obj, evt); } -void ShortcutSettings::apply() +void ShortcutButton::updateText() { - foreach (ShortcutItem *item, m_scitems) - item->m_cmd->setKeySequence(item->m_key); + setText(isChecked() ? m_checkedText : m_uncheckedText); } -void ShortcutSettings::finish() +void ShortcutButton::handleToggleChange(bool toogleState) { - qDeleteAll(m_scitems); - m_scitems.clear(); + updateText(); + m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0; + if (toogleState) { + if (qApp->focusWidget()) + qApp->focusWidget()->clearFocus(); // funny things happen otherwise + qApp->installEventFilter(this); + } else { + qApp->removeEventFilter(this); + } +} - CommandMappings::finish(); - m_initialized = false; +ShortcutSettingsWidget::ShortcutSettingsWidget(QWidget *parent) + : CommandMappings(parent) +{ + setPageTitle(tr("Keyboard Shortcuts")); + setTargetHeader(tr("Shortcut")); + + connect(ActionManager::instance(), &ActionManager::commandListChanged, + this, &ShortcutSettingsWidget::initialize); + connect(this, &ShortcutSettingsWidget::currentCommandChanged, + this, &ShortcutSettingsWidget::handleCurrentCommandChanged); + + m_shortcutBox = new QGroupBox(tr("Shortcut"), this); + m_shortcutBox->setEnabled(false); + auto vboxLayout = new QVBoxLayout(m_shortcutBox); + m_shortcutBox->setLayout(vboxLayout); + auto hboxLayout = new QHBoxLayout; + vboxLayout->addLayout(hboxLayout); + m_shortcutEdit = new Utils::FancyLineEdit(m_shortcutBox); + m_shortcutEdit->setFiltering(true); + m_shortcutEdit->setPlaceholderText(tr("Enter key sequence as text")); + m_shortcutEdit->setValidationFunction([this](Utils::FancyLineEdit *, QString *) { + return validateShortcutEdit(); + }); + auto shortcutLabel = new QLabel(tr("Key sequence:")); + shortcutLabel->setToolTip(Utils::HostOsInfo::isMacHost() + ? QLatin1String("<html><body>") + + tr("Use \"Cmd\", \"Opt\", \"Ctrl\", and \"Shift\" for modifier keys. " + "Use \"Escape\", \"Backspace\", \"Delete\", \"Insert\", \"Home\", and so on, for special keys. " + "Combine individual keys with \"+\", " + "and combine multiple shortcuts to a shortcut sequence with \",\". " + "For example, if the user must hold the Ctrl and Shift modifier keys " + "while pressing Escape, and then release and press A, " + "enter \"Ctrl+Shift+Escape,A\".") + + QLatin1String("</body></html>") + : QLatin1String("<html><body>") + + tr("Use \"Ctrl\", \"Alt\", \"Meta\", and \"Shift\" for modifier keys. " + "Use \"Escape\", \"Backspace\", \"Delete\", \"Insert\", \"Home\", and so on, for special keys. " + "Combine individual keys with \"+\", " + "and combine multiple shortcuts to a shortcut sequence with \",\". " + "For example, if the user must hold the Ctrl and Shift modifier keys " + "while pressing Escape, and then release and press A, " + "enter \"Ctrl+Shift+Escape,A\".") + + QLatin1String("</body></html>")); + auto shortcutButton = new ShortcutButton(m_shortcutBox); + connect(shortcutButton, &ShortcutButton::keySequenceChanged, + this, &ShortcutSettingsWidget::setKeySequence); + auto resetButton = new QPushButton(tr("Reset"), m_shortcutBox); + resetButton->setToolTip(tr("Reset to default.")); + connect(resetButton, &QPushButton::clicked, + this, &ShortcutSettingsWidget::resetToDefault); + hboxLayout->addWidget(shortcutLabel); + hboxLayout->addWidget(m_shortcutEdit); + hboxLayout->addWidget(shortcutButton); + hboxLayout->addWidget(resetButton); + + m_warningLabel = new QLabel(m_shortcutBox); + m_warningLabel->setTextFormat(Qt::RichText); + QPalette palette = m_warningLabel->palette(); + palette.setColor(QPalette::Active, QPalette::WindowText, + Utils::creatorTheme()->color(Utils::Theme::TextColorError)); + m_warningLabel->setPalette(palette); + connect(m_warningLabel, &QLabel::linkActivated, this, &ShortcutSettingsWidget::showConflicts); + vboxLayout->addWidget(m_warningLabel); + + layout()->addWidget(m_shortcutBox); + + initialize(); } -bool ShortcutSettings::eventFilter(QObject *o, QEvent *e) +ShortcutSettingsWidget::~ShortcutSettingsWidget() { - Q_UNUSED(o) + qDeleteAll(m_scitems); +} - if ( e->type() == QEvent::KeyPress ) { - QKeyEvent *k = static_cast<QKeyEvent*>(e); - handleKeyEvent(k); - return true; - } +ShortcutSettings::ShortcutSettings(QObject *parent) + : IOptionsPage(parent) +{ + setId(Constants::SETTINGS_ID_SHORTCUTS); + setDisplayName(tr("Keyboard")); + setCategory(Constants::SETTINGS_CATEGORY_CORE); + setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE)); + setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CORE_ICON)); +} - if ( e->type() == QEvent::Shortcut || - e->type() == QEvent::KeyRelease ) { - return true; - } +QWidget *ShortcutSettings::widget() +{ + if (!m_widget) + m_widget = new ShortcutSettingsWidget(); + return m_widget; +} - if (e->type() == QEvent::ShortcutOverride) { - // for shortcut overrides, we need to accept as well - e->accept(); - return true; - } +void ShortcutSettingsWidget::apply() +{ + foreach (ShortcutItem *item, m_scitems) + item->m_cmd->setKeySequence(item->m_key); +} - return false; +void ShortcutSettings::apply() +{ + QTC_ASSERT(m_widget, return); + m_widget->apply(); } -void ShortcutSettings::commandChanged(QTreeWidgetItem *current) +void ShortcutSettings::finish() { - CommandMappings::commandChanged(current); - if (!current || !current->data(0, Qt::UserRole).isValid()) - return; - ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole)); - setKeySequence(scitem->m_key); - markCollisions(scitem); + delete m_widget; } -void ShortcutSettings::targetIdentifierChanged() +void ShortcutSettingsWidget::handleCurrentCommandChanged(QTreeWidgetItem *current) { - QTreeWidgetItem *current = commandList()->currentItem(); - if (current && current->data(0, Qt::UserRole).isValid()) { + if (!current || !current->data(0, Qt::UserRole).isValid()) { + m_shortcutEdit->clear(); + m_warningLabel->clear(); + m_shortcutBox->setEnabled(false); + return; + } else { ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole)); - scitem->m_key = QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3]); - if (scitem->m_cmd->defaultKeySequence() != scitem->m_key) - setModified(current, true); - else - setModified(current, false); - current->setText(2, scitem->m_key.toString(QKeySequence::NativeText)); + setKeySequence(scitem->m_key); markCollisions(scitem); + m_shortcutBox->setEnabled(true); } } -bool ShortcutSettings::hasConflicts() const +bool ShortcutSettingsWidget::validateShortcutEdit() const { + m_warningLabel->clear(); QTreeWidgetItem *current = commandList()->currentItem(); if (!current || !current->data(0, Qt::UserRole).isValid()) - return false; + return true; ShortcutItem *item = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole)); - if (!item) - return false; + QTC_ASSERT(item, return true); - const QKeySequence currentKey = QKeySequence::fromString(targetEdit()->text(), QKeySequence::NativeText); - if (currentKey.isEmpty()) - return false; + bool valid = false; - const Id globalId(Constants::C_GLOBAL); - const Context itemContext = item->m_cmd->context(); + const QString text = m_shortcutEdit->text().trimmed(); + const QKeySequence currentKey = keySequenceFromEditString(text); - foreach (ShortcutItem *listItem, m_scitems) { - if (item == listItem) - continue; - if (listItem->m_key.isEmpty()) - continue; - if (listItem->m_key.matches(currentKey) == QKeySequence::NoMatch) - continue; + if (keySequenceIsValid(currentKey) || text.isEmpty()) { + item->m_key = currentKey; + auto that = const_cast<ShortcutSettingsWidget *>(this); + if (item->m_cmd->defaultKeySequence() != item->m_key) + that->setModified(current, true); + else + that->setModified(current, false); + current->setText(2, item->m_key.toString(QKeySequence::NativeText)); + valid = !that->markCollisions(item); + if (!valid) { + m_warningLabel->setText( + tr("Key sequence has potential conflicts. <a href=\"#conflicts\">Show.</a>")); + } + } else { + m_warningLabel->setText(tr("Invalid key sequence.")); + } + return valid; +} - const Context listContext = listItem->m_cmd->context(); - if (itemContext.contains(globalId) && !listContext.isEmpty()) - return true; - if (listContext.contains(globalId) && !itemContext.isEmpty()) +bool ShortcutSettingsWidget::filterColumn(const QString &filterString, QTreeWidgetItem *item, + int column) const +{ + QString text; + if (column == item->columnCount() - 1) { + // filter on the shortcut edit text + if (!item->data(0, Qt::UserRole).isValid()) return true; - foreach (Id id, listContext) - if (itemContext.contains(id)) - return true; + ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(item->data(0, Qt::UserRole)); + text = keySequenceToEditString(scitem->m_key); + } else { + text = item->text(column); } - return false; + return !text.contains(filterString, Qt::CaseInsensitive); } -void ShortcutSettings::setKeySequence(const QKeySequence &key) +void ShortcutSettingsWidget::setKeySequence(const QKeySequence &key) { - m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0; - m_keyNum = key.count(); - for (int i = 0; i < m_keyNum; ++i) { - m_key[i] = key[i]; + m_shortcutEdit->setText(keySequenceToEditString(key)); +} + +void ShortcutSettingsWidget::showConflicts() +{ + QTreeWidgetItem *current = commandList()->currentItem(); + if (current && current->data(0, Qt::UserRole).isValid()) { + ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole)); + setFilterText(keySequenceToEditString(scitem->m_key)); } - targetEdit()->setText(key.toString(QKeySequence::NativeText)); } -void ShortcutSettings::resetTargetIdentifier() +void ShortcutSettingsWidget::resetToDefault() { QTreeWidgetItem *current = commandList()->currentItem(); if (current && current->data(0, Qt::UserRole).isValid()) { @@ -206,18 +410,9 @@ void ShortcutSettings::resetTargetIdentifier() } } -void ShortcutSettings::removeTargetIdentifier() +void ShortcutSettingsWidget::importAction() { - m_keyNum = m_key[0] = m_key[1] = m_key[2] = m_key[3] = 0; - targetEdit()->clear(); - - foreach (ShortcutItem *item, m_scitems) - markCollisions(item); -} - -void ShortcutSettings::importAction() -{ - QString fileName = QFileDialog::getOpenFileName(widget(), tr("Import Keyboard Mapping Scheme"), + QString fileName = QFileDialog::getOpenFileName(ICore::dialogParent(), tr("Import Keyboard Mapping Scheme"), ICore::resourcePath() + QLatin1String("/schemes/"), tr("Keyboard Mapping Scheme (*.kms)")); if (!fileName.isEmpty()) { @@ -231,7 +426,7 @@ void ShortcutSettings::importAction() item->m_key = mapping.value(sid); item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText)); if (item->m_item == commandList()->currentItem()) - commandChanged(item->m_item); + currentCommandChanged(item->m_item); if (item->m_cmd->defaultKeySequence() != item->m_key) setModified(item->m_item, true); @@ -245,21 +440,21 @@ void ShortcutSettings::importAction() } } -void ShortcutSettings::defaultAction() +void ShortcutSettingsWidget::defaultAction() { foreach (ShortcutItem *item, m_scitems) { item->m_key = item->m_cmd->defaultKeySequence(); item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText)); setModified(item->m_item, false); if (item->m_item == commandList()->currentItem()) - commandChanged(item->m_item); + currentCommandChanged(item->m_item); } foreach (ShortcutItem *item, m_scitems) markCollisions(item); } -void ShortcutSettings::exportAction() +void ShortcutSettingsWidget::exportAction() { QString fileName = DocumentManager::getSaveFileNameWithExtension( tr("Export Keyboard Mapping Scheme"), @@ -271,7 +466,7 @@ void ShortcutSettings::exportAction() } } -void ShortcutSettings::clear() +void ShortcutSettingsWidget::clear() { QTreeWidget *tree = commandList(); for (int i = tree->topLevelItemCount()-1; i >= 0 ; --i) { @@ -281,10 +476,8 @@ void ShortcutSettings::clear() m_scitems.clear(); } -void ShortcutSettings::initialize() +void ShortcutSettingsWidget::initialize() { - if (!m_initialized) - return; clear(); QMap<QString, QTreeWidgetItem *> sections; @@ -329,86 +522,39 @@ void ShortcutSettings::initialize() filterChanged(filterText()); } -void ShortcutSettings::handleKeyEvent(QKeyEvent *e) -{ - int nextKey = e->key(); - if ( m_keyNum > 3 || - nextKey == Qt::Key_Control || - nextKey == Qt::Key_Shift || - nextKey == Qt::Key_Meta || - nextKey == Qt::Key_Alt ) - return; - - nextKey |= translateModifiers(e->modifiers(), e->text()); - switch (m_keyNum) { - case 0: - m_key[0] = nextKey; - break; - case 1: - m_key[1] = nextKey; - break; - case 2: - m_key[2] = nextKey; - break; - case 3: - m_key[3] = nextKey; - break; - default: - break; - } - m_keyNum++; - QKeySequence ks(m_key[0], m_key[1], m_key[2], m_key[3]); - targetEdit()->setText(ks.toString(QKeySequence::NativeText)); - e->accept(); -} - -int ShortcutSettings::translateModifiers(Qt::KeyboardModifiers state, - const QString &text) -{ - int result = 0; - // The shift modifier only counts when it is not used to type a symbol - // that is only reachable using the shift key anyway - if ((state & Qt::ShiftModifier) && (text.size() == 0 - || !text.at(0).isPrint() - || text.at(0).isLetterOrNumber() - || text.at(0).isSpace())) - result |= Qt::SHIFT; - if (state & Qt::ControlModifier) - result |= Qt::CTRL; - if (state & Qt::MetaModifier) - result |= Qt::META; - if (state & Qt::AltModifier) - result |= Qt::ALT; - return result; -} - -void ShortcutSettings::markCollisions(ShortcutItem *item) +bool ShortcutSettingsWidget::markCollisions(ShortcutItem *item) { bool hasCollision = false; if (!item->m_key.isEmpty()) { - Id globalId = Context(Constants::C_GLOBAL).at(0); + Id globalId(Constants::C_GLOBAL); const Context itemContext = item->m_cmd->context(); - + const bool itemHasGlobalContext = itemContext.contains(globalId); foreach (ShortcutItem *currentItem, m_scitems) { - if (currentItem->m_key.isEmpty() || item == currentItem || item->m_key != currentItem->m_key) continue; - - foreach (Id id, currentItem->m_cmd->context()) { - // conflict if context is identical, OR if one - // of the contexts is the global context - const Context thisContext = currentItem->m_cmd->context(); - if (itemContext.contains(id) - || (itemContext.contains(globalId) && !thisContext.isEmpty()) - || (thisContext.contains(globalId) && !itemContext.isEmpty())) { - currentItem->m_item->setForeground(2, Qt::red); - hasCollision = true; + const Context currentContext = currentItem->m_cmd->context(); + bool currentIsConflicting = (itemHasGlobalContext && !currentContext.isEmpty()); + if (!currentIsConflicting) { + foreach (const Id &id, currentContext) { + if ((id == globalId && !itemContext.isEmpty()) + || itemContext.contains(id)) { + currentIsConflicting = true; + break; + } } } + if (currentIsConflicting) { + currentItem->m_item->setForeground( + 2, Utils::creatorTheme()->color(Utils::Theme::TextColorError)); + hasCollision = true; + } } } - item->m_item->setForeground(2, hasCollision ? Qt::red : commandList()->palette().foreground()); + item->m_item->setForeground(2, hasCollision + ? Utils::creatorTheme()->color(Utils::Theme::TextColorError) + : commandList()->palette().foreground()); + return hasCollision; } } // namespace Internal diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.h b/src/plugins/coreplugin/dialogs/shortcutsettings.h index 405aceafb4a..0b35836f5a0 100644 --- a/src/plugins/coreplugin/dialogs/shortcutsettings.h +++ b/src/plugins/coreplugin/dialogs/shortcutsettings.h @@ -32,11 +32,18 @@ #define SHORTCUTSETTINGS_H #include <coreplugin/actionmanager/commandmappings.h> +#include <coreplugin/dialogs/ioptionspage.h> #include <QKeySequence> +#include <QPointer> +#include <QPushButton> + +#include <array> QT_BEGIN_NAMESPACE +class QGroupBox; class QKeyEvent; +class QLabel; QT_END_NAMESPACE namespace Core { @@ -55,45 +62,76 @@ struct ShortcutItem QTreeWidgetItem *m_item; }; +class ShortcutButton : public QPushButton +{ + Q_OBJECT +public: + ShortcutButton(QWidget *parent = 0); + + QSize sizeHint() const; + +signals: + void keySequenceChanged(const QKeySequence &sequence); -class ShortcutSettings : public CommandMappings +protected: + bool eventFilter(QObject *obj, QEvent *evt); + +private: + void updateText(); + void handleToggleChange(bool toggleState); + + QString m_checkedText; + QString m_uncheckedText; + mutable int m_preferredWidth = -1; + std::array<int, 4> m_key; + int m_keyNum = 0; +}; + +class ShortcutSettingsWidget : public CommandMappings { Q_OBJECT public: - ShortcutSettings(QObject *parent = 0); + ShortcutSettingsWidget(QWidget *parent = 0); + ~ShortcutSettingsWidget() override; - QWidget *widget(); void apply(); - void finish(); protected: - bool eventFilter(QObject *o, QEvent *e); - -private slots: - void commandChanged(QTreeWidgetItem *current); - void targetIdentifierChanged(); - void resetTargetIdentifier(); - void removeTargetIdentifier(); - void importAction(); - void exportAction(); - void defaultAction(); - void initialize(); + void importAction() override; + void exportAction() override; + void defaultAction() override; + bool filterColumn(const QString &filterString, QTreeWidgetItem *item, int column) const override; private: + void initialize(); + void handleCurrentCommandChanged(QTreeWidgetItem *current); + void resetToDefault(); + bool validateShortcutEdit() const; + bool markCollisions(ShortcutItem *); void setKeySequence(const QKeySequence &key); + void showConflicts(); void clear(); - void handleKeyEvent(QKeyEvent *e); - int translateModifiers(Qt::KeyboardModifiers state, const QString &text); + QList<ShortcutItem *> m_scitems; + QGroupBox *m_shortcutBox; + Utils::FancyLineEdit *m_shortcutEdit; + QLabel *m_warningLabel; +}; - void markCollisions(ShortcutItem *); - bool hasConflicts() const; +class ShortcutSettings : public IOptionsPage +{ + Q_OBJECT - QList<ShortcutItem *> m_scitems; - int m_key[4], m_keyNum; +public: + ShortcutSettings(QObject *parent = 0); - bool m_initialized; + QWidget *widget() override; + void apply() override; + void finish() override; + +private: + QPointer<ShortcutSettingsWidget> m_widget; }; } // namespace Internal diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 076aac930f1..e2c0e1b9bbc 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -72,6 +72,7 @@ #include <utils/mimetypes/mimedatabase.h> #include <utils/mimetypes/mimetype.h> #include <utils/qtcassert.h> +#include <utils/overridecursor.h> #include <QClipboard> #include <QDateTime> @@ -91,6 +92,8 @@ #include <QPushButton> #include <QSplitter> +#include <algorithm> + using namespace Utils; enum { debugEditorManager=0 }; @@ -174,7 +177,7 @@ void EditorManagerPlaceHolder::currentModeChanged(IMode *mode) static EditorManager *m_instance = 0; static EditorManagerPrivate *d; -static int extractLineNumber(QString *fileName) +static int extractNumericSuffix(QString *fileName) { int i = fileName->length() - 1; for (; i >= 0; --i) { @@ -196,6 +199,22 @@ static int extractLineNumber(QString *fileName) return -1; } +static void extractLineAndColumnNumbers(QString *fileName, int *lineNumber, int *columnNumber) +{ + *lineNumber = -1; + *columnNumber = -1; + int lastSuffix = extractNumericSuffix(fileName); + if (lastSuffix == -1) + return; + int secondToLastSuffix = extractNumericSuffix(fileName); + if (secondToLastSuffix == -1) { + *lineNumber = lastSuffix; + return; + } + *lineNumber = secondToLastSuffix; + *columnNumber = lastSuffix - 1; //column is 0 based, despite line being 1 based +} + static QString autoSaveName(const QString &fileName) { return fileName + QLatin1String(".autosave"); @@ -534,8 +553,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN QString fn = fileName; QFileInfo fi(fn); int lineNumber = -1; - if ((flags & EditorManager::CanContainLineNumber) && !fi.exists()) { - lineNumber = extractLineNumber(&fn); + int columnNumber = -1; + if ((flags & EditorManager::CanContainLineAndColumnNumber) && !fi.exists()) { + extractLineAndColumnNumbers(&fn, &lineNumber, &columnNumber); if (lineNumber != -1) fi.setFile(fn); } @@ -550,8 +570,8 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN if (!editors.isEmpty()) { IEditor *editor = editors.first(); editor = activateEditor(view, editor, flags); - if (editor && flags & EditorManager::CanContainLineNumber) - editor->gotoLine(lineNumber, -1); + if (editor && flags & EditorManager::CanContainLineAndColumnNumber) + editor->gotoLine(lineNumber, columnNumber); return editor; } @@ -562,20 +582,80 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN realFn = fn; } - IEditor *editor = createEditor(editorId, fn); - // If we could not open the file in the requested editor, fall - // back to the default editor: - if (!editor) - editor = createEditor(Id(), fn); - QTC_ASSERT(editor, return 0); - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - QString errorString; - if (!editor->open(&errorString, fn, realFn)) { - QApplication::restoreOverrideCursor(); - QMessageBox::critical(ICore::mainWindow(), EditorManager::tr("File Error"), errorString); - delete editor; + EditorManager::EditorFactoryList factories = EditorManagerPrivate::findFactories(Id(), fn); + if (factories.isEmpty()) { + Utils::MimeDatabase mdb; + Utils::MimeType mimeType = mdb.mimeTypeForFile(fn); + QMessageBox msgbox(QMessageBox::Critical, EditorManager::tr("File Error"), + tr("Could not open \"%1\": Cannot open files of type \"%2\".") + .arg(FileName::fromString(realFn).toUserOutput()).arg(mimeType.name()), + QMessageBox::Ok, ICore::dialogParent()); + msgbox.exec(); return 0; } + if (editorId.isValid()) { + if (IEditorFactory *factory = findById<IEditorFactory>(editorId)) { + factories.removeOne(factory); + factories.push_front(factory); + } + } + + IEditor *editor = 0; + auto overrideCursor = Utils::OverrideCursor(QCursor(Qt::WaitCursor)); + + IEditorFactory *factory = factories.takeFirst(); + while (factory) { + editor = createEditor(factory, fn); + if (!editor) { + factory = factories.takeFirst(); + continue; + } + + QString errorString; + if (editor->open(&errorString, fn, realFn)) + break; + + overrideCursor.reset(); + delete editor; + + if (errorString.isEmpty()) { + errorString = tr("Could not open \"%1\": Unknown error.") + .arg(FileName::fromString(realFn).toUserOutput()); + } + + QMessageBox msgbox(QMessageBox::Critical, EditorManager::tr("File Error"), errorString, QMessageBox::Open | QMessageBox::Cancel, ICore::mainWindow()); + + IEditorFactory *selectedFactory = 0; + if (!factories.isEmpty()) { + QPushButton *button = qobject_cast<QPushButton *>(msgbox.button(QMessageBox::Open)); + QTC_ASSERT(button, return 0); + QMenu *menu = new QMenu(button); + foreach (IEditorFactory *factory, factories) { + QAction *action = menu->addAction(factory->displayName()); + connect(action, &QAction::triggered, [&selectedFactory, factory, &msgbox]() { + selectedFactory = factory; + msgbox.done(QMessageBox::Open); + }); + } + + button->setMenu(menu); + } else { + msgbox.setStandardButtons(QMessageBox::Ok); + } + + int ret = msgbox.exec(); + if (ret == QMessageBox::Cancel || ret == QMessageBox::Ok) + return 0; + + overrideCursor.set(); + + factories.removeOne(selectedFactory); + factory = selectedFactory; + } + + if (!editor) + return 0; + if (realFn != fn) editor->document()->setRestoredFrom(realFn); addEditor(editor); @@ -587,10 +667,9 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN if (editor == result) restoreEditorState(editor); - if (flags & EditorManager::CanContainLineNumber) - editor->gotoLine(lineNumber, -1); + if (flags & EditorManager::CanContainLineAndColumnNumber) + editor->gotoLine(lineNumber, columnNumber); - QApplication::restoreOverrideCursor(); return result; } @@ -886,7 +965,7 @@ int EditorManagerPrivate::autoSaveInterval() return d->m_autoSaveInterval; } -IEditor *EditorManagerPrivate::createEditor(Id editorId, const QString &fileName) +EditorManager::EditorFactoryList EditorManagerPrivate::findFactories(Id editorId, const QString &fileName) { if (debugEditorManager) qDebug() << Q_FUNC_INFO << editorId.name() << fileName; @@ -907,7 +986,7 @@ IEditor *EditorManagerPrivate::createEditor(Id editorId, const QString &fileName && mimeType.name().startsWith(QLatin1String("text"))) { mimeType = mdb.mimeTypeForName(QLatin1String("application/octet-stream")); } - factories = EditorManager::editorFactories(mimeType, true); + factories = EditorManager::editorFactories(mimeType, false); } else { // Find by editor id if (IEditorFactory *factory = findById<IEditorFactory>(editorId)) @@ -916,10 +995,17 @@ IEditor *EditorManagerPrivate::createEditor(Id editorId, const QString &fileName if (factories.empty()) { qWarning("%s: unable to find an editor factory for the file '%s', editor Id '%s'.", Q_FUNC_INFO, fileName.toUtf8().constData(), editorId.name().constData()); - return 0; } - IEditor *editor = factories.front()->createEditor(); + return factories; +} + +IEditor *EditorManagerPrivate::createEditor(IEditorFactory *factory, const QString &fileName) +{ + if (!factory) + return 0; + + IEditor *editor = factory->createEditor(); if (editor) { QTC_CHECK(editor->document()->id().isValid()); // sanity check that the editor has an id set connect(editor->document(), SIGNAL(changed()), d, SLOT(handleDocumentStateChange())); @@ -2401,10 +2487,13 @@ IEditor *EditorManager::openEditorWithContents(Id editorId, } } - edt = EditorManagerPrivate::createEditor(editorId, title); - if (!edt) + EditorFactoryList factories = EditorManagerPrivate::findFactories(editorId, title); + if (factories.isEmpty()) return 0; + edt = EditorManagerPrivate::createEditor(factories.first(), title); + if (!edt) + return 0; if (!edt->document()->setContents(contents)) { delete edt; edt = 0; diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h index dc945802504..6d0f208f443 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.h +++ b/src/plugins/coreplugin/editormanager/editormanager.h @@ -102,7 +102,7 @@ public: DoNotChangeCurrentEditor = 1, IgnoreNavigationHistory = 2, DoNotMakeVisible = 4, - CanContainLineNumber = 8, + CanContainLineAndColumnNumber = 8, OpenInOtherSplit = 16, DoNotSwitchToDesignMode = 32 }; diff --git a/src/plugins/coreplugin/editormanager/editormanager_p.h b/src/plugins/coreplugin/editormanager/editormanager_p.h index a6411645320..28872f3a022 100644 --- a/src/plugins/coreplugin/editormanager/editormanager_p.h +++ b/src/plugins/coreplugin/editormanager/editormanager_p.h @@ -174,7 +174,8 @@ private: static OpenEditorsWindow *windowPopup(); static void showPopupOrSelectDocument(); - static IEditor *createEditor(Id editorId = Id(), const QString &fileName = QString()); + static EditorManager::EditorFactoryList findFactories(Id editorId, const QString &fileName); + static IEditor *createEditor(IEditorFactory *factory, const QString &fileName); static void addEditor(IEditor *editor); static void removeEditor(IEditor *editor); static IEditor *placeEditor(EditorView *view, IEditor *editor); diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp index 34cbd4cafca..2178644e240 100644 --- a/src/plugins/coreplugin/editormanager/editorview.cpp +++ b/src/plugins/coreplugin/editormanager/editorview.cpp @@ -48,6 +48,7 @@ #include <QDebug> +#include <QFileInfo> #include <QHBoxLayout> #include <QLabel> #include <QMenu> @@ -517,6 +518,13 @@ void EditorView::updateCurrentPositionInNavigationHistory() location->state = QVariant(editor->saveState()); } +namespace { +static inline bool fileNameWasRemoved(const QString &fileName) +{ + return !fileName.isEmpty() && !QFileInfo(fileName).exists(); +} +} // End of anonymous namespace + void EditorView::goBackInNavigationHistory() { updateCurrentPositionInNavigationHistory(); @@ -529,6 +537,10 @@ void EditorView::goBackInNavigationHistory() EditorManager::IgnoreNavigationHistory); } if (!editor) { + if (fileNameWasRemoved(location.fileName)) { + m_navigationHistory.removeAt(m_currentNavigationHistoryPosition); + continue; + } editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id, EditorManager::IgnoreNavigationHistory); if (!editor) { @@ -548,22 +560,30 @@ void EditorView::goForwardInNavigationHistory() if (m_currentNavigationHistoryPosition >= m_navigationHistory.size()-1) return; ++m_currentNavigationHistoryPosition; - EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition); - IEditor *editor = 0; - if (location.document) { - editor = EditorManagerPrivate::activateEditorForDocument(this, location.document, - EditorManager::IgnoreNavigationHistory); - } - if (!editor) { - editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id, - EditorManager::IgnoreNavigationHistory); + while (m_currentNavigationHistoryPosition < m_navigationHistory.size()) { + IEditor *editor = 0; + EditLocation location = m_navigationHistory.at(m_currentNavigationHistoryPosition); + if (location.document) { + editor = EditorManagerPrivate::activateEditorForDocument(this, location.document, + EditorManager::IgnoreNavigationHistory); + } if (!editor) { - //TODO - qDebug() << Q_FUNC_INFO << "can't open file" << location.fileName; - return; + if (fileNameWasRemoved(location.fileName)) { + m_navigationHistory.removeAt(m_currentNavigationHistoryPosition); + continue; + } + editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id, + EditorManager::IgnoreNavigationHistory); + if (!editor) { + m_navigationHistory.removeAt(m_currentNavigationHistoryPosition); + continue; + } } + editor->restoreState(location.state.toByteArray()); + break; } - editor->restoreState(location.state.toByteArray()); + if (m_currentNavigationHistoryPosition >= m_navigationHistory.size()) + m_currentNavigationHistoryPosition = qMax<int>(m_navigationHistory.size() - 1, 0); updateNavigatorActions(); } diff --git a/src/plugins/coreplugin/find/findtoolbar.cpp b/src/plugins/coreplugin/find/findtoolbar.cpp index 45089651be3..2256d26e8bd 100644 --- a/src/plugins/coreplugin/find/findtoolbar.cpp +++ b/src/plugins/coreplugin/find/findtoolbar.cpp @@ -473,8 +473,12 @@ void FindToolBar::invokeFindNext() void FindToolBar::invokeGlobalFindNext() { - acceptCandidateAndMoveToolBar(); - invokeFindNext(); + if (getFindText().isEmpty()) { + openFind(); + } else { + acceptCandidateAndMoveToolBar(); + invokeFindNext(); + } } void FindToolBar::invokeFindPrevious() @@ -485,8 +489,12 @@ void FindToolBar::invokeFindPrevious() void FindToolBar::invokeGlobalFindPrevious() { - acceptCandidateAndMoveToolBar(); - invokeFindPrevious(); + if (getFindText().isEmpty()) { + openFind(); + } else { + acceptCandidateAndMoveToolBar(); + invokeFindPrevious(); + } } QString FindToolBar::getFindText() diff --git a/src/plugins/coreplugin/find/images/empty.png b/src/plugins/coreplugin/find/images/empty.png Binary files differdeleted file mode 100644 index f02154247c2..00000000000 --- a/src/plugins/coreplugin/find/images/empty.png +++ /dev/null diff --git a/src/plugins/coreplugin/find/images/replace_all.png b/src/plugins/coreplugin/find/images/replace_all.png Binary files differdeleted file mode 100644 index d2298a8aade..00000000000 --- a/src/plugins/coreplugin/find/images/replace_all.png +++ /dev/null diff --git a/src/plugins/coreplugin/find/images/wordandcase.png b/src/plugins/coreplugin/find/images/wordandcase.png Binary files differdeleted file mode 100644 index 34c0ac31908..00000000000 --- a/src/plugins/coreplugin/find/images/wordandcase.png +++ /dev/null diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index dce4a74a21f..3550d827bdd 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -533,11 +533,6 @@ void ICore::openFiles(const QStringList &arguments, ICore::OpenFilesFlags flags) m_mainwindow->openFiles(arguments, flags); } -void ICore::emitNewItemsDialogRequested() -{ - emit m_instance->newItemsDialogRequested(); -} - void ICore::saveSettings() { emit m_instance->saveSettingsRequested(); diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h index 1391701cdc4..61df88c61b2 100644 --- a/src/plugins/coreplugin/icore.h +++ b/src/plugins/coreplugin/icore.h @@ -117,21 +117,18 @@ public: enum OpenFilesFlags { None = 0, SwitchMode = 1, - CanContainLineNumbers = 2, + CanContainLineAndColumnNumbers = 2, /// Stop loading once the first file fails to load StopOnLoadFail = 4 }; static void openFiles(const QStringList &fileNames, OpenFilesFlags flags = None); - static void emitNewItemsDialogRequested(); - public slots: static void saveSettings(); signals: void coreAboutToOpen(); void coreOpened(); - void newItemsDialogRequested(); void newItemDialogRunningChanged(); void saveSettingsRequested(); void optionsDialogRequested(); diff --git a/src/plugins/projectexplorer/images/Desktop.png b/src/plugins/coreplugin/images/Desktop.png Binary files differindex 93a092ab13d..93a092ab13d 100644 --- a/src/plugins/projectexplorer/images/Desktop.png +++ b/src/plugins/coreplugin/images/Desktop.png diff --git a/src/plugins/coreplugin/images/lightarrowdown.png b/src/plugins/coreplugin/images/lightarrowdown.png Binary files differnew file mode 100644 index 00000000000..ccb04c2fdc5 --- /dev/null +++ b/src/plugins/coreplugin/images/lightarrowdown.png diff --git a/src/plugins/coreplugin/images/lightarrowdown@2x.png b/src/plugins/coreplugin/images/lightarrowdown@2x.png Binary files differnew file mode 100644 index 00000000000..171e0a64a49 --- /dev/null +++ b/src/plugins/coreplugin/images/lightarrowdown@2x.png diff --git a/src/plugins/coreplugin/images/lightarrowup.png b/src/plugins/coreplugin/images/lightarrowup.png Binary files differnew file mode 100644 index 00000000000..ba7a70ed265 --- /dev/null +++ b/src/plugins/coreplugin/images/lightarrowup.png diff --git a/src/plugins/coreplugin/images/lightarrowup@2x.png b/src/plugins/coreplugin/images/lightarrowup@2x.png Binary files differnew file mode 100644 index 00000000000..b2561589c4d --- /dev/null +++ b/src/plugins/coreplugin/images/lightarrowup@2x.png diff --git a/src/plugins/coreplugin/images/lightclose.png b/src/plugins/coreplugin/images/lightclose.png Binary files differnew file mode 100644 index 00000000000..1c507592c6b --- /dev/null +++ b/src/plugins/coreplugin/images/lightclose.png diff --git a/src/plugins/coreplugin/images/lightclose@2x.png b/src/plugins/coreplugin/images/lightclose@2x.png Binary files differnew file mode 100644 index 00000000000..f95b569a784 --- /dev/null +++ b/src/plugins/coreplugin/images/lightclose@2x.png diff --git a/src/plugins/coreplugin/infobar.cpp b/src/plugins/coreplugin/infobar.cpp index eb982a3a7db..1b4fdc9c58b 100644 --- a/src/plugins/coreplugin/infobar.cpp +++ b/src/plugins/coreplugin/infobar.cpp @@ -177,8 +177,8 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar) m_infoBar->disconnect(this); m_infoBar = infoBar; if (m_infoBar) { - connect(infoBar, SIGNAL(changed()), SLOT(update())); - connect(infoBar, SIGNAL(destroyed()), SLOT(infoBarDestroyed())); + connect(m_infoBar, SIGNAL(changed()), SLOT(update())); + connect(m_infoBar, SIGNAL(destroyed()), SLOT(infoBarDestroyed())); } update(); } diff --git a/src/plugins/coreplugin/iversioncontrol.cpp b/src/plugins/coreplugin/iversioncontrol.cpp index f9cbf4a90d1..d7af51eabbd 100644 --- a/src/plugins/coreplugin/iversioncontrol.cpp +++ b/src/plugins/coreplugin/iversioncontrol.cpp @@ -83,6 +83,18 @@ QStringList IVersionControl::additionalToolsPath() const return QStringList(); } +ShellCommand *IVersionControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + Q_UNUSED(url); + Q_UNUSED(baseDirectory); + Q_UNUSED(localName); + Q_UNUSED(extraArgs); + return 0; +} + QString IVersionControl::vcsTopic(const QString &topLevel) { return m_topicCache ? m_topicCache->topic(topLevel) : QString(); diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h index d47619777e6..04c733cefd1 100644 --- a/src/plugins/coreplugin/iversioncontrol.h +++ b/src/plugins/coreplugin/iversioncontrol.h @@ -34,6 +34,8 @@ #include "core_global.h" #include "id.h" +#include <utils/fileutils.h> + #include <QDateTime> #include <QFlags> #include <QHash> @@ -42,6 +44,8 @@ namespace Core { +class ShellCommand; + class CORE_EXPORT IVersionControl : public QObject { Q_OBJECT @@ -56,7 +60,8 @@ public: AddOperation, DeleteOperation, MoveOperation, CreateRepositoryOperation, SnapshotOperations, - AnnotateOperation + AnnotateOperation, + InitialCheckoutOperation }; enum OpenSupportMode { @@ -194,6 +199,17 @@ public: */ virtual QStringList additionalToolsPath() const; + /*! + * Return a ShellCommand capable of checking out \a url into \a baseDirectory, where + * a new subdirectory with \a localName will be created. + * + * \a extraArgs are passed on to the command being run. + */ + virtual ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs); + signals: void repositoryChanged(const QString &repository); void filesChanged(const QStringList &files); @@ -229,18 +245,18 @@ public: int fileCount() const { return m_fileCount; } // IVersionControl interface - QString displayName() const { return m_displayName; } - Id id() const { return m_id; } - bool managesDirectory(const QString &filename, QString *topLevel) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; - bool isConfigured() const { return true; } - bool supportsOperation(Operation) const { return false; } - bool vcsOpen(const QString &) { return false; } - bool vcsAdd(const QString &) { return false; } - bool vcsDelete(const QString &) { return false; } - bool vcsMove(const QString &, const QString &) { return false; } - bool vcsCreateRepository(const QString &) { return false; } - bool vcsAnnotate(const QString &, int) { return false; } + QString displayName() const override { return m_displayName; } + Id id() const override { return m_id; } + bool managesDirectory(const QString &filename, QString *topLevel) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; + bool isConfigured() const override { return true; } + bool supportsOperation(Operation) const override { return false; } + bool vcsOpen(const QString &) override { return false; } + bool vcsAdd(const QString &) override { return false; } + bool vcsDelete(const QString &) override { return false; } + bool vcsMove(const QString &, const QString &) override { return false; } + bool vcsCreateRepository(const QString &) override { return false; } + bool vcsAnnotate(const QString &, int) override { return false; } private: Id m_id; diff --git a/src/plugins/coreplugin/iwizardfactory.cpp b/src/plugins/coreplugin/iwizardfactory.cpp index 4262b4abc53..0feac766a19 100644 --- a/src/plugins/coreplugin/iwizardfactory.cpp +++ b/src/plugins/coreplugin/iwizardfactory.cpp @@ -147,16 +147,18 @@ using namespace Core; + namespace { static QList<IFeatureProvider *> s_providerList; +QList<IWizardFactory *> s_allFactories; +QList<IWizardFactory::FactoryCreator> s_factoryCreators; +bool s_areFactoriesLoaded = false; } /* A utility to find all wizards supporting a view mode and matching a predicate */ template <class Predicate> QList<IWizardFactory*> findWizardFactories(Predicate predicate) { - // Hack: Trigger delayed creation of wizards - ICore::emitNewItemsDialogRequested(); // Filter all wizards const QList<IWizardFactory*> allFactories = IWizardFactory::allWizardFactories(); QList<IWizardFactory*> rc; @@ -169,9 +171,33 @@ template <class Predicate> QList<IWizardFactory*> IWizardFactory::allWizardFactories() { - // Hack: Trigger delayed creation of wizards - ICore::emitNewItemsDialogRequested(); - return ExtensionSystem::PluginManager::getObjects<IWizardFactory>(); + if (!s_areFactoriesLoaded) { + QTC_ASSERT(s_allFactories.isEmpty(), return s_allFactories); + + s_areFactoriesLoaded = true; + + QHash<Id, IWizardFactory *> sanityCheck; + foreach (const FactoryCreator &fc, s_factoryCreators) { + QList<IWizardFactory *> tmp = fc(); + foreach (IWizardFactory *newFactory, tmp) { + QTC_ASSERT(newFactory, continue); + IWizardFactory *existingFactory = sanityCheck.value(newFactory->id()); + + QTC_ASSERT(existingFactory != newFactory, continue); + if (existingFactory) { + qWarning("%s", qPrintable(tr("Factory with id=\"%1\" already registered. Deleting.") + .arg(existingFactory->id().toString()))); + delete newFactory; + continue; + } + + sanityCheck.insert(newFactory->id(), newFactory); + s_allFactories << newFactory; + } + } + } + + return s_allFactories; } // Utility to find all registered wizards of a certain kind @@ -211,6 +237,11 @@ QStringList IWizardFactory::supportedPlatforms() const return stringList; } +void IWizardFactory::registerFactoryCreator(const IWizardFactory::FactoryCreator &creator) +{ + s_factoryCreators << creator; +} + QStringList IWizardFactory::allAvailablePlatforms() { QStringList platforms; @@ -257,3 +288,9 @@ FeatureSet IWizardFactory::pluginFeatures() const } return plugins; } + +void IWizardFactory::initialize() +{ + connect(ICore::instance(), &ICore::coreAboutToClose, + ICore::instance(), []() { qDeleteAll(s_allFactories); s_allFactories.clear(); }); +} diff --git a/src/plugins/coreplugin/iwizardfactory.h b/src/plugins/coreplugin/iwizardfactory.h index e18714e2cf9..0d52a0e54a3 100644 --- a/src/plugins/coreplugin/iwizardfactory.h +++ b/src/plugins/coreplugin/iwizardfactory.h @@ -38,6 +38,8 @@ #include <QObject> #include <QString> +#include <functional> + namespace Core { namespace Internal { class CorePlugin; } @@ -49,10 +51,8 @@ class CORE_EXPORT IWizardFactory public: enum WizardKind { FileWizard = 0x01, - ClassWizard = 0x02, - ProjectWizard = 0x04 + ProjectWizard = 0x02 }; - Q_DECLARE_FLAGS(WizardKinds, WizardKind) enum WizardFlag { PlatformIndependent = 0x01, ForceCapitalLetterForFileName = 0x02 @@ -61,7 +61,7 @@ public: IWizardFactory() : m_kind(FileWizard) { } - QString id() const { return m_id; } + Id id() const { return m_id; } WizardKind kind() const { return m_kind; } QIcon icon() const { return m_icon; } QString description() const { return m_description; } @@ -72,7 +72,7 @@ public: FeatureSet requiredFeatures() const { return m_requiredFeatures; } WizardFlags flags() const { return m_flags; } - void setId(const QString &id) { m_id = id; } + void setId(const Id id) { m_id = id; } void setWizardKind(WizardKind kind) { m_kind = kind; } void setIcon(const QIcon &icon) { m_icon = icon; } void setDescription(const QString &description) { m_description = description; } @@ -89,6 +89,9 @@ public: bool isAvailable(const QString &platformName) const; QStringList supportedPlatforms() const; + typedef std::function<QList<IWizardFactory *>()> FactoryCreator; + static void registerFactoryCreator(const FactoryCreator &creator); + // Utility to find all registered wizards static QList<IWizardFactory*> allWizardFactories(); // Utility to find all registered wizards of a certain kind @@ -102,13 +105,14 @@ protected: FeatureSet pluginFeatures() const; private: + static void initialize(); static void destroyFeatureProvider(); IWizardFactory::WizardKind m_kind; QIcon m_icon; QString m_description; QString m_displayName; - QString m_id; + Id m_id; QString m_category; QString m_displayCategory; FeatureSet m_requiredFeatures; @@ -120,7 +124,6 @@ private: } // namespace Core -Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardKinds) Q_DECLARE_OPERATORS_FOR_FLAGS(Core::IWizardFactory::WizardFlags) #endif // IWIZARDFACTORY_H diff --git a/src/plugins/coreplugin/jsexpander.cpp b/src/plugins/coreplugin/jsexpander.cpp index a1d733df772..10db6a8c8b7 100644 --- a/src/plugins/coreplugin/jsexpander.cpp +++ b/src/plugins/coreplugin/jsexpander.cpp @@ -37,7 +37,7 @@ #include <QCoreApplication> #include <QDebug> -#include <QScriptEngine> +#include <QJSEngine> namespace Core { @@ -45,10 +45,7 @@ namespace Internal { class JsExpanderPrivate { public: - ~JsExpanderPrivate() { qDeleteAll(m_registeredObjects); } - - QScriptEngine m_engine; - QList<QObject *> m_registeredObjects; + QJSEngine m_engine; }; } // namespace Internal @@ -57,26 +54,23 @@ static Internal::JsExpanderPrivate *d; void JsExpander::registerQObjectForJs(const QString &name, QObject *obj) { - obj->setParent(0); // take ownership! - d->m_registeredObjects.append(obj); - QScriptValue jsObj = d->m_engine.newQObject(obj, QScriptEngine::QtOwnership); + QJSValue jsObj = d->m_engine.newQObject(obj); d->m_engine.globalObject().setProperty(name, jsObj); } QString JsExpander::evaluate(const QString &expression, QString *errorMessage) { - d->m_engine.clearExceptions(); - QScriptValue value = d->m_engine.evaluate(expression); - if (d->m_engine.hasUncaughtException()) { + QJSValue value = d->m_engine.evaluate(expression); + if (value.isError()) { const QString msg = QCoreApplication::translate("Core::JsExpander", "Error in \"%1\": %2") - .arg(expression, d->m_engine.uncaughtException().toString()); + .arg(expression, value.toString()); if (errorMessage) *errorMessage = msg; return QString(); } // Try to convert to bool, be that an int or whatever. if (value.isBool()) - return value.toBool() ? QStringLiteral("true") : QStringLiteral("false"); + return value.toString(); if (value.isNumber()) return QString::number(value.toNumber()); if (value.isString()) diff --git a/src/plugins/coreplugin/locator/basefilefilter.cpp b/src/plugins/coreplugin/locator/basefilefilter.cpp index 30ff691ea0d..8f28191433b 100644 --- a/src/plugins/coreplugin/locator/basefilefilter.cpp +++ b/src/plugins/coreplugin/locator/basefilefilter.cpp @@ -169,7 +169,7 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil void BaseFileFilter::accept(LocatorFilterEntry selection) const { EditorManager::openEditor(selection.internalData.toString(), Id(), - EditorManager::CanContainLineNumber); + EditorManager::CanContainLineAndColumnNumber); } /*! diff --git a/src/plugins/coreplugin/locator/directoryfilter.cpp b/src/plugins/coreplugin/locator/directoryfilter.cpp index 019c99033bf..a9b2accfdd7 100644 --- a/src/plugins/coreplugin/locator/directoryfilter.cpp +++ b/src/plugins/coreplugin/locator/directoryfilter.cpp @@ -190,14 +190,17 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future) } directories = m_directories; } - Utils::SubDirFileIterator it(directories, m_filters); - future.setProgressRange(0, it.maxProgress()); + Utils::SubDirFileIterator subDirIterator(directories, m_filters); + future.setProgressRange(0, subDirIterator.maxProgress()); QStringList filesFound; - while (!future.isCanceled() && it.hasNext()) { - filesFound << it.next(); + auto end = subDirIterator.end(); + for (auto it = subDirIterator.begin(); it != end; ++it) { + if (future.isCanceled()) + break; + filesFound << (*it).filePath; if (future.isProgressUpdateNeeded() || future.progressValue() == 0 /*workaround for regression in Qt*/) { - future.setProgressValueAndText(it.currentProgress(), + future.setProgressValueAndText(subDirIterator.currentProgress(), tr("%1 filter update: %n files", 0, filesFound.size()).arg(displayName())); } } @@ -206,8 +209,8 @@ void DirectoryFilter::refresh(QFutureInterface<void> &future) QMutexLocker locker(&m_lock); m_files = filesFound; QTimer::singleShot(0, this, SLOT(updateFileIterator())); - future.setProgressValue(it.maxProgress()); + future.setProgressValue(subDirIterator.maxProgress()); } else { - future.setProgressValueAndText(it.currentProgress(), tr("%1 filter update: canceled").arg(displayName())); + future.setProgressValueAndText(subDirIterator.currentProgress(), tr("%1 filter update: canceled").arg(displayName())); } } diff --git a/src/plugins/coreplugin/locator/externaltoolsfilter.cpp b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp new file mode 100644 index 00000000000..29802cd03b9 --- /dev/null +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.cpp @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include <coreplugin/externaltool.h> +#include <coreplugin/externaltoolmanager.h> +#include <coreplugin/messagemanager.h> +#include <utils/qtcassert.h> + +#include "externaltoolsfilter.h" + +using namespace Core; +using namespace Core::Internal; + +ExternalToolsFilter::ExternalToolsFilter() +{ + setId("Run external tool"); + setDisplayName(tr("Run External Tool")); + setShortcutString(QLatin1String("x")); + setPriority(Medium); +} + +QList<LocatorFilterEntry> ExternalToolsFilter::matchesFor(QFutureInterface<LocatorFilterEntry> &, + const QString &) +{ + return m_results; +} + +void ExternalToolsFilter::accept(LocatorFilterEntry selection) const +{ + auto tool = selection.internalData.value<ExternalTool *>(); + QTC_ASSERT(tool, return); + + auto runner = new ExternalToolRunner(tool); + if (runner->hasError()) + MessageManager::write(runner->errorString()); +} + +void ExternalToolsFilter::refresh(QFutureInterface<void> &) +{ +} + +void ExternalToolsFilter::prepareSearch(const QString &entry) +{ + m_results.clear(); + + Qt::CaseSensitivity useCaseSensitivity = caseSensitivity(entry); + const QMap<QString, ExternalTool *> externalToolsById = ExternalToolManager::toolsById(); + auto end = externalToolsById.cend(); + for (auto it = externalToolsById.cbegin(); it != end; ++it) { + ExternalTool *tool = *it; + if (tool->description().contains(entry, useCaseSensitivity) || + tool->displayName().contains(entry, useCaseSensitivity)) { + + LocatorFilterEntry filterEntry(this, tool->displayName(), QVariant::fromValue(tool)); + filterEntry.extraInfo = tool->description(); + m_results.append(filterEntry); + } + } +} diff --git a/src/plugins/qbsprojectmanager/qbspropertylineedit.h b/src/plugins/coreplugin/locator/externaltoolsfilter.h index 278f32b644f..7301c80d29b 100644 --- a/src/plugins/qbsprojectmanager/qbspropertylineedit.h +++ b/src/plugins/coreplugin/locator/externaltoolsfilter.h @@ -28,36 +28,31 @@ ** ****************************************************************************/ -#ifndef QBSPROPERTYLINEEDIT_H -#define QBSPROPERTYLINEEDIT_H +#ifndef EXTERNALTOOLSFILTER_H +#define EXTERNALTOOLSFILTER_H -#include <utils/fancylineedit.h> +#include "ilocatorfilter.h" -#include <QList> -#include <QPair> - -namespace QbsProjectManager { +namespace Core { namespace Internal { -class QbsPropertyLineEdit : public Utils::FancyLineEdit +class ExternalToolsFilter : public ILocatorFilter { Q_OBJECT - public: - explicit QbsPropertyLineEdit(QWidget *parent = 0); + ExternalToolsFilter(); - QList<QPair<QString, QString> > properties() const; - -signals: - void propertiesChanged() const; + QList<LocatorFilterEntry> matchesFor(QFutureInterface<LocatorFilterEntry> &future, + const QString &entry) override; + void accept(LocatorFilterEntry selection) const override; + void refresh(QFutureInterface<void> &future) override; + void prepareSearch(const QString &entry) override; private: - bool validate(const QString &value, QString *errorMessage) const; - - mutable QList<QPair<QString, QString> > m_propertyCache; + QList<LocatorFilterEntry> m_results; }; } // namespace Internal -} // namespace QbsProjectManager +} // namespace Core -#endif // QBSPROPERTYLINEEDIT_H +#endif // EXTERNALTOOLSFILTER_H diff --git a/src/plugins/coreplugin/locator/filesystemfilter.cpp b/src/plugins/coreplugin/locator/filesystemfilter.cpp index 59ee3827aa7..51c79beaf2e 100644 --- a/src/plugins/coreplugin/locator/filesystemfilter.cpp +++ b/src/plugins/coreplugin/locator/filesystemfilter.cpp @@ -162,7 +162,7 @@ void FileSystemFilter::accept(LocatorFilterEntry selection) const } const QFileInfo fileInfo(selection.internalData.toString()); const QString cleanedFilePath = QDir::cleanPath(fileInfo.absoluteFilePath()); - EditorManager::openEditor(cleanedFilePath, Id(), EditorManager::CanContainLineNumber); + EditorManager::openEditor(cleanedFilePath, Id(), EditorManager::CanContainLineAndColumnNumber); } bool FileSystemFilter::openConfigDialog(QWidget *parent, bool &needsRefresh) diff --git a/src/plugins/coreplugin/locator/locator.cpp b/src/plugins/coreplugin/locator/locator.cpp index 6e80703cd17..095ffa57ded 100644 --- a/src/plugins/coreplugin/locator/locator.cpp +++ b/src/plugins/coreplugin/locator/locator.cpp @@ -36,6 +36,7 @@ #include "opendocumentsfilter.h" #include "filesystemfilter.h" #include "locatorsettingspage.h" +#include "externaltoolsfilter.h" #include <coreplugin/coreplugin.h> #include <coreplugin/statusbarwidget.h> @@ -58,6 +59,10 @@ #include <QFuture> #include <QAction> +#ifdef Q_OS_OSX +#include "spotlightlocatorfilter.h" +#endif + namespace Core { namespace Internal { @@ -75,10 +80,12 @@ Locator::~Locator() m_corePlugin->removeObject(m_fileSystemFilter); m_corePlugin->removeObject(m_executeFilter); m_corePlugin->removeObject(m_settingsPage); + m_corePlugin->removeObject(m_externalToolsFilter); delete m_openDocumentsFilter; delete m_fileSystemFilter; delete m_executeFilter; delete m_settingsPage; + delete m_externalToolsFilter; qDeleteAll(m_customFilters); } @@ -118,7 +125,13 @@ void Locator::initialize(CorePlugin *corePlugin, const QStringList &, QString *) m_executeFilter = new ExecuteFilter(); m_corePlugin->addObject(m_executeFilter); + m_externalToolsFilter = new ExternalToolsFilter; + m_corePlugin->addObject(m_externalToolsFilter); + m_corePlugin->addAutoReleasedObject(new LocatorFiltersFilter(this, m_locatorWidget)); +#ifdef Q_OS_OSX + m_corePlugin->addAutoReleasedObject(new SpotlightLocatorFilter); +#endif connect(ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings())); } diff --git a/src/plugins/coreplugin/locator/locator.h b/src/plugins/coreplugin/locator/locator.h index 6c115be7eb6..72cbf41a1d5 100644 --- a/src/plugins/coreplugin/locator/locator.h +++ b/src/plugins/coreplugin/locator/locator.h @@ -50,6 +50,7 @@ class LocatorWidget; class OpenDocumentsFilter; class FileSystemFilter; class LocatorSettingsPage; +class ExternalToolsFilter; class Locator : public QObject { @@ -97,6 +98,7 @@ private: FileSystemFilter *m_fileSystemFilter; ExecuteFilter *m_executeFilter; CorePlugin *m_corePlugin; + ExternalToolsFilter *m_externalToolsFilter; }; template <typename S> diff --git a/src/plugins/coreplugin/locator/locator.pri b/src/plugins/coreplugin/locator/locator.pri index 5ff92bfd43d..c697437d693 100644 --- a/src/plugins/coreplugin/locator/locator.pri +++ b/src/plugins/coreplugin/locator/locator.pri @@ -12,7 +12,8 @@ HEADERS += \ $$PWD/basefilefilter.h \ $$PWD/executefilter.h \ $$PWD/locatorsearchutils.h \ - $$PWD/locatorsettingspage.h + $$PWD/locatorsettingspage.h \ + $$PWD/externaltoolsfilter.h SOURCES += \ $$PWD/locator.cpp \ @@ -27,7 +28,8 @@ SOURCES += \ $$PWD/ilocatorfilter.cpp \ $$PWD/executefilter.cpp \ $$PWD/locatorsearchutils.cpp \ - $$PWD/locatorsettingspage.cpp + $$PWD/locatorsettingspage.cpp \ + $$PWD/externaltoolsfilter.cpp FORMS += \ $$PWD/filesystemfilter.ui \ @@ -44,3 +46,8 @@ equals(TEST, 1) { $$PWD/locator_test.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" } + +osx { + HEADERS += $$PWD/spotlightlocatorfilter.h + OBJECTIVE_SOURCES += $$PWD/spotlightlocatorfilter.mm +} diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 5c38f647c81..afe793e1ddb 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -288,10 +288,9 @@ LocatorWidget::LocatorWidget(Locator *qop) : connect(m_entriesWatcher, &QFutureWatcher<LocatorFilterEntry>::finished, this, &LocatorWidget::handleSearchFinished); - m_showPopupTimer = new QTimer(this); - m_showPopupTimer->setInterval(100); - m_showPopupTimer->setSingleShot(true); - connect(m_showPopupTimer, SIGNAL(timeout()), SLOT(showPopupNow())); + m_showPopupTimer.setInterval(100); + m_showPopupTimer.setSingleShot(true); + connect(&m_showPopupTimer, SIGNAL(timeout()), SLOT(showPopupNow())); m_progressIndicator = new Utils::ProgressIndicator(Utils::ProgressIndicator::Small, m_fileLineEdit); @@ -453,12 +452,12 @@ void LocatorWidget::showCompletionList() void LocatorWidget::showPopup() { m_updateRequested = true; - m_showPopupTimer->start(); + m_showPopupTimer.start(); } void LocatorWidget::showPopupNow() { - m_showPopupTimer->stop(); + m_showPopupTimer.stop(); updateCompletionList(m_fileLineEdit->text()); showCompletionList(); } diff --git a/src/plugins/coreplugin/locator/locatorwidget.h b/src/plugins/coreplugin/locator/locatorwidget.h index 312fb0b363a..10884556f49 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.h +++ b/src/plugins/coreplugin/locator/locatorwidget.h @@ -92,7 +92,7 @@ private: QAction *m_refreshAction; QAction *m_configureAction; Utils::FancyLineEdit *m_fileLineEdit; - QTimer *m_showPopupTimer; + QTimer m_showPopupTimer; QFutureWatcher<LocatorFilterEntry> *m_entriesWatcher; QMap<Id, QAction *> m_filterActionMap; QString m_requestedCompletionText; diff --git a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp index 94a7fe5c151..7dfa8d64115 100644 --- a/src/plugins/coreplugin/locator/opendocumentsfilter.cpp +++ b/src/plugins/coreplugin/locator/opendocumentsfilter.cpp @@ -122,5 +122,5 @@ void OpenDocumentsFilter::refresh(QFutureInterface<void> &future) void OpenDocumentsFilter::accept(LocatorFilterEntry selection) const { EditorManager::openEditor(selection.internalData.toString(), Id(), - EditorManager::CanContainLineNumber); + EditorManager::CanContainLineAndColumnNumber); } diff --git a/src/plugins/cvs/checkoutwizardpage.h b/src/plugins/coreplugin/locator/spotlightlocatorfilter.h index b7e863fecdf..41ecef9fae1 100644 --- a/src/plugins/cvs/checkoutwizardpage.h +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.h @@ -28,23 +28,26 @@ ** ****************************************************************************/ -#ifndef CHECKOUTWIZARDPAGE_H -#define CHECKOUTWIZARDPAGE_H -#include <vcsbase/basecheckoutwizardpage.h> +#ifndef SPOTLIGHTLOCATORFILTER_H +#define SPOTLIGHTLOCATORFILTER_H -namespace Cvs { +#include "basefilefilter.h" + +namespace Core { namespace Internal { -class CheckoutWizardPage : public VcsBase::BaseCheckoutWizardPage +class SpotlightLocatorFilter : public BaseFileFilter { - Q_OBJECT - public: - CheckoutWizardPage(QWidget *parent = 0); + SpotlightLocatorFilter(); + + void prepareSearch(const QString &entry); + void refresh(QFutureInterface<void> &future); }; -} // namespace Internal -} // namespace Cvs +} // Internal +} // Core + +#endif // SPOTLIGHTLOCATORFILTER_H -#endif // CHECKOUTWIZARDPAGE_H diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm new file mode 100644 index 00000000000..4b632745adb --- /dev/null +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm @@ -0,0 +1,217 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "spotlightlocatorfilter.h" + +#include <utils/autoreleasepool.h> +#include <utils/qtcassert.h> + +#include <QMutex> +#include <QMutexLocker> +#include <QWaitCondition> + +#include <Foundation/NSArray.h> +#include <Foundation/NSAutoreleasePool.h> +#include <Foundation/NSDictionary.h> +#include <Foundation/NSMetadata.h> +#include <Foundation/NSNotification.h> +#include <Foundation/NSOperation.h> +#include <Foundation/NSPredicate.h> + +namespace Core { +namespace Internal { + +// #pragma mark -- SpotlightIterator + +class SpotlightIterator : public BaseFileFilter::Iterator +{ +public: + SpotlightIterator(const QString &expression); + ~SpotlightIterator(); + + void toFront(); + bool hasNext() const; + QString next(); + QString filePath() const; + QString fileName() const; + +private: + void ensureNext(); + + NSMetadataQuery *m_query; + id<NSObject> m_progressObserver; + id<NSObject> m_finishObserver; + QMutex m_mutex; + QWaitCondition m_waitForItems; + NSMutableArray *m_queue; + QStringList m_filePaths; + QStringList m_fileNames; + int m_index; + unsigned int m_queueIndex; + bool m_finished; +}; + +SpotlightIterator::SpotlightIterator(const QString &expression) + : m_index(-1), + m_queueIndex(-1), + m_finished(false) +{ + Utils::AutoreleasePool pool; Q_UNUSED(pool) + NSPredicate *predicate = [NSPredicate predicateWithFormat:expression.toNSString()]; + m_query = [[NSMetadataQuery alloc] init]; + m_query.predicate = predicate; + m_query.searchScopes = [NSArray arrayWithObject:NSMetadataQueryLocalComputerScope]; + m_queue = [[NSMutableArray alloc] init]; + m_progressObserver = [[[NSNotificationCenter defaultCenter] + addObserverForName:NSMetadataQueryGatheringProgressNotification + object:m_query + queue:nil + usingBlock:^(NSNotification *note) { + [m_query disableUpdates]; + QMutexLocker lock(&m_mutex); Q_UNUSED(lock) + [m_queue addObjectsFromArray:[note.userInfo objectForKey:NSMetadataQueryUpdateAddedItemsKey]]; + [m_query enableUpdates]; + m_waitForItems.wakeAll(); + }] retain]; + m_finishObserver = [[[NSNotificationCenter defaultCenter] + addObserverForName:NSMetadataQueryDidFinishGatheringNotification + object:m_query + queue:nil + usingBlock:^(NSNotification *) { + QMutexLocker lock(&m_mutex); Q_UNUSED(lock) + m_finished = true; + m_waitForItems.wakeAll(); + }] retain]; + [m_query startQuery]; +} + +SpotlightIterator::~SpotlightIterator() +{ + [[NSNotificationCenter defaultCenter] removeObserver:m_progressObserver]; + [m_progressObserver release]; + [[NSNotificationCenter defaultCenter] removeObserver:m_finishObserver]; + [m_finishObserver release]; + [m_query stopQuery]; + [m_query release]; + [m_queue release]; +} + +void SpotlightIterator::toFront() +{ + m_index = -1; +} + +bool SpotlightIterator::hasNext() const +{ + auto that = const_cast<SpotlightIterator *>(this); + that->ensureNext(); + return (m_index + 1 < m_filePaths.size()); +} + +QString SpotlightIterator::next() +{ + ensureNext(); + ++m_index; + QTC_ASSERT(m_index < m_filePaths.size(), return QString()); + return m_filePaths.at(m_index); +} + +QString SpotlightIterator::filePath() const +{ + QTC_ASSERT(m_index < m_filePaths.size(), return QString()); + return m_filePaths.at(m_index); +} + +QString SpotlightIterator::fileName() const +{ + QTC_ASSERT(m_index < m_fileNames.size(), return QString()); + return m_fileNames.at(m_index); +} + +void SpotlightIterator::ensureNext() +{ + if (m_index + 1 < m_filePaths.size()) // nothing to do + return; + if (m_index >= 10000) // limit the amount of data that is passed on + return; + Utils::AutoreleasePool pool; Q_UNUSED(pool) + // check if there are items in the queue, otherwise wait for some + m_mutex.lock(); + bool itemAvailable = (m_queueIndex + 1 < m_queue.count); + if (!itemAvailable && !m_finished) { + m_waitForItems.wait(&m_mutex); + itemAvailable = (m_queueIndex + 1 < m_queue.count); + } + if (itemAvailable) { + ++m_queueIndex; + NSMetadataItem *item = [m_queue objectAtIndex:m_queueIndex]; + m_filePaths.append(QString::fromNSString([item valueForAttribute:NSMetadataItemPathKey])); + m_fileNames.append(QString::fromNSString([item valueForAttribute:NSMetadataItemFSNameKey])); + + } + m_mutex.unlock(); +} + +// #pragma mark -- SpotlightLocatorFilter + +SpotlightLocatorFilter::SpotlightLocatorFilter() +{ + setId("SpotlightFileNamesLocatorFilter"); + setDisplayName(tr("Spotlight File Name Index")); + setShortcutString(QLatin1String("md")); +} + +void SpotlightLocatorFilter::prepareSearch(const QString &entry) +{ + if (entry.isEmpty()) { + setFileIterator(new BaseFileFilter::ListIterator(QStringList())); + } else { + // only pass the file name part to spotlight to allow searches like "somepath/*foo" + int lastSlash = entry.lastIndexOf(QLatin1Char('/')); + QString quoted = entry.mid(lastSlash + 1); + quoted.replace(QLatin1Char('\\'), QLatin1String("\\\\")) + .replace(QLatin1Char('\''), QLatin1String("\\\'")) + .replace(QLatin1Char('\"'), QLatin1String("\\\"")); + setFileIterator(new SpotlightIterator( + QString::fromLatin1("kMDItemFSName like%1 \"*%2*\"") + .arg(caseSensitivity(entry) == Qt::CaseInsensitive ? QLatin1String("[c]") + : QString()) + .arg(quoted))); + } + BaseFileFilter::prepareSearch(entry); +} + +void SpotlightLocatorFilter::refresh(QFutureInterface<void> &future) +{ + Q_UNUSED(future) +} + +} // Internal +} // Core diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp index 2bfa13b42ea..7d7953cd179 100644 --- a/src/plugins/coreplugin/mainwindow.cpp +++ b/src/plugins/coreplugin/mainwindow.cpp @@ -794,8 +794,8 @@ IDocument *MainWindow::openFiles(const QStringList &fileNames, } } else { QFlags<EditorManager::OpenEditorFlag> emFlags; - if (flags & ICore::CanContainLineNumbers) - emFlags |= EditorManager::CanContainLineNumber; + if (flags & ICore::CanContainLineAndColumnNumbers) + emFlags |= EditorManager::CanContainLineAndColumnNumber; IEditor *editor = EditorManager::openEditor(absoluteFilePath, Id(), emFlags); if (!editor) { if (flags & ICore::StopOnLoadFail) diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 9326552159c..2d87a448a2e 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -34,6 +34,7 @@ #include <coreplugin/coreconstants.h> +#include <utils/algorithm.h> #include <utils/hostosinfo.h> #include <utils/stylehelper.h> @@ -43,6 +44,7 @@ #include <QApplication> #include <QComboBox> #include <QDockWidget> +#include <QFormLayout> #include <QLabel> #include <QLineEdit> #include <QMenuBar> @@ -314,19 +316,6 @@ void ManhattanStyle::polish(QPalette &pal) QProxyStyle::polish(pal); } -QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const -{ - QIcon icon; - switch (standardIcon) { - case QStyle::SP_TitleBarCloseButton: - case QStyle::SP_ToolBarHorizontalExtensionButton: - return QIcon(standardPixmap(standardIcon, option, widget)); - default: - icon = baseStyle()->standardIcon(standardIcon, option, widget); - } - return icon; -} - QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const { @@ -348,16 +337,24 @@ QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QSty return pixmap; } +QIcon ManhattanStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const +{ + QIcon icon = QProxyStyle::standardIcon(standardIcon, option, widget); + if (standardIcon == QStyle::SP_ComputerIcon) { + // Ubuntu has in some versions a 16x16 icon, see QTCREATORBUG-12832 + const QList<QSize> &sizes = icon.availableSizes(); + if (Utils::allOf(sizes, [](const QSize &size) { return size.width() < 32;})) { + icon = QIcon(QLatin1String(":/core/images/Desktop.png")); + } + } + return icon; +} + int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const { int ret = QProxyStyle::styleHint(hint, option, widget, returnData); switch (hint) { - // Make project explorer alternate rows all the way - case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea: - if (widget && widget->property("AlternateEmpty").toBool()) - ret = true; - break; case QStyle::SH_EtchDisabledText: if (panelWidget(widget) || qobject_cast<const QMenu *> (widget) ) ret = false; @@ -372,6 +369,13 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const if (activationMode.isValid()) ret = activationMode.toBool(); } + break; + case QStyle::SH_FormLayoutFieldGrowthPolicy: + // The default in QMacStyle, FieldsStayAtSizeHint, is just always the wrong thing + // Use the same as on all other shipped styles + if (Utils::HostOsInfo::isMacHost()) + ret = QFormLayout::AllNonFixedFieldsGrow; + break; default: break; } diff --git a/src/plugins/coreplugin/manhattanstyle.h b/src/plugins/coreplugin/manhattanstyle.h index 72827a9f017..bb7993c93a5 100644 --- a/src/plugins/coreplugin/manhattanstyle.h +++ b/src/plugins/coreplugin/manhattanstyle.h @@ -56,6 +56,7 @@ public: SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const; QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0, const QWidget *widget = 0) const; int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const; QRect itemRect(QPainter *p, const QRect &r, int flags, bool enabled, const QPixmap *pixmap, const QString &text, int len = -1) const; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const; @@ -71,9 +72,6 @@ public: void unpolish(QWidget *widget); void unpolish(QApplication *app); -protected slots: - QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const; - private: void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const; diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp index 64c107def76..a4565c34138 100644 --- a/src/plugins/coreplugin/modemanager.cpp +++ b/src/plugins/coreplugin/modemanager.cpp @@ -123,14 +123,6 @@ ModeManager::~ModeManager() m_instance = 0; } -void ModeManager::addWidget(QWidget *widget) -{ - // We want the actionbar to stay on the bottom - // so d->m_modeStack->cornerWidgetCount() -1 inserts it at the position immediately above - // the actionbar - d->m_modeStack->insertCornerWidget(d->m_modeStack->cornerWidgetCount() -1, widget); -} - IMode *ModeManager::currentMode() { int currentIndex = d->m_modeStack->currentIndex(); diff --git a/src/plugins/coreplugin/modemanager.h b/src/plugins/coreplugin/modemanager.h index ae74dd4a949..77d2e31f6c6 100644 --- a/src/plugins/coreplugin/modemanager.h +++ b/src/plugins/coreplugin/modemanager.h @@ -60,7 +60,6 @@ public: static void addAction(QAction *action, int priority); static void addProjectSelector(QAction *action); - static void addWidget(QWidget *widget); static void activateMode(Id id); static void setFocusToCurrentMode(); diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index e19505fd442..860f6490e02 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -127,6 +127,12 @@ OutputWindow::OutputWindow(Context context, QWidget *parent) redoAction->setEnabled(false); cutAction->setEnabled(false); copyAction->setEnabled(false); + + m_scrollTimer.setInterval(10); + m_scrollTimer.setSingleShot(true); + connect(&m_scrollTimer, &QTimer::timeout, + this, &OutputWindow::scrollToBottom); + m_lastMessage.start(); } OutputWindow::~OutputWindow() @@ -241,7 +247,7 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) { const QString out = SynchronousProcess::normalizeNewlines(output); setMaximumBlockCount(d->maxLineCount); - const bool atBottom = isScrollbarAtBottom(); + const bool atBottom = isScrollbarAtBottom() || m_scrollTimer.isActive(); if (format == ErrorMessageFormat || format == NormalMessageFormat) { @@ -281,8 +287,16 @@ void OutputWindow::appendMessage(const QString &output, OutputFormat format) } } - if (atBottom) - scrollToBottom(); + if (atBottom) { + if (m_lastMessage.elapsed() < 5) { + m_scrollTimer.start(); + } else { + m_scrollTimer.stop(); + scrollToBottom(); + } + } + + m_lastMessage.start(); enableUndoRedo(); } diff --git a/src/plugins/coreplugin/outputwindow.h b/src/plugins/coreplugin/outputwindow.h index a649a58c677..d5738ab7206 100644 --- a/src/plugins/coreplugin/outputwindow.h +++ b/src/plugins/coreplugin/outputwindow.h @@ -37,6 +37,8 @@ #include <utils/outputformat.h> #include <QPlainTextEdit> +#include <QTimer> +#include <QTime> namespace Utils { class OutputFormatter; } @@ -82,6 +84,8 @@ protected: virtual void keyPressEvent(QKeyEvent *ev); private: + QTimer m_scrollTimer; + QTime m_lastMessage; void enableUndoRedo(); QString doNewlineEnforcement(const QString &out); diff --git a/src/plugins/coreplugin/patchtool.cpp b/src/plugins/coreplugin/patchtool.cpp index f57a5865442..098575b3251 100644 --- a/src/plugins/coreplugin/patchtool.cpp +++ b/src/plugins/coreplugin/patchtool.cpp @@ -111,7 +111,7 @@ bool PatchTool::runPatch(const QByteArray &input, const QString &workingDirector patchProcess.closeWriteChannel(); QByteArray stdOut; QByteArray stdErr; - if (!Utils::SynchronousProcess::readDataFromProcess(patchProcess, 30000, &stdOut, &stdErr, true)) { + if (!Utils::SynchronousProcess::readDataFromProcess(patchProcess, 30, &stdOut, &stdErr, true)) { Utils::SynchronousProcess::stopProcess(patchProcess); MessageManager::write(QApplication::translate("Core::PatchTool", "A timeout occurred running \"%1\"").arg(patch)); return false; diff --git a/src/plugins/coreplugin/plugindialog.cpp b/src/plugins/coreplugin/plugindialog.cpp index ee7440db14a..59096e7d07b 100644 --- a/src/plugins/coreplugin/plugindialog.cpp +++ b/src/plugins/coreplugin/plugindialog.cpp @@ -36,6 +36,8 @@ #include <extensionsystem/pluginerrorview.h> #include <extensionsystem/pluginspec.h> +#include <utils/fancylineedit.h> + #include <QVBoxLayout> #include <QHBoxLayout> #include <QDialog> @@ -54,6 +56,13 @@ PluginDialog::PluginDialog(QWidget *parent) m_view(new ExtensionSystem::PluginView(this)) { QVBoxLayout *vl = new QVBoxLayout(this); + + auto filterEdit = new Utils::FancyLineEdit(this); + filterEdit->setFiltering(true); + connect(filterEdit, &Utils::FancyLineEdit::filterChanged, + m_view, &ExtensionSystem::PluginView::setFilter); + vl->addWidget(filterEdit); + vl->addWidget(m_view); m_detailsButton = new QPushButton(tr("Details"), this); diff --git a/src/plugins/coreplugin/variablemanager.cpp b/src/plugins/coreplugin/shellcommand.cpp index a4810476228..c02d71b3c2c 100644 --- a/src/plugins/coreplugin/variablemanager.cpp +++ b/src/plugins/coreplugin/shellcommand.cpp @@ -1,6 +1,6 @@ -/**************************************************************************** +/************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Brian McGillion and Hugues Delorme ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. @@ -28,29 +28,29 @@ ** ****************************************************************************/ -#include "variablemanager.h" +#include "shellcommand.h" - -#include <QCoreApplication> - -using namespace Utils; +#include "icore.h" +#include "progressmanager/progressmanager.h" namespace Core { -class GlobalMacroExpander : public MacroExpander +ShellCommand::ShellCommand(const QString &workingDirectory, const QProcessEnvironment &environment) : + Utils::ShellCommand(workingDirectory, environment) +{ + connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose, + this, &ShellCommand::coreAboutToClose); +} + +void ShellCommand::addTask(QFuture<void> &future) { -public: - GlobalMacroExpander() - { - registerPrefix("Env", QCoreApplication::translate("Core::VariableManager", "Access environment variables."), - [](const QString &value) { return QString::fromLocal8Bit(qgetenv(value.toLocal8Bit())); }); - } -}; + const QString name = displayName(); + Core::ProgressManager::addTask(future, name, Core::Id::fromString(name + QLatin1String(".action"))); +} -MacroExpander *globalMacroExpander() +void ShellCommand::coreAboutToClose() { - static MacroExpander theGlobalExpander; - return &theGlobalExpander; + abort(); } } // namespace Core diff --git a/src/plugins/coreplugin/variablemanager.h b/src/plugins/coreplugin/shellcommand.h index 9bda9a8559f..0aa679220f3 100644 --- a/src/plugins/coreplugin/variablemanager.h +++ b/src/plugins/coreplugin/shellcommand.h @@ -1,6 +1,6 @@ -/**************************************************************************** +/************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Brian McGillion and Hugues Delorme ** Contact: http://www.qt.io/licensing ** ** This file is part of Qt Creator. @@ -28,17 +28,28 @@ ** ****************************************************************************/ -#ifndef VARIABLEMANAGER_H -#define VARIABLEMANAGER_H +#ifndef CORE_SHELLCOMMAND_H +#define CORE_SHELLCOMMAND_H #include "core_global.h" -#include <utils/macroexpander.h> +#include <utils/shellcommand.h> namespace Core { -CORE_EXPORT Utils::MacroExpander *globalMacroExpander(); +class CORE_EXPORT ShellCommand : public Utils::ShellCommand +{ + Q_OBJECT + +public: + ShellCommand(const QString &workingDirectory, const QProcessEnvironment &environment); + +protected: + void addTask(QFuture<void> &future); + + virtual void coreAboutToClose(); +}; } // namespace Core -#endif // VARIABLEMANAGER_H +#endif // CORE_SHELLCOMMAND_H diff --git a/src/plugins/coreplugin/themeeditor/themesettingstablemodel.cpp b/src/plugins/coreplugin/themeeditor/themesettingstablemodel.cpp index 192f657a1d4..13a2accda8a 100644 --- a/src/plugins/coreplugin/themeeditor/themesettingstablemodel.cpp +++ b/src/plugins/coreplugin/themeeditor/themesettingstablemodel.cpp @@ -65,7 +65,6 @@ int ThemeSettingsTableModel::sectionRowCount(int section) const case SectionWidgetStyle: return 1; case SectionColors: return m_colors->numColorRoles(); case SectionFlags: return m_flags.size(); - case SectionImageFiles: return m_imageFiles.size(); default: return 0; } } @@ -110,15 +109,6 @@ QVariant ThemeSettingsTableModel::sectionBodyData(int section, int row, int colu return QVariant::fromValue(makeDecoration(Qt::transparent)); return QVariant(); } - case SectionImageFiles: { - if (column == 0 && role == Qt::DisplayRole) - return m_imageFiles[row].first; - else if (column == 1 && role == Qt::DisplayRole) - return m_imageFiles[row].second; - else if (column == 0 && role == Qt::DecorationRole) - return QVariant::fromValue(makeDecoration(Qt::transparent)); - return QVariant(); - } default: return QVariant(); } @@ -131,7 +121,6 @@ QVariant ThemeSettingsTableModel::sectionHeaderData(int section, int role) const case SectionWidgetStyle: return tr("Widget Style"); case SectionColors: return tr("Colors"); case SectionFlags: return tr("Flags"); - case SectionImageFiles: return tr("Image Files"); default: return QString(); } } @@ -159,8 +148,6 @@ Qt::ItemFlags ThemeSettingsTableModel::sectionBodyFlags(int section, int row, in case SectionFlags: return (column == 0) ? Qt::ItemIsEnabled : Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; - case SectionImageFiles: - return Qt::ItemIsEnabled; default: return Qt::ItemIsEnabled; } } diff --git a/src/plugins/coreplugin/themeeditor/themesettingstablemodel.h b/src/plugins/coreplugin/themeeditor/themesettingstablemodel.h index 2652cb7cb15..f2416ec7233 100644 --- a/src/plugins/coreplugin/themeeditor/themesettingstablemodel.h +++ b/src/plugins/coreplugin/themeeditor/themesettingstablemodel.h @@ -52,7 +52,6 @@ public: SectionWidgetStyle, SectionColors, SectionFlags, - SectionImageFiles, SectionInvalid // end }; diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 8044c049d54..c7337de83f0 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -127,9 +127,8 @@ class VariableGroupItem : public TreeItem { public: VariableGroupItem() - : m_chooser(0) + : m_chooser(0), m_populated(false) { - setLazy(true); } QVariant data(int column, int role) const @@ -143,16 +142,23 @@ public: return QVariant(); } - void populate() + bool canFetchMore() const + { + return !m_populated; + } + + void fetchMore() { if (MacroExpander *expander = m_provider()) populateGroup(expander); + m_populated = true; } void populateGroup(MacroExpander *expander); public: VariableChooserPrivate *m_chooser; // Not owned. + bool m_populated; MacroExpanderProvider m_provider; }; diff --git a/src/plugins/cpaster/protocol.h b/src/plugins/cpaster/protocol.h index 81716c8b758..2698d919cca 100644 --- a/src/plugins/cpaster/protocol.h +++ b/src/plugins/cpaster/protocol.h @@ -36,7 +36,6 @@ #include <QSharedPointer> QT_BEGIN_NAMESPACE -class QNetworkAccessManager; class QNetworkReply; class QWidget; QT_END_NAMESPACE diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 460d8b7c3a0..c01958baa4c 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -389,7 +389,7 @@ void CppEditorWidget::switchDeclarationDefinition(bool inNextSplit) } else if (functionDefinitionSymbol) { const Snapshot snapshot = d->m_modelManager->snapshot(); LookupContext context(d->m_lastSemanticInfo.doc, snapshot); - ClassOrNamespace *binding = context.lookupType(functionDefinitionSymbol); + LookupScope *binding = context.lookupType(functionDefinitionSymbol); const QList<LookupItem> declarations = context.lookup(functionDefinitionSymbol->name(), functionDefinitionSymbol->enclosingScope()); diff --git a/src/plugins/cppeditor/cppeditor.qbs b/src/plugins/cppeditor/cppeditor.qbs index 243fb637742..bc2a8ea3a73 100644 --- a/src/plugins/cppeditor/cppeditor.qbs +++ b/src/plugins/cppeditor/cppeditor.qbs @@ -5,7 +5,6 @@ QtcPlugin { name: "CppEditor" Depends { name: "Qt.widgets" } - Depends { name: "Aggregation" } Depends { name: "CPlusPlus" } Depends { name: "Utils" } diff --git a/src/plugins/cppeditor/cppeditor_dependencies.pri b/src/plugins/cppeditor/cppeditor_dependencies.pri index 751d75224ac..c9a690b079e 100644 --- a/src/plugins/cppeditor/cppeditor_dependencies.pri +++ b/src/plugins/cppeditor/cppeditor_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = CppEditor QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ utils \ cplusplus diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index c8afea541a3..a3255199a63 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -291,7 +291,9 @@ ExtensionSystem::IPlugin::ShutdownFlag CppEditorPlugin::aboutToShutdown() static CppEditorWidget *currentCppEditorWidget() { - return qobject_cast<CppEditorWidget*>(EditorManager::currentEditor()->widget()); + if (IEditor *currentEditor = EditorManager::currentEditor()) + return qobject_cast<CppEditorWidget*>(currentEditor->widget()); + return 0; } void CppEditorPlugin::switchDeclarationDefinition() diff --git a/src/plugins/cppeditor/cppelementevaluator.cpp b/src/plugins/cppeditor/cppelementevaluator.cpp index fa85a8eb05d..119ab2d69b1 100644 --- a/src/plugins/cppeditor/cppelementevaluator.cpp +++ b/src/plugins/cppeditor/cppelementevaluator.cpp @@ -327,10 +327,10 @@ bool CppClass::operator==(const CppClass &other) void CppClass::lookupBases(Symbol *declaration, const LookupContext &context) { - typedef QPair<ClassOrNamespace *, CppClass *> Data; + typedef QPair<LookupScope *, CppClass *> Data; - if (ClassOrNamespace *clazz = context.lookupType(declaration)) { - QSet<ClassOrNamespace *> visited; + if (LookupScope *clazz = context.lookupType(declaration)) { + QSet<LookupScope *> visited; QQueue<Data> q; q.enqueue(qMakePair(clazz, this)); @@ -338,8 +338,8 @@ void CppClass::lookupBases(Symbol *declaration, const LookupContext &context) Data current = q.dequeue(); clazz = current.first; visited.insert(clazz); - const QList<ClassOrNamespace *> &bases = clazz->usings(); - foreach (ClassOrNamespace *baseClass, bases) { + const QList<LookupScope *> &bases = clazz->usings(); + foreach (LookupScope *baseClass, bases) { const QList<Symbol *> &symbols = baseClass->symbols(); foreach (Symbol *symbol, symbols) { if (symbol->isClass() && ( @@ -429,7 +429,7 @@ CppVariable::CppVariable(Symbol *declaration, const LookupContext &context, Scop } if (typeName) { - if (ClassOrNamespace *clazz = context.lookupType(typeName, scope)) { + if (LookupScope *clazz = context.lookupType(typeName, scope)) { if (!clazz->symbols().isEmpty()) { Overview overview; Symbol *symbol = clazz->symbols().at(0); diff --git a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp index 92498eef9aa..a166e8d6412 100644 --- a/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp +++ b/src/plugins/cppeditor/cppfollowsymbolundercursor.cpp @@ -38,6 +38,7 @@ #include <cplusplus/ExpressionUnderCursor.h> #include <cplusplus/ResolveExpression.h> #include <cplusplus/SimpleLexer.h> +#include <cplusplus/Templates.h> #include <cplusplus/TypeOfExpression.h> #include <cpptools/cppmodelmanager.h> #include <cpptools/functionutils.h> @@ -61,7 +62,7 @@ namespace { class VirtualFunctionHelper { public: - VirtualFunctionHelper(const TypeOfExpression &typeOfExpression, + VirtualFunctionHelper(TypeOfExpression &typeOfExpression, Scope *scope, const Document::Ptr &document, const Snapshot &snapshot, @@ -85,6 +86,7 @@ private: Scope *m_scope; const Document::Ptr &m_document; const Snapshot &m_snapshot; + TypeOfExpression &m_typeOfExpression; SymbolFinder *m_finder; // Determined @@ -94,7 +96,7 @@ private: Class *m_staticClassOfFunctionCallExpression; // Output }; -VirtualFunctionHelper::VirtualFunctionHelper(const TypeOfExpression &typeOfExpression, +VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression, Scope *scope, const Document::Ptr &document, const Snapshot &snapshot, @@ -103,6 +105,7 @@ VirtualFunctionHelper::VirtualFunctionHelper(const TypeOfExpression &typeOfExpre , m_scope(scope) , m_document(document) , m_snapshot(snapshot) + , m_typeOfExpression(typeOfExpression) , m_finder(finder) , m_baseExpressionAST(0) , m_function(0) @@ -144,10 +147,7 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function if (m_accessTokenKind == T_ARROW) { result = true; } else if (m_accessTokenKind == T_DOT) { - TypeOfExpression typeOfExpression; - typeOfExpression.init(m_document, m_snapshot); - typeOfExpression.setExpandTemplates(true); - const QList<LookupItem> items = typeOfExpression.reference( + const QList<LookupItem> items = m_typeOfExpression.reference( memberAccessAST->base_expression, m_document, m_scope); if (!items.isEmpty()) { const LookupItem item = items.first(); @@ -181,13 +181,10 @@ Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() con } } else if (MemberAccessAST *memberAccessAST = m_baseExpressionAST->asMemberAccess()) { QTC_ASSERT(m_accessTokenKind == T_ARROW || m_accessTokenKind == T_DOT, return result); - TypeOfExpression typeOfExpression; - typeOfExpression.init(m_document, m_snapshot); - typeOfExpression.setExpandTemplates(true); - const QList<LookupItem> items = typeOfExpression(memberAccessAST->base_expression, - m_expressionDocument, m_scope); - ResolveExpression resolveExpression(typeOfExpression.context()); - ClassOrNamespace *binding = resolveExpression.baseExpression(items, m_accessTokenKind); + const QList<LookupItem> items = m_typeOfExpression(memberAccessAST->base_expression, + m_expressionDocument, m_scope); + ResolveExpression resolveExpression(m_typeOfExpression.context()); + LookupScope *binding = resolveExpression.baseExpression(items, m_accessTokenKind); if (binding) { if (Class *klass = binding->rootClass()) { result = klass; diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index 4c359ed9b62..dfb0b1018a7 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -607,7 +607,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse SubstitutionEnvironment env; env.setContext(sourceContext); env.switchScope(sourceFunction->enclosingScope()); - ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction->enclosingScope()); + LookupScope *targetCoN = targetContext.lookupType(targetFunction->enclosingScope()); if (!targetCoN) targetCoN = targetContext.globalNamespace(); UseMinimalNames q(targetCoN); @@ -653,7 +653,7 @@ ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targetOffse SubstitutionEnvironment env; env.setContext(sourceContext); env.switchScope(sourceFunction); - ClassOrNamespace *targetCoN = targetContext.lookupType(targetFunction); + LookupScope *targetCoN = targetContext.lookupType(targetFunction); if (!targetCoN) targetCoN = targetContext.globalNamespace(); UseMinimalNames q(targetCoN); diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp index 1564bc0da21..bd4c8c83fd9 100644 --- a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp +++ b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp @@ -480,15 +480,15 @@ public: // Determine base classes QList<const Class *> baseClasses; - QQueue<ClassOrNamespace *> baseClassQueue; - QSet<ClassOrNamespace *> visitedBaseClasses; - if (ClassOrNamespace *clazz = interface.context().lookupType(m_classAST->symbol)) + QQueue<LookupScope *> baseClassQueue; + QSet<LookupScope *> visitedBaseClasses; + if (LookupScope *clazz = interface.context().lookupType(m_classAST->symbol)) baseClassQueue.enqueue(clazz); while (!baseClassQueue.isEmpty()) { - ClassOrNamespace *clazz = baseClassQueue.dequeue(); + LookupScope *clazz = baseClassQueue.dequeue(); visitedBaseClasses.insert(clazz); - const QList<ClassOrNamespace *> bases = clazz->usings(); - foreach (ClassOrNamespace *baseClass, bases) { + const QList<LookupScope *> bases = clazz->usings(); + foreach (LookupScope *baseClass, bases) { foreach (Symbol *symbol, baseClass->symbols()) { Class *base = symbol->asClass(); if (base @@ -690,7 +690,7 @@ public: const LookupContext targetContext(headerFile->cppDocument(), snapshot()); const Class *targetClass = m_classAST->symbol; - ClassOrNamespace *targetCoN = targetContext.lookupType(targetClass->enclosingScope()); + LookupScope *targetCoN = targetContext.lookupType(targetClass->enclosingScope()); if (!targetCoN) targetCoN = targetContext.globalNamespace(); UseMinimalNames useMinimalNames(targetCoN); @@ -778,7 +778,7 @@ public: implementationDoc->translationUnit()->getPosition(insertPos, &line, &column); Scope *targetScope = implementationDoc->scopeAt(line, column); const LookupContext targetContext(implementationDoc, snapshot()); - ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope); + LookupScope *targetCoN = targetContext.lookupType(targetScope); if (!targetCoN) targetCoN = targetContext.globalNamespace(); diff --git a/src/plugins/cppeditor/cppquickfix_test.cpp b/src/plugins/cppeditor/cppquickfix_test.cpp index 631759c15c9..84e30d751d6 100644 --- a/src/plugins/cppeditor/cppquickfix_test.cpp +++ b/src/plugins/cppeditor/cppquickfix_test.cpp @@ -1559,6 +1559,19 @@ void CppEditorPlugin::test_quickfix_data() " str.clear();\n" "}\n"); + QTest::newRow("ConvertFromPointer_withEmptyInitializer") + << CppQuickFixFactoryPtr(new ConvertFromAndToPointer) + << _("void foo() {\n" + " QString *@str = new QString();\n" + " if (!str->isEmpty())\n" + " str->clear();\n" + "}\n") + << _("void foo() {\n" + " QString str;\n" + " if (!str.isEmpty())\n" + " str.clear();\n" + "}\n"); + QTest::newRow("ConvertFromPointer_structWithPointer") << CppQuickFixFactoryPtr(new ConvertFromAndToPointer) << _("struct Bar{ QString *str; };\n" diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 123acefb228..6a94db77651 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -211,7 +211,7 @@ Class *isMemberFunction(const LookupContext &context, Function *function) if (!q->base()) return 0; - if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) { + if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) { foreach (Symbol *s, binding->symbols()) { if (Class *matchingClass = s->asClass()) return matchingClass; @@ -249,7 +249,7 @@ Namespace *isNamespaceFunction(const LookupContext &context, Function *function) if (!q->base()) return 0; - if (ClassOrNamespace *binding = context.lookupType(q->base(), enclosingScope)) { + if (LookupScope *binding = context.lookupType(q->base(), enclosingScope)) { foreach (Symbol *s, binding->symbols()) { if (Namespace *matchingNamespace = s->asNamespace()) return matchingNamespace; @@ -1323,7 +1323,7 @@ void TranslateStringLiteral::match(const CppQuickFixInterface &interface, for (int i = path.size() - 1; i >= 0; --i) { if (FunctionDefinitionAST *definition = path.at(i)->asFunctionDefinition()) { Function *function = definition->symbol; - ClassOrNamespace *b = interface.context().lookupType(function); + LookupScope *b = interface.context().lookupType(function); if (b) { // Do we have a tr function? foreach (const LookupItem &r, b->find(trName)) { @@ -1584,7 +1584,7 @@ public: SubstitutionEnvironment env; env.setContext(context()); env.switchScope(result.first().scope()); - ClassOrNamespace *con = typeOfExpression.context().lookupType(scope); + LookupScope *con = typeOfExpression.context().lookupType(scope); if (!con) con = typeOfExpression.context().globalNamespace(); UseMinimalNames q(con); @@ -2274,7 +2274,7 @@ Enum *findEnum(const QList<LookupItem> &results, const LookupContext &ctxt) if (Enum *e = type->asEnumType()) return e; if (const NamedType *namedType = type->asNamedType()) { - if (ClassOrNamespace *con = ctxt.lookupType(namedType->name(), result.scope())) { + if (LookupScope *con = ctxt.lookupType(namedType->name(), result.scope())) { const QList<Enum *> enums = con->unscopedEnums(); const Name *referenceName = namedType->name(); if (const QualifiedNameId *qualifiedName = referenceName->asQualifiedNameId()) @@ -2571,7 +2571,7 @@ public: Document::Ptr targetDoc = targetFile->cppDocument(); Scope *targetScope = targetDoc->scopeAt(m_loc.line(), m_loc.column()); LookupContext targetContext(targetDoc, snapshot()); - ClassOrNamespace *targetCoN = targetContext.lookupType(targetScope); + LookupScope *targetCoN = targetContext.lookupType(targetScope); if (!targetCoN) targetCoN = targetContext.globalNamespace(); @@ -3173,7 +3173,7 @@ public: SubstitutionEnvironment env; env.setContext(context()); env.switchScope(refFunc); - ClassOrNamespace *targetCoN = context().lookupType(refFunc->enclosingScope()); + LookupScope *targetCoN = context().lookupType(refFunc->enclosingScope()); if (!targetCoN) targetCoN = context().globalNamespace(); UseMinimalNames subs(targetCoN); @@ -4059,19 +4059,20 @@ private: void removeNewExpression(ChangeSet &changes, NewExpressionAST *newExprAST) const { - if (newExprAST->new_initializer) { + ExpressionListParenAST *exprlist = newExprAST->new_initializer + ? newExprAST->new_initializer->asExpressionListParen() + : 0; + + if (exprlist && exprlist->expression_list) { // remove 'new' keyword and type before initializer changes.remove(m_file->startOf(newExprAST->new_token), m_file->startOf(newExprAST->new_initializer)); // remove parenthesis around initializer - if (ExpressionListParenAST *exprlist - = newExprAST->new_initializer->asExpressionListParen()) { - int pos = m_file->startOf(exprlist->lparen_token); - changes.remove(pos, pos + 1); - pos = m_file->startOf(exprlist->rparen_token); - changes.remove(pos, pos + 1); - } + int pos = m_file->startOf(exprlist->lparen_token); + changes.remove(pos, pos + 1); + pos = m_file->startOf(exprlist->rparen_token); + changes.remove(pos, pos + 1); } else { // remove the whole new expression changes.remove(m_file->endOf(m_identifierAST->firstToken()), @@ -4574,7 +4575,7 @@ QString definitionSignature(const CppQuickFixInterface *assist, QTC_ASSERT(func, return QString()); LookupContext cppContext(targetFile->cppDocument(), assist->snapshot()); - ClassOrNamespace *cppCoN = cppContext.lookupType(scope); + LookupScope *cppCoN = cppContext.lookupType(scope); if (!cppCoN) cppCoN = cppContext.globalNamespace(); SubstitutionEnvironment env; @@ -5055,7 +5056,7 @@ public: SubstitutionEnvironment env; env.setContext(context()); env.switchScope(result.first().scope()); - ClassOrNamespace *con = typeOfExpression.context().lookupType(scope); + LookupScope *con = typeOfExpression.context().lookupType(scope); if (!con) con = typeOfExpression.context().globalNamespace(); UseMinimalNames q(con); @@ -5654,7 +5655,7 @@ PointerType *determineConvertedType(NamedType *namedType, const LookupContext &c { if (!namedType) return 0; - if (ClassOrNamespace *binding = context.lookupType(namedType->name(), scope)) { + if (LookupScope *binding = context.lookupType(namedType->name(), scope)) { if (Symbol *objectClassSymbol = skipForwardDeclarations(binding->symbols())) { if (Class *klass = objectClassSymbol->asClass()) { for (auto it = klass->memberBegin(), end = klass->memberEnd(); it != end; ++it) { @@ -5712,7 +5713,7 @@ Class *senderOrReceiverClass(const CppQuickFixInterface &interface, NamedType *objectType = objectTypeBase->asNamedType(); QTC_ASSERT(objectType, return 0); - ClassOrNamespace *objectClassCON = context.lookupType(objectType->name(), objectPointerScope); + LookupScope *objectClassCON = context.lookupType(objectType->name(), objectPointerScope); QTC_ASSERT(objectClassCON, return 0); QTC_ASSERT(!objectClassCON->symbols().isEmpty(), return 0); @@ -5764,7 +5765,7 @@ bool findConnectReplacement(const CppQuickFixInterface &interface, // Minimize qualification Control *control = context.bindings()->control().data(); - ClassOrNamespace *functionCON = context.lookupParent(scope); + LookupScope *functionCON = context.lookupParent(scope); const Name *shortName = LookupContext::minimalName(method, functionCON, control); if (!shortName->asQualifiedNameId()) shortName = control->qualifiedNameId(classOfMethod->name(), shortName); diff --git a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp index 97db446ac89..3a3b20aedad 100644 --- a/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp +++ b/src/plugins/cppeditor/cppvirtualfunctionassistprovider.cpp @@ -152,8 +152,8 @@ public: QTC_ASSERT(m_params.staticClass, return 0); QTC_ASSERT(!m_params.snapshot.isEmpty(), return 0); - Class *functionsClass = m_finder.findMatchingClassDeclaration(m_params.function, - m_params.snapshot); + Class *functionsClass = m_finder.findMatchingClassDeclaration( + m_params.function, m_params.snapshot, &m_params.typeOfExpression->context()); if (!functionsClass) return 0; diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 960ea4cec78..406887e1a7f 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -84,6 +84,10 @@ public: OverrideItem() : line(0) {} OverrideItem(const QString &text, int line = 0) : text(text), line(line) {} bool isValid() { return line != 0; } + QByteArray toByteArray() const + { + return "OverrideItem(" + text.toLatin1() + ", " + QByteArray::number(line) + ')'; + } QString text; int line; @@ -101,11 +105,14 @@ QT_BEGIN_NAMESPACE namespace QTest { template<> char *toString(const OverrideItem &data) { - QByteArray ba = "OverrideItem("; - ba += data.text.toLatin1() + ", " + QByteArray::number(data.line); - ba += ")"; - return qstrdup(ba.data()); + return qstrdup(data.toByteArray().data()); +} } + +QDebug &operator<<(QDebug &d, const OverrideItem &data) +{ + d << data.toByteArray(); + return d; } QT_END_NAMESPACE @@ -1364,7 +1371,7 @@ void CppEditorPlugin::test_FollowSymbolUnderCursor_virtualFunctionCall_data() "template <class T> struct A { virtual void virt() {} };\n" "void f(A<int> *l) { l->$@virt(); }\n") << (OverrideItemList() - << OverrideItem(QLatin1String("A::virt"), 1)); + << OverrideItem(QLatin1String("A<int>::virt"), 1)); /// Check: Static type is nicely resolved, especially for QSharedPointers. QTest::newRow("QSharedPointer") << _( diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp index d7bee2281d0..5ba8864b186 100644 --- a/src/plugins/cpptools/cppchecksymbols.cpp +++ b/src/plugins/cpptools/cppchecksymbols.cpp @@ -673,7 +673,7 @@ bool CheckSymbols::visit(NewExpressionAST *ast) if (highlightCtorDtorAsType) { accept(ast->new_type_id); } else { - ClassOrNamespace *binding = 0; + LookupScope *binding = 0; NameAST *nameAST = 0; if (ast->new_type_id) { for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) { @@ -739,7 +739,7 @@ void CheckSymbols::checkNamespace(NameAST *name) unsigned line, column; getTokenStartPosition(name->firstToken(), &line, &column); - if (ClassOrNamespace *b = _context.lookupType(name->name, enclosingScope())) { + if (LookupScope *b = _context.lookupType(name->name, enclosingScope())) { foreach (Symbol *s, b->symbols()) { if (s->isNamespace()) return; @@ -772,14 +772,14 @@ bool CheckSymbols::hasVirtualDestructor(Class *klass) const return false; } -bool CheckSymbols::hasVirtualDestructor(ClassOrNamespace *binding) const +bool CheckSymbols::hasVirtualDestructor(LookupScope *binding) const { - QSet<ClassOrNamespace *> processed; - QList<ClassOrNamespace *> todo; + QSet<LookupScope *> processed; + QList<LookupScope *> todo; todo.append(binding); while (!todo.isEmpty()) { - ClassOrNamespace *b = todo.takeFirst(); + LookupScope *b = todo.takeFirst(); if (b && !processed.contains(b)) { processed.insert(b); foreach (Symbol *s, b->symbols()) { @@ -861,7 +861,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast) { if (ast->name) { - ClassOrNamespace *binding = checkNestedName(ast); + LookupScope *binding = checkNestedName(ast); if (binding && ast->unqualified_name) { if (ast->unqualified_name->asDestructorName() != 0) { @@ -890,9 +890,9 @@ bool CheckSymbols::visit(QualifiedNameAST *ast) return false; } -ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast) +LookupScope *CheckSymbols::checkNestedName(QualifiedNameAST *ast) { - ClassOrNamespace *binding = 0; + LookupScope *binding = 0; if (ast->name) { if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) { @@ -958,7 +958,7 @@ bool CheckSymbols::visit(MemInitializerAST *ast) { if (FunctionDefinitionAST *enclosingFunction = enclosingFunctionDefinition()) { if (ast->name && enclosingFunction->symbol) { - if (ClassOrNamespace *binding = _context.lookupType(enclosingFunction->symbol)) { + if (LookupScope *binding = _context.lookupType(enclosingFunction->symbol)) { foreach (Symbol *s, binding->symbols()) { if (Class *klass = s->asClass()) { NameAST *nameAST = ast->name; @@ -1161,7 +1161,7 @@ void CheckSymbols::addUse(const Result &use) _usages.append(use); } -void CheckSymbols::addType(ClassOrNamespace *b, NameAST *ast) +void CheckSymbols::addType(LookupScope *b, NameAST *ast) { unsigned startToken; if (!b || !acceptName(ast, &startToken)) diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h index f874c163231..11cde211460 100644 --- a/src/plugins/cpptools/cppchecksymbols.h +++ b/src/plugins/cpptools/cppchecksymbols.h @@ -105,7 +105,7 @@ protected: const QList<Result> &otherUses); bool hasVirtualDestructor(CPlusPlus::Class *klass) const; - bool hasVirtualDestructor(CPlusPlus::ClassOrNamespace *binding) const; + bool hasVirtualDestructor(CPlusPlus::LookupScope *binding) const; bool warning(unsigned line, unsigned column, const QString &text, unsigned length = 0); bool warning(CPlusPlus::AST *ast, const QString &text); @@ -119,13 +119,13 @@ protected: void checkNamespace(CPlusPlus::NameAST *name); void checkName(CPlusPlus::NameAST *ast, CPlusPlus::Scope *scope = 0); - CPlusPlus::ClassOrNamespace *checkNestedName(CPlusPlus::QualifiedNameAST *ast); + CPlusPlus::LookupScope *checkNestedName(CPlusPlus::QualifiedNameAST *ast); void addUse(const Result &use); void addUse(unsigned tokenIndex, Kind kind); void addUse(CPlusPlus::NameAST *name, Kind kind); - void addType(CPlusPlus::ClassOrNamespace *b, CPlusPlus::NameAST *ast); + void addType(CPlusPlus::LookupScope *b, CPlusPlus::NameAST *ast); bool maybeAddTypeOrStatic(const QList<CPlusPlus::LookupItem> &candidates, CPlusPlus::NameAST *ast); diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index a035c6425f6..e9c35198cb5 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -326,16 +326,13 @@ void CppToolsPlugin::test_completion() actualCompletions.sort(); expectedCompletions.sort(); - QEXPECT_FAIL("template_as_base: explicit typedef from base", "QTCREATORBUG-14218", Abort); + QEXPECT_FAIL("template_as_base: typedef not available in derived", + "We can live with that...", Abort); QEXPECT_FAIL("enum_in_function_in_struct_in_function", "QTCREATORBUG-13757", Abort); QEXPECT_FAIL("enum_in_function_in_struct_in_function_cxx11", "QTCREATORBUG-13757", Abort); QEXPECT_FAIL("enum_in_function_in_struct_in_function_anon", "QTCREATORBUG-13757", Abort); QEXPECT_FAIL("enum_in_class_accessed_in_member_func_cxx11", "QTCREATORBUG-13757", Abort); QEXPECT_FAIL("enum_in_class_accessed_in_member_func_inline_cxx11", "QTCREATORBUG-13757", Abort); - QEXPECT_FAIL("pointer_indirect_specialization", "QTCREATORBUG-14141", Abort); - QEXPECT_FAIL("pointer_indirect_specialization_typedef", "QTCREATORBUG-14141", Abort); - QEXPECT_FAIL("pointer_indirect_specialization_double_indirection", "QTCREATORBUG-14141", Abort); - QEXPECT_FAIL("pointer_indirect_specialization_double_indirection_with_base", "QTCREATORBUG-14141", Abort); QCOMPARE(actualCompletions, expectedCompletions); } @@ -2831,6 +2828,28 @@ void CppToolsPlugin::test_completion_data() << QLatin1String("Foo") << QLatin1String("bar")); + QTest::newRow("instantiation_of_indirect_typedef") << _( + "template<typename _Tp>\n" + "struct Indirect { _Tp t; };\n" + "\n" + "template<typename T>\n" + "struct Temp\n" + "{\n" + " typedef T MyT;\n" + " typedef Indirect<MyT> indirect;\n" + "};\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " Temp<Foo>::indirect i;\n" + " @\n" + "}\n" + ) << _("i.t.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar"));; + QTest::newRow("pointer_indirect_specialization_double_indirection_with_base") << _( "template<typename _Tp>\n" "struct Traits { };\n" @@ -2867,6 +2886,104 @@ void CppToolsPlugin::test_completion_data() ) << _("t.p->") << (QStringList() << QLatin1String("Foo") << QLatin1String("bar")); + + QTest::newRow("recursive_instantiation_of_template_type") << _( + "template<typename _Tp>\n" + "struct Temp { typedef _Tp value_type; };\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " Temp<Temp<Foo> >::value_type::value_type *p;\n" + " @\n" + "}\n" + ) << _("p->") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("recursive_instantiation_of_template_type_2") << _( + "template<typename _Tp>\n" + "struct Temp { typedef _Tp value_type; };\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void func()\n" + "{\n" + " Temp<Temp<Foo>::value_type>::value_type *p;\n" + " @\n" + "}\n" + ) << _("p->") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("qualified_name_in_nested_type") << _( + "template<typename _Tp>\n" + "struct Temp {\n" + " struct Nested {\n" + " typedef typename _Tp::Nested2 N;\n" + " };\n" + "};\n" + "\n" + "struct Foo {\n" + " struct Nested2 {\n" + " int bar;\n" + " };\n" + "};\n" + "\n" + "void func()\n" + "{\n" + " Temp<Foo>::Nested::N p;\n" + " @;\n" + "}\n" + ) << _("p.") << (QStringList() + << QLatin1String("Nested2") + << QLatin1String("bar")); + + QTest::newRow("simple_decltype_declaration") << _( + "struct Foo { int bar; };\n" + "Foo foo;\n" + "void fun() {\n" + " decltype(foo) s;\n" + " @\n" + "}\n" + ) << _("s.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("typedefed_decltype_declaration") << _( + "struct Foo { int bar; };\n" + "Foo foo;\n" + "typedef decltype(foo) TypedefedFooWithDecltype;\n" + "void fun() {\n" + " TypedefedFooWithDecltype s;\n" + " @\n" + "}\n" + ) << _("s.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); + + QTest::newRow("nested_instantiation_typedefed_decltype_declaration") << _( + "template <typename T>\n" + "struct Temp\n" + "{\n" + " struct Nested\n" + " {\n" + " static T f();\n" + " typedef decltype(f()) type;\n" + " };\n" + "};\n" + "\n" + "struct Foo { int bar; };\n" + "\n" + "void fun()\n" + "{\n" + " Temp<Foo>::Nested::type s;\n" + " @\n" + "}\n" + ) << _("s.") << (QStringList() + << QLatin1String("Foo") + << QLatin1String("bar")); } void CppToolsPlugin::test_completion_member_access_operator() diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index daa0af12a47..4872448c72c 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -746,8 +746,8 @@ bool canCompleteClassNameAt2ndOr4thConnectArgument( || eater.eatConnectOpenParenthesisExpressionCommaAmpersandExpressionComma(); } -ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem, - const LookupContext &context) +LookupScope *lookupScopeFromLookupItem(const LookupItem &lookupItem, + const LookupContext &context) { const Name *name = 0; @@ -776,7 +776,7 @@ ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem, Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context) { - ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); + LookupScope *b = lookupScopeFromLookupItem(lookupItem, context); if (!b) return 0; @@ -789,7 +789,7 @@ Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &co const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context) { - ClassOrNamespace *target = context.lookupType(targetScope); + LookupScope *target = context.lookupType(targetScope); if (!target) target = context.globalNamespace(); return context.minimalName(symbol, target, context.bindings()->control().data()); @@ -1212,12 +1212,12 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion() ty = ty->asPointerType()->elementType().simplified(); if (NamedType *namedTy = ty->asNamedType()) { - ClassOrNamespace *binding = lookupContext.lookupType(namedTy->name(), item.scope()); + LookupScope *binding = lookupContext.lookupType(namedTy->name(), item.scope()); completeObjCMsgSend(binding, false); } } else { if (ObjCClass *clazz = ty->asObjCClassType()) { - ClassOrNamespace *binding = lookupContext.lookupType(clazz->name(), item.scope()); + LookupScope *binding = lookupContext.lookupType(clazz->name(), item.scope()); completeObjCMsgSend(binding, true); } } @@ -1266,7 +1266,7 @@ void InternalCppCompletionAssistProcessor::addCompletionItem(Symbol *symbol, int } } -void InternalCppCompletionAssistProcessor::completeObjCMsgSend(ClassOrNamespace *binding, +void InternalCppCompletionAssistProcessor::completeObjCMsgSend(LookupScope *binding, bool staticClassAccess) { QList<Scope*> memberScopes; @@ -1535,26 +1535,26 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) return !m_completions.isEmpty(); } - QList<ClassOrNamespace *> usingBindings; - ClassOrNamespace *currentBinding = 0; + QList<LookupScope *> usingBindings; + LookupScope *currentBinding = 0; for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) { if (Block *block = scope->asBlock()) { - if (ClassOrNamespace *binding = context.lookupType(scope)) { + if (LookupScope *binding = context.lookupType(scope)) { for (unsigned i = 0; i < scope->memberCount(); ++i) { Symbol *member = scope->memberAt(i); if (member->isEnum()) { - if (ClassOrNamespace *b = binding->findBlock(block)) + if (LookupScope *b = binding->findBlock(block)) completeNamespace(b); } if (!member->name()) continue; if (UsingNamespaceDirective *u = member->asUsingNamespaceDirective()) { - if (ClassOrNamespace *b = binding->lookupType(u->name())) + if (LookupScope *b = binding->lookupType(u->name())) usingBindings.append(b); } else if (Class *c = member->asClass()) { if (c->name()->isAnonymousNameId()) { - if (ClassOrNamespace *b = binding->findBlock(block)) + if (LookupScope *b = binding->findBlock(block)) completeClass(b); } } @@ -1581,7 +1581,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) } for (; currentBinding; currentBinding = currentBinding->parent()) { - foreach (ClassOrNamespace* u, currentBinding->usings()) + foreach (LookupScope* u, currentBinding->usings()) usingBindings.append(u); const QList<Symbol *> symbols = currentBinding->symbols(); @@ -1594,7 +1594,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope) } } - foreach (ClassOrNamespace *b, usingBindings) + foreach (LookupScope *b, usingBindings) completeNamespace(b); addKeywords(); @@ -1617,7 +1617,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem if (!m_interface->languageFeatures().objCEnabled) replaceDotForArrow = &m_model->m_replaceDotForArrow; - if (ClassOrNamespace *binding = + if (LookupScope *binding = resolveExpression.baseExpression(baseResults, m_model->m_completionOperator, replaceDotForArrow)) { @@ -1641,27 +1641,27 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem> Scope *scope = result.scope(); if (NamedType *namedTy = ty->asNamedType()) { - if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) { + if (LookupScope *b = context.lookupType(namedTy->name(), scope)) { completeClass(b); break; } } else if (Class *classTy = ty->asClassType()) { - if (ClassOrNamespace *b = context.lookupType(classTy)) { + if (LookupScope *b = context.lookupType(classTy)) { completeClass(b); break; } // it can be class defined inside a block if (classTy->enclosingScope()->isBlock()) { - if (ClassOrNamespace *b = context.lookupType(classTy->name(), classTy->enclosingScope())) { + if (LookupScope *b = context.lookupType(classTy->name(), classTy->enclosingScope())) { completeClass(b); break; } } } else if (Namespace *nsTy = ty->asNamespaceType()) { - if (ClassOrNamespace *b = context.lookupType(nsTy)) { + if (LookupScope *b = context.lookupType(nsTy)) { completeNamespace(b); break; } @@ -1669,7 +1669,7 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem> } else if (Template *templ = ty->asTemplateType()) { if (!result.binding()) continue; - if (ClassOrNamespace *b = result.binding()->lookupType(templ->name())) { + if (LookupScope *b = result.binding()->lookupType(templ->name())) { completeClass(b); break; } @@ -1677,16 +1677,16 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem> } else if (Enum *e = ty->asEnumType()) { // it can be class defined inside a block if (e->enclosingScope()->isBlock()) { - if (ClassOrNamespace *b = context.lookupType(e)) { + if (LookupScope *b = context.lookupType(e)) { Block *block = e->enclosingScope()->asBlock(); - if (ClassOrNamespace *bb = b->findBlock(block)) { + if (LookupScope *bb = b->findBlock(block)) { completeNamespace(bb); break; } } } - if (ClassOrNamespace *b = context.lookupType(e)) { + if (LookupScope *b = context.lookupType(e)) { completeNamespace(b); break; } @@ -1697,14 +1697,14 @@ bool InternalCppCompletionAssistProcessor::completeScope(const QList<LookupItem> return !m_completions.isEmpty(); } -void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b) +void InternalCppCompletionAssistProcessor::completeNamespace(LookupScope *b) { - QSet<ClassOrNamespace *> bindingsVisited; - QList<ClassOrNamespace *> bindingsToVisit; + QSet<LookupScope *> bindingsVisited; + QList<LookupScope *> bindingsToVisit; bindingsToVisit.append(b); while (!bindingsToVisit.isEmpty()) { - ClassOrNamespace *binding = bindingsToVisit.takeFirst(); + LookupScope *binding = bindingsToVisit.takeFirst(); if (!binding || bindingsVisited.contains(binding)) continue; @@ -1737,14 +1737,14 @@ void InternalCppCompletionAssistProcessor::completeNamespace(ClassOrNamespace *b } } -void InternalCppCompletionAssistProcessor::completeClass(ClassOrNamespace *b, bool staticLookup) +void InternalCppCompletionAssistProcessor::completeClass(LookupScope *b, bool staticLookup) { - QSet<ClassOrNamespace *> bindingsVisited; - QList<ClassOrNamespace *> bindingsToVisit; + QSet<LookupScope *> bindingsVisited; + QList<LookupScope *> bindingsToVisit; bindingsToVisit.append(b); while (!bindingsToVisit.isEmpty()) { - ClassOrNamespace *binding = bindingsToVisit.takeFirst(); + LookupScope *binding = bindingsToVisit.takeFirst(); if (!binding || bindingsVisited.contains(binding)) continue; @@ -1831,16 +1831,16 @@ bool InternalCppCompletionAssistProcessor::completeQtMethod(const QList<LookupIt QSet<QString> signatures; foreach (const LookupItem &lookupItem, results) { - ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context); + LookupScope *b = lookupScopeFromLookupItem(lookupItem, context); if (!b) continue; - QList<ClassOrNamespace *>todo; - QSet<ClassOrNamespace *> processed; + QList<LookupScope *>todo; + QSet<LookupScope *> processed; QList<Scope *> scopes; todo.append(b); while (!todo.isEmpty()) { - ClassOrNamespace *binding = todo.takeLast(); + LookupScope *binding = todo.takeLast(); if (!processed.contains(binding)) { processed.insert(binding); @@ -1913,7 +1913,8 @@ bool InternalCppCompletionAssistProcessor::completeQtMethodClassName( foreach (const LookupItem &lookupItem, results) { Class *klass = classFromLookupItem(lookupItem, context); - QTC_ASSERT(klass, continue); + if (!klass) + continue; const Name *name = minimalName(klass, cursorScope, context); QTC_ASSERT(name, continue); @@ -2055,7 +2056,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q Scope *scope = result.scope(); if (NamedType *namedTy = ty->asNamedType()) { - if (ClassOrNamespace *b = context.lookupType(namedTy->name(), scope)) { + if (LookupScope *b = context.lookupType(namedTy->name(), scope)) { foreach (const LookupItem &r, b->lookup(functionCallOp)) { Symbol *overload = r.declaration(); FullySpecifiedType overloadTy = overload->type().simplified(); @@ -2137,7 +2138,7 @@ bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const Q SubstitutionEnvironment env; env.setContext(context); env.switchScope(sc); - ClassOrNamespace *targetCoN = context.lookupType(sc); + LookupScope *targetCoN = context.lookupType(sc); if (!targetCoN) targetCoN = context.globalNamespace(); UseMinimalNames q(targetCoN); diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 585d66eb0cf..beea43dc23f 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -52,7 +52,7 @@ namespace CPlusPlus { class LookupItem; -class ClassOrNamespace; +class LookupScope; class Function; class LookupContext; } // namespace CPlusPlus @@ -120,7 +120,7 @@ private: const QString &expression, int endOfExpression); - void completeObjCMsgSend(CPlusPlus::ClassOrNamespace *binding, bool staticClassAccess); + void completeObjCMsgSend(CPlusPlus::LookupScope *binding, bool staticClassAccess); bool completeInclude(const QTextCursor &cursor); void completeInclude(const QString &realPath, const QStringList &suffixes); void completePreprocessor(); @@ -129,8 +129,8 @@ private: bool toolTipOnly); bool completeMember(const QList<CPlusPlus::LookupItem> &results); bool completeScope(const QList<CPlusPlus::LookupItem> &results); - void completeNamespace(CPlusPlus::ClassOrNamespace *binding); - void completeClass(CPlusPlus::ClassOrNamespace *b, bool staticLookup = true); + void completeNamespace(CPlusPlus::LookupScope *binding); + void completeClass(CPlusPlus::LookupScope *b, bool staticLookup = true); void addClassMembersToCompletion(CPlusPlus::Scope *scope, bool staticLookup); enum CompleteQtMethodMode { CompleteQt4Signals, diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index af5680b42d7..960de9f5970 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -278,7 +278,7 @@ CppFileSettingsWidget::CppFileSettingsWidget(QWidget *parent) : } m_ui->licenseTemplatePathChooser->setExpectedKind(Utils::PathChooser::File); m_ui->licenseTemplatePathChooser->setHistoryCompleter(QLatin1String("Cpp.LicenseTemplate.History")); - m_ui->licenseTemplatePathChooser->addButton(tr("Edit..."), this, SLOT(slotEdit())); + m_ui->licenseTemplatePathChooser->addButton(tr("Edit..."), this, [this] { slotEdit(); }); } CppFileSettingsWidget::~CppFileSettingsWidget() diff --git a/src/plugins/cpptools/cppfilesettingspage.h b/src/plugins/cpptools/cppfilesettingspage.h index a2920a71f9a..84ad6529a92 100644 --- a/src/plugins/cpptools/cppfilesettingspage.h +++ b/src/plugins/cpptools/cppfilesettingspage.h @@ -83,12 +83,10 @@ public: CppFileSettings settings() const; void setSettings(const CppFileSettings &s); -private slots: - void slotEdit(); - private: - inline QString licenseTemplatePath() const; - inline void setLicenseTemplatePath(const QString &); + void slotEdit(); + QString licenseTemplatePath() const; + void setLicenseTemplatePath(const QString &); Ui::CppFileSettingsPage *m_ui; }; diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp index 27c540fae92..3f948bb5808 100644 --- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp +++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp @@ -108,7 +108,8 @@ public: QVERIFY(ast); // Open file - TextEditor::BaseTextEditor *editor = TextEditor::PlainTextEditorFactory::createPlainTextEditor(); + QScopedPointer<TextEditor::BaseTextEditor> editor( + TextEditor::PlainTextEditorFactory::createPlainTextEditor()); QString error; editor->open(&error, document->fileName(), document->fileName()); QVERIFY(error.isEmpty()); diff --git a/src/plugins/cpptools/cpptools.qbs b/src/plugins/cpptools/cpptools.qbs index 72b68b9a9a1..f5ffb85f46e 100644 --- a/src/plugins/cpptools/cpptools.qbs +++ b/src/plugins/cpptools/cpptools.qbs @@ -5,7 +5,6 @@ QtcPlugin { name: "CppTools" Depends { name: "Qt.widgets" } - Depends { name: "Aggregation" } Depends { name: "CPlusPlus" } Depends { name: "Utils" } diff --git a/src/plugins/cpptools/cpptools_dependencies.pri b/src/plugins/cpptools/cpptools_dependencies.pri index 27d0f90d681..9ff54010ad7 100644 --- a/src/plugins/cpptools/cpptools_dependencies.pri +++ b/src/plugins/cpptools/cpptools_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = CppTools QTC_LIB_DEPENDS += \ - aggregation \ cplusplus \ extensionsystem \ utils diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp index 7814553339c..05e5f868309 100644 --- a/src/plugins/cpptools/cpptoolsreuse.cpp +++ b/src/plugins/cpptools/cpptoolsreuse.cpp @@ -105,7 +105,7 @@ bool isOwnershipRAIIType(Symbol *symbol, const LookupContext &context) Declaration *declaration = symbol->asDeclaration(); const NamedType *namedType = declaration->type()->asNamedType(); if (namedType) { - ClassOrNamespace *clazz = context.lookupType(namedType->name(), + LookupScope *clazz = context.lookupType(namedType->name(), declaration->enclosingScope()); if (clazz && !clazz->symbols().isEmpty()) { Overview overview; diff --git a/src/plugins/cpptools/symbolfinder.cpp b/src/plugins/cpptools/symbolfinder.cpp index d307a0c07df..26df91bc049 100644 --- a/src/plugins/cpptools/symbolfinder.cpp +++ b/src/plugins/cpptools/symbolfinder.cpp @@ -149,7 +149,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration, QList<Function *> viableFunctions; - ClassOrNamespace *enclosingType = context.lookupType(declaration); + LookupScope *enclosingType = context.lookupType(declaration); if (!enclosingType) continue; // nothing to do @@ -212,13 +212,15 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration, return 0; } -Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot) +Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot, + const LookupContext *context) { if (!declaration->identifier()) return 0; QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength()); + const bool useLocalContext = !context; foreach (const QString &file, fileIterationOrder(declFile, snapshot)) { Document::Ptr doc = snapshot.document(file); if (!doc) { @@ -230,9 +232,13 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna declaration->identifier()->size())) continue; - LookupContext context(doc, snapshot); + QScopedPointer<LookupContext> localContext; + if (useLocalContext) { + localContext.reset(new LookupContext(doc, snapshot)); + context = localContext.data(); + } - ClassOrNamespace *type = context.lookupType(declaration); + LookupScope *type = context->lookupType(declaration); if (!type) continue; @@ -281,7 +287,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context, if (!functionName) return; - ClassOrNamespace *binding = 0; + LookupScope *binding = 0; const QualifiedNameId *qName = functionName->asQualifiedNameId(); if (qName) { if (qName->base()) diff --git a/src/plugins/cpptools/symbolfinder.h b/src/plugins/cpptools/symbolfinder.h index e9c301aaf22..a71d9ed4d22 100644 --- a/src/plugins/cpptools/symbolfinder.h +++ b/src/plugins/cpptools/symbolfinder.h @@ -59,7 +59,8 @@ public: bool strict = false); CPlusPlus::Class *findMatchingClassDeclaration(CPlusPlus::Symbol *declaration, - const CPlusPlus::Snapshot &snapshot); + const CPlusPlus::Snapshot &snapshot, + const CPlusPlus::LookupContext *context = 0); void findMatchingDeclaration(const CPlusPlus::LookupContext &context, CPlusPlus::Function *functionType, diff --git a/src/plugins/cvs/checkoutwizard.cpp b/src/plugins/cvs/checkoutwizard.cpp deleted file mode 100644 index 65573926bb9..00000000000 --- a/src/plugins/cvs/checkoutwizard.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "checkoutwizard.h" -#include "checkoutwizardpage.h" -#include "cvsplugin.h" - -#include <coreplugin/iversioncontrol.h> -#include <vcsbase/vcscommand.h> -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> -#include <utils/qtcassert.h> - -using namespace VcsBase; - -namespace Cvs { -namespace Internal { - -// -------------------------------------------------------------------- -// CheckoutWizard: -// -------------------------------------------------------------------- - -CheckoutWizard::CheckoutWizard(const Utils::FileName &path, QWidget *parent) : - BaseCheckoutWizard(path, parent) -{ - const Core::IVersionControl *vc = CvsPlugin::instance()->versionControl(); - if (!vc->isConfigured()) { - auto configPage = new VcsConfigurationPage; - configPage->setVersionControl(vc); - addPage(configPage); - } - auto cwp = new CheckoutWizardPage; - cwp->setPath(path.toString()); - addPage(cwp); -} - -VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir) -{ - // Collect parameters for the checkout command. - // CVS does not allow for checking out into a different directory. - const CheckoutWizardPage *cwp = 0; - foreach (int pageId, pageIds()) { - if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId)))) - break; - } - - QTC_ASSERT(cwp, return 0); - const CvsSettings settings = CvsPlugin::instance()->settings(); - const Utils::FileName binary = settings.binaryPath(); - QStringList args; - - const QString repository = cwp->repository(); - args << QLatin1String("checkout") << repository; - const QString workingDirectory = cwp->path(); - *checkoutDir = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + repository); - - auto command = new VcsCommand(binary, workingDirectory, - QProcessEnvironment::systemEnvironment()); - command->addJob(settings.addOptions(args), -1); - return command; -} - -} // namespace Internal -} // namespace Cvs diff --git a/src/plugins/cvs/cvs.pro b/src/plugins/cvs/cvs.pro index be1d4af402d..aff49e95cae 100644 --- a/src/plugins/cvs/cvs.pro +++ b/src/plugins/cvs/cvs.pro @@ -9,9 +9,7 @@ HEADERS += annotationhighlighter.h \ cvssubmiteditor.h \ cvssettings.h \ cvsutils.h \ - cvsconstants.h \ - checkoutwizard.h \ - checkoutwizardpage.h + cvsconstants.h SOURCES += annotationhighlighter.cpp \ cvsplugin.cpp \ @@ -21,9 +19,7 @@ SOURCES += annotationhighlighter.cpp \ cvseditor.cpp \ cvssubmiteditor.cpp \ cvssettings.cpp \ - cvsutils.cpp \ - checkoutwizard.cpp \ - checkoutwizardpage.cpp + cvsutils.cpp FORMS += settingspage.ui diff --git a/src/plugins/cvs/cvs.qbs b/src/plugins/cvs/cvs.qbs index e07f71f55ae..040b86debe5 100644 --- a/src/plugins/cvs/cvs.qbs +++ b/src/plugins/cvs/cvs.qbs @@ -13,10 +13,6 @@ QtcPlugin { files: [ "annotationhighlighter.cpp", "annotationhighlighter.h", - "checkoutwizard.cpp", - "checkoutwizard.h", - "checkoutwizardpage.cpp", - "checkoutwizardpage.h", "cvs.qrc", "cvsclient.cpp", "cvsclient.h", diff --git a/src/plugins/cvs/cvs.qrc b/src/plugins/cvs/cvs.qrc index 7278fc2db87..8d80a8c248d 100644 --- a/src/plugins/cvs/cvs.qrc +++ b/src/plugins/cvs/cvs.qrc @@ -2,7 +2,4 @@ <qresource prefix="/trolltech.cvs"> <file>CVS.mimetypes.xml</file> </qresource> - <qresource prefix="/cvs"> - <file>images/cvs.png</file> - </qresource> </RCC> diff --git a/src/plugins/cvs/cvsclient.cpp b/src/plugins/cvs/cvsclient.cpp index d41c7c4467a..359eb39a727 100644 --- a/src/plugins/cvs/cvsclient.cpp +++ b/src/plugins/cvs/cvsclient.cpp @@ -70,40 +70,41 @@ class CvsDiffParameterWidget : public VcsBaseEditorParameterWidget { Q_OBJECT public: - explicit CvsDiffParameterWidget(CvsSettings *settings, QWidget *parent = 0); + explicit CvsDiffParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0); QStringList arguments() const; private: - const CvsSettings *m_settings; + VcsBaseClientSettings &m_settings; }; -CvsDiffParameterWidget::CvsDiffParameterWidget(CvsSettings *settings, QWidget *parent) - : VcsBaseEditorParameterWidget(parent), - m_settings(settings) +CvsDiffParameterWidget::CvsDiffParameterWidget(VcsBaseClientSettings &settings, + QWidget *parent) : + VcsBaseEditorParameterWidget(parent), + m_settings(settings) { mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")), - settings->boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey)); + settings.boolPointer(CvsSettings::diffIgnoreWhiteSpaceKey)); mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")), - settings->boolPointer(CvsSettings::diffIgnoreBlankLinesKey)); + settings.boolPointer(CvsSettings::diffIgnoreBlankLinesKey)); } QStringList CvsDiffParameterWidget::arguments() const { QStringList args; - args = m_settings->stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), QString::SkipEmptyParts); + args = m_settings.stringValue(CvsSettings::diffOptionsKey).split(QLatin1Char(' '), + QString::SkipEmptyParts); args += VcsBaseEditorParameterWidget::arguments(); return args; } -CvsClient::CvsClient(CvsSettings *settings) : - VcsBaseClient(settings) +CvsClient::CvsClient() : VcsBaseClient(new CvsSettings) { - setDiffParameterWidgetCreator([=] { return new CvsDiffParameterWidget(settings); }); + setDiffParameterWidgetCreator([this] { return new CvsDiffParameterWidget(settings()); }); } -CvsSettings *CvsClient::settings() const +CvsSettings &CvsClient::settings() const { - return dynamic_cast<CvsSettings *>(VcsBaseClient::settings()); + return static_cast<CvsSettings &>(VcsBaseClient::settings()); } Core::Id CvsClient::vcsEditorKind(VcsCommandTag cmd) const diff --git a/src/plugins/cvs/cvsclient.h b/src/plugins/cvs/cvsclient.h index 1b3058e95a9..445c4fa6f96 100644 --- a/src/plugins/cvs/cvsclient.h +++ b/src/plugins/cvs/cvsclient.h @@ -44,9 +44,9 @@ class CvsClient : public VcsBase::VcsBaseClient Q_OBJECT public: - CvsClient(CvsSettings *settings); + CvsClient(); - CvsSettings *settings() const; + CvsSettings &settings() const; void diff(const QString &workingDir, const QStringList &files, const QStringList &extraOptions = QStringList()); QString findTopLevelForFile(const QFileInfo &file) const; diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp index ff274a1390c..8c7b6b713be 100644 --- a/src/plugins/cvs/cvscontrol.cpp +++ b/src/plugins/cvs/cvscontrol.cpp @@ -29,12 +29,16 @@ ****************************************************************************/ #include "cvscontrol.h" + +#include "cvsclient.h" #include "cvsplugin.h" #include "cvssettings.h" #include <vcsbase/vcsbaseconstants.h> +#include <vcsbase/vcscommand.h> #include <utils/fileutils.h> +#include <utils/qtcassert.h> #include <QFileInfo> @@ -58,7 +62,7 @@ Core::Id CvsControl::id() const bool CvsControl::isConfigured() const { - const Utils::FileName binary = m_plugin->settings().binaryPath(); + const Utils::FileName binary = m_plugin->client()->vcsBinary(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -72,6 +76,7 @@ bool CvsControl::supportsOperation(Operation operation) const case AddOperation: case DeleteOperation: case AnnotateOperation: + case InitialCheckoutOperation: break; case MoveOperation: case CreateRepositoryOperation: @@ -130,6 +135,25 @@ QString CvsControl::vcsOpenText() const return tr("&Edit"); } +Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + QTC_ASSERT(localName == url, return 0); + + const CvsSettings settings = CvsPlugin::instance()->client()->settings(); + + QStringList args; + args << QLatin1String("checkout") << url << extraArgs; + + auto command = new VcsBase::VcsCommand(baseDirectory.toString(), + QProcessEnvironment::systemEnvironment()); + command->setDisplayName(tr("cvs checkout")); + command->addJob(m_plugin->client()->vcsBinary(), settings.addOptions(args), -1); + return command; +} + bool CvsControl::managesDirectory(const QString &directory, QString *topLevel) const { return m_plugin->managesDirectory(directory, topLevel); @@ -149,8 +173,3 @@ void CvsControl::emitFilesChanged(const QStringList &l) { emit filesChanged(l); } - -void CvsControl::emitConfigurationChanged() -{ - emit configurationChanged(); -} diff --git a/src/plugins/cvs/cvscontrol.h b/src/plugins/cvs/cvscontrol.h index c1bedee0f35..ec18756877a 100644 --- a/src/plugins/cvs/cvscontrol.h +++ b/src/plugins/cvs/cvscontrol.h @@ -45,27 +45,31 @@ class CvsControl : public Core::IVersionControl public: explicit CvsControl(CvsPlugin *plugin); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; + bool managesDirectory(const QString &directory, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - OpenSupportMode openSupportMode(const QString &fileName) const; - bool vcsOpen(const QString &fileName); - bool vcsAdd(const QString &fileName); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); - bool vcsAnnotate(const QString &file, int line); + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + OpenSupportMode openSupportMode(const QString &fileName) const override; + bool vcsOpen(const QString &fileName) override; + bool vcsAdd(const QString &fileName) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; + bool vcsAnnotate(const QString &file, int line) override; - QString vcsOpenText() const; + QString vcsOpenText() const override; + + Core::ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) override; void emitRepositoryChanged(const QString &s); void emitFilesChanged(const QStringList &l); - void emitConfigurationChanged(); private: CvsPlugin *m_plugin; diff --git a/src/plugins/cvs/cvseditor.cpp b/src/plugins/cvs/cvseditor.cpp index b7ba81a79a0..2f532f4c38c 100644 --- a/src/plugins/cvs/cvseditor.cpp +++ b/src/plugins/cvs/cvseditor.cpp @@ -35,7 +35,7 @@ #include "cvsconstants.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QTextCursor> diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index ad2b1e38a6f..74a004ea64f 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -35,14 +35,14 @@ #include "cvsclient.h" #include "cvsconstants.h" #include "cvscontrol.h" -#include "checkoutwizard.h" #include <vcsbase/basevcseditorfactory.h> +#include <vcsbase/basevcssubmiteditorfactory.h> #include <vcsbase/vcsbaseconstants.h> #include <vcsbase/vcsbaseeditor.h> -#include <vcsbase/basevcssubmiteditorfactory.h> -#include <vcsbase/vcsoutputwindow.h> #include <vcsbase/vcsbaseeditorparameterwidget.h> +#include <vcsbase/vcscommand.h> +#include <vcsbase/vcsoutputwindow.h> #include <texteditor/textdocument.h> @@ -90,13 +90,13 @@ namespace Internal { static inline QString msgCannotFindTopLevel(const QString &f) { - return CvsPlugin::tr("Cannot find repository for \"%1\""). + return CvsPlugin::tr("Cannot find repository for \"%1\"."). arg(QDir::toNativeSeparators(f)); } static inline QString msgLogParsingFailed() { - return CvsPlugin::tr("Parsing of the log output failed"); + return CvsPlugin::tr("Parsing of the log output failed."); } const char CVS_CONTEXT[] = "CVS Context"; @@ -211,6 +211,12 @@ CvsPlugin::~CvsPlugin() cleanCommitMessageFile(); } +CvsClient *CvsPlugin::client() const +{ + QTC_CHECK(m_client); + return m_client; +} + void CvsPlugin::cleanCommitMessageFile() { if (!m_commitMessageFileName.isEmpty()) { @@ -246,10 +252,9 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) Utils::MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.cvs/CVS.mimetypes.xml")); - m_settings.readSettings(ICore::settings()); - m_client = new CvsClient(&m_settings); + m_client = new CvsClient; - addAutoReleasedObject(new SettingsPage); + addAutoReleasedObject(new SettingsPage(versionControl())); addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new CvsSubmitEditor(&submitParameters); })); @@ -260,16 +265,6 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) for (int i = 0; i < editorCount; i++) addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlotC)); - auto checkoutWizardFactory = new BaseCheckoutWizardFactory; - checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_CVS)); - checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/cvs/images/cvs.png"))); - checkoutWizardFactory->setDescription(tr("Checks out a CVS repository and tries to load the contained project.")); - checkoutWizardFactory->setDisplayName(tr("CVS Checkout")); - checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CheckoutWizard(path, parent); - }); - addAutoReleasedObject(checkoutWizardFactory); - const QString prefix = QLatin1String("cvs"); m_commandLocator = new CommandLocator("CVS", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -503,12 +498,11 @@ bool CvsPlugin::submitEditorAboutToClose() // Prompt user. Force a prompt unless submit was actually invoked (that // is, the editor was closed or shutdown). - CvsSettings newSettings = m_settings; const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit(tr("Closing CVS Editor"), tr("Do you want to commit the change?"), tr("The commit message check failed. Do you want to commit the change?"), - newSettings.boolPointer(CvsSettings::promptOnSubmitKey), + client()->settings().boolPointer(CvsSettings::promptOnSubmitKey), !m_submitActionTriggered); m_submitActionTriggered = false; switch (answer) { @@ -520,7 +514,6 @@ bool CvsPlugin::submitEditorAboutToClose() default: break; } - setSettings(newSettings); // in case someone turned prompting off const QStringList fileList = editor->checkedFiles(); bool closeEditor = true; if (!fileList.empty()) { @@ -611,14 +604,14 @@ void CvsPlugin::revertAll() { const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); - const QString title = tr("Revert repository"); + const QString title = tr("Revert Repository"); if (!messageBoxQuestion(title, tr("Revert all pending changes to the repository?"))) return; QStringList args; args << QLatin1String("update") << QLatin1String("-C") << state.topLevel(); const CvsResponse revertResponse = - runCvs(state.topLevel(), args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(state.topLevel(), args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.result == CvsResponse::Ok) cvsVersionControl()->emitRepositoryChanged(state.topLevel()); else @@ -633,7 +626,7 @@ void CvsPlugin::revertCurrentFile() QStringList args; args << QLatin1String("diff") << state.relativeCurrentFile(); const CvsResponse diffResponse = - runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(), 0); + runCvs(state.currentFileTopLevel(), args, client()->vcsTimeoutS(), 0); switch (diffResponse.result) { case CvsResponse::Ok: return; // Not modified, diff exit code 0 @@ -655,8 +648,8 @@ void CvsPlugin::revertCurrentFile() args.clear(); args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile(); const CvsResponse revertResponse = - runCvs(state.currentFileTopLevel(), args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(state.currentFileTopLevel(), args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.result == CvsResponse::Ok) cvsVersionControl()->emitFilesChanged(QStringList(state.currentFile())); } @@ -717,7 +710,7 @@ void CvsPlugin::startCommit(const QString &workingDir, const QString &file) // where we are, so, have stdout/stderr channels merged. QStringList args = QStringList(QLatin1String("status")); const CvsResponse response = - runCvs(workingDir, args, m_settings.timeOutMs(), MergeOutputChannels); + runCvs(workingDir, args, client()->vcsTimeoutS(), VcsCommand::MergeOutputChannels); if (response.result != CvsResponse::Ok) return; // Get list of added/modified/deleted files and purge out undesired ones @@ -765,8 +758,8 @@ bool CvsPlugin::commit(const QString &messageFile, args << QLatin1String("-F") << messageFile; args.append(fileList); const CvsResponse response = - runCvs(m_commitRepository, args, 10 * m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(m_commitRepository, args, 10 * client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok ; } @@ -803,8 +796,8 @@ void CvsPlugin::filelog(const QString &workingDir, args << QLatin1String("log"); args.append(file); const CvsResponse response = - runCvs(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt, codec); + runCvs(workingDir, args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt, codec); if (response.result != CvsResponse::Ok) return; @@ -844,8 +837,8 @@ bool CvsPlugin::update(const QString &topLevel, const QString &file) if (!file.isEmpty()) args.append(file); const CvsResponse response = - runCvs(topLevel, args, 10 * m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(topLevel, args, 10 * client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); const bool ok = response.result == CvsResponse::Ok; if (ok) cvsVersionControl()->emitRepositoryChanged(topLevel); @@ -891,8 +884,8 @@ bool CvsPlugin::edit(const QString &topLevel, const QStringList &files) QStringList args(QLatin1String("edit")); args.append(files); const CvsResponse response = - runCvs(topLevel, args, m_settings.timeOutMs(), - ShowStdOutInLogWindow|SshPasswordPrompt); + runCvs(topLevel, args, client()->vcsTimeoutS(), + VcsCommand::ShowStdOut | VcsCommand::SshPasswordPrompt); return response.result == CvsResponse::Ok; } @@ -903,7 +896,7 @@ bool CvsPlugin::diffCheckModified(const QString &topLevel, const QStringList &fi QStringList args(QLatin1String("-q")); args << QLatin1String("diff"); args.append(files); - const CvsResponse response = runCvs(topLevel, args, m_settings.timeOutMs(), 0); + const CvsResponse response = runCvs(topLevel, args, client()->vcsTimeoutS(), 0); if (response.result == CvsResponse::OtherError) return false; *modified = response.result == CvsResponse::NonNullExitCode; @@ -931,8 +924,8 @@ bool CvsPlugin::unedit(const QString &topLevel, const QStringList &files) args.append(QLatin1String("-y")); args.append(files); const CvsResponse response = - runCvs(topLevel, args, m_settings.timeOutMs(), - ShowStdOutInLogWindow|SshPasswordPrompt); + runCvs(topLevel, args, client()->vcsTimeoutS(), + VcsCommand::ShowStdOut | VcsCommand::SshPasswordPrompt); return response.result == CvsResponse::Ok; } @@ -950,8 +943,8 @@ void CvsPlugin::annotate(const QString &workingDir, const QString &file, args << QLatin1String("-r") << revision; args << file; const CvsResponse response = - runCvs(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt, codec); + runCvs(workingDir, args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt, codec); if (response.result != CvsResponse::Ok) return; @@ -979,7 +972,7 @@ bool CvsPlugin::status(const QString &topLevel, const QString &file, const QStri if (!file.isEmpty()) args.append(file); const CvsResponse response = - runCvs(topLevel, args, m_settings.timeOutMs(), 0); + runCvs(topLevel, args, client()->vcsTimeoutS(), 0); const bool ok = response.result == CvsResponse::Ok; if (ok) showOutputInEditor(title, response.stdOut, OtherContent, topLevel, 0); @@ -1062,7 +1055,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const QStringList args; args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file; const CvsResponse logResponse = - runCvs(toplevel, args, m_settings.timeOutMs(), SshPasswordPrompt); + runCvs(toplevel, args, client()->vcsTimeoutS(), VcsCommand::SshPasswordPrompt); if (logResponse.result != CvsResponse::Ok) { *errorMessage = logResponse.message; return false; @@ -1072,7 +1065,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const *errorMessage = msgLogParsingFailed(); return false; } - if (m_settings.boolValue(CvsSettings::describeByCommitIdKey)) { + if (client()->settings().boolValue(CvsSettings::describeByCommitIdKey)) { // Run a log command over the repo, filtering by the commit date // and commit id, collecting all files touched by the commit. const QString commitId = fileLog.front().revisions.front().commitId; @@ -1084,7 +1077,7 @@ bool CvsPlugin::describe(const QString &toplevel, const QString &file, const args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS); const CvsResponse repoLogResponse = - runCvs(toplevel, args, 10 * m_settings.timeOutMs(), SshPasswordPrompt); + runCvs(toplevel, args, 10 * client()->vcsTimeoutS(), VcsCommand::SshPasswordPrompt); if (repoLogResponse.result != CvsResponse::Ok) { *errorMessage = repoLogResponse.message; return false; @@ -1121,7 +1114,7 @@ bool CvsPlugin::describe(const QString &repositoryPath, QStringList args(QLatin1String("log")); args << (QLatin1String("-r") + it->revisions.front().revision) << it->file; const CvsResponse logResponse = - runCvs(repositoryPath, args, m_settings.timeOutMs(), SshPasswordPrompt); + runCvs(repositoryPath, args, client()->vcsTimeoutS(), VcsCommand::SshPasswordPrompt); if (logResponse.result != CvsResponse::Ok) { *errorMessage = logResponse.message; return false; @@ -1134,11 +1127,11 @@ bool CvsPlugin::describe(const QString &repositoryPath, if (!isFirstRevision(revision)) { const QString previousRev = previousRevision(revision); QStringList args(QLatin1String("diff")); - args << m_settings.stringValue(CvsSettings::diffOptionsKey) << QLatin1String("-r") << previousRev - << QLatin1String("-r") << it->revisions.front().revision - << it->file; + args << client()->settings().stringValue(CvsSettings::diffOptionsKey) + << QLatin1String("-r") << previousRev << QLatin1String("-r") + << it->revisions.front().revision << it->file; const CvsResponse diffResponse = - runCvs(repositoryPath, args, m_settings.timeOutMs(), 0, codec); + runCvs(repositoryPath, args, client()->vcsTimeoutS(), 0, codec); switch (diffResponse.result) { case CvsResponse::Ok: case CvsResponse::NonNullExitCode: // Diff exit code != 0 @@ -1182,21 +1175,21 @@ void CvsPlugin::submitCurrentLog() // the working directory (see above). CvsResponse CvsPlugin::runCvs(const QString &workingDirectory, const QStringList &arguments, - int timeOut, + int timeOutS, unsigned flags, QTextCodec *outputCodec) const { - const FileName executable = m_settings.binaryPath(); + const FileName executable = client()->vcsBinary(); CvsResponse response; if (executable.isEmpty()) { response.result = CvsResponse::OtherError; - response.message =tr("No cvs executable specified."); + response.message =tr("No CVS executable specified."); return response; } // Run, connect stderr to the output window const SynchronousProcessResponse sp_resp = - runVcs(workingDirectory, executable, m_settings.addOptions(arguments), - timeOut, flags, outputCodec); + runVcs(workingDirectory, executable, client()->settings().addOptions(arguments), + timeOutS, flags, outputCodec); response.result = CvsResponse::OtherError; response.stdErr = sp_resp.stdErr; @@ -1215,7 +1208,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory, } if (response.result != CvsResponse::Ok) - response.message = sp_resp.exitMessage(executable.toString(), timeOut); + response.message = sp_resp.exitMessage(executable.toString(), timeOutS); return response; } @@ -1247,20 +1240,6 @@ IEditor *CvsPlugin::showOutputInEditor(const QString& title, const QString &outp return editor; } -CvsSettings CvsPlugin::settings() const -{ - return m_settings; -} - -void CvsPlugin::setSettings(const CvsSettings &s) -{ - if (s != m_settings) { - m_settings = s; - m_settings.writeSettings(ICore::settings()); - cvsVersionControl()->emitConfigurationChanged(); - } -} - CvsPlugin *CvsPlugin::instance() { QTC_ASSERT(m_cvsPluginInstance, return m_cvsPluginInstance); @@ -1272,8 +1251,8 @@ bool CvsPlugin::vcsAdd(const QString &workingDir, const QString &rawFileName) QStringList args; args << QLatin1String("add") << rawFileName; const CvsResponse response = - runCvs(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(workingDir, args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok; } @@ -1282,8 +1261,8 @@ bool CvsPlugin::vcsDelete(const QString &workingDir, const QString &rawFileName) QStringList args; args << QLatin1String("remove") << QLatin1String("-f") << rawFileName; const CvsResponse response = - runCvs(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + runCvs(workingDir, args, client()->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return response.result == CvsResponse::Ok; } @@ -1328,7 +1307,7 @@ bool CvsPlugin::managesFile(const QString &workingDirectory, const QString &file QStringList args; args << QLatin1String("status") << fileName; const CvsResponse response = - runCvs(workingDirectory, args, m_settings.timeOutMs(), SshPasswordPrompt); + runCvs(workingDirectory, args, client()->vcsTimeoutS(), VcsCommand::SshPasswordPrompt); if (response.result != CvsResponse::Ok) return false; return !response.stdOut.contains(QLatin1String("Status: Unknown")); diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h index 2e9f61fb08c..47458336725 100644 --- a/src/plugins/cvs/cvsplugin.h +++ b/src/plugins/cvs/cvsplugin.h @@ -78,13 +78,12 @@ public: CvsPlugin(); ~CvsPlugin(); + CvsClient *client() const; + bool initialize(const QStringList &arguments, QString *errorMessage); CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName); - CvsSettings settings() const; - void setSettings(const CvsSettings &s); - // IVersionControl bool vcsAdd(const QString &workingDir, const QString &fileName); bool vcsDelete(const QString &workingDir, const QString &fileName); @@ -143,7 +142,7 @@ private: CvsResponse runCvs(const QString &workingDirectory, const QStringList &arguments, - int timeOut, + int timeOutS, unsigned flags, QTextCodec *outputCodec = 0) const; diff --git a/src/plugins/cvs/images/cvs.png b/src/plugins/cvs/images/cvs.png Binary files differdeleted file mode 100644 index ea82090aa80..00000000000 --- a/src/plugins/cvs/images/cvs.png +++ /dev/null diff --git a/src/plugins/cvs/settingspage.cpp b/src/plugins/cvs/settingspage.cpp index 1ceb755082a..d0ee1f6d95d 100644 --- a/src/plugins/cvs/settingspage.cpp +++ b/src/plugins/cvs/settingspage.cpp @@ -29,6 +29,8 @@ ****************************************************************************/ #include "settingspage.h" + +#include "cvsclient.h" #include "cvssettings.h" #include "cvsplugin.h" @@ -43,9 +45,9 @@ using namespace Cvs::Internal; using namespace Utils; +using namespace VcsBase; -SettingsPageWidget::SettingsPageWidget(QWidget *parent) : - QWidget(parent) +SettingsPageWidget::SettingsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent) { m_ui.setupUi(this); m_ui.commandPathChooser->setExpectedKind(PathChooser::ExistingCommand); @@ -53,7 +55,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : m_ui.commandPathChooser->setPromptDialogTitle(tr("CVS Command")); } -CvsSettings SettingsPageWidget::settings() const +VcsBaseClientSettings SettingsPageWidget::settings() const { CvsSettings rc; rc.setValue(CvsSettings::binaryPathKey, m_ui.commandPathChooser->rawPath()); @@ -65,7 +67,7 @@ CvsSettings SettingsPageWidget::settings() const return rc; } -void SettingsPageWidget::setSettings(const CvsSettings &s) +void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s) { m_ui.commandPathChooser->setFileName(s.binaryPath()); m_ui.rootLineEdit->setText(s.stringValue(CvsSettings::cvsRootKey)); @@ -75,27 +77,10 @@ void SettingsPageWidget::setSettings(const CvsSettings &s) m_ui.describeByCommitIdCheckBox->setChecked(s.boolValue(CvsSettings::describeByCommitIdKey)); } -SettingsPage::SettingsPage() +SettingsPage::SettingsPage(Core::IVersionControl *control) : + VcsClientOptionsPage(control, CvsPlugin::instance()->client()) { setId(VcsBase::Constants::VCS_ID_CVS); setDisplayName(tr("CVS")); -} - -QWidget *SettingsPage::widget() -{ - if (!m_widget) { - m_widget = new SettingsPageWidget; - m_widget->setSettings(CvsPlugin::instance()->settings()); - } - return m_widget; -} - -void SettingsPage::apply() -{ - CvsPlugin::instance()->setSettings(m_widget->settings()); -} - -void SettingsPage::finish() -{ - delete m_widget; + setWidgetFactory([]() { return new SettingsPageWidget; }); } diff --git a/src/plugins/cvs/settingspage.h b/src/plugins/cvs/settingspage.h index e94ac163a6c..18ec0906dbf 100644 --- a/src/plugins/cvs/settingspage.h +++ b/src/plugins/cvs/settingspage.h @@ -43,39 +43,34 @@ QT_BEGIN_NAMESPACE class QSettings; QT_END_NAMESPACE +namespace VcsBase { +class VcsBaseClientSettings; +} // namespace VcsBase + namespace Cvs { namespace Internal { -class CvsSettings; - -class SettingsPageWidget : public QWidget +class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: explicit SettingsPageWidget(QWidget *parent = 0); - CvsSettings settings() const; - void setSettings(const CvsSettings &); + VcsBase::VcsBaseClientSettings settings() const; + void setSettings(const VcsBase::VcsBaseClientSettings &); private: Ui::SettingsPage m_ui; }; -class SettingsPage : public VcsBase::VcsBaseOptionsPage +class SettingsPage : public VcsBase::VcsClientOptionsPage { Q_OBJECT public: - SettingsPage(); - - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<SettingsPageWidget> m_widget; + SettingsPage(Core::IVersionControl *control); }; } // namespace Cvs diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 7ae00161cb3..7c9d7b1d62e 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -48,6 +48,7 @@ #include <utils/hostosinfo.h> #include <utils/qtcassert.h> #include <utils/fileutils.h> +#include <utils/theme/theme.h> #if USE_BREAK_MODEL_TEST #include <modeltest.h> @@ -145,7 +146,7 @@ class BreakpointMarker : public TextEditor::TextMark { public: BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber) - : TextMark(fileName, lineNumber), m_bp(b) + : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b) { setIcon(b->icon()); setPriority(TextEditor::TextMark::NormalPriority); @@ -253,6 +254,8 @@ BreakHandler::BreakHandler() : m_syncTimerId(-1) { qRegisterMetaType<BreakpointModelId>(); + TextEditor::TextMark::setCategoryColor(Constants::TEXT_MARK_CATEGORY_BREAKPOINT, + Utils::Theme::Debugger_Breakpoint_TextMarkColor); #if USE_BREAK_MODEL_TEST new ModelTest(this, 0); @@ -409,7 +412,7 @@ void BreakHandler::deletionHelper(BreakpointModelId id) { Breakpoint b = breakpointById(id); QTC_ASSERT(b, return); - removeItem(b.b); + takeItem(b.b); delete b.b; } @@ -542,7 +545,7 @@ void BreakHandler::updateMarkers() Breakpoint BreakHandler::findBreakpointByIndex(const QModelIndex &index) const { - TreeItem *item = itemFromIndex(index); + TreeItem *item = itemForIndex(index); return Breakpoint(item && item->parent() == rootItem() ? static_cast<BreakpointItem *>(item) : 0); } @@ -1140,7 +1143,7 @@ void BreakHandler::saveSessionData() void BreakHandler::loadSessionData() { - removeItems(); + clear(); loadBreakpoints(); } @@ -1232,7 +1235,7 @@ void BreakHandler::changeLineNumberFromMarkerHelper(BreakpointModelId id) Breakpoint b = breakpointById(id); QTC_ASSERT(b, return); BreakpointParameters params = b.parameters(); - removeItem(b.b); + takeItem(b.b); delete b.b; appendBreakpoint(params); } diff --git a/src/plugins/debugger/cdb/cdbengine.cpp b/src/plugins/debugger/cdb/cdbengine.cpp index 69e0d20cf29..c785d8c96da 100644 --- a/src/plugins/debugger/cdb/cdbengine.cpp +++ b/src/plugins/debugger/cdb/cdbengine.cpp @@ -1831,29 +1831,20 @@ void CdbEngine::handleLocals(const CdbResponse &response, bool newFrame) watchHandler()->notifyUpdateFinished(); if (boolSetting(VerboseLog)) showMessage(QLatin1String("Locals: ") + QString::fromLatin1(response.extensionReply), LogDebug); - WatchHandler *handler = watchHandler(); - GdbMi all; - all.fromString(response.extensionReply); - QTC_ASSERT(all.type() == GdbMi::List, return); - - QSet<QByteArray> toDelete; - if (newFrame) { - foreach (WatchItem *item, handler->model()->treeLevelItems<WatchItem *>(2)) - toDelete.insert(item->iname); - } - foreach (const GdbMi &child, all.children()) { - WatchItem *item = new WatchItem(child); - handler->insertItem(item); - toDelete.remove(item->iname); - } + GdbMi data; + data.fromString(response.extensionReply); + QTC_ASSERT(data.type() == GdbMi::List, return); + data.m_name = "data"; - handler->purgeOutdatedItems(toDelete); + GdbMi partial; + partial.m_name = "partial"; + partial.m_data = QByteArray::number(newFrame ? 0 : 1); - if (newFrame) { - emit stackFrameCompleted(); - DebuggerToolTipManager::updateEngine(this); - } + GdbMi all; + all.m_children.push_back(data); + all.m_children.push_back(partial); + updateLocalsView(all); } else { showMessage(QString::fromLatin1(response.errorMessage), LogWarning); } diff --git a/src/plugins/debugger/debugger.pro b/src/plugins/debugger/debugger.pro index 83e790c0427..c40bd632221 100644 --- a/src/plugins/debugger/debugger.pro +++ b/src/plugins/debugger/debugger.pro @@ -7,8 +7,7 @@ include(../../qtcreatorplugin.pri) DEFINES += DEBUGGER_LIBRARY QT += gui \ - network \ - script + network CONFIG += exceptions diff --git a/src/plugins/debugger/debugger.qbs b/src/plugins/debugger/debugger.qbs index bb4a37057b6..0560b5b4730 100644 --- a/src/plugins/debugger/debugger.qbs +++ b/src/plugins/debugger/debugger.qbs @@ -3,7 +3,7 @@ import qbs 1.0 QtcPlugin { name: "Debugger" - Depends { name: "Qt"; submodules: ["widgets", "network", "script"] } + Depends { name: "Qt"; submodules: ["widgets", "network"] } Depends { name: "Aggregation" } Depends { name: "CPlusPlus" } Depends { name: "QtcSsh" } diff --git a/src/plugins/debugger/debuggerconstants.h b/src/plugins/debugger/debuggerconstants.h index 800e81bac15..f0f69da3bd7 100644 --- a/src/plugins/debugger/debuggerconstants.h +++ b/src/plugins/debugger/debuggerconstants.h @@ -69,6 +69,9 @@ const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool"; const char TASK_CATEGORY_DEBUGGER_DEBUGINFO[] = "Debuginfo"; const char TASK_CATEGORY_DEBUGGER_RUNTIME[] = "DebugRuntime"; +const char TEXT_MARK_CATEGORY_BREAKPOINT[] = "Debugger.Mark.Breakpoint"; +const char TEXT_MARK_CATEGORY_LOCATION[] = "Debugger.Mark.Location"; + // Run Configuration Aspect defaults: const int QML_DEFAULT_DEBUG_SERVER_PORT = 3768; diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index 5c688ba4891..a2d293be670 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -610,7 +610,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true); if (loc.needsMarker()) { - d->m_locationMark.reset(new TextMark(file, line)); + d->m_locationMark.reset(new TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION)); d->m_locationMark->setIcon(Internal::locationMarkIcon()); d->m_locationMark->setPriority(TextMark::HighPriority); } @@ -1265,6 +1265,7 @@ void DebuggerEngine::setState(DebuggerState state, bool forced) foreach (Breakpoint bp, breakHandler()->engineBreakpoints(this)) bp.notifyBreakpointReleased(); DebuggerToolTipManager::deregisterEngine(this); + d->m_memoryAgent.handleDebuggerFinished(); } showMessage(msg, LogDebug); @@ -1310,6 +1311,7 @@ QString DebuggerEngine::toFileInProject(const QUrl &fileUrl) const DebuggerStartParameters &sp = startParameters(); d->m_fileFinder.setProjectDirectory(sp.projectSourceDirectory); d->m_fileFinder.setProjectFiles(sp.projectSourceFiles); + d->m_fileFinder.setAdditionalSearchDirectories(sp.additionalSearchDirectories); d->m_fileFinder.setSysroot(sp.sysRoot); return d->m_fileFinder.findFile(fileUrl); @@ -1944,7 +1946,7 @@ void DebuggerEngine::updateLocalsView(const GdbMi &all) QSet<QByteArray> toDelete; if (!partial) { - foreach (WatchItem *item, handler->model()->treeLevelItems<WatchItem *>(2)) + foreach (WatchItem *item, handler->model()->itemsAtLevel<WatchItem *>(2)) toDelete.insert(item->iname); } diff --git a/src/plugins/debugger/debuggeroptionspage.cpp b/src/plugins/debugger/debuggeroptionspage.cpp index 6d4f9417217..00198db40ed 100644 --- a/src/plugins/debugger/debuggeroptionspage.cpp +++ b/src/plugins/debugger/debuggeroptionspage.cpp @@ -151,7 +151,7 @@ QModelIndex DebuggerItemModel::lastIndex() const { TreeItem *manualGroup = rootItem()->lastChild(); TreeItem *lastItem = manualGroup->lastChild(); - return lastItem ? indexFromItem(lastItem) : QModelIndex(); + return lastItem ? indexForItem(lastItem) : QModelIndex(); } DebuggerItem *DebuggerItemModel::currentDebugger() const @@ -165,7 +165,7 @@ void DebuggerItemModel::removeCurrentDebugger() QVariant id = m_currentTreeItem->m_item.id(); DebuggerTreeItem *treeItem = m_currentTreeItem; m_currentTreeItem = 0; - removeItem(treeItem); + takeItem(treeItem); delete treeItem; m_removedItems.append(id); } @@ -175,7 +175,7 @@ void DebuggerItemModel::apply() foreach (const QVariant &id, m_removedItems) DebuggerItemManager::deregisterDebugger(id); - foreach (auto item, treeLevelItems<DebuggerTreeItem *>(2)) { + foreach (auto item, itemsAtLevel<DebuggerTreeItem *>(2)) { item->m_changed = false; DebuggerItemManager::updateOrAddDebugger(item->m_item); } @@ -183,7 +183,7 @@ void DebuggerItemModel::apply() void DebuggerItemModel::setCurrentIndex(const QModelIndex &index) { - TreeItem *treeItem = itemFromIndex(index); + TreeItem *treeItem = itemForIndex(index); m_currentTreeItem = treeItem && treeItem->level() == 2 ? static_cast<DebuggerTreeItem *>(treeItem) : 0; } diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index ab39164e620..b1c01f2b3d2 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -2307,6 +2307,8 @@ static QString formatStartParameters(DebuggerStartParameters &sp) str << " (built: " << QDir::toNativeSeparators(sp.projectBuildDirectory) << ')'; str << '\n'; + str << "Addtional Search Directories:" + << sp.additionalSearchDirectories.join(QLatin1Char(' ')) << '\n'; } if (!sp.qmlServerAddress.isEmpty()) str << "QML server: " << sp.qmlServerAddress << ':' diff --git a/src/plugins/debugger/debuggerruncontrol.cpp b/src/plugins/debugger/debuggerruncontrol.cpp index 4162ca16298..4a4138162f2 100644 --- a/src/plugins/debugger/debuggerruncontrol.cpp +++ b/src/plugins/debugger/debuggerruncontrol.cpp @@ -101,8 +101,8 @@ static const char *engineTypeName(DebuggerEngineType et) return "No engine"; } -DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfiguration, DebuggerEngine *engine) - : RunControl(runConfiguration, DebugRunMode), +DebuggerRunControl::DebuggerRunControl(RunConfiguration *runConfig, DebuggerEngine *engine) + : RunControl(runConfig, DebugRunMode), m_engine(engine), m_running(false) { @@ -283,27 +283,27 @@ DebuggerRunControlFactory::DebuggerRunControlFactory(QObject *parent) : IRunControlFactory(parent) {} -bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const +bool DebuggerRunControlFactory::canRun(RunConfiguration *runConfig, RunMode mode) const { return (mode == DebugRunMode || mode == DebugRunModeWithBreakOnMain) - && qobject_cast<LocalApplicationRunConfiguration *>(runConfiguration); + && qobject_cast<LocalApplicationRunConfiguration *>(runConfig); } bool DebuggerRunControlFactory::fillParametersFromLocalRunConfiguration - (DebuggerStartParameters *sp, const RunConfiguration *runConfiguration, QString *errorMessage) + (DebuggerStartParameters *sp, const RunConfiguration *runConfig, QString *errorMessage) { - QTC_ASSERT(runConfiguration, return false); - auto rc = qobject_cast<const LocalApplicationRunConfiguration *>(runConfiguration); - QTC_ASSERT(rc, return false); - EnvironmentAspect *environmentAspect = rc->extraAspect<EnvironmentAspect>(); + QTC_ASSERT(runConfig, return false); + EnvironmentAspect *environmentAspect = runConfig->extraAspect<EnvironmentAspect>(); QTC_ASSERT(environmentAspect, return false); - Target *target = runConfiguration->target(); + Target *target = runConfig->target(); Kit *kit = target ? target->kit() : KitManager::defaultKit(); if (!fillParametersFromKit(sp, kit, errorMessage)) return false; sp->environment = environmentAspect->environment(); + auto rc = qobject_cast<const LocalApplicationRunConfiguration *>(runConfig); + QTC_ASSERT(rc, return false); // Normalize to work around QTBUG-17529 (QtDeclarative fails with 'File name case mismatch'...) sp->workingDirectory = FileUtils::normalizePathName(rc->workingDirectory()); @@ -323,7 +323,7 @@ bool DebuggerRunControlFactory::fillParametersFromLocalRunConfiguration } } - DebuggerRunConfigurationAspect *debuggerAspect = runConfiguration->extraAspect<DebuggerRunConfigurationAspect>(); + DebuggerRunConfigurationAspect *debuggerAspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>(); QTC_ASSERT(debuggerAspect, return false); sp->multiProcess = debuggerAspect->useMultiProcess(); @@ -331,8 +331,7 @@ bool DebuggerRunControlFactory::fillParametersFromLocalRunConfiguration sp->languages |= CppLanguage; if (debuggerAspect->useQmlDebugger()) { - const IDevice::ConstPtr device = - DeviceKitInformation::device(runConfiguration->target()->kit()); + const IDevice::ConstPtr device = DeviceKitInformation::device(runConfig->target()->kit()); QTC_ASSERT(device->type() == ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE, return sp); QTcpServer server; const bool canListen = server.listen(QHostAddress::LocalHost) @@ -356,7 +355,7 @@ bool DebuggerRunControlFactory::fillParametersFromLocalRunConfiguration } sp->startMode = StartInternal; - sp->displayName = rc->displayName(); + sp->displayName = runConfig->displayName(); return true; } @@ -402,7 +401,9 @@ DebuggerRunControl *DebuggerRunControlFactory::doCreate } if (sp.masterEngineType == NoEngineType) { - if (sp.executable.endsWith(_(".py")) || sp.executable == _("/usr/bin/python")) { + if (sp.executable.endsWith(_(".py")) + || sp.executable == _("/usr/bin/python") + || sp.executable == _("/usr/bin/python3")) { sp.masterEngineType = PdbEngineType; } else { if (RunConfiguration *rc = sp.runConfiguration) { diff --git a/src/plugins/debugger/debuggerruncontrol.h b/src/plugins/debugger/debuggerruncontrol.h index 1f1c43e6043..031ab923ede 100644 --- a/src/plugins/debugger/debuggerruncontrol.h +++ b/src/plugins/debugger/debuggerruncontrol.h @@ -82,7 +82,7 @@ signals: private: void handleFinished(); friend class DebuggerRunControlFactory; - DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfiguration, + DebuggerRunControl(ProjectExplorer::RunConfiguration *runConfig, Internal::DebuggerEngine *engine); Internal::DebuggerEngine *m_engine; @@ -97,11 +97,11 @@ public: // FIXME: Used by qmljsinspector.cpp:469 ProjectExplorer::RunControl *create( - ProjectExplorer::RunConfiguration *runConfiguration, + ProjectExplorer::RunConfiguration *runConfig, ProjectExplorer::RunMode mode, QString *errorMessage); - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, + bool canRun(ProjectExplorer::RunConfiguration *runConfig, ProjectExplorer::RunMode mode) const; static Internal::DebuggerEngine *createEngine(DebuggerEngineType et, @@ -112,7 +112,7 @@ public: const ProjectExplorer::Kit *kit, QString *errorMessage = 0); static bool fillParametersFromLocalRunConfiguration(DebuggerStartParameters *sp, - const ProjectExplorer::RunConfiguration *rc, QString *errorMessage = 0); + const ProjectExplorer::RunConfiguration *runConfig, QString *errorMessage = 0); static DebuggerRunControl *createAndScheduleRun(const DebuggerStartParameters &sp); diff --git a/src/plugins/debugger/debuggerstartparameters.h b/src/plugins/debugger/debuggerstartparameters.h index c6e7eb304db..27aff60495c 100644 --- a/src/plugins/debugger/debuggerstartparameters.h +++ b/src/plugins/debugger/debuggerstartparameters.h @@ -127,6 +127,7 @@ public: QString qmlServerAddress; quint16 qmlServerPort; QString projectSourceDirectory; + QStringList additionalSearchDirectories; QString projectBuildDirectory; QStringList projectSourceFiles; diff --git a/src/plugins/debugger/debuggertooltipmanager.cpp b/src/plugins/debugger/debuggertooltipmanager.cpp index 9b7556d5547..022602f2ed9 100644 --- a/src/plugins/debugger/debuggertooltipmanager.cpp +++ b/src/plugins/debugger/debuggertooltipmanager.cpp @@ -199,7 +199,7 @@ public: ToolTipWatchItem(WatchItem *item); bool hasChildren() const { return expandable; } - bool canFetchMore() const { return children().isEmpty() && expandable && model(); } + bool canFetchMore() const { return childCount() == 0 && expandable && model(); } void fetchMore() {} QVariant data(int column, int role) const; @@ -264,7 +264,7 @@ public: { if (!idx.isValid()) return; - auto item = dynamic_cast<ToolTipWatchItem *>(itemFromIndex(idx)); + auto item = dynamic_cast<ToolTipWatchItem *>(itemForIndex(idx)); if (!item) return; QByteArray iname = item->iname; @@ -473,7 +473,7 @@ public: void reexpand(const QModelIndex &idx) { - TreeItem *item = model.itemFromIndex(idx); + TreeItem *item = model.itemForIndex(idx); QTC_ASSERT(item, return); QByteArray iname = item->data(0, LocalsINameRole).toByteArray(); bool shouldExpand = model.m_expandedINames.contains(iname); @@ -637,7 +637,6 @@ public: void releaseEngine(); void saveSessionData(QXmlStreamWriter &w) const; - void handleStackFrameCompleted(const QString &frameFile, const QString &frameFunction); void positionShow(const TextEditorWidget *editorWidget); @@ -678,9 +677,8 @@ DebuggerToolTipContext::DebuggerToolTipContext() static bool filesMatch(const QString &file1, const QString &file2) { - QFileInfo f1(file1); - QFileInfo f2(file2); - return f1.canonicalFilePath() == f2.canonicalFilePath(); + return FileName::fromString(QFileInfo(file1).canonicalFilePath()) + == FileName::fromString(QFileInfo(file2).canonicalFilePath()); } bool DebuggerToolTipContext::matchesFrame(const StackFrame &frame) const diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 9269a8aafc1..a7df1f215ec 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -116,7 +116,7 @@ public: DisassemblerAgentPrivate::DisassemblerAgentPrivate() : document(0), - locationMark(QString(), 0), + locationMark(QString(), 0, Constants::TEXT_MARK_CATEGORY_LOCATION), mimeType(_("text/x-qtcreator-generic-asm")), resetLocationScheduled(false) { @@ -352,7 +352,8 @@ void DisassemblerAgent::updateBreakpointMarkers() const int lineNumber = contents.lineForAddress(address); if (!lineNumber) continue; - TextMark *marker = new TextMark(QString(), lineNumber); + TextMark *marker = new TextMark(QString(), lineNumber, + Constants::TEXT_MARK_CATEGORY_BREAKPOINT); marker->setIcon(bp.icon()); marker->setPriority(TextMark::NormalPriority); d->breakpointMarks.append(marker); diff --git a/src/plugins/debugger/memoryagent.cpp b/src/plugins/debugger/memoryagent.cpp index 5dbef0020f2..6a532a6ed48 100644 --- a/src/plugins/debugger/memoryagent.cpp +++ b/src/plugins/debugger/memoryagent.cpp @@ -75,7 +75,8 @@ namespace Internal { (m_view). \endlist - Views are updated on the DebuggerEngine::stackFrameCompleted signal. + Views are asked to update themselves directly by the owning + DebuggerEngine. An exception are views of class Debugger::RegisterMemoryView tracking the content pointed to by a register (eg stack pointer, instruction pointer). They are connected to the set/changed signals of @@ -88,10 +89,8 @@ MemoryAgent::MemoryAgent(DebuggerEngine *engine) : QObject(engine), m_engine(engine) { QTC_CHECK(engine); - connect(engine, SIGNAL(stateChanged(Debugger::DebuggerState)), - this, SLOT(engineStateChanged(Debugger::DebuggerState))); - connect(engine, SIGNAL(stackFrameCompleted()), this, - SLOT(updateContents())); + connect(engine, &DebuggerEngine::stackFrameCompleted, + this, &MemoryAgent::updateContents); } MemoryAgent::~MemoryAgent() @@ -254,19 +253,13 @@ bool MemoryAgent::hasVisibleEditor() const return false; } -void MemoryAgent::engineStateChanged(Debugger::DebuggerState s) +void MemoryAgent::handleDebuggerFinished() { - switch (s) { - case DebuggerFinished: - closeViews(); - foreach (const QPointer<IEditor> &editor, m_editors) - if (editor) { // Prevent triggering updates, etc. - MemoryView::setBinEditorReadOnly(editor->widget(), true); - editor->widget()->disconnect(this); - } - break; - default: - break; + foreach (const QPointer<IEditor> &editor, m_editors) { + if (editor) { // Prevent triggering updates, etc. + MemoryView::setBinEditorReadOnly(editor->widget(), true); + editor->widget()->disconnect(this); + } } } diff --git a/src/plugins/debugger/memoryagent.h b/src/plugins/debugger/memoryagent.h index 33386f126e0..a2be79fce56 100644 --- a/src/plugins/debugger/memoryagent.h +++ b/src/plugins/debugger/memoryagent.h @@ -101,6 +101,7 @@ public slots: void updateContents(); void closeEditors(); void closeViews(); + void handleDebuggerFinished(); private slots: void fetchLazyData(quint64 block); @@ -108,7 +109,6 @@ private slots: void handleDataChanged(quint64 address, const QByteArray &data); void handleWatchpointRequest(quint64 address, uint size); void updateMemoryView(quint64 address, quint64 length); - void engineStateChanged(Debugger::DebuggerState s); private: void connectBinEditorWidget(QWidget *w); diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 3e793a424b6..0e62454b78f 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -197,7 +197,7 @@ QAbstractItemModel *ModulesHandler::model() const void ModulesHandler::removeAll() { - m_model->removeItems(); + m_model->clear(); } Modules ModulesHandler::modules() const @@ -212,7 +212,7 @@ Modules ModulesHandler::modules() const void ModulesHandler::removeModule(const QString &modulePath) { if (ModuleItem *item = moduleFromPath(m_model->rootItem(), modulePath)) - m_model->removeItem(item); + m_model->takeItem(item); } void ModulesHandler::updateModule(const Module &module) @@ -254,7 +254,7 @@ void ModulesHandler::endUpdateAll() for (int i = root->rowCount(); --i >= 0; ) { auto item = static_cast<ModuleItem *>(root->child(i)); if (!item->updated) - m_model->removeItem(item); + m_model->takeItem(item); } } diff --git a/src/plugins/debugger/pdb/pdbengine.cpp b/src/plugins/debugger/pdb/pdbengine.cpp index 88d3bb7abf3..278cd355940 100644 --- a/src/plugins/debugger/pdb/pdbengine.cpp +++ b/src/plugins/debugger/pdb/pdbengine.cpp @@ -82,23 +82,23 @@ void PdbEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages showMessage(_("PDB PROCESS NOT RUNNING, PLAIN CMD IGNORED: ") + command); return; } - QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll()); + QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); postDirectCommand(command.toLatin1()); } void PdbEngine::postDirectCommand(const QByteArray &command) { - QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll()); + QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); showMessage(_(command), LogInput); - m_pdbProc.write(command + '\n'); + m_proc.write(command + '\n'); } void PdbEngine::runCommand(const DebuggerCommand &cmd) { - QTC_ASSERT(m_pdbProc.state() == QProcess::Running, notifyEngineIll()); + QTC_ASSERT(m_proc.state() == QProcess::Running, notifyEngineIll()); QByteArray command = "qdebug('" + cmd.function + "',{" + cmd.args + "})"; showMessage(_(command), LogInput); - m_pdbProc.write(command + '\n'); + m_proc.write(command + '\n'); } void PdbEngine::shutdownInferior() @@ -110,30 +110,30 @@ void PdbEngine::shutdownInferior() void PdbEngine::shutdownEngine() { QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state()); - m_pdbProc.kill(); + m_proc.kill(); } void PdbEngine::setupEngine() { QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state()); - m_pdb = _("python"); - showMessage(_("STARTING PDB ") + m_pdb); + QString python = pythonInterpreter(); + showMessage(_("STARTING PDB ") + python); - connect(&m_pdbProc, static_cast<void(QProcess::*)(QProcess::ProcessError)>(&QProcess::error), + connect(&m_proc, static_cast<void(QProcess::*)(QProcess::ProcessError)>(&QProcess::error), this, &PdbEngine::handlePdbError); - connect(&m_pdbProc, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), + connect(&m_proc, static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished), this, &PdbEngine::handlePdbFinished); - connect(&m_pdbProc, &QProcess::readyReadStandardOutput, + connect(&m_proc, &QProcess::readyReadStandardOutput, this, &PdbEngine::readPdbStandardOutput); - connect(&m_pdbProc, &QProcess::readyReadStandardError, + connect(&m_proc, &QProcess::readyReadStandardError, this, &PdbEngine::readPdbStandardError); - m_pdbProc.start(m_pdb, QStringList() << _("-i")); + m_proc.start(python, QStringList() << _("-i")); - if (!m_pdbProc.waitForStarted()) { + if (!m_proc.waitForStarted()) { const QString msg = tr("Unable to start pdb \"%1\": %2") - .arg(m_pdb, m_pdbProc.errorString()); + .arg(pythonInterpreter(), m_proc.errorString()); notifyEngineSetupFailed(); showMessage(_("ADAPTER START FAILED")); if (!msg.isEmpty()) @@ -165,15 +165,23 @@ QString PdbEngine::mainPythonFile() const return QFileInfo(startParameters().processArgs).absoluteFilePath(); } +QString PdbEngine::pythonInterpreter() const +{ + return startParameters().executable; +} + void PdbEngine::runEngine() { QTC_ASSERT(state() == EngineRunRequested, qDebug() << state()); showStatusMessage(tr("Running requested..."), 5000); - const QByteArray dumperSourcePath = ICore::resourcePath().toLocal8Bit() + "/debugger/"; + QByteArray bridge = ICore::resourcePath().toUtf8() + "/debugger/pdbbridge.py"; + QByteArray pdb = "/usr/bin/pdb"; + if (pythonInterpreter().endsWith(QLatin1Char('3'))) + pdb += '3'; postDirectCommand("import sys"); postDirectCommand("sys.argv.append('" + mainPythonFile().toLocal8Bit() + "')"); - postDirectCommand("execfile('/usr/bin/pdb')"); - postDirectCommand("execfile('" + dumperSourcePath + "pdbbridge.py')"); + postDirectCommand("exec(open('" + pdb + "').read())"); + postDirectCommand("exec(open('" + bridge + "').read())"); attemptBreakpointSynchronization(); notifyEngineRunAndInferiorStopOk(); continueInferior(); @@ -412,7 +420,7 @@ void PdbEngine::handlePdbError(QProcess::ProcessError error) case QProcess::Timedout: default: //setState(EngineShutdownRequested, true); - m_pdbProc.kill(); + m_proc.kill(); AsynchronousMessageBox::critical(tr("Pdb I/O Error"), errorMessage(error)); break; } @@ -425,7 +433,7 @@ QString PdbEngine::errorMessage(QProcess::ProcessError error) const return tr("The Pdb process failed to start. Either the " "invoked program \"%1\" is missing, or you may have insufficient " "permissions to invoke the program.") - .arg(m_pdb); + .arg(pythonInterpreter()); case QProcess::Crashed: return tr("The Pdb process crashed some time after starting " "successfully."); @@ -454,7 +462,7 @@ void PdbEngine::handlePdbFinished(int code, QProcess::ExitStatus type) void PdbEngine::readPdbStandardError() { - QByteArray err = m_pdbProc.readAllStandardError(); + QByteArray err = m_proc.readAllStandardError(); qDebug() << "\nPDB STDERR" << err; //qWarning() << "Unexpected pdb stderr:" << err; //showMessage(_("Unexpected pdb stderr: " + err)); @@ -463,7 +471,7 @@ void PdbEngine::readPdbStandardError() void PdbEngine::readPdbStandardOutput() { - QByteArray out = m_pdbProc.readAllStandardOutput(); + QByteArray out = m_proc.readAllStandardOutput(); qDebug() << "\nPDB STDOUT" << out; handleOutput(out); } @@ -572,7 +580,7 @@ void PdbEngine::refreshLocals(const GdbMi &vars) handler->resetValueCache(); QSet<QByteArray> toDelete; - foreach (WatchItem *item, handler->model()->treeLevelItems<WatchItem *>(2)) + foreach (WatchItem *item, handler->model()->itemsAtLevel<WatchItem *>(2)) toDelete.insert(item->iname); foreach (const GdbMi &child, vars.children()) { diff --git a/src/plugins/debugger/pdb/pdbengine.h b/src/plugins/debugger/pdb/pdbengine.h index 751ebbc943d..d9575ef53ed 100644 --- a/src/plugins/debugger/pdb/pdbengine.h +++ b/src/plugins/debugger/pdb/pdbengine.h @@ -97,7 +97,9 @@ private: bool supportsThreads() const { return true; } bool isSynchronous() const { return true; } void updateWatchItem(WatchItem *item); + QString mainPythonFile() const; + QString pythonInterpreter() const; void runCommand(const DebuggerCommand &cmd); void postDirectCommand(const QByteArray &command); @@ -121,8 +123,7 @@ private: void updateLocals(); QByteArray m_inbuffer; - QProcess m_pdbProc; - QString m_pdb; + QProcess m_proc; }; } // namespace Internal diff --git a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp index 811f00bc46f..cc4536ad27a 100644 --- a/src/plugins/debugger/qml/qmlv8debuggerclient.cpp +++ b/src/plugins/debugger/qml/qmlv8debuggerclient.cpp @@ -48,7 +48,9 @@ #include <QTextBlock> #include <QFileInfo> -#include <QScriptEngine> +#include <QJsonArray> +#include <QJsonDocument> +#include <QJsonObject> #define DEBUG_QML 0 #if DEBUG_QML @@ -82,8 +84,6 @@ public: engine(0), previousStepAction(QmlV8DebuggerClient::Continue) { - parser = m_scriptEngine.evaluate(_("JSON.parse")); - stringifier = m_scriptEngine.evaluate(_("JSON.stringify")); } void connect(); @@ -111,12 +111,13 @@ public: //void profile(ProfileCommand command); //NOT SUPPORTED void clearCache(); + void sendAndLogV8Request(const QJsonObject &request); void logSendMessage(const QString &msg) const; void logReceiveMessage(const QString &msg) const; private: QByteArray packMessage(const QByteArray &type, const QByteArray &message = QByteArray()); - QScriptValue initObject(); + QJsonObject initObject(); public: QmlV8DebuggerClient *q; @@ -127,9 +128,6 @@ public: QHash<int, BreakpointModelId> breakpointsSync; QList<int> breakpointsTemp; - QScriptValue parser; - QScriptValue stringifier; - QHash<int, QString> evaluatingExpression; QHash<int, QByteArray> localsAndWatchers; QList<int> updateLocalsAndWatchers; @@ -140,8 +138,6 @@ public: QHash<int, int> stackIndexLookup; QmlV8DebuggerClient::StepAction previousStepAction; -private: - QScriptEngine m_scriptEngine; }; /////////////////////////////////////////////////////////////////////// @@ -162,12 +158,14 @@ void QmlV8DebuggerClientPrivate::disconnect() // "type" : "request", // "command" : "disconnect", // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(DISCONNECT))); - - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2")).arg(_(V8DEBUG), jsonMessage.toString())); - q->sendMessage(packMessage(DISCONNECT, jsonMessage.toString().toUtf8())); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(DISCONNECT)); + + const QJsonDocument jsonMessage(jsonVal); + logSendMessage(QString::fromLatin1("%1 %2") + .arg(_(V8DEBUG), + QString::fromUtf8(jsonMessage.toJson(QJsonDocument::Compact)))); + q->sendMessage(packMessage(DISCONNECT, jsonMessage.toJson(QJsonDocument::Compact))); } void QmlV8DebuggerClientPrivate::interrupt() @@ -185,30 +183,27 @@ void QmlV8DebuggerClientPrivate::continueDebugging(QmlV8DebuggerClient::StepActi // "stepcount" : <number of steps (default 1)> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), - QScriptValue(_(CONTINEDEBUGGING))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(CONTINEDEBUGGING)); if (action != QmlV8DebuggerClient::Continue) { - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject args; switch (action) { case QmlV8DebuggerClient::In: - args.setProperty(_(STEPACTION), QScriptValue(_(IN))); + args.insert(_(STEPACTION), _(IN)); break; case QmlV8DebuggerClient::Out: - args.setProperty(_(STEPACTION), QScriptValue(_(OUT))); + args.insert(_(STEPACTION), _(OUT)); break; case QmlV8DebuggerClient::Next: - args.setProperty(_(STEPACTION), QScriptValue(_(NEXT))); + args.insert(_(STEPACTION), _(NEXT)); break; default:break; } - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); } - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); previousStepAction = action; } @@ -230,45 +225,45 @@ void QmlV8DebuggerClientPrivate::evaluate(const QString expr, bool global, // ] // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(EVALUATE))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(EVALUATE)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); - args.setProperty(_(EXPRESSION), QScriptValue(expr)); + QJsonObject args { + { _(EXPRESSION), expr } + }; if (frame != -1) - args.setProperty(_(FRAME), QScriptValue(frame)); + args.insert(_(FRAME), frame); if (global) - args.setProperty(_(GLOBAL), QScriptValue(global)); + args.insert(_(GLOBAL), global); if (disableBreak) - args.setProperty(_(DISABLE_BREAK), QScriptValue(disableBreak)); + args.insert(_(DISABLE_BREAK), disableBreak); if (addContext) { WatchHandler *watchHandler = engine->watchHandler(); QAbstractItemModel *watchModel = watchHandler->model(); int rowCount = watchModel->rowCount(); - QScriptValue ctxtList = parser.call(QScriptValue(), QScriptValueList() << _(ARRAY )); + QJsonArray ctxtList; while (rowCount) { QModelIndex index = watchModel->index(--rowCount, 0); const WatchData *data = watchHandler->watchItem(index); - QScriptValue ctxt = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); - ctxt.setProperty(_(NAME), QScriptValue(data->name)); - ctxt.setProperty(_(HANDLE), QScriptValue(int(data->id))); + const QJsonObject ctxt { + { _(NAME), data->name }, + { _(HANDLE), int(data->id) } + }; - ctxtList.setProperty(rowCount, ctxt); + ctxtList.push_front(ctxt); } - args.setProperty(_(ADDITIONAL_CONTEXT), QScriptValue(ctxtList)); + args.insert(_(ADDITIONAL_CONTEXT), ctxtList); } - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::lookup(QList<int> handles, bool includeSource) @@ -282,26 +277,22 @@ void QmlV8DebuggerClientPrivate::lookup(QList<int> handles, bool includeSource) // script objects are returned>, // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(LOOKUP))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(LOOKUP)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject args; - QScriptValue array = parser.call(QScriptValue(), QScriptValueList() << _(ARRAY)); - int index = 0; - foreach (int handle, handles) { - array.setProperty(index++, QScriptValue(handle)); - } - args.setProperty(_(HANDLES), array); + QJsonArray array; + foreach (int handle, handles) + array.push_back(handle); + args.insert(_(HANDLES), array); if (includeSource) - args.setProperty(_(INCLUDESOURCE), QScriptValue(includeSource)); + args.insert(_(INCLUDESOURCE), includeSource); - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::backtrace(int fromFrame, int toFrame, bool bottom) @@ -315,25 +306,23 @@ void QmlV8DebuggerClientPrivate::backtrace(int fromFrame, int toFrame, bool bott // stack is requested> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(BACKTRACE))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(BACKTRACE)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject args; if (fromFrame != -1) - args.setProperty(_(FROMFRAME), QScriptValue(fromFrame)); + args.insert(_(FROMFRAME), fromFrame); if (toFrame != -1) - args.setProperty(_(TOFRAME), QScriptValue(toFrame)); + args.insert(_(TOFRAME), toFrame); if (bottom) - args.setProperty(_(BOTTOM), QScriptValue(bottom)); + args.insert(_(BOTTOM), bottom); - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::frame(int number) @@ -344,19 +333,18 @@ void QmlV8DebuggerClientPrivate::frame(int number) // "arguments" : { "number" : <frame number> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(FRAME))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(FRAME)); if (number != -1) { - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); - args.setProperty(_(NUMBER), QScriptValue(number)); + const QJsonObject args { + { _(NUMBER), number } + }; - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); } - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::scope(int number, int frameNumber) @@ -369,22 +357,21 @@ void QmlV8DebuggerClientPrivate::scope(int number, int frameNumber) // frame if missing> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(SCOPE))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(SCOPE)); if (number != -1) { - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); - args.setProperty(_(NUMBER), QScriptValue(number)); + QJsonObject args { + { _(NUMBER), number } + }; if (frameNumber != -1) - args.setProperty(_(FRAMENUMBER), QScriptValue(frameNumber)); + args.insert(_(FRAMENUMBER), frameNumber); - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); } - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::scripts(int types, const QList<int> ids, bool includeSource, @@ -405,39 +392,37 @@ void QmlV8DebuggerClientPrivate::scripts(int types, const QList<int> ids, bool i // If a string is specified, then only scripts whose names contain the filter string will be retrieved.> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(SCRIPTS))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(SCRIPTS)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); - args.setProperty(_(TYPES), QScriptValue(types)); + QJsonObject args { + { _(TYPES), types } + }; if (ids.count()) { - QScriptValue array = parser.call(QScriptValue(), QScriptValueList() << _(ARRAY)); - int index = 0; + QJsonArray array; foreach (int id, ids) { - array.setProperty(index++, QScriptValue(id)); + array.push_back(id); } - args.setProperty(_(IDS), array); + args.insert(_(IDS), array); } if (includeSource) - args.setProperty(_(INCLUDESOURCE), QScriptValue(includeSource)); + args.insert(_(INCLUDESOURCE), includeSource); - QScriptValue filterValue; + QJsonValue filterValue; if (filter.type() == QVariant::String) - filterValue = QScriptValue(filter.toString()); + filterValue = filter.toString(); else if (filter.type() == QVariant::Int) - filterValue = QScriptValue(filter.toInt()); + filterValue = filter.toInt(); else QTC_CHECK(!filter.isValid()); - args.setProperty(_(FILTER), filterValue); + args.insert(_(FILTER), filterValue); - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::setBreakpoint(const QString type, const QString target, @@ -464,37 +449,34 @@ void QmlV8DebuggerClientPrivate::setBreakpoint(const QString type, const QString q->sendMessage(packMessage(BREAKONSIGNAL, params)); } else { - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(SETBREAKPOINT))); - - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(SETBREAKPOINT)); - args.setProperty(_(TYPE), QScriptValue(type)); + QJsonObject args { + { _(TYPE), type }, + { _(ENABLED), enabled } + }; if (type == _(SCRIPTREGEXP)) - args.setProperty(_(TARGET), - QScriptValue(Utils::FileName::fromString(target).fileName())); + args.insert(_(TARGET), + Utils::FileName::fromString(target).fileName()); else - args.setProperty(_(TARGET), QScriptValue(target)); + args.insert(_(TARGET), target); if (line) - args.setProperty(_(LINE), QScriptValue(line - 1)); + args.insert(_(LINE), line - 1); if (column) - args.setProperty(_(COLUMN), QScriptValue(column - 1)); - - args.setProperty(_(ENABLED), QScriptValue(enabled)); + args.insert(_(COLUMN), column - 1); if (!condition.isEmpty()) - args.setProperty(_(CONDITION), QScriptValue(condition)); + args.insert(_(CONDITION), condition); if (ignoreCount != -1) - args.setProperty(_(IGNORECOUNT), QScriptValue(ignoreCount)); + args.insert(_(IGNORECOUNT), ignoreCount); - jsonVal.setProperty(_(ARGUMENTS), args); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } } @@ -506,19 +488,16 @@ void QmlV8DebuggerClientPrivate::clearBreakpoint(int breakpoint) // "arguments" : { "breakpoint" : <number of the break point to clear> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), - QScriptValue(_(CLEARBREAKPOINT))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(CLEARBREAKPOINT)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject args { + { _(BREAKPOINT), breakpoint } + }; - args.setProperty(_(BREAKPOINT), QScriptValue(breakpoint)); + jsonVal.insert(_(ARGUMENTS), args); - jsonVal.setProperty(_(ARGUMENTS), args); - - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::setExceptionBreak(QmlV8DebuggerClient::Exceptions type, @@ -531,27 +510,23 @@ void QmlV8DebuggerClientPrivate::setExceptionBreak(QmlV8DebuggerClient::Exceptio // "enabled" : <optional bool: enables the break type if true> // } // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), - QScriptValue(_(SETEXCEPTIONBREAK))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(SETEXCEPTIONBREAK)); - QScriptValue args = parser.call(QScriptValue(), QScriptValueList() << QScriptValue(_(OBJECT))); + QJsonObject args; if (type == QmlV8DebuggerClient::AllExceptions) - args.setProperty(_(TYPE), QScriptValue(_(ALL))); + args.insert(_(TYPE), _(ALL)); //Not Supported // else if (type == QmlV8DebuggerClient::UncaughtExceptions) // args.setProperty(_(TYPE),QScriptValue(_(UNCAUGHT))); if (enabled) - args.setProperty(_(ENABLED), QScriptValue(enabled)); - - jsonVal.setProperty(_(ARGUMENTS), args); + args.insert(_(ENABLED), enabled); + jsonVal.insert(_(ARGUMENTS), args); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } void QmlV8DebuggerClientPrivate::version() @@ -560,12 +535,10 @@ void QmlV8DebuggerClientPrivate::version() // "type" : "request", // "command" : "version", // } - QScriptValue jsonVal = initObject(); - jsonVal.setProperty(_(COMMAND), QScriptValue(_(VERSION))); + QJsonObject jsonVal = initObject(); + jsonVal.insert(_(COMMAND), _(VERSION)); - const QScriptValue jsonMessage = stringifier.call(QScriptValue(), QScriptValueList() << jsonVal); - logSendMessage(QString(_("%1 %2 %3")).arg(_(V8DEBUG), _(V8REQUEST), jsonMessage.toString())); - q->sendMessage(packMessage(V8REQUEST, jsonMessage.toString().toUtf8())); + sendAndLogV8Request(jsonVal); } //void QmlV8DebuggerClientPrivate::profile(ProfileCommand command) @@ -736,13 +709,21 @@ QByteArray QmlV8DebuggerClientPrivate::packMessage(const QByteArray &type, const return request; } -QScriptValue QmlV8DebuggerClientPrivate::initObject() +QJsonObject QmlV8DebuggerClientPrivate::initObject() +{ + return QJsonObject { + {_(SEQ), ++sequence}, + {_(TYPE), _(REQUEST)} + }; +} + +void QmlV8DebuggerClientPrivate::sendAndLogV8Request(const QJsonObject &request) { - QScriptValue jsonVal = parser.call(QScriptValue(), - QScriptValueList() << QScriptValue(_(OBJECT))); - jsonVal.setProperty(_(SEQ), QScriptValue(++sequence)); - jsonVal.setProperty(_(TYPE), _(REQUEST)); - return jsonVal; + const QJsonDocument jsonMessage(request); + logSendMessage(QString::fromLatin1("%1 %2 %3") + .arg(_(V8DEBUG), _(V8REQUEST), + QString::fromUtf8(jsonMessage.toJson(QJsonDocument::Compact)))); + q->sendMessage(packMessage(V8REQUEST, jsonMessage.toJson(QJsonDocument::Compact))); } void QmlV8DebuggerClientPrivate::logSendMessage(const QString &msg) const @@ -1021,9 +1002,9 @@ void QmlV8DebuggerClient::messageReceived(const QByteArray &data) SDEBUG(responseString); d->logReceiveMessage(QLatin1String(V8MESSAGE) + QLatin1Char(' ') + responseString); - const QVariantMap resp = d->parser.call(QScriptValue(), - QScriptValueList() << - QScriptValue(responseString)).toVariant().toMap(); + const QVariantMap resp = + QJsonDocument::fromJson(responseString.toUtf8()).toVariant().toMap(); + const QString type(resp.value(_(TYPE)).toString()); if (type == _("response")) { diff --git a/src/plugins/debugger/registerhandler.cpp b/src/plugins/debugger/registerhandler.cpp index 545631c90f8..da667a2e07d 100644 --- a/src/plugins/debugger/registerhandler.cpp +++ b/src/plugins/debugger/registerhandler.cpp @@ -603,7 +603,7 @@ void RegisterHandler::setNumberFormat(const QByteArray &name, RegisterFormat for RegisterItem *reg = m_registerByName.value(name, 0); QTC_ASSERT(reg, return); reg->m_format = format; - QModelIndex index = indexFromItem(reg); + QModelIndex index = indexForItem(reg); emit dataChanged(index, index); } diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index 3cf6ccea5b9..7fa8562916f 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -144,7 +144,8 @@ void SourceAgent::updateLocationMarker() if (d->engine->stackHandler()->currentFrame().file == d->path) { int lineNumber = d->engine->stackHandler()->currentFrame().line; - d->locationMark = new TextMark(QString(), lineNumber); + d->locationMark = new TextMark(QString(), lineNumber, + Constants::TEXT_MARK_CATEGORY_LOCATION); d->locationMark->setIcon(locationMarkIcon()); d->locationMark->setPriority(TextMark::HighPriority); diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 0f3e8672d8b..6512bf4df51 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -906,9 +906,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const if (role == BaseTreeView::ExtraIndicesForColumnWidth) { QModelIndexList l; foreach (TreeItem *item, m_watchRoot->children()) - l.append(indexFromItem(item)); + l.append(indexForItem(item)); foreach (TreeItem *item, m_returnRoot->children()) - l.append(indexFromItem(item)); + l.append(indexForItem(item)); return QVariant::fromValue(l); } return WatchModelBase::data(idx, role); @@ -919,7 +919,7 @@ bool WatchModel::setData(const QModelIndex &idx, const QVariant &value, int role if (!idx.isValid()) return false; // Triggered by ModelTester. - WatchItem *item = static_cast<WatchItem *>(itemFromIndex(idx)); + WatchItem *item = static_cast<WatchItem *>(itemForIndex(idx)); QTC_ASSERT(item, return false); switch (role) { @@ -1191,7 +1191,7 @@ void WatchModel::reinsertAllData() parent->insertChild(row, newItem); if (m_expandedINames.contains(parent->iname)) { emit inameIsExpanded(parent->iname); - emit itemIsExpanded(indexFromItem(parent)); + emit itemIsExpanded(indexForItem(parent)); } showEditValue(newItem); // FIXME: Needed? } @@ -1245,7 +1245,7 @@ void WatchModel::insertItem(WatchItem *item) QTC_ASSERT(parent, return); if (WatchItem *existing = parent->findItem(item->iname)) - removeItem(existing); + takeItem(existing); //item->walkTree([item](TreeItem *sub) { sub->sortChildren(&watchItemSorter); }); item->sortChildren(&watchItemSorter); @@ -1260,7 +1260,7 @@ void WatchModel::reexpandItems() { foreach (const QByteArray &iname, m_expandedINames) { if (WatchItem *item = findItem(iname)) { - emit itemIsExpanded(indexFromItem(item)); + emit itemIsExpanded(indexForItem(item)); emit inameIsExpanded(iname); } else { // Can happen. We might have stepped into another frame @@ -1310,7 +1310,7 @@ void WatchHandler::purgeOutdatedItems(const QSet<QByteArray> &inames) { foreach (const QByteArray &iname, inames) { WatchItem *item = findItem(iname); - m_model->removeItem(item); + m_model->takeItem(item); } m_model->layoutChanged(); @@ -1328,7 +1328,7 @@ void WatchHandler::removeItemByIName(const QByteArray &iname) theWatcherNames.remove(item->exp); saveWatchers(); } - m_model->removeItem(item); + m_model->takeItem(item); delete item; updateWatchersWindow(); } @@ -1494,7 +1494,7 @@ void WatchHandler::updateWatchersWindow() // Force show/hide of watchers and return view. int showWatch = !theWatcherNames.isEmpty(); - int showReturn = !m_model->m_returnRoot->children().isEmpty(); + int showReturn = m_model->m_returnRoot->childCount() != 0; Internal::updateWatchersWindow(showWatch, showReturn); } @@ -1536,7 +1536,7 @@ WatchModelBase *WatchHandler::model() const const WatchItem *WatchHandler::watchItem(const QModelIndex &idx) const { - return static_cast<WatchItem *>(m_model->itemFromIndex(idx)); + return static_cast<WatchItem *>(m_model->itemForIndex(idx)); } void WatchHandler::fetchMore(const QByteArray &iname) const @@ -1725,7 +1725,7 @@ void WatchHandler::resetLocation() void WatchHandler::setCurrentItem(const QByteArray &iname) { if (WatchItem *item = m_model->findItem(iname)) { - QModelIndex idx = m_model->indexFromItem(item); + QModelIndex idx = m_model->indexForItem(item); emit m_model->currentIndexRequested(idx); } } diff --git a/src/plugins/debugger/watchwindow.cpp b/src/plugins/debugger/watchwindow.cpp index c8f145fb29a..da800380e89 100644 --- a/src/plugins/debugger/watchwindow.cpp +++ b/src/plugins/debugger/watchwindow.cpp @@ -737,14 +737,15 @@ void WatchTreeView::contextMenuEvent(QContextMenuEvent *ev) p = pp; } - bool showExpressionActions = (canHandleWatches || state == DebuggerNotReady) && m_type == WatchersType; + bool canRemoveWatches = ((canHandleWatches && canInsertWatches) || state == DebuggerNotReady) + && m_type == WatchersType; QString removeExp = p.data(LocalsExpressionRole).toString(); QAction actRemoveWatchExpression(removeWatchActionText(removeExp), 0); - actRemoveWatchExpression.setEnabled(showExpressionActions && !exp.isEmpty()); + actRemoveWatchExpression.setEnabled(canRemoveWatches && !exp.isEmpty()); QAction actRemoveAllWatchExpression(tr("Remove All Expression Evaluators"), 0); - actRemoveAllWatchExpression.setEnabled(showExpressionActions + actRemoveAllWatchExpression.setEnabled(canRemoveWatches && !handler->watchedExpressions().isEmpty()); QMenu formatMenu(tr("Change Local Display Format...")); diff --git a/src/plugins/designer/designer.pro b/src/plugins/designer/designer.pro index dc7743ab8dc..0a35709c9db 100644 --- a/src/plugins/designer/designer.pro +++ b/src/plugins/designer/designer.pro @@ -4,7 +4,7 @@ include(../../qtcreatorplugin.pri) include(../../shared/designerintegrationv2/designerintegration.pri) include(cpp/cpp.pri) -QT += printsupport designer designercomponents-private xml +QT += printsupport designer designercomponents-private HEADERS += formeditorplugin.h \ formeditorfactory.h \ diff --git a/src/plugins/designer/formeditorplugin.cpp b/src/plugins/designer/formeditorplugin.cpp index daeff861699..97a3ec314dd 100644 --- a/src/plugins/designer/formeditorplugin.cpp +++ b/src/plugins/designer/formeditorplugin.cpp @@ -85,7 +85,21 @@ bool FormEditorPlugin::initialize(const QStringList &arguments, QString *error) { Q_UNUSED(arguments) - initializeTemplates(); +#ifdef CPP_ENABLED + IWizardFactory::registerFactoryCreator( + []() -> QList<IWizardFactory *> { + IWizardFactory *wizard = new FormClassWizard; + wizard->setWizardKind(IWizardFactory::FileWizard); + wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); + wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); + wizard->setDisplayName(tr("Qt Designer Form Class")); + wizard->setId("C.FormClass"); + wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) " + "for implementation purposes. You can add the form and class to an existing Qt Widget Project.")); + + return QList<IWizardFactory *>() << wizard; + }); +#endif ProjectExplorer::JsonWizardFactory::registerPageFactory(new Internal::FormPageFactory); addAutoReleasedObject(new FormEditorFactory); @@ -130,21 +144,6 @@ void FormEditorPlugin::extensionsInitialized() // //////////////////////////////////////////////////// -void FormEditorPlugin::initializeTemplates() -{ -#ifdef CPP_ENABLED - IWizardFactory *wizard = new FormClassWizard; - wizard->setWizardKind(IWizardFactory::ClassWizard); - wizard->setCategory(QLatin1String(Core::Constants::WIZARD_CATEGORY_QT)); - wizard->setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::WIZARD_TR_CATEGORY_QT)); - wizard->setDisplayName(tr("Qt Designer Form Class")); - wizard->setId(QLatin1String("C.FormClass")); - wizard->setDescription(tr("Creates a Qt Designer form along with a matching class (C++ header and source file) " - "for implementation purposes. You can add the form and class to an existing Qt Widget Project.")); - addAutoReleasedObject(wizard); -#endif -} - // Find out current existing editor file static QString currentFile() { diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index f1d3c86640f..5a08be7445c 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -215,8 +215,8 @@ void DescriptionEditorWidget::handleCurrentContents() ///////////////////////////////// DiffEditor ////////////////////////////////// -DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) - : m_document(doc) +DiffEditor::DiffEditor() + : m_document(0) , m_descriptionWidget(0) , m_stackedWidget(0) , m_toolBar(0) @@ -233,10 +233,10 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) , m_sync(false) , m_showDescription(true) { - Guard guard(&m_ignoreChanges); - QTC_ASSERT(m_document, return); + // Editor: setDuplicateSupported(true); + // Widget: QSplitter *splitter = new Core::MiniSplitter(Qt::Vertical); m_descriptionWidget = new DescriptionEditorWidget(splitter); @@ -251,67 +251,11 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc) setWidget(splitter); - connect(m_descriptionWidget, &DescriptionEditorWidget::requestBranchList, - m_document.data(), &DiffEditorDocument::requestMoreInformation); - connect(m_document.data(), &DiffEditorDocument::documentChanged, - this, &DiffEditor::documentHasChanged); - connect(m_document.data(), &DiffEditorDocument::descriptionChanged, - this, &DiffEditor::updateDescription); - connect(m_document.data(), &DiffEditorDocument::aboutToReload, - this, &DiffEditor::prepareForReload); - connect(m_document.data(), &DiffEditorDocument::reloadFinished, - this, &DiffEditor::reloadHasFinished); - - toolBar(); - - loadSettings(); - documentHasChanged(); -} - -DiffEditor::~DiffEditor() -{ - delete m_toolBar; - delete m_widget; -} - -Core::IEditor *DiffEditor::duplicate() -{ - return new DiffEditor(m_document); -} - -bool DiffEditor::open(QString *errorString, - const QString &fileName, - const QString &realFileName) -{ - Q_UNUSED(realFileName) - return m_document->open(errorString, fileName); -} - -Core::IDocument *DiffEditor::document() -{ - return m_document.data(); -} - -static QToolBar *createToolBar(IDiffView *someView) -{ - // Create - QToolBar *toolBar = new QToolBar; - toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); - const int size = someView->widget()->style()->pixelMetric(QStyle::PM_SmallIconSize); - toolBar->setIconSize(QSize(size, size)); - - return toolBar; -} - -QWidget *DiffEditor::toolBar() -{ - QTC_ASSERT(!m_views.isEmpty(), return 0); - - if (m_toolBar) - return m_toolBar; - - // Create - m_toolBar = createToolBar(m_views.at(0)); + // Toolbar: + m_toolBar = new QToolBar; + m_toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly); + const int size = m_views.at(0)->widget()->style()->pixelMetric(QStyle::PM_SmallIconSize); + m_toolBar->setIconSize(QSize(size, size)); m_entriesComboBox = new QComboBox; m_entriesComboBox->setMinimumContentsLength(20); @@ -331,14 +275,12 @@ QWidget *DiffEditor::toolBar() m_contextSpinBox = new QSpinBox(m_toolBar); m_contextSpinBox->setRange(1, 100); - m_contextSpinBox->setValue(m_document->contextLineCount()); m_contextSpinBox->setFrame(false); m_contextSpinBox->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); // Mac Qt5 m_toolBar->addWidget(m_contextSpinBox); m_whitespaceButtonAction = m_toolBar->addAction(tr("Ignore Whitespace")); m_whitespaceButtonAction->setCheckable(true); - m_whitespaceButtonAction->setChecked(m_document->ignoreWhitespace()); m_toggleDescriptionAction = m_toolBar->addAction(QIcon(QLatin1String(Constants::ICON_TOP_BAR)), QString()); @@ -347,14 +289,12 @@ QWidget *DiffEditor::toolBar() m_reloadAction = m_toolBar->addAction(QIcon(QLatin1String(Core::Constants::ICON_RELOAD_GRAY)), tr("Reload Diff")); m_reloadAction->setToolTip(tr("Reload Diff")); - documentStateChanged(); m_toggleSyncAction = m_toolBar->addAction(QIcon(QLatin1String(Core::Constants::ICON_LINK)), QString()); m_toggleSyncAction->setCheckable(true); m_viewSwitcherAction = m_toolBar->addAction(QIcon(), QString()); - updateDiffEditorSwitcher(); connect(m_whitespaceButtonAction, &QAction::toggled, this, &DiffEditor::ignoreWhitespaceHasChanged); connect(m_contextSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), @@ -362,10 +302,84 @@ QWidget *DiffEditor::toolBar() connect(m_toggleSyncAction, &QAction::toggled, this, &DiffEditor::toggleSync); connect(m_toggleDescriptionAction, &QAction::toggled, this, &DiffEditor::toggleDescription); connect(m_viewSwitcherAction, &QAction::triggered, this, [this]() { showDiffView(nextView()); }); +} + +void DiffEditor::setDocument(QSharedPointer<DiffEditorDocument>(doc)) +{ + QTC_ASSERT(m_document.isNull(), return); + QTC_ASSERT(doc, return); + + m_document = QSharedPointer<DiffEditorDocument>(doc); + + connect(m_descriptionWidget, &DescriptionEditorWidget::requestBranchList, + m_document.data(), &DiffEditorDocument::requestMoreInformation); + connect(m_document.data(), &DiffEditorDocument::documentChanged, + this, &DiffEditor::documentHasChanged); + connect(m_document.data(), &DiffEditorDocument::descriptionChanged, + this, &DiffEditor::updateDescription); + connect(m_document.data(), &DiffEditorDocument::aboutToReload, + this, &DiffEditor::prepareForReload); + connect(m_document.data(), &DiffEditorDocument::reloadFinished, + this, &DiffEditor::reloadHasFinished); + connect(m_reloadAction, &QAction::triggered, this, [this]() { m_document->reload(); }); connect(m_document.data(), &DiffEditorDocument::temporaryStateChanged, this, &DiffEditor::documentStateChanged); + m_contextSpinBox->setValue(m_document->contextLineCount()); + m_whitespaceButtonAction->setChecked(m_document->ignoreWhitespace()); + + documentStateChanged(); + documentHasChanged(); +} + +DiffEditor::DiffEditor(DiffEditorDocument *doc) : DiffEditor() +{ + Guard guard(&m_ignoreChanges); + setDocument(QSharedPointer<DiffEditorDocument>(doc)); + setupView(loadSettings()); +} + +DiffEditor::~DiffEditor() +{ + delete m_toolBar; + delete m_widget; +} + +Core::IEditor *DiffEditor::duplicate() +{ + DiffEditor *editor = new DiffEditor(); + Guard guard(&editor->m_ignoreChanges); + + editor->setDocument(m_document); + editor->m_sync = m_sync; + editor->m_showDescription = m_showDescription; + + Core::Id id = currentView()->id(); + IDiffView *view = Utils::findOr(editor->m_views, editor->m_views.at(0), + [id](IDiffView *v) { return v->id() == id; }); + QTC_ASSERT(view, view = editor->currentView()); + editor->setupView(view); + + return editor; +} + +bool DiffEditor::open(QString *errorString, + const QString &fileName, + const QString &realFileName) +{ + Q_UNUSED(realFileName) + return m_document->open(errorString, fileName); +} + +Core::IDocument *DiffEditor::document() +{ + return m_document.data(); +} + +QWidget *DiffEditor::toolBar() +{ + QTC_ASSERT(m_toolBar, return 0); return m_toolBar; } @@ -573,9 +587,9 @@ void DiffEditor::toggleSync() currentView()->setSync(m_sync); } -void DiffEditor::loadSettings() +IDiffView *DiffEditor::loadSettings() { - QTC_ASSERT(currentView(), return); + QTC_ASSERT(currentView(), return 0); QSettings *s = Core::ICore::settings(); // TODO: Remove in 3.6: Read legacy settings first: @@ -602,9 +616,9 @@ void DiffEditor::loadSettings() s->endGroup(); IDiffView *view = Utils::findOr(m_views, m_views.at(0), [id](IDiffView *v) { return v->id() == id; }); - QTC_ASSERT(view, return); + QTC_CHECK(view); - setupView(view); + return view; } void DiffEditor::saveSetting(const QString &key, const QVariant &value) const diff --git a/src/plugins/diffeditor/diffeditor.h b/src/plugins/diffeditor/diffeditor.h index 3be67972e41..99875712295 100644 --- a/src/plugins/diffeditor/diffeditor.h +++ b/src/plugins/diffeditor/diffeditor.h @@ -59,10 +59,9 @@ class DiffEditor : public Core::IEditor Q_OBJECT public: - DiffEditor(const QSharedPointer<DiffEditorDocument> &doc); + DiffEditor(DiffEditorDocument *doc); ~DiffEditor(); -public: Core::IEditor *duplicate(); bool open(QString *errorString, @@ -86,7 +85,10 @@ private slots: void toggleSync(); private: - void loadSettings(); + DiffEditor(); + void setDocument(QSharedPointer<DiffEditorDocument> doc); + + IDiffView *loadSettings(); void saveSetting(const QString &key, const QVariant &value) const; void updateEntryToolTip(); void showDiffView(IDiffView *view); diff --git a/src/plugins/diffeditor/diffeditor.pro b/src/plugins/diffeditor/diffeditor.pro index b93d6ae9366..829e7367f5f 100644 --- a/src/plugins/diffeditor/diffeditor.pro +++ b/src/plugins/diffeditor/diffeditor.pro @@ -7,7 +7,6 @@ HEADERS += diffeditor_global.h \ diffeditorcontroller.h \ diffeditordocument.h \ diffeditorfactory.h \ - diffeditormanager.h \ diffeditorplugin.h \ differ.h \ diffutils.h \ @@ -20,7 +19,6 @@ SOURCES += diffeditor.cpp \ diffeditorcontroller.cpp \ diffeditordocument.cpp \ diffeditorfactory.cpp \ - diffeditormanager.cpp \ diffeditorplugin.cpp \ differ.cpp \ diffutils.cpp \ diff --git a/src/plugins/diffeditor/diffeditor.qbs b/src/plugins/diffeditor/diffeditor.qbs index 7b2090c4de5..8a23861f954 100644 --- a/src/plugins/diffeditor/diffeditor.qbs +++ b/src/plugins/diffeditor/diffeditor.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "DiffEditor" Depends { name: "Qt.widgets" } - Depends { name: "Aggregation" } Depends { name: "Utils" } Depends { name: "Core" } @@ -22,8 +21,6 @@ QtcPlugin { "diffeditordocument.h", "diffeditorfactory.cpp", "diffeditorfactory.h", - "diffeditormanager.cpp", - "diffeditormanager.h", "diffeditorplugin.cpp", "diffeditorplugin.h", "differ.cpp", diff --git a/src/plugins/diffeditor/diffeditor_dependencies.pri b/src/plugins/diffeditor/diffeditor_dependencies.pri index 4433db61b30..0458f03fbe8 100644 --- a/src/plugins/diffeditor/diffeditor_dependencies.pri +++ b/src/plugins/diffeditor/diffeditor_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = DiffEditor QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ utils QTC_PLUGIN_DEPENDS += \ diff --git a/src/plugins/diffeditor/diffeditorcontroller.cpp b/src/plugins/diffeditor/diffeditorcontroller.cpp index 5f4cfef23e2..18dd6017958 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorcontroller.cpp @@ -32,6 +32,8 @@ #include "diffeditorcontroller.h" #include "diffeditordocument.h" +#include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/editormanager/ieditor.h> #include <coreplugin/icore.h> #include <utils/qtcassert.h> @@ -82,6 +84,21 @@ QString DiffEditorController::makePatch(bool revert, bool addPrefix) const return m_document->makePatch(m_diffFileIndex, m_chunkIndex, revert, addPrefix); } +Core::IDocument *DiffEditorController::findOrCreateDocument(const QString &vcsId, + const QString &displayName) +{ + QString preferredDisplayName = displayName; + Core::IEditor *editor = Core::EditorManager::openEditorWithContents( + Constants::DIFF_EDITOR_ID, &preferredDisplayName, QByteArray(), vcsId); + return editor ? editor->document() : 0; +} + +DiffEditorController *DiffEditorController::controller(Core::IDocument *document) +{ + auto doc = qobject_cast<Internal::DiffEditorDocument *>(document); + return doc ? doc->controller() : 0; +} + void DiffEditorController::setDiffFiles(const QList<FileData> &diffFileList, const QString &workingDirectory) { diff --git a/src/plugins/diffeditor/diffeditorcontroller.h b/src/plugins/diffeditor/diffeditorcontroller.h index b21946fff20..db1812fc2aa 100644 --- a/src/plugins/diffeditor/diffeditorcontroller.h +++ b/src/plugins/diffeditor/diffeditorcontroller.h @@ -61,6 +61,9 @@ public: QString makePatch(bool revert, bool addPrefix = false) const; + static Core::IDocument *findOrCreateDocument(const QString &vcsId, const QString &displayName); + static DiffEditorController *controller(Core::IDocument *document); + public slots: void informationForCommitReceived(const QString &output); @@ -73,7 +76,7 @@ protected: // inside reload() (for synchronous reload) // or later (for asynchronous reload) virtual void reload() = 0; - void reloadFinished(bool success); + virtual void reloadFinished(bool success); void setDiffFiles(const QList<FileData> &diffFileList, const QString &baseDirectory = QString()); diff --git a/src/plugins/diffeditor/diffeditordocument.cpp b/src/plugins/diffeditor/diffeditordocument.cpp index 510401e95a6..fc979858610 100644 --- a/src/plugins/diffeditor/diffeditordocument.cpp +++ b/src/plugins/diffeditor/diffeditordocument.cpp @@ -31,7 +31,6 @@ #include "diffeditordocument.h" #include "diffeditorconstants.h" #include "diffeditorcontroller.h" -#include "diffeditormanager.h" #include "diffutils.h" #include <utils/fileutils.h> @@ -63,11 +62,6 @@ DiffEditorDocument::DiffEditorDocument() : setTemporary(true); } -DiffEditorDocument::~DiffEditorDocument() -{ - DiffEditorManager::removeDocument(this); -} - /** * @brief Set a controller for a document * @param controller The controller to set. @@ -214,8 +208,6 @@ bool DiffEditorDocument::save(QString *errorString, const QString &fileName, boo if (!ok) return false; - DiffEditorManager::removeDocument(this); - setController(0); setDescription(QString()); diff --git a/src/plugins/diffeditor/diffeditordocument.h b/src/plugins/diffeditor/diffeditordocument.h index 911f4f49aca..62d43766409 100644 --- a/src/plugins/diffeditor/diffeditordocument.h +++ b/src/plugins/diffeditor/diffeditordocument.h @@ -49,7 +49,6 @@ class DiffEditorDocument : public Core::BaseTextDocument Q_PROPERTY(QString plainText READ plainText STORED false) // For access by code pasters public: DiffEditorDocument(); - ~DiffEditorDocument(); DiffEditorController *controller() const; diff --git a/src/plugins/diffeditor/diffeditorfactory.cpp b/src/plugins/diffeditor/diffeditorfactory.cpp index e52b0c5e170..6687cc191bb 100644 --- a/src/plugins/diffeditor/diffeditorfactory.cpp +++ b/src/plugins/diffeditor/diffeditorfactory.cpp @@ -49,7 +49,7 @@ DiffEditorFactory::DiffEditorFactory(QObject *parent) Core::IEditor *DiffEditorFactory::createEditor() { - return new DiffEditor(QSharedPointer<DiffEditorDocument>(new DiffEditorDocument)); + return new DiffEditor(new DiffEditorDocument); } } // namespace Internal diff --git a/src/plugins/diffeditor/diffeditormanager.cpp b/src/plugins/diffeditor/diffeditormanager.cpp deleted file mode 100644 index 5d3388d4a21..00000000000 --- a/src/plugins/diffeditor/diffeditormanager.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "diffeditormanager.h" -#include "diffeditor.h" -#include "diffeditorconstants.h" -#include "diffeditordocument.h" -#include <coreplugin/editormanager/editormanager.h> -#include <coreplugin/editormanager/documentmodel.h> -#include <coreplugin/id.h> -#include <coreplugin/idocument.h> -#include <coreplugin/editormanager/ieditor.h> - -#include <utils/qtcassert.h> - -namespace DiffEditor { - -using namespace Internal; - -static DiffEditorManager *m_instance = 0; - -DiffEditorManager::DiffEditorManager(QObject *parent) - : QObject(parent) -{ - QTC_ASSERT(!m_instance, return); - m_instance = this; -} - -DiffEditorManager::~DiffEditorManager() -{ - m_instance = 0; -} - -Core::IDocument *DiffEditorManager::find(const QString &vcsId) -{ - Core::IDocument *document = m_instance->m_idToDocument.value(vcsId); - QTC_ASSERT(!document || document->isTemporary(), return 0); - return document; -} - -Core::IDocument *DiffEditorManager::findOrCreate(const QString &vcsId, const QString &displayName) -{ - auto document = static_cast<Internal::DiffEditorDocument *>(find(vcsId)); - if (document) - return document; - - DiffEditor *diffEditor = qobject_cast<DiffEditor *>( - Core::EditorManager::openEditorWithContents(Constants::DIFF_EDITOR_ID, 0)); - QTC_ASSERT(diffEditor, return 0); - - document = qobject_cast<Internal::DiffEditorDocument *>(diffEditor->document()); - QTC_ASSERT(document, return 0); - - document->setPreferredDisplayName(displayName); - - m_instance->m_idToDocument.insert(vcsId, document); - - return document; -} - -DiffEditorController *DiffEditorManager::controller(Core::IDocument *document) -{ - auto doc = qobject_cast<DiffEditorDocument *>(document); - return doc ? doc->controller() : 0; -} - -void DiffEditorManager::removeDocument(Core::IDocument *document) -{ - DiffEditorDocument *doc = qobject_cast<DiffEditorDocument *>(document); - QTC_ASSERT(doc, return); - for (auto it = m_instance->m_idToDocument.constBegin(); it != m_instance->m_idToDocument.constEnd(); ++it) { - if (it.value() == doc) { - m_instance->m_idToDocument.remove(it.key()); - break; - } - } -} - -} // namespace DiffEditor diff --git a/src/plugins/diffeditor/diffeditormanager.h b/src/plugins/diffeditor/diffeditormanager.h deleted file mode 100644 index 80f50b4ec7c..00000000000 --- a/src/plugins/diffeditor/diffeditormanager.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef DIFFEDITORMANAGER_H -#define DIFFEDITORMANAGER_H - -#include "diffeditor_global.h" - -#include <QMap> -#include <QObject> - -namespace Core { -class IDocument; -class IEditor; -} - -namespace DiffEditor { - -class DiffEditorController; - -namespace Internal { class DiffEditorDocument; } - -class DIFFEDITOR_EXPORT DiffEditorManager : public QObject -{ - Q_OBJECT -public: - explicit DiffEditorManager(QObject *parent); - virtual ~DiffEditorManager(); - - static Core::IDocument *findOrCreate(const QString &vcsId, const QString &displayName); - static DiffEditorController *controller(Core::IDocument *document); - -private: - static Core::IDocument *find(const QString &vcsId); - static void removeDocument(Core::IDocument *document); - - QMap<QString, Internal::DiffEditorDocument *> m_idToDocument; - - friend class Internal::DiffEditorDocument; -}; - -} // namespace DiffEditor - -#endif // DIFFEDITORMANAGER_H diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index e87f8aaa900..2a69205e43d 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -34,7 +34,6 @@ #include "diffeditorcontroller.h" #include "diffeditordocument.h" #include "diffeditorfactory.h" -#include "diffeditormanager.h" #include "differ.h" #include <QAction> @@ -148,8 +147,6 @@ bool DiffEditorPlugin::initialize(const QStringList &arguments, QString *errorMe addAutoReleasedObject(new DiffEditorFactory(this)); - new DiffEditorManager(this); - return true; } @@ -173,15 +170,14 @@ void DiffEditorPlugin::diff() const QString documentId = QLatin1String("Diff ") + fileName1 + QLatin1String(", ") + fileName2; QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1).arg(fileName2); - auto const document - = qobject_cast<DiffEditorDocument *>(DiffEditorManager::findOrCreate(documentId, title)); + auto const document = qobject_cast<DiffEditorDocument *>( + DiffEditorController::findOrCreateDocument(documentId, title)); if (!document) return; - DiffEditorController *controller = DiffEditorManager::controller(document); + DiffEditorController *controller = DiffEditorController::controller(document); if (!controller) controller = new FileDiffController(document, fileName1, fileName2); - QTC_ASSERT(controller, return); Core::EditorManager::activateEditorForDocument(document); document->reload(); } diff --git a/src/plugins/diffeditor/diffutils.cpp b/src/plugins/diffeditor/diffutils.cpp index 0e16becbdf6..9bc5d3a75e2 100644 --- a/src/plugins/diffeditor/diffutils.cpp +++ b/src/plugins/diffeditor/diffutils.cpp @@ -868,6 +868,11 @@ static QList<FileData> readDiffPatch(const QString &patch, return fileDataList; } +static bool fileNameEnd(const QChar &c) +{ + return c == QLatin1Char('\n') || c == QLatin1Char('\t'); +} + static FileData readGitHeaderAndChunks(const QString &headerAndChunks, const QString &fileName, bool *ok) @@ -909,34 +914,30 @@ static FileData readGitHeaderAndChunks(const QString &headerAndChunks, patch.remove(0, indexRegExp.matchedLength()); } - const QRegExp leftFileRegExp(QLatin1String("^-{3} ") // "--- " - + leftFileName // "a/fileName" or "/dev/null" - + QLatin1String("(?:\\t[^\\n]*)*\\n")); // optionally followed by: \t anything \t anything ...) - const QRegExp rightFileRegExp(QLatin1String("^\\+{3} ") // "+++ " - + rightFileName // "b/fileName" or "/dev/null" - + QLatin1String("(?:\\t[^\\n]*)*\\n")); // optionally followed by: \t anything \t anything ...) - const QRegExp binaryRegExp(QLatin1String("^Binary files ") - + leftFileName - + QLatin1String(" and ") - + rightFileName - + QLatin1String(" differ$")); + const QString binaryLine = QString::fromLatin1("Binary files ") + leftFileName + + QLatin1String(" and ") + rightFileName + QLatin1String(" differ"); + const QString leftStart = QString::fromLatin1("--- ") + leftFileName; + QChar leftFollow = patch.count() > leftStart.count() ? patch.at(leftStart.count()) : QLatin1Char('\n'); // empty or followed either by leftFileRegExp or by binaryRegExp if (patch.isEmpty() && (fileData.fileOperation == FileData::NewFile || fileData.fileOperation == FileData::DeleteFile)) { readOk = true; - } else if (leftFileRegExp.indexIn(patch) == 0) { - patch.remove(0, leftFileRegExp.matchedLength()); + } else if (patch.startsWith(leftStart) && fileNameEnd(leftFollow)) { + patch.remove(0, patch.indexOf(QLatin1Char('\n'), leftStart.count()) + 1); + + const QString rightStart = QString::fromLatin1("+++ ") + rightFileName; + QChar rightFollow = patch.count() > rightStart.count() ? patch.at(rightStart.count()) : QLatin1Char('\n'); // followed by rightFileRegExp - if (rightFileRegExp.indexIn(patch) == 0) { - patch.remove(0, rightFileRegExp.matchedLength()); + if (patch.startsWith(rightStart) && fileNameEnd(rightFollow)) { + patch.remove(0, patch.indexOf(QLatin1Char('\n'), rightStart.count()) + 1); fileData.chunks = readChunks(patch, &fileData.lastChunkAtTheEndOfFile, &readOk); } - } else if (binaryRegExp.indexIn(patch) == 0) { + } else if (patch == binaryLine) { readOk = true; fileData.binaryFiles = true; } @@ -966,9 +967,6 @@ static FileData readCopyRenameChunks(const QString ©RenameChunks, const QRegExp indexRegExp(QLatin1String("^index (\\w+)\\.{2}(\\w+)(?: \\d+)?(\\n|$)")); // index cap1..cap2(optionally: octal) - QString leftGitFileName = QLatin1String("a/") + leftFileName; - QString rightGitFileName = QLatin1String("b/") + rightFileName; - if (fileOperation == FileData::CopyFile || fileOperation == FileData::RenameFile) { if (indexRegExp.indexIn(patch) == 0) { fileData.leftFileInfo.typeInfo = indexRegExp.cap(1); @@ -976,20 +974,20 @@ static FileData readCopyRenameChunks(const QString ©RenameChunks, patch.remove(0, indexRegExp.matchedLength()); - const QRegExp leftFileRegExp(QLatin1String("^-{3} ") // "--- " - + leftGitFileName // "a/fileName" or "/dev/null" - + QLatin1String("(?:\\t[^\\n]*)*\\n")); // optionally followed by: \t anything \t anything ...) - const QRegExp rightFileRegExp(QLatin1String("^\\+{3} ") // "+++ " - + rightGitFileName // "b/fileName" or "/dev/null" - + QLatin1String("(?:\\t[^\\n]*)*\\n")); // optionally followed by: \t anything \t anything ...) + const QString leftStart = QString::fromLatin1("--- a/") + leftFileName; + QChar leftFollow = patch.count() > leftStart.count() ? patch.at(leftStart.count()) : QLatin1Char('\n'); // followed by leftFileRegExp - if (leftFileRegExp.indexIn(patch) == 0) { - patch.remove(0, leftFileRegExp.matchedLength()); + if (patch.startsWith(leftStart) && fileNameEnd(leftFollow)) { + patch.remove(0, patch.indexOf(QLatin1Char('\n'), leftStart.count()) + 1); + + // followed by rightFileRegExp + const QString rightStart = QString::fromLatin1("+++ b/") + rightFileName; + QChar rightFollow = patch.count() > rightStart.count() ? patch.at(rightStart.count()) : QLatin1Char('\n'); // followed by rightFileRegExp - if (rightFileRegExp.indexIn(patch) == 0) { - patch.remove(0, rightFileRegExp.matchedLength()); + if (patch.startsWith(rightStart) && fileNameEnd(rightFollow)) { + patch.remove(0, patch.indexOf(QLatin1Char('\n'), rightStart.count()) + 1); fileData.chunks = readChunks(patch, &fileData.lastChunkAtTheEndOfFile, diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index ffa5f480478..633f04db59a 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -631,14 +631,14 @@ void SideBySideDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex) QTextCursor leftCursor = m_leftEditor->textCursor(); leftCursor.setPosition(leftBlock.position()); m_leftEditor->setTextCursor(leftCursor); + m_leftEditor->verticalScrollBar()->setValue(blockNumber); QTextBlock rightBlock = m_rightEditor->document()->findBlockByNumber(blockNumber); QTextCursor rightCursor = m_rightEditor->textCursor(); rightCursor.setPosition(rightBlock.position()); m_rightEditor->setTextCursor(rightCursor); + m_rightEditor->verticalScrollBar()->setValue(blockNumber); - m_leftEditor->centerCursor(); - m_rightEditor->centerCursor(); m_ignoreCurrentIndexChange = oldIgnore; } diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index e94f21b2380..fbc3a220642 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -37,6 +37,7 @@ #include <QPlainTextEdit> #include <QMenu> #include <QPlainTextDocumentLayout> +#include <QScrollBar> #include <QTextBlock> #include <QTextCodec> #include <QPainter> @@ -734,7 +735,7 @@ void UnifiedDiffEditorWidget::setCurrentDiffFileIndex(int diffFileIndex) QTextCursor cursor = textCursor(); cursor.setPosition(block.position()); setTextCursor(cursor); - centerCursor(); + verticalScrollBar()->setValue(blockNumber); m_ignoreCurrentIndexChange = oldIgnore; } diff --git a/src/plugins/fakevim/fakevim_test.cpp b/src/plugins/fakevim/fakevim_test.cpp index 2f6ef057caa..5cef7cc793e 100644 --- a/src/plugins/fakevim/fakevim_test.cpp +++ b/src/plugins/fakevim/fakevim_test.cpp @@ -2184,6 +2184,20 @@ void FakeVimPlugin::test_vim_search() data.setText("abc" N "def" N "abc" N "ghi abc jkl" N "xyz"); KEYS("vj" "/abc<ESC>" "x", X "ef" N "abc" N "ghi abc jkl" N "xyz"); KEYS("vj" "/xxx<CR>" "x", X "bc" N "ghi abc jkl" N "xyz"); + + // insert word under cursor (C-R C-W) + data.setText("abc def ghi def."); + KEYS("fe/<C-R><C-W><CR>", "abc def ghi " X "def."); + // insert register (C-R{register}) + data.setText("abc def ghi def."); + KEYS("feyiw/<C-R>0<CR>", "abc def ghi " X "def."); + // insert non-existing register + data.setText("abc def ghi def."); + KEYS("feyiw/<C-R>adef<CR>", "abc def ghi " X "def."); + // abort C-R via Esc + data.doCommand("set noincsearch"); + data.setText("abc def ghi def."); + KEYS("fe/d<C-R><ESC>ef<CR>", "abc def ghi " X "def."); } void FakeVimPlugin::test_vim_indent() @@ -2526,6 +2540,14 @@ void FakeVimPlugin::test_vim_copy_paste() // yank register is only used for y{motion} commands data.setText("aaa bbb ccc"); KEYS("yiwwdiw\"0P", "aaa aaa ccc"); + + // paste register in insert mode + data.setText("aaa bbb ccc "); + KEYS("yiwA<C-r>0", "aaa bbb ccc aaa"); + KEYS("<C-r><Esc>x", "aaa bbb ccc aaax"); + KEYS("<Esc>dd", ""); + data.setText("aaa bbb"); + KEYS("\"ayawA<C-r>a", "aaa bbbaaa "); } void FakeVimPlugin::test_vim_undo_redo() @@ -2991,6 +3013,15 @@ void FakeVimPlugin::test_vim_substitute() COMMAND("undo | s/f\\|$/-/g", "abc de-"); } +void FakeVimPlugin::test_vim_ex_commandbuffer_paste() +{ + TestData data; + setup(&data); + + data.setText("abc def abc def xyz"); + KEYS("fyyiw0:s/<C-R><C-W>/<C-R>0/g<CR>", "xyz def xyz def xyz"); +} + void FakeVimPlugin::test_vim_ex_yank() { TestData data; diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 828b0e18da5..40ee16666a7 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -193,7 +193,8 @@ enum SubMode ReplaceSubMode, // Used for r MacroRecordSubMode, // Used for q MacroExecuteSubMode, // Used for @ - CtrlVSubMode // Used for Ctrl-v in insert mode + CtrlVSubMode, // Used for Ctrl-v in insert mode + CtrlRSubMode // Used for Ctrl-r in insert mode }; /*! A \e SubSubMode is used for things that require one more data item @@ -781,91 +782,89 @@ static QString getProcessOutput(const QString &command, const QString &input) static const QMap<QString, int> &vimKeyNames() { - static QMap<QString, int> k; - if (!k.isEmpty()) - return k; - - // FIXME: Should be value of mapleader. - k.insert(_("LEADER"), Key_Backslash); - - k.insert(_("SPACE"), Key_Space); - k.insert(_("TAB"), Key_Tab); - k.insert(_("NL"), Key_Return); - k.insert(_("NEWLINE"), Key_Return); - k.insert(_("LINEFEED"), Key_Return); - k.insert(_("LF"), Key_Return); - k.insert(_("CR"), Key_Return); - k.insert(_("RETURN"), Key_Return); - k.insert(_("ENTER"), Key_Return); - k.insert(_("BS"), Key_Backspace); - k.insert(_("BACKSPACE"), Key_Backspace); - k.insert(_("ESC"), Key_Escape); - k.insert(_("BAR"), Key_Bar); - k.insert(_("BSLASH"), Key_Backslash); - k.insert(_("DEL"), Key_Delete); - k.insert(_("DELETE"), Key_Delete); - k.insert(_("KDEL"), Key_Delete); - k.insert(_("UP"), Key_Up); - k.insert(_("DOWN"), Key_Down); - k.insert(_("LEFT"), Key_Left); - k.insert(_("RIGHT"), Key_Right); - - k.insert(_("LT"), Key_Less); - k.insert(_("GT"), Key_Greater); - - k.insert(_("F1"), Key_F1); - k.insert(_("F2"), Key_F2); - k.insert(_("F3"), Key_F3); - k.insert(_("F4"), Key_F4); - k.insert(_("F5"), Key_F5); - k.insert(_("F6"), Key_F6); - k.insert(_("F7"), Key_F7); - k.insert(_("F8"), Key_F8); - k.insert(_("F9"), Key_F9); - k.insert(_("F10"), Key_F10); - - k.insert(_("F11"), Key_F11); - k.insert(_("F12"), Key_F12); - k.insert(_("F13"), Key_F13); - k.insert(_("F14"), Key_F14); - k.insert(_("F15"), Key_F15); - k.insert(_("F16"), Key_F16); - k.insert(_("F17"), Key_F17); - k.insert(_("F18"), Key_F18); - k.insert(_("F19"), Key_F19); - k.insert(_("F20"), Key_F20); - - k.insert(_("F21"), Key_F21); - k.insert(_("F22"), Key_F22); - k.insert(_("F23"), Key_F23); - k.insert(_("F24"), Key_F24); - k.insert(_("F25"), Key_F25); - k.insert(_("F26"), Key_F26); - k.insert(_("F27"), Key_F27); - k.insert(_("F28"), Key_F28); - k.insert(_("F29"), Key_F29); - k.insert(_("F30"), Key_F30); - - k.insert(_("F31"), Key_F31); - k.insert(_("F32"), Key_F32); - k.insert(_("F33"), Key_F33); - k.insert(_("F34"), Key_F34); - k.insert(_("F35"), Key_F35); - - k.insert(_("INSERT"), Key_Insert); - k.insert(_("INS"), Key_Insert); - k.insert(_("KINSERT"), Key_Insert); - k.insert(_("HOME"), Key_Home); - k.insert(_("END"), Key_End); - k.insert(_("PAGEUP"), Key_PageUp); - k.insert(_("PAGEDOWN"), Key_PageDown); - - k.insert(_("KPLUS"), Key_Plus); - k.insert(_("KMINUS"), Key_Minus); - k.insert(_("KDIVIDE"), Key_Slash); - k.insert(_("KMULTIPLY"), Key_Asterisk); - k.insert(_("KENTER"), Key_Enter); - k.insert(_("KPOINT"), Key_Period); + static const QMap<QString, int> k = { + // FIXME: Should be value of mapleader. + { _("LEADER"), Key_Backslash }, + + { _("SPACE"), Key_Space }, + { _("TAB"), Key_Tab }, + { _("NL"), Key_Return }, + { _("NEWLINE"), Key_Return }, + { _("LINEFEED"), Key_Return }, + { _("LF"), Key_Return }, + { _("CR"), Key_Return }, + { _("RETURN"), Key_Return }, + { _("ENTER"), Key_Return }, + { _("BS"), Key_Backspace }, + { _("BACKSPACE"), Key_Backspace }, + { _("ESC"), Key_Escape }, + { _("BAR"), Key_Bar }, + { _("BSLASH"), Key_Backslash }, + { _("DEL"), Key_Delete }, + { _("DELETE"), Key_Delete }, + { _("KDEL"), Key_Delete }, + { _("UP"), Key_Up }, + { _("DOWN"), Key_Down }, + { _("LEFT"), Key_Left }, + { _("RIGHT"), Key_Right }, + + { _("LT"), Key_Less }, + { _("GT"), Key_Greater }, + + { _("F1"), Key_F1 }, + { _("F2"), Key_F2 }, + { _("F3"), Key_F3 }, + { _("F4"), Key_F4 }, + { _("F5"), Key_F5 }, + { _("F6"), Key_F6 }, + { _("F7"), Key_F7 }, + { _("F8"), Key_F8 }, + { _("F9"), Key_F9 }, + { _("F10"), Key_F10 }, + + { _("F11"), Key_F11 }, + { _("F12"), Key_F12 }, + { _("F13"), Key_F13 }, + { _("F14"), Key_F14 }, + { _("F15"), Key_F15 }, + { _("F16"), Key_F16 }, + { _("F17"), Key_F17 }, + { _("F18"), Key_F18 }, + { _("F19"), Key_F19 }, + { _("F20"), Key_F20 }, + + { _("F21"), Key_F21 }, + { _("F22"), Key_F22 }, + { _("F23"), Key_F23 }, + { _("F24"), Key_F24 }, + { _("F25"), Key_F25 }, + { _("F26"), Key_F26 }, + { _("F27"), Key_F27 }, + { _("F28"), Key_F28 }, + { _("F29"), Key_F29 }, + { _("F30"), Key_F30 }, + + { _("F31"), Key_F31 }, + { _("F32"), Key_F32 }, + { _("F33"), Key_F33 }, + { _("F34"), Key_F34 }, + { _("F35"), Key_F35 }, + + { _("INSERT"), Key_Insert }, + { _("INS"), Key_Insert }, + { _("KINSERT"), Key_Insert }, + { _("HOME"), Key_Home }, + { _("END"), Key_End }, + { _("PAGEUP"), Key_PageUp }, + { _("PAGEDOWN"), Key_PageDown }, + + { _("KPLUS"), Key_Plus }, + { _("KMINUS"), Key_Minus }, + { _("KDIVIDE"), Key_Slash }, + { _("KMULTIPLY"), Key_Asterisk }, + { _("KENTER"), Key_Enter }, + { _("KPOINT"), Key_Period } + }; return k; } @@ -1682,6 +1681,7 @@ public: EventResult handleKey(const Input &input); EventResult handleDefaultKey(const Input &input); + bool handleCommandBufferPaste(const Input &input); EventResult handleCurrentMapAsDefault(); void prependInputs(const QVector<Input> &inputs); // Handle inputs. void prependMapping(const Inputs &inputs); // Handle inputs as mapping. @@ -1913,6 +1913,8 @@ public: // changes externally (e.g. by code completion). void pullCursor(); + QTextCursor editorCursor() const; + // Values to save when starting FakeVim processing. int m_firstVisibleLine; QTextCursor m_cursor; @@ -2245,6 +2247,7 @@ public: SubSubMode subsubmode; Input subsubdata; VisualMode visualMode; + Input minibufferData; // [count] for current command, 0 if no [count] available int mvcount; @@ -2403,7 +2406,7 @@ void FakeVimHandler::Private::fixExternalCursor(bool focus) void FakeVimHandler::Private::fixExternalCursorPosition(bool focus) { - QTextCursor tc = EDITOR(textCursor()); + QTextCursor tc = editorCursor(); if (tc.anchor() < tc.position()) { tc.movePosition(focus ? Left : Right, KeepAnchor); EDITOR(setTextCursor(tc)); @@ -2708,7 +2711,7 @@ void FakeVimHandler::Private::restoreWidget(int tabSize) EventResult FakeVimHandler::Private::handleKey(const Input &input) { - KEY_DEBUG("HANDLE INPUT: " << input << " MODE: " << mode); + KEY_DEBUG("HANDLE INPUT: " << input); bool hasInput = input.isValid(); @@ -2757,8 +2760,44 @@ EventResult FakeVimHandler::Private::handleKey(const Input &input) return r; } +bool FakeVimHandler::Private::handleCommandBufferPaste(const Input &input) +{ + if (input.isControl('r') + && (g.subsubmode == SearchSubSubMode || g.mode == ExMode)) { + g.minibufferData = input; + return true; + } + if (g.minibufferData.isControl('r')) { + g.minibufferData = Input(); + if (input.isEscape()) + return true; + CommandBuffer &buffer = (g.subsubmode == SearchSubSubMode) + ? g.searchBuffer : g.commandBuffer; + if (input.isControl('w')) { + QTextCursor tc = m_cursor; + tc.select(QTextCursor::WordUnderCursor); + QString word = tc.selectedText(); + buffer.insertText(word); + } else { + QString r = registerContents(input.asChar().unicode()); + buffer.insertText(r); + } + updateMiniBuffer(); + return true; + } + return false; +} + EventResult FakeVimHandler::Private::handleDefaultKey(const Input &input) { + if (g.passing) { + passShortcuts(false); + QKeyEvent event(QEvent::KeyPress, input.key(), input.modifiers(), input.text()); + bool accepted = QApplication::sendEvent(editor()->window(), &event); + if (accepted || (!m_textedit && !m_plaintextedit)) + return EventHandled; + } + if (input == Nop) return EventHandled; else if (g.subsubmode == SearchSubSubMode) @@ -3183,7 +3222,7 @@ void FakeVimHandler::Private::pullCursor() if (visualBlockMode) q->requestBlockSelection(&m_cursor); else if (editor()) - m_cursor = EDITOR(textCursor()); + m_cursor = editorCursor(); // Cursor should be always valid. if (m_cursor.isNull()) @@ -3212,6 +3251,13 @@ void FakeVimHandler::Private::pullCursor() setTargetColumn(); } +QTextCursor FakeVimHandler::Private::editorCursor() const +{ + QTextCursor tc = EDITOR(textCursor()); + tc.setVisualNavigation(false); + return tc; +} + bool FakeVimHandler::Private::moveToNextParagraph(int count) { const bool forward = count > 0; @@ -3629,6 +3675,10 @@ void FakeVimHandler::Private::updateMiniBuffer() msg = _("VISUAL BLOCK"); } else if (g.mode == InsertMode) { msg = _("-- INSERT --"); + if (g.submode == CtrlRSubMode) + msg += _(" ^R"); + else if (g.submode == CtrlVSubMode) + msg += _(" ^V"); } else if (g.mode == ReplaceMode) { msg = _("-- REPLACE --"); } else { @@ -4848,7 +4898,16 @@ void FakeVimHandler::Private::finishInsertMode() void FakeVimHandler::Private::handleInsertMode(const Input &input) { if (input.isEscape()) { - finishInsertMode(); + if (g.submode == CtrlRSubMode || g.submode == CtrlVSubMode) { + g.submode = NoSubMode; + g.subsubmode = NoSubSubMode; + updateMiniBuffer(); + } else { + finishInsertMode(); + } + } else if (g.submode == CtrlRSubMode) { + m_cursor.insertText(registerContents(input.asChar().unicode())); + g.submode = NoSubMode; } else if (g.submode == CtrlVSubMode) { if (g.subsubmode == NoSubSubMode) { g.subsubmode = CtrlVUnicodeSubSubMode; @@ -4908,6 +4967,11 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input) } else if (input.isControl('v')) { g.submode = CtrlVSubMode; g.subsubmode = NoSubSubMode; + updateMiniBuffer(); + } else if (input.isControl('r')) { + g.submode = CtrlRSubMode; + g.subsubmode = NoSubSubMode; + updateMiniBuffer(); } else if (input.isControl('w')) { const int blockNumber = m_cursor.blockNumber(); const int endPos = position(); @@ -5128,6 +5192,10 @@ bool FakeVimHandler::Private::executeRegister(int reg) EventResult FakeVimHandler::Private::handleExMode(const Input &input) { + // handle C-R, C-R C-W, C-R {register} + if (handleCommandBufferPaste(input)) + return EventHandled; + if (input.isEscape()) { g.commandBuffer.clear(); leaveCurrentMode(); @@ -5167,6 +5235,10 @@ EventResult FakeVimHandler::Private::handleSearchSubSubMode(const Input &input) { EventResult handled = EventHandled; + // handle C-R, C-R C-W, C-R {register} + if (handleCommandBufferPaste(input)) + return handled; + if (input.isEscape()) { g.currentMessage.clear(); setPosition(m_searchStartPosition); @@ -7271,7 +7343,7 @@ bool FakeVimHandler::Private::passEventToEditor(QEvent &event, QTextCursor &tc) return false; if (accepted) - tc = EDITOR(textCursor()); + tc = editorCursor(); return accepted; } @@ -7595,7 +7667,7 @@ void FakeVimHandler::Private::onCursorPositionChanged() // Selecting text with mouse disables the thick cursor so it's more obvious // that extra character under cursor is not selected when moving text around or // making operations on text outside FakeVim mode. - setThinCursor(g.mode == InsertMode || EDITOR(textCursor()).hasSelection()); + setThinCursor(g.mode == InsertMode || editorCursor().hasSelection()); } } @@ -8543,7 +8615,8 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev) return res == EventHandled || res == EventCancelled; } - if (ev->type() == QEvent::ShortcutOverride && ob == d->editor()) { + if (ev->type() == QEvent::ShortcutOverride && (ob == d->editor() + || (Private::g.mode == ExMode || Private::g.subsubmode == SearchSubSubMode))) { QKeyEvent *kev = static_cast<QKeyEvent *>(ev); if (d->wantsOverride(kev)) { KEY_DEBUG("OVERRIDING SHORTCUT" << kev->key()); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index c482f0605e8..c720324923c 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -539,7 +539,63 @@ void FakeVimOptionPage::updateVimRcWidgets() enum { CommandRole = Qt::UserRole }; -class FakeVimExCommandsPage : public CommandMappings +class FakeVimExCommandsWidget : public CommandMappings +{ + Q_OBJECT + +public: + FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent = 0); + +protected: + void commandChanged(); + void resetToDefault(); + void defaultAction() override; + + void handleCurrentCommandChanged(QTreeWidgetItem *current); + +private: + void initialize(); + + ExCommandMap &exCommandMap(); + ExCommandMap &defaultExCommandMap(); + + FakeVimPluginPrivate *m_q; + QGroupBox *m_commandBox; + Utils::FancyLineEdit *m_commandEdit; +}; + +FakeVimExCommandsWidget::FakeVimExCommandsWidget(FakeVimPluginPrivate *q, QWidget *parent) + : CommandMappings(parent), m_q(q) +{ + setPageTitle(Tr::tr("Ex Command Mapping")); + setTargetHeader(Tr::tr("Ex Trigger Expression")); + setImportExportEnabled(false); + + connect(this, &FakeVimExCommandsWidget::currentCommandChanged, + this, &FakeVimExCommandsWidget::handleCurrentCommandChanged); + + m_commandBox = new QGroupBox(Tr::tr("Ex Command"), this); + m_commandBox->setEnabled(false); + auto boxLayout = new QHBoxLayout(m_commandBox); + m_commandEdit = new Utils::FancyLineEdit(m_commandBox); + m_commandEdit->setFiltering(true); + m_commandEdit->setPlaceholderText(QString()); + connect(m_commandEdit, &Utils::FancyLineEdit::textChanged, + this, &FakeVimExCommandsWidget::commandChanged); + auto resetButton = new QPushButton(Tr::tr("Reset"), m_commandBox); + resetButton->setToolTip(Tr::tr("Reset to default.")); + connect(resetButton, &QPushButton::clicked, + this, &FakeVimExCommandsWidget::resetToDefault); + boxLayout->addWidget(new QLabel(Tr::tr("Regular expression:"))); + boxLayout->addWidget(m_commandEdit); + boxLayout->addWidget(resetButton); + + layout()->addWidget(m_commandBox); + + initialize(); +} + +class FakeVimExCommandsPage : public IOptionsPage { Q_OBJECT @@ -554,34 +610,28 @@ public: setCategoryIcon(_(SETTINGS_CATEGORY_FAKEVIM_ICON)); } - QWidget *widget(); - void initialize(); - ExCommandMap &exCommandMap(); - ExCommandMap &defaultExCommandMap(); - -public slots: - void commandChanged(QTreeWidgetItem *current); - void targetIdentifierChanged(); - void resetTargetIdentifier(); - void removeTargetIdentifier(); - void defaultAction(); + QWidget *widget() override; + void apply() override {} + void finish() override; private: FakeVimPluginPrivate *m_q; + QPointer<QWidget> m_widget; }; QWidget *FakeVimExCommandsPage::widget() { - QWidget *w = CommandMappings::widget(); - setPageTitle(Tr::tr("Ex Command Mapping")); - setTargetHeader(Tr::tr("Ex Trigger Expression")); - setTargetLabelText(Tr::tr("Regular expression:")); - setTargetEditTitle(Tr::tr("Ex Command")); - setImportExportEnabled(false); - return w; + if (!m_widget) + m_widget = new FakeVimExCommandsWidget(m_q); + return m_widget; +} + +void FakeVimExCommandsPage::finish() +{ + delete m_widget; } -void FakeVimExCommandsPage::initialize() +void FakeVimExCommandsWidget::initialize() { QMap<QString, QTreeWidgetItem *> sections; @@ -619,24 +669,28 @@ void FakeVimExCommandsPage::initialize() setModified(item, true); } - commandChanged(0); + handleCurrentCommandChanged(0); } -void FakeVimExCommandsPage::commandChanged(QTreeWidgetItem *current) +void FakeVimExCommandsWidget::handleCurrentCommandChanged(QTreeWidgetItem *current) { - CommandMappings::commandChanged(current); - if (current) - targetEdit()->setText(current->text(2)); + if (current) { + m_commandEdit->setText(current->text(2)); + m_commandBox->setEnabled(true); + } else { + m_commandEdit->clear(); + m_commandBox->setEnabled(false); + } } -void FakeVimExCommandsPage::targetIdentifierChanged() +void FakeVimExCommandsWidget::commandChanged() { QTreeWidgetItem *current = commandList()->currentItem(); if (!current) return; const QString name = current->data(0, CommandRole).toString(); - const QString regex = targetEdit()->text(); + const QString regex = m_commandEdit->text(); if (current->data(0, Qt::UserRole).isValid()) { current->setText(2, regex); @@ -646,7 +700,7 @@ void FakeVimExCommandsPage::targetIdentifierChanged() setModified(current, regex != defaultExCommandMap()[name].pattern()); } -void FakeVimExCommandsPage::resetTargetIdentifier() +void FakeVimExCommandsWidget::resetToDefault() { QTreeWidgetItem *current = commandList()->currentItem(); if (!current) @@ -655,15 +709,10 @@ void FakeVimExCommandsPage::resetTargetIdentifier() QString regex; if (defaultExCommandMap().contains(name)) regex = defaultExCommandMap()[name].pattern(); - targetEdit()->setText(regex); -} - -void FakeVimExCommandsPage::removeTargetIdentifier() -{ - targetEdit()->clear(); + m_commandEdit->setText(regex); } -void FakeVimExCommandsPage::defaultAction() +void FakeVimExCommandsWidget::defaultAction() { int n = commandList()->topLevelItemCount(); for (int i = 0; i != n; ++i) { @@ -678,7 +727,7 @@ void FakeVimExCommandsPage::defaultAction() setModified(item, false); item->setText(2, regex); if (item == commandList()->currentItem()) - commandChanged(item); + currentCommandChanged(item); } } } @@ -987,7 +1036,7 @@ public: FakeVimPluginPrivate(FakeVimPlugin *); ~FakeVimPluginPrivate(); friend class FakeVimPlugin; - friend class FakeVimExCommandsPage; + friend class FakeVimExCommandsWidget; friend class FakeVimUserCommandsPage; friend class FakeVimUserCommandsModel; @@ -2201,12 +2250,12 @@ void FakeVimPluginPrivate::switchToFile(int n) EditorManager::activateEditorForEntry(DocumentModel::entries().at(n)); } -ExCommandMap &FakeVimExCommandsPage::exCommandMap() +ExCommandMap &FakeVimExCommandsWidget::exCommandMap() { return m_q->exCommandMap(); } -ExCommandMap &FakeVimExCommandsPage::defaultExCommandMap() +ExCommandMap &FakeVimExCommandsWidget::defaultExCommandMap() { return m_q->defaultExCommandMap(); } diff --git a/src/plugins/fakevim/fakevimplugin.h b/src/plugins/fakevim/fakevimplugin.h index ece5052ad2e..4a1f8cdd187 100644 --- a/src/plugins/fakevim/fakevimplugin.h +++ b/src/plugins/fakevim/fakevimplugin.h @@ -105,6 +105,7 @@ private slots: void test_vim_code_folding(); void test_vim_code_completion(); void test_vim_substitute(); + void test_vim_ex_commandbuffer_paste(); void test_vim_ex_yank(); void test_vim_ex_delete(); void test_vim_ex_change(); diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index ce33b8a889d..f006984922d 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -46,7 +46,9 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/kitmanager.h> #include <projectexplorer/projectexplorerconstants.h> +#include <qtsupport/baseqtversion.h> #include <qtsupport/customexecutablerunconfiguration.h> +#include <qtsupport/qtkitinformation.h> #include <utils/fileutils.h> #include <utils/qtcassert.h> @@ -349,6 +351,17 @@ void GenericProject::refreshCppCodeModel() CppTools::ProjectInfo pInfo(this); CppTools::ProjectPartBuilder ppBuilder(pInfo); + + CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt; + if (QtSupport::BaseQtVersion *qtVersion = + QtSupport::QtKitInformation::qtVersion(activeTarget()->kit())) { + if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0)) + activeQtVersion = CppTools::ProjectPart::Qt4; + else + activeQtVersion = CppTools::ProjectPart::Qt5; + } + + ppBuilder.setQtVersion(activeQtVersion); ppBuilder.setIncludePaths(projectIncludePaths()); ppBuilder.setConfigFileName(configFileName()); ppBuilder.setCxxFlags(QStringList() << QLatin1String("-std=c++11")); diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp index cb0f5b46239..35e4d1bff11 100644 --- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp +++ b/src/plugins/genericprojectmanager/genericprojectnodes.cpp @@ -120,6 +120,8 @@ void GenericProjectNode::refresh(QSet<QString> oldFileList) QList<FileNode *> fileNodes; foreach (const QString &file, it.value()) { FileType fileType = SourceType; // ### FIXME + if (file.endsWith(QLatin1String(".qrc"))) + fileType = ResourceType; FileNode *fileNode = new FileNode(Utils::FileName::fromString(file), fileType, /*generated = */ false); fileNodes.append(fileNode); diff --git a/src/plugins/genericprojectmanager/genericprojectplugin.cpp b/src/plugins/genericprojectmanager/genericprojectplugin.cpp index 2b784b24346..2a595b4d26a 100644 --- a/src/plugins/genericprojectmanager/genericprojectplugin.cpp +++ b/src/plugins/genericprojectmanager/genericprojectplugin.cpp @@ -70,9 +70,10 @@ bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage addAutoReleasedObject(new Manager); addAutoReleasedObject(new ProjectFilesFactory); addAutoReleasedObject(new GenericMakeStepFactory); - addAutoReleasedObject(new GenericProjectWizard); addAutoReleasedObject(new GenericBuildConfigurationFactory); + IWizardFactory::registerFactoryCreator([]() { return QList<IWizardFactory *>() << new GenericProjectWizard; }); + ActionContainer *mproject = ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); diff --git a/src/plugins/genericprojectmanager/genericprojectwizard.cpp b/src/plugins/genericprojectmanager/genericprojectwizard.cpp index f7b9e757b8f..944eb030ba7 100644 --- a/src/plugins/genericprojectmanager/genericprojectwizard.cpp +++ b/src/plugins/genericprojectmanager/genericprojectwizard.cpp @@ -121,7 +121,7 @@ GenericProjectWizard::GenericProjectWizard() setIcon(icon); } setDisplayName(tr("Import Existing Project")); - setId(QLatin1String("Z.Makefile")); + setId("Z.Makefile"); setDescription(tr("Imports existing projects that do not use qmake, CMake or Autotools. " "This allows you to use Qt Creator as a code editor.")); setCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY)); diff --git a/src/plugins/git/annotationhighlighter.h b/src/plugins/git/annotationhighlighter.h index 61cf115de46..778b87b6dde 100644 --- a/src/plugins/git/annotationhighlighter.h +++ b/src/plugins/git/annotationhighlighter.h @@ -45,7 +45,7 @@ public: QTextDocument *document = 0); private: - QString changeNumber(const QString &block) const; + QString changeNumber(const QString &block) const override; const QChar m_blank; }; diff --git a/src/plugins/git/branchadddialog.cpp b/src/plugins/git/branchadddialog.cpp index b4caca3500b..42a312c3c30 100644 --- a/src/plugins/git/branchadddialog.cpp +++ b/src/plugins/git/branchadddialog.cpp @@ -71,7 +71,7 @@ public: ~BranchNameValidator() {} - State validate(QString &input, int &pos) const + State validate(QString &input, int &pos) const override { Q_UNUSED(pos) diff --git a/src/plugins/git/branchdialog.cpp b/src/plugins/git/branchdialog.cpp index 135b8d7b473..2c2e129cf8e 100644 --- a/src/plugins/git/branchdialog.cpp +++ b/src/plugins/git/branchdialog.cpp @@ -59,7 +59,7 @@ namespace Internal { BranchDialog::BranchDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::BranchDialog), - m_model(new BranchModel(GitPlugin::instance()->gitClient(), this)) + m_model(new BranchModel(GitPlugin::instance()->client(), this)) { setModal(false); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); @@ -197,7 +197,7 @@ void BranchDialog::checkout() QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash "); BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch); - GitClient *gitClient = GitPlugin::instance()->gitClient(); + GitClient *gitClient = GitPlugin::instance()->client(); if (gitClient->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged) branchCheckoutDialog.foundNoLocalChanges(); @@ -317,7 +317,7 @@ void BranchDialog::diff() if (fullName.isEmpty()) return; // Do not pass working dir by reference since it might change - GitPlugin::instance()->gitClient()->diffBranch(QString(m_repository), fullName); + GitPlugin::instance()->client()->diffBranch(QString(m_repository), fullName); } void BranchDialog::log() @@ -326,7 +326,7 @@ void BranchDialog::log() if (branchName.isEmpty()) return; // Do not pass working dir by reference since it might change - GitPlugin::instance()->gitClient()->log(QString(m_repository), QString(), false, QStringList(branchName)); + GitPlugin::instance()->client()->log(QString(m_repository), QString(), false, QStringList(branchName)); } void BranchDialog::reset() @@ -339,7 +339,7 @@ void BranchDialog::reset() if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?") .arg(currentName).arg(branchName), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) { - GitPlugin::instance()->gitClient()->reset(QString(m_repository), QLatin1String("--hard"), + GitPlugin::instance()->client()->reset(QString(m_repository), QLatin1String("--hard"), branchName); } @@ -353,7 +353,7 @@ void BranchDialog::merge() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString branch = m_model->fullName(idx, true); - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); bool allowFastForward = true; if (client->isFastForwardMerge(m_repository, branch)) { QMenu popup; @@ -376,7 +376,7 @@ void BranchDialog::rebase() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString baseBranch = m_model->fullName(idx, true); - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); if (client->beginStashScope(m_repository, QLatin1String("rebase"))) client->rebase(m_repository, baseBranch); } @@ -389,7 +389,7 @@ void BranchDialog::cherryPick() QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled! const QString branch = m_model->fullName(idx, true); - GitPlugin::instance()->gitClient()->synchronousCherryPick(m_repository, branch); + GitPlugin::instance()->client()->synchronousCherryPick(m_repository, branch); } void BranchDialog::setRemoteTracking() diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index b34a4d3453c..41d1bfa59a9 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -33,7 +33,7 @@ #include <utils/qtcassert.h> #include <vcsbase/vcsoutputwindow.h> -#include <vcsbase/vcsbaseplugin.h> +#include <vcsbase/vcscommand.h> #include <QFont> @@ -646,7 +646,7 @@ void BranchModel::parseOutputLine(const QString &line) const QString fullName = lineParts.at(1); bool current = (sha == m_currentSha); - bool showTags = m_client->settings()->boolValue(GitSettings::showTagsKey); + bool showTags = m_client->settings().boolValue(GitSettings::showTagsKey); // insert node into tree: QStringList nameParts = fullName.split(QLatin1Char('/')); @@ -724,7 +724,7 @@ QString BranchModel::toolTip(const QString &sha) const QStringList arguments(QLatin1String("-n1")); arguments << sha; if (!m_client->synchronousLog(m_workingDirectory, arguments, &output, &errorMessage, - VcsBasePlugin::SuppressCommandLogging)) { + VcsCommand::SuppressCommandLogging)) { return errorMessage; } return output; diff --git a/src/plugins/git/branchmodel.h b/src/plugins/git/branchmodel.h index a8b0dc676cc..cee398efa70 100644 --- a/src/plugins/git/branchmodel.h +++ b/src/plugins/git/branchmodel.h @@ -53,13 +53,13 @@ public: ~BranchModel(); // QAbstractItemModel - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parentIdx = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - Qt::ItemFlags flags(const QModelIndex &index) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override; + QModelIndex parent(const QModelIndex &index) const override; + int rowCount(const QModelIndex &parentIdx = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; void clear(); bool refresh(const QString &workingDirectory, QString *errorMessage); diff --git a/src/plugins/git/changeselectiondialog.cpp b/src/plugins/git/changeselectiondialog.cpp index 662e443f195..43b59431f72 100644 --- a/src/plugins/git/changeselectiondialog.cpp +++ b/src/plugins/git/changeselectiondialog.cpp @@ -36,6 +36,8 @@ #include <coreplugin/vcsmanager.h> +#include <utils/theme/theme.h> + #include <QProcess> #include <QFormLayout> #include <QHBoxLayout> @@ -49,6 +51,8 @@ #include <QStringListModel> #include <QTimer> +using namespace Utils; + namespace Git { namespace Internal { @@ -59,10 +63,10 @@ ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Co , m_command(NoCommand) { setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - m_gitExecutable = GitPlugin::instance()->gitClient()->gitExecutable(); + m_gitExecutable = GitPlugin::instance()->client()->vcsBinary(); m_ui->setupUi(this); m_ui->workingDirectoryEdit->setText(workingDirectory); - m_gitEnvironment = GitPlugin::instance()->gitClient()->processEnvironment(); + m_gitEnvironment = GitPlugin::instance()->client()->processEnvironment(); m_ui->changeNumberEdit->setFocus(); m_ui->changeNumberEdit->selectAll(); @@ -186,15 +190,17 @@ void ChangeSelectionDialog::acceptShow() //! Set commit message in details void ChangeSelectionDialog::setDetails(int exitCode) { + Theme *theme = creatorTheme(); + QPalette palette; if (exitCode == 0) { m_ui->detailsText->setPlainText(QString::fromUtf8(m_process->readAllStandardOutput())); - palette.setColor(QPalette::Text, Qt::black); + palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal)); m_ui->changeNumberEdit->setPalette(palette); enableButtons(true); } else { m_ui->detailsText->setPlainText(tr("Error: Unknown reference")); - palette.setColor(QPalette::Text, Qt::red); + palette.setColor(QPalette::Text, theme->color(Theme::TextColorError)); m_ui->changeNumberEdit->setPalette(palette); } } @@ -225,7 +231,7 @@ void ChangeSelectionDialog::recalculateCompletion() m_oldWorkingDir = workingDir; if (!workingDir.isEmpty()) { - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); QStringList args; args << QLatin1String("--format=%(refname:short)"); QString output; @@ -244,13 +250,14 @@ void ChangeSelectionDialog::recalculateDetails() const QString workingDir = workingDirectory(); QPalette palette = m_ui->workingDirectoryEdit->palette(); + Theme *theme = creatorTheme(); if (workingDir.isEmpty()) { m_ui->detailsText->setPlainText(tr("Error: Bad working directory.")); - palette.setColor(QPalette::Text, Qt::red); + palette.setColor(QPalette::Text, theme->color(Theme::TextColorError)); m_ui->workingDirectoryEdit->setPalette(palette); return; } else { - palette.setColor(QPalette::Text, Qt::black); + palette.setColor(QPalette::Text, theme->color(Theme::TextColorNormal)); m_ui->workingDirectoryEdit->setPalette(palette); } diff --git a/src/plugins/git/clonewizard.cpp b/src/plugins/git/clonewizard.cpp deleted file mode 100644 index 5570c0bd46d..00000000000 --- a/src/plugins/git/clonewizard.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizard.h" -#include "clonewizardpage.h" - -#include "gitplugin.h" -#include "gitversioncontrol.h" - -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> -#include <utils/qtcassert.h> - -using namespace VcsBase; - -namespace Git { -namespace Internal { - -// -------------------------------------------------------------------- -// CloneWizard: -// -------------------------------------------------------------------- - -CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : - BaseCheckoutWizard(path, parent) -{ - setTitle(tr("Cloning")); - setStartedStatus(tr("Cloning started...")); - - const Internal::GitVersionControl *vc = Internal::GitPlugin::instance()->gitVersionControl(); - if (!vc->isConfigured()) { - auto configPage = new VcsConfigurationPage; - configPage->setVersionControl(vc); - addPage(configPage); - } - auto cwp = new CloneWizardPage; - cwp->setPath(path.toString()); - addPage(cwp); -} - -VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) -{ - // Collect parameters for the clone command. - const CloneWizardPage *cwp = 0; - foreach (int pageId, pageIds()) { - if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId)))) - break; - } - - QTC_ASSERT(cwp, return 0); - return cwp->createCheckoutJob(checkoutDir); -} - -} // namespace Internal -} // namespace Git diff --git a/src/plugins/git/clonewizardpage.cpp b/src/plugins/git/clonewizardpage.cpp deleted file mode 100644 index 5ba51b19a65..00000000000 --- a/src/plugins/git/clonewizardpage.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizardpage.h" -#include "gitplugin.h" -#include "gitclient.h" - -#include <vcsbase/vcscommand.h> - -#include <QCheckBox> - -using namespace VcsBase; - -namespace Git { - -struct CloneWizardPagePrivate -{ - CloneWizardPagePrivate(); - - bool urlIsLocal(const QString &url); - - const QString mainLinePostfix; - const QString gitPostFix; - QCheckBox *recursiveCheckBox; -}; - -CloneWizardPagePrivate::CloneWizardPagePrivate() : - mainLinePostfix(QLatin1String("/mainline.git")), - gitPostFix(QLatin1String(".git")), - recursiveCheckBox(0) -{ -} - -bool CloneWizardPagePrivate::urlIsLocal(const QString &url) -{ - if (url.startsWith(QLatin1String("file://")) - || url.startsWith(QLatin1Char('/')) - || (url.at(0).isLetter() && url.at(1) == QLatin1Char(':') && url.at(2) == QLatin1Char('\\'))) - return true; - return false; -} - -CloneWizardPage::CloneWizardPage(QWidget *parent) : - BaseCheckoutWizardPage(parent), - d(new CloneWizardPagePrivate) -{ - setTitle(tr("Location")); - setSubTitle(tr("Specify repository URL, checkout directory and path.")); - setRepositoryLabel(tr("Clone URL:")); - d->recursiveCheckBox = new QCheckBox(tr("Recursive")); - addLocalControl(d->recursiveCheckBox); -} - -CloneWizardPage::~CloneWizardPage() -{ - delete d; -} - -QString CloneWizardPage::directoryFromRepository(const QString &urlIn) const -{ - const QChar slash = QLatin1Char('/'); - QString url = urlIn.trimmed().replace(QLatin1Char('\\'), slash); - - // Remove postfixes - if (url.endsWith(d->mainLinePostfix)) - url.truncate(url.size() - d->mainLinePostfix.size()); - else if (url.endsWith(d->gitPostFix)) - url.truncate(url.size() - d->gitPostFix.size()); - - // extract repository name (last part of path) - int startOfRepoName = url.lastIndexOf(slash); - if (startOfRepoName == -1) - startOfRepoName = url.lastIndexOf(QLatin1Char(':')); - url.remove(0, startOfRepoName); - - // fix invalid characters - const QChar dash = QLatin1Char('-'); - url.replace(QRegExp(QLatin1String("[^0-9a-zA-Z_.-]")), dash); - // trim leading dashes (they are annoying and get created when using local pathes) - url.replace(QRegExp(QLatin1String("^-+")), QString()); - return url; -} - -VcsCommand *CloneWizardPage::createCheckoutJob(Utils::FileName *checkoutPath) const -{ - const Internal::GitClient *client = Internal::GitPlugin::instance()->gitClient(); - const QString workingDirectory = path(); - const QString checkoutDir = directory(); - *checkoutPath = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + checkoutDir); - - const QString checkoutBranch = branch(); - - QStringList args(QLatin1String("clone")); - if (!checkoutBranch.isEmpty()) - args << QLatin1String("--branch") << checkoutBranch; - if (d->recursiveCheckBox->isChecked()) - args << QLatin1String("--recursive"); - args << QLatin1String("--progress") << repository() << checkoutDir; - auto command = new VcsCommand(client->gitExecutable(), workingDirectory, - client->processEnvironment()); - command->addFlags(VcsBasePlugin::MergeOutputChannels); - command->addJob(args, -1); - return command; -} - -QStringList CloneWizardPage::branches(const QString &repository, int *current) -{ - // Run git on remote repository if an URL was specified. - *current = -1; - - if (repository.isEmpty()) - return QStringList(); - const QStringList branches = Internal::GitPlugin::instance()->gitClient()->synchronousRepositoryBranches(repository); - if (!branches.isEmpty()) - *current = 0; // default branch is always returned first! - return branches; -} - -} // namespace Git - -#ifdef WITH_TESTS -#include <QTest> - -void Git::CloneWizardPage::testDirectoryFromRepository() -{ - QFETCH(QString, repository); - QFETCH(QString, localDirectory); - - QCOMPARE(directoryFromRepository(repository), localDirectory); -} -#endif diff --git a/src/plugins/git/gerrit/branchcombobox.cpp b/src/plugins/git/gerrit/branchcombobox.cpp index 213490e028b..564c9ea0810 100644 --- a/src/plugins/git/gerrit/branchcombobox.cpp +++ b/src/plugins/git/gerrit/branchcombobox.cpp @@ -39,7 +39,7 @@ BranchComboBox::BranchComboBox(QWidget *parent) : QComboBox(parent), m_detached(false) { - m_client = GitPlugin::instance()->gitClient(); + m_client = GitPlugin::instance()->client(); } void BranchComboBox::init(const QString &repository) diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index d296c93112a..10b7b8e737f 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -280,7 +280,7 @@ QueryContext::QueryContext(const QStringList &queries, this, &QueryContext::terminate); m_watcher.setFuture(m_progress.future()); m_process.setProcessEnvironment(Git::Internal::GitPlugin::instance()-> - gitClient()->processEnvironment()); + client()->processEnvironment()); m_progress.setProgressRange(0, m_queries.size()); // Determine binary and common command line arguments. @@ -390,7 +390,7 @@ void QueryContext::timeout() if (!parent) parent = QApplication::activeWindow(); QMessageBox box(QMessageBox::Question, tr("Timeout"), - tr("The gerrit process has not responded within %1s.\n" + tr("The gerrit process has not responded within %1 s.\n" "Most likely this is caused by problems with SSH authentication.\n" "Would you like to terminate it?"). arg(timeOutMS / 1000), QMessageBox::NoButton, parent); diff --git a/src/plugins/git/gerrit/gerritmodel.h b/src/plugins/git/gerrit/gerritmodel.h index 58796da460a..b3c48a57511 100644 --- a/src/plugins/git/gerrit/gerritmodel.h +++ b/src/plugins/git/gerrit/gerritmodel.h @@ -118,7 +118,7 @@ public: GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = 0); ~GerritModel(); - QVariant data(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const override; GerritChangePtr change(const QModelIndex &index) const; QString toHtml(const QModelIndex &index) const; diff --git a/src/plugins/git/gerrit/gerritoptionspage.h b/src/plugins/git/gerrit/gerritoptionspage.h index ad27b91963f..c3153d63f98 100644 --- a/src/plugins/git/gerrit/gerritoptionspage.h +++ b/src/plugins/git/gerrit/gerritoptionspage.h @@ -75,9 +75,9 @@ public: QObject *parent = 0); ~GerritOptionsPage(); - QWidget *widget(); - void apply(); - void finish(); + QWidget *widget() override; + void apply() override; + void finish() override; private: const QSharedPointer<GerritParameters> &m_parameters; diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 9baaddedff1..be359a69580 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -91,7 +91,7 @@ enum FetchMode static inline GitClient *gitClient() { - return GitPlugin::instance()->gitClient(); + return GitPlugin::instance()->client(); } /* FetchContext: Retrieves the patch and displays @@ -404,12 +404,9 @@ void GerritPlugin::push() Utils::FileName GerritPlugin::gitBinary() { - bool ok; - const Utils::FileName git = gitClient()->gitExecutable(&ok); - if (!ok) { + const Utils::FileName git = gitClient()->vcsBinary(); + if (git.isEmpty()) VcsBase::VcsOutputWindow::appendError(tr("Git is not available.")); - return Utils::FileName(); - } return git; } diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index b088367ded9..c1e16d6016e 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -54,7 +54,7 @@ public: } protected: - bool hasIcon(int row) const + bool hasIcon(int row) const override { return row >= currentRow(); } @@ -138,7 +138,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev m_ui(new Ui::GerritPushDialog), m_isValid(false) { - m_client = GitPlugin::instance()->gitClient(); + m_client = GitPlugin::instance()->client(); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_ui->setupUi(this); m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir)); diff --git a/src/plugins/git/git.pro b/src/plugins/git/git.pro index dba0e3733ca..9f8846e7b06 100644 --- a/src/plugins/git/git.pro +++ b/src/plugins/git/git.pro @@ -13,8 +13,6 @@ HEADERS += gitplugin.h \ gitsettings.h \ branchdialog.h \ branchmodel.h \ - clonewizard.h \ - clonewizardpage.h \ stashdialog.h \ gitutils.h \ remotemodel.h \ @@ -38,8 +36,6 @@ SOURCES += gitplugin.cpp \ gitsettings.cpp \ branchdialog.cpp \ branchmodel.cpp \ - clonewizard.cpp \ - clonewizardpage.cpp \ stashdialog.cpp \ gitutils.cpp \ remotemodel.cpp \ diff --git a/src/plugins/git/git.qbs b/src/plugins/git/git.qbs index 381168e73a1..5b1180033c2 100644 --- a/src/plugins/git/git.qbs +++ b/src/plugins/git/git.qbs @@ -28,10 +28,6 @@ QtcPlugin { "changeselectiondialog.cpp", "changeselectiondialog.h", "changeselectiondialog.ui", - "clonewizard.cpp", - "clonewizard.h", - "clonewizardpage.cpp", - "clonewizardpage.h", "commitdata.cpp", "commitdata.h", "git.qrc", diff --git a/src/plugins/git/git.qrc b/src/plugins/git/git.qrc index bab9c15f27a..f7c801436ad 100644 --- a/src/plugins/git/git.qrc +++ b/src/plugins/git/git.qrc @@ -1,6 +1,5 @@ <RCC> <qresource prefix="/git"> - <file>images/git.png</file> <file>images/arrowup.png</file> <file>Git.mimetypes.xml</file> </qresource> diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index f658c14cf58..a7e10d41744 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -64,7 +64,6 @@ #include <diffeditor/diffeditorconstants.h> #include <diffeditor/diffeditorcontroller.h> -#include <diffeditor/diffeditormanager.h> #include <diffeditor/diffutils.h> #include <QCoreApplication> @@ -100,9 +99,12 @@ namespace Internal { // Suppress git diff warnings about "LF will be replaced by CRLF..." on Windows. static unsigned diffExecutionFlags() { - return HostOsInfo::isWindowsHost() ? unsigned(VcsBasePlugin::SuppressStdErrInLogWindow) : 0u; + return HostOsInfo::isWindowsHost() ? unsigned(VcsCommand::SuppressStdErr) : 0u; } +const unsigned silentFlags = unsigned(VcsCommand::SuppressCommandLogging + | VcsCommand::SuppressStdErr); + ///////////////////////////////////// class BaseController : public DiffEditorController @@ -148,16 +150,16 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code m_command->cancel(); } - m_command = new VcsCommand(gitClient()->gitExecutable(), m_directory, gitClient()->processEnvironment()); + m_command = new VcsCommand(m_directory, gitClient()->processEnvironment()); m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec()); - connect(m_command, &VcsCommand::output, this, &BaseController::processOutput); + connect(m_command, &VcsCommand::stdOutText, this, &BaseController::processOutput); connect(m_command, &VcsCommand::finished, this, &BaseController::reloadFinished); m_command->addFlags(diffExecutionFlags()); foreach (const QStringList &arg, args) { QTC_ASSERT(!arg.isEmpty(), continue); - m_command->addJob(arg, GitPlugin::instance()->settings().intValue(GitSettings::timeoutKey)); + m_command->addJob(gitClient()->vcsBinary(), arg, gitClient()->vcsTimeoutS()); } m_command->execute(); @@ -179,6 +181,7 @@ QStringList BaseController::addConfigurationArguments(const QStringList &args) c QStringList realArgs; realArgs << args.at(0); realArgs << QLatin1String("-m"); // show diff agains parents instead of merge commits + realArgs << QLatin1String("-M") << QLatin1String("-C"); // Detect renames and copies realArgs << QLatin1String("--first-parent"); // show only first parent if (ignoreWhitespace()) realArgs << QLatin1String("--ignore-space-change"); @@ -196,7 +199,7 @@ void BaseController::processOutput(const QString &output) GitClient *BaseController::gitClient() const { - return GitPlugin::instance()->gitClient(); + return GitPlugin::instance()->client(); } QStringList BaseController::addHeadWhenCommandInProgress() const @@ -219,7 +222,7 @@ public: BaseController(document, dir) { } - void reload(); + void reload() override; }; void RepositoryDiffController::reload() @@ -239,7 +242,7 @@ public: m_fileName(fileName) { } - void reload(); + void reload() override; private: const QString m_fileName; @@ -265,7 +268,7 @@ public: m_unstagedFiles(unstagedFiles) { } - void reload(); + void reload() override; private: const QStringList m_stagedFiles; @@ -303,7 +306,7 @@ public: m_projectPaths(projectPaths) { } - void reload(); + void reload() override; private: const QStringList m_projectPaths; @@ -327,7 +330,7 @@ public: m_branch(branch) { } - void reload(); + void reload() override; private: const QString m_branch; @@ -350,8 +353,9 @@ public: m_state(Idle) { } - void reload(); - void processOutput(const QString &output); + void reload() override; + void processOutput(const QString &output) override; + void reloadFinished(bool success) override; private: const QString m_id; @@ -373,17 +377,26 @@ void ShowController::processOutput(const QString &output) QTC_ASSERT(m_state != Idle, return); if (m_state == GettingDescription) { setDescription(gitClient()->extendedShowDescription(m_directory, output)); + } else if (m_state == GettingDiff) { + processDiff(output); + } +} +void ShowController::reloadFinished(bool success) +{ + QTC_ASSERT(m_state != Idle, return); + + if (m_state == GettingDescription && success) { QStringList args; args << QLatin1String("show") << QLatin1String("--format=format:") // omit header, already generated - << QLatin1String("-M") << QLatin1String("-C") << QLatin1String(noColorOption) - << QLatin1String(decorateOption) << m_id; + << QLatin1String(noColorOption) << QLatin1String(decorateOption) << m_id; m_state = GettingDiff; runCommand(QList<QStringList>() << addConfigurationArguments(args)); - } else if (m_state == GettingDiff) { - m_state = Idle; - processDiff(output); + return; } + + m_state = Idle; + BaseController::reloadFinished(success); } /////////////////////////////// @@ -393,21 +406,19 @@ class BaseGitDiffArgumentsWidget : public VcsBaseEditorParameterWidget Q_OBJECT public: - BaseGitDiffArgumentsWidget(GitSettings *settings, QWidget *parent = 0) : + BaseGitDiffArgumentsWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { - QTC_ASSERT(settings, return); - m_patienceButton = addToggleButton( QLatin1String("--patience"), tr("Patience"), tr("Use the patience algorithm for calculating the differences.")); - mapSetting(m_patienceButton, settings->boolPointer(GitSettings::diffPatienceKey)); + mapSetting(m_patienceButton, settings.boolPointer(GitSettings::diffPatienceKey)); m_ignoreWSButton = addToggleButton( QLatin1String("--ignore-space-change"), tr("Ignore Whitespace"), tr("Ignore whitespace only changes.")); mapSetting(m_ignoreWSButton, - settings->boolPointer(GitSettings::ignoreSpaceChangesInDiffKey)); + settings.boolPointer(GitSettings::ignoreSpaceChangesInDiffKey)); } protected: @@ -420,15 +431,15 @@ class GitBlameArgumentsWidget : public VcsBaseEditorParameterWidget Q_OBJECT public: - GitBlameArgumentsWidget(GitSettings *settings, QWidget *parent = 0) : + GitBlameArgumentsWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { mapSetting(addToggleButton(QString(), tr("Omit Date"), tr("Hide the date of a change from the output.")), - settings->boolPointer(GitSettings::omitAnnotationDateKey)); + settings.boolPointer(GitSettings::omitAnnotationDateKey)); mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace"), tr("Ignore whitespace only changes.")), - settings->boolPointer(GitSettings::ignoreSpaceChangesInBlameKey)); + settings.boolPointer(GitSettings::ignoreSpaceChangesInBlameKey)); } }; @@ -437,12 +448,12 @@ class GitLogArgumentsWidget : public BaseGitDiffArgumentsWidget Q_OBJECT public: - GitLogArgumentsWidget(GitSettings *settings, QWidget *parent = 0) : + GitLogArgumentsWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : BaseGitDiffArgumentsWidget(settings, parent) { QToolButton *diffButton = addToggleButton(QLatin1String("--patch"), tr("Show Diff"), tr("Show difference.")); - mapSetting(diffButton, settings->boolPointer(GitSettings::logDiffKey)); + mapSetting(diffButton, settings.boolPointer(GitSettings::logDiffKey)); connect(diffButton, &QToolButton::toggled, m_patienceButton, &QToolButton::setVisible); connect(diffButton, &QToolButton::toggled, m_ignoreWSButton, &QToolButton::setVisible); m_patienceButton->setVisible(diffButton->isChecked()); @@ -452,7 +463,7 @@ public: graphArguments << (QLatin1String("--pretty=format:") + QLatin1String(graphLogFormatC)); QToolButton *graphButton = addToggleButton(graphArguments, tr("Graph"), tr("Show textual graph log.")); - mapSetting(graphButton, settings->boolPointer(GitSettings::graphLogKey)); + mapSetting(graphButton, settings.boolPointer(GitSettings::graphLogKey)); } }; @@ -460,36 +471,45 @@ class ConflictHandler : public QObject { Q_OBJECT public: - ConflictHandler(VcsCommand *parentCommand, - const QString &workingDirectory, - const QString &command = QString()) - : QObject(parentCommand), - m_workingDirectory(workingDirectory), - m_command(command) + static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) { + ConflictHandler *handler = new ConflictHandler(command->workingDirectory(), abortCommand); + handler->setParent(command); // delete when command goes out of scope + + command->addFlags(VcsCommand::ExpectRepoChanges); + connect(command, &VcsCommand::stdOutText, handler, &ConflictHandler::readStdOut); + connect(command, &VcsCommand::stdErrText, handler, &ConflictHandler::readStdErr); + } + + static void handleResponse(const Utils::SynchronousProcessResponse &response, + const QString &workingDirectory, + const QString &abortCommand = QString()) { - if (parentCommand) { - parentCommand->addFlags(VcsBasePlugin::ExpectRepoChanges); - connect(parentCommand, &VcsCommand::output, this, &ConflictHandler::readStdOut); - connect(parentCommand, &VcsCommand::errorText, this, &ConflictHandler::readStdErr); - } + ConflictHandler handler(workingDirectory, abortCommand); + handler.readStdOut(response.stdOut); + handler.readStdErr(response.stdErr); } +private: + ConflictHandler(const QString &workingDirectory, const QString &abortCommand) : + m_workingDirectory(workingDirectory), + m_abortCommand(abortCommand) + { } + ~ConflictHandler() { // If interactive rebase editor window is closed, plugin is terminated // but referenced here when the command ends if (GitPlugin *plugin = GitPlugin::instance()) { - GitClient *client = plugin->gitClient(); + GitClient *client = plugin->client(); if (m_commit.isEmpty() && m_files.isEmpty()) { if (client->checkCommandInProgress(m_workingDirectory) == GitClient::NoCommand) client->endStashScope(m_workingDirectory); } else { - client->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_command); + client->handleMergeConflicts(m_workingDirectory, m_commit, m_files, m_abortCommand); } } } -public slots: void readStdOut(const QString &data) { static QRegExp patchFailedRE(QLatin1String("Patch failed at ([^\\n]*)")); @@ -497,9 +517,8 @@ public slots: if (patchFailedRE.indexIn(data) != -1) m_commit = patchFailedRE.cap(1); int fileIndex = -1; - while ((fileIndex = conflictedFilesRE.indexIn(data, fileIndex + 1)) != -1) { + while ((fileIndex = conflictedFilesRE.indexIn(data, fileIndex + 1)) != -1) m_files.append(conflictedFilesRE.cap(1)); - } } void readStdErr(const QString &data) @@ -510,7 +529,7 @@ public slots: } private: QString m_workingDirectory; - QString m_command; + QString m_abortCommand; QString m_commit; QStringList m_files; }; @@ -518,48 +537,24 @@ private: class GitProgressParser : public ProgressParser { public: - GitProgressParser() : - m_progressExp(QLatin1String("\\((\\d+)/(\\d+)\\)")) // e.g. Rebasing (7/42) + static void attachToCommand(VcsCommand *command) { + command->setProgressParser(new GitProgressParser); } -protected: - void parseProgress(const QString &text) +private: + GitProgressParser() : m_progressExp(QLatin1String("\\((\\d+)/(\\d+)\\)")) // e.g. Rebasing (7/42) + { } + + void parseProgress(const QString &text) override { if (m_progressExp.lastIndexIn(text) != -1) setProgressAndMaximum(m_progressExp.cap(1).toInt(), m_progressExp.cap(2).toInt()); } -private: QRegExp m_progressExp; }; -IEditor *locateEditor(const char *property, const QString &entry) -{ - foreach (IDocument *document, DocumentModel::openedDocuments()) - if (document->property(property).toString() == entry) - return DocumentModel::editorsForDocument(document).first(); - return 0; -} - -// Return converted command output, remove '\r' read on Windows -static inline QString commandOutputFromLocal8Bit(const QByteArray &a) -{ - return SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a)); -} - -// Return converted command output split into lines -static inline QStringList commandOutputLinesFromLocal8Bit(const QByteArray &a) -{ - QString output = commandOutputFromLocal8Bit(a); - const QChar newLine = QLatin1Char('\n'); - if (output.endsWith(newLine)) - output.truncate(output.size() - 1); - if (output.isEmpty()) - return QStringList(); - return output.split(newLine); -} - static inline QString msgRepositoryNotFound(const QString &dir) { return GitClient::tr("Cannot determine the repository for \"%1\".").arg(dir); @@ -575,13 +570,6 @@ static inline QString msgCannotLaunch(const QString &binary) return GitClient::tr("Cannot launch \"%1\".").arg(QDir::toNativeSeparators(binary)); } -static inline QString currentDocumentPath() -{ - if (IDocument *document= EditorManager::currentDocument()) - return document->filePath().toFileInfo().path(); - return QString(); -} - static inline void msgCannotRun(const QString &message, QString *errorMessage) { if (errorMessage) @@ -596,7 +584,7 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD const QString message = GitClient::tr("Cannot run \"%1 %2\" in \"%2\": %3") .arg(QLatin1String("git ") + args.join(QLatin1Char(' ')), QDir::toNativeSeparators(workingDirectory), - commandOutputFromLocal8Bit(error)); + GitClient::commandOutputFromLocal8Bit(error)); msgCannotRun(message, errorMessage); } @@ -605,13 +593,10 @@ static inline void msgCannotRun(const QStringList &args, const QString &workingD const char *GitClient::stashNamePrefix = "stash@{"; -GitClient::GitClient(GitSettings *settings) : +GitClient::GitClient() : VcsBase::VcsBaseClientImpl(this, new GitSettings), m_cachedGitVersion(0), - m_settings(settings), m_disableEditor(false) { - QTC_CHECK(settings); - connect(ICore::instance(), &ICore::saveSettingsRequested, this, &GitClient::saveSettings); m_gitQtcEditor = QString::fromLatin1("\"%1\" -client -block -pid %2") .arg(QCoreApplication::applicationFilePath()) .arg(QCoreApplication::applicationPid()); @@ -658,24 +643,18 @@ bool GitClient::managesFile(const QString &workingDirectory, const QString &file QByteArray output; QStringList arguments; arguments << QLatin1String("ls-files") << QLatin1String("--error-unmatch") << fileName; - return fullySynchronousGit(workingDirectory, arguments, &output, 0, - VcsBasePlugin::SuppressCommandLogging); + return vcsFullySynchronousExec(workingDirectory, arguments, &output, 0, silentFlags); } -VcsBaseEditorWidget *GitClient::findExistingVCSEditor(const char *registerDynamicProperty, - const QString &dynamicPropertyValue) const +QTextCodec *GitClient::codecFor(GitClient::CodecType codecType, const QString &source) const { - VcsBaseEditorWidget *rc = 0; - IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue); - if (!outputEditor) - return 0; - - // Exists already - EditorManager::activateEditor(outputEditor); - outputEditor->document()->setContents(QByteArray()); // clear - rc = VcsBaseEditor::getVcsBaseEditor(outputEditor); - - return rc; + if (codecType == CodecSource) { + return QFileInfo(source).isFile() ? VcsBaseEditor::getCodec(source) + : encoding(source, "gui.encoding"); + } + if (codecType == CodecLogOutput) + return encoding(source, "i18n.logOutputEncoding"); + return 0; } void GitClient::slotChunkActionsRequested(QMenu *menu, bool isValid) @@ -751,48 +730,11 @@ void GitClient::stage(const QString &patch, bool revert) } } -/* Create an editor associated to VCS output of a source file/directory - * (using the file's codec). Makes use of a dynamic property to find an - * existing instance and to reuse it (in case, say, 'git diff foo' is - * already open). */ -VcsBaseEditorWidget *GitClient::createVcsEditor( - Id id, - QString title, - const QString &source, // Source file or directory - CodecType codecType, - const char *registerDynamicProperty, // Dynamic property and value to identify that editor - const QString &dynamicPropertyValue, - VcsBaseEditorParameterWidget *configWidget) const -{ - VcsBaseEditorWidget *rc = 0; - QTC_CHECK(!findExistingVCSEditor(registerDynamicProperty, dynamicPropertyValue)); - - // Create new, set wait message, set up with source and codec - IEditor *outputEditor = EditorManager::openEditorWithContents(id, &title); - outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); - rc = VcsBaseEditor::getVcsBaseEditor(outputEditor); - connect(rc, &VcsBaseEditorWidget::annotateRevisionRequested, - this, &GitClient::slotBlameRevisionRequested); - QTC_ASSERT(rc, return 0); - rc->setSource(source); - if (codecType == CodecSource) - rc->setCodec(getSourceCodec(source)); - else if (codecType == CodecLogOutput) - rc->setCodec(encoding(source, "i18n.logOutputEncoding")); - - rc->setForceReadOnly(true); - - if (configWidget) - rc->setConfigurationWidget(configWidget); - - return rc; -} - void GitClient::requestReload(const QString &documentId, const QString &source, const QString &title, std::function<DiffEditorController *(IDocument *)> factory) const { - IDocument *document = DiffEditorManager::findOrCreate(documentId, title); + IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); QTC_ASSERT(document, return); DiffEditorController *controller = factory(document); QTC_ASSERT(controller, return); @@ -877,7 +819,7 @@ void GitClient::status(const QString &workingDirectory) QStringList statusArgs; statusArgs << QLatin1String("status") << QLatin1String("-u"); VcsOutputWindow::setRepository(workingDirectory); - VcsCommand *command = executeGit(workingDirectory, statusArgs, 0, true); + VcsCommand *command = vcsExec(workingDirectory, statusArgs, 0, true); connect(command, &VcsCommand::finished, VcsOutputWindow::instance(), &VcsOutputWindow::clearRepository, Qt::QueuedConnection); } @@ -895,13 +837,13 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName, const QString title = tr("Git Log \"%1\"").arg(msgArg); const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID; const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName); - VcsBaseEditorWidget *editor = findExistingVCSEditor("logTitle", msgArg); - if (!editor) { + VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, sourceFile, + codecFor(CodecLogOutput), "logTitle", msgArg); + if (!editor->configurationWidget()) { auto *argWidget = new GitLogArgumentsWidget(settings()); connect(argWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested, [=]() { this->log(workingDirectory, fileName, enableAnnotationContextMenu, args); }); - editor = createVcsEditor(editorId, title, sourceFile, CodecLogOutput, "logTitle", msgArg, - argWidget); + editor->setConfigurationWidget(argWidget); } editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu); editor->setWorkingDirectory(workingDirectory); @@ -910,7 +852,7 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName, arguments << QLatin1String("log") << QLatin1String(noColorOption) << QLatin1String(decorateOption); - int logCount = settings()->intValue(GitSettings::logCountKey); + int logCount = settings().intValue(GitSettings::logCountKey); if (logCount > 0) arguments << QLatin1String("-n") << QString::number(logCount); @@ -923,29 +865,26 @@ void GitClient::log(const QString &workingDirectory, const QString &fileName, if (!fileName.isEmpty()) arguments << QLatin1String("--follow") << QLatin1String("--") << fileName; - executeGit(workingDirectory, arguments, editor); + vcsExec(workingDirectory, arguments, editor); } void GitClient::reflog(const QString &workingDirectory) { const QString title = tr("Git Reflog \"%1\"").arg(workingDirectory); const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID; - VcsBaseEditorWidget *editor = findExistingVCSEditor("reflogRepository", workingDirectory); - if (!editor) { - editor = createVcsEditor(editorId, title, workingDirectory, CodecLogOutput, - "reflogRepository", workingDirectory, 0); - } + VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, workingDirectory, codecFor(CodecLogOutput), + "reflogRepository", workingDirectory); editor->setWorkingDirectory(workingDirectory); QStringList arguments; arguments << QLatin1String("reflog") << QLatin1String(noColorOption) << QLatin1String(decorateOption); - int logCount = settings()->intValue(GitSettings::logCountKey); + int logCount = settings().intValue(GitSettings::logCountKey); if (logCount > 0) arguments << QLatin1String("-n") << QString::number(logCount); - executeGit(workingDirectory, arguments, editor); + vcsExec(workingDirectory, arguments, editor); } // Do not show "0000" or "^32ae4" @@ -985,59 +924,37 @@ void GitClient::show(const QString &source, const QString &id, const QString &na }); } -void GitClient::saveSettings() -{ - settings()->writeSettings(ICore::settings()); -} - -void GitClient::slotBlameRevisionRequested(const QString &workingDirectory, const QString &file, - QString change, int lineNumber) -{ - // This might be invoked with a verbose revision description - // "SHA1 author subject" from the annotation context menu. Strip the rest. - const int blankPos = change.indexOf(QLatin1Char(' ')); - if (blankPos != -1) - change.truncate(blankPos); - blame(workingDirectory, QStringList(), file, change, lineNumber); -} - -QTextCodec *GitClient::getSourceCodec(const QString &file) const -{ - return QFileInfo(file).isFile() ? VcsBaseEditor::getCodec(file) - : encoding(file, "gui.encoding"); -} - -void GitClient::blame(const QString &workingDirectory, - const QStringList &args, - const QString &fileName, - const QString &revision, - int lineNumber) +void GitClient::annotate(const QString &workingDir, const QString &file, const QString &revision, + int lineNumber, const QStringList &extraOptions) { const Id editorId = Git::Constants::GIT_BLAME_EDITOR_ID; - const QString id = VcsBaseEditor::getTitleId(workingDirectory, QStringList(fileName), revision); + const QString id = VcsBaseEditor::getTitleId(workingDir, QStringList(file), revision); const QString title = tr("Git Blame \"%1\"").arg(id); - const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName); + const QString sourceFile = VcsBaseEditor::getSource(workingDir, file); - VcsBaseEditorWidget *editor = findExistingVCSEditor("blameFileName", id); - if (!editor) { + VcsBaseEditorWidget *editor + = createVcsEditor(editorId, title, sourceFile, codecFor(CodecSource, sourceFile), + "blameFileName", id); + if (!editor->configurationWidget()) { auto *argWidget = new GitBlameArgumentsWidget(settings()); - argWidget->setBaseArguments(args); + argWidget->setBaseArguments(extraOptions); connect(argWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested, [=] { const int line = VcsBaseEditor::lineNumberOfCurrentEditor(); - blame(workingDirectory, args, fileName, revision, line); + annotate(workingDir, file, revision, line, extraOptions); } ); - editor = createVcsEditor(editorId, title, sourceFile, CodecSource, "blameFileName", id, argWidget); + editor->setConfigurationWidget(argWidget); } - editor->setWorkingDirectory(workingDirectory); + editor->setWorkingDirectory(workingDir); QStringList arguments(QLatin1String("blame")); arguments << QLatin1String("--root"); arguments.append(editor->configurationWidget()->arguments()); - arguments << QLatin1String("--") << fileName; + arguments.append(extraOptions); + arguments << QLatin1String("--") << file; if (!revision.isEmpty()) arguments << revision; - executeGit(workingDirectory, arguments, editor, false, 0, lineNumber); + vcsExec(workingDir, arguments, editor, false, 0, lineNumber); } bool GitClient::synchronousCheckout(const QString &workingDirectory, @@ -1047,15 +964,14 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory, QByteArray outputText; QByteArray errorText; QStringList arguments = setupCheckoutArguments(workingDirectory, ref); - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, - VcsBasePlugin::ExpectRepoChanges); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, 0, + VcsCommand::ExpectRepoChanges); VcsOutputWindow::append(commandOutputFromLocal8Bit(outputText)); - if (!rc) { + if (rc) + updateSubmodulesIfNeeded(workingDirectory, true); + else msgCannotRun(arguments, workingDirectory, errorText, errorMessage); - return false; - } - updateSubmodulesIfNeeded(workingDirectory, true); - return true; + return rc; } /* method used to setup arguments for checkout, in case user wants to create local branch */ @@ -1128,8 +1044,8 @@ void GitClient::reset(const QString &workingDirectory, const QString &argument, unsigned flags = 0; if (argument == QLatin1String("--hard")) - flags |= VcsBasePlugin::ExpectRepoChanges; - executeGit(workingDirectory, arguments, 0, true, flags); + flags |= VcsCommand::ExpectRepoChanges; + vcsExec(workingDirectory, arguments, 0, true, flags); } void GitClient::addFile(const QString &workingDirectory, const QString &fileName) @@ -1137,28 +1053,28 @@ void GitClient::addFile(const QString &workingDirectory, const QString &fileName QStringList arguments; arguments << QLatin1String("add") << fileName; - executeGit(workingDirectory, arguments, 0); + vcsExec(workingDirectory, arguments); } bool GitClient::synchronousLog(const QString &workingDirectory, const QStringList &arguments, QString *output, QString *errorMessageIn, unsigned flags) { - QByteArray outputText; - QByteArray errorText; + QByteArray outputData; + QByteArray errorData; QStringList allArguments; allArguments << QLatin1String("log") << QLatin1String(noColorOption); allArguments.append(arguments); - const bool rc = fullySynchronousGit(workingDirectory, allArguments, &outputText, &errorText, - flags); + const bool rc = vcsFullySynchronousExec(workingDirectory, allArguments, &outputData, &errorData, flags); if (rc) { if (QTextCodec *codec = encoding(workingDirectory, "i18n.logOutputEncoding")) - *output = codec->toUnicode(outputText); + *output = codec->toUnicode(outputData); else - *output = commandOutputFromLocal8Bit(outputText); + *output = commandOutputFromLocal8Bit(outputData); } else { msgCannotRun(tr("Cannot obtain log of \"%1\": %2") .arg(QDir::toNativeSeparators(workingDirectory), - commandOutputFromLocal8Bit(errorText)), errorMessageIn); + commandOutputFromLocal8Bit(errorData)), errorMessageIn); + } return rc; } @@ -1166,16 +1082,9 @@ bool GitClient::synchronousLog(const QString &workingDirectory, const QStringLis bool GitClient::synchronousAdd(const QString &workingDirectory, const QStringList &files) { QByteArray outputText; - QByteArray errorText; QStringList arguments; arguments << QLatin1String("add") << files; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); - if (!rc) { - msgCannotRun(tr("Cannot add %n file(s) to \"%1\": %2", 0, files.size()) - .arg(QDir::toNativeSeparators(workingDirectory), - commandOutputFromLocal8Bit(errorText)), 0); - } - return rc; + return vcsFullySynchronousExec(workingDirectory, arguments, &outputText); } bool GitClient::synchronousDelete(const QString &workingDirectory, @@ -1183,19 +1092,12 @@ bool GitClient::synchronousDelete(const QString &workingDirectory, const QStringList &files) { QByteArray outputText; - QByteArray errorText; QStringList arguments; arguments << QLatin1String("rm"); if (force) arguments << QLatin1String("--force"); arguments.append(files); - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); - if (!rc) { - msgCannotRun(tr("Cannot remove %n file(s) from \"%1\": %2", 0, files.size()) - .arg(QDir::toNativeSeparators(workingDirectory), - commandOutputFromLocal8Bit(errorText)), 0); - } - return rc; + return vcsFullySynchronousExec(workingDirectory, arguments, &outputText); } bool GitClient::synchronousMove(const QString &workingDirectory, @@ -1203,17 +1105,11 @@ bool GitClient::synchronousMove(const QString &workingDirectory, const QString &to) { QByteArray outputText; - QByteArray errorText; QStringList arguments; arguments << QLatin1String("mv"); arguments << (from); arguments << (to); - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); - if (!rc) { - msgCannotRun(tr("Cannot move from \"%1\" to \"%2\": %3") - .arg(from, to, commandOutputFromLocal8Bit(errorText)), 0); - } - return rc; + return vcsFullySynchronousExec(workingDirectory, arguments, &outputText); } bool GitClient::synchronousReset(const QString &workingDirectory, @@ -1228,7 +1124,7 @@ bool GitClient::synchronousReset(const QString &workingDirectory, arguments << QLatin1String("--hard"); else arguments << QLatin1String(HEAD) << QLatin1String("--") << files; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, &errorText); const QString output = commandOutputFromLocal8Bit(outputText); VcsOutputWindow::append(output); // Note that git exits with 1 even if the operation is successful @@ -1253,17 +1149,12 @@ bool GitClient::synchronousReset(const QString &workingDirectory, bool GitClient::synchronousInit(const QString &workingDirectory) { QByteArray outputText; - QByteArray errorText; const QStringList arguments(QLatin1String("init")); - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText); // '[Re]Initialized...' VcsOutputWindow::append(commandOutputFromLocal8Bit(outputText)); - if (!rc) { - VcsOutputWindow::appendError(commandOutputFromLocal8Bit(errorText)); - } else { - // TODO: Turn this into a VcsBaseClient and use resetCachedVcsInfo(...) - VcsManager::resetVersionControlForDirectory(workingDirectory); - } + if (rc) + resetCachedVcsInfo(workingDirectory); return rc; } @@ -1288,8 +1179,8 @@ bool GitClient::synchronousCheckoutFiles(const QString &workingDirectory, if (revertStaging) arguments << revision; arguments << QLatin1String("--") << files; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, - VcsBasePlugin::ExpectRepoChanges); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, &errorText, + VcsCommand::ExpectRepoChanges); if (!rc) { const QString fileArg = files.join(QLatin1String(", ")); //: Meaning of the arguments: %1: revision, %2: files, %3: repository, @@ -1355,8 +1246,8 @@ bool GitClient::synchronousRevListCmd(const QString &workingDirectory, const QSt QStringList args(QLatin1String("rev-list")); args << QLatin1String(noColorOption) << arguments; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputTextData, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputTextData, &errorText, + silentFlags); if (!rc) { msgCannotRun(args, workingDirectory, errorText, errorMessage); return false; @@ -1424,8 +1315,7 @@ QString GitClient::synchronousCurrentLocalBranch(const QString &workingDirectory QByteArray outputTextData; QStringList arguments; arguments << QLatin1String("symbolic-ref") << QLatin1String(HEAD); - if (fullySynchronousGit(workingDirectory, arguments, &outputTextData, 0, - VcsBasePlugin::SuppressCommandLogging)) { + if (vcsFullySynchronousExec(workingDirectory, arguments, &outputTextData, 0, silentFlags)) { QString branch = commandOutputFromLocal8Bit(outputTextData.trimmed()); const QString refsHeadsPrefix = QLatin1String("refs/heads/"); if (branch.startsWith(refsHeadsPrefix)) { @@ -1444,8 +1334,8 @@ bool GitClient::synchronousHeadRefs(const QString &workingDirectory, QStringList << QLatin1String("--abbrev=10") << QLatin1String("--dereference"); QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputText, &errorText, + silentFlags); if (!rc) { msgCannotRun(args, workingDirectory, errorText, errorMessage); return false; @@ -1502,7 +1392,7 @@ QString GitClient::synchronousTopic(const QString &workingDirectory) const QByteArray output; QStringList arguments; arguments << QLatin1String("describe"); - if (fullySynchronousGit(workingDirectory, arguments, &output, 0, VcsBasePlugin::NoOutput)) { + if (vcsFullySynchronousExec(workingDirectory, arguments, &output, 0, VcsCommand::NoOutput)) { const QString describeOutput = commandOutputFromLocal8Bit(output.trimmed()); if (!describeOutput.isEmpty()) return describeOutput; @@ -1517,8 +1407,8 @@ bool GitClient::synchronousRevParseCmd(const QString &workingDirectory, const QS arguments << ref; QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, &errorText, + silentFlags); *output = commandOutputFromLocal8Bit(outputText.trimmed()); if (!rc) msgCannotRun(arguments, workingDirectory, errorText, errorMessage); @@ -1542,8 +1432,7 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const QByteArray pr; QStringList arguments; arguments << QLatin1String("describe") << QLatin1String("--contains") << revision; - fullySynchronousGit(workingDirectory, arguments, &pr, 0, - VcsBasePlugin::SuppressCommandLogging); + vcsFullySynchronousExec(workingDirectory, arguments, &pr, 0, silentFlags); int tilde = pr.indexOf('~'); if (tilde != -1) pr.truncate(tilde); @@ -1559,8 +1448,7 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const arguments.clear(); arguments << QLatin1String("describe") << QLatin1String("--tags") << QLatin1String("--abbrev=0") << p; - fullySynchronousGit(workingDirectory, arguments, &pf, 0, - VcsBasePlugin::SuppressCommandLogging); + vcsFullySynchronousExec(workingDirectory, arguments, &pf, 0, silentFlags); pf.truncate(pf.lastIndexOf('\n')); if (!pf.isEmpty()) { if (!follows.isEmpty()) @@ -1578,15 +1466,9 @@ void GitClient::branchesForCommit(const QString &revision) auto controller = qobject_cast<DiffEditorController *>(sender()); QString workingDirectory = controller->baseDirectory(); - auto command = new VcsCommand(gitExecutable(), workingDirectory, processEnvironment()); - command->setCodec(getSourceCodec(currentDocumentPath())); - - connect(command, &VcsCommand::output, controller, + VcsCommand *command = vcsExec(workingDirectory, arguments, 0, false, 0, workingDirectory); + connect(command, &VcsCommand::stdOutText, controller, &DiffEditorController::informationForCommitReceived); - - command->addJob(arguments, -1); - command->setCookie(workingDirectory); - command->execute(); } bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit) @@ -1595,8 +1477,7 @@ bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &c QByteArray outputText; arguments << QLatin1String("branch") << QLatin1String("-r") << QLatin1String("--contains") << commit; - fullySynchronousGit(workingDirectory, arguments, &outputText, 0, - VcsBasePlugin::SuppressCommandLogging); + vcsFullySynchronousExec(workingDirectory, arguments, &outputText, 0, silentFlags); return !outputText.isEmpty(); } @@ -1605,8 +1486,7 @@ bool GitClient::isFastForwardMerge(const QString &workingDirectory, const QStrin QStringList arguments; QByteArray outputText; arguments << QLatin1String("merge-base") << QLatin1String(HEAD) << branch; - fullySynchronousGit(workingDirectory, arguments, &outputText, 0, - VcsBasePlugin::SuppressCommandLogging); + vcsFullySynchronousExec(workingDirectory, arguments, &outputText, 0, silentFlags); return commandOutputFromLocal8Bit(outputText).trimmed() == synchronousTopRevision(workingDirectory); } @@ -1622,7 +1502,7 @@ QString GitClient::synchronousShortDescription(const QString &workingDirectory, arguments << QLatin1String("log") << QLatin1String(noColorOption) << (QLatin1String("--pretty=format:") + format) << QLatin1String("--max-count=1") << revision; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputTextData, &errorText); if (!rc) { VcsOutputWindow::appendSilently(tr("Cannot describe revision \"%1\" in \"%2\": %3") .arg(revision, workingDirectory, commandOutputFromLocal8Bit(errorText))); @@ -1706,10 +1586,10 @@ bool GitClient::executeSynchronousStash(const QString &workingDirectory, arguments << QLatin1String("--keep-index"); if (!message.isEmpty()) arguments << message; - const unsigned flags = VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ExpectRepoChanges - | VcsBasePlugin::ShowSuccessMessage; - const SynchronousProcessResponse response = synchronousGit(workingDirectory, arguments, flags); + const unsigned flags = VcsCommand::ShowStdOut + | VcsCommand::ExpectRepoChanges + | VcsCommand::ShowSuccessMessage; + const SynchronousProcessResponse response = vcsSynchronousExec(workingDirectory, arguments, flags); const bool rc = response.result == SynchronousProcessResponse::Finished; if (!rc) msgCannotRun(arguments, workingDirectory, response.stdErr.toLocal8Bit(), errorMessage); @@ -1749,7 +1629,7 @@ bool GitClient::synchronousBranchCmd(const QString &workingDirectory, QStringLis branchArgs.push_front(QLatin1String("branch")); QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, branchArgs, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, branchArgs, &outputText, &errorText); *output = commandOutputFromLocal8Bit(outputText); if (!rc) msgCannotRun(branchArgs, workingDirectory, errorText, errorMessage); @@ -1763,7 +1643,7 @@ bool GitClient::synchronousTagCmd(const QString &workingDirectory, QStringList t tagArgs.push_front(QLatin1String("tag")); QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, tagArgs, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, tagArgs, &outputText, &errorText); *output = commandOutputFromLocal8Bit(outputText); if (!rc) msgCannotRun(tagArgs, workingDirectory, errorText, errorMessage); @@ -1777,8 +1657,8 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin args.push_front(QLatin1String("for-each-ref")); QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputText, &errorText, + silentFlags); *output = SynchronousProcess::normalizeNewlines(QString::fromUtf8(outputText)); if (!rc) msgCannotRun(args, workingDirectory, errorText, errorMessage); @@ -1792,8 +1672,8 @@ bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringLis remoteArgs.push_front(QLatin1String("remote")); QByteArray outputText; QByteArray errorText; - if (!fullySynchronousGit(workingDirectory, remoteArgs, &outputText, &errorText, - silent ? VcsBasePlugin::SuppressCommandLogging : 0)) { + if (!vcsFullySynchronousExec(workingDirectory, remoteArgs, &outputText, &errorText, + silent ? silentFlags : 0)) { msgCannotRun(remoteArgs, workingDirectory, errorText, errorMessage); return false; } @@ -1837,7 +1717,7 @@ QStringList GitClient::synchronousSubmoduleStatus(const QString &workingDirector // get submodule status arguments << QLatin1String("submodule") << QLatin1String("status"); - if (!fullySynchronousGit(workingDirectory, arguments, &outputTextData, &errorText)) { + if (!vcsFullySynchronousExec(workingDirectory, arguments, &outputTextData, &errorText)) { msgCannotRun(tr("Cannot retrieve submodule status of \"%1\": %2") .arg(QDir::toNativeSeparators(workingDirectory), commandOutputFromLocal8Bit(errorText)), errorMessage); @@ -1914,7 +1794,7 @@ bool GitClient::synchronousShow(const QString &workingDirectory, const QString & args << QLatin1String(decorateOption) << QLatin1String(noColorOption) << id; QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputText, &errorText); if (rc) *output = commandOutputFromLocal8Bit(outputText); else @@ -1929,7 +1809,7 @@ bool GitClient::cleanList(const QString &workingDirectory, const QString &flag, args << QLatin1String("clean") << QLatin1String("--dry-run") << flag; QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputText, &errorText); if (!rc) { msgCannotRun(QStringList(QLatin1String("clean")), workingDirectory, errorText, errorMessage); @@ -1968,75 +1848,33 @@ bool GitClient::synchronousApplyPatch(const QString &workingDirectory, args << QLatin1String("apply") << QLatin1String("--whitespace=fix") << arguments << file; QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, args, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, args, &outputText, &errorText); if (rc) { if (!errorText.isEmpty()) - *errorMessage = tr("There were warnings while applying \"%1\" to \"%2\":\n%3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText)); + *errorMessage = tr("There were warnings while applying \"%1\" to \"%2\":\n%3") + .arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText)); } else { - *errorMessage = tr("Cannot apply patch \"%1\" to \"%2\": %3").arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText)); + *errorMessage = tr("Cannot apply patch \"%1\" to \"%2\": %3") + .arg(file, workingDirectory, commandOutputFromLocal8Bit(errorText)); return false; } return true; } -// Factory function to create an asynchronous command -VcsCommand *GitClient::createCommand(const QString &workingDirectory, - VcsBaseEditorWidget* editor, - bool useOutputToWindow, - int editorLineNumber) -{ - GitEditorWidget *gitEditor = qobject_cast<GitEditorWidget *>(editor); - auto command = new VcsCommand(gitExecutable(), workingDirectory, processEnvironment()); - command->setCodec(getSourceCodec(currentDocumentPath())); - command->setCookie(QVariant(editorLineNumber)); - if (gitEditor) { - gitEditor->setCommand(command); - connect(command, &VcsCommand::finished, - gitEditor, &GitEditorWidget::commandFinishedGotoLine); - } - if (useOutputToWindow) { - command->addFlags(VcsBasePlugin::ShowStdOutInLogWindow); - command->addFlags(VcsBasePlugin::ShowSuccessMessage); - if (editor) // assume that the commands output is the important thing - command->addFlags(VcsBasePlugin::SilentOutput); - } else if (gitEditor) { - connect(command, &VcsCommand::output, gitEditor, &GitEditorWidget::setPlainTextFiltered); - } - - return command; -} - -// Execute a single command -VcsCommand *GitClient::executeGit(const QString &workingDirectory, - const QStringList &arguments, - VcsBaseEditorWidget* editor, - bool useOutputToWindow, - unsigned additionalFlags, - int editorLineNumber) -{ - VcsCommand *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber); - command->addJob(arguments, settings()->intValue(GitSettings::timeoutKey)); - command->addFlags(additionalFlags); - command->execute(); - return command; -} - QProcessEnvironment GitClient::processEnvironment() const { - QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); - QString gitPath = settings()->stringValue(GitSettings::pathKey); + QProcessEnvironment environment = VcsBaseClientImpl::processEnvironment(); + QString gitPath = settings().stringValue(GitSettings::pathKey); if (!gitPath.isEmpty()) { gitPath += HostOsInfo::pathListSeparator(); gitPath += environment.value(QLatin1String("PATH")); environment.insert(QLatin1String("PATH"), gitPath); } if (HostOsInfo::isWindowsHost() - && settings()->boolValue(GitSettings::winSetHomeEnvironmentKey)) { + && settings().boolValue(GitSettings::winSetHomeEnvironmentKey)) { environment.insert(QLatin1String("HOME"), QDir::toNativeSeparators(QDir::homePath())); } environment.insert(QLatin1String("GIT_EDITOR"), m_disableEditor ? QLatin1String("true") : m_gitQtcEditor); - // Set up SSH and C locale (required by git using perl). - VcsBasePlugin::setProcessEnvironment(&environment, false); return environment; } @@ -2074,31 +1912,6 @@ bool GitClient::isValidRevision(const QString &revision) const return false; } -// Synchronous git execution using Utils::SynchronousProcess, with -// log windows updating. -SynchronousProcessResponse GitClient::synchronousGit(const QString &workingDirectory, - const QStringList &gitArguments, - unsigned flags, - QTextCodec *outputCodec) const -{ - return VcsBasePlugin::runVcs(workingDirectory, gitExecutable(), gitArguments, - settings()->intValue(GitSettings::timeoutKey) * 1000, - flags, outputCodec, processEnvironment()); -} - -bool GitClient::fullySynchronousGit(const QString &workingDirectory, - const QStringList &gitArguments, - QByteArray* outputText, - QByteArray* errorText, - unsigned flags) const -{ - VcsCommand command(gitExecutable(), workingDirectory, processEnvironment()); - command.addFlags(flags); - return command.runFullySynchronous(gitArguments, - settings()->intValue(GitSettings::timeoutKey) * 1000, - outputText, errorText); -} - void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool prompt) { if (!m_updatedSubmodules.isEmpty() || submoduleList(workingDirectory).isEmpty()) @@ -2147,8 +1960,8 @@ void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool p QStringList arguments; arguments << QLatin1String("submodule") << QLatin1String("update"); - VcsCommand *cmd = executeGit(workingDirectory, arguments, 0, true, - VcsBasePlugin::ExpectRepoChanges); + VcsCommand *cmd = vcsExec(workingDirectory, arguments, 0, true, + VcsCommand::ExpectRepoChanges); connect(cmd, &VcsCommand::finished, this, &GitClient::finishSubmoduleUpdate); } @@ -2181,8 +1994,8 @@ GitClient::StatusResult GitClient::gitStatus(const QString &workingDirectory, St statusArgs << QLatin1String("--ignore-submodules=all"); statusArgs << QLatin1String("--porcelain") << QLatin1String("-b"); - const bool statusRc = fullySynchronousGit(workingDirectory, statusArgs, &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool statusRc = vcsFullySynchronousExec(workingDirectory, statusArgs, + &outputText, &errorText, silentFlags); if (output) *output = commandOutputFromLocal8Bit(outputText); @@ -2347,10 +2160,10 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR { QStringList arguments(QLatin1String("ls-remote")); arguments << repositoryURL << QLatin1String(HEAD) << QLatin1String("refs/heads/*"); - const unsigned flags = VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::SuppressStdErrInLogWindow - | VcsBasePlugin::SuppressFailMessageInLogWindow; - const SynchronousProcessResponse resp = synchronousGit(workingDirectory, arguments, flags); + const unsigned flags = VcsCommand::SshPasswordPrompt + | VcsCommand::SuppressStdErr + | VcsCommand::SuppressFailMessage; + const SynchronousProcessResponse resp = vcsSynchronousExec(workingDirectory, arguments, flags); QStringList branches; branches << tr("<Detached HEAD>"); QString headSha; @@ -2380,7 +2193,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR void GitClient::launchGitK(const QString &workingDirectory, const QString &fileName) { - const QFileInfo binaryInfo = gitExecutable().toFileInfo(); + const QFileInfo binaryInfo = vcsBinary().toFileInfo(); QDir foundBinDir(binaryInfo.dir()); const bool foundBinDirIsCmdDir = foundBinDir.dirName() == QLatin1String("cmd"); QProcessEnvironment env = processEnvironment(); @@ -2413,7 +2226,7 @@ void GitClient::launchGitK(const QString &workingDirectory, const QString &fileN void GitClient::launchRepositoryBrowser(const QString &workingDirectory) { - const QString repBrowserBinary = settings()->stringValue(GitSettings::repositoryBrowserCmd); + const QString repBrowserBinary = settings().stringValue(GitSettings::repositoryBrowserCmd); if (!repBrowserBinary.isEmpty()) QProcess::startDetached(repBrowserBinary, QStringList(workingDirectory), workingDirectory); } @@ -2433,7 +2246,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env, binary = wish; } } - const QString gitkOpts = settings()->stringValue(GitSettings::gitkOptionsKey); + const QString gitkOpts = settings().stringValue(GitSettings::gitkOptionsKey); if (!gitkOpts.isEmpty()) arguments.append(QtcProcess::splitArgs(gitkOpts, HostOsInfo::hostOs())); if (!fileName.isEmpty()) @@ -2442,7 +2255,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env, // This should always use QProcess::startDetached (as not to kill // the child), but that does not have an environment parameter. bool success = false; - if (!settings()->stringValue(GitSettings::pathKey).isEmpty()) { + if (!settings().stringValue(GitSettings::pathKey).isEmpty()) { auto process = new QProcess(this); process->setWorkingDirectory(workingDirectory); process->setProcessEnvironment(env); @@ -2461,9 +2274,11 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env, } bool GitClient::launchGitGui(const QString &workingDirectory) { - bool success; - FileName gitBinary = gitExecutable(&success); - if (success) { + bool success = true; + FileName gitBinary = vcsBinary(); + if (gitBinary.isEmpty()) { + success = false; + } else { success = QProcess::startDetached(gitBinary.toString(), QStringList(QLatin1String("gui")), workingDirectory); } @@ -2476,7 +2291,7 @@ bool GitClient::launchGitGui(const QString &workingDirectory) { FileName GitClient::gitBinDirectory() { - const QString git = gitExecutable().toString(); + const QString git = vcsBinary().toString(); if (git.isEmpty()) return FileName(); @@ -2492,19 +2307,23 @@ FileName GitClient::gitBinDirectory() return FileName::fromString(path); } -FileName GitClient::gitExecutable(bool *ok, QString *errorMessage) const +FileName GitClient::vcsBinary() const { - return settings()->gitExecutable(ok, errorMessage); + bool ok; + Utils::FileName binary = static_cast<GitSettings &>(settings()).gitExecutable(&ok); + if (!ok) + return Utils::FileName(); + return binary; } QTextCodec *GitClient::encoding(const QString &workingDirectory, const QByteArray &configVar) const { - QByteArray codecName = readConfigBytes(workingDirectory, QLatin1String(configVar)).trimmed(); + QString codecName = readConfigValue(workingDirectory, QLatin1String(configVar)).trimmed(); // Set default commit encoding to 'UTF-8', when it's not set, // to solve displaying error of commit log with non-latin characters. if (codecName.isEmpty()) - codecName = "UTF-8"; - return QTextCodec::codecForName(codecName); + return QTextCodec::codecForName("UTF-8"); + return QTextCodec::codecForName(codecName.toUtf8()); } // returns first line from log and removes it @@ -2525,8 +2344,7 @@ bool GitClient::readDataFromCommit(const QString &repoDirectory, const QString & args << QLatin1String("--max-count=1") << QLatin1String("--pretty=format:%h\n%an\n%ae\n%B"); args << commit; QByteArray outputText; - if (!fullySynchronousGit(repoDirectory, args, &outputText, 0, - VcsBasePlugin::SuppressCommandLogging)) { + if (!vcsFullySynchronousExec(repoDirectory, args, &outputText, 0, silentFlags)) { if (errorMessage) *errorMessage = tr("Cannot retrieve last commit data of repository \"%1\".").arg(repoDirectory); return false; @@ -2773,7 +2591,7 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory, QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(repositoryDirectory, args, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(repositoryDirectory, args, &outputText, &errorText); const QString stdErr = commandOutputFromLocal8Bit(errorText); if (rc) { VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount)); @@ -2898,8 +2716,7 @@ void GitClient::fetch(const QString &workingDirectory, const QString &remote) { QStringList arguments(QLatin1String("fetch")); arguments << (remote.isEmpty() ? QLatin1String("--all") : remote); - VcsCommand *command = executeGit(workingDirectory, arguments, 0, true); - command->setCookie(workingDirectory); + VcsCommand *command = vcsExec(workingDirectory, arguments, 0, true, 0, workingDirectory); connect(command, &VcsCommand::success, this, &GitClient::fetchFinished); } @@ -2908,18 +2725,15 @@ bool GitClient::executeAndHandleConflicts(const QString &workingDirectory, const QString &abortCommand) const { // Disable UNIX terminals to suppress SSH prompting. - const unsigned flags = VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ExpectRepoChanges - | VcsBasePlugin::ShowSuccessMessage; - const SynchronousProcessResponse resp = synchronousGit(workingDirectory, arguments, flags); - ConflictHandler conflictHandler(0, workingDirectory, abortCommand); + const unsigned flags = VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ExpectRepoChanges + | VcsCommand::ShowSuccessMessage; + const SynchronousProcessResponse resp = vcsSynchronousExec(workingDirectory, arguments, flags); // Notify about changed files or abort the rebase. const bool ok = resp.result == SynchronousProcessResponse::Finished; - if (!ok) { - conflictHandler.readStdOut(resp.stdOut); - conflictHandler.readStdErr(resp.stdErr); - } + if (!ok) + ConflictHandler::handleResponse(resp, workingDirectory, abortCommand); return ok; } @@ -2954,12 +2768,8 @@ void GitClient::synchronousAbortCommand(const QString &workingDir, const QString QStringList arguments; arguments << abortCommand << QLatin1String("--abort"); QByteArray stdOut; - QByteArray stdErr; - const bool rc = fullySynchronousGit(workingDir, arguments, &stdOut, &stdErr, - VcsBasePlugin::ExpectRepoChanges); + vcsFullySynchronousExec(workingDir, arguments, &stdOut, 0, VcsCommand::ExpectRepoChanges); VcsOutputWindow::append(commandOutputFromLocal8Bit(stdOut)); - if (!rc) - VcsOutputWindow::appendError(commandOutputFromLocal8Bit(stdErr)); } QString GitClient::synchronousTrackingBranch(const QString &workingDirectory, const QString &branch) @@ -2983,19 +2793,13 @@ bool GitClient::synchronousSetTrackingBranch(const QString &workingDirectory, const QString &branch, const QString &tracking) { QByteArray outputText; - QByteArray errorText; QStringList arguments; arguments << QLatin1String("branch"); if (gitVersion() >= 0x010800) arguments << (QLatin1String("--set-upstream-to=") + tracking) << branch; else arguments << QLatin1String("--set-upstream") << branch << tracking; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); - if (!rc) { - msgCannotRun(tr("Cannot set tracking branch: %1") - .arg(commandOutputFromLocal8Bit(errorText)), 0); - } - return rc; + return vcsFullySynchronousExec(workingDirectory, arguments, &outputText); } void GitClient::handleMergeConflicts(const QString &workingDir, const QString &commit, @@ -3044,17 +2848,17 @@ void GitClient::synchronousSubversionFetch(const QString &workingDirectory) QStringList args; args << QLatin1String("svn") << QLatin1String("fetch"); // Disable UNIX terminals to suppress SSH prompting. - const unsigned flags = VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ShowSuccessMessage; - synchronousGit(workingDirectory, args, flags); + const unsigned flags = VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ShowSuccessMessage; + vcsSynchronousExec(workingDirectory, args, flags); } void GitClient::subversionLog(const QString &workingDirectory) { QStringList arguments; arguments << QLatin1String("svn") << QLatin1String("log"); - int logCount = settings()->intValue(GitSettings::logCountKey); + int logCount = settings().intValue(GitSettings::logCountKey); if (logCount > 0) arguments << (QLatin1String("--limit=") + QString::number(logCount)); @@ -3062,11 +2866,10 @@ void GitClient::subversionLog(const QString &workingDirectory) const QString title = tr("Git SVN Log"); const Id editorId = Git::Constants::GIT_COMMAND_LOG_EDITOR_ID; const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, QStringList()); - VcsBaseEditorWidget *editor = findExistingVCSEditor("svnLog", sourceFile); - if (!editor) - editor = createVcsEditor(editorId, title, sourceFile, CodecNone, "svnLog", sourceFile, 0); + VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, sourceFile, codecFor(CodecNone), + "svnLog", sourceFile); editor->setWorkingDirectory(workingDirectory); - executeGit(workingDirectory, arguments, editor); + vcsExec(workingDirectory, arguments, editor); } void GitClient::push(const QString &workingDirectory, const QStringList &pushArgs) @@ -3074,7 +2877,7 @@ void GitClient::push(const QString &workingDirectory, const QStringList &pushArg QStringList arguments(QLatin1String("push")); if (!pushArgs.isEmpty()) arguments += pushArgs; - executeGit(workingDirectory, arguments, 0, true); + vcsExec(workingDirectory, arguments, 0, true); } bool GitClient::synchronousMerge(const QString &workingDirectory, const QString &branch, @@ -3104,34 +2907,36 @@ bool GitClient::canRebase(const QString &workingDirectory) const void GitClient::rebase(const QString &workingDirectory, const QString &argument) { - asyncCommand(workingDirectory, QStringList() << QLatin1String("rebase") << argument, true); + VcsCommand *command = vcsExecAbortable(workingDirectory, + QStringList() << QLatin1String("rebase") << argument); + GitProgressParser::attachToCommand(command); } void GitClient::cherryPick(const QString &workingDirectory, const QString &argument) { - asyncCommand(workingDirectory, QStringList() << QLatin1String("cherry-pick") << argument); + vcsExecAbortable(workingDirectory, QStringList() << QLatin1String("cherry-pick") << argument); } void GitClient::revert(const QString &workingDirectory, const QString &argument) { - asyncCommand(workingDirectory, QStringList() << QLatin1String("revert") << argument); + vcsExecAbortable(workingDirectory, QStringList() << QLatin1String("revert") << argument); } // Executes a command asynchronously. Work tree is expected to be clean. // Stashing is handled prior to this call. -void GitClient::asyncCommand(const QString &workingDirectory, const QStringList &arguments, - bool hasProgress) +VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory, + const QStringList &arguments) { + QTC_ASSERT(!arguments.isEmpty(), return 0); + + QString abortCommand = arguments.at(0); // Git might request an editor, so this must be done asynchronously - // and without timeout - QString gitCommand = arguments.first(); - VcsCommand *command = createCommand(workingDirectory, 0, true); - new ConflictHandler(command, workingDirectory, gitCommand); - if (hasProgress) - command->setProgressParser(new GitProgressParser); - command->addJob(arguments, -1); - command->execute(); - command->setCookie(workingDirectory); + VcsCommand *command = vcsExec(workingDirectory, arguments, 0, true, 0, workingDirectory); + // ... and without timeout + command->setDefaultTimeoutS(0); + ConflictHandler::attachToCommand(command, abortCommand); + + return command; } bool GitClient::synchronousRevert(const QString &workingDirectory, const QString &commit) @@ -3172,7 +2977,8 @@ void GitClient::interactiveRebase(const QString &workingDirectory, const QString arguments << commit + QLatin1Char('^'); if (fixup) m_disableEditor = true; - asyncCommand(workingDirectory, arguments, true); + VcsCommand *command = vcsExecAbortable(workingDirectory, arguments); + GitProgressParser::attachToCommand(command); if (fixup) m_disableEditor = false; } @@ -3193,9 +2999,8 @@ void GitClient::stashPop(const QString &workingDirectory, const QString &stash) arguments << QLatin1String("pop"); if (!stash.isEmpty()) arguments << stash; - VcsCommand *cmd = executeGit(workingDirectory, arguments, 0, true, - VcsBasePlugin::ExpectRepoChanges); - new ConflictHandler(cmd, workingDirectory); + VcsCommand *cmd = vcsExec(workingDirectory, arguments, 0, true, VcsCommand::ExpectRepoChanges); + ConflictHandler::attachToCommand(cmd); } bool GitClient::synchronousStashRestore(const QString &workingDirectory, @@ -3222,7 +3027,7 @@ bool GitClient::synchronousStashRemove(const QString &workingDirectory, arguments << QLatin1String("drop") << stash; QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, &errorText); if (rc) { const QString output = commandOutputFromLocal8Bit(outputText); if (!output.isEmpty()) @@ -3242,7 +3047,7 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, arguments << QLatin1String("list") << QLatin1String(noColorOption); QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText); + const bool rc = vcsFullySynchronousExec(workingDirectory, arguments, &outputText, &errorText); if (!rc) { msgCannotRun(arguments, workingDirectory, errorText, errorMessage); return false; @@ -3254,21 +3059,6 @@ bool GitClient::synchronousStashList(const QString &workingDirectory, return true; } -QByteArray GitClient::readConfigBytes(const QString &workingDirectory, const QString &configVar) const -{ - QStringList arguments; - arguments << QLatin1String("config") << configVar; - - QByteArray outputText; - QByteArray errorText; - if (!fullySynchronousGit(workingDirectory, arguments, &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging)) - return QByteArray(); - if (HostOsInfo::isWindowsHost()) - outputText.replace("\r\n", "\n"); - return outputText; -} - // Read a single-line config value, return trimmed QString GitClient::readConfigValue(const QString &workingDirectory, const QString &configVar) const { @@ -3277,16 +3067,23 @@ QString GitClient::readConfigValue(const QString &workingDirectory, const QStrin static QTextCodec *codec = HostOsInfo::isWindowsHost() ? QTextCodec::codecForName("UTF-8") : QTextCodec::codecForLocale(); - const QByteArray value = readConfigBytes(workingDirectory, configVar).trimmed(); - return SynchronousProcess::normalizeNewlines(codec->toUnicode(value)); + QStringList arguments; + arguments << QLatin1String("config") << configVar; + + QByteArray outputText; + if (!vcsFullySynchronousExec(workingDirectory, arguments, &outputText, 0, silentFlags)) + return QString(); + if (HostOsInfo::isWindowsHost()) + outputText.replace("\r\n", "\n"); + + return SynchronousProcess::normalizeNewlines(codec->toUnicode(outputText.trimmed())); } bool GitClient::cloneRepository(const QString &directory,const QByteArray &url) { QDir workingDirectory(directory); - const unsigned flags = VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ShowSuccessMessage; + const unsigned flags = VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage; if (workingDirectory.exists()) { if (!synchronousInit(workingDirectory.path())) @@ -3294,13 +3091,13 @@ bool GitClient::cloneRepository(const QString &directory,const QByteArray &url) QStringList arguments(QLatin1String("remote")); arguments << QLatin1String("add") << QLatin1String("origin") << QLatin1String(url); - if (!fullySynchronousGit(workingDirectory.path(), arguments, 0)) + if (!vcsFullySynchronousExec(workingDirectory.path(), arguments, 0)) return false; arguments.clear(); arguments << QLatin1String("fetch"); - const SynchronousProcessResponse resp = - synchronousGit(workingDirectory.path(), arguments, flags); + const SynchronousProcessResponse resp + = vcsSynchronousExec(workingDirectory.path(), arguments, flags); if (resp.result != SynchronousProcessResponse::Finished) return false; @@ -3308,14 +3105,14 @@ bool GitClient::cloneRepository(const QString &directory,const QByteArray &url) arguments << QLatin1String("config") << QLatin1String("branch.master.remote") << QLatin1String("origin"); - if (!fullySynchronousGit(workingDirectory.path(), arguments, 0)) + if (!vcsFullySynchronousExec(workingDirectory.path(), arguments, 0)) return false; arguments.clear(); arguments << QLatin1String("config") << QLatin1String("branch.master.merge") << QLatin1String("refs/heads/master"); - if (!fullySynchronousGit(workingDirectory.path(), arguments, 0)) + if (!vcsFullySynchronousExec(workingDirectory.path(), arguments, 0)) return false; return true; @@ -3323,23 +3120,17 @@ bool GitClient::cloneRepository(const QString &directory,const QByteArray &url) QStringList arguments(QLatin1String("clone")); arguments << QLatin1String(url) << workingDirectory.dirName(); workingDirectory.cdUp(); - const SynchronousProcessResponse resp = - synchronousGit(workingDirectory.path(), arguments, flags); - // TODO: Turn this into a VcsBaseClient and use resetCachedVcsInfo(...) - VcsManager::resetVersionControlForDirectory(workingDirectory.absolutePath()); + const SynchronousProcessResponse resp + = vcsSynchronousExec(workingDirectory.path(), arguments, flags); + resetCachedVcsInfo(workingDirectory.absolutePath()); return (resp.result == SynchronousProcessResponse::Finished); } } -GitSettings *GitClient::settings() const -{ - return m_settings; -} - // determine version as '(major << 16) + (minor << 8) + patch' or 0. unsigned GitClient::gitVersion(QString *errorMessage) const { - const FileName newGitBinary = gitExecutable(); + const FileName newGitBinary = vcsBinary(); if (m_gitVersionForBinary != newGitBinary && !newGitBinary.isEmpty()) { // Do not execute repeatedly if that fails (due to git // not being installed) until settings are changed. @@ -3352,15 +3143,14 @@ unsigned GitClient::gitVersion(QString *errorMessage) const // determine version as '(major << 16) + (minor << 8) + patch' or 0. unsigned GitClient::synchronousGitVersion(QString *errorMessage) const { - if (gitExecutable().isEmpty()) + if (vcsBinary().isEmpty()) return 0; // run git --version QByteArray outputText; QByteArray errorText; - const bool rc = fullySynchronousGit(QString(), QStringList(QLatin1String("--version")), - &outputText, &errorText, - VcsBasePlugin::SuppressCommandLogging); + const bool rc = vcsFullySynchronousExec(QString(), QStringList(QLatin1String("--version")), + &outputText, &errorText, silentFlags); if (!rc) { msgCannotRun(tr("Cannot determine Git version: %1") .arg(commandOutputFromLocal8Bit(errorText)), @@ -3380,7 +3170,7 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const } GitClient::StashInfo::StashInfo() : - m_client(GitPlugin::instance()->gitClient()), + m_client(GitPlugin::instance()->client()), m_pushAction(NoPush) { } diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 870e2e25903..80b237aa899 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -35,6 +35,7 @@ #include "commitdata.h" #include <coreplugin/editormanager/ieditor.h> +#include <vcsbase/vcsbaseclient.h> #include <utils/fileutils.h> @@ -61,7 +62,10 @@ namespace VcsBase { class VcsBaseEditorParameterWidget; } -namespace Utils { struct SynchronousProcessResponse; } +namespace Utils { +class ExitCodeInterpreter; +struct SynchronousProcessResponse; +} // namespace Utils namespace DiffEditor { class DiffEditorDocument; @@ -98,7 +102,7 @@ public: typedef QMap<QString, SubmoduleData> SubmoduleDataMap; -class GitClient : public QObject +class GitClient : public VcsBase::VcsBaseClientImpl { Q_OBJECT @@ -134,11 +138,13 @@ public: static const char *stashNamePrefix; - explicit GitClient(GitSettings *settings); + explicit GitClient(); - Utils::FileName gitExecutable(bool *ok = 0, QString *errorMessage = 0) const; + Utils::FileName vcsBinary() const override; unsigned gitVersion(QString *errorMessage = 0) const; + VcsBase::VcsCommand *vcsExecAbortable(const QString &workingDirectory, const QStringList &arguments); + QString findRepositoryForDirectory(const QString &dir) const; QString findGitDirForRepository(const QString &repositoryDir) const; bool managesFile(const QString &workingDirectory, const QString &fileName) const; @@ -158,8 +164,9 @@ public: void log(const QString &workingDirectory, const QString &fileName = QString(), bool enableAnnotationContextMenu = false, const QStringList &args = QStringList()); void reflog(const QString &workingDirectory); - void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName, - const QString &revision = QString(), int lineNumber = -1); + void annotate(const QString &workingDir, const QString &file, + const QString &revision = QString(), int lineNumber = -1, + const QStringList &extraOptions = QStringList()) override; void reset(const QString &workingDirectory, const QString &argument, const QString &commit = QString()); void addFile(const QString &workingDirectory, const QString &fileName); bool synchronousLog(const QString &workingDirectory, @@ -261,8 +268,7 @@ public: void rebase(const QString &workingDirectory, const QString &argument); void cherryPick(const QString &workingDirectory, const QString &argument); void revert(const QString &workingDirectory, const QString &argument); - void asyncCommand(const QString &workingDirectory, const QStringList &arguments, - bool hasProgress = false); + bool synchronousRevert(const QString &workingDirectory, const QString &commit); bool synchronousCherryPick(const QString &workingDirectory, const QString &commit); void interactiveRebase(const QString &workingDirectory, const QString &commit, bool fixup); @@ -326,9 +332,7 @@ public: QStringList synchronousRepositoryBranches(const QString &repositoryURL, const QString &workingDirectory = QString()) const; - GitSettings *settings() const; - - QProcessEnvironment processEnvironment() const; + QProcessEnvironment processEnvironment() const override; bool beginStashScope(const QString &workingDirectory, const QString &command, StashFlag flag = Default, PushAction pushAction = NoPush); @@ -345,11 +349,8 @@ public slots: void show(const QString &source, const QString &id, const QString &name = QString()); - void saveSettings(); private slots: - void slotBlameRevisionRequested(const QString &workingDirectory, const QString &file, - QString change, int lineNumber); void finishSubmoduleUpdate(); void fetchFinished(const QVariant &cookie); void slotChunkActionsRequested(QMenu *menu, bool isValid); @@ -359,49 +360,13 @@ private slots: private: void stage(const QString &patch, bool revert); - QByteArray readConfigBytes(const QString &workingDirectory, const QString &configVar) const; - QTextCodec *getSourceCodec(const QString &file) const; - VcsBase::VcsBaseEditorWidget *findExistingVCSEditor(const char *registerDynamicProperty, - const QString &dynamicPropertyValue) const; enum CodecType { CodecSource, CodecLogOutput, CodecNone }; - - VcsBase::VcsBaseEditorWidget *createVcsEditor(Core::Id kind, - QString title, - const QString &source, - CodecType codecType, - const char *registerDynamicProperty, - const QString &dynamicPropertyValue, - VcsBase::VcsBaseEditorParameterWidget *configWidget) const; + QTextCodec *codecFor(CodecType codecType, const QString &source = QString()) const; void requestReload(const QString &documentId, const QString &source, const QString &title, std::function<DiffEditor::DiffEditorController *(Core::IDocument *)> factory) const; - VcsBase::VcsCommand *createCommand(const QString &workingDirectory, - VcsBase::VcsBaseEditorWidget* editor = 0, - bool useOutputToWindow = false, - int editorLineNumber = -1); - - VcsBase::VcsCommand *executeGit(const QString &workingDirectory, - const QStringList &arguments, - VcsBase::VcsBaseEditorWidget* editor = 0, - bool useOutputToWindow = false, - unsigned additionalFlags = 0, - int editorLineNumber = -1); - - // Fully synchronous git execution (QProcess-based). - bool fullySynchronousGit(const QString &workingDirectory, - const QStringList &arguments, - QByteArray* outputText, - QByteArray* errorText = 0, - unsigned flags = 0) const; - - // Synchronous git execution using Utils::SynchronousProcess, with - // log windows updating (using VcsBasePlugin::runVcs with flags). - inline Utils::SynchronousProcessResponse - synchronousGit(const QString &workingDirectory, const QStringList &arguments, - unsigned flags = 0, QTextCodec *outputCodec = 0) const; - // determine version as '(major << 16) + (minor << 8) + patch' or 0. unsigned synchronousGitVersion(QString *errorMessage = 0) const; @@ -432,7 +397,6 @@ private: mutable Utils::FileName m_gitVersionForBinary; mutable unsigned m_cachedGitVersion; - GitSettings *m_settings; QString m_gitQtcEditor; QMap<QString, StashInfo> m_stashInfo; QStringList m_updatedSubmodules; diff --git a/src/plugins/git/giteditor.cpp b/src/plugins/git/giteditor.cpp index d621573a31b..bfff94ac057 100644 --- a/src/plugins/git/giteditor.cpp +++ b/src/plugins/git/giteditor.cpp @@ -176,7 +176,7 @@ static QString removeAnnotationDate(const QString &b) return result; } -void GitEditorWidget::setPlainTextFiltered(const QString &text) +void GitEditorWidget::setPlainText(const QString &text) { QString modText = text; GitPlugin *plugin = GitPlugin::instance(); @@ -184,7 +184,8 @@ void GitEditorWidget::setPlainTextFiltered(const QString &text) switch (contentType()) { case AnnotateOutput: { - const bool omitAnnotationDate = plugin->settings().boolValue(GitSettings::omitAnnotationDateKey); + const bool omitAnnotationDate + = plugin->client()->settings().boolValue(GitSettings::omitAnnotationDateKey); if (omitAnnotationDate) modText = removeAnnotationDate(text); break; @@ -196,19 +197,9 @@ void GitEditorWidget::setPlainTextFiltered(const QString &text) textDocument()->setPlainText(modText); } -void GitEditorWidget::commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v) -{ - reportCommandFinished(ok, exitCode, v); - if (ok && v.type() == QVariant::Int) { - const int line = v.toInt(); - if (line >= 0) - gotoLine(line); - } -} - void GitEditorWidget::checkoutChange() { - GitPlugin::instance()->gitClient()->stashAndCheckout( + GitPlugin::instance()->client()->stashAndCheckout( sourceWorkingDirectory(), m_currentChange); } @@ -216,7 +207,7 @@ void GitEditorWidget::resetChange(const QByteArray &resetType) { const QString workingDir = sourceWorkingDirectory(); - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); if (resetType == "hard" && client->gitStatus(workingDir, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusUnchanged) { @@ -233,19 +224,19 @@ void GitEditorWidget::resetChange(const QByteArray &resetType) void GitEditorWidget::cherryPickChange() { - GitPlugin::instance()->gitClient()->synchronousCherryPick( + GitPlugin::instance()->client()->synchronousCherryPick( sourceWorkingDirectory(), m_currentChange); } void GitEditorWidget::revertChange() { - GitPlugin::instance()->gitClient()->synchronousRevert( + GitPlugin::instance()->client()->synchronousRevert( sourceWorkingDirectory(), m_currentChange); } void GitEditorWidget::logChange() { - GitPlugin::instance()->gitClient()->log( + GitPlugin::instance()->client()->log( sourceWorkingDirectory(), QString(), false, QStringList(m_currentChange)); } @@ -260,7 +251,7 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert) patchFile.write(chunk.chunk); patchFile.close(); - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); QStringList args = QStringList() << QLatin1String("--cached"); if (revert) args << QLatin1String("--reverse"); @@ -313,7 +304,7 @@ bool GitEditorWidget::open(QString *errorString, const QString &fileName, const const QString gitPath = fi.absolutePath(); setSource(gitPath); textDocument()->setCodec( - GitPlugin::instance()->gitClient()->encoding(gitPath, "i18n.commitEncoding")); + GitPlugin::instance()->client()->encoding(gitPath, "i18n.commitEncoding")); } return VcsBaseEditorWidget::open(errorString, fileName, realFileName); } @@ -324,14 +315,14 @@ QString GitEditorWidget::decorateVersion(const QString &revision) const const QString workingDirectory = fi.absolutePath(); // Format verbose, SHA1 being first token - return GitPlugin::instance()->gitClient()->synchronousShortDescription(workingDirectory, revision); + return GitPlugin::instance()->client()->synchronousShortDescription(workingDirectory, revision); } QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const { QStringList revisions; QString errorMessage; - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); const QFileInfo fi(source()); const QString workingDirectory = fi.absolutePath(); // Get the SHA1's of the file. @@ -345,7 +336,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) bool GitEditorWidget::isValidRevision(const QString &revision) const { - return GitPlugin::instance()->gitClient()->isValidRevision(revision); + return GitPlugin::instance()->client()->isValidRevision(revision); } void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change) diff --git a/src/plugins/git/giteditor.h b/src/plugins/git/giteditor.h index 8d2803c1a46..3540c5e4aa1 100644 --- a/src/plugins/git/giteditor.h +++ b/src/plugins/git/giteditor.h @@ -49,10 +49,7 @@ class GitEditorWidget : public VcsBase::VcsBaseEditorWidget public: GitEditorWidget(); -public slots: - void setPlainTextFiltered(const QString &text); - // Matches the signature of the finished signal of GitCommand - void commandFinishedGotoLine(bool ok, int exitCode, const QVariant &v); + void setPlainText(const QString &text) override; private slots: void checkoutChange(); @@ -62,20 +59,20 @@ private slots: void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert); private: - void init(); + void init() override; void resetChange(const QByteArray &resetType); - void addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk); - bool open(QString *errorString, const QString &fileName, const QString &realFileName); - QSet<QString> annotationChanges() const; - QString changeUnderCursor(const QTextCursor &) const; - VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const; - QString decorateVersion(const QString &revision) const; - QStringList annotationPreviousVersions(const QString &revision) const; - bool isValidRevision(const QString &revision) const; - void addChangeActions(QMenu *menu, const QString &change); - QString revisionSubject(const QTextBlock &inBlock) const; - bool supportChangeLinks() const; - QString fileNameForLine(int line) const; + void addDiffActions(QMenu *menu, const VcsBase::DiffChunk &chunk) override; + bool open(QString *errorString, const QString &fileName, const QString &realFileName) override; + QSet<QString> annotationChanges() const override; + QString changeUnderCursor(const QTextCursor &) const override; + VcsBase::BaseAnnotationHighlighter *createAnnotationHighlighter(const QSet<QString> &changes) const override; + QString decorateVersion(const QString &revision) const override; + QStringList annotationPreviousVersions(const QString &revision) const override; + bool isValidRevision(const QString &revision) const override; + void addChangeActions(QMenu *menu, const QString &change) override; + QString revisionSubject(const QTextBlock &inBlock) const override; + bool supportChangeLinks() const override; + QString fileNameForLine(int line) const override; QString sourceWorkingDirectory() const; mutable QRegExp m_changeNumberPattern; diff --git a/src/plugins/git/githighlighters.h b/src/plugins/git/githighlighters.h index 669f09595a8..381d34f8a9d 100644 --- a/src/plugins/git/githighlighters.h +++ b/src/plugins/git/githighlighters.h @@ -55,7 +55,7 @@ class GitSubmitHighlighter : public TextEditor::SyntaxHighlighter { public: explicit GitSubmitHighlighter(QTextEdit *parent = 0); - void highlightBlock(const QString &text); + void highlightBlock(const QString &text) override; private: enum State { None = -1, Header, Other }; @@ -69,7 +69,7 @@ class GitRebaseHighlighter : public TextEditor::SyntaxHighlighter { public: explicit GitRebaseHighlighter(QTextDocument *parent = 0); - void highlightBlock(const QString &text); + void highlightBlock(const QString &text) override; private: class RebaseAction diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 3e2f1b8c283..708ca4bd37e 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -39,7 +39,6 @@ #include "gitversioncontrol.h" #include "branchdialog.h" #include "remotedialog.h" -#include "clonewizard.h" #include "stashdialog.h" #include "settingspage.h" #include "logchangedialog.h" @@ -86,7 +85,6 @@ #include <QScopedPointer> #ifdef WITH_TESTS -#include "clonewizardpage.h" #include <QTest> #endif @@ -274,14 +272,12 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) Context context(Constants::GIT_CONTEXT); - m_settings.readSettings(ICore::settings()); - - m_gitClient = new GitClient(&m_settings); + m_gitClient = new GitClient; initializeVcs(new GitVersionControl(m_gitClient), context); // Create the settings Page - addAutoReleasedObject(new SettingsPage()); + addAutoReleasedObject(new SettingsPage(versionControl())); static const char *describeSlot = SLOT(show(QString,QString)); const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]); @@ -292,16 +288,6 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new GitSubmitEditor(&submitParameters); })); - auto cloneWizardFactory = new BaseCheckoutWizardFactory; - cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_GIT)); - cloneWizardFactory->setIcon(QIcon(QLatin1String(":/git/images/git.png"))); - cloneWizardFactory->setDescription(tr("Clones a Git repository and tries to load the contained project.")); - cloneWizardFactory->setDisplayName(tr("Git Repository Clone")); - cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CloneWizard(path, parent); - }); - addAutoReleasedObject(cloneWizardFactory); - const QString prefix = QLatin1String("git"); m_commandLocator = new CommandLocator("Git", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -717,7 +703,7 @@ void GitPlugin::blameFile() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasFile(), return); const int lineNumber = VcsBaseEditor::lineNumberOfCurrentEditor(state.currentFile()); - m_gitClient->blame(state.currentFileTopLevel(), QStringList(), state.relativeCurrentFile(), QString(), lineNumber); + m_gitClient->annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), lineNumber); } void GitPlugin::logProject() @@ -762,7 +748,7 @@ class ResetItemDelegate : public LogItemDelegate { public: ResetItemDelegate(LogChangeWidget *widget) : LogItemDelegate(widget) {} - void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const + void initStyleOption(QStyleOptionViewItem *option, const QModelIndex &index) const override { if (index.row() < currentRow()) option->font.setStrikeOut(true); @@ -779,7 +765,7 @@ public: } protected: - bool hasIcon(int row) const + bool hasIcon(int row) const override { return row <= currentRow(); } @@ -1109,7 +1095,7 @@ void GitPlugin::pull() const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); QString topLevel = state.topLevel(); - bool rebase = m_settings.boolValue(GitSettings::pullRebaseKey); + bool rebase = client()->settings().boolValue(GitSettings::pullRebaseKey); if (!rebase) { QString currentBranch = m_gitClient->synchronousCurrentLocalBranch(topLevel); @@ -1415,27 +1401,12 @@ void GitPlugin::updateBranches(const QString &repository) void GitPlugin::updateRepositoryBrowserAction() { const bool repositoryEnabled = currentState().hasTopLevel(); - const bool hasRepositoryBrowserCmd = !m_settings.stringValue(GitSettings::repositoryBrowserCmd).isEmpty(); + const bool hasRepositoryBrowserCmd + = !client()->settings().stringValue(GitSettings::repositoryBrowserCmd).isEmpty(); m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd); } -const GitSettings &GitPlugin::settings() const -{ - return m_settings; -} - -void GitPlugin::setSettings(const GitSettings &s) -{ - if (s == m_settings) - return; - - m_settings = s; - m_gitClient->saveSettings(); - static_cast<GitVersionControl *>(versionControl())->emitConfigurationChanged(); - updateRepositoryBrowserAction(); -} - -GitClient *GitPlugin::gitClient() const +GitClient *GitPlugin::client() const { return m_gitClient; } @@ -1557,27 +1528,6 @@ void GitPlugin::testLogResolving() "50a6b54c - Merge branch 'for-junio' of git://bogomips.org/git-svn", "3587b513 - Update draft release notes to 1.8.2"); } - -void GitPlugin::testCloneWizard_directoryFromRepository() -{ - CloneWizardPage page; - page.testDirectoryFromRepository(); -} - -void GitPlugin::testCloneWizard_directoryFromRepository_data() -{ - QTest::addColumn<QString>("repository"); - QTest::addColumn<QString>("localDirectory"); - - QTest::newRow("http") << "http://host/qt/qt.git" << "qt"; - QTest::newRow("without slash") << "user@host:qt.git" << "qt"; - QTest::newRow("mainline.git") << "git://gitorious.org/gitorious/mainline.git" << "gitorious"; - QTest::newRow("local repo (Unix)") << "/home/user/qt-creator.git" << "qt-creator"; - QTest::newRow("local repo (Windows)") << "c:\\repos\\qt-creator.git" << "qt-creator"; - QTest::newRow("ssh with port") << "ssh://host:29418/qt/qt.git" << "qt"; - QTest::newRow("invalid chars removed") << "ssh://host/in%va$lid.git" << "in-va-lid"; - QTest::newRow("leading dashs removed") << "https://gerrit.local/--leadingDash" << "leadingDash"; -} #endif } // namespace Internal diff --git a/src/plugins/git/gitplugin.h b/src/plugins/git/gitplugin.h index 1d01add9885..d2219a535be 100644 --- a/src/plugins/git/gitplugin.h +++ b/src/plugins/git/gitplugin.h @@ -81,14 +81,11 @@ public: static GitPlugin *instance(); - bool initialize(const QStringList &arguments, QString *errorMessage); + bool initialize(const QStringList &arguments, QString *errorMessage) override; GitVersionControl *gitVersionControl() const; - const GitSettings &settings() const; - void setSettings(const GitSettings &s); - - GitClient *gitClient() const; + GitClient *client() const; Gerrit::Internal::GerritPlugin *gerritPlugin() const; public slots: @@ -146,12 +143,10 @@ private slots: void testDiffFileResolving_data(); void testDiffFileResolving(); void testLogResolving(); - void testCloneWizard_directoryFromRepository(); - void testCloneWizard_directoryFromRepository_data(); #endif protected: - void updateActions(VcsBase::VcsBasePlugin::ActionState); - bool submitEditorAboutToClose(); + void updateActions(VcsBase::VcsBasePlugin::ActionState) override; + bool submitEditorAboutToClose() override; private: Utils::ParameterAction *createParameterAction(Core::ActionContainer *ac, diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp index 819b9b73c69..c4c6f8583a9 100644 --- a/src/plugins/git/gitsubmiteditor.cpp +++ b/src/plugins/git/gitsubmiteditor.cpp @@ -58,7 +58,7 @@ public: GitSubmitFileModel(QObject *parent = 0) : SubmitFileModel(parent) { } - void updateSelections(SubmitFileModel *source) + void updateSelections(SubmitFileModel *source) override { QTC_ASSERT(source, return); GitSubmitFileModel *gitSource = static_cast<GitSubmitFileModel *>(source); @@ -100,7 +100,7 @@ public: void start() { - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); QString commitTemplate; bool success = client->getCommitData(m_workingDirectory, &commitTemplate, m_commitData, &m_errorMessage); @@ -175,6 +175,21 @@ void GitSubmitEditor::setCommitData(const CommitData &d) m_model = new GitSubmitFileModel(this); m_model->setRepositoryRoot(d.panelInfo.repository); + m_model->setFileStatusQualifier([](const QString &, const QVariant &extraData) + -> SubmitFileModel::FileStatusHint + { + const FileStates state = static_cast<FileStates>(extraData.toInt()); + if (state.testFlag(AddedFile) || state.testFlag(UntrackedFile)) + return SubmitFileModel::FileAdded; + if (state.testFlag(ModifiedFile)) + return SubmitFileModel::FileModified; + if (state.testFlag(DeletedFile)) + return SubmitFileModel::FileDeleted; + if (state.testFlag(RenamedFile)) + return SubmitFileModel::FileRenamed; + return SubmitFileModel::FileStatusUnknown; + } ); + if (!d.files.isEmpty()) { for (QList<CommitData::StateFilePair>::const_iterator it = d.files.constBegin(); it != d.files.constEnd(); ++it) { @@ -205,14 +220,23 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows) foreach (int row, rows) { const QString fileName = m_model->file(row); const FileStates state = static_cast<FileStates>(m_model->extraData(row).toInt()); - if (state & UnmergedFile) + if (state & UnmergedFile) { unmergedFiles.push_back(fileName); - else if (state & StagedFile) + } else if (state & StagedFile) { + if (state & (RenamedFile | CopiedFile)) { + const int arrow = fileName.indexOf(QLatin1String(" -> ")); + if (arrow != -1) { + stagedFiles.push_back(fileName.left(arrow)); + stagedFiles.push_back(fileName.mid(arrow + 4)); + continue; + } + } stagedFiles.push_back(fileName); - else if (state == UntrackedFile) + } else if (state == UntrackedFile) { Core::EditorManager::openEditor(m_workingDirectory + QLatin1Char('/') + fileName); - else + } else { unstagedFiles.push_back(fileName); + } } if (!unstagedFiles.empty() || !stagedFiles.empty()) emit diff(unstagedFiles, stagedFiles); @@ -244,7 +268,7 @@ void GitSubmitEditor::updateFileModel() QFuture<void> future = QtConcurrent::run(m_commitDataFetcher, &CommitDataFetcher::start); Core::ProgressManager::addTask(future, tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT); - GitPlugin::instance()->gitClient()->addFuture(future); + GitPlugin::instance()->client()->addFuture(future); } void GitSubmitEditor::commitDataRetrieved(bool success) diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h index a2f111a0516..2aba05a6217 100644 --- a/src/plugins/git/gitsubmiteditor.h +++ b/src/plugins/git/gitsubmiteditor.h @@ -65,8 +65,8 @@ signals: void show(const QString &workingDirectory, const QString &commit); protected: - QByteArray fileContents() const; - void updateFileModel(); + QByteArray fileContents() const override; + void updateFileModel() override; private slots: void slotDiffSelected(const QList<int> &rows); diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index f66991d3886..29750c35544 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -59,6 +59,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() : new GitSubmitHighlighter(descriptionEdit()); m_emailValidator = new QRegExpValidator(QRegExp(QLatin1String("[^@ ]+@[^@ ]+\\.[a-zA-Z]+")), this); + m_gitSubmitPanelUi.invalidEmailLabel->setToolTip(tr("Provide a valid email to commit.")); connect(m_gitSubmitPanelUi.authorLineEdit, &QLineEdit::textChanged, this, &GitSubmitEditorWidget::authorInformationChanged); @@ -104,7 +105,7 @@ void GitSubmitEditorWidget::initialize(CommitType commitType, connect(m_logChangeWidget, &LogChangeWidget::activated, this, &GitSubmitEditorWidget::show); logChangeLayout->addWidget(m_logChangeWidget); - insertTopWidget(logChangeGroupBox); + insertLeftWidget(logChangeGroupBox); m_gitSubmitPanelUi.editGroup->hide(); hideDescription(); } diff --git a/src/plugins/git/gitsubmiteditorwidget.h b/src/plugins/git/gitsubmiteditorwidget.h index ff632e718be..7b0ca0b6174 100644 --- a/src/plugins/git/gitsubmiteditorwidget.h +++ b/src/plugins/git/gitsubmiteditorwidget.h @@ -78,9 +78,9 @@ public: void refreshLog(const QString &repository); protected: - bool canSubmit() const; - QString cleanupDescription(const QString &) const; - QString commitName() const; + bool canSubmit() const override; + QString cleanupDescription(const QString &) const override; + QString commitName() const override; signals: void show(const QString &commit); diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp index f33409abf0a..412f62d2739 100644 --- a/src/plugins/git/gitversioncontrol.cpp +++ b/src/plugins/git/gitversioncontrol.cpp @@ -33,8 +33,10 @@ #include "gitutils.h" #include <vcsbase/vcsbaseconstants.h> +#include <vcsbase/vcscommand.h> #include <QFileInfo> +#include <QProcessEnvironment> namespace Git { namespace Internal { @@ -44,17 +46,16 @@ class GitTopicCache : public Core::IVersionControl::TopicCache public: GitTopicCache(GitClient *client) : m_client(client) - { - } + { } protected: - QString trackFile(const QString &repository) + QString trackFile(const QString &repository) override { const QString gitDir = m_client->findGitDirForRepository(repository); return gitDir.isEmpty() ? QString() : (gitDir + QLatin1String("/HEAD")); } - QString refreshTopic(const QString &repository) + QString refreshTopic(const QString &repository) override { return m_client->synchronousTopic(repository); } @@ -66,8 +67,7 @@ private: GitVersionControl::GitVersionControl(GitClient *client) : Core::IVersionControl(new GitTopicCache(client)), m_client(client) -{ -} +{ } QString GitVersionControl::displayName() const { @@ -81,9 +81,7 @@ Core::Id GitVersionControl::id() const bool GitVersionControl::isConfigured() const { - bool ok = false; - m_client->gitExecutable(&ok); - return ok; + return !m_client->vcsBinary().isEmpty(); } bool GitVersionControl::supportsOperation(Operation operation) const @@ -98,6 +96,7 @@ bool GitVersionControl::supportsOperation(Operation operation) const case CreateRepositoryOperation: case SnapshotOperations: case AnnotateOperation: + case InitialCheckoutOperation: return true; } return false; @@ -141,9 +140,22 @@ QString GitVersionControl::vcsTopic(const QString &directory) return topic; } +Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + QStringList args; + args << QLatin1String("clone") << QLatin1String("--progress") << extraArgs << url << localName; + + auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment()); + command->addJob(m_client->vcsBinary(), args, -1); + return command; +} + QStringList GitVersionControl::additionalToolsPath() const { - QStringList res = m_client->settings()->searchPathList(); + QStringList res = m_client->settings().searchPathList(); const QString binaryPath = m_client->gitBinDirectory().toString(); if (!binaryPath.isEmpty() && !res.contains(binaryPath)) res << binaryPath; @@ -166,7 +178,7 @@ bool GitVersionControl::managesFile(const QString &workingDirectory, const QStri bool GitVersionControl::vcsAnnotate(const QString &file, int line) { const QFileInfo fi(file); - m_client->blame(fi.absolutePath(), QStringList(), fi.fileName(), QString(), line); + m_client->annotate(fi.absolutePath(), fi.fileName(), QString(), line); return true; } @@ -180,10 +192,5 @@ void GitVersionControl::emitRepositoryChanged(const QString &r) emit repositoryChanged(r); } -void GitVersionControl::emitConfigurationChanged() -{ - emit configurationChanged(); -} - } // Internal } // Git diff --git a/src/plugins/git/gitversioncontrol.h b/src/plugins/git/gitversioncontrol.h index cc7faad3608..71dedb09ee3 100644 --- a/src/plugins/git/gitversioncontrol.h +++ b/src/plugins/git/gitversioncontrol.h @@ -45,28 +45,32 @@ class GitVersionControl : public Core::IVersionControl public: explicit GitVersionControl(GitClient *client); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &directory, QString *topLevel) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; + bool managesDirectory(const QString &directory, QString *topLevel) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - bool vcsOpen(const QString &fileName); - bool vcsAdd(const QString &fileName); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + bool vcsOpen(const QString &fileName) override; + bool vcsAdd(const QString &fileName) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; - bool vcsAnnotate(const QString &file, int line); - QString vcsTopic(const QString &directory); + bool vcsAnnotate(const QString &file, int line) override; + QString vcsTopic(const QString &directory) override; - QStringList additionalToolsPath() const; + Core::ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) override; + + QStringList additionalToolsPath() const override; void emitFilesChanged(const QStringList &); void emitRepositoryChanged(const QString &); - void emitConfigurationChanged(); private: GitClient *m_client; diff --git a/src/plugins/git/images/git.png b/src/plugins/git/images/git.png Binary files differdeleted file mode 100644 index 8895fe0165d..00000000000 --- a/src/plugins/git/images/git.png +++ /dev/null diff --git a/src/plugins/git/logchangedialog.cpp b/src/plugins/git/logchangedialog.cpp index 7e7a967765d..aa169375295 100644 --- a/src/plugins/git/logchangedialog.cpp +++ b/src/plugins/git/logchangedialog.cpp @@ -33,7 +33,7 @@ #include "gitclient.h" #include <vcsbase/vcsoutputwindow.h> -#include <vcsbase/vcsbaseplugin.h> +#include <vcsbase/vcscommand.h> #include <utils/qtcassert.h> @@ -84,7 +84,7 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, Log return true; if (!(flags & Silent)) { VcsOutputWindow::appendError( - GitPlugin::instance()->gitClient()->msgNoCommits(flags & IncludeRemotes)); + GitPlugin::instance()->client()->msgNoCommits(flags & IncludeRemotes)); } return false; } @@ -157,14 +157,14 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm m_model->removeRows(0, rowCount); // Retrieve log using a custom format "Sha1:Subject [(refs)]" - GitClient *client = GitPlugin::instance()->gitClient(); + GitClient *client = GitPlugin::instance()->client(); QStringList arguments; arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d"); arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit); if (!(flags & IncludeRemotes)) arguments << QLatin1String("--not") << QLatin1String("--remotes"); QString output; - if (!client->synchronousLog(repository, arguments, &output, 0, VcsBasePlugin::NoOutput)) + if (!client->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput)) return false; foreach (const QString &line, output.split(QLatin1Char('\n'))) { const int colonPos = line.indexOf(QLatin1Char(':')); @@ -216,8 +216,8 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) : m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard")); m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed")); m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft")); - GitClient *client = GitPlugin::instance()->gitClient(); - m_resetTypeComboBox->setCurrentIndex(client->settings()->intValue( + GitClient *client = GitPlugin::instance()->client(); + m_resetTypeComboBox->setCurrentIndex(client->settings().intValue( GitSettings::lastResetIndexKey)); popUpLayout->addWidget(m_resetTypeComboBox); popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored)); @@ -246,9 +246,9 @@ bool LogChangeDialog::runDialog(const QString &repository, if (QDialog::exec() == QDialog::Accepted) { if (m_resetTypeComboBox) { - GitClient *client = GitPlugin::instance()->gitClient(); - client->settings()->setValue(GitSettings::lastResetIndexKey, - m_resetTypeComboBox->currentIndex()); + GitClient *client = GitPlugin::instance()->client(); + client->settings().setValue(GitSettings::lastResetIndexKey, + m_resetTypeComboBox->currentIndex()); } return true; } diff --git a/src/plugins/git/logchangedialog.h b/src/plugins/git/logchangedialog.h index 52e48ee5e1c..5b2000f9797 100644 --- a/src/plugins/git/logchangedialog.h +++ b/src/plugins/git/logchangedialog.h @@ -78,7 +78,7 @@ private slots: void emitActivated(const QModelIndex &index); private: - void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); + void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) override; bool populateLog(const QString &repository, const QString &commit, LogFlags flags); const QStandardItem *currentItem(int column = 0) const; @@ -126,7 +126,7 @@ public: virtual bool hasIcon(int row) const = 0; void paint(QPainter *painter, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + const QModelIndex &index) const override; private: QIcon m_icon; diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index 2cbace20b25..c273ef629ae 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -56,7 +56,7 @@ public: } protected: - qint64 readData(char *data, qint64 maxlen) + qint64 readData(char *data, qint64 maxlen) override { qint64 res = QProcess::readData(data, maxlen); if (res > 0) @@ -64,7 +64,7 @@ protected: return res; } - qint64 writeData(const char *data, qint64 len) + qint64 writeData(const char *data, qint64 len) override { if (len > 0) VcsOutputWindow::append(QString::fromLocal8Bit(data, len)); @@ -78,7 +78,7 @@ MergeTool::MergeTool(QObject *parent) : m_mergeType(NormalMerge), m_localState(UnknownState), m_remoteState(UnknownState), - m_gitClient(GitPlugin::instance()->gitClient()), + m_client(GitPlugin::instance()->client()), m_merging(false) { } @@ -93,7 +93,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files) QStringList arguments; arguments << QLatin1String("mergetool") << QLatin1String("-y"); if (!files.isEmpty()) { - if (m_gitClient->gitVersion() < 0x010708) { + if (m_client->gitVersion() < 0x010708) { Core::AsynchronousMessageBox::warning(tr("Error"), tr("File input for the merge tool requires Git 1.7.8, or later.")); return false; @@ -102,7 +102,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files) } m_process = new MergeToolProcess(this); m_process->setWorkingDirectory(workingDirectory); - const Utils::FileName binary = m_gitClient->gitExecutable(); + const Utils::FileName binary = m_client->vcsBinary(); VcsOutputWindow::appendCommand(workingDirectory, binary, arguments); m_process->start(binary.toString(), arguments); if (m_process->waitForStarted()) { @@ -274,7 +274,7 @@ void MergeTool::done() VcsOutputWindow::appendError(tr("Merge tool process terminated with exit code %1") .arg(exitCode)); } - m_gitClient->continueCommandIfNeeded(workingDirectory, exitCode == 0); + m_client->continueCommandIfNeeded(workingDirectory, exitCode == 0); GitPlugin::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory); deleteLater(); } diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h index 49c3f0a37cd..ddc4589010f 100644 --- a/src/plugins/git/mergetool.h +++ b/src/plugins/git/mergetool.h @@ -87,7 +87,7 @@ private: QString m_localInfo; FileState m_remoteState; QString m_remoteInfo; - GitClient *m_gitClient; + GitClient *m_client; bool m_merging; }; diff --git a/src/plugins/git/remotedialog.cpp b/src/plugins/git/remotedialog.cpp index 50fed86a59f..c145a0fee0c 100644 --- a/src/plugins/git/remotedialog.cpp +++ b/src/plugins/git/remotedialog.cpp @@ -86,7 +86,7 @@ void RemoteAdditionDialog::clear() RemoteDialog::RemoteDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::RemoteDialog), - m_remoteModel(new RemoteModel(GitPlugin::instance()->gitClient(), this)), + m_remoteModel(new RemoteModel(GitPlugin::instance()->client(), this)), m_addDialog(0) { setModal(false); diff --git a/src/plugins/git/remotemodel.h b/src/plugins/git/remotemodel.h index a71a5af2768..dea5adb6006 100644 --- a/src/plugins/git/remotemodel.h +++ b/src/plugins/git/remotemodel.h @@ -57,13 +57,13 @@ public: bool updateUrl(const QString &name, const QString &newUrl); // QAbstractListModel - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role); - Qt::ItemFlags flags(const QModelIndex &index) const; + int role = Qt::DisplayRole) const override; + bool setData(const QModelIndex &index, const QVariant &value, int role) override; + Qt::ItemFlags flags(const QModelIndex &index) const override; int remoteCount() const; diff --git a/src/plugins/git/settingspage.cpp b/src/plugins/git/settingspage.cpp index 4c85840d3b5..8e127187093 100644 --- a/src/plugins/git/settingspage.cpp +++ b/src/plugins/git/settingspage.cpp @@ -33,6 +33,7 @@ #include "gitplugin.h" #include "gitclient.h" +#include <coreplugin/icore.h> #include <vcsbase/vcsbaseconstants.h> #include <utils/hostosinfo.h> #include <coreplugin/messagebox.h> @@ -41,11 +42,12 @@ #include <QDebug> #include <QTextStream> +using namespace VcsBase; + namespace Git { namespace Internal { -SettingsPageWidget::SettingsPageWidget(QWidget *parent) : - QWidget(parent) +SettingsPageWidget::SettingsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent) { m_ui.setupUi(this); if (Utils::HostOsInfo::isWindowsHost()) { @@ -66,7 +68,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : m_ui.repBrowserCommandPathChooser->setPromptDialogTitle(tr("Git Repository Browser Command")); } -GitSettings SettingsPageWidget::settings() const +VcsBaseClientSettings SettingsPageWidget::settings() const { GitSettings rc; rc.setValue(GitSettings::pathKey, m_ui.pathLineEdit->text()); @@ -77,10 +79,11 @@ GitSettings SettingsPageWidget::settings() const rc.setValue(GitSettings::winSetHomeEnvironmentKey, m_ui.winHomeCheckBox->isChecked()); rc.setValue(GitSettings::gitkOptionsKey, m_ui.gitkOptionsLineEdit->text().trimmed()); rc.setValue(GitSettings::repositoryBrowserCmd, m_ui.repBrowserCommandPathChooser->path().trimmed()); + return rc; } -void SettingsPageWidget::setSettings(const GitSettings &s) +void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s) { m_ui.pathLineEdit->setText(s.stringValue(GitSettings::pathKey)); m_ui.logCountSpinBox->setValue(s.intValue(GitSettings::logCountKey)); @@ -93,41 +96,28 @@ void SettingsPageWidget::setSettings(const GitSettings &s) } // -------- SettingsPage -SettingsPage::SettingsPage() : - m_widget(0) +SettingsPage::SettingsPage(Core::IVersionControl *control) : + VcsClientOptionsPage(control, GitPlugin::instance()->client()) { setId(VcsBase::Constants::VCS_ID_GIT); setDisplayName(tr("Git")); -} - -QWidget *SettingsPage::widget() -{ - if (!m_widget) { - m_widget = new SettingsPageWidget; - m_widget->setSettings(GitPlugin::instance()->settings()); - } - return m_widget; + setWidgetFactory([]() { return new SettingsPageWidget; }); } void SettingsPage::apply() { - const GitSettings newSettings = m_widget->settings(); - // Warn if git cannot be found in path if the widget is on top - if (m_widget->isVisible()) { + VcsClientOptionsPage::apply(); + + if (widget()->isVisible()) { + const VcsBaseClientSettings settings = widget()->settings(); + const GitSettings *rc = static_cast<const GitSettings *>(&settings); bool gitFoundOk; QString errorMessage; - newSettings.gitExecutable(&gitFoundOk, &errorMessage); + rc->gitExecutable(&gitFoundOk, &errorMessage); if (!gitFoundOk) Core::AsynchronousMessageBox::warning(tr("Git Settings"), errorMessage); } - - GitPlugin::instance()->setSettings(newSettings); -} - -void SettingsPage::finish() -{ - delete m_widget; } -} -} +} // namespace Internal +} // namespace Git diff --git a/src/plugins/git/settingspage.h b/src/plugins/git/settingspage.h index d161b814097..8ac00a8ac93 100644 --- a/src/plugins/git/settingspage.h +++ b/src/plugins/git/settingspage.h @@ -42,36 +42,32 @@ QT_BEGIN_NAMESPACE class QSettings; QT_END_NAMESPACE +namespace VcsBase { +class VcsBaseClientSettings; +} // namespace VcsBase + namespace Git { namespace Internal { -class GitSettings; - -class SettingsPageWidget : public QWidget { +class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: explicit SettingsPageWidget(QWidget *parent = 0); - GitSettings settings() const; - void setSettings(const GitSettings &); + VcsBase::VcsBaseClientSettings settings() const override; + void setSettings(const VcsBase::VcsBaseClientSettings &s) override; private: Ui::SettingsPage m_ui; }; -class SettingsPage : public VcsBase::VcsBaseOptionsPage +class SettingsPage : public VcsBase::VcsClientOptionsPage { Q_OBJECT public: - SettingsPage(); - - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<SettingsPageWidget> m_widget; + SettingsPage(Core::IVersionControl *control); + void apply() override; }; } // namespace Internal diff --git a/src/plugins/git/stashdialog.cpp b/src/plugins/git/stashdialog.cpp index a430ac252d9..0a3049c18ef 100644 --- a/src/plugins/git/stashdialog.cpp +++ b/src/plugins/git/stashdialog.cpp @@ -53,7 +53,7 @@ namespace Internal { static inline GitClient *gitClient() { - return GitPlugin::instance()->gitClient(); + return GitPlugin::instance()->client(); } static inline QList<QStandardItem*> stashModelRowItems(const Stash &s) diff --git a/src/plugins/glsleditor/glsleditor.qbs b/src/plugins/glsleditor/glsleditor.qbs index 6a809a6e5cb..1d5003de46d 100644 --- a/src/plugins/glsleditor/glsleditor.qbs +++ b/src/plugins/glsleditor/glsleditor.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "GLSLEditor" Depends { name: "Qt.widgets" } - Depends { name: "Aggregation" } Depends { name: "GLSL" } Depends { name: "CPlusPlus" } Depends { name: "Utils" } diff --git a/src/plugins/glsleditor/glsleditor_dependencies.pri b/src/plugins/glsleditor/glsleditor_dependencies.pri index a238c8c9db1..26a7703072c 100644 --- a/src/plugins/glsleditor/glsleditor_dependencies.pri +++ b/src/plugins/glsleditor/glsleditor_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = GLSLEditor QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ glsl \ utils \ diff --git a/src/plugins/help/centralwidget.cpp b/src/plugins/help/centralwidget.cpp index 9849a3f18ae..32941d7f44b 100644 --- a/src/plugins/help/centralwidget.cpp +++ b/src/plugins/help/centralwidget.cpp @@ -35,8 +35,6 @@ #include <utils/qtcassert.h> -#include <QHelpEngine> - using namespace Help::Internal; CentralWidget *gStaticCentralWidget = 0; @@ -53,21 +51,20 @@ CentralWidget::CentralWidget(const Core::Context &context, QWidget *parent) CentralWidget::~CentralWidget() { // TODO: this shouldn't be done here - QString zoomFactors; - QString currentPages; + QList<float> zoomFactors; + QStringList currentPages; for (int i = 0; i < viewerCount(); ++i) { const HelpViewer * const viewer = viewerAt(i); const QUrl &source = viewer->source(); if (source.isValid()) { - currentPages += source.toString() + QLatin1Char('|'); - zoomFactors += QString::number(viewer->scale()) + QLatin1Char('|'); + currentPages.append(source.toString()); + zoomFactors.append(viewer->scale()); } } - QHelpEngineCore *engine = &LocalHelpManager::helpEngine(); - engine->setCustomValue(QLatin1String("LastShownPages"), currentPages); - engine->setCustomValue(QLatin1String("LastShownPagesZoom"), zoomFactors); - engine->setCustomValue(QLatin1String("LastTabPage"), currentIndex()); + LocalHelpManager::setLastShownPages(currentPages); + LocalHelpManager::setLastShownPagesZoom(zoomFactors); + LocalHelpManager::setLastSelectedTab(currentIndex()); } CentralWidget *CentralWidget::instance() diff --git a/src/plugins/help/generalsettingspage.cpp b/src/plugins/help/generalsettingspage.cpp index e216b93da88..aff6c70415d 100644 --- a/src/plugins/help/generalsettingspage.cpp +++ b/src/plugins/help/generalsettingspage.cpp @@ -61,12 +61,6 @@ using namespace Help::Internal; GeneralSettingsPage::GeneralSettingsPage() : m_ui(0) { - m_font = qApp->font(); - // TODO remove QT_NO_WEBKIT -#if !defined(QT_NO_WEBKIT) - QWebSettings* webSettings = QWebSettings::globalSettings(); - m_font.setPointSize(webSettings->fontSize(QWebSettings::DefaultFontSize)); -#endif setId("A.General settings"); setDisplayName(tr("General")); setCategory(Help::Constants::HELP_CATEGORY); @@ -83,9 +77,7 @@ QWidget *GeneralSettingsPage::widget() m_ui->sizeComboBox->setEditable(false); m_ui->styleComboBox->setEditable(false); - QVariant fontSetting = LocalHelpManager::engineFontSettings(); - if (fontSetting.isValid()) - m_font = fontSetting.value<QFont>(); + m_font = LocalHelpManager::fallbackFont(); updateFontSize(); updateFontStyle(); @@ -94,12 +86,10 @@ QWidget *GeneralSettingsPage::widget() m_homePage = LocalHelpManager::homePage(); m_ui->homePageLineEdit->setText(m_homePage); - m_startOption = HelpManager::customValue(QLatin1String("StartOption"), - Help::Constants::ShowLastPages).toInt(); + m_startOption = LocalHelpManager::startOption(); m_ui->helpStartComboBox->setCurrentIndex(m_startOption); - m_contextOption = HelpManager::customValue(QLatin1String("ContextHelpOption"), - HelpManager::SideBySideIfPossible).toInt(); + m_contextOption = LocalHelpManager::contextHelpOption(); m_ui->contextHelpComboBox->setCurrentIndex(m_contextOption); connect(m_ui->currentPageButton, &QPushButton::clicked, @@ -119,8 +109,7 @@ QWidget *GeneralSettingsPage::widget() connect(m_ui->exportButton, &QPushButton::clicked, this, &GeneralSettingsPage::exportBookmarks); - m_returnOnClose = HelpManager::customValue(QLatin1String("ReturnOnClose"), - false).toBool(); + m_returnOnClose = LocalHelpManager::returnOnClose(); m_ui->m_returnOnClose->setChecked(m_returnOnClose); } return m_widget; @@ -158,7 +147,7 @@ void GeneralSettingsPage::apply() if (newFont != m_font) { m_font = newFont; - HelpManager::setCustomValue(Constants::FontKey, newFont); + LocalHelpManager::setFallbackFont(newFont); emit fontChanged(); } @@ -174,25 +163,19 @@ void GeneralSettingsPage::apply() const int startOption = m_ui->helpStartComboBox->currentIndex(); if (m_startOption != startOption) { m_startOption = startOption; - HelpManager::setCustomValue(QLatin1String("StartOption"), startOption); + LocalHelpManager::setStartOption((LocalHelpManager::StartOption)m_startOption); } const int helpOption = m_ui->contextHelpComboBox->currentIndex(); if (m_contextOption != helpOption) { m_contextOption = helpOption; - HelpManager::setCustomValue(QLatin1String("ContextHelpOption"), helpOption); - - QSettings *settings = ICore::settings(); - settings->beginGroup(QLatin1String(Help::Constants::ID_MODE_HELP)); - settings->setValue(QLatin1String("ContextHelpOption"), helpOption); - settings->endGroup(); + LocalHelpManager::setContextHelpOption((HelpManager::HelpViewerLocation)m_contextOption); } const bool close = m_ui->m_returnOnClose->isChecked(); if (m_returnOnClose != close) { m_returnOnClose = close; - HelpManager::setCustomValue(QLatin1String("ReturnOnClose"), close); - emit returnOnCloseChanged(); + LocalHelpManager::setReturnOnClose(m_returnOnClose); } } diff --git a/src/plugins/help/generalsettingspage.h b/src/plugins/help/generalsettingspage.h index 5cdcb9141e3..f592aff639d 100644 --- a/src/plugins/help/generalsettingspage.h +++ b/src/plugins/help/generalsettingspage.h @@ -54,7 +54,6 @@ public: signals: void fontChanged(); - void returnOnCloseChanged(); private slots: void setCurrentPage(); diff --git a/src/plugins/help/help.pro b/src/plugins/help/help.pro index ca6e1adb911..6ca91900c70 100644 --- a/src/plugins/help/help.pro +++ b/src/plugins/help/help.pro @@ -1,5 +1,6 @@ QT += help network printsupport sql -!isEmpty(QT.webkitwidgets.name): QT += webkitwidgets webkit +!isEmpty(QT.htmlviewwidgets.name): QT += htmlviewwidgets htmlview +else:!isEmpty(QT.webkitwidgets.name): QT += webkitwidgets webkit else: DEFINES += QT_NO_WEBKIT INCLUDEPATH += $$PWD diff --git a/src/plugins/help/helpconstants.h b/src/plugins/help/helpconstants.h index 6165a219520..6485bed43aa 100644 --- a/src/plugins/help/helpconstants.h +++ b/src/plugins/help/helpconstants.h @@ -37,18 +37,10 @@ namespace Help { namespace Constants { -enum { - ShowHomePage = 0, - ShowBlankPage = 1, - ShowLastPages = 2 -}; - static const QLatin1String ListSeparator("|"); -static const QLatin1String DefaultZoomFactor("0.0"); static const QLatin1String AboutBlank("about:blank"); static const QLatin1String WeAddedFilterKey("UnfilteredFilterInserted"); static const QLatin1String PreviousFilterNameKey("UnfilteredFilterName"); -static const QLatin1String FontKey("font"); const int P_MODE_HELP = 70; const char ID_MODE_HELP [] = "Help"; diff --git a/src/plugins/help/helpplugin.cpp b/src/plugins/help/helpplugin.cpp index baf14aa2675..2fb9705df2a 100644 --- a/src/plugins/help/helpplugin.cpp +++ b/src/plugins/help/helpplugin.cpp @@ -146,7 +146,7 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) m_openPagesManager = new OpenPagesManager(this); addAutoReleasedObject(m_docSettingsPage = new DocSettingsPage()); addAutoReleasedObject(m_filterSettingsPage = new FilterSettingsPage()); - addAutoReleasedObject(m_generalSettingsPage = new GeneralSettingsPage()); + addAutoReleasedObject(new GeneralSettingsPage()); addAutoReleasedObject(m_searchTaskHandler = new SearchTaskHandler); m_centralWidget = new CentralWidget(modecontext); @@ -155,10 +155,8 @@ bool HelpPlugin::initialize(const QStringList &arguments, QString *error) connect(m_centralWidget, &CentralWidget::closeButtonClicked, &OpenPagesManager::instance(), &OpenPagesManager::closeCurrentPage); - connect(m_generalSettingsPage, SIGNAL(fontChanged()), this, - SLOT(fontChanged())); - connect(m_generalSettingsPage, SIGNAL(returnOnCloseChanged()), m_centralWidget, - SLOT(updateCloseButton())); + connect(LocalHelpManager::instance(), &LocalHelpManager::returnOnCloseChanged, + m_centralWidget, &CentralWidget::updateCloseButton); connect(HelpManager::instance(), SIGNAL(helpRequested(QUrl,Core::HelpManager::HelpViewerLocation)), this, SLOT(handleHelpRequest(QUrl,Core::HelpManager::HelpViewerLocation))); connect(m_searchTaskHandler, SIGNAL(search(QUrl)), this, @@ -403,9 +401,9 @@ HelpViewer *HelpPlugin::createHelpViewer(qreal zoom) HelpViewer *viewer = factory(); // initialize font - QVariant fontSetting = LocalHelpManager::engineFontSettings(); - if (fontSetting.isValid()) - viewer->setViewerFont(fontSetting.value<QFont>()); + viewer->setViewerFont(LocalHelpManager::fallbackFont()); + connect(LocalHelpManager::instance(), &LocalHelpManager::fallbackFontChanged, + viewer, &HelpViewer::setViewerFont); // initialize zoom viewer->setScale(zoom); @@ -473,24 +471,11 @@ void HelpPlugin::updateSideBarSource(const QUrl &newUrl) } } -void HelpPlugin::fontChanged() -{ - if (!m_rightPaneSideBarWidget) - createRightPaneContextViewer(); - - QVariant fontSetting = LocalHelpManager::engineFontSettings(); - QFont font = fontSetting.isValid() ? fontSetting.value<QFont>() - : m_rightPaneSideBarWidget->currentViewer()->viewerFont(); - - m_rightPaneSideBarWidget->setViewerFont(font); - m_centralWidget->setViewerFont(font); -} - void HelpPlugin::setupHelpEngineIfNeeded() { LocalHelpManager::setEngineNeedsUpdate(); if (ModeManager::currentMode() == m_mode - || contextHelpOption() == HelpManager::ExternalHelpAlways) + || LocalHelpManager::contextHelpOption() == HelpManager::ExternalHelpAlways) LocalHelpManager::setupGuiHelpEngine(); } @@ -541,7 +526,7 @@ HelpViewer *HelpPlugin::viewerForHelpViewerLocation(HelpManager::HelpViewerLocat HelpViewer *HelpPlugin::viewerForContextHelp() { - return viewerForHelpViewerLocation(contextHelpOption()); + return viewerForHelpViewerLocation(LocalHelpManager::contextHelpOption()); } static QUrl findBestLink(const QMap<QString, QUrl> &links, QString *highlightId) @@ -684,16 +669,3 @@ void HelpPlugin::doSetupIfNeeded() LocalHelpManager::bookmarkManager().setupBookmarkModels(); } } - -HelpManager::HelpViewerLocation HelpPlugin::contextHelpOption() const -{ - QSettings *settings = ICore::settings(); - const QString key = QLatin1String(Help::Constants::ID_MODE_HELP) + QLatin1String("/ContextHelpOption"); - if (settings->contains(key)) - return HelpManager::HelpViewerLocation( - settings->value(key, HelpManager::SideBySideIfPossible).toInt()); - - const QHelpEngineCore &engine = LocalHelpManager::helpEngine(); - return HelpManager::HelpViewerLocation(engine.customValue(QLatin1String("ContextHelpOption"), - HelpManager::SideBySideIfPossible).toInt()); -} diff --git a/src/plugins/help/helpplugin.h b/src/plugins/help/helpplugin.h index 0540c5ad536..ed3325643cf 100644 --- a/src/plugins/help/helpplugin.h +++ b/src/plugins/help/helpplugin.h @@ -99,8 +99,6 @@ private slots: void updateSideBarSource(); void updateSideBarSource(const QUrl &newUrl); - void fontChanged(); - void setupHelpEngineIfNeeded(); void highlightSearchTermsInContextHelp(); @@ -120,7 +118,6 @@ private: HelpViewer *externalHelpViewer(); void doSetupIfNeeded(); - Core::HelpManager::HelpViewerLocation contextHelpOption() const; private: HelpMode *m_mode; @@ -129,7 +126,6 @@ private: DocSettingsPage *m_docSettingsPage; FilterSettingsPage *m_filterSettingsPage; - GeneralSettingsPage *m_generalSettingsPage; SearchTaskHandler *m_searchTaskHandler; bool m_setupNeeded; diff --git a/src/plugins/help/helpwidget.cpp b/src/plugins/help/helpwidget.cpp index 67146cf53c9..552736b291a 100644 --- a/src/plugins/help/helpwidget.cpp +++ b/src/plugins/help/helpwidget.cpp @@ -47,7 +47,6 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/icore.h> #include <coreplugin/findplaceholder.h> -#include <coreplugin/helpmanager.h> #include <coreplugin/minisplitter.h> #include <coreplugin/sidebar.h> #include <texteditor/texteditorconstants.h> @@ -478,15 +477,6 @@ void HelpWidget::removeViewerAt(int index) updateCloseButton(); } -void HelpWidget::setViewerFont(const QFont &font) -{ - for (int i = 0; i < m_viewerStack->count(); ++i) { - HelpViewer *viewer = qobject_cast<HelpViewer *>(m_viewerStack->widget(i)); - QTC_ASSERT(viewer, continue); - viewer->setFont(font); - } -} - int HelpWidget::viewerCount() const { return m_viewerStack->count(); @@ -580,8 +570,7 @@ void HelpWidget::helpModeButtonClicked() void HelpWidget::updateCloseButton() { if (m_style == ModeWidget) { - const bool closeOnReturn = Core::HelpManager::customValue(QLatin1String("ReturnOnClose"), - false).toBool(); + const bool closeOnReturn = LocalHelpManager::returnOnClose(); m_closeAction->setEnabled(closeOnReturn || m_viewerStack->count() > 1); } } diff --git a/src/plugins/help/helpwidget.h b/src/plugins/help/helpwidget.h index 2bee28b2f0e..6ff34ee42b1 100644 --- a/src/plugins/help/helpwidget.h +++ b/src/plugins/help/helpwidget.h @@ -74,8 +74,6 @@ public: void addViewer(HelpViewer *viewer); void removeViewerAt(int index); - void setViewerFont(const QFont &font); - // so central widget can save the state int viewerCount() const; HelpViewer *viewerAt(int index) const; diff --git a/src/plugins/help/localhelpmanager.cpp b/src/plugins/help/localhelpmanager.cpp index 96508149e75..606f5029aee 100644 --- a/src/plugins/help/localhelpmanager.cpp +++ b/src/plugins/help/localhelpmanager.cpp @@ -36,7 +36,7 @@ #include <app/app_version.h> #include <coreplugin/icore.h> -#include <coreplugin/helpmanager.h> +#include <utils/algorithm.h> #include <utils/qtcassert.h> #include <QMutexLocker> @@ -60,7 +60,27 @@ QStandardItemModel *LocalHelpManager::m_filterModel = 0; QString LocalHelpManager::m_currentFilter = QString(); int LocalHelpManager::m_currentFilterIndex = -1; -static char kHelpHomePageKey[] = "Help/HomePage"; +static const char kHelpHomePageKey[] = "Help/HomePage"; +static const char kFontKey[] = "Help/Font"; +static const char kStartOptionKey[] = "Help/StartOption"; +static const char kContextHelpOptionKey[] = "Help/ContextHelpOption"; +static const char kReturnOnCloseKey[] = "Help/ReturnOnClose"; +static const char kLastShownPagesKey[] = "Help/LastShownPages"; +static const char kLastShownPagesZoomKey[] = "Help/LastShownPagesZoom"; +static const char kLastSelectedTabKey[] = "Help/LastSelectedTab"; + +// TODO remove some time after Qt Creator 3.5 +static QVariant getSettingWithFallback(const QString &settingsKey, + const QString &fallbackSettingsKey, + const QVariant &fallbackSettingsValue) +{ + QSettings *settings = Core::ICore::settings(); + if (settings->contains(settingsKey)) + return settings->value(settingsKey); + // read from help engine for old settings + // TODO remove some time after Qt Creator 3.5 + return LocalHelpManager::helpEngine().customValue(fallbackSettingsKey, fallbackSettingsValue); +} LocalHelpManager::LocalHelpManager(QObject *parent) : QObject(parent) @@ -106,6 +126,129 @@ void LocalHelpManager::setHomePage(const QString &page) Core::ICore::settings()->setValue(QLatin1String(kHelpHomePageKey), page); } +QFont LocalHelpManager::fallbackFont() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kFontKey), + QLatin1String("font"), QVariant()); + return value.value<QFont>(); +} + +void LocalHelpManager::setFallbackFont(const QFont &font) +{ + Core::ICore::settings()->setValue(QLatin1String(kFontKey), font); + emit m_instance->fallbackFontChanged(font); +} + +LocalHelpManager::StartOption LocalHelpManager::startOption() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kStartOptionKey), + QLatin1String("StartOption"), ShowLastPages); + bool ok; + int optionValue = value.toInt(&ok); + if (!ok) + optionValue = ShowLastPages; + switch (optionValue) { + case ShowHomePage: + return ShowHomePage; + case ShowBlankPage: + return ShowBlankPage; + case ShowLastPages: + return ShowLastPages; + default: + break; + } + return ShowLastPages; +} + +void LocalHelpManager::setStartOption(LocalHelpManager::StartOption option) +{ + Core::ICore::settings()->setValue(QLatin1String(kStartOptionKey), option); +} + +Core::HelpManager::HelpViewerLocation LocalHelpManager::contextHelpOption() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kContextHelpOptionKey), + QLatin1String("ContextHelpOption"), + Core::HelpManager::SideBySideIfPossible); + bool ok; + int optionValue = value.toInt(&ok); + if (!ok) + optionValue = Core::HelpManager::SideBySideIfPossible; + switch (optionValue) { + case Core::HelpManager::SideBySideIfPossible: + return Core::HelpManager::SideBySideIfPossible; + case Core::HelpManager::SideBySideAlways: + return Core::HelpManager::SideBySideAlways; + case Core::HelpManager::HelpModeAlways: + return Core::HelpManager::HelpModeAlways; + case Core::HelpManager::ExternalHelpAlways: + return Core::HelpManager::ExternalHelpAlways; + default: + break; + } + return Core::HelpManager::SideBySideIfPossible; +} + +void LocalHelpManager::setContextHelpOption(Core::HelpManager::HelpViewerLocation location) +{ + Core::ICore::settings()->setValue(QLatin1String(kContextHelpOptionKey), location); +} + +bool LocalHelpManager::returnOnClose() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kReturnOnCloseKey), + QLatin1String("ReturnOnClose"), false); + return value.toBool(); +} + +void LocalHelpManager::setReturnOnClose(bool returnOnClose) +{ + Core::ICore::settings()->setValue(QLatin1String(kReturnOnCloseKey), returnOnClose); + emit m_instance->returnOnCloseChanged(); +} + +QStringList LocalHelpManager::lastShownPages() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kLastShownPagesKey), + QLatin1String("LastShownPages"), QVariant()); + return value.toString().split(Constants::ListSeparator, QString::SkipEmptyParts); +} + +void LocalHelpManager::setLastShownPages(const QStringList &pages) +{ + Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesKey), + pages.join(Constants::ListSeparator)); +} + +QList<float> LocalHelpManager::lastShownPagesZoom() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kLastShownPagesZoomKey), + QLatin1String("LastShownPagesZoom"), QVariant()); + const QStringList stringValues = value.toString().split(Constants::ListSeparator, + QString::SkipEmptyParts); + return Utils::transform(stringValues, [](const QString &str) { return str.toFloat(); }); +} + +void LocalHelpManager::setLastShownPagesZoom(const QList<float> &zoom) +{ + const QStringList stringValues = Utils::transform(zoom, + [](float z) { return QString::number(z); }); + Core::ICore::settings()->setValue(QLatin1String(kLastShownPagesZoomKey), + stringValues.join(Constants::ListSeparator)); +} + +int LocalHelpManager::lastSelectedTab() +{ + const QVariant value = getSettingWithFallback(QLatin1String(kLastSelectedTabKey), + QLatin1String("LastTabPage"), 0); + return value.toInt(); +} + +void LocalHelpManager::setLastSelectedTab(int index) +{ + Core::ICore::settings()->setValue(QLatin1String(kLastSelectedTabKey), index); +} + void LocalHelpManager::setupGuiHelpEngine() { if (m_needsCollectionFile) { @@ -146,11 +289,6 @@ BookmarkManager& LocalHelpManager::bookmarkManager() return *m_bookmarkManager; } -QVariant LocalHelpManager::engineFontSettings() -{ - return helpEngine().customValue(Constants::FontKey, QVariant()); -} - /*! * Checks if the string does contain a scheme, and if that scheme is a "sensible" scheme for * opening in a internal or external browser (qthelp, about, file, http, https). diff --git a/src/plugins/help/localhelpmanager.h b/src/plugins/help/localhelpmanager.h index 0fe6676057b..91f482691ce 100644 --- a/src/plugins/help/localhelpmanager.h +++ b/src/plugins/help/localhelpmanager.h @@ -31,6 +31,8 @@ #ifndef LOCALHELPMANAGER_H #define LOCALHELPMANAGER_H +#include <coreplugin/helpmanager.h> + #include <QMetaType> #include <QMutex> #include <QObject> @@ -55,6 +57,12 @@ public: QString mimeType; }; + enum StartOption { + ShowHomePage = 0, + ShowBlankPage = 1, + ShowLastPages = 2, + }; + LocalHelpManager(QObject *parent = 0); ~LocalHelpManager(); @@ -64,13 +72,33 @@ public: static QString homePage(); static void setHomePage(const QString &page); + static QFont fallbackFont(); + static void setFallbackFont(const QFont &font); + + static StartOption startOption(); + static void setStartOption(StartOption option); + + static Core::HelpManager::HelpViewerLocation contextHelpOption(); + static void setContextHelpOption(Core::HelpManager::HelpViewerLocation location); + + static bool returnOnClose(); + static void setReturnOnClose(bool returnOnClose); + + static QStringList lastShownPages(); + static void setLastShownPages(const QStringList &pages); + + static QList<float> lastShownPagesZoom(); + static void setLastShownPagesZoom(const QList<float> &zoom); + + static int lastSelectedTab(); + static void setLastSelectedTab(int index); + static void setupGuiHelpEngine(); static void setEngineNeedsUpdate(); static QHelpEngine& helpEngine(); static BookmarkManager& bookmarkManager(); - static QVariant engineFontSettings(); static bool isValidUrl(const QString &link); static QByteArray loadErrorMessage(const QUrl &url, const QString &errorString); @@ -84,6 +112,8 @@ public: signals: void filterIndexChanged(int index); + void fallbackFontChanged(const QFont &font); + void returnOnCloseChanged(); private: static bool m_guiNeedsSetup; diff --git a/src/plugins/help/macwebkithelpviewer.mm b/src/plugins/help/macwebkithelpviewer.mm index 096d0c34129..b5476d32f73 100644 --- a/src/plugins/help/macwebkithelpviewer.mm +++ b/src/plugins/help/macwebkithelpviewer.mm @@ -34,6 +34,7 @@ #include "openpagesmanager.h" #include <coreplugin/icore.h> +#include <utils/autoreleasepool.h> #include <utils/qtcassert.h> #include <QApplication> @@ -68,26 +69,7 @@ #import <WebKit/WebUIDelegate.h> #import <WebKit/WebView.h> -// #pragma mark -- AutoreleasePool - -class AutoreleasePool -{ -public: - AutoreleasePool(); - ~AutoreleasePool(); -private: - NSAutoreleasePool *pool; -}; - -AutoreleasePool::AutoreleasePool() -{ - pool = [[NSAutoreleasePool alloc] init]; -} - -AutoreleasePool::~AutoreleasePool() -{ - [pool release]; -} +using namespace Utils; // #pragma mark -- mac helpers diff --git a/src/plugins/help/openpagesmanager.cpp b/src/plugins/help/openpagesmanager.cpp index 4b994a13d1a..a1f0be1a926 100644 --- a/src/plugins/help/openpagesmanager.cpp +++ b/src/plugins/help/openpagesmanager.cpp @@ -46,7 +46,6 @@ #include <QHelpEngine> #include <coreplugin/coreconstants.h> -#include <coreplugin/helpmanager.h> #include <coreplugin/modemanager.h> using namespace Core; @@ -127,37 +126,34 @@ QStringList splitString(const QVariant &value) void OpenPagesManager::setupInitialPages() { const QHelpEngineCore &engine = LocalHelpManager::helpEngine(); - const int option = engine.customValue(QLatin1String("StartOption"), - Help::Constants::ShowLastPages).toInt(); + const LocalHelpManager::StartOption option = LocalHelpManager::startOption(); QString homePage = LocalHelpManager::homePage(); int initialPage = 0; switch (option) { - case Help::Constants::ShowHomePage: { + case LocalHelpManager::ShowHomePage: { m_model->addPage(homePage); } break; - case Help::Constants::ShowBlankPage: { + case LocalHelpManager::ShowBlankPage: { m_model->addPage(QUrl(Help::Constants::AboutBlank)); } break; - case Help::Constants::ShowLastPages: { - const QStringList &lastShownPageList = splitString(engine - .customValue(QLatin1String("LastShownPages"))); + case LocalHelpManager::ShowLastPages: { + const QStringList &lastShownPageList = LocalHelpManager::lastShownPages(); const int pageCount = lastShownPageList.count(); if (pageCount > 0) { - QStringList zoomFactors = splitString(engine - .customValue(QLatin1String("LastShownPagesZoom"))); + QList<float> zoomFactors = LocalHelpManager::lastShownPagesZoom(); while (zoomFactors.count() < pageCount) - zoomFactors.append(Help::Constants::DefaultZoomFactor); + zoomFactors.append(0.); - initialPage = engine.customValue(QLatin1String("LastTabPage"), 0).toInt(); + initialPage = LocalHelpManager::lastSelectedTab(); for (int curPage = 0; curPage < pageCount; ++curPage) { const QString &curFile = lastShownPageList.at(curPage); if (engine.findFile(curFile).isValid() || curFile == Help::Constants::AboutBlank) { - m_model->addPage(curFile, zoomFactors.at(curPage).toFloat()); + m_model->addPage(curFile, zoomFactors.at(curPage)); } else if (curPage <= initialPage && initialPage > 0) { --initialPage; } @@ -228,10 +224,9 @@ void OpenPagesManager::closeCurrentPage() if (indexes.isEmpty()) return; - const bool closeOnReturn = HelpManager::customValue(QLatin1String("ReturnOnClose"), - false).toBool(); + const bool returnOnClose = LocalHelpManager::returnOnClose(); - if (m_model->rowCount() == 1 && closeOnReturn) { + if (m_model->rowCount() == 1 && returnOnClose) { ModeManager::activateMode(Core::Constants::MODE_EDIT); } else { Q_ASSERT(indexes.count() == 1); diff --git a/src/plugins/imageviewer/imageviewer.qbs b/src/plugins/imageviewer/imageviewer.qbs index d47336d0fc3..98cf684a5d0 100644 --- a/src/plugins/imageviewer/imageviewer.qbs +++ b/src/plugins/imageviewer/imageviewer.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "ImageViewer" Depends { name: "Qt"; submodules: ["widgets", "svg"] } - Depends { name: "Aggregation" } Depends { name: "Utils" } Depends { name: "Core" } diff --git a/src/plugins/imageviewer/imageviewer_dependencies.pri b/src/plugins/imageviewer/imageviewer_dependencies.pri index bd6e9dc3585..991a3b81880 100644 --- a/src/plugins/imageviewer/imageviewer_dependencies.pri +++ b/src/plugins/imageviewer/imageviewer_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = ImageViewer QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ utils QTC_PLUGIN_DEPENDS += \ diff --git a/src/plugins/mercurial/clonewizard.cpp b/src/plugins/mercurial/clonewizard.cpp deleted file mode 100644 index bd4e4328190..00000000000 --- a/src/plugins/mercurial/clonewizard.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Brian McGillion -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizard.h" -#include "clonewizardpage.h" -#include "mercurialplugin.h" -#include "mercurialsettings.h" - -#include <coreplugin/iversioncontrol.h> -#include <vcsbase/vcscommand.h> -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> - -using namespace VcsBase; - -namespace Mercurial { -namespace Internal { -// -------------------------------------------------------------------- -// CloneWizard: -// -------------------------------------------------------------------- - -CloneWizard::CloneWizard(const Utils::FileName &path, QWidget *parent) : - BaseCheckoutWizard(path, parent) -{ - setTitle(tr("Cloning")); - setStartedStatus(tr("Cloning started...")); - - const Core::IVersionControl *vc = MercurialPlugin::instance()->versionControl(); - if (!vc->isConfigured()) { - auto configPage = new VcsConfigurationPage; - configPage->setVersionControl(vc); - addPage(configPage); - } - auto page = new CloneWizardPage; - page->setPath(path.toString()); - addPage(page); -} - -VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir) -{ - const CloneWizardPage *cwp = 0; - foreach (int pageId, pageIds()) { - if ((cwp = qobject_cast<const CloneWizardPage *>(page(pageId)))) - break; - } - - if (!cwp) - return 0; - - const MercurialSettings &settings = MercurialPlugin::settings(); - - QString path = cwp->path(); - QString directory = cwp->directory(); - - QStringList args; - args << QLatin1String("clone") << cwp->repository() << directory; - *checkoutDir = Utils::FileName::fromString(path + QLatin1Char('/') + directory); - auto command = new VcsCommand(settings.binaryPath(), path, - QProcessEnvironment::systemEnvironment()); - command->addJob(args, -1); - return command; -} - -} // namespace Internal -} // namespace Mercurial diff --git a/src/plugins/mercurial/clonewizard.h b/src/plugins/mercurial/clonewizard.h deleted file mode 100644 index 798f4e962c5..00000000000 --- a/src/plugins/mercurial/clonewizard.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Brian McGillion -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARD_H -#define CLONEWIZARD_H - -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> - -namespace Mercurial { -namespace Internal { - -class CloneWizard : public VcsBase::BaseCheckoutWizard -{ - Q_OBJECT - -public: - CloneWizard(const Utils::FileName &path, QWidget *parent = 0); - -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir); -}; - -} //namespace Internal -} //namespace Mercurial - -#endif // CLONEWIZARD_H diff --git a/src/plugins/mercurial/clonewizardpage.cpp b/src/plugins/mercurial/clonewizardpage.cpp deleted file mode 100644 index 34507a991c7..00000000000 --- a/src/plugins/mercurial/clonewizardpage.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Brian McGillion -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "clonewizardpage.h" - -namespace Mercurial { -namespace Internal { - -CloneWizardPage::CloneWizardPage(QWidget *parent) - : VcsBase::BaseCheckoutWizardPage(parent) -{ - setTitle(tr("Location")); - setSubTitle(tr("Specify repository URL, checkout directory and path.")); - setRepositoryLabel(tr("Clone URL:")); - setBranchSelectorVisible(false); -} - -QString CloneWizardPage::directoryFromRepository(const QString &repository) const -{ - // Mercurial repositories are generally of the form protocol://repositoryUrl/repository/ - // We are just looking for repository. - const QChar slash = QLatin1Char('/'); - QString repo = repository.trimmed(); - if (repo.endsWith(slash)) - repo.truncate(repo.size() - 1); - - // Take the basename or the repository url. - return repo.mid(repo.lastIndexOf(slash) + 1); -} - -} // namespace Internal -} // namespace Mercurial diff --git a/src/plugins/mercurial/clonewizardpage.h b/src/plugins/mercurial/clonewizardpage.h deleted file mode 100644 index 753b84674c4..00000000000 --- a/src/plugins/mercurial/clonewizardpage.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 Brian McGillion -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CLONEWIZARDPAGE_H -#define CLONEWIZARDPAGE_H - -#include <vcsbase/basecheckoutwizardpage.h> - -namespace Mercurial { -namespace Internal { - -class CloneWizardPage : public VcsBase::BaseCheckoutWizardPage -{ - Q_OBJECT -public: - CloneWizardPage(QWidget *parent = 0); - -protected: - QString directoryFromRepository(const QString &rrepository) const; -}; - -} //namespace Internal -} //namespace Mercurial - -#endif // CLONEWIZARDPAGE_H diff --git a/src/plugins/mercurial/images/hg.png b/src/plugins/mercurial/images/hg.png Binary files differdeleted file mode 100644 index 1daa4b82225..00000000000 --- a/src/plugins/mercurial/images/hg.png +++ /dev/null diff --git a/src/plugins/mercurial/mercurial.pro b/src/plugins/mercurial/mercurial.pro index a10510d5a1b..69f250bd2db 100644 --- a/src/plugins/mercurial/mercurial.pro +++ b/src/plugins/mercurial/mercurial.pro @@ -9,8 +9,6 @@ SOURCES += mercurialplugin.cpp \ srcdestdialog.cpp \ mercurialcommitwidget.cpp \ commiteditor.cpp \ - clonewizardpage.cpp \ - clonewizard.cpp \ mercurialsettings.cpp \ authenticationdialog.cpp HEADERS += mercurialplugin.h \ @@ -24,8 +22,6 @@ HEADERS += mercurialplugin.h \ srcdestdialog.h \ mercurialcommitwidget.h \ commiteditor.h \ - clonewizardpage.h \ - clonewizard.h \ mercurialsettings.h \ authenticationdialog.h FORMS += optionspage.ui \ @@ -33,4 +29,3 @@ FORMS += optionspage.ui \ srcdestdialog.ui \ mercurialcommitpanel.ui \ authenticationdialog.ui -RESOURCES += mercurial.qrc diff --git a/src/plugins/mercurial/mercurial.qbs b/src/plugins/mercurial/mercurial.qbs index 3198da245c5..a168c5a4310 100644 --- a/src/plugins/mercurial/mercurial.qbs +++ b/src/plugins/mercurial/mercurial.qbs @@ -16,14 +16,9 @@ QtcPlugin { "authenticationdialog.cpp", "authenticationdialog.h", "authenticationdialog.ui", - "clonewizard.cpp", - "clonewizard.h", - "clonewizardpage.cpp", - "clonewizardpage.h", "commiteditor.cpp", "commiteditor.h", "constants.h", - "mercurial.qrc", "mercurialclient.cpp", "mercurialclient.h", "mercurialcommitpanel.ui", diff --git a/src/plugins/mercurial/mercurial.qrc b/src/plugins/mercurial/mercurial.qrc deleted file mode 100644 index b001b7e60b5..00000000000 --- a/src/plugins/mercurial/mercurial.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/mercurial" > - <file>images/hg.png</file> - </qresource> -</RCC> diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp index 1f51137eedd..404c3770550 100644 --- a/src/plugins/mercurial/mercurialclient.cpp +++ b/src/plugins/mercurial/mercurialclient.cpp @@ -58,25 +58,19 @@ class MercurialDiffParameterWidget : public VcsBaseEditorParameterWidget { Q_OBJECT public: - MercurialDiffParameterWidget(MercurialSettings *settings, QWidget *parent = 0) : + MercurialDiffParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore Whitespace")), - settings->boolPointer(MercurialSettings::diffIgnoreWhiteSpaceKey)); + settings.boolPointer(MercurialSettings::diffIgnoreWhiteSpaceKey)); mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore Blank Lines")), - settings->boolPointer(MercurialSettings::diffIgnoreBlankLinesKey)); + settings.boolPointer(MercurialSettings::diffIgnoreBlankLinesKey)); } }; -MercurialClient::MercurialClient(MercurialSettings *settings) : - VcsBaseClient(settings) +MercurialClient::MercurialClient() : VcsBaseClient(new MercurialSettings) { - setDiffParameterWidgetCreator([=] { return new MercurialDiffParameterWidget(settings); }); -} - -MercurialSettings *MercurialClient::settings() const -{ - return dynamic_cast<MercurialSettings *>(VcsBaseClient::settings()); + setDiffParameterWidgetCreator([this] { return new MercurialDiffParameterWidget(settings()); }); } bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename) @@ -108,9 +102,9 @@ bool MercurialClient::synchronousClone(const QString &workingDir, Q_UNUSED(extraOptions); QDir workingDirectory(srcLocation); QByteArray output; - const unsigned flags = VcsBasePlugin::SshPasswordPrompt | - VcsBasePlugin::ShowStdOutInLogWindow | - VcsBasePlugin::ShowSuccessMessage; + const unsigned flags = VcsCommand::SshPasswordPrompt | + VcsCommand::ShowStdOut | + VcsCommand::ShowSuccessMessage; if (workingDirectory.exists()) { // Let's make first init @@ -157,17 +151,15 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString & args << vcsCommandString(PullCommand) << extraOptions << srcLocation; // Disable UNIX terminals to suppress SSH prompting const unsigned flags = - VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ShowSuccessMessage; - const FileName binary = settings()->binaryPath(); - const int timeoutSec = settings()->value(settings()->timeoutKey).toInt(); + VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ShowSuccessMessage; // cause mercurial doesn`t understand LANG QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(QLatin1String("LANGUAGE"), QLatin1String("C")); const SynchronousProcessResponse resp = VcsBasePlugin::runVcs( - workingDir, binary, args, timeoutSec * 1000, flags, 0, env); + workingDir, vcsBinary(), args, vcsTimeoutS(), flags, 0, env); const bool ok = resp.result == SynchronousProcessResponse::Finished; parsePullOutput(resp.stdOut.trimmed()); @@ -252,7 +244,7 @@ QString MercurialClient::shortDescriptionSync(const QString &workingDirectory, QByteArray outputData; if (!vcsFullySynchronousExec(workingDirectory, args, &outputData)) return revision; - description = SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(outputData)); + description = commandOutputFromLocal8Bit(outputData); if (description.endsWith(QLatin1Char('\n'))) description.truncate(description.size() - 1); return description; @@ -290,7 +282,8 @@ void MercurialClient::incoming(const QString &repositoryRoot, const QString &rep const QString title = tr("Hg incoming %1").arg(id); VcsBaseEditorWidget *editor = createVcsEditor(Constants::DIFFLOG_ID, title, repositoryRoot, - true, "incoming", id); + VcsBaseEditor::getCodec(repositoryRoot), + "incoming", id); VcsCommand *cmd = createCommand(repository, editor); enqueueJob(cmd, args); } @@ -303,7 +296,8 @@ void MercurialClient::outgoing(const QString &repositoryRoot) const QString title = tr("Hg outgoing %1"). arg(QDir::toNativeSeparators(repositoryRoot)); - VcsBaseEditorWidget *editor = createVcsEditor(Constants::DIFFLOG_ID, title, repositoryRoot, true, + VcsBaseEditorWidget *editor = createVcsEditor(Constants::DIFFLOG_ID, title, repositoryRoot, + VcsBaseEditor::getCodec(repositoryRoot), "outgoing", repositoryRoot); VcsCommand *cmd = createCommand(repositoryRoot, editor); diff --git a/src/plugins/mercurial/mercurialclient.h b/src/plugins/mercurial/mercurialclient.h index cae751fce8b..80c9067e1c6 100644 --- a/src/plugins/mercurial/mercurialclient.h +++ b/src/plugins/mercurial/mercurialclient.h @@ -42,9 +42,7 @@ class MercurialClient : public VcsBase::VcsBaseClient { Q_OBJECT public: - MercurialClient(MercurialSettings *settings); - - MercurialSettings *settings() const; + MercurialClient(); bool synchronousClone(const QString &workingDir, const QString &srcLocation, diff --git a/src/plugins/mercurial/mercurialcontrol.cpp b/src/plugins/mercurial/mercurialcontrol.cpp index 8482d703538..827355601ff 100644 --- a/src/plugins/mercurial/mercurialcontrol.cpp +++ b/src/plugins/mercurial/mercurialcontrol.cpp @@ -33,12 +33,14 @@ #include <vcsbase/vcsbaseclientsettings.h> #include <vcsbase/vcsbaseconstants.h> +#include <vcsbase/vcscommand.h> #include <coreplugin/vcsmanager.h> #include <utils/fileutils.h> #include <QFileInfo> +#include <QProcessEnvironment> #include <QVariant> #include <QStringList> #include <QDir> @@ -98,7 +100,7 @@ bool MercurialControl::managesFile(const QString &workingDirectory, const QStrin bool MercurialControl::isConfigured() const { - const Utils::FileName binary = mercurialClient->settings()->binaryPath(); + const Utils::FileName binary = mercurialClient->vcsBinary(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -114,6 +116,7 @@ bool MercurialControl::supportsOperation(Operation operation) const case Core::IVersionControl::MoveOperation: case Core::IVersionControl::CreateRepositoryOperation: case Core::IVersionControl::AnnotateOperation: + case Core::IVersionControl::InitialCheckoutOperation: break; case Core::IVersionControl::SnapshotOperations: supported = false; @@ -161,6 +164,19 @@ bool MercurialControl::vcsAnnotate(const QString &file, int line) return true; } +Core::ShellCommand *MercurialControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + QStringList args; + args << QLatin1String("clone") << extraArgs << url << localName; + auto command = new VcsBase::VcsCommand(baseDirectory.toString(), + mercurialClient->processEnvironment()); + command->addJob(mercurialClient->vcsBinary(), args, -1); + return command; +} + bool MercurialControl::sccManaged(const QString &filename) { const QFileInfo fi(filename); @@ -186,10 +202,5 @@ void MercurialControl::changed(const QVariant &v) } } -void MercurialControl::emitConfigurationChanged() -{ - emit configurationChanged(); -} - } // namespace Internal } // namespace Mercurial diff --git a/src/plugins/mercurial/mercurialcontrol.h b/src/plugins/mercurial/mercurialcontrol.h index e3db1a08938..30b33c8de3a 100644 --- a/src/plugins/mercurial/mercurialcontrol.h +++ b/src/plugins/mercurial/mercurialcontrol.h @@ -51,26 +51,31 @@ class MercurialControl: public Core::IVersionControl public: explicit MercurialControl(MercurialClient *mercurialClient); - QString displayName() const; - Core::Id id() const; - bool managesDirectory(const QString &filename, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - bool vcsOpen(const QString &fileName); - bool vcsAdd(const QString &filename); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); + QString displayName() const override; + Core::Id id() const override; + bool managesDirectory(const QString &filename, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + bool vcsOpen(const QString &fileName) override; + bool vcsAdd(const QString &filename) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; + bool vcsAnnotate(const QString &file, int line) override; + + Core::ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) override; + bool sccManaged(const QString &filename); - bool vcsAnnotate(const QString &file, int line); public slots: // To be connected to the HgTask's success signal to emit the repository/ // files changed signals according to the variant's type: // String -> repository, StringList -> files void changed(const QVariant&); - void emitConfigurationChanged(); private: MercurialClient *mercurialClient; diff --git a/src/plugins/mercurial/mercurialeditor.cpp b/src/plugins/mercurial/mercurialeditor.cpp index 6d8a2bc936e..11215e3a38b 100644 --- a/src/plugins/mercurial/mercurialeditor.cpp +++ b/src/plugins/mercurial/mercurialeditor.cpp @@ -35,7 +35,7 @@ #include "mercurialclient.h" #include <coreplugin/editormanager/editormanager.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QString> #include <QTextCursor> diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index a7dcb65b26e..e9e70c4768c 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -37,7 +37,6 @@ #include "revertdialog.h" #include "srcdestdialog.h" #include "commiteditor.h" -#include "clonewizard.h" #include "mercurialsettings.h" #include <coreplugin/actionmanager/actionmanager.h> @@ -136,12 +135,10 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * { Core::Context context(Constants::MERCURIAL_CONTEXT); - m_client = new MercurialClient(&mercurialSettings); + m_client = new MercurialClient; initializeVcs(new MercurialControl(m_client), context); - optionsPage = new OptionsPage(); - addAutoReleasedObject(optionsPage); - mercurialSettings.readSettings(core->settings()); + addAutoReleasedObject(new OptionsPage(versionControl())); connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant))); connect(m_client, SIGNAL(needUpdate()), this, SLOT(update())); @@ -155,16 +152,6 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters, []() { return new CommitEditor(&submitEditorParameters); })); - auto cloneWizardFactory = new BaseCheckoutWizardFactory; - cloneWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_MERCURIAL)); - cloneWizardFactory->setIcon(QIcon(QLatin1String(":/mercurial/images/hg.png"))); - cloneWizardFactory->setDescription(tr("Clones a Mercurial repository and tries to load the contained project.")); - cloneWizardFactory->setDisplayName(tr("Mercurial Clone")); - cloneWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CloneWizard(path, parent); - }); - addAutoReleasedObject(cloneWizardFactory); - const QString prefix = QLatin1String("hg"); m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -176,19 +163,6 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * return true; } -const MercurialSettings &MercurialPlugin::settings() -{ - return m_instance->mercurialSettings; -} - -void MercurialPlugin::setSettings(const MercurialSettings &settings) -{ - if (settings != m_instance->mercurialSettings) { - m_instance->mercurialSettings = settings; - static_cast<MercurialControl *>(m_instance->versionControl())->emitConfigurationChanged(); - } -} - void MercurialPlugin::createMenu(const Core::Context &context) { // Create menu item for Mercurial diff --git a/src/plugins/mercurial/mercurialplugin.h b/src/plugins/mercurial/mercurialplugin.h index c2c5c80f92d..e2386e78ad8 100644 --- a/src/plugins/mercurial/mercurialplugin.h +++ b/src/plugins/mercurial/mercurialplugin.h @@ -75,9 +75,6 @@ public: static MercurialPlugin *instance() { return m_instance; } static MercurialClient *client() { return m_instance->m_client; } - static const MercurialSettings &settings(); - static void setSettings(const MercurialSettings &settings); - private slots: // File menu action slots void addCurrentFile(); diff --git a/src/plugins/mercurial/optionspage.cpp b/src/plugins/mercurial/optionspage.cpp index ffeb84dd0f0..bd28db736cc 100644 --- a/src/plugins/mercurial/optionspage.cpp +++ b/src/plugins/mercurial/optionspage.cpp @@ -29,6 +29,8 @@ ****************************************************************************/ #include "optionspage.h" + +#include "mercurialclient.h" #include "mercurialsettings.h" #include "mercurialplugin.h" @@ -38,11 +40,12 @@ #include <QTextStream> +using namespace VcsBase; + namespace Mercurial { namespace Internal { -OptionsPageWidget::OptionsPageWidget(QWidget *parent) : - QWidget(parent) +OptionsPageWidget::OptionsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent) { m_ui.setupUi(this); m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand); @@ -50,9 +53,9 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) : m_ui.commandChooser->setPromptDialogTitle(tr("Mercurial Command")); } -MercurialSettings OptionsPageWidget::settings() const +VcsBaseClientSettings OptionsPageWidget::settings() const { - MercurialSettings s = MercurialPlugin::settings(); + MercurialSettings s; s.setValue(MercurialSettings::binaryPathKey, m_ui.commandChooser->rawPath()); s.setValue(MercurialSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed()); s.setValue(MercurialSettings::userEmailKey, m_ui.defaultEmailLineEdit->text().trimmed()); @@ -61,7 +64,7 @@ MercurialSettings OptionsPageWidget::settings() const return s; } -void OptionsPageWidget::setSettings(const MercurialSettings &s) +void OptionsPageWidget::setSettings(const VcsBaseClientSettings &s) { m_ui.commandChooser->setPath(s.stringValue(MercurialSettings::binaryPathKey)); m_ui.defaultUsernameLineEdit->setText(s.stringValue(MercurialSettings::userNameKey)); @@ -70,36 +73,12 @@ void OptionsPageWidget::setSettings(const MercurialSettings &s) m_ui.timeout->setValue(s.intValue(MercurialSettings::timeoutKey)); } -OptionsPage::OptionsPage() +OptionsPage::OptionsPage(Core::IVersionControl *control) : + VcsClientOptionsPage(control, MercurialPlugin::client()) { setId(VcsBase::Constants::VCS_ID_MERCURIAL); setDisplayName(tr("Mercurial")); -} - -QWidget *OptionsPage::widget() -{ - if (!optionsPageWidget) - optionsPageWidget = new OptionsPageWidget; - optionsPageWidget->setSettings(MercurialPlugin::settings()); - return optionsPageWidget; -} - -void OptionsPage::apply() -{ - if (!optionsPageWidget) - return; - const MercurialSettings newSettings = optionsPageWidget->settings(); - if (newSettings != MercurialPlugin::settings()) { - //assume success and emit signal that settings are changed; - MercurialPlugin::setSettings(newSettings); - newSettings.writeSettings(Core::ICore::settings()); - emit settingsChanged(); - } -} - -void OptionsPage::finish() -{ - delete optionsPageWidget; + setWidgetFactory([]() { return new OptionsPageWidget; }); } } // namespace Internal diff --git a/src/plugins/mercurial/optionspage.h b/src/plugins/mercurial/optionspage.h index 15e84096dde..5b7e0876bb1 100644 --- a/src/plugins/mercurial/optionspage.h +++ b/src/plugins/mercurial/optionspage.h @@ -38,42 +38,34 @@ #include <QWidget> #include <QPointer> +namespace VcsBase { +class VcsBaseClientSettings; +} // namespace VcsBase + namespace Mercurial { namespace Internal { -class MercurialSettings; - -class OptionsPageWidget : public QWidget +class OptionsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: explicit OptionsPageWidget(QWidget *parent = 0); - MercurialSettings settings() const; - void setSettings(const MercurialSettings &s); + VcsBase::VcsBaseClientSettings settings() const; + void setSettings(const VcsBase::VcsBaseClientSettings &s); private: Ui::OptionsPage m_ui; }; -class OptionsPage : public VcsBase::VcsBaseOptionsPage +class OptionsPage : public VcsBase::VcsClientOptionsPage { Q_OBJECT public: - OptionsPage(); - - QWidget *widget(); - void apply(); - void finish(); - -signals: - void settingsChanged(); - -private: - QPointer<OptionsPageWidget> optionsPageWidget; + OptionsPage(Core::IVersionControl *control); }; } // namespace Internal diff --git a/src/plugins/perforce/perforcechecker.cpp b/src/plugins/perforce/perforcechecker.cpp index 1e6518c9493..566f0b5dcea 100644 --- a/src/plugins/perforce/perforcechecker.cpp +++ b/src/plugins/perforce/perforcechecker.cpp @@ -29,6 +29,7 @@ ****************************************************************************/ #include "perforcechecker.h" +#include "perforceconstants.h" #include <utils/qtcassert.h> #include <utils/synchronousprocess.h> @@ -69,6 +70,11 @@ bool PerforceChecker::isRunning() const return m_process.state() == QProcess::Running; } +bool PerforceChecker::waitForFinished(int msec) +{ + return m_process.waitForFinished(msec); +} + void PerforceChecker::resetOverrideCursor() { if (m_isOverrideCursor) { @@ -77,7 +83,7 @@ void PerforceChecker::resetOverrideCursor() } } -void PerforceChecker::start(const QString &binary, +void PerforceChecker::start(const QString &binary, const QString &workingDirectory, const QStringList &basicArgs, int timeoutMS) { @@ -92,6 +98,10 @@ void PerforceChecker::start(const QString &binary, m_binary = binary; QStringList args = basicArgs; args << QLatin1String("client") << QLatin1String("-o"); + + if (!workingDirectory.isEmpty()) + m_process.setWorkingDirectory(workingDirectory); + m_process.start(m_binary, args); m_process.closeWriteChannel(); // Timeout handling @@ -112,7 +122,7 @@ void PerforceChecker::slotTimeOut() return; m_timedOut = true; Utils::SynchronousProcess::stopProcess(m_process); - emitFailed(tr("\"%1\" timed out after %2ms."). + emitFailed(tr("\"%1\" timed out after %2 ms."). arg(m_binary).arg(m_timeOutMS)); } diff --git a/src/plugins/perforce/perforcechecker.h b/src/plugins/perforce/perforcechecker.h index a43bd31702c..c4e262db579 100644 --- a/src/plugins/perforce/perforcechecker.h +++ b/src/plugins/perforce/perforcechecker.h @@ -50,11 +50,14 @@ public: public slots: void start(const QString &binary, + const QString &workingDirectory, const QStringList &basicArgs = QStringList(), int timeoutMS = -1); bool isRunning() const; + bool waitForFinished(int msec = -1); + bool useOverideCursor() const; void setUseOverideCursor(bool v); diff --git a/src/plugins/perforce/perforceeditor.cpp b/src/plugins/perforce/perforceeditor.cpp index ee4359a919c..50c449be8ba 100644 --- a/src/plugins/perforce/perforceeditor.cpp +++ b/src/plugins/perforce/perforceeditor.cpp @@ -36,7 +36,7 @@ #include <coreplugin/editormanager/editormanager.h> #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QFileInfo> diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index eb594dbfe9f..d303b6cd45c 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -865,29 +865,46 @@ bool PerforcePlugin::managesFile(const QString &workingDirectory, const QString bool PerforcePlugin::managesDirectoryFstat(const QString &directory) { - if (!m_settings.isValid()) - return false; // Cached? const ManagedDirectoryCache::const_iterator cit = m_managedDirectoryCache.constFind(directory); - if (cit != m_managedDirectoryCache.constEnd()) - return cit.value(); + if (cit != m_managedDirectoryCache.constEnd()) { + const DirectoryCacheEntry &entry = cit.value(); + setTopLevel(entry.m_topLevel); + return entry.m_isManaged; + } + if (!m_settings.isValid()) { + if (m_settings.topLevel().isEmpty() && m_settings.defaultEnv()) + getTopLevel(directory, true); + + if (!m_settings.isValid()) + return false; + } // Determine value and insert into cache bool managed = false; do { // Quick check: Must be at or below top level and not "../../other_path" const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory); - if (!relativeDirArgs.isEmpty() && relativeDirArgs.startsWith(QLatin1String(".."))) - break; + if (!relativeDirArgs.isEmpty() && relativeDirArgs.startsWith(QLatin1String(".."))) { + if (!m_settings.defaultEnv()) + break; + else + getTopLevel(directory, true); + } // Is it actually managed by perforce? QStringList args; args << QLatin1String("fstat") << QLatin1String("-m1") << perforceRelativeFileArguments(relativeDirArgs); const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args, RunFullySynchronous); + + if (Perforce::Constants::debug) + qDebug() << "Perforce result:\n" << result.stdOut << "\n---\n" << result.stdErr + << "\n---\n" << result.message; + managed = result.stdOut.contains(QLatin1String("depotFile")) || result.stdErr.contains(QLatin1String("... - no such file(s)")); } while (false); - m_managedDirectoryCache.insert(directory, managed); + m_managedDirectoryCache.insert(directory, DirectoryCacheEntry(managed, m_settings.topLevel())); return managed; } @@ -991,9 +1008,9 @@ static inline QString msgNotStarted(const QString &cmd) return PerforcePlugin::tr("Could not start perforce \"%1\". Please check your settings in the preferences.").arg(cmd); } -static inline QString msgTimeout(int timeOut) +static inline QString msgTimeout(int timeOutS) { - return PerforcePlugin::tr("Perforce did not respond within timeout limit (%1 ms).").arg(timeOut ); + return PerforcePlugin::tr("Perforce did not respond within timeout limit (%1 s).").arg(timeOutS); } static inline QString msgCrash() @@ -1018,8 +1035,8 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir, VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); // Run, connect stderr to the output window SynchronousProcess process; - const int timeOut = (flags & LongTimeOut) ? settings().longTimeOutMS() : settings().timeOutMS(); - process.setTimeout(timeOut); + const int timeOutS = (flags & LongTimeOut) ? settings().longTimeOutS() : settings().timeOutS(); + process.setTimeoutS(timeOutS); process.setCodec(outputCodec); if (flags & OverrideDiffEnvironment) process.setProcessEnvironment(overrideDiffEnvironmentVariable()); @@ -1116,11 +1133,11 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD QByteArray stdOut; QByteArray stdErr; - const int timeOut = (flags & LongTimeOut) ? settings().longTimeOutMS() : settings().timeOutMS(); - if (!SynchronousProcess::readDataFromProcess(process, timeOut, &stdOut, &stdErr, true)) { + const int timeOutS = (flags & LongTimeOut) ? settings().longTimeOutS() : settings().timeOutS(); + if (!SynchronousProcess::readDataFromProcess(process, timeOutS, &stdOut, &stdErr, true)) { SynchronousProcess::stopProcess(process); response.error = true; - response.message = msgTimeout(timeOut); + response.message = msgTimeout(timeOutS); return response; } if (process.exitStatus() != QProcess::NormalExit) { @@ -1529,14 +1546,17 @@ PerforceVersionControl *PerforcePlugin::perforceVersionControl() return static_cast<PerforceVersionControl *>(m_instance->versionControl()); } -void PerforcePlugin::slotTopLevelFound(const QString &t) +void PerforcePlugin::setTopLevel(const QString &topLevel) { - m_settings.setTopLevel(t); - const QString msg = tr("Perforce repository: %1"). - arg(QDir::toNativeSeparators(t)); + if (m_settings.topLevel() == topLevel) + return; + + m_settings.setTopLevel(topLevel); + + const QString msg = tr("Perforce repository: %1").arg(QDir::toNativeSeparators(topLevel)); VcsOutputWindow::appendSilently(msg); if (Perforce::Constants::debug) - qDebug() << "P4: " << t; + qDebug() << "P4: " << topLevel; } void PerforcePlugin::slotTopLevelFailed(const QString &errorMessage) @@ -1546,7 +1566,7 @@ void PerforcePlugin::slotTopLevelFailed(const QString &errorMessage) qDebug() << errorMessage; } -void PerforcePlugin::getTopLevel() +void PerforcePlugin::getTopLevel(const QString &workingDirectory, bool isSync) { // Run a new checker if (m_instance->m_settings.p4BinaryPath().isEmpty()) @@ -1554,9 +1574,14 @@ void PerforcePlugin::getTopLevel() auto checker = new PerforceChecker(m_instance); connect(checker, &PerforceChecker::failed, m_instance, &PerforcePlugin::slotTopLevelFailed); connect(checker, &PerforceChecker::failed, checker, &QObject::deleteLater); - connect(checker, &PerforceChecker::succeeded, m_instance, &PerforcePlugin::slotTopLevelFound); + connect(checker, &PerforceChecker::succeeded, m_instance, &PerforcePlugin::setTopLevel); connect(checker, &PerforceChecker::succeeded,checker, &QObject::deleteLater); - checker->start(settings().p4BinaryPath(), settings().commonP4Arguments(QString()), 30000); + + checker->start(settings().p4BinaryPath(), workingDirectory, + settings().commonP4Arguments(QString()), 30000); + + if (isSync) + checker->waitForFinished(); } #ifdef WITH_TESTS diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index f6ce849533d..251166a3231 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -136,7 +136,7 @@ private slots: void submitCurrentLog(); void printPendingChanges(); void slotSubmitDiff(const QStringList &files); - void slotTopLevelFound(const QString &); + void setTopLevel(const QString &); void slotTopLevelFailed(const QString &); #ifdef WITH_TESTS @@ -148,7 +148,19 @@ protected: private: - typedef QHash<QString, bool> ManagedDirectoryCache; + class DirectoryCacheEntry + { + public: + DirectoryCacheEntry(bool isManaged, const QString &topLevel): + m_isManaged(isManaged), m_topLevel(topLevel) + { + } + + bool m_isManaged; + QString m_topLevel; + }; + + typedef QHash<QString, DirectoryCacheEntry> ManagedDirectoryCache; Core::IEditor *showOutputInEditor(const QString &title, const QString &output, int editorType, const QString &source, @@ -197,7 +209,8 @@ private: bool isCommitEditorOpen() const; static QSharedPointer<Utils::TempFileSaver> createTemporaryArgumentFile(const QStringList &extraArgs, QString *errorString); - static void getTopLevel(); + + static void getTopLevel(const QString &workingDirectory = QString(), bool isSync = false); QString pendingChangesData(); void updateCheckout(const QString &workingDir = QString(), diff --git a/src/plugins/perforce/perforcesettings.h b/src/plugins/perforce/perforcesettings.h index a8cc9cd0ab4..db661608b0f 100644 --- a/src/plugins/perforce/perforcesettings.h +++ b/src/plugins/perforce/perforcesettings.h @@ -103,8 +103,8 @@ public: Settings settings() const; inline int timeOutS() const { return m_settings.timeOutS; } + inline int longTimeOutS() const { return m_settings.timeOutS * 10; } inline int timeOutMS() const { return m_settings.timeOutS * 1000; } - inline int longTimeOutMS() const { return m_settings.timeOutS * 10000; } inline int logCount() const { return m_settings.logCount; } diff --git a/src/plugins/perforce/perforceversioncontrol.cpp b/src/plugins/perforce/perforceversioncontrol.cpp index 8ae4b02c069..5e7cb29bb05 100644 --- a/src/plugins/perforce/perforceversioncontrol.cpp +++ b/src/plugins/perforce/perforceversioncontrol.cpp @@ -76,6 +76,7 @@ bool PerforceVersionControl::supportsOperation(Operation operation) const return supported; case CreateRepositoryOperation: case SnapshotOperations: + case InitialCheckoutOperation: break; } return false; diff --git a/src/plugins/perforce/perforceversioncontrol.h b/src/plugins/perforce/perforceversioncontrol.h index 70f9439fda1..5855fa91fc5 100644 --- a/src/plugins/perforce/perforceversioncontrol.h +++ b/src/plugins/perforce/perforceversioncontrol.h @@ -44,24 +44,24 @@ class PerforceVersionControl : public Core::IVersionControl public: explicit PerforceVersionControl(PerforcePlugin *plugin); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; + bool managesDirectory(const QString &directory, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - OpenSupportMode openSupportMode(const QString &fileName) const; - bool vcsOpen(const QString &fileName); - SettingsFlags settingsFlags() const; - bool vcsAdd(const QString &fileName); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); - bool vcsAnnotate(const QString &file, int line); - QString vcsOpenText() const; - QString vcsMakeWritableText() const; + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + OpenSupportMode openSupportMode(const QString &fileName) const override; + bool vcsOpen(const QString &fileName) override; + SettingsFlags settingsFlags() const override; + bool vcsAdd(const QString &fileName) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; + bool vcsAnnotate(const QString &file, int line) override; + QString vcsOpenText() const override; + QString vcsMakeWritableText() const override; void emitRepositoryChanged(const QString &s); void emitFilesChanged(const QStringList &l); diff --git a/src/plugins/perforce/settingspage.cpp b/src/plugins/perforce/settingspage.cpp index db0851a7a09..b37e7e72ba8 100644 --- a/src/plugins/perforce/settingspage.cpp +++ b/src/plugins/perforce/settingspage.cpp @@ -68,7 +68,7 @@ void SettingsPageWidget::slotTest() setStatusText(tr("Testing...")); const Settings s = settings(); - m_checker->start(s.p4BinaryPath, s.commonP4Arguments(), 10000); + m_checker->start(s.p4BinaryPath, QString(), s.commonP4Arguments(), 10000); } void SettingsPageWidget::testSucceeded(const QString &repo) diff --git a/src/plugins/projectexplorer/abiwidget.cpp b/src/plugins/projectexplorer/abiwidget.cpp index fa6dc06ac0f..c6745625e4a 100644 --- a/src/plugins/projectexplorer/abiwidget.cpp +++ b/src/plugins/projectexplorer/abiwidget.cpp @@ -82,6 +82,8 @@ AbiWidget::AbiWidget(QWidget *parent) : layout->setSpacing(2); d->m_abi = new QComboBox(this); + d->m_abi->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon); + d->m_abi->setMinimumContentsLength(4); layout->addWidget(d->m_abi); connect(d->m_abi, SIGNAL(currentIndexChanged(int)), this, SLOT(modeChanged())); diff --git a/src/plugins/projectexplorer/abstractprocessstep.cpp b/src/plugins/projectexplorer/abstractprocessstep.cpp index a3620fdadbd..29b5e901849 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.cpp +++ b/src/plugins/projectexplorer/abstractprocessstep.cpp @@ -391,7 +391,7 @@ void AbstractProcessStep::checkForCancel() } } -void AbstractProcessStep::taskAdded(const Task &task) +void AbstractProcessStep::taskAdded(const Task &task, int linkedOutputLines, int skipLines) { // Do not bother to report issues if we do not care about the results of // the buildstep anyway: @@ -443,7 +443,7 @@ void AbstractProcessStep::taskAdded(const Task &task) qWarning() << "Could not find absolute location of file " << filePath; } } - emit addTask(editable); + emit addTask(editable, linkedOutputLines, skipLines); } void AbstractProcessStep::outputAdded(const QString &string, BuildStep::OutputFormat format) diff --git a/src/plugins/projectexplorer/abstractprocessstep.h b/src/plugins/projectexplorer/abstractprocessstep.h index f8841a19c74..a79ebd2db5e 100644 --- a/src/plugins/projectexplorer/abstractprocessstep.h +++ b/src/plugins/projectexplorer/abstractprocessstep.h @@ -90,7 +90,7 @@ private slots: void cleanUp(); - void taskAdded(const Task &task); + void taskAdded(const Task &task, int linkedOutputLines = 0, int skipLines = 0); void outputAdded(const QString &string, BuildStep::OutputFormat format); diff --git a/src/plugins/projectexplorer/allprojectsfind.cpp b/src/plugins/projectexplorer/allprojectsfind.cpp index 5a01c34f028..c038137f7fd 100644 --- a/src/plugins/projectexplorer/allprojectsfind.cpp +++ b/src/plugins/projectexplorer/allprojectsfind.cpp @@ -114,7 +114,7 @@ Utils::FileIterator *AllProjectsFind::filesForProjects(const QStringList &nameFi encodings.insert(fileName, codec); } } - return new Utils::FileIterator(encodings.keys(), encodings.values()); + return new Utils::FileListIterator(encodings.keys(), encodings.values()); } QVariant AllProjectsFind::additionalParameters() const diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index a269723f362..b5bcf661630 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -517,6 +517,10 @@ bool AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode) delete m_runControlTabs[index].window; m_runControlTabs.removeAt(index); updateCloseActions(); + + if (m_runControlTabs.isEmpty()) + hide(); + return true; } diff --git a/src/plugins/projectexplorer/buildmanager.cpp b/src/plugins/projectexplorer/buildmanager.cpp index 9cff3972d93..4d8db4520f7 100644 --- a/src/plugins/projectexplorer/buildmanager.cpp +++ b/src/plugins/projectexplorer/buildmanager.cpp @@ -341,10 +341,10 @@ void BuildManager::showBuildResults() //toggleTaskWindow(); } -void BuildManager::addToTaskWindow(const Task &task) +void BuildManager::addToTaskWindow(const Task &task, int linkedOutputLines, int skipLines) { - d->m_outputWindow->registerPositionOf(task); // Distribute to all others + d->m_outputWindow->registerPositionOf(task, linkedOutputLines, skipLines); TaskHub::addTask(task); } @@ -496,8 +496,8 @@ bool BuildManager::buildQueueAppend(QList<BuildStep *> steps, QStringList names, int i = 0; for (; i < count; ++i) { BuildStep *bs = steps.at(i); - connect(bs, SIGNAL(addTask(ProjectExplorer::Task)), - m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task))); + connect(bs, SIGNAL(addTask(ProjectExplorer::Task, int, int)), + m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task, int, int))); connect(bs, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting)), m_instance, SLOT(addToOutputWindow(QString,ProjectExplorer::BuildStep::OutputFormat,ProjectExplorer::BuildStep::OutputNewlineSetting))); if (bs->enabled()) { @@ -657,8 +657,8 @@ void BuildManager::decrementActiveBuildSteps(BuildStep *bs) void BuildManager::disconnectOutput(BuildStep *bs) { - disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task)), - m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task))); + disconnect(bs, SIGNAL(addTask(ProjectExplorer::Task, int, int)), + m_instance, SLOT(addToTaskWindow(ProjectExplorer::Task, int, int))); disconnect(bs, SIGNAL(addOutput(QString, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting)), m_instance, SLOT(addToOutputWindow(QString, ProjectExplorer::BuildStep::OutputFormat, diff --git a/src/plugins/projectexplorer/buildmanager.h b/src/plugins/projectexplorer/buildmanager.h index 0752fa0f5e0..518185d72d5 100644 --- a/src/plugins/projectexplorer/buildmanager.h +++ b/src/plugins/projectexplorer/buildmanager.h @@ -86,7 +86,7 @@ signals: void tasksCleared(); private slots: - static void addToTaskWindow(const ProjectExplorer::Task &task); + static void addToTaskWindow(const ProjectExplorer::Task &task, int linkedOutputLines, int skipLines); static void addToOutputWindow(const QString &string, ProjectExplorer::BuildStep::OutputFormat, ProjectExplorer::BuildStep::OutputNewlineSetting = BuildStep::DoAppendNewline); diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp index 432896735f9..a303b4210e2 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.cpp +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.cpp @@ -186,8 +186,10 @@ void BuildSettingsWidget::updateAddButtonMenu() return; m_buildInfoList = factory->availableBuilds(m_target); foreach (BuildInfo *info, m_buildInfoList) { - QAction *action = m_addButtonMenu->addAction(info->typeName, this, SLOT(createConfiguration())); - action->setData(QVariant::fromValue(static_cast<void *>(info))); + QAction *action = m_addButtonMenu->addAction(info->typeName); + connect(action, &QAction::triggered, this, [this, info] { + createConfiguration(info); + }); } } } @@ -235,10 +237,8 @@ void BuildSettingsWidget::updateActiveConfiguration() updateBuildSettings(); } -void BuildSettingsWidget::createConfiguration() +void BuildSettingsWidget::createConfiguration(BuildInfo *info) { - QAction *action = qobject_cast<QAction *>(sender()); - BuildInfo *info = static_cast<BuildInfo *>(action->data().value<void*>()); QString originalDisplayName = info->displayName; if (info->displayName.isEmpty()) { diff --git a/src/plugins/projectexplorer/buildsettingspropertiespage.h b/src/plugins/projectexplorer/buildsettingspropertiespage.h index 0565dc43982..d77d56b60ca 100644 --- a/src/plugins/projectexplorer/buildsettingspropertiespage.h +++ b/src/plugins/projectexplorer/buildsettingspropertiespage.h @@ -64,7 +64,6 @@ private slots: void updateBuildSettings(); void currentIndexChanged(int index); - void createConfiguration(); void cloneConfiguration(); void deleteConfiguration(); void renameConfiguration(); @@ -73,6 +72,7 @@ private slots: void updateActiveConfiguration(); private: + void createConfiguration(BuildInfo *info); void cloneConfiguration(BuildConfiguration *toClone); void deleteConfiguration(BuildConfiguration *toDelete); QString uniqueName(const QString &name); diff --git a/src/plugins/projectexplorer/buildstep.h b/src/plugins/projectexplorer/buildstep.h index 867fc15f4d0..bfd0dfd6167 100644 --- a/src/plugins/projectexplorer/buildstep.h +++ b/src/plugins/projectexplorer/buildstep.h @@ -84,8 +84,13 @@ public: enum OutputNewlineSetting { DoAppendNewline, DontAppendNewline }; signals: - void addTask(const ProjectExplorer::Task &task); + /// Adds a \p task to the Issues pane. + /// Do note that for linking compile output with tasks, you should first emit the task + /// and then emit the output. \p linkedOutput lines will be linked. And the last \p skipLines will + /// be skipped. + void addTask(const ProjectExplorer::Task &task, int linkedOutputLines = 0, int skipLines = 0); + /// Adds \p string to the compile output view, formatted in \p format void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format, ProjectExplorer::BuildStep::OutputNewlineSetting newlineSetting = DoAppendNewline) const; diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp index 98b3536a149..72a5b009b8c 100644 --- a/src/plugins/projectexplorer/buildstepspage.cpp +++ b/src/plugins/projectexplorer/buildstepspage.cpp @@ -40,6 +40,7 @@ #include <utils/qtcassert.h> #include <utils/detailswidget.h> #include <utils/hostosinfo.h> +#include <utils/theme/theme.h> #include <QSignalMapper> @@ -74,7 +75,8 @@ ToolWidget::ToolWidget(QWidget *parent) m_disableButton->setAutoRaise(true); m_disableButton->setToolTip(BuildStepListWidget::tr("Disable")); m_disableButton->setFixedSize(buttonSize); - m_disableButton->setIcon(QIcon(QLatin1String(":/projectexplorer/images/disabledbuildstep.png"))); + m_disableButton->setIcon(QIcon(creatorTheme()->imageFile(Theme::BuildStepDisable, + QLatin1String(":/projectexplorer/images/disabledbuildstep.png")))); m_disableButton->setCheckable(true); hbox->addWidget(m_disableButton); layout->addWidget(m_firstWidget); @@ -90,21 +92,24 @@ ToolWidget::ToolWidget(QWidget *parent) m_upButton->setAutoRaise(true); m_upButton->setToolTip(BuildStepListWidget::tr("Move Up")); m_upButton->setFixedSize(buttonSize); - m_upButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowup.png"))); + m_upButton->setIcon(QIcon(creatorTheme()->imageFile(Theme::BuildStepMoveUp, + QLatin1String(":/core/images/darkarrowup.png")))); hbox->addWidget(m_upButton); m_downButton = new QToolButton(m_secondWidget); m_downButton->setAutoRaise(true); m_downButton->setToolTip(BuildStepListWidget::tr("Move Down")); m_downButton->setFixedSize(buttonSize); - m_downButton->setIcon(QIcon(QLatin1String(":/core/images/darkarrowdown.png"))); + m_downButton->setIcon(QIcon(creatorTheme()->imageFile(Theme::BuildStepMoveDown, + QLatin1String(":/core/images/darkarrowdown.png")))); hbox->addWidget(m_downButton); m_removeButton = new QToolButton(m_secondWidget); m_removeButton->setAutoRaise(true); m_removeButton->setToolTip(BuildStepListWidget::tr("Remove Item")); m_removeButton->setFixedSize(buttonSize); - m_removeButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_DARK_CLOSE))); + m_removeButton->setIcon(QIcon(creatorTheme()->imageFile(Theme::BuildStepRemove, + QLatin1String(Core::Constants::ICON_DARK_CLOSE)))); hbox->addWidget(m_removeButton); layout->addWidget(m_secondWidget); diff --git a/src/plugins/projectexplorer/compileoutputwindow.cpp b/src/plugins/projectexplorer/compileoutputwindow.cpp index c20f813a617..47a11cff514 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.cpp +++ b/src/plugins/projectexplorer/compileoutputwindow.cpp @@ -257,14 +257,21 @@ bool CompileOutputWindow::canNavigate() const return false; } -void CompileOutputWindow::registerPositionOf(const Task &task) +void CompileOutputWindow::registerPositionOf(const Task &task, int linkedOutputLines, int skipLines) { - int blocknumber = m_outputWindow->blockCount(); + if (linkedOutputLines <= 0) + return; + int blocknumber = m_outputWindow->document()->blockCount(); if (blocknumber > MAX_LINECOUNT) return; - m_taskPositions.insert(task.taskId, blocknumber); - m_outputWindow->addTask(task, blocknumber); + const int startLine = blocknumber - linkedOutputLines + 1 - skipLines; + const int endLine = blocknumber - skipLines; + + m_taskPositions.insert(task.taskId, qMakePair(startLine, endLine)); + + for (int i = startLine; i <= endLine; ++i) + m_outputWindow->addTask(task, i); } bool CompileOutputWindow::knowsPositionOf(const Task &task) @@ -274,10 +281,20 @@ bool CompileOutputWindow::knowsPositionOf(const Task &task) void CompileOutputWindow::showPositionOf(const Task &task) { - int position = m_taskPositions.value(task.taskId); - QTextCursor newCursor(m_outputWindow->document()->findBlockByNumber(position)); - newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + QPair<int, int> position = m_taskPositions.value(task.taskId); + QTextCursor newCursor(m_outputWindow->document()->findBlockByNumber(position.second)); + + // Move cursor to end of last line of interest: + newCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::MoveAnchor); m_outputWindow->setTextCursor(newCursor); + + // Move cursor and select lines: + newCursor.setPosition(m_outputWindow->document()->findBlockByNumber(position.first).position(), + QTextCursor::KeepAnchor); + m_outputWindow->setTextCursor(newCursor); + + // Center cursor now: + m_outputWindow->centerCursor(); } void CompileOutputWindow::flush() diff --git a/src/plugins/projectexplorer/compileoutputwindow.h b/src/plugins/projectexplorer/compileoutputwindow.h index 12e294d0ff0..1df5a05ca8e 100644 --- a/src/plugins/projectexplorer/compileoutputwindow.h +++ b/src/plugins/projectexplorer/compileoutputwindow.h @@ -35,6 +35,7 @@ #include <coreplugin/ioutputpane.h> #include <QHash> +#include <QPair> QT_BEGIN_NAMESPACE class QPlainTextEdit; @@ -79,7 +80,7 @@ public: void goToPrev(); bool canNavigate() const; - void registerPositionOf(const Task &task); + void registerPositionOf(const Task &task, int linkedOutputLines, int skipLines); bool knowsPositionOf(const Task &task); void showPositionOf(const Task &task); @@ -90,7 +91,7 @@ private slots: private: CompileOutputTextEdit *m_outputWindow; - QHash<unsigned int, int> m_taskPositions; + QHash<unsigned int, QPair<int, int>> m_taskPositions; ShowOutputTaskHandler * m_handler; QToolButton *m_cancelBuildButton; Utils::AnsiEscapeCodeHandler *m_escapeCodeHandler; diff --git a/src/plugins/projectexplorer/currentprojectfilter.cpp b/src/plugins/projectexplorer/currentprojectfilter.cpp index 12383cd4528..fa286a12f0b 100644 --- a/src/plugins/projectexplorer/currentprojectfilter.cpp +++ b/src/plugins/projectexplorer/currentprojectfilter.cpp @@ -31,7 +31,6 @@ #include "currentprojectfilter.h" #include "projecttree.h" #include "project.h" -#include "session.h" #include <utils/algorithm.h> @@ -52,8 +51,6 @@ CurrentProjectFilter::CurrentProjectFilter() connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, this, &CurrentProjectFilter::currentProjectChanged); - connect(SessionManager::instance(), &SessionManager::startupProjectChanged, - this, &CurrentProjectFilter::currentProjectChanged); } void CurrentProjectFilter::markFilesAsOutOfDate() @@ -78,9 +75,6 @@ void CurrentProjectFilter::prepareSearch(const QString &entry) void CurrentProjectFilter::currentProjectChanged() { Project *project = ProjectTree::currentProject(); - if (!project) - project = SessionManager::startupProject(); - if (project == m_project) return; if (m_project) diff --git a/src/plugins/projectexplorer/currentprojectfind.cpp b/src/plugins/projectexplorer/currentprojectfind.cpp index 876ab96d005..ac50a82d5cd 100644 --- a/src/plugins/projectexplorer/currentprojectfind.cpp +++ b/src/plugins/projectexplorer/currentprojectfind.cpp @@ -44,24 +44,10 @@ using namespace ProjectExplorer; using namespace ProjectExplorer::Internal; using namespace TextEditor; -static Project *currentProject() -{ - Project *p = ProjectTree::currentProject(); - if (p) - return p; - return SessionManager::startupProject(); -} - CurrentProjectFind::CurrentProjectFind() { connect(ProjectTree::instance(), &ProjectTree::currentProjectChanged, this, &CurrentProjectFind::handleProjectChanged); - connect(SessionManager::instance(), &SessionManager::startupProjectChanged, - this, &CurrentProjectFind::handleProjectChanged); - connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), - this, SLOT(handleProjectChanged())); - connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), - this, SLOT(handleProjectChanged())); } QString CurrentProjectFind::id() const @@ -76,12 +62,12 @@ QString CurrentProjectFind::displayName() const bool CurrentProjectFind::isEnabled() const { - return currentProject() != 0 && BaseFileFind::isEnabled(); + return ProjectTree::currentProject() != 0 && BaseFileFind::isEnabled(); } QVariant CurrentProjectFind::additionalParameters() const { - Project *project = currentProject(); + Project *project = ProjectTree::currentProject(); if (project && project->document()) return qVariantFromValue(project->projectFilePath().toString()); return QVariant(); @@ -91,18 +77,18 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters, const QVariant &additionalParameters) const { QTC_ASSERT(additionalParameters.isValid(), - return new Utils::FileIterator(QStringList(), QList<QTextCodec *>())); + return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>())); QString projectFile = additionalParameters.toString(); foreach (Project *project, SessionManager::projects()) { if (project->document() && projectFile == project->projectFilePath().toString()) return filesForProjects(nameFilters, QList<Project *>() << project); } - return new Utils::FileIterator(QStringList(), QList<QTextCodec *>()); + return new Utils::FileListIterator(QStringList(), QList<QTextCodec *>()); } QString CurrentProjectFind::label() const { - Project *p = currentProject(); + Project *p = ProjectTree::currentProject(); QTC_ASSERT(p, return QString()); return tr("Project \"%1\":").arg(p->displayName()); } diff --git a/src/plugins/projectexplorer/customparser.cpp b/src/plugins/projectexplorer/customparser.cpp index 9eee9ff2ca4..d7d3f913389 100644 --- a/src/plugins/projectexplorer/customparser.cpp +++ b/src/plugins/projectexplorer/customparser.cpp @@ -31,6 +31,7 @@ #include "customparser.h" #include "task.h" #include "projectexplorerconstants.h" +#include "buildmanager.h" #include <utils/qtcassert.h> @@ -143,7 +144,8 @@ bool CustomParser::parseLine(const QString &rawLine) const int lineNumber = m_errorRegExp.cap(m_lineNumberCap).toInt(); const QString message = m_errorRegExp.cap(m_messageCap); - emit addTask(Task(Task::Error, message, fileName, lineNumber, Constants::TASK_CATEGORY_COMPILE)); + Task task = Task(Task::Error, message, fileName, lineNumber, Constants::TASK_CATEGORY_COMPILE); + emit addTask(task, 1); return true; } diff --git a/src/plugins/projectexplorer/customwizard/customwizard.cpp b/src/plugins/projectexplorer/customwizard/customwizard.cpp index b14d74f3ab0..2336f57f923 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizard.cpp @@ -356,9 +356,9 @@ CustomWizard *CustomWizard::createWizard(const CustomProjectWizard::CustomWizard containing valid configuration files and parse them into wizards. */ -QList<CustomWizard*> CustomWizard::createWizards() +QList<Core::IWizardFactory *> CustomWizard::createWizards() { - QList<CustomWizard*> rc; + QList<Core::IWizardFactory *> rc; QString errorMessage; QString verboseLog; const QString templateDirName = Core::ICore::resourcePath() + @@ -407,7 +407,7 @@ QList<CustomWizard*> CustomWizard::createWizards() if (CustomWizard *w = createWizard(parameters)) rc.push_back(w); else - qWarning("Custom wizard factory function failed for %s", qPrintable(parameters->id)); + qWarning("Custom wizard factory function failed for %s", qPrintable(parameters->id.toString())); break; case CustomWizardParameters::ParseDisabled: if (CustomWizardPrivate::verbose) diff --git a/src/plugins/projectexplorer/customwizard/customwizard.h b/src/plugins/projectexplorer/customwizard/customwizard.h index f31b956b1fa..6974ad9be22 100644 --- a/src/plugins/projectexplorer/customwizard/customwizard.h +++ b/src/plugins/projectexplorer/customwizard/customwizard.h @@ -102,7 +102,7 @@ public: // Create all wizards. As other plugins might register factories for derived // classes, call it in extensionsInitialized(). - static QList<CustomWizard*> createWizards(); + static QList<IWizardFactory *> createWizards(); static void setVerbose(int); static int verbose(); diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index 1f23a903f00..8d8720c6ddc 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -255,7 +255,7 @@ QWidget *CustomWizardFieldPage::registerPathChooser(const QString &fieldName, pathChooser->setExpectedKind(PathChooser::Command); else if (expectedKind == QLatin1String("any")) pathChooser->setExpectedKind(PathChooser::Any); - pathChooser->setHistoryCompleter(QString::fromLatin1("PE.Custom.") + m_parameters->id + QLatin1Char('.') + field.name); + pathChooser->setHistoryCompleter(QString::fromLatin1("PE.Custom.") + m_parameters->id.toString() + QLatin1Char('.') + field.name); registerField(fieldName, pathChooser, "path", SIGNAL(changed(QString))); // Connect to completeChanged() for derived classes that reimplement isComplete() diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp index 80ce3a40ba8..a9a93bf8686 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.cpp @@ -45,7 +45,7 @@ #include <QFile> #include <QFileInfo> #include <QIcon> -#include <QScriptEngine> +#include <QJSEngine> #include <QTemporaryFile> #include <QTime> #include <QXmlStreamAttribute> @@ -177,7 +177,7 @@ bool CustomWizardValidationRule::validateRules(const QList<CustomWizardValidatio errorMessage->clear(); if (rules.isEmpty()) return true; - QScriptEngine engine; + QJSEngine engine; foreach (const CustomWizardValidationRule &rule, rules) if (!rule.validate(engine, replacementMap)) { *errorMessage = rule.message; @@ -187,7 +187,7 @@ bool CustomWizardValidationRule::validateRules(const QList<CustomWizardValidatio return true; } -bool CustomWizardValidationRule::validate(QScriptEngine &engine, const QMap<QString, QString> &replacementMap) const +bool CustomWizardValidationRule::validate(QJSEngine &engine, const QMap<QString, QString> &replacementMap) const { // Apply parameters and evaluate using JavaScript QString cond = condition; @@ -451,12 +451,8 @@ static ParseState nextClosingState(ParseState in, const QStringRef &name) static inline IWizardFactory::WizardKind kindAttribute(const QXmlStreamReader &r) { const QStringRef value = r.attributes().value(QLatin1String(kindAttributeC)); - if (!value.isEmpty()) { - if (value == QLatin1String("file")) - return IWizardFactory::FileWizard; - if (value == QLatin1String("class")) - return IWizardFactory::ClassWizard; - } + if (value == QLatin1String("file") || value == QLatin1String("class")) + return IWizardFactory::FileWizard; return IWizardFactory::ProjectWizard; } @@ -583,7 +579,11 @@ CustomWizardParameters::parse(QIODevice &device, const QString &configFileFullPa case ParseWithinWizard: if (!booleanAttributeValue(reader, wizardEnabledAttributeC, true)) return ParseDisabled; - id = attributeValue(reader, idAttributeC); + { + const QString idString = attributeValue(reader, idAttributeC); + if (!idString.isEmpty()) + id = Core::Id::fromString(idString); + } category = attributeValue(reader, categoryAttributeC); kind = kindAttribute(reader); requiredFeatures = readRequiredFeatures(reader); diff --git a/src/plugins/projectexplorer/customwizard/customwizardparameters.h b/src/plugins/projectexplorer/customwizard/customwizardparameters.h index 38b9bc6b45f..329b038cd98 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardparameters.h +++ b/src/plugins/projectexplorer/customwizard/customwizardparameters.h @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE class QIODevice; class QDebug; class QTemporaryFile; -class QScriptEngine; +class QJSEngine; QT_END_NAMESPACE namespace ProjectExplorer { @@ -82,7 +82,7 @@ public: static bool validateRules(const QList<CustomWizardValidationRule> &rules, const QMap<QString, QString> &replacementMap, QString *errorMessage); - bool validate(QScriptEngine &, const QMap<QString, QString> &replacementMap) const; + bool validate(QJSEngine &, const QMap<QString, QString> &replacementMap) const; QString condition; QString message; }; @@ -114,7 +114,7 @@ public: QString *errorMessage); ParseResult parse(const QString &configFileFullPath, QString *errorMessage); - QString id; + Core::Id id; QString directory; QString klass; QList<CustomWizardFile> files; diff --git a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp index fe793327fa8..e2493707d53 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.cpp @@ -40,9 +40,7 @@ #include <QStack> #include <QRegExp> #include <QDebug> - -#include <QScriptEngine> -#include <QScriptValue> +#include <QJSEngine> namespace ProjectExplorer { namespace Internal { @@ -94,7 +92,7 @@ private: mutable QRegExp m_endifPattern; QStack<PreprocessStackEntry> m_sectionStack; - QScriptEngine m_scriptEngine; + QJSEngine m_scriptEngine; }; PreprocessContext::PreprocessContext() : @@ -137,16 +135,15 @@ PreprocessorSection PreprocessContext::preprocessorLine(const QString &in, return OtherSection; } -// Evaluate an expression within an 'if'/'elsif' to a bool via QScript -bool evaluateBooleanJavaScriptExpression(QScriptEngine &engine, const QString &expression, bool *result, QString *errorMessage) +// Evaluate an expression within an 'if'/'elsif' to a bool via QJSEngine +bool evaluateBooleanJavaScriptExpression(QJSEngine &engine, const QString &expression, bool *result, QString *errorMessage) { errorMessage->clear(); *result = false; - engine.clearExceptions(); - const QScriptValue value = engine.evaluate(expression); - if (engine.hasUncaughtException()) { + const QJSValue value = engine.evaluate(expression); + if (value.isError()) { *errorMessage = QString::fromLatin1("Error in \"%1\": %2"). - arg(expression, engine.uncaughtException().toString()); + arg(expression, value.toString()); return false; } // Try to convert to bool, be that an int or whatever. diff --git a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h index 4922e5331ef..66af67609fc 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h +++ b/src/plugins/projectexplorer/customwizard/customwizardpreprocessor.h @@ -33,14 +33,14 @@ #include <QString> -QT_FORWARD_DECLARE_CLASS(QScriptEngine) +QT_FORWARD_DECLARE_CLASS(QJSEngine) namespace ProjectExplorer { namespace Internal { bool customWizardPreprocess(const QString &in, QString *out, QString *errorMessage); /* Helper to evaluate an expression. */ -bool evaluateBooleanJavaScriptExpression(QScriptEngine &engine, const QString &expression, bool *result, QString *errorMessage); +bool evaluateBooleanJavaScriptExpression(QJSEngine &engine, const QString &expression, bool *result, QString *errorMessage); } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/devicesupport/idevicewidget.cpp b/src/plugins/projectexplorer/devicesupport/idevicewidget.cpp deleted file mode 100644 index 1ae3998342e..00000000000 --- a/src/plugins/projectexplorer/devicesupport/idevicewidget.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#include <idevicewidget.h> - -/*! - \class ProjectExplorer::IDeviceWidget - \brief The IDeviceWidget class provides an interface for the widget - configuring an IDevice. - - A class implementing this interface will display a widget on the - \gui Devices options page. It enables the user to configure a particular - device. -*/ - -/*! - \fn virtual void updateDeviceFromUi() - - Ensures that all changes in the UI are propagated to the device object. - - If the device is always updated right when the change happens, the - implementation of this function can be empty. However, you cannot generally - rely on the QLineEdit::editingFinished() signal being emitted on time if - some button in the dialog is clicked (such as \gui Apply). So if you have - any handlers for line edit changes, they should probably be called here. -*/ diff --git a/src/plugins/qmldesigner/designercore/model/objectpropertybinding.cpp b/src/plugins/projectexplorer/expanddata.cpp index 23a19b463f8..e39d2ab2a07 100644 --- a/src/plugins/qmldesigner/designercore/model/objectpropertybinding.cpp +++ b/src/plugins/projectexplorer/expanddata.cpp @@ -28,29 +28,26 @@ ** ****************************************************************************/ -#include "objectpropertybinding.h" +#include "expanddata.h" -namespace QmlDesigner { +using namespace ProjectExplorer; +using namespace ProjectExplorer::Internal; -ObjectPropertyBinding::ObjectPropertyBinding() -{ -} +ExpandData::ExpandData(const QString &path_, const QString &displayName_) + : path(path_), displayName(displayName_) +{} -ObjectPropertyBinding::ObjectPropertyBinding(const ModelNode &node) - : m_node(node) +bool ExpandData::operator==(const ExpandData &other) const { - + return path == other.path && displayName == other.displayName; } -ModelNode ObjectPropertyBinding::modelNode() const +QStringList ExpandData::toStringList() const { - return m_node; + return { path, displayName }; } -bool ObjectPropertyBinding::isValid() const +int ProjectExplorer::Internal::qHash(const ExpandData &data) { - return m_node.isValid(); + return qHash(data.path) ^ qHash(data.displayName); } - - -} // namespace QmlDesigner diff --git a/src/plugins/git/clonewizard.h b/src/plugins/projectexplorer/expanddata.h index b9d6f871833..b675b03c54a 100644 --- a/src/plugins/git/clonewizard.h +++ b/src/plugins/projectexplorer/expanddata.h @@ -28,27 +28,31 @@ ** ****************************************************************************/ -#ifndef CLONEWIZARD_H -#define CLONEWIZARD_H +#ifndef EXPANDDATA_H +#define EXPANDDATA_H -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> +#include <QString> +#include <QHash> +#include <QDebug> -namespace Git { +namespace ProjectExplorer { namespace Internal { -class CloneWizard : public VcsBase::BaseCheckoutWizard +class ExpandData { - Q_OBJECT - public: - CloneWizard(const Utils::FileName &path, QWidget *parent = 0); + ExpandData() = default; + ExpandData(const QString &path_, const QString &displayName_); + bool operator==(const ExpandData &other) const; + QStringList toStringList() const; -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir); + QString path; + QString displayName; }; +int qHash(const ExpandData &data); + } // namespace Internal -} // namespace Git +} // namespace ProjectExplorer -#endif // CLONEWIZARD_H +#endif // EXPANDDATA_H diff --git a/src/plugins/projectexplorer/gccparser.cpp b/src/plugins/projectexplorer/gccparser.cpp index 61dadc78330..edd09bb1595 100644 --- a/src/plugins/projectexplorer/gccparser.cpp +++ b/src/plugins/projectexplorer/gccparser.cpp @@ -32,6 +32,7 @@ #include "ldparser.h" #include "task.h" #include "projectexplorerconstants.h" +#include "buildmanager.h" #include <texteditor/fontsettings.h> #include <texteditor/texteditorsettings.h> @@ -152,6 +153,7 @@ void GccParser::newTask(const Task &task) { doFlush(); m_currentTask = task; + m_lines = 1; } void GccParser::doFlush() @@ -160,7 +162,8 @@ void GccParser::doFlush() return; Task t = m_currentTask; m_currentTask.clear(); - emit addTask(t); + emit addTask(t, m_lines, 1); + m_lines = 0; } void GccParser::amendDescription(const QString &desc, bool monospaced) @@ -178,6 +181,7 @@ void GccParser::amendDescription(const QString &desc, bool monospaced) fr.format.setFontStyleHint(QFont::Monospace); m_currentTask.formats.append(fr); } + ++m_lines; return; } diff --git a/src/plugins/projectexplorer/gccparser.h b/src/plugins/projectexplorer/gccparser.h index c4fe2e21ff7..cf478bfab10 100644 --- a/src/plugins/projectexplorer/gccparser.h +++ b/src/plugins/projectexplorer/gccparser.h @@ -61,6 +61,7 @@ private: QRegularExpression m_regExpGccNames; Task m_currentTask; + int m_lines = 0; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/gnumakeparser.cpp b/src/plugins/projectexplorer/gnumakeparser.cpp index 9416cd46eda..c6adc9fb7f1 100644 --- a/src/plugins/projectexplorer/gnumakeparser.cpp +++ b/src/plugins/projectexplorer/gnumakeparser.cpp @@ -128,7 +128,7 @@ void GnuMakeParser::stdError(const QString &line) taskAdded(Task(res.type, res.description, Utils::FileName::fromUserInput(match.captured(1)) /* filename */, match.captured(4).toInt(), /* line */ - Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM))); + Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)), 1, 0); } return; } @@ -138,9 +138,10 @@ void GnuMakeParser::stdError(const QString &line) if (res.isFatal) ++m_fatalErrorCount; if (!m_suppressIssues) { - taskAdded(Task(res.type, res.description, - Utils::FileName() /* filename */, -1, /* line */ - Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM))); + Task task = Task(res.type, res.description, + Utils::FileName() /* filename */, -1, /* line */ + Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)); + taskAdded(task, 1, 0); } return; } @@ -160,7 +161,7 @@ void GnuMakeParser::removeDirectory(const QString &dir) m_directories.removeOne(dir); } -void GnuMakeParser::taskAdded(const Task &task) +void GnuMakeParser::taskAdded(const Task &task, int linkedLines, int skippedLines) { Task editable(task); @@ -187,7 +188,7 @@ void GnuMakeParser::taskAdded(const Task &task) // identify the file! } - IOutputParser::taskAdded(editable); + IOutputParser::taskAdded(editable, linkedLines, skippedLines); } #if defined WITH_TESTS diff --git a/src/plugins/projectexplorer/gnumakeparser.h b/src/plugins/projectexplorer/gnumakeparser.h index 26d3bf4503d..cf34bf68a5c 100644 --- a/src/plugins/projectexplorer/gnumakeparser.h +++ b/src/plugins/projectexplorer/gnumakeparser.h @@ -55,7 +55,7 @@ public: bool hasFatalErrors() const; public slots: - void taskAdded(const ProjectExplorer::Task &task); + void taskAdded(const ProjectExplorer::Task &task, int linkedLines, int skippedLines); private: void addDirectory(const QString &dir); diff --git a/src/plugins/projectexplorer/images/lightdisabledbuildstep.png b/src/plugins/projectexplorer/images/lightdisabledbuildstep.png Binary files differnew file mode 100644 index 00000000000..476bebe32cc --- /dev/null +++ b/src/plugins/projectexplorer/images/lightdisabledbuildstep.png diff --git a/src/plugins/projectexplorer/images/lightdisabledbuildstep@2x.png b/src/plugins/projectexplorer/images/lightdisabledbuildstep@2x.png Binary files differnew file mode 100644 index 00000000000..2bacc03ed3c --- /dev/null +++ b/src/plugins/projectexplorer/images/lightdisabledbuildstep@2x.png diff --git a/src/plugins/projectexplorer/ioutputparser.cpp b/src/plugins/projectexplorer/ioutputparser.cpp index 283a06a9778..420e77043e4 100644 --- a/src/plugins/projectexplorer/ioutputparser.cpp +++ b/src/plugins/projectexplorer/ioutputparser.cpp @@ -149,8 +149,8 @@ void IOutputParser::appendOutputParser(IOutputParser *parser) m_parser = parser; connect(parser, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)), this, SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat)), Qt::DirectConnection); - connect(parser, SIGNAL(addTask(ProjectExplorer::Task)), - this, SLOT(taskAdded(ProjectExplorer::Task)), Qt::DirectConnection); + connect(parser, SIGNAL(addTask(ProjectExplorer::Task, int, int)), + this, SLOT(taskAdded(ProjectExplorer::Task, int, int)), Qt::DirectConnection); } IOutputParser *IOutputParser::takeOutputParserChain() @@ -158,8 +158,8 @@ IOutputParser *IOutputParser::takeOutputParserChain() IOutputParser *parser = m_parser; disconnect(parser, SIGNAL(addOutput(QString,ProjectExplorer::BuildStep::OutputFormat)), this, SLOT(outputAdded(QString,ProjectExplorer::BuildStep::OutputFormat))); - disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task)), - this, SLOT(taskAdded(ProjectExplorer::Task))); + disconnect(parser, SIGNAL(addTask(ProjectExplorer::Task, int, int)), + this, SLOT(taskAdded(ProjectExplorer::Task, int, int))); m_parser = 0; return parser; } @@ -193,9 +193,9 @@ void IOutputParser::outputAdded(const QString &string, BuildStep::OutputFormat f emit addOutput(string, format); } -void IOutputParser::taskAdded(const Task &task) +void IOutputParser::taskAdded(const Task &task, int linkedOutputLines, int skipLines) { - emit addTask(task); + emit addTask(task, linkedOutputLines, skipLines); } void IOutputParser::doFlush() diff --git a/src/plugins/projectexplorer/ioutputparser.h b/src/plugins/projectexplorer/ioutputparser.h index bb93af8518f..840ce0d5527 100644 --- a/src/plugins/projectexplorer/ioutputparser.h +++ b/src/plugins/projectexplorer/ioutputparser.h @@ -67,11 +67,11 @@ public: signals: void addOutput(const QString &string, ProjectExplorer::BuildStep::OutputFormat format); - void addTask(const ProjectExplorer::Task &task); + void addTask(const ProjectExplorer::Task &task, int linkedOutputLines = 0, int skipLines = 0); public slots: virtual void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format); - virtual void taskAdded(const ProjectExplorer::Task &task); + virtual void taskAdded(const ProjectExplorer::Task &task, int linkedOutputLines = 0, int skipLines = 0); private: virtual void doFlush(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp index 07bb89a3eac..b901071c222 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.cpp @@ -38,6 +38,7 @@ #include <utils/stringutils.h> #include <utils/textfieldcheckbox.h> #include <utils/textfieldcombobox.h> +#include <utils/theme/theme.h> #include <QCheckBox> #include <QApplication> @@ -55,12 +56,15 @@ using namespace Utils; const char NAME_KEY[] = "name"; const char DISPLAY_NAME_KEY[] = "trDisplayName"; +const char TOOLTIP_KEY[] = "trToolTip"; const char MANDATORY_KEY[] = "mandatory"; const char VISIBLE_KEY[] = "visible"; const char ENABLED_KEY[] = "enabled"; const char SPAN_KEY[] = "span"; const char TYPE_KEY[] = "type"; const char DATA_KEY[] = "data"; +const char IS_COMPLETE_KEY[] = "isComplete"; +const char IS_COMPLETE_MESSAGE_KEY[] = "trIncompleteMessage"; namespace ProjectExplorer { @@ -160,11 +164,14 @@ JsonFieldPage::Field *JsonFieldPage::Field::parse(const QVariant &input, QString return 0; } data->name = name; + data->toolTip = tmp.value(QLatin1String(TOOLTIP_KEY)).toString(); data->m_visibleExpression = tmp.value(QLatin1String(VISIBLE_KEY), true); data->m_enabledExpression = tmp.value(QLatin1String(ENABLED_KEY), true); data->mandatory = tmp.value(QLatin1String(MANDATORY_KEY), true).toBool(); data->span = tmp.value(QLatin1String(SPAN_KEY), false).toBool(); + data->m_isCompleteExpando = tmp.value(QLatin1String(IS_COMPLETE_KEY), true); + data->m_isCompleteExpandoMessage = tmp.value(QLatin1String(IS_COMPLETE_MESSAGE_KEY)).toString(); data->displayName = JsonWizardFactory::localizedString(tmp.value(QLatin1String(DISPLAY_NAME_KEY)).toString()); @@ -200,6 +207,18 @@ void JsonFieldPage::Field::adjustState(MacroExpander *expander) { setVisible(JsonWizard::boolFromVariant(m_visibleExpression, expander)); setEnabled(JsonWizard::boolFromVariant(m_enabledExpression, expander)); + QTC_ASSERT(m_widget, return); + m_widget->setToolTip(expander->expand(toolTip)); +} + +bool JsonFieldPage::Field::validate(MacroExpander *expander, QString *message) +{ + if (!JsonWizard::boolFromVariant(m_isCompleteExpando, expander)) { + if (message) + *message = expander->expand(m_isCompleteExpandoMessage); + return false; + } + return true; } void JsonFieldPage::Field::initialize(MacroExpander *expander) @@ -365,7 +384,9 @@ void JsonFieldPage::LineEditField::setup(JsonFieldPage *page, const QString &nam bool JsonFieldPage::LineEditField::validate(MacroExpander *expander, QString *message) { - Q_UNUSED(message); + if (!JsonFieldPage::Field::validate(expander, message)) + return false; + if (m_isValidating) return true; @@ -455,8 +476,8 @@ void JsonFieldPage::TextEditField::setup(JsonFieldPage *page, const QString &nam bool JsonFieldPage::TextEditField::validate(MacroExpander *expander, QString *message) { - Q_UNUSED(expander); - Q_UNUSED(message); + if (!JsonFieldPage::Field::validate(expander, message)) + return false; QTextEdit *w = static_cast<QTextEdit *>(m_widget); @@ -553,8 +574,9 @@ void JsonFieldPage::PathChooserField::setup(JsonFieldPage *page, const QString & bool JsonFieldPage::PathChooserField::validate(MacroExpander *expander, QString *message) { - Q_UNUSED(expander); - Q_UNUSED(message); + if (!JsonFieldPage::Field::validate(expander, message)) + return false; + PathChooser *w = static_cast<PathChooser *>(m_widget); return w->isValid(); } @@ -619,13 +641,15 @@ QWidget *JsonFieldPage::CheckBoxField::widget(const QString &displayName, JsonFi void JsonFieldPage::CheckBoxField::setup(JsonFieldPage *page, const QString &name) { TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget); - connect(w, &TextFieldCheckBox::clicked, [this]() { m_isModified = true; }); + connect(w, &TextFieldCheckBox::clicked, [this, page]() { m_isModified = true; page->completeChanged();}); page->registerFieldWithName(name, w, "text", SIGNAL(textChanged(QString))); } bool JsonFieldPage::CheckBoxField::validate(MacroExpander *expander, QString *message) { - Q_UNUSED(message); + if (!JsonFieldPage::Field::validate(expander, message)) + return false; + if (!m_isModified) { TextFieldCheckBox *w = static_cast<TextFieldCheckBox *>(m_widget); w->setChecked(JsonWizard::boolFromVariant(m_checkedExpression, expander)); @@ -649,7 +673,7 @@ void JsonFieldPage::CheckBoxField::initializeData(MacroExpander *expander) // -------------------------------------------------------------------- JsonFieldPage::ComboBoxField::ComboBoxField() : - m_index(-1), m_disabledIndex(-1), m_savedIndex(-1), m_currentIndex(-1) + m_index(-1), m_disabledIndex(-1), m_savedIndex(-1) { } QPair<QString, QString> parseComboBoxItem(const QVariant &item, QString *errorMessage) @@ -741,8 +765,8 @@ void JsonFieldPage::ComboBoxField::setup(JsonFieldPage *page, const QString &nam bool JsonFieldPage::ComboBoxField::validate(MacroExpander *expander, QString *message) { - Q_UNUSED(expander); - Q_UNUSED(message); + if (!JsonFieldPage::Field::validate(expander, message)) + return false; TextFieldComboBox *w = static_cast<TextFieldComboBox *>(m_widget); if (!w->isEnabled() && m_disabledIndex >= 0 && m_savedIndex < 0) { @@ -768,10 +792,7 @@ void JsonFieldPage::ComboBoxField::initializeData(MacroExpander *expander) w->setItems(tmpItems, tmpData); w->setInsertPolicy(QComboBox::NoInsert); - if (m_currentIndex >= 0) - w->setCurrentIndex(m_currentIndex); - else - w->setCurrentIndex(m_index); + w->setCurrentIndex(m_index); } // -------------------------------------------------------------------- @@ -790,7 +811,9 @@ JsonFieldPage::JsonFieldPage(MacroExpander *expander, QWidget *parent) : m_formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); vLayout->addLayout(m_formLayout); m_errorLabel->setVisible(false); - m_errorLabel->setStyleSheet(QLatin1String("background: red")); + QPalette palette = m_errorLabel->palette(); + palette.setColor(QPalette::WindowText, creatorTheme()->color(Theme::TextColorError)); + m_errorLabel->setPalette(palette); vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); vLayout->addWidget(m_errorLabel); setLayout(vLayout); @@ -813,7 +836,6 @@ bool JsonFieldPage::setup(const QVariant &data) f->createWidget(this); m_fields.append(f); } - return true; } diff --git a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h index 96d92b9703e..92090c62e02 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonfieldpage.h @@ -71,8 +71,7 @@ public: virtual void setEnabled(bool e) { m_widget->setEnabled(e); } void setVisible(bool v) { m_widget->setVisible(v); } - virtual bool validate(Utils::MacroExpander *expander, QString *message) - { Q_UNUSED(expander); Q_UNUSED(message); return true; } + virtual bool validate(Utils::MacroExpander *expander, QString *message); void initialize(Utils::MacroExpander *expander); virtual void cleanup(Utils::MacroExpander *expander) { Q_UNUSED(expander); } @@ -81,12 +80,15 @@ public: QString name; QString displayName; + QString toolTip; bool mandatory; bool span; protected: QVariant m_visibleExpression; QVariant m_enabledExpression; + QVariant m_isCompleteExpando; + QString m_isCompleteExpandoMessage; virtual bool parseData(const QVariant &data, QString *errorMessage) = 0; virtual void initializeData(Utils::MacroExpander *expander) { Q_UNUSED(expander); } @@ -237,7 +239,6 @@ public: int m_disabledIndex; mutable int m_savedIndex; - int m_currentIndex; }; JsonFieldPage(Utils::MacroExpander *expander, QWidget *parent = 0); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonkitspage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonkitspage.cpp index ed6985ecc5d..65737f55932 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonkitspage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonkitspage.cpp @@ -55,7 +55,7 @@ void JsonKitsPage::initializePage() JsonWizard *wiz = qobject_cast<JsonWizard *>(wizard()); QTC_ASSERT(wiz, return); - connect(wiz, &JsonWizard::filesReady, this, &JsonKitsPage::setupProjectFiles); + connect(wiz, &JsonWizard::filesPolished, this, &JsonKitsPage::setupProjectFiles); const QString platform = wiz->stringValue(QLatin1String("Platform")); const Core::FeatureSet preferred = Core::FeatureSet::fromStringList(wiz->value(QLatin1String("PreferredFeatures")).toStringList()); @@ -73,7 +73,7 @@ void JsonKitsPage::cleanupPage() JsonWizard *wiz = qobject_cast<JsonWizard *>(wizard()); QTC_ASSERT(wiz, return); - disconnect(wiz, &JsonWizard::filesReady, this, 0); + disconnect(wiz, &JsonWizard::allDone, this, 0); TargetSetupPage::cleanupPage(); } diff --git a/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp b/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp index e0e3f900b02..37317bd78d1 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonsummarypage.cpp @@ -67,8 +67,6 @@ static IWizardFactory::WizardKind wizardKind(JsonWizard *wiz) const QString kindStr = wiz->stringValue(QLatin1String("kind")); if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_PROJECT)) kind = IWizardFactory::ProjectWizard; - else if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_CLASS)) - kind = IWizardFactory::ClassWizard; else if (kindStr == QLatin1String(Core::Constants::WIZARD_KIND_FILE)) kind = IWizardFactory::FileWizard; else @@ -197,7 +195,7 @@ void JsonSummaryPage::projectNodeHasChanged() void JsonSummaryPage::versionControlHasChanged() { IVersionControl *vc = currentVersionControl(); - m_wizard->setProperty("VersionControl", vc ? vc->id().toString() : QString()); + m_wizard->setProperty("VersionControl", vc ? vc->id().toString() : QLatin1String("")); updateFileList(); } diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp index 3a932ebcef6..a3ddf29f607 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.cpp @@ -32,6 +32,10 @@ #include "jsonwizardgeneratorfactory.h" +#include "../project.h" +#include "../projectexplorer.h" + +#include <coreplugin/editormanager/editormanager.h> #include <coreplugin/messagemanager.h> #include <utils/algorithm.h> @@ -155,19 +159,27 @@ QVariant JsonWizard::value(const QString &n) const bool JsonWizard::boolFromVariant(const QVariant &v, Utils::MacroExpander *expander) { - if (v.type() == QVariant::String) - return !expander->expand(v.toString()).isEmpty(); + if (v.type() == QVariant::String) { + const QString tmp = expander->expand(v.toString()); + return !(tmp.isEmpty() || tmp == QLatin1String("false")); + } return v.toBool(); } void JsonWizard::removeAttributeFromAllFiles(Core::GeneratedFile::Attribute a) { - for (int i = 0; i < m_files.count(); ++i) - m_files[i].file.setAttributes(m_files.at(i).file.attributes() ^ a); + for (int i = 0; i < m_files.count(); ++i) { + if (m_files.at(i).file.attributes() & a) + m_files[i].file.setAttributes(m_files.at(i).file.attributes() ^ a); + } } void JsonWizard::accept() { + auto page = qobject_cast<Utils::WizardPage *>(currentPage()); + if (page && page->handleAccept()) + return; + Utils::Wizard::accept(); QString errorMessage; @@ -207,13 +219,29 @@ void JsonWizard::accept() return; } emit filesReady(m_files); + if (!JsonWizardGenerator::polish(this, &m_files, &errorMessage)) { + if (!errorMessage.isEmpty()) + QMessageBox::warning(this, tr("Failed to Polish Files"), errorMessage); + return; + } + emit filesPolished(m_files); if (!JsonWizardGenerator::allDone(this, &m_files, &errorMessage)) { if (!errorMessage.isEmpty()) QMessageBox::warning(this, tr("Failed to Open Files"), errorMessage); return; } - emit allDone(m_files); + + openFiles(m_files); +} + +void JsonWizard::reject() +{ + auto page = qobject_cast<Utils::WizardPage *>(currentPage()); + if (page && page->handleReject()) + return; + + Utils::Wizard::reject(); } void JsonWizard::handleNewPages(int pageId) @@ -230,4 +258,59 @@ void JsonWizard::handleError(const QString &message) Core::MessageManager::write(message, Core::MessageManager::ModeSwitch); } +void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files) +{ + QString errorMessage; + bool openedSomething = false; + foreach (const JsonWizard::GeneratorFile &f, files) { + const Core::GeneratedFile &file = f.file; + if (!QFileInfo(file.path()).exists()) { + errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", + "\"%1\" does not exist in the file system.") + .arg(QDir::toNativeSeparators(file.path())); + break; + } + if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { + Project *project = ProjectExplorerPlugin::instance()->openProject(file.path(), &errorMessage); + if (!project) { + if (errorMessage.isEmpty()) { + errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", + "Failed to open \"%1\" as a project.") + .arg(QDir::toNativeSeparators(file.path())); + } + break; + } + openedSomething = true; + } + if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) { + if (!Core::EditorManager::openEditor(file.path(), file.editorId())) { + errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", + "Failed to open an editor for \"%1\".") + .arg(QDir::toNativeSeparators(file.path())); + break; + } + openedSomething = true; + } + } + + const QString path + = QDir::toNativeSeparators(m_expander.expand(value(QLatin1String("TargetPath")).toString())); + + // Now try to find the project file and open + if (!openedSomething) { + errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", + "No file to open found in \"%1\".") + .arg(path); + } + + if (!errorMessage.isEmpty()) { + const QString text = path.isEmpty() ? tr("Failed to open project.") + : tr("Failed to open project in \"%1\".").arg(path); + QMessageBox msgBox(QMessageBox::Warning, tr("Cannot Open Project"), text); + msgBox.setDetailedText(errorMessage); + msgBox.addButton(QMessageBox::Ok); + msgBox.exec(); + } +} + } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h index 37362a2cfeb..73fa2300e5c 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.h @@ -90,16 +90,20 @@ signals: void preWriteFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are written to disk. void postProcessFiles(const JsonWizard::GeneratorFiles &files); // emitted before files are post-processed. void filesReady(const JsonWizard::GeneratorFiles &files); // emitted just after files are in final state on disk. + void filesPolished(const JsonWizard::GeneratorFiles &files); // emitted just after additional files (e.g. settings) not directly related to the project were created. void allDone(const JsonWizard::GeneratorFiles &files); // emitted just after the wizard is done with the files. They are ready to be opened. public slots: void accept(); + void reject(); private slots: void handleNewPages(int pageId); void handleError(const QString &message); private: + void openFiles(const GeneratorFiles &files); + QList<JsonWizardGenerator *> m_generators; GeneratorFiles m_files; diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizard.pri b/src/plugins/projectexplorer/jsonwizard/jsonwizard.pri index b9d7fe5136a..72f914f4f49 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizard.pri +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizard.pri @@ -8,7 +8,8 @@ HEADERS += $$PWD/jsonfieldpage.h \ $$PWD/jsonwizardfilegenerator.h \ $$PWD/jsonwizardgeneratorfactory.h \ $$PWD/jsonwizardpagefactory.h \ - $$PWD/jsonwizardpagefactory_p.h + $$PWD/jsonwizardpagefactory_p.h \ + $$PWD/jsonwizardscannergenerator.h SOURCES += $$PWD/jsonfieldpage.cpp \ $$PWD/jsonfilepage.cpp \ @@ -20,4 +21,5 @@ SOURCES += $$PWD/jsonfieldpage.cpp \ $$PWD/jsonwizardfilegenerator.cpp \ $$PWD/jsonwizardgeneratorfactory.cpp \ $$PWD/jsonwizardpagefactory.cpp \ - $$PWD/jsonwizardpagefactory_p.cpp + $$PWD/jsonwizardpagefactory_p.cpp \ + $$PWD/jsonwizardscannergenerator.cpp diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp index 794f6849954..3913eada70d 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.cpp @@ -73,6 +73,7 @@ static const char CATEGORY_KEY[] = "category"; static const char CATEGORY_NAME_KEY[] = "trDisplayCategory"; static const char DISPLAY_NAME_KEY[] = "trDisplayName"; static const char ICON_KEY[] = "icon"; +static const char IMAGE_KEY[] = "image"; static const char DESCRIPTION_KEY[] = "trDescription"; static const char REQUIRED_FEATURES_KEY[] = "featuresRequired"; static const char SUGGESTED_FEATURES_KEY[] = "featuresSuggested"; @@ -204,13 +205,13 @@ static JsonWizardFactory::Page parsePage(const QVariant &value, QString *errorMe return p; } -QList<JsonWizardFactory *> JsonWizardFactory::createWizardFactories() +QList<Core::IWizardFactory *> JsonWizardFactory::createWizardFactories() { QString errorMessage; QString verboseLog; const QString wizardFileName = QLatin1String(WIZARD_FILE); - QList <JsonWizardFactory *> result; + QList <Core::IWizardFactory *> result; foreach (const Utils::FileName &path, searchPaths()) { if (path.isEmpty()) continue; @@ -387,8 +388,6 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS QString kindStr = QLatin1String(Core::Constants::WIZARD_KIND_UNKNOWN); if (kind() == IWizardFactory::FileWizard) kindStr = QLatin1String(Core::Constants::WIZARD_KIND_FILE); - else if (kind() == IWizardFactory::ClassWizard) - kindStr = QLatin1String(Core::Constants::WIZARD_KIND_CLASS); else if (kind() == IWizardFactory::ProjectWizard) kindStr = QLatin1String(Core::Constants::WIZARD_KIND_PROJECT); wizard.setValue(QStringLiteral("kind"), kindStr); @@ -396,12 +395,14 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS for (auto i = m_options.constBegin(); i != m_options.constEnd(); ++i) wizard.setValue(i.key(), i.value()); + bool havePage = false; foreach (const Page &data, m_pages) { QTC_ASSERT(data.isValid(), continue); if (!JsonWizard::boolFromVariant(data.enabled, wizard.expander())) continue; + havePage = true; JsonWizardPageFactory *factory = Utils::findOr(s_pageFactories, 0, [&data](JsonWizardPageFactory *f) { return f->canCreate(data.typeId); @@ -436,7 +437,7 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS wizard.addGenerator(gen); } - if (!m_pages.isEmpty()) { + if (havePage) { Core::ICore::registerWindow(&wizard, Core::Context("Core.NewJSONWizard")); wizard.exec(); } else { @@ -447,7 +448,9 @@ void JsonWizardFactory::runWizard(const QString &path, QWidget *parent, const QS QList<QVariant> JsonWizardFactory::objectOrList(const QVariant &data, QString *errorMessage) { QList<QVariant> result; - if (data.type() == QVariant::Map) + if (data.isNull()) + *errorMessage = tr("key not found."); + else if (data.type() == QVariant::Map) result.append(data); else if (data.type() == QVariant::List) result = data.toList(); @@ -473,7 +476,6 @@ QString JsonWizardFactory::localizedString(const QVariant &value) return QString(); } return QCoreApplication::translate("ProjectExplorer::JsonWizardFactory", value.toByteArray()); - } void JsonWizardFactory::destroyAllFactories() @@ -496,13 +498,11 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir, if (strVal != QLatin1String("class") && strVal != QLatin1String("file") && strVal != QLatin1String("project")) { - *errorMessage = tr("\"kind\" value \"%1\" is not \"class\", \"file\" or \"project\".").arg(strVal); + *errorMessage = tr("\"kind\" value \"%1\" is not \"class\" (deprecated!), \"file\" or \"project\".").arg(strVal); return false; } IWizardFactory::WizardKind kind = IWizardFactory::ProjectWizard; - if (strVal == QLatin1String("class")) - kind = IWizardFactory::ClassWizard; - if (strVal == QLatin1String("file")) + if (strVal == QLatin1String("file") || strVal == QLatin1String("class")) kind = IWizardFactory::FileWizard; setWizardKind(kind); @@ -511,7 +511,7 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir, *errorMessage = tr("No id set."); return false; } - setId(strVal); + setId(Core::Id::fromString(strVal)); strVal = data.value(QLatin1String(CATEGORY_KEY)).toString(); if (strVal.isEmpty()) { @@ -524,12 +524,22 @@ bool JsonWizardFactory::initialize(const QVariantMap &data, const QDir &baseDir, if (!strVal.isEmpty()) { strVal = baseDir.absoluteFilePath(strVal); if (!QFileInfo::exists(strVal)) { - *errorMessage = tr("Icon \"%1\" not found.").arg(strVal); + *errorMessage = tr("Icon file \"%1\" not found.").arg(QDir::toNativeSeparators(strVal)); return false; } setIcon(QIcon(strVal)); } + strVal = data.value(QLatin1String(IMAGE_KEY)).toString(); + if (!strVal.isEmpty()) { + strVal = baseDir.absoluteFilePath(strVal); + if (!QFileInfo::exists(strVal)) { + *errorMessage = tr("Image file \"%1\" not found.").arg(QDir::toNativeSeparators(strVal)); + return false; + } + setDescriptionImage(strVal); + } + setRequiredFeatures(Core::FeatureSet::fromStringList(data.value(QLatin1String(REQUIRED_FEATURES_KEY)).toStringList())); m_preferredFeatures = Core::FeatureSet::fromStringList(data.value(QLatin1String(SUGGESTED_FEATURES_KEY)).toStringList()); m_preferredFeatures |= requiredFeatures(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h index ff7389d088d..5098930bfb9 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfactory.h @@ -95,7 +95,7 @@ public: private: // Create all wizards. As other plugins might register factories for derived // classes. Called when the new file dialog is shown for the first time. - static QList<JsonWizardFactory *> createWizardFactories(); + static QList<IWizardFactory *> createWizardFactories(); static JsonWizardFactory *createWizardFactory(const QVariantMap &data, const QDir &baseDir, QString *errorMessage); static QList<Utils::FileName> &searchPaths(); diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp index 873ff04c719..832b7d4a465 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.cpp @@ -191,38 +191,5 @@ bool JsonWizardFileGenerator::writeFile(const JsonWizard *wizard, Core::Generate return true; } -bool JsonWizardFileGenerator::postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) -{ - Q_UNUSED(wizard); - Q_UNUSED(file); - Q_UNUSED(errorMessage); - return true; -} - -bool JsonWizardFileGenerator::allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) -{ - Q_UNUSED(wizard); - if (file->attributes() & Core::GeneratedFile::OpenProjectAttribute) { - Project *project = ProjectExplorerPlugin::instance()->openProject(file->path(), errorMessage); - if (!project) { - *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", - "Failed to open \"%1\" as a project.") - .arg(QDir::toNativeSeparators(file->path())); - - return false; - } - } - if (file->attributes() & Core::GeneratedFile::OpenEditorAttribute) { - if (!Core::EditorManager::openEditor(file->path(), file->editorId())) { - if (errorMessage) - *errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard", - "Failed to open an editor for \"%1\".") - .arg(QDir::toNativeSeparators(file->path())); - return false; - } - } - return true; -} - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h index c5e3e35fbe3..2a66f496230 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardfilegenerator.h @@ -49,8 +49,6 @@ public: QString *errorMessage); bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); - bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); - bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); private: class File { diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp index ec643baf794..04ae2411452 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.cpp @@ -32,6 +32,7 @@ #include "jsonwizard.h" #include "jsonwizardfilegenerator.h" +#include "jsonwizardscannergenerator.h" #include "../editorconfiguration.h" #include "../project.h" @@ -124,6 +125,38 @@ bool JsonWizardGenerator::formatFile(const JsonWizard *wizard, GeneratedFile *fi return true; } +bool JsonWizardGenerator::writeFile(const JsonWizard *wizard, GeneratedFile *file, QString *errorMessage) +{ + Q_UNUSED(wizard); + Q_UNUSED(file); + Q_UNUSED(errorMessage); + return true; +} + +bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, GeneratedFile *file, QString *errorMessage) +{ + Q_UNUSED(wizard); + Q_UNUSED(file); + Q_UNUSED(errorMessage); + return true; +} + +bool JsonWizardGenerator::polish(const JsonWizard *wizard, GeneratedFile *file, QString *errorMessage) +{ + Q_UNUSED(wizard); + Q_UNUSED(file); + Q_UNUSED(errorMessage); + return true; +} + +bool JsonWizardGenerator::allDone(const JsonWizard *wizard, GeneratedFile *file, QString *errorMessage) +{ + Q_UNUSED(wizard); + Q_UNUSED(file); + Q_UNUSED(errorMessage); + return true; +} + JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(JsonWizard::GeneratorFiles *files, QString *errorMessage) { @@ -132,7 +165,9 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso foreach (const JsonWizard::GeneratorFile &f, *files) { const QFileInfo fi(f.file.path()); - if (fi.exists() && !(f.file.attributes() & GeneratedFile::ForceOverwrite)) + if (fi.exists() + && !(f.file.attributes() & GeneratedFile::ForceOverwrite) + && !(f.file.attributes() & GeneratedFile::KeepExistingFileAttribute)) existingFiles.append(f.file.path()); } if (existingFiles.isEmpty()) @@ -200,7 +235,8 @@ JsonWizardGenerator::OverwriteResult JsonWizardGenerator::promptForOverwrite(Jso return OverwriteOk; } -bool JsonWizardGenerator::formatFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage) +bool JsonWizardGenerator::formatFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, + QString *errorMessage) { for (auto i = files->begin(); i != files->end(); ++i) { if (!i->generator->formatFile(wizard, &(i->file), errorMessage)) @@ -209,7 +245,8 @@ bool JsonWizardGenerator::formatFiles(const JsonWizard *wizard, JsonWizard::Gene return true; } -bool JsonWizardGenerator::writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage) +bool JsonWizardGenerator::writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, + QString *errorMessage) { for (auto i = files->begin(); i != files->end(); ++i) { if (!i->generator->writeFile(wizard, &(i->file), errorMessage)) @@ -218,7 +255,8 @@ bool JsonWizardGenerator::writeFiles(const JsonWizard *wizard, JsonWizard::Gener return true; } -bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage) +bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, + QString *errorMessage) { for (auto i = files->begin(); i != files->end(); ++i) { if (!i->generator->postWrite(wizard, &(i->file), errorMessage)) @@ -227,7 +265,18 @@ bool JsonWizardGenerator::postWrite(const JsonWizard *wizard, JsonWizard::Genera return true; } -bool JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage) +bool JsonWizardGenerator::polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, + QString *errorMessage) +{ + for (auto i = files->begin(); i != files->end(); ++i) { + if (!i->generator->polish(wizard, &(i->file), errorMessage)) + return false; + } + return true; +} + +bool JsonWizardGenerator::allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, + QString *errorMessage) { for (auto i = files->begin(); i != files->end(); ++i) { if (!i->generator->allDone(wizard, &(i->file), errorMessage)) @@ -255,6 +304,7 @@ void JsonWizardGeneratorFactory::setTypeIdsSuffix(const QString &suffix) // FileGeneratorFactory: // -------------------------------------------------------------------- +namespace Internal { FileGeneratorFactory::FileGeneratorFactory() { @@ -265,14 +315,13 @@ JsonWizardGenerator *FileGeneratorFactory::create(Id typeId, const QVariant &dat const QString &path, const QString &platform, const QVariantMap &variables) { - Q_UNUSED(data); Q_UNUSED(path); Q_UNUSED(platform); Q_UNUSED(variables); QTC_ASSERT(canCreate(typeId), return 0); - auto *gen = new Internal::JsonWizardFileGenerator(); + auto gen = new JsonWizardFileGenerator; QString errorMessage; gen->setup(data, &errorMessage); @@ -287,16 +336,51 @@ JsonWizardGenerator *FileGeneratorFactory::create(Id typeId, const QVariant &dat bool FileGeneratorFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage) { - Q_UNUSED(data); - Q_UNUSED(errorMessage); - QTC_ASSERT(canCreate(typeId), return false); - QScopedPointer<Internal::JsonWizardFileGenerator> gen(new Internal::JsonWizardFileGenerator()); - if (!gen->setup(data, errorMessage)) - return false; + QScopedPointer<JsonWizardFileGenerator> gen(new JsonWizardFileGenerator); + return gen->setup(data, errorMessage); +} - return true; +// -------------------------------------------------------------------- +// ScannerGeneratorFactory: +// -------------------------------------------------------------------- + +ScannerGeneratorFactory::ScannerGeneratorFactory() +{ + setTypeIdsSuffix(QLatin1String("Scanner")); +} + +JsonWizardGenerator *ScannerGeneratorFactory::create(Id typeId, const QVariant &data, + const QString &path, const QString &platform, + const QVariantMap &variables) +{ + Q_UNUSED(path); + Q_UNUSED(platform); + Q_UNUSED(variables); + + QTC_ASSERT(canCreate(typeId), return 0); + + auto gen = new JsonWizardScannerGenerator; + QString errorMessage; + gen->setup(data, &errorMessage); + + if (!errorMessage.isEmpty()) { + qWarning() << "ScannerGeneratorFactory setup error:" << errorMessage; + delete gen; + return 0; + } + + return gen; +} + +bool ScannerGeneratorFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage) +{ + QTC_ASSERT(canCreate(typeId), return false); + + QScopedPointer<JsonWizardScannerGenerator> gen(new JsonWizardScannerGenerator); + return gen->setup(data, errorMessage); } +} // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h index 08dff686d75..e9b182dfc1c 100644 --- a/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardgeneratorfactory.h @@ -53,9 +53,10 @@ public: const QString &baseDir, const QString &projectDir, QString *errorMessage) = 0; virtual bool formatFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); - virtual bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; - virtual bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; - virtual bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage) = 0; + virtual bool writeFile(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); + virtual bool postWrite(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); + virtual bool polish(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); + virtual bool allDone(const JsonWizard *wizard, Core::GeneratedFile *file, QString *errorMessage); virtual bool canKeepExistingFiles() const { return true; } @@ -65,6 +66,7 @@ public: static bool formatFiles(const JsonWizard *wizard, QList<JsonWizard::GeneratorFile> *files, QString *errorMessage); static bool writeFiles(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); static bool postWrite(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); + static bool polish(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); static bool allDone(const JsonWizard *wizard, JsonWizard::GeneratorFiles *files, QString *errorMessage); }; @@ -92,6 +94,8 @@ private: QList<Core::Id> m_typeIds; }; +namespace Internal { + class FileGeneratorFactory : public JsonWizardGeneratorFactory { Q_OBJECT @@ -105,6 +109,20 @@ public: bool validateData(Core::Id typeId, const QVariant &data, QString *errorMessage); }; +class ScannerGeneratorFactory : public JsonWizardGeneratorFactory +{ + Q_OBJECT + +public: + ScannerGeneratorFactory(); + + JsonWizardGenerator *create(Core::Id typeId, const QVariant &data, + const QString &path, const QString &platform, + const QVariantMap &variables); + bool validateData(Core::Id typeId, const QVariant &data, QString *errorMessage); +}; + +} // namespace Internal } // namespace ProjectExplorer #endif // JSONWIZARDGENERATORFACTORY_H diff --git a/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp new file mode 100644 index 00000000000..dc4c6da937a --- /dev/null +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.cpp @@ -0,0 +1,169 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "jsonwizardscannergenerator.h" + +#include "../customwizard/customwizardpreprocessor.h" +#include "../projectexplorer.h" +#include "../iprojectmanager.h" +#include "jsonwizard.h" +#include "jsonwizardfactory.h" + +#include <coreplugin/editormanager/editormanager.h> + +#include <extensionsystem/pluginmanager.h> + +#include <utils/algorithm.h> +#include <utils/fileutils.h> +#include <utils/qtcassert.h> +#include <utils/macroexpander.h> +#include <utils/mimetypes/mimedatabase.h> + +#include <QCoreApplication> +#include <QDir> +#include <QVariant> + +namespace ProjectExplorer { +namespace Internal { + +bool JsonWizardScannerGenerator::setup(const QVariant &data, QString *errorMessage) +{ + if (data.isNull()) + return true; + + if (data.type() != QVariant::Map) { + *errorMessage = QCoreApplication::translate("ProjectExplorer::Internal::JsonWizard", + "Key is not an object."); + return false; + } + + QVariantMap gen = data.toMap(); + + m_binaryPattern = gen.value(QLatin1String("binaryPattern")).toString(); + QStringList patterns = gen.value(QLatin1String("subdirectoryPatterns")).toStringList(); + foreach (const QString pattern, patterns) { + QRegularExpression regexp(pattern); + if (!regexp.isValid()) { + *errorMessage = QCoreApplication::translate("ProjectExplorer::Internal::JsonWizard", + "Pattern \"%1\" is no valid regular expression."); + return false; + } + m_subDirectoryExpressions << regexp; + } + + m_firstProjectOnly = gen.value(QLatin1String("firstProjectOnly"), QLatin1String("true")).toString(); + + return true; +} + +Core::GeneratedFiles JsonWizardScannerGenerator::fileList(Utils::MacroExpander *expander, + const QString &wizardDir, + const QString &projectDir, + QString *errorMessage) +{ + Q_UNUSED(wizardDir); + errorMessage->clear(); + + QDir project(projectDir); + Core::GeneratedFiles result; + Utils::MimeDatabase mdb; + + QRegularExpression binaryPattern; + if (!m_binaryPattern.isEmpty()) { + binaryPattern = QRegularExpression(expander->expand(m_binaryPattern)); + if (!binaryPattern.isValid()) { + qWarning() << QCoreApplication::translate("ProjectExplorer::Internal::JsonWizard", + "ScannerGenerator: Binary pattern \"%1\" not valid.") + .arg(m_binaryPattern); + return result; + } + } + + bool onlyFirst = JsonWizard::boolFromVariant(m_firstProjectOnly, expander); + + result = scan(project.absolutePath(), project); + + QList<IProjectManager *> projectManagers + = ExtensionSystem::PluginManager::getObjects<IProjectManager>(); + + int projectCount = 0; + for (auto it = result.begin(); it != result.end(); ++it) { + const QString relPath = project.relativeFilePath(it->path()); + it->setBinary(binaryPattern.match(relPath).hasMatch()); + + Utils::MimeType mt = mdb.mimeTypeForFile(relPath); + if (mt.isValid()) { + bool found = Utils::anyOf(projectManagers, [mt](IProjectManager *m) { + return mt.matchesName(m->mimeType()); + }); + if (found && !(onlyFirst && projectCount++)) + it->setAttributes(it->attributes() | Core::GeneratedFile::OpenProjectAttribute); + } + } + + return result; +} + +bool JsonWizardScannerGenerator::matchesSubdirectoryPattern(const QString &path) +{ + foreach (const QRegularExpression ®exp, m_subDirectoryExpressions) { + if (regexp.match(path).hasMatch()) + return true; + } + return false; +} + +Core::GeneratedFiles JsonWizardScannerGenerator::scan(const QString &dir, const QDir &base) +{ + Core::GeneratedFiles result; + QDir directory(dir); + + if (!directory.exists()) + return result; + + QList<QFileInfo> entries = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot, + QDir::DirsLast | QDir::Name); + foreach (const QFileInfo &fi, entries) { + const QString relativePath = base.relativeFilePath(fi.absoluteFilePath()); + if (fi.isDir() && matchesSubdirectoryPattern(relativePath)) { + result += scan(fi.absoluteFilePath(), base); + } else { + Core::GeneratedFile f(fi.absoluteFilePath()); + f.setAttributes(f.attributes() | Core::GeneratedFile::KeepExistingFileAttribute); + + result.append(f); + } + } + + return result; +} + +} // namespace Internal +} // namespace ProjectExplorer diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.h b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.h index 40a890730e0..0ff34fcaba0 100644 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.h +++ b/src/plugins/projectexplorer/jsonwizard/jsonwizardscannergenerator.h @@ -28,37 +28,38 @@ ** ****************************************************************************/ -#ifndef QTQUICKAPPWIZARD_H -#define QTQUICKAPPWIZARD_H +#ifndef JSONWIZARDSCANNERGENERATOR_H +#define JSONWIZARDSCANNERGENERATOR_H -#include "abstractmobileappwizard.h" +#include "jsonwizardgeneratorfactory.h" -namespace QmakeProjectManager { +#include <QDir> +#include <QRegularExpression> +#include <QVariant> + +namespace ProjectExplorer { namespace Internal { -class QtQuickAppWizard : public AbstractMobileAppWizard +// Documentation inside. +class JsonWizardScannerGenerator : public JsonWizardGenerator { - Q_OBJECT - public: - QtQuickAppWizard(); - ~QtQuickAppWizard(); + bool setup(const QVariant &data, QString *errorMessage); -protected: - QString fileToOpenPostGeneration() const; + Core::GeneratedFiles fileList(Utils::MacroExpander *expander, + const QString &wizardDir, const QString &projectDir, + QString *errorMessage); private: - AbstractMobileApp *app() const; - AbstractMobileAppWizardDialog *wizardDialog() const; - AbstractMobileAppWizardDialog *createInternal(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const; - void projectPathChanged(const QString &path) const; - void prepareGenerateFiles(const QWizard *wizard, QString *errorMessage) const; + Core::GeneratedFiles scan(const QString &dir, const QDir &base); + bool matchesSubdirectoryPattern(const QString &path); - class QtQuickAppWizardPrivate *d; + QString m_binaryPattern; + QString m_firstProjectOnly; + QList<QRegularExpression> m_subDirectoryExpressions; }; } // namespace Internal -} // namespace QmakeProjectManager +} // namespace ProjectExplorer -#endif // QTQUICKAPPWIZARD_H +#endif // JSONWIZARDSCANNERGENERATOR_H diff --git a/src/plugins/projectexplorer/kit.cpp b/src/plugins/projectexplorer/kit.cpp index c7e39507cf9..820ca56043b 100644 --- a/src/plugins/projectexplorer/kit.cpp +++ b/src/plugins/projectexplorer/kit.cpp @@ -175,16 +175,21 @@ Kit::Kit(const QVariantMap &data) : QVariantMap extra = data.value(QLatin1String(DATA_KEY)).toMap(); d->m_data.clear(); // remove default values const QVariantMap::ConstIterator cend = extra.constEnd(); - for (QVariantMap::ConstIterator it = extra.constBegin(); it != cend; ++it) - d->m_data.insert(Id::fromString(it.key()), it.value()); + for (QVariantMap::ConstIterator it = extra.constBegin(); it != cend; ++it) { + const QString key = it.key(); + if (!key.isEmpty()) + d->m_data.insert(Id::fromString(key), it.value()); + } QStringList mutableInfoList = data.value(QLatin1String(MUTABLE_INFO_KEY)).toStringList(); foreach (const QString &mutableInfo, mutableInfoList) - d->m_mutable.insert(Id::fromString(mutableInfo)); + if (!mutableInfo.isEmpty()) + d->m_mutable.insert(Id::fromString(mutableInfo)); QStringList stickyInfoList = data.value(QLatin1String(STICKY_INFO_KEY)).toStringList(); foreach (const QString &stickyInfo, stickyInfoList) - d->m_sticky.insert(Id::fromString(stickyInfo)); + if (!stickyInfo.isEmpty()) + d->m_sticky.insert(Id::fromString(stickyInfo)); } Kit::~Kit() diff --git a/src/plugins/projectexplorer/kitchooser.cpp b/src/plugins/projectexplorer/kitchooser.cpp index b597d59166d..b0ad5dc62e1 100644 --- a/src/plugins/projectexplorer/kitchooser.cpp +++ b/src/plugins/projectexplorer/kitchooser.cpp @@ -97,7 +97,7 @@ QString KitChooser::kitToolTip(Kit *k) const void KitChooser::populate() { m_chooser->clear(); - foreach (Kit *kit, KitManager::sortedKits()) { + foreach (Kit *kit, KitManager::sortKits(KitManager::kits())) { if (kitMatches(kit)) { m_chooser->addItem(kitText(kit), qVariantFromValue(kit->id())); m_chooser->setItemData(m_chooser->count() - 1, kitToolTip(kit), Qt::ToolTipRole); diff --git a/src/plugins/projectexplorer/kitmanager.cpp b/src/plugins/projectexplorer/kitmanager.cpp index 531310ff1a9..35df6ec65a3 100644 --- a/src/plugins/projectexplorer/kitmanager.cpp +++ b/src/plugins/projectexplorer/kitmanager.cpp @@ -331,6 +331,23 @@ FeatureSet KitManager::availableFeatures(const QString &platform) return features; } +QList<Kit *> KitManager::sortKits(const QList<Kit *> kits) +{ + // This method was added to delay the sorting of kits as long as possible. + // Since the displayName can contain variables it can be costly (e.g. involve + // calling executables to find version information, etc.) to call that + // method! + // Avoid lots of potentially expensive calls to Kit::displayName(): + QList<QPair<QString, Kit *> > sortList + = Utils::transform(kits, [](Kit *k) { return qMakePair(k->displayName(), k); }); + Utils::sort(sortList, [](const QPair<QString, Kit *> &a, const QPair<QString, Kit *> &b) -> bool { + if (a.first == b.first) + return a.second < b.second; + return a. first < b.first; + }); + return Utils::transform(sortList, [](const QPair<QString, Kit *> &a) { return a.second; }); +} + KitManager::KitList KitManager::restoreKits(const FileName &fileName) { KitList result; @@ -385,21 +402,6 @@ QList<Kit *> KitManager::kits() return d->m_kitList; } -QList<Kit *> KitManager::sortedKits() -{ - // This method was added to delay the sorting of kits as long as possible. - // Since the displayName can contain variables it can be costly (e.g. involve - // calling executables to find version information, etc.) to call that - // method! - // Avoid lots of potentially expensive calls to Kit::displayName(): - QList<QPair<QString, Kit *> > sortList - = Utils::transform(d->m_kitList, [](Kit *k) { return qMakePair(k->displayName(), k); }); - Utils::sort(sortList, [](const QPair<QString, Kit *> &a, const QPair<QString, Kit *> &b) { - return a.first < b.first; - }); - return Utils::transform(sortList, [](const QPair<QString, Kit *> &a) { return a.second; }); -} - QList<Kit *> KitManager::matchingKits(const KitMatcher &matcher) { QList<Kit *> result; diff --git a/src/plugins/projectexplorer/kitmanager.h b/src/plugins/projectexplorer/kitmanager.h index faa9bdbc829..6f53f39574c 100644 --- a/src/plugins/projectexplorer/kitmanager.h +++ b/src/plugins/projectexplorer/kitmanager.h @@ -134,7 +134,6 @@ public: ~KitManager(); static QList<Kit *> kits(); - static QList<Kit *> sortedKits(); // Use kits() whenever possible as that is cheaper! static QList<Kit *> matchingKits(const KitMatcher &matcher); static Kit *find(Core::Id id); static Kit *find(const KitMatcher &matcher); @@ -157,6 +156,8 @@ public: static QString displayNameForPlatform(const QString &platform); static Core::FeatureSet availableFeatures(const QString &platform); + static QList<Kit *> sortKits(const QList<Kit *> kits); // Avoid sorting whenever possible! + public slots: void saveKits(); diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp index de3e9043ad0..7812b291b4f 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.cpp @@ -380,13 +380,5 @@ QLabel *KitManagerConfigWidget::createLabel(const QString &name, const QString & return label; } -void KitManagerConfigWidget::paintEvent(QPaintEvent *) -{ - QPainter p(this); - if (m_background.size() != size()) - m_background = Utils::DetailsWidget::createBackground(size(), 0, this); - p.drawPixmap(rect(), m_background); -} - } // namespace Internal } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/kitmanagerconfigwidget.h b/src/plugins/projectexplorer/kitmanagerconfigwidget.h index 70e13398e36..e42aba1bd55 100644 --- a/src/plugins/projectexplorer/kitmanagerconfigwidget.h +++ b/src/plugins/projectexplorer/kitmanagerconfigwidget.h @@ -95,7 +95,6 @@ private: void showEvent(QShowEvent *event); QLabel *createLabel(const QString &name, const QString &toolTip); - void paintEvent(QPaintEvent *ev); QGridLayout *m_layout; QToolButton *m_iconButton; @@ -108,7 +107,6 @@ private: bool m_isDefaultKit; bool m_fixingKit; bool m_hasUniqueName; - QPixmap m_background; QList<QAction *> m_actions; mutable QString m_cachedDisplayName; }; diff --git a/src/plugins/projectexplorer/kitmodel.cpp b/src/plugins/projectexplorer/kitmodel.cpp index 489da8c6ea8..fd24304194e 100644 --- a/src/plugins/projectexplorer/kitmodel.cpp +++ b/src/plugins/projectexplorer/kitmodel.cpp @@ -118,7 +118,7 @@ KitModel::KitModel(QBoxLayout *parentLayout, QObject *parent) : rootItem()->appendChild(m_autoRoot); rootItem()->appendChild(m_manualRoot); - foreach (Kit *k, KitManager::sortedKits()) + foreach (Kit *k, KitManager::sortKits(KitManager::kits())) addKit(k); changeDefaultKit(); @@ -143,14 +143,14 @@ Kit *KitModel::kit(const QModelIndex &index) KitNode *KitModel::kitNode(const QModelIndex &index) { - TreeItem *n = itemFromIndex(index); + TreeItem *n = itemForIndex(index); return n && n->level() == 2 ? static_cast<KitNode *>(n) : 0; } QModelIndex KitModel::indexOf(Kit *k) const { KitNode *n = findWorkingCopy(k); - return n ? indexFromItem(n) : QModelIndex(); + return n ? indexForItem(n) : QModelIndex(); } void KitModel::setDefaultKit(const QModelIndex &index) @@ -191,9 +191,9 @@ void KitModel::isAutoDetectedChanged() } if (oldParent && oldParent != newParent) { - beginMoveRows(indexFromItem(oldParent), idx, idx, indexFromItem(newParent), newParent->children().size()); - TreeItem *n = oldParent->children().at(idx); - removeItem(n); + beginMoveRows(indexForItem(oldParent), idx, idx, indexForItem(newParent), newParent->children().size()); + TreeItem *n = oldParent->childAt(idx); + takeItem(n); newParent->appendChild(n); endMoveRows(); } @@ -202,7 +202,7 @@ void KitModel::isAutoDetectedChanged() void KitModel::validateKitNames() { QHash<QString, int> nameHash; - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { const QString displayName = n->widget->displayName(); if (nameHash.contains(displayName)) ++nameHash[displayName]; @@ -210,7 +210,7 @@ void KitModel::validateKitNames() nameHash.insert(displayName, 1); } - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { const QString displayName = n->widget->displayName(); n->widget->setHasUniqueName(nameHash.value(displayName) == 1); } @@ -223,7 +223,7 @@ void KitModel::apply() n->widget->removeKit(); // Update kits: - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { if (n->widget->isDirty()) { n->widget->apply(); n->update(); @@ -249,7 +249,7 @@ void KitModel::markForRemoval(Kit *k) if (node == m_defaultNode) setDefaultNode(findItemAtLevel<KitNode *>(2, [node](KitNode *kn) { return kn != node; })); - removeItem(node); + takeItem(node); if (node->widget->configures(0)) delete node; else @@ -279,7 +279,7 @@ Kit *KitModel::markForAddition(Kit *baseKit) KitNode *KitModel::findWorkingCopy(Kit *k) const { - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { if (n->widget->workingCopy() == k) return n; } @@ -349,7 +349,7 @@ void KitModel::removeKit(Kit *k) } KitNode *node = 0; - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { if (n->widget->configures(k)) { node = n; break; @@ -359,7 +359,7 @@ void KitModel::removeKit(Kit *k) if (node == m_defaultNode) setDefaultNode(findItemAtLevel<KitNode *>(2, [node](KitNode *kn) { return kn != node; })); - removeItem(node); + takeItem(node); delete node; validateKitNames(); @@ -369,7 +369,7 @@ void KitModel::removeKit(Kit *k) void KitModel::changeDefaultKit() { Kit *defaultKit = KitManager::defaultKit(); - foreach (KitNode *n, treeLevelItems<KitNode *>(2)) { + foreach (KitNode *n, itemsAtLevel<KitNode *>(2)) { if (n->widget->configures(defaultKit)) { setDefaultNode(n); return; diff --git a/src/plugins/projectexplorer/ldparser.cpp b/src/plugins/projectexplorer/ldparser.cpp index 696583c47e4..ea3eb618ffd 100644 --- a/src/plugins/projectexplorer/ldparser.cpp +++ b/src/plugins/projectexplorer/ldparser.cpp @@ -71,11 +71,12 @@ void LdParser::stdError(const QString &line) } if (lne.startsWith(QLatin1String("collect2:"))) { - emit addTask(Task(Task::Error, - lne /* description */, - Utils::FileName() /* filename */, - -1 /* linenumber */, - Constants::TASK_CATEGORY_COMPILE)); + Task task = Task(Task::Error, + lne /* description */, + Utils::FileName() /* filename */, + -1 /* linenumber */, + Constants::TASK_CATEGORY_COMPILE); + emit addTask(task, 1); return; } @@ -85,7 +86,7 @@ void LdParser::stdError(const QString &line) Task task(Task::Warning, description, Utils::FileName(), -1, Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } @@ -101,7 +102,7 @@ void LdParser::stdError(const QString &line) } Task task(type, description, Utils::FileName() /* filename */, -1 /* line */, Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } @@ -131,7 +132,7 @@ void LdParser::stdError(const QString &line) description = description.mid(9); } Task task(type, description, filename, lineno, Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } diff --git a/src/plugins/projectexplorer/linuxiccparser.cpp b/src/plugins/projectexplorer/linuxiccparser.cpp index 640ea0cdae3..55d3748072a 100644 --- a/src/plugins/projectexplorer/linuxiccparser.cpp +++ b/src/plugins/projectexplorer/linuxiccparser.cpp @@ -90,6 +90,7 @@ void LinuxIccParser::stdError(const QString &line) m_firstLine.cap(2).toInt(), Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; m_expectFirstLine = false; } else if (!m_expectFirstLine && m_caretLine.indexIn(line) != -1) { // Format the last line as code @@ -106,7 +107,7 @@ void LinuxIccParser::stdError(const QString &line) m_temporary.formats.append(fr2); } else if (!m_expectFirstLine && line.trimmed().isEmpty()) { // last Line m_expectFirstLine = true; - emit addTask(m_temporary); + emit addTask(m_temporary, m_lines); m_temporary = Task(); } else if (!m_expectFirstLine && m_continuationLines.indexIn(line) != -1) { m_temporary.description.append(QLatin1Char('\n')); @@ -114,6 +115,7 @@ void LinuxIccParser::stdError(const QString &line) while (m_indent < line.length() && line.at(m_indent).isSpace()) m_indent++; m_temporary.description.append(m_continuationLines.cap(1).trimmed()); + ++m_lines; } else { IOutputParser::stdError(line); } @@ -125,7 +127,7 @@ void LinuxIccParser::doFlush() return; Task t = m_temporary; m_temporary.clear(); - emit addTask(t); + emit addTask(t, m_lines, 1); } #ifdef WITH_TESTS diff --git a/src/plugins/projectexplorer/linuxiccparser.h b/src/plugins/projectexplorer/linuxiccparser.h index 1414ac38ec1..f160f02e790 100644 --- a/src/plugins/projectexplorer/linuxiccparser.h +++ b/src/plugins/projectexplorer/linuxiccparser.h @@ -58,6 +58,7 @@ private: bool m_expectFirstLine; int m_indent; Task m_temporary; + int m_lines = 0; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/miniprojecttargetselector.cpp b/src/plugins/projectexplorer/miniprojecttargetselector.cpp index 103cd765fd5..62ebc738f17 100644 --- a/src/plugins/projectexplorer/miniprojecttargetselector.cpp +++ b/src/plugins/projectexplorer/miniprojecttargetselector.cpp @@ -60,6 +60,7 @@ #include <QStatusBar> #include <QKeyEvent> #include <QPainter> +#include <QStyleFactory> #include <QAction> #include <QItemDelegate> @@ -549,6 +550,14 @@ KitAreaWidget::KitAreaWidget(QWidget *parent) : QWidget(parent), m_layout(new QGridLayout(this)), m_kit(0) { m_layout->setMargin(3); + setAutoFillBackground(true); + connect(KitManager::instance(), &KitManager::kitUpdated, this, &KitAreaWidget::updateKit); + + QPalette p = palette(); + p.setColor(QPalette::Window, creatorTheme()->color(Theme::MiniProjectTargetSelectorSummaryBackgroundColor).name()); + p.setColor(QPalette::Button, creatorTheme()->color(Theme::MiniProjectTargetSelectorSummaryBackgroundColor).name()); + p.setColor(QPalette::ButtonText, creatorTheme()->color(Theme::MiniProjectTargetSelectorTextColor).name()); + setPalette(p); } KitAreaWidget::~KitAreaWidget() @@ -558,21 +567,17 @@ KitAreaWidget::~KitAreaWidget() void KitAreaWidget::setKit(Kit *k) { - if (k == m_kit) - return; - foreach (KitConfigWidget *w, m_widgets) delete(w); m_widgets.clear(); + + if (!k) + return; + foreach (QLabel *l, m_labels) l->deleteLater(); m_labels.clear(); - if (m_kit) { - disconnect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)), - this, SLOT(updateKit(ProjectExplorer::Kit*))); - } - int row = 0; foreach (KitInformation *ki, KitManager::kitInformation()) { if (k && k->isMutable(ki->id())) { @@ -582,17 +587,15 @@ void KitAreaWidget::setKit(Kit *k) m_labels << label; m_layout->addWidget(label, row, 0); - m_layout->addWidget(widget->mainWidget(), row, 1); + QWidget *mainWidget = widget->mainWidget(); + // force fusion style as native style has rendering issues on windows: + mainWidget->setStyle(QStyleFactory::create(QLatin1String("fusion"))); + m_layout->addWidget(mainWidget, row, 1); ++row; } } m_kit = k; - if (m_kit) { - connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)), - this, SLOT(updateKit(ProjectExplorer::Kit*))); - } - setHidden(m_widgets.isEmpty()); } @@ -1487,7 +1490,7 @@ void MiniProjectTargetSelector::mousePressEvent(QMouseEvent *e) void MiniProjectTargetSelector::updateActionAndSummary() { - QString projectName; + QString projectName = QLatin1String(" "); QString fileName; // contains the path if projectName is not unique QString targetName; QString targetToolTipText; diff --git a/src/plugins/projectexplorer/msvcparser.cpp b/src/plugins/projectexplorer/msvcparser.cpp index f088ce86afb..1a6ccf2cd24 100644 --- a/src/plugins/projectexplorer/msvcparser.cpp +++ b/src/plugins/projectexplorer/msvcparser.cpp @@ -30,6 +30,7 @@ #include "msvcparser.h" #include "projectexplorerconstants.h" +#include "buildmanager.h" #include <utils/qtcassert.h> #include <utils/fileutils.h> @@ -101,6 +102,7 @@ void MsvcParser::stdOutput(const QString &line) } else { m_lastTask.formats[0].length = m_lastTask.description.length() - m_lastTask.formats[0].start; } + ++m_lines; return; } @@ -112,6 +114,7 @@ void MsvcParser::stdOutput(const QString &line) Utils::FileName(), /* fileName */ -1, /* linenumber */ Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; return; } if (line.startsWith(QLatin1String("Warning:"))) { @@ -120,6 +123,7 @@ void MsvcParser::stdOutput(const QString &line) Utils::FileName(), /* fileName */ -1, /* linenumber */ Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; return; } if (match.hasMatch()) { @@ -131,6 +135,7 @@ void MsvcParser::stdOutput(const QString &line) Utils::FileName::fromUserInput(match.captured(2)), /* fileName */ match.captured(3).toInt(), /* linenumber */ Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; return; } IOutputParser::stdOutput(line); @@ -147,6 +152,7 @@ void MsvcParser::stdError(const QString &line) Utils::FileName(), /* fileName */ -1, /* linenumber */ Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; return; } IOutputParser::stdError(line); @@ -168,6 +174,7 @@ bool MsvcParser::processCompileLine(const QString &line) m_lastTask = Task(type, match.captured(4).trimmed() /* description */, position.first, position.second, Constants::TASK_CATEGORY_COMPILE); + m_lines = 1; return true; } return false; @@ -180,7 +187,7 @@ void MsvcParser::doFlush() Task t = m_lastTask; m_lastTask.clear(); - emit addTask(t); + emit addTask(t, m_lines, 1); } // Unit tests: diff --git a/src/plugins/projectexplorer/msvcparser.h b/src/plugins/projectexplorer/msvcparser.h index a00e1bf0975..34795e45d68 100644 --- a/src/plugins/projectexplorer/msvcparser.h +++ b/src/plugins/projectexplorer/msvcparser.h @@ -57,6 +57,7 @@ private: QRegularExpression m_additionalInfoRegExp; Task m_lastTask; + int m_lines = 0; }; } // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/nodesvisitor.cpp b/src/plugins/projectexplorer/nodesvisitor.cpp index a950eebdddb..076953028b3 100644 --- a/src/plugins/projectexplorer/nodesvisitor.cpp +++ b/src/plugins/projectexplorer/nodesvisitor.cpp @@ -128,3 +128,7 @@ void FindAllFilesVisitor::visitFolderNode(FolderNode *folderNode) foreach (const FileNode *fileNode, folderNode->fileNodes()) m_filePaths.append(fileNode->path()); } + +NodesVisitor::~NodesVisitor() +{ +} diff --git a/src/plugins/projectexplorer/nodesvisitor.h b/src/plugins/projectexplorer/nodesvisitor.h index 570b3b4d5a2..98f5d53beab 100644 --- a/src/plugins/projectexplorer/nodesvisitor.h +++ b/src/plugins/projectexplorer/nodesvisitor.h @@ -45,9 +45,9 @@ class SessionNode; class ProjectNode; class FolderNode; -class NodesVisitor { +class PROJECTEXPLORER_EXPORT NodesVisitor { public: - virtual ~NodesVisitor() {} + virtual ~NodesVisitor(); virtual void visitSessionNode(SessionNode *) {} virtual void visitProjectNode(ProjectNode *) {} diff --git a/src/plugins/projectexplorer/osparser.cpp b/src/plugins/projectexplorer/osparser.cpp index 9cfbaf0f574..87be284b523 100644 --- a/src/plugins/projectexplorer/osparser.cpp +++ b/src/plugins/projectexplorer/osparser.cpp @@ -44,6 +44,12 @@ OsParser::OsParser() : void OsParser::stdError(const QString &line) { + if (Utils::HostOsInfo::isLinuxHost()) { + const QString trimmed = line.trimmed(); + if (trimmed.contains(QLatin1String(": error while loading shared libraries:"))) { + addTask(Task(Task::Error, trimmed, Utils::FileName(), -1, Constants::TASK_CATEGORY_COMPILE)); + } + } IOutputParser::stdError(line); } diff --git a/src/plugins/projectexplorer/outputparser_test.cpp b/src/plugins/projectexplorer/outputparser_test.cpp index f29e95f4e47..0ac1b3182d4 100644 --- a/src/plugins/projectexplorer/outputparser_test.cpp +++ b/src/plugins/projectexplorer/outputparser_test.cpp @@ -151,8 +151,10 @@ void OutputParserTester::outputAdded(const QString &line, BuildStep::OutputForma m_receivedOutput.append(line); } -void OutputParserTester::taskAdded(const Task &task) +void OutputParserTester::taskAdded(const Task &task, int linkedLines, int skipLines) { + Q_UNUSED(linkedLines); + Q_UNUSED(skipLines); m_receivedTasks.append(task); } diff --git a/src/plugins/projectexplorer/outputparser_test.h b/src/plugins/projectexplorer/outputparser_test.h index 69d042c4dc4..ffd57e0fb6e 100644 --- a/src/plugins/projectexplorer/outputparser_test.h +++ b/src/plugins/projectexplorer/outputparser_test.h @@ -75,7 +75,7 @@ signals: private slots: void outputAdded(const QString &string, ProjectExplorer::BuildStep::OutputFormat format); - void taskAdded(const ProjectExplorer::Task &task); + void taskAdded(const ProjectExplorer::Task &task, int linkedLines, int skipLines); private: void reset(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index f4512647b61..18e3e63cfea 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -284,7 +284,6 @@ public: void slotUpdateRunActions(); void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode); - void loadCustomWizards(); void updateWelcomePage(); @@ -490,8 +489,12 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new TaskHub); - connect(ICore::instance(), &ICore::newItemsDialogRequested, - dd, &ProjectExplorerPluginPrivate::loadCustomWizards); + IWizardFactory::registerFactoryCreator([]() -> QList<IWizardFactory *> { + QList<IWizardFactory *> result; + result << CustomWizard::createWizards(); + result << JsonWizardFactory::createWizardFactories(); + return result; + }); dd->m_welcomePage = new ProjectWelcomePage; connect(dd->m_welcomePage, &ProjectWelcomePage::manageSessions, @@ -528,7 +531,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new CustomWizardMetaFactory<CustomProjectWizard>(IWizardFactory::ProjectWizard)); addAutoReleasedObject(new CustomWizardMetaFactory<CustomWizard>(IWizardFactory::FileWizard)); - addAutoReleasedObject(new CustomWizardMetaFactory<CustomWizard>(IWizardFactory::ClassWizard)); // For JsonWizard: JsonWizardFactory::registerPageFactory(new FieldPageFactory); @@ -538,6 +540,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er JsonWizardFactory::registerPageFactory(new SummaryPageFactory); JsonWizardFactory::registerGeneratorFactory(new FileGeneratorFactory); + JsonWizardFactory::registerGeneratorFactory(new ScannerGeneratorFactory); dd->m_proWindow = new ProjectWindow; addAutoReleasedObject(dd->m_proWindow); @@ -1504,20 +1507,6 @@ void ProjectExplorerPlugin::extensionsInitialized() dd->m_kitManager->restoreKits(); } -void ProjectExplorerPluginPrivate::loadCustomWizards() -{ - // Add custom wizards, for which other plugins might have registered - // class factories - static bool firstTime = true; - if (firstTime) { - firstTime = false; - foreach (IWizardFactory *cpw, CustomWizard::createWizards()) - m_instance->addAutoReleasedObject(cpw); - foreach (IWizardFactory *cpw, JsonWizardFactory::createWizardFactories()) - m_instance->addAutoReleasedObject(cpw); - } -} - void ProjectExplorerPluginPrivate::updateRunWithoutDeployMenu() { m_runWithoutDeployAction->setVisible(m_projectExplorerSettings.deployBeforeRun); @@ -1902,7 +1891,7 @@ void ProjectExplorerPluginPrivate::loadSession(const QString &session) void ProjectExplorerPlugin::restoreSession2() { QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineNumbers | ICore::SwitchMode)); + ICore::openFiles(dd->m_arguments, ICore::OpenFilesFlags(ICore::CanContainLineAndColumnNumbers | ICore::SwitchMode)); } void ProjectExplorerPluginPrivate::buildStateChanged(Project * pro) @@ -2994,8 +2983,7 @@ void ProjectExplorerPluginPrivate::addNewFile() map.insert(QLatin1String(Constants::PROJECT_KIT_IDS), QVariant::fromValue(profileIds)); } ICore::showNewItemDialog(tr("New File", "Title of dialog"), - IWizardFactory::wizardFactoriesOfKind(IWizardFactory::FileWizard) - + IWizardFactory::wizardFactoriesOfKind(IWizardFactory::ClassWizard), + IWizardFactory::wizardFactoriesOfKind(IWizardFactory::FileWizard), location, map); } diff --git a/src/plugins/projectexplorer/projectexplorer.pro b/src/plugins/projectexplorer/projectexplorer.pro index e0c9ca9b9e5..399980d683e 100644 --- a/src/plugins/projectexplorer/projectexplorer.pro +++ b/src/plugins/projectexplorer/projectexplorer.pro @@ -1,4 +1,4 @@ -QT += quick script xml +QT += quick qml include(../../qtcreatorplugin.pri) include(customwizard/customwizard.pri) @@ -99,6 +99,7 @@ HEADERS += projectexplorer.h \ buildenvironmentwidget.h \ ldparser.h \ linuxiccparser.h \ + runconfigurationaspects.h \ runconfigurationmodel.h \ buildconfigurationmodel.h \ processparameters.h \ @@ -152,7 +153,8 @@ HEADERS += projectexplorer.h \ panelswidget.h \ projectwelcomepage.h \ projectpanelfactory.h \ - projecttree.h + projecttree.h \ + expanddata.h SOURCES += projectexplorer.cpp \ abi.cpp \ @@ -244,6 +246,7 @@ SOURCES += projectexplorer.cpp \ buildenvironmentwidget.cpp \ ldparser.cpp \ linuxiccparser.cpp \ + runconfigurationaspects.cpp \ runconfigurationmodel.cpp \ buildconfigurationmodel.cpp \ taskhub.cpp \ @@ -290,7 +293,8 @@ SOURCES += projectexplorer.cpp \ panelswidget.cpp \ projectwelcomepage.cpp \ projectpanelfactory.cpp \ - projecttree.cpp + projecttree.cpp \ + expanddata.cpp FORMS += processstep.ui \ editorsettingspropertiespage.ui \ diff --git a/src/plugins/projectexplorer/projectexplorer.qbs b/src/plugins/projectexplorer/projectexplorer.qbs index 1b328792c43..ebba8f707b7 100644 --- a/src/plugins/projectexplorer/projectexplorer.qbs +++ b/src/plugins/projectexplorer/projectexplorer.qbs @@ -3,7 +3,7 @@ import qbs 1.0 QtcPlugin { name: "ProjectExplorer" - Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "script"] } + Depends { name: "Qt"; submodules: ["widgets", "xml", "network", "qml"] } Depends { name: "Qt.quick" } Depends { name: "Aggregation" } Depends { name: "QtcSsh" } @@ -70,6 +70,7 @@ QtcPlugin { "environmentaspectwidget.cpp", "environmentaspectwidget.h", "environmentitemswidget.cpp", "environmentitemswidget.h", "environmentwidget.cpp", "environmentwidget.h", + "expanddata.cpp", "expanddata.h", "foldernavigationwidget.cpp", "foldernavigationwidget.h", "gccparser.cpp", "gccparser.h", "gcctoolchain.cpp", "gcctoolchain.h", @@ -127,6 +128,7 @@ QtcPlugin { "propertiespanel.cpp", "propertiespanel.h", "removetaskhandler.cpp", "removetaskhandler.h", "runconfiguration.cpp", "runconfiguration.h", + "runconfigurationaspects.cpp", "runconfigurationaspects.h", "runconfigurationmodel.cpp", "runconfigurationmodel.h", "runsettingspropertiespage.cpp", "runsettingspropertiespage.h", "selectablefilesmodel.cpp", "selectablefilesmodel.h", @@ -177,7 +179,8 @@ QtcPlugin { "jsonwizardfilegenerator.cpp", "jsonwizardfilegenerator.h", "jsonwizardgeneratorfactory.cpp", "jsonwizardgeneratorfactory.h", "jsonwizardpagefactory.cpp", "jsonwizardpagefactory.h", - "jsonwizardpagefactory_p.cpp", "jsonwizardpagefactory_p.h" + "jsonwizardpagefactory_p.cpp", "jsonwizardpagefactory_p.h", + "jsonwizardscannergenerator.cpp", "jsonwizardscannergenerator.h" ] } @@ -230,7 +233,6 @@ QtcPlugin { files: [ "BuildSettings.png", "CodeStyleSettings.png", - "Desktop.png", "DeviceConnected.png", "DeviceDisconnected.png", "DeviceReadyToUse.png", diff --git a/src/plugins/projectexplorer/projectexplorer.qrc b/src/plugins/projectexplorer/projectexplorer.qrc index faa38fd3abe..4fd236b7cd5 100644 --- a/src/plugins/projectexplorer/projectexplorer.qrc +++ b/src/plugins/projectexplorer/projectexplorer.qrc @@ -43,6 +43,8 @@ <file>images/stop_small.png</file> <file>images/disabledbuildstep.png</file> <file>images/disabledbuildstep@2x.png</file> + <file>images/lightdisabledbuildstep.png</file> + <file>images/lightdisabledbuildstep@2x.png</file> <file>images/unconfigured.png</file> <file>images/targetleftbutton.png</file> <file>images/targetrightbutton.png</file> diff --git a/src/plugins/projectexplorer/projectexplorerconstants.h b/src/plugins/projectexplorer/projectexplorerconstants.h index 562713dddf6..37a346332ca 100644 --- a/src/plugins/projectexplorer/projectexplorerconstants.h +++ b/src/plugins/projectexplorer/projectexplorerconstants.h @@ -194,6 +194,10 @@ const char TASK_CATEGORY_COMPILE[] = "Task.Category.Compile"; const char TASK_CATEGORY_BUILDSYSTEM[] = "Task.Category.Buildsystem"; const char TASK_CATEGORY_DEPLOYMENT[] = "Task.Category.Deploy"; +// Task mark categories +const char TASK_MARK_WARNING[] = "Task.Mark.Warning"; +const char TASK_MARK_ERROR[] = "Task.Mark.Error"; + // Wizard categories const char QT_PROJECT_WIZARD_CATEGORY[] = "H.Project"; const char QT_PROJECT_WIZARD_CATEGORY_DISPLAY[] = QT_TRANSLATE_NOOP("ProjectExplorer", "Other Project"); diff --git a/src/plugins/projectexplorer/projecttree.cpp b/src/plugins/projectexplorer/projecttree.cpp index 47bbca77c60..691b616b0eb 100644 --- a/src/plugins/projectexplorer/projecttree.cpp +++ b/src/plugins/projectexplorer/projecttree.cpp @@ -81,11 +81,11 @@ ProjectTree::ProjectTree(QObject *parent) this, &ProjectTree::focusChanged); connect(SessionManager::instance(), &SessionManager::projectAdded, - this, &ProjectTree::updateDefaultLocationForNewFiles); + this, &ProjectTree::sessionChanged); connect(SessionManager::instance(), &SessionManager::projectRemoved, - this, &ProjectTree::updateDefaultLocationForNewFiles); + this, &ProjectTree::sessionChanged); connect(SessionManager::instance(), &SessionManager::startupProjectChanged, - this, &ProjectTree::updateDefaultLocationForNewFiles); + this, &ProjectTree::sessionChanged); } void ProjectTree::aboutToShutDown() @@ -193,7 +193,11 @@ void ProjectTree::updateFromDocumentManager(bool invalidCurrentNode) void ProjectTree::updateFromNode(Node *node) { - Project *project = projectForNode(node); + Project *project; + if (node) + project = projectForNode(node); + else + project = SessionManager::startupProject(); update(node, project); foreach (ProjectTreeWidget *widget, m_projectTreeWidgets) @@ -236,12 +240,12 @@ void ProjectTree::update(Node *node, Project *project) if (changedProject) { emit currentProjectChanged(m_currentProject); - updateDefaultLocationForNewFiles(); + sessionChanged(); updateContext(); } } -void ProjectTree::updateDefaultLocationForNewFiles() +void ProjectTree::sessionChanged() { if (m_currentProject) Core::DocumentManager::setDefaultLocationForNewFiles(m_currentProject->projectDirectory().toString()); @@ -249,6 +253,7 @@ void ProjectTree::updateDefaultLocationForNewFiles() Core::DocumentManager::setDefaultLocationForNewFiles(SessionManager::startupProject()->projectDirectory().toString()); else Core::DocumentManager::setDefaultLocationForNewFiles(QString()); + updateFromFocus(); } void ProjectTree::updateContext() diff --git a/src/plugins/projectexplorer/projecttree.h b/src/plugins/projectexplorer/projecttree.h index 3f28618a0fc..5f74f157188 100644 --- a/src/plugins/projectexplorer/projecttree.h +++ b/src/plugins/projectexplorer/projecttree.h @@ -130,7 +130,7 @@ public: // for nodes to emit signals, do not call unless you are a node void collapseAll(); private: - void updateDefaultLocationForNewFiles(); + void sessionChanged(); void focusChanged(); void updateFromProjectTreeWidget(Internal::ProjectTreeWidget *widget); void documentManagerCurrentFileChanged(); diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 656fe9b5d88..b39e98ea92b 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -218,10 +218,14 @@ int ProjectTreeWidget::expandedCount(Node *node) void ProjectTreeWidget::rowsInserted(const QModelIndex &parent, int start, int end) { - const QString path = m_model->nodeForIndex(parent)->path().toString(); - if (m_toExpand.contains(path)) { + Node *node = m_model->nodeForIndex(parent); + const QString path = node->path().toString(); + const QString displayName = node->displayName(); + + auto it = m_toExpand.find(ExpandData(path, displayName)); + if (it != m_toExpand.end()) { m_view->expand(parent); - m_toExpand.remove(path); + m_toExpand.erase(it); } int i = start; while (i <= end) { @@ -272,19 +276,31 @@ void ProjectTreeWidget::disableAutoExpand() void ProjectTreeWidget::loadExpandData() { m_autoExpand = true; - QSet<QString> data = SessionManager::value(QLatin1String("ProjectTree.ExpandData")).toStringList().toSet(); - recursiveLoadExpandData(m_view->rootIndex(), data); + QList<QVariant> data = SessionManager::value(QLatin1String("ProjectTree.ExpandData")).value<QList<QVariant>>(); + QSet<ExpandData> set = Utils::transform<QSet>(data, [](const QVariant &v) { + QStringList list = v.toStringList(); + if (list.size() != 2) + return ExpandData(); + return ExpandData(list.at(0), list.at(1)); + }); + + set.remove(ExpandData()); + + recursiveLoadExpandData(m_view->rootIndex(), set); // store remaning nodes to expand - m_toExpand = data; + m_toExpand = set; } -void ProjectTreeWidget::recursiveLoadExpandData(const QModelIndex &index, QSet<QString> &data) +void ProjectTreeWidget::recursiveLoadExpandData(const QModelIndex &index, QSet<ExpandData> &data) { - const QString path = m_model->nodeForIndex(index)->path().toString(); - if (data.contains(path)) { + Node *node = m_model->nodeForIndex(index); + const QString path = node->path().toString(); + const QString displayName = node->displayName(); + auto it = data.find(ExpandData(path, displayName)); + if (it != data.end()) { m_view->expand(index); - data.remove(path); + data.erase(it); int count = m_model->rowCount(index); for (int i = 0; i < count; ++i) recursiveLoadExpandData(index.child(i, 0), data); @@ -293,19 +309,21 @@ void ProjectTreeWidget::recursiveLoadExpandData(const QModelIndex &index, QSet<Q void ProjectTreeWidget::saveExpandData() { - QStringList data; + QList<QVariant> data; recursiveSaveExpandData(m_view->rootIndex(), &data); // TODO if there are multiple ProjectTreeWidgets, the last one saves the data SessionManager::setValue(QLatin1String("ProjectTree.ExpandData"), data); } -void ProjectTreeWidget::recursiveSaveExpandData(const QModelIndex &index, QStringList *data) +void ProjectTreeWidget::recursiveSaveExpandData(const QModelIndex &index, QList<QVariant> *data) { Q_ASSERT(data); if (m_view->isExpanded(index) || index == m_view->rootIndex()) { - // Note: We store the path of the node, which isn't unique for e.g. .pri files + // Note: We store the path+displayname of the node, which isn't unique for e.g. .pri files // but works for most nodes - data->append(m_model->nodeForIndex(index)->path().toString()); + Node *node = m_model->nodeForIndex(index); + const QStringList &list = ExpandData(node->path().toString(), node->displayName()).toStringList(); + data->append(QVariant::fromValue(list)); int count = m_model->rowCount(index); for (int i = 0; i < count; ++i) recursiveSaveExpandData(index.child(i, 0), data); diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 8b2eba324b6..3ebca208e84 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -31,6 +31,8 @@ #ifndef PROJECTTREEWIDGET_H #define PROJECTTREEWIDGET_H +#include "expanddata.h" + #include <coreplugin/inavigationwidgetfactory.h> #include <utils/fileutils.h> @@ -92,13 +94,13 @@ private slots: private: void setCurrentItem(ProjectExplorer::Node *node); - void recursiveLoadExpandData(const QModelIndex &index, QSet<QString> &data); - void recursiveSaveExpandData(const QModelIndex &index, QStringList *data); + void recursiveLoadExpandData(const QModelIndex &index, QSet<ExpandData> &data); + void recursiveSaveExpandData(const QModelIndex &index, QList<QVariant> *data); static int expandedCount(Node *node); void rowsInserted(const QModelIndex &parent, int start, int end); void renamed(const Utils::FileName &oldPath, const Utils::FileName &newPath); - QSet<QString> m_toExpand; + QSet<ExpandData> m_toExpand; QTreeView *m_view; FlatModel *m_model; QAction *m_filterProjectsAction; diff --git a/src/plugins/projectexplorer/projectwizardpage.cpp b/src/plugins/projectexplorer/projectwizardpage.cpp index 464df95ce24..b2127f430ac 100644 --- a/src/plugins/projectexplorer/projectwizardpage.cpp +++ b/src/plugins/projectexplorer/projectwizardpage.cpp @@ -337,8 +337,10 @@ ProjectWizardPage::ProjectWizardPage(QWidget *parent) : ProjectWizardPage::~ProjectWizardPage() { - delete m_ui; + disconnect(m_ui->projectComboBox, SIGNAL(currentIndexChanged(int)), + this, SLOT(projectChanged(int))); delete m_model; + delete m_ui; } void ProjectWizardPage::setModel(TreeModel *model) @@ -383,7 +385,7 @@ bool ProjectWizardPage::expandTree(const QModelIndex &root) void ProjectWizardPage::setBestNode(AddNewTree *tree) { - QModelIndex index = tree ? m_model->indexFromItem(tree) : QModelIndex(); + QModelIndex index = tree ? m_model->indexForItem(tree) : QModelIndex(); m_ui->projectComboBox->setCurrentIndex(index); while (index.isValid()) { @@ -395,7 +397,7 @@ void ProjectWizardPage::setBestNode(AddNewTree *tree) FolderNode *ProjectWizardPage::currentNode() const { QModelIndex index = m_ui->projectComboBox->view()->currentIndex(); - TreeItem *item = m_model->itemFromIndex(index); + TreeItem *item = m_model->itemForIndex(index); return item ? static_cast<AddNewTree *>(item)->node() : 0; } diff --git a/src/plugins/projectexplorer/publishing/ipublishingwizardfactory.cpp b/src/plugins/projectexplorer/publishing/ipublishingwizardfactory.cpp deleted file mode 100644 index 4e40809bcc3..00000000000 --- a/src/plugins/projectexplorer/publishing/ipublishingwizardfactory.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#include <ipublishingwizardfactory.h> - - -/*! - \class ProjectExplorer::IPublishingWizardFactory - - \brief The IPublishingWizardFactory class provides an interface for creating - wizards to publish a project. - - A class implementing this interface is used to create an associated wizard - that allows users to publish their project to a remote facility, such as an - app store. - - Such a wizard would typically transform the project content into a format - expected by that facility (\e packaging) and also upload it, if possible. - - The factory objects have to be added to the global object pool via - \c ExtensionSystem::PluginManager::addObject(). - - \sa ExtensionSystem::PluginManager::addObject() -*/ - -/*! - \fn virtual QString displayName() const = 0 - - Describes on one line the type of wizard that this factory can create. -*/ - - /*! - \fn virtual QString description() const = 0 - - Explains the exact purpose of the wizard created by this factory. -*/ - -/*! - \fn virtual bool canCreateWizard(const Project *project) const = 0 - - Returns true if the type of wizard that this factory can create is available - for the specified \a project. -*/ - -/*! - \fn virtual QWizard *createWizard(const Project *project) const = 0 - - Creates a wizard that can publish \a project. Behavior is undefined if - canCreateWizard() returns \c false for the project. Returns the newly - created publishing wizard - - \sa canCreateWizard() -*/ diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 4d54fd40771..43890d3ad99 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -41,6 +41,10 @@ #include <QPointer> #include <QWidget> +QT_BEGIN_NAMESPACE +class QFormLayout; +QT_END_NAMESPACE + namespace Utils { class OutputFormatter; } namespace ProjectExplorer { diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp new file mode 100644 index 00000000000..b8a77facad3 --- /dev/null +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -0,0 +1,331 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "runconfigurationaspects.h" + +#include "project.h" +#include "runconfiguration.h" +#include "environmentaspect.h" + +#include <coreplugin/coreconstants.h> + +#include <utils/fancylineedit.h> +#include <utils/pathchooser.h> + +#include <QCheckBox> +#include <QLineEdit> +#include <QDebug> +#include <QFormLayout> +#include <QLabel> +#include <QToolButton> + +using namespace Utils; + +namespace ProjectExplorer { + +/*! + \class ProjectExplorer::TerminalAspect +*/ + +TerminalAspect::TerminalAspect(RunConfiguration *runConfig, const QString &key, bool useTerminal, bool userSet) + : IRunConfigurationAspect(runConfig), m_useTerminal(useTerminal), + m_userSet(userSet), m_checkBox(0), m_key(key) +{ + setDisplayName(tr("Terminal")); + setId("TerminalAspect"); +} + +TerminalAspect *TerminalAspect::create(RunConfiguration *runConfig) const +{ + return new TerminalAspect(runConfig, m_key, false, false); +} + +TerminalAspect *TerminalAspect::clone(RunConfiguration *runConfig) const +{ + return new TerminalAspect(runConfig, m_key, m_useTerminal, m_userSet); +} + +void TerminalAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout) +{ + QTC_CHECK(!m_checkBox); + m_checkBox = new QCheckBox(tr("Run in terminal"), parent); + m_checkBox->setChecked(m_useTerminal); + layout->addRow(QString(), m_checkBox); + connect(m_checkBox.data(), &QAbstractButton::clicked, this, [this] { + m_userSet = true; + m_useTerminal = m_checkBox->isChecked(); + emit useTerminalChanged(m_useTerminal); + }); +} + +void TerminalAspect::fromMap(const QVariantMap &map) +{ + if (map.contains(m_key)) { + m_useTerminal = map.value(m_key).toBool(); + m_userSet = true; + } else { + m_userSet = false; + } +} + +void TerminalAspect::toMap(QVariantMap &data) const +{ + if (m_userSet) + data.insert(m_key, m_useTerminal); +} + +bool TerminalAspect::useTerminal() const +{ + return m_useTerminal; +} + +void TerminalAspect::setUseTerminal(bool useTerminal) +{ + if (m_useTerminal != useTerminal) { + m_useTerminal = useTerminal; + emit useTerminalChanged(useTerminal); + } + if (m_checkBox) + m_checkBox->setChecked(m_useTerminal); +} + +bool TerminalAspect::isUserSet() const +{ + return m_userSet; +} + +ApplicationLauncher::Mode TerminalAspect::runMode() const +{ + return m_useTerminal ? ApplicationLauncher::Console : ApplicationLauncher::Gui; +} + +void TerminalAspect::setRunMode(ApplicationLauncher::Mode runMode) +{ + setUseTerminal(runMode == ApplicationLauncher::Console); +} + +/*! + \class ProjectExplorer::WorkingDirectoryAspect +*/ + +WorkingDirectoryAspect::WorkingDirectoryAspect(RunConfiguration *runConfig, const QString &key, const QString &dir) + : IRunConfigurationAspect(runConfig), m_workingDirectory(dir), m_chooser(0), m_key(key) +{ + setDisplayName(tr("Working Directory")); + setId("WorkingDirectoryAspect"); +} + +WorkingDirectoryAspect *WorkingDirectoryAspect::create(RunConfiguration *runConfig) const +{ + return new WorkingDirectoryAspect(runConfig, m_key); +} + +WorkingDirectoryAspect *WorkingDirectoryAspect::clone(RunConfiguration *runConfig) const +{ + return new WorkingDirectoryAspect(runConfig, m_key, m_workingDirectory); +} + +void WorkingDirectoryAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout) +{ + QTC_CHECK(!m_chooser); + m_chooser = new PathChooser(parent); + m_chooser->setHistoryCompleter(m_key); + m_chooser->setExpectedKind(Utils::PathChooser::Directory); + m_chooser->setPromptDialogTitle(tr("Select Working Directory")); + connect(m_chooser, &PathChooser::pathChanged, this, &WorkingDirectoryAspect::setWorkingDirectory); + + auto resetButton = new QToolButton(parent); + resetButton->setToolTip(tr("Reset to default")); + resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET))); + connect(resetButton, &QAbstractButton::clicked, this, [this] { m_chooser->setPath(QString()); }); + + if (auto envAspect = runConfiguration()->extraAspect<EnvironmentAspect>()) { + connect(envAspect, &EnvironmentAspect::environmentChanged, this, [this, envAspect] { + m_chooser->setEnvironment(envAspect->environment()); + }); + m_chooser->setEnvironment(envAspect->environment()); + } + + auto hbox = new QHBoxLayout; + hbox->addWidget(m_chooser); + hbox->addWidget(resetButton); + layout->addRow(tr("Working directory:"), hbox); +} + +void WorkingDirectoryAspect::fromMap(const QVariantMap &map) +{ + m_workingDirectory = map.value(m_key).toBool(); +} + +void WorkingDirectoryAspect::toMap(QVariantMap &data) const +{ + data.insert(m_key, m_workingDirectory); +} + +QString WorkingDirectoryAspect::workingDirectory() const +{ + return runConfiguration()->macroExpander()->expandProcessArgs(m_workingDirectory); +} + +QString WorkingDirectoryAspect::unexpandedWorkingDirectory() const +{ + return m_workingDirectory; +} + +void WorkingDirectoryAspect::setWorkingDirectory(const QString &workingDirectory) +{ + m_workingDirectory = workingDirectory; +} + + +/*! + \class ProjectExplorer::ArgumentsAspect +*/ + +ArgumentsAspect::ArgumentsAspect(RunConfiguration *runConfig, const QString &key, const QString &arguments) + : IRunConfigurationAspect(runConfig), m_arguments(arguments), m_chooser(0), m_key(key) +{ + setDisplayName(tr("Arguments")); + setId("ArgumentsAspect"); +} + +QString ArgumentsAspect::arguments() const +{ + return runConfiguration()->macroExpander()->expandProcessArgs(m_arguments); +} + +QString ArgumentsAspect::unexpandedArguments() const +{ + return m_arguments; +} + +void ArgumentsAspect::setArguments(const QString &arguments) +{ + if (arguments != m_arguments) { + m_arguments = arguments; + emit argumentsChanged(arguments); + } + if (m_chooser->text() != arguments) + m_chooser->setText(arguments); +} + +void ArgumentsAspect::fromMap(const QVariantMap &map) +{ + m_arguments = map.value(m_key).toString(); +} + +void ArgumentsAspect::toMap(QVariantMap &map) const +{ + map.insert(m_key, m_arguments); +} + +ArgumentsAspect *ArgumentsAspect::create(RunConfiguration *runConfig) const +{ + return new ArgumentsAspect(runConfig, m_key); +} + +ArgumentsAspect *ArgumentsAspect::clone(RunConfiguration *runConfig) const +{ + return new ArgumentsAspect(runConfig, m_key, m_arguments); +} + +void ArgumentsAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout) +{ + QTC_CHECK(!m_chooser); + m_chooser = new FancyLineEdit(parent); + m_chooser->setHistoryCompleter(m_key); + m_chooser->setText(m_arguments); + + connect(m_chooser.data(), &QLineEdit::textChanged, this, &ArgumentsAspect::setArguments); + + layout->addRow(tr("Command line arguments:"), m_chooser); +} + + +/*! + \class ProjectExplorer::ExecutableAspect +*/ + +ExecutableAspect::ExecutableAspect(RunConfiguration *runConfig, const QString &key, const QString &executable) + : IRunConfigurationAspect(runConfig), m_executable(executable), m_chooser(0), m_key(key) +{ + setDisplayName(tr("Executable")); + setId("ExecutableAspect"); +} + +QString ExecutableAspect::executable() const +{ + return runConfiguration()->macroExpander()->expandProcessArgs(m_executable); +} + +QString ExecutableAspect::unexpandedExecutable() const +{ + return m_executable; +} + +void ExecutableAspect::setExectuable(const QString &executable) +{ + m_executable = executable; + if (m_chooser) + m_chooser->setText(m_executable); +} + +void ExecutableAspect::fromMap(const QVariantMap &map) +{ + m_executable = map.value(m_key).toBool(); +} + +void ExecutableAspect::toMap(QVariantMap &map) const +{ + map.insert(m_key, m_executable); +} + +ExecutableAspect *ExecutableAspect::create(RunConfiguration *runConfig) const +{ + return new ExecutableAspect(runConfig, m_key); +} + +ExecutableAspect *ExecutableAspect::clone(RunConfiguration *runConfig) const +{ + return new ExecutableAspect(runConfig, m_key, m_executable); +} + +void ExecutableAspect::addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout) +{ + QTC_CHECK(!m_chooser); + m_chooser = new FancyLineEdit(parent); + m_chooser->setHistoryCompleter(m_key); + + connect(m_chooser, &QLineEdit::textChanged, this, &ExecutableAspect::setExectuable); + + layout->addRow(tr("Command line arguments:"), m_chooser); +} + +} // namespace ProjectExplorer diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h new file mode 100644 index 00000000000..a619fd3fb7b --- /dev/null +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -0,0 +1,166 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef RUNCONFIGURATION_ASPECTS_H +#define RUNCONFIGURATION_ASPECTS_H + +#include "runconfiguration.h" +#include "applicationlauncher.h" + +QT_BEGIN_NAMESPACE +class QCheckBox; +class QFormLayout; +class QLineEdit; +QT_END_NAMESPACE + +namespace Utils { +class FancyLineEdit; +class PathChooser; +} + +namespace ProjectExplorer { + +class PROJECTEXPLORER_EXPORT TerminalAspect : public IRunConfigurationAspect +{ + Q_OBJECT + +public: + explicit TerminalAspect(RunConfiguration *rc, const QString &key, bool useTerminal = false, bool userSet = false); + + TerminalAspect *create(RunConfiguration *runConfig) const override; + TerminalAspect *clone(RunConfiguration *runConfig) const override; + + void addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout); + + bool useTerminal() const; + void setUseTerminal(bool useTerminal); + + ApplicationLauncher::Mode runMode() const; + void setRunMode(ApplicationLauncher::Mode runMode); + + bool isUserSet() const; + +signals: + void useTerminalChanged(bool); + +private: + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + + bool m_useTerminal; + bool m_userSet; + QPointer<QCheckBox> m_checkBox; // Owned by RunConfigWidget + QString m_key; +}; + +class PROJECTEXPLORER_EXPORT WorkingDirectoryAspect : public IRunConfigurationAspect +{ + Q_OBJECT + +public: + explicit WorkingDirectoryAspect(RunConfiguration *runConfig, const QString &key, const QString &dir = QString()); + + WorkingDirectoryAspect *create(RunConfiguration *runConfig) const override; + WorkingDirectoryAspect *clone(RunConfiguration *runConfig) const override; + + void addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout); + + QString workingDirectory() const; + QString unexpandedWorkingDirectory() const; + void setWorkingDirectory(const QString &workingDirectory); + Utils::PathChooser *pathChooser() const { return m_chooser; } + +private: + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + + QString m_workingDirectory; + Utils::PathChooser *m_chooser; + QString m_key; +}; + +class PROJECTEXPLORER_EXPORT ArgumentsAspect : public IRunConfigurationAspect +{ + Q_OBJECT + +public: + explicit ArgumentsAspect(RunConfiguration *runConfig, const QString &key, const QString &arguments = QString()); + + ArgumentsAspect *create(RunConfiguration *runConfig) const override; + ArgumentsAspect *clone(RunConfiguration *runConfig) const override; + + void addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout); + + QString arguments() const; + QString unexpandedArguments() const; + + void setArguments(const QString &arguments); + +signals: + void argumentsChanged(const QString &arguments); + +private: + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + + QString m_arguments; + QPointer<Utils::FancyLineEdit> m_chooser; + QString m_key; +}; + +class PROJECTEXPLORER_EXPORT ExecutableAspect : public IRunConfigurationAspect +{ + Q_OBJECT + +public: + explicit ExecutableAspect(RunConfiguration *runConfig, const QString &key, const QString &executable = QString()); + + ExecutableAspect *create(RunConfiguration *runConfig) const override; + ExecutableAspect *clone(RunConfiguration *runConfig) const override; + + void addToMainConfigurationWidget(QWidget *parent, QFormLayout *layout); + + QString executable() const; + QString unexpandedExecutable() const; + + void setExectuable(const QString &executable); + +private: + void fromMap(const QVariantMap &map) override; + void toMap(QVariantMap &map) const override; + + QString m_executable; + Utils::FancyLineEdit *m_chooser; + QString m_key; +}; + +} // namespace ProjectExplorer + +#endif // RUNCONFIGURATION_ASPECTS_H diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index 74e9e8f0dc4..889ede52a7a 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -433,7 +433,7 @@ void SessionManager::closeAllProjects() removeProjects(projects()); } -const QList<Project *> &SessionManager::projects() +QList<Project *> SessionManager::projects() { return d->m_projects; } @@ -927,6 +927,8 @@ bool SessionManager::loadSession(const QString &session) d->m_values.clear(); d->m_sessionName = session; + delete d->m_writer; + d->m_writer = 0; EditorManager::updateWindowTitles(); if (fileName.exists()) { diff --git a/src/plugins/projectexplorer/session.h b/src/plugins/projectexplorer/session.h index 9f59f8c622b..06600557ed9 100644 --- a/src/plugins/projectexplorer/session.h +++ b/src/plugins/projectexplorer/session.h @@ -101,7 +101,7 @@ public: static Utils::FileName sessionNameToFileName(const QString &session); static Project *startupProject(); - static const QList<Project *> &projects(); + static QList<Project *> projects(); static bool hasProjects(); static bool isDefaultVirgin(); diff --git a/src/plugins/projectexplorer/settingsaccessor.cpp b/src/plugins/projectexplorer/settingsaccessor.cpp index 802e5c424a1..8702a8e6b40 100644 --- a/src/plugins/projectexplorer/settingsaccessor.cpp +++ b/src/plugins/projectexplorer/settingsaccessor.cpp @@ -990,9 +990,9 @@ QList<FileName> SettingsAccessor::settingsFiles(const QString &suffix) const if (!sharedUserFileDir().isEmpty()) { const QString sharedPath = sharedUserFileDir() + QLatin1Char('/') + makeRelative(pfi.absolutePath()); - list.append(QDir(sharedPath).entryInfoList(filter, QDir::Files)); + list.append(QDir(sharedPath).entryInfoList(filter, QDir::Files | QDir::Hidden | QDir::System)); } - list.append(QDir(pfi.dir()).entryInfoList(filter, QDir::Files)); + list.append(QDir(pfi.dir()).entryInfoList(filter, QDir::Files | QDir::Hidden | QDir::System)); foreach (const QFileInfo &fi, list) { const FileName path = FileName::fromString(fi.absoluteFilePath()); diff --git a/src/plugins/projectexplorer/targetsettingspanel.cpp b/src/plugins/projectexplorer/targetsettingspanel.cpp index 6a742292241..c32f79d7123 100644 --- a/src/plugins/projectexplorer/targetsettingspanel.cpp +++ b/src/plugins/projectexplorer/targetsettingspanel.cpp @@ -611,7 +611,7 @@ void TargetSettingsPanelWidget::updateTargetButtons() this, SLOT(duplicateActionTriggered(QAction*))); connect(removeAction, SIGNAL(triggered()), this, SLOT(removeTarget())); - foreach (Kit *k, KitManager::sortedKits()) { + foreach (Kit *k, KitManager::sortKits(KitManager::kits())) { if (m_project->target(k)) continue; createAction(k, m_addMenu); diff --git a/src/plugins/projectexplorer/targetsettingswidget.cpp b/src/plugins/projectexplorer/targetsettingswidget.cpp index 4dc7de6b5d6..e4c1cc76c2a 100644 --- a/src/plugins/projectexplorer/targetsettingswidget.cpp +++ b/src/plugins/projectexplorer/targetsettingswidget.cpp @@ -139,7 +139,10 @@ QString TargetSettingsWidget::targetNameAt(int index) const void TargetSettingsWidget::setCentralWidget(QWidget *widget) { - ui->scrollArea->setWidget(widget); + if (m_centralWidget) + ui->scrollAreaWidgetContents->layout()->removeWidget(m_centralWidget); + m_centralWidget = widget; + ui->scrollAreaWidgetContents->layout()->addWidget(m_centralWidget); } int TargetSettingsWidget::targetCount() const diff --git a/src/plugins/projectexplorer/targetsettingswidget.h b/src/plugins/projectexplorer/targetsettingswidget.h index 1e8bdbf0ad5..36d4265cf39 100644 --- a/src/plugins/projectexplorer/targetsettingswidget.h +++ b/src/plugins/projectexplorer/targetsettingswidget.h @@ -83,6 +83,7 @@ private: TargetSelector *m_targetSelector; QPushButton *m_addButton; QPushButton *m_manageButton; + QWidget *m_centralWidget = 0; }; } // namespace Internal diff --git a/src/plugins/projectexplorer/targetsettingswidget.ui b/src/plugins/projectexplorer/targetsettingswidget.ui index 028e3d647d7..d515dd9da9b 100644 --- a/src/plugins/projectexplorer/targetsettingswidget.ui +++ b/src/plugins/projectexplorer/targetsettingswidget.ui @@ -17,7 +17,16 @@ <property name="spacing"> <number>0</number> </property> - <property name="margin"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> <number>0</number> </property> <item> @@ -30,7 +39,7 @@ </property> </widget> </item> - <item> + <item> <widget class="QWidget" name="separator" native="true"> <property name="minimumSize"> <size> @@ -130,23 +139,24 @@ </widget> </item> <item> - <widget class="QScrollArea" name="scrollArea"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="widgetResizable"> - <bool>true</bool> - </property> - <widget class="QWidget" name="scrollAreaWidgetContents"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>618</width> - <height>424</height> - </rect> + <widget class="QWidget" name="scrollAreaWidgetContents" native="true"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <property name="spacing"> + <number>0</number> + </property> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> </property> - </widget> + </layout> </widget> </item> </layout> diff --git a/src/plugins/projectexplorer/targetsetuppage.cpp b/src/plugins/projectexplorer/targetsetuppage.cpp index f4195406b2e..1dbaa29f9af 100644 --- a/src/plugins/projectexplorer/targetsetuppage.cpp +++ b/src/plugins/projectexplorer/targetsetuppage.cpp @@ -265,6 +265,7 @@ void TargetSetupPage::setupWidgets() else kitList = KitManager::kits(); + kitList = KitManager::sortKits(kitList); foreach (Kit *k, kitList) addWidget(k); diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 59e205c618e..07ebff0c4e3 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -29,21 +29,36 @@ ****************************************************************************/ #include "taskhub.h" +#include "projectexplorerconstants.h" #include <coreplugin/coreconstants.h> #include <coreplugin/ioutputpane.h> #include <utils/qtcassert.h> +#include <utils/theme/theme.h> using namespace ProjectExplorer; TaskHub *m_instance = 0; QSet<Core::Id> TaskHub::m_registeredCategories; +static Core::Id categoryForType(Task::TaskType type) +{ + switch (type) { + case Task::Error: + return Constants::TASK_MARK_ERROR; + case Task::Warning: + return Constants::TASK_MARK_WARNING; + default: + return Core::Id(); + } +} + class TaskMark : public TextEditor::TextMark { public: - TaskMark(unsigned int id, const QString &fileName, int lineNumber, bool visible) - : TextMark(fileName, lineNumber), m_id(id) + TaskMark(unsigned int id, const QString &fileName, int lineNumber, Task::TaskType type, bool visible) + : TextMark(fileName, lineNumber, categoryForType(type)) + , m_id(id) { setVisible(visible); } @@ -92,6 +107,10 @@ TaskHub::TaskHub() m_instance = this; qRegisterMetaType<ProjectExplorer::Task>("ProjectExplorer::Task"); qRegisterMetaType<QList<ProjectExplorer::Task> >("QList<ProjectExplorer::Task>"); + TaskMark::setCategoryColor(Constants::TASK_MARK_ERROR, + Utils::Theme::ProjectExplorer_TaskError_TextMarkColor); + TaskMark::setCategoryColor(Constants::TASK_MARK_WARNING, + Utils::Theme::ProjectExplorer_TaskWarn_TextMarkColor); } TaskHub::~TaskHub() @@ -130,7 +149,8 @@ void TaskHub::addTask(Task task) task.movedLine = task.line; if (task.line != -1 && !task.file.isEmpty()) { - TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, !task.icon.isNull()); + TaskMark *mark = new TaskMark(task.taskId, task.file.toString(), task.line, + task.type, !task.icon.isNull()); mark->setIcon(task.icon); mark->setPriority(TextEditor::TextMark::LowPriority); task.addMark(mark); diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 07489dc7b2f..a7e34151254 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -32,6 +32,7 @@ #include "itaskhandler.h" #include "projectexplorerconstants.h" +#include "session.h" #include "task.h" #include "taskhub.h" #include "taskmodel.h" @@ -42,6 +43,7 @@ #include <coreplugin/icore.h> #include <coreplugin/icontext.h> #include <extensionsystem/pluginmanager.h> +#include <utils/algorithm.h> #include <utils/qtcassert.h> #include <utils/itemviews.h> @@ -54,6 +56,8 @@ namespace { const int ELLIPSIS_GRADIENT_WIDTH = 16; +const char SESSION_FILTER_CATEGORIES[] = "TaskWindow.Categories"; +const char SESSION_FILTER_WARNINGS[] = "TaskWindow.IncludeWarnings"; } namespace ProjectExplorer { @@ -272,7 +276,6 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate) d->m_categoriesMenu = new QMenu(d->m_categoriesButton); connect(d->m_categoriesMenu, SIGNAL(aboutToShow()), this, SLOT(updateCategoriesMenu())); - connect(d->m_categoriesMenu, SIGNAL(triggered(QAction*)), this, SLOT(filterCategoryTriggered(QAction*))); d->m_categoriesButton->setMenu(d->m_categoriesMenu); @@ -304,6 +307,10 @@ TaskWindow::TaskWindow() : d(new TaskWindowPrivate) [this]() { emit setBadgeNumber(d->m_filter->rowCount()); }); connect(d->m_filter, &TaskFilterModel::modelReset, [this]() { emit setBadgeNumber(d->m_filter->rowCount()); }); + + SessionManager *session = SessionManager::instance(); + connect(session, &SessionManager::aboutToSaveSession, this, &TaskWindow::saveSettings); + connect(session, &SessionManager::sessionLoaded, this, &TaskWindow::loadSettings); } TaskWindow::~TaskWindow() @@ -399,6 +406,30 @@ void TaskWindow::currentChanged(const QModelIndex &index) } } +void TaskWindow::saveSettings() +{ + QStringList categories = Utils::transform(d->m_filter->filteredCategories(), &Core::Id::toString); + SessionManager::setValue(QLatin1String(SESSION_FILTER_CATEGORIES), categories); + SessionManager::setValue(QLatin1String(SESSION_FILTER_WARNINGS), d->m_filter->filterIncludesWarnings()); +} + +void TaskWindow::loadSettings() +{ + QVariant value = SessionManager::value(QLatin1String(SESSION_FILTER_CATEGORIES)); + if (value.isValid()) { + QList<Core::Id> categories + = Utils::transform(value.toStringList(), &Core::Id::fromString); + d->m_filter->setFilteredCategories(categories); + } + value = SessionManager::value(QLatin1String(SESSION_FILTER_WARNINGS)); + if (value.isValid()) { + bool includeWarnings = value.toBool(); + d->m_filter->setFilterIncludesWarnings(includeWarnings); + d->m_filter->setFilterIncludesUnknowns(includeWarnings); + d->m_filterWarningsButton->setDown(d->m_filter->filterIncludesWarnings()); + } +} + void TaskWindow::visibilityChanged(bool visible) { if (visible) @@ -523,20 +554,14 @@ void TaskWindow::updateCategoriesMenu() QAction *action = new QAction(d->m_categoriesMenu); action->setCheckable(true); action->setText(displayName); - action->setData(categoryId.toSetting()); action->setChecked(!filteredCategories.contains(categoryId)); + connect(action, &QAction::triggered, this, [this, action, categoryId] { + setCategoryVisibility(categoryId, action->isChecked()); + }); d->m_categoriesMenu->addAction(action); } } -void TaskWindow::filterCategoryTriggered(QAction *action) -{ - Core::Id categoryId = Core::Id::fromSetting(action->data()); - QTC_CHECK(categoryId.uniqueIdentifier() != 0); - - setCategoryVisibility(categoryId, action->isChecked()); -} - int TaskWindow::taskCount(Core::Id category) const { return d->m_model->taskCount(category); diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 5db790d69c6..9b7b8b869b7 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -96,12 +96,13 @@ private slots: void clearTasks(Core::Id categoryId); void setCategoryVisibility(Core::Id categoryId, bool visible); void currentChanged(const QModelIndex &index); + void saveSettings(); + void loadSettings(); void triggerDefaultHandler(const QModelIndex &index); void actionTriggered(); void setShowWarnings(bool); void updateCategoriesMenu(); - void filterCategoryTriggered(QAction *action); private: int sizeHintForColumn(int column) const; diff --git a/src/plugins/projectexplorer/toolchainconfigwidget.cpp b/src/plugins/projectexplorer/toolchainconfigwidget.cpp index 65e1e13d091..362e463b5c8 100644 --- a/src/plugins/projectexplorer/toolchainconfigwidget.cpp +++ b/src/plugins/projectexplorer/toolchainconfigwidget.cpp @@ -31,6 +31,7 @@ #include "toolchainconfigwidget.h" #include "toolchain.h" +#include <utils/detailswidget.h> #include <utils/qtcassert.h> #include <QString> @@ -38,6 +39,8 @@ #include <QFormLayout> #include <QLineEdit> #include <QLabel> +#include <QScrollArea> +#include <QPainter> namespace ProjectExplorer { @@ -46,10 +49,26 @@ ToolChainConfigWidget::ToolChainConfigWidget(ToolChain *tc) : { Q_ASSERT(tc); - m_nameLineEdit = new QLineEdit(this); - m_mainLayout = new QFormLayout(this); - m_nameLineEdit->setText(tc->displayName()); + Utils::DetailsWidget *centralWidget = new Utils::DetailsWidget; + centralWidget->setState(Utils::DetailsWidget::NoSummary); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setFrameShape(QFrame::NoFrame); + setWidgetResizable(true); + setFocusPolicy(Qt::NoFocus); + + setWidget(centralWidget); + + QWidget *detailsBox = new QWidget(); + + m_mainLayout = new QFormLayout(detailsBox); + m_mainLayout->setContentsMargins(0, 0, 0, 0); + centralWidget->setWidget(detailsBox); m_mainLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); // for the Macs... + + m_nameLineEdit = new QLineEdit; + m_nameLineEdit->setText(tc->displayName()); + m_mainLayout->addRow(tr("Name:"), m_nameLineEdit); connect(m_nameLineEdit, SIGNAL(textChanged(QString)), SIGNAL(dirty())); diff --git a/src/plugins/projectexplorer/toolchainconfigwidget.h b/src/plugins/projectexplorer/toolchainconfigwidget.h index 13df6d3ae70..a1e5ba5b94c 100644 --- a/src/plugins/projectexplorer/toolchainconfigwidget.h +++ b/src/plugins/projectexplorer/toolchainconfigwidget.h @@ -33,7 +33,7 @@ #include "projectexplorer_export.h" -#include <QWidget> +#include <QScrollArea> QT_BEGIN_NAMESPACE class QFormLayout; @@ -50,7 +50,7 @@ class ToolChain; // ToolChainConfigWidget // -------------------------------------------------------------------------- -class PROJECTEXPLORER_EXPORT ToolChainConfigWidget : public QWidget +class PROJECTEXPLORER_EXPORT ToolChainConfigWidget : public QScrollArea { Q_OBJECT diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp index 45e59926df4..6482acebdb4 100644 --- a/src/plugins/projectexplorer/toolchainoptionspage.cpp +++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp @@ -219,7 +219,7 @@ public: void ToolChainOptionsWidget::markForRemoval(ToolChainTreeItem *item) { - m_model.removeItem(item); + m_model.takeItem(item); if (m_toAddList.contains(item)) { delete item->toolChain; item->toolChain = 0; @@ -257,9 +257,9 @@ void ToolChainOptionsWidget::removeToolChain(ToolChain *tc) } TreeItem *parent = m_model.rootItem()->child(tc->isAutoDetected() ? 0 : 1); - foreach (ToolChainTreeItem *item, m_model.treeLevelItems<ToolChainTreeItem *>(1, parent)) { + foreach (ToolChainTreeItem *item, m_model.itemsAtLevel<ToolChainTreeItem *>(1, parent)) { if (item->toolChain == tc) { - m_model.removeItem(item); + m_model.takeItem(item); delete item; break; } @@ -292,7 +292,7 @@ void ToolChainOptionsWidget::apply() Q_ASSERT(m_toRemoveList.isEmpty()); // Update tool chains: - foreach (ToolChainTreeItem *item, m_model.treeLevelItems<ToolChainTreeItem *>(1, m_manualRoot)) { + foreach (ToolChainTreeItem *item, m_model.itemsAtLevel<ToolChainTreeItem *>(1, m_manualRoot)) { if (item->changed) { Q_ASSERT(item->toolChain); if (item->widget) @@ -357,7 +357,7 @@ void ToolChainOptionsWidget::createToolChain(ToolChainFactory *factory) m_manualRoot->appendChild(item); - m_toolChainView->setCurrentIndex(m_model.indexFromItem(item)); + m_toolChainView->setCurrentIndex(m_model.indexForItem(item)); } void ToolChainOptionsWidget::updateState() @@ -377,7 +377,7 @@ void ToolChainOptionsWidget::updateState() ToolChainTreeItem *ToolChainOptionsWidget::currentTreeItem() { QModelIndex index = m_toolChainView->currentIndex(); - TreeItem *item = m_model.itemFromIndex(index); + TreeItem *item = m_model.itemForIndex(index); return item && item->level() == 2 ? static_cast<ToolChainTreeItem *>(item) : 0; } diff --git a/src/plugins/projectexplorer/xcodebuildparser.cpp b/src/plugins/projectexplorer/xcodebuildparser.cpp index 0f1fbe4a64d..1dd13d243cd 100644 --- a/src/plugins/projectexplorer/xcodebuildparser.cpp +++ b/src/plugins/projectexplorer/xcodebuildparser.cpp @@ -84,7 +84,7 @@ void XcodebuildParser::stdOutput(const QString &line) Utils::FileName::fromString(m_replacingSignatureRe.cap(1)), /* filename */ -1, /* line */ Constants::TASK_CATEGORY_COMPILE); - taskAdded(task); + taskAdded(task, 1); return; } IOutputParser::stdError(line); diff --git a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp index 9fb3877e21f..f4f369e392b 100644 --- a/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp +++ b/src/plugins/qbsprojectmanager/defaultpropertyprovider.cpp @@ -118,9 +118,7 @@ static QStringList targetOSList(const ProjectExplorer::Abi &abi, const ProjectEx os << QLatin1String("bsd") << QLatin1String("unix"); break; case ProjectExplorer::Abi::UnixOS: - if (device == QNX_BB_OS_TYPE) - os << QLatin1String("blackberry") << QLatin1String("qnx"); - else if (device == QNX_QNX_OS_TYPE) + if (device == QNX_QNX_OS_TYPE) os << QLatin1String("qnx"); else if (abi.osFlavor() == ProjectExplorer::Abi::SolarisUnixFlavor) os << QLatin1String("solaris"); diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp index 5c88e2a70b9..1c127971a07 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.cpp @@ -322,9 +322,10 @@ void QbsBuildStep::handleProcessResultReport(const qbs::ProcessResult &result) void QbsBuildStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line) { - emit addTask(ProjectExplorer::Task(type, message, - Utils::FileName::fromString(file), line, - ProjectExplorer::Constants::TASK_CATEGORY_COMPILE)); + ProjectExplorer::Task task = ProjectExplorer::Task(type, message, + Utils::FileName::fromString(file), line, + ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); + emit addTask(task, 1); emit addOutput(message, NormalOutput); } @@ -477,6 +478,11 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : m_ui = new Ui::QbsBuildStepConfigWidget; m_ui->setupUi(this); + m_ui->propertyEdit->setValidationFunction([this](Utils::FancyLineEdit *edit, + QString *errorMessage) { + return validateProperties(edit, errorMessage); + }); + connect(m_ui->buildVariantComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(changeBuildVariant(int))); connect(m_ui->dryRunCheckBox, SIGNAL(toggled(bool)), this, SLOT(changeDryRun(bool))); @@ -488,7 +494,6 @@ QbsBuildStepConfigWidget::QbsBuildStepConfigWidget(QbsBuildStep *step) : &QbsBuildStepConfigWidget::changeInstall); connect(m_ui->cleanInstallRootCheckBox, &QCheckBox::toggled, this, &QbsBuildStepConfigWidget::changeCleanInstallRoot); - connect(m_ui->propertyEdit, SIGNAL(propertiesChanged()), this, SLOT(changeProperties())); connect(m_ui->qmlDebuggingLibraryCheckBox, SIGNAL(toggled(bool)), this, SLOT(linkQmlDebuggingLibraryChecked(bool))); connect(QtSupport::QtVersionManager::instance(), SIGNAL(dumpUpdatedFor(Utils::FileName)), @@ -531,10 +536,9 @@ void QbsBuildStepConfigWidget::updateState() m_ui->buildVariantComboBox->setCurrentIndex(idx); QString command = QbsBuildConfiguration::equivalentCommandLine(m_step); - QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties(); - for (int i = 0; i < propertyList.count(); ++i) { - command += QLatin1Char(' ') + propertyList.at(i).first - + QLatin1Char(':') + propertyList.at(i).second; + for (int i = 0; i < m_propertyCache.count(); ++i) { + command += QLatin1Char(' ') + m_propertyCache.at(i).first + + QLatin1Char(':') + m_propertyCache.at(i).second; } if (m_step->isQmlDebuggingEnabled()) @@ -634,7 +638,7 @@ void QbsBuildStepConfigWidget::changeCleanInstallRoot(bool clean) m_ignoreChange = false; } -void QbsBuildStepConfigWidget::changeProperties() +void QbsBuildStepConfigWidget::applyCachedProperties() { QVariantMap data; QVariantMap tmp = m_step->qbsConfiguration(); @@ -651,9 +655,8 @@ void QbsBuildStepConfigWidget::changeProperties() data.insert(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY), tmp.value(QLatin1String(Constants::QBS_CONFIG_QUICK_DEBUG_KEY))); - QList<QPair<QString, QString> > propertyList = m_ui->propertyEdit->properties(); - for (int i = 0; i < propertyList.count(); ++i) - data.insert(propertyList.at(i).first, propertyList.at(i).second); + for (int i = 0; i < m_propertyCache.count(); ++i) + data.insert(m_propertyCache.at(i).first, m_propertyCache.at(i).second); m_ignoreChange = true; m_step->setQbsConfiguration(data); @@ -676,6 +679,40 @@ void QbsBuildStepConfigWidget::linkQmlDebuggingLibraryChecked(bool checked) m_ignoreChange = false; } +bool QbsBuildStepConfigWidget::validateProperties(Utils::FancyLineEdit *edit, QString *errorMessage) +{ + Utils::QtcProcess::SplitError err; + QStringList argList = Utils::QtcProcess::splitArgs(edit->text(), Utils::HostOsInfo::hostOs(), + false, &err); + if (err != Utils::QtcProcess::SplitOk) { + if (errorMessage) + *errorMessage = tr("Could not split properties."); + return false; + } + + QList<QPair<QString, QString> > properties; + foreach (const QString &arg, argList) { + int pos = arg.indexOf(QLatin1Char(':')); + QString key; + QString value; + if (pos > 0) { + key = arg.left(pos); + value = arg.mid(pos + 1); + properties.append(qMakePair(key, value)); + } else { + if (errorMessage) + *errorMessage = tr("No ':' found in property definition."); + return false; + } + } + + if (m_propertyCache != properties) { + m_propertyCache = properties; + applyCachedProperties(); + } + return true; +} + // -------------------------------------------------------------------- // QbsBuildStepFactory: // -------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbsbuildstep.h b/src/plugins/qbsprojectmanager/qbsbuildstep.h index 2351c60c2e6..debf9c2ef64 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstep.h +++ b/src/plugins/qbsprojectmanager/qbsbuildstep.h @@ -38,6 +38,8 @@ #include <qbs.h> +namespace Utils { class FancyLineEdit; } + namespace QbsProjectManager { namespace Internal { class QbsProject; @@ -151,14 +153,17 @@ private slots: void changeJobCount(int count); void changeInstall(bool install); void changeCleanInstallRoot(bool clean); - void changeProperties(); + void applyCachedProperties(); // QML debugging: void linkQmlDebuggingLibraryChecked(bool checked); private: + bool validateProperties(Utils::FancyLineEdit *edit, QString *errorMessage); + Ui::QbsBuildStepConfigWidget *m_ui; + QList<QPair<QString, QString> > m_propertyCache; QbsBuildStep *m_step; QString m_summary; bool m_ignoreChange; diff --git a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui index 6c9709c26ef..8cb7f8a8a5b 100644 --- a/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui +++ b/src/plugins/qbsprojectmanager/qbsbuildstepconfigwidget.ui @@ -142,7 +142,7 @@ </widget> </item> <item row="3" column="1"> - <widget class="QbsPropertyLineEdit" name="propertyEdit"> + <widget class="Utils::FancyLineEdit" name="propertyEdit"> <property name="toolTip"> <string>Properties to pass to the project.</string> </property> @@ -254,9 +254,9 @@ </widget> <customwidgets> <customwidget> - <class>QbsPropertyLineEdit</class> + <class>Utils::FancyLineEdit</class> <extends>QLineEdit</extends> - <header location="global">qbsprojectmanager/qbspropertylineedit.h</header> + <header location="global">utils/fancylineedit.h</header> </customwidget> </customwidgets> <resources> diff --git a/src/plugins/qbsprojectmanager/qbscleanstep.cpp b/src/plugins/qbsprojectmanager/qbscleanstep.cpp index a93572130a7..0d4a46d479f 100644 --- a/src/plugins/qbsprojectmanager/qbscleanstep.cpp +++ b/src/plugins/qbsprojectmanager/qbscleanstep.cpp @@ -39,6 +39,7 @@ #include <projectexplorer/buildsteplist.h> #include <projectexplorer/kit.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/buildmanager.h> #include <projectexplorer/target.h> #include <utils/qtcassert.h> @@ -211,9 +212,10 @@ void QbsCleanStep::handleProgress(int value) void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line) { - emit addTask(ProjectExplorer::Task(type, message, - Utils::FileName::fromString(file), line, - ProjectExplorer::Constants::TASK_CATEGORY_COMPILE)); + ProjectExplorer::Task task = ProjectExplorer::Task(type, message, + Utils::FileName::fromString(file), line, + ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); + emit addTask(task, 1); emit addOutput(message, NormalOutput); } diff --git a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp index 98712f1a8c7..76aba0fd3b1 100644 --- a/src/plugins/qbsprojectmanager/qbsinstallstep.cpp +++ b/src/plugins/qbsprojectmanager/qbsinstallstep.cpp @@ -222,9 +222,10 @@ void QbsInstallStep::handleProgress(int value) void QbsInstallStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line) { - emit addTask(ProjectExplorer::Task(type, message, - Utils::FileName::fromString(file), line, - ProjectExplorer::Constants::TASK_CATEGORY_COMPILE)); + ProjectExplorer::Task task = ProjectExplorer::Task(type, message, + Utils::FileName::fromString(file), line, + ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); + emit addTask(task, 1); emit addOutput(message, NormalOutput); } diff --git a/src/plugins/qbsprojectmanager/qbsparser.cpp b/src/plugins/qbsprojectmanager/qbsparser.cpp index e9a12ab8942..a5475141f40 100644 --- a/src/plugins/qbsprojectmanager/qbsparser.cpp +++ b/src/plugins/qbsprojectmanager/qbsparser.cpp @@ -50,7 +50,7 @@ void QbsParser::setWorkingDirectory(const QString &workingDirectory) IOutputParser::setWorkingDirectory(workingDirectory); } -void QbsParser::taskAdded(const ProjectExplorer::Task &task) +void QbsParser::taskAdded(const ProjectExplorer::Task &task, int linkedLines, int skipLines) { ProjectExplorer::Task editable(task); @@ -59,7 +59,7 @@ void QbsParser::taskAdded(const ProjectExplorer::Task &task) if (!filePath.isEmpty()) editable.file = Utils::FileName::fromUserInput(m_workingDirectory.absoluteFilePath(filePath)); - IOutputParser::taskAdded(editable); + IOutputParser::taskAdded(editable, linkedLines, skipLines); } } // namespace Internal diff --git a/src/plugins/qbsprojectmanager/qbsparser.h b/src/plugins/qbsprojectmanager/qbsparser.h index 28d49977eec..e4b977237e3 100644 --- a/src/plugins/qbsprojectmanager/qbsparser.h +++ b/src/plugins/qbsprojectmanager/qbsparser.h @@ -50,7 +50,7 @@ public: void setWorkingDirectory(const QString &workingDirectory); public slots: - void taskAdded(const ProjectExplorer::Task &task); + void taskAdded(const ProjectExplorer::Task &task, int linkedLines, int skipLines); private: QDir m_workingDirectory; diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro index 9262c5317b2..ea5b7fee5d9 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.pro +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.pro @@ -39,7 +39,6 @@ HEADERS = \ qbsprojectmanagerconstants.h \ qbsprojectmanagerplugin.h \ qbsprojectparser.h \ - qbspropertylineedit.h \ qbsrunconfiguration.h \ qbsconstants.h @@ -61,7 +60,6 @@ SOURCES = \ qbsprojectmanager.cpp \ qbsprojectmanagerplugin.cpp \ qbsprojectparser.cpp \ - qbspropertylineedit.cpp \ qbsrunconfiguration.cpp FORMS = \ diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs index a33ad0da968..c22178c1fd8 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager.qbs @@ -27,7 +27,6 @@ QtcPlugin { property bool useInternalQbsProducts: project.qbsSubModuleExists && !project.useExternalQbs Depends { name: "Qt"; submodules: [ "widgets", "script" ] } - Depends { name: "Aggregation" } Depends { name: "qbscore" condition: product.useInternalQbsProducts @@ -104,8 +103,6 @@ QtcPlugin { "qbsprojectmanagerplugin.h", "qbsprojectparser.cpp", "qbsprojectparser.h", - "qbspropertylineedit.cpp", - "qbspropertylineedit.h", "qbsrunconfiguration.cpp", "qbsrunconfiguration.h" ] diff --git a/src/plugins/qbsprojectmanager/qbsprojectmanager_dependencies.pri b/src/plugins/qbsprojectmanager/qbsprojectmanager_dependencies.pri index 749f6ee59ef..b02aabfe7df 100644 --- a/src/plugins/qbsprojectmanager/qbsprojectmanager_dependencies.pri +++ b/src/plugins/qbsprojectmanager/qbsprojectmanager_dependencies.pri @@ -1,7 +1,6 @@ QTC_PLUGIN_NAME = QbsProjectManager # The Qbs libraries require special code and can not be covered here! QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmljs QTC_PLUGIN_DEPENDS += \ diff --git a/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp b/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp deleted file mode 100644 index faf53da21d6..00000000000 --- a/src/plugins/qbsprojectmanager/qbspropertylineedit.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qbspropertylineedit.h" - -#include <utils/qtcprocess.h> - -#include <QStringList> - -namespace QbsProjectManager { -namespace Internal { - -QbsPropertyLineEdit::QbsPropertyLineEdit(QWidget *parent) : - Utils::FancyLineEdit(parent) -{ } - -QList<QPair<QString, QString> > QbsPropertyLineEdit::properties() const -{ - return m_propertyCache; -} - -bool QbsPropertyLineEdit::validate(const QString &value, QString *errorMessage) const -{ - Utils::QtcProcess::SplitError err; - QStringList argList = Utils::QtcProcess::splitArgs(value, Utils::HostOsInfo::hostOs(), false, &err); - if (err != Utils::QtcProcess::SplitOk) { - if (errorMessage) - *errorMessage = tr("Could not split properties."); - return false; - } - - QList<QPair<QString, QString> > properties; - foreach (const QString &arg, argList) { - int pos = arg.indexOf(QLatin1Char(':')); - QString key; - QString value; - if (pos > 0) { - key = arg.left(pos); - value = arg.mid(pos + 1); - properties.append(qMakePair(key, value)); - } else { - if (errorMessage) - *errorMessage = tr("No ':' found in property definition."); - return false; - } - } - - if (m_propertyCache != properties) { - m_propertyCache = properties; - emit propertiesChanged(); - } - return true; -} - -} // namespace Internal -} // namespace QbsProjectManager - diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp index 7496145e1cf..ede7456db90 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.cpp @@ -40,7 +40,9 @@ #include <projectexplorer/deployconfiguration.h> #include <projectexplorer/localapplicationruncontrol.h> #include <projectexplorer/localenvironmentaspect.h> +#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> +#include <projectexplorer/runconfigurationaspects.h> #include <utils/qtcprocess.h> #include <utils/pathchooser.h> #include <utils/detailswidget.h> @@ -68,9 +70,6 @@ namespace QbsProjectManager { namespace Internal { const char QBS_RC_PREFIX[] = "Qbs.RunConfiguration:"; -const char COMMAND_LINE_ARGUMENTS_KEY[] = "Qbs.RunConfiguration.CommandLineArguments"; -const char USE_TERMINAL_KEY[] = "Qbs.RunConfiguration.UseTerminal"; -const char USER_WORKING_DIRECTORY_KEY[] = "Qbs.RunConfiguration.UserWorkingDirectory"; static QString rcNameSeparator() { return QLatin1String("---Qbs.RC.NameSeparator---"); } @@ -113,14 +112,16 @@ const qbs::ProductData findProduct(const qbs::ProjectData &pro, const QString &u QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) : LocalApplicationRunConfiguration(parent, id), m_uniqueProductName(uniqueProductNameFromId(id)), - m_runMode(ApplicationLauncher::Gui), m_currentInstallStep(0), m_currentBuildStepList(0) { addExtraAspect(new LocalEnvironmentAspect(this)); + addExtraAspect(new ArgumentsAspect(this, QStringLiteral("Qbs.RunConfiguration.CommandLineArguments"))); + addExtraAspect(new WorkingDirectoryAspect(this, QStringLiteral("Qbs.RunConfiguration.WorkingDirectory"))); - m_runModeForced = false; - m_runMode = isConsoleApplication() ? ApplicationLauncher::Console : ApplicationLauncher::Gui; + addExtraAspect(new TerminalAspect(this, + QStringLiteral("Qbs.RunConfiguration.UseTerminal"), + isConsoleApplication())); ctor(); } @@ -128,10 +129,6 @@ QbsRunConfiguration::QbsRunConfiguration(Target *parent, Core::Id id) : QbsRunConfiguration::QbsRunConfiguration(Target *parent, QbsRunConfiguration *source) : LocalApplicationRunConfiguration(parent, source), m_uniqueProductName(source->m_uniqueProductName), - m_commandLineArguments(source->m_commandLineArguments), - m_runMode(source->m_runMode), - m_runModeForced(source->m_runModeForced), - m_userWorkingDirectory(source->m_userWorkingDirectory), m_currentInstallStep(0), // no need to copy this, we will get if from the DC anyway. m_currentBuildStepList(0) // ditto { @@ -162,9 +159,9 @@ void QbsRunConfiguration::ctor() QbsProject *project = static_cast<QbsProject *>(target()->project()); connect(project, &QbsProject::projectParsingStarted, this, &RunConfiguration::enabledChanged); connect(project, &QbsProject::projectParsingDone, this, [this](bool success) { - if (success && !m_runModeForced) - m_runMode = isConsoleApplication() ? ApplicationLauncher::Console - : ApplicationLauncher::Gui; + auto terminalAspect = extraAspect<TerminalAspect>(); + if (success && !terminalAspect->isUserSet()) + terminalAspect->setUseTerminal(isConsoleApplication()); emit enabledChanged(); }); @@ -178,30 +175,6 @@ QWidget *QbsRunConfiguration::createConfigurationWidget() return new QbsRunConfigurationWidget(this, 0); } -QVariantMap QbsRunConfiguration::toMap() const -{ - QVariantMap map(LocalApplicationRunConfiguration::toMap()); - map.insert(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY), m_commandLineArguments); - if (m_runModeForced) - map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == ApplicationLauncher::Console); - map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory); - return map; -} - -bool QbsRunConfiguration::fromMap(const QVariantMap &map) -{ - m_commandLineArguments = map.value(QLatin1String(COMMAND_LINE_ARGUMENTS_KEY)).toString(); - if (map.contains(QLatin1String(USE_TERMINAL_KEY))) { - m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY), false).toBool() ? - ApplicationLauncher::Console : ApplicationLauncher::Gui; - m_runModeForced = true; - } - - m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString(); - - return RunConfiguration::fromMap(map); -} - void QbsRunConfiguration::installStepChanged() { if (m_currentInstallStep) @@ -254,7 +227,7 @@ QString QbsRunConfiguration::executable() const ApplicationLauncher::Mode QbsRunConfiguration::runMode() const { - return m_runMode; + return extraAspect<TerminalAspect>()->runMode(); } bool QbsRunConfiguration::isConsoleApplication() const @@ -274,9 +247,11 @@ QString QbsRunConfiguration::workingDirectory() const QString QbsRunConfiguration::baseWorkingDirectory() const { + WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>(); // if the user overrode us, then return his working directory - if (!m_userWorkingDirectory.isEmpty()) - return m_userWorkingDirectory; + QString wd = aspect->unexpandedWorkingDirectory(); + if (!wd.isEmpty()) + return wd; // else what the pro file reader tells us const QString exe = executable(); @@ -287,39 +262,24 @@ QString QbsRunConfiguration::baseWorkingDirectory() const QString QbsRunConfiguration::commandLineArguments() const { - return macroExpander()->expandProcessArgs(m_commandLineArguments); -} - -QString QbsRunConfiguration::rawCommandLineArguments() const -{ - return m_commandLineArguments; + return extraAspect<ArgumentsAspect>()->arguments(); } void QbsRunConfiguration::setBaseWorkingDirectory(const QString &wd) { + WorkingDirectoryAspect *aspect = extraAspect<WorkingDirectoryAspect>(); const QString &oldWorkingDirectory = workingDirectory(); - m_userWorkingDirectory = wd; + aspect->setWorkingDirectory(wd); const QString &newWorkingDirectory = workingDirectory(); if (oldWorkingDirectory != newWorkingDirectory) emit baseWorkingDirectoryChanged(newWorkingDirectory); } -void QbsRunConfiguration::setCommandLineArguments(const QString &argumentsString) -{ - m_commandLineArguments = argumentsString; - emit commandLineArgumentsChanged(argumentsString); -} - void QbsRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) { - if (m_runMode == runMode) - return; - - m_runModeForced = true; - m_runMode = runMode; - emit runModeChanged(runMode); + extraAspect<TerminalAspect>()->setRunMode(runMode); } void QbsRunConfiguration::addToBaseEnvironment(Utils::Environment &env) const @@ -416,58 +376,13 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW setExecutableLineText(); toplayout->addRow(tr("Executable:"), m_executableLineLabel); - QLabel *argumentsLabel = new QLabel(tr("Arguments:"), this); - m_argumentsLineEdit = new QLineEdit(m_rc->rawCommandLineArguments(), this); - argumentsLabel->setBuddy(m_argumentsLineEdit); - toplayout->addRow(argumentsLabel, m_argumentsLineEdit); - - m_workingDirectoryEdit = new Utils::PathChooser(this); - m_workingDirectoryEdit->setHistoryCompleter(QLatin1String("Qbs.WorkingDir.History")); - m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); - EnvironmentAspect *aspect = m_rc->extraAspect<EnvironmentAspect>(); - if (aspect) { - connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged())); - environmentWasChanged(); - } - m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory")); - - QToolButton *resetButton = new QToolButton(this); - resetButton->setToolTip(tr("Reset to default")); - resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET))); + m_rc->extraAspect<ArgumentsAspect>()->addToMainConfigurationWidget(this, toplayout); + m_rc->extraAspect<WorkingDirectoryAspect>()->addToMainConfigurationWidget(this, toplayout); - QHBoxLayout *boxlayout = new QHBoxLayout(); - boxlayout->setMargin(0); - boxlayout->addWidget(m_workingDirectoryEdit); - boxlayout->addWidget(resetButton); - toplayout->addRow(tr("Working directory:"), boxlayout); - - QHBoxLayout *innerBox = new QHBoxLayout(); - m_useTerminalCheck = new QCheckBox(tr("Run in terminal"), this); - innerBox->addWidget(m_useTerminalCheck); - - innerBox->addStretch(); - toplayout->addRow(QString(), innerBox); + m_rc->extraAspect<TerminalAspect>()->addToMainConfigurationWidget(this, toplayout); runConfigurationEnabledChange(); - connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), - this, SLOT(workDirectoryEdited())); - - connect(resetButton, SIGNAL(clicked()), - this, SLOT(workingDirectoryWasReset())); - - connect(m_argumentsLineEdit, SIGNAL(textEdited(QString)), - this, SLOT(argumentsEdited(QString))); - connect(m_useTerminalCheck, SIGNAL(toggled(bool)), - this, SLOT(termToggled(bool))); - - connect(m_rc, SIGNAL(baseWorkingDirectoryChanged(QString)), - this, SLOT(workingDirectoryChanged(QString))); - - connect(m_rc, SIGNAL(commandLineArgumentsChanged(QString)), - this, SLOT(commandLineArgumentsChanged(QString))); - connect(m_rc, SIGNAL(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode)), - this, SLOT(runModeChanged(ProjectExplorer::ApplicationLauncher::Mode))); connect(m_rc, SIGNAL(targetInformationChanged()), this, SLOT(targetInformationHasChanged()), Qt::QueuedConnection); @@ -475,13 +390,6 @@ QbsRunConfigurationWidget::QbsRunConfigurationWidget(QbsRunConfiguration *rc, QW this, SLOT(runConfigurationEnabledChange())); } -void QbsRunConfigurationWidget::environmentWasChanged() -{ - EnvironmentAspect *aspect = m_rc->extraAspect<EnvironmentAspect>(); - QTC_ASSERT(aspect, return); - m_workingDirectoryEdit->setEnvironment(aspect->environment()); -} - void QbsRunConfigurationWidget::runConfigurationEnabledChange() { bool enabled = m_rc->isEnabled(); @@ -489,47 +397,17 @@ void QbsRunConfigurationWidget::runConfigurationEnabledChange() m_disabledReason->setVisible(!enabled); m_disabledReason->setText(m_rc->disabledReason()); - m_useTerminalCheck->setChecked(m_rc->runMode() == ApplicationLauncher::Console); targetInformationHasChanged(); } -void QbsRunConfigurationWidget::workDirectoryEdited() -{ - if (m_ignoreChange) - return; - m_ignoreChange = true; - m_rc->setBaseWorkingDirectory(m_workingDirectoryEdit->rawPath()); - m_ignoreChange = false; -} - -void QbsRunConfigurationWidget::workingDirectoryWasReset() -{ - // This emits a signal connected to workingDirectoryChanged() - // that sets the m_workingDirectoryEdit - m_rc->setBaseWorkingDirectory(QString()); -} - -void QbsRunConfigurationWidget::argumentsEdited(const QString &args) -{ - m_ignoreChange = true; - m_rc->setCommandLineArguments(args); - m_ignoreChange = false; -} - -void QbsRunConfigurationWidget::termToggled(bool on) -{ - m_ignoreChange = true; - m_rc->setRunMode(on ? ApplicationLauncher::Console : ApplicationLauncher::Gui); - m_ignoreChange = false; -} - void QbsRunConfigurationWidget::targetInformationHasChanged() { m_ignoreChange = true; setExecutableLineText(m_rc->executable()); - m_workingDirectoryEdit->setPath(m_rc->baseWorkingDirectory()); - m_workingDirectoryEdit->setBaseFileName(m_rc->target()->project()->projectDirectory()); + WorkingDirectoryAspect *aspect = m_rc->extraAspect<WorkingDirectoryAspect>(); + aspect->pathChooser()->setPath(m_rc->baseWorkingDirectory()); + aspect->pathChooser()->setBaseFileName(m_rc->target()->project()->projectDirectory()); m_ignoreChange = false; } @@ -539,25 +417,6 @@ void QbsRunConfigurationWidget::setExecutableLineText(const QString &text) m_executableLineLabel->setText(newText); } -void QbsRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory) -{ - if (!m_ignoreChange) - m_workingDirectoryEdit->setPath(workingDirectory); -} - -void QbsRunConfigurationWidget::commandLineArgumentsChanged(const QString &args) -{ - if (m_ignoreChange) - return; - m_argumentsLineEdit->setText(args); -} - -void QbsRunConfigurationWidget::runModeChanged(ApplicationLauncher::Mode runMode) -{ - if (!m_ignoreChange) - m_useTerminalCheck->setChecked(runMode == ApplicationLauncher::Console); -} - // -------------------------------------------------------------------- // QbsRunConfigurationFactory: // -------------------------------------------------------------------- diff --git a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h index b00d1cc89ed..d6e2be2f23b 100644 --- a/src/plugins/qbsprojectmanager/qbsrunconfiguration.h +++ b/src/plugins/qbsprojectmanager/qbsrunconfiguration.h @@ -82,8 +82,6 @@ public: QString workingDirectory() const; QString commandLineArguments() const; - QVariantMap toMap() const; - Utils::OutputFormatter *createOutputFormatter() const; void setRunMode(ProjectExplorer::ApplicationLauncher::Mode runMode); @@ -94,15 +92,12 @@ public: bool isConsoleApplication() const; signals: - void commandLineArgumentsChanged(const QString&); void baseWorkingDirectoryChanged(const QString&); - void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode); void targetInformationChanged(); void usingDyldImageSuffixChanged(bool); protected: QbsRunConfiguration(ProjectExplorer::Target *parent, QbsRunConfiguration *source); - bool fromMap(const QVariantMap &map); private slots: void installStepChanged(); @@ -111,8 +106,6 @@ private slots: private: void setBaseWorkingDirectory(const QString &workingDirectory); QString baseWorkingDirectory() const; - void setCommandLineArguments(const QString &argumentsString); - QString rawCommandLineArguments() const; QString defaultDisplayName(); qbs::InstallOptions installOptions() const; QString installRoot() const; @@ -122,12 +115,8 @@ private: void updateTarget(); QString m_uniqueProductName; - QString m_commandLineArguments; // Cached startup sub project information - ProjectExplorer::ApplicationLauncher::Mode m_runMode; - bool m_runModeForced; - QString m_userWorkingDirectory; QbsInstallStep *m_currentInstallStep; // We do not take ownership! ProjectExplorer::BuildStepList *m_currentBuildStepList; // We do not take ownership! @@ -142,18 +131,6 @@ public: private slots: void runConfigurationEnabledChange(); - void workDirectoryEdited(); - void workingDirectoryWasReset(); - void argumentsEdited(const QString &arguments); - void environmentWasChanged(); - - void workingDirectoryChanged(const QString &workingDirectory); - void commandLineArgumentsChanged(const QString &args); - void runModeChanged(ProjectExplorer::ApplicationLauncher::Mode runMode); - - void termToggled(bool); - -private slots: void targetInformationHasChanged(); private: @@ -164,9 +141,6 @@ private: QLabel *m_disabledIcon; QLabel *m_disabledReason; QLabel *m_executableLineLabel; - Utils::PathChooser *m_workingDirectoryEdit; - QLineEdit *m_argumentsLineEdit; - QCheckBox *m_useTerminalCheck; QCheckBox *m_usingDyldImageSuffix; QLineEdit *m_qmlDebugPort; Utils::DetailsWidget *m_detailsContainer; diff --git a/src/plugins/qmakeandroidsupport/androidpackageinstallationstep.cpp b/src/plugins/qmakeandroidsupport/androidpackageinstallationstep.cpp index 53a98aab3d0..04bdf309675 100644 --- a/src/plugins/qmakeandroidsupport/androidpackageinstallationstep.cpp +++ b/src/plugins/qmakeandroidsupport/androidpackageinstallationstep.cpp @@ -40,6 +40,7 @@ #include <projectexplorer/kitinformation.h> #include <projectexplorer/gnumakeparser.h> #include <utils/hostosinfo.h> +#include <utils/qtcprocess.h> #include <QDir> @@ -79,7 +80,10 @@ bool AndroidPackageInstallationStep::init() // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); - pp->setArguments(QString::fromLatin1("INSTALL_ROOT=\"%1\" install").arg(dirPath)); + const QString innerQuoted = Utils::QtcProcess::quoteArg(dirPath); + const QString outerQuoted = Utils::QtcProcess::quoteArg(QString::fromLatin1("INSTALL_ROOT=") + innerQuoted); + pp->setArguments(outerQuoted + QString::fromLatin1(" install")); + pp->resolveAll(); setOutputParser(new ProjectExplorer::GnuMakeParser()); ProjectExplorer::IOutputParser *parser = target()->kit()->createOutputParser(); diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidsupport_dependencies.pri b/src/plugins/qmakeandroidsupport/qmakeandroidsupport_dependencies.pri index dc7c706fa65..08c57f8fcf0 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidsupport_dependencies.pri +++ b/src/plugins/qmakeandroidsupport/qmakeandroidsupport_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = QmakeAndroidSupport QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmljs \ utils diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidsupport_global.h b/src/plugins/qmakeandroidsupport/qmakeandroidsupport_global.h deleted file mode 100644 index 8db046b4a4c..00000000000 --- a/src/plugins/qmakeandroidsupport/qmakeandroidsupport_global.h +++ /dev/null @@ -1,42 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QMAKEANDROID_GLOBAL_H -#define QMAKEANDROID_GLOBAL_H - -#include <qglobal.h> - -#if defined(QMAKEANDROID_LIBRARY) -# define QMAKEANDROIDSUPPORT_EXPORT Q_DECL_EXPORT -#else -# define QMAKEANDROIDSUPPORT_EXPORT Q_DECL_IMPORT -#endif - -#endif // QMAKEANDROID_GLOBAL_H diff --git a/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp b/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp index 3950ba55798..c499e2e38a9 100644 --- a/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp +++ b/src/plugins/qmakeprojectmanager/addlibrarywizard.cpp @@ -59,24 +59,17 @@ QStringList qt_clean_filter_list(const QString &filter) return f.split(QLatin1Char(' '), QString::SkipEmptyParts); } -LibraryPathChooser::LibraryPathChooser(QWidget *parent) - : Utils::PathChooser(parent) +static bool validateLibraryPath(const QString &path, const Utils::PathChooser *pathChooser, + QString *errorMessage) { -} - -bool LibraryPathChooser::validatePath(const QString &path, QString *errorMessage) -{ - bool result = PathChooser::validatePath(path, errorMessage); - if (!result) - return false; - + Q_UNUSED(errorMessage); QFileInfo fi(path); if (!fi.exists()) return false; const QString fileName = fi.fileName(); - QStringList filters = qt_clean_filter_list(promptDialogFilter()); + QStringList filters = qt_clean_filter_list(pathChooser->promptDialogFilter()); for (int i = 0; i < filters.count(); i++) { QRegExp regExp(filters.at(i)); regExp.setPatternSyntax(QRegExp::Wildcard); @@ -201,7 +194,13 @@ DetailsPage::DetailsPage(AddLibraryWizard *parent) { m_libraryDetailsWidget = new Ui::LibraryDetailsWidget(); m_libraryDetailsWidget->setupUi(this); - + Utils::PathChooser * const libPathChooser = m_libraryDetailsWidget->libraryPathChooser; + const auto pathValidator = [libPathChooser](Utils::FancyLineEdit *edit, QString *errorMessage) { + return libPathChooser->defaultValidationFunction()(edit, errorMessage) + && validateLibraryPath(libPathChooser->fileName().toString(), libPathChooser, + errorMessage); + }; + libPathChooser->setValidationFunction(pathValidator); setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Details")); } diff --git a/src/plugins/qmakeprojectmanager/addlibrarywizard.h b/src/plugins/qmakeprojectmanager/addlibrarywizard.h index fd06f61d778..624eff7e6dd 100644 --- a/src/plugins/qmakeprojectmanager/addlibrarywizard.h +++ b/src/plugins/qmakeprojectmanager/addlibrarywizard.h @@ -144,15 +144,6 @@ private: QString m_snippet; }; -class LibraryPathChooser : public Utils::PathChooser -{ - Q_OBJECT -public: - LibraryPathChooser(QWidget *parent); - virtual bool validatePath(const QString &path, QString *errorMessage); -}; - - } // namespace Internal } // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp index 36bef024c47..5f268063e86 100644 --- a/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp +++ b/src/plugins/qmakeprojectmanager/customwidgetwizard/customwidgetwizard.cpp @@ -45,7 +45,7 @@ namespace Internal { CustomWidgetWizard::CustomWidgetWizard() { - setId(QLatin1String("P.Qt4CustomWidget")); + setId("P.Qt4CustomWidget"); setCategory(QLatin1String(ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY)); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY_DISPLAY)); diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp index 3e37c836705..d9a2515f5a9 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.cpp @@ -101,7 +101,6 @@ DesktopQmakeRunConfiguration::DesktopQmakeRunConfiguration(Target *parent, Deskt m_commandLineArguments(source->m_commandLineArguments), m_proFilePath(source->m_proFilePath), m_runMode(source->m_runMode), - m_forcedGuiMode(source->m_forcedGuiMode), m_isUsingDyldImageSuffix(source->m_isUsingDyldImageSuffix), m_userWorkingDirectory(source->m_userWorkingDirectory), m_parseSuccess(source->m_parseSuccess), @@ -162,23 +161,11 @@ void DesktopQmakeRunConfiguration::ctor() { setDefaultDisplayName(defaultDisplayName()); - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); - m_forcedGuiMode = (version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)); - QmakeProject *project = static_cast<QmakeProject *>(target()->project()); connect(project, &QmakeProject::proFileUpdated, this, &DesktopQmakeRunConfiguration::proFileUpdated); connect(project, &QmakeProject::proFilesEvaluated, this, &DesktopQmakeRunConfiguration::proFileEvaluated); - connect(target(), &Target::kitChanged, - this, &DesktopQmakeRunConfiguration::kitChanged); -} - -void DesktopQmakeRunConfiguration::kitChanged() -{ - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); - m_forcedGuiMode = (version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)); - emit runModeChanged(runMode()); // Always emit } ////// @@ -249,7 +236,6 @@ DesktopQmakeRunConfigurationWidget::DesktopQmakeRunConfigurationWidget(DesktopQm QHBoxLayout *innerBox = new QHBoxLayout(); m_useTerminalCheck = new QCheckBox(tr("Run in terminal"), this); m_useTerminalCheck->setChecked(m_qmakeRunConfiguration->runMode() == ApplicationLauncher::Console); - m_useTerminalCheck->setVisible(!m_qmakeRunConfiguration->forcedGuiMode()); innerBox->addWidget(m_useTerminalCheck); m_useQvfbCheck = new QCheckBox(tr("Run on QVFb"), this); @@ -380,10 +366,8 @@ void DesktopQmakeRunConfigurationWidget::commandLineArgumentsChanged(const QStri void DesktopQmakeRunConfigurationWidget::runModeChanged(ApplicationLauncher::Mode runMode) { - if (!m_ignoreChange) { - m_useTerminalCheck->setVisible(!m_qmakeRunConfiguration->forcedGuiMode()); + if (!m_ignoreChange) m_useTerminalCheck->setChecked(runMode == ApplicationLauncher::Console); - } } void DesktopQmakeRunConfigurationWidget::usingDyldImageSuffixChanged(bool state) @@ -458,16 +442,9 @@ QString DesktopQmakeRunConfiguration::executable() const ApplicationLauncher::Mode DesktopQmakeRunConfiguration::runMode() const { - if (m_forcedGuiMode) - return ProjectExplorer::ApplicationLauncher::Gui; return m_runMode; } -bool DesktopQmakeRunConfiguration::forcedGuiMode() const -{ - return m_forcedGuiMode; -} - bool DesktopQmakeRunConfiguration::isUsingDyldImageSuffix() const { return m_isUsingDyldImageSuffix; diff --git a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h index 5d3b17fa128..d1e23c20372 100644 --- a/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h +++ b/src/plugins/qmakeprojectmanager/desktopqmakerunconfiguration.h @@ -80,7 +80,6 @@ public: virtual QString executable() const; virtual ProjectExplorer::ApplicationLauncher::Mode runMode() const; - bool forcedGuiMode() const; virtual QString workingDirectory() const; virtual QString commandLineArguments() const; @@ -107,7 +106,6 @@ signals: void effectiveTargetInformationChanged(); private slots: - void kitChanged(); void proFileUpdated(QmakeProjectManager::QmakeProFileNode *pro, bool success, bool parseInProgress); void proFileEvaluated(); @@ -131,7 +129,6 @@ private: // Cached startup sub project information ProjectExplorer::ApplicationLauncher::Mode m_runMode; - bool m_forcedGuiMode; bool m_isUsingDyldImageSuffix; QString m_userWorkingDirectory; bool m_parseSuccess; diff --git a/src/plugins/qmakeprojectmanager/librarydetailswidget.ui b/src/plugins/qmakeprojectmanager/librarydetailswidget.ui index ebcb80396b1..0d3b4b1c120 100644 --- a/src/plugins/qmakeprojectmanager/librarydetailswidget.ui +++ b/src/plugins/qmakeprojectmanager/librarydetailswidget.ui @@ -31,7 +31,7 @@ </widget> </item> <item row="1" column="1"> - <widget class="QmakeProjectManager::Internal::LibraryPathChooser" name="libraryPathChooser" native="true"/> + <widget class="Utils::PathChooser" name="libraryPathChooser" native="true"/> </item> <item row="3" column="0"> <widget class="QLabel" name="includeLabel"> @@ -241,12 +241,6 @@ <header location="global">utils/pathchooser.h</header> <container>1</container> </customwidget> - <customwidget> - <class>QmakeProjectManager::Internal::LibraryPathChooser</class> - <extends>QWidget</extends> - <header location="global">qmakeprojectmanager/addlibrarywizard.h</header> - <container>1</container> - </customwidget> </customwidgets> <resources/> <connections/> diff --git a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp index 4f5e27d2e4b..92af58f4ace 100644 --- a/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp +++ b/src/plugins/qmakeprojectmanager/qmakebuildconfiguration.cpp @@ -100,15 +100,9 @@ const char BUILD_CONFIGURATION_KEY[] = "Qt4ProjectManager.Qt4BuildConfiguration. enum { debug = 0 }; -QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target) : - BuildConfiguration(target, Core::Id(QMAKE_BC_ID)), - m_shadowBuild(true), - m_isEnabled(false), - m_qmakeBuildConfiguration(0), - m_subNodeBuild(0), - m_fileNodeBuild(0) +QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target) + : QmakeBuildConfiguration(target, Core::Id(QMAKE_BC_ID)) { - ctor(); } QmakeBuildConfiguration::QmakeBuildConfiguration(Target *target, Core::Id id) : diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.cpp b/src/plugins/qmakeprojectmanager/qmakenodes.cpp index 6a18db58247..7de13272d18 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakenodes.cpp @@ -1743,6 +1743,8 @@ void QmakeProFileNode::asyncUpdate() { m_project->incrementPendingEvaluateFutures(); setupReader(); + if (!includedInExactParse()) + m_readerExact->setVerbose(false); m_parseFutureWatcher.waitForFinished(); EvalInput input = evalInput(); QFuture<EvalResult *> future = QtConcurrent::run(&QmakeProFileNode::asyncEvaluate, this, input); diff --git a/src/plugins/qmakeprojectmanager/qmakenodes.h b/src/plugins/qmakeprojectmanager/qmakenodes.h index 59344ed5611..c33e70d2c1c 100644 --- a/src/plugins/qmakeprojectmanager/qmakenodes.h +++ b/src/plugins/qmakeprojectmanager/qmakenodes.h @@ -213,7 +213,6 @@ private: Utils::FileName m_projectFilePath; QString m_projectDir; - QMap<QString, QtSupport::UiCodeModelSupport *> m_uiCodeModelSupport; Internal::QmakePriFile *m_qmakePriFile; // Memory is cheap... diff --git a/src/plugins/qmakeprojectmanager/qmakeparser.cpp b/src/plugins/qmakeprojectmanager/qmakeparser.cpp index 93423ac1ee9..c14ae2e525f 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparser.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeparser.cpp @@ -32,6 +32,7 @@ #include <projectexplorer/task.h> #include <projectexplorer/projectexplorerconstants.h> +#include <projectexplorer/buildmanager.h> using namespace QmakeProjectManager; using ProjectExplorer::Task; @@ -47,20 +48,22 @@ void QMakeParser::stdError(const QString &line) QString lne = rightTrimmed(line); if (lne.startsWith(QLatin1String("Project ERROR:"))) { const QString description = lne.mid(15); - emit addTask(Task(Task::Error, - description, - Utils::FileName() /* filename */, - -1 /* linenumber */, - Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + Task task = Task(Task::Error, + description, + Utils::FileName() /* filename */, + -1 /* linenumber */, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + emit addTask(task, 1); return; } if (lne.startsWith(QLatin1String("Project WARNING:"))) { const QString description = lne.mid(17); - emit addTask(Task(Task::Warning, - description, - Utils::FileName() /* filename */, - -1 /* linenumber */, - Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + Task task = Task(Task::Warning, + description, + Utils::FileName() /* filename */, + -1 /* linenumber */, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + emit addTask(task, 1); return; } if (m_error.indexIn(lne) > -1) { @@ -72,11 +75,12 @@ void QMakeParser::stdError(const QString &line) } else if (fileName.startsWith(QLatin1String("ERROR: "))) { fileName = fileName.mid(7); } - emit addTask(Task(type, - m_error.cap(3) /* description */, - Utils::FileName::fromUserInput(fileName), - m_error.cap(2).toInt() /* line */, - Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM))); + Task task = Task(type, + m_error.cap(3) /* description */, + Utils::FileName::fromUserInput(fileName), + m_error.cap(2).toInt() /* line */, + Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); + emit addTask(task, 1); return; } IOutputParser::stdError(line); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index aaab37486b7..3a979591f3f 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -38,8 +38,6 @@ #include "qmakeprojectmanagerconstants.h" #include "qmakebuildconfiguration.h" #include "findqmakeprofiles.h" -#include "wizards/abstractmobileapp.h" -#include "wizards/qtquickapp.h" #include <utils/algorithm.h> #include <coreplugin/icontext.h> @@ -90,28 +88,6 @@ QmakeBuildConfiguration *enableActiveQmakeBuildConfiguration(Target *t, bool ena return bc; } -void updateBoilerPlateCodeFiles(const AbstractMobileApp *app, const QString &proFile) -{ - const QList<AbstractGeneratedFileInfo> updates = app->fileUpdates(proFile); - const QString nativeProFile = QDir::toNativeSeparators(proFile); - if (!updates.empty()) { - const QString title = QmakeManager::tr("Update of Generated Files"); - QStringList fileNames; - foreach (const AbstractGeneratedFileInfo &info, updates) - fileNames.append(QDir::toNativeSeparators(info.fileInfo.fileName())); - const QString message = - QmakeManager::tr("In project<br><br>%1<br><br>The following files are either " - "outdated or have been modified:<br><br>%2<br><br>Do you want " - "Qt Creator to update the files? Any changes will be lost.") - .arg(nativeProFile, fileNames.join(QLatin1String(", "))); - if (QMessageBox::question(Core::ICore::dialogParent(), title, message, QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - QString error; - if (!app->updateFiles(updates, error)) - QMessageBox::critical(0, title, error); - } - } -} - } // namespace namespace QmakeProjectManager { @@ -346,8 +322,7 @@ QmakeProject::QmakeProject(QmakeManager *manager, const QString &fileName) : m_asyncUpdateState(Base), m_cancelEvaluate(false), m_centralizedFolderWatcher(0), - m_activeTarget(0), - m_checkForTemplateUpdate(true) + m_activeTarget(0) { setId(Constants::QMAKEPROJECT_ID); setProjectContext(Core::Context(QmakeProjectManager::Constants::PROJECT_ID)); @@ -507,22 +482,9 @@ void QmakeProject::updateCppCodeModel() // part->defines templatePart->projectDefines += pro->cxxDefines(); - // part->headerPaths - if (qtVersion) { - foreach (const HeaderPath &header, qtVersion->systemHeaderPathes(k)) { - ProjectPart::HeaderPath::Type type = ProjectPart::HeaderPath::IncludePath; - if (header.kind() == HeaderPath::FrameworkHeaderPath) - type = ProjectPart::HeaderPath::FrameworkPath; - templatePart->headerPaths += ProjectPart::HeaderPath(header.path(), type); - } - } - foreach (const QString &inc, pro->variableValue(IncludePathVar)) { const auto headerPath = ProjectPart::HeaderPath(inc, ProjectPart::HeaderPath::IncludePath); - // We've added header paths from qtVersion->systemHeaderPathes() above, - // which also contains the mkspecs dir. However, it's also part of - // the pro->variableValue(IncludePathVar), so check for duplicates. if (!templatePart->headerPaths.contains(headerPath)) templatePart->headerPaths += headerPath; } @@ -822,22 +784,6 @@ void QmakeProject::decrementPendingEvaluateFutures() if (debug) qDebug()<<" Setting state to Base"; } - - if (m_checkForTemplateUpdate) { - // Update boiler plate code for subprojects. - QtQuickApp qtQuickApp; - - foreach (QmakeProFileNode *node, applicationProFiles(QmakeProject::ExactAndCumulativeParse)) { - const QString path = node->path().toString(); - - foreach (TemplateInfo info, QtQuickApp::templateInfos()) { - qtQuickApp.setTemplateInfo(info); - updateBoilerPlateCodeFiles(&qtQuickApp, path); - } - } - m_checkForTemplateUpdate = false; - } - } } diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h index d9fca176ea9..ccedabd2425 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.h +++ b/src/plugins/qmakeprojectmanager/qmakeproject.h @@ -214,7 +214,6 @@ private: Internal::CentralizedFolderWatcher *m_centralizedFolderWatcher; ProjectExplorer::Target *m_activeTarget; - bool m_checkForTemplateUpdate; // initialized to true, set to false after first parse friend class Internal::QmakeProjectFile; friend class Internal::QmakeProjectConfigWidget; diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp index b2d660d596f..b529ea68698 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectimporter.cpp @@ -296,9 +296,6 @@ Target *QmakeProjectImporter::preferredTarget(const QList<Target *> &possibleTar if (t->kit() == KitManager::defaultKit()) { activeTarget = t; activeTargetPriority = 3; - } else if (activeTargetPriority < 2 && version && version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)) { - activeTarget = t; - activeTargetPriority = 2; } else if (activeTargetPriority < 1 && version && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT)) { activeTarget = t; activeTargetPriority = 1; diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp index d7f762e10b2..d8614bf7c8c 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.cpp @@ -38,7 +38,6 @@ #include "qmakestep.h" #include "qmakebuildconfiguration.h" #include "addlibrarywizard.h" -#include "wizards/qtquickapp.h" #include <coreplugin/icore.h> #include <coreplugin/editormanager/editormanager.h> diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro index 204ea2adf4e..e32cdbd9517 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.pro @@ -19,8 +19,6 @@ HEADERS += \ profilehoverhandler.h \ wizards/qtprojectparameters.h \ wizards/guiappwizard.h \ - wizards/consoleappwizard.h \ - wizards/consoleappwizarddialog.h \ wizards/libraryparameters.h \ wizards/librarywizard.h \ wizards/librarywizarddialog.h \ @@ -31,11 +29,6 @@ HEADERS += \ wizards/modulespage.h \ wizards/filespage.h \ wizards/qtwizard.h \ - wizards/qtquickapp.h \ - wizards/qtquickappwizard.h \ - wizards/qtquickappwizardpages.h \ - wizards/abstractmobileapp.h \ - wizards/abstractmobileappwizard.h \ wizards/subdirsprojectwizard.h \ wizards/subdirsprojectwizarddialog.h \ qmakeprojectmanagerconstants.h \ @@ -68,8 +61,6 @@ SOURCES += \ profilehoverhandler.cpp \ wizards/qtprojectparameters.cpp \ wizards/guiappwizard.cpp \ - wizards/consoleappwizard.cpp \ - wizards/consoleappwizarddialog.cpp \ wizards/libraryparameters.cpp \ wizards/librarywizard.cpp \ wizards/librarywizarddialog.cpp \ @@ -80,11 +71,6 @@ SOURCES += \ wizards/modulespage.cpp \ wizards/filespage.cpp \ wizards/qtwizard.cpp \ - wizards/qtquickapp.cpp \ - wizards/qtquickappwizard.cpp \ - wizards/qtquickappwizardpages.cpp \ - wizards/abstractmobileapp.cpp \ - wizards/abstractmobileappwizard.cpp \ wizards/subdirsprojectwizard.cpp \ wizards/subdirsprojectwizarddialog.cpp \ makestep.cpp \ diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs index eca1908c0c2..43d82e38d17 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "QmakeProjectManager" Depends { name: "Qt"; submodules: ["widgets", "network"] } - Depends { name: "Aggregation" } Depends { name: "QmlJS" } Depends { name: "Utils" } @@ -86,10 +85,6 @@ QtcPlugin { name: "Wizards" prefix: "wizards/" files: [ - "abstractmobileapp.cpp", "abstractmobileapp.h", - "abstractmobileappwizard.cpp", "abstractmobileappwizard.h", - "consoleappwizard.cpp", "consoleappwizard.h", - "consoleappwizarddialog.cpp", "consoleappwizarddialog.h", "filespage.cpp", "filespage.h", "guiappwizard.cpp", "guiappwizard.h", "guiappwizarddialog.cpp", "guiappwizarddialog.h", @@ -98,9 +93,6 @@ QtcPlugin { "librarywizarddialog.cpp", "librarywizarddialog.h", "modulespage.cpp", "modulespage.h", "qtprojectparameters.cpp", "qtprojectparameters.h", - "qtquickapp.cpp", "qtquickapp.h", - "qtquickappwizard.cpp", "qtquickappwizard.h", - "qtquickappwizardpages.cpp", "qtquickappwizardpages.h", "qtwizard.cpp", "qtwizard.h", "subdirsprojectwizard.cpp", "subdirsprojectwizard.h", "subdirsprojectwizarddialog.cpp", "subdirsprojectwizarddialog.h", diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanager_dependencies.pri b/src/plugins/qmakeprojectmanager/qmakeprojectmanager_dependencies.pri index 321a5785f67..41bfc38201c 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanager_dependencies.pri +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanager_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = QmakeProjectManager QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmljs \ utils diff --git a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp index c91a99b7aff..9500d0d6d9d 100644 --- a/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeprojectmanagerplugin.cpp @@ -37,12 +37,10 @@ #include "makestep.h" #include "qmakebuildconfiguration.h" #include "desktopqmakerunconfiguration.h" -#include "wizards/consoleappwizard.h" #include "wizards/guiappwizard.h" #include "wizards/librarywizard.h" #include "wizards/testwizard.h" #include "wizards/subdirsprojectwizard.h" -#include "wizards/qtquickappwizard.h" #include "customwidgetwizard/customwidgetwizard.h" #include "qmakeprojectmanagerconstants.h" #include "qmakeproject.h" @@ -73,6 +71,7 @@ #include <QtPlugin> +using namespace Core; using namespace QmakeProjectManager::Internal; using namespace QmakeProjectManager; using namespace ProjectExplorer; @@ -96,8 +95,8 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString { Q_UNUSED(arguments) Q_UNUSED(errorMessage) - const Core::Context projectContext(QmakeProjectManager::Constants::PROJECT_ID); - Core::Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE); + const Context projectContext(QmakeProjectManager::Constants::PROJECT_ID); + Context projecTreeContext(ProjectExplorer::Constants::C_PROJECT_TREE); Utils::MimeDatabase::addMimeTypes(QLatin1String(":qmakeprojectmanager/QmakeProjectManager.mimetypes.xml")); @@ -107,16 +106,15 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString ProjectExplorer::KitManager::registerKitInformation(new QmakeKitInformation); - addAutoReleasedObject(new SubdirsProjectWizard); - addAutoReleasedObject(new GuiAppWizard); - addAutoReleasedObject(new ConsoleAppWizard); - addAutoReleasedObject(new QtQuickAppWizard); - addAutoReleasedObject(new LibraryWizard); - addAutoReleasedObject(new TestWizard); - addAutoReleasedObject(new CustomWidgetWizard); + IWizardFactory::registerFactoryCreator([]() { + QList<IWizardFactory *> result; + result << new SubdirsProjectWizard << new GuiAppWizard << new LibraryWizard + << new TestWizard << new CustomWidgetWizard; + return result; + }); addAutoReleasedObject(new CustomWizardMetaFactory<CustomQmakeProjectWizard> - (QLatin1String("qmakeproject"), Core::IWizardFactory::ProjectWizard)); + (QLatin1String("qmakeproject"), IWizardFactory::ProjectWizard)); addAutoReleasedObject(new QMakeStepFactory); addAutoReleasedObject(new MakeStepFactory); @@ -133,97 +131,97 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString addAutoReleasedObject(new ProFileEditorFactory); //menus - Core::ActionContainer *mbuild = - Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); - Core::ActionContainer *mproject = - Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); - Core::ActionContainer *msubproject = - Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); - Core::ActionContainer *mfile = - Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT); + ActionContainer *mbuild = + ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); + ActionContainer *mproject = + ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); + ActionContainer *msubproject = + ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); + ActionContainer *mfile = + ActionManager::actionContainer(ProjectExplorer::Constants::M_FILECONTEXT); //register actions - Core::Command *command; + Command *command; m_buildSubProjectContextMenu = new Utils::ParameterAction(tr("Build"), tr("Build \"%1\""), Utils::ParameterAction::AlwaysEnabled/*handled manually*/, this); - command = Core::ActionManager::registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext); - command->setAttribute(Core::Command::CA_Hide); - command->setAttribute(Core::Command::CA_UpdateText); + command = ActionManager::registerAction(m_buildSubProjectContextMenu, Constants::BUILDSUBDIRCONTEXTMENU, projectContext); + command->setAttribute(Command::CA_Hide); + command->setAttribute(Command::CA_UpdateText); command->setDescription(m_buildSubProjectContextMenu->text()); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_buildSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildSubDirContextMenu())); m_runQMakeActionContextMenu = new QAction(tr("Run qmake"), this); - command = Core::ActionManager::registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext); - command->setAttribute(Core::Command::CA_Hide); + command = ActionManager::registerAction(m_runQMakeActionContextMenu, Constants::RUNQMAKECONTEXTMENU, projectContext); + command->setAttribute(Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_runQMakeActionContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(runQMakeContextMenu())); command = msubproject->addSeparator(projectContext, ProjectExplorer::Constants::G_PROJECT_BUILD, &m_subProjectRebuildSeparator); - command->setAttribute(Core::Command::CA_Hide); + command->setAttribute(Command::CA_Hide); m_rebuildSubProjectContextMenu = new QAction(tr("Rebuild"), this); - command = Core::ActionManager::registerAction( + command = ActionManager::registerAction( m_rebuildSubProjectContextMenu, Constants::REBUILDSUBDIRCONTEXTMENU, projectContext); - command->setAttribute(Core::Command::CA_Hide); + command->setAttribute(Command::CA_Hide); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_rebuildSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(rebuildSubDirContextMenu())); m_cleanSubProjectContextMenu = new QAction(tr("Clean"), this); - command = Core::ActionManager::registerAction( + command = ActionManager::registerAction( m_cleanSubProjectContextMenu, Constants::CLEANSUBDIRCONTEXTMENU, projectContext); - command->setAttribute(Core::Command::CA_Hide); + command->setAttribute(Command::CA_Hide); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_cleanSubProjectContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(cleanSubDirContextMenu())); m_buildFileContextMenu = new QAction(tr("Build"), this); - command = Core::ActionManager::registerAction(m_buildFileContextMenu, Constants::BUILDFILECONTEXTMENU, projectContext); - command->setAttribute(Core::Command::CA_Hide); + command = ActionManager::registerAction(m_buildFileContextMenu, Constants::BUILDFILECONTEXTMENU, projectContext); + command->setAttribute(Command::CA_Hide); mfile->addAction(command, ProjectExplorer::Constants::G_FILE_OTHER); connect(m_buildFileContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildFileContextMenu())); m_buildSubProjectAction = new Utils::ParameterAction(tr("Build Subproject"), tr("Build Subproject \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext); - command->setAttribute(Core::Command::CA_Hide); - command->setAttribute(Core::Command::CA_UpdateText); + command = ActionManager::registerAction(m_buildSubProjectAction, Constants::BUILDSUBDIR, projectContext); + command->setAttribute(Command::CA_Hide); + command->setAttribute(Command::CA_UpdateText); command->setDescription(m_buildSubProjectAction->text()); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_buildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(buildSubDirContextMenu())); m_runQMakeAction = new QAction(tr("Run qmake"), this); - const Core::Context globalcontext(Core::Constants::C_GLOBAL); - command = Core::ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, globalcontext); + const Context globalcontext(Core::Constants::C_GLOBAL); + command = ActionManager::registerAction(m_runQMakeAction, Constants::RUNQMAKE, globalcontext); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); connect(m_runQMakeAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(runQMake())); m_rebuildSubProjectAction = new Utils::ParameterAction(tr("Rebuild Subproject"), tr("Rebuild Subproject \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext); - command->setAttribute(Core::Command::CA_Hide); - command->setAttribute(Core::Command::CA_UpdateText); + command = ActionManager::registerAction(m_rebuildSubProjectAction, Constants::REBUILDSUBDIR, projectContext); + command->setAttribute(Command::CA_Hide); + command->setAttribute(Command::CA_UpdateText); command->setDescription(m_rebuildSubProjectAction->text()); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_REBUILD); connect(m_rebuildSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(rebuildSubDirContextMenu())); m_cleanSubProjectAction = new Utils::ParameterAction(tr("Clean Subproject"), tr("Clean Subproject \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_cleanSubProjectAction, Constants::CLEANSUBDIR, projectContext); - command->setAttribute(Core::Command::CA_Hide); - command->setAttribute(Core::Command::CA_UpdateText); + command = ActionManager::registerAction(m_cleanSubProjectAction, Constants::CLEANSUBDIR, projectContext); + command->setAttribute(Command::CA_Hide); + command->setAttribute(Command::CA_UpdateText); command->setDescription(m_cleanSubProjectAction->text()); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_CLEAN); connect(m_cleanSubProjectAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(cleanSubDirContextMenu())); m_buildFileAction = new Utils::ParameterAction(tr("Build File"), tr("Build File \"%1\""), Utils::ParameterAction::AlwaysEnabled, this); - command = Core::ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE); - command->setAttribute(Core::Command::CA_Hide); - command->setAttribute(Core::Command::CA_UpdateText); + command = ActionManager::registerAction(m_buildFileAction, Constants::BUILDFILE); + command->setAttribute(Command::CA_Hide); + command->setAttribute(Command::CA_UpdateText); command->setDescription(m_buildFileAction->text()); command->setDefaultKeySequence(QKeySequence(tr("Ctrl+Alt+B"))); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_BUILD); @@ -239,22 +237,22 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, this, &QmakeProjectManagerPlugin::updateContextActions); - Core::ActionContainer *contextMenu = Core::ActionManager::createMenu(QmakeProjectManager::Constants::M_CONTEXT); + ActionContainer *contextMenu = ActionManager::createMenu(QmakeProjectManager::Constants::M_CONTEXT); - Core::Context proFileEditorContext = Core::Context(QmakeProjectManager::Constants::PROFILE_EDITOR_ID); + Context proFileEditorContext = Context(QmakeProjectManager::Constants::PROFILE_EDITOR_ID); - command = Core::ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR); + command = ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR); contextMenu->addAction(command); m_addLibraryAction = new QAction(tr("Add Library..."), this); - command = Core::ActionManager::registerAction(m_addLibraryAction, + command = ActionManager::registerAction(m_addLibraryAction, Constants::ADDLIBRARY, proFileEditorContext); connect(m_addLibraryAction, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(addLibrary())); contextMenu->addAction(command); m_addLibraryActionContextMenu = new QAction(tr("Add Library..."), this); - command = Core::ActionManager::registerAction(m_addLibraryActionContextMenu, + command = ActionManager::registerAction(m_addLibraryActionContextMenu, Constants::ADDLIBRARY, projecTreeContext); connect(m_addLibraryActionContextMenu, SIGNAL(triggered()), m_qmakeProjectManager, SLOT(addLibraryContextMenu())); @@ -263,11 +261,11 @@ bool QmakeProjectManagerPlugin::initialize(const QStringList &arguments, QString contextMenu->addSeparator(proFileEditorContext); - command = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); + command = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(command); - connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), - this, SLOT(updateBuildFileAction())); + connect(EditorManager::instance(), &EditorManager::currentEditorChanged, + this, &QmakeProjectManagerPlugin::updateBuildFileAction); return true; } @@ -398,7 +396,7 @@ void QmakeProjectManagerPlugin::updateBuildFileAction() bool visible = false; bool enabled = false; - if (Core::IDocument *currentDocument= Core::EditorManager::currentDocument()) { + if (IDocument *currentDocument= EditorManager::currentDocument()) { Utils::FileName file = currentDocument->filePath(); Node *node = SessionManager::nodeForFile(file); Project *project = SessionManager::projectForFile(file); diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.cpp b/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.cpp deleted file mode 100644 index 1390528cbd5..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.cpp +++ /dev/null @@ -1,362 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "abstractmobileapp.h" - -#include <QDir> -#include <QFile> -#include <QTextStream> - -#ifndef CREATORLESSTEST -#include <coreplugin/icore.h> -#endif // CREATORLESSTEST - -#include <utils/fileutils.h> -#include <utils/qtcassert.h> - -namespace QmakeProjectManager { - -AbstractGeneratedFileInfo::AbstractGeneratedFileInfo() - : fileType(ExtendedFile) - , currentVersion(-1) - , version(-1) - , dataChecksum(0) - , statedChecksum(0) -{ -} - -const QString AbstractMobileApp::CFileComment(QLatin1String("//")); -const QString AbstractMobileApp::ProFileComment(QLatin1Char('#')); -const QString AbstractMobileApp::DeploymentPriFileName(QLatin1String("deployment.pri")); -const QString AbstractMobileApp::FileChecksum(QLatin1String("checksum")); -const QString AbstractMobileApp::FileStubVersion(QLatin1String("version")); -const int AbstractMobileApp::StubVersion = 9; - -AbstractMobileApp::AbstractMobileApp() - : QObject() -{ -} - -AbstractMobileApp::~AbstractMobileApp() { } - -void AbstractMobileApp::setProjectName(const QString &name) -{ - m_projectName = name; -} - -QString AbstractMobileApp::projectName() const -{ - return m_projectName; -} - -void AbstractMobileApp::setProjectPath(const QString &path) -{ - m_projectPath.setFile(path); -} - -QString AbstractMobileApp::path(int fileType) const -{ - const QString originsRootApp = originsRoot(); - const QString originsRootShared = templatesRoot() + QLatin1String("shared/"); - const QString mainCppFileName = QLatin1String("main.cpp"); - switch (fileType) { - case MainCpp: return outputPathBase() + mainCppFileName; - case MainCppOrigin: return originsRootApp + mainCppFileName; - case AppPro: return outputPathBase() + m_projectName + QLatin1String(".pro"); - case AppProOrigin: return originsRootApp + QLatin1String("app.pro"); - case AppProPath: return outputPathBase(); - case DesktopOrigin: return originsRootShared + QLatin1String("app.desktop"); - case DeploymentPri: return outputPathBase() + DeploymentPriFileName; - case DeploymentPriOrigin: return originsRootShared + DeploymentPriFileName; - default: return pathExtended(fileType); - } - return QString(); -} - -bool AbstractMobileApp::readTemplate(int fileType, QByteArray *data, QString *errorMessage) const -{ - Utils::FileReader reader; - if (!reader.fetch(path(fileType), errorMessage)) - return false; - *data = reader.data(); - return true; -} - -QByteArray AbstractMobileApp::generateDesktopFile(QString *errorMessage, int fileType) const -{ - Q_UNUSED(fileType) - QByteArray desktopFileContent; - if (!readTemplate(DesktopOrigin, &desktopFileContent, errorMessage)) - return QByteArray(); - return desktopFileContent.replace("thisApp", projectName().toUtf8()); -} - -QByteArray AbstractMobileApp::generateMainCpp(QString *errorMessage) const -{ - QByteArray mainCppInput; - if (!readTemplate(MainCppOrigin, &mainCppInput, errorMessage)) - return QByteArray(); - QTextStream in(&mainCppInput); - - QByteArray mainCppContent; - QTextStream out(&mainCppContent, QIODevice::WriteOnly | QIODevice::Text); - - QString line; - while (!(line = in.readLine()).isNull()) { - bool adaptLine = true; - if (line.contains(QLatin1String("// DELETE_LINE"))) - continue; // omit this line in the output - else - adaptLine = adaptCurrentMainCppTemplateLine(line); - if (adaptLine) { - const int commentIndex = line.indexOf(QLatin1String(" //")); - if (commentIndex != -1) - line.truncate(commentIndex); - out << line << endl; - } - } - - return mainCppContent; -} - -QByteArray AbstractMobileApp::generateProFile(QString *errorMessage) const -{ - const QChar comment = QLatin1Char('#'); - QByteArray proFileInput; - if (!readTemplate(AppProOrigin, &proFileInput, errorMessage)) - return QByteArray(); - QTextStream in(&proFileInput); - - QByteArray proFileContent; - QTextStream out(&proFileContent, QIODevice::WriteOnly | QIODevice::Text); - - QString valueOnNextLine; - bool commentOutNextLine = false; - QString line; - while (!(line = in.readLine()).isNull()) { - if (line.contains(QLatin1String("# DEPLOYMENTFOLDERS"))) { - // Eat lines - QString nextLine; - while (!(nextLine = in.readLine()).isNull() - && !nextLine.contains(QLatin1String("# DEPLOYMENTFOLDERS_END"))) - { } - if (nextLine.isNull()) - continue; - - int foldersCount = 0; - QStringList folders; - foreach (const DeploymentFolder &folder, deploymentFolders()) { - foldersCount++; - const QString folderName = - QString::fromLatin1("folder_%1").arg(foldersCount, 2, 10, QLatin1Char('0')); - out << folderName << ".source = " << folder.first << endl; - if (!folder.second.isEmpty()) - out << folderName << ".target = " << folder.second << endl; - folders.append(folderName); - } - if (foldersCount > 0) - out << "DEPLOYMENTFOLDERS = " << folders.join(QLatin1Char(' ')) << endl; - } else if (line.contains(QLatin1String("# REMOVE_NEXT_LINE"))) { - in.readLine(); // eats the following line - } else { - handleCurrentProFileTemplateLine(line, in, out, commentOutNextLine); - } - - // Remove all marker comments - if (line.trimmed().startsWith(comment) - && line.trimmed().endsWith(comment)) - continue; - - if (!valueOnNextLine.isEmpty()) { - out << line.left(line.indexOf(QLatin1Char('=')) + 2) - << QDir::fromNativeSeparators(valueOnNextLine) << endl; - valueOnNextLine.clear(); - continue; - } - - if (commentOutNextLine) { - out << comment << line << endl; - commentOutNextLine = false; - continue; - } - out << line << endl; - }; - - proFileContent.replace("../shared/" + DeploymentPriFileName.toLatin1(), - DeploymentPriFileName.toLatin1()); - return proFileContent; -} - -QList<AbstractGeneratedFileInfo> AbstractMobileApp::fileUpdates(const QString &mainProFile) const -{ - QList<AbstractGeneratedFileInfo> result; - foreach (const AbstractGeneratedFileInfo &file, updateableFiles(mainProFile)) { - AbstractGeneratedFileInfo newFile = file; - QFile readFile(newFile.fileInfo.absoluteFilePath()); - if (!readFile.open(QIODevice::ReadOnly)) - continue; - const QString firstLine = QString::fromUtf8(readFile.readLine()); - const QStringList elements = firstLine.split(QLatin1Char(' ')); - if (elements.count() != 5 || elements.at(1) != FileChecksum - || elements.at(3) != FileStubVersion) - continue; - const QString versionString = elements.at(4); - newFile.version = versionString.startsWith(QLatin1String("0x")) - ? versionString.toInt(0, 16) : 0; - newFile.statedChecksum = elements.at(2).toUShort(0, 16); - QByteArray data = readFile.readAll(); - data.replace('\x0D', ""); - data.replace('\x0A', ""); - newFile.dataChecksum = qChecksum(data.constData(), data.length()); - if (newFile.dataChecksum != newFile.statedChecksum - || newFile.version < newFile.currentVersion) - result.append(newFile); - } - return result; -} - - -bool AbstractMobileApp::updateFiles(const QList<AbstractGeneratedFileInfo> &list, QString &error) const -{ - error.clear(); - foreach (const AbstractGeneratedFileInfo &info, list) { - const QByteArray data = generateFile(info.fileType, &error); - if (!error.isEmpty()) - return false; - Utils::FileSaver saver(QDir::cleanPath(info.fileInfo.absoluteFilePath())); - saver.write(data); - if (!saver.finalize(&error)) - return false; - } - return true; -} - -#ifndef CREATORLESSTEST -// The definition of QtQuickApp::templatesRoot() for -// CREATORLESSTEST is in tests/manual/appwizards/helpers.cpp -QString AbstractMobileApp::templatesRoot() -{ - return Core::ICore::resourcePath() - + QLatin1String("/templates/"); -} - -Core::GeneratedFile AbstractMobileApp::file(const QByteArray &data, - const QString &targetFile) -{ - Core::GeneratedFile generatedFile(targetFile); - generatedFile.setBinary(true); - generatedFile.setBinaryContents(data); - return generatedFile; -} - -Core::GeneratedFiles AbstractMobileApp::generateFiles(QString *errorMessage) const -{ - Core::GeneratedFiles files; - files << file(generateFile(AbstractGeneratedFileInfo::AppProFile, errorMessage), path(AppPro)); - files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute); - files << file(generateFile(AbstractGeneratedFileInfo::MainCppFile, errorMessage), path(MainCpp)); - return files; -} -#endif // CREATORLESSTEST - -QString AbstractMobileApp::error() const -{ - return m_error; -} - -QByteArray AbstractMobileApp::readBlob(const QString &filePath, - QString *errorMsg) const -{ - Utils::FileReader reader; - if (!reader.fetch(filePath, errorMsg)) - return QByteArray(); - return reader.data(); -} - -QByteArray AbstractMobileApp::generateFile(int fileType, - QString *errorMessage) const -{ - QByteArray data; - QString comment = CFileComment; - bool versionAndChecksum = false; - switch (fileType) { - case AbstractGeneratedFileInfo::MainCppFile: - data = generateMainCpp(errorMessage); - break; - case AbstractGeneratedFileInfo::AppProFile: - data = generateProFile(errorMessage); - comment = ProFileComment; - break; - case AbstractGeneratedFileInfo::DeploymentPriFile: - data = readBlob(path(DeploymentPriOrigin), errorMessage); - comment = ProFileComment; - versionAndChecksum = true; - break; - default: - data = generateFileExtended(fileType, &versionAndChecksum, - &comment, errorMessage); - } - if (!versionAndChecksum) - return data; - QByteArray versioned = data; - versioned.replace('\x0D', ""); - versioned.replace('\x0A', ""); - const QLatin1String hexPrefix("0x"); - const quint16 checkSum = qChecksum(versioned.constData(), versioned.length()); - const QString checkSumString = hexPrefix + QString::number(checkSum, 16); - const QString versionString - = hexPrefix + QString::number(makeStubVersion(stubVersionMinor()), 16); - const QChar sep = QLatin1Char(' '); - const QString versionLine = - comment + sep + FileChecksum + sep + checkSumString - + sep + FileStubVersion + sep + versionString + QLatin1Char('\x0A'); - return versionLine.toLatin1() + data; -} - -int AbstractMobileApp::makeStubVersion(int minor) -{ - return StubVersion << 16 | minor; -} - -QString AbstractMobileApp::outputPathBase() const -{ - QString path = m_projectPath.absoluteFilePath(); - if (!path.endsWith(QLatin1Char('/'))) - path.append(QLatin1Char('/')); - return path + projectName() + QLatin1Char('/'); -} - -void AbstractMobileApp::insertParameter(QString &line, const QString ¶meter) -{ - line.replace(QRegExp(QLatin1String("\\([^()]+\\)")), - QLatin1Char('(') + parameter + QLatin1Char(')')); -} - -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h b/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h deleted file mode 100644 index 08844240bd0..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileapp.h +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef ABSTRACTMOBILEAPP_H -#define ABSTRACTMOBILEAPP_H - -#include "../qmakeprojectmanager_global.h" -#include <QFileInfo> -#include <QPair> - -#ifndef CREATORLESSTEST -# include <coreplugin/generatedfile.h> -#endif // CREATORLESSTEST - -QT_FORWARD_DECLARE_CLASS(QTextStream) - -namespace QmakeProjectManager { - -/// \internal -struct -#ifndef CREATORLESSTEST - QMAKEPROJECTMANAGER_EXPORT -#endif // CREATORLESSTEST - AbstractGeneratedFileInfo -{ - enum FileType { - MainCppFile, - AppProFile, - DeploymentPriFile, - ExtendedFile - }; - - AbstractGeneratedFileInfo(); - - int fileType; - QFileInfo fileInfo; - int currentVersion; // Current version of the template file in Creator - int version; // The version in the file header - quint16 dataChecksum; // The calculated checksum - quint16 statedChecksum; // The checksum in the file header -}; - -typedef QPair<QString, QString> DeploymentFolder; // QPair<.source, .target> - -/// \internal -class -#ifndef CREATORLESSTEST - QMAKEPROJECTMANAGER_EXPORT -#endif // CREATORLESSTEST - AbstractMobileApp : public QObject -{ - Q_OBJECT - -public: - enum FileType { - MainCpp, - MainCppOrigin, - AppPro, - AppProOrigin, - AppProPath, - DesktopOrigin, - DeploymentPri, - DeploymentPriOrigin, - ExtendedFile - }; - - virtual ~AbstractMobileApp(); - - void setProjectName(const QString &name); - QString projectName() const; - void setProjectPath(const QString &path); - QString path(int fileType) const; - QString error() const; - -#ifndef CREATORLESSTEST - virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const; -#else - bool generateFiles(QString *errorMessage) const; -#endif // CREATORLESSTEST - - static int makeStubVersion(int minor); - QList<AbstractGeneratedFileInfo> fileUpdates(const QString &mainProFile) const; - bool updateFiles(const QList<AbstractGeneratedFileInfo> &list, QString &error) const; - - static const QString DeploymentPriFileName; -protected: - AbstractMobileApp(); - virtual QByteArray generateProFile(QString *errorMessage) const; - - static QString templatesRoot(); - static void insertParameter(QString &line, const QString ¶meter); - - QByteArray readBlob(const QString &filePath, QString *errorMsg) const; - bool readTemplate(int fileType, QByteArray *data, QString *errorMessage) const; - QByteArray generateFile(int fileType, QString *errorMessage) const; - QString outputPathBase() const; - -#ifndef CREATORLESSTEST - static Core::GeneratedFile file(const QByteArray &data, - const QString &targetFile); -#endif // CREATORLESSTEST - - static const QString CFileComment; - static const QString ProFileComment; - static const QString FileChecksum; - static const QString FileStubVersion; - static const int StubVersion; - - QString m_error; - -private: - QByteArray generateDesktopFile(QString *errorMessage, int fileType) const; - QByteArray generateMainCpp(QString *errorMessage) const; - - virtual QByteArray generateFileExtended(int fileType, - bool *versionAndCheckSum, QString *comment, QString *errorMessage) const = 0; - virtual QString pathExtended(int fileType) const = 0; - virtual QString originsRoot() const = 0; - virtual QString mainWindowClassName() const = 0; - virtual int stubVersionMinor() const = 0; - virtual bool adaptCurrentMainCppTemplateLine(QString &line) const = 0; - virtual void handleCurrentProFileTemplateLine(const QString &line, - QTextStream &proFileTemplate, QTextStream &proFile, - bool &commentOutNextLine) const = 0; - virtual QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const = 0; - virtual QList<DeploymentFolder> deploymentFolders() const = 0; - - QString m_projectName; - QFileInfo m_projectPath; - QString m_pngIcon64; - QString m_pngIcon80; -}; - -} // namespace QmakeProjectManager - -#endif // ABSTRACTMOBILEAPP_H diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp deleted file mode 100644 index 7efb103b153..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "abstractmobileappwizard.h" -#include "abstractmobileapp.h" - -#include "../qmakeprojectimporter.h" - -#include <extensionsystem/pluginmanager.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <qmakeprojectmanager/qmakeprojectmanager.h> -#include <qtsupport/qtsupportconstants.h> -#include <qtsupport/qtkitinformation.h> -#include <projectexplorer/projectexplorer.h> -#include <projectexplorer/targetsetuppage.h> -#include <projectexplorer/customwizard/customwizard.h> -#include <projectexplorer/session.h> -#include <coreplugin/editormanager/editormanager.h> - -using namespace Core; -using namespace ProjectExplorer; -using namespace QtSupport; - -namespace QmakeProjectManager { - -AbstractMobileAppWizardDialog::AbstractMobileAppWizardDialog(QWidget *parent, - const QtSupport::QtVersionNumber &minimumQtVersionNumber, - const QtSupport::QtVersionNumber &maximumQtVersionNumber, - const Core::WizardDialogParameters ¶meters) - : ProjectExplorer::BaseProjectWizardDialog(parent, parameters) - , m_kitsPage(0) - , m_minimumQtVersionNumber(minimumQtVersionNumber) - , m_maximumQtVersionNumber(maximumQtVersionNumber) -{ - if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) { - m_kitsPage = new ProjectExplorer::TargetSetupPage; - updateKitsPage(); - resize(900, 450); - } -} - -void AbstractMobileAppWizardDialog::addKitsPage() -{ - if (m_kitsPage) - addPage(m_kitsPage); -} - -void AbstractMobileAppWizardDialog::updateKitsPage() -{ - if (m_kitsPage) { - QString platform = selectedPlatform(); - if (platform.isEmpty()) { - m_kitsPage->setPreferredKitMatcher( - QtKitInformation::qtVersionMatcher(FeatureSet(QtSupport::Constants::FEATURE_MOBILE))); - } else { - m_kitsPage->setPreferredKitMatcher(QtKitInformation::platformMatcher(platform)); - } - m_kitsPage->setRequiredKitMatcher(QtKitInformation::qtVersionMatcher(requiredFeatures(), - m_minimumQtVersionNumber, - m_maximumQtVersionNumber)); - } -} - -ProjectExplorer::TargetSetupPage *AbstractMobileAppWizardDialog::kitsPage() const -{ - return m_kitsPage; -} - -Core::BaseFileWizard *AbstractMobileAppWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - AbstractMobileAppWizardDialog * const wdlg = createInternal(parent, parameters); - wdlg->setProjectName(ProjectExplorer::BaseProjectWizardDialog::uniqueProjectName(parameters.defaultPath())); - connect(wdlg, SIGNAL(projectParametersChanged(QString,QString)), - SLOT(useProjectPath(QString,QString))); - wdlg->addExtensionPages(parameters.extensionPages()); - - return wdlg; -} - -Core::GeneratedFiles AbstractMobileAppWizard::generateFiles(const QWizard *wizard, - QString *errorMessage) const -{ - prepareGenerateFiles(wizard, errorMessage); - return app()->generateFiles(errorMessage); -} - -bool AbstractMobileAppWizard::postGenerateFiles(const QWizard *w, - const Core::GeneratedFiles &l, QString *errorMessage) -{ - Q_UNUSED(w) - Q_UNUSED(l) - Q_UNUSED(errorMessage) - QmakeManager * const manager - = ExtensionSystem::PluginManager::getObject<QmakeManager>(); - Q_ASSERT(manager); - QmakeProject project(manager, app()->path(AbstractMobileApp::AppPro)); - bool success = true; - if (wizardDialog()->kitsPage()) { - success = wizardDialog()->kitsPage()->setupProject(&project); - if (success) { - project.saveSettings(); - success = ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); - } - } - if (success) { - const QString fileToOpen = fileToOpenPostGeneration(); - if (!fileToOpen.isEmpty()) - EditorManager::openEditor(fileToOpen); - } - return success; -} - -void AbstractMobileAppWizard::useProjectPath(const QString &projectName, - const QString &projectPath) -{ - app()->setProjectName(projectName); - app()->setProjectPath(projectPath); - if (wizardDialog()->kitsPage()) - wizardDialog()->kitsPage()->setProjectPath(app()->path(AbstractMobileApp::AppPro)); - projectPathChanged(app()->path(AbstractMobileApp::AppPro)); -} - -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.h b/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.h deleted file mode 100644 index 60a7a814d2f..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/abstractmobileappwizard.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef ABSTRACTMOBILEAPPWIZARD_H -#define ABSTRACTMOBILEAPPWIZARD_H - -#include <qmakeprojectmanager/qmakeprojectmanager_global.h> -#include <projectexplorer/baseprojectwizarddialog.h> -#include <qtsupport/baseqtversion.h> - -namespace ProjectExplorer { class TargetSetupPage; } - -namespace QtSupport { class QtVersionNumber; } - -namespace QmakeProjectManager { - -class AbstractMobileApp; - -/// \internal -class QMAKEPROJECTMANAGER_EXPORT AbstractMobileAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog -{ - Q_OBJECT - -protected: - explicit AbstractMobileAppWizardDialog(QWidget *parent, const QtSupport::QtVersionNumber &minimumQtVersionNumber, - const QtSupport::QtVersionNumber &maximumQtVersionNumber, - const Core::WizardDialogParameters ¶meters); -public: - ProjectExplorer::TargetSetupPage *kitsPage() const; - -protected: - void addKitsPage(); - void updateKitsPage(); - -private: - ProjectExplorer::TargetSetupPage *m_kitsPage; - const QtSupport::QtVersionNumber m_minimumQtVersionNumber; - const QtSupport::QtVersionNumber m_maximumQtVersionNumber; -}; - -/// \internal -class QMAKEPROJECTMANAGER_EXPORT AbstractMobileAppWizard : public Core::BaseFileWizardFactory -{ - Q_OBJECT - -private slots: - void useProjectPath(const QString &projectName, const QString &projectPath); - -protected: - virtual QString fileToOpenPostGeneration() const = 0; - -private: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - Core::GeneratedFiles generateFiles(const QWizard *wizard, QString *errorMessage) const; - bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); - - virtual AbstractMobileApp *app() const = 0; - virtual AbstractMobileAppWizardDialog *wizardDialog() const = 0; - virtual AbstractMobileAppWizardDialog *createInternal(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const = 0; - virtual void projectPathChanged(const QString &path) const = 0; - virtual void prepareGenerateFiles(const QWizard *wizard, QString *errorMessage) const = 0; -}; - -} // namespace QmakeProjectManager - -#endif // ABSTRACTMOBILEAPPWIZARD_H diff --git a/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.cpp deleted file mode 100644 index e4d87e304c0..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "consoleappwizard.h" - -#include "consoleappwizarddialog.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <cpptools/abstracteditorsupport.h> -#include <qtsupport/qtsupportconstants.h> - -#include <utils/fileutils.h> - -#include <QCoreApplication> -#include <QTextStream> - -static const char mainCppC[] = -"#include <QCoreApplication>\n\n" -"int main(int argc, char *argv[])\n" -"{\n" -" QCoreApplication a(argc, argv);\n\n" -" return a.exec();\n" -"}\n"; - -static const char mainSourceFileC[] = "main"; - -namespace QmakeProjectManager { -namespace Internal { - -ConsoleAppWizard::ConsoleAppWizard() -{ - setId(QLatin1String("E.Qt4Core")); - setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("Qt Console Application")); - setDescription(tr("Creates a project containing a single main.cpp file with a stub implementation.\n\n" - "Preselects a desktop Qt for building the application if available.")); - setIcon(QIcon(QLatin1String(":/wizards/images/console.png"))); - setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_CONSOLE)); -} - -Core::BaseFileWizard *ConsoleAppWizard::create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const -{ - ConsoleAppWizardDialog *dialog = new ConsoleAppWizardDialog(displayName(), icon(), - showModulesPageForApplications(), parent, parameters); - dialog->setProjectName(ConsoleAppWizardDialog::uniqueProjectName(parameters.defaultPath())); - return dialog; -} - -Core::GeneratedFiles - ConsoleAppWizard::generateFiles(const QWizard *w, - QString * /*errorMessage*/) const -{ - const ConsoleAppWizardDialog *wizard = qobject_cast< const ConsoleAppWizardDialog *>(w); - const QtProjectParameters params = wizard->parameters(); - const QString projectPath = params.projectPath(); - - // Create files: Source - - const QString sourceFileName = Core::BaseFileWizardFactory::buildFileName(projectPath, QLatin1String(mainSourceFileC), sourceSuffix()); - Core::GeneratedFile source(sourceFileName); - source.setContents(CppTools::AbstractEditorSupport::licenseTemplate(sourceFileName) + QLatin1String(mainCppC)); - source.setAttributes(Core::GeneratedFile::OpenEditorAttribute); - // Create files: Profile - const QString profileName = Core::BaseFileWizardFactory::buildFileName(projectPath, params.fileName, profileSuffix()); - - Core::GeneratedFile profile(profileName); - profile.setAttributes(Core::GeneratedFile::OpenProjectAttribute); - QString contents; - { - QTextStream proStr(&contents); - QtProjectParameters::writeProFileHeader(proStr); - params.writeProFile(proStr); - proStr << "\n\nSOURCES += " << Utils::FileName::fromString(sourceFileName).fileName() << '\n'; - } - profile.setContents(contents); - return Core::GeneratedFiles() << source << profile; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.h b/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.h deleted file mode 100644 index 33dcd4cc304..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/consoleappwizard.h +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CONSOLEAPPWIZARD_H -#define CONSOLEAPPWIZARD_H - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -class ModulesPage; - -class ConsoleAppWizard : public QtWizard -{ - Q_OBJECT - -public: - ConsoleAppWizard(); - -protected: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; -}; - -} // namespace Internal -} // namespace QmakeProjectManager - -#endif // CONSOLEAPPWIZARD_H diff --git a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp b/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp deleted file mode 100644 index b3ccf1bb89e..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "consoleappwizarddialog.h" -#include <projectexplorer/projectexplorerconstants.h> - -#include <QDebug> - -namespace QmakeProjectManager { -namespace Internal { - -ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName, - const QIcon &icon, - bool showModulesPage, - QWidget *parent, const Core::WizardDialogParameters ¶meters) : - BaseQmakeProjectWizardDialog(showModulesPage, parent, parameters) -{ - setWindowIcon(icon); - setWindowTitle(templateName); - setSelectedModules(QLatin1String("core")); - setDeselectedModules(QLatin1String("gui")); - - setIntroDescription(tr("This wizard generates a Qt Console Application " - "project. The application derives from QCoreApplication and does not " - "provide a GUI.")); - - addModulesPage(); - if (!parameters.extraValues().contains(QLatin1String(ProjectExplorer::Constants::PROJECT_KIT_IDS))) - addTargetSetupPage(); - - addExtensionPages(parameters.extensionPages()); -} - -QtProjectParameters ConsoleAppWizardDialog::parameters() const -{ - QtProjectParameters rc; - rc.type = QtProjectParameters::ConsoleApp; - rc.fileName = projectName(); - rc.path = path(); - - rc.selectedModules = selectedModulesList(); - rc.deselectedModules = deselectedModulesList(); - return rc; -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.h b/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.h deleted file mode 100644 index 38657cc9564..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/consoleappwizarddialog.h +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CONSOLEAPPWIZARDDIALOG_H -#define CONSOLEAPPWIZARDDIALOG_H - -#include "qtwizard.h" - -namespace QmakeProjectManager { -namespace Internal { - -struct QtProjectParameters; - -class ConsoleAppWizardDialog : public BaseQmakeProjectWizardDialog -{ - Q_OBJECT -public: - explicit ConsoleAppWizardDialog(const QString &templateName, - const QIcon &icon, - bool showModulesPage, - QWidget *parent, const Core::WizardDialogParameters ¶meters); - - QtProjectParameters parameters() const; -}; - -} // namespace Internal -} // namespace QmakeProjectManager - -#endif // CONSOLEAPPWIZARDDIALOG_H diff --git a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp index d338bf3a297..64d09919e72 100644 --- a/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/guiappwizard.cpp @@ -74,7 +74,7 @@ namespace Internal { GuiAppWizard::GuiAppWizard() { - setId(QLatin1String("C.Qt4Gui")); + setId("C.Qt4Gui"); setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); diff --git a/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp b/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp index ef75296057f..7e6f92b5419 100644 --- a/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/librarywizard.cpp @@ -47,7 +47,7 @@ namespace Internal { LibraryWizard::LibraryWizard() { - setId(QLatin1String("H.Qt4Library")); + setId("H.Qt4Library"); setCategory(QLatin1String(ProjectExplorer::Constants::LIBRARIES_WIZARD_CATEGORY)); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::LIBRARIES_WIZARD_CATEGORY_DISPLAY)); diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp deleted file mode 100644 index fa0c3226668..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.cpp +++ /dev/null @@ -1,451 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qtquickapp.h" - -#include <utils/qtcassert.h> -#include <utils/fileutils.h> -#include <extensionsystem/pluginmanager.h> -#include <extensionsystem/pluginspec.h> - -#include <QDebug> -#include <QDir> -#include <QFile> -#include <QTextStream> - -#ifndef CREATORLESSTEST -#include <coreplugin/icore.h> -#endif // CREATORLESSTEST - -namespace QmakeProjectManager { -namespace Internal { - -static QString sharedDirectory() -{ - return Core::ICore::resourcePath() + QLatin1String("/templates/shared/"); -} - -static QString qtQuickApplicationViewerDirectory() -{ - return sharedDirectory() + QLatin1String("qtquickapplicationviewer/"); -} - -static QString templateRootDirectory() -{ - return Core::ICore::resourcePath() + QLatin1String("/templates/qtquick/"); -} - -static QStringList templateNames() -{ - QStringList templateNameList; - const QDir templateRoot(templateRootDirectory()); - - foreach (const QFileInfo &subDirectory, - templateRoot.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) - templateNameList.append(subDirectory.fileName()); - - return templateNameList; -} - -// Return locale language attribute "de_UTF8" -> "de", empty string for "C" -static QString languageSetting() -{ -#ifdef QT_CREATOR - QString name = Core::ICore::userInterfaceLanguage(); - const int underScorePos = name.indexOf(QLatin1Char('_')); - if (underScorePos != -1) - name.truncate(underScorePos); - if (name.compare(QLatin1String("C"), Qt::CaseInsensitive) == 0) - name.clear(); - return name; -#else - return QLocale::system().name(); -#endif -} - -static inline bool assignLanguageElementText(QXmlStreamReader &reader, - const QString &desiredLanguage, - QString *target) -{ - const QStringRef elementLanguage = reader.attributes().value(QLatin1String("xml:lang")); - if (elementLanguage.isEmpty()) { - // Try to find a translation for our Wizards - *target = QCoreApplication::translate("QmakeProjectManager::QtQuickAppWizard", - reader.readElementText().toLatin1().constData()); - return true; - } - if (elementLanguage == desiredLanguage) { - *target = reader.readElementText(); - return true; - } - return false; -} - -static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info) -{ - const QString locale = languageSetting(); - - static const QLatin1String tag_template("template"); - static const QLatin1String tag_displayName("displayname"); - static const QLatin1String tag_description("description"); - static const QLatin1String attribute_featuresRequired("featuresRequired"); - static const QLatin1String attribute_openEditor("openeditor"); - static const QLatin1String attribute_priority("priority"); - static const QLatin1String attribute_viewerdir("viewerdir"); - static const QLatin1String attribute_viewerclassname("viewerclassname"); - static const QLatin1String attribute_qrcdeployment("qrcdeployment"); - static const QLatin1String attribute_stubversionminor("stubversionminor"); - static const QLatin1String attribute_requiredPlugins("requiredPlugins"); - - while (!reader.atEnd() && !reader.hasError()) { - reader.readNext(); - if (reader.tokenType() != QXmlStreamReader::StartElement) - continue; - - if (reader.name() == tag_template) { - info->openFile = reader.attributes().value(attribute_openEditor).toString(); - if (reader.attributes().hasAttribute(attribute_priority)) - info->priority = reader.attributes().value(attribute_priority).toString(); - - if (reader.attributes().hasAttribute(attribute_featuresRequired)) - info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString(); - - if (reader.attributes().hasAttribute(attribute_viewerdir)) - info->viewerDir = reader.attributes().value(attribute_viewerdir).toString(); - - if (reader.attributes().hasAttribute(attribute_viewerclassname)) - info->viewerClassName = reader.attributes().value(attribute_viewerclassname).toString(); - - if (reader.attributes().hasAttribute(attribute_qrcdeployment)) - info->qrcDeployment = reader.attributes().value(attribute_qrcdeployment).toString(); - - if (reader.attributes().hasAttribute(attribute_stubversionminor)) - info->stubVersionMinor = reader.attributes().value(attribute_stubversionminor).toString().toInt(); - - // This attribute is currently used in enterprise addons to filter out templates when the enterprise - // addon is not installed. This applies to the Boot To Qt addon for example. - if (reader.attributes().hasAttribute(attribute_requiredPlugins)) - info->requiredPlugins = reader.attributes().value(attribute_requiredPlugins).toString() - .split(QLatin1Char(','), QString::SkipEmptyParts); - - } else if (reader.name() == tag_displayName) { - if (!assignLanguageElementText(reader, locale, &info->displayName)) - continue; - } else if (reader.name() == tag_description) { - if (!assignLanguageElementText(reader, locale, &info->description)) - continue; - } - } - if (reader.hasError()) { - qWarning() << reader.errorString(); - return false; - } - - return true; -} - -class TemplateInfoList -{ -public: - TemplateInfoList() - { - QSet<QString> availablePlugins; - foreach (ExtensionSystem::PluginSpec *s, ExtensionSystem::PluginManager::plugins()) { - if (s->state() == ExtensionSystem::PluginSpec::Running && !s->hasError()) - availablePlugins += s->name(); - } - - QMultiMap<QString, TemplateInfo> multiMap; - foreach (const QString &templateName, templateNames()) { - const QString templatePath = templateRootDirectory() + templateName; - QFile xmlFile(templatePath + QLatin1String("/template.xml")); - if (!xmlFile.open(QIODevice::ReadOnly)) { - qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath())); - continue; - } - TemplateInfo info; - info.templateName = templateName; - info.templatePath = templatePath; - QXmlStreamReader reader(&xmlFile); - if (!parseTemplateXml(reader, &info)) - continue; - - bool ok = true; - foreach (const QString &neededPlugin, info.requiredPlugins) { - if (!availablePlugins.contains(neededPlugin)) { - ok = false; - break; - } - } - if (ok) - multiMap.insert(info.priority, info); - } - m_templateInfoList = multiMap.values(); - } - QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; } - -private: - QList<TemplateInfo> m_templateInfoList; -}; - -Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList) - -QList<TemplateInfo> QtQuickApp::templateInfos() -{ - return templateInfoList()->templateInfoList(); -} - -QtQuickApp::QtQuickApp() - : AbstractMobileApp() -{ -} - -void QtQuickApp::setTemplateInfo(const TemplateInfo &templateInfo) -{ - m_templateInfo = templateInfo; -} - -QString QtQuickApp::pathExtended(int fileType) const -{ - const QString appViewerTargetSubDir = appViewerOriginSubDir(); - - const QString mainQmlFile = QLatin1String("main.qml"); - const QString mainQrcFile = QLatin1String("qml.qrc"); - - const QString qrcDeploymentFile = QLatin1String("deployment.pri"); - - const QString pathBase = outputPathBase(); - - switch (fileType) { - case MainQml: return pathBase + mainQmlFile; - case MainQmlOrigin: return originsRoot() + mainQmlFile; - case MainQrc: return pathBase + mainQrcFile; - case MainQrcOrigin: return originsRoot() + mainQrcFile; - case QrcDeployment: return pathBase + qrcDeploymentFile; - case QrcDeploymentOrigin: return sharedDirectory() + qrcDeployment(); - case AppViewerPri: return pathBase + appViewerTargetSubDir + fileName(AppViewerPri); - case AppViewerPriOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerPri); - case AppViewerCpp: return pathBase + appViewerTargetSubDir + fileName(AppViewerCpp); - case AppViewerCppOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerCpp); - case AppViewerH: return pathBase + appViewerTargetSubDir + fileName(AppViewerH); - case AppViewerHOrigin: return qtQuickApplicationViewerDirectory() + appViewerOriginSubDir() + fileName(AppViewerH); - default: qFatal("QtQuickApp::pathExtended() needs more work"); - } - return QString(); -} - -QString QtQuickApp::originsRoot() const -{ - return m_templateInfo.templatePath + QLatin1Char('/'); -} - -QString QtQuickApp::mainWindowClassName() const -{ - return m_templateInfo.viewerClassName; -} - -bool QtQuickApp::adaptCurrentMainCppTemplateLine(QString &line) const -{ - Q_UNUSED(line) - return true; -} - -void QtQuickApp::handleCurrentProFileTemplateLine(const QString &line, - QTextStream &proFileTemplate, QTextStream &proFile, - bool &commentOutNextLine) const -{ - Q_UNUSED(commentOutNextLine) - if (line.contains(QLatin1String("# QML_IMPORT_PATH"))) { - QString nextLine = proFileTemplate.readLine(); // eats 'QML_IMPORT_PATH =' - if (!nextLine.startsWith(QLatin1String("QML_IMPORT_PATH ="))) - return; - proFile << nextLine << endl; - } -} - -#ifndef CREATORLESSTEST - -static QFileInfoList allFilesRecursive(const QString &path) -{ - const QDir currentDirectory(path); - - QFileInfoList allFiles = currentDirectory.entryInfoList(QDir::Files); - - foreach (const QFileInfo &subDirectory, currentDirectory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) - allFiles.append(allFilesRecursive(subDirectory.absoluteFilePath())); - - return allFiles; -} - -Core::GeneratedFiles QtQuickApp::generateFiles(QString *errorMessage) const -{ - Core::GeneratedFiles files = AbstractMobileApp::generateFiles(errorMessage); - - const QFileInfoList templateFiles = allFilesRecursive(originsRoot()); - - //Deploy additional .qml files - foreach (const QFileInfo &templateFile, templateFiles) { - QString targetFileName = templateFile.fileName(); - if (templateFile.suffix() == QLatin1String("qml") - && targetFileName != QLatin1String("main.qml")) - files.append(file(readBlob(templateFile.absoluteFilePath(), errorMessage), outputPathBase() + targetFileName)); - } - - if (!useExistingMainQml()) { - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainQmlFile, errorMessage), path(MainQml))); - files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute); - } - if (QFileInfo::exists(path(MainQrcOrigin))) { - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::MainQrcFile, errorMessage), path(MainQrc))); - } - if (!qrcDeployment().isEmpty()) { - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::QrcDeploymentFile, errorMessage), path(QrcDeployment))); - } - if (!appViewerBaseName().isEmpty()) { - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::AppViewerPriFile, errorMessage), path(AppViewerPri))); - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp))); - files.append(file(generateFile(QtQuickAppGeneratedFileInfo::AppViewerHFile, errorMessage), path(AppViewerH))); - } - - return files; -} -#endif // CREATORLESSTEST - -bool QtQuickApp::useExistingMainQml() const -{ - return !m_mainQmlFile.filePath().isEmpty(); -} - -QString QtQuickApp::appViewerBaseName() const -{ - return m_templateInfo.viewerDir; -} - -QString QtQuickApp::qrcDeployment() const -{ - return m_templateInfo.qrcDeployment; -} - -QString QtQuickApp::fileName(QtQuickApp::ExtendedFileType type) const -{ - switch (type) { - case AppViewerPri: return appViewerBaseName() + QLatin1String(".pri"); - case AppViewerH: return appViewerBaseName() + QLatin1String(".h"); - case AppViewerCpp: return appViewerBaseName() + QLatin1String(".cpp"); - default: return QString(); - } -} - -QString QtQuickApp::appViewerOriginSubDir() const -{ - return appViewerBaseName() + QLatin1Char('/'); -} - -QByteArray QtQuickApp::generateProFile(QString *errorMessage) const -{ - QByteArray proFileContent = AbstractMobileApp::generateProFile(errorMessage); - proFileContent.replace("../../shared/qtquickapplicationviewer/", ""); - proFileContent.replace("../../shared/qrc", ""); // fix a path to qrcdeployment.pri - return proFileContent; -} - -QByteArray QtQuickApp::generateFileExtended(int fileType, - bool *versionAndCheckSum, QString *comment, QString *errorMessage) const -{ - QByteArray data; - switch (fileType) { - case QtQuickAppGeneratedFileInfo::MainQmlFile: - data = readBlob(path(MainQmlOrigin), errorMessage); - break; - case QtQuickAppGeneratedFileInfo::MainQrcFile: - data = readBlob(path(MainQrcOrigin), errorMessage); - break; - case QtQuickAppGeneratedFileInfo::QrcDeploymentFile: - data = readBlob(path(QrcDeploymentOrigin), errorMessage); - break; - case QtQuickAppGeneratedFileInfo::AppViewerPriFile: - data = readBlob(path(AppViewerPriOrigin), errorMessage); - *comment = ProFileComment; - *versionAndCheckSum = true; - break; - case QtQuickAppGeneratedFileInfo::AppViewerCppFile: - data = readBlob(path(AppViewerCppOrigin), errorMessage); - *versionAndCheckSum = true; - break; - case QtQuickAppGeneratedFileInfo::AppViewerHFile: - default: - data = readBlob(path(AppViewerHOrigin), errorMessage); - *versionAndCheckSum = true; - break; - } - return data; -} - -int QtQuickApp::stubVersionMinor() const -{ - return m_templateInfo.stubVersionMinor; -} - -QList<AbstractGeneratedFileInfo> QtQuickApp::updateableFiles(const QString &mainProFile) const -{ - QList<AbstractGeneratedFileInfo> result; - static const struct { - int fileType; - QString fileName; - } files[] = { - {QtQuickAppGeneratedFileInfo::AppViewerPriFile, fileName(AppViewerPri)}, - {QtQuickAppGeneratedFileInfo::AppViewerHFile, fileName(AppViewerH)}, - {QtQuickAppGeneratedFileInfo::AppViewerCppFile, fileName(AppViewerCpp)} - }; - const QFileInfo mainProFileInfo(mainProFile); - const int size = sizeof(files) / sizeof(files[0]); - for (int i = 0; i < size; ++i) { - const QString fileName = mainProFileInfo.dir().absolutePath() - + QLatin1Char('/') + appViewerOriginSubDir() + files[i].fileName; - if (!QFile::exists(fileName)) - continue; - QtQuickAppGeneratedFileInfo file; - file.fileType = files[i].fileType; - file.fileInfo = QFileInfo(fileName); - file.currentVersion = AbstractMobileApp::makeStubVersion(stubVersionMinor()); - result.append(file); - } - if (result.count() != size) - result.clear(); // All files must be found. No wrong/partial updates, please. - return result; -} - -QList<DeploymentFolder> QtQuickApp::deploymentFolders() const -{ - return QList<DeploymentFolder>(); -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h b/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h deleted file mode 100644 index 512c5bbe589..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickapp.h +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QTQUICKAPP_H -#define QTQUICKAPP_H - -#include "abstractmobileapp.h" - -#include <QStringList> - -namespace QmakeProjectManager { -namespace Internal { - -struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo -{ - enum ExtendedFileType { - MainQmlFile = ExtendedFile, - MainQrcFile, - AppViewerPriFile, - AppViewerCppFile, - AppViewerHFile, - QrcDeploymentFile - }; - - QtQuickAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {} -}; - -class TemplateInfo -{ -public: - TemplateInfo() : stubVersionMinor(9) {} - QString templateName; - QString templatePath; - QString displayName; - QString description; - QString openFile; - QString featuresRequired; - QString priority; - QString viewerClassName; - QString viewerDir; - QString qrcDeployment; - QStringList requiredPlugins; - int stubVersionMinor; -}; - -class QtQuickApp : public AbstractMobileApp -{ -public: - enum ExtendedFileType { - MainQml = ExtendedFile, - MainQmlOrigin, - MainQrc, - MainQrcOrigin, - AppViewerPri, - AppViewerPriOrigin, - AppViewerCpp, - AppViewerCppOrigin, - AppViewerH, - AppViewerHOrigin, - QrcDeployment, - QrcDeploymentOrigin - }; - - QtQuickApp(); - - static QList<TemplateInfo> templateInfos(); - - void setTemplateInfo(const TemplateInfo &templateInfo); - -#ifndef CREATORLESSTEST - virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const; -#else - bool generateFiles(QString *errorMessage) const; -#endif // CREATORLESSTEST - bool useExistingMainQml() const; - - static const int StubVersion; - -protected: - virtual QByteArray generateProFile(QString *errorMessage) const; - - QString appViewerBaseName() const; - QString qrcDeployment() const; - QString fileName(ExtendedFileType type) const; - QString appViewerOriginSubDir() const; - -private: - virtual QByteArray generateFileExtended(int fileType, - bool *versionAndCheckSum, QString *comment, QString *errorMessage) const; - virtual QString pathExtended(int fileType) const; - virtual QString originsRoot() const; - virtual QString mainWindowClassName() const; - virtual int stubVersionMinor() const; - virtual bool adaptCurrentMainCppTemplateLine(QString &line) const; - virtual void handleCurrentProFileTemplateLine(const QString &line, - QTextStream &proFileTemplate, QTextStream &proFile, - bool &commentOutNextLine) const; - QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const; - QList<DeploymentFolder> deploymentFolders() const; - - QFileInfo m_mainQmlFile; - TemplateInfo m_templateInfo; -}; - -} // namespace Internal -} // namespace QmakeProjectManager - -#endif // QTQUICKAPP_H diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp deleted file mode 100644 index df155bd145c..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizard.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qtquickappwizard.h" - -#include "qtquickapp.h" -#include "qtquickappwizardpages.h" -#include "../qmakeprojectmanagerconstants.h" - -#include <qtsupport/qtsupportconstants.h> -#include <qtsupport/baseqtversion.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/targetsetuppage.h> - -#include <QIcon> - -namespace QmakeProjectManager { -namespace Internal { - -class QtQuickAppWizardDialog : public AbstractMobileAppWizardDialog -{ - Q_OBJECT - -public: - explicit QtQuickAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters); - TemplateInfo templateInfo() const; - -protected: - void initializePage(int id); - -private: - QtQuickComponentSetPage *m_componentSetPage; -}; - -QtQuickAppWizardDialog::QtQuickAppWizardDialog(QWidget *parent, - const Core::WizardDialogParameters ¶meters) - : AbstractMobileAppWizardDialog(parent, - QtSupport::QtVersionNumber(4, 7, 0), - QtSupport::QtVersionNumber(5, INT_MAX, INT_MAX), parameters) -{ - setWindowTitle(tr("New Qt Quick Application")); - setIntroDescription(tr("This wizard generates a Qt Quick Application project.")); - - m_componentSetPage = new Internal::QtQuickComponentSetPage; - addPage(m_componentSetPage); - - addKitsPage(); - - setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK)); -} - -void QtQuickAppWizardDialog::initializePage(int id) -{ - if (page(id) == kitsPage()) { - QStringList stringList = - templateInfo().featuresRequired.split(QLatin1Char(','), QString::SkipEmptyParts); - Core::FeatureSet features; - foreach (const QString &string, stringList) { - Core::Feature feature(Core::Id::fromString(string.trimmed())); - features |= feature; - } - - setRequiredFeatures(features); - updateKitsPage(); - } - AbstractMobileAppWizardDialog::initializePage(id); -} - -TemplateInfo QtQuickAppWizardDialog::templateInfo() const -{ - return m_componentSetPage->templateInfo(); -} - - -class QtQuickAppWizardPrivate -{ - class QtQuickApp *app; - class QtQuickAppWizardDialog *wizardDialog; - friend class QtQuickAppWizard; -}; - -QtQuickAppWizard::QtQuickAppWizard() - : d(new QtQuickAppWizardPrivate) -{ - setWizardKind(ProjectWizard); - setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP))); - setId(QLatin1String("D.QMLA Application")); - setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); - setDisplayCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("Qt Quick Application")); - setDescription(tr("Creates a Qt Quick application project that can contain both QML and C++ code.")); - setRequiredFeatures(Core::Feature(QtSupport::Constants::FEATURE_QT_QUICK)); - - d->app = new QtQuickApp; - d->wizardDialog = 0; -} - -QtQuickAppWizard::~QtQuickAppWizard() -{ - delete d->app; - delete d; -} - -AbstractMobileAppWizardDialog *QtQuickAppWizard::createInternal(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const -{ - d->wizardDialog = new QtQuickAppWizardDialog(parent, parameters); - return d->wizardDialog; -} - -void QtQuickAppWizard::projectPathChanged(const QString &path) const -{ - if (d->wizardDialog->kitsPage()) - d->wizardDialog->kitsPage()->setProjectPath(path); -} - -void QtQuickAppWizard::prepareGenerateFiles(const QWizard *w, - QString *errorMessage) const -{ - Q_UNUSED(errorMessage) - const QtQuickAppWizardDialog *wizard = qobject_cast<const QtQuickAppWizardDialog*>(w); - d->app->setTemplateInfo(wizard->templateInfo()); -} - -QString QtQuickAppWizard::fileToOpenPostGeneration() const -{ - return d->app->path(QtQuickApp::MainQml); -} - -AbstractMobileApp *QtQuickAppWizard::app() const -{ - return d->app; -} - -AbstractMobileAppWizardDialog *QtQuickAppWizard::wizardDialog() const -{ - return d->wizardDialog; -} - -} // namespace Internal -} // namespace QmakeProjectManager - -#include "qtquickappwizard.moc" diff --git a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizardpages.cpp b/src/plugins/qmakeprojectmanager/wizards/qtquickappwizardpages.cpp deleted file mode 100644 index 25e1980b86f..00000000000 --- a/src/plugins/qmakeprojectmanager/wizards/qtquickappwizardpages.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qtquickappwizardpages.h" - -#include <utils/wizard.h> - -#include <QComboBox> -#include <QLabel> -#include <QVBoxLayout> - -namespace QmakeProjectManager { -namespace Internal { - -class QtQuickComponentSetPagePrivate -{ -public: - QComboBox *m_versionComboBox; - QLabel *m_descriptionLabel; -}; - -QtQuickComponentSetPage::QtQuickComponentSetPage(QWidget *parent) - : QWizardPage(parent) - , d(new QtQuickComponentSetPagePrivate) -{ - setTitle(tr("Select Qt Quick Component Set")); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - QHBoxLayout *l = new QHBoxLayout(); - - QLabel *label = new QLabel(tr("Qt Quick component set:"), this); - d->m_versionComboBox = new QComboBox(this); - - foreach (const TemplateInfo &templateInfo, QtQuickApp::templateInfos()) - d->m_versionComboBox->addItem(templateInfo.displayName); - - l->addWidget(label); - l->addWidget(d->m_versionComboBox); - - d->m_descriptionLabel = new QLabel(this); - d->m_descriptionLabel->setWordWrap(true); - d->m_descriptionLabel->setTextFormat(Qt::RichText); - connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(updateDescription(int))); - updateDescription(d->m_versionComboBox->currentIndex()); - - mainLayout->addLayout(l); - mainLayout->addWidget(d->m_descriptionLabel); - - setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Component Set")); -} - -QtQuickComponentSetPage::~QtQuickComponentSetPage() -{ - delete d; -} - -TemplateInfo QtQuickComponentSetPage::templateInfo() const -{ - if (QtQuickApp::templateInfos().isEmpty()) - return TemplateInfo(); - return QtQuickApp::templateInfos().at(d->m_versionComboBox->currentIndex()); -} - -void QtQuickComponentSetPage::updateDescription(int index) -{ - if (QtQuickApp::templateInfos().isEmpty()) - return; - - const TemplateInfo templateInfo = QtQuickApp::templateInfos().at(index); - d->m_descriptionLabel->setText(templateInfo.description); -} - -} // namespace Internal -} // namespace QmakeProjectManager diff --git a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp index c3f63374ed0..1fba31814ae 100644 --- a/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/subdirsprojectwizard.cpp @@ -43,7 +43,7 @@ namespace Internal { SubdirsProjectWizard::SubdirsProjectWizard() { - setId(QLatin1String("U.Qt4Subdirs")); + setId("U.Qt4Subdirs"); setCategory(QLatin1String(ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY)); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY_DISPLAY)); diff --git a/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp b/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp index f450ee78bd5..a64fc7d99c5 100644 --- a/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp +++ b/src/plugins/qmakeprojectmanager/wizards/testwizard.cpp @@ -47,7 +47,7 @@ namespace Internal { TestWizard::TestWizard() { - setId(QLatin1String("L.Qt4Test")); + setId("L.Qt4Test"); setCategory(QLatin1String(ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY)); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::QT_PROJECT_WIZARD_CATEGORY_DISPLAY)); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditornodeinstanceview.cpp b/src/plugins/qmldesigner/components/formeditor/formeditornodeinstanceview.cpp deleted file mode 100644 index 7083620226b..00000000000 --- a/src/plugins/qmldesigner/components/formeditor/formeditornodeinstanceview.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "formeditornodeinstanceview.h" -#include "formeditorview.h" - -#include <modelnode.h> -#include <QDebug> - - -namespace QmlDesigner { - -FormEditorNodeInstanceView::FormEditorNodeInstanceView(QObject * parent) : NodeInstanceView(parent) -{ - -} - -FormEditorNodeInstanceView::~FormEditorNodeInstanceView() -{ -} - -} diff --git a/src/plugins/qmldesigner/components/formeditor/manipulatorlayeritem.h b/src/plugins/qmldesigner/components/formeditor/manipulatorlayeritem.h deleted file mode 100644 index de50498dc89..00000000000 --- a/src/plugins/qmldesigner/components/formeditor/manipulatorlayeritem.h +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef MANIPULATORLAYERITEM_H -#define MANIPULATORLAYERITEM_H - -class ManipulatorLayerItem -{ -public: - ManipulatorLayerItem(); -}; - -#endif // MANIPULATORLAYERITEM_H diff --git a/src/plugins/qmldesigner/componentsplugin/images/busyindicator.png b/src/plugins/qmldesigner/componentsplugin/images/busyindicator.png Binary files differdeleted file mode 100644 index 3cf3c11ddbe..00000000000 --- a/src/plugins/qmldesigner/componentsplugin/images/busyindicator.png +++ /dev/null diff --git a/src/plugins/qmldesigner/componentsplugin/images/busyindicator16.png b/src/plugins/qmldesigner/componentsplugin/images/busyindicator16.png Binary files differdeleted file mode 100644 index 15e7f442a6b..00000000000 --- a/src/plugins/qmldesigner/componentsplugin/images/busyindicator16.png +++ /dev/null diff --git a/src/plugins/qmldesigner/componentsplugin/images/busyindicatora.png b/src/plugins/qmldesigner/componentsplugin/images/busyindicatora.png Binary files differdeleted file mode 100644 index 4cd7ad590a4..00000000000 --- a/src/plugins/qmldesigner/componentsplugin/images/busyindicatora.png +++ /dev/null diff --git a/src/plugins/qmldesigner/componentsplugin/images/busyindicatora16.png b/src/plugins/qmldesigner/componentsplugin/images/busyindicatora16.png Binary files differdeleted file mode 100644 index 2e6083c1c81..00000000000 --- a/src/plugins/qmldesigner/componentsplugin/images/busyindicatora16.png +++ /dev/null diff --git a/src/plugins/qmldesigner/designercore/designercore-lib.pri b/src/plugins/qmldesigner/designercore/designercore-lib.pri index 2704f9b1603..66dd1419690 100644 --- a/src/plugins/qmldesigner/designercore/designercore-lib.pri +++ b/src/plugins/qmldesigner/designercore/designercore-lib.pri @@ -1,8 +1,7 @@ include($$PWD/filemanager/filemanager.pri) include (../config.pri) -QT += script \ - network +QT += network DEFINES += TEST_EXPORTS DEFINES += DESIGNER_CORE_LIBRARY diff --git a/src/plugins/qmldesigner/designercore/exceptions/modificationgroupexception.cpp b/src/plugins/qmldesigner/designercore/exceptions/modificationgroupexception.cpp deleted file mode 100644 index 3272462a71b..00000000000 --- a/src/plugins/qmldesigner/designercore/exceptions/modificationgroupexception.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "modificationgroupexception.h" - -/*! -\class QmlDesigner::ModificationGroupException -\ingroup CoreExceptions -\brief The ModificationGroupException class provides an exception for a -modification group. - -*/ -namespace QmlDesigner { -/*! - Constructs an exception. \a line uses the __LINE__ macro, - \a function uses the __FUNCTION__ or the Q_FUNC_INFO macro, and \a file uses - the __FILE__ macro. -*/ -ModificationGroupException::ModificationGroupException(int line, - const QString &function, - const QString &file) - : Exception(line, function, file) -{ - createWarning(); -} - -/*! - Returns the type of the exception as a string. -*/ -QString ModificationGroupException::type() const -{ - return "ModificationGroupException"; -} - -} diff --git a/src/plugins/qmldesigner/designercore/include/replaceallobjectdefinitionsvisitor.h b/src/plugins/qmldesigner/designercore/include/replaceallobjectdefinitionsvisitor.h deleted file mode 100644 index a9e9bbc41a8..00000000000 --- a/src/plugins/qmldesigner/designercore/include/replaceallobjectdefinitionsvisitor.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef REPLACEALLOBJECTDEFINITIONSVISITOR_H -#define REPLACEALLOBJECTDEFINITIONSVISITOR_H - -#include "qmlrewriter.h" - -namespace QmlDesigner { -namespace Internal { - -class ReplaceAllObjectDefinitionsVisitor: public QMLRewriter -{ -public: - ReplaceAllObjectDefinitionsVisitor(TextModifier &textModifier, - const TextLocation &objectLocation, - const QString &newContent); - -protected: - virtual bool visit(QmlJS::AST::UiObjectDefinition *ast); - virtual bool visit(QmlJS::AST::UiObjectBinding *ast); - -private: - void replaceMembers(QmlJS::AST::UiObjectInitializer *initializer); - -private: - QString m_newContent; -}; - -} // namespace Internal -} // namespace QmlDesigner - -#endif // REPLACEALLOBJECTDEFINITIONSVISITOR_H diff --git a/src/plugins/qmldesigner/designercore/include/widgetplugin_helper.h b/src/plugins/qmldesigner/designercore/include/widgetplugin_helper.h deleted file mode 100644 index 40f45d550fe..00000000000 --- a/src/plugins/qmldesigner/designercore/include/widgetplugin_helper.h +++ /dev/null @@ -1,38 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef WIDGETPLUGIN_HELPER_H -#define WIDGETPLUGIN_HELPER_H - -#define QMLDESIGNER_REGISTER_WIDGET(TYPE) uiEngine->addObjectCreator(new QUiWidgetCreator<TYPE>(QStringLiteral(#TYPE))); -#define QMLDESIGNER_REGISTER_GRAPHICSWIDGET(TYPE) uiEngine->addObjectCreator(new QUiGraphicsWidgetCreator<TYPE>(QStringLiteral(#TYPE))); - -#endif //WIDGETPLUGIN_HELPER - diff --git a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp index 36b00dcaeb6..fe97abea273 100644 --- a/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp +++ b/src/plugins/qmldesigner/designercore/instances/puppetcreator.cpp @@ -463,14 +463,10 @@ bool PuppetCreator::qtIsSupported() const { QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitInformation::qtVersion(m_kit); - if (currentQtVersion + return currentQtVersion && currentQtVersion->isValid() && nonEarlyQt5Version(currentQtVersion->qtVersion()) - && (currentQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) - || currentQtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT))) - return true; - - return false; + && currentQtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT); } bool PuppetCreator::checkPuppetVersion(const QString &qmlPuppetPath) diff --git a/src/plugins/qmldesigner/designercore/model/bytearraymodifier.cpp b/src/plugins/qmldesigner/designercore/model/bytearraymodifier.cpp deleted file mode 100644 index cc2451ee802..00000000000 --- a/src/plugins/qmldesigner/designercore/model/bytearraymodifier.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bytearraymodifier.h" - -namespace QmlDesigner { - -ByteArrayModifier::ByteArrayModifier(QPlainTextEdit* textEdit): - PlainTextEditModifier(textEdit), - m_textEdit(textEdit) -{ -} - -ByteArrayModifier::~ByteArrayModifier() -{ - delete m_textEdit; -} - -void ByteArrayModifier::undo() -{ - m_textEdit->undo(); -} - -void ByteArrayModifier::redo() -{ - m_textEdit->redo(); -} - -ByteArrayModifier* ByteArrayModifier::create(const QString& data) -{ - QPlainTextEdit* edit = new QPlainTextEdit; - edit->setPlainText(data); - return new ByteArrayModifier(edit); -} - -void ByteArrayModifier::setText(const QString& text) -{ - m_textEdit->setPlainText(text); - emit textChanged(); -} - -} diff --git a/src/plugins/qmldesigner/designercore/model/modificationgrouptoken.cpp b/src/plugins/qmldesigner/designercore/model/modificationgrouptoken.cpp deleted file mode 100644 index 4330f9ec96d..00000000000 --- a/src/plugins/qmldesigner/designercore/model/modificationgrouptoken.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "modificationgrouptoken.h" - -namespace QmlDesigner { - -long ModificationGroupToken::uniqueNumberCounter = 0; - -ModificationGroupToken::ModificationGroupToken(unsigned depth): - m_depth(depth), - m_uniqueNumber(++uniqueNumberCounter) -{ -} - -} diff --git a/src/plugins/qmldesigner/designercore/model/nodeanchors.cpp b/src/plugins/qmldesigner/designercore/model/nodeanchors.cpp deleted file mode 100644 index 16f932648d5..00000000000 --- a/src/plugins/qmldesigner/designercore/model/nodeanchors.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -//#include "nodeanchors.h" -// -//#include <model.h> -//#include <modelnode.h> -// -//#include "internalnode_p.h" -//#include "internalnodeanchors.h" -//#include "internalnodestate.h" -//#include "invalidargumentexception.h" -// -//using namespace QmlDesigner::Internal; -// -//namespace QmlDesigner { -// -///*! -//\class QmlDesigner::NodeAnchors -//\ingroup CoreModel -//\brief NodeAnchors is a value holder for an anchor -//*/ -// -//NodeAnchors::NodeAnchors(const NodeState &nodeState): -// m_internalNode(nodeState.m_internalNode), -// m_internalNodeState(nodeState.m_internalNodeState), -// m_model(nodeState.m_model) -//{ -//} -// -//NodeAnchors::~NodeAnchors() -//{ -//} -// -//NodeAnchors::NodeAnchors(const NodeAnchors &other) -// :m_internalNode(other.m_internalNode), -// m_model(other.m_model) -//{ -// -//} -// -//NodeAnchors::NodeAnchors(const Internal::InternalNodeStatePointer &internalNodeState, Model *model): -// m_internalNode(internalNodeState->modelNode()), -// m_internalNodeState(internalNodeState), -// m_model(model) -//{ -//} -// -//NodeAnchors &NodeAnchors::operator=(const NodeAnchors &other) -//{ -// m_internalNode = other.m_internalNode; -// m_internalNodeState = other.m_internalNodeState; -// m_model = other.m_model; -// -// return *this; -//} -// -//ModelNode NodeAnchors::modelNode() const -//{ -// return ModelNode(m_internalNode, m_model.data()); -//} -// -//bool NodeAnchors::isValid() const -//{ -// return m_internalNode->isValid() -// && m_internalNodeState->isValid() && -// m_model; -//} -// -//NodeState NodeAnchors::nodeState() const -//{ -// return NodeState(m_internalNodeState, m_internalNode, m_model.data()); -//} -// -//void NodeAnchors::setAnchor(AnchorLine::Type sourceAnchorLineType, -// const ModelNode &targetModelNode, -// AnchorLine::Type targetAnchorLineType) -//{ -// Q_ASSERT(m_internalNode->isValid()); -// Q_ASSERT(m_internalNodeState->isValid()); -// Q_ASSERT(modelNode().isValid()); -// -// m_model->setAnchor(AnchorLine(nodeState(), sourceAnchorLineType), -// AnchorLine(targetModelNode.baseNodeState(), targetAnchorLineType)); -//} -// -//bool NodeAnchors::canAnchor(AnchorLine::Type sourceAnchorLineType, -// const ModelNode & targetModelNode, -// AnchorLine::Type targetAnchorLineType) const -//{ -// if (modelNode() == targetModelNode) -// return false; -// -// return InternalNodeAnchors(m_internalNodeState).canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), targetAnchorLineType); -//} -// -//bool NodeAnchors::canAnchor(const ModelNode & targetModelNode) const -//{ -// if (modelNode() == targetModelNode) -// return false; -// -// if (possibleAnchorLines(AnchorLine::Left, targetModelNode) != AnchorLine::NoAnchor) -// return true; -// else if (possibleAnchorLines(AnchorLine::Top, targetModelNode) != AnchorLine::NoAnchor) -// return true; -// else if (possibleAnchorLines(AnchorLine::Right, targetModelNode) != AnchorLine::NoAnchor) -// return true; -// else if (possibleAnchorLines(AnchorLine::Bottom, targetModelNode) != AnchorLine::NoAnchor) -// return true; -// else if (possibleAnchorLines(AnchorLine::HorizontalCenter, targetModelNode) != AnchorLine::NoAnchor) -// return true; -// else -// return possibleAnchorLines(AnchorLine::VerticalCenter, targetModelNode) != AnchorLine::NoAnchor; -//} -// -//AnchorLine::Type NodeAnchors::possibleAnchorLines(AnchorLine::Type sourceAnchorLineType, -// const ModelNode & targetModelNode) const -//{ -// if (modelNode() == targetModelNode) -// return AnchorLine::NoAnchor; -// -// int anchorTypes = AnchorLine::NoAnchor; -// const InternalNodeAnchors anchors(m_internalNodeState); -// -// if (sourceAnchorLineType & AnchorLine::HorizontalMask) { -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::Left)) -// anchorTypes |= AnchorLine::Left; -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::Right)) -// anchorTypes |= AnchorLine::Right; -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::HorizontalCenter)) -// anchorTypes |= AnchorLine::HorizontalCenter; -// } else if (sourceAnchorLineType & AnchorLine::VerticalMask) { -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::Top)) -// anchorTypes |= AnchorLine::Top; -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::Bottom)) -// anchorTypes |= AnchorLine::Bottom; -// if (anchors.canAnchor(sourceAnchorLineType, targetModelNode.baseNodeState().internalNodeState(), AnchorLine::VerticalCenter)) -// anchorTypes |= AnchorLine::VerticalCenter; -// } -// -// return (AnchorLine::Type) anchorTypes; -//} -// -//AnchorLine NodeAnchors::localAnchor(AnchorLine::Type anchorLineType) const -//{ -// return InternalNodeAnchors(m_internalNodeState).anchor(anchorLineType); -//} -// -//AnchorLine NodeAnchors::anchor(AnchorLine::Type anchorLineType) const -//{ -// Internal::InternalNodeState::Pointer statePointer(m_internalNodeState); -// AnchorLine anchorLine = InternalNodeAnchors(statePointer).anchor(anchorLineType); -// -// while (!anchorLine.isValid() && statePointer->hasParentState()) { -// statePointer = statePointer->parentState(); -// anchorLine = InternalNodeAnchors(statePointer).anchor(anchorLineType); -// } -// -// return anchorLine; -//} -// -//bool NodeAnchors::hasAnchor(AnchorLine::Type sourceAnchorLineType) const -//{ -// Internal::InternalNodeState::Pointer statePointer(m_internalNodeState); -// InternalNodeAnchors internalNodeAnchors(statePointer); -// while (!internalNodeAnchors.hasAnchor(sourceAnchorLineType) && -// statePointer->hasParentState()) { -// statePointer = statePointer->parentState(); -// internalNodeAnchors = InternalNodeAnchors(statePointer); -// } -// -// return internalNodeAnchors.hasAnchor(sourceAnchorLineType); -//} -// -//void NodeAnchors::removeAnchor(AnchorLine::Type sourceAnchorLineType) -//{ -// if (hasLocalAnchor(sourceAnchorLineType)) -// m_model->removeAnchor(AnchorLine(nodeState(), sourceAnchorLineType)); -//} -// -//void NodeAnchors::removeMargins() -//{ -// removeMargin(AnchorLine::Left); -// removeMargin(AnchorLine::Right); -// removeMargin(AnchorLine::Top); -// removeMargin(AnchorLine::Bottom); -// removeMargin(AnchorLine::HorizontalCenter); -// removeMargin(AnchorLine::VerticalCenter); -// removeMargin(AnchorLine::Baseline); -//} -// -//void NodeAnchors::removeAnchors() -//{ -// removeAnchor(AnchorLine::Left); -// removeAnchor(AnchorLine::Right); -// removeAnchor(AnchorLine::Top); -// removeAnchor(AnchorLine::Bottom); -// removeAnchor(AnchorLine::HorizontalCenter); -// removeAnchor(AnchorLine::VerticalCenter); -// removeAnchor(AnchorLine::Baseline); -//} -// -//bool NodeAnchors::hasLocalAnchor(AnchorLine::Type sourceAnchorLineType) const -//{ -// return InternalNodeAnchors(m_internalNodeState).hasAnchor(sourceAnchorLineType); -//} -// -//bool NodeAnchors::hasLocalAnchors() const -//{ -// return hasLocalAnchor(AnchorLine::Top) || -// hasLocalAnchor(AnchorLine::Bottom) || -// hasLocalAnchor(AnchorLine::Left) || -// hasLocalAnchor(AnchorLine::Right) || -// hasLocalAnchor(AnchorLine::VerticalCenter) || -// hasLocalAnchor(AnchorLine::HorizontalCenter) || -// hasLocalAnchor(AnchorLine::Baseline); -//} -// -//bool NodeAnchors::hasAnchors() const -//{ -// return hasAnchor(AnchorLine::Top) || -// hasAnchor(AnchorLine::Bottom) || -// hasAnchor(AnchorLine::Left) || -// hasAnchor(AnchorLine::Right) || -// hasAnchor(AnchorLine::VerticalCenter) || -// hasAnchor(AnchorLine::HorizontalCenter) || -// hasAnchor(AnchorLine::Baseline); -//} -// -//void NodeAnchors::setMargin(AnchorLine::Type sourceAnchorLineType, double margin) const -//{ -// m_model->setAnchorMargin(AnchorLine(nodeState(), sourceAnchorLineType), margin); -//} -// -//bool NodeAnchors::hasMargin(AnchorLine::Type sourceAnchorLineType) const -//{ -// return InternalNodeAnchors(m_internalNodeState).hasMargin(sourceAnchorLineType); -//} -// -//double NodeAnchors::localMargin(AnchorLine::Type sourceAnchorLineType) const -//{ -// return InternalNodeAnchors(m_internalNodeState).margin(sourceAnchorLineType); -//} -// -//double NodeAnchors::margin(AnchorLine::Type sourceAnchorLineType) const -//{ -// Internal::InternalNodeState::Pointer statePointer(m_internalNodeState); -// InternalNodeAnchors internalNodeAnchors(statePointer); -// while (!internalNodeAnchors.hasMargin(sourceAnchorLineType) && -// statePointer->hasParentState()) { -// statePointer = statePointer->parentState(); -// internalNodeAnchors = InternalNodeAnchors(statePointer); -// } -// -// return internalNodeAnchors.margin(sourceAnchorLineType); -//} -// -//void NodeAnchors::removeMargin(AnchorLine::Type sourceAnchorLineType) -//{ -// m_model->removeAnchorMargin(AnchorLine(nodeState(), sourceAnchorLineType)); -// -//} -// -//QDebug operator<<(QDebug debug, const NodeAnchors &anchors) -//{ -// debug.nospace() << "NodeAnchors("; -// if (anchors.isValid()) { -// if (anchors.hasAnchor(AnchorLine::Top)) -// debug << "top"; -// if (anchors.hasMargin(AnchorLine::Top)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::Top) << ")"; -// if (anchors.hasAnchor(AnchorLine::Bottom)) -// debug << "bottom"; -// if (anchors.hasMargin(AnchorLine::Bottom)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::Bottom) << ")"; -// if (anchors.hasAnchor(AnchorLine::Left)) -// debug << "left"; -// if (anchors.hasMargin(AnchorLine::Left)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::Left) << ")"; -// if (anchors.hasAnchor(AnchorLine::Right)) -// debug << "right"; -// if (anchors.hasMargin(AnchorLine::Right)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::Right) << ")"; -// if (anchors.hasAnchor(AnchorLine::VerticalCenter)) -// debug << "verticalCenter"; -// if (anchors.hasMargin(AnchorLine::VerticalCenter)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::VerticalCenter) << ")"; -// if (anchors.hasAnchor(AnchorLine::HorizontalCenter)) -// debug << "horizontalCenter"; -// if (anchors.hasMargin(AnchorLine::HorizontalCenter)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::HorizontalCenter) << ")"; -// if (anchors.hasAnchor(AnchorLine::Baseline)) -// debug << "baseline"; -// if (anchors.hasMargin(AnchorLine::Baseline)) -// debug.nospace() << "(" << anchors.margin(AnchorLine::Baseline) << ")"; -// } else { -// debug.nospace() << "invalid"; -// } -// -// debug.nospace() << ")"; -// -// return debug.space(); -//} -// -//QTextStream& operator<<(QTextStream &stream, const NodeAnchors &anchors) -//{ -// stream << "NodeAnchors("; -// if (anchors.isValid()) { -// if (anchors.hasAnchor(AnchorLine::Top)) -// stream << "top"; -// if (anchors.hasMargin(AnchorLine::Top)) -// stream << "(" << anchors.margin(AnchorLine::Top) << ")"; -// if (anchors.hasAnchor(AnchorLine::Bottom)) -// stream << "bottom"; -// if (anchors.hasMargin(AnchorLine::Bottom)) -// stream << "(" << anchors.margin(AnchorLine::Bottom) << ")"; -// if (anchors.hasAnchor(AnchorLine::Left)) -// stream << "left"; -// if (anchors.hasMargin(AnchorLine::Left)) -// stream << "(" << anchors.margin(AnchorLine::Left) << ")"; -// if (anchors.hasAnchor(AnchorLine::Right)) -// stream << "right"; -// if (anchors.hasMargin(AnchorLine::Right)) -// stream << "(" << anchors.margin(AnchorLine::Right) << ")"; -// if (anchors.hasAnchor(AnchorLine::VerticalCenter)) -// stream << "verticalCenter"; -// if (anchors.hasMargin(AnchorLine::VerticalCenter)) -// stream << "(" << anchors.margin(AnchorLine::VerticalCenter) << ")"; -// if (anchors.hasAnchor(AnchorLine::HorizontalCenter)) -// stream << "horizontalCenter"; -// if (anchors.hasMargin(AnchorLine::HorizontalCenter)) -// stream << "(" << anchors.margin(AnchorLine::HorizontalCenter) << ")"; -// if (anchors.hasAnchor(AnchorLine::Baseline)) -// stream << "baseline"; -// if (anchors.hasMargin(AnchorLine::Baseline)) -// stream << "(" << anchors.margin(AnchorLine::Baseline) << ")"; -// } else { -// stream << "invalid"; -// } -// -// stream << ")"; -// -// return stream; -//} -// -// -//} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/propertybinding.cpp b/src/plugins/qmldesigner/designercore/model/propertybinding.cpp deleted file mode 100644 index ec2f2b6cbb2..00000000000 --- a/src/plugins/qmldesigner/designercore/model/propertybinding.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "propertybinding.h" -#include "invalidpropertyexception.h" - -namespace QmlDesigner { - -PropertyBinding::PropertyBinding() -{ -} - -PropertyBinding::PropertyBinding(const QString &value): - m_value(value) -{ -} - -PropertyBinding::PropertyBinding(const PropertyBinding &other): - m_value(other.m_value) -{ -} - -PropertyBinding &PropertyBinding::operator=(const PropertyBinding &other) -{ - m_value = other.m_value; - - return *this; -} - -bool PropertyBinding::isValid() const -{ - return !m_value.isEmpty(); -} - -QString PropertyBinding::value() const -{ - return m_value; -} - - -} // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp index fda7c9bb93a..4ce998fc454 100644 --- a/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/texttomodelmerger.cpp @@ -66,8 +66,7 @@ namespace { static inline QStringList supportedVersionsList() { QStringList list; - list << QStringLiteral("1.0") << QStringLiteral("1.1") - << QStringLiteral("2.0") << QStringLiteral("2.1") + list << QStringLiteral("2.0") << QStringLiteral("2.1") << QStringLiteral("2.2") << QStringLiteral("2.3") << QStringLiteral("2.4"); return list; diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index c1af7211134..13a85a8c5fc 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -36,6 +36,7 @@ #include "qmljseditordocument.h" #include "qmljseditorplugin.h" #include "qmljsfindreferences.h" +#include "qmljshighlighter.h" #include "qmljshoverhandler.h" #include "qmljsquickfixassist.h" #include "qmloutlinemodel.h" @@ -72,10 +73,10 @@ #include <texteditor/codeassist/genericproposalmodel.h> #include <texteditor/texteditoractionhandler.h> +#include <utils/annotateditemdelegate.h> #include <utils/changeset.h> -#include <utils/uncommentselection.h> #include <utils/qtcassert.h> -#include <utils/annotateditemdelegate.h> +#include <utils/uncommentselection.h> #include <QComboBox> #include <QCoreApplication> @@ -556,6 +557,166 @@ void QmlJSEditorWidget::createToolBar() insertExtraToolBarWidget(TextEditorWidget::Left, m_outlineCombo); } +class CodeModelInspector : public MemberProcessor +{ +public: + explicit CodeModelInspector(const CppComponentValue *processingValue, QTextStream *stream) : + m_processingValue(processingValue), + m_stream(stream), + m_indent(QLatin1String(" ")) + { + } + + bool processProperty(const QString &name, const Value *value, + const PropertyInfo &propertyInfo) override + { + QString type; + if (const CppComponentValue *cpp = value->asCppComponentValue()) + type = cpp->metaObject()->className(); + else + type = m_processingValue->propertyType(name); + + if (propertyInfo.isList()) + type = QStringLiteral("list<%1>").arg(type); + + *m_stream << m_indent; + if (!propertyInfo.isWriteable()) + *m_stream << "readonly "; + *m_stream << "property " << type << " " << name << endl; + + return true; + } + bool processSignal(const QString &name, const Value *value) override + { + *m_stream << m_indent << "signal " << name << stringifyFunctionParameters(value) << endl; + return true; + } + bool processSlot(const QString &name, const Value *value) override + { + *m_stream << m_indent << "function " << name << stringifyFunctionParameters(value) << endl; + return true; + } + bool processGeneratedSlot(const QString &name, const Value *value) override + { + *m_stream << m_indent << "/*generated*/ function " << name + << stringifyFunctionParameters(value) << endl; + return true; + } + +private: + QString stringifyFunctionParameters(const Value *value) const + { + QStringList params; + const QmlJS::MetaFunction *metaFunction = value->asMetaFunction(); + if (metaFunction) { + QStringList paramNames = metaFunction->fakeMetaMethod().parameterNames(); + QStringList paramTypes = metaFunction->fakeMetaMethod().parameterTypes(); + for (int i = 0; i < paramTypes.size(); ++i) { + QString typeAndNamePair = paramTypes.at(i); + if (paramNames.size() > i) { + QString paramName = paramNames.at(i); + if (!paramName.isEmpty()) + typeAndNamePair += QLatin1Char(' ') + paramName; + } + params.append(typeAndNamePair); + } + } + return QLatin1Char('(') + params.join(QLatin1String(", ")) + QLatin1Char(')'); + } + +private: + const CppComponentValue *m_processingValue; + QTextStream *m_stream; + const QString m_indent; +}; + +static const CppComponentValue *findCppComponentToInspect(const SemanticInfo &semanticInfo, + const unsigned cursorPosition) +{ + AST::Node *node = semanticInfo.astNodeAt(cursorPosition); + if (!node) + return 0; + + const ScopeChain scopeChain = semanticInfo.scopeChain(semanticInfo.rangePath(cursorPosition)); + Evaluate evaluator(&scopeChain); + const Value *value = evaluator.reference(node); + if (!value) + return 0; + + return value->asCppComponentValue(); +} + +static QString inspectCppComponent(const CppComponentValue *cppValue) +{ + QString result; + QTextStream bufWriter(&result); + + // for QtObject + QString superClassName = cppValue->metaObject()->superclassName(); + if (superClassName.isEmpty()) + superClassName = cppValue->metaObject()->className(); + + bufWriter << "import QtQuick " << cppValue->importVersion().toString() << endl + << "// " << cppValue->metaObject()->className() + << " imported as " << cppValue->moduleName() << " " + << cppValue->importVersion().toString() << endl + << endl + << superClassName << " {" << endl; + + CodeModelInspector insp(cppValue, &bufWriter); + cppValue->processMembers(&insp); + + bufWriter << endl; + const int enumeratorCount = cppValue->metaObject()->enumeratorCount(); + for (int index = cppValue->metaObject()->enumeratorOffset(); index < enumeratorCount; ++index) { + LanguageUtils::FakeMetaEnum enumerator = cppValue->metaObject()->enumerator(index); + bufWriter << " // Enum " << enumerator.name() << " { " << + enumerator.keys().join(QLatin1Char(',')) << " }" << endl; + } + + bufWriter << "}" << endl; + return result; +} + +void QmlJSEditorWidget::inspectElementUnderCursor() const +{ + const QTextCursor cursor = textCursor(); + + const unsigned cursorPosition = cursor.position(); + const SemanticInfo semanticInfo = m_qmlJsEditorDocument->semanticInfo(); + if (!semanticInfo.isValid()) + return; + + const CppComponentValue *cppValue = findCppComponentToInspect(semanticInfo, cursorPosition); + if (!cppValue) { + QString title = tr("Code Model Not Available"); + const QString nothingToShow = QStringLiteral("nothingToShow"); + EditorManager::openEditorWithContents(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title, + tr("Code model not available.").toUtf8(), nothingToShow, + EditorManager::IgnoreNavigationHistory); + return; + } + + QString title = tr("Code Model of %1").arg(cppValue->metaObject()->className()); + IEditor *outputEditor = EditorManager::openEditorWithContents( + Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title, QByteArray(), + cppValue->metaObject()->className(), EditorManager::IgnoreNavigationHistory); + + if (!outputEditor) + return; + + auto widget = qobject_cast<TextEditor::TextEditorWidget *>(outputEditor->widget()); + if (!widget) + return; + + widget->setReadOnly(true); + widget->textDocument()->setTemporary(true); + widget->textDocument()->setSyntaxHighlighter(new QmlJSHighlighter(widget->document())); + + const QString buf = inspectCppComponent(cppValue); + widget->textDocument()->setPlainText(buf); +} + TextEditorWidget::Link QmlJSEditorWidget::findLinkAt(const QTextCursor &cursor, bool /*resolveTarget*/, bool /*inNextSplit*/) diff --git a/src/plugins/qmljseditor/qmljseditor.h b/src/plugins/qmljseditor/qmljseditor.h index 0f126c9504f..475aa62ff31 100644 --- a/src/plugins/qmljseditor/qmljseditor.h +++ b/src/plugins/qmljseditor/qmljseditor.h @@ -75,6 +75,9 @@ public: TextEditor::AssistInterface *createAssistInterface(TextEditor::AssistKind assistKind, TextEditor::AssistReason reason) const; + + void inspectElementUnderCursor() const; + public slots: void findUsages(); void renameUsages(); diff --git a/src/plugins/qmljseditor/qmljseditor.pro b/src/plugins/qmljseditor/qmljseditor.pro index 3cbd8cb59dd..450feb25b1a 100644 --- a/src/plugins/qmljseditor/qmljseditor.pro +++ b/src/plugins/qmljseditor/qmljseditor.pro @@ -1,5 +1,4 @@ include(../../qtcreatorplugin.pri) -QT += script DEFINES += \ QMLJSEDITOR_LIBRARY diff --git a/src/plugins/qmljseditor/qmljseditor.qbs b/src/plugins/qmljseditor/qmljseditor.qbs index a4296540920..139f13cba11 100644 --- a/src/plugins/qmljseditor/qmljseditor.qbs +++ b/src/plugins/qmljseditor/qmljseditor.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "QmlJSEditor" Depends { name: "Qt"; submodules: ["widgets", "script"] } - Depends { name: "Aggregation" } Depends { name: "LanguageUtils" } Depends { name: "Utils" } Depends { name: "QmlEditorWidgets" } diff --git a/src/plugins/qmljseditor/qmljseditor_dependencies.pri b/src/plugins/qmljseditor/qmljseditor_dependencies.pri index 00faea24218..92092ea1eb1 100644 --- a/src/plugins/qmljseditor/qmljseditor_dependencies.pri +++ b/src/plugins/qmljseditor/qmljseditor_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = QmlJSEditor QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ languageutils \ qmljs \ diff --git a/src/plugins/qmljseditor/qmljseditorconstants.h b/src/plugins/qmljseditor/qmljseditorconstants.h index 7dde902b7ff..9ae56afd15b 100644 --- a/src/plugins/qmljseditor/qmljseditorconstants.h +++ b/src/plugins/qmljseditor/qmljseditorconstants.h @@ -51,6 +51,7 @@ const char RENAME_USAGES[] = "QmlJSEditor.RenameUsages"; const char RUN_SEMANTIC_SCAN[] = "QmlJSEditor.RunSemanticScan"; const char REFORMAT_FILE[] = "QmlJSEditor.ReformatFile"; const char SHOW_QT_QUICK_HELPER[] = "QmlJSEditor.ShowQtQuickHelper"; +const char INSPECT_ELEMENT_UNDER_CURSOR[] = "QmlJSEditor.InspectElementUnderCursor"; const char TASK_CATEGORY_QML[] = "Task.Category.Qml"; const char TASK_CATEGORY_QML_ANALYSIS[] = "Task.Category.QmlAnalysis"; diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 557935896b2..cf6f201e361 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -158,6 +158,15 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e connect(m_reformatFileAction, SIGNAL(triggered()), this, SLOT(reformatFile())); qmlToolsMenu->addAction(cmd); + QAction *inspectElementAction = new QAction(tr("Inspect API for Element Under Cursor"), this); + cmd = ActionManager::registerAction(inspectElementAction, + Id(Constants::INSPECT_ELEMENT_UNDER_CURSOR), context); + connect(inspectElementAction, &QAction::triggered, [] { + if (auto widget = qobject_cast<QmlJSEditorWidget *>(EditorManager::currentEditor()->widget())) + widget->inspectElementUnderCursor(); + }); + qmlToolsMenu->addAction(cmd); + QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this); cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); cmd->setDefaultKeySequence(UseMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space) diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index c02cb6e094b..e5216eaeee3 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -110,9 +110,7 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( if (!setPreferDump && qtVersion) preferDebugDump = (qtVersion->defaultBuildConfig() & QtSupport::BaseQtVersion::DebugBuild); if (qtVersion && qtVersion->isValid()) { - projectInfo.tryQmlDump = project && ( - qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) - || qtVersion->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)); + projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT); projectInfo.qtQmlPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_QML")).canonicalFilePath(); projectInfo.qtImportsPath = QFileInfo(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")).canonicalFilePath(); projectInfo.qtVersionString = qtVersion->qtVersionString(); diff --git a/src/plugins/qmlprofiler/qmlprofiler.qbs b/src/plugins/qmlprofiler/qmlprofiler.qbs index aedf53224c2..d70309f10b7 100644 --- a/src/plugins/qmlprofiler/qmlprofiler.qbs +++ b/src/plugins/qmlprofiler/qmlprofiler.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "QmlProfiler" Depends { name: "Qt"; submodules: ["widgets", "network", "quick", "quickwidgets"] } - Depends { name: "Aggregation" } Depends { name: "QmlJS" } Depends { name: "QmlDebug" } Depends { name: "QtcSsh" } diff --git a/src/plugins/qmlprofiler/qmlprofiler_dependencies.pri b/src/plugins/qmlprofiler/qmlprofiler_dependencies.pri index 114c006d9f5..401f0fa51f3 100644 --- a/src/plugins/qmlprofiler/qmlprofiler_dependencies.pri +++ b/src/plugins/qmlprofiler/qmlprofiler_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = QmlProfiler QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmldebug \ qmljs \ diff --git a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp index b75e0ca5032..059d39dbe85 100644 --- a/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerbindingloopsrenderpass.cpp @@ -40,17 +40,27 @@ public: BindingLoopMaterial(); }; -struct BindingLoopsRenderPassState : public Timeline::TimelineRenderPass::State { - BindingLoopsRenderPassState() : indexFrom(std::numeric_limits<int>::max()), indexTo(-1) {} - BindingLoopMaterial material; - int indexFrom; - int indexTo; +class BindingLoopsRenderPassState : public Timeline::TimelineRenderPass::State { +public: + BindingLoopsRenderPassState(const QmlProfilerRangeModel *model); + ~BindingLoopsRenderPassState(); - QVector<QSGNode *> m_expandedRows; + BindingLoopMaterial *material() { return &m_material; } + void updateIndexes(int from, int to); + + int indexFrom() const { return m_indexFrom; } + int indexTo() const { return m_indexTo; } + + QSGNode *expandedRow(int row) const { return m_expandedRows[row]; } const QVector<QSGNode *> &expandedRows() const { return m_expandedRows; } + QSGNode *collapsedOverlay() const { return m_collapsedOverlay; } +private: + QVector<QSGNode *> m_expandedRows; QSGNode *m_collapsedOverlay; - QSGNode *collapsedOverlay() const { return m_collapsedOverlay; } + BindingLoopMaterial m_material; + int m_indexFrom; + int m_indexTo; }; struct Point2DWithOffset { @@ -111,14 +121,14 @@ void updateNodes(const QmlProfilerRangeModel *model, int from, int to, for (int i = 0; i < model->expandedRowCount(); ++i) { BindlingLoopsGeometry &row = expandedPerRow[i]; if (row.usedVertices > 0) { - row.allocate(&state->material); - state->m_expandedRows[i]->appendChildNode(row.node); + row.allocate(state->material()); + state->expandedRow(i)->appendChildNode(row.node); } } if (collapsed.usedVertices > 0) { - collapsed.allocate(&state->material); - state->m_collapsedOverlay->appendChildNode(collapsed.node); + collapsed.allocate(state->material()); + state->collapsedOverlay()->appendChildNode(collapsed.node); } int rowHeight = Timeline::TimelineModel::defaultRowHeight(); @@ -163,25 +173,20 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update( return oldState; BindingLoopsRenderPassState *state; - if (oldState == 0) { - state = new BindingLoopsRenderPassState; - state->m_expandedRows.reserve(model->expandedRowCount()); - for (int i = 0; i < model->expandedRowCount(); ++i) - state->m_expandedRows << new QSGNode; - state->m_collapsedOverlay = new QSGNode; - } else { + if (oldState == 0) + state = new BindingLoopsRenderPassState(model); + else state = static_cast<BindingLoopsRenderPassState *>(oldState); - } - if (state->indexFrom < state->indexTo) { - if (indexFrom < state->indexFrom) { - for (int i = indexFrom; i < state->indexFrom; + if (state->indexFrom() < state->indexTo()) { + if (indexFrom < state->indexFrom()) { + for (int i = indexFrom; i < state->indexFrom(); i += BindlingLoopsGeometry::maxEventsPerNode) updateNodes(model, i, qMin(i + BindlingLoopsGeometry::maxEventsPerNode, - state->indexFrom), parentState, state); + state->indexFrom()), parentState, state); } - if (indexTo > state->indexTo) { - for (int i = state->indexTo; i < indexTo; i+= BindlingLoopsGeometry::maxEventsPerNode) + if (indexTo > state->indexTo()) { + for (int i = state->indexTo(); i < indexTo; i+= BindlingLoopsGeometry::maxEventsPerNode) updateNodes(model, i, qMin(i + BindlingLoopsGeometry::maxEventsPerNode, indexTo), parentState, state); } @@ -191,8 +196,7 @@ Timeline::TimelineRenderPass::State *QmlProfilerBindingLoopsRenderPass::update( parentState, state); } - state->indexFrom = qMin(state->indexFrom, indexFrom); - state->indexTo = qMax(state->indexTo, indexTo); + state->updateIndexes(indexFrom, indexTo); return state; } @@ -354,6 +358,32 @@ void Point2DWithOffset::set(float nx, float ny, float nx2, float ny2) x = nx; y = ny; x2 = nx2; y2 = ny2; } +BindingLoopsRenderPassState::BindingLoopsRenderPassState(const QmlProfilerRangeModel *model) : + m_indexFrom(std::numeric_limits<int>::max()), m_indexTo(-1) +{ + m_collapsedOverlay = new QSGNode; + m_collapsedOverlay->setFlag(QSGNode::OwnedByParent, false); + m_expandedRows.reserve(model->expandedRowCount()); + for (int i = 0; i < model->expandedRowCount(); ++i) { + QSGNode *node = new QSGNode; + node->setFlag(QSGNode::OwnedByParent, false); + m_expandedRows << node; + } +} + +BindingLoopsRenderPassState::~BindingLoopsRenderPassState() +{ + delete m_collapsedOverlay; + qDeleteAll(m_expandedRows); +} + +void BindingLoopsRenderPassState::updateIndexes(int from, int to) +{ + if (from < m_indexFrom) + m_indexFrom = from; + if (to > m_indexTo) + m_indexTo = to; +} } } diff --git a/src/plugins/qmlprofiler/qmlprofilerconstants.h b/src/plugins/qmlprofiler/qmlprofilerconstants.h index c3ba93d652a..8addadce456 100644 --- a/src/plugins/qmlprofiler/qmlprofilerconstants.h +++ b/src/plugins/qmlprofiler/qmlprofilerconstants.h @@ -36,6 +36,8 @@ namespace Constants { const char ATTACH[] = "Menu.Analyzer.Attach"; const char TraceFileExtension[] = ".qtd"; +const char TASK_LOAD[] = "QmlProfiler.TaskLoad"; +const char TASK_SAVE[] = "QmlProfiler.TaskSave"; } // namespace Constants } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp index 0174a51090c..91473e7dbb0 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.cpp @@ -29,11 +29,14 @@ ****************************************************************************/ #include "qmlprofilermodelmanager.h" +#include "qmlprofilerconstants.h" #include "qmlprofilerdatamodel.h" #include "qv8profilerdatamodel.h" #include "qmlprofilertracefile.h" #include "qmlprofilernotesmodel.h" +#include <coreplugin/progressmanager/progressmanager.h> +#include <utils/runextensions.h> #include <utils/qtcassert.h> #include <QDebug> @@ -334,7 +337,6 @@ void QmlProfilerModelManager::complete() // Load notes after the timeline models have been initialized. d->notesModel->loadData(); setState(QmlProfilerDataState::Done); - emit dataAvailable(); break; case QmlProfilerDataState::AcquiringData: // Make sure the trace fits into the time span. @@ -363,20 +365,31 @@ void QmlProfilerModelManager::modelProcessingDone() void QmlProfilerModelManager::save(const QString &filename) { - QFile file(filename); - if (!file.open(QIODevice::WriteOnly)) { + QFile *file = new QFile(filename); + if (!file->open(QIODevice::WriteOnly)) { emit error(tr("Could not open %1 for writing.").arg(filename)); + delete file; + emit saveFinished(); return; } - QmlProfilerFileWriter writer; - d->notesModel->saveData(); - writer.setTraceTime(traceTime()->startTime(), traceTime()->endTime(), traceTime()->duration()); - writer.setV8DataModel(d->v8Model); - writer.setQmlEvents(d->model->getEventTypes(), d->model->getEvents()); - writer.setNotes(d->model->getEventNotes()); - writer.save(&file); + + QFuture<void> result = QtConcurrent::run<void>([this, file] (QFutureInterface<void> &future) { + QmlProfilerFileWriter writer; + writer.setTraceTime(traceTime()->startTime(), traceTime()->endTime(), + traceTime()->duration()); + writer.setV8DataModel(d->v8Model); + writer.setQmlEvents(d->model->getEventTypes(), d->model->getEvents()); + writer.setNotes(d->model->getEventNotes()); + writer.setFuture(&future); + writer.save(file); + file->deleteLater(); + QMetaObject::invokeMethod(this, "saveFinished", Qt::QueuedConnection); + }); + + Core::ProgressManager::addTask(result, tr("Saving Trace Data"), Constants::TASK_SAVE, + Core::ProgressManager::ShowInApplicationIcon); } void QmlProfilerModelManager::load(const QString &filename) @@ -392,27 +405,33 @@ void QmlProfilerModelManager::setFilename(const QString &filename) void QmlProfilerModelManager::load() { - QString filename = d->fileName; - - QFile file(filename); - - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - emit error(tr("Could not open %1 for reading.").arg(filename)); + QFile *file = new QFile(d->fileName, this); + if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) { + emit error(tr("Could not open %1 for reading.").arg(d->fileName)); + delete file; + emit loadFinished(); return; } - // erase current clear(); - setState(QmlProfilerDataState::AcquiringData); - QmlProfilerFileReader reader; - connect(&reader, SIGNAL(error(QString)), this, SIGNAL(error(QString))); - reader.setV8DataModel(d->v8Model); - reader.setQmlDataModel(d->model); - reader.load(&file); + QFuture<void> result = QtConcurrent::run<void>([this, file] (QFutureInterface<void> &future) { + QmlProfilerFileReader reader; + reader.setFuture(&future); + connect(&reader, &QmlProfilerFileReader::error, this, &QmlProfilerModelManager::error); + reader.setV8DataModel(d->v8Model); + reader.setQmlDataModel(d->model); + reader.load(file); + file->close(); + file->deleteLater(); + + // The completion step uses the old progress display widget for now. + complete(); + QMetaObject::invokeMethod(this, "loadFinished", Qt::QueuedConnection); + }); - complete(); + Core::ProgressManager::addTask(result, tr("Loading Trace Data"), Constants::TASK_LOAD); } diff --git a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h index 775e69da9ae..a90e7b98bf1 100644 --- a/src/plugins/qmlprofiler/qmlprofilermodelmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilermodelmanager.h @@ -136,7 +136,8 @@ signals: void error(const QString &error); void stateChanged(); void progressChanged(); - void dataAvailable(); + void loadFinished(); + void saveFinished(); void requestDetailsForLocation(int eventType, const QmlDebug::QmlEventLocation &location); void availableFeaturesChanged(quint64 features); @@ -161,6 +162,7 @@ public slots: void load(); void newTimeEstimation(qint64 estimation); + private: void setState(QmlProfilerDataState::State state); diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 5bfdf53e64c..586055f8dbd 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -56,6 +56,7 @@ #include <coreplugin/coreconstants.h> #include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/find/findplugin.h> #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> #include <coreplugin/helpmanager.h> @@ -109,11 +110,8 @@ public: QTime m_recordingElapsedTime; QLabel *m_timeLabel; - // search field + // open search QToolButton *m_searchButton; - QLineEdit *m_searchField; - QTimer *m_searchFieldTimer; - int m_lastSearchResult; // save and load actions QAction *m_saveQmlTrace; @@ -132,9 +130,6 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) d->m_clearButton = 0; d->m_timeLabel = 0; d->m_searchButton = 0; - d->m_searchField = 0; - d->m_searchFieldTimer = 0; - d->m_lastSearchResult = -1; d->m_profilerState = new QmlProfilerStateManager(this); connect(d->m_profilerState, SIGNAL(stateChanged()), this, SLOT(profilerStateChanged())); @@ -150,6 +145,10 @@ QmlProfilerTool::QmlProfilerTool(QObject *parent) connect(d->m_profilerModelManager, SIGNAL(error(QString)), this, SLOT(showErrorDialog(QString))); connect(d->m_profilerModelManager, SIGNAL(availableFeaturesChanged(quint64)), this, SLOT(setAvailableFeatures(quint64))); + connect(d->m_profilerModelManager, &QmlProfilerModelManager::saveFinished, + this, &QmlProfilerTool::onLoadSaveFinished); + connect(d->m_profilerModelManager, &QmlProfilerModelManager::loadFinished, + this, &QmlProfilerTool::onLoadSaveFinished); d->m_profilerConnections->setModelManager(d->m_profilerModelManager); Command *command = 0; @@ -295,28 +294,10 @@ QWidget *QmlProfilerTool::createWidgets() d->m_searchButton = new QToolButton; d->m_searchButton->setIcon(QIcon(QStringLiteral(":/timeline/ico_zoom.png"))); - d->m_searchButton->setToolTip(tr("Toggle the event search field.")); - d->m_searchButton->setCheckable(true); + d->m_searchButton->setToolTip(tr("Search timeline event notes.")); layout->addWidget(d->m_searchButton); - d->m_searchField = new QLineEdit; - d->m_searchField->setToolTip(tr("Find events that have a specific note.")); - d->m_searchField->hide(); - layout->addWidget(d->m_searchField); - - connect(d->m_searchButton, &QToolButton::toggled, [this] (bool checked) { - d->m_searchField->setVisible(checked); - if (checked) { - d->m_searchButton->setText(d->m_searchButton->text() + QLatin1Char(':')); - d->m_searchField->setFocus(); - d->m_searchField->selectAll(); - } else { - QString str = d->m_searchButton->text(); - str.chop(1); - d->m_searchButton->setText(str); - } - }); - connect(d->m_searchField, &QLineEdit::returnPressed, this, &QmlProfilerTool::findEvent); + connect(d->m_searchButton, &QToolButton::clicked, this, &QmlProfilerTool::showTimeLineSearch); layout->addStretch(); toolbarWidget->setLayout(layout); @@ -433,43 +414,10 @@ void QmlProfilerTool::updateTimeDisplay() d->m_timeLabel->setText(tr("Elapsed: %1").arg(profilerTimeStr)); } -void QmlProfilerTool::findEvent() +void QmlProfilerTool::showTimeLineSearch() { - const QString substr = d->m_searchField->text(); - QmlProfilerNotesModel *model = d->m_profilerModelManager->notesModel(); - - bool found = false; - forever { - for (int i = d->m_lastSearchResult + 1; i < model->count(); ++i) { - if (model->text(i).contains(substr)) { - d->m_lastSearchResult = i; - found = true; - break; - } - } - if (found || d->m_lastSearchResult == -1) - break; - d->m_lastSearchResult = -1; - } - - if (found) { - emit selectTimelineElement(model->timelineModel(d->m_lastSearchResult), - model->timelineIndex(d->m_lastSearchResult)); - d->m_searchField->setFocus(); - } else { - QPalette p = d->m_searchField->palette(); - p.setColor(QPalette::Text, Qt::red); - d->m_searchField->setPalette(p); - if (!d->m_searchFieldTimer) { - d->m_searchFieldTimer = new QTimer(this); - connect(d->m_searchFieldTimer, &QTimer::timeout, [this] () { - d->m_searchField->setPalette(d->m_searchField->parentWidget()->palette()); - }); - } - if (d->m_searchFieldTimer->isActive()) - d->m_searchFieldTimer->stop(); - d->m_searchFieldTimer->start(1500); - } + d->m_viewContainer->raiseTimeline(); + Core::FindPlugin::instance()->openFindToolBar(Core::FindPlugin::FindForwardDirection); } void QmlProfilerTool::clearData() @@ -589,6 +537,7 @@ void QmlProfilerTool::showSaveDialog() if (!filename.isEmpty()) { if (!filename.endsWith(QLatin1String(TraceFileExtension))) filename += QLatin1String(TraceFileExtension); + AnalyzerManager::mainWindow()->setEnabled(false); d->m_profilerModelManager->save(filename); } } @@ -607,12 +556,16 @@ void QmlProfilerTool::showLoadDialog() tr("QML traces (*%1)").arg(QLatin1String(TraceFileExtension))); if (!filename.isEmpty()) { - // delayed load (prevent graphical artifacts due to long load time) - d->m_profilerModelManager->setFilename(filename); - QTimer::singleShot(100, d->m_profilerModelManager, SLOT(load())); + AnalyzerManager::mainWindow()->setEnabled(false); + d->m_profilerModelManager->load(filename); } } +void QmlProfilerTool::onLoadSaveFinished() +{ + AnalyzerManager::mainWindow()->setEnabled(true); +} + /*! Checks if we have unsaved notes. If so, shows a warning dialog. Returns true if we can continue with a potentially destructive operation and discard the warnings, or false if not. We don't diff --git a/src/plugins/qmlprofiler/qmlprofilertool.h b/src/plugins/qmlprofiler/qmlprofilertool.h index 924ab77edde..cc062075503 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.h +++ b/src/plugins/qmlprofiler/qmlprofilertool.h @@ -70,9 +70,6 @@ public: static void logError(const QString &msg); static void showNonmodalWarning(const QString &warningMsg); -signals: - void selectTimelineElement(int modelId, int eventIndex); - public slots: void profilerStateChanged(); void clientRecordingChanged(); @@ -90,12 +87,13 @@ private slots: void showErrorDialog(const QString &error); void profilerDataModelStateChanged(); void updateTimeDisplay(); - void findEvent(); + void showTimeLineSearch(); void showSaveOption(); void showLoadOption(); void showSaveDialog(); void showLoadDialog(); + void onLoadSaveFinished(); void toggleRecordingFeature(QAction *action); diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp index 3033dcca11e..1aa9ec6b87d 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.cpp @@ -122,7 +122,8 @@ static QString qmlTypeAsString(Message message, RangeType rangeType) QmlProfilerFileReader::QmlProfilerFileReader(QObject *parent) : QObject(parent), - m_v8Model(0) + m_v8Model(0), + m_future(0) { } @@ -136,8 +137,18 @@ void QmlProfilerFileReader::setQmlDataModel(QmlProfilerDataModel *dataModel) m_qmlModel = dataModel; } +void QmlProfilerFileReader::setFuture(QFutureInterface<void> *future) +{ + m_future = future; +} + bool QmlProfilerFileReader::load(QIODevice *device) { + if (m_future) { + m_future->setProgressRange(0, qMin(device->size(), qint64(INT_MAX))); + m_future->setProgressValue(0); + } + QXmlStreamReader stream(device); bool validVersion = true; @@ -145,58 +156,60 @@ bool QmlProfilerFileReader::load(QIODevice *device) qint64 traceEnd = -1; while (validVersion && !stream.atEnd() && !stream.hasError()) { - QXmlStreamReader::TokenType token = stream.readNext(); - const QStringRef elementName = stream.name(); - switch (token) { - case QXmlStreamReader::StartDocument : continue; - case QXmlStreamReader::StartElement : { - if (elementName == _("trace")) { - QXmlStreamAttributes attributes = stream.attributes(); - if (attributes.hasAttribute(_("version"))) - validVersion = attributes.value(_("version")) == _(PROFILER_FILE_VERSION); - else - validVersion = false; - if (attributes.hasAttribute(_("traceStart"))) - traceStart = attributes.value(_("traceStart")).toString().toLongLong(); - if (attributes.hasAttribute(_("traceEnd"))) - traceEnd = attributes.value(_("traceEnd")).toString().toLongLong(); - } - - if (elementName == _("eventData")) { - loadEventData(stream); - break; - } - - if (elementName == _("profilerDataModel")) { - loadProfilerDataModel(stream); - break; - } - - if (elementName == _("noteData")) { - loadNoteData(stream); - break; - } - - if (elementName == _("v8profile")) { - if (m_v8Model) - m_v8Model->load(stream); - break; - } - - break; - } - default: break; - } - } - - if (stream.hasError()) { - emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString())); - return false; - } else { - m_qmlModel->setData(traceStart, qMax(traceStart, traceEnd), m_qmlEvents, m_ranges); - m_qmlModel->setNoteData(m_notes); - return true; - } + if (isCanceled()) + return false; + QXmlStreamReader::TokenType token = stream.readNext(); + const QStringRef elementName = stream.name(); + switch (token) { + case QXmlStreamReader::StartDocument : continue; + case QXmlStreamReader::StartElement : { + if (elementName == _("trace")) { + QXmlStreamAttributes attributes = stream.attributes(); + if (attributes.hasAttribute(_("version"))) + validVersion = attributes.value(_("version")) == _(PROFILER_FILE_VERSION); + else + validVersion = false; + if (attributes.hasAttribute(_("traceStart"))) + traceStart = attributes.value(_("traceStart")).toString().toLongLong(); + if (attributes.hasAttribute(_("traceEnd"))) + traceEnd = attributes.value(_("traceEnd")).toString().toLongLong(); + } + + if (elementName == _("eventData")) { + loadEventData(stream); + break; + } + + if (elementName == _("profilerDataModel")) { + loadProfilerDataModel(stream); + break; + } + + if (elementName == _("noteData")) { + loadNoteData(stream); + break; + } + + if (elementName == _("v8profile")) { + if (m_v8Model) + m_v8Model->load(stream, m_future); + break; + } + + break; + } + default: break; + } + } + + if (stream.hasError()) { + emit error(tr("Error while parsing trace data file: %1").arg(stream.errorString())); + return false; + } else { + m_qmlModel->setData(traceStart, qMax(traceStart, traceEnd), m_qmlEvents, m_ranges); + m_qmlModel->setNoteData(m_notes); + return true; + } } void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) @@ -217,12 +230,16 @@ void QmlProfilerFileReader::loadEventData(QXmlStreamReader &stream) const QmlProfilerDataModel::QmlEventTypeData defaultEvent = event; while (!stream.atEnd() && !stream.hasError()) { + if (isCanceled()) + return; + QXmlStreamReader::TokenType token = stream.readNext(); const QStringRef elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { if (elementName == _("event")) { + progress(stream.device()); event = defaultEvent; const QXmlStreamAttributes attributes = stream.attributes(); @@ -324,12 +341,16 @@ void QmlProfilerFileReader::loadProfilerDataModel(QXmlStreamReader &stream) QTC_ASSERT(stream.name() == _("profilerDataModel"), return); while (!stream.atEnd() && !stream.hasError()) { + if (isCanceled()) + return; + QXmlStreamReader::TokenType token = stream.readNext(); const QStringRef elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { if (elementName == _("range")) { + progress(stream.device()); QmlProfilerDataModel::QmlEventData range = { -1, 0, 0, 0, 0, 0, 0, 0 }; const QXmlStreamAttributes attributes = stream.attributes(); @@ -391,12 +412,16 @@ void QmlProfilerFileReader::loadNoteData(QXmlStreamReader &stream) { QmlProfilerDataModel::QmlEventNoteData currentNote; while (!stream.atEnd() && !stream.hasError()) { + if (isCanceled()) + return; + QXmlStreamReader::TokenType token = stream.readNext(); const QStringRef elementName = stream.name(); switch (token) { case QXmlStreamReader::StartElement: { if (elementName == _("note")) { + progress(stream.device()); QXmlStreamAttributes attrs = stream.attributes(); currentNote.startTime = attrs.value(_("startTime")).toString().toLongLong(); currentNote.duration = attrs.value(_("duration")).toString().toLongLong(); @@ -422,12 +447,26 @@ void QmlProfilerFileReader::loadNoteData(QXmlStreamReader &stream) } } +void QmlProfilerFileReader::progress(QIODevice *device) +{ + if (!m_future) + return; + + m_future->setProgressValue(qMin(device->pos(), qint64(INT_MAX))); +} + +bool QmlProfilerFileReader::isCanceled() const +{ + return m_future && m_future->isCanceled(); +} + QmlProfilerFileWriter::QmlProfilerFileWriter(QObject *parent) : QObject(parent), m_startTime(0), m_endTime(0), m_measuredTime(0), - m_v8Model(0) + m_v8Model(0), + m_future(0) { } @@ -455,8 +494,21 @@ void QmlProfilerFileWriter::setNotes(const QVector<QmlProfilerDataModel::QmlEven m_notes = notes; } +void QmlProfilerFileWriter::setFuture(QFutureInterface<void> *future) +{ + m_future = future; +} + void QmlProfilerFileWriter::save(QIODevice *device) { + if (m_future) { + m_future->setProgressRange(0, + qMax(m_qmlEvents.size() + m_ranges.size() + m_notes.size() + + m_v8Model->numberOfV8Events(), 1)); + m_future->setProgressValue(0); + m_newProgressValue = 0; + } + QXmlStreamWriter stream(device); stream.setAutoFormatting(true); @@ -471,7 +523,10 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeStartElement(_("eventData")); stream.writeAttribute(_("totalTime"), QString::number(m_measuredTime)); - for (int typeIndex = 0; typeIndex < m_qmlEvents.size(); ++typeIndex) { + for (int typeIndex = 0; typeIndex < m_qmlEvents.size(); ++typeIndex) { + if (isCanceled()) + return; + const QmlProfilerDataModel::QmlEventTypeData &event = m_qmlEvents[typeIndex]; stream.writeStartElement(_("event")); @@ -511,12 +566,16 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeTextElement(_("memoryEventType"), QString::number(event.detailType)); } stream.writeEndElement(); + incrementProgress(); } stream.writeEndElement(); // eventData stream.writeStartElement(_("profilerDataModel")); for (int rangeIndex = 0; rangeIndex < m_ranges.size(); ++rangeIndex) { + if (isCanceled()) + return; + const QmlProfilerDataModel::QmlEventData &range = m_ranges[rangeIndex]; stream.writeStartElement(_("range")); @@ -565,11 +624,15 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeAttribute(_("amount"), QString::number(range.numericData1)); stream.writeEndElement(); + incrementProgress(); } stream.writeEndElement(); // profilerDataModel stream.writeStartElement(_("noteData")); for (int noteIndex = 0; noteIndex < m_notes.size(); ++noteIndex) { + if (isCanceled()) + return; + const QmlProfilerDataModel::QmlEventNoteData ¬es = m_notes[noteIndex]; stream.writeStartElement(_("note")); stream.writeAttribute(_("startTime"), QString::number(notes.startTime)); @@ -577,15 +640,35 @@ void QmlProfilerFileWriter::save(QIODevice *device) stream.writeAttribute(_("eventIndex"), QString::number(notes.typeIndex)); stream.writeCharacters(notes.text); stream.writeEndElement(); // note + incrementProgress(); } stream.writeEndElement(); // noteData - m_v8Model->save(stream); + if (isCanceled()) + return; + m_v8Model->save(stream, m_future); stream.writeEndElement(); // trace stream.writeEndDocument(); } +void QmlProfilerFileWriter::incrementProgress() +{ + if (!m_future) + return; + + m_newProgressValue++; + if (float(m_newProgressValue - m_future->progressValue()) + / float(m_future->progressMaximum() - m_future->progressMinimum()) >= 0.01) { + m_future->setProgressValue(m_newProgressValue); + } +} + +bool QmlProfilerFileWriter::isCanceled() const +{ + return m_future && m_future->isCanceled(); +} + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilertracefile.h b/src/plugins/qmlprofiler/qmlprofilertracefile.h index 9b8c7e671e1..e87cd15c47f 100644 --- a/src/plugins/qmlprofiler/qmlprofilertracefile.h +++ b/src/plugins/qmlprofiler/qmlprofilertracefile.h @@ -31,6 +31,7 @@ #ifndef QMLPROFILERTRACEFILE_H #define QMLPROFILERTRACEFILE_H +#include <QFutureInterface> #include <QObject> #include <QVector> #include <QString> @@ -57,6 +58,7 @@ public: void setV8DataModel(QV8ProfilerDataModel *dataModel); void setQmlDataModel(QmlProfilerDataModel *dataModel); + void setFuture(QFutureInterface<void> *future); bool load(QIODevice *device); @@ -67,9 +69,12 @@ private: void loadEventData(QXmlStreamReader &reader); void loadProfilerDataModel(QXmlStreamReader &reader); void loadNoteData(QXmlStreamReader &reader); + void progress(QIODevice *device); + bool isCanceled() const; QV8ProfilerDataModel *m_v8Model; QmlProfilerDataModel *m_qmlModel; + QFutureInterface<void> *m_future; QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents; QVector<QmlProfilerDataModel::QmlEventData> m_ranges; QVector<QmlProfilerDataModel::QmlEventNoteData> m_notes; @@ -88,17 +93,22 @@ public: void setQmlEvents(const QVector<QmlProfilerDataModel::QmlEventTypeData> &types, const QVector<QmlProfilerDataModel::QmlEventData> &events); void setNotes(const QVector<QmlProfilerDataModel::QmlEventNoteData> ¬es); + void setFuture(QFutureInterface<void> *future); void save(QIODevice *device); private: void calculateMeasuredTime(); + void incrementProgress(); + bool isCanceled() const; qint64 m_startTime, m_endTime, m_measuredTime; QV8ProfilerDataModel *m_v8Model; + QFutureInterface<void> *m_future; QVector<QmlProfilerDataModel::QmlEventTypeData> m_qmlEvents; QVector<QmlProfilerDataModel::QmlEventData> m_ranges; QVector<QmlProfilerDataModel::QmlEventNoteData> m_notes; + int m_newProgressValue; }; diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index a4d60a9d7a3..78716dd4bb4 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -45,9 +45,10 @@ #include "timeline/timelinerenderer.h" #include "timeline/timelineoverviewrenderer.h" +#include <aggregation/aggregate.h> // Needed for the load&save actions in the context menu #include <analyzerbase/ianalyzertool.h> - +#include <coreplugin/findplaceholder.h> #include <utils/styledbar.h> #include <QQmlContext> @@ -61,6 +62,7 @@ #include <QQuickItem> #include <QQuickWidget> #include <QApplication> +#include <QTextCursor> #include <math.h> @@ -96,7 +98,10 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *pro d->m_zoomControl = new Timeline::TimelineZoomControl(this); connect(modelManager->traceTime(), &QmlProfilerTraceTime::timeChanged, - d->m_zoomControl, &Timeline::TimelineZoomControl::setTrace); + [this](qint64 start, qint64 end) { + d->m_zoomControl->setTrace(start, end); + d->m_zoomControl->setRange(start, start + (end - start) / 10); + }); QVBoxLayout *groupLayout = new QVBoxLayout; groupLayout->setContentsMargins(0, 0, 0, 0); @@ -112,8 +117,14 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *pro d->m_mainView = new QQuickWidget(this); d->m_mainView->setResizeMode(QQuickWidget::SizeRootObjectToView); d->m_mainView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + setFocusProxy(d->m_mainView); + + Aggregation::Aggregate *agg = new Aggregation::Aggregate; + agg->add(d->m_mainView); + agg->add(new TraceViewFindSupport(this, modelManager)); groupLayout->addWidget(d->m_mainView); + groupLayout->addWidget(new Core::FindToolBarPlaceHolder(this)); setLayout(groupLayout); d->m_profilerTool = profilerTool; @@ -122,10 +133,6 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *pro d->m_modelProxy = new Timeline::TimelineModelAggregator(modelManager->notesModel(), this); d->m_modelManager = modelManager; - connect(qobject_cast<QmlProfilerTool *>(profilerTool), &QmlProfilerTool::selectTimelineElement, - this, &QmlProfilerTraceView::selectByEventIndex); - connect(modelManager,SIGNAL(dataAvailable()), d->m_modelProxy,SIGNAL(dataAvailable())); - // external models pushed on top foreach (QmlProfilerTimelineModel *timelineModel, QmlProfilerPlugin::instance->getModels(modelManager)) { @@ -138,9 +145,6 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerTool *pro d->m_modelProxy->addModel(new QmlProfilerRangeModel(modelManager, (RangeType)i, d->m_modelProxy)); - // Connect this last so that it's executed after the models have updated their data. - connect(modelManager->qmlModel(), SIGNAL(changed()), d->m_modelProxy, SIGNAL(stateChanged())); - // Minimum height: 5 rows of 20 pixels + scrollbar of 50 pixels + 20 pixels margin setMinimumHeight(170); @@ -299,5 +303,130 @@ void QmlProfilerTraceView::showContextMenu(QPoint position) //////////////////////////////////////////////////////////////// +void QmlProfilerTraceView::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::EnabledChange) { + QQuickItem *rootObject = d->m_mainView->rootObject(); + rootObject->setProperty("enabled", isEnabled()); + } +} + +TraceViewFindSupport::TraceViewFindSupport(QmlProfilerTraceView *view, + QmlProfilerModelManager *manager) + : m_view(view), m_modelManager(manager) +{ +} + +bool TraceViewFindSupport::supportsReplace() const +{ + return false; +} + +Core::FindFlags TraceViewFindSupport::supportedFindFlags() const +{ + return Core::FindBackward | Core::FindCaseSensitively | Core::FindRegularExpression + | Core::FindWholeWords; +} + +void TraceViewFindSupport::resetIncrementalSearch() +{ + m_incrementalStartPos = -1; + m_incrementalWrappedState = false; +} + +void TraceViewFindSupport::clearHighlights() +{ +} + +QString TraceViewFindSupport::currentFindString() const +{ + return QString(); +} + +QString TraceViewFindSupport::completedFindString() const +{ + return QString(); +} + +Core::IFindSupport::Result TraceViewFindSupport::findIncremental(const QString &txt, + Core::FindFlags findFlags) +{ + if (m_incrementalStartPos < 0) + m_incrementalStartPos = qMax(m_currentPosition, 0); + bool wrapped = false; + bool found = find(txt, findFlags, m_incrementalStartPos, &wrapped); + if (wrapped != m_incrementalWrappedState && found) { + m_incrementalWrappedState = wrapped; + showWrapIndicator(m_view); + } + return found ? Core::IFindSupport::Found : Core::IFindSupport::NotFound; +} + +Core::IFindSupport::Result TraceViewFindSupport::findStep(const QString &txt, + Core::FindFlags findFlags) +{ + int start = (findFlags & Core::FindBackward) ? m_currentPosition : m_currentPosition + 1; + bool wrapped; + bool found = find(txt, findFlags, start, &wrapped); + if (wrapped) + showWrapIndicator(m_view); + if (found) { + m_incrementalStartPos = m_currentPosition; + m_incrementalWrappedState = false; + } + return found ? Core::IFindSupport::Found : Core::IFindSupport::NotFound; +} + +// "start" is the model index that is searched first in a forward search, i.e. as if the +// "cursor" were between start-1 and start +bool TraceViewFindSupport::find(const QString &txt, Core::FindFlags findFlags, int start, + bool *wrapped) +{ + if (wrapped) + *wrapped = false; + if (!findOne(txt, findFlags, start)) { + int secondStart; + if (findFlags & Core::FindBackward) + secondStart = m_modelManager->notesModel()->count(); + else + secondStart = 0; + if (!findOne(txt, findFlags, secondStart)) + return false; + if (wrapped) + *wrapped = true; + } + return true; +} + +// "start" is the model index that is searched first in a forward search, i.e. as if the +// "cursor" were between start-1 and start +bool TraceViewFindSupport::findOne(const QString &txt, Core::FindFlags findFlags, int start) +{ + bool caseSensitiveSearch = (findFlags & Core::FindCaseSensitively); + QRegExp regexp(txt); + regexp.setPatternSyntax((findFlags & Core::FindRegularExpression) ? QRegExp::RegExp : QRegExp::FixedString); + regexp.setCaseSensitivity(caseSensitiveSearch ? Qt::CaseSensitive : Qt::CaseInsensitive); + QTextDocument::FindFlags flags; + if (caseSensitiveSearch) + flags |= QTextDocument::FindCaseSensitively; + if (findFlags & Core::FindWholeWords) + flags |= QTextDocument::FindWholeWords; + bool forwardSearch = !(findFlags & Core::FindBackward); + int increment = forwardSearch ? +1 : -1; + int current = forwardSearch ? start : start - 1; + QmlProfilerNotesModel *model = m_modelManager->notesModel(); + while (current >= 0 && current < model->count()) { + QTextDocument doc(model->text(current)); // for automatic handling of WholeWords option + if (!doc.find(regexp, 0, flags).isNull()) { + m_currentPosition = current; + m_view->selectByEventIndex(model->timelineModel(m_currentPosition), + model->timelineIndex(m_currentPosition)); + return true; + } + current += increment; + } + return false; +} + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.h b/src/plugins/qmlprofiler/qmlprofilertraceview.h index b70de78e947..4c5447b136b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.h +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.h @@ -32,8 +32,11 @@ #define QMLPROFILERTRACEVIEW_H #include "qmlprofilermodelmanager.h" -#include <QWidget> + +#include <coreplugin/find/ifindsupport.h> + #include <QTimer> +#include <QWidget> namespace QmlProfiler { @@ -69,6 +72,7 @@ private slots: void updateCursorPosition(); protected: + void changeEvent(QEvent *e) Q_DECL_OVERRIDE; virtual void contextMenuEvent(QContextMenuEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); @@ -82,6 +86,33 @@ private: QmlProfilerTraceViewPrivate *d; }; +class TraceViewFindSupport : public Core::IFindSupport +{ + Q_OBJECT + +public: + TraceViewFindSupport(QmlProfilerTraceView *view, QmlProfilerModelManager *manager); + + bool supportsReplace() const override; + Core::FindFlags supportedFindFlags() const override; + void resetIncrementalSearch() override; + void clearHighlights() override; + QString currentFindString() const override; + QString completedFindString() const override; + Result findIncremental(const QString &txt, Core::FindFlags findFlags) override; + Result findStep(const QString &txt, Core::FindFlags findFlags) override; + +private: + bool find(const QString &txt, Core::FindFlags findFlags, int start, bool *wrapped); + bool findOne(const QString &txt, Core::FindFlags findFlags, int start); + + QmlProfilerTraceView *m_view; + QmlProfilerModelManager *m_modelManager; + int m_incrementalStartPos = -1; + bool m_incrementalWrappedState = false; + int m_currentPosition = -1; +}; + } // namespace Internal } // namespace QmlProfiler diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp index d5100209ed3..03d448fc788 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.cpp @@ -53,6 +53,7 @@ class QmlProfilerViewManager::QmlProfilerViewManagerPrivate { public: QmlProfilerViewManagerPrivate(QmlProfilerViewManager *qq) { Q_UNUSED(qq); } + QDockWidget *timelineDock; QmlProfilerTraceView *traceView; QmlProfilerEventsWidget *eventsView; QV8ProfilerEventsWidget *v8profilerView; @@ -124,19 +125,19 @@ void QmlProfilerViewManager::createViews() QDockWidget *eventsDock = AnalyzerManager::createDockWidget (QmlProfilerToolId, d->eventsView); - QDockWidget *timelineDock = AnalyzerManager::createDockWidget + d->timelineDock = AnalyzerManager::createDockWidget (QmlProfilerToolId, d->traceView); QDockWidget *v8profilerDock = AnalyzerManager::createDockWidget (QmlProfilerToolId, d->v8profilerView); eventsDock->show(); - timelineDock->show(); + d->timelineDock->show(); v8profilerDock->show(); - mw->splitDockWidget(mw->toolBarDockWidget(), timelineDock, Qt::Vertical); - mw->tabifyDockWidget(timelineDock, eventsDock); + mw->splitDockWidget(mw->toolBarDockWidget(), d->timelineDock, Qt::Vertical); + mw->tabifyDockWidget(d->timelineDock, eventsDock); mw->tabifyDockWidget(eventsDock, v8profilerDock); - timelineDock->raise(); + d->timelineDock->raise(); new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->eventsView); new QmlProfilerStateWidget(d->profilerState, d->profilerModelManager, d->traceView); @@ -168,6 +169,12 @@ void QmlProfilerViewManager::getStatisticsInRange(qint64 rangeStart, qint64 rang d->eventsView->getStatisticsInRange(rangeStart, rangeEnd); } +void QmlProfilerViewManager::raiseTimeline() +{ + d->timelineDock->raise(); + d->traceView->setFocus(); +} + void QmlProfilerViewManager::clear() { d->traceView->clear(); diff --git a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h index 80096fa2516..3aa3ada7752 100644 --- a/src/plugins/qmlprofiler/qmlprofilerviewmanager.h +++ b/src/plugins/qmlprofiler/qmlprofilerviewmanager.h @@ -60,6 +60,8 @@ public: bool hasGlobalStats() const; void getStatisticsInRange(qint64 rangeStart, qint64 rangeEnd); + void raiseTimeline(); + public slots: void clear(); diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp index cb7fbd441ff..264c5d8f79e 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.cpp @@ -164,6 +164,12 @@ QList<QV8ProfilerDataModel::QV8EventData *> QV8ProfilerDataModel::getV8Events() return d->v8EventHash.values(); } +int QV8ProfilerDataModel::numberOfV8Events() const +{ + Q_D(const QV8ProfilerDataModel); + return d->v8EventHash.size(); +} + QString getHashStringForV8Event(const QString &displayName, const QString &function) { return QString::fromLatin1("%1:%2").arg(displayName, function); @@ -323,7 +329,7 @@ void QV8ProfilerDataModel::clearV8RootEvent() d->v8RootEvent.childrenHash.clear(); } -void QV8ProfilerDataModel::save(QXmlStreamWriter &stream) +void QV8ProfilerDataModel::save(QXmlStreamWriter &stream, QFutureInterface<void> *future) { Q_D(QV8ProfilerDataModel); stream.writeStartElement(QLatin1String("v8profile")); // v8 profiler output @@ -359,11 +365,14 @@ void QV8ProfilerDataModel::save(QXmlStreamWriter &stream) stream.writeEndElement(); } stream.writeEndElement(); + + if (future) + future->setProgressValue(future->progressValue() + 1); } stream.writeEndElement(); // v8 profiler output } -void QV8ProfilerDataModel::load(QXmlStreamReader &stream) +void QV8ProfilerDataModel::load(QXmlStreamReader &stream, QFutureInterface<void> *future) { Q_D(QV8ProfilerDataModel); QHash <int, QV8EventData *> v8eventBuffer; @@ -383,12 +392,17 @@ void QV8ProfilerDataModel::load(QXmlStreamReader &stream) bool finishedReading = false; while (!stream.atEnd() && !stream.hasError() && !finishedReading) { + if (future && future->isCanceled()) + return; + QXmlStreamReader::TokenType token = stream.readNext(); const QStringRef elementName = stream.name(); switch (token) { case QXmlStreamReader::StartDocument : continue; case QXmlStreamReader::StartElement : { if (elementName == QLatin1String("event")) { + if (future) + future->setProgressValue(qMin(stream.device()->pos(), qint64(INT_MAX))); QXmlStreamAttributes attributes = stream.attributes(); if (attributes.hasAttribute(QLatin1String("index"))) { int ndx = attributes.value(QLatin1String("index")).toString().toInt(); diff --git a/src/plugins/qmlprofiler/qv8profilerdatamodel.h b/src/plugins/qmlprofiler/qv8profilerdatamodel.h index 031edc4277f..90708212563 100644 --- a/src/plugins/qmlprofiler/qv8profilerdatamodel.h +++ b/src/plugins/qmlprofiler/qv8profilerdatamodel.h @@ -34,6 +34,7 @@ #include "qmlprofilerbasemodel.h" #include <utils/fileinprojectfinder.h> +#include <QFutureInterface> #include <QObject> #include <QHash> @@ -82,12 +83,13 @@ public: void clear(); bool isEmpty() const; QList<QV8EventData *> getV8Events() const; + int numberOfV8Events() const; QV8EventData *v8EventDescription(int typeId) const; qint64 v8MeasuredTime() const; - void save(QXmlStreamWriter &stream); - void load(QXmlStreamReader &stream); + void save(QXmlStreamWriter &stream, QFutureInterface<void> *future = 0); + void load(QXmlStreamReader &stream, QFutureInterface<void> *future = 0); void complete(); diff --git a/src/plugins/qmlprojectmanager/images/qml_wizard.png b/src/plugins/qmlprojectmanager/images/qml_wizard.png Binary files differdeleted file mode 100644 index 23c02368718..00000000000 --- a/src/plugins/qmlprojectmanager/images/qml_wizard.png +++ /dev/null diff --git a/src/plugins/qmlprojectmanager/qmlapp.cpp b/src/plugins/qmlprojectmanager/qmlapp.cpp deleted file mode 100644 index 32015d4a89d..00000000000 --- a/src/plugins/qmlprojectmanager/qmlapp.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qmlapp.h" - -#include <coreplugin/basefilewizardfactory.h> -#include <coreplugin/icore.h> -#include <utils/fileutils.h> -#include <utils/qtcassert.h> - -#include <QDebug> -#include <QDir> -#include <QTextStream> - -namespace QmlProjectManager { -namespace Internal { - -static QStringList binaryFiles() -{ - static QStringList result; - if (result.isEmpty()) - result << QLatin1String("png") << QLatin1String("jpg") << QLatin1String("jpeg"); - return result; -} - -static QString templateRootDirectory() -{ - return Core::ICore::resourcePath() + QLatin1String("/templates/qml/"); -} - -QmlApp::QmlApp(QObject *parent) - : QObject(parent) -{ -} - -QmlApp::~QmlApp() -{ -} - -QString QmlApp::mainQmlFileName() const -{ - return projectName() + QLatin1String(".qml"); -} - -void QmlApp::setProjectNameAndBaseDirectory(const QString &projectName, const QString &projectBaseDirectory) -{ - m_projectBaseDirectory = projectBaseDirectory; - m_projectName = projectName.trimmed(); -} - -QString QmlApp::projectDirectory() const -{ - return QDir::cleanPath(m_projectBaseDirectory + QLatin1Char('/') + m_projectName); -} - -QString QmlApp::projectName() const -{ - return m_projectName; -} - -void QmlApp::setTemplateInfo(const TemplateInfo &templateInfo) -{ - m_templateInfo = templateInfo; -} - -QString QmlApp::creatorFileName() const -{ - return m_creatorFileName; -} - -QString QmlApp::templateDirectory() const -{ - const QDir dir(templateRootDirectory() + m_templateInfo.templateName); - return QDir::cleanPath(dir.absolutePath()); -} - -static QStringList templateNames() -{ - QStringList templateNameList; - const QDir templateRoot(templateRootDirectory()); - - foreach (const QFileInfo &subDirectory, - templateRoot.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) - templateNameList.append(subDirectory.fileName()); - - return templateNameList; -} - -// Return locale language attribute "de_UTF8" -> "de", empty string for "C" -static QString languageSetting() -{ -#ifdef QT_CREATOR - QString name = Core::ICore::userInterfaceLanguage(); - const int underScorePos = name.indexOf(QLatin1Char('_')); - if (underScorePos != -1) - name.truncate(underScorePos); - if (name.compare(QLatin1String("C"), Qt::CaseInsensitive) == 0) - name.clear(); - return name; -#else - return QLocale::system().name(); -#endif -} - -static inline bool assignLanguageElementText(QXmlStreamReader &reader, - const QString &desiredLanguage, - QString *target) -{ - const QStringRef elementLanguage = reader.attributes().value(QLatin1String("xml:lang")); - if (elementLanguage.isEmpty()) { - // Try to find a translation for our Wizards - *target = QCoreApplication::translate("QmlProjectManager::QmlApplicationWizard", - reader.readElementText().toLatin1().constData()); - return true; - } - if (elementLanguage == desiredLanguage) { - *target = reader.readElementText(); - return true; - } - return false; -} - -static bool parseTemplateXml(QXmlStreamReader &reader, TemplateInfo *info) -{ - const QString locale = languageSetting(); - - static const QLatin1String tag_template("template"); - static const QLatin1String tag_displayName("displayname"); - static const QLatin1String tag_description("description"); - static const QLatin1String attribute_featuresRequired("featuresRequired"); - static const QLatin1String attribute_openEditor("openeditor"); - static const QLatin1String attribute_priority("priority"); - - while (!reader.atEnd() && !reader.hasError()) { - reader.readNext(); - if (reader.tokenType() != QXmlStreamReader::StartElement) - continue; - - if (reader.name() == tag_template) { - info->openFile = reader.attributes().value(attribute_openEditor).toString(); - if (reader.attributes().hasAttribute(attribute_priority)) - info->priority = reader.attributes().value(attribute_priority).toString(); - - if (reader.attributes().hasAttribute(attribute_featuresRequired)) - info->featuresRequired = reader.attributes().value(attribute_featuresRequired).toString(); - - } else if (reader.name() == tag_displayName) { - if (!assignLanguageElementText(reader, locale, &info->displayName)) - continue; - } else if (reader.name() == tag_description) { - if (!assignLanguageElementText(reader, locale, &info->description)) - continue; - } - } - if (reader.hasError()) { - qWarning() << reader.errorString(); - return false; - } - - return true; -} - -class TemplateInfoList -{ -public: - TemplateInfoList() - { - QMultiMap<QString, TemplateInfo> multiMap; - foreach (const QString &templateName, templateNames()) { - const QString templatePath = templateRootDirectory() + templateName; - QFile xmlFile(templatePath + QLatin1String("/template.xml")); - if (!xmlFile.open(QIODevice::ReadOnly)) { - qWarning().nospace() << QString::fromLatin1("Cannot open %1").arg(QDir::toNativeSeparators(QFileInfo(xmlFile.fileName()).absoluteFilePath())); - continue; - } - TemplateInfo info; - info.templateName = templateName; - info.templatePath = templatePath; - QXmlStreamReader reader(&xmlFile); - if (parseTemplateXml(reader, &info)) - multiMap.insert(info.priority, info); - } - m_templateInfoList = multiMap.values(); - } - QList<TemplateInfo> templateInfoList() const { return m_templateInfoList; } - -private: - QList<TemplateInfo> m_templateInfoList; -}; - -Q_GLOBAL_STATIC(TemplateInfoList, templateInfoList) - -QList<TemplateInfo> QmlApp::templateInfos() -{ - return templateInfoList()->templateInfoList(); -} - -static QFileInfoList allFilesRecursive(const QString &path) -{ - const QDir currentDirectory(path); - - QFileInfoList allFiles = currentDirectory.entryInfoList(QDir::Files); - - foreach (const QFileInfo &subDirectory, currentDirectory.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)) - allFiles.append(allFilesRecursive(subDirectory.absoluteFilePath())); - - return allFiles; -} - -QByteArray QmlApp::readFile(const QString &filePath, bool &ok) const -{ - Utils::FileReader reader; - - if (!reader.fetch(filePath)) { - ok = false; - return QByteArray(); - } - - ok = true; - return reader.data(); -} - -QString QmlApp::readAndAdaptTemplateFile(const QString &filePath, bool &ok) const -{ - const QByteArray originalTemplate = readFile(filePath, ok); - if (!ok) - return QString(); - - QTextStream tsIn(originalTemplate); - QByteArray adaptedTemplate; - QTextStream tsOut(&adaptedTemplate, QIODevice::WriteOnly | QIODevice::Text); - int lineNr = 1; - QString line; - do { - static const QString markerQtcReplace = QLatin1String("QTC_REPLACE"); - static const QString markerWith = QLatin1String("WITH"); - - line = tsIn.readLine(); - const int markerQtcReplaceIndex = line.indexOf(markerQtcReplace); - if (markerQtcReplaceIndex >= 0) { - QString replaceXWithYString = line.mid(markerQtcReplaceIndex + markerQtcReplace.length()).trimmed(); - if (filePath.endsWith(QLatin1String(".json"))) - replaceXWithYString.replace(QRegExp(QLatin1String("\",$")), QString()); - else if (filePath.endsWith(QLatin1String(".html"))) - replaceXWithYString.replace(QRegExp(QLatin1String(" -->$")), QString()); - const QStringList replaceXWithY = replaceXWithYString.split(markerWith); - if (replaceXWithY.count() != 2) { - qWarning().nospace() << QString::fromLatin1("Error in %1:%2. Invalid %3 options.") - .arg(QDir::toNativeSeparators(filePath)).arg(lineNr).arg(markerQtcReplace); - ok = false; - return QString(); - } - const QString replaceWhat = replaceXWithY.at(0).trimmed(); - const QString replaceWith = replaceXWithY.at(1).trimmed(); - if (!m_replacementVariables.contains(replaceWith)) { - qWarning().nospace() << QString::fromLatin1("Error in %1:%2. Unknown %3 option \"%4\".") - .arg(QDir::toNativeSeparators(filePath)).arg(lineNr).arg(markerQtcReplace).arg(replaceWith); - ok = false; - return QString(); - } - line = tsIn.readLine(); // Following line which is to be patched. - lineNr++; - if (line.indexOf(replaceWhat) < 0) { - qWarning().nospace() << QString::fromLatin1("Error in %1:%2. Replacement \"%3\" not found.") - .arg(QDir::toNativeSeparators(filePath)).arg(lineNr).arg(replaceWhat); - ok = false; - return QString(); - } - line.replace(replaceWhat, m_replacementVariables.value(replaceWith)); - } - if (!line.isNull()) - tsOut << line << endl; - lineNr++; - } while (!line.isNull()); - - ok = true; - return QString::fromUtf8(adaptedTemplate); -} - -bool QmlApp::addTemplate(const QString &sourceDirectory, - const QString &templateFileName, - const QString &tragetDirectory, - const QString &targetFileName, - Core::GeneratedFiles *files, - QString *errorMessage) const -{ - bool fileIsReadable; - Core::GeneratedFile file(tragetDirectory + QLatin1Char('/') + targetFileName); - - const QString &data = readAndAdaptTemplateFile(sourceDirectory + QLatin1Char('/') + templateFileName, fileIsReadable); - - if (!fileIsReadable) { - if (errorMessage) - *errorMessage = QCoreApplication::translate("QmlApplicationWizard", "Failed to read %1 template.").arg(templateFileName); - return false; - } - - file.setContents(data); - files->append(file); - - return true; -} - -bool QmlApp::addBinaryFile(const QString &sourceDirectory, - const QString &templateFileName, - const QString &tragetDirectory, - const QString &targetFileName, - Core::GeneratedFiles *files, - QString *errorMessage) const -{ - bool fileIsReadable; - - Core::GeneratedFile file(tragetDirectory + targetFileName); - file.setBinary(true); - - const QByteArray &data = readFile(sourceDirectory + QLatin1Char('/') + templateFileName, fileIsReadable); - - if (!fileIsReadable) { - if (errorMessage) - *errorMessage = QCoreApplication::translate("QmlApplicationWizard", "Failed to read file %1.").arg(templateFileName); - return false; - } - - file.setBinaryContents(data); - files->append(file); - - return true; -} - -QString QmlApp::renameQmlFile(const QString &fileName) { - if (fileName == QLatin1String("main.qml")) - return mainQmlFileName(); - return fileName; -} - -Core::GeneratedFiles QmlApp::generateFiles(QString *errorMessage) -{ - Core::GeneratedFiles files; - - QTC_ASSERT(errorMessage, return files); - - errorMessage->clear(); - setReplacementVariables(); - const QFileInfoList templateFiles = allFilesRecursive(templateDirectory()); - - foreach (const QFileInfo &templateFile, templateFiles) { - const QString targetSubDirectory = templateFile.path().mid(templateDirectory().length()); - const QString targetDirectory = projectDirectory() + targetSubDirectory + QLatin1Char('/'); - - QString targetFileName = templateFile.fileName(); - - if (templateFile.fileName() == QLatin1String("main.pro")) { - targetFileName = projectName() + QLatin1String(".pro"); - m_creatorFileName = Core::BaseFileWizardFactory::buildFileName(projectDirectory(), - projectName(), - QLatin1String("pro")); - } else if (templateFile.fileName() == QLatin1String("main.qmlproject")) { - targetFileName = projectName() + QLatin1String(".qmlproject"); - m_creatorFileName = Core::BaseFileWizardFactory::buildFileName(projectDirectory(), - projectName(), - QLatin1String("qmlproject")); - } else if (templateFile.fileName() == QLatin1String("main.qbp")) { - targetFileName = projectName() + QLatin1String(".qbp"); - } else if (targetFileName == QLatin1String("template.xml") - || targetFileName == QLatin1String("template.png")) { - continue; - } else { - targetFileName = renameQmlFile(templateFile.fileName()); - } - - if (binaryFiles().contains(templateFile.suffix())) { - bool canAddBinaryFile = addBinaryFile(templateFile.absolutePath(), - templateFile.fileName(), - targetDirectory, - targetFileName, - &files, - errorMessage); - if (!canAddBinaryFile) - return Core::GeneratedFiles(); - } else { - bool canAddTemplate = addTemplate(templateFile.absolutePath(), - templateFile.fileName(), - targetDirectory, - targetFileName, - &files, - errorMessage); - if (!canAddTemplate) - return Core::GeneratedFiles(); - - if (templateFile.fileName() == QLatin1String("main.pro")) - files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute); - else if (templateFile.fileName() == QLatin1String("main.qmlproject")) - files.last().setAttributes(Core::GeneratedFile::OpenProjectAttribute); - else if (templateFile.fileName() == m_templateInfo.openFile) - files.last().setAttributes(Core::GeneratedFile::OpenEditorAttribute); - } - } - - return files; -} - -void QmlApp::setReplacementVariables() -{ - m_replacementVariables.clear(); - - m_replacementVariables.insert(QLatin1String("main"), mainQmlFileName()); - m_replacementVariables.insert(QLatin1String("projectName"), projectName()); -} - -} // namespace Internal -} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlapp.h b/src/plugins/qmlprojectmanager/qmlapp.h deleted file mode 100644 index b5a7f1270e6..00000000000 --- a/src/plugins/qmlprojectmanager/qmlapp.h +++ /dev/null @@ -1,112 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QMLAPP_H -#define QMLAPP_H - -#include <QString> -#include <QHash> -#include <QObject> - -#include <coreplugin/generatedfile.h> - -namespace QmlProjectManager { -namespace Internal { - -class TemplateInfo -{ -public: - QString templateName; - QString templatePath; - QString displayName; - QString description; - QString openFile; - QString featuresRequired; - QString priority; -}; - -class QmlApp : public QObject -{ - Q_OBJECT -public: - - QmlApp(QObject *parent = 0); - ~QmlApp(); - - QString mainQmlFileName() const; - QString projectDirectory() const; - QString projectName() const; - QString templateDirectory() const; - - static QList<TemplateInfo> templateInfos(); - - Core::GeneratedFiles generateFiles(QString *errorMessage); - QString renameQmlFile(const QString &fileName); - - void setTemplateInfo(const TemplateInfo &templateInfo); - - QString creatorFileName() const; - -public slots: - void setProjectNameAndBaseDirectory(const QString &projectName, const QString &projectBaseDirectory); - -protected: - QString readAndAdaptTemplateFile(const QString &filePath, bool &ok) const; - bool addTemplate(const QString &sourceDirectory, - const QString &sourceFileName, - const QString &targetDirectory, - const QString &targetFileName, - Core::GeneratedFiles *files, - QString *errorMessage) const; - bool addBinaryFile(const QString &sourceDirectory, - const QString &sourceFileName, - const QString &targetDirectory, - const QString &targetFileName, - Core::GeneratedFiles *files, - QString *errorMessage) const; - QByteArray readFile(const QString &filePath, bool &ok) const; - -private: - void setReplacementVariables(); - - QString m_runtime; - - QString m_projectName; - QString m_projectBaseDirectory; - bool m_grantUserDataAccess; - QHash<QString, QString> m_replacementVariables; - TemplateInfo m_templateInfo; - QString m_creatorFileName; -}; - -} // namespace Internal -} // namespace QmlProjectManager - -#endif // QMLAPP_H diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp b/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp deleted file mode 100644 index c45bb0487eb..00000000000 --- a/src/plugins/qmlprojectmanager/qmlapplicationwizard.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qmlapplicationwizard.h" - -#include "qmlapp.h" - -#include <extensionsystem/pluginmanager.h> -#include <projectexplorer/customwizard/customwizard.h> -#include <projectexplorer/kitmanager.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h> -#include <qtsupport/qtkitinformation.h> -#include <qtsupport/qtsupportconstants.h> - -#include "qmlprojectmanager.h" -#include "qmlproject.h" -#include "qmlapplicationwizardpages.h" - -#include <QIcon> - -using namespace Core; -using namespace ExtensionSystem; -using namespace ProjectExplorer; -using namespace QmakeProjectManager; - -namespace QmlProjectManager { -namespace Internal { - -QmlApplicationWizardDialog::QmlApplicationWizardDialog(QWidget *parent, const WizardDialogParameters ¶meters) - : BaseProjectWizardDialog(parent, parameters) -{ - setWindowTitle(tr("New Qt Quick UI Project")); - setIntroDescription(tr("This wizard generates a Qt Quick UI project.")); - m_componentSetPage = new QmlComponentSetPage; - addPage(m_componentSetPage); -} - -TemplateInfo QmlApplicationWizardDialog::templateInfo() const -{ - return m_componentSetPage->templateInfo(); -} - - -QmlApplicationWizard::QmlApplicationWizard() - : m_qmlApp(new QmlApp(this)) -{ - setWizardKind(ProjectWizard); - setCategory(QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY)); - setId(QLatin1String("QA.QMLB Application")); - setIcon(QIcon(QLatin1String(QmakeProjectManager::Constants::ICON_QTQUICK_APP))); - setDisplayCategory( - QLatin1String(ProjectExplorer::Constants::QT_APPLICATION_WIZARD_CATEGORY_DISPLAY)); - setDisplayName(tr("Qt Quick UI")); - setDescription(tr("Creates a Qt Quick UI project.")); - setRequiredFeatures(Feature(QtSupport::Constants::FEATURE_QMLPROJECT) - | Feature(QtSupport::Constants::FEATURE_QT_QUICK)); -} - -BaseFileWizard *QmlApplicationWizard::create(QWidget *parent, const WizardDialogParameters ¶meters) const -{ - QmlApplicationWizardDialog *wizardDialog = new QmlApplicationWizardDialog(parent, parameters); - - connect(wizardDialog, &QmlApplicationWizardDialog::projectParametersChanged, - m_qmlApp, &QmlApp::setProjectNameAndBaseDirectory); - - wizardDialog->setPath(parameters.defaultPath()); - - wizardDialog->setProjectName(QmlApplicationWizardDialog::uniqueProjectName(parameters.defaultPath())); - - foreach (QWizardPage *page, parameters.extensionPages()) - wizardDialog->addPage(page); - - return wizardDialog; -} - -GeneratedFiles QmlApplicationWizard::generateFiles(const QWizard *w, - QString *errorMessage) const -{ - const QmlApplicationWizardDialog *wizard = qobject_cast<const QmlApplicationWizardDialog*>(w); - m_qmlApp->setTemplateInfo(wizard->templateInfo()); - return m_qmlApp->generateFiles(errorMessage); -} - -bool QmlApplicationWizard::postGenerateFiles(const QWizard * /*wizard*/, const GeneratedFiles &l, - QString *errorMessage) -{ - return CustomProjectWizard::postGenerateOpen(l, errorMessage); -} - -} // namespace Internal -} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp b/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp deleted file mode 100644 index f6a0910aa2d..00000000000 --- a/src/plugins/qmlprojectmanager/qmlapplicationwizardpages.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qmlapplicationwizardpages.h" -#include "qmlapp.h" - -#include <utils/wizard.h> - -#include <QComboBox> -#include <QLabel> -#include <QVBoxLayout> - -namespace QmlProjectManager { -namespace Internal { - -class QmlComponentSetPagePrivate -{ -public: - QComboBox *m_versionComboBox; - QLabel *m_detailedDescriptionLabel; -}; - -QmlComponentSetPage::QmlComponentSetPage(QWidget *parent) - : QWizardPage(parent) - , d(new QmlComponentSetPagePrivate) -{ - setTitle(tr("Select Qt Quick Component Set")); - QVBoxLayout *mainLayout = new QVBoxLayout(this); - QHBoxLayout *l = new QHBoxLayout(); - - QLabel *label = new QLabel(tr("Qt Quick component set:"), this); - d->m_versionComboBox = new QComboBox(this); - - foreach (const TemplateInfo &templateInfo, QmlApp::templateInfos()) - d->m_versionComboBox->addItem(templateInfo.displayName); - - l->addWidget(label); - l->addWidget(d->m_versionComboBox); - - d->m_detailedDescriptionLabel = new QLabel(this); - d->m_detailedDescriptionLabel->setWordWrap(true); - d->m_detailedDescriptionLabel->setTextFormat(Qt::RichText); - connect(d->m_versionComboBox, SIGNAL(currentIndexChanged(int)), this, - SLOT(updateDescription(int))); - updateDescription(d->m_versionComboBox->currentIndex()); - - mainLayout->addLayout(l); - mainLayout->addWidget(d->m_detailedDescriptionLabel); - - setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Component Set")); -} - -QmlComponentSetPage::~QmlComponentSetPage() -{ - delete d; -} - -TemplateInfo QmlComponentSetPage::templateInfo() const -{ - if (QmlApp::templateInfos().isEmpty()) - return TemplateInfo(); - return QmlApp::templateInfos().at(d->m_versionComboBox->currentIndex()); -} - -void QmlComponentSetPage::updateDescription(int index) -{ - if (QmlApp::templateInfos().isEmpty()) - return; - - const TemplateInfo templateInfo = QmlApp::templateInfos().at(index); - d->m_detailedDescriptionLabel->setText(templateInfo.description); -} - -} // namespace Internal -} // namespace QmlProjectManager diff --git a/src/plugins/qmlprojectmanager/qmlproject.qrc b/src/plugins/qmlprojectmanager/qmlproject.qrc index 2443c3f9aef..31d6ba9b6df 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.qrc +++ b/src/plugins/qmlprojectmanager/qmlproject.qrc @@ -3,6 +3,5 @@ <file>QmlProjectManager.mimetypes.xml</file> <file>images/qmlfolder.png</file> <file>images/qmlproject.png</file> - <file>images/qml_wizard.png</file> </qresource> </RCC> diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro index 4c8a6211e4b..8545eee471a 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.pro +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.pro @@ -15,10 +15,7 @@ HEADERS += qmlproject.h \ qmlprojectrunconfigurationfactory.h \ qmlprojectmanager_global.h \ qmlprojectmanagerconstants.h \ - qmlprojectrunconfigurationwidget.h \ - qmlapp.h \ - qmlapplicationwizard.h \ - qmlapplicationwizardpages.h + qmlprojectrunconfigurationwidget.h SOURCES += qmlproject.cpp \ qmlprojectenvironmentaspect.cpp \ @@ -28,9 +25,6 @@ SOURCES += qmlproject.cpp \ qmlprojectfile.cpp \ qmlprojectrunconfiguration.cpp \ qmlprojectrunconfigurationfactory.cpp \ - qmlprojectrunconfigurationwidget.cpp \ - qmlapp.cpp \ - qmlapplicationwizard.cpp \ - qmlapplicationwizardpages.cpp + qmlprojectrunconfigurationwidget.cpp RESOURCES += qmlproject.qrc diff --git a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs index ef9b6014db8..a138a95bd99 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs +++ b/src/plugins/qmlprojectmanager/qmlprojectmanager.qbs @@ -14,9 +14,6 @@ QtcPlugin { Group { name: "General" files: [ - "qmlapp.cpp", "qmlapp.h", - "qmlapplicationwizard.cpp", "qmlapplicationwizard.h", - "qmlapplicationwizardpages.cpp", "qmlapplicationwizardpages.h", "qmlproject.cpp", "qmlproject.h", "qmlproject.qrc", "qmlprojectconstants.h", diff --git a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp index 71e48493f35..de93e7c235a 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectplugin.cpp @@ -32,7 +32,6 @@ #include "qmlprojectmanager.h" #include "qmlproject.h" #include "qmlprojectrunconfigurationfactory.h" -#include "qmlapplicationwizard.h" #include "fileformat/qmlprojectfileformat.h" #include <coreplugin/fileiconprovider.h> @@ -64,7 +63,6 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage) addAutoReleasedObject(new Internal::Manager); addAutoReleasedObject(new Internal::QmlProjectRunConfigurationFactory); - addAutoReleasedObject(new Internal::QmlApplicationWizard); Core::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png", "qmlproject"); return true; diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 75912ba5b78..640857f4dd1 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -305,8 +305,7 @@ void QmlProjectRunConfiguration::updateEnabled() bool QmlProjectRunConfiguration::isValidVersion(QtSupport::BaseQtVersion *version) { if (version - && (version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) - || version->type() == QLatin1String(QtSupport::Constants::SIMULATORQT)) + && version->type() == QLatin1String(QtSupport::Constants::DESKTOPQT) && !version->qmlviewerCommand().isEmpty()) { return true; } diff --git a/src/plugins/qnx/Qnx.json.in b/src/plugins/qnx/Qnx.json.in index 96048b7eeff..b9863b105af 100644 --- a/src/plugins/qnx/Qnx.json.in +++ b/src/plugins/qnx/Qnx.json.in @@ -13,7 +13,7 @@ \"Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 or version 3 as published by the Free Software Foundation. Please review the following information to ensure the GNU Lesser General Public License requirements will be met: https://www.gnu.org/licenses/lgpl.html and http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.\" ], \"Category\" : \"Device Support\", - \"Description\" : \"Adds support for QNX and BlackBerry 10 to Qt Creator.\", + \"Description\" : \"Adds support for QNX to Qt Creator.\", \"Url\" : \"http://www.blackberry.com\", $$dependencyList } diff --git a/src/plugins/qnx/Qnx.mimetypes.xml b/src/plugins/qnx/Qnx.mimetypes.xml deleted file mode 100644 index e9ac133fc79..00000000000 --- a/src/plugins/qnx/Qnx.mimetypes.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0"?> -<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'> - <mime-type type="application/z-vnd.rim.qnx.bar_descriptor"> - <comment>BAR descriptor file (BlackBerry)</comment> - <sub-class-of type="application/xml"/> - <glob pattern="*.xml"/> - <magic> - <match value="<qnx>" type="string" offset="0:1000"/> - </magic> - </mime-type> -</mime-info> diff --git a/src/plugins/qnx/bardescriptordocument.cpp b/src/plugins/qnx/bardescriptordocument.cpp deleted file mode 100644 index 7545adfad6f..00000000000 --- a/src/plugins/qnx/bardescriptordocument.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptordocument.h" - -#include "qnxconstants.h" - -#include <coreplugin/editormanager/editormanager.h> -#include <utils/qtcassert.h> - -#include <QDir> -#include <QFileInfo> -#include <QMetaEnum> -#include <QTextCodec> -#include <QSet> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorDocument::BarDescriptorDocument(QObject *parent) - : Core::BaseTextDocument(parent) -{ - setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID); - setMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE)); - // blackberry-nativepackager requires the XML file to be in UTF-8 encoding, - // force if possible - if (QTextCodec *defaultUTF8 = QTextCodec::codecForName("UTF-8")) - setCodec(defaultUTF8); - else - setCodec(Core::EditorManager::defaultTextCodec()); -} - -BarDescriptorDocument::~BarDescriptorDocument() -{ -} - -bool BarDescriptorDocument::open(QString *errorString, const QString &fileName) { - QString contents; - if (read(fileName, &contents, errorString) != Utils::TextFileFormat::ReadSuccess) - return false; - - setFilePath(Utils::FileName::fromString(fileName)); - - const bool result = loadContent(contents, false); - - if (!result) - *errorString = tr("%1 does not appear to be a valid application descriptor file").arg(QDir::toNativeSeparators(fileName)); - - return result; -} - -bool BarDescriptorDocument::save(QString *errorString, const QString &fn, bool autoSave) -{ - QTC_ASSERT(!autoSave, return false); - QTC_ASSERT(fn.isEmpty(), return false); - - const bool result = write(filePath().toString(), xmlSource(), errorString); - if (!result) - return false; - - m_dirty = false; - emit Core::IDocument::changed(); - return true; -} - -QString BarDescriptorDocument::defaultPath() const -{ - return filePath().toFileInfo().absolutePath(); -} - -QString BarDescriptorDocument::suggestedFileName() const -{ - return filePath().fileName(); -} - -bool BarDescriptorDocument::shouldAutoSave() const -{ - return false; -} - -bool BarDescriptorDocument::isModified() const -{ - return m_dirty; -} - -bool BarDescriptorDocument::isSaveAsAllowed() const -{ - return false; -} - -Core::IDocument::ReloadBehavior BarDescriptorDocument::reloadBehavior(Core::IDocument::ChangeTrigger state, Core::IDocument::ChangeType type) const -{ - if (type == TypeRemoved || type == TypePermissions) - return BehaviorSilent; - if (type == TypeContents && state == TriggerInternal && !isModified()) - return BehaviorSilent; - return BehaviorAsk; -} - -bool BarDescriptorDocument::reload(QString *errorString, Core::IDocument::ReloadFlag flag, Core::IDocument::ChangeType type) -{ - Q_UNUSED(type); - - if (flag == Core::IDocument::FlagIgnore) - return true; - - return open(errorString, filePath().toString()); -} - -QString BarDescriptorDocument::xmlSource() const -{ - const int indent = 4; - return m_barDocument.toString(indent); -} - -bool BarDescriptorDocument::loadContent(const QString &xmlCode, bool setDirty, QString *errorMessage, int *errorLine) -{ - if (xmlCode == xmlSource()) - return true; - - bool result = m_barDocument.setContent(xmlCode, errorMessage, errorLine); - - m_dirty = setDirty; - - emitAllChanged(); - emit Core::IDocument::changed(); - return result; -} - -QVariant BarDescriptorDocument::value(BarDescriptorDocument::Tag tag) const -{ - const QString tagName = QString::fromLatin1(metaObject()->enumerator(metaObject()->enumeratorOffset()).valueToKey(tag)); - - switch (tag) { - case id: - case versionNumber: - case buildId: - case name: - case description: - case author: - case publisher: - case authorId: - return stringValue(tagName); - case icon: - return childStringListValue(tagName, QLatin1String("image")).value(0); - case splashScreens: - return childStringListValue(tagName, QLatin1String("image")); - case asset: { - QVariant var; - var.setValue(assets()); - return var; - } - case aspectRatio: - case autoOrients: - case systemChrome: - return childStringListValue(QLatin1String("initialWindow"), tagName).value(0); - case transparent: - return childStringListValue(QLatin1String("initialWindow"), tagName).value(0) == QLatin1String("true"); - case arg: - case action: - return stringListValue(tagName); - case env: - QVariant var; - var.setValue(environment()); - return var; - } - - return QVariant(); -} - -void BarDescriptorDocument::setValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - const QMetaEnum tagEnum = metaObject()->enumerator(metaObject()->enumeratorOffset()); - const QString tagName = QString::fromLatin1(tagEnum.valueToKey(tag)); - - switch (tag) { - case id: - case versionNumber: - case buildId: - case name: - case description: - case authorId: - setStringValue(tagName, value.toString()); - break; - case icon: - case splashScreens: - setChildStringListValue(tagName, QLatin1String("image"), value.toStringList()); - break; - case asset: - setAssets(value.value<BarDescriptorAssetList>()); - break; - case aspectRatio: - case autoOrients: - case systemChrome: - setChildStringListValue(QLatin1String("initialWindow"), tagName, value.toStringList()); - break; - case transparent: - setChildStringListValue(QLatin1String("initialWindow"), tagName, QStringList() << (value.toBool() ? QLatin1String("true") : QLatin1String("false"))); - break; - case arg: - case action: - setStringListValue(tagName, value.toStringList()); - break; - case env: - setEnvironment(value.value<QList<Utils::EnvironmentItem> >()); - break; - case author: - case publisher: - // Unset <publisher> when setting <author> as only one should be used - setStringValue(QString::fromLatin1(tagEnum.valueToKey(author)), value.toString()); - setStringValue(QString::fromLatin1(tagEnum.valueToKey(publisher)), QLatin1String("")); - break; - } - - m_dirty = true; - emit changed(tag, value); - emit Core::IDocument::changed(); -} - -QString BarDescriptorDocument::stringValue(const QString &tagName) const -{ - QDomNodeList nodes = m_barDocument.elementsByTagName(tagName); - if (nodes.isEmpty() || nodes.size() > 1) - return QString(); - - QDomNode node = nodes.item(0); - QDomText textNode = node.firstChild().toText(); - if (textNode.isNull()) - return QString(); - - return textNode.data(); -} - -void BarDescriptorDocument::setStringValue(const QString &tagName, const QString &value) -{ - QDomNodeList nodes = m_barDocument.elementsByTagName(tagName); - - if (nodes.size() > 1) - return; - - QDomNode existingNode = nodes.item(0); - if (existingNode.isNull() && value.isEmpty()) - return; - - if (!existingNode.isNull() && value.isEmpty()) { - m_barDocument.documentElement().removeChild(existingNode); - } else if (existingNode.isNull()) { - QDomElement newNode = m_barDocument.createElement(tagName); - newNode.appendChild(m_barDocument.createTextNode(value)); - m_barDocument.documentElement().appendChild(newNode); - } else { - QDomText textNode = existingNode.firstChild().toText(); - if (textNode.isNull()) - return; - textNode.setData(value); - } -} - -QStringList BarDescriptorDocument::childStringListValue(const QString &tagName, const QString &childTagName) const -{ - QDomNodeList nodes = m_barDocument.elementsByTagName(tagName); - if (nodes.isEmpty() || nodes.size() > 1) - return QStringList(); - - QDomNode parentNode = nodes.item(0); - QDomElement childElm = parentNode.firstChildElement(childTagName); - if (childElm.isNull()) - return QStringList(); - - QStringList result; - while (!childElm.isNull()) { - QDomText textNode = childElm.firstChild().toText(); - if (textNode.isNull()) - return QStringList(); - - result.append(textNode.data()); - - childElm = childElm.nextSiblingElement(childTagName); - } - - return result; -} - -void BarDescriptorDocument::setChildStringListValue(const QString &tagName, const QString &childTagName, const QStringList &stringList) -{ - QDomNodeList nodes = m_barDocument.elementsByTagName(tagName); - - if (nodes.size() > 1) - return; - - QDomNode existingNode = nodes.item(0); - - if (existingNode.isNull()) { - QDomElement newParentNode = m_barDocument.createElement(tagName); - - foreach (const QString &value, stringList) { - QDomElement newChildNode = m_barDocument.createElement(childTagName); - QDomText newTextNode = m_barDocument.createTextNode(value); - newChildNode.appendChild(newTextNode); - newParentNode.appendChild(newChildNode); - } - m_barDocument.documentElement().appendChild(newParentNode); - } else { - QStringList values = stringList; - QDomElement childElm = existingNode.firstChildElement(childTagName); - if (!childElm.isNull()) { - // Loop through existing elements, remove the existing nodes - // that no longer are in "values", and remove from "values" - // the existing nodes that don't need re-creation - while (!childElm.isNull()) { - QDomText textNode = childElm.firstChild().toText(); - if (textNode.isNull()) - continue; - - QDomElement toRemove; - if (!values.contains(textNode.data())) - toRemove = childElm; - else - values.removeAll(textNode.data()); - - childElm = childElm.nextSiblingElement(childTagName); - - if (!toRemove.isNull()) - existingNode.removeChild(toRemove); - } - } - - // Add the new elements - int newElementCount = 0; - foreach (const QString &value, values) { - if (value.isEmpty()) - continue; - QDomElement newChildNode = m_barDocument.createElement(childTagName); - newChildNode.appendChild(m_barDocument.createTextNode(value)); - existingNode.appendChild(newChildNode); - ++newElementCount; - } - - if (newElementCount == 0) - m_barDocument.documentElement().removeChild(existingNode); - } -} - -QStringList BarDescriptorDocument::stringListValue(const QString &tagName) const -{ - QStringList result; - - QDomElement childElm = m_barDocument.documentElement().firstChildElement(tagName); - while (!childElm.isNull()) { - QDomText textNode = childElm.firstChild().toText(); - if (textNode.isNull()) - continue; - - result.append(textNode.data()); - - childElm = childElm.nextSiblingElement(tagName); - } - - return result; -} - -void BarDescriptorDocument::setStringListValue(const QString &tagName, const QStringList &stringList) -{ - QStringList values = stringList; - QDomElement childElm = m_barDocument.documentElement().firstChildElement(tagName); - if (!childElm.isNull()) { - // Loop through existing elements, remove the existing nodes - // that no longer are in "values", and remove from "values" - // the existing nodes that don't need re-creation - while (!childElm.isNull()) { - QDomText textNode = childElm.firstChild().toText(); - if (textNode.isNull()) - continue; - - QDomElement toRemove; - if (!values.contains(textNode.data())) - toRemove = childElm; - else - values.removeAll(textNode.data()); - - childElm = childElm.nextSiblingElement(tagName); - - if (!toRemove.isNull()) - m_barDocument.documentElement().removeChild(toRemove); - } - } - - // Add the new elements - foreach (const QString &value, values) { - if (value.isEmpty()) - continue; - QDomElement newChildNode = m_barDocument.createElement(tagName); - newChildNode.appendChild(m_barDocument.createTextNode(value)); - m_barDocument.documentElement().appendChild(newChildNode); - } -} - -BarDescriptorAssetList BarDescriptorDocument::assets() const -{ - BarDescriptorAssetList result; - QDomNodeList nodes = m_barDocument.elementsByTagName(QLatin1String("asset")); - if (nodes.isEmpty()) - return result; - - for (int i = 0; i < nodes.size(); ++i) { - QDomElement assetElm = nodes.item(i).toElement(); - if (assetElm.isNull()) - continue; - - QDomText textNode = assetElm.firstChild().toText(); - if (textNode.isNull()) - continue; - - QString path = assetElm.attribute(QLatin1String("path")); - QString entry = assetElm.attribute(QLatin1String("entry")); - QString dest = textNode.data(); - - BarDescriptorAsset asset; - asset.source = path; - asset.destination = dest; - asset.entry = entry == QLatin1String("true"); - result.append(asset); - } - - return result; -} - -void BarDescriptorDocument::setAssets(const BarDescriptorAssetList &assets) -{ - QDomNodeList nodes = m_barDocument.elementsByTagName(QLatin1String("asset")); - - BarDescriptorAssetList newAssets = assets; - QList<QDomNode> toRemove; - - for (int i = 0; i < nodes.size(); ++i) { - QDomElement assetElm = nodes.at(i).toElement(); - if (assetElm.isNull()) - continue; - - QDomText textNode = assetElm.firstChild().toText(); - if (textNode.isNull()) - continue; - - QString source = assetElm.attribute(QLatin1String("path")); - bool found = false; - foreach (const BarDescriptorAsset &asset, newAssets) { - if (asset.source == source) { - found = true; - if (asset.entry) { - assetElm.setAttribute(QLatin1String("type"), QLatin1String("Qnx/Elf")); - assetElm.setAttribute(QLatin1String("entry"), QLatin1String("true")); - } else { - assetElm.removeAttribute(QLatin1String("type")); - assetElm.removeAttribute(QLatin1String("entry")); - } - textNode.setData(asset.destination); - - newAssets.removeAll(asset); - break; - } - } - - if (!found) - toRemove.append(assetElm); - } - - foreach (const QDomNode &node, toRemove) - m_barDocument.documentElement().removeChild(node); - - foreach (const BarDescriptorAsset &asset, newAssets) { - QDomElement assetElm = m_barDocument.createElement(QLatin1String("asset")); - assetElm.setAttribute(QLatin1String("path"), asset.source); - if (asset.entry) { - assetElm.setAttribute(QLatin1String("type"), QLatin1String("Qnx/Elf")); - assetElm.setAttribute(QLatin1String("entry"), QLatin1String("true")); - } - assetElm.appendChild(m_barDocument.createTextNode(asset.destination)); - m_barDocument.documentElement().appendChild(assetElm); - } -} - -QList<Utils::EnvironmentItem> BarDescriptorDocument::environment() const -{ - QList<Utils::EnvironmentItem> result; - - QDomElement envElm = m_barDocument.documentElement().firstChildElement(QLatin1String("env")); - while (!envElm.isNull()) { - QString var = envElm.attribute(QLatin1String("var")); - QString value = envElm.attribute(QLatin1String("value")); - - Utils::EnvironmentItem item(var, value); - result.append(item); - - envElm = envElm.nextSiblingElement(QLatin1String("env")); - } - return result; -} - -void BarDescriptorDocument::setEnvironment(const QList<Utils::EnvironmentItem> &environment) -{ - QDomNodeList envNodes = m_barDocument.elementsByTagName(QLatin1String("env")); - - QList<Utils::EnvironmentItem> newEnvironment = environment; - QList<QDomElement> toRemove; - for (int i = 0; i < envNodes.size(); ++i) { - QDomElement elm = envNodes.at(i).toElement(); - if (elm.isNull()) - continue; - - QString var = elm.attribute(QLatin1String("var")); - bool found = false; - foreach (const Utils::EnvironmentItem item, newEnvironment) { - if (item.name == var) { - found = true; - elm.setAttribute(QLatin1String("value"), item.value); - newEnvironment.removeAll(item); - break; - } - } - - if (!found) - toRemove.append(elm); - } - - foreach (const QDomNode &node, toRemove) - m_barDocument.documentElement().removeChild(node); - - foreach (const Utils::EnvironmentItem item, newEnvironment) { - QDomElement elm = m_barDocument.createElement(QLatin1String("env")); - elm.setAttribute(QLatin1String("var"), item.name); - elm.setAttribute(QLatin1String("value"), item.value); - m_barDocument.documentElement().appendChild(elm); - } -} - -void BarDescriptorDocument::emitAllChanged() -{ - QMetaEnum tags = metaObject()->enumerator(metaObject()->enumeratorOffset()); - for (int i = 0; i < tags.keyCount(); ++i) { - Tag tag = static_cast<Tag>(tags.value(i)); - emit changed(tag, value(tag)); - } -} - -QString BarDescriptorDocument::bannerComment() const -{ - QDomNode nd = m_barDocument.firstChild(); - QDomProcessingInstruction pi = nd.toProcessingInstruction(); - if (!pi.isNull()) - nd = pi.nextSibling(); - - return nd.toComment().data(); -} - -void BarDescriptorDocument::setBannerComment(const QString &commentText) -{ - QDomNode nd = m_barDocument.firstChild(); - QDomProcessingInstruction pi = nd.toProcessingInstruction(); - if (!pi.isNull()) - nd = pi.nextSibling(); - - bool oldDirty = m_dirty; - QDomComment cnd = nd.toComment(); - if (cnd.isNull()) { - if (!commentText.isEmpty()) { - cnd = m_barDocument.createComment(commentText); - m_barDocument.insertBefore(cnd, nd); - m_dirty = true; - } - } else { - if (commentText.isEmpty()) { - m_barDocument.removeChild(cnd); - m_dirty = true; - } else { - if (cnd.data() != commentText) { - cnd.setData(commentText); - m_dirty = true; - } - } - } - if (m_dirty != oldDirty) - emit Core::IDocument::changed(); -} - -int BarDescriptorDocument::tagForElement(const QDomElement &element) -{ - QMetaEnum tags = metaObject()->enumerator(metaObject()->enumeratorOffset()); - QDomElement el = element; - while (!el.isNull()) { - const int n = tags.keyToValue(el.tagName().toLatin1().constData()); - if (n > -1) - return n; - el = el.parentNode().toElement(); - } - return -1; -} - -bool BarDescriptorDocument::expandPlaceHolder_helper(const QDomElement &el, - const QString &placeholderKey, - const QString &placeholderText, - QSet<BarDescriptorDocument::Tag> &changedTags) -{ - // replace attributes - bool elementChanged = false; - QDomNamedNodeMap attrs = el.attributes(); - for (int i = 0; i < attrs.count(); ++i) { - QDomAttr attr = attrs.item(i).toAttr(); - if (!attr.isNull()) { - QString s = attr.value(); - s.replace(placeholderKey, placeholderText); - if (s != attr.value()) { - attr.setValue(s); - elementChanged = true; - } - } - } - - bool documentChanged = false; - // replace text - for (QDomNode nd = el.firstChild(); !nd.isNull(); nd = nd.nextSibling()) { - QDomText txtnd = nd.toText(); - if (!txtnd.isNull()) { - QString s = txtnd.data(); - s.replace(placeholderKey, placeholderText); - if (s != txtnd.data()) { - txtnd.setData(s); - elementChanged = true; - } - } - QDomElement child = nd.toElement(); - if (!child.isNull()) { - bool hit = expandPlaceHolder_helper(child, placeholderKey, placeholderText, changedTags); - documentChanged = documentChanged || hit; - } - } - if (elementChanged) { - int n = tagForElement(el); - if (n >= 0) - changedTags << static_cast<Tag>(n); - } - documentChanged = documentChanged || elementChanged; - return documentChanged; -} - -void BarDescriptorDocument::expandPlaceHolders(const QHash<QString, QString> &placeholdersKeyVals) -{ - QSet<Tag> changedTags; - QHashIterator<QString, QString> it(placeholdersKeyVals); - bool docChanged = false; - while (it.hasNext()) { - it.next(); - bool expanded = expandPlaceHolder_helper(m_barDocument.documentElement(), - it.key(), it.value(), changedTags); - docChanged = docChanged || expanded; - } - m_dirty = m_dirty || docChanged; - foreach (Tag tag, changedTags) - emit changed(tag, value(tag)); - if (docChanged) - emit Core::IDocument::changed(); -} diff --git a/src/plugins/qnx/bardescriptordocument.h b/src/plugins/qnx/bardescriptordocument.h deleted file mode 100644 index d68c9048804..00000000000 --- a/src/plugins/qnx/bardescriptordocument.h +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTORDOCUMENT_H -#define QNX_INTERNAL_BARDESCRIPTORDOCUMENT_H - -#include <coreplugin/textdocument.h> -#include <utils/environment.h> - -#include <QDomDocument> -#include <QMetaType> - -namespace Qnx { -namespace Internal { - -class BarDescriptorAsset { -public: - QString source; - QString destination; - bool entry; - - bool operator==(const BarDescriptorAsset &asset) const - { - return source == asset.source && destination == asset.destination; - } -}; - -typedef QList<BarDescriptorAsset> BarDescriptorAssetList; - -class BarDescriptorDocument : public Core::BaseTextDocument -{ - Q_OBJECT - - Q_ENUMS(Tag) - -public: - enum Tag { - id = 0, - versionNumber, - buildId, - name, - description, - icon, - splashScreens, - asset, - aspectRatio, - autoOrients, - systemChrome, - transparent, - arg, - action, - env, - author, - publisher, - authorId - }; - - explicit BarDescriptorDocument(QObject *parent = 0); - ~BarDescriptorDocument(); - - bool open(QString *errorString, const QString &fileName); - bool save(QString *errorString, const QString &fileName = QString(), bool autoSave = false); - - QString defaultPath() const; - QString suggestedFileName() const; - - bool shouldAutoSave() const; - bool isModified() const; - bool isSaveAsAllowed() const; - - ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; - bool reload(QString *errorString, ReloadFlag flag, ChangeType type); - - QString xmlSource() const; - bool loadContent(const QString &xmlCode, bool setDirty, QString *errorMessage = 0, int *errorLine = 0); - - QVariant value(Tag tag) const; - - void expandPlaceHolders(const QHash<QString, QString> &placeholdersKeyVals); - - QString bannerComment() const; - void setBannerComment(const QString &commentText); - -signals: - void changed(BarDescriptorDocument::Tag tag, const QVariant &value); - -public slots: - void setValue(BarDescriptorDocument::Tag tag, const QVariant &value); -private: - QString stringValue(const QString &tagName) const; - void setStringValue(const QString &tagName, const QString &value); - - QStringList childStringListValue(const QString &tagName, const QString &childTagName) const; - void setChildStringListValue(const QString &tagName, const QString &childTagName, const QStringList &stringList); - - QStringList stringListValue(const QString &tagName) const; - void setStringListValue(const QString &tagName, const QStringList &stringList); - - BarDescriptorAssetList assets() const; - void setAssets(const BarDescriptorAssetList &assets); - - QList<Utils::EnvironmentItem> environment() const; - void setEnvironment(const QList<Utils::EnvironmentItem> &environment); - - int tagForElement(const QDomElement &element); - bool expandPlaceHolder_helper(const QDomElement &el, const QString &placeholderKey, - const QString &placeholderText, - QSet<BarDescriptorDocument::Tag> &changedTags); - - void emitAllChanged(); - - bool m_dirty; - QDomDocument m_barDocument; -}; - -} // namespace Internal -} // namespace Qnx - -Q_DECLARE_METATYPE(Qnx::Internal::BarDescriptorAssetList) -Q_DECLARE_METATYPE(QList<Utils::EnvironmentItem>) -Q_DECLARE_METATYPE(Qnx::Internal::BarDescriptorDocument::Tag) - -#endif // QNX_INTERNAL_BARDESCRIPTORDOCUMENT_H diff --git a/src/plugins/qnx/bardescriptoreditor.cpp b/src/plugins/qnx/bardescriptoreditor.cpp deleted file mode 100644 index 5274774d30c..00000000000 --- a/src/plugins/qnx/bardescriptoreditor.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditor.h" - -#include "qnxconstants.h" -#include "bardescriptoreditorwidget.h" -#include "bardescriptordocument.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/task.h> -#include <projectexplorer/taskhub.h> -#include <texteditor/texteditorconstants.h> -#include <texteditor/texteditor.h> -#include <texteditor/textdocument.h> -#include <texteditor/tabsettings.h> -#include <utils/linecolumnlabel.h> -#include <utils/qtcassert.h> - -#include <QAction> -#include <QStyle> -#include <QTextBlock> -#include <QToolBar> - -using namespace ProjectExplorer; - -namespace Qnx { -namespace Internal { - -BarDescriptorEditor::BarDescriptorEditor() -{ - m_file = new BarDescriptorDocument(this); - - BarDescriptorEditorWidget *editorWidget = new BarDescriptorEditorWidget(this); - setWidget(editorWidget); - - m_toolBar = new QToolBar(editorWidget); - - m_actionGroup = new QActionGroup(this); - connect(m_actionGroup, SIGNAL(triggered(QAction*)), this, SLOT(changeEditorPage(QAction*))); - - QAction *generalAction = m_toolBar->addAction(tr("General")); - generalAction->setData(General); - generalAction->setCheckable(true); - m_actionGroup->addAction(generalAction); - - QAction *applicationAction = m_toolBar->addAction(tr("Application")); - applicationAction->setData(Application); - applicationAction->setCheckable(true); - m_actionGroup->addAction(applicationAction); - - QAction *assetsAction = m_toolBar->addAction(tr("Assets")); - assetsAction->setData(Assets); - assetsAction->setCheckable(true); - m_actionGroup->addAction(assetsAction); - - QAction *sourceAction = m_toolBar->addAction(tr("XML Source")); - sourceAction->setData(Source); - sourceAction->setCheckable(true); - m_actionGroup->addAction(sourceAction); - - generalAction->setChecked(true); - - m_cursorPositionLabel = new Utils::LineColumnLabel; - const int spacing = editorWidget->style()->pixelMetric(QStyle::PM_LayoutHorizontalSpacing) / 2; - m_cursorPositionLabel->setContentsMargins(spacing, 0, spacing, 0); - - QWidget *spacer = new QWidget; - spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - m_toolBar->addWidget(spacer); - - m_cursorPositionAction = m_toolBar->addWidget(m_cursorPositionLabel); - connect(editorWidget->sourceWidget(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition())); - - setContext(Core::Context(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT, - TextEditor::Constants::C_TEXTEDITOR)); -} - -bool BarDescriptorEditor::open(QString *errorString, const QString &fileName, const QString &realFileName) -{ - QTC_ASSERT(fileName == realFileName, return false); - - bool result = m_file->open(errorString, fileName); - if (result) { - BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget()); - QTC_ASSERT(editorWidget, return false); - editorWidget->setFilePath(Utils::FileName::fromString(fileName)); - } - - return result; -} - -Core::IDocument *BarDescriptorEditor::document() -{ - return m_file; -} - -QWidget *BarDescriptorEditor::toolBar() -{ - return m_toolBar; -} - -BarDescriptorEditor::EditorPage BarDescriptorEditor::activePage() const -{ - BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget()); - QTC_ASSERT(editorWidget, return static_cast<EditorPage>(-1)); - - return static_cast<EditorPage>(editorWidget->currentIndex()); -} - -void BarDescriptorEditor::changeEditorPage(QAction *action) -{ - setActivePage(static_cast<EditorPage>(action->data().toInt())); -} - -void BarDescriptorEditor::setActivePage(BarDescriptorEditor::EditorPage page) -{ - BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget()); - QTC_ASSERT(editorWidget, return); - - m_cursorPositionAction->setVisible(page == Source); - editorWidget->setCurrentIndex(page); -} - -void BarDescriptorEditor::updateCursorPosition() -{ - BarDescriptorEditorWidget *editorWidget = qobject_cast<BarDescriptorEditorWidget *>(widget()); - QTC_ASSERT(editorWidget, return); - - const QTextCursor cursor = editorWidget->sourceWidget()->textCursor(); - const QTextBlock block = cursor.block(); - const int line = block.blockNumber() + 1; - const int column = cursor.position() - block.position(); - m_cursorPositionLabel->setText(tr("Line: %1, Col: %2").arg(line) - .arg(editorWidget->sourceWidget()->textDocument() - ->tabSettings().columnAt(block.text(), column)+1), - tr("Line: 9999, Col: 999")); - if (!block.isVisible()) - editorWidget->sourceWidget()->ensureCursorVisible(); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/bardescriptoreditor.h b/src/plugins/qnx/bardescriptoreditor.h deleted file mode 100644 index e70ac547421..00000000000 --- a/src/plugins/qnx/bardescriptoreditor.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITOR_H -#define QNX_INTERNAL_BARDESCRIPTOREDITOR_H - -#include <coreplugin/editormanager/ieditor.h> - -QT_BEGIN_NAMESPACE -class QActionGroup; -class QToolBar; -QT_END_NAMESPACE - -namespace Utils { class LineColumnLabel; } - -namespace Qnx { -namespace Internal { - -class BarDescriptorDocument; -class BarDescriptorEditorWidget; - -class BarDescriptorEditor : public Core::IEditor -{ - Q_OBJECT -public: - enum EditorPage { - General = 0, - Application, - Assets, - Source - }; - - BarDescriptorEditor(); - - bool open(QString *errorString, const QString &fileName, const QString &realFileName); - Core::IDocument *document(); - QWidget *toolBar(); - - EditorPage activePage() const; - -private slots: - void changeEditorPage(QAction *action); - void updateCursorPosition(); - -private: - void setActivePage(EditorPage page); - - BarDescriptorDocument *m_file; - - QToolBar *m_toolBar; - QActionGroup *m_actionGroup; - Utils::LineColumnLabel *m_cursorPositionLabel; - QAction *m_cursorPositionAction; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTOREDITOR_H diff --git a/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.cpp b/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.cpp deleted file mode 100644 index eae6e5bacbd..00000000000 --- a/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorabstractpanelwidget.h" - -#include <utils/pathchooser.h> -#include <utils/qtcassert.h> - -#include <QCheckBox> -#include <QComboBox> -#include <QLineEdit> -#include <QSignalMapper> -#include <QTextEdit> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorAbstractPanelWidget::BarDescriptorEditorAbstractPanelWidget(QWidget *parent) : - QWidget(parent) -{ - m_signalMapper = new QSignalMapper(this); - connect(m_signalMapper, SIGNAL(mapped(int)), this, SLOT(handleSignalMapped(int))); -} - -void BarDescriptorEditorAbstractPanelWidget::setValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (m_blockedSignals.contains(tag)) - return; - - blockSignalMapping(tag); - updateWidgetValue(tag, value); - unblockSignalMapping(tag); -} - -void BarDescriptorEditorAbstractPanelWidget::addSignalMapping(BarDescriptorDocument::Tag tag, QObject *object, const char *signal) -{ - m_signalMapper->setMapping(object, tag); - connect(object, signal, m_signalMapper, SLOT(map())); -} - -void BarDescriptorEditorAbstractPanelWidget::blockSignalMapping(BarDescriptorDocument::Tag tag) -{ - m_blockedSignals.prepend(tag); -} - -void BarDescriptorEditorAbstractPanelWidget::unblockSignalMapping(BarDescriptorDocument::Tag tag) -{ - BarDescriptorDocument::Tag removedTag = m_blockedSignals.takeFirst(); - QTC_CHECK(removedTag == tag); -} - -void BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - QObject *object = m_signalMapper->mapping(static_cast<int>(tag)); - if (!object) - return; - - if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(object)) - lineEdit->setText(value.toString()); - else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(object)) - textEdit->setPlainText(value.toString()); - else if (Utils::PathChooser *pathChooser = qobject_cast<Utils::PathChooser *>(object)) - pathChooser->setPath(value.toString()); - else if (QComboBox *comboBox = qobject_cast<QComboBox *>(object)) - comboBox->setCurrentIndex(comboBox->findData(value.toString())); - else if (QCheckBox *checkBox = qobject_cast<QCheckBox *>(object)) - checkBox->setChecked(value.toBool()); - else - QTC_CHECK(false); -} - -void BarDescriptorEditorAbstractPanelWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - QObject *sender = m_signalMapper->mapping(tag); - - if (!sender) - return; - - if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(sender)) - emit changed(tag, lineEdit->text()); - else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(sender)) - emit changed(tag, textEdit->toPlainText()); - else if (Utils::PathChooser *pathChooser = qobject_cast<Utils::PathChooser *>(sender)) - emit changed(tag, pathChooser->path()); - else if (QComboBox *comboBox = qobject_cast<QComboBox *>(sender)) - emit changed(tag, comboBox->itemData(comboBox->currentIndex())); - else if (QCheckBox *checkBox = qobject_cast<QCheckBox *>(sender)) - emit changed(tag, checkBox->isChecked()); - else - QTC_CHECK(false); -} - -void BarDescriptorEditorAbstractPanelWidget::handleSignalMapped(int id) -{ - BarDescriptorDocument::Tag tag = static_cast<BarDescriptorDocument::Tag>(id); - - if (m_blockedSignals.contains(tag)) - return; - - blockSignalMapping(tag); - emitChanged(tag); - unblockSignalMapping(tag); -} diff --git a/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.h b/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.h deleted file mode 100644 index 23408667dc0..00000000000 --- a/src/plugins/qnx/bardescriptoreditorabstractpanelwidget.h +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORABSTRACTPANELWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORABSTRACTPANELWIDGET_H - -#include <QWidget> - -#include "bardescriptordocument.h" - -namespace Utils { class PathChooser; } - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -class QLineEdit; -class QSignalMapper; -class QStringListModel; -class QTextEdit; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BarDescriptorEditorAbstractPanelWidget : public QWidget -{ - Q_OBJECT -public: - explicit BarDescriptorEditorAbstractPanelWidget(QWidget *parent = 0); - -public slots: - void setValue(BarDescriptorDocument::Tag tag, const QVariant &value); - -signals: - void changed(BarDescriptorDocument::Tag tag, const QVariant &value); - -protected: - virtual void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - virtual void emitChanged(BarDescriptorDocument::Tag tag); - - void addSignalMapping(BarDescriptorDocument::Tag tag, QObject *object, const char *signal); - void blockSignalMapping(BarDescriptorDocument::Tag tag); - void unblockSignalMapping(BarDescriptorDocument::Tag tag); - -private slots: - void handleSignalMapped(int id); - -private: - QSignalMapper *m_signalMapper; - QList<BarDescriptorDocument::Tag> m_blockedSignals; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORABSTRACTPANELWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorassetswidget.cpp b/src/plugins/qnx/bardescriptoreditorassetswidget.cpp deleted file mode 100644 index c973c347ee3..00000000000 --- a/src/plugins/qnx/bardescriptoreditorassetswidget.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorassetswidget.h" -#include "ui_bardescriptoreditorassetswidget.h" - -#include "bardescriptordocument.h" - -#include <utils/qtcassert.h> - -#include <QFileDialog> -#include <QStandardItemModel> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorAssetsWidget::BarDescriptorEditorAssetsWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorAssetsWidget) -{ - m_ui->setupUi(this); - - QStringList headerLabels; - headerLabels << tr("Path") << tr("Destination") << tr("Entry-Point"); - m_assetsModel = new QStandardItemModel(this); - m_assetsModel->setHorizontalHeaderLabels(headerLabels); - m_ui->assets->setModel(m_assetsModel); - - connect(m_ui->addAsset, SIGNAL(clicked()), this, SLOT(addNewAsset())); - connect(m_ui->removeAsset, SIGNAL(clicked()), this, SLOT(removeSelectedAsset())); - connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*))); - - addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex))); - addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(rowsInserted(QModelIndex,int,int))); - addSignalMapping(BarDescriptorDocument::asset, m_assetsModel, SIGNAL(rowsRemoved(QModelIndex,int,int))); -} - -BarDescriptorEditorAssetsWidget::~BarDescriptorEditorAssetsWidget() -{ - delete m_ui; -} - -void BarDescriptorEditorAssetsWidget::clear() -{ - blockSignalMapping(BarDescriptorDocument::asset); - m_assetsModel->removeRows(0, m_assetsModel->rowCount()); - unblockSignalMapping(BarDescriptorDocument::asset); -} - -QStandardItemModel *BarDescriptorEditorAssetsWidget::assetsModel() const -{ - return m_assetsModel; -} - -void BarDescriptorEditorAssetsWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (tag != BarDescriptorDocument::asset) { - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); - return; - } - - clear(); - BarDescriptorAssetList assets = value.value<BarDescriptorAssetList>(); - foreach (const BarDescriptorAsset asset, assets) - addAsset(asset); -} - -void BarDescriptorEditorAssetsWidget::addAsset(const QString &fullPath) -{ - if (fullPath.isEmpty()) - return; - - BarDescriptorAsset asset; - asset.source = fullPath; - asset.destination = Utils::FileName::fromString(fullPath).fileName(); - asset.entry = false; - addAsset(asset); -} - -void BarDescriptorEditorAssetsWidget::removeAsset(const QString &fullPath) -{ - QList<QStandardItem*> assetItems = m_assetsModel->findItems(fullPath); - foreach (QStandardItem *assetItem, assetItems) { - QList<QStandardItem*> assetRow = m_assetsModel->takeRow(assetItem->row()); - while (!assetRow.isEmpty()) - delete assetRow.takeLast(); - } -} - -void BarDescriptorEditorAssetsWidget::addNewAsset() -{ - const QString fileName = QFileDialog::getOpenFileName(this, tr("Select File to Add")); - if (fileName.isEmpty()) - return; - addAsset(fileName); -} - -void BarDescriptorEditorAssetsWidget::removeSelectedAsset() -{ - QModelIndexList selectedIndexes = m_ui->assets->selectionModel()->selectedRows(); - if (selectedIndexes.isEmpty()) - return; - - foreach (const QModelIndex &index, selectedIndexes) - m_assetsModel->removeRow(index.row()); -} - -void BarDescriptorEditorAssetsWidget::updateEntryCheckState(QStandardItem *item) -{ - if (item->column() != 2 || item->checkState() == Qt::Unchecked) - return; - - disconnect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*))); - for (int i = 0; i < m_assetsModel->rowCount(); ++i) { - QStandardItem *other = m_assetsModel->item(i, 2); - if (other == item) - continue; - - // Only one asset can be the entry point - other->setCheckState(Qt::Unchecked); - } - connect(m_assetsModel, SIGNAL(itemChanged(QStandardItem*)), this, SLOT(updateEntryCheckState(QStandardItem*))); -} - -void BarDescriptorEditorAssetsWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - if (tag != BarDescriptorDocument::asset) { - BarDescriptorEditorAbstractPanelWidget::emitChanged(tag); - return; - } - - BarDescriptorAssetList result; - for (int i = 0; i < m_assetsModel->rowCount(); ++i) { - BarDescriptorAsset asset; - asset.source = m_assetsModel->item(i, 0)->text(); - asset.destination = m_assetsModel->item(i, 1)->text(); - asset.entry = m_assetsModel->item(i, 2)->checkState() == Qt::Checked; - result.append(asset); - } - - QVariant var; - var.setValue(result); - emit changed(tag, var); -} - -void BarDescriptorEditorAssetsWidget::addAsset(const BarDescriptorAsset &asset) -{ - const QString path = asset.source; - const QString dest = asset.destination; - QTC_ASSERT(!path.isEmpty(), return); - QTC_ASSERT(!dest.isEmpty(), return); - - if (hasAsset(asset)) - return; - - QList<QStandardItem *> items; - items << new QStandardItem(path); - items << new QStandardItem(dest); - - QStandardItem *entryItem = new QStandardItem(); - entryItem->setCheckable(true); - entryItem->setCheckState(asset.entry ? Qt::Checked : Qt::Unchecked); - items << entryItem; - m_assetsModel->appendRow(items); -} - -bool BarDescriptorEditorAssetsWidget::hasAsset(const BarDescriptorAsset &asset) -{ - for (int i = 0; i < m_assetsModel->rowCount(); ++i) { - QStandardItem *sourceItem = m_assetsModel->item(i, 0); - QStandardItem *destItem = m_assetsModel->item(i, 1); - if (sourceItem->text() == asset.source && destItem->text() == asset.destination) - return true; - } - - return false; -} diff --git a/src/plugins/qnx/bardescriptoreditorassetswidget.h b/src/plugins/qnx/bardescriptoreditorassetswidget.h deleted file mode 100644 index 41b3710135c..00000000000 --- a/src/plugins/qnx/bardescriptoreditorassetswidget.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORASSETSWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORASSETSWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -QT_BEGIN_NAMESPACE -class QStandardItem; -class QStandardItemModel; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorAssetsWidget; } - -class BarDescriptorAsset; - -class BarDescriptorEditorAssetsWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorAssetsWidget(QWidget *parent = 0); - ~BarDescriptorEditorAssetsWidget(); - - QStandardItemModel *assetsModel() const; - -public slots: - void addAsset(const QString &fullPath); - void removeAsset(const QString &fullPath); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - void emitChanged(BarDescriptorDocument::Tag tag); - -private slots: - void addNewAsset(); - void removeSelectedAsset(); - void updateEntryCheckState(QStandardItem *item); - -private: - void clear(); - void addAsset(const BarDescriptorAsset &asset); - bool hasAsset(const BarDescriptorAsset &asset); - - Ui::BarDescriptorEditorAssetsWidget *m_ui; - - QStandardItemModel *m_assetsModel; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORASSETSWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorassetswidget.ui b/src/plugins/qnx/bardescriptoreditorassetswidget.ui deleted file mode 100644 index 42242b92732..00000000000 --- a/src/plugins/qnx/bardescriptoreditorassetswidget.ui +++ /dev/null @@ -1,59 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorAssetsWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorAssetsWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>380</width> - <height>245</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="assets"> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QPushButton" name="addAsset"> - <property name="text"> - <string>Add...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeAsset"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.cpp b/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.cpp deleted file mode 100644 index 0c5090997a0..00000000000 --- a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorauthorinformationwidget.h" -#include "ui_bardescriptoreditorauthorinformationwidget.h" - -#include "blackberrydebugtokenreader.h" -#include "blackberrydeviceconfiguration.h" -#include "blackberrysigningutils.h" -#include "qnxconstants.h" - -#include <projectexplorer/devicesupport/devicemanager.h> -#include <utils/qtcassert.h> - -#include <QInputDialog> -#include <QMessageBox> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorAuthorInformationWidget::BarDescriptorEditorAuthorInformationWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorAuthorInformationWidget) -{ - m_ui->setupUi(this); - - m_ui->setFromDebugToken->setVisible(BlackBerryDebugTokenReader::isSupported()); - - addSignalMapping(BarDescriptorDocument::author, m_ui->author, SIGNAL(textChanged(QString))); - addSignalMapping(BarDescriptorDocument::authorId, m_ui->authorId, SIGNAL(textChanged(QString))); - connect(m_ui->setFromDebugToken, SIGNAL(clicked()), this, SLOT(setAuthorFromDebugToken())); -} - -BarDescriptorEditorAuthorInformationWidget::~BarDescriptorEditorAuthorInformationWidget() -{ - delete m_ui; -} - -void BarDescriptorEditorAuthorInformationWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (tag == BarDescriptorDocument::publisher && !value.toString().isEmpty()) - // <publisher> is deprecated and hence not connected to the author field as we only want to read it from the XML - m_ui->author->setText(value.toString()); - else - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); -} - -void BarDescriptorEditorAuthorInformationWidget::setAuthorFromDebugToken() -{ - // To select debug token, make it fancier once the debug token management is done in - // Qt Creator - QStringList debugTokens; - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - for (int i = 0; i < deviceManager->deviceCount(); ++i) { - ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i); - if (device->type() == Core::Id(Constants::QNX_BB_OS_TYPE)) { - BlackBerryDeviceConfiguration::ConstPtr bbDevice = device.dynamicCast<const BlackBerryDeviceConfiguration>(); - QTC_ASSERT(bbDevice, continue); - - debugTokens << bbDevice->debugToken(); - } - } - debugTokens << BlackBerrySigningUtils::instance().debugTokens(); - debugTokens.removeDuplicates(); - - bool ok; - QString debugToken = QInputDialog::getItem(this, tr("Select Debug Token"), tr("Debug token:"), debugTokens, 0, false, &ok); - if (!ok || debugToken.isEmpty()) - return; - - BlackBerryDebugTokenReader debugTokenReader(debugToken); - if (!debugTokenReader.isValid()) { - QMessageBox::warning(this, tr("Error Reading Debug Token"), tr("There was a problem reading debug token.")); - return; - } - - m_ui->author->setText(debugTokenReader.author()); - m_ui->authorId->setText(debugTokenReader.authorId()); -} diff --git a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.h b/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.h deleted file mode 100644 index 893760cad7e..00000000000 --- a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORAUTHORINFORMATIONWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORAUTHORINFORMATIONWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorAuthorInformationWidget; } - -class BarDescriptorEditorAuthorInformationWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorAuthorInformationWidget(QWidget *parent = 0); - ~BarDescriptorEditorAuthorInformationWidget(); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - -private slots: - void setAuthorFromDebugToken(); - -private: - Ui::BarDescriptorEditorAuthorInformationWidget *m_ui; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORAUTHORINFORMATIONWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.ui b/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.ui deleted file mode 100644 index cd2de193088..00000000000 --- a/src/plugins/qnx/bardescriptoreditorauthorinformationwidget.ui +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorAuthorInformationWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorAuthorInformationWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>371</width> - <height>90</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Author:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="author"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Author ID:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="authorId"/> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="setFromDebugToken"> - <property name="text"> - <string>Set from debug token...</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorentrypointwidget.cpp b/src/plugins/qnx/bardescriptoreditorentrypointwidget.cpp deleted file mode 100644 index 6ed3e6be20e..00000000000 --- a/src/plugins/qnx/bardescriptoreditorentrypointwidget.cpp +++ /dev/null @@ -1,309 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorentrypointwidget.h" -#include "ui_bardescriptoreditorentrypointwidget.h" - -#include <QFileDialog> -#include <QStringListModel> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -// Recommended maximum size for icons according to -// http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/r_barfile_dtd_ref_image.html -static int AppIconMaxWidth = 114; -static int AppIconMaxHeight = 114; - -// Recommended maximum size for splashscreens according to -// http://developer.blackberry.com/native/documentation/bb10/com.qnx.doc.native_sdk.devguide/com.qnx.doc.native_sdk.devguide/topic/r_barfile_dtd_ref_splashscreens.html -static int SplashScreenMaxWidth = 1280; -static int SplashScreenMaxHeight = 1280; -} - -BarDescriptorEditorEntryPointWidget::BarDescriptorEditorEntryPointWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorEntryPointWidget) -{ - m_ui->setupUi(this); - - m_ui->iconFilePath->setExpectedKind(Utils::PathChooser::File); - m_ui->iconFilePath->setHistoryCompleter(QLatin1String("Qmake.Icon.History")); - m_ui->iconFilePath->setPromptDialogFilter(tr("Images (*.jpg *.png)")); - - m_ui->iconWarningLabel->setVisible(false); - m_ui->iconWarningPixmap->setVisible(false); - - m_ui->splashScreenWarningLabel->setVisible(false); - m_ui->splashScreenWarningPixmap->setVisible(false); - - connect(m_ui->iconFilePath, SIGNAL(changed(QString)), this, SLOT(handleIconChanged(QString))); - connect(m_ui->iconClearButton, SIGNAL(clicked()), this, SLOT(clearIcon())); - - m_splashScreenModel = new QStringListModel(this); - m_ui->splashScreensView->setModel(m_splashScreenModel); - connect(m_ui->addSplashScreen, SIGNAL(clicked()), this, SLOT(browseForSplashScreen())); - connect(m_ui->removeSplashScreen, SIGNAL(clicked()), this, SLOT(removeSelectedSplashScreen())); - connect(m_ui->splashScreensView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(handleSplashScreenSelectionChanged(QItemSelection,QItemSelection))); - - addSignalMapping(BarDescriptorDocument::name, m_ui->applicationName, SIGNAL(textChanged(QString))); - addSignalMapping(BarDescriptorDocument::description, m_ui->applicationDescription, SIGNAL(textChanged())); - addSignalMapping(BarDescriptorDocument::icon, m_ui->iconFilePath, SIGNAL(changed(QString))); - addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(dataChanged(QModelIndex,QModelIndex))); - addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(rowsRemoved(QModelIndex,int,int))); - addSignalMapping(BarDescriptorDocument::splashScreens, m_splashScreenModel, SIGNAL(rowsInserted(QModelIndex,int,int))); -} - -BarDescriptorEditorEntryPointWidget::~BarDescriptorEditorEntryPointWidget() -{ - delete m_ui; -} - -void BarDescriptorEditorEntryPointWidget::setAssetsModel(QStandardItemModel *assetsModel) -{ - m_assetsModel = assetsModel; -} - -void BarDescriptorEditorEntryPointWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - // During file loading, the assets might not have been read yet - if (tag == BarDescriptorDocument::icon) { - QMetaObject::invokeMethod(this, "setApplicationIconDelayed", Qt::QueuedConnection, Q_ARG(QString, value.toString())); - } else if (tag == BarDescriptorDocument::splashScreens) { - QStringList splashScreens = value.toStringList(); - foreach (const QString &splashScreen, splashScreens) - QMetaObject::invokeMethod(this, "appendSplashScreenDelayed", Qt::QueuedConnection, Q_ARG(QString, splashScreen)); - } else { - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); - } -} - -void BarDescriptorEditorEntryPointWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - if (tag == BarDescriptorDocument::icon) { - emit changed(tag, Utils::FileName::fromString(m_ui->iconFilePath->path()).fileName()); - } else if (tag == BarDescriptorDocument::splashScreens) { - QStringList list; - foreach (const QString &splashScreen, m_splashScreenModel->stringList()) - list << Utils::FileName::fromString(splashScreen).fileName(); - - emit changed(tag, list); - } else { - BarDescriptorEditorAbstractPanelWidget::emitChanged(tag); - } -} - -void BarDescriptorEditorEntryPointWidget::setApplicationIconPreview(const QString &path) -{ - setImagePreview(m_ui->iconPreviewLabel, path); -} - -void BarDescriptorEditorEntryPointWidget::validateIconSize(const QString &path) -{ - validateImage(path, m_ui->iconWarningLabel, m_ui->iconWarningPixmap, QSize(AppIconMaxWidth, AppIconMaxHeight)); -} - -void BarDescriptorEditorEntryPointWidget::handleIconChanged(const QString &path) -{ - if (path == m_prevIconPath) - return; - - setApplicationIconPreview(path); - validateIconSize(path); - - if (!m_splashScreenModel->stringList().contains(m_prevIconPath)) - emit imageRemoved(m_prevIconPath); - - m_prevIconPath = path; - if (QFileInfo::exists(path)) - emit imageAdded(path); -} - -void BarDescriptorEditorEntryPointWidget::clearIcon() -{ - m_ui->iconFilePath->setPath(QString()); -} - -void BarDescriptorEditorEntryPointWidget::browseForSplashScreen() -{ - const QString fileName = QFileDialog::getOpenFileName(this, tr("Select Splash Screen"), QString(), tr("Images (*.jpg *.png)")); - if (fileName.isEmpty()) - return; - - if (m_splashScreenModel->stringList().contains(fileName)) - return; - - int rowCount = m_splashScreenModel->rowCount(); - m_splashScreenModel->insertRow(rowCount); - m_splashScreenModel->setData(m_splashScreenModel->index(rowCount), fileName); - emit imageAdded(fileName); -} - -void BarDescriptorEditorEntryPointWidget::removeSelectedSplashScreen() -{ - QModelIndexList selectedIndexes = m_ui->splashScreensView->selectionModel()->selectedRows(); - if (selectedIndexes.isEmpty()) - return; - - foreach (const QModelIndex &index, selectedIndexes) { - QString path = m_splashScreenModel->data(index, Qt::DisplayRole).toString(); - if (path != m_ui->iconFilePath->path()) - emit imageRemoved(path); - - m_splashScreenModel->removeRow(index.row()); - } -} - -void BarDescriptorEditorEntryPointWidget::handleSplashScreenSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) -{ - Q_UNUSED(deselected); - - const bool emptySelection = selected.indexes().isEmpty(); - m_ui->removeSplashScreen->setEnabled(!emptySelection); - - if (!emptySelection) { - QString path = m_splashScreenModel->data(selected.indexes().at(0), Qt::DisplayRole).toString(); - setImagePreview(m_ui->splashScreenPreviewLabel, path); - validateSplashScreenSize(path); - } else { - setImagePreview(m_ui->splashScreenPreviewLabel, QString()); - m_ui->splashScreenWarningLabel->setVisible(false); - m_ui->splashScreenWarningPixmap->setVisible(false); - } -} - -void BarDescriptorEditorEntryPointWidget::appendSplashScreenDelayed(const QString &splashScreenPath) -{ - const QString fullSplashScreenPath = localAssetPathFromDestination(splashScreenPath); - if (fullSplashScreenPath.isEmpty()) - return; - - blockSignalMapping(BarDescriptorDocument::splashScreens); - int rowCount = m_splashScreenModel->rowCount(); - m_splashScreenModel->insertRow(rowCount); - m_splashScreenModel->setData(m_splashScreenModel->index(rowCount), fullSplashScreenPath); - unblockSignalMapping(BarDescriptorDocument::splashScreens); -} - -void BarDescriptorEditorEntryPointWidget::setImagePreview(QLabel *previewLabel, const QString &path) -{ - if (path.isEmpty()) { - previewLabel->clear(); - return; - } - - QPixmap originalPixmap(path); - if (originalPixmap.isNull()) { - previewLabel->clear(); - return; - } - - QSize size = previewLabel->minimumSize(); - QPixmap scaledPixmap = originalPixmap.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); - if (scaledPixmap.isNull()) { - previewLabel->clear(); - return; - } - - previewLabel->setPixmap(scaledPixmap); -} - -void BarDescriptorEditorEntryPointWidget::validateSplashScreenSize(const QString &path) -{ - validateImage(path, m_ui->splashScreenWarningLabel, m_ui->splashScreenWarningPixmap, QSize(SplashScreenMaxWidth, SplashScreenMaxHeight)); -} - -void BarDescriptorEditorEntryPointWidget::validateImage(const QString &path, QLabel *warningMessage, QLabel *warningPixmap, const QSize &maximumSize) -{ - ImageValidationResult result = Valid; - - QSize actualSize; - if (!path.isEmpty()) { - QImage img(path); - if (img.isNull()) { - result = CouldNotLoad; - } else { - actualSize = img.size(); - if (actualSize.width() > maximumSize.width() || actualSize.height() > maximumSize.height()) - result = IncorrectSize; - } - } - - switch (result) { - case CouldNotLoad: - warningMessage->setText(tr("<font color=\"red\">Could not open \"%1\" for reading.</font>").arg(path)); - warningMessage->setVisible(true); - warningPixmap->setVisible(true); - break; - case IncorrectSize: { - warningMessage->setText(tr("<font color=\"red\">The selected image is too big (%1x%2). The maximum size is %3x%4 pixels.</font>") - .arg(actualSize.width()).arg(actualSize.height()) - .arg(maximumSize.width()).arg(maximumSize.height())); - warningMessage->setVisible(true); - warningPixmap->setVisible(true); - break; - } - case Valid: - default: - warningMessage->setVisible(false); - warningPixmap->setVisible(false); - break; - } -} - -void BarDescriptorEditorEntryPointWidget::setApplicationIconDelayed(const QString &iconPath) -{ - const QString fullIconPath = localAssetPathFromDestination(iconPath); - if (fullIconPath.isEmpty()) - return; - - blockSignalMapping(BarDescriptorDocument::icon); - m_ui->iconFilePath->setPath(fullIconPath); - setApplicationIconPreview(fullIconPath); - validateIconSize(fullIconPath); - unblockSignalMapping(BarDescriptorDocument::icon); -} - -QString BarDescriptorEditorEntryPointWidget::localAssetPathFromDestination(const QString &destination) -{ - if (!m_assetsModel) - return QString(); - - for (int i = 0; i < m_assetsModel.data()->rowCount(); ++i) { - QStandardItem *destItem = m_assetsModel.data()->item(i, 1); - if (destItem->text() == destination) - return m_assetsModel.data()->item(i, 0)->text(); - } - - return QString(); -} diff --git a/src/plugins/qnx/bardescriptoreditorentrypointwidget.h b/src/plugins/qnx/bardescriptoreditorentrypointwidget.h deleted file mode 100644 index 880cdfd9a92..00000000000 --- a/src/plugins/qnx/bardescriptoreditorentrypointwidget.h +++ /dev/null @@ -1,106 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORENTRYPOINTWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORENTRYPOINTWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -#include <QPointer> -#include <QStandardItemModel> - -QT_BEGIN_NAMESPACE -class QItemSelection; -class QLabel; -class QStringListModel; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorEntryPointWidget; } - -class BarDescriptorEditorEntryPointWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorEntryPointWidget(QWidget *parent = 0); - ~BarDescriptorEditorEntryPointWidget(); - - void setAssetsModel(QStandardItemModel *assetsModel); - -signals: - void imageAdded(const QString &path); - void imageRemoved(const QString &path); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - void emitChanged(BarDescriptorDocument::Tag tag); - -private slots: - void setApplicationIconDelayed(const QString &iconPath); - void setApplicationIconPreview(const QString &path); - void validateIconSize(const QString &path); - void handleIconChanged(const QString &path); - void clearIcon(); - - void browseForSplashScreen(); - void removeSelectedSplashScreen(); - void handleSplashScreenSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); - void appendSplashScreenDelayed(const QString &splashScreenPath); - -private: - enum ImageValidationResult { - Valid, - CouldNotLoad, - IncorrectSize - }; - - void setImagePreview(QLabel *previewLabel, const QString &path); - void validateSplashScreenSize(const QString &path); - void validateImage(const QString &path, QLabel *warningMessage, QLabel *warningPixmap, const QSize &maximumSize); - - QString localAssetPathFromDestination(const QString &path); - - QStringListModel *m_splashScreenModel; - QPointer<QStandardItemModel> m_assetsModel; - - QString m_prevIconPath; - - Ui::BarDescriptorEditorEntryPointWidget *m_ui; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORENTRYPOINTWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorentrypointwidget.ui b/src/plugins/qnx/bardescriptoreditorentrypointwidget.ui deleted file mode 100644 index f83b6bc72be..00000000000 --- a/src/plugins/qnx/bardescriptoreditorentrypointwidget.ui +++ /dev/null @@ -1,212 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorEntryPointWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorEntryPointWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>611</width> - <height>455</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="applicationName"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Description:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QTextEdit" name="applicationDescription"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Icon:</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <layout class="QVBoxLayout" name="verticalLayout_8"> - <item> - <widget class="QLabel" name="iconPreviewLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>90</width> - <height>90</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="Utils::PathChooser" name="iconFilePath" native="true"/> - </item> - <item> - <widget class="QPushButton" name="iconClearButton"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="iconWarningPixmap"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../coreplugin/core.qrc">:/core/images/warning.png</pixmap> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QLabel" name="iconWarningLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="7" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Splash screens:</string> - </property> - </widget> - </item> - <item row="7" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QListView" name="splashScreensView"/> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_9"> - <item> - <widget class="QPushButton" name="addSplashScreen"> - <property name="text"> - <string>Add...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeSplashScreen"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="splashScreenPreviewLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>90</width> - <height>90</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::Panel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Sunken</enum> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item row="9" column="0"> - <widget class="QLabel" name="splashScreenWarningPixmap"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../coreplugin/core.qrc">:/core/images/warning.png</pixmap> - </property> - </widget> - </item> - <item row="9" column="1"> - <widget class="QLabel" name="splashScreenWarningLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources> - <include location="../projectexplorer/projectexplorer.qrc"/> - </resources> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.cpp b/src/plugins/qnx/bardescriptoreditorenvironmentwidget.cpp deleted file mode 100644 index 4612748a345..00000000000 --- a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorenvironmentwidget.h" -#include "ui_bardescriptoreditorenvironmentwidget.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorEnvironmentWidget::BarDescriptorEditorEnvironmentWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorEnvironmentWidget) -{ - m_ui->setupUi(this); - - m_ui->environmentWidget->setBaseEnvironmentText(tr("Device Environment")); - - addSignalMapping(BarDescriptorDocument::env, m_ui->environmentWidget, SIGNAL(userChangesChanged())); -} - -BarDescriptorEditorEnvironmentWidget::~BarDescriptorEditorEnvironmentWidget() -{ - delete m_ui; -} - -void BarDescriptorEditorEnvironmentWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (tag != BarDescriptorDocument::env) { - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); - return; - } - - m_ui->environmentWidget->setUserChanges(value.value<QList<Utils::EnvironmentItem> >()); -} - -void BarDescriptorEditorEnvironmentWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - if (tag != BarDescriptorDocument::env) { - BarDescriptorEditorAbstractPanelWidget::emitChanged(tag); - return; - } - - QVariant var; - var.setValue(m_ui->environmentWidget->userChanges()); - emit changed(tag, var); -} diff --git a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.h b/src/plugins/qnx/bardescriptoreditorenvironmentwidget.h deleted file mode 100644 index 515b59221c4..00000000000 --- a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORENVIRONMENTWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORENVIRONMENTWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -#include <utils/environment.h> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorEnvironmentWidget; } - -class BarDescriptorEditorEnvironmentWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorEnvironmentWidget(QWidget *parent = 0); - ~BarDescriptorEditorEnvironmentWidget(); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - void emitChanged(BarDescriptorDocument::Tag tag); - -private: - Ui::BarDescriptorEditorEnvironmentWidget *m_ui; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORENVIRONMENTWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.ui b/src/plugins/qnx/bardescriptoreditorenvironmentwidget.ui deleted file mode 100644 index 07cfedf4937..00000000000 --- a/src/plugins/qnx/bardescriptoreditorenvironmentwidget.ui +++ /dev/null @@ -1,32 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorEnvironmentWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorEnvironmentWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="ProjectExplorer::EnvironmentWidget" name="environmentWidget" native="true"/> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>ProjectExplorer::EnvironmentWidget</class> - <extends>QWidget</extends> - <header location="global">projectexplorer/environmentwidget.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorfactory.cpp b/src/plugins/qnx/bardescriptoreditorfactory.cpp deleted file mode 100644 index dc8c2774bd6..00000000000 --- a/src/plugins/qnx/bardescriptoreditorfactory.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorfactory.h" - -#include "qnxconstants.h" -#include "bardescriptoreditor.h" -#include "bardescriptoreditorwidget.h" - -#include <coreplugin/editormanager/editormanager.h> -#include <coreplugin/editormanager/ieditor.h> -#include <texteditor/texteditoractionhandler.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -class BarDescriptorActionHandler : public TextEditor::TextEditorActionHandler -{ -public: - BarDescriptorActionHandler(QObject *parent) - : TextEditor::TextEditorActionHandler(parent, Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT) - { - } -protected: - TextEditor::TextEditorWidget *resolveTextEditorWidget(Core::IEditor *editor) const - { - BarDescriptorEditorWidget *w = qobject_cast<BarDescriptorEditorWidget *>(editor->widget()); - return w ? w->sourceWidget() : 0; - } -}; - -BarDescriptorEditorFactory::BarDescriptorEditorFactory(QObject *parent) - : Core::IEditorFactory(parent) -{ - setId(Constants::QNX_BAR_DESCRIPTOR_EDITOR_ID); - setDisplayName(tr("Bar descriptor editor")); - addMimeType(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE); - new BarDescriptorActionHandler(this); -} - -Core::IEditor *BarDescriptorEditorFactory::createEditor() -{ - BarDescriptorEditor *editor = new BarDescriptorEditor(); - return editor; -} diff --git a/src/plugins/qnx/bardescriptoreditorfactory.h b/src/plugins/qnx/bardescriptoreditorfactory.h deleted file mode 100644 index 72d7d2ce238..00000000000 --- a/src/plugins/qnx/bardescriptoreditorfactory.h +++ /dev/null @@ -1,54 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORFACTORY_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORFACTORY_H - -#include <coreplugin/editormanager/ieditorfactory.h> - -namespace Qnx { -namespace Internal { - -class BarDescriptorEditorFactory : public Core::IEditorFactory -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorFactory(QObject *parent = 0); - - Core::IEditor *createEditor(); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORFACTORY_H diff --git a/src/plugins/qnx/bardescriptoreditorgeneralwidget.cpp b/src/plugins/qnx/bardescriptoreditorgeneralwidget.cpp deleted file mode 100644 index 887370ea806..00000000000 --- a/src/plugins/qnx/bardescriptoreditorgeneralwidget.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorgeneralwidget.h" -#include "ui_bardescriptoreditorgeneralwidget.h" - -#include <utils/qtcassert.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorGeneralWidget::BarDescriptorEditorGeneralWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorGeneralWidget) -{ - m_ui->setupUi(this); - - m_ui->orientation->addItem(tr("Default"), QLatin1String("")); - m_ui->orientation->addItem(tr("Auto-orient"), QLatin1String("auto-orient")); - m_ui->orientation->addItem(tr("Landscape"), QLatin1String("landscape")); - m_ui->orientation->addItem(tr("Portrait"), QLatin1String("portrait")); - - m_ui->chrome->addItem(tr("Standard"), QLatin1String("standard")); - m_ui->chrome->addItem(tr("None"), QLatin1String("none")); - - addSignalMapping(BarDescriptorDocument::aspectRatio, m_ui->orientation, SIGNAL(currentIndexChanged(int))); - addSignalMapping(BarDescriptorDocument::systemChrome, m_ui->chrome, SIGNAL(currentIndexChanged(int))); - addSignalMapping(BarDescriptorDocument::transparent, m_ui->transparentMainWindow, SIGNAL(toggled(bool))); - addSignalMapping(BarDescriptorDocument::arg, m_ui->applicationArguments, SIGNAL(textChanged(QString))); -} - -BarDescriptorEditorGeneralWidget::~BarDescriptorEditorGeneralWidget() -{ - delete m_ui; -} - -void BarDescriptorEditorGeneralWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (tag == BarDescriptorDocument::aspectRatio) { - m_ui->orientation->setCurrentIndex(m_ui->orientation->findData(value)); - } else if (tag == BarDescriptorDocument::autoOrients) { - if (value.toString() == QLatin1String("true")) { - blockSignalMapping(BarDescriptorDocument::aspectRatio); - m_ui->orientation->setCurrentIndex(m_ui->orientation->findData(QLatin1String("auto-orient"))); - unblockSignalMapping(BarDescriptorDocument::aspectRatio); - } - } else if (tag == BarDescriptorDocument::arg) { - m_ui->applicationArguments->setText(value.toStringList().join(QLatin1Char(' '))); - } else { - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); - } -} - -void BarDescriptorEditorGeneralWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - if (tag == BarDescriptorDocument::aspectRatio) { - QString value = m_ui->orientation->itemData(m_ui->orientation->currentIndex()).toString(); - if (value == QLatin1String("auto-orient")) { - emit changed(BarDescriptorDocument::aspectRatio, QLatin1String("")); - emit changed(BarDescriptorDocument::autoOrients, QLatin1String("true")); - return; - } else if (!value.isEmpty()) { - emit changed(BarDescriptorDocument::aspectRatio, value); - emit changed(BarDescriptorDocument::autoOrients, QLatin1String("false")); - } else { - emit changed(BarDescriptorDocument::aspectRatio, value); - emit changed(BarDescriptorDocument::autoOrients, QLatin1String("")); - } - } else if (tag == BarDescriptorDocument::arg) { - emit changed(tag, m_ui->applicationArguments->text().split(QLatin1Char(' '))); - } else { - BarDescriptorEditorAbstractPanelWidget::emitChanged(tag); - } -} diff --git a/src/plugins/qnx/bardescriptoreditorgeneralwidget.h b/src/plugins/qnx/bardescriptoreditorgeneralwidget.h deleted file mode 100644 index 18951100187..00000000000 --- a/src/plugins/qnx/bardescriptoreditorgeneralwidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORGENERALWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORGENERALWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorGeneralWidget; } - -class BarDescriptorEditorGeneralWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorGeneralWidget(QWidget *parent = 0); - ~BarDescriptorEditorGeneralWidget(); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - void emitChanged(BarDescriptorDocument::Tag tag); - -private: - Ui::BarDescriptorEditorGeneralWidget *m_ui; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORGENERALWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorgeneralwidget.ui b/src/plugins/qnx/bardescriptoreditorgeneralwidget.ui deleted file mode 100644 index 8a4c3d87876..00000000000 --- a/src/plugins/qnx/bardescriptoreditorgeneralwidget.ui +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorGeneralWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorGeneralWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>373</width> - <height>112</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_12"> - <property name="text"> - <string>Orientation:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="orientation"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_13"> - <property name="text"> - <string>Chrome:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QComboBox" name="chrome"/> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QCheckBox" name="transparentMainWindow"> - <property name="text"> - <string>Transparent main window</string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_14"> - <property name="text"> - <string>Application Arguments:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLineEdit" name="applicationArguments"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.cpp b/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.cpp deleted file mode 100644 index c4bd78a98b4..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorpackageinformationwidget.h" -#include "ui_bardescriptoreditorpackageinformationwidget.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorPackageInformationWidget::BarDescriptorEditorPackageInformationWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorPackageInformationWidget) -{ - m_ui->setupUi(this); - - QRegExp versionNumberRegExp(QLatin1String("(\\d{1,3}\\.)?(\\d{1,3}\\.)?(\\d{1,3})")); - QRegExpValidator *versionNumberValidator = new QRegExpValidator(versionNumberRegExp, this); - m_ui->packageVersion->setValidator(versionNumberValidator); - - addSignalMapping(BarDescriptorDocument::id, m_ui->packageId, SIGNAL(textChanged(QString))); - addSignalMapping(BarDescriptorDocument::versionNumber, m_ui->packageVersion, SIGNAL(textChanged(QString))); - addSignalMapping(BarDescriptorDocument::buildId, m_ui->packageBuildId, SIGNAL(textChanged(QString))); -} - -BarDescriptorEditorPackageInformationWidget::~BarDescriptorEditorPackageInformationWidget() -{ - delete m_ui; -} diff --git a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.h b/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.h deleted file mode 100644 index 373bfef349a..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORPACKAGEINFORMATIONWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORPACKAGEINFORMATIONWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -namespace Qnx { -namespace Internal { - -namespace Ui { class BarDescriptorEditorPackageInformationWidget; } - -class BarDescriptorEditorPackageInformationWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorPackageInformationWidget(QWidget *parent = 0); - ~BarDescriptorEditorPackageInformationWidget(); - -private: - Ui::BarDescriptorEditorPackageInformationWidget *m_ui; -}; - - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORPACKAGEINFORMATIONWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.ui b/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.ui deleted file mode 100644 index dbfe6e85a9f..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpackageinformationwidget.ui +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorPackageInformationWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorPackageInformationWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>372</width> - <height>85</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Package ID:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="packageId"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Package version:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="packageVersion"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Package build ID:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="packageBuildId"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorpermissionswidget.cpp b/src/plugins/qnx/bardescriptoreditorpermissionswidget.cpp deleted file mode 100644 index cd29247b403..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpermissionswidget.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorpermissionswidget.h" -#include "ui_bardescriptoreditorpermissionswidget.h" - -#include "bardescriptorpermissionsmodel.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorPermissionsWidget::BarDescriptorEditorPermissionsWidget(QWidget *parent) : - BarDescriptorEditorAbstractPanelWidget(parent), - m_ui(new Ui::BarDescriptorEditorPermissionsWidget) -{ - m_ui->setupUi(this); - - m_permissionsModel = new BarDescriptorPermissionsModel(this); - m_ui->permissionsView->setModel(m_permissionsModel); - - connect(m_ui->selectAllPermissions, SIGNAL(clicked()), m_permissionsModel, SLOT(checkAll())); - connect(m_ui->deselectAllPermissions, SIGNAL(clicked()), m_permissionsModel, SLOT(uncheckAll())); - - addSignalMapping(BarDescriptorDocument::action, m_permissionsModel, SIGNAL(dataChanged(QModelIndex,QModelIndex))); -} - -BarDescriptorEditorPermissionsWidget::~BarDescriptorEditorPermissionsWidget() -{ - delete m_ui; -} - -QStringList BarDescriptorEditorPermissionsWidget::checkedPermissions() const -{ - return m_permissionsModel->checkedIdentifiers(); -} - -void BarDescriptorEditorPermissionsWidget::checkPermission(const QString &identifier) -{ - blockSignalMapping(BarDescriptorDocument::action); - m_permissionsModel->checkPermission(identifier); - unblockSignalMapping(BarDescriptorDocument::action); -} - -void BarDescriptorEditorPermissionsWidget::updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value) -{ - if (tag != BarDescriptorDocument::action) { - BarDescriptorEditorAbstractPanelWidget::updateWidgetValue(tag, value); - return; - } - - QStringList permissions = value.toStringList(); - Q_FOREACH (const QString &permission, permissions) - checkPermission(permission); -} - -void BarDescriptorEditorPermissionsWidget::emitChanged(BarDescriptorDocument::Tag tag) -{ - if (tag != BarDescriptorDocument::action) { - BarDescriptorEditorAbstractPanelWidget::emitChanged(tag); - return; - } - - emit changed(tag, checkedPermissions()); -} diff --git a/src/plugins/qnx/bardescriptoreditorpermissionswidget.h b/src/plugins/qnx/bardescriptoreditorpermissionswidget.h deleted file mode 100644 index 0ac9d2ce99b..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpermissionswidget.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORPERMISSIONSWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORPERMISSIONSWIDGET_H - -#include "bardescriptoreditorabstractpanelwidget.h" - -namespace Qnx { -namespace Internal { - -class BarDescriptorPermissionsModel; - -namespace Ui { class BarDescriptorEditorPermissionsWidget; } - -class BarDescriptorEditorPermissionsWidget : public BarDescriptorEditorAbstractPanelWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorPermissionsWidget(QWidget *parent = 0); - ~BarDescriptorEditorPermissionsWidget(); - -protected: - void updateWidgetValue(BarDescriptorDocument::Tag tag, const QVariant &value); - void emitChanged(BarDescriptorDocument::Tag tag); - -private: - QStringList checkedPermissions() const; - void checkPermission(const QString &identifier); - - Ui::BarDescriptorEditorPermissionsWidget *m_ui; - - BarDescriptorPermissionsModel *m_permissionsModel; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORPERMISSIONSWIDGET_H diff --git a/src/plugins/qnx/bardescriptoreditorpermissionswidget.ui b/src/plugins/qnx/bardescriptoreditorpermissionswidget.ui deleted file mode 100644 index 0d90505cc08..00000000000 --- a/src/plugins/qnx/bardescriptoreditorpermissionswidget.ui +++ /dev/null @@ -1,62 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BarDescriptorEditorPermissionsWidget</class> - <widget class="QWidget" name="Qnx::Internal::BarDescriptorEditorPermissionsWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>314</width> - <height>171</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QTreeView" name="permissionsView"> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="itemsExpandable"> - <bool>false</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="selectAllPermissions"> - <property name="text"> - <string>Select All</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deselectAllPermissions"> - <property name="text"> - <string>Deselect All</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/bardescriptoreditorwidget.cpp b/src/plugins/qnx/bardescriptoreditorwidget.cpp deleted file mode 100644 index bf8fa3a176d..00000000000 --- a/src/plugins/qnx/bardescriptoreditorwidget.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptoreditorwidget.h" - -#include "qnxconstants.h" -#include "bardescriptoreditor.h" -#include "bardescriptoreditorassetswidget.h" -#include "bardescriptoreditorauthorinformationwidget.h" -#include "bardescriptoreditorentrypointwidget.h" -#include "bardescriptoreditorenvironmentwidget.h" -#include "bardescriptoreditorgeneralwidget.h" -#include "bardescriptoreditorpackageinformationwidget.h" -#include "bardescriptoreditorpermissionswidget.h" - -#include <coreplugin/coreconstants.h> -#include <coreplugin/icore.h> -#include <projectexplorer/panelswidget.h> -#include <projectexplorer/propertiespanel.h> -#include <projectexplorer/task.h> -#include <projectexplorer/taskhub.h> -#include <texteditor/textdocument.h> -#include <texteditor/texteditor.h> -#include <texteditor/texteditorconstants.h> -#include <texteditor/normalindenter.h> -#include <utils/qtcassert.h> - -using namespace TextEditor; -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorEditorWidget::BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent) - : QStackedWidget(parent) - , m_editor(editor) -{ - Core::IContext *myContext = new Core::IContext(this); - myContext->setWidget(this); - myContext->setContext(Core::Context(Constants::QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT, TextEditor::Constants::C_TEXTEDITOR)); - Core::ICore::addContextObject(myContext); - - initGeneralPage(); - initApplicationPage(); - initAssetsPage(); - initSourcePage(); - - setCurrentIndex(0); - - connect(m_entryPointWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_packageInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_authorInformationWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_generalWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_permissionsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_environmentWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(m_assetsWidget, SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), barDescriptorDocument(), SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_entryPointWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_packageInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_authorInformationWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_generalWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_permissionsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_environmentWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - connect(barDescriptorDocument(), SIGNAL(changed(BarDescriptorDocument::Tag,QVariant)), m_assetsWidget, SLOT(setValue(BarDescriptorDocument::Tag,QVariant))); - - connect(m_xmlSourceWidget, SIGNAL(textChanged()), this, SLOT(updateDocumentContent())); - connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView())); -} - -void BarDescriptorEditorWidget::initGeneralPage() -{ - ProjectExplorer::PanelsWidget *generalPanel = new ProjectExplorer::PanelsWidget(this); - initPanelSize(generalPanel); - addWidget(generalPanel); - - // Entry-Point Text and Images - ProjectExplorer::PropertiesPanel *entryPointPanel = new ProjectExplorer::PropertiesPanel; - m_entryPointWidget = new BarDescriptorEditorEntryPointWidget; - entryPointPanel->setDisplayName(tr("Entry-Point Text and Images")); - entryPointPanel->setWidget(m_entryPointWidget); - generalPanel->addPropertiesPanel(entryPointPanel); - - // Package Information - ProjectExplorer::PropertiesPanel *packageInformationPanel = new ProjectExplorer::PropertiesPanel; - m_packageInformationWidget = new BarDescriptorEditorPackageInformationWidget; - packageInformationPanel->setDisplayName(tr("Package Information")); - packageInformationPanel->setWidget(m_packageInformationWidget); - generalPanel->addPropertiesPanel(packageInformationPanel); - - // Author information - ProjectExplorer::PropertiesPanel *authorInformationPanel = new ProjectExplorer::PropertiesPanel; - m_authorInformationWidget = new BarDescriptorEditorAuthorInformationWidget; - authorInformationPanel->setDisplayName(tr("Author Information")); - authorInformationPanel->setWidget(m_authorInformationWidget); - generalPanel->addPropertiesPanel(authorInformationPanel); -} - -void BarDescriptorEditorWidget::initApplicationPage() -{ - ProjectExplorer::PanelsWidget *applicationPanel = new ProjectExplorer::PanelsWidget(this); - initPanelSize(applicationPanel); - addWidget(applicationPanel); - - // General - ProjectExplorer::PropertiesPanel *generalPanel = new ProjectExplorer::PropertiesPanel; - m_generalWidget = new BarDescriptorEditorGeneralWidget; - generalPanel->setDisplayName(tr("General")); - generalPanel->setWidget(m_generalWidget); - applicationPanel->addPropertiesPanel(generalPanel); - - //Permissions - ProjectExplorer::PropertiesPanel *permissionsPanel = new ProjectExplorer::PropertiesPanel; - m_permissionsWidget = new BarDescriptorEditorPermissionsWidget; - permissionsPanel->setDisplayName(tr("Permissions")); - permissionsPanel->setWidget(m_permissionsWidget); - applicationPanel->addPropertiesPanel(permissionsPanel); - - // Environment - ProjectExplorer::PropertiesPanel *environmentPanel = new ProjectExplorer::PropertiesPanel; - m_environmentWidget = new BarDescriptorEditorEnvironmentWidget; - environmentPanel->setDisplayName(tr("Environment")); - environmentPanel->setWidget(m_environmentWidget); - applicationPanel->addPropertiesPanel(environmentPanel); -} - -void BarDescriptorEditorWidget::initAssetsPage() -{ - ProjectExplorer::PanelsWidget *assetsPanel = new ProjectExplorer::PanelsWidget(this); - initPanelSize(assetsPanel); - addWidget(assetsPanel); - - ProjectExplorer::PropertiesPanel *assetsPropertiesPanel = new ProjectExplorer::PropertiesPanel; - m_assetsWidget = new BarDescriptorEditorAssetsWidget; - assetsPropertiesPanel->setDisplayName(tr("Assets")); - assetsPropertiesPanel->setWidget(m_assetsWidget); - assetsPanel->addPropertiesPanel(assetsPropertiesPanel); - - m_entryPointWidget->setAssetsModel(m_assetsWidget->assetsModel()); - connect(m_entryPointWidget, SIGNAL(imageAdded(QString)), m_assetsWidget, SLOT(addAsset(QString))); - connect(m_entryPointWidget, SIGNAL(imageRemoved(QString)), m_assetsWidget, SLOT(removeAsset(QString))); -} - -void BarDescriptorEditorWidget::initSourcePage() -{ - TextDocumentPtr doc(new TextDocument); - doc->setId(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID); // FIXME: This looks odd. - doc->setIndenter(new NormalIndenter); - doc->setMimeType(QLatin1String(Constants::QNX_BAR_DESCRIPTOR_MIME_TYPE)); - - m_xmlSourceWidget = new TextEditorWidget(this); - m_xmlSourceWidget->setTextDocument(doc); - m_xmlSourceWidget->setupGenericHighlighter(); - addWidget(m_xmlSourceWidget); -} - -void BarDescriptorEditorWidget::initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget) -{ - panelsWidget->widget()->setMaximumWidth(900); - panelsWidget->widget()->setMinimumWidth(0); -} - -TextEditorWidget *BarDescriptorEditorWidget::sourceWidget() const -{ - return m_xmlSourceWidget; -} - -void BarDescriptorEditorWidget::setFilePath(const Utils::FileName &filePath) -{ - Core::IDocument *doc = m_xmlSourceWidget->textDocument(); - if (doc) - doc->setFilePath(filePath); -} - -void BarDescriptorEditorWidget::updateDocumentContent() -{ - ProjectExplorer::TaskHub::clearTasks(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR); - QString errorMsg; - int errorLine; - - disconnect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView())); - bool result = barDescriptorDocument()->loadContent(m_xmlSourceWidget->toPlainText(), true, &errorMsg, &errorLine); - connect(barDescriptorDocument(), SIGNAL(changed()), this, SLOT(updateSourceView())); - - if (!result) { - ProjectExplorer::TaskHub::addTask(ProjectExplorer::Task::Error, errorMsg, Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR, - Utils::FileName::fromString(barDescriptorDocument()->filePath().toString()), errorLine); - ProjectExplorer::TaskHub::requestPopup(); - } -} - -void BarDescriptorEditorWidget::updateSourceView() -{ - bool blocked = m_xmlSourceWidget->blockSignals(true); - - int line; - int column; - int position = m_xmlSourceWidget->position(); - m_xmlSourceWidget->convertPosition(position, &line, &column); - - m_xmlSourceWidget->setPlainText(barDescriptorDocument()->xmlSource()); - - m_xmlSourceWidget->gotoLine(line, column); - - m_xmlSourceWidget->blockSignals(blocked); -} - -BarDescriptorDocument *BarDescriptorEditorWidget::barDescriptorDocument() const -{ - return qobject_cast<BarDescriptorDocument*>(m_editor->document()); -} diff --git a/src/plugins/qnx/bardescriptoreditorwidget.h b/src/plugins/qnx/bardescriptoreditorwidget.h deleted file mode 100644 index 82784a01377..00000000000 --- a/src/plugins/qnx/bardescriptoreditorwidget.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTOREDITORWIDGET_H -#define QNX_INTERNAL_BARDESCRIPTOREDITORWIDGET_H - -#include "bardescriptordocument.h" - -#include <QStackedWidget> - -namespace Core { class IEditor; } - -namespace ProjectExplorer { class PanelsWidget; } - -namespace TextEditor { class TextEditorWidget; } - -namespace Qnx { -namespace Internal { - -class BarDescriptorEditor; -class BarDescriptorEditorEntryPointWidget; -class BarDescriptorEditorPackageInformationWidget; -class BarDescriptorEditorAuthorInformationWidget; -class BarDescriptorEditorGeneralWidget; -class BarDescriptorEditorPermissionsWidget; -class BarDescriptorEditorEnvironmentWidget; -class BarDescriptorEditorAssetsWidget; - -class BarDescriptorEditorWidget : public QStackedWidget -{ - Q_OBJECT - -public: - explicit BarDescriptorEditorWidget(BarDescriptorEditor *editor, QWidget *parent = 0); - - TextEditor::TextEditorWidget *sourceWidget() const; - - void setFilePath(const Utils::FileName &filePath); - -signals: - void changed(BarDescriptorDocument::Tag tag, const QVariant &value); - -private slots: - void updateDocumentContent(); - void updateSourceView(); - -private: - BarDescriptorDocument *barDescriptorDocument() const; - - void initGeneralPage(); - void initApplicationPage(); - void initAssetsPage(); - void initSourcePage(); - void initPanelSize(ProjectExplorer::PanelsWidget *panelsWidget); - - Core::IEditor *m_editor; - - // New UI - BarDescriptorEditorEntryPointWidget *m_entryPointWidget; - BarDescriptorEditorPackageInformationWidget *m_packageInformationWidget; - BarDescriptorEditorAuthorInformationWidget *m_authorInformationWidget; - - BarDescriptorEditorGeneralWidget *m_generalWidget; - BarDescriptorEditorPermissionsWidget *m_permissionsWidget; - BarDescriptorEditorEnvironmentWidget *m_environmentWidget; - - BarDescriptorEditorAssetsWidget *m_assetsWidget; - - TextEditor::TextEditorWidget *m_xmlSourceWidget; -}; - - -} // namespace Internal -} // namespace Qnx -#endif // QNX_INTERNAL_BARDESCRIPTOREDITORWIDGET_H diff --git a/src/plugins/qnx/bardescriptorfilenode.cpp b/src/plugins/qnx/bardescriptorfilenode.cpp deleted file mode 100644 index 65a48425fdd..00000000000 --- a/src/plugins/qnx/bardescriptorfilenode.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptorfilenode.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorFileNode::BarDescriptorFileNode(const Utils::FileName &filePath) - : ProjectExplorer::FileNode(filePath, ProjectExplorer::ProjectFileType, false) -{ -} - -QList<ProjectExplorer::ProjectAction> BarDescriptorFileNode::supportedActions(ProjectExplorer::Node *node) const -{ - Q_UNUSED(node) - - // To disable "Remove File..." and "Rename..." context menu actions - return QList<ProjectExplorer::ProjectAction>(); -} diff --git a/src/plugins/qnx/bardescriptorfilenode.h b/src/plugins/qnx/bardescriptorfilenode.h deleted file mode 100644 index 07f5e9b0fda..00000000000 --- a/src/plugins/qnx/bardescriptorfilenode.h +++ /dev/null @@ -1,52 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTORFILENODE_H -#define QNX_INTERNAL_BARDESCRIPTORFILENODE_H - -#include <projectexplorer/projectnodes.h> - -namespace Qnx { -namespace Internal { - -class BarDescriptorFileNode : public ProjectExplorer::FileNode -{ -public: - explicit BarDescriptorFileNode(const Utils::FileName &filePath); - - QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTORFILENODE_H diff --git a/src/plugins/qnx/bardescriptorfilenodemanager.cpp b/src/plugins/qnx/bardescriptorfilenodemanager.cpp deleted file mode 100644 index 0c777c6c457..00000000000 --- a/src/plugins/qnx/bardescriptorfilenodemanager.cpp +++ /dev/null @@ -1,357 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptorfilenodemanager.h" - -#include "bardescriptorfilenode.h" -#include "blackberrydeployconfiguration.h" -#include "blackberrydeployinformation.h" -#include "blackberrycreatepackagestep.h" -#include "blackberryqtversion.h" -#include "bardescriptordocument.h" -#include "qnxconstants.h" - -#include <coreplugin/editormanager/editormanager.h> -#include <coreplugin/icore.h> -#include <coreplugin/messagemanager.h> -#include <projectexplorer/buildstep.h> -#include <projectexplorer/buildsteplist.h> -#include <projectexplorer/project.h> -#include <projectexplorer/projecttree.h> -#include <projectexplorer/session.h> -#include <projectexplorer/target.h> -#include <projectexplorer/buildconfiguration.h> -#include <qmakeprojectmanager/qmakenodes.h> -#include <qtsupport/baseqtversion.h> -#include <qtsupport/qtkitinformation.h> -#include <utils/checkablemessagebox.h> -#include <utils/qtcassert.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char SKIP_BAR_DESCRIPTOR_CREATION_KEY[] = "Qnx.BlackBerry.BarDescriptorFileNodeManager.SkipCreation"; -} - -BarDescriptorFileNodeManager::BarDescriptorFileNodeManager(QObject *parent) - : QObject(parent) -{ - connect(ProjectExplorer::ProjectTree::instance(), &ProjectExplorer::ProjectTree::currentProjectChanged, - this, &BarDescriptorFileNodeManager::setCurrentProject); - connect(ProjectExplorer::SessionManager::instance(), &ProjectExplorer::SessionManager::startupProjectChanged, - this, &BarDescriptorFileNodeManager::setCurrentProject); -} - -void BarDescriptorFileNodeManager::setCurrentProject(ProjectExplorer::Project *project) -{ - if (!project) - return; - - connect(project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), - this, SLOT(updateBarDescriptorNodes(ProjectExplorer::Target*)), Qt::UniqueConnection); - - updateBarDescriptorNodes(project->activeTarget()); -} - -void BarDescriptorFileNodeManager::updateBarDescriptorNodes(ProjectExplorer::Target *target) -{ - if (!target) - return; - - // We are not consistently getting a signal when the current project changes, - // so instead use target->project() to get access to the current project - - if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(target->kit()) != Constants::QNX_BB_OS_TYPE) { - removeBarDescriptorNodes(target->project()); - return; - } - - updateBarDescriptorNodes(target->project(), true); - - QList<ProjectExplorer::DeployConfiguration*> deployConfigurations = target->deployConfigurations(); - foreach (ProjectExplorer::DeployConfiguration *deployConfiguration, deployConfigurations) { - BlackBerryDeployConfiguration *bbdc = qobject_cast<BlackBerryDeployConfiguration*>(deployConfiguration); - if (!bbdc) - continue; - - connect(bbdc->deploymentInfo(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), - this, SLOT(handleDeploymentDataChanged()), Qt::UniqueConnection); - connect(bbdc->deploymentInfo(), SIGNAL(modelReset()), - this, SLOT(handleDeploymentModelReset()), Qt::UniqueConnection); - } -} - -void BarDescriptorFileNodeManager::handleDeploymentDataChanged() -{ - handleDeploymentInfoChanged(false); -} - -void BarDescriptorFileNodeManager::handleDeploymentModelReset() -{ - handleDeploymentInfoChanged(true); -} - -void BarDescriptorFileNodeManager::handleDeploymentInfoChanged(bool modelReset) -{ - BlackBerryDeployInformation *deployInfo = qobject_cast<BlackBerryDeployInformation*>(sender()); - QTC_ASSERT(deployInfo, return); - - updateBarDescriptorNodes(deployInfo->target()->project(), modelReset); -} - -void BarDescriptorFileNodeManager::updateBarDescriptorNodes(ProjectExplorer::Project *project, bool attemptCreate) -{ - if (!project) - return; - - ProjectExplorer::ProjectNode *rootProject = project->rootProjectNode(); - if (!rootProject) - return; - - BlackBerryDeployConfiguration *dc = - qobject_cast<BlackBerryDeployConfiguration*>(project->activeTarget()->activeDeployConfiguration()); - if (!dc) - return; - - QList<BarPackageDeployInformation> packages = dc->deploymentInfo()->allPackages(); - foreach (const BarPackageDeployInformation &package, packages) { - ProjectExplorer::ProjectNode *projectNode = rootProject->path() == package.proFilePath ? - rootProject : findProjectNode(rootProject, package.proFilePath); - if (!projectNode) - continue; - - if (!package.appDescriptorPath().exists()) { - if (!attemptCreate) - continue; - - if (!createBarDescriptor(project, package.appDescriptorPath(), projectNode)) - continue; - } else { - // Update the Qt environment if not matching the one in the deployment settings - updateBarDescriptor(package.appDescriptorPath(), project->activeTarget()); - } - - BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(projectNode); - if (existingNode) { - if (existingNode->path() != package.appDescriptorPath()) { - // Reload the new bar-descriptor document in the existing editor (if there is one) - Core::IDocument *oldDocument = Core::DocumentModel::documentForFilePath( - existingNode->path().toString()); - if (oldDocument) { - QString errorMessage; - - if (!oldDocument->save(&errorMessage)) { - Core::MessageManager::write(tr("Cannot save bar descriptor file: %1").arg(errorMessage)); - continue; - } else { - oldDocument->setFilePath(package.appDescriptorPath()); - - if (!oldDocument->reload(&errorMessage, Core::IDocument::FlagReload, Core::IDocument::TypeContents)) - Core::MessageManager::write(tr("Cannot reload bar descriptor file: %1").arg(errorMessage)); - } - } - - existingNode->setPath(package.appDescriptorPath()); - } - } else { - BarDescriptorFileNode *fileNode = new BarDescriptorFileNode(package.appDescriptorPath()); - projectNode->addFileNodes(QList<ProjectExplorer::FileNode*>() << fileNode); - } - } -} - -bool BarDescriptorFileNodeManager::createBarDescriptor(ProjectExplorer::Project *project, - const Utils::FileName &barDescriptorPath, - ProjectExplorer::ProjectNode *projectNode) -{ - const QString projectName = projectNode->path().toFileInfo().completeBaseName(); - - QmakeProjectManager::QmakeProFileNode *proFileNode = - dynamic_cast<QmakeProjectManager::QmakeProFileNode*>(projectNode); - QTC_ASSERT(proFileNode, return false); - const QString targetName = proFileNode->targetInformation().target; - - const QFile barDescriptorFile(barDescriptorPath.toString()); - if (barDescriptorFile.exists()) - return false; - - bool skipFileCreation = project->namedSettings(QLatin1String(SKIP_BAR_DESCRIPTOR_CREATION_KEY)).toBool(); - - if (skipFileCreation) - return false; - - QDialogButtonBox::StandardButton button = Utils::CheckableMessageBox::question(Core::ICore::mainWindow(), - tr("Setup Application Descriptor File"), - tr("You need to set up a bar descriptor file to enable " - "packaging.\nDo you want Qt Creator to generate it for your project (%1)?") - .arg(project->projectFilePath().toUserOutput()), - tr("Don't ask again for this project"), &skipFileCreation); - - if (button != QDialogButtonBox::Yes) { - project->setNamedSettings(QLatin1String(SKIP_BAR_DESCRIPTOR_CREATION_KEY), skipFileCreation); - return false; - } - - QString barDescriptorTemplate; - QtSupport::QtVersionNumber qtVersion = - QtSupport::QtKitInformation::qtVersion(project->activeTarget()->kit())->qtVersion(); - if (qtVersion >= QtSupport::QtVersionNumber(5, 0, 0)) - barDescriptorTemplate = Core::ICore::resourcePath() - + QLatin1String("/templates/wizards/bb-qt5-bardescriptor/bar-descriptor.xml"); - else - barDescriptorTemplate = Core::ICore::resourcePath() - + QLatin1String("/templates/wizards/bb-bardescriptor/bar-descriptor.xml"); - - Utils::FileReader reader; - if (!reader.fetch(barDescriptorTemplate)) { - Core::MessageManager::write(tr("Cannot set up application descriptor file: " - "Reading the bar descriptor template failed.")); - return false; - } - - QString content = QString::fromUtf8(reader.data()); - content.replace(QLatin1String("PROJECTNAME"), projectName); - content.replace(QLatin1String("TARGETNAME"), targetName); - content.replace(QLatin1String("ID"), QLatin1String("com.example.") + projectName); - - if (project->projectDirectory().appendPath(QLatin1String("qml")).exists()) - content.replace(QLatin1String("</qnx>"), - QLatin1String(" <asset path=\"qml\">qml</asset>\n</qnx>")); - - Utils::FileSaver writer(barDescriptorFile.fileName(), QIODevice::WriteOnly); - writer.write(content.toUtf8()); - if (!writer.finalize()) { - Core::MessageManager::write(tr("Cannot set up application descriptor file: " - "Writing the bar descriptor file failed.")); - return false; - } - - // Check if the Qt environment matches the Qt bundle mode in the deployment step - updateBarDescriptor(barDescriptorPath, project->activeTarget(), true); - - return true; -} - -void BarDescriptorFileNodeManager::updateBarDescriptor(const Utils::FileName &barDescriptorPath, - ProjectExplorer::Target *target, - bool skipConfirmation) -{ - BarDescriptorDocument doc; - QString errorString; - if (!doc.open(&errorString, barDescriptorPath.toString())) { - QMessageBox::warning(Core::ICore::mainWindow(), tr("Error"), - tr("Cannot open BAR application descriptor file")); - return; - } - - QList<Utils::EnvironmentItem> envItems = - doc.value(BarDescriptorDocument::env).value<QList<Utils::EnvironmentItem> >(); - - BlackBerryQtVersion *qtVersion = - dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(target->kit())); - if (!qtVersion) - return; - - ProjectExplorer::BuildStepList *stepList = target->activeDeployConfiguration()->stepList(); - foreach (ProjectExplorer::BuildStep *step, stepList->steps()) { - BlackBerryCreatePackageStep *createPackageStep = dynamic_cast<BlackBerryCreatePackageStep *>(step); - if (createPackageStep) { - createPackageStep->doUpdateAppDescriptorFile(barDescriptorPath, - BlackBerryCreatePackageStep::QtEnvironment, - skipConfirmation); - } - } -} - -void BarDescriptorFileNodeManager::removeBarDescriptorNodes(ProjectExplorer::Project *project) -{ - if (!project) - return; - - ProjectExplorer::ProjectNode *rootProject = project->rootProjectNode(); - if (!rootProject) - return; - - BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(rootProject); - if (existingNode) - rootProject->removeFileNodes(QList<ProjectExplorer::FileNode*>() << existingNode); - - // Also remove the bar descriptor nodes for sub-projects - removeBarDescriptorNodes(rootProject); -} - -void BarDescriptorFileNodeManager::removeBarDescriptorNodes(ProjectExplorer::ProjectNode *parent) -{ - QList<ProjectExplorer::ProjectNode*> projectNodes = parent->subProjectNodes(); - foreach (ProjectExplorer::ProjectNode *projectNode, projectNodes) { - BarDescriptorFileNode *existingNode = findBarDescriptorFileNode(projectNode); - if (existingNode) - projectNode->removeFileNodes(QList<ProjectExplorer::FileNode*>() << existingNode); - - removeBarDescriptorNodes(projectNode); - } -} - -BarDescriptorFileNode *BarDescriptorFileNodeManager::findBarDescriptorFileNode(ProjectExplorer::ProjectNode *parent) const -{ - QTC_ASSERT(parent, return 0); - - QList<ProjectExplorer::FileNode*> fileNodes = parent->fileNodes(); - foreach (ProjectExplorer::FileNode *fileNode, fileNodes) { - BarDescriptorFileNode *barDescriptorNode = dynamic_cast<BarDescriptorFileNode*>(fileNode); - if (barDescriptorNode) - return barDescriptorNode; - } - - return 0; -} - -ProjectExplorer::ProjectNode *BarDescriptorFileNodeManager::findProjectNode( - ProjectExplorer::ProjectNode *parent, - const Utils::FileName &projectFilePath) const -{ - QTC_ASSERT(parent, return 0); - - QList<ProjectExplorer::ProjectNode*> projectNodes = parent->subProjectNodes(); - foreach (ProjectExplorer::ProjectNode *projectNode, projectNodes) { - if (projectNode->path() == projectFilePath) { - return projectNode; - } else if (!projectNode->subProjectNodes().isEmpty()) { - ProjectExplorer::ProjectNode *hit = findProjectNode(projectNode, projectFilePath); - if (hit) - return hit; - } - } - - return 0; -} diff --git a/src/plugins/qnx/bardescriptorfilenodemanager.h b/src/plugins/qnx/bardescriptorfilenodemanager.h deleted file mode 100644 index b47fa3f8a51..00000000000 --- a/src/plugins/qnx/bardescriptorfilenodemanager.h +++ /dev/null @@ -1,86 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H -#define QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H - -#include <QObject> - -namespace Utils { -class FileName; -} - -namespace ProjectExplorer { -class DeployConfiguration; -class Project; -class ProjectNode; -class Target; -} - -namespace Qnx { -namespace Internal { - -class BarDescriptorFileNode; - -class BarDescriptorFileNodeManager : public QObject -{ - Q_OBJECT -public: - explicit BarDescriptorFileNodeManager(QObject *parent = 0); - -private slots: - void setCurrentProject(ProjectExplorer::Project *project); - void updateBarDescriptorNodes(ProjectExplorer::Target *target); - void handleDeploymentInfoChanged(bool modelReset); - - void handleDeploymentDataChanged(); - void handleDeploymentModelReset(); - -private: - BarDescriptorFileNode *findBarDescriptorFileNode(ProjectExplorer::ProjectNode *parent) const; - ProjectExplorer::ProjectNode *findProjectNode(ProjectExplorer::ProjectNode *parent, - const Utils::FileName &projectFilePath) const; - - void updateBarDescriptorNodes(ProjectExplorer::Project *project, bool attemptCreate); - bool createBarDescriptor(ProjectExplorer::Project *project, const Utils::FileName &barDescriptorPath, - ProjectExplorer::ProjectNode *projectNode); - void updateBarDescriptor(const Utils::FileName &barDescriptorPath, ProjectExplorer::Target *target, - bool skipConfirmation = false); - - void removeBarDescriptorNodes(ProjectExplorer::Project *project); - void removeBarDescriptorNodes(ProjectExplorer::ProjectNode *parent); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTORFILENODEMANAGER_H diff --git a/src/plugins/qnx/bardescriptorpermissionsmodel.cpp b/src/plugins/qnx/bardescriptorpermissionsmodel.cpp deleted file mode 100644 index a7d8656f6f6..00000000000 --- a/src/plugins/qnx/bardescriptorpermissionsmodel.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptorpermissionsmodel.h" - -#include <QStringList> - -using namespace Qnx; -using namespace Qnx::Internal; - -BarDescriptorPermissionsModel::BarDescriptorPermissionsModel(QObject *parent) : - QAbstractTableModel(parent) -{ - initModel(); -} - -Qt::ItemFlags BarDescriptorPermissionsModel::flags(const QModelIndex &index) const -{ - Qt::ItemFlags flags = QAbstractTableModel::flags(index); - flags |= Qt::ItemIsUserCheckable; - return flags; -} - -int BarDescriptorPermissionsModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return m_permissions.size(); -} - -int BarDescriptorPermissionsModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return 1; -} - -QVariant BarDescriptorPermissionsModel::data(const QModelIndex &index, int role) const -{ - if (!index.isValid() || index.row() >= m_permissions.size() || index.column() >= 1) - return QVariant(); - - BarDescriptorPermission perm = m_permissions[index.row()]; - switch (role) { - case Qt::DisplayRole: - case Qt::EditRole: - return perm.permission; - case Qt::CheckStateRole: - return perm.checked ? Qt::Checked : Qt::Unchecked; - case Qt::ToolTipRole: - return perm.description; - case IdentifierRole: - return perm.identifier; - } - - return QVariant(); -} - -bool BarDescriptorPermissionsModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (!index.isValid() || index.row() >= m_permissions.size() || index.column() >= 1) - return false; - - if (role == Qt::CheckStateRole) { - BarDescriptorPermission &perm = m_permissions[index.row()]; - perm.checked = static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked; - emit dataChanged(index, index); - - return true; - } - - return false; -} - -QVariant BarDescriptorPermissionsModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole || orientation == Qt::Vertical) - return QVariant(); - - if (section == 0) - return tr("Permission"); - - return QVariant(); -} - -void BarDescriptorPermissionsModel::uncheckAll() -{ - setCheckStateAll(Qt::Unchecked); -} - -void BarDescriptorPermissionsModel::checkAll() -{ - setCheckStateAll(Qt::Checked); -} - -void BarDescriptorPermissionsModel::checkPermission(const QString &identifier) -{ - for (int i = 0; i < rowCount(); ++i) { - QModelIndex idx = index(i, 0); - if (data(idx, IdentifierRole).toString() == identifier) - setData(idx, Qt::Checked, Qt::CheckStateRole); - } -} - -QStringList BarDescriptorPermissionsModel::checkedIdentifiers() const -{ - QStringList result; - foreach (const BarDescriptorPermission &perm, m_permissions) { - if (perm.checked) - result << perm.identifier; - } - return result; -} - -void BarDescriptorPermissionsModel::initModel() -{ - beginResetModel(); - m_permissions << BarDescriptorPermission(tr("BlackBerry Messenger"), QLatin1String("bbm_connect"), - tr("<html><head/><body><p>Allows this app to connect to the BBM Social Platform to access BBM " - "contact lists and user profiles, invite BBM contacts to download your " - "app, initiate BBM chats and share content from within your app, or " - "stream data between apps in real time.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Calendar"), QLatin1String("access_pimdomain_calendars"), - tr("<html><head/><body><p>Allows this app to access the calendar on the device. This access " - "includes viewing, adding, and deleting calendar appointments.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Camera"), QLatin1String("use_camera"), - tr("<html><head/><body><p>Allows this app to take pictures, record video, and use the flash.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Contacts"), QLatin1String("access_pimdomain_contacts"), - tr("<html><head/><body><p>Allows this app to access the contacts stored on the device. This " - "access includes viewing, creating, and deleting the contacts.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Device Identifying Information"), QLatin1String("read_device_identifying_information"), - tr("<html><head/><body><p>Allows this app to access device identifiers such as serial number and PIN.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Email and PIN Messages"), QLatin1String("access_pimdomain_messages"), - tr("<html><head/><body><p>Allows this app to access the email and PIN messages stored on the " - "device. This access includes viewing, creating, sending, and deleting the messages.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("GPS Location"), QLatin1String("read_geolocation"), - tr("<html><head/><body><p>Allows this app to access the current GPS location of the device.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Internet"), QLatin1String("access_internet"), - tr("<html><head/><body><p>Allows this app to use Wi-fi, wired, or other connections to a " - "destination that is not local on the user's device.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Location"), QLatin1String("access_location_services"), - tr("<html><head/><body><p>Allows this app to access the device's current or saved locations.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Microphone"), QLatin1String("record_audio"), - tr("<html><head/><body><p>Allows this app to record sound using the microphone.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Notebooks"), QLatin1String("access_pimdomain_notebooks"), - tr("<html><head/><body><p>Allows this app to access the content stored in the notebooks on the " - "device. This access includes adding and deleting entries and content.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Post Notifications"), QLatin1String("post_notification"), - tr("<html><head/><body><p>Post a notification to the notifications area of the screen.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Push"), QLatin1String("_sys_use_consumer_push"), - tr("<html><head/><body><p>Allows this app to use the Push Service with the BlackBerry Internet " - "Service. This access allows the app to receive and request push " - "messages. To use the Push Service with the BlackBerry Internet Service, " - "you must register with BlackBerry. When you register, you " - "receive a confirmation email message that contains information that " - "your application needs to receive and request push messages. For more " - "information about registering, visit " - "https://developer.blackberry.com/services/push/. If you're using the " - "Push Service with the BlackBerry Enterprise Server or the BlackBerry " - "Device Service, you don't need to register with BlackBerry.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Run When Backgrounded"), QLatin1String("run_when_backgrounded"), - tr("<html><head/><body><p>Allows background processing. Without this permission, the app is " - "stopped when the user switches focus to another app. Apps that use this " - "permission are rigorously reviewed for acceptance to BlackBerry App " - "World storefront for their use of power.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Shared Files"), QLatin1String("access_shared"), - tr("<html><head/><body><p>Allows this app to access pictures, music, documents, and other files " - "stored on the user's device, at a remote storage provider, on a media " - "card, or in the cloud.</p></body></html>")); - m_permissions << BarDescriptorPermission(tr("Text Messages"), QLatin1String("access_sms_mms"), - tr("<html><head/><body><p>Allows this app to access the text messages stored on the device. The " - "access includes viewing, creating, sending, and deleting text messages.</p></body></html>")); - endResetModel(); -} - - -void BarDescriptorPermissionsModel::setCheckStateAll(Qt::CheckState checkState) -{ - for (int i = 0; i < rowCount(); ++i) - setData(index(i, 0), checkState, Qt::CheckStateRole); -} diff --git a/src/plugins/qnx/bardescriptorpermissionsmodel.h b/src/plugins/qnx/bardescriptorpermissionsmodel.h deleted file mode 100644 index fba201ef7f4..00000000000 --- a/src/plugins/qnx/bardescriptorpermissionsmodel.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BARDESCRIPTORPERMISSIONSMODEL_H -#define QNX_INTERNAL_BARDESCRIPTORPERMISSIONSMODEL_H - -#include <QAbstractTableModel> - -namespace Qnx { -namespace Internal { - -class BarDescriptorPermission { -public: - BarDescriptorPermission(const QString &perm, const QString &ident, const QString &desc) - : checked(false) - , permission(perm) - , identifier(ident) - , description(desc) - { - } - - bool checked; - QString permission; - QString identifier; - QString description; -}; - -class BarDescriptorPermissionsModel : public QAbstractTableModel -{ - Q_OBJECT -public: - explicit BarDescriptorPermissionsModel(QObject *parent = 0); - - Qt::ItemFlags flags(const QModelIndex &index) const; - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - - void checkPermission(const QString &identifier); - QStringList checkedIdentifiers() const; - -public slots: - void uncheckAll(); - void checkAll(); - -private: - enum DataRole { - IdentifierRole = Qt::UserRole - }; - - void setCheckStateAll(Qt::CheckState checkState); - - void initModel(); - - QList<BarDescriptorPermission> m_permissions; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BARDESCRIPTORPERMISSIONSMODEL_H diff --git a/src/plugins/qnx/blackberryabstractdeploystep.cpp b/src/plugins/qnx/blackberryabstractdeploystep.cpp deleted file mode 100644 index c572a09b0b9..00000000000 --- a/src/plugins/qnx/blackberryabstractdeploystep.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryabstractdeploystep.h" - -#include <projectexplorer/buildconfiguration.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> -#include <projectexplorer/task.h> -#include <utils/qtcassert.h> -#include <utils/qtcprocess.h> - -#include <QDir> -#include <QTimer> -#include <QEventLoop> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, Core::Id id) - : ProjectExplorer::BuildStep(bsl, id) - , m_processCounter(-1) - , m_process(0) - , m_timer(0) - , m_futureInterface(0) - , m_eventLoop(0) -{ - connect(&m_outputParser, SIGNAL(addTask(ProjectExplorer::Task)), this, SIGNAL(addTask(ProjectExplorer::Task))); - connect(&m_outputParser, SIGNAL(progressParsed(int)), this, SLOT(reportProgress(int))); -} - -BlackBerryAbstractDeployStep::BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs) - : ProjectExplorer::BuildStep(bsl, bs) - , m_processCounter(-1) - , m_process(0) - , m_timer(0) - , m_futureInterface(0) - , m_eventLoop(0) -{ - connect(&m_outputParser, SIGNAL(addTask(ProjectExplorer::Task)), this, SIGNAL(addTask(ProjectExplorer::Task))); - connect(&m_outputParser, SIGNAL(progressParsed(int)), this, SLOT(reportProgress(int))); -} - -BlackBerryAbstractDeployStep::~BlackBerryAbstractDeployStep() -{ - delete m_process; - m_process = 0; -} - -bool BlackBerryAbstractDeployStep::init() -{ - m_params.clear(); - m_processCounter = -1; - - m_environment = target()->activeBuildConfiguration()->environment(); - m_buildDirectory = target()->activeBuildConfiguration()->buildDirectory().toString(); - // The bar descriptor is using BUILD_DIR variable to set the target path - m_environment.appendOrSet(QLatin1String("BUILD_DIR"), m_buildDirectory); - - return true; -} - -void BlackBerryAbstractDeployStep::run(QFutureInterface<bool> &fi) -{ - m_timer = new QTimer(); - connect(m_timer, SIGNAL(timeout()), this, SLOT(checkForCancel()), Qt::DirectConnection); - m_timer->start(500); - m_eventLoop = new QEventLoop; - - fi.setProgressRange(0, 100 * m_params.size()); - - Q_ASSERT(!m_futureInterface); - m_futureInterface = &fi; - - runCommands(); - - bool returnValue = m_eventLoop->exec(); - - // Finished - m_params.clear(); - m_processCounter = -1; - - m_timer->stop(); - delete m_timer; - m_timer = 0; - - delete m_process; - m_process = 0; - delete m_eventLoop; - m_eventLoop = 0; - - m_futureInterface = 0; - - fi.reportResult(returnValue); -} - -void BlackBerryAbstractDeployStep::addCommand(const QString &command, const QStringList &arguments) -{ - ProjectExplorer::ProcessParameters param; - param.setCommand(command); - param.setArguments(arguments.join(QLatin1Char(' '))); - m_params << param; -} - -void BlackBerryAbstractDeployStep::reportProgress(int progress) -{ - QTC_ASSERT(progress >= 0 && progress <= 100, return); - - if (m_futureInterface) - m_futureInterface->setProgressValue(100 * m_processCounter + progress); -} - -void BlackBerryAbstractDeployStep::runCommands() -{ - if (!m_process) { - m_process = new Utils::QtcProcess(); - connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(processReadyReadStdOutput()), Qt::DirectConnection); - connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(processReadyReadStdError()), Qt::DirectConnection); - } - - m_process->setEnvironment(m_environment); - m_process->setWorkingDirectory(m_buildDirectory); - - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(handleProcessFinished(int,QProcess::ExitStatus)), Qt::DirectConnection); - - runNextCommand(); -} - -void BlackBerryAbstractDeployStep::runNextCommand() -{ - ++m_processCounter; - m_futureInterface->setProgressValue(100 * m_processCounter); - - ProjectExplorer::ProcessParameters param = m_params.takeFirst(); - - QTC_ASSERT(m_process->state() == QProcess::NotRunning, return); - - m_process->setCommand(param.effectiveCommand(), param.effectiveArguments()); - m_process->start(); - if (!m_process->waitForStarted()) { - m_eventLoop->exit(false); - return; - } - processStarted(param); -} - -void BlackBerryAbstractDeployStep::processStarted(const ProjectExplorer::ProcessParameters ¶ms) -{ - emitOutputInfo(params, params.prettyArguments()); -} - -void BlackBerryAbstractDeployStep::emitOutputInfo(const ProjectExplorer::ProcessParameters ¶ms, const QString &arguments) -{ - emit addOutput(tr("Starting: \"%1\" %2") - .arg(QDir::toNativeSeparators(params.effectiveCommand()), - arguments), - BuildStep::MessageOutput); -} - -void BlackBerryAbstractDeployStep::raiseError(const QString &errorMessage) -{ - emit addOutput(errorMessage, BuildStep::ErrorMessageOutput); - emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, Utils::FileName(), -1, - ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); -} - -void BlackBerryAbstractDeployStep::processReadyReadStdOutput() -{ - m_process->setReadChannel(QProcess::StandardOutput); - while (m_process->canReadLine()) { - const QString line = QString::fromLocal8Bit(m_process->readLine()); - stdOutput(line); - } -} - -void BlackBerryAbstractDeployStep::stdOutput(const QString &line) -{ - m_outputParser.stdOutput(line); - emit addOutput(line, BuildStep::NormalOutput, BuildStep::DontAppendNewline); -} - -void BlackBerryAbstractDeployStep::processReadyReadStdError() -{ - m_process->setReadChannel(QProcess::StandardError); - while (m_process->canReadLine()) { - const QString line = QString::fromLocal8Bit(m_process->readLine()); - stdError(line); - } -} - -void BlackBerryAbstractDeployStep::checkForCancel() -{ - if (m_futureInterface->isCanceled() - && m_timer && m_timer->isActive()) { - m_timer->stop(); - if (m_process) { - m_process->terminate(); - m_process->waitForFinished(5000); //while waiting, the process can be killed - if (m_process) - m_process->kill(); - } - if (m_eventLoop) - m_eventLoop->exit(false); - } -} - -void BlackBerryAbstractDeployStep::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - if (exitCode == 0 && exitStatus == QProcess::NormalExit) { - if (!m_params.isEmpty()) - runNextCommand(); - else - m_eventLoop->exit(true); - } else { - m_eventLoop->exit(false); - } -} - -void BlackBerryAbstractDeployStep::stdError(const QString &line) -{ - m_outputParser.stdError(line); - emit addOutput(line, BuildStep::ErrorOutput, BuildStep::DontAppendNewline); -} diff --git a/src/plugins/qnx/blackberryabstractdeploystep.h b/src/plugins/qnx/blackberryabstractdeploystep.h deleted file mode 100644 index 60cdd08de82..00000000000 --- a/src/plugins/qnx/blackberryabstractdeploystep.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H -#define QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H - -#include "blackberryprocessparser.h" - -#include <projectexplorer/buildstep.h> -#include <projectexplorer/processparameters.h> - -#include <QProcess> - -QT_BEGIN_NAMESPACE -class QEventLoop; -QT_END_NAMESPACE - -namespace Utils { class QtcProcess; } - -namespace Qnx { -namespace Internal { - -class BlackBerryAbstractDeployStep : public ProjectExplorer::BuildStep -{ - Q_OBJECT -public: - explicit BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); - ~BlackBerryAbstractDeployStep(); - - bool init(); - void run(QFutureInterface<bool> &fi); - -protected: - BlackBerryAbstractDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryAbstractDeployStep *bs); - - void addCommand(const QString &command, const QStringList &arguments); - - virtual void stdOutput(const QString &line); - virtual void stdError(const QString &line); - - virtual void processStarted(const ProjectExplorer::ProcessParameters ¶m); - - void emitOutputInfo(const ProjectExplorer::ProcessParameters ¶ms, const QString& arguments); - - void raiseError(const QString &errorMessage); - -private slots: - void reportProgress(int progress); - - void processReadyReadStdOutput(); - void processReadyReadStdError(); - - void checkForCancel(); - - void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - -private: - void ctor(); - - void runCommands(); - void runNextCommand(); - - QList<ProjectExplorer::ProcessParameters> m_params; - int m_processCounter; - Utils::QtcProcess *m_process; - - Utils::Environment m_environment; - QString m_buildDirectory; - - QTimer *m_timer; - QFutureInterface<bool> *m_futureInterface; - QEventLoop *m_eventLoop; - - BlackBerryProcessParser m_outputParser; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYABSTRACTDEPLOYSTEP_H diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.cpp b/src/plugins/qnx/blackberryapilevelconfiguration.cpp deleted file mode 100644 index d96a66dd6a3..00000000000 --- a/src/plugins/qnx/blackberryapilevelconfiguration.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryapilevelconfiguration.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryqtversion.h" - -#include "qnxtoolchain.h" -#include "qnxconstants.h" - -#include <utils/qtcassert.h> - -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/kitmanager.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/toolchainmanager.h> -#include <projectexplorer/gcctoolchain.h> - -#include <qtsupport/baseqtversion.h> -#include <qtsupport/qtversionmanager.h> -#include <qtsupport/qtkitinformation.h> - -#include <qmakeprojectmanager/qmakekitinformation.h> - -#include <debugger/debuggeritemmanager.h> -#include <debugger/debuggeritem.h> -#include <debugger/debuggerkitinformation.h> - -#include <coreplugin/icore.h> - -#include <QFileInfo> -#include <QDir> -#include <QMessageBox> - -using namespace ProjectExplorer; -using namespace QtSupport; -using namespace Utils; -using namespace Debugger; - -namespace Qnx { -namespace Internal { - -const QLatin1String NDKPathKey("NDKPath"); -const QLatin1String NDKDisplayNameKey("NDKDisplayName"); -const QLatin1String NDKTargetKey("NDKTarget"); -const QLatin1String NDKHostKey("NDKHost"); -const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource"); -const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey"); - -#ifdef WITH_TESTS -bool BlackBerryApiLevelConfiguration::m_fakeConfig = false; -#endif - -BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const ConfigInstallInformation &ndkInstallInfo) - : QnxBaseConfiguration(FileName::fromString( - QnxUtils::envFilePath(ndkInstallInfo.path, ndkInstallInfo.version))) -{ - m_displayName = ndkInstallInfo.name; - QString sep = QString::fromLatin1("/qnx6"); - // The QNX_TARGET value is using Unix-like separator on all platforms. - m_targetName = ndkInstallInfo.target.split(sep).first().split(QLatin1Char('/')).last(); - m_sysRoot = FileName::fromString(ndkInstallInfo.target); - m_autoDetectionSource = FileName::fromString(ndkInstallInfo.installationXmlFilePath); - setVersion(QnxVersionNumber(ndkInstallInfo.version)); - ctor(); -} - -BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const FileName &ndkEnvFile) - : QnxBaseConfiguration(ndkEnvFile) -{ - m_displayName = ndkPath().split(QDir::separator()).last(); - QString ndkTarget = qnxTarget().toString(); - // The QNX_TARGET value is using Unix-like separator on all platforms. - QString sep = QString::fromLatin1("/qnx6"); - m_targetName = ndkTarget.split(sep).first().split(QLatin1Char('/')).last(); - if (QDir(ndkTarget).exists()) - m_sysRoot = FileName::fromString(ndkTarget); - - setVersion(QnxVersionNumber::fromNdkEnvFileName(QFileInfo(envFile().toString()).baseName())); - if (version().isEmpty()) - setVersion(QnxVersionNumber::fromTargetName(m_targetName)); - - ctor(); -} - -BlackBerryApiLevelConfiguration::BlackBerryApiLevelConfiguration(const QVariantMap &data) - : QnxBaseConfiguration(data) -{ - m_displayName = data.value(NDKDisplayNameKey).toString(); - QString sep = QString::fromLatin1("/qnx6"); - // The QNX_TARGET value is using Unix-like separator on all platforms. - m_targetName = data.value(NDKTargetKey).toString().split(sep).first().split(QLatin1Char('/')).last(); - m_sysRoot = FileName::fromString(data.value(NDKTargetKey).toString()); - if (data.value(QLatin1String(NDKAutoDetectedKey)).toBool()) - m_autoDetectionSource = FileName::fromString(data.value(NDKAutoDetectionSourceKey).toString()); - - ctor(); -} - -void BlackBerryApiLevelConfiguration::ctor() -{ - QString host = qnxHost().toString(); - FileName qmake4Path = FileName::fromString(HostOsInfo::withExecutableSuffix(host + QLatin1String("/usr/bin/qmake"))); - FileName qmake5Path = FileName::fromString(HostOsInfo::withExecutableSuffix(host + QLatin1String("/usr/bin/qt5/qmake"))); - if (qmake4Path.exists()) - m_qmake4BinaryFile = qmake4Path; - - if (qmake5Path.exists()) - m_qmake5BinaryFile = qmake5Path; -} - -QString BlackBerryApiLevelConfiguration::ndkPath() const -{ - return envFile().parentDir().toString(); -} - -QString BlackBerryApiLevelConfiguration::displayName() const -{ - return m_displayName; -} - -QString BlackBerryApiLevelConfiguration::targetName() const -{ - return m_targetName; -} - -bool BlackBerryApiLevelConfiguration::isAutoDetected() const -{ - return !m_autoDetectionSource.isEmpty(); -} - -FileName BlackBerryApiLevelConfiguration::autoDetectionSource() const -{ - return m_autoDetectionSource; -} - -bool BlackBerryApiLevelConfiguration::isActive() const -{ - foreach (Kit *kit, KitManager::kits()) { - if (kit->isAutoDetected() && - kit->autoDetectionSource() == envFile().toString()) - return true; - } - - return false; -} - -bool BlackBerryApiLevelConfiguration::isValid() const -{ -#ifdef WITH_TESTS - if (BlackBerryApiLevelConfiguration::fakeConfig()) - return true; -#endif - - return QnxBaseConfiguration::isValid() && - ((!m_qmake4BinaryFile.isEmpty() || !m_qmake5BinaryFile.isEmpty()) - && (m_autoDetectionSource.isEmpty() || - m_autoDetectionSource.exists()) - && (!m_sysRoot.isEmpty() && m_sysRoot.exists())); -} - - -FileName BlackBerryApiLevelConfiguration::qmake4BinaryFile() const -{ - return m_qmake4BinaryFile; -} - -FileName BlackBerryApiLevelConfiguration::qmake5BinaryFile() const -{ - return m_qmake5BinaryFile; -} - -FileName BlackBerryApiLevelConfiguration::sysRoot() const -{ - return m_sysRoot; -} - -QVariantMap BlackBerryApiLevelConfiguration::toMap() const -{ - QVariantMap data = QnxBaseConfiguration::toMap(); - data.insert(QLatin1String(Qnx::Constants::QNX_BB_KEY_CONFIGURATION_TYPE), - QLatin1String(Qnx::Constants::QNX_BB_APILEVEL_TYPE)); - data.insert(QLatin1String(NDKDisplayNameKey), m_displayName); - data.insert(QLatin1String(NDKPathKey), ndkPath()); - data.insert(QLatin1String(NDKTargetKey), m_sysRoot.toString()); - data.insert(QLatin1String(NDKAutoDetectionSourceKey), m_autoDetectionSource.toString()); - data.insert(QLatin1String(NDKAutoDetectedKey), isAutoDetected()); - return data; -} - -QnxAbstractQtVersion *BlackBerryApiLevelConfiguration::createQtVersion( - const FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName) -{ - QnxAbstractQtVersion *version = new BlackBerryQtVersion( - arch, qmakePath, true, QString(), envFile().toString()); - version->setUnexpandedDisplayName(tr("Qt %{Qt:Version} for %2") - .arg(version->qtVersionString(), versionName)); - QtVersionManager::addVersion(version); - return version; -} - -Kit *BlackBerryApiLevelConfiguration::createKit( - QnxAbstractQtVersion *version, QnxToolChain *toolChain, const QVariant &debuggerItemId) -{ - Kit *kit = new Kit; - bool isSimulator = version->architecture() == X86; - - QtKitInformation::setQtVersion(kit, version); - ToolChainKitInformation::setToolChain(kit, toolChain); - - if (debuggerItemId.isValid()) - DebuggerKitInformation::setDebugger(kit, debuggerItemId); - - if (version->qtVersion().majorVersion == 4) { - if (isSimulator) { - QmakeProjectManager::QmakeKitInformation::setMkspec( - kit, FileName::fromLatin1("blackberry-x86-qcc")); - } else { - QmakeProjectManager::QmakeKitInformation::setMkspec( - kit, FileName::fromLatin1("blackberry-armv7le-qcc")); - } - } - - DeviceTypeKitInformation::setDeviceTypeId(kit, Constants::QNX_BB_OS_TYPE); - SysRootKitInformation::setSysRoot(kit, m_sysRoot); - - kit->setUnexpandedDisplayName(version->displayName()); - kit->setIconPath(FileName::fromString(QLatin1String(Constants::QNX_BB_CATEGORY_ICON))); - - kit->setAutoDetected(true); - kit->setAutoDetectionSource(envFile().toString()); - kit->setMutable(DeviceKitInformation::id(), true); - - kit->setSticky(QtKitInformation::id(), true); - kit->setSticky(ToolChainKitInformation::id(), true); - kit->setSticky(DeviceTypeKitInformation::id(), true); - kit->setSticky(SysRootKitInformation::id(), true); - kit->setSticky(DebuggerKitInformation::id(), true); - kit->setSticky(QmakeProjectManager::QmakeKitInformation::id(), true); - - KitManager::registerKit(kit); - return kit; -} - -QStringList BlackBerryApiLevelConfiguration::validationErrors() const -{ - QStringList errorStrings = QnxBaseConfiguration::validationErrors(); - if (m_qmake4BinaryFile.isEmpty() && m_qmake5BinaryFile.isEmpty()) - errorStrings << tr("- No Qt version found."); - - if (!m_autoDetectionSource.isEmpty() && !m_autoDetectionSource.exists()) - errorStrings << tr("- No auto detection source found."); - - if (m_sysRoot.isEmpty() && m_sysRoot.exists()) - errorStrings << tr("- No sysroot found."); - - - return errorStrings; -} - -bool BlackBerryApiLevelConfiguration::activate() -{ - if (!isValid()) { - if (!m_autoDetectionSource.isEmpty()) - return false; - - QString errorMessage = tr("The following errors occurred while activating target \"%1\":\n").arg(m_targetName); - errorMessage.append(validationErrors().join(QLatin1Char('\n'))); - QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set up BB10 Configuration"), - errorMessage, QMessageBox::Ok); - return false; - } - - if (isActive()) - return true; - - deactivate(); // cleaning-up artifacts autodetected by old QtCreator versions - - QString armVersionName = tr("BlackBerry %1 Device").arg(version().toString()); - QString x86VersionName = tr("BlackBerry %1 Simulator").arg(version().toString()); - - // create versions - QnxAbstractQtVersion *qt4ArmVersion = 0; - QnxAbstractQtVersion *qt4X86Version = 0; - QnxAbstractQtVersion *qt5ArmVersion = 0; - QnxAbstractQtVersion *qt5X86Version = 0; - QList<Abi> armAbis; - QList<Abi> x86Abis; - - if (!m_qmake4BinaryFile.isEmpty()) { - qt4ArmVersion = createQtVersion(m_qmake4BinaryFile, Qnx::ArmLeV7, armVersionName); - armAbis << qt4ArmVersion->qtAbis(); - qt4X86Version = createQtVersion(m_qmake4BinaryFile, Qnx::X86, x86VersionName); - x86Abis << qt4X86Version->qtAbis(); - } - if (!m_qmake5BinaryFile.isEmpty()) { - qt5ArmVersion = createQtVersion(m_qmake5BinaryFile, Qnx::ArmLeV7, armVersionName); - foreach (Abi abi, qt5ArmVersion->qtAbis()) - if (!armAbis.contains(abi)) - armAbis << abi; - qt5X86Version = createQtVersion(m_qmake5BinaryFile, Qnx::X86, x86VersionName); - foreach (Abi abi, qt5X86Version->qtAbis()) - if (!x86Abis.contains(abi)) - x86Abis << abi; - } - - // Create tool chains - QnxToolChain *armvle7ToolChain = createToolChain(ArmLeV7, - tr("QCC for %1").arg(armVersionName), - ndkPath()); - QnxToolChain *x86ToolChain = createToolChain(X86, - tr("QCC for %1").arg(x86VersionName), - ndkPath()); - // Create debuggers - QVariant armDebuggerId = createDebuggerItem(ArmLeV7, - tr("Debugger for %1").arg(armVersionName)); - - QVariant x86DebuggerId = createDebuggerItem(X86, - tr("Debugger for %1").arg(x86VersionName)); - - // create kits - if (qt4ArmVersion) - createKit(qt4ArmVersion, armvle7ToolChain, armDebuggerId); - if (qt4X86Version) - createKit(qt4X86Version, x86ToolChain, x86DebuggerId); - if (qt5ArmVersion) - createKit(qt5ArmVersion, armvle7ToolChain, armDebuggerId); - if (qt5X86Version) - createKit(qt5X86Version, x86ToolChain, x86DebuggerId); - - BlackBerryConfigurationManager::instance()->emitSettingsChanged(); - - return true; -} - -void BlackBerryApiLevelConfiguration::deactivate() -{ - QList<BaseQtVersion *> qtvToRemove; - QList<ToolChain *> tcToRemove; - QList<const DebuggerItem *> dbgToRemove; - - foreach (Kit *kit, KitManager::kits()) { - if (kit->isAutoDetected() && - kit->autoDetectionSource() == envFile().toString()) { - BaseQtVersion *version = QtKitInformation::qtVersion(kit); - ToolChain *toolChain = ToolChainKitInformation::toolChain(kit); - const DebuggerItem *debugger = DebuggerKitInformation::debugger(kit); - // Kit's Qt version, tool chain or debugger might be used by other BB kits - // generated for the same API level that are not yet unregistered. This triggers warning outputs. - // Let's unregistered/removed them later once all API level kits are unregistered. - if (version && !qtvToRemove.contains(version)) - qtvToRemove << version; - if (toolChain && !tcToRemove.contains(toolChain)) - tcToRemove << toolChain; - if (debugger && !dbgToRemove.contains(debugger)) - dbgToRemove << debugger; - - KitManager::deregisterKit(kit); - } - } - - foreach (BaseQtVersion *qtv, qtvToRemove) - QtVersionManager::removeVersion(qtv); - - foreach (ToolChain *tc, tcToRemove) - ToolChainManager::deregisterToolChain(tc); - - foreach (const DebuggerItem *debugger, dbgToRemove) - DebuggerItemManager::deregisterDebugger(debugger->id()); - - BlackBerryConfigurationManager::instance()->emitSettingsChanged(); -} - -#ifdef WITH_TESTS -void BlackBerryApiLevelConfiguration::setFakeConfig(bool fakeConfig) -{ - m_fakeConfig = fakeConfig; -} - -bool BlackBerryApiLevelConfiguration::fakeConfig() -{ - return m_fakeConfig; -} - -#endif - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryapilevelconfiguration.h b/src/plugins/qnx/blackberryapilevelconfiguration.h deleted file mode 100644 index e61cabfe04e..00000000000 --- a/src/plugins/qnx/blackberryapilevelconfiguration.h +++ /dev/null @@ -1,110 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYCONFIGURATIONS_H -#define BLACKBERRYCONFIGURATIONS_H - -#include "qnxutils.h" -#include "qnxversionnumber.h" -#include "qnxbaseconfiguration.h" -#include "qnxconstants.h" - -#include <utils/environment.h> -#include <utils/fileutils.h> - -#include <projectexplorer/abi.h> -#include <projectexplorer/kit.h> - -#include <QObject> -#include <QCoreApplication> - -namespace QtSupport { class BaseQtVersion; } -namespace Debugger { class DebuggerItem; } - -namespace Qnx { -namespace Internal { - -class QnxAbstractQtVersion; -class QnxToolChain; - -class BlackBerryApiLevelConfiguration : public QnxBaseConfiguration -{ - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryApiLevelConfiguration) -public: - BlackBerryApiLevelConfiguration(const ConfigInstallInformation &ndkInstallInfo); - BlackBerryApiLevelConfiguration(const Utils::FileName &ndkEnvFile); - BlackBerryApiLevelConfiguration(const QVariantMap &data); - bool activate(); - void deactivate(); - QString ndkPath() const; - QString displayName() const; - QString targetName() const; - bool isAutoDetected() const; - Utils::FileName autoDetectionSource() const; - bool isActive() const; - bool isValid() const; - Utils::FileName qmake4BinaryFile() const; - Utils::FileName qmake5BinaryFile() const; - Utils::FileName sysRoot() const; - QVariantMap toMap() const; - -#ifdef WITH_TESTS - static void setFakeConfig(bool fakeConfig); - static bool fakeConfig(); -#endif - -protected: - QnxAbstractQtVersion *createQtVersion( - const Utils::FileName &qmakePath, Qnx::QnxArchitecture arch, const QString &versionName); - ProjectExplorer::Kit *createKit( - QnxAbstractQtVersion *version, QnxToolChain *armToolChain, const QVariant &debuggerItemId); - QStringList validationErrors() const; - -private: - QString m_displayName; - QString m_targetName; - Utils::FileName m_autoDetectionSource; - Utils::FileName m_qmake4BinaryFile; - Utils::FileName m_qmake5BinaryFile; - Utils::FileName m_sysRoot; - - void ctor(); - -#ifdef WITH_TESTS - static bool m_fakeConfig; -#endif -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYCONFIGURATIONS_H diff --git a/src/plugins/qnx/blackberryapplicationrunner.cpp b/src/plugins/qnx/blackberryapplicationrunner.cpp deleted file mode 100644 index 7d7b3f63db7..00000000000 --- a/src/plugins/qnx/blackberryapplicationrunner.cpp +++ /dev/null @@ -1,515 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryapplicationrunner.h" - -#include "blackberrydeployconfiguration.h" -#include "blackberrydeviceconnectionmanager.h" -#include "blackberryrunconfiguration.h" -#include "blackberrylogprocessrunner.h" -#include "blackberrydeviceinformation.h" -#include "qnxconstants.h" - -#include <coreplugin/icore.h> -#include <projectexplorer/kit.h> -#include <projectexplorer/target.h> -#include <qmakeprojectmanager/qmakebuildconfiguration.h> -#include <debugger/debuggerrunconfigurationaspect.h> -#include <ssh/sshremoteprocessrunner.h> -#include <utils/qtcassert.h> - -#include <QMessageBox> -#include <QTimer> -#include <QDir> -#include <QTemporaryFile> - -namespace { -enum { debugCheckQmlJSArgs = 0 }; - -bool parseRunningState(const QString &line) -{ - QTC_ASSERT(line.startsWith(QLatin1String("result::")), return false); - return line.trimmed().mid(8) == QLatin1String("true"); -} -} - -using namespace ProjectExplorer; -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryApplicationRunner::BlackBerryApplicationRunner(const BlackBerryApplicationRunner::LaunchFlags &launchFlags, BlackBerryRunConfiguration *runConfiguration, QObject *parent) - : QObject(parent) - , m_launchFlags(launchFlags) - , m_pid(-1) - , m_appId(QString()) - , m_running(false) - , m_stopping(false) - , m_launchProcess(0) - , m_stopProcess(0) - , m_deviceInfo(0) - , m_logProcessRunner(0) - , m_runningStateTimer(new QTimer(this)) - , m_runningStateProcess(0) - , m_qmlDebugServerPort(0) - , m_checkQmlJsDebugArgumentsProcess(0) -{ - QTC_ASSERT(runConfiguration, return); - - Target *target = runConfiguration->target(); - BuildConfiguration *buildConfig = target->activeBuildConfiguration(); - m_environment = buildConfig->environment(); - m_deployCmd = m_environment.searchInPath(QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD)).toString(); - - QFileInfo fi(target->kit()->autoDetectionSource()); - m_bbApiLevelVersion = QnxVersionNumber::fromNdkEnvFileName(fi.baseName()); - - m_device = BlackBerryDeviceConfiguration::device(target->kit()); - m_barPackage = runConfiguration->barPackage(); - - // The BlackBerry device always uses key authentication - m_sshParams = m_device->sshParameters(); - m_sshParams.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePublicKey; - - Debugger::DebuggerRunConfigurationAspect *aspect = - runConfiguration->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); - if (aspect) - m_qmlDebugServerPort = aspect->qmlDebugServerPort(); - - m_runningStateTimer->setInterval(3000); - m_runningStateTimer->setSingleShot(true); - connect(m_runningStateTimer, SIGNAL(timeout()), this, SLOT(determineRunningState())); - connect(this, SIGNAL(started()), this, SLOT(startLogProcessRunner())); - - connect(&m_launchStopProcessParser, SIGNAL(pidParsed(qint64)), this, SLOT(setPid(qint64))); - connect(&m_launchStopProcessParser, SIGNAL(applicationIdParsed(QString)), this, SLOT(setApplicationId(QString))); -} - -void BlackBerryApplicationRunner::start() -{ - if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) { - connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()), - this, SLOT(checkDeployMode())); - connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceDisconnected(Core::Id)), - this, SLOT(disconnectFromDeviceSignals(Core::Id))); - connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)), - this, SLOT(displayConnectionOutput(Core::Id,QString))); - BlackBerryDeviceConnectionManager::instance()->connectDevice(m_device->id()); - } else { - checkDeployMode(); - } -} - -void BlackBerryApplicationRunner::startLogProcessRunner() -{ - if (!m_logProcessRunner) { - m_logProcessRunner = new BlackBerryLogProcessRunner(this, m_appId, m_device); - connect(m_logProcessRunner, SIGNAL(output(QString,Utils::OutputFormat)), - this, SIGNAL(output(QString,Utils::OutputFormat))); - connect(m_logProcessRunner, SIGNAL(finished()), this, SIGNAL(finished())); - } - - m_logProcessRunner->start(); -} - -void BlackBerryApplicationRunner::displayConnectionOutput(Core::Id deviceId, const QString &msg) -{ - if (deviceId != m_device->id()) - return; - - if (msg.contains(QLatin1String("Info:"))) - emit output(msg, Utils::StdOutFormat); - else if (msg.contains(QLatin1String("Error:"))) - emit output(msg, Utils::StdErrFormat); -} - -void BlackBerryApplicationRunner::checkDeviceRuntimeVersion(int status) -{ - if (status != BlackBerryNdkProcess::Success) { - emit output(tr("Cannot determine device runtime version."), Utils::StdErrFormat); - return; - } - - if (m_bbApiLevelVersion.isEmpty()) { - emit output(tr("Cannot determine API level version."), Utils::StdErrFormat); - checkQmlJsDebugArguments(); - return; - } - - const QString runtimeVersion = m_deviceInfo->scmBundle(); - if (m_bbApiLevelVersion.toString() != runtimeVersion) { - const QMessageBox::StandardButton answer = - QMessageBox::question(Core::ICore::mainWindow(), - tr("Confirmation"), - tr("The device runtime version (%1) does not match " - "the API level version (%2).\n" - "This may cause unexpected behavior when debugging.\n" - "Do you want to continue anyway?") - .arg(runtimeVersion, m_bbApiLevelVersion.toString()), - QMessageBox::Yes | QMessageBox::No); - - if (answer == QMessageBox::No) { - emit startFailed(tr("API level version does not match Runtime version.")); - return; - } - } - - checkQmlJsDebugArguments(); -} - -void BlackBerryApplicationRunner::queryDeviceInformation() -{ - if (!m_deviceInfo) { - m_deviceInfo = new BlackBerryDeviceInformation(this); - connect(m_deviceInfo, SIGNAL(finished(int)), - this, SLOT(checkDeviceRuntimeVersion(int))); - } - - m_deviceInfo->setDeviceTarget(m_sshParams.host, m_sshParams.password); - emit output(tr("Querying device runtime version..."), Utils::StdOutFormat); -} - -void BlackBerryApplicationRunner::startFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - if (exitCode == 0 && exitStatus == QProcess::NormalExit && m_pid > -1) { - emit started(); - } else { - m_running = false; - m_runningStateTimer->stop(); - - QTC_ASSERT(m_launchProcess, return); - const QString errorString = (m_launchProcess->error() != QProcess::UnknownError) - ? m_launchProcess->errorString() : tr("Launching application failed"); - emit startFailed(errorString); - reset(); - } -} - -RunControl::StopResult BlackBerryApplicationRunner::stop() -{ - if (m_stopping) - return RunControl::AsynchronousStop; - - m_stopping = true; - - QStringList args; - args << QLatin1String("-terminateApp"); - args << QLatin1String("-device") << m_sshParams.host; - if (!m_sshParams.password.isEmpty()) - args << QLatin1String("-password") << m_sshParams.password; - args << m_barPackage.toUserOutput(); - - if (!m_stopProcess) { - m_stopProcess = new QProcess(this); - connect(m_stopProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError())); - connect(m_stopProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput())); - connect(m_stopProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(stopFinished(int,QProcess::ExitStatus))); - - m_stopProcess->setEnvironment(m_environment.toStringList()); - } - - m_stopProcess->start(m_deployCmd, args); - return RunControl::AsynchronousStop; -} - -bool BlackBerryApplicationRunner::isRunning() const -{ - return m_running; -} - -qint64 BlackBerryApplicationRunner::pid() const -{ - return m_pid; -} - -void BlackBerryApplicationRunner::stopFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - Q_UNUSED(exitCode); - Q_UNUSED(exitStatus); - - reset(); -} - -void BlackBerryApplicationRunner::readStandardOutput() -{ - QProcess *process = qobject_cast<QProcess *>(sender()); - process->setReadChannel(QProcess::StandardOutput); - while (process->canReadLine()) { - QString line = QString::fromLocal8Bit(process->readLine()); - m_launchStopProcessParser.stdOutput(line); - emit output(line, Utils::StdOutFormat); - } -} - -void BlackBerryApplicationRunner::readStandardError() -{ - QProcess *process = qobject_cast<QProcess *>(sender()); - process->setReadChannel(QProcess::StandardError); - while (process->canReadLine()) { - const QString line = QString::fromLocal8Bit(process->readLine()); - m_launchStopProcessParser.stdError(line); - emit output(line, Utils::StdErrFormat); - } -} - -void BlackBerryApplicationRunner::disconnectFromDeviceSignals(Core::Id deviceId) -{ - if (m_device->id() == deviceId) { - disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceConnected()), - this, SLOT(checkDeployMode())); - disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceDisconnected(Core::Id)), - this, SLOT(disconnectFromDeviceSignals(Core::Id))); - disconnect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)), - this, SLOT(displayConnectionOutput(Core::Id,QString))); - } -} - -void BlackBerryApplicationRunner::setPid(qint64 pid) -{ - m_pid = pid; -} - -void BlackBerryApplicationRunner::setApplicationId(const QString &applicationId) -{ - m_appId = applicationId; -} - -void BlackBerryApplicationRunner::checkQmlJsDebugArguments() -{ - if (!m_launchFlags.testFlag(QmlDebugLaunch)) { - // no need to change anytning in app manifest for this kind of run - launchApplication(); - } - - emit output(tr("Checking qmljsdebugger command line argument."), Utils::StdOutFormat); - QString nativePackagerCmd = m_environment.searchInPath(QLatin1String("blackberry-nativepackager")).toString(); - if (nativePackagerCmd.isEmpty()) { - emit output(tr("Cannot find Native Packager executable."), Utils::StdErrFormat); - return; - } - - m_checkQmlJsDebugArgumentsProcess = new QProcess(this); - connect(m_checkQmlJsDebugArgumentsProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(checkQmlJsDebugArgumentsManifestLoaded())); - connect(m_checkQmlJsDebugArgumentsProcess, SIGNAL(finished(int)), this, SLOT(checkQmlJsDebugArgumentsManifestLoaded())); - - QStringList args; - args << QLatin1String("-listManifest") << m_barPackage.toUserOutput(); - if (debugCheckQmlJSArgs) - qDebug() << "get manifest:" << nativePackagerCmd << args.join(QLatin1Char(' ')); - m_checkQmlJsDebugArgumentsProcess->start(nativePackagerCmd, args); -} - -void BlackBerryApplicationRunner::checkQmlJsDebugArgumentsManifestLoaded() -{ - m_checkQmlJsDebugArgumentsProcess->deleteLater(); - - if (m_checkQmlJsDebugArgumentsProcess->exitStatus() != QProcess::NormalExit) { - emit output(tr("Cannot read bar package manifest."), Utils::StdErrFormat); - qWarning() << "Cannot read bar package manifest:" << m_checkQmlJsDebugArgumentsProcess->errorString(); - qWarning() << m_checkQmlJsDebugArgumentsProcess->readAllStandardError(); - return; - } - - QString manifestContent = QString::fromUtf8(m_checkQmlJsDebugArgumentsProcess->readAllStandardOutput()); - - QRegExp rxEoln(QLatin1String("(\\r\\n|\\n|\\r)")); - QStringList manifestLines = manifestContent.split(rxEoln); - - QMutableListIterator<QString> it(manifestLines); - QLatin1String entryPoint("Entry-Point: "); - while (it.hasNext()) { - it.next(); - if (it.value().startsWith(entryPoint)) { - while (it.hasNext() && it.peekNext().startsWith(QLatin1Char(' '))) - it.next(); - QString qmljsdbgArg = QString::fromLatin1("-qmljsdebugger=port:%1%2") - .arg(m_qmlDebugServerPort) - .arg(m_launchFlags.testFlag(QmlDebugLaunchBlocking)? QLatin1String(",block"): QLatin1String("")); - it.insert(QLatin1String(" ") + qmljsdbgArg); - manifestContent = manifestLines.join(QLatin1Char('\n')); - break; - } - } - - m_checkQmlJsDebugArgumentsProcess = new QProcess(this); - connect(m_checkQmlJsDebugArgumentsProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(checkQmlJsDebugArgumentsManifestSaved())); - connect(m_checkQmlJsDebugArgumentsProcess, SIGNAL(finished(int)), this, SLOT(checkQmlJsDebugArgumentsManifestSaved())); - - QTemporaryFile *manifestFile = new QTemporaryFile(m_checkQmlJsDebugArgumentsProcess); - if (!manifestFile->open()) { - emit output(tr("Internal error: Cannot create temporary manifest file \"%1\"") - .arg(manifestFile->fileName()), Utils::StdErrFormat); - delete manifestFile; - return; - } - - manifestFile->write(manifestContent.toUtf8()); - manifestFile->flush(); - - QStringList args; - args << QLatin1String("-device") << m_sshParams.host; - if (!m_sshParams.password.isEmpty()) - args << QLatin1String("-password") << m_sshParams.password; - args << QLatin1String("-package") << m_barPackage.toUserOutput(); - args << QLatin1String("-putFile"); - args << manifestFile->fileName(); - args << QLatin1String("app/META-INF/MANIFEST.MF"); - if (debugCheckQmlJSArgs) - qDebug() << "set manifest:" << m_deployCmd << args.join(QLatin1Char(' ')); - m_checkQmlJsDebugArgumentsProcess->start(m_deployCmd, args); -} - -void BlackBerryApplicationRunner::checkQmlJsDebugArgumentsManifestSaved() -{ - m_checkQmlJsDebugArgumentsProcess->deleteLater(); - - if (m_checkQmlJsDebugArgumentsProcess->exitStatus() != QProcess::NormalExit) { - emit output(tr("Cannot set command line arguments."), Utils::StdErrFormat); - qWarning() << "Cannot set command line arguments:" << m_checkQmlJsDebugArgumentsProcess->errorString(); - qWarning() << m_checkQmlJsDebugArgumentsProcess->readAllStandardError(); - return; - } - - launchApplication(); -} - -void BlackBerryApplicationRunner::launchApplication() -{ - // If original device connection fails before launching, this method maybe triggered - // if any other device is connected(?) - if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) - return; - - QStringList args; - args << QLatin1String("-launchApp"); - if (m_launchFlags.testFlag(CppDebugLaunch)) - args << QLatin1String("-debugNative"); - args << QLatin1String("-device") << m_sshParams.host; - if (!m_sshParams.password.isEmpty()) - args << QLatin1String("-password") << m_sshParams.password; - args << QLatin1String("-package") << m_barPackage.toUserOutput(); - - if (!m_launchProcess) { - m_launchProcess = new QProcess(this); - connect(m_launchProcess, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError())); - connect(m_launchProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput())); - connect(m_launchProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(startFinished(int,QProcess::ExitStatus))); - - m_launchProcess->setEnvironment(m_environment.toStringList()); - } - if (debugCheckQmlJSArgs) - qDebug() << "launch:" << m_deployCmd << args.join(QLatin1Char(' ')); - m_launchProcess->start(m_deployCmd, args); - m_runningStateTimer->start(); - m_running = true; -} - -void BlackBerryApplicationRunner::checkDeployMode() -{ - // If original device connection fails before launching, this method maybe triggered - // if any other device is connected - if (!BlackBerryDeviceConnectionManager::instance()->isConnected(m_device->id())) - return; - - if (m_launchFlags.testFlag(CppDebugLaunch)) - queryDeviceInformation(); // check API version vs Runtime version - else - checkQmlJsDebugArguments(); -} - -void BlackBerryApplicationRunner::startRunningStateTimer() -{ - if (m_running) - m_runningStateTimer->start(); -} - -void BlackBerryApplicationRunner::determineRunningState() -{ - QStringList args; - args << QLatin1String("-isAppRunning"); - args << QLatin1String("-device") << m_sshParams.host; - if (!m_sshParams.password.isEmpty()) - args << QLatin1String("-password") << m_sshParams.password; - args << m_barPackage.toUserOutput(); - - if (!m_runningStateProcess) { - m_runningStateProcess = new QProcess(this); - - connect(m_runningStateProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readRunningStateStandardOutput())); - connect(m_runningStateProcess, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(startRunningStateTimer())); - } - - m_runningStateProcess->setEnvironment(m_environment.toStringList()); - - m_runningStateProcess->start(m_deployCmd, args); -} - -void BlackBerryApplicationRunner::readRunningStateStandardOutput() -{ - QProcess *process = qobject_cast<QProcess *>(sender()); - process->setReadChannel(QProcess::StandardOutput); - while (process->canReadLine()) { - const QString line = QString::fromLocal8Bit(process->readLine()); - if (line.startsWith(QLatin1String("result"))) { - m_running = parseRunningState(line); - break; - } - } - - if (!m_running) - reset(); -} - -void BlackBerryApplicationRunner::reset() -{ - m_pid = -1; - m_appId.clear(); - m_running = false; - m_stopping = false; - - m_runningStateTimer->stop(); - if (m_runningStateProcess) { - m_runningStateProcess->terminate(); - if (!m_runningStateProcess->waitForFinished(1000)) - m_runningStateProcess->kill(); - } - - if (m_logProcessRunner) { - m_logProcessRunner->stop(); - - delete m_logProcessRunner; - m_logProcessRunner = 0; - } else { - emit finished(); - } -} diff --git a/src/plugins/qnx/blackberryapplicationrunner.h b/src/plugins/qnx/blackberryapplicationrunner.h deleted file mode 100644 index 792c5874280..00000000000 --- a/src/plugins/qnx/blackberryapplicationrunner.h +++ /dev/null @@ -1,152 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYAPPLICATIONRUNNER_H -#define QNX_INTERNAL_BLACKBERRYAPPLICATIONRUNNER_H - -#include "blackberrydeviceconfiguration.h" -#include "blackberryprocessparser.h" -#include "qnxversionnumber.h" - -#include <projectexplorer/runconfiguration.h> - -#include <ssh/sshconnection.h> -#include <utils/environment.h> -#include <utils/fileutils.h> - -#include <QObject> -#include <QProcess> -#include <QDateTime> - -namespace QSsh { class SshRemoteProcessRunner; } - -namespace Qnx { -namespace Internal { - -class BlackBerryRunConfiguration; -class BlackBerryLogProcessRunner; -class BlackBerryDeviceInformation; - -class BlackBerryApplicationRunner : public QObject -{ - Q_OBJECT -public: - enum LaunchFlag - { - CppDebugLaunch = 0x1, - QmlDebugLaunch = 0x2, - QmlDebugLaunchBlocking = 0x4, - QmlProfilerLaunch = 0x8 - }; - Q_DECLARE_FLAGS(LaunchFlags, LaunchFlag) - -public: - explicit BlackBerryApplicationRunner(const LaunchFlags &launchFlags, BlackBerryRunConfiguration *runConfiguration, QObject *parent = 0); - - bool isRunning() const; - qint64 pid() const; - -public slots: - void start(); - ProjectExplorer::RunControl::StopResult stop(); - -signals: - void output(const QString &msg, Utils::OutputFormat format); - void started(); - void finished(); - - void startFailed(const QString &msg); - -private slots: - void startFinished(int exitCode, QProcess::ExitStatus exitStatus); - void stopFinished(int exitCode, QProcess::ExitStatus exitStatus); - - void readStandardOutput(); - void readStandardError(); - - void disconnectFromDeviceSignals(Core::Id deviceId); - void startRunningStateTimer(); - void determineRunningState(); - void readRunningStateStandardOutput(); - - void setPid(qint64 pid); - void setApplicationId(const QString &applicationId); - - void launchApplication(); - void checkDeployMode(); - void startLogProcessRunner(); - - void displayConnectionOutput(Core::Id deviceId, const QString &output); - void checkDeviceRuntimeVersion(int status); - - void checkQmlJsDebugArguments(); - void checkQmlJsDebugArgumentsManifestLoaded(); - void checkQmlJsDebugArgumentsManifestSaved(); - -private: - void reset(); - void queryDeviceInformation(); - - LaunchFlags m_launchFlags; - - qint64 m_pid; - QString m_appId; - - bool m_running; - bool m_stopping; - - Utils::Environment m_environment; - QString m_deployCmd; - BlackBerryDeviceConfiguration::ConstPtr m_device; - Utils::FileName m_barPackage; - QSsh::SshConnectionParameters m_sshParams; - - QProcess *m_launchProcess; - QProcess *m_stopProcess; - BlackBerryProcessParser m_launchStopProcessParser; - BlackBerryDeviceInformation *m_deviceInfo; - - BlackBerryLogProcessRunner *m_logProcessRunner; - - QTimer *m_runningStateTimer; - QProcess *m_runningStateProcess; - - QnxVersionNumber m_bbApiLevelVersion; - - int m_qmlDebugServerPort; - QProcess *m_checkQmlJsDebugArgumentsProcess; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYAPPLICATIONRUNNER_H diff --git a/src/plugins/qnx/blackberrycertificate.cpp b/src/plugins/qnx/blackberrycertificate.cpp deleted file mode 100644 index 3accfd432d8..00000000000 --- a/src/plugins/qnx/blackberrycertificate.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycertificate.h" -#include "blackberryapilevelconfiguration.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryndkprocess.h" - -#include <utils/environment.h> -#include <utils/hostosinfo.h> - -#include <QProcess> -#include <QFile> -#include <QTextStream> - -namespace Qnx { -namespace Internal { - -BlackBerryCertificate::BlackBerryCertificate(const QString &fileName, - const QString &author, const QString &storePass, QObject *parent) : - QObject(parent), - m_fileName(fileName), - m_author(author), - m_storePass(storePass), - m_process(new QProcess(this)) -{ - m_process->setProcessChannelMode(QProcess::MergedChannels); - m_process->setEnvironment(Utils::EnvironmentItem::toStringList( - BlackBerryConfigurationManager::instance()->defaultConfigurationEnv())); -} - -void BlackBerryCertificate::load() -{ - if (m_process->state() != QProcess::NotRunning) { - emit finished(BlackBerryCertificate::Busy); - return; - } - QStringList arguments; - - arguments << QLatin1String("-keystore") - << m_fileName - << QLatin1String("-list") - << QLatin1String("-verbose") - << QLatin1String("-storepass") - << m_storePass; - - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(loadFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError())); - - m_process->start(command(), arguments); -} - -void BlackBerryCertificate::store() -{ - if (m_process->state() != QProcess::NotRunning) { - emit finished(BlackBerryCertificate::Busy); - return; - } - - QFile file(m_fileName); - - if (file.exists()) - file.remove(); - - QStringList arguments; - - arguments << QLatin1String("-genkeypair") - << QLatin1String("-storepass") - << m_storePass - << QLatin1String("-author") - << m_author - << QLatin1String("-keystore") - << m_fileName; - - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(storeFinished(int))); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError())); - - m_process->start(command(), arguments); -} - -QString BlackBerryCertificate::fileName() const -{ - return m_fileName; -} - -QString BlackBerryCertificate::author() const -{ - return m_author; -} - -QString BlackBerryCertificate::id() const -{ - QString tmpId = fileName(); - return tmpId.replace(QLatin1Char('/'), QLatin1Char('-')); -} - -void BlackBerryCertificate::storeFinished(int status) -{ - m_process->disconnect(); - - if (status == 0) - emit finished(BlackBerryCertificate::Success); - else - emit finished(BlackBerryCertificate::Error); -} - -void BlackBerryCertificate::loadFinished() -{ - m_process->disconnect(); - - ResultCode status = Error; - - QTextStream processOutput(m_process); - - while (!processOutput.atEnd()) { - QString chunk = processOutput.readLine(); - - if (chunk.contains(QLatin1String("invalid password"))) { - status = WrongPassword; - break; - } else if (chunk.contains(QLatin1String("must be at least 6 characters"))) { - status = PasswordTooSmall; - break; - } else if (chunk.startsWith(QLatin1String("Owner:"))) { - chunk.remove(QLatin1String("Owner:")); - m_author = chunk.remove(QLatin1String("CN=")).trimmed(); - status = Success; - break; - } else if (chunk.contains(QLatin1String("Subject Name:"))) { - // this format is used by newer NDKs, the interesting data - // comes on the next line - chunk = processOutput.readLine(); - const QString token = QLatin1String("CommonName="); - if (chunk.contains(token)) { - m_author = chunk.remove(token).trimmed(); - status = Success; - } else { - status = InvalidOutputFormat; - } - - break; - } - } - - emit finished(status); -} - -void BlackBerryCertificate::processError() -{ - m_process->disconnect(); - - emit finished(Error); -} - -QString BlackBerryCertificate::command() const -{ - return BlackBerryNdkProcess::resolveNdkToolPath(QLatin1String("blackberry-keytool")); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrycertificate.h b/src/plugins/qnx/blackberrycertificate.h deleted file mode 100644 index e39cb36da5d..00000000000 --- a/src/plugins/qnx/blackberrycertificate.h +++ /dev/null @@ -1,95 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCERTIFICATE_H -#define QNX_INTERNAL_BLACKBERRYCERTIFICATE_H - -#include <QObject> -#include <QString> - -QT_BEGIN_NAMESPACE -class QProcess; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryCertificate : public QObject -{ -Q_OBJECT - -public: - enum ResultCode { - Success, - Busy, - WrongPassword, - PasswordTooSmall, - InvalidOutputFormat, - Error - }; - - BlackBerryCertificate(const QString &fileName, - const QString &author = QString(), - const QString &storePass = QString(), - QObject *parent = 0); - - void load(); - void store(); - - QString fileName() const; - QString author() const; - QString id() const; - -signals: - void loaded(); - void stored(); - void finished(int status); - -private slots: - void storeFinished(int status); - void loadFinished(); - void processError(); - -private: - QString command() const; - - QString m_fileName; - QString m_author; - QString m_storePass; - - QProcess *m_process; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCERTIFICATE_H diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstep.cpp b/src/plugins/qnx/blackberrycheckdevicestatusstep.cpp deleted file mode 100644 index e2faf7e7ed8..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstep.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycheckdevicestatusstep.h" - -#include "blackberrycheckdevicestatusstepconfigwidget.h" -#include "blackberrydeviceinformation.h" -#include "qnxversionnumber.h" -#include "qnxconstants.h" - -#include <projectexplorer/buildconfiguration.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> -#include <projectexplorer/kit.h> -#include <projectexplorer/task.h> -#include <ssh/sshconnection.h> - -#include <coreplugin/icore.h> - -#include <qfileinfo.h> - -#include <qmessagebox.h> - -#include <qeventloop.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char RUNTIME_CHECK_ENABLED[] = - "Qnx.Internal.BlackBerryCheckDeviceStatusStep.RuntimeCheckEnabled"; -const char DEBUG_TOKEN_CHECK_ENABLED[] = - "Qnx.Internal.BlackBerryCheckDeviceStatusStep.DebugTokenCheckEnabled"; -} - -BlackBerryCheckDeviceStatusStep::BlackBerryCheckDeviceStatusStep(ProjectExplorer::BuildStepList *bsl) : - ProjectExplorer::BuildStep(bsl, Core::Id(Constants::QNX_CHECK_DEVICE_STATUS_BS_ID)) - , m_deviceInfo(0) - , m_eventLoop(0) - , m_runtimeCheckEnabled(true) - , m_debugTokenCheckEnabled(true) -{ - setDisplayName(tr("Check Device Status")); -} - -BlackBerryCheckDeviceStatusStep::BlackBerryCheckDeviceStatusStep(ProjectExplorer::BuildStepList *bsl, - BlackBerryCheckDeviceStatusStep *bs) : - ProjectExplorer::BuildStep(bsl, bs) - , m_deviceInfo(0) - , m_eventLoop(0) - , m_runtimeCheckEnabled(true) - , m_debugTokenCheckEnabled(true) -{ - setDisplayName(tr("Check Device Status")); -} - -void BlackBerryCheckDeviceStatusStep::checkDeviceInfo(int status) -{ - if (!m_runtimeCheckEnabled && m_debugTokenCheckEnabled) { - // Skip debug token check for internal non secure devices and simulators - if (!m_deviceInfo->isProductionDevice() || m_deviceInfo->isSimulator()) { - m_eventLoop->exit(true); - return; - } - } - - if (status != BlackBerryDeviceInformation::Success) { - switch (status) { - case BlackBerryDeviceInformation::AuthenticationFailed: - raiseError(tr("Authentication failed.")); - break; - case BlackBerryDeviceInformation::NoRouteToHost: - raiseError(tr("Cannot connect to device.")); - break; - case BlackBerryDeviceInformation::DevelopmentModeDisabled: - raiseError(tr("Device is not in the development mode.")); - break; - case BlackBerryDeviceInformation::InferiorProcessTimedOut: - raiseError(tr("Timeout querying device information.")); - break; - case BlackBerryDeviceInformation::FailedToStartInferiorProcess: - raiseError(tr("Failed to query device information.")); - break; - case BlackBerryDeviceInformation::InferiorProcessCrashed: - raiseError(tr("Process to query device information has crashed.")); - break; - default: - raiseError(tr("Cannot query device information.")); - break; - } - m_eventLoop->exit(false); - return; - } - - if (m_debugTokenCheckEnabled && !m_deviceInfo->debugTokenValid()) { - //: %1: Error message from BlackBerryDeviceInformation - const QString errorMsg = - tr("%1. Upload a valid debug token into the device.") - .arg(m_deviceInfo->debugTokenValidationError()); - raiseError(errorMsg); - m_eventLoop->exit(false); - return; - } - - if (m_runtimeCheckEnabled) { - QnxVersionNumber deviceRuntimeVersion(m_deviceInfo->scmBundle()); - QFileInfo fi(target()->kit()->autoDetectionSource()); - - if (deviceRuntimeVersion.isEmpty()) { - // Skip the check if device runtime is not determined - m_eventLoop->exit(true); - raiseWarning(tr("Cannot determine device runtime version.")); - return; - } - - QnxVersionNumber apiLevelVersion = QnxVersionNumber::fromNdkEnvFileName(fi.baseName()); - if (apiLevelVersion.isEmpty()) { - // Skip the check if device API level version is not determined - m_eventLoop->exit(true); - raiseWarning(tr("Cannot determine API level version.")); - return; - } - - bool ok = true; - if (apiLevelVersion > deviceRuntimeVersion) { - raiseError(tr("The device runtime version (%1) is inferior to the API level version (%2)") - .arg(deviceRuntimeVersion.toString(), apiLevelVersion.toString())); - - QMetaObject::invokeMethod(this, "handleVersionMismatch", Qt::BlockingQueuedConnection, - Q_RETURN_ARG(bool, ok), - Q_ARG(QString, deviceRuntimeVersion.toString()), - Q_ARG(QString, apiLevelVersion.toString())); - } - - m_eventLoop->exit(ok); - return; - } - - m_eventLoop->exit(true); -} - -void BlackBerryCheckDeviceStatusStep::emitOutputInfo() -{ - emit addOutput(tr("Checking device status..."), BuildStep::MessageOutput); -} - -void BlackBerryCheckDeviceStatusStep::enableDebugTokenCheck(bool enable) -{ - m_debugTokenCheckEnabled = enable; -} - -void BlackBerryCheckDeviceStatusStep::enableRuntimeCheck(bool enable) -{ - m_runtimeCheckEnabled = enable; -} - -bool BlackBerryCheckDeviceStatusStep::handleVersionMismatch(const QString &runtimeVersion, const QString &apiLevelVersion) -{ - // TODO: Check if a matching API level exists in the user configurations, - // otherwise let the user download the matching device runtime. - const QMessageBox::StandardButton answer = QMessageBox::question(Core::ICore::mainWindow(), tr("Confirmation"), - tr("The device runtime version (%1) does not match the API level version (%2).\n" - "Do you want to continue anyway?").arg(runtimeVersion, apiLevelVersion), - QMessageBox::Yes | QMessageBox::No); - return answer == QMessageBox::Yes; -} - -bool BlackBerryCheckDeviceStatusStep::init() -{ - m_device = BlackBerryDeviceConfiguration::device(target()->kit()); - if (!m_device) - return false; - - if (m_device->sshParameters().host.isEmpty()) { - raiseError(tr("No hostname specified for the device")); - return false; - } - - return true; -} - -void BlackBerryCheckDeviceStatusStep::run(QFutureInterface<bool> &fi) -{ - if (!m_runtimeCheckEnabled && !m_debugTokenCheckEnabled) - return fi.reportResult(true); - - m_eventLoop = new QEventLoop; - m_deviceInfo = new BlackBerryDeviceInformation; - - connect(m_deviceInfo, SIGNAL(started()), this, SLOT(emitOutputInfo())); - connect(m_deviceInfo, SIGNAL(finished(int)), this, SLOT(checkDeviceInfo(int)), Qt::DirectConnection); - m_deviceInfo->setDeviceTarget(m_device->sshParameters().host, m_device->sshParameters().password); - - bool returnValue = m_eventLoop->exec(); - - delete m_eventLoop; - m_eventLoop = 0; - - delete m_deviceInfo; - m_deviceInfo = 0; - - return fi.reportResult(returnValue); -} - -ProjectExplorer::BuildStepConfigWidget *BlackBerryCheckDeviceStatusStep::createConfigWidget() -{ - return new BlackBerryCheckDeviceStatusStepConfigWidget(this); -} - -void BlackBerryCheckDeviceStatusStep::raiseError(const QString &errorMessage) -{ - emit addOutput(errorMessage, BuildStep::ErrorMessageOutput); - emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Error, errorMessage, Utils::FileName(), -1, - ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); -} - -void BlackBerryCheckDeviceStatusStep::raiseWarning(const QString &warningMessage) -{ - emit addOutput(warningMessage, BuildStep::ErrorOutput); - emit addTask(ProjectExplorer::Task(ProjectExplorer::Task::Warning, warningMessage, Utils::FileName(), -1, - ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); -} - - -bool BlackBerryCheckDeviceStatusStep::fromMap(const QVariantMap &map) -{ - m_runtimeCheckEnabled = map.value(QLatin1String(RUNTIME_CHECK_ENABLED), false).toBool(); - m_debugTokenCheckEnabled = map.value(QLatin1String(DEBUG_TOKEN_CHECK_ENABLED), false).toBool(); - - return BuildStep::fromMap(map); -} - -QVariantMap BlackBerryCheckDeviceStatusStep::toMap() const -{ - QVariantMap map = BuildStep::toMap(); - map.insert(QLatin1String(RUNTIME_CHECK_ENABLED), m_runtimeCheckEnabled); - map.insert(QLatin1String(DEBUG_TOKEN_CHECK_ENABLED), m_debugTokenCheckEnabled); - - return map; -} - -bool BlackBerryCheckDeviceStatusStep::debugTokenCheckEnabled() const -{ - return m_debugTokenCheckEnabled; -} - -bool BlackBerryCheckDeviceStatusStep::runtimeCheckEnabled() const -{ - return m_runtimeCheckEnabled; -} diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstep.h b/src/plugins/qnx/blackberrycheckdevicestatusstep.h deleted file mode 100644 index 21b841a2cf5..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstep.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEP_H -#define QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEP_H - -#include "blackberrydeviceconfiguration.h" - -#include <projectexplorer/buildstep.h> - -QT_BEGIN_NAMESPACE -class QEventLoop; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceInformation; -class BlackBerryCheckDeviceStatusStep : public ProjectExplorer::BuildStep -{ - Q_OBJECT - friend class BlackBerryCheckDeviceStatusStepFactory; - -public: - explicit BlackBerryCheckDeviceStatusStep(ProjectExplorer::BuildStepList *bsl); - - bool init(); - void run(QFutureInterface<bool> &fi); - ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - void raiseError(const QString &error); - void raiseWarning(const QString &warning); - - bool fromMap(const QVariantMap &map); - QVariantMap toMap() const; - - bool debugTokenCheckEnabled () const; - bool runtimeCheckEnabled() const; - -protected: - BlackBerryCheckDeviceStatusStep(ProjectExplorer::BuildStepList *bsl, - BlackBerryCheckDeviceStatusStep *bs); - -protected slots: - void checkDeviceInfo(int status); - void emitOutputInfo(); - - void enableDebugTokenCheck(bool enable); - void enableRuntimeCheck(bool enable); - - bool handleVersionMismatch(const QString &runtimeVersion, const QString &apiLevelVersion); - -private: - BlackBerryDeviceInformation *m_deviceInfo; - BlackBerryDeviceConfiguration::ConstPtr m_device; - QEventLoop *m_eventLoop; - - bool m_runtimeCheckEnabled; - bool m_debugTokenCheckEnabled; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEP_H diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.cpp b/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.cpp deleted file mode 100644 index 17a0bc523c2..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycheckdevicestatusstepconfigwidget.h" -#include "ui_blackberrycheckdevicestatusstepconfigwidget.h" -#include "blackberrycheckdevicestatusstep.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryCheckDeviceStatusStepConfigWidget::BlackBerryCheckDeviceStatusStepConfigWidget( - BlackBerryCheckDeviceStatusStep *checkDeviceStatuStep) - : ProjectExplorer::BuildStepConfigWidget() - , m_checkDeviceStatusStep(checkDeviceStatuStep) - , m_ui(new Ui::BlackBerryCheckDeviceStatusStepConfigWidget) -{ - m_ui->setupUi(this); - m_ui->checkRuntime->setChecked(m_checkDeviceStatusStep->runtimeCheckEnabled()); - m_ui->checkDebugToken->setChecked(m_checkDeviceStatusStep->debugTokenCheckEnabled()); - - connect(m_ui->checkRuntime, SIGNAL(clicked(bool)), - m_checkDeviceStatusStep, SLOT(enableRuntimeCheck(bool))); - connect(m_ui->checkDebugToken, SIGNAL(clicked(bool)), - m_checkDeviceStatusStep, SLOT(enableDebugTokenCheck(bool))); -} - -BlackBerryCheckDeviceStatusStepConfigWidget::~BlackBerryCheckDeviceStatusStepConfigWidget() -{ - delete m_ui; -} - -QString BlackBerryCheckDeviceStatusStepConfigWidget::displayName() const -{ - return tr("<b>Check device status</b>"); -} - -QString BlackBerryCheckDeviceStatusStepConfigWidget::summaryText() const -{ - return displayName(); -} - -bool BlackBerryCheckDeviceStatusStepConfigWidget::showWidget() const -{ - return true; -} diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.h b/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.h deleted file mode 100644 index b94f2302ddd..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPCONFIGWIDGET_H -#define QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPCONFIGWIDGET_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BlackBerryCheckDeviceStatusStepConfigWidget; } - -class BlackBerryCheckDeviceStatusStep; -class BlackBerryCheckDeviceStatusStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT -public: - explicit BlackBerryCheckDeviceStatusStepConfigWidget( - BlackBerryCheckDeviceStatusStep *checkDeviceStatuStep); - ~BlackBerryCheckDeviceStatusStepConfigWidget(); - - QString displayName() const; - QString summaryText() const; - - bool showWidget() const; -private: - BlackBerryCheckDeviceStatusStep *m_checkDeviceStatusStep; - Ui::BlackBerryCheckDeviceStatusStepConfigWidget *m_ui; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPCONFIGWIDGET_H diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.ui b/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.ui deleted file mode 100644 index 370a1932927..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstepconfigwidget.ui +++ /dev/null @@ -1,35 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryCheckDeviceStatusStepConfigWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryCheckDeviceStatusStepConfigWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>126</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QCheckBox" name="checkRuntime"> - <property name="text"> - <string>Check device runtime</string> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="checkDebugToken"> - <property name="text"> - <string>Check debug token</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.cpp b/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.cpp deleted file mode 100644 index 05d6808cbfb..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycheckdevicestatusstepfactory.h" - -#include "blackberrycheckdevicestatusstep.h" -#include "blackberrydeviceconfigurationfactory.h" -#include "qnxconstants.h" - -#include <projectexplorer/buildsteplist.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryCheckDeviceStatusStepFactory::BlackBerryCheckDeviceStatusStepFactory(QObject *parent) : - ProjectExplorer::IBuildStepFactory(parent) -{ -} - -QList<Core::Id> BlackBerryCheckDeviceStatusStepFactory::availableCreationIds( - ProjectExplorer::BuildStepList *parent) const -{ - if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) - return QList<Core::Id>(); - - Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(parent->target()->kit()); - if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType()) - return QList<Core::Id>(); - - return QList<Core::Id>() << Core::Id(Constants::QNX_CHECK_DEVICE_STATUS_BS_ID); -} - -QString BlackBerryCheckDeviceStatusStepFactory::displayNameForId(Core::Id id) const -{ - if (id == Constants::QNX_CHECK_DEVICE_STATUS_BS_ID) - return tr("Check Device Status"); - return QString(); -} - -bool BlackBerryCheckDeviceStatusStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const -{ - return availableCreationIds(parent).contains(id); -} - -ProjectExplorer::BuildStep *BlackBerryCheckDeviceStatusStepFactory::create(ProjectExplorer::BuildStepList *parent, - const Core::Id id) -{ - if (!canCreate(parent, id)) - return 0; - return new BlackBerryCheckDeviceStatusStep(parent); -} - -bool BlackBerryCheckDeviceStatusStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const -{ - return canCreate(parent, ProjectExplorer::idFromMap(map)); -} - -ProjectExplorer::BuildStep *BlackBerryCheckDeviceStatusStepFactory::restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - BlackBerryCheckDeviceStatusStep *bs = new BlackBerryCheckDeviceStatusStep(parent); - if (bs->fromMap(map)) - return bs; - delete bs; - return 0; -} - -bool BlackBerryCheckDeviceStatusStepFactory::canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - -ProjectExplorer::BuildStep *BlackBerryCheckDeviceStatusStepFactory::clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) -{ - if (!canClone(parent, product)) - return 0; - return new BlackBerryCheckDeviceStatusStep(parent, static_cast<BlackBerryCheckDeviceStatusStep *>(product)); -} diff --git a/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.h b/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.h deleted file mode 100644 index 6c6d18e7e3b..00000000000 --- a/src/plugins/qnx/blackberrycheckdevicestatusstepfactory.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPFACTORY_H -#define QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPFACTORY_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryCheckDeviceStatusStepFactory : public ProjectExplorer::IBuildStepFactory -{ - Q_OBJECT -public: - explicit BlackBerryCheckDeviceStatusStepFactory(QObject *parent = 0); - - QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const; - QString displayNameForId(Core::Id id) const; - - bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id); - - bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map); - - bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCHECKDEVICESTATUSSTEPFACTORY_H diff --git a/src/plugins/qnx/blackberryconfigurationmanager.cpp b/src/plugins/qnx/blackberryconfigurationmanager.cpp deleted file mode 100644 index b2bc841d058..00000000000 --- a/src/plugins/qnx/blackberryconfigurationmanager.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryconfigurationmanager.h" -#include "blackberrycertificate.h" -#include "blackberryapilevelconfiguration.h" -#include "blackberryruntimeconfiguration.h" - -#include "qnxtoolchain.h" -#include "qnxutils.h" - -#include <coreplugin/icore.h> - -#include <utils/persistentsettings.h> -#include <utils/hostosinfo.h> - -#include <projectexplorer/kit.h> -#include <projectexplorer/kitmanager.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/toolchainmanager.h> - -#include <qtsupport/qtversionmanager.h> -#include <qtsupport/qtkitinformation.h> - -#include <debugger/debuggerkitinformation.h> -#include <qmakeprojectmanager/qmakekitinformation.h> - -#include <QMessageBox> -#include <QFileInfo> -#include <QDebug> -#include <QDir> - -using namespace ProjectExplorer; - -namespace Qnx { -namespace Internal { - -BlackBerryConfigurationManager *BlackBerryConfigurationManager::m_instance = 0; - -namespace { -const QLatin1String SettingsGroup("BlackBerryConfiguration"); -const QLatin1String NDKLocationKey("NDKLocation"); // For 10.1 NDK support (< QTC 3.0) -const QLatin1String NDKEnvFileKey("NDKEnvFile"); -const QLatin1String ManualNDKsGroup("ManualNDKs"); -const QLatin1String ActiveNDKsGroup("ActiveNDKs"); -const QLatin1String DefaultConfigurationKey("DefaultConfiguration"); -const QLatin1String NewestConfigurationValue("Newest"); -const QLatin1String BBConfigsFileVersionKey("Version"); -const QLatin1String BBConfigDataKey("BBConfiguration."); -const QLatin1String BBConfigCountKey("BBConfiguration.Count"); -} - -static Utils::FileName bbConfigSettingsFileName() -{ - return Utils::FileName::fromString(Core::ICore::userResourcePath() + QLatin1String("/qnx/") - + QLatin1String(Constants::QNX_BLACKBERRY_CONFIGS_FILENAME)); -} - -template <class T> static bool sortConfigurationsByVersion(const T *a, const T *b) -{ - return a->version() > b->version(); -} - -BlackBerryConfigurationManager::BlackBerryConfigurationManager(QObject *parent) - : QObject(parent), - m_defaultConfiguration(0) -{ - m_writer = new Utils::PersistentSettingsWriter(bbConfigSettingsFileName(), - QLatin1String("BlackBerryConfigurations")); - connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings())); - m_instance = this; -} - -void BlackBerryConfigurationManager::saveConfigurations() -{ - QTC_ASSERT(m_writer, return); - QVariantMap data; - data.insert(QLatin1String(BBConfigsFileVersionKey), 1); - int count = 0; - foreach (BlackBerryApiLevelConfiguration *apiLevel, m_apiLevels) { - QVariantMap tmp = apiLevel->toMap(); - if (tmp.isEmpty()) - continue; - - data.insert(BBConfigDataKey + QString::number(count), tmp); - ++count; - } - - foreach (BlackBerryRuntimeConfiguration *runtime, m_runtimes) { - QVariantMap tmp = runtime->toMap(); - if (tmp.isEmpty()) - continue; - - data.insert(BBConfigDataKey + QString::number(count), tmp); - ++count; - } - - data.insert(QLatin1String(BBConfigCountKey), count); - - const QString newestConfig = (newestApiLevelEnabled()) - ? NewestConfigurationValue : defaultApiLevel()->envFile().toString(); - - //save default configuration - data.insert(QLatin1String(DefaultConfigurationKey), newestConfig); - - m_writer->save(data, Core::ICore::mainWindow()); -} - -void BlackBerryConfigurationManager::restoreConfigurations() -{ - Utils::PersistentSettingsReader reader; - if (!reader.load(bbConfigSettingsFileName())) - return; - - QVariantMap data = reader.restoreValues(); - - // load default configuration - const QString ndkEnvFile = data.value(DefaultConfigurationKey).toString(); - - // use newest API level - const bool useNewestConfiguration = (ndkEnvFile == NewestConfigurationValue); - - int count = data.value(BBConfigCountKey, 0).toInt(); - - for (int i = 0; i < count; ++i) { - const QString key = BBConfigDataKey + QString::number(i); - - if (!data.contains(key)) - continue; - - const QVariantMap dMap = data.value(key).toMap(); - const QString configurationType = - dMap.value(QLatin1String(Constants::QNX_BB_KEY_CONFIGURATION_TYPE)).toString(); - if (configurationType == QLatin1String(Constants::QNX_BB_RUNTIME_TYPE)) { - BlackBerryRuntimeConfiguration *runtime = new BlackBerryRuntimeConfiguration(dMap); - insertRuntimeByVersion(runtime); - } else if (configurationType == QLatin1String(Constants::QNX_BB_APILEVEL_TYPE) - || configurationType.isEmpty()) { // Backward compatibility - BlackBerryApiLevelConfiguration *apiLevel = new BlackBerryApiLevelConfiguration(dMap); - insertApiLevelByVersion(apiLevel); - - if (!useNewestConfiguration && (apiLevel->envFile().toString() == ndkEnvFile)) - setDefaultConfiguration(apiLevel); - } - } - - emit settingsChanged(); -} - -// Backward compatibility: Read existing entries in the ManualNDKsGroup -// and then remove the group since not used. -void BlackBerryConfigurationManager::loadManualConfigurations() -{ - QSettings *settings = Core::ICore::settings(); - - settings->beginGroup(SettingsGroup); - settings->beginGroup(ManualNDKsGroup); - - foreach (const QString &manualNdk, settings->childGroups()) { - settings->beginGroup(manualNdk); - QString ndkEnvPath = settings->value(NDKEnvFileKey).toString(); - // For 10.1 NDK support (< QTC 3.0): - // Since QTC 3.0 BBConfigurations are based on the bbndk-env file - // to support multiple targets per NDK - if (ndkEnvPath.isEmpty()) { - QString ndkPath = settings->value(NDKLocationKey).toString(); - ndkEnvPath = QnxUtils::envFilePath(ndkPath); - } - - BlackBerryApiLevelConfiguration *config = - new BlackBerryApiLevelConfiguration(Utils::FileName::fromString(ndkEnvPath)); - if (!addApiLevel(config)) - delete config; - - settings->endGroup(); - } - - settings->endGroup(); - settings->remove(ManualNDKsGroup); - settings->endGroup(); -} - -void BlackBerryConfigurationManager::loadAutoDetectedApiLevels() -{ - foreach (const ConfigInstallInformation &ndkInfo, QnxUtils::installedConfigs()) { - BlackBerryApiLevelConfiguration *config = new BlackBerryApiLevelConfiguration(ndkInfo); - if (!addApiLevel(config)) { - delete config; - } - } -} - -void BlackBerryConfigurationManager::loadAutoDetectedRuntimes() -{ - QRegExp regExp(QLatin1String("runtime_(\\d+)_(\\d+)_(\\d+)_(\\d+)")); - foreach (BlackBerryApiLevelConfiguration *apiLevel, m_apiLevels) { - QDir ndkDir(apiLevel->ndkPath()); - foreach (const QFileInfo& fi, ndkDir.entryInfoList(QDir::Dirs)) { - if (regExp.exactMatch(fi.baseName())) { - BlackBerryRuntimeConfiguration *runtime = - new BlackBerryRuntimeConfiguration(fi.absoluteFilePath()); - if (!addRuntime(runtime)) - delete runtime; - } - } - } -} - -void BlackBerryConfigurationManager::setDefaultConfiguration( - BlackBerryApiLevelConfiguration *config) -{ - if (config && !m_apiLevels.contains(config)) { - qWarning() << "BlackBerryConfigurationManager::setDefaultConfiguration -" - " configuration does not belong to this instance: " - << config->envFile().toString(); - return; - } - - m_defaultConfiguration = config; - emit settingsChanged(); -} - -bool BlackBerryConfigurationManager::newestApiLevelEnabled() const -{ - return !m_defaultConfiguration; -} - -void BlackBerryConfigurationManager::emitSettingsChanged() -{ - emit settingsChanged(); -} - -#ifdef WITH_TESTS -void BlackBerryConfigurationManager::initUnitTest() -{ - foreach (BlackBerryApiLevelConfiguration *apiLevel, m_apiLevels) - removeApiLevel(apiLevel); - - foreach (BlackBerryRuntimeConfiguration *runtime, m_runtimes) - removeRuntime(runtime); - - m_defaultConfiguration = 0; -} -#endif - -void BlackBerryConfigurationManager::setKitsAutoDetectionSource() -{ - foreach (Kit *kit, KitManager::kits()) { - if (kit->isAutoDetected() && - (DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_OS_TYPE) && - kit->autoDetectionSource().isEmpty()) { - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); - foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - if ((version && - (version->qmakeCommand() == config->qmake4BinaryFile() || version->qmakeCommand() == config->qmake5BinaryFile())) - && (SysRootKitInformation::sysRoot(kit) == config->sysRoot())) { - kit->setAutoDetectionSource(config->envFile().toString()); - // Set stickyness since not necessary saved for those kits - kit->setSticky(QtSupport::QtKitInformation::id(), true); - kit->setSticky(ToolChainKitInformation::id(), true); - kit->setSticky(DeviceTypeKitInformation::id(), true); - kit->setSticky(SysRootKitInformation::id(), true); - kit->setSticky(Debugger::DebuggerKitInformation::id(), true); - kit->setSticky(QmakeProjectManager::QmakeKitInformation::id(), true); - } - } - } - } -} - -void BlackBerryConfigurationManager::insertApiLevelByVersion( - BlackBerryApiLevelConfiguration *apiLevel) -{ - QList<BlackBerryApiLevelConfiguration *>::iterator it = - qLowerBound(m_apiLevels.begin(), m_apiLevels.end(), - apiLevel, sortConfigurationsByVersion<BlackBerryApiLevelConfiguration>); - m_apiLevels.insert(it, apiLevel); -} - -void BlackBerryConfigurationManager::insertRuntimeByVersion( - BlackBerryRuntimeConfiguration *runtime) -{ - QList<BlackBerryRuntimeConfiguration *>::iterator it = - qLowerBound(m_runtimes.begin(), m_runtimes.end(), - runtime, sortConfigurationsByVersion<BlackBerryRuntimeConfiguration>); - m_runtimes.insert(it, runtime); -} - -// Switch to QnxToolchain for exisintg configuration using GccToolChain -void BlackBerryConfigurationManager::checkToolChainConfiguration() -{ - foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - foreach (ToolChain *tc, ToolChainManager::toolChains()) { - if (tc->compilerCommand() == config->qccCompilerPath() - && !tc->id().startsWith(QLatin1String(Constants::QNX_TOOLCHAIN_ID))) { - if (config->isActive()) { - // reset - config->deactivate(); - config->activate(); - break; - } - } - } - } -} - -bool BlackBerryConfigurationManager::addApiLevel(BlackBerryApiLevelConfiguration *config) -{ - foreach (BlackBerryApiLevelConfiguration *c, m_apiLevels) { - if (config->envFile() == c->envFile()) { - if (!config->isAutoDetected()) - QMessageBox::warning(Core::ICore::mainWindow(), tr("NDK Already Known"), - tr("The NDK already has a configuration."), QMessageBox::Ok); - return false; - } - } - - if (config->isValid()) { - insertApiLevelByVersion(config); - emit settingsChanged(); - return true; - } - - return false; -} - -void BlackBerryConfigurationManager::removeApiLevel(BlackBerryApiLevelConfiguration *config) -{ - if (!config) - return; - - if (config->isActive()) - config->deactivate(); - - m_apiLevels.removeAll(config); - - if (defaultApiLevel() == config) - setDefaultConfiguration(0); - - delete config; - - emit settingsChanged(); -} - -bool BlackBerryConfigurationManager::addRuntime(BlackBerryRuntimeConfiguration *runtime) -{ - foreach (BlackBerryRuntimeConfiguration *rt, m_runtimes) { - if (runtime->path() == rt->path()) - return false; - } - - insertRuntimeByVersion(runtime); - return true; -} - -void BlackBerryConfigurationManager::removeRuntime(BlackBerryRuntimeConfiguration *runtime) -{ - if (!runtime) - return; - - m_runtimes.removeAll(runtime); - delete runtime; -} - -QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::apiLevels() const -{ - return m_apiLevels; -} - -QList<BlackBerryRuntimeConfiguration *> BlackBerryConfigurationManager::runtimes() const -{ - return m_runtimes; -} - -QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::manualApiLevels() const -{ - QList<BlackBerryApiLevelConfiguration*> manuals; - foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - if (!config->isAutoDetected()) - manuals << config; - } - - return manuals; -} - -QList<BlackBerryApiLevelConfiguration *> BlackBerryConfigurationManager::activeApiLevels() const -{ - QList<BlackBerryApiLevelConfiguration*> actives; - foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - if (config->isActive()) - actives << config; - } - - return actives; -} - -BlackBerryApiLevelConfiguration *BlackBerryConfigurationManager::apiLevelFromEnvFile( - const Utils::FileName &envFile) const -{ - if (envFile.isEmpty()) - return 0; - - foreach (BlackBerryApiLevelConfiguration *config, m_apiLevels) { - if (config->envFile() == envFile) - return config; - } - - return 0; -} - -BlackBerryRuntimeConfiguration *BlackBerryConfigurationManager::runtimeFromFilePath( - const QString &path) -{ - foreach (BlackBerryRuntimeConfiguration *runtime, m_runtimes) { - if (runtime->path() == path) - return runtime; - } - - return 0; -} - -BlackBerryApiLevelConfiguration *BlackBerryConfigurationManager::defaultApiLevel() const -{ - if (m_apiLevels.isEmpty()) - return 0; - - // !m_defaultConfiguration means use newest configuration - if (!m_defaultConfiguration) - return m_apiLevels.first(); - - return m_defaultConfiguration; -} - -QList<Utils::EnvironmentItem> BlackBerryConfigurationManager::defaultConfigurationEnv() const -{ - const BlackBerryApiLevelConfiguration *config = defaultApiLevel(); - - if (config) - return config->qnxEnv(); - - return QList<Utils::EnvironmentItem>(); -} - -void BlackBerryConfigurationManager::loadAutoDetectedConfigurations(QFlags<ConfigurationType> types) -{ - if (types.testFlag(ApiLevel)) - loadAutoDetectedApiLevels(); - if (types.testFlag(Runtime)) - loadAutoDetectedRuntimes(); - emit settingsChanged(); -} - -void BlackBerryConfigurationManager::loadSettings() -{ - restoreConfigurations(); - // For backward compatibility - loadManualConfigurations(); - loadAutoDetectedApiLevels(); - loadAutoDetectedRuntimes(); - checkToolChainConfiguration(); - - // Backward compatibility: Set kit's auto detection source - // for existing BlackBerry kits that do not have it set yet. - setKitsAutoDetectionSource(); - - emit settingsLoaded(); - emit settingsChanged(); -} - -void BlackBerryConfigurationManager::saveSettings() -{ - saveConfigurations(); -} - -BlackBerryConfigurationManager *BlackBerryConfigurationManager::instance() -{ - return m_instance; -} - -BlackBerryConfigurationManager::~BlackBerryConfigurationManager() -{ - m_instance = 0; - qDeleteAll(m_apiLevels); - qDeleteAll(m_runtimes); - delete m_writer; -} - -QString BlackBerryConfigurationManager::barsignerCskPath() const -{ - return QnxUtils::bbDataDirPath() + QLatin1String("/barsigner.csk"); -} - -QString BlackBerryConfigurationManager::idTokenPath() const -{ - return QnxUtils::bbDataDirPath() + QLatin1String("/bbidtoken.csk"); -} - -QString BlackBerryConfigurationManager::barsignerDbPath() const -{ - return QnxUtils::bbDataDirPath() + QLatin1String("/barsigner.db"); -} - -QString BlackBerryConfigurationManager::defaultKeystorePath() const -{ - return QnxUtils::bbDataDirPath() + QLatin1String("/author.p12"); -} - -QString BlackBerryConfigurationManager::defaultDebugTokenPath() const -{ - return QnxUtils::bbDataDirPath() + QLatin1String("/debugtoken.bar"); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryconfigurationmanager.h b/src/plugins/qnx/blackberryconfigurationmanager.h deleted file mode 100644 index 9088a7bea95..00000000000 --- a/src/plugins/qnx/blackberryconfigurationmanager.h +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYCONFIGURATIONMANAGER_H -#define BLACKBERRYCONFIGURATIONMANAGER_H - -#include <utils/environment.h> -#include <utils/fileutils.h> - -#include <QSettings> -#include <QObject> - -namespace Utils { class PersistentSettingsWriter; } - -namespace Qnx { -namespace Internal { - -class BlackBerryApiLevelConfiguration; -class BlackBerryRuntimeConfiguration; -class QnxPlugin; - -class BlackBerryConfigurationManager : public QObject -{ - Q_OBJECT -public: - enum ConfigurationType { - ApiLevel = 0x01, - Runtime = 0x02 - }; - Q_DECLARE_FLAGS(ConfigurationTypes, ConfigurationType) - - static BlackBerryConfigurationManager *instance(); - ~BlackBerryConfigurationManager(); - bool addApiLevel(BlackBerryApiLevelConfiguration *config); - void removeApiLevel(BlackBerryApiLevelConfiguration *config); - bool addRuntime(BlackBerryRuntimeConfiguration *runtime); - void removeRuntime(BlackBerryRuntimeConfiguration *runtime); - QList<BlackBerryApiLevelConfiguration*> apiLevels() const; - QList<BlackBerryRuntimeConfiguration *> runtimes() const; - QList<BlackBerryApiLevelConfiguration*> manualApiLevels() const; - QList<BlackBerryApiLevelConfiguration *> activeApiLevels() const; - BlackBerryApiLevelConfiguration *apiLevelFromEnvFile(const Utils::FileName &envFile) const; - BlackBerryRuntimeConfiguration *runtimeFromFilePath(const QString &path); - BlackBerryApiLevelConfiguration *defaultApiLevel() const; - - QString barsignerCskPath() const; - QString idTokenPath() const; - QString barsignerDbPath() const; - QString defaultKeystorePath() const; - QString defaultDebugTokenPath() const; - - // returns the environment for the default API level - QList<Utils::EnvironmentItem> defaultConfigurationEnv() const; - - void loadAutoDetectedConfigurations(QFlags<ConfigurationType> types); - void setDefaultConfiguration(BlackBerryApiLevelConfiguration *config); - - bool newestApiLevelEnabled() const; - - void emitSettingsChanged(); - -#ifdef WITH_TESTS - void initUnitTest(); -#endif - -public slots: - void loadSettings(); - void saveSettings(); - void checkToolChainConfiguration(); - -signals: - void settingsLoaded(); - void settingsChanged(); - -private: - BlackBerryConfigurationManager(QObject *parent = 0); - - static BlackBerryConfigurationManager *m_instance; - - QList<BlackBerryApiLevelConfiguration*> m_apiLevels; - QList<BlackBerryRuntimeConfiguration*> m_runtimes; - - BlackBerryApiLevelConfiguration *m_defaultConfiguration; - - Utils::PersistentSettingsWriter *m_writer; - - void saveConfigurations(); - void restoreConfigurations(); - - void loadAutoDetectedApiLevels(); - void loadAutoDetectedRuntimes(); - - void loadManualConfigurations(); - void setKitsAutoDetectionSource(); - - void insertApiLevelByVersion(BlackBerryApiLevelConfiguration* apiLevel); - void insertRuntimeByVersion(BlackBerryRuntimeConfiguration* runtime); - - friend class QnxPlugin; -}; - -} // namespace Internal -} // namespace Qnx - -Q_DECLARE_OPERATORS_FOR_FLAGS(Qnx::Internal::BlackBerryConfigurationManager::ConfigurationTypes) - -#endif // BLACKBERRYCONFIGURATIONMANAGER_H diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.cpp b/src/plugins/qnx/blackberrycreatecertificatedialog.cpp deleted file mode 100644 index 8f1708a5c3c..00000000000 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycreatecertificatedialog.h" -#include "blackberrycertificate.h" -#include "blackberryconfigurationmanager.h" -#include "ui_blackberrycreatecertificatedialog.h" - -#include <QPushButton> -#include <QDir> -#include <QDebug> -#include <QMessageBox> - -namespace Qnx { -namespace Internal { - -BlackBerryCreateCertificateDialog::BlackBerryCreateCertificateDialog( - QWidget *parent, Qt::WindowFlags f) : - QDialog(parent, f), - m_ui(new Ui_BlackBerryCreateCertificateDialog), - m_certificate(0) -{ - m_ui->setupUi(this); - m_ui->progressBar->hide(); - m_ui->status->clear(); - - m_cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); - Q_ASSERT(m_cancelButton); - - m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); - m_okButton->setEnabled(false); - - connect(m_cancelButton, SIGNAL(clicked()), - this, SLOT(reject())); - connect(m_okButton, SIGNAL(clicked()), - this, SLOT(createCertificate())); - connect(m_ui->author, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->password, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->password2, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->showPassword, SIGNAL(stateChanged(int)), - this, SLOT(checkBoxChanged(int))); -} - -QString BlackBerryCreateCertificateDialog::author() const -{ - return m_ui->author->text(); -} - -QString BlackBerryCreateCertificateDialog::certPath() const -{ - return BlackBerryConfigurationManager::instance()->defaultKeystorePath(); -} - -QString BlackBerryCreateCertificateDialog::keystorePassword() const -{ - return m_ui->password->text(); -} - -BlackBerryCertificate * BlackBerryCreateCertificateDialog::certificate() const -{ - return m_certificate; -} - -void BlackBerryCreateCertificateDialog::validate() -{ - if (m_ui->author->text().isEmpty() - || m_ui->password->text().isEmpty() - || m_ui->password2->text().isEmpty()) { - m_ui->status->clear(); - m_okButton->setEnabled(false); - return; - } - - QFileInfo fileInfo(certPath()); - - if (!fileInfo.dir().exists()) { - m_ui->status->setText(tr("Base directory does not exist.")); - m_okButton->setEnabled(false); - return; - } - - if (m_ui->password->text() != m_ui->password2->text()) { - m_ui->status->setText(tr("The entered passwords do not match.")); - m_okButton->setEnabled(false); - return; - } - - if (m_ui->password->text().size() < 6) { - m_ui->status->setText(tr("Password must be at least 6 characters long.")); - m_okButton->setEnabled(false); - return; - } - - m_ui->status->clear(); - m_okButton->setEnabled(true); -} - -void BlackBerryCreateCertificateDialog::createCertificate() -{ - setBusy(true); - - QFile file(certPath()); - - if (file.exists()) { - const int result = QMessageBox::question(this, tr("Are you sure?"), - tr("The file \"%1\" will be overwritten. Do you want to proceed?") - .arg(file.fileName()), QMessageBox::Yes | QMessageBox::No); - - if (result & QMessageBox::Yes) { - file.remove(); - } else { - setBusy(false); - return; - } - } - - m_certificate = new BlackBerryCertificate(certPath(), - author(), keystorePassword()); - - connect(m_certificate, SIGNAL(finished(int)), this, SLOT(certificateCreated(int))); - m_certificate->store(); -} - -void BlackBerryCreateCertificateDialog::checkBoxChanged(int state) -{ - if (state == Qt::Checked) { - m_ui->password->setEchoMode(QLineEdit::Normal); - m_ui->password2->setEchoMode(QLineEdit::Normal); - } else { - m_ui->password->setEchoMode(QLineEdit::Password); - m_ui->password2->setEchoMode(QLineEdit::Password); - } -} - -void BlackBerryCreateCertificateDialog::certificateCreated(int status) -{ - QString errorMessage; - - switch (status) { - case BlackBerryCertificate::Success: - accept(); - return; - case BlackBerryCertificate::Busy: - errorMessage = tr("The blackberry-keytool process is already running."); - break; - case BlackBerryCertificate::WrongPassword: - errorMessage = tr("The password entered is invalid."); - break; - case BlackBerryCertificate::PasswordTooSmall: - errorMessage = tr("The password entered is too short."); - break; - case BlackBerryCertificate::InvalidOutputFormat: - errorMessage = tr("Invalid output format."); - break; - case BlackBerryCertificate::Error: - default: - errorMessage = tr("An unknown error occurred."); - break; - } - - m_certificate->deleteLater(); - m_certificate = 0; - QMessageBox::critical(this, tr("Error"), errorMessage); - - reject(); -} - -void BlackBerryCreateCertificateDialog::setBusy(bool busy) -{ - m_okButton->setEnabled(!busy); - m_cancelButton->setEnabled(!busy); - m_ui->author->setEnabled(!busy); - m_ui->password->setEnabled(!busy); - m_ui->password2->setEnabled(!busy); - m_ui->showPassword->setEnabled(!busy); - m_ui->progressBar->setVisible(busy); - - if (busy) - m_ui->status->setText(tr("Please be patient...")); - else - m_ui->status->clear(); -} - -} -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.h b/src/plugins/qnx/blackberrycreatecertificatedialog.h deleted file mode 100644 index e23039cbc1c..00000000000 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.h +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCREATECERTIFICATEDIALOG_H -#define QNX_INTERNAL_BLACKBERRYCREATECERTIFICATEDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QPushButton; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryCreateCertificateDialog; -class BlackBerryCertificate; - -class BlackBerryCreateCertificateDialog : public QDialog -{ -Q_OBJECT - -public: - explicit BlackBerryCreateCertificateDialog(QWidget *parent = 0, - Qt::WindowFlags f = 0); - - QString author() const; - QString certPath() const; - QString keystorePassword() const; - - BlackBerryCertificate *certificate() const; - -private slots: - void validate(); - void createCertificate(); - void checkBoxChanged(int state); - void certificateCreated(int status); - -private: - void setBusy(bool busy); - - Ui_BlackBerryCreateCertificateDialog *m_ui; - - BlackBerryCertificate *m_certificate; - - QPushButton *m_cancelButton; - QPushButton *m_okButton; -}; - -} -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCREATECERTIFICATEDIALOG_H diff --git a/src/plugins/qnx/blackberrycreatecertificatedialog.ui b/src/plugins/qnx/blackberrycreatecertificatedialog.ui deleted file mode 100644 index 02369458c17..00000000000 --- a/src/plugins/qnx/blackberrycreatecertificatedialog.ui +++ /dev/null @@ -1,112 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryCreateCertificateDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerryCreateCertificateDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>495</width> - <height>191</height> - </rect> - </property> - <property name="windowTitle"> - <string>Create Certificate</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Author:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="author"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="password"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Confirm password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="password2"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QCheckBox" name="showPassword"> - <property name="text"> - <string>Show password</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="status"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Status</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>-1</number> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrycreatepackagestep.cpp b/src/plugins/qnx/blackberrycreatepackagestep.cpp deleted file mode 100644 index da34a85afc1..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestep.cpp +++ /dev/null @@ -1,576 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycreatepackagestep.h" - -#include "qnxconstants.h" -#include "blackberrycreatepackagestepconfigwidget.h" -#include "blackberrydeployconfiguration.h" -#include "qnxutils.h" -#include "bardescriptordocument.h" -#include "blackberryqtversion.h" -#include "blackberrydeviceconfiguration.h" -#include "blackberrydeployinformation.h" -#include "blackberrysigningpasswordsdialog.h" -#include "bardescriptordocument.h" - -#include <debugger/debuggerrunconfigurationaspect.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> -#include <projectexplorer/runconfiguration.h> -#include <qmakeprojectmanager/qmakebuildconfiguration.h> -#include <qmakeprojectmanager/qmakenodes.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <qtsupport/qtkitinformation.h> -#include <utils/qtcassert.h> -#include <coreplugin/documentmanager.h> -#include <coreplugin/icore.h> - -#include <QMessageBox> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char PACKAGER_CMD[] = "blackberry-nativepackager"; - -const char PACKAGE_MODE_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.PackageMode"; -const char CSK_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.CskPassword"; -const char KEYSTORE_PASSWORD_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.KeystorePassword"; -const char SAVE_PASSWORDS_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.SavePasswords"; -const char BUNDLE_MODE_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.BundleMode"; -const char QT_LIBRARY_PATH_KEY[] = "Qt4ProjectManager.BlackBerryCreatePackageStep.QtLibraryPath"; -} - -static void prependOrSetQtEnvironment(Utils::Environment &env, - const QString &key, - const QString &value, - bool &updated) -{ - const QString currentValue = env.value(key); - const QString newValue = value + QLatin1String(":$") + key; - if (!currentValue.isEmpty()) { - if (currentValue == newValue) - return; - else - env.unset(key); - } - - env.prependOrSet(key, newValue); - updated = true; -} - -static void setQtEnvironment(Utils::Environment &env, const QString &qtPath, - bool &updated, bool isQt5) -{ - prependOrSetQtEnvironment(env, QLatin1String("LD_LIBRARY_PATH"), - QString::fromLatin1("%1/lib").arg(qtPath), - updated); - prependOrSetQtEnvironment(env, QLatin1String("QML_IMPORT_PATH"), - QString::fromLatin1("%1/imports").arg(qtPath), - updated); - prependOrSetQtEnvironment(env, QLatin1String("QT_PLUGIN_PATH"), - QString::fromLatin1("%1/plugins").arg(qtPath), - updated); - if (isQt5) { - prependOrSetQtEnvironment(env, QLatin1String("QML2_IMPORT_PATH"), - QString::fromLatin1("%1/qml").arg(qtPath), - updated); - } -} - -static bool removeQtAssets(BarDescriptorAssetList &assetList) -{ - bool assetsRemoved = false; - foreach (const BarDescriptorAsset &a, assetList) { - if (a.destination == QLatin1String("runtime/qt/lib") || - a.destination == QLatin1String("runtime/qt/plugins") || - a.destination == QLatin1String("runtime/qt/imports") || - a.destination == QLatin1String("runtime/qt/qml")) { - assetList.removeOne(a); - assetsRemoved = true; - } - } - - return assetsRemoved; -} - -static bool addQtAssets(BarDescriptorAssetList &assetList, BlackBerryQtVersion *qtVersion) -{ - const bool isQt5 = qtVersion->qtVersion().majorVersion == 5; - bool libAssetExists = false; - bool pluginAssetExists = false; - bool importAssetExists = false; - bool qmlAssetExists = false; - const QString qtInstallLibsPath = - qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_LIBS")); - const QString qtInstallPluginPath = - qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_PLUGINS")); - const QString qtInstallImportsPath = - qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_IMPORTS")); - const QString qtInstallQmlPath = - qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_QML")); - foreach (const BarDescriptorAsset &a, assetList) { - // TODO: Also check if the asset's source is correct - if (a.destination == QLatin1String("runtime/qt/lib")) { - if (a.source == qtInstallLibsPath) - libAssetExists = true; - else - assetList.removeOne(a); - } else if (a.destination == QLatin1String("runtime/qt/plugins")) { - if (a.source == qtInstallPluginPath) - pluginAssetExists = true; - else - assetList.removeOne(a); - } else if (a.destination == QLatin1String("runtime/qt/imports")) { - if (a.source == qtInstallImportsPath) - importAssetExists = true; - else - assetList.removeOne(a); - } else if (isQt5 && a.destination == QLatin1String("runtime/qt/qml")) { - if (a.destination == qtInstallQmlPath) - qmlAssetExists = true; - else - assetList.removeOne(a); - } - } - - // return false if all assets already exist - if (libAssetExists && pluginAssetExists && importAssetExists) { - if (!isQt5 || qmlAssetExists) - return false; - } - - QList<QPair<QString, QString> > qtFolders; - qtFolders.append(qMakePair(QString::fromLatin1("runtime/qt/lib"), - qtInstallLibsPath)); - qtFolders.append(qMakePair(QString::fromLatin1("runtime/qt/plugins"), - qtInstallPluginPath)); - qtFolders.append(qMakePair(QString::fromLatin1("runtime/qt/imports"), - qtInstallImportsPath)); - - if (isQt5) { - qtFolders.append(qMakePair(QString::fromLatin1("runtime/qt/qml"), - qtInstallQmlPath)); - } - - for (QList<QPair<QString, QString> >::const_iterator it = qtFolders.constBegin(); - it != qtFolders.constEnd(); ++it) { - const QString target = it->first; - const QString qtFolder = it->second; - if (QFileInfo::exists(qtFolder)) { - BarDescriptorAsset asset; - asset.source = qtFolder; - asset.destination = target; - asset.entry = false; - assetList << asset; - } - } - - return true; -} - -BlackBerryCreatePackageStep::BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl) - : BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_CREATE_PACKAGE_BS_ID)) -{ - ctor(); -} - -BlackBerryCreatePackageStep::BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl, - BlackBerryCreatePackageStep *bs) - : BlackBerryAbstractDeployStep(bsl, bs) -{ - ctor(); -} - -void BlackBerryCreatePackageStep::ctor() -{ - setDisplayName(tr("Create packages")); - - m_packageMode = DevelopmentMode; - m_bundleMode = PreInstalledQt; - m_qtLibraryPath = QLatin1String("qt"); -} - -bool BlackBerryCreatePackageStep::init() -{ - if (!BlackBerryAbstractDeployStep::init()) - return false; - - const Utils::FileName packageCmd = - target()->activeBuildConfiguration()->environment().searchInPath(QLatin1String(PACKAGER_CMD)); - if (packageCmd.isEmpty()) { - raiseError(tr("Could not find packager command \"%1\" in the build environment.") - .arg(QLatin1String(PACKAGER_CMD))); - return false; - } - - BlackBerryDeployConfiguration *deployConfig = qobject_cast<BlackBerryDeployConfiguration *>(deployConfiguration()); - QTC_ASSERT(deployConfig, return false); - - QList<BarPackageDeployInformation> packagesToDeploy = deployConfig->deploymentInfo()->enabledPackages(); - if (packagesToDeploy.isEmpty()) { - raiseError(tr("No packages enabled for deployment.")); - return false; - } - - foreach (const BarPackageDeployInformation &info, packagesToDeploy) { - if (info.appDescriptorPath().isEmpty()) { - raiseError(tr("BAR application descriptor file not specified. Check deployment settings.")); - return false; - } - - if (info.packagePath().isEmpty()) { - raiseError(tr("No package specified. Check deployment settings.")); - return false; - } - - const QString buildDir = info.packagePath().toFileInfo().absolutePath(); - QDir dir(buildDir); - if (!dir.exists()) { - if (!dir.mkpath(buildDir)) { - raiseError(tr("Could not create build directory \"%1\".").arg(buildDir)); - return false; - } - } - - const Utils::FileName appDescriptorPath = info.appDescriptorPath(); - if (!doUpdateAppDescriptorFile(appDescriptorPath, PlaceHolders)) - // If there is an error, prepareAppDescriptorFile() will raise it - return false; - - QStringList args; - if (m_packageMode == DevelopmentMode) { - args << QLatin1String("-devMode"); - if (!debugToken().isEmpty()) - args << QLatin1String("-debugToken") << QnxUtils::addQuotes(QDir::toNativeSeparators(debugToken())); - } else if (m_packageMode == SigningPackageMode) { - if (m_cskPassword.isEmpty() || m_keystorePassword.isEmpty()) { - BlackBerrySigningPasswordsDialog dlg; - dlg.setCskPassword(m_cskPassword); - dlg.setStorePassword(m_keystorePassword); - if (dlg.exec() == QDialog::Rejected) { - raiseError(tr("Missing passwords for signing packages.")); - return false; - } - - m_cskPassword = dlg.cskPassword(); - m_keystorePassword = dlg.storePassword(); - - emit cskPasswordChanged(m_cskPassword); - emit keystorePasswordChanged(m_keystorePassword); - } - args << QLatin1String("-sign"); - args << QLatin1String("-cskpass"); - args << m_cskPassword; - args << QLatin1String("-storepass"); - args << m_keystorePassword; - } - args << QLatin1String("-package") << QnxUtils::addQuotes(info.packagePath().toUserOutput()); - args << QnxUtils::addQuotes(appDescriptorPath.toUserOutput()); - - addCommand(packageCmd.toString(), args); - } - - return true; -} - -ProjectExplorer::BuildStepConfigWidget *BlackBerryCreatePackageStep::createConfigWidget() -{ - BlackBerryCreatePackageStepConfigWidget *config = new BlackBerryCreatePackageStepConfigWidget(this); - connect(config, SIGNAL(bundleModeChanged()), this, SLOT(updateAppDescriptorFile())); - return config; -} - -QString BlackBerryCreatePackageStep::debugToken() const -{ - BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(target()->kit()); - if (!device) - return QString(); - - return device->debugToken(); -} - -bool BlackBerryCreatePackageStep::fromMap(const QVariantMap &map) -{ - m_packageMode = static_cast<PackageMode>(map.value(QLatin1String(PACKAGE_MODE_KEY), - DevelopmentMode).toInt()); - m_savePasswords = map.value(QLatin1String(SAVE_PASSWORDS_KEY), false).toBool(); - if (m_savePasswords) { - m_cskPassword = map.value(QLatin1String(CSK_PASSWORD_KEY)).toString(); - m_keystorePassword = map.value(QLatin1String(KEYSTORE_PASSWORD_KEY)).toString(); - } - m_bundleMode = static_cast<BundleMode>(map.value(QLatin1String(BUNDLE_MODE_KEY), - PreInstalledQt).toInt()); - m_qtLibraryPath = map.value(QLatin1String(QT_LIBRARY_PATH_KEY), - QLatin1String("qt")).toString(); - return BlackBerryAbstractDeployStep::fromMap(map); -} - -QVariantMap BlackBerryCreatePackageStep::toMap() const -{ - QVariantMap map = BlackBerryAbstractDeployStep::toMap(); - map.insert(QLatin1String(PACKAGE_MODE_KEY), m_packageMode); - map.insert(QLatin1String(SAVE_PASSWORDS_KEY), m_savePasswords); - if (m_savePasswords) { - map.insert(QLatin1String(CSK_PASSWORD_KEY), m_cskPassword); - map.insert(QLatin1String(KEYSTORE_PASSWORD_KEY), m_keystorePassword); - } - map.insert(QLatin1String(BUNDLE_MODE_KEY), m_bundleMode); - map.insert(QLatin1String(QT_LIBRARY_PATH_KEY), m_qtLibraryPath); - return map; -} - -BlackBerryCreatePackageStep::PackageMode BlackBerryCreatePackageStep::packageMode() const -{ - return m_packageMode; -} - -QString BlackBerryCreatePackageStep::cskPassword() const -{ - return m_cskPassword; -} - -QString BlackBerryCreatePackageStep::keystorePassword() const -{ - return m_keystorePassword; -} - -bool BlackBerryCreatePackageStep::savePasswords() const -{ - return m_savePasswords; -} - -BlackBerryCreatePackageStep::BundleMode BlackBerryCreatePackageStep::bundleMode() const -{ - return m_bundleMode; -} - -QString BlackBerryCreatePackageStep::qtLibraryPath() const -{ - return m_qtLibraryPath; -} - -QString BlackBerryCreatePackageStep::fullDeployedQtLibraryPath() const -{ - return QLatin1String(Constants::QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH) + m_qtLibraryPath; -} - -void BlackBerryCreatePackageStep::setPackageMode(BlackBerryCreatePackageStep::PackageMode packageMode) -{ - m_packageMode = packageMode; -} - -void BlackBerryCreatePackageStep::setCskPassword(const QString &cskPassword) -{ - m_cskPassword = cskPassword; -} - -void BlackBerryCreatePackageStep::setKeystorePassword(const QString &storePassword) -{ - m_keystorePassword = storePassword; -} - -void BlackBerryCreatePackageStep::setSavePasswords(bool savePasswords) -{ - m_savePasswords = savePasswords; -} - -void BlackBerryCreatePackageStep::setBundleMode(BlackBerryCreatePackageStep::BundleMode bundleMode) -{ - m_bundleMode = bundleMode; -} - -void BlackBerryCreatePackageStep::setQtLibraryPath(const QString &qtLibraryPath) -{ - m_qtLibraryPath = qtLibraryPath; -} - -void BlackBerryCreatePackageStep::updateAppDescriptorFile() -{ - BlackBerryDeployConfiguration *deployConfig = qobject_cast<BlackBerryDeployConfiguration *>(deployConfiguration()); - QTC_ASSERT(deployConfig, return); - - QList<BarPackageDeployInformation> packagesToDeploy = deployConfig->deploymentInfo()->enabledPackages(); - if (packagesToDeploy.isEmpty()) - return; - - foreach (const BarPackageDeployInformation &info, packagesToDeploy) - doUpdateAppDescriptorFile(info.appDescriptorPath(), QtEnvironment); -} - -bool BlackBerryCreatePackageStep::doUpdateAppDescriptorFile(const Utils::FileName &appDescriptorPath, - QFlags<EditMode> types, - bool skipConfirmation) -{ - Core::FileChangeBlocker fb(appDescriptorPath.toString()); - BarDescriptorDocument doc; - QString errorString; - if (!doc.open(&errorString, appDescriptorPath.toString())) { - raiseError(tr("Error opening BAR application descriptor file \"%1\" - %2") - .arg(appDescriptorPath.toUserOutput()) - .arg(errorString)); - return false; - } - - BarDescriptorAssetList assetList = doc.value(BarDescriptorDocument::asset) - .value<BarDescriptorAssetList>(); - bool updated = false; - if (types.testFlag(PlaceHolders)) { - - foreach (const BarDescriptorAsset &a, assetList) { - if (a.source.contains(QLatin1String("%SRC_DIR%"))) { - // Keep backward compatibility with older templates - QHash<QString, QString> placeHoldersHash; - placeHoldersHash[QLatin1String("%SRC_DIR%")] = QString(); - doc.expandPlaceHolders(placeHoldersHash); - updated = true; - } - - // Update the entry point source path to make use of the BUILD_DIR variable - // if not set - if (a.entry) { - BarDescriptorAsset asset = a; - if (asset.source.contains(QLatin1String("${BUILD_DIR}/"))) - break; - asset.source = QLatin1String("${BUILD_DIR}/") + asset.destination; - assetList.removeOne(a); - assetList << asset; - updated = true; - break; - } - } - } - - if (types.testFlag(QtEnvironment)) { - bool environmentUpdated = false; - bool assetsUpdated = false; - // Set up correct environment depending on using bundled/pre-installed Qt - QList<Utils::EnvironmentItem> envItems = - doc.value(BarDescriptorDocument::env).value<QList<Utils::EnvironmentItem> >(); - Utils::Environment env(Utils::EnvironmentItem::toStringList(envItems), Utils::OsTypeOtherUnix); - BlackBerryQtVersion *qtVersion = dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(target()->kit())); - const bool isQt5 = qtVersion->qtVersion().majorVersion == 5; - if (!qtVersion) { - raiseError(tr("Error preparing BAR application descriptor file.")); - return false; - } - - if (m_packageMode == SigningPackageMode - || (m_packageMode == DevelopmentMode && m_bundleMode == PreInstalledQt)) { - QtSupport::QtVersionNumber versionNumber = qtVersion->qtVersion(); - setQtEnvironment(env, QString::fromLatin1("/usr/lib/qt%1").arg(versionNumber.majorVersion), - environmentUpdated, isQt5); - // remove qt assets if existing since not needed - assetsUpdated = removeQtAssets(assetList); - } else if (m_packageMode == DevelopmentMode && m_bundleMode == BundleQt) { - assetsUpdated = addQtAssets(assetList, qtVersion); - // TODO: Check for every Qt environment if the corresponding - // assets exist for broken/internal builds(?) - setQtEnvironment(env, QLatin1String("app/native/runtime/qt"), - environmentUpdated, isQt5); - } else if (m_packageMode == DevelopmentMode && m_bundleMode == DeployedQt) { - setQtEnvironment(env, fullDeployedQtLibraryPath(), - environmentUpdated, isQt5); - // remove qt assets if existing since not needed - assetsUpdated = removeQtAssets(assetList); - } - - if (environmentUpdated) { - QMessageBox::StandardButton answer = QMessageBox::Yes; - if (!skipConfirmation) { - QString confirmationText = tr("In order to link to the correct Qt library specified in the deployment settings " - "Qt Creator needs to update the Qt environment variables " - "in the BAR application file as follows:\n\n" - "<env var=\"LD_LIBRARY_PATH\" value=\"%1\"/>\n" - "<env var=\"QT_PLUGIN_PATH\" value=\"%2\"/>\n" - "<env var=\"QML_IMPORT_PATH\" value=\"%3\"/>\n") - .arg(env.value(QLatin1String("LD_LIBRARY_PATH")), - env.value(QLatin1String("QT_PLUGIN_PATH")), - env.value(QLatin1String("QML_IMPORT_PATH"))); - - if (isQt5) - confirmationText.append(QString::fromLatin1("<env var=\"QML2_IMPORT_PATH\" value=\"%1\"/>\n") - .arg(env.value(QLatin1String("QML2_IMPORT_PATH")))); - - confirmationText.append(tr("\nDo you want to update it?")); - answer = QMessageBox::question(Core::ICore::mainWindow(), tr("Confirmation"), - confirmationText, - QMessageBox::Yes | QMessageBox::No); - } - - if (answer == QMessageBox::Yes) { - QVariant envVar; - envVar.setValue(Utils::EnvironmentItem::fromStringList(env.toStringList())); - doc.setValue(BarDescriptorDocument::env, envVar); - updated = true; - } - } - - if (assetsUpdated) { - doc.setValue(BarDescriptorDocument::asset, QVariant::fromValue(assetList)); - updated = true; - } - } - - // Skip unnecessary saving - if (!updated) - return true; - - if (!doc.save(&errorString)) { - raiseError(tr("Error saving BAR application descriptor file \"%1\" - %2") - .arg(appDescriptorPath.toUserOutput()) - .arg(errorString)); - return false; - } - - return true; -} - -void BlackBerryCreatePackageStep::processStarted(const ProjectExplorer::ProcessParameters ¶ms) -{ - if (m_packageMode == SigningPackageMode) { - QString arguments = params.prettyArguments(); - - const QString cskPasswordLine = QLatin1String(" -cskpass ") + m_cskPassword; - const QString hiddenCskPasswordLine = QLatin1String(" -cskpass <hidden>"); - arguments.replace(cskPasswordLine, hiddenCskPasswordLine); - - const QString storePasswordLine = QLatin1String(" -storepass ") + m_keystorePassword; - const QString hiddenStorePasswordLine = QLatin1String(" -storepass <hidden>"); - arguments.replace(storePasswordLine, hiddenStorePasswordLine); - - emitOutputInfo(params, arguments); - } else { - BlackBerryAbstractDeployStep::processStarted(params); - } -} diff --git a/src/plugins/qnx/blackberrycreatepackagestep.h b/src/plugins/qnx/blackberrycreatepackagestep.h deleted file mode 100644 index 721d48cb8b4..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestep.h +++ /dev/null @@ -1,128 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEP_H -#define QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEP_H - -#include "blackberryabstractdeploystep.h" - -QT_BEGIN_NAMESPACE -class QFile; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryCreatePackageStep : public BlackBerryAbstractDeployStep -{ - Q_OBJECT - friend class BlackBerryCreatePackageStepFactory; - friend class BarDescriptorFileNodeManager; - -public: - enum PackageMode { - SigningPackageMode, - DevelopmentMode - }; - - enum BundleMode { - PreInstalledQt, - BundleQt, - DeployedQt - }; - - enum EditMode { - PlaceHolders = 0x01, - QtEnvironment = 0x02 - }; - Q_DECLARE_FLAGS(EditModes, EditMode) - - explicit BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl); - - bool init(); - ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - - QString debugToken() const; - - bool fromMap(const QVariantMap &map); - QVariantMap toMap() const; - - PackageMode packageMode() const; - QString cskPassword() const; - QString keystorePassword() const; - bool savePasswords() const; - - BundleMode bundleMode() const; - QString qtLibraryPath() const; - -public slots: - void setPackageMode(PackageMode packageMode); - void setCskPassword(const QString &cskPassword); - void setKeystorePassword(const QString &keystorePassword); - void setSavePasswords(bool savePasswords); - - void setBundleMode(BundleMode bundleMode); - void setQtLibraryPath(const QString &qtLibraryPath); - void updateAppDescriptorFile(); - -signals: - void cskPasswordChanged(QString); - void keystorePasswordChanged(QString); - -protected: - BlackBerryCreatePackageStep(ProjectExplorer::BuildStepList *bsl, BlackBerryCreatePackageStep *bs); - - void processStarted(const ProjectExplorer::ProcessParameters ¶ms); - -private: - void ctor(); - - bool doUpdateAppDescriptorFile(const Utils::FileName &appDescriptorPath, - QFlags<EditMode> types, - bool skipConfirmation = false); - - QString fullDeployedQtLibraryPath() const; - - PackageMode m_packageMode; - QString m_cskPassword; - QString m_keystorePassword; - bool m_savePasswords; - BundleMode m_bundleMode; - QString m_qtLibraryPath; -}; - -} // namespace Internal -} // namespace Qnx - -Q_DECLARE_OPERATORS_FOR_FLAGS(Qnx::Internal::BlackBerryCreatePackageStep::EditModes) - -#endif // QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEP_H diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp deleted file mode 100644 index 6b6e215df2b..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycreatepackagestepconfigwidget.h" -#include "ui_blackberrycreatepackagestepconfigwidget.h" -#include "blackberrycreatepackagestep.h" -#include "qnxdeployqtlibrariesdialog.h" - -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/target.h> -#include <qtsupport/qtkitinformation.h> -#include <utils/qtcassert.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryCreatePackageStepConfigWidget::BlackBerryCreatePackageStepConfigWidget(BlackBerryCreatePackageStep *step) - : ProjectExplorer::BuildStepConfigWidget() - , m_step(step) -{ - m_ui = new Ui::BlackBerryCreatePackageStepConfigWidget; - m_ui->setupUi(this); - - m_ui->cskPassword->setText(m_step->cskPassword()); - m_ui->keystorePassword->setText(m_step->keystorePassword()); - m_ui->savePasswords->setChecked(m_step->savePasswords()); - m_ui->qtLibraryPath->setText(m_step->qtLibraryPath()); - - m_qtLibraryExplanations[0] = tr("Use the Qt libraries shipped with the BlackBerry device."); - m_qtLibraryExplanations[1] = tr("Include Qt libraries in the package. " - "This will increase the package size."); - m_qtLibraryExplanations[2] = tr("Use deployed Qt libraries on the device."); - m_ui->qtLibrary->addItem(tr("Use Pre-installed Qt"), BlackBerryCreatePackageStep::PreInstalledQt); - m_ui->qtLibrary->addItem(tr("Bundle Qt in Package"), BlackBerryCreatePackageStep::BundleQt); - m_ui->qtLibrary->addItem(tr("Use Deployed Qt"), BlackBerryCreatePackageStep::DeployedQt); - - connect(m_ui->signPackages, SIGNAL(toggled(bool)), this, SLOT(setPackageMode(bool))); - connect(m_ui->cskPassword, SIGNAL(textChanged(QString)), m_step, SLOT(setCskPassword(QString))); - connect(m_ui->keystorePassword, SIGNAL(textChanged(QString)), - m_step, SLOT(setKeystorePassword(QString))); - connect(m_ui->showPasswords, SIGNAL(toggled(bool)), this, SLOT(showPasswords(bool))); - connect(m_ui->savePasswords, SIGNAL(toggled(bool)), m_step, SLOT(setSavePasswords(bool))); - connect(m_ui->qtLibrary, SIGNAL(currentIndexChanged(int)), this, SLOT(setBundleMode(int))); - connect(m_ui->qtLibrary, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDeployWidgetsState())); - connect(m_ui->qtLibraryPath, SIGNAL(textChanged(QString)), - m_step, SLOT(setQtLibraryPath(QString))); - connect(m_ui->qtLibraryPath, SIGNAL(textChanged(QString)), - this, SLOT(updateDeployWidgetsState())); - connect(m_ui->deployNowButton, SIGNAL(clicked()), this, SLOT(deployLibraries())); - connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(updateDeployWidgetsState())); - - connect(m_step, SIGNAL(cskPasswordChanged(QString)), m_ui->cskPassword, SLOT(setText(QString))); - connect(m_step, SIGNAL(keystorePasswordChanged(QString)), - m_ui->keystorePassword, SLOT(setText(QString))); - - m_ui->signPackages->setChecked(m_step->packageMode() == - BlackBerryCreatePackageStep::SigningPackageMode); - m_ui->developmentMode->setChecked(m_step->packageMode() == - BlackBerryCreatePackageStep::DevelopmentMode); - - m_ui->qtLibrary->setCurrentIndex(m_ui->qtLibrary->findData(m_step->bundleMode())); - setBundleMode(m_step->bundleMode()); - updateDeployWidgetsState(); -} - -BlackBerryCreatePackageStepConfigWidget::~BlackBerryCreatePackageStepConfigWidget() -{ - delete m_ui; - m_ui = 0; -} - -QString BlackBerryCreatePackageStepConfigWidget::displayName() const -{ - return tr("<b>Create packages</b>"); -} - -QString BlackBerryCreatePackageStepConfigWidget::summaryText() const -{ - return displayName(); -} - -bool BlackBerryCreatePackageStepConfigWidget::showWidget() const -{ - return true; -} - -void BlackBerryCreatePackageStepConfigWidget::setPackageMode(bool signPackagesChecked) -{ - m_step->setPackageMode(signPackagesChecked ? BlackBerryCreatePackageStep::SigningPackageMode : BlackBerryCreatePackageStep::DevelopmentMode); -} - -void BlackBerryCreatePackageStepConfigWidget::showPasswords(bool show) -{ - m_ui->cskPassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password); - m_ui->keystorePassword->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password); -} - -void BlackBerryCreatePackageStepConfigWidget::setBundleMode(int qtLibraryIndex) -{ - QTC_ASSERT(m_qtLibraryExplanations.contains(qtLibraryIndex), return); - - BlackBerryCreatePackageStep::BundleMode bundleMode = - static_cast<BlackBerryCreatePackageStep::BundleMode>( - m_ui->qtLibrary->itemData(qtLibraryIndex).toInt()); - - m_step->setBundleMode(bundleMode); - m_ui->qtLibraryExplanationLabel->setText(m_qtLibraryExplanations[qtLibraryIndex]); - m_ui->qtLibraryPath->setVisible(bundleMode == BlackBerryCreatePackageStep::DeployedQt); - m_ui->qtLibraryLabel->setVisible(bundleMode == BlackBerryCreatePackageStep::DeployedQt); - - emit bundleModeChanged(); -} - -void BlackBerryCreatePackageStepConfigWidget::updateDeployWidgetsState() -{ - BlackBerryCreatePackageStep::BundleMode bundleMode = - static_cast<BlackBerryCreatePackageStep::BundleMode>( - m_ui->qtLibrary->itemData(m_ui->qtLibrary->currentIndex()).toInt()); - - ProjectExplorer::Kit *kit = m_step->target()->kit(); - ProjectExplorer::IDevice::ConstPtr device = ProjectExplorer::DeviceKitInformation::device(kit); - - const bool enableButton = !m_ui->qtLibraryPath->text().isEmpty() - && bundleMode == BlackBerryCreatePackageStep::DeployedQt - && !device.isNull(); - const bool visibleButton = bundleMode == BlackBerryCreatePackageStep::DeployedQt; - const bool visibleLabels = bundleMode == BlackBerryCreatePackageStep::DeployedQt - && device.isNull(); - - m_ui->deployNowButton->setEnabled(enableButton); - m_ui->deployNowButton->setVisible(visibleButton); - - m_ui->deployErrorPixmap->setVisible(visibleLabels); - m_ui->deployErrorLabel->setVisible(visibleLabels); -} - -void BlackBerryCreatePackageStepConfigWidget::deployLibraries() -{ - ProjectExplorer::Kit *kit = m_step->target()->kit(); - QnxDeployQtLibrariesDialog dlg(ProjectExplorer::DeviceKitInformation::device(kit), - QnxDeployQtLibrariesDialog::BB10, - this); - dlg.execAndDeploy(QtSupport::QtKitInformation::qtVersionId(kit), m_ui->qtLibraryPath->text()); -} diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h deleted file mode 100644 index 8e0945a7e7f..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPCONFIGWIDGET_H -#define QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPCONFIGWIDGET_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BlackBerryCreatePackageStepConfigWidget; } - -class BlackBerryCreatePackageStep; - -class BlackBerryCreatePackageStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT -public: - explicit BlackBerryCreatePackageStepConfigWidget(BlackBerryCreatePackageStep *step); - ~BlackBerryCreatePackageStepConfigWidget(); - - QString displayName() const; - QString summaryText() const; - - bool showWidget() const; - -private slots: - void setPackageMode(bool signPackagesChecked); - void showPasswords(bool show); - void setBundleMode(int qtLibraryIndex); - void updateDeployWidgetsState(); - void deployLibraries(); - -signals: - void bundleModeChanged(); - -private: - BlackBerryCreatePackageStep *m_step; - Ui::BlackBerryCreatePackageStepConfigWidget *m_ui; - - QMap<int, QString> m_qtLibraryExplanations; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPCONFIGWIDGET_H diff --git a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui b/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui deleted file mode 100644 index 41ebb3f1ef6..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestepconfigwidget.ui +++ /dev/null @@ -1,296 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryCreatePackageStepConfigWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryCreatePackageStepConfigWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>613</width> - <height>204</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QRadioButton" name="signPackages"> - <property name="text"> - <string>Sign packages</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="signPackagesWidget" native="true"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>CSK password:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="cskPassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Keystore password:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="keystorePassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QCheckBox" name="savePasswords"> - <property name="toolTip"> - <string>Note: This will store the passwords in a world-readable file.</string> - </property> - <property name="text"> - <string>Save passwords</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QCheckBox" name="showPasswords"> - <property name="text"> - <string>Show passwords</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QRadioButton" name="developmentMode"> - <property name="text"> - <string>Package in development mode</string> - </property> - </widget> - </item> - <item> - <widget class="QWidget" name="developmentModeWidget" native="true"> - <layout class="QGridLayout" name="gridLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item row="0" column="0"> - <spacer name="horizontalSpacer_3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="qtLibrary"/> - </item> - <item row="0" column="2"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>0</number> - </property> - <item> - <widget class="QLabel" name="qtLibraryLabel"> - <property name="text"> - <string>/accounts/devuser/</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="qtLibraryPath"/> - </item> - </layout> - </item> - <item row="0" column="3"> - <widget class="QPushButton" name="deployNowButton"> - <property name="text"> - <string>Deploy Now</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QLabel" name="deployErrorPixmap"> - <property name="text"> - <string/> - </property> - <property name="pixmap"> - <pixmap resource="../coreplugin/core.qrc">:/core/images/warning.png</pixmap> - </property> - </widget> - </item> - <item row="0" column="5"> - <widget class="QLabel" name="deployErrorLabel"> - <property name="text"> - <string>No device configured, cannot deploy.</string> - </property> - </widget> - </item> - <item row="0" column="6"> - <spacer name="horizontalSpacer_4"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="1" colspan="5"> - <widget class="QLabel" name="qtLibraryExplanationLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources> - <include location="../projectexplorer/projectexplorer.qrc"/> - </resources> - <connections> - <connection> - <sender>signPackages</sender> - <signal>toggled(bool)</signal> - <receiver>signPackagesWidget</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>40</x> - <y>12</y> - </hint> - <hint type="destinationlabel"> - <x>12</x> - <y>62</y> - </hint> - </hints> - </connection> - <connection> - <sender>developmentMode</sender> - <signal>toggled(bool)</signal> - <receiver>developmentModeWidget</receiver> - <slot>setEnabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>44</x> - <y>129</y> - </hint> - <hint type="destinationlabel"> - <x>22</x> - <y>169</y> - </hint> - </hints> - </connection> - <connection> - <sender>signPackages</sender> - <signal>toggled(bool)</signal> - <receiver>developmentModeWidget</receiver> - <slot>setDisabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>66</x> - <y>16</y> - </hint> - <hint type="destinationlabel"> - <x>115</x> - <y>174</y> - </hint> - </hints> - </connection> - <connection> - <sender>developmentMode</sender> - <signal>toggled(bool)</signal> - <receiver>signPackagesWidget</receiver> - <slot>setDisabled(bool)</slot> - <hints> - <hint type="sourcelabel"> - <x>69</x> - <y>132</y> - </hint> - <hint type="destinationlabel"> - <x>338</x> - <y>97</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/plugins/qnx/blackberrycreatepackagestepfactory.cpp b/src/plugins/qnx/blackberrycreatepackagestepfactory.cpp deleted file mode 100644 index 2a391d38882..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestepfactory.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrycreatepackagestepfactory.h" - -#include "qnxconstants.h" -#include "blackberrycreatepackagestep.h" -#include "blackberrydeviceconfigurationfactory.h" - -#include <projectexplorer/buildsteplist.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryCreatePackageStepFactory::BlackBerryCreatePackageStepFactory(QObject *parent) : - ProjectExplorer::IBuildStepFactory(parent) -{ -} - -BlackBerryCreatePackageStepFactory::~BlackBerryCreatePackageStepFactory() -{ -} - -QList<Core::Id> BlackBerryCreatePackageStepFactory::availableCreationIds( - ProjectExplorer::BuildStepList *parent) const -{ - if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) - return QList<Core::Id>(); - - Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(parent->target()->kit()); - if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType()) - return QList<Core::Id>(); - - return QList<Core::Id>() << Core::Id(Constants::QNX_CREATE_PACKAGE_BS_ID); -} - -QString BlackBerryCreatePackageStepFactory::displayNameForId(Core::Id id) const -{ - if (id == Constants::QNX_CREATE_PACKAGE_BS_ID) - return tr("Create BAR Packages"); - return QString(); -} - -bool BlackBerryCreatePackageStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, - const Core::Id id) const -{ - return availableCreationIds(parent).contains(id); -} - -ProjectExplorer::BuildStep *BlackBerryCreatePackageStepFactory::create(ProjectExplorer::BuildStepList *parent, Core::Id id) -{ - if (!canCreate(parent, id)) - return 0; - return new BlackBerryCreatePackageStep(parent); -} - -bool BlackBerryCreatePackageStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) const -{ - return canCreate(parent, ProjectExplorer::idFromMap(map)); -} - -ProjectExplorer::BuildStep *BlackBerryCreatePackageStepFactory::restore( - ProjectExplorer::BuildStepList *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - BlackBerryCreatePackageStep *bs = new BlackBerryCreatePackageStep(parent); - if (bs->fromMap(map)) - return bs; - delete bs; - return 0; -} - -bool BlackBerryCreatePackageStepFactory::canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *source) const -{ - return canCreate(parent, source->id()); -} - -ProjectExplorer::BuildStep *BlackBerryCreatePackageStepFactory::clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *source) -{ - if (!canClone(parent, source)) - return 0; - return new BlackBerryCreatePackageStep(parent, static_cast<BlackBerryCreatePackageStep *>(source)); -} diff --git a/src/plugins/qnx/blackberrycreatepackagestepfactory.h b/src/plugins/qnx/blackberrycreatepackagestepfactory.h deleted file mode 100644 index dbe0189324b..00000000000 --- a/src/plugins/qnx/blackberrycreatepackagestepfactory.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPFACTORY_H -#define QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPFACTORY_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryCreatePackageStepFactory : public ProjectExplorer::IBuildStepFactory -{ - Q_OBJECT -public: - explicit BlackBerryCreatePackageStepFactory(QObject *parent = 0); - ~BlackBerryCreatePackageStepFactory(); - - QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const; - QString displayNameForId(Core::Id id) const; - - bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id); - - bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map); - - bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *product) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYCREATEPACKAGESTEPFACTORY_H diff --git a/src/plugins/qnx/blackberrydebugsupport.cpp b/src/plugins/qnx/blackberrydebugsupport.cpp deleted file mode 100644 index 7f7fdf8a25f..00000000000 --- a/src/plugins/qnx/blackberrydebugsupport.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugsupport.h" -#include "blackberryapplicationrunner.h" - -#include <debugger/debuggerruncontrol.h> -#include <debugger/debuggerstartparameters.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDebugSupport::BlackBerryDebugSupport(BlackBerryRunConfiguration *runConfig, - Debugger::DebuggerRunControl *runControl) - : QObject(runControl) - , m_runControl(runControl) -{ - BlackBerryApplicationRunner::LaunchFlags launchFlags; - if (m_runControl->startParameters().languages & Debugger::CppLanguage) - launchFlags |= BlackBerryApplicationRunner::CppDebugLaunch; - if (m_runControl->startParameters().languages & Debugger::QmlLanguage) - launchFlags |= BlackBerryApplicationRunner::QmlDebugLaunch; - m_runner = new BlackBerryApplicationRunner(launchFlags, runConfig, this); - - connect(m_runControl, &Debugger::DebuggerRunControl::requestRemoteSetup, - this, &BlackBerryDebugSupport::launchRemoteApplication); - connect(m_runControl, SIGNAL(stateChanged(Debugger::DebuggerState)), - this, SLOT(handleDebuggerStateChanged(Debugger::DebuggerState))); - - connect(m_runner, SIGNAL(started()), this, SLOT(handleStarted())); - connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString))); - connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)), - this, SLOT(handleApplicationOutput(QString,Utils::OutputFormat))); - - connect(this, SIGNAL(output(QString,Utils::OutputFormat)), - runControl, SLOT(appendMessage(QString,Utils::OutputFormat))); -} - -void BlackBerryDebugSupport::launchRemoteApplication() -{ - m_runner->start(); -} - -void BlackBerryDebugSupport::handleStarted() -{ - m_runControl->startParameters().attachPID = m_runner->pid(); // FIXME: Is that needed? - Debugger::RemoteSetupResult result; - result.success = true; - result.inferiorPid = m_runner->pid(); - result.gdbServerPort = 8000; - result.qmlServerPort = Debugger::InvalidPort; - m_runControl->notifyEngineRemoteSetupFinished(result); -} - -void BlackBerryDebugSupport::handleStartFailed(const QString &message) -{ - Debugger::RemoteSetupResult result; - result.success = false; - result.reason = message; - m_runControl->notifyEngineRemoteSetupFinished(result); -} - -void BlackBerryDebugSupport::handleDebuggerStateChanged(Debugger::DebuggerState state) -{ - if (state == Debugger::EngineShutdownOk || state == Debugger::DebuggerFinished) { - if (m_runner->isRunning()) - m_runner->stop(); - } -} - -void BlackBerryDebugSupport::handleApplicationOutput(const QString &msg, Utils::OutputFormat format) -{ - Q_UNUSED(format) - m_runControl->showMessage(msg, Debugger::AppOutput); -} diff --git a/src/plugins/qnx/blackberrydebugsupport.h b/src/plugins/qnx/blackberrydebugsupport.h deleted file mode 100644 index 56741039cc6..00000000000 --- a/src/plugins/qnx/blackberrydebugsupport.h +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEBUGSUPPORT_H -#define QNX_INTERNAL_BLACKBERRYDEBUGSUPPORT_H - -#include <debugger/debuggerconstants.h> - -#include <utils/outputformat.h> - -#include <QObject> -#include <QProcess> - -namespace Debugger { class DebuggerRunControl; } - -namespace Qnx { -namespace Internal { - -class BlackBerryConnect; -class BlackBerryRunConfiguration; -class BlackBerryApplicationRunner; - -class BlackBerryDebugSupport : public QObject -{ - Q_OBJECT -public: - explicit BlackBerryDebugSupport(BlackBerryRunConfiguration *runConfig, - Debugger::DebuggerRunControl *runControl); - -signals: - void output(const QString &msg, Utils::OutputFormat format); - -private slots: - void launchRemoteApplication(); - - void handleStarted(); - void handleStartFailed(const QString &message); - - void handleDebuggerStateChanged(Debugger::DebuggerState state); - - void handleApplicationOutput(const QString &msg, Utils::OutputFormat format); - -private: - Debugger::DebuggerRunControl *m_runControl; - BlackBerryApplicationRunner *m_runner; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGSUPPORT_H diff --git a/src/plugins/qnx/blackberrydebugtokenpinsdialog.cpp b/src/plugins/qnx/blackberrydebugtokenpinsdialog.cpp deleted file mode 100644 index d0c654a7e88..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenpinsdialog.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugtokenpinsdialog.h" -#include "ui_blackberrydebugtokenpinsdialog.h" -#include "blackberrydebugtokenreader.h" -#include "blackberryconfigurationmanager.h" -#include "blackberrysigningutils.h" - -#include <QStandardItemModel> -#include <QMessageBox> -#include <QLineEdit> - -namespace Qnx { -namespace Internal { - -BlackBerryDebugTokenPinsDialog::BlackBerryDebugTokenPinsDialog(const QString &debugToken, QWidget *parent) : - QDialog(parent), - ui(new Ui_BlackBerryDebugTokenPinsDialog), - m_model(new QStandardItemModel(this)), - m_debugTokenPath(debugToken), - m_updated(false) -{ - ui->setupUi(this); - setWindowTitle(tr("Debug Token PINs")); - ui->pins->setModel(m_model); - ui->pathLabel->setText(debugToken); - BlackBerryDebugTokenReader reader(debugToken); - if (reader.isValid()) { - QStringList pins = reader.pins().split(QLatin1Char(',')); - foreach (const QString &pin, pins) - m_model->appendRow(new QStandardItem(pin)); - } - - m_okButton = ui->buttonBox->button(QDialogButtonBox::Ok); - - ui->editButton->setEnabled(false); - ui->removeButton->setEnabled(false); - - connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addPin())); - connect(ui->editButton, SIGNAL(clicked()), this, SLOT(editPin())); - connect(ui->removeButton, SIGNAL(clicked()), this, SLOT(removePin())); - connect(m_okButton, SIGNAL(clicked()), this, SLOT(emitUpdatedPins())); - connect(ui->pins, SIGNAL(pressed(QModelIndex)), this, SLOT(updateUi(QModelIndex))); -} - -BlackBerryDebugTokenPinsDialog::~BlackBerryDebugTokenPinsDialog() -{ - delete ui; -} - -void BlackBerryDebugTokenPinsDialog::addPin() -{ - bool ok; - const QString pin = promptPIN(QString(), &ok); - if (ok && !pin.isEmpty()) { - m_model->appendRow(new QStandardItem(pin)); - m_updated = true; - } -} - -void BlackBerryDebugTokenPinsDialog::editPin() -{ - const QModelIndex index = ui->pins->currentIndex(); - if (!index.isValid()) - return; - - bool ok; - QString pin = m_model->item(index.row(), 0)->text(); - QString newPin = promptPIN(pin, &ok); - if (ok && newPin != pin) { - m_model->item(index.row(), 0)->setText(newPin); - m_updated = true; - } -} - -void BlackBerryDebugTokenPinsDialog::removePin() -{ - const QModelIndex index = ui->pins->currentIndex(); - if (!index.isValid()) - return; - - const QString pin = m_model->item(index.row(), 0)->text(); - const int result = QMessageBox::question(this, tr("Confirmation"), - tr("Are you sure you want to remove PIN: %1?") - .arg(pin), QMessageBox::Yes | QMessageBox::No); - - if (result == QMessageBox::Yes) { - m_model->removeRow(index.row()); - m_updated = true; - } -} - -void BlackBerryDebugTokenPinsDialog::updateUi(const QModelIndex& index) -{ - ui->editButton->setEnabled(index.isValid()); - ui->removeButton->setEnabled(index.isValid()); -} - -void BlackBerryDebugTokenPinsDialog::emitUpdatedPins() -{ - if (!m_updated) - return; - - QStringList pins; - for (int i = 0; i < m_model->rowCount(); i++) - pins << m_model->item(i)->text(); - - emit pinsUpdated(pins); -} - -QString BlackBerryDebugTokenPinsDialog::promptPIN(const QString &value, bool *ok) -{ - QDialog dialog(this); - QVBoxLayout *layout = new QVBoxLayout; - QLineEdit *lineEdit = new QLineEdit; - QDialogButtonBox *buttonBox = new QDialogButtonBox; - - lineEdit->setMaxLength(8); - lineEdit->setText(value); - - buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); - buttonBox->button(QDialogButtonBox::Ok)->setDefault(true); - - connect(buttonBox, SIGNAL(accepted()), &dialog, SLOT(accept())); - connect(buttonBox, SIGNAL(rejected()), &dialog, SLOT(reject())); - - layout->addWidget(lineEdit); - layout->addWidget(buttonBox); - - dialog.setWindowTitle(tr("Debug Token PIN")); - dialog.setLayout(layout); - - const bool rejected = dialog.exec() == QDialog::Rejected; - if (ok) - *ok = !rejected; - - if (rejected) - return QString(); - - return lineEdit->text(); -} - -} // Internal -} // Qnx diff --git a/src/plugins/qnx/blackberrydebugtokenpinsdialog.h b/src/plugins/qnx/blackberrydebugtokenpinsdialog.h deleted file mode 100644 index 6b099fe7f1b..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenpinsdialog.h +++ /dev/null @@ -1,80 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYDEBUGTOKENSDIALOG_H -#define BLACKBERRYDEBUGTOKENSDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QStandardItemModel; -class QModelIndex; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryDebugTokenPinsDialog; - -class BlackBerryDebugTokenPinsDialog : public QDialog -{ - Q_OBJECT - -public: - explicit BlackBerryDebugTokenPinsDialog(const QString &debugToken, QWidget *parent = 0); - ~BlackBerryDebugTokenPinsDialog(); - -private slots: - void addPin(); - void editPin(); - void removePin(); - void updateUi(const QModelIndex& index); - - void emitUpdatedPins(); - QString promptPIN(const QString& defaultValue, bool *ok = 0); - -signals: - void pinsUpdated(const QStringList &pins); - -private: - Ui_BlackBerryDebugTokenPinsDialog *ui; - QStandardItemModel *m_model; - - QPushButton *m_okButton; - - QString m_debugTokenPath; - bool m_updated; -}; - -} // Internal -} // Qnx -#endif // BLACKBERRYDEBUGTOKENSDIALOG_H diff --git a/src/plugins/qnx/blackberrydebugtokenpinsdialog.ui b/src/plugins/qnx/blackberrydebugtokenpinsdialog.ui deleted file mode 100644 index a4eb9e96322..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenpinsdialog.ui +++ /dev/null @@ -1,144 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDebugTokenPinsDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerryDebugTokenPinsDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>432</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Dialog</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Debug token: </span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="pathLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListView" name="pins"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="addButton"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editButton"> - <property name="text"> - <string>Edit</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>Qnx::Internal::BlackBerryDebugTokenPinsDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>Qnx::Internal::BlackBerryDebugTokenPinsDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/plugins/qnx/blackberrydebugtokenreader.cpp b/src/plugins/qnx/blackberrydebugtokenreader.cpp deleted file mode 100644 index 0edc3e71191..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenreader.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugtokenreader.h" - -#include <QStringList> - -#ifdef QNX_ZIP_FILE_SUPPORT -#include <private/qzipreader_p.h> -#endif - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -#ifdef QNX_ZIP_FILE_SUPPORT -const char MANIFEST_FILENAME[] = "META-INF/MANIFEST.MF"; -#endif - -const char MANIFEST_AUTHOR_KEY[] = "Package-Author: "; -const char MANIFEST_AUTHOR_ID_KEY[] = "Package-Author-Id: "; -const char MANIFEST_EXPIRY[] = "Debug-Token-Expiry-Date: "; -const char MANIFEST_PINS[] = "Debug-Token-Device-Id: "; -} - -BlackBerryDebugTokenReader::BlackBerryDebugTokenReader(const QString &filePath) -{ -#ifdef QNX_ZIP_FILE_SUPPORT - m_zipReader = new QZipReader(filePath); -#else - Q_UNUSED(filePath); - Q_UNUSED(m_zipReader); -#endif -} - -BlackBerryDebugTokenReader::~BlackBerryDebugTokenReader() -{ -#ifdef QNX_ZIP_FILE_SUPPORT - m_zipReader->close(); - delete m_zipReader; - m_zipReader = 0; -#endif -} - -bool BlackBerryDebugTokenReader::isValid() const -{ -#ifdef QNX_ZIP_FILE_SUPPORT - return m_zipReader->status() == QZipReader::NoError; -#else - return false; -#endif -} - -QString BlackBerryDebugTokenReader::author() const -{ - return manifestValue(MANIFEST_AUTHOR_KEY); -} - -QString BlackBerryDebugTokenReader::authorId() const -{ - return manifestValue(MANIFEST_AUTHOR_ID_KEY); -} - -QString BlackBerryDebugTokenReader::expiry() const -{ - return manifestValue(MANIFEST_EXPIRY); -} - -QString BlackBerryDebugTokenReader::pins() const -{ - const QString value = manifestValue(MANIFEST_PINS); - QStringList pins = value.split(QLatin1Char(',')); - QStringList pinsHexa; - foreach (const QString &pin, pins) { - QString hexa; - pinsHexa << hexa.setNum(pin.toUInt(), 16); - } - - return pinsHexa.join(QLatin1Char(',')); -} - -bool BlackBerryDebugTokenReader::isSupported() -{ -#ifdef QNX_ZIP_FILE_SUPPORT - return true; -#else - return false; -#endif -} - -QString BlackBerryDebugTokenReader::manifestValue(const QByteArray &key) const -{ - if (!isValid()) - return QString(); - -#ifdef QNX_ZIP_FILE_SUPPORT - QByteArray manifestContent = m_zipReader->fileData(QLatin1String(MANIFEST_FILENAME)); - return value(key, manifestContent); -#else - Q_UNUSED(key); - return QString(); -#endif -} - -QString BlackBerryDebugTokenReader::value(const QByteArray &key, const QByteArray &data) const -{ - int valueStart = data.indexOf(key) + key.size(); - int valueEnd = data.indexOf(QByteArray("\r\n"), valueStart); - return QString::fromLatin1(data.mid(valueStart, valueEnd - valueStart)); -} diff --git a/src/plugins/qnx/blackberrydebugtokenreader.h b/src/plugins/qnx/blackberrydebugtokenreader.h deleted file mode 100644 index 920eb803c61..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenreader.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H -#define QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H - -#include <QString> - -QT_BEGIN_NAMESPACE -class QZipReader; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryDebugTokenReader -{ -public: - BlackBerryDebugTokenReader(const QString &filePath); - ~BlackBerryDebugTokenReader(); - - bool isValid() const; - - QString author() const; - QString authorId() const; - QString expiry() const; - QString pins() const; - - static bool isSupported(); - -private: - QString manifestValue(const QByteArray &key) const; - QString value(const QByteArray &key, const QByteArray &data) const; - - QZipReader *m_zipReader; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENREADER_H diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp b/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp deleted file mode 100644 index a2029b892cd..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.cpp +++ /dev/null @@ -1,291 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugtokenrequestdialog.h" -#include "blackberrydebugtokenrequester.h" -#include "blackberrydeviceinformation.h" -#include "blackberryconfigurationmanager.h" -#include "blackberrysigningutils.h" -#include "ui_blackberrydebugtokenrequestdialog.h" - -#include <QPushButton> -#include <QDir> -#include <QMessageBox> - -namespace Qnx { -namespace Internal { - -BlackBerryDebugTokenRequestDialog::BlackBerryDebugTokenRequestDialog( - QWidget *parent, Qt::WindowFlags f) : - QDialog(parent, f), - m_ui(new Ui_BlackBerryDebugTokenRequestDialog), - m_requester(new BlackBerryDebugTokenRequester(this)), - m_deviceInfo(new BlackBerryDeviceInformation(this)), - m_utils(BlackBerrySigningUtils::instance()) -{ - m_ui->setupUi(this); - m_ui->progressBar->hide(); - m_ui->status->clear(); - m_ui->debugTokenPath->setExpectedKind(Utils::PathChooser::SaveFile); - m_ui->debugTokenPath->setHistoryCompleter(QLatin1String("BB.DebugToken.History")); - m_ui->debugTokenPath->setPromptDialogTitle(tr("Request Debug Token")); - m_ui->debugTokenPath->setPromptDialogFilter(tr("BAR Files (*.bar)")); - - m_cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); - m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); - m_okButton->setEnabled(false); - - connect(m_cancelButton, SIGNAL(clicked()), - this, SLOT(reject())); - connect(m_okButton, SIGNAL(clicked()), - this, SLOT(requestDebugToken())); - connect(m_ui->debugTokenPath, SIGNAL(changed(QString)), - this, SLOT(validate())); - connect(m_ui->debugTokenPath, SIGNAL(beforeBrowsing()), - this, SLOT(setDefaultPath())); - connect(m_ui->debugTokenPath, SIGNAL(editingFinished()), - this, SLOT(appendExtension())); - connect(m_ui->debugTokenPath, SIGNAL(editingFinished()), - this, SLOT(expandPath())); - connect(m_ui->devicePin, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_requester, SIGNAL(finished(int)), - this, SLOT(debugTokenArrived(int))); - connect(m_deviceInfo, SIGNAL(finished(int)), - this, SLOT(setDevicePin(int))); -} - -BlackBerryDebugTokenRequestDialog::~BlackBerryDebugTokenRequestDialog() -{ - delete m_ui; -} - -QString BlackBerryDebugTokenRequestDialog::debugToken() const -{ - return m_ui->debugTokenPath->path(); -} - -void BlackBerryDebugTokenRequestDialog::setDevicePin(const QString &devicePin) -{ - m_ui->devicePin->setText(devicePin); -} - -void BlackBerryDebugTokenRequestDialog::setTargetDetails(const QString &deviceIp, const QString &password) -{ - m_ui->devicePin->setPlaceholderText(tr("Requesting Device PIN...")); - m_deviceInfo->setDeviceTarget(deviceIp, password); -} - -void BlackBerryDebugTokenRequestDialog::validate() -{ - if (!m_ui->debugTokenPath->isValid() || m_ui->devicePin->text().isEmpty()) { - m_okButton->setEnabled(false); - return; - } - - QFileInfo fileInfo(m_ui->debugTokenPath->path()); - - if (!fileInfo.dir().exists()) { - m_ui->status->setText(tr("Base directory does not exist.")); - m_okButton->setEnabled(false); - return; - } - - m_ui->status->clear(); - m_okButton->setEnabled(true); -} - -void BlackBerryDebugTokenRequestDialog::requestDebugToken() -{ - setBusy(true); - - QFile file(m_ui->debugTokenPath->path()); - - if (file.exists()) { - const int result = QMessageBox::question(this, tr("Are you sure?"), - tr("The file \"%1\" will be overwritten. Do you want to proceed?") - .arg(file.fileName()), QMessageBox::Yes | QMessageBox::No); - - if (result & QMessageBox::Yes) { - file.remove(); - } else { - setBusy(false); - return; - } - } - - bool ok; - const QString cskPassword = m_utils.cskPassword(this, &ok); - - if (!ok) { - setBusy(false); - return; - } - - const QString certificatePassword = m_utils.certificatePassword(this, &ok); - - if (!ok) { - setBusy(false); - return; - } - - m_requester->requestDebugToken(m_ui->debugTokenPath->path(), - cskPassword, BlackBerryConfigurationManager::instance()->defaultKeystorePath(), - certificatePassword, m_ui->devicePin->text()); -} - -void BlackBerryDebugTokenRequestDialog::setDefaultPath() -{ - const QString path = m_ui->debugTokenPath->path(); - const QString defaultFileName = QLatin1String("/debugToken.bar"); - - if (path.isEmpty()) { - m_ui->debugTokenPath->setPath(QDir::homePath() + defaultFileName); - return; - } - - const QFileInfo fileInfo(path); - - if (fileInfo.isDir()) - m_ui->debugTokenPath->setPath(path + defaultFileName); -} - -void BlackBerryDebugTokenRequestDialog::appendExtension() -{ - QString path = m_ui->debugTokenPath->path(); - - if (path.isEmpty()) - return; - - if (!path.endsWith(QLatin1String(".bar"))) { - path += QLatin1String(".bar"); - m_ui->debugTokenPath->setPath(path); - } -} - -void BlackBerryDebugTokenRequestDialog::expandPath() -{ - const QString path = m_ui->debugTokenPath->path(); - - if (path.isEmpty() || path.startsWith(QLatin1Char('/'))) - return; - - const QFileInfo fileInfo(path); - - m_ui->debugTokenPath->setPath(fileInfo.absoluteFilePath()); -} - -void BlackBerryDebugTokenRequestDialog::debugTokenArrived(int status) -{ - QString errorString = tr("Failed to request debug token:") + QLatin1Char(' '); - - switch (status) { - case BlackBerryDebugTokenRequester::Success: - accept(); - return; - case BlackBerryDebugTokenRequester::WrongCskPassword: - m_utils.clearCskPassword(); - errorString += tr("Wrong CSK password."); - break; - case BlackBerryDebugTokenRequester::WrongKeystorePassword: - m_utils.clearCertificatePassword(); - errorString += tr("Wrong keystore password."); - break; - case BlackBerryDebugTokenRequester::NetworkUnreachable: - errorString += tr("Network unreachable."); - break; - case BlackBerryDebugTokenRequester::IllegalPin: - errorString += tr("Illegal device PIN."); - break; - case BlackBerryDebugTokenRequester::FailedToStartInferiorProcess: - errorString += tr("Failed to start inferior process."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessTimedOut: - errorString += tr("Inferior processes timed out."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessCrashed: - errorString += tr("Inferior process has crashed."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessReadError: - case BlackBerryDebugTokenRequester::InferiorProcessWriteError: - errorString += tr("Failed to communicate with the inferior process."); - break; - case BlackBerryDebugTokenRequester::NotYetRegistered: - errorString += tr("Not yet registered to request debug tokens."); - break; - case BlackBerryDebugTokenRequester::UnknownError: - default: - m_utils.clearCertificatePassword(); - m_utils.clearCskPassword(); - errorString += tr("An unknwon error has occurred."); - break; - } - - QFile file(m_ui->debugTokenPath->path()); - - if (file.exists()) - file.remove(); - - QMessageBox::critical(this, tr("Error"), errorString); - - setBusy(false); -} - -void BlackBerryDebugTokenRequestDialog::setDevicePin(int status) -{ - m_ui->devicePin->setPlaceholderText(QString()); - if (status != BlackBerryDeviceInformation::Success) - return; - - const QString devicePin = m_deviceInfo->devicePin(); - if (devicePin.isEmpty()) - return; - - m_ui->devicePin->setText(devicePin); -} - -void BlackBerryDebugTokenRequestDialog::setBusy(bool busy) -{ - m_okButton->setEnabled(!busy); - m_cancelButton->setEnabled(!busy); - m_ui->debugTokenPath->setEnabled(!busy); - m_ui->devicePin->setEnabled(!busy); - m_ui->progressBar->setVisible(busy); - - if (busy) - m_ui->status->setText(tr("Requesting debug token...")); - else - m_ui->status->clear(); -} - -} -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h b/src/plugins/qnx/blackberrydebugtokenrequestdialog.h deleted file mode 100644 index abd0d086e6c..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.h +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTDIALOG_H -#define QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QPushButton; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryDebugTokenRequestDialog; -class BlackBerryDebugTokenRequester; -class BlackBerryDeviceInformation; -class BlackBerrySigningUtils; - -class BlackBerryDebugTokenRequestDialog : public QDialog -{ -Q_OBJECT - -public: - explicit BlackBerryDebugTokenRequestDialog(QWidget *parent = 0, - Qt::WindowFlags f = 0); - ~BlackBerryDebugTokenRequestDialog(); - - QString debugToken() const; - void setDevicePin(const QString &devicePin); - void setTargetDetails(const QString &deviceIp, const QString &password); - -private slots: - void validate(); - void requestDebugToken(); - void setDefaultPath(); - void appendExtension(); - void expandPath(); - void debugTokenArrived(int status); - void setDevicePin(int status); - -private: - void setBusy(bool busy); - - Ui_BlackBerryDebugTokenRequestDialog *m_ui; - - BlackBerryDebugTokenRequester *m_requester; - BlackBerryDeviceInformation *m_deviceInfo; - BlackBerrySigningUtils &m_utils; - - QPushButton *m_cancelButton; - QPushButton *m_okButton; -}; - -} -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTDIALOG_H diff --git a/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui b/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui deleted file mode 100644 index aa65f78ce47..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenrequestdialog.ui +++ /dev/null @@ -1,99 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDebugTokenRequestDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerryDebugTokenRequestDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>388</width> - <height>153</height> - </rect> - </property> - <property name="windowTitle"> - <string>Request Debug Token</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Debug token path:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="debugTokenPath" native="true"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Device PIN:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="devicePin"> - <property name="inputMask"> - <string notr="true">HHHHHHHH</string> - </property> - <property name="maxLength"> - <number>8</number> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="maximum"> - <number>0</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="status"> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Status</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - </widget> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydebugtokenrequester.cpp b/src/plugins/qnx/blackberrydebugtokenrequester.cpp deleted file mode 100644 index 9767b7f7c81..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenrequester.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugtokenrequester.h" - -namespace { -static const char PROCESS_NAME[] = "blackberry-debugtokenrequest"; -static const char ERR_WRONG_CSK_PASS[] = "The signature on the code signing request didn't verify."; -static const char ERR_WRONG_CSK_PASS_10_2[] = "The specified CSK password is not valid."; -static const char ERR_WRONG_KEYSTORE_PASS[] = "Failed to decrypt keystore, invalid password"; -static const char ERR_WRONG_KEYSTORE_PASS_10_2[] = "Failed to decrypt keystore, invalid store password or store password not supplied."; -static const char ERR_NETWORK_UNREACHABLE[] = "Network is unreachable"; -static const char ERR_NOT_YET_REGISTGERED[] = "Not yet registered to request debug tokens"; -} - -namespace Qnx { -namespace Internal { - -BlackBerryDebugTokenRequester::BlackBerryDebugTokenRequester(QObject *parent) : - BlackBerryNdkProcess(QLatin1String(PROCESS_NAME), parent) -{ - addErrorStringMapping(QLatin1String(ERR_WRONG_CSK_PASS), WrongCskPassword); - addErrorStringMapping(QLatin1String(ERR_WRONG_CSK_PASS_10_2), WrongCskPassword); - addErrorStringMapping(QLatin1String(ERR_WRONG_KEYSTORE_PASS), WrongKeystorePassword); - addErrorStringMapping(QLatin1String(ERR_WRONG_KEYSTORE_PASS_10_2), WrongKeystorePassword); - addErrorStringMapping(QLatin1String(ERR_NETWORK_UNREACHABLE), NetworkUnreachable); - addErrorStringMapping(QLatin1String(ERR_NOT_YET_REGISTGERED), NotYetRegistered); -} - -void BlackBerryDebugTokenRequester::requestDebugToken(const QString &path, - const QString &cskPassword, const QString &keyStore, - const QString &keyStorePassword, const QString &devicePin) -{ - QStringList arguments; - - arguments << QLatin1String("-keystore") - << keyStore - << QLatin1String("-storepass") - << keyStorePassword - << QLatin1String("-cskpass") - << cskPassword; - - // devicePin may contain multiple pins - QStringList pins = devicePin.split(QLatin1Char(',')); - foreach (const QString &pin, pins) - arguments << QLatin1String("-devicepin") << pin; - - arguments << path; - - start(arguments); - -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrydebugtokenrequester.h b/src/plugins/qnx/blackberrydebugtokenrequester.h deleted file mode 100644 index e3238224b83..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenrequester.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTER_H -#define QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTER_H - -#include "blackberryndkprocess.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryDebugTokenRequester : public BlackBerryNdkProcess -{ - Q_OBJECT - -public: - enum ReturnStatus - { - WrongCskPassword = UserStatus, - WrongKeystorePassword, - NetworkUnreachable, - IllegalPin, - NotYetRegistered - }; - - explicit BlackBerryDebugTokenRequester(QObject *parent = 0); - - void requestDebugToken(const QString &path, const QString &cskPassword, - const QString &keyStore, const QString &keyStorePassword, - const QString &devicePin); -}; - -} -} - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENREQUESTER_H diff --git a/src/plugins/qnx/blackberrydebugtokenuploader.cpp b/src/plugins/qnx/blackberrydebugtokenuploader.cpp deleted file mode 100644 index 876f1a0b1d2..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenuploader.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydebugtokenuploader.h" - -#include "qnxconstants.h" - -namespace { -static const char ERR_NO_ROUTE_HOST[] = "Cannot connect"; -static const char ERR_AUTH_FAILED[] = "Authentication failed"; -static const char ERR_DEVELOPMENT_MODE_DISABLED[] = "Device is not in the Development Mode"; -static const char ERR_FILE_NOT_EXIST[] = "File does not exist"; -} - -namespace Qnx { -namespace Internal { - -BlackBerryDebugTokenUploader::BlackBerryDebugTokenUploader(QObject *parent) : - BlackBerryNdkProcess(QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD), parent) -{ - addErrorStringMapping(QLatin1String(ERR_NO_ROUTE_HOST), NoRouteToHost); - addErrorStringMapping(QLatin1String(ERR_AUTH_FAILED), AuthenticationFailed); - addErrorStringMapping(QLatin1String(ERR_DEVELOPMENT_MODE_DISABLED), DevelopmentModeDisabled); - addErrorStringMapping(QLatin1String(ERR_FILE_NOT_EXIST), InvalidDebugTokenPath); -} - -void BlackBerryDebugTokenUploader::uploadDebugToken(const QString &path, - const QString &deviceIp, const QString &devicePassword) -{ - QStringList arguments; - - arguments << QLatin1String("-installDebugToken") - << path - << QLatin1String("-device") - << deviceIp - << QLatin1String("-password") - << devicePassword; - - start(arguments); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrydebugtokenuploader.h b/src/plugins/qnx/blackberrydebugtokenuploader.h deleted file mode 100644 index be111247cce..00000000000 --- a/src/plugins/qnx/blackberrydebugtokenuploader.h +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEBUGTOKENUPLOADER_H -#define QNX_INTERNAL_BLACKBERRYDEBUGTOKENUPLOADER_H - -#include "blackberryndkprocess.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryDebugTokenUploader : public BlackBerryNdkProcess -{ - Q_OBJECT - -public: - enum ReturnStatus - { - NoRouteToHost = UserStatus, - AuthenticationFailed, - DevelopmentModeDisabled, - FailedToStartInferiorProcess, - InferiorProcessTimedOut, - InferiorProcessCrashed, - InferiorProcessWriteError, - InferiorProcessReadError, - InvalidDebugTokenPath - }; - - explicit BlackBerryDebugTokenUploader(QObject *parent = 0); - - void uploadDebugToken(const QString &path, const QString &deviceIp, - const QString &devicePassword); -}; - -} -} - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENUPLOADER_H diff --git a/src/plugins/qnx/blackberrydeployconfiguration.cpp b/src/plugins/qnx/blackberrydeployconfiguration.cpp deleted file mode 100644 index bc2c559598c..00000000000 --- a/src/plugins/qnx/blackberrydeployconfiguration.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeployconfiguration.h" - -#include "qnxconstants.h" -#include "bardescriptorfilenode.h" -#include "blackberrydeployconfigurationwidget.h" -#include "blackberrydeployinformation.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char DEPLOYMENT_INFO_KEY[] = "Qnx.BlackBerry.DeployInformation"; -} - -BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Target *parent) - : ProjectExplorer::DeployConfiguration(parent, Core::Id(Constants::QNX_BB_DEPLOYCONFIGURATION_ID)) -{ - ctor(); -} - -BlackBerryDeployConfiguration::BlackBerryDeployConfiguration(ProjectExplorer::Target *parent, - BlackBerryDeployConfiguration *source) - : ProjectExplorer::DeployConfiguration(parent, source) -{ - ctor(); - cloneSteps(source); -} - -void BlackBerryDeployConfiguration::ctor() -{ - m_deployInformation = new BlackBerryDeployInformation(target()); - - setDefaultDisplayName(tr("Deploy to BlackBerry Device")); -} - -BlackBerryDeployConfiguration::~BlackBerryDeployConfiguration() -{ -} - -BlackBerryDeployInformation *BlackBerryDeployConfiguration::deploymentInfo() const -{ - return m_deployInformation; -} - -ProjectExplorer::NamedWidget *BlackBerryDeployConfiguration::createConfigWidget() -{ - return new BlackBerryDeployConfigurationWidget(this); -} - -QVariantMap BlackBerryDeployConfiguration::toMap() const -{ - QVariantMap map(ProjectExplorer::DeployConfiguration::toMap()); - map.insert(QLatin1String(DEPLOYMENT_INFO_KEY), deploymentInfo()->toMap()); - return map; -} - -bool BlackBerryDeployConfiguration::fromMap(const QVariantMap &map) -{ - if (!ProjectExplorer::DeployConfiguration::fromMap(map)) - return false; - - QVariantMap deployInfoMap = map.value(QLatin1String(DEPLOYMENT_INFO_KEY)).toMap(); - deploymentInfo()->fromMap(deployInfoMap); - return true; -} diff --git a/src/plugins/qnx/blackberrydeployconfiguration.h b/src/plugins/qnx/blackberrydeployconfiguration.h deleted file mode 100644 index cd4c73869fa..00000000000 --- a/src/plugins/qnx/blackberrydeployconfiguration.h +++ /dev/null @@ -1,74 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATION_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATION_H - -#include <projectexplorer/deployconfiguration.h> - -#include "blackberrydeviceconfiguration.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployInformation; - -class BlackBerryDeployConfiguration : public ProjectExplorer::DeployConfiguration -{ - Q_OBJECT - friend class BlackBerryDeployConfigurationFactory; - -public: - explicit BlackBerryDeployConfiguration(ProjectExplorer::Target *parent); - virtual ~BlackBerryDeployConfiguration(); - - ProjectExplorer::NamedWidget *createConfigWidget(); - - BlackBerryDeployInformation *deploymentInfo() const; - - QVariantMap toMap() const; - -protected: - BlackBerryDeployConfiguration(ProjectExplorer::Target *parent, BlackBerryDeployConfiguration *source); - - bool fromMap(const QVariantMap &map); - -private: - void ctor(); - - BlackBerryDeployInformation *m_deployInformation; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATION_H diff --git a/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp b/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp deleted file mode 100644 index 71f9abe0def..00000000000 --- a/src/plugins/qnx/blackberrydeployconfigurationfactory.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeployconfigurationfactory.h" - -#include "qnxconstants.h" -#include "blackberrycheckdevicestatusstep.h" -#include "blackberrydeployconfiguration.h" -#include "blackberrycreatepackagestep.h" -#include "blackberrydeploystep.h" -#include "blackberrydeviceconfigurationfactory.h" - -#include <projectexplorer/buildsteplist.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/target.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <remotelinux/genericdirectuploadstep.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeployConfigurationFactory::BlackBerryDeployConfigurationFactory(QObject *parent) : - ProjectExplorer::DeployConfigurationFactory(parent) -{ -} - -BlackBerryDeployConfigurationFactory::~BlackBerryDeployConfigurationFactory() -{ -} - -QList<Core::Id> BlackBerryDeployConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const -{ - QList<Core::Id> result; - - QmakeProjectManager::QmakeProject *project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project()); - if (!project) - return result; - - Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(parent->kit()); - if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType()) - return result; - - result << Core::Id(Constants::QNX_BB_DEPLOYCONFIGURATION_ID); - return result; -} - -QString BlackBerryDeployConfigurationFactory::displayNameForId(Core::Id id) const -{ - if (id == Constants::QNX_BB_DEPLOYCONFIGURATION_ID) - return tr("Deploy to BlackBerry Device"); - - return QString(); -} - -bool BlackBerryDeployConfigurationFactory::canCreate(ProjectExplorer::Target *parent, - const Core::Id id) const -{ - return availableCreationIds(parent).contains(id); -} - -ProjectExplorer::DeployConfiguration *BlackBerryDeployConfigurationFactory::create( - ProjectExplorer::Target *parent, const Core::Id id) -{ - if (!canCreate(parent, id)) - return 0; - - BlackBerryDeployConfiguration *dc = new BlackBerryDeployConfiguration(parent); - dc->stepList()->insertStep(0, new BlackBerryCheckDeviceStatusStep(dc->stepList())); - dc->stepList()->insertStep(1, new BlackBerryCreatePackageStep(dc->stepList())); - dc->stepList()->insertStep(2, new BlackBerryDeployStep(dc->stepList())); - return dc; -} - -bool BlackBerryDeployConfigurationFactory::canRestore(ProjectExplorer::Target *parent, - const QVariantMap &map) const -{ - return canCreate(parent, ProjectExplorer::idFromMap(map)); -} - -ProjectExplorer::DeployConfiguration *BlackBerryDeployConfigurationFactory::restore( - ProjectExplorer::Target *parent, const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - - BlackBerryDeployConfiguration *dc = new BlackBerryDeployConfiguration(parent); - if (dc->fromMap(map)) - return dc; - - delete dc; - return 0; -} - -bool BlackBerryDeployConfigurationFactory::canClone(ProjectExplorer::Target *parent, - ProjectExplorer::DeployConfiguration *source) const -{ - return canCreate(parent, source->id()); -} - -ProjectExplorer::DeployConfiguration *BlackBerryDeployConfigurationFactory::clone( - ProjectExplorer::Target *parent, ProjectExplorer::DeployConfiguration *source) -{ - if (!canClone(parent, source)) - return 0; - BlackBerryDeployConfiguration *old = static_cast<BlackBerryDeployConfiguration *>(source); - return new BlackBerryDeployConfiguration(parent, old); -} diff --git a/src/plugins/qnx/blackberrydeployconfigurationfactory.h b/src/plugins/qnx/blackberrydeployconfigurationfactory.h deleted file mode 100644 index 37a144f0a5a..00000000000 --- a/src/plugins/qnx/blackberrydeployconfigurationfactory.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONFACTORY_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONFACTORY_H - -#include <projectexplorer/deployconfiguration.h> - -namespace ProjectExplorer { class Target; } - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployConfigurationFactory : public ProjectExplorer::DeployConfigurationFactory -{ - Q_OBJECT -public: - explicit BlackBerryDeployConfigurationFactory(QObject *parent = 0); - ~BlackBerryDeployConfigurationFactory(); - - QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent) const; - QString displayNameForId(Core::Id id) const; - - bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const; - ProjectExplorer::DeployConfiguration *create(ProjectExplorer::Target *parent, Core::Id id); - - bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const; - ProjectExplorer::DeployConfiguration *restore(ProjectExplorer::Target *parent, - const QVariantMap &map); - - bool canClone(ProjectExplorer::Target *parent, - ProjectExplorer::DeployConfiguration *source) const; - ProjectExplorer::DeployConfiguration *clone(ProjectExplorer::Target *parent, - ProjectExplorer::DeployConfiguration *source); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONFACTORY_H diff --git a/src/plugins/qnx/blackberrydeployconfigurationwidget.cpp b/src/plugins/qnx/blackberrydeployconfigurationwidget.cpp deleted file mode 100644 index 51c5cd78017..00000000000 --- a/src/plugins/qnx/blackberrydeployconfigurationwidget.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeployconfigurationwidget.h" -#include "ui_blackberrydeployconfigurationwidget.h" -#include "blackberrydeployconfiguration.h" -#include "blackberrydeployinformation.h" -#include "pathchooserdelegate.h" - -#include <coreplugin/icore.h> -#include <projectexplorer/devicesupport/devicemanager.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <utils/pathchooser.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeployConfigurationWidget::BlackBerryDeployConfigurationWidget(BlackBerryDeployConfiguration *dc, - QWidget *parent) - : ProjectExplorer::NamedWidget(parent) - , m_ui(new Ui::BlackBerryDeployConfigurationWidget) - , m_deployConfiguration(0) -{ - m_ui->setupUi(this); - m_deployConfiguration = dc; - - m_ui->deployPackagesView->setModel(m_deployConfiguration->deploymentInfo()); - - PathChooserDelegate *appDescriptorPathDelegate = new PathChooserDelegate(this); - appDescriptorPathDelegate->setExpectedKind(Utils::PathChooser::File); - appDescriptorPathDelegate->setHistoryCompleter(QLatin1String("BB.BarXml.History")); - appDescriptorPathDelegate->setPromptDialogFilter(QLatin1String("*.xml")); - - PathChooserDelegate *barPathDelegate = new PathChooserDelegate(this); - barPathDelegate->setExpectedKind(Utils::PathChooser::File); - barPathDelegate->setHistoryCompleter(QLatin1String("BB.AppBar.History")); - barPathDelegate->setPromptDialogFilter(QLatin1String("*.bar")); - - m_ui->deployPackagesView->setItemDelegateForColumn(1, appDescriptorPathDelegate); - m_ui->deployPackagesView->setItemDelegateForColumn(2, barPathDelegate); - - m_ui->deployPackagesView->header()->resizeSections(QHeaderView::ResizeToContents); -} - -BlackBerryDeployConfigurationWidget::~BlackBerryDeployConfigurationWidget() -{ - delete m_ui; -} diff --git a/src/plugins/qnx/blackberrydeployconfigurationwidget.h b/src/plugins/qnx/blackberrydeployconfigurationwidget.h deleted file mode 100644 index cb06ed63230..00000000000 --- a/src/plugins/qnx/blackberrydeployconfigurationwidget.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONWIDGET_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONWIDGET_H - -#include <projectexplorer/deployconfiguration.h> -#include <projectexplorer/namedwidget.h> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BlackBerryDeployConfigurationWidget; } - -class BlackBerryDeployConfiguration; - -class BlackBerryDeployConfigurationWidget : public ProjectExplorer::NamedWidget -{ - Q_OBJECT -public: - explicit BlackBerryDeployConfigurationWidget(BlackBerryDeployConfiguration *dc, QWidget *parent = 0); - ~BlackBerryDeployConfigurationWidget(); - -private: - Ui::BlackBerryDeployConfigurationWidget *m_ui; - - BlackBerryDeployConfiguration *m_deployConfiguration; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYCONFIGURATIONWIDGET_H diff --git a/src/plugins/qnx/blackberrydeployconfigurationwidget.ui b/src/plugins/qnx/blackberrydeployconfigurationwidget.ui deleted file mode 100644 index 393ed5c2f63..00000000000 --- a/src/plugins/qnx/blackberrydeployconfigurationwidget.ui +++ /dev/null @@ -1,41 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDeployConfigurationWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryDeployConfigurationWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>599</width> - <height>213</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Packages to deploy:</string> - </property> - </widget> - </item> - <item> - <widget class="QTreeView" name="deployPackagesView"> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="textElideMode"> - <enum>Qt::ElideLeft</enum> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <property name="itemsExpandable"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydeployinformation.cpp b/src/plugins/qnx/blackberrydeployinformation.cpp deleted file mode 100644 index fa81f9b4034..00000000000 --- a/src/plugins/qnx/blackberrydeployinformation.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeployinformation.h" - -#include "blackberrydeployconfiguration.h" - -#include <projectexplorer/buildconfiguration.h> -#include <projectexplorer/target.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <qmakeprojectmanager/qmakenodes.h> -#include <qtsupport/baseqtversion.h> -#include <qtsupport/qtkitinformation.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char COUNT_KEY[] = "Qnx.BlackBerry.DeployInformationCount"; -const char DEPLOYINFO_KEY[] = "Qnx.BlackBerry.DeployInformation.%1"; - -const char ENABLED_KEY[] = "Qnx.BlackBerry.DeployInformation.Enabled"; -const char APPDESCRIPTOR_KEY[] = "Qnx.BlackBerry.DeployInformation.AppDescriptor"; -const char PACKAGE_KEY[] = "Qnx.BlackBerry.DeployInformation.Package"; -const char PROFILE_KEY[] = "Qnx.BlackBerry.DeployInformation.ProFile"; -const char TARGET_KEY[] = "Qnx.BlackBerry.DeployInformation.Target"; -const char SOURCE_KEY[] = "Qnx.BlackBerry.DeployInformation.Source"; -} - -Utils::FileName BarPackageDeployInformation::appDescriptorPath() const -{ - if (userAppDescriptorPath.isEmpty()) - return Utils::FileName(sourceDir).appendPath(QLatin1String("bar-descriptor.xml")); - - return userAppDescriptorPath; -} - -Utils::FileName BarPackageDeployInformation::packagePath() const -{ - if (userPackagePath.isEmpty()) - return Utils::FileName(buildDir).appendPath(targetName).appendString(QLatin1String(".bar")); - - return userPackagePath; -} - -// ---------------------------------------------------------------------------- - -BlackBerryDeployInformation::BlackBerryDeployInformation(ProjectExplorer::Target *target) - : QAbstractTableModel(target) - , m_target(target) -{ - connect(project(), SIGNAL(proFilesEvaluated()), this, SLOT(updateModel())); -} - -int BlackBerryDeployInformation::rowCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return m_deployInformation.count(); -} - -int BlackBerryDeployInformation::columnCount(const QModelIndex &parent) const -{ - if (parent.isValid()) - return 0; - - return ColumnCount; -} - -QVariant BlackBerryDeployInformation::data(const QModelIndex &index, int role) const -{ - if (!index.isValid()) - return QVariant(); - - if (index.row() >= m_deployInformation.count() || index.column() >= ColumnCount) - return QVariant(); - - BarPackageDeployInformation di = m_deployInformation[index.row()]; - if (role == Qt::CheckStateRole) { - if (index.column() == EnabledColumn) - return di.enabled ? Qt::Checked : Qt::Unchecked; - } else if (role == Qt::DisplayRole || role == Qt::EditRole) { - if (index.column() == AppDescriptorColumn) - return di.appDescriptorPath().toUserOutput(); - else if (index.column() == PackageColumn) - return di.packagePath().toUserOutput(); - } - - return QVariant(); -} - -QVariant BlackBerryDeployInformation::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Vertical || role != Qt::DisplayRole) - return QVariant(); - - switch (section) { - case EnabledColumn: - return tr("Enabled"); - case AppDescriptorColumn: - return tr("Application descriptor file"); - case PackageColumn: - return tr("Package"); - default: - return QVariant(); - } -} - -bool BlackBerryDeployInformation::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (!index.isValid()) - return false; - if (index.row() >= m_deployInformation.count() || index.column() >= ColumnCount) - return false; - - BarPackageDeployInformation &di = m_deployInformation[index.row()]; - if (role == Qt::CheckStateRole && index.column() == EnabledColumn) { - di.enabled = static_cast<Qt::CheckState>(value.toInt()) == Qt::Checked; - } else if (role == Qt::EditRole) { - if (index.column() == AppDescriptorColumn) - di.userAppDescriptorPath = Utils::FileName::fromString(value.toString()); - else if (index.column() == PackageColumn) - di.userPackagePath = Utils::FileName::fromString(value.toString()); - } - - emit dataChanged(index, index); - return true; -} - -Qt::ItemFlags BlackBerryDeployInformation::flags(const QModelIndex &index) const -{ - Qt::ItemFlags flags = QAbstractTableModel::flags(index); - switch (index.column()) { - case EnabledColumn: - flags |= Qt::ItemIsEditable | Qt::ItemIsUserCheckable; - break; - case AppDescriptorColumn: - case PackageColumn: - flags |= Qt::ItemIsEditable; - break; - } - - return flags; -} - -QList<BarPackageDeployInformation> BlackBerryDeployInformation::enabledPackages() const -{ - QList<BarPackageDeployInformation> result; - - foreach (const BarPackageDeployInformation& info, m_deployInformation) { - if (info.enabled) - result << info; - } - - return result; -} - -QList<BarPackageDeployInformation> BlackBerryDeployInformation::allPackages() const -{ - return m_deployInformation; -} - -QVariantMap BlackBerryDeployInformation::toMap() const -{ - QVariantMap outerMap; - outerMap[QLatin1String(COUNT_KEY)] = m_deployInformation.size(); - - for (int i = 0; i < m_deployInformation.size(); ++i) { - const BarPackageDeployInformation &deployInfo = m_deployInformation[i]; - - QVariantMap deployInfoMap; - deployInfoMap[QLatin1String(ENABLED_KEY)] = deployInfo.enabled; - deployInfoMap[QLatin1String(APPDESCRIPTOR_KEY)] = deployInfo.userAppDescriptorPath.toString(); - deployInfoMap[QLatin1String(PACKAGE_KEY)] = deployInfo.userPackagePath.toString(); - deployInfoMap[QLatin1String(PROFILE_KEY)] = deployInfo.proFilePath.toString(); - deployInfoMap[QLatin1String(TARGET_KEY)] = deployInfo.targetName; - deployInfoMap[QLatin1String(SOURCE_KEY)] = deployInfo.sourceDir.toString(); - - outerMap[QString::fromLatin1(DEPLOYINFO_KEY).arg(i)] = deployInfoMap; - } - - return outerMap; -} - -void BlackBerryDeployInformation::fromMap(const QVariantMap &map) -{ - beginResetModel(); - m_deployInformation.clear(); - - int count = map.value(QLatin1String(COUNT_KEY)).toInt(); - for (int i = 0; i < count; ++i) { - QVariantMap innerMap = map.value(QString::fromLatin1(DEPLOYINFO_KEY).arg(i)).toMap(); - - const bool enabled = innerMap.value(QLatin1String(ENABLED_KEY)).toBool(); - const QString appDescriptorPath = innerMap.value(QLatin1String(APPDESCRIPTOR_KEY)).toString(); - const QString packagePath = innerMap.value(QLatin1String(PACKAGE_KEY)).toString(); - const QString proFilePath = innerMap.value(QLatin1String(PROFILE_KEY)).toString(); - const QString targetName = innerMap.value(QLatin1String(TARGET_KEY)).toString(); - const QString sourceDir = innerMap.value(QLatin1String(SOURCE_KEY)).toString(); - - BarPackageDeployInformation deployInformation(enabled, Utils::FileName::fromString(proFilePath), - Utils::FileName::fromString(sourceDir), - m_target->activeBuildConfiguration()->buildDirectory(), - targetName); - deployInformation.userAppDescriptorPath = Utils::FileName::fromString(appDescriptorPath); - deployInformation.userPackagePath = Utils::FileName::fromString(packagePath); - m_deployInformation << deployInformation; - } - - endResetModel(); -} - -ProjectExplorer::Target *BlackBerryDeployInformation::target() const -{ - return m_target; -} - -void BlackBerryDeployInformation::updateModel() -{ - if (m_deployInformation.isEmpty()) { - initModel(); - return; - } - - beginResetModel(); - QList<BarPackageDeployInformation> keep; - QList<QmakeProjectManager::QmakeProFileNode *> appNodes = project()->applicationProFiles(); - foreach (QmakeProjectManager::QmakeProFileNode *node, appNodes) { - bool nodeFound = false; - for (int i = 0; i < m_deployInformation.size(); ++i) { - if (m_deployInformation[i].proFilePath == node->path() - && (!m_deployInformation[i].userAppDescriptorPath.isEmpty() - || !m_deployInformation[i].userPackagePath.isEmpty())) { - BarPackageDeployInformation deployInformation = m_deployInformation[i]; - // In case the user resets the bar package path (or if it is empty already), we need the current build dir - deployInformation.buildDir = m_target->activeBuildConfiguration()->buildDirectory(); - keep << deployInformation; - nodeFound = true; - break; - } - } - - if (!nodeFound) - keep << deployInformationFromNode(node); - } - m_deployInformation = keep; - endResetModel(); -} - -QmakeProjectManager::QmakeProject *BlackBerryDeployInformation::project() const -{ - return static_cast<QmakeProjectManager::QmakeProject *>(m_target->project()); -} - -void BlackBerryDeployInformation::initModel() -{ - if (!m_deployInformation.isEmpty()) - return; - - QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(m_target->kit()); - if (!version || !version->isValid()) { - beginResetModel(); - m_deployInformation.clear(); - endResetModel(); - return; - } - - const QmakeProjectManager::QmakeProFileNode *const rootNode = project()->rootQmakeProjectNode(); - if (!rootNode || rootNode->parseInProgress()) // Can be null right after project creation by wizard. - return; - - disconnect(project(), SIGNAL(proFilesEvaluated()), this, SLOT(updateModel())); - - beginResetModel(); - m_deployInformation.clear(); - - QList<QmakeProjectManager::QmakeProFileNode *> appNodes = project()->applicationProFiles(); - foreach (QmakeProjectManager::QmakeProFileNode *node, appNodes) - m_deployInformation << deployInformationFromNode(node); - - endResetModel(); - connect(project(), SIGNAL(proFilesEvaluated()), this, SLOT(updateModel())); -} - -BarPackageDeployInformation BlackBerryDeployInformation::deployInformationFromNode(QmakeProjectManager::QmakeProFileNode *node) const -{ - QmakeProjectManager::TargetInformation ti = node->targetInformation(); - - const Utils::FileName buildDir = m_target->activeBuildConfiguration()->buildDirectory(); - - return BarPackageDeployInformation(true, node->path(), node->path(), buildDir, ti.target); -} diff --git a/src/plugins/qnx/blackberrydeployinformation.h b/src/plugins/qnx/blackberrydeployinformation.h deleted file mode 100644 index 0e059410066..00000000000 --- a/src/plugins/qnx/blackberrydeployinformation.h +++ /dev/null @@ -1,126 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYINFORMATION_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYINFORMATION_H - -#include <utils/fileutils.h> - -#include <QAbstractTableModel> - -namespace ProjectExplorer { class Target; } - -namespace QmakeProjectManager { -class QmakeProFileNode; -class QmakeProject; -} - -namespace Qnx { -namespace Internal { - -class BarPackageDeployInformation { -public: - BarPackageDeployInformation(bool enabled, - const Utils::FileName &proFilePath, - const Utils::FileName &sourceDir, - const Utils::FileName &buildDir, - const QString &targetName) - : enabled(enabled) - , proFilePath(proFilePath) - , sourceDir(sourceDir) - , buildDir(buildDir) - , targetName(targetName) - { - } - - Utils::FileName appDescriptorPath() const; - Utils::FileName packagePath() const; - - bool enabled; - Utils::FileName proFilePath; - Utils::FileName sourceDir; - Utils::FileName buildDir; - QString targetName; - - Utils::FileName userAppDescriptorPath; - Utils::FileName userPackagePath; -}; - -class BlackBerryDeployInformation : public QAbstractTableModel -{ - Q_OBJECT -public: - explicit BlackBerryDeployInformation(ProjectExplorer::Target *target); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - - Qt::ItemFlags flags(const QModelIndex &index) const; - - QList<BarPackageDeployInformation> enabledPackages() const; - QList<BarPackageDeployInformation> allPackages() const; - - QVariantMap toMap() const; - void fromMap(const QVariantMap &map); - - ProjectExplorer::Target *target() const; - -private slots: - void updateModel(); - -private: - enum Columns { - EnabledColumn = 0, - AppDescriptorColumn, - PackageColumn, - ColumnCount // Always have last - }; - - QmakeProjectManager::QmakeProject *project() const; - - void initModel(); - BarPackageDeployInformation deployInformationFromNode(QmakeProjectManager::QmakeProFileNode *node) const; - - ProjectExplorer::Target *m_target; - - QList<BarPackageDeployInformation> m_deployInformation; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYINFORMATION_H diff --git a/src/plugins/qnx/blackberrydeploystep.cpp b/src/plugins/qnx/blackberrydeploystep.cpp deleted file mode 100644 index ebce6d50295..00000000000 --- a/src/plugins/qnx/blackberrydeploystep.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeploystep.h" - -#include "qnxconstants.h" -#include "blackberrydeployconfiguration.h" -#include "blackberrydeploystepconfigwidget.h" -#include "qnxutils.h" -#include "blackberrydeployinformation.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> -#include <qmakeprojectmanager/qmakebuildconfiguration.h> -#include <utils/qtcassert.h> -#include <ssh/sshconnection.h> - -#include <QDir> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeployStep::BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl) - : BlackBerryAbstractDeployStep(bsl, Core::Id(Constants::QNX_DEPLOY_PACKAGE_BS_ID)) -{ - setDisplayName(tr("Deploy packages")); -} - -BlackBerryDeployStep::BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryDeployStep *bs) - : BlackBerryAbstractDeployStep(bsl, bs) -{ - setDisplayName(tr("Deploy packages")); -} - -BlackBerryDeployStep::~BlackBerryDeployStep() -{ -} - -bool BlackBerryDeployStep::init() -{ - if (!BlackBerryAbstractDeployStep::init()) - return false; - - Utils::FileName deployCmd = - target()->activeBuildConfiguration()->environment().searchInPath( - QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD)); - if (deployCmd.isEmpty()) { - raiseError(tr("Could not find deploy command \"%1\" in the build environment") - .arg(QLatin1String(Constants::QNX_BLACKBERRY_DEPLOY_CMD))); - return false; - } - - if (deviceHost().isEmpty()) { - raiseError(tr("No hostname specified for device")); - return false; - } - - BlackBerryDeployConfiguration *deployConfig = qobject_cast<BlackBerryDeployConfiguration *>(deployConfiguration()); - QTC_ASSERT(deployConfig, return false); - - QList<BarPackageDeployInformation> packagesToDeploy = deployConfig->deploymentInfo()->enabledPackages(); - if (packagesToDeploy.isEmpty()) { - raiseError(tr("No packages enabled for deployment")); - return false; - } - - foreach (const BarPackageDeployInformation &info, packagesToDeploy) { - QStringList args; - args << QLatin1String("-installApp"); - args << QLatin1String("-device") << deviceHost(); - if (!password().isEmpty()) - args << QLatin1String("-password") << password(); - args << QnxUtils::addQuotes(info.packagePath().toUserOutput()); - - addCommand(deployCmd.toString(), args); - } - - return true; -} - -void BlackBerryDeployStep::run(QFutureInterface<bool> &fi) -{ - BlackBerryDeployConfiguration *deployConfig = qobject_cast<BlackBerryDeployConfiguration *>(deployConfiguration()); - QTC_ASSERT(deployConfig, return); - - QList<BarPackageDeployInformation> packagesToDeploy = deployConfig->deploymentInfo()->enabledPackages(); - foreach (const BarPackageDeployInformation &info, packagesToDeploy) { - if (!info.packagePath().exists()) { - raiseError(tr("Package \"%1\" does not exist. Create the package first.") - .arg(info.packagePath().toUserOutput())); - fi.reportResult(false); - return; - } - } - - BlackBerryAbstractDeployStep::run(fi); -} - -void BlackBerryDeployStep::cleanup() -{ -} - -void BlackBerryDeployStep::processStarted(const ProjectExplorer::ProcessParameters ¶ms) -{ - QString arguments = params.prettyArguments(); - if (!password().isEmpty()) { - const QString passwordLine = QLatin1String(" -password ") + password(); - const QString hiddenPasswordLine = QLatin1String(" -password <hidden>"); - arguments.replace(passwordLine, hiddenPasswordLine); - } - - emitOutputInfo(params, arguments); -} - -ProjectExplorer::BuildStepConfigWidget *BlackBerryDeployStep::createConfigWidget() -{ - return new BlackBerryDeployStepConfigWidget(); -} - -QString BlackBerryDeployStep::deviceHost() const -{ - BlackBerryDeviceConfiguration::ConstPtr device - = BlackBerryDeviceConfiguration::device(target()->kit()); - if (device) - return device->sshParameters().host; - return QString(); -} - -QString BlackBerryDeployStep::password() const -{ - BlackBerryDeviceConfiguration::ConstPtr device - = BlackBerryDeviceConfiguration::device(target()->kit()); - if (device) - return device->sshParameters().password; - return QString(); -} diff --git a/src/plugins/qnx/blackberrydeploystep.h b/src/plugins/qnx/blackberrydeploystep.h deleted file mode 100644 index bca69a34b5a..00000000000 --- a/src/plugins/qnx/blackberrydeploystep.h +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYSTEP_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYSTEP_H - -#include "blackberryabstractdeploystep.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployStep : public BlackBerryAbstractDeployStep -{ - Q_OBJECT - friend class BlackBerryDeployStepFactory; - -public: - explicit BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl); - ~BlackBerryDeployStep(); - - bool init(); - void run(QFutureInterface<bool> &fi); - void cleanup(); - - ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); - -protected: - BlackBerryDeployStep(ProjectExplorer::BuildStepList *bsl, BlackBerryDeployStep *bs); - - void processStarted(const ProjectExplorer::ProcessParameters ¶ms); - -private: - QString deviceHost() const; - QString password() const; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYSTEP_H diff --git a/src/plugins/qnx/blackberrydeploystepconfigwidget.cpp b/src/plugins/qnx/blackberrydeploystepconfigwidget.cpp deleted file mode 100644 index 449be7550c9..00000000000 --- a/src/plugins/qnx/blackberrydeploystepconfigwidget.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeploystepconfigwidget.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeployStepConfigWidget::BlackBerryDeployStepConfigWidget() - : ProjectExplorer::BuildStepConfigWidget() -{ -} - -QString BlackBerryDeployStepConfigWidget::summaryText() const -{ - return displayName(); -} - -QString BlackBerryDeployStepConfigWidget::displayName() const -{ - return tr("<b>Deploy packages</b>"); -} - -bool BlackBerryDeployStepConfigWidget::showWidget() const -{ - return false; -} diff --git a/src/plugins/qnx/blackberrydeploystepconfigwidget.h b/src/plugins/qnx/blackberrydeploystepconfigwidget.h deleted file mode 100644 index 5f4d390b429..00000000000 --- a/src/plugins/qnx/blackberrydeploystepconfigwidget.h +++ /dev/null @@ -1,56 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYSTEPCONFIGWIDGET_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYSTEPCONFIGWIDGET_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployStepConfigWidget : public ProjectExplorer::BuildStepConfigWidget -{ - Q_OBJECT -public: - explicit BlackBerryDeployStepConfigWidget(); - - QString summaryText() const; - QString displayName() const; - - bool showWidget() const; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYSTEPCONFIGWIDGET_H diff --git a/src/plugins/qnx/blackberrydeploystepfactory.cpp b/src/plugins/qnx/blackberrydeploystepfactory.cpp deleted file mode 100644 index 6f8fd6118cf..00000000000 --- a/src/plugins/qnx/blackberrydeploystepfactory.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeploystepfactory.h" -#include "qnxconstants.h" -#include "blackberrydeploystep.h" -#include "blackberrydeviceconfigurationfactory.h" - -#include <projectexplorer/buildsteplist.h> -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/target.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeployStepFactory::BlackBerryDeployStepFactory() -{ -} - -QList<Core::Id> BlackBerryDeployStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const -{ - if (parent->id() != ProjectExplorer::Constants::BUILDSTEPS_DEPLOY) - return QList<Core::Id>(); - - Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(parent->target()->kit()); - if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType()) - return QList<Core::Id>(); - - return QList<Core::Id>() << Core::Id(Constants::QNX_DEPLOY_PACKAGE_BS_ID); -} - -QString BlackBerryDeployStepFactory::displayNameForId(Core::Id id) const -{ - if (id == Constants::QNX_DEPLOY_PACKAGE_BS_ID) - return tr("Deploy Package"); - return QString(); -} - -bool BlackBerryDeployStepFactory::canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const -{ - return availableCreationIds(parent).contains(id); -} - -ProjectExplorer::BuildStep *BlackBerryDeployStepFactory::create(ProjectExplorer::BuildStepList *parent, - const Core::Id id) -{ - if (!canCreate(parent, id)) - return 0; - return new BlackBerryDeployStep(parent); -} - -bool BlackBerryDeployStepFactory::canRestore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) const -{ - return canCreate(parent, ProjectExplorer::idFromMap(map)); -} - -ProjectExplorer::BuildStep *BlackBerryDeployStepFactory::restore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map) -{ - if (!canRestore(parent, map)) - return 0; - BlackBerryDeployStep *bs = new BlackBerryDeployStep(parent); - if (bs->fromMap(map)) - return bs; - delete bs; - return 0; -} - -bool BlackBerryDeployStepFactory::canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) const -{ - return canCreate(parent, product->id()); -} - -ProjectExplorer::BuildStep *BlackBerryDeployStepFactory::clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) -{ - if (!canClone(parent, product)) - return 0; - return new BlackBerryDeployStep(parent, static_cast<BlackBerryDeployStep *>(product)); -} diff --git a/src/plugins/qnx/blackberrydeploystepfactory.h b/src/plugins/qnx/blackberrydeploystepfactory.h deleted file mode 100644 index 73307de7d1a..00000000000 --- a/src/plugins/qnx/blackberrydeploystepfactory.h +++ /dev/null @@ -1,66 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEPLOYSTEPFACTORY_H -#define QNX_INTERNAL_BLACKBERRYDEPLOYSTEPFACTORY_H - -#include <projectexplorer/buildstep.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployStepFactory : public ProjectExplorer::IBuildStepFactory -{ - Q_OBJECT -public: - BlackBerryDeployStepFactory(); - - QList<Core::Id> availableCreationIds(ProjectExplorer::BuildStepList *parent) const; - QString displayNameForId(Core::Id id) const; - - bool canCreate(ProjectExplorer::BuildStepList *parent, Core::Id id) const; - ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, Core::Id id); - - bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; - ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, - const QVariantMap &map); - - bool canClone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product) const; - ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, - ProjectExplorer::BuildStep *product); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEPLOYSTEPFACTORY_H diff --git a/src/plugins/qnx/blackberrydeviceconfiguration.cpp b/src/plugins/qnx/blackberrydeviceconfiguration.cpp deleted file mode 100644 index 07e3efae5e6..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfiguration.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconfiguration.h" - -#include "qnxconstants.h" -#include "qnxdeviceprocesssignaloperation.h" -#include "qnxdeployqtlibrariesdialog.h" -#include "blackberrydeviceconfigurationwidget.h" -#include "blackberrydeviceconnectionmanager.h" -#include "qnxdeviceprocesslist.h" - -#include <projectexplorer/kitinformation.h> -#include <ssh/sshconnection.h> - -using namespace Qnx; -using namespace Qnx::Internal; -using namespace ProjectExplorer; - -namespace { -const char ConnectToDeviceActionId[] = "Qnx.BlackBerry.ConnectToDeviceAction"; -const char DisconnectFromDeviceActionId[] = "Qnx.BlackBerry.DisconnectFromDeviceAction"; -const char DeployQtLibrariesActionId[] = "Qnx.BlackBerry.DeployQtLibrariesAction"; -} - -BlackBerryDeviceConfiguration::BlackBerryDeviceConfiguration() - : RemoteLinux::LinuxDevice() -{ -} - -BlackBerryDeviceConfiguration::BlackBerryDeviceConfiguration(const QString &name, Core::Id type, - IDevice::MachineType machineType, - IDevice::Origin origin, Core::Id id) - : RemoteLinux::LinuxDevice(name, type, machineType, origin, id) -{ -} - -BlackBerryDeviceConfiguration::BlackBerryDeviceConfiguration(const BlackBerryDeviceConfiguration &other) - : RemoteLinux::LinuxDevice(other) - , m_debugToken(other.m_debugToken) -{ -} - -BlackBerryDeviceConfiguration::Ptr BlackBerryDeviceConfiguration::create() -{ - return Ptr(new BlackBerryDeviceConfiguration); -} - -BlackBerryDeviceConfiguration::Ptr BlackBerryDeviceConfiguration::create(const QString &name, Core::Id type, - IDevice::MachineType machineType, - IDevice::Origin origin, Core::Id id) -{ - return Ptr(new BlackBerryDeviceConfiguration(name, type, machineType, origin, id)); -} - -QString BlackBerryDeviceConfiguration::debugToken() const -{ - return m_debugToken; -} - -void BlackBerryDeviceConfiguration::setDebugToken(const QString &debugToken) -{ - m_debugToken = debugToken; -} - -void BlackBerryDeviceConfiguration::fromMap(const QVariantMap &map) -{ - RemoteLinux::LinuxDevice::fromMap(map); - m_debugToken = map.value(QLatin1String(Constants::QNX_DEBUG_TOKEN_KEY)).toString(); -} - -IDevice::Ptr BlackBerryDeviceConfiguration::clone() const -{ - return Ptr(new BlackBerryDeviceConfiguration(*this)); -} - -bool BlackBerryDeviceConfiguration::hasDeviceTester() const -{ - // we are unable to easily verify that a device is available unless we duplicate - // 'Connect to device' functionality, therefore disabling device-tester - return false; -} - -BlackBerryDeviceConfiguration::ConstPtr BlackBerryDeviceConfiguration::device(const Kit *k) -{ - IDevice::ConstPtr dev = DeviceKitInformation::device(k); - return dev.dynamicCast<const BlackBerryDeviceConfiguration>(); -} - -QString BlackBerryDeviceConfiguration::displayType() const -{ - return tr("BlackBerry"); -} - -IDeviceWidget *BlackBerryDeviceConfiguration::createWidget() -{ - return new BlackBerryDeviceConfigurationWidget(sharedFromThis() - .staticCast<BlackBerryDeviceConfiguration>()); -} - -QList<Core::Id> BlackBerryDeviceConfiguration::actionIds() const -{ - return QList<Core::Id>() << Core::Id(ConnectToDeviceActionId) - << Core::Id(DisconnectFromDeviceActionId) - << Core::Id(DeployQtLibrariesActionId); -} - -QString BlackBerryDeviceConfiguration::displayNameForActionId(Core::Id actionId) const -{ - if (actionId == Core::Id(ConnectToDeviceActionId)) - return tr("Connect to device"); - else if (actionId == Core::Id(DisconnectFromDeviceActionId)) - return tr("Disconnect from device"); - else if (actionId == Core::Id(DeployQtLibrariesActionId)) - return tr("Deploy Qt libraries..."); - - return QString(); -} - -void BlackBerryDeviceConfiguration::executeAction(Core::Id actionId, QWidget *parent) -{ - Q_UNUSED(parent); - - const BlackBerryDeviceConfiguration::ConstPtr device = - sharedFromThis().staticCast<const BlackBerryDeviceConfiguration>(); - - BlackBerryDeviceConnectionManager *connectionManager = - BlackBerryDeviceConnectionManager::instance(); - if (actionId == Core::Id(ConnectToDeviceActionId)) { - connectionManager->connectDevice(device); - } else if (actionId == Core::Id(DisconnectFromDeviceActionId) - && connectionManager->isConnected(id())) { - connectionManager->disconnectDevice(device); - } else if (actionId == Core::Id(DeployQtLibrariesActionId)) { - QnxDeployQtLibrariesDialog dialog(device, QnxDeployQtLibrariesDialog::BB10, parent); - dialog.exec(); - } -} - -QVariantMap BlackBerryDeviceConfiguration::toMap() const -{ - QVariantMap map = RemoteLinux::LinuxDevice::toMap(); - map.insert(QLatin1String(Constants::QNX_DEBUG_TOKEN_KEY), m_debugToken); - return map; -} - -DeviceProcessList *BlackBerryDeviceConfiguration::createProcessListModel(QObject *parent) const -{ - return new QnxDeviceProcessList(sharedFromThis(), parent); -} - -DeviceProcessSignalOperation::Ptr BlackBerryDeviceConfiguration::signalOperation() const -{ - return DeviceProcessSignalOperation::Ptr( - new BlackBerryDeviceProcessSignalOperation(sshParameters())); -} diff --git a/src/plugins/qnx/blackberrydeviceconfiguration.h b/src/plugins/qnx/blackberrydeviceconfiguration.h deleted file mode 100644 index 6ef38f4ef7e..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfiguration.h +++ /dev/null @@ -1,87 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATION_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATION_H - -#include <remotelinux/linuxdevice.h> - -namespace ProjectExplorer { class Kit; } - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceConfiguration : public RemoteLinux::LinuxDevice -{ - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryDeviceConfiguration) -public: - typedef QSharedPointer<BlackBerryDeviceConfiguration> Ptr; - typedef QSharedPointer<const BlackBerryDeviceConfiguration> ConstPtr; - - - static Ptr create(); - static Ptr create(const QString &name, Core::Id type, MachineType machineType, - Origin origin = ManuallyAdded, Core::Id id = Core::Id()); - - QString debugToken() const; - void setDebugToken(const QString &debugToken); - - void fromMap(const QVariantMap &map); - - QString displayType() const; - ProjectExplorer::IDeviceWidget *createWidget(); - QList<Core::Id> actionIds() const; - QString displayNameForActionId(Core::Id actionId) const; - void executeAction(Core::Id actionId, QWidget *parent); - ProjectExplorer::IDevice::Ptr clone() const; - ProjectExplorer::DeviceProcessList *createProcessListModel(QObject *parent) const; - bool hasDeviceTester() const; - ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const; - - static ConstPtr device(const ProjectExplorer::Kit *k); - -protected: - BlackBerryDeviceConfiguration(); - BlackBerryDeviceConfiguration(const QString &name, Core::Id type, MachineType machineType, - Origin origin, Core::Id id); - BlackBerryDeviceConfiguration(const BlackBerryDeviceConfiguration &other); - - QVariantMap toMap() const; - -private: - QString m_debugToken; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATION_H diff --git a/src/plugins/qnx/blackberrydeviceconfigurationfactory.cpp b/src/plugins/qnx/blackberrydeviceconfigurationfactory.cpp deleted file mode 100644 index 61585b61f54..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationfactory.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconfigurationfactory.h" - -#include "qnxconstants.h" -#include "blackberrydeviceconfigurationwizard.h" -#include "blackberrydeviceconfiguration.h" - -#include <utils/qtcassert.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeviceConfigurationFactory::BlackBerryDeviceConfigurationFactory(QObject *parent) : - ProjectExplorer::IDeviceFactory(parent) -{ -} - -QString BlackBerryDeviceConfigurationFactory::displayNameForId(Core::Id type) const -{ - Q_UNUSED(type); - return tr("BlackBerry Device"); -} - -QList<Core::Id> BlackBerryDeviceConfigurationFactory::availableCreationIds() const -{ - QList<Core::Id> result; - result << Core::Id(Constants::QNX_BB_OS_TYPE); - return result; -} - -bool BlackBerryDeviceConfigurationFactory::canCreate() const -{ - return true; -} - -ProjectExplorer::IDevice::Ptr BlackBerryDeviceConfigurationFactory::create(Core::Id id) const -{ - Q_UNUSED(id); - BlackBerryDeviceConfigurationWizard wizard; - if (wizard.exec() != QDialog::Accepted) - return ProjectExplorer::IDevice::Ptr(); - return wizard.device(); -} - -bool BlackBerryDeviceConfigurationFactory::canRestore(const QVariantMap &map) const -{ - return ProjectExplorer::IDevice::typeFromMap(map) == Constants::QNX_BB_OS_TYPE; -} - -ProjectExplorer::IDevice::Ptr BlackBerryDeviceConfigurationFactory::restore(const QVariantMap &map) const -{ - QTC_ASSERT(canRestore(map), return BlackBerryDeviceConfiguration::Ptr()); - const BlackBerryDeviceConfiguration::Ptr device = BlackBerryDeviceConfiguration::create(); - device->fromMap(map); - return device; -} - -Core::Id BlackBerryDeviceConfigurationFactory::deviceType() -{ - return Core::Id(Constants::QNX_BB_OS_TYPE); -} diff --git a/src/plugins/qnx/blackberrydeviceconfigurationfactory.h b/src/plugins/qnx/blackberrydeviceconfigurationfactory.h deleted file mode 100644 index 67067f488d3..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationfactory.h +++ /dev/null @@ -1,62 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONFACTORY_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONFACTORY_H - -#include <projectexplorer/devicesupport/idevicefactory.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceConfigurationFactory : public ProjectExplorer::IDeviceFactory -{ - Q_OBJECT -public: - explicit BlackBerryDeviceConfigurationFactory(QObject *parent = 0); - - QString displayNameForId(Core::Id type) const; - QList<Core::Id> availableCreationIds() const; - - bool canCreate() const; - ProjectExplorer::IDevice::Ptr create(Core::Id id) const; - - bool canRestore(const QVariantMap &map) const; - ProjectExplorer::IDevice::Ptr restore(const QVariantMap &map) const; - - static Core::Id deviceType(); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONFACTORY_H diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp deleted file mode 100644 index 48da7658b4c..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.cpp +++ /dev/null @@ -1,296 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconfigurationwidget.h" -#include "blackberrydebugtokenuploader.h" -#include "blackberrydebugtokenrequestdialog.h" -#include "ui_blackberrydeviceconfigurationwidget.h" -#include "blackberrydeviceconnectionmanager.h" -#include "blackberrysigningutils.h" -#include "blackberrydebugtokenreader.h" -#include "qnxconstants.h" -#include "qnxutils.h" - -#include <ssh/sshconnection.h> -#include <texteditor/texteditorsettings.h> -#include <texteditor/fontsettings.h> -#include <utils/pathchooser.h> -#include <utils/fancylineedit.h> - -#include <QProgressDialog> -#include <QMessageBox> -#include <QFileInfo> -#include <QFileDialog> -#include <QDir> -#include <QAbstractButton> - -using namespace ProjectExplorer; -using namespace Qnx::Internal; - -BlackBerryDeviceConfigurationWidget::BlackBerryDeviceConfigurationWidget(const IDevice::Ptr &device, QWidget *parent) : - IDeviceWidget(device, parent), - ui(new Ui::BlackBerryDeviceConfigurationWidget), - progressDialog(new QProgressDialog(this)), - uploader(new BlackBerryDebugTokenUploader(this)), - m_utils(BlackBerrySigningUtils::instance()) -{ - ui->setupUi(this); - - ui->connectionLog->setFont(TextEditor::TextEditorSettings::fontSettings().font()); - - populateDebugTokenCombo(deviceConfiguration()->debugToken()); - - connect(ui->hostLineEdit, SIGNAL(editingFinished()), this, SLOT(hostNameEditingFinished())); - connect(ui->pwdLineEdit, SIGNAL(editingFinished()), this, SLOT(passwordEditingFinished())); - connect(ui->keyFileLineEdit, SIGNAL(editingFinished()), this, SLOT(keyFileEditingFinished())); - connect(ui->keyFileLineEdit, SIGNAL(browsingFinished()), this, SLOT(keyFileEditingFinished())); - connect(ui->showPasswordCheckBox, SIGNAL(toggled(bool)), this, SLOT(showPassword(bool))); - connect(ui->debugToken, SIGNAL(currentTextChanged(QString)), this, SLOT(updateUploadButton())); - connect(ui->debugToken, SIGNAL(currentTextChanged(QString)), this, SLOT(debugTokenEditingFinished())); - connect(uploader, SIGNAL(finished(int)), this, SLOT(uploadFinished(int))); - - connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(connectionOutput(Core::Id,QString)), - this, SLOT(appendConnectionLog(Core::Id,QString))); - connect(BlackBerryDeviceConnectionManager::instance(), SIGNAL(deviceAboutToConnect(Core::Id)), - this, SLOT(clearConnectionLog(Core::Id))); - - connect(ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken())); - connect(ui->requestButton, SIGNAL(clicked()), this, SLOT(requestDebugToken())); - connect(ui->uploadButton, SIGNAL(clicked()), this, SLOT(uploadDebugToken())); - - connect(&m_utils, SIGNAL(debugTokenListChanged()), this, SLOT(updateDebugTokenCombo())); - - initGui(); -} - -BlackBerryDeviceConfigurationWidget::~BlackBerryDeviceConfigurationWidget() -{ - m_utils.saveDebugTokens(); - delete ui; -} - -void BlackBerryDeviceConfigurationWidget::hostNameEditingFinished() -{ - QSsh::SshConnectionParameters sshParams = deviceConfiguration()->sshParameters(); - sshParams.host = ui->hostLineEdit->text(); - deviceConfiguration()->setSshParameters(sshParams); -} - -void BlackBerryDeviceConfigurationWidget::passwordEditingFinished() -{ - QSsh::SshConnectionParameters sshParams = deviceConfiguration()->sshParameters(); - sshParams.password = ui->pwdLineEdit->text(); - deviceConfiguration()->setSshParameters(sshParams); -} - -void BlackBerryDeviceConfigurationWidget::keyFileEditingFinished() -{ - QSsh::SshConnectionParameters sshParams = deviceConfiguration()->sshParameters(); - sshParams.privateKeyFile = ui->keyFileLineEdit->path(); - deviceConfiguration()->setSshParameters(sshParams); -} - -void BlackBerryDeviceConfigurationWidget::showPassword(bool showClearText) -{ - ui->pwdLineEdit->setEchoMode(showClearText - ? QLineEdit::Normal : QLineEdit::Password); -} - -void BlackBerryDeviceConfigurationWidget::debugTokenEditingFinished() -{ - deviceConfiguration()->setDebugToken(ui->debugToken->currentText()); -} - -void BlackBerryDeviceConfigurationWidget::importDebugToken() -{ - const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"), - QString(), tr("BAR file (*.bar)")); - - if (debugToken.isEmpty()) - return; - - BlackBerryDebugTokenReader debugTokenReader(debugToken); - if (!debugTokenReader.isValid()) { - QMessageBox::warning(this, tr("Invalid Debug Token"), - tr("Debug token file %1 cannot be read.").arg(debugToken)); - return; - } - - m_utils.addDebugToken(debugToken); - populateDebugTokenCombo(debugToken); - debugTokenEditingFinished(); -} - -void BlackBerryDeviceConfigurationWidget::requestDebugToken() -{ - BlackBerryDebugTokenRequestDialog dialog; - - if (!ui->hostLineEdit->text().isEmpty() && !ui->pwdLineEdit->text().isEmpty()) - dialog.setTargetDetails(ui->hostLineEdit->text(), ui->pwdLineEdit->text()); - - const int result = dialog.exec(); - - if (result != QDialog::Accepted) - return; - - m_utils.addDebugToken(dialog.debugToken()); - populateDebugTokenCombo(dialog.debugToken()); - debugTokenEditingFinished(); -} - -void BlackBerryDeviceConfigurationWidget::uploadDebugToken() -{ - // check the debug token path before even laucnhing the uploader process - if (!QFileInfo::exists(ui->debugToken->currentText())) { - QMessageBox::critical(this, tr("Error"), tr("Invalid debug token path.")); - return; - } - - progressDialog->show(); - - uploader->uploadDebugToken(ui->debugToken->currentText(), - ui->hostLineEdit->text(), ui->pwdLineEdit->text()); -} - -void BlackBerryDeviceConfigurationWidget::updateUploadButton() -{ - const QString path = ui->debugToken->currentText(); - ui->uploadButton->setEnabled(QFileInfo::exists(path)); -} - -void BlackBerryDeviceConfigurationWidget::uploadFinished(int status) -{ - progressDialog->hide(); - - QString errorString = tr("Failed to upload debug token:") + QLatin1Char(' '); - - switch (status) { - case BlackBerryDebugTokenUploader::Success: - QMessageBox::information(this, tr("Qt Creator"), tr("Debug token successfully uploaded.")); - return; - case BlackBerryDebugTokenUploader::NoRouteToHost: - errorString += tr("No route to host."); - break; - case BlackBerryDebugTokenUploader::AuthenticationFailed: - errorString += tr("Authentication failed."); - break; - case BlackBerryDebugTokenUploader::DevelopmentModeDisabled: - errorString += tr("Development mode is disabled on the device."); - break; - case BlackBerryDebugTokenUploader::FailedToStartInferiorProcess: - errorString += tr("Failed to start inferior process."); - break; - case BlackBerryDebugTokenUploader::InferiorProcessTimedOut: - errorString += tr("Inferior processes timed out."); - break; - case BlackBerryDebugTokenUploader::InferiorProcessCrashed: - errorString += tr("Inferior process has crashed."); - break; - case BlackBerryDebugTokenUploader::InferiorProcessReadError: - case BlackBerryDebugTokenUploader::InferiorProcessWriteError: - errorString += tr("Failed to communicate with the inferior process."); - break; - case BlackBerryDebugTokenUploader::UnknownError: - errorString += tr("An unknwon error has happened."); - break; - } - - QMessageBox::critical(this, tr("Error"), errorString); -} - -void BlackBerryDeviceConfigurationWidget::appendConnectionLog(Core::Id deviceId, const QString &line) -{ - if (deviceId == device()->id()) - ui->connectionLog->appendPlainText(line.trimmed()); -} - -void BlackBerryDeviceConfigurationWidget::clearConnectionLog(Core::Id deviceId) -{ - if (deviceId == device()->id()) - ui->connectionLog->clear(); -} - -void BlackBerryDeviceConfigurationWidget::populateDebugTokenCombo(const QString& current) -{ - ui->debugToken->clear(); - ui->debugToken->addItems(m_utils.debugTokens()); - ui->debugToken->setEditText(current); -} - -void BlackBerryDeviceConfigurationWidget::updateDebugTokenCombo() -{ - populateDebugTokenCombo(ui->debugToken->currentText()); -} - -void BlackBerryDeviceConfigurationWidget::updateDeviceFromUi() -{ - hostNameEditingFinished(); - passwordEditingFinished(); - keyFileEditingFinished(); - debugTokenEditingFinished(); -} - -void BlackBerryDeviceConfigurationWidget::initGui() -{ - ui->keyFileLineEdit->setExpectedKind(Utils::PathChooser::File); - ui->keyFileLineEdit->setHistoryCompleter(QLatin1String("BB.Key.History")); - ui->keyFileLineEdit->lineEdit()->setMinimumWidth(0); - - const QSsh::SshConnectionParameters &sshParams = deviceConfiguration()->sshParameters(); - - ui->hostLineEdit->setEnabled(!deviceConfiguration()->isAutoDetected()); - - ui->hostLineEdit->setText(sshParams.host); - ui->pwdLineEdit->setText(sshParams.password); - ui->keyFileLineEdit->setPath(sshParams.privateKeyFile); - ui->showPasswordCheckBox->setChecked(false); - if (deviceConfiguration()->machineType() == IDevice::Emulator) { - ui->debugToken->setEnabled(false); - ui->requestButton->setEnabled(false); - ui->uploadButton->setEnabled(false); - ui->debugTokenLabel->setEnabled(false); - } - - progressDialog->setWindowModality(Qt::WindowModal); - progressDialog->setWindowTitle(tr("Operation in Progress")); - progressDialog->setCancelButton(0); - progressDialog->setLabelText(tr("Uploading debug token")); - progressDialog->setMinimum(0); - progressDialog->setMaximum(0); - - ui->connectionLog->setPlainText(BlackBerryDeviceConnectionManager::instance()->connectionLog(device()->id()).trimmed()); -} - -BlackBerryDeviceConfiguration::Ptr BlackBerryDeviceConfigurationWidget::deviceConfiguration() const -{ - return device().dynamicCast<BlackBerryDeviceConfiguration>(); -} diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h b/src/plugins/qnx/blackberrydeviceconfigurationwidget.h deleted file mode 100644 index 2ee33f405c1..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.h +++ /dev/null @@ -1,97 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIDGET_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIDGET_H - -#include <projectexplorer/devicesupport/idevicewidget.h> - -#include "blackberrydeviceconfiguration.h" - -QT_BEGIN_NAMESPACE -class QProgressDialog; -class QAbstractButton; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryDebugTokenUploader; -class BlackBerrySigningUtils; - -namespace Ui { class BlackBerryDeviceConfigurationWidget; } - -class BlackBerryDeviceConfigurationWidget : public ProjectExplorer::IDeviceWidget -{ - Q_OBJECT - -public: - explicit BlackBerryDeviceConfigurationWidget(const ProjectExplorer::IDevice::Ptr &device, - QWidget *parent = 0); - ~BlackBerryDeviceConfigurationWidget(); - -private slots: - void hostNameEditingFinished(); - void passwordEditingFinished(); - void keyFileEditingFinished(); - void showPassword(bool showClearText); - void debugTokenEditingFinished(); - void importDebugToken(); - void requestDebugToken(); - void uploadDebugToken(); - void updateUploadButton(); - void uploadFinished(int status); - void appendConnectionLog(Core::Id deviceId, const QString &line); - void clearConnectionLog(Core::Id deviceId); - void populateDebugTokenCombo(const QString ¤t); - void updateDebugTokenCombo(); - -private: - void updateDeviceFromUi(); - void initGui(); - - BlackBerryDeviceConfiguration::Ptr deviceConfiguration() const; - - Ui::BlackBerryDeviceConfigurationWidget *ui; - QAbstractButton *uploadButton; - - QProgressDialog *progressDialog; - - BlackBerryDebugTokenUploader *uploader; - BlackBerrySigningUtils &m_utils; -}; - - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIDGET_H diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui b/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui deleted file mode 100644 index 1bcbf8e1b1d..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwidget.ui +++ /dev/null @@ -1,180 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDeviceConfigurationWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryDeviceConfigurationWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>458</width> - <height>308</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <property name="margin"> - <number>0</number> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="hostNameLabel"> - <property name="text"> - <string>&Device name:</string> - </property> - <property name="buddy"> - <cstring>hostLineEdit</cstring> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="hostLineEdit"> - <property name="placeholderText"> - <string>IP or host name of the device</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="passwordLabel"> - <property name="text"> - <string>Device &password:</string> - </property> - <property name="buddy"> - <cstring>pwdLineEdit</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QLineEdit" name="pwdLineEdit"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item> - <widget class="QCheckBox" name="showPasswordCheckBox"> - <property name="text"> - <string>Show password</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="debugTokenLabel"> - <property name="text"> - <string>Debug token:</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="keyLabel"> - <property name="text"> - <string>Private key file:</string> - </property> - <property name="buddy"> - <cstring>keyFileLineEdit</cstring> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="Utils::PathChooser" name="keyFileLineEdit" native="true"/> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Connection log:</string> - </property> - <property name="buddy"> - <cstring>connectionLog</cstring> - </property> - </widget> - </item> - <item row="7" column="0" colspan="2"> - <widget class="QPlainTextEdit" name="connectionLog"> - <property name="readOnly"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="3" column="1"> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="importButton"> - <property name="text"> - <string>Import</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="requestButton"> - <property name="text"> - <string>Request</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="uploadButton"> - <property name="text"> - <string>Upload</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="debugToken"> - <property name="editable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - <zorder>keyFileLineEdit</zorder> - <zorder>hostNameLabel</zorder> - <zorder>hostLineEdit</zorder> - <zorder>passwordLabel</zorder> - <zorder>keyLabel</zorder> - <zorder>debugTokenLabel</zorder> - <zorder>label</zorder> - <zorder>connectionLog</zorder> - <zorder>debugToken</zorder> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - <slots> - <signal>editingFinished()</signal> - <signal>browsingFinished()</signal> - </slots> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>hostLineEdit</tabstop> - <tabstop>pwdLineEdit</tabstop> - <tabstop>showPasswordCheckBox</tabstop> - <tabstop>requestButton</tabstop> - <tabstop>uploadButton</tabstop> - <tabstop>connectionLog</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizard.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwizard.cpp deleted file mode 100644 index dc3d1eb12f4..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizard.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconfigurationwizard.h" -#include "blackberrydeviceconfigurationwizardpages.h" -#include "qnxconstants.h" -#include "blackberrydeviceconfiguration.h" -#include "blackberrydeviceconnectionmanager.h" - -#include <ssh/sshconnection.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeviceConfigurationWizard::BlackBerryDeviceConfigurationWizard(QWidget *parent) : - Utils::Wizard(parent) -{ - setWindowTitle(tr("New BlackBerry Device Configuration Setup")); - - m_setupPage = new BlackBerryDeviceConfigurationWizardSetupPage(this); - m_queryPage = new BlackBerryDeviceConfigurationWizardQueryPage(m_holder, this); - m_configPage = new BlackBerryDeviceConfigurationWizardConfigPage(m_holder, this); - m_finalPage = new BlackBerryDeviceConfigurationWizardFinalPage(this); - - setPage(SetupPageId, m_setupPage); - setPage(QueryPageId, m_queryPage); - setPage(ConfigPageId, m_configPage); - setPage(FinalPageId, m_finalPage); - m_finalPage->setCommitPage(true); -} - -ProjectExplorer::IDevice::Ptr BlackBerryDeviceConfigurationWizard::device() -{ - QSsh::SshConnectionParameters sshParams; - sshParams.options = QSsh::SshIgnoreDefaultProxy; - sshParams.host = m_setupPage->hostName(); - sshParams.password = m_setupPage->password(); - sshParams.authenticationType = QSsh::SshConnectionParameters::AuthenticationTypePublicKey; - sshParams.privateKeyFile = BlackBerryDeviceConnectionManager::instance()->privateKeyPath(); - sshParams.userName = QLatin1String("devuser"); - sshParams.timeout = 10; - sshParams.port = 22; - - BlackBerryDeviceConfiguration::Ptr configuration = BlackBerryDeviceConfiguration::create( - m_configPage->configurationName(), - Core::Id(Constants::QNX_BB_OS_TYPE), - m_holder.isSimulator - ? ProjectExplorer::IDevice::Emulator - : ProjectExplorer::IDevice::Hardware); - configuration->setSshParameters(sshParams); - configuration->setDebugToken(m_configPage->debugToken()); - return configuration; -} diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizard.h b/src/plugins/qnx/blackberrydeviceconfigurationwizard.h deleted file mode 100644 index d080b81681e..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizard.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H - -#include "blackberrydeviceconfigurationwizardpages.h" - -#include <projectexplorer/devicesupport/idevice.h> -#include <utils/wizard.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceConfigurationWizard : public Utils::Wizard -{ - Q_OBJECT -public: - explicit BlackBerryDeviceConfigurationWizard(QWidget *parent = 0); - - ProjectExplorer::IDevice::Ptr device(); - -private: - enum PageId { - SetupPageId, - QueryPageId, - ConfigPageId, - FinalPageId - }; - - BlackBerryDeviceConfigurationWizardSetupPage *m_setupPage; - BlackBerryDeviceConfigurationWizardQueryPage *m_queryPage; - BlackBerryDeviceConfigurationWizardConfigPage *m_configPage; - BlackBerryDeviceConfigurationWizardFinalPage *m_finalPage; - - BlackBerryDeviceConfigurationWizardHolder m_holder; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARD_H diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui b/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui deleted file mode 100644 index a021d859f88..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardconfigpage.ui +++ /dev/null @@ -1,157 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDeviceConfigurationWizardConfigPage</class> - <widget class="QWizardPage" name="Qnx::Internal::BlackBerryDeviceConfigurationWizardConfigPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>477</width> - <height>348</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="0" colspan="3"> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Debug Token</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="2" column="0"> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Location:</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QPushButton" name="generateButton"> - <property name="text"> - <string>Generate</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QComboBox" name="debugTokenCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="editable"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="4" column="0" colspan="4"> - <widget class="QLabel" name="label_3"> - <property name="font"> - <font> - <italic>true</italic> - </font> - </property> - <property name="text"> - <string>Debug token is needed for deploying applications to BlackBerry devices.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QPushButton" name="importButton"> - <property name="text"> - <string>Import</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="4" column="0"> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" colspan="3"> - <widget class="QFrame" name="frame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="2" column="1"> - <widget class="QLabel" name="deviceTypeField"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Type:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="deviceHostNameField"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Host name or IP address:</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Configuration name:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="configurationNameField"/> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <tabstops> - <tabstop>generateButton</tabstop> - </tabstops> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp deleted file mode 100644 index 49898e35a27..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.cpp +++ /dev/null @@ -1,458 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconfigurationwizardpages.h" -#include "blackberrydebugtokenrequestdialog.h" -#include "blackberrydebugtokenreader.h" -#include "blackberrysshkeysgenerator.h" -#include "blackberrydeviceinformation.h" -#include "ui_blackberrydeviceconfigurationwizardsetuppage.h" -#include "ui_blackberrydeviceconfigurationwizardquerypage.h" -#include "ui_blackberrydeviceconfigurationwizardconfigpage.h" -#include "blackberrydeviceconnectionmanager.h" -#include "blackberrysigningutils.h" -#include "qnxutils.h" - -#include <coreplugin/icore.h> -#include <ssh/sshkeygenerator.h> - -#include <QDir> -#include <QFormLayout> -#include <QMessageBox> -#include <QFileDialog> -#include <QFileInfo> -#include <QHostInfo> -#include <QAbstractItemModel> - -using namespace ProjectExplorer; -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char DEVICEHOSTNAME_FIELD_ID[] = "DeviceHostName"; -const char DEVICEPASSWORD_FIELD_ID[] = "DevicePassword"; -const char CONFIGURATIONNAME_FIELD_ID[] = "ConfigurationName"; -const char DEBUGTOKENPATH_FIELD_ID[] = "DebugTokenPath"; - -enum DeviceListUserRole -{ - ItemKindRole = Qt::UserRole, DeviceNameRole, DeviceIpRole, DeviceTypeRole -}; -} - -BlackBerryDeviceConfigurationWizardSetupPage::BlackBerryDeviceConfigurationWizardSetupPage(QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui::BlackBerryDeviceConfigurationWizardSetupPage) - , m_deviceListDetector(new BlackBerryDeviceListDetector(this)) - -{ - m_ui->setupUi(this); - setTitle(tr("Connection")); - - connect(m_ui->deviceListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onDeviceSelectionChanged())); - connect(m_deviceListDetector, SIGNAL(deviceDetected(QString,QString,bool)), - this, SLOT(onDeviceDetected(QString,QString,bool))); - connect(m_deviceListDetector, SIGNAL(finished()), this, SLOT(onDeviceListDetectorFinished())); - connect(m_ui->deviceHostIp, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); - - registerField(QLatin1String(DEVICEHOSTNAME_FIELD_ID), m_ui->deviceHostIp); - registerField(QLatin1String(DEVICEPASSWORD_FIELD_ID), m_ui->password); -} - -BlackBerryDeviceConfigurationWizardSetupPage::~BlackBerryDeviceConfigurationWizardSetupPage() -{ - delete m_ui; - m_ui = 0; -} - -void BlackBerryDeviceConfigurationWizardSetupPage::initializePage() -{ - m_ui->password->clear(); - refreshDeviceList(); -} - -void BlackBerryDeviceConfigurationWizardSetupPage::refreshDeviceList() -{ - m_ui->deviceListWidget->clear(); - - QListWidgetItem *manual = createDeviceListItem(tr("Specify device manually"), SpecifyManually); - m_ui->deviceListWidget->addItem(manual); - manual->setSelected(true); - - QListWidgetItem *pleaseWait = - createDeviceListItem(tr("Auto-detecting devices - please wait..."), PleaseWait); - m_ui->deviceListWidget->addItem(pleaseWait); - - m_deviceListDetector->detectDeviceList(); -} - -void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceListDetectorFinished() -{ - QListWidgetItem *pleaseWait = findDeviceListItem(PleaseWait); - if (pleaseWait) { - m_ui->deviceListWidget->removeItemWidget(pleaseWait); - delete pleaseWait; - } - - if (!findDeviceListItem(Autodetected)) { - QListWidgetItem *note = createDeviceListItem(tr("No device has been auto-detected."), Note); - note->setToolTip(tr("Device auto-detection is available in BB NDK 10.2. " - "Make sure that your device is in Development Mode.")); - m_ui->deviceListWidget->addItem(note); - } -} - -void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceDetected( - const QString &deviceName, const QString &hostName, bool isSimulator) -{ - QString displayName(deviceName); - if (displayName != hostName) - displayName.append(QLatin1String(" (")).append(hostName).append(QLatin1Char(')')); - - QListWidgetItem *device = createDeviceListItem(displayName, Autodetected); - device->setData(DeviceNameRole, displayName); - device->setData(DeviceIpRole, hostName); - device->setData(DeviceTypeRole, isSimulator); - QListWidgetItem *pleaseWait = findDeviceListItem(PleaseWait); - int row = pleaseWait ? m_ui->deviceListWidget->row(pleaseWait) : m_ui->deviceListWidget->count(); - m_ui->deviceListWidget->insertItem(row, device); -} - -void BlackBerryDeviceConfigurationWizardSetupPage::onDeviceSelectionChanged() -{ - QList<QListWidgetItem *> selectedItems = m_ui->deviceListWidget->selectedItems(); - const QListWidgetItem *selected = selectedItems.count() == 1 ? selectedItems[0] : 0; - const ItemKind itemKind = selected ? selected->data(ItemKindRole).value<ItemKind>() : Note; - switch (itemKind) { - case SpecifyManually: - m_ui->deviceHostIp->setEnabled(true); - m_ui->deviceHostIp->setText(QLatin1String("169.254.0.1")); - m_ui->password->setEnabled(true); - m_ui->deviceHostIp->selectAll(); - m_ui->deviceHostIp->setFocus(); - break; - case Autodetected: - m_ui->deviceHostIp->setEnabled(false); - m_ui->deviceHostIp->setText(selected->data(DeviceIpRole).toString()); - m_ui->password->setEnabled(true); - m_ui->password->setFocus(); - break; - case PleaseWait: - case Note: - m_ui->deviceHostIp->setEnabled(false); - m_ui->deviceHostIp->clear(); - m_ui->password->setEnabled(false); - break; - } -} - -QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::createDeviceListItem( - const QString &displayName, ItemKind itemKind) const -{ - QListWidgetItem *item = new QListWidgetItem(displayName); - if (itemKind == PleaseWait || itemKind == Note) { - item->setFlags(item->flags() & ~Qt::ItemIsSelectable); - QFont font = item->font(); - font.setItalic(true); - item->setFont(font); - } - item->setData(ItemKindRole, QVariant::fromValue(itemKind)); - return item; -} - -QListWidgetItem *BlackBerryDeviceConfigurationWizardSetupPage::findDeviceListItem(ItemKind itemKind) const -{ - int count = m_ui->deviceListWidget->count(); - for (int i = 0; i < count; ++i) { - QListWidgetItem *item = m_ui->deviceListWidget->item(i); - if (item->data(ItemKindRole).value<ItemKind>() == itemKind) - return item; - } - return 0; -} - -bool BlackBerryDeviceConfigurationWizardSetupPage::isComplete() const -{ - return !m_ui->deviceHostIp->text().isEmpty(); -} - -QString BlackBerryDeviceConfigurationWizardSetupPage::hostName() const -{ - return m_ui->deviceHostIp->text(); -} - -QString BlackBerryDeviceConfigurationWizardSetupPage::password() const -{ - return m_ui->password->text(); -} - -// ---------------------------------------------------------------------------- - -BlackBerryDeviceConfigurationWizardQueryPage::BlackBerryDeviceConfigurationWizardQueryPage - (BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui::BlackBerryDeviceConfigurationWizardQueryPage) - , m_holder(holder) - , m_deviceInformation(new BlackBerryDeviceInformation(this)) -{ - m_ui->setupUi(this); - setTitle(tr("Device Information")); - m_ui->progressBar->setMaximum(Done); - - connect(m_deviceInformation,SIGNAL(finished(int)),this,SLOT(processQueryFinished(int))); -} - -BlackBerryDeviceConfigurationWizardQueryPage::~BlackBerryDeviceConfigurationWizardQueryPage() -{ - delete m_ui; - m_ui = 0; -} - -void BlackBerryDeviceConfigurationWizardQueryPage::initializePage() -{ - m_holder.deviceInfoRetrieved = false; - - setState(Querying, tr("Querying device information. Please wait...")); - - m_deviceInformation->setDeviceTarget( - field(QLatin1String(DEVICEHOSTNAME_FIELD_ID)).toString(), - field(QLatin1String(DEVICEPASSWORD_FIELD_ID)).toString()); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::processQueryFinished(int status) -{ - m_holder.deviceInfoRetrieved = status == BlackBerryDeviceInformation::Success; - m_holder.devicePin = m_deviceInformation->devicePin(); - m_holder.scmBundle = m_deviceInformation->scmBundle(); - m_holder.deviceName = m_deviceInformation->hostName(); - if (m_holder.deviceName.isEmpty()) - m_holder.deviceName = QLatin1String("BlackBerry at ") - + field(QLatin1String(DEVICEHOSTNAME_FIELD_ID)).toString(); - m_holder.debugTokenAuthor = m_deviceInformation->debugTokenAuthor(); - m_holder.debugTokenValid = m_deviceInformation->debugTokenValid(); - m_holder.isSimulator = m_deviceInformation->isSimulator(); - m_holder.isProductionDevice = m_deviceInformation->isProductionDevice(); - - if (m_holder.deviceInfoRetrieved) - checkAndGenerateSSHKeys(); - else - setState(Done, tr("Cannot connect to the device. " - "Check that the device is in development mode and has matching host name and password.")); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::checkAndGenerateSSHKeys() -{ - if (! BlackBerryDeviceConnectionManager::instance()->hasValidSSHKeys()) { - setState(GeneratingSshKey, tr("Generating SSH keys. Please wait...")); - - BlackBerrySshKeysGenerator *sshKeysGenerator = new BlackBerrySshKeysGenerator(); - connect(sshKeysGenerator, SIGNAL(sshKeysGenerationFailed(QString)), - this, SLOT(sshKeysGenerationFailed(QString)), Qt::QueuedConnection); - connect(sshKeysGenerator, SIGNAL(sshKeysGenerationFinished(QByteArray,QByteArray)), - this, SLOT(processSshKeys(QByteArray,QByteArray)), Qt::QueuedConnection); - sshKeysGenerator->start(); - } else - queryDone(); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::sshKeysGenerationFailed(const QString &error) -{ - // this slot can be called asynchronously - processing it only in GeneratingSshKey state - if (m_state != GeneratingSshKey) - return; - - QString message = tr("Failed generating SSH key needed for securing connection to a device. Error:"); - message += QLatin1Char(' '); - message.append(error); - setState(Done, message); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::processSshKeys(const QByteArray &privateKey, - const QByteArray &publicKey) -{ - // this slot can be called asynchronously - processing it only in GeneratingSshKey state - if (m_state != GeneratingSshKey) - return; - - // condition prevents overriding already generated SSH keys - // this may happens when an user enter the QueryPage several times before - // the first SSH keys are generated i.e. when multiple calls of checkAndGenerateSSHKeys() - // before processSshKeys() is called, multiple processSshKeys() calls are triggered later. - // only the first one is allowed to write the SSH keys. - if (! BlackBerryDeviceConnectionManager::instance()->hasValidSSHKeys()) { - QString error; - if (!BlackBerryDeviceConnectionManager::instance()->setSSHKeys(privateKey, publicKey, &error)) { - QString message = tr("Failed saving SSH key needed for securing connection to a device. Error:"); - message += QLatin1Char(' '); - message.append(error); - setState(Done, message); - return; - } - } - - queryDone(); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::queryDone() -{ - setState(Done, tr("Device information retrieved successfully.")); -} - -void BlackBerryDeviceConfigurationWizardQueryPage::setState(QueryState state, const QString &message) -{ - m_state = state; - m_ui->statusLabel->setText(message); - m_ui->progressBar->setVisible(state != Done); - m_ui->progressBar->setValue(state); - emit completeChanged(); - - if (isComplete()) - if (wizard()->currentPage() == this) - wizard()->next(); -} - -bool BlackBerryDeviceConfigurationWizardQueryPage::isComplete() const -{ - return m_state == Done - && m_holder.deviceInfoRetrieved - && BlackBerryDeviceConnectionManager::instance()->hasValidSSHKeys(); -} - -// ---------------------------------------------------------------------------- - -BlackBerryDeviceConfigurationWizardConfigPage::BlackBerryDeviceConfigurationWizardConfigPage - (BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui::BlackBerryDeviceConfigurationWizardConfigPage) - , m_holder(holder) - , m_utils(BlackBerrySigningUtils::instance()) -{ - m_ui->setupUi(this); - setTitle(tr("Configuration")); - - m_ui->debugTokenCombo->addItems(m_utils.debugTokens()); - - connect(m_ui->configurationNameField, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->debugTokenCombo, SIGNAL(currentTextChanged(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->generateButton, SIGNAL(clicked()), this, SLOT(generateDebugToken())); - connect(m_ui->importButton, SIGNAL(clicked()), this, SLOT(importDebugToken())); - - registerField(QLatin1String(CONFIGURATIONNAME_FIELD_ID), m_ui->configurationNameField); - registerField(QLatin1String(DEBUGTOKENPATH_FIELD_ID), m_ui->debugTokenCombo); -} - -BlackBerryDeviceConfigurationWizardConfigPage::~BlackBerryDeviceConfigurationWizardConfigPage() -{ - delete m_ui; - m_ui = 0; -} - -void BlackBerryDeviceConfigurationWizardConfigPage::initializePage() -{ - QString deviceHostName = field(QLatin1String(DEVICEHOSTNAME_FIELD_ID)).toString(); - m_ui->configurationNameField->setText(m_holder.deviceName); - m_ui->deviceHostNameField->setText(deviceHostName); - m_ui->deviceTypeField->setText(QLatin1String (m_holder.isSimulator ? "Simulator" : "Device")); - m_ui->debugTokenCombo->setEnabled(!m_holder.isSimulator); - m_ui->generateButton->setEnabled(!m_holder.isSimulator); -} - -bool BlackBerryDeviceConfigurationWizardConfigPage::isComplete() const -{ - bool configurationNameComplete = !m_ui->configurationNameField->text().isEmpty(); - Utils::FileName fileName = Utils::FileName::fromString(m_ui->debugTokenCombo->currentText()); - bool debugTokenComplete = m_holder.isSimulator || !m_holder.isProductionDevice - || (!fileName.isEmpty() && fileName.exists()); - - return configurationNameComplete && debugTokenComplete; -} - -void BlackBerryDeviceConfigurationWizardConfigPage::generateDebugToken() -{ - BlackBerryDebugTokenRequestDialog dialog; - dialog.setDevicePin(m_holder.devicePin); - - const int result = dialog.exec(); - - if (result != QDialog::Accepted) - return; - - m_utils.addDebugToken(dialog.debugToken()); - m_ui->debugTokenCombo->addItem(dialog.debugToken()); - const int index = m_ui->debugTokenCombo->findText(dialog.debugToken()); - if (index != -1) - m_ui->debugTokenCombo->setCurrentIndex(index); -} - -void BlackBerryDeviceConfigurationWizardConfigPage::importDebugToken() -{ - const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"), - QString(), tr("BAR file (*.bar)")); - - if (debugToken.isEmpty()) - return; - - BlackBerryDebugTokenReader debugTokenReader(debugToken); - if (!debugTokenReader.isValid()) { - QMessageBox::warning(this, tr("Invalid Debug Token"), - tr("Debug token file %1 cannot be read.").arg(debugToken)); - return; - } - - m_utils.addDebugToken(debugToken); - m_ui->debugTokenCombo->addItem(debugToken); - const int index = m_ui->debugTokenCombo->findText(debugToken); - if (index != -1) - m_ui->debugTokenCombo->setCurrentIndex(index); -} - -QString BlackBerryDeviceConfigurationWizardConfigPage::configurationName() const -{ - return m_ui->configurationNameField->text(); -} - -QString BlackBerryDeviceConfigurationWizardConfigPage::debugToken() const -{ - return m_ui->debugTokenCombo->currentText(); -} - -// ---------------------------------------------------------------------------- - -BlackBerryDeviceConfigurationWizardFinalPage::BlackBerryDeviceConfigurationWizardFinalPage(QWidget *parent) - : QWizardPage(parent) -{ - setTitle(tr("Summary")); - - QVBoxLayout *layout = new QVBoxLayout(this); - QLabel *label = new QLabel(tr("The new device configuration will be created now."), this); - layout->addWidget(label); -} diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h b/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h deleted file mode 100644 index e5dd186320a..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardpages.h +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H - -#include "blackberrydevicelistdetector.h" - -#include <projectexplorer/devicesupport/idevice.h> - -#include <QWizardPage> -#include <QListWidgetItem> - -namespace QSsh { class SshKeyGenerator; } - -namespace Qnx { -namespace Internal { -namespace Ui { -class BlackBerryDeviceConfigurationWizardSetupPage; -class BlackBerryDeviceConfigurationWizardQueryPage; -class BlackBerryDeviceConfigurationWizardConfigPage; -} -class BlackBerrySshKeysGenerator; -class BlackBerryDeviceInformation; -class BlackBerrySigningUtils; - -struct BlackBerryDeviceConfigurationWizardHolder { - QString devicePin; - QString deviceName; - QString scmBundle; - QString debugTokenAuthor; - bool isSimulator; - bool debugTokenValid; - bool deviceInfoRetrieved; - bool isProductionDevice; - - BlackBerryDeviceConfigurationWizardHolder() - : isSimulator(false) - , debugTokenValid(false) - , deviceInfoRetrieved(false) - , isProductionDevice(true) {} -}; - -class BlackBerryDeviceConfigurationWizardSetupPage : public QWizardPage -{ - Q_OBJECT -public: - enum ItemKind { - SpecifyManually, Autodetected, PleaseWait, Note - }; - - explicit BlackBerryDeviceConfigurationWizardSetupPage(QWidget *parent = 0); - ~BlackBerryDeviceConfigurationWizardSetupPage(); - - void initializePage(); - bool isComplete() const; - - QString hostName() const; - QString password() const; -private slots: - void onDeviceSelectionChanged(); - void onDeviceDetected(const QString &deviceName, const QString &hostName, bool isSimulator); - void onDeviceListDetectorFinished(); - -private: - void refreshDeviceList(); - QListWidgetItem *createDeviceListItem(const QString &displayName, ItemKind itemKind) const; - QListWidgetItem *findDeviceListItem(ItemKind itemKind) const; - - Ui::BlackBerryDeviceConfigurationWizardSetupPage *m_ui; - BlackBerryDeviceListDetector *m_deviceListDetector; -}; - -class BlackBerryDeviceConfigurationWizardQueryPage : public QWizardPage -{ - Q_OBJECT - enum QueryState - { - Querying = 0, GeneratingSshKey, Done - }; - -public: - explicit BlackBerryDeviceConfigurationWizardQueryPage(BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent = 0); - ~BlackBerryDeviceConfigurationWizardQueryPage(); - - void initializePage(); - bool isComplete() const; - -private slots: - void processQueryFinished(int status); - void sshKeysGenerationFailed(const QString &error); - void processSshKeys(const QByteArray &privateKey, const QByteArray &publicKey); - -private: - void checkAndGenerateSSHKeys(); - void queryDone(); - void setState(QueryState state, const QString &message); - - Ui::BlackBerryDeviceConfigurationWizardQueryPage *m_ui; - BlackBerryDeviceConfigurationWizardHolder &m_holder; - BlackBerryDeviceInformation *m_deviceInformation; - QueryState m_state; -}; - -class BlackBerryDeviceConfigurationWizardConfigPage : public QWizardPage -{ - Q_OBJECT -public: - explicit BlackBerryDeviceConfigurationWizardConfigPage(BlackBerryDeviceConfigurationWizardHolder &holder, QWidget *parent = 0); - ~BlackBerryDeviceConfigurationWizardConfigPage(); - - void initializePage(); - bool isComplete() const; - - QString configurationName() const; - QString debugToken() const; -private slots: - void generateDebugToken(); - void importDebugToken(); - -private: - Ui::BlackBerryDeviceConfigurationWizardConfigPage *m_ui; - BlackBerryDeviceConfigurationWizardHolder &m_holder; - BlackBerrySigningUtils &m_utils; -}; - -class BlackBerryDeviceConfigurationWizardFinalPage : public QWizardPage -{ - Q_OBJECT -public: - explicit BlackBerryDeviceConfigurationWizardFinalPage(QWidget *parent = 0); -}; - -} // namespace Internal -} // namespace Qnx - -Q_DECLARE_METATYPE(Qnx::Internal::BlackBerryDeviceConfigurationWizardSetupPage::ItemKind) - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONFIGURATIONWIZARDPAGES_H diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardquerypage.ui b/src/plugins/qnx/blackberrydeviceconfigurationwizardquerypage.ui deleted file mode 100644 index 5286649f9d4..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardquerypage.ui +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDeviceConfigurationWizardQueryPage</class> - <widget class="QWizardPage" name="Qnx::Internal::BlackBerryDeviceConfigurationWizardQueryPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>381</width> - <height>142</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="statusLabel"> - <property name="text"> - <string/> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"/> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>58</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydeviceconfigurationwizardsetuppage.ui b/src/plugins/qnx/blackberrydeviceconfigurationwizardsetuppage.ui deleted file mode 100644 index b4a6b27a59c..00000000000 --- a/src/plugins/qnx/blackberrydeviceconfigurationwizardsetuppage.ui +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryDeviceConfigurationWizardSetupPage</class> - <widget class="QWizardPage" name="Qnx::Internal::BlackBerryDeviceConfigurationWizardSetupPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>484</width> - <height>182</height> - </rect> - </property> - <property name="windowTitle"> - <string>WizardPage</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QListWidget" name="deviceListWidget"/> - </item> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="1" column="1"> - <widget class="QLineEdit" name="password"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Device password:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="deviceHostIp"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Device host name or IP address:</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrydeviceconnection.cpp b/src/plugins/qnx/blackberrydeviceconnection.cpp deleted file mode 100644 index f701c2f4392..00000000000 --- a/src/plugins/qnx/blackberrydeviceconnection.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconnection.h" - -#include "blackberryconfigurationmanager.h" -#include "qnxutils.h" - -#include <projectexplorer/devicesupport/devicemanager.h> -#include <ssh/sshconnection.h> -#include <utils/environment.h> - -#include <QProcess> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char CONNECT_SUCCESS_MSG[] = "Successfully connected"; -} - -BlackBerryDeviceConnection::BlackBerryDeviceConnection() : - QObject(), - m_connectionState(Disconnected), - m_process(new QProcess(this)) -{ - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processFinished())); - connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(readStandardOutput())); - connect(m_process, SIGNAL(readyReadStandardError()), this, SLOT(readStandardError())); -} - -void BlackBerryDeviceConnection::connectDevice(const ProjectExplorer::IDevice::ConstPtr &device) -{ - Utils::Environment env = Utils::Environment::systemEnvironment(); - env.modify(BlackBerryConfigurationManager::instance()->defaultConfigurationEnv()); - - m_process->setEnvironment(env.toStringList()); - - m_host = device->sshParameters().host; - const QString password = device->sshParameters().password; - const QString publicKeyFile = device->sshParameters().privateKeyFile + QLatin1String(".pub"); - - // Since killing the blackberry-connect script won't kill the java process it launches, - // let's just call the java process directly instead. - Utils::FileName command = env.searchInPath(QLatin1String("java")); - if (command.isEmpty()) { - const QString line = tr("Error connecting to device: java could not be found in the environment.") + QLatin1Char('\n'); - emit processOutput(line); - m_messageLog.append(line); - return; - } - - QStringList args; - args << QLatin1String("-Xmx512M"); - args << QLatin1String("-jar"); - args << env.value(QLatin1String("QNX_HOST")) + QLatin1String("/usr/lib/Connect.jar"); - - args << QLatin1String("-targetHost") << m_host; - if (!password.isEmpty()) - args << QLatin1String("-password") << password; - args << QLatin1String("-sshPublicKey") << publicKeyFile; - - m_connectionState = Connecting; - m_process->start(command.toString(), args); - m_messageLog.clear(); - emit deviceAboutToConnect(); -} - -void BlackBerryDeviceConnection::disconnectDevice() -{ - m_process->terminate(); - if (!m_process->waitForFinished(5000)) - m_process->kill(); - m_connectionState = Disconnected; -} - -QString BlackBerryDeviceConnection::host() const -{ - return m_host; -} - -BlackBerryDeviceConnection::State BlackBerryDeviceConnection::connectionState() -{ - return m_connectionState; -} - -QString BlackBerryDeviceConnection::messageLog() const -{ - return m_messageLog; -} - -void BlackBerryDeviceConnection::processFinished() -{ - m_connectionState = Disconnected; - emit deviceDisconnected(); -} - -void BlackBerryDeviceConnection::readStandardOutput() -{ - m_process->setReadChannel(QProcess::StandardOutput); - while (m_process->canReadLine()) { - const QString line = QString::fromLocal8Bit(m_process->readLine()); - - emit processOutput(line); - m_messageLog.append(line); - - if (line.contains(QLatin1String(CONNECT_SUCCESS_MSG))) { - m_connectionState = Connected; - emit deviceConnected(); - } - } -} - -void BlackBerryDeviceConnection::readStandardError() -{ - m_process->setReadChannel(QProcess::StandardError); - while (m_process->canReadLine()) { - const QString line = QString::fromLocal8Bit(m_process->readLine()); - - emit processOutput(line); - m_messageLog.append(line); - } -} diff --git a/src/plugins/qnx/blackberrydeviceconnection.h b/src/plugins/qnx/blackberrydeviceconnection.h deleted file mode 100644 index 35174665886..00000000000 --- a/src/plugins/qnx/blackberrydeviceconnection.h +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H - -#include <QObject> - -#include <coreplugin/id.h> -#include <projectexplorer/devicesupport/idevice.h> - -QT_BEGIN_NAMESPACE -class QProcess; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceConnection : public QObject -{ - Q_OBJECT -public: - enum State { - Disconnected, - Connecting, - Connected - }; - - explicit BlackBerryDeviceConnection(); - - void connectDevice(const ProjectExplorer::IDevice::ConstPtr &device); - void disconnectDevice(); - - QString host() const; - State connectionState(); - - QString messageLog() const; - -signals: - void deviceAboutToConnect(); - void deviceConnected(); - void deviceDisconnected(); - - void processOutput(const QString &output); - -private slots: - void processFinished(); - void readStandardOutput(); - void readStandardError(); - -private: - QString m_host; - State m_connectionState; - - QString m_messageLog; - - QProcess *m_process; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONNECTION_H diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp b/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp deleted file mode 100644 index 6c9e9696ed3..00000000000 --- a/src/plugins/qnx/blackberrydeviceconnectionmanager.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceconnectionmanager.h" - -#include "blackberrydeviceconfiguration.h" -#include "blackberrydeviceconnection.h" -#include "blackberryconfigurationmanager.h" -#include "qnxconstants.h" - -#include <coreplugin/icore.h> -#include <projectexplorer/devicesupport/devicemanager.h> -#include <ssh/sshconnection.h> -#include <ssh/sshkeygenerator.h> -#include <utils/fileutils.h> -#include <utils/qtcassert.h> - -#include <QFileInfo> -#include <QDir> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryDeviceConnectionManager *BlackBerryDeviceConnectionManager::m_instance = 0; - -BlackBerryDeviceConnectionManager::BlackBerryDeviceConnectionManager() : - QObject() -{ -} - -BlackBerryDeviceConnectionManager::~BlackBerryDeviceConnectionManager() -{ - killAllConnections(); -} - -void BlackBerryDeviceConnectionManager::initialize() -{ - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - connect(deviceManager, SIGNAL(deviceAdded(Core::Id)), this, SLOT(connectDevice(Core::Id))); - connect(deviceManager, SIGNAL(deviceRemoved(Core::Id)), this, SLOT(disconnectDevice(Core::Id))); - connect(deviceManager, SIGNAL(deviceListReplaced()), this, SLOT(handleDeviceListChanged())); -} - -void BlackBerryDeviceConnectionManager::killAllConnections() -{ - QList<BlackBerryDeviceConnection*> connections = m_connections.uniqueKeys(); - foreach (BlackBerryDeviceConnection *connection, connections) { - connection->disconnect(); - connection->disconnectDevice(); - delete connection; - } -} - -BlackBerryDeviceConnectionManager *BlackBerryDeviceConnectionManager::instance() -{ - if (m_instance == 0) - m_instance = new BlackBerryDeviceConnectionManager(); - return m_instance; -} - -bool BlackBerryDeviceConnectionManager::isConnected(Core::Id deviceId) -{ - BlackBerryDeviceConnection *connection = m_connections.key(deviceId); - if (!connection) - return false; - - return connection->connectionState() == BlackBerryDeviceConnection::Connected; -} - -QString BlackBerryDeviceConnectionManager::connectionLog(Core::Id deviceId) const -{ - BlackBerryDeviceConnection *connection = m_connections.key(deviceId); - if (!connection) - return QString(); - - return connection->messageLog(); -} - -void BlackBerryDeviceConnectionManager::connectDevice(Core::Id deviceId) -{ - ProjectExplorer::IDevice::ConstPtr device = - ProjectExplorer::DeviceManager::instance()->find(deviceId); - if (device.isNull()) - return; - - // BlackBerry Device connection needs the Qnx environments to be set - // in order to find the Connect.jar package. - // Let's delay the device connections at startup till the Qnx settings are loaded. - if (BlackBerryConfigurationManager::instance()->apiLevels().isEmpty()) { - m_pendingDeviceConnections << device; - connect(BlackBerryConfigurationManager::instance(), SIGNAL(settingsLoaded()), - this, SLOT(processPendingDeviceConnections()), Qt::UniqueConnection); - return; - } - - connectDevice(device); -} - -void BlackBerryDeviceConnectionManager::connectDevice(const ProjectExplorer::IDevice::ConstPtr &device) -{ - if (device->type() != Core::Id(Constants::QNX_BB_OS_TYPE)) - return; - - ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(), - ProjectExplorer::IDevice::DeviceStateUnknown); - - // Disconnect existing connection if it only belongs to this device, - // and if the host has changed - BlackBerryDeviceConnection *connection = m_connections.key(device->id()); - if (connection && connection->host() != device->sshParameters().host) { - if (connectionUsageCount(device->id()) == 1) - disconnectDevice(device); - - m_connections.remove(connection, device->id()); - connection = 0; - } - - if (!connection) - connection = connectionForHost(device->sshParameters().host); - - if (!connection) { - connection = new BlackBerryDeviceConnection(); - m_connections.insertMulti(connection, device->id()); - - connect(connection, SIGNAL(deviceConnected()), this, SLOT(handleDeviceConnected())); - connect(connection, SIGNAL(deviceDisconnected()), this, SLOT(handleDeviceDisconnected())); - connect(connection, SIGNAL(processOutput(QString)), this, SLOT(handleProcessOutput(QString))); - connect(connection, SIGNAL(deviceAboutToConnect()), this, SLOT(handleDeviceAboutToConnect())); - - connection->connectDevice(device); - } else { - if (!m_connections.values(connection).contains(device->id())) - m_connections.insertMulti(connection, device->id()); - - switch (connection->connectionState()) { - case BlackBerryDeviceConnection::Connected: - ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(), - ProjectExplorer::IDevice::DeviceReadyToUse); - break; - case BlackBerryDeviceConnection::Connecting: - ProjectExplorer::DeviceManager::instance()->setDeviceState(device->id(), - ProjectExplorer::IDevice::DeviceStateUnknown); - break; - case BlackBerryDeviceConnection::Disconnected: - connection->connectDevice(device); - break; - } - } -} - -void BlackBerryDeviceConnectionManager::disconnectDevice(const ProjectExplorer::IDevice::ConstPtr &device) -{ - disconnectDevice(device->id()); -} - -/*! - * @brief Returns default private key path in local settings. - * @return the default private key path - */ -const QString BlackBerryDeviceConnectionManager::privateKeyPath() const -{ - return Core::ICore::userResourcePath() + QLatin1String("/qnx/id_rsa"); -} - -/*! - * @brief Checks validity of default SSH keys used for connecting to a device. - * @return true, if the default SSH keys are valid - */ -bool BlackBerryDeviceConnectionManager::hasValidSSHKeys() const -{ - const QString privateKey = privateKeyPath(); - QFileInfo privateKeyFileInfo(privateKey); - QFileInfo publicKeyFileInfo(privateKey + QLatin1String(".pub")); - - return privateKeyFileInfo.exists() && privateKeyFileInfo.isReadable() - && publicKeyFileInfo.exists() && publicKeyFileInfo.isReadable(); -} - -/*! - * @brief Stores a new private and public SSH key in local settings. - * @param privateKeyContent the private key content - * @param publicKeyContent the public key content - */ -bool BlackBerryDeviceConnectionManager::setSSHKeys(const QByteArray &privateKeyContent, - const QByteArray &publicKeyContent, QString *error) -{ - const QString privateKey = privateKeyPath(); - const QString publicKey = privateKey + QLatin1String(".pub"); - - QFileInfo fileInfo(privateKey); - QDir dir = fileInfo.dir(); - if (!dir.exists()) - dir.mkpath(QLatin1String(".")); - - Utils::FileSaver privSaver(privateKey); - privSaver.write(privateKeyContent); - if (!privSaver.finalize(error)) - return false; - QFile::setPermissions(privateKey, QFile::ReadOwner | QFile::WriteOwner); - - Utils::FileSaver pubSaver(publicKey); - pubSaver.write(publicKeyContent); - if (!pubSaver.finalize(error)) - return false; - - return true; -} - -void BlackBerryDeviceConnectionManager::disconnectDevice(Core::Id deviceId) -{ - BlackBerryDeviceConnection *connection = m_connections.key(deviceId); - if (!connection) - return; - - connection->disconnectDevice(); -} - -void BlackBerryDeviceConnectionManager::handleDeviceListChanged() -{ - disconnectRemovedDevices(); - reconnectChangedDevices(); - connectAddedDevices(); -} - -void BlackBerryDeviceConnectionManager::handleDeviceConnected() -{ - BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender()); - QTC_ASSERT(connection, return); - - QList<Core::Id> knownDevices = m_connections.values(connection); - foreach (Core::Id id, knownDevices) - ProjectExplorer::DeviceManager::instance()->setDeviceState(id, - ProjectExplorer::IDevice::DeviceReadyToUse); - - QList<Core::Id> sameHostDevices = devicesForHost(connection->host()); - foreach (Core::Id id, sameHostDevices) { - if (!knownDevices.contains(id)) { - m_connections.insertMulti(connection, id); - ProjectExplorer::DeviceManager::instance()->setDeviceState(id, - ProjectExplorer::IDevice::DeviceReadyToUse); - } - } - - emit deviceConnected(); -} - -void BlackBerryDeviceConnectionManager::handleDeviceDisconnected() -{ - BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender()); - QTC_ASSERT(connection, return); - - QList<Core::Id> disconnectedDevices = m_connections.values(connection); - foreach (Core::Id id, disconnectedDevices) { - ProjectExplorer::DeviceManager::instance()->setDeviceState(id, - ProjectExplorer::IDevice::DeviceDisconnected); - emit deviceDisconnected(id); - } -} - -void BlackBerryDeviceConnectionManager::handleDeviceAboutToConnect() -{ - BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender()); - QTC_ASSERT(connection, return); - - QList<Core::Id> deviceIds = m_connections.values(connection); - foreach (Core::Id deviceId, deviceIds) - emit deviceAboutToConnect(deviceId); -} - -void BlackBerryDeviceConnectionManager::handleProcessOutput(const QString &output) -{ - BlackBerryDeviceConnection *connection = qobject_cast<BlackBerryDeviceConnection*>(sender()); - QTC_ASSERT(connection, return); - - QList<Core::Id> deviceIds = m_connections.values(connection); - foreach (Core::Id deviceId, deviceIds) - emit connectionOutput(deviceId, output); -} - -void BlackBerryDeviceConnectionManager::processPendingDeviceConnections() -{ - if (m_pendingDeviceConnections.isEmpty() - || BlackBerryConfigurationManager::instance()->apiLevels().isEmpty()) - return; - - foreach (ProjectExplorer::IDevice::ConstPtr device, m_pendingDeviceConnections) - connectDevice(device); - - m_pendingDeviceConnections.clear(); - disconnect(BlackBerryConfigurationManager::instance(), SIGNAL(settingsLoaded()), - this, SLOT(processPendingDeviceConnections())); -} - -BlackBerryDeviceConnection *BlackBerryDeviceConnectionManager::connectionForHost(const QString &host) const -{ - QList<BlackBerryDeviceConnection*> connections = m_connections.uniqueKeys(); - - foreach (BlackBerryDeviceConnection *connection, connections) { - if (connection->host() == host) - return connection; - } - - return 0; -} - -QList<Core::Id> BlackBerryDeviceConnectionManager::devicesForHost(const QString &host) const -{ - QList<Core::Id> result; - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - - for (int i = 0; i < deviceManager->deviceCount(); ++i) { - ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i); - if (device->type() == Core::Id(Constants::QNX_BB_OS_TYPE) - && device->sshParameters().host == host) - result << device->id(); - } - - return result; -} - -int BlackBerryDeviceConnectionManager::connectionUsageCount(Core::Id deviceId) -{ - BlackBerryDeviceConnection *connection = m_connections.key(deviceId); - return m_connections.count(connection); -} - -void BlackBerryDeviceConnectionManager::disconnectRemovedDevices() -{ - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - - QList<Core::Id> knownDevices = m_connections.values(); - foreach (Core::Id id, knownDevices) { - ProjectExplorer::IDevice::ConstPtr device = deviceManager->find(id); - if (device.isNull() && connectionUsageCount(id) <= 1) - disconnectDevice(id); - } -} - -void BlackBerryDeviceConnectionManager::reconnectChangedDevices() -{ - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - QList<Core::Id> connectedDevices = m_connections.values(); - - for (int i = 0; i < deviceManager->deviceCount(); ++i) { - ProjectExplorer::IDevice::ConstPtr device = deviceManager->deviceAt(i); - if (!connectedDevices.contains(device->id())) - continue; - - BlackBerryDeviceConnection *connection = m_connections.key(device->id()); - QTC_ASSERT(connection, continue); - - if (connection->host() == device->sshParameters().host) - continue; - - if (connectionUsageCount(device->id()) <= 1) - disconnectDevice(device->id()); - - m_connections.remove(connection, device->id()); - connectDevice(device->id()); - } -} - -void BlackBerryDeviceConnectionManager::connectAddedDevices() -{ - ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance(); - - QList<Core::Id> knownDevices = m_connections.values(); - for (int i = 0; i < deviceManager->deviceCount(); ++i) { - Core::Id deviceId = deviceManager->deviceAt(i)->id(); - if (!knownDevices.contains(deviceId)) - connectDevice(deviceId); - } -} diff --git a/src/plugins/qnx/blackberrydeviceconnectionmanager.h b/src/plugins/qnx/blackberrydeviceconnectionmanager.h deleted file mode 100644 index f2ae361e33f..00000000000 --- a/src/plugins/qnx/blackberrydeviceconnectionmanager.h +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICECONNECTIONMANAGER_H -#define QNX_INTERNAL_BLACKBERRYDEVICECONNECTIONMANAGER_H - -#include <QObject> - -#include <coreplugin/id.h> -#include <projectexplorer/devicesupport/idevice.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceConnection; - -class BlackBerryDeviceConnectionManager : public QObject -{ - Q_OBJECT -public: - ~BlackBerryDeviceConnectionManager(); - - void initialize(); - void killAllConnections(); - - static BlackBerryDeviceConnectionManager *instance(); - - bool isConnected(Core::Id deviceId); - - QString connectionLog(Core::Id deviceId) const; - - void connectDevice(const ProjectExplorer::IDevice::ConstPtr &device); - void disconnectDevice(const ProjectExplorer::IDevice::ConstPtr &device); - - const QString privateKeyPath() const; - bool hasValidSSHKeys() const; - bool setSSHKeys(const QByteArray &privateKeyContent, const QByteArray &publicKeyContent, - QString *error); - -signals: - void connectionOutput(Core::Id deviceId, const QString &output); - void deviceAboutToConnect(Core::Id deviceId); - void deviceConnected(); - void deviceDisconnected(Core::Id deviceId); - -public slots: - void connectDevice(Core::Id deviceId); - void disconnectDevice(Core::Id deviceId); - -private slots: - void handleDeviceListChanged(); - - void handleDeviceAboutToConnect(); - void handleDeviceConnected(); - void handleDeviceDisconnected(); - - void handleProcessOutput(const QString &output); - - void processPendingDeviceConnections(); - -private: - explicit BlackBerryDeviceConnectionManager(); - - BlackBerryDeviceConnection *connectionForHost(const QString &host) const; - QList<Core::Id> devicesForHost(const QString &host) const; - - int connectionUsageCount(Core::Id deviceId); - - void disconnectRemovedDevices(); - void reconnectChangedDevices(); - void connectAddedDevices(); - - static BlackBerryDeviceConnectionManager *m_instance; - QMultiMap<BlackBerryDeviceConnection*, Core::Id> m_connections; - - QList<ProjectExplorer::IDevice::ConstPtr> m_pendingDeviceConnections; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICECONNECTIONMANAGER_H diff --git a/src/plugins/qnx/blackberrydeviceinformation.cpp b/src/plugins/qnx/blackberrydeviceinformation.cpp deleted file mode 100644 index edb4fcb8dd7..00000000000 --- a/src/plugins/qnx/blackberrydeviceinformation.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydeviceinformation.h" - -namespace { -static const char PROCESS_NAME[] = "blackberry-deploy"; -static const char ERR_NO_ROUTE_HOST[] = "Cannot connect"; -static const char ERR_AUTH_FAILED[] = "Authentication failed"; -static const char ERR_DEVELOPMENT_MODE_DISABLED[] = "Device is not in the Development Mode"; -} - -namespace Qnx { -namespace Internal { - -BlackBerryDeviceInformation::BlackBerryDeviceInformation(QObject *parent) : - BlackBerryNdkProcess(QLatin1String(PROCESS_NAME), parent), - m_debugTokenValid(false), m_isSimulator(false), m_isProductionDevice(true) -{ - addErrorStringMapping(QLatin1String(ERR_NO_ROUTE_HOST), NoRouteToHost); - addErrorStringMapping(QLatin1String(ERR_AUTH_FAILED), AuthenticationFailed); - addErrorStringMapping(QLatin1String(ERR_DEVELOPMENT_MODE_DISABLED), DevelopmentModeDisabled); -} - -void BlackBerryDeviceInformation::setDeviceTarget(const QString &deviceIp, const QString &devicePassword) -{ - QStringList arguments; - - arguments << QLatin1String("-listDeviceInfo") - << QLatin1String("-device") - << deviceIp - << QLatin1String("-password") - << devicePassword; - - start(arguments); -} - -void BlackBerryDeviceInformation::resetResults() -{ - m_devicePin.clear(); - m_deviceOS.clear(); - m_hardwareId.clear(); - m_debugTokenAuthor.clear(); - m_debugTokenValidationError.clear(); - m_scmBundle.clear(); - m_hostName.clear(); - m_debugTokenValid = false; - m_isSimulator = false; - m_isProductionDevice = true; -} - -QString BlackBerryDeviceInformation::devicePin() const -{ - return m_devicePin; -} - -QString BlackBerryDeviceInformation::deviceOS() const -{ - return m_deviceOS; -} - -QString BlackBerryDeviceInformation::hardwareId() const -{ - return m_hardwareId; -} - -QString BlackBerryDeviceInformation::debugTokenAuthor() const -{ - return m_debugTokenAuthor; -} - -QString BlackBerryDeviceInformation::debugTokenValidationError() const -{ - return m_debugTokenValidationError; -} - -QString BlackBerryDeviceInformation::scmBundle() const -{ - return m_scmBundle; -} - -QString BlackBerryDeviceInformation::hostName() const -{ - return m_hostName; -} - -bool BlackBerryDeviceInformation::debugTokenValid() const -{ - return m_debugTokenValid; -} - -bool BlackBerryDeviceInformation::isSimulator() const -{ - return m_isSimulator; -} - -bool BlackBerryDeviceInformation::isProductionDevice() const -{ - return m_isProductionDevice; -} - -void BlackBerryDeviceInformation::processData(const QString &line) -{ - static const QString devicepin = QLatin1String("devicepin::0x"); - static const QString device_os = QLatin1String("device_os::"); - static const QString hardwareid = QLatin1String("hardwareid::"); - static const QString debug_token_author = QLatin1String("[n]debug_token_author::"); - static const QString debug_token_validation_error = QLatin1String("[n]debug_token_validation_error::"); - static const QString debug_token_valid = QLatin1String("[n]debug_token_valid:b:"); - static const QString simulator = QLatin1String("simulator:b:"); - static const QString scmbundle = QLatin1String("scmbundle::"); - static const QString hostname = QLatin1String("hostname::"); - static const QString production_device = QLatin1String("production_device:b:"); - - if (line.startsWith(devicepin)) - m_devicePin = line.mid(devicepin.size()).trimmed(); - else if (line.startsWith(device_os)) - m_deviceOS = line.mid(device_os.size()).trimmed(); - else if (line.startsWith(hardwareid)) - m_hardwareId = line.mid(hardwareid.size()).trimmed(); - else if (line.startsWith(debug_token_author)) - m_debugTokenAuthor = line.mid(debug_token_author.size()).trimmed(); - else if (line.startsWith(debug_token_validation_error)) - m_debugTokenValidationError = line.mid(debug_token_validation_error.size()).trimmed(); - else if (line.startsWith(debug_token_valid)) - m_debugTokenValid = line.mid(debug_token_valid.size()).trimmed() == QLatin1String("true"); - else if (line.startsWith(simulator)) - m_isSimulator = line.mid(simulator.size()).trimmed() == QLatin1String("true"); - else if (line.startsWith(scmbundle)) - m_scmBundle = line.mid(scmbundle.size()).trimmed(); - else if (line.startsWith(hostname)) - m_hostName = line.mid(hostname.size()).trimmed(); - else if (line.startsWith(production_device)) - m_isProductionDevice = line.mid(production_device.size()).trimmed() == QLatin1String("true"); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrydeviceinformation.h b/src/plugins/qnx/blackberrydeviceinformation.h deleted file mode 100644 index b08dba75b82..00000000000 --- a/src/plugins/qnx/blackberrydeviceinformation.h +++ /dev/null @@ -1,92 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICEINFO_H -#define QNX_INTERNAL_BLACKBERRYDEVICEINFO_H - -#include "blackberryndkprocess.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceInformation : public BlackBerryNdkProcess -{ - Q_OBJECT - -public: - enum ReturnStatus - { - NoRouteToHost = UserStatus, - AuthenticationFailed, - DevelopmentModeDisabled, - FailedToStartInferiorProcess, - InferiorProcessTimedOut, - InferiorProcessCrashed, - InferiorProcessWriteError, - InferiorProcessReadError - }; - - explicit BlackBerryDeviceInformation(QObject *parent = 0); - - void setDeviceTarget(const QString &deviceIp, const QString &devicePassword); - - QString devicePin() const; - QString deviceOS() const; - QString hardwareId() const; - QString debugTokenAuthor() const; - QString debugTokenValidationError() const; - bool debugTokenValid() const; - QString scmBundle() const; - QString hostName() const; - bool isSimulator() const; - bool isProductionDevice() const; - -private: - QString m_devicePin; - QString m_deviceOS; - QString m_hardwareId; - QString m_debugTokenAuthor; - QString m_scmBundle; - QString m_hostName; - QString m_debugTokenValidationError; - bool m_debugTokenValid; - bool m_isSimulator; - bool m_isProductionDevice; - - void processData(const QString &line); - void resetResults(); -}; - -} -} - -#endif // QNX_INTERNAL_BLACKBERRYDEBUGTOKENUPLOADER_H diff --git a/src/plugins/qnx/blackberrydevicelistdetector.cpp b/src/plugins/qnx/blackberrydevicelistdetector.cpp deleted file mode 100644 index c8a5a35df96..00000000000 --- a/src/plugins/qnx/blackberrydevicelistdetector.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrydevicelistdetector.h" - -#include "blackberryconfigurationmanager.h" -#include "blackberryndkprocess.h" - -#include <utils/environment.h> - -#include <QStringList> - -namespace Qnx { -namespace Internal { - -BlackBerryDeviceListDetector::BlackBerryDeviceListDetector(QObject *parent) - : QObject(parent) - , m_process(new QProcess(this)) -{ - m_process->setProcessChannelMode(QProcess::MergedChannels); - - connect(m_process, SIGNAL(readyRead()), this, SLOT(processReadyRead())); - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(processFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processFinished())); -} - -void BlackBerryDeviceListDetector::detectDeviceList() -{ - if (m_process->state() != QProcess::NotRunning) - return; - - m_process->setEnvironment(Utils::EnvironmentItem::toStringList( - BlackBerryConfigurationManager::instance()->defaultConfigurationEnv())); - const QString command = BlackBerryNdkProcess::resolveNdkToolPath(QLatin1String("blackberry-deploy")); - QStringList arguments; - arguments << QLatin1String("-devices"); - - m_process->start(command, arguments, QIODevice::ReadWrite | QIODevice::Unbuffered); -} - -void BlackBerryDeviceListDetector::processReadyRead() -{ - while (m_process->canReadLine()) - processData(readProcessLine()); -} - -void BlackBerryDeviceListDetector::processFinished() -{ - while (!m_process->atEnd()) - processData(readProcessLine()); - emit finished(); -} - -const QString BlackBerryDeviceListDetector::readProcessLine() -{ - // we assume that the process output is ASCII only - QByteArray bytes = m_process->readLine(); - while (bytes.endsWith('\r') || bytes.endsWith('\n')) - bytes.chop(1); - return QString::fromLocal8Bit(bytes); -} - -void BlackBerryDeviceListDetector::processData(const QString &line) -{ - // line format is: deviceName,deviceHostNameOrIP,deviceType,versionIfSimulator - QStringList list = line.split(QLatin1Char(',')); - if (list.count() == 4) - emit deviceDetected (list[0], list[1], QLatin1String("Simulator") == list[2]); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrydevicelistdetector.h b/src/plugins/qnx/blackberrydevicelistdetector.h deleted file mode 100644 index b391ac1b314..00000000000 --- a/src/plugins/qnx/blackberrydevicelistdetector.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYDEVICELISTDETECTOR_H -#define QNX_INTERNAL_BLACKBERRYDEVICELISTDETECTOR_H - -#include <QObject> -#include <QString> - -QT_FORWARD_DECLARE_CLASS(QProcess) - -namespace Qnx { -namespace Internal { - -class BlackBerryDeviceListDetector : public QObject -{ - Q_OBJECT -public: - explicit BlackBerryDeviceListDetector(QObject *parent = 0); - - void detectDeviceList(); - -signals: - void deviceDetected(const QString &deviceName, const QString &deviceHostName, - bool isSimulator); - void finished(); - -private slots: - void processReadyRead(); - void processFinished(); - -private: - const QString readProcessLine(); - void processData(const QString &line); - - QProcess *m_process; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYDEVICELISTDETECTOR_H diff --git a/src/plugins/qnx/blackberryimportcertificatedialog.cpp b/src/plugins/qnx/blackberryimportcertificatedialog.cpp deleted file mode 100644 index 8e989e90cf0..00000000000 --- a/src/plugins/qnx/blackberryimportcertificatedialog.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryimportcertificatedialog.h" -#include "blackberrycertificate.h" -#include "ui_blackberryimportcertificatedialog.h" - -#include <QPushButton> -#include <QMessageBox> - -#include <utils/pathchooser.h> - -namespace Qnx { -namespace Internal { - -BlackBerryImportCertificateDialog::BlackBerryImportCertificateDialog( - QWidget *parent, Qt::WindowFlags f) : - QDialog(parent, f), - m_ui(new Ui_BlackBerryImportCertificateDialog), - m_certificate(0) -{ - m_ui->setupUi(this); - m_ui->certPath->setExpectedKind(Utils::PathChooser::File); - m_ui->certPath->setHistoryCompleter(QLatin1String("BB.Certificate.History")); - m_ui->certPath->setPromptDialogTitle(tr("Import Certificate")); - m_ui->certPath->setPromptDialogFilter(tr("PKCS 12 Archives (*.p12)")); - - m_cancelButton = m_ui->buttonBox->button(QDialogButtonBox::Cancel); - - m_okButton = m_ui->buttonBox->button(QDialogButtonBox::Ok); - m_okButton->setEnabled(false); - - connect(m_cancelButton, SIGNAL(clicked()), - this, SLOT(reject())); - connect(m_okButton, SIGNAL(clicked()), - this, SLOT(importCertificate())); - connect(m_ui->certPath, SIGNAL(changed(QString)), - this, SLOT(validate())); - connect(m_ui->certPass, SIGNAL(textChanged(QString)), - this, SLOT(validate())); -} - -QString BlackBerryImportCertificateDialog::author() const -{ - return m_author; -} - -QString BlackBerryImportCertificateDialog::certPath() const -{ - return m_ui->certPath->path(); -} - -QString BlackBerryImportCertificateDialog::keystorePassword() const -{ - return m_ui->certPass->text(); -} - -BlackBerryCertificate * BlackBerryImportCertificateDialog::certificate() const -{ - return m_certificate; -} - -void BlackBerryImportCertificateDialog::importCertificate() -{ - setBusy(true); - - m_certificate = new BlackBerryCertificate(certPath(), - QString(), keystorePassword()); - - connect(m_certificate, SIGNAL(finished(int)), this, SLOT(certificateLoaded(int))); - - m_certificate->load(); -} - -void BlackBerryImportCertificateDialog::validate() -{ - if (!m_ui->certPath->isValid() || m_ui->certPass->text().isEmpty()) { - m_okButton->setEnabled(false); - return; - } - - m_okButton->setEnabled(true); -} - -void BlackBerryImportCertificateDialog::certificateLoaded(int status) -{ - if (status != BlackBerryCertificate::Success) { - setBusy(false); - - m_certificate->deleteLater(); - m_certificate = 0; - - QString message; - - if (status == BlackBerryCertificate::WrongPassword) - message = tr("The keystore password is invalid."); - else if (status == BlackBerryCertificate::InvalidOutputFormat) - message = tr("Error parsing inferior process output."); - else - message = tr("An unknown error has occurred."); - - QMessageBox::information(this, tr("Error"), message); - - } else { - m_author = m_certificate->author(); - accept(); - } -} - -void BlackBerryImportCertificateDialog::setBusy(bool busy) -{ - m_ui->certPath->setEnabled(!busy); - m_ui->certPass->setEnabled(!busy); - m_okButton->setEnabled(!busy); - m_cancelButton->setEnabled(!busy); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryimportcertificatedialog.h b/src/plugins/qnx/blackberryimportcertificatedialog.h deleted file mode 100644 index 41d06444ad7..00000000000 --- a/src/plugins/qnx/blackberryimportcertificatedialog.h +++ /dev/null @@ -1,83 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYIMPORTCERTIFICATEDIALOG_H -#define QNX_INTERNAL_BLACKBERRYIMPORTCERTIFICATEDIALOG_H - -#include <QDialog> - -QT_BEGIN_NAMESPACE -class QPushButton; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryImportCertificateDialog; -class BlackBerryCertificate; - -class BlackBerryImportCertificateDialog : public QDialog -{ -Q_OBJECT - -public: - explicit BlackBerryImportCertificateDialog(QWidget *parent = 0, - Qt::WindowFlags f = 0); - - QString author() const; - QString certPath() const; - QString keystorePassword() const; - - BlackBerryCertificate *certificate() const; - -private slots: - void importCertificate(); - void validate(); - void certificateLoaded(int); - -private: - void setBusy(bool busy); - - Ui_BlackBerryImportCertificateDialog *m_ui; - - BlackBerryCertificate *m_certificate; - - QString m_author; - - QPushButton *m_cancelButton; - QPushButton *m_okButton; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYIMPORTCERTIFICATEDIALOG_H diff --git a/src/plugins/qnx/blackberryimportcertificatedialog.ui b/src/plugins/qnx/blackberryimportcertificatedialog.ui deleted file mode 100644 index 26d08fcfdc4..00000000000 --- a/src/plugins/qnx/blackberryimportcertificatedialog.ui +++ /dev/null @@ -1,70 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryImportCertificateDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerryImportCertificateDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>412</width> - <height>88</height> - </rect> - </property> - <property name="windowTitle"> - <string>Import Certificate</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Path:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="certPath" native="true"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Password:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="certPass"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberryinstallwizard.cpp b/src/plugins/qnx/blackberryinstallwizard.cpp deleted file mode 100644 index 044685e2f63..00000000000 --- a/src/plugins/qnx/blackberryinstallwizard.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryinstallwizard.h" -#include "blackberryinstallwizardpages.h" - -#include <QAbstractButton> - -#include <QMessageBox> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryInstallWizard::BlackBerryInstallWizard(BlackBerryInstallerDataHandler::Mode mode, - BlackBerryInstallerDataHandler::Target target, - const QString& version, - QWidget *parent) - : Utils::Wizard(parent) - , m_ndkPage(0) - , m_targetPage(0) -{ - setWindowTitle(tr("BlackBerry NDK Installation Wizard")); - - m_data.mode = mode; - m_data.installTarget = target; - m_data.version = version; - - - if (m_data.mode != BlackBerryInstallerDataHandler::UninstallMode) { - m_optionPage = new BlackBerryInstallWizardOptionPage(m_data, this); - m_ndkPage = new BlackBerryInstallWizardNdkPage(m_data, this); - m_targetPage = new BlackBerryInstallWizardTargetPage(m_data, this); - setPage(OptionPage, m_optionPage); - setPage(NdkPageId, m_ndkPage); - setPage(TargetPageId, m_targetPage); - } - - m_processPage = new BlackBerryInstallWizardProcessPage(m_data, this); - m_finalPage = new BlackBerryInstallWizardFinalPage(m_data, this); - - connect(m_finalPage, SIGNAL(done()), this, SIGNAL(processFinished())); - disconnect(button(CancelButton), SIGNAL(clicked()), this, SLOT(reject())); - connect(button(CancelButton), SIGNAL(clicked()), this, SLOT(handleProcessCancelled())); - - setPage(ProcessPageId, m_processPage); - setPage(FinalPageId, m_finalPage); - - m_finalPage->setCommitPage(true); - - setOption(DisabledBackButtonOnLastPage, true); -} - -void BlackBerryInstallWizard::handleProcessCancelled() -{ - if ((m_targetPage && m_targetPage->isProcessRunning()) - || m_processPage->isProcessRunning()) { - const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Confirmation"), - tr("Are you sure you want to cancel?"), - QMessageBox::Yes | QMessageBox::No); - if (answer == QMessageBox::No) - return; - } - - reject(); -} diff --git a/src/plugins/qnx/blackberryinstallwizard.h b/src/plugins/qnx/blackberryinstallwizard.h deleted file mode 100644 index 7c38d0f5e24..00000000000 --- a/src/plugins/qnx/blackberryinstallwizard.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H -#define QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H - -#include <utils/wizard.h> - -#include <QProcess> - -namespace Qnx { -namespace Internal { - -class BlackBerryInstallWizardOptionPage; -class BlackBerryInstallWizardNdkPage; -class BlackBerryInstallWizardTargetPage; -class BlackBerryInstallWizardProcessPage; -class BlackBerryInstallWizardFinalPage; - -class BlackBerryInstallerDataHandler { -public: - enum Mode { - InstallMode, - UninstallMode, - ManuallMode - }; - - enum Target { - ApiLevel, - Simulator, - Runtime - }; - - QString ndkPath; - QString target; - QString version; - int exitCode; - QProcess::ExitStatus exitStatus; - Mode mode; - Target installTarget; -}; - -class BlackBerryInstallWizard : public Utils::Wizard -{ - Q_OBJECT -public: - enum PageId { - OptionPage, - NdkPageId, - TargetPageId, - ProcessPageId, - FinalPageId - }; - - explicit BlackBerryInstallWizard(BlackBerryInstallerDataHandler::Mode mode = BlackBerryInstallerDataHandler::InstallMode, - BlackBerryInstallerDataHandler::Target target = BlackBerryInstallerDataHandler::ApiLevel, - const QString& version = QString(), - QWidget *parent = 0); - -signals: - void processFinished(); - -private slots: - void handleProcessCancelled(); - -private: - - BlackBerryInstallWizardOptionPage *m_optionPage; - BlackBerryInstallWizardNdkPage *m_ndkPage; - BlackBerryInstallWizardTargetPage *m_targetPage; - BlackBerryInstallWizardProcessPage *m_processPage; - BlackBerryInstallWizardFinalPage *m_finalPage; - - BlackBerryInstallerDataHandler m_data; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYINSTALLWIZARD_H diff --git a/src/plugins/qnx/blackberryinstallwizardndkpage.ui b/src/plugins/qnx/blackberryinstallwizardndkpage.ui deleted file mode 100644 index 133d1ca012e..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardndkpage.ui +++ /dev/null @@ -1,31 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryInstallWizardNdkPage</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryInstallWizardNdkPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Select Native SDK path:</string> - </property> - </widget> - </item> - <item> - <widget class="QListWidget" name="ndkPathListWidget"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberryinstallwizardoptionpage.ui b/src/plugins/qnx/blackberryinstallwizardoptionpage.ui deleted file mode 100644 index d632fec0924..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardoptionpage.ui +++ /dev/null @@ -1,97 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryInstallWizardOptionPage</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryInstallWizardOptionPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>457</width> - <height>278</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QRadioButton" name="apiLevelButton"> - <property name="text"> - <string>Install API level</string> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - <item> - <layout class="QVBoxLayout" name="apiLevelOptionsLayout"> - <item> - <widget class="QRadioButton" name="installButton"> - <property name="text"> - <string>Install new target</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="addButton"> - <property name="text"> - <string>Add existing target</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </item> - <item> - <widget class="QRadioButton" name="simulatorButton"> - <property name="text"> - <string>Install simulator</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="runtimeButton"> - <property name="text"> - <string>Install runtime</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberryinstallwizardpages.cpp b/src/plugins/qnx/blackberryinstallwizardpages.cpp deleted file mode 100644 index de6f36838fd..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardpages.cpp +++ /dev/null @@ -1,564 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryinstallwizardpages.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" - -#include "ui_blackberryinstallwizardoptionpage.h" -#include "ui_blackberryinstallwizardtargetpage.h" -#include "ui_blackberryinstallwizardprocesspage.h" -#include "ui_blackberryinstallwizardndkpage.h" - -#include "qnxutils.h" - -#include <utils/synchronousprocess.h> -#include <utils/pathchooser.h> - -#include <QProcess> - -#include <QTreeWidgetItem> - -#include <QFileInfo> -#include <QDir> - -#include <QMessageBox> - -namespace Qnx { -namespace Internal { - -namespace { -const QLatin1String targetKeyWord("Native SDK"); -} - -NdkPathChooser::NdkPathChooser(Mode mode, QWidget *parent) - : Utils::PathChooser(parent) - , m_mode(mode) -{ - setHistoryCompleter(QLatin1String("Qnx.NdkPath.History")); - if (m_mode == NdkPathChooser::InstallMode) { - setExpectedKind(Utils::PathChooser::Directory); - } else { - setExpectedKind(Utils::PathChooser::File); - setPromptDialogFilter(Utils::HostOsInfo::isWindowsHost() ? QLatin1String("*.bat") : - QLatin1String("*.sh")); - } -} - -bool NdkPathChooser::validatePath(const QString &path, QString *errorMessage) -{ - bool result = PathChooser::validatePath(path, errorMessage); - if (!result) - return false; - - if (m_mode == NdkPathChooser::InstallMode) - return !(QnxUtils::sdkInstallerPath(path).isEmpty()); - - QFileInfo fi(path); - if (Utils::HostOsInfo::isWindowsHost()) - return fi.suffix() == QLatin1String("bat"); - - return fi.suffix() == QLatin1String("sh"); -} - -//------------------------------------------------------------------ - -BlackBerryInstallWizardOptionPage::BlackBerryInstallWizardOptionPage(BlackBerryInstallerDataHandler &data, - QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui_BlackBerryInstallWizardOptionPage) - , m_buttonGroup(new QButtonGroup(this)) - , m_envFileChooser(new NdkPathChooser(NdkPathChooser::ManualMode)) - , m_data(data) -{ - m_ui->setupUi(this); - setTitle(tr("Options")); - connect(m_ui->addButton, SIGNAL(toggled(bool)), this, SLOT(handleApiLevelOptionChanged())); - connect(m_envFileChooser, SIGNAL(pathChanged(QString)), this, SLOT(handlePathChanged(QString))); - connect(m_ui->apiLevelButton, SIGNAL(toggled(bool)), this, SLOT(handleTargetChanged())); - connect(m_ui->simulatorButton, SIGNAL(toggled(bool)), this, SLOT(handleTargetChanged())); - connect(m_ui->runtimeButton, SIGNAL(toggled(bool)), this, SLOT(handleTargetChanged())); -} - -BlackBerryInstallWizardOptionPage::~BlackBerryInstallWizardOptionPage() -{ - delete m_ui; -} - -void BlackBerryInstallWizardOptionPage::initializePage() -{ - m_ui->apiLevelOptionsLayout->addWidget(m_envFileChooser); - m_buttonGroup->addButton(m_ui->installButton); - m_buttonGroup->addButton(m_ui->addButton); - - m_ui->apiLevelButton->setChecked(true); - if (m_data.mode == BlackBerryInstallerDataHandler::ManuallMode) - m_ui->addButton->setChecked(true); - else - m_ui->installButton->setChecked(true); - - m_envFileChooser->setEnabled(m_ui->addButton->isChecked()); -} - -bool BlackBerryInstallWizardOptionPage::isComplete() const -{ - if (m_ui->addButton->isEnabled() && m_ui->addButton->isChecked()) - return m_envFileChooser->isValid(); - - return true; -} - -int BlackBerryInstallWizardOptionPage::nextId() const -{ - if (m_ui->addButton->isChecked()) - return BlackBerryInstallWizard::FinalPageId; - - return BlackBerryInstallWizard::NdkPageId; -} - -void BlackBerryInstallWizardOptionPage::handleApiLevelOptionChanged() -{ - if (m_ui->addButton->isChecked()) - m_data.mode = BlackBerryInstallerDataHandler::ManuallMode; - else - m_data.mode = BlackBerryInstallerDataHandler::InstallMode; - - m_envFileChooser->setEnabled(m_ui->addButton->isChecked()); - emit completeChanged(); -} - -void BlackBerryInstallWizardOptionPage::handlePathChanged(const QString &envFilePath) -{ - if (m_envFileChooser->isValid()) - m_data.ndkPath = envFilePath; - - emit completeChanged(); -} - -void BlackBerryInstallWizardOptionPage::handleTargetChanged() -{ - m_ui->installButton->setEnabled(m_ui->apiLevelButton->isChecked()); - m_ui->addButton->setEnabled(m_ui->apiLevelButton->isChecked()); - - if (m_ui->apiLevelButton->isChecked()) - m_data.installTarget = BlackBerryInstallerDataHandler::ApiLevel; - else if (m_ui->simulatorButton->isChecked()) - m_data.installTarget = BlackBerryInstallerDataHandler::Simulator; - else if (m_ui->runtimeButton->isChecked()) - m_data.installTarget = BlackBerryInstallerDataHandler::Runtime; - - emit completeChanged(); -} - -//------------------------------------------------------------------ - -BlackBerryInstallWizardNdkPage::BlackBerryInstallWizardNdkPage(BlackBerryInstallerDataHandler &data, QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui_BlackBerryInstallWizardNdkPage) - , m_data(data) - , m_ndkPathChooser(new NdkPathChooser(NdkPathChooser::InstallMode)) - , m_manual(new QListWidgetItem) - , m_validNdkPath(false) -{ - m_ui->setupUi(this); - setTitle(tr("Native SDK")); - m_ui->verticalLayout->addWidget(m_ndkPathChooser); - connect(m_ui->ndkPathListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(setNdkPath())); - connect(m_ndkPathChooser, SIGNAL(pathChanged(QString)), this, SLOT(setManualNdkPath())); -} - -BlackBerryInstallWizardNdkPage::~BlackBerryInstallWizardNdkPage() -{ - delete m_ui; -} - -void BlackBerryInstallWizardNdkPage::initializePage() -{ - m_manual->setText(tr("Specify 10.2 NDK path manually")); - m_ui->ndkPathListWidget->addItem(m_manual); - m_manual->setSelected(true); - QFont font; - font.setItalic(true); - m_manual->setFont(font); - foreach (const ConfigInstallInformation &ndk, QnxUtils::installedConfigs()) { - bool found = false; - for (int i = 0; i < m_ui->ndkPathListWidget->count(); i++) { - QListWidgetItem* item = m_ui->ndkPathListWidget->item(i); - if (item->text() == ndk.path) { - found = true; - break; - } - } - - if (found) - continue; - - if (!QnxUtils::sdkInstallerPath(ndk.path).isEmpty()) { - QListWidgetItem *ndkItem = new QListWidgetItem(m_ui->ndkPathListWidget); - ndkItem->setText(ndk.path); - } - } -} - -void BlackBerryInstallWizardNdkPage::setNdkPath() -{ - if (m_ui->ndkPathListWidget->selectedItems().isEmpty()) - return; - - m_ndkPathChooser->setEnabled(m_manual->isSelected()); - QString selected = m_ui->ndkPathListWidget->selectedItems().first()->text(); - if (!QnxUtils::sdkInstallerPath(selected).isEmpty()) { - m_validNdkPath = true; - m_data.ndkPath = selected; - } else { - m_validNdkPath = false; - } - - emit completeChanged(); -} - -void BlackBerryInstallWizardNdkPage::setManualNdkPath() -{ - if (m_ndkPathChooser->isValid()) { - m_validNdkPath = true; - m_data.ndkPath = m_ndkPathChooser->path(); - } else { - m_validNdkPath = false; - } - - emit completeChanged(); -} - -bool BlackBerryInstallWizardNdkPage::isComplete() const -{ - return m_validNdkPath; -} - -//------------------------------------------------------------------ - -BlackBerryInstallWizardTargetPage::BlackBerryInstallWizardTargetPage(BlackBerryInstallerDataHandler &data, - QWidget *parent) - : QWizardPage(parent) - , m_data(data) - , m_ui(new Ui_BlackBerryInstallWizardTargetPage) - , m_isTargetValid(false) - , m_targetListProcess(new QProcess(this)) -{ - m_ui->setupUi(this); - setTitle(tr("Version")); - - connect(m_targetListProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(targetsListProcessFinished())); - connect(m_ui->targetsTreeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(setTarget())); -} - -BlackBerryInstallWizardTargetPage::~BlackBerryInstallWizardTargetPage() -{ - Utils::SynchronousProcess::stopProcess(*m_targetListProcess); - delete m_ui; -} - -void BlackBerryInstallWizardTargetPage::initializePage() -{ - // process may be running if going back and forth - if (m_targetListProcess->state() == QProcess::Running) { - disconnect(m_targetListProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(targetsListProcessFinished())); - Utils::SynchronousProcess::stopProcess(*m_targetListProcess); - connect(m_targetListProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(targetsListProcessFinished())); - } - - updateAvailableTargetsList(); -} - -bool BlackBerryInstallWizardTargetPage::isComplete() const -{ - return m_isTargetValid; -} - -bool BlackBerryInstallWizardTargetPage::isProcessRunning() const -{ - return (m_targetListProcess->state() == QProcess::Running); -} - -void BlackBerryInstallWizardTargetPage::targetsListProcessFinished() -{ - initTargetsTreeWidget(); - QString output = Utils::SynchronousProcess::normalizeNewlines(QString::fromLatin1(m_targetListProcess->readAll())); - QList<QString> targetList = output.split(QLatin1Char('\n')); - m_ui->targetsTreeWidget->clear(); - foreach (const QString &target, targetList) { - if (!target.isEmpty() && target.contains(targetKeyWord)) { - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->targetsTreeWidget); - QStringList res = target.split(QLatin1Char('-')); - if (res.count() > 1) { - item->setText(0, res.at(0)); - item->setText(1, res.at(1)); - } - } - } - - m_ui->targetsTreeWidget->sortByColumn(0, Qt::DescendingOrder); - -} - -void BlackBerryInstallWizardTargetPage::setTarget() -{ - if (m_ui->targetsTreeWidget->selectedItems().isEmpty()) - return; - - QString version = m_ui->targetsTreeWidget->selectedItems().first()->text(0); - QString target = m_ui->targetsTreeWidget->selectedItems().first()->text(1); - if (target.contains(targetKeyWord)) { - m_data.target = target; - m_data.version = version; - m_isTargetValid = true; - } else { - m_isTargetValid = false; - } - - emit completeChanged(); -} - -void BlackBerryInstallWizardTargetPage::initTargetsTreeWidget() -{ - m_ui->targetsTreeWidget->clear(); - m_ui->targetsTreeWidget->setHeaderHidden(false); - m_ui->targetsTreeWidget->header()->setSectionResizeMode(QHeaderView::ResizeToContents); - m_ui->targetsTreeWidget->setHeaderItem(new QTreeWidgetItem(QStringList() << tr("Version") << tr("Name"))); - m_ui->targetsTreeWidget->setTextElideMode(Qt::ElideNone); - m_ui->targetsTreeWidget->setColumnCount(2); -} - -void BlackBerryInstallWizardTargetPage::updateAvailableTargetsList() -{ - m_ui->targetsTreeWidget->clear(); - m_ui->targetsTreeWidget->setHeaderHidden(true); - QTreeWidgetItem *item = new QTreeWidgetItem(m_ui->targetsTreeWidget); - item->setText(0, tr("Querying available versions. Please wait...")); - QFont font; - font.setItalic(true); - item->setFont(0, font); - QString qdeProcess = QnxUtils::qdeInstallProcess(m_data.ndkPath, QString(), QLatin1String(" --list")); - QTC_ASSERT(!qdeProcess.isEmpty(), return); - m_targetListProcess->start(qdeProcess); -} - -//------------------------------------------------------------------ - -BlackBerryInstallWizardProcessPage::BlackBerryInstallWizardProcessPage(BlackBerryInstallerDataHandler &data, - QWidget *parent) - : QWizardPage(parent) - , m_ui(new Ui_BlackBerryInstallWizardProcessPage) - , m_data(data) - , m_targetProcess(new QProcess(this)) -{ - m_ui->setupUi(this); - if (m_data.mode == BlackBerryInstallerDataHandler::UninstallMode) - setTitle(tr("Uninstalling")); - else - setTitle(tr("Installing")); - - connect(m_targetProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(handleProcessFinished(int,QProcess::ExitStatus))); -} - -BlackBerryInstallWizardProcessPage::~BlackBerryInstallWizardProcessPage() -{ - Utils::SynchronousProcess::stopProcess(*m_targetProcess); - delete m_ui; -} - -static QString msgTarget(BlackBerryInstallerDataHandler::Target t) -{ - switch (t) { - case BlackBerryInstallerDataHandler::ApiLevel: - return BlackBerryInstallWizardProcessPage::tr("API level"); - case BlackBerryInstallerDataHandler::Simulator: - return BlackBerryInstallWizardProcessPage::tr("simulator"); - case BlackBerryInstallerDataHandler::Runtime: - return BlackBerryInstallWizardProcessPage::tr("runtime"); - default: - break; - } - return QString(); -} - -void BlackBerryInstallWizardProcessPage::initializePage() -{ - if (m_data.mode == BlackBerryInstallerDataHandler::UninstallMode) { - if (m_data.version.isEmpty()) { - wizard()->next(); - return; - } - - foreach (const ConfigInstallInformation &ndk, QnxUtils::installedConfigs()) { - if (ndk.version == m_data.version) { - m_data.ndkPath = ndk.path; - m_data.target = ndk.name; - break; - } - } - - m_ui->label->setText(tr("Uninstalling %1 version: %2") - .arg(msgTarget(m_data.installTarget), m_data.version)); - } else { - m_ui->label->setText(tr("Installing %1 version: %2") - .arg(msgTarget(m_data.installTarget), m_data.version)); - } - // m_targetProcess could be running - if (m_targetProcess->state() == QProcess::Running) { - disconnect(m_targetProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(handleProcessFinished(int,QProcess::ExitStatus))); - Utils::SynchronousProcess::stopProcess(*m_targetProcess); - connect(m_targetProcess, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(handleProcessFinished(int,QProcess::ExitStatus))); - } - - processTarget(); -} - -bool BlackBerryInstallWizardProcessPage::isComplete() const -{ - return false; -} - -bool BlackBerryInstallWizardProcessPage::isProcessRunning() const -{ - return (m_targetProcess->state() == QProcess::Running); -} - -void BlackBerryInstallWizardProcessPage::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) -{ - m_data.exitCode = exitCode; - m_data.exitStatus = exitStatus; - - if (wizard()->currentPage() == this) - wizard()->next(); -} - -void BlackBerryInstallWizardProcessPage::processTarget() -{ - QString target; - if (m_data.installTarget == BlackBerryInstallerDataHandler::Simulator) - target = QLatin1String(" --simulator"); - else if (m_data.installTarget == BlackBerryInstallerDataHandler::Runtime) - target = QLatin1String(" --runtime"); - - QString option; - if (m_data.mode == BlackBerryInstallerDataHandler::UninstallMode) - option = QLatin1String(" --uninstall"); - else - option = QLatin1String(" --install"); - - QString version = m_data.version; - QTC_ASSERT(!version.isEmpty(), return); - - // deactivate target if activated before uninstalling - if (m_data.mode == BlackBerryInstallerDataHandler::UninstallMode) { - foreach (BlackBerryApiLevelConfiguration *config, BlackBerryConfigurationManager::instance()->apiLevels()) { - if (m_data.target.contains((config->targetName())) && config->isActive()) { - config->deactivate(); - break; - } - } - } - - // Killing the sdkinstall process won't kill the qde process it launched - // thus, let's directly launch the resulting qde process - QString qdeProcess = QnxUtils::qdeInstallProcess(m_data.ndkPath, target, option, version); - QTC_ASSERT(!qdeProcess.isEmpty(), return); - m_targetProcess->start(qdeProcess); - - m_ui->progressBar->setMaximum(0); - m_ui->progressBar->setMinimum(0); - m_ui->progressBar->setValue(0); -} - -// -------------------------------------------------------------------------------- - -BlackBerryInstallWizardFinalPage::BlackBerryInstallWizardFinalPage(BlackBerryInstallerDataHandler &data, - QWidget *parent) - : QWizardPage(parent) - , m_data(data) -{ - setTitle(tr("Summary")); -} - -void BlackBerryInstallWizardFinalPage::initializePage() -{ - QVBoxLayout *layout = new QVBoxLayout(this); - QLabel *label = new QLabel(this); - layout->addWidget(label); - - if (m_data.mode == BlackBerryInstallerDataHandler::ManuallMode) { - BlackBerryConfigurationManager *configManager = BlackBerryConfigurationManager::instance(); - BlackBerryApiLevelConfiguration *config = - configManager->apiLevelFromEnvFile(Utils::FileName::fromString(m_data.ndkPath)); - - if (!config) { - config = new BlackBerryApiLevelConfiguration(Utils::FileName::fromString(m_data.ndkPath)); - if (!configManager->addApiLevel(config)) { - delete config; - // TODO: more explicit error message! - label->setText(tr("An error has occurred while adding target from:\n %1").arg(m_data.ndkPath)); - return; - } - - label->setText(tr("Target %1 is being added.").arg(m_data.ndkPath)); - emit done(); - return; - } else { - label->setText(tr("Target %1 is already added.").arg(m_data.ndkPath)); - return; - } - } - - QString message; - const QString target = msgTarget(m_data.installTarget); - - if (m_data.exitCode == 0 && m_data.exitStatus == QProcess::NormalExit) { - message = m_data.mode == BlackBerryInstallerDataHandler::UninstallMode ? - tr("Finished uninstalling %1 version:\n %2").arg(target, m_data.version) : - tr("Finished installing %1 version:\n %2").arg(target, m_data.version); - emit done(); - } else { - message = m_data.mode == BlackBerryInstallerDataHandler::UninstallMode ? - tr("An error has occurred while uninstalling %1 version:\n %2").arg(target, m_data.version) : - tr("An error has occurred while installing %1 version:\n %2").arg(target, m_data.version); - } - label->setText(message); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryinstallwizardpages.h b/src/plugins/qnx/blackberryinstallwizardpages.h deleted file mode 100644 index b45c5656cbc..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardpages.h +++ /dev/null @@ -1,190 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYINSTALLWIZARDPAGES_H -#define QNX_INTERNAL_BLACKBERRYINSTALLWIZARDPAGES_H - -#include <QWizardPage> -#include <QListWidgetItem> - -#include "blackberryinstallwizard.h" - -#include <utils/pathchooser.h> - -QT_BEGIN_NAMESPACE -class QProcess; -class QButtonGroup; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class Ui_BlackBerryInstallWizardOptionPage; -class Ui_BlackBerryInstallWizardNdkPage; -class Ui_BlackBerryInstallWizardTargetPage; -class Ui_BlackBerryInstallWizardProcessPage; - -class NdkPathChooser : public Utils::PathChooser -{ - Q_OBJECT -public: - enum Mode { - InstallMode, // Select a valid 10.2 NDK path - ManualMode // Select a target bbnk-env file path - }; - - NdkPathChooser(Mode mode, QWidget *parent = 0); - virtual bool validatePath(const QString &path, QString *errorMessage); - -private: - Mode m_mode; -}; - -class BlackBerryInstallWizardOptionPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit BlackBerryInstallWizardOptionPage(BlackBerryInstallerDataHandler &data, QWidget *parent = 0); - ~BlackBerryInstallWizardOptionPage(); - void initializePage(); - bool isComplete() const; - int nextId() const; - -protected slots: - void handleApiLevelOptionChanged(); - void handlePathChanged(const QString &envFilePath); - void handleTargetChanged(); - -signals: - void installModeChanged(); - -private: - Ui_BlackBerryInstallWizardOptionPage *m_ui; - QButtonGroup *m_buttonGroup; - - NdkPathChooser *m_envFileChooser; - BlackBerryInstallerDataHandler &m_data; -}; - -class BlackBerryInstallWizardNdkPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit BlackBerryInstallWizardNdkPage(BlackBerryInstallerDataHandler &data, QWidget *parent = 0); - ~BlackBerryInstallWizardNdkPage(); - void initializePage(); - bool isComplete() const; - -protected slots: - void setNdkPath(); - void setManualNdkPath(); - -private: - Ui_BlackBerryInstallWizardNdkPage *m_ui; - BlackBerryInstallerDataHandler &m_data; - NdkPathChooser* m_ndkPathChooser; - QListWidgetItem* m_manual; - bool m_validNdkPath; -}; - -class BlackBerryInstallWizardTargetPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit BlackBerryInstallWizardTargetPage(BlackBerryInstallerDataHandler &data, QWidget *parent = 0); - ~BlackBerryInstallWizardTargetPage(); - - void initializePage(); - bool isComplete() const; - bool isProcessRunning() const; - -protected slots: - void targetsListProcessFinished(); - void setTarget(); - -private: - BlackBerryInstallerDataHandler &m_data; - Ui_BlackBerryInstallWizardTargetPage *m_ui; - bool m_isTargetValid; - QProcess *m_targetListProcess; - - void initTargetsTreeWidget(); - void updateAvailableTargetsList(); - -}; - -class BlackBerryInstallWizardProcessPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit BlackBerryInstallWizardProcessPage(BlackBerryInstallerDataHandler &data, - QWidget *parent = 0); - ~BlackBerryInstallWizardProcessPage(); - - void initializePage(); - bool isComplete() const; - bool isProcessRunning() const; - -protected slots: - void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - -private: - Ui_BlackBerryInstallWizardProcessPage *m_ui; - BlackBerryInstallerDataHandler &m_data; - QProcess *m_targetProcess; - - void processTarget(); -}; - -class BlackBerryInstallWizardFinalPage : public QWizardPage -{ - Q_OBJECT - -public: - explicit BlackBerryInstallWizardFinalPage(BlackBerryInstallerDataHandler &data, QWidget *parent = 0); - void initializePage(); - -signals: - void done(); - -private: - BlackBerryInstallerDataHandler &m_data; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYINSTALLWIZARDPAGES_H diff --git a/src/plugins/qnx/blackberryinstallwizardprocesspage.ui b/src/plugins/qnx/blackberryinstallwizardprocesspage.ui deleted file mode 100644 index 02fe3f76438..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardprocesspage.ui +++ /dev/null @@ -1,48 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryInstallWizardProcessPage</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryInstallWizardProcessPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>400</width> - <height>300</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Please wait...</string> - </property> - </widget> - </item> - <item> - <widget class="QProgressBar" name="progressBar"> - <property name="value"> - <number>24</number> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberryinstallwizardtargetpage.ui b/src/plugins/qnx/blackberryinstallwizardtargetpage.ui deleted file mode 100644 index e3af1ab5804..00000000000 --- a/src/plugins/qnx/blackberryinstallwizardtargetpage.ui +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryInstallWizardTargetPage</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryInstallWizardTargetPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>543</width> - <height>373</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Please select version:</string> - </property> - </widget> - </item> - <item> - <widget class="QTreeWidget" name="targetsTreeWidget"> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrykeyspage.cpp b/src/plugins/qnx/blackberrykeyspage.cpp deleted file mode 100644 index e594af1850d..00000000000 --- a/src/plugins/qnx/blackberrykeyspage.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrykeyspage.h" -#include "blackberrykeyswidget.h" -#include "qnxconstants.h" - -#include <projectexplorer/projectexplorerconstants.h> - -#include <QCoreApplication> - -namespace Qnx { -namespace Internal { - -BlackBerryKeysPage::BlackBerryKeysPage(QObject *parent) : - Core::IOptionsPage(parent), - m_widget(0) -{ - setId(Core::Id(Constants::QNX_BB_SIGNING_ID)); - setDisplayName(tr("Keys")); - setCategory(Constants::QNX_BB_CATEGORY); - setDisplayCategory(QCoreApplication::translate("BlackBerry", - Constants::QNX_BB_CATEGORY_TR)); -} - -QWidget *BlackBerryKeysPage::widget() -{ - if (!m_widget) - m_widget = new BlackBerryKeysWidget; - return m_widget; -} - -void BlackBerryKeysPage::apply() -{ - m_widget->saveSettings(); -} - -void BlackBerryKeysPage::finish() -{ - delete m_widget; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrykeyspage.h b/src/plugins/qnx/blackberrykeyspage.h deleted file mode 100644 index 52b0cb4f0a9..00000000000 --- a/src/plugins/qnx/blackberrykeyspage.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYKEYSPAGE_H -#define BLACKBERRYKEYSPAGE_H - -#include <coreplugin/dialogs/ioptionspage.h> - -#include <QPointer> - -namespace Qnx { -namespace Internal { - -class BlackBerryKeysWidget; - -class BlackBerryKeysPage : public Core::IOptionsPage -{ - Q_OBJECT -public: - explicit BlackBerryKeysPage(QObject *parent = 0); - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<BlackBerryKeysWidget> m_widget; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYKEYSPAGE_H diff --git a/src/plugins/qnx/blackberrykeyswidget.cpp b/src/plugins/qnx/blackberrykeyswidget.cpp deleted file mode 100644 index dcf6231b808..00000000000 --- a/src/plugins/qnx/blackberrykeyswidget.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrykeyswidget.h" -#include "blackberryconfigurationmanager.h" -#include "blackberrycertificate.h" -#include "blackberrysigningutils.h" -#include "blackberrycreatecertificatedialog.h" -#include "blackberrydebugtokenreader.h" -#include "blackberrydebugtokenpinsdialog.h" -#include "blackberrydebugtokenrequester.h" -#include "blackberrydebugtokenrequestdialog.h" -#include "ui_blackberrykeyswidget.h" - -#include "qnxconstants.h" - -#include <QInputDialog> -#include <QFileDialog> -#include <QMessageBox> - -#include <QStandardItemModel> - -namespace Qnx { -namespace Internal { - -BlackBerryKeysWidget::BlackBerryKeysWidget(QWidget *parent) : - QWidget(parent), - m_utils(BlackBerrySigningUtils::instance()), - m_ui(new Ui_BlackBerryKeysWidget), - m_dtModel(new QStandardItemModel(this)), - m_requester(new BlackBerryDebugTokenRequester(this)) -{ - m_ui->setupUi(this); - m_ui->keyStatus->setTextFormat(Qt::RichText); - m_ui->keyStatus->setTextInteractionFlags(Qt::TextBrowserInteraction); - m_ui->keyStatus->setOpenExternalLinks(true); - m_ui->openCertificateButton->setVisible(false); - m_ui->editDbTkButton->setEnabled(false); - m_ui->removeDbTkButton->setEnabled(false); - m_ui->debugTokens->setModel(m_dtModel); - - updateDebugTokenList(); - - connect(m_ui->createCertificateButton, SIGNAL(clicked()), - this, SLOT(createCertificate())); - connect(m_ui->clearCertificateButton, SIGNAL(clicked()), - this, SLOT(clearCertificate())); - connect(m_ui->openCertificateButton, SIGNAL(clicked()), - this, SLOT(loadDefaultCertificate())); - connect(m_ui->requestDbTkButton, SIGNAL(clicked()), - this, SLOT(requestDebugToken())); - connect(m_ui->importDbTkButton, SIGNAL(clicked()), - this, SLOT(importDebugToken())); - connect(m_ui->editDbTkButton, SIGNAL(clicked()), - this, SLOT(editDebugToken())); - connect(m_ui->removeDbTkButton, SIGNAL(clicked()), - this, SLOT(removeDebugToken())); - connect(m_requester, SIGNAL(finished(int)), - this, SLOT(requestFinished(int))); - connect(m_ui->debugTokens, SIGNAL(pressed(QModelIndex)), - this, SLOT(updateUi(QModelIndex))); - connect(&m_utils, SIGNAL(debugTokenListChanged()), - this, SLOT(updateDebugTokenList())); -} - -void BlackBerryKeysWidget::saveSettings() -{ - m_utils.saveDebugTokens(); -} - -void BlackBerryKeysWidget::initModel() -{ - m_dtModel->clear(); - QStringList headers; - headers << tr("Path") << tr("Author") << tr("PINs") << tr("Expiry"); - m_dtModel->setHorizontalHeaderLabels(headers); -} - -void BlackBerryKeysWidget::certificateLoaded(int status) -{ - disconnect(&m_utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(certificateLoaded(int))); - - switch (status) { - case BlackBerryCertificate::Success: - m_ui->certificateAuthor->setText(m_utils.defaultCertificate()->author()); - m_ui->certificateAuthor->setVisible(true); - m_ui->authorLabel->setVisible(true); - m_ui->openCertificateButton->setVisible(false); - break; - case BlackBerryCertificate::WrongPassword: - if (QMessageBox::question(this, tr("Qt Creator"), - tr("Invalid certificate password. Try again?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - loadDefaultCertificate(); - } else { - m_ui->certificateAuthor->clear(); - m_ui->openCertificateButton->setVisible(true); - } - break; - case BlackBerryCertificate::Busy: - case BlackBerryCertificate::InvalidOutputFormat: - case BlackBerryCertificate::Error: - setCertificateError(tr("Error loading certificate.")); - m_ui->openCertificateButton->setVisible(true); - break; - } -} - -void BlackBerryKeysWidget::createCertificate() -{ - if (m_utils.createCertificate()) - updateCertificateSection(); -} - -void BlackBerryKeysWidget::clearCertificate() -{ - if (QMessageBox::warning(this, tr("Qt Creator"), - tr("This action cannot be undone. Would you like to continue?"), - QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { - m_utils.deleteDefaultCertificate(); - updateCertificateSection(); - } -} - -void BlackBerryKeysWidget::showEvent(QShowEvent *) -{ - updateKeysSection(); - updateCertificateSection(); -} - -void BlackBerryKeysWidget::updateCertificateSection() -{ - if (m_utils.hasDefaultCertificate()) { - setCreateCertificateVisible(false); - - m_ui->certificatePath->setText(BlackBerryConfigurationManager::instance()->defaultKeystorePath()); - - const BlackBerryCertificate *certificate = m_utils.defaultCertificate(); - - if (certificate) { - m_ui->certificateAuthor->setText(certificate->author()); - m_ui->openCertificateButton->setVisible(false); - return; - } - - m_ui->openCertificateButton->setVisible(true); - m_ui->certificateAuthor->setVisible(false); - m_ui->authorLabel->setVisible(false); - } else { - setCreateCertificateVisible(true); - } -} - -void BlackBerryKeysWidget::updateKeysSection() -{ - if (m_utils.hasLegacyKeys()) { - m_ui->keyStatus->setText(tr("It appears you are using legacy key files. Please refer to the " - "<a href=\"%1\">BlackBerry website</a> to find out how to update your keys.") - .arg(QLatin1String(Qnx::Constants::QNX_LEGACY_KEYS_URL))); - } else if (m_utils.hasRegisteredKeys()) { - m_ui->keyStatus->setText(tr("Your keys are ready to be used")); - } else { - m_ui->keyStatus->setText(tr("No keys found. Please refer to the " - "<a href=\"%1\">BlackBerry website</a> " - "to find out how to request your keys.") - .arg(QLatin1String(Qnx::Constants::QNX_REGISTER_KEYS_URL))); - } -} - -void BlackBerryKeysWidget::loadDefaultCertificate() -{ - connect(&m_utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(certificateLoaded(int))); - m_utils.openDefaultCertificate(this); -} - -void BlackBerryKeysWidget::updateDebugTokenList() -{ - initModel(); - foreach (const QString &dt, m_utils.debugTokens()) { - QList<QStandardItem*> row; - BlackBerryDebugTokenReader debugTokenReader(dt); - if (!debugTokenReader.isValid()) - continue; - - row << new QStandardItem(dt); - row << new QStandardItem(debugTokenReader.author()); - row << new QStandardItem(debugTokenReader.pins()); - row << new QStandardItem(debugTokenReader.expiry()); - m_dtModel->appendRow(row); - } - - m_ui->debugTokens->header()->resizeSections(QHeaderView::ResizeToContents); -} - -void BlackBerryKeysWidget::requestDebugToken() -{ - BlackBerryDebugTokenRequestDialog dialog(this); - if (dialog.exec() != QDialog::Accepted) - return; - - m_utils.addDebugToken(dialog.debugToken()); -} - -void BlackBerryKeysWidget::importDebugToken() -{ - const QString debugToken = QFileDialog::getOpenFileName(this, tr("Select Debug Token"), - QString(), tr("Bar file (*.bar)")); - if (debugToken.isEmpty()) - return; - - BlackBerryDebugTokenReader debugTokenReader(debugToken); - if (!debugTokenReader.isValid()) { - QMessageBox::warning(this, tr("Invalid Debug Token"), - tr("Debug token file %1 cannot be read.").arg(debugToken)); - return; - } - - m_utils.addDebugToken(debugToken); -} - -void BlackBerryKeysWidget::editDebugToken() -{ - const QModelIndex index = m_ui->debugTokens->currentIndex(); - if (!index.isValid()) - return; - - QString pins = m_dtModel->item(index.row(), 0)->text(); - - BlackBerryDebugTokenPinsDialog dialog(pins, this); - connect(&dialog, SIGNAL(pinsUpdated(QStringList)), this, SLOT(updateDebugToken(QStringList))); - dialog.exec(); -} - -void BlackBerryKeysWidget::removeDebugToken() -{ - const QModelIndex index = m_ui->debugTokens->currentIndex(); - if (!index.isValid()) - return; - - const QString dt = m_dtModel->item(index.row(), 0)->text(); - const int result = QMessageBox::question(this, tr("Confirmation"), - tr("Are you sure you want to remove %1?") - .arg(dt), QMessageBox::Yes | QMessageBox::No); - - if (result == QMessageBox::Yes) - m_utils.removeDebugToken(dt); -} - -void BlackBerryKeysWidget::updateDebugToken(const QStringList &pins) -{ - bool ok; - const QString cskPassword = m_utils.cskPassword(this, &ok); - if (!ok) - return; - - const QString certificatePassword = m_utils.certificatePassword(this, &ok); - if (!ok) - return; - - const QString debugTokenPath = m_dtModel->item(m_ui->debugTokens->currentIndex().row(), 0)->text(); - m_requester->requestDebugToken(debugTokenPath, - cskPassword, BlackBerryConfigurationManager::instance()->defaultKeystorePath(), - certificatePassword, pins.join(QLatin1Char(','))); -} - -void BlackBerryKeysWidget::requestFinished(int status) -{ - QString errorString = tr("Failed to request debug token:") + QLatin1Char(' '); - - switch (status) { - case BlackBerryDebugTokenRequester::Success: - updateDebugTokenList(); - return; - case BlackBerryDebugTokenRequester::WrongCskPassword: - m_utils.clearCskPassword(); - errorString += tr("Wrong CSK password."); - break; - case BlackBerryDebugTokenRequester::WrongKeystorePassword: - m_utils.clearCertificatePassword(); - errorString += tr("Wrong keystore password."); - break; - case BlackBerryDebugTokenRequester::NetworkUnreachable: - errorString += tr("Network unreachable."); - break; - case BlackBerryDebugTokenRequester::IllegalPin: - errorString += tr("Illegal device PIN."); - break; - case BlackBerryDebugTokenRequester::FailedToStartInferiorProcess: - errorString += tr("Failed to start inferior process."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessTimedOut: - errorString += tr("Inferior processes timed out."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessCrashed: - errorString += tr("Inferior process has crashed."); - break; - case BlackBerryDebugTokenRequester::InferiorProcessReadError: - case BlackBerryDebugTokenRequester::InferiorProcessWriteError: - errorString += tr("Failed to communicate with the inferior process."); - break; - case BlackBerryDebugTokenRequester::NotYetRegistered: - errorString += tr("Not yet registered to request debug tokens."); - break; - case BlackBerryDebugTokenRequester::UnknownError: - default: - m_utils.clearCertificatePassword(); - m_utils.clearCskPassword(); - errorString += tr("An unknown error has occurred."); - break; - } - - QMessageBox::critical(this, tr("Error"), errorString); -} - -void BlackBerryKeysWidget::updateUi(const QModelIndex &index) -{ - m_ui->editDbTkButton->setEnabled(index.isValid()); - m_ui->removeDbTkButton->setEnabled(index.isValid()); -} - -void BlackBerryKeysWidget::setCertificateError(const QString &error) -{ - m_ui->certificateAuthor->clear(); - QMessageBox::critical(this, tr("Qt Creator"), error); -} - -void BlackBerryKeysWidget::setCreateCertificateVisible(bool visible) -{ - m_ui->pathLabel->setVisible(!visible); - m_ui->authorLabel->setVisible(!visible); - m_ui->certificatePath->setVisible(!visible); - m_ui->certificateAuthor->setVisible(!visible); - m_ui->clearCertificateButton->setVisible(!visible); - m_ui->openCertificateButton->setVisible(!visible); - m_ui->noCertificateLabel->setVisible(visible); - m_ui->createCertificateButton->setVisible(visible); -} - -} // namespace Internal -} // namespace Qnx - diff --git a/src/plugins/qnx/blackberrykeyswidget.h b/src/plugins/qnx/blackberrykeyswidget.h deleted file mode 100644 index 57ca0c7bf9b..00000000000 --- a/src/plugins/qnx/blackberrykeyswidget.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYKEYSWIDGET_H_H -#define BLACKBERRYKEYSWIDGET_H_H - -#include <QWidget> -#include <QString> - -QT_BEGIN_NAMESPACE -class QStandardItemModel; -class QModelIndex; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryCertificate; -class BlackBerrySigningUtils; -class BlackBerryDebugTokenRequester; -class Ui_BlackBerryKeysWidget; - -class BlackBerryKeysWidget : public QWidget -{ - Q_OBJECT -public: - explicit BlackBerryKeysWidget(QWidget *parent = 0); - void saveSettings(); - -private slots: - void certificateLoaded(int status); - void createCertificate(); - void clearCertificate(); - void loadDefaultCertificate(); - void updateDebugTokenList(); - - void requestDebugToken(); - void importDebugToken(); - void editDebugToken(); - void removeDebugToken(); - void updateDebugToken(const QStringList &pins); - void requestFinished(int status); - void updateUi(const QModelIndex &index); - -protected: - void showEvent(QShowEvent *event); - -private: - void updateKeysSection(); - void updateCertificateSection(); - void setCertificateError(const QString &error); - void setCreateCertificateVisible(bool show); - void initModel(); - - BlackBerrySigningUtils &m_utils; - - Ui_BlackBerryKeysWidget *m_ui; - QStandardItemModel *m_dtModel; - BlackBerryDebugTokenRequester *m_requester; -}; - -} // namespace Internal -} // namespeace Qnx - -#endif // BLACKBERRYKEYSWIDGET_H_H diff --git a/src/plugins/qnx/blackberrykeyswidget.ui b/src/plugins/qnx/blackberrykeyswidget.ui deleted file mode 100644 index 666e81c1707..00000000000 --- a/src/plugins/qnx/blackberrykeyswidget.ui +++ /dev/null @@ -1,254 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryKeysWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryKeysWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>959</width> - <height>703</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="groupBox"> - <property name="title"> - <string>BlackBerry Signing Authority</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="keyStatus"> - <property name="font"> - <font> - <weight>50</weight> - <bold>false</bold> - </font> - </property> - <property name="text"> - <string>STATUS</string> - </property> - <property name="textFormat"> - <enum>Qt::RichText</enum> - </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - <property name="textInteractionFlags"> - <set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>Developer Certificate</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Path:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="certificatePath"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>PATH</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="authorLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="font"> - <font> - <weight>75</weight> - <bold>true</bold> - </font> - </property> - <property name="text"> - <string>Author:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="certificateAuthor"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>LABEL</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="noCertificateLabel"> - <property name="font"> - <font> - <weight>50</weight> - <bold>false</bold> - </font> - </property> - <property name="text"> - <string>No developer certificate has been found.</string> - </property> - </widget> - </item> - <item> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="openCertificateButton"> - <property name="text"> - <string>Open Certificate</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="clearCertificateButton"> - <property name="text"> - <string>Clear Certificate</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="createCertificateButton"> - <property name="text"> - <string>Create Certificate...</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>Debug Tokens</string> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QTreeView" name="debugTokens"> - <property name="editTriggers"> - <set>QAbstractItemView::NoEditTriggers</set> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QPushButton" name="requestDbTkButton"> - <property name="text"> - <string>Request...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="importDbTkButton"> - <property name="text"> - <string>Import...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="editDbTkButton"> - <property name="text"> - <string>Edit...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeDbTkButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - </layout> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrylogprocessrunner.cpp b/src/plugins/qnx/blackberrylogprocessrunner.cpp deleted file mode 100644 index 73db7cbf31b..00000000000 --- a/src/plugins/qnx/blackberrylogprocessrunner.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrylogprocessrunner.h" -#include "slog2inforunner.h" - -#include <projectexplorer/devicesupport/sshdeviceprocess.h> -#include <utils/qtcassert.h> - -using namespace Qnx::Internal; - -BlackBerryLogProcessRunner::BlackBerryLogProcessRunner(QObject *parent, const QString& appId, const BlackBerryDeviceConfiguration::ConstPtr &device) - : QObject(parent) -{ - Q_ASSERT(!appId.isEmpty() && device); - - m_appId = appId; - m_device = device; - - m_slog2InfoRunner = new Slog2InfoRunner(appId, m_device, this); - connect(m_slog2InfoRunner, SIGNAL(finished()), this, SIGNAL(finished())); - connect(m_slog2InfoRunner, SIGNAL(output(QString,Utils::OutputFormat)), this, SIGNAL(output(QString,Utils::OutputFormat))); - - m_tailProcess = new ProjectExplorer::SshDeviceProcess(m_device, this); - connect(m_tailProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(readTailStandardOutput())); - connect(m_tailProcess, SIGNAL(readyReadStandardError()), this, SLOT(readTailStandardError())); - connect(m_tailProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(handleTailProcessError())); -} - -void BlackBerryLogProcessRunner::start() -{ - m_slog2InfoRunner->start(); - launchTailProcess(); -} - -void BlackBerryLogProcessRunner::readTailStandardOutput() -{ - const QString message = QString::fromLatin1(m_tailProcess->readAllStandardOutput()); - emit output(message, Utils::StdOutFormat); -} - -void BlackBerryLogProcessRunner::readTailStandardError() -{ - const QString message = QString::fromLatin1(m_tailProcess->readAllStandardError()); - emit output(message, Utils::StdErrFormat); -} - -void BlackBerryLogProcessRunner::handleTailProcessError() -{ - emit output(tr("Cannot show debug output. Error: %1").arg(m_tailProcess->errorString()), Utils::StdErrFormat); -} - -void BlackBerryLogProcessRunner::launchTailProcess() -{ - if (m_tailProcess->state() == QProcess::Running) - return; - - QStringList parameters; - parameters << QLatin1String("-c") - << QLatin1String("+1") - << QLatin1String("-f") - << QLatin1String("/accounts/1000/appdata/") + m_appId + QLatin1String("/logs/log"); - m_tailProcess->start(QLatin1String("tail"), parameters); -} - -void BlackBerryLogProcessRunner::stop() -{ - m_slog2InfoRunner->stop(); - m_tailProcess->kill(); - - emit finished(); -} diff --git a/src/plugins/qnx/blackberrylogprocessrunner.h b/src/plugins/qnx/blackberrylogprocessrunner.h deleted file mode 100644 index 0de41610ddf..00000000000 --- a/src/plugins/qnx/blackberrylogprocessrunner.h +++ /dev/null @@ -1,79 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYSLOGPROCESS_H -#define BLACKBERRYSLOGPROCESS_H - -#include "blackberrydeviceconfiguration.h" - -#include <utils/outputformat.h> - -#include <QObject> - -namespace ProjectExplorer { class SshDeviceProcess; } - -namespace Qnx { -namespace Internal { - -class Slog2InfoRunner; - -class BlackBerryLogProcessRunner : public QObject -{ - Q_OBJECT -public: - explicit BlackBerryLogProcessRunner(QObject *parent, const QString &appId, const BlackBerryDeviceConfiguration::ConstPtr &device); - void start(); - -signals: - void output(const QString &msg, Utils::OutputFormat format); - void finished(); - -public slots: - void stop(); - -private slots: - void launchTailProcess(); - void readTailStandardOutput(); - void readTailStandardError(); - void handleTailProcessError(); - -private: - QString m_appId; - - BlackBerryDeviceConfiguration::ConstPtr m_device; - ProjectExplorer::SshDeviceProcess *m_tailProcess; - Slog2InfoRunner *m_slog2InfoRunner; -}; -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYSLOGPROCESS_H diff --git a/src/plugins/qnx/blackberryndkprocess.cpp b/src/plugins/qnx/blackberryndkprocess.cpp deleted file mode 100644 index dfa64225ee5..00000000000 --- a/src/plugins/qnx/blackberryndkprocess.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryndkprocess.h" -#include "blackberryconfigurationmanager.h" - -#include <utils/hostosinfo.h> - -#include <QTextStream> - -namespace Qnx { -namespace Internal { - -BlackBerryNdkProcess::BlackBerryNdkProcess(const QString &command, QObject *parent) : - QObject(parent), - m_process(new QProcess(this)), - m_command(command) -{ - m_process->setProcessChannelMode(QProcess::MergedChannels); - m_process->setEnvironment(Utils::EnvironmentItem::toStringList( - BlackBerryConfigurationManager::instance()->defaultConfigurationEnv())); - - connect(m_process, SIGNAL(started()), this, SIGNAL(started())); - connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), - this, SLOT(processFinished())); - connect(m_process, SIGNAL(error(QProcess::ProcessError)), - this, SLOT(processError(QProcess::ProcessError))); -} - -const QString BlackBerryNdkProcess::resolveNdkToolPath(const QString &tool) -{ - QString toolPath; - QList<Utils::EnvironmentItem> qnxEnv = - BlackBerryConfigurationManager::instance()->defaultConfigurationEnv(); - foreach (const Utils::EnvironmentItem &item, qnxEnv) { - if (item.name == QLatin1String("QNX_HOST") && !item.value.isEmpty()) { - toolPath = item.value - + (QLatin1String("/usr/bin/")) + tool; - - if (Utils::HostOsInfo::isWindowsHost()) - toolPath += QLatin1String(".bat"); - - break; - } - } - - return toolPath; -} - -QString BlackBerryNdkProcess::command() const -{ - return resolveNdkToolPath(m_command); -} - -void BlackBerryNdkProcess::start(const QStringList &arguments) -{ - if (m_process->state() != QProcess::NotRunning) - return; - - resetResults(); - - m_process->start(command(), arguments); -} - -void BlackBerryNdkProcess::addErrorStringMapping( - const QString &message, int errorCode) -{ - m_errorStringMap.insert(message, errorCode); -} - -void BlackBerryNdkProcess::processFinished() -{ - QTextStream processOutput(m_process); - if (m_process->exitCode() == 0) { - while (!processOutput.atEnd()) - processData(processOutput.readLine()); - - emit finished(Success); - return; - } - - int returnStatus = UnknownError; - while (!processOutput.atEnd()) { - returnStatus = errorLineToReturnStatus(processOutput.readLine()); - if (returnStatus >= 0) - break; - } - - emit finished(returnStatus); -} - -void BlackBerryNdkProcess::processError(QProcess::ProcessError error) -{ - int errorCode; - - switch (error) { - case QProcess::FailedToStart: - errorCode = FailedToStartInferiorProcess; - break; - case QProcess::Timedout: - errorCode = InferiorProcessTimedOut; - break; - case QProcess::Crashed: - errorCode = InferiorProcessCrashed; - break; - case QProcess::WriteError: - errorCode = InferiorProcessWriteError; - break; - case QProcess::ReadError: - errorCode = InferiorProcessReadError; - break; - case QProcess::UnknownError: - default: - errorCode = UnknownError; - break; - } - - emit finished(errorCode); -} - -int BlackBerryNdkProcess::errorLineToReturnStatus(const QString &line) const -{ - typedef QMap<QString, int>::ConstIterator ConstIt; - - const ConstIt cend = m_errorStringMap.constEnd(); - for (ConstIt it = m_errorStringMap.constBegin(); it != cend; ++it) { - if (line.contains(it.key())) - return it.value(); - } - - return -1; -} - -void BlackBerryNdkProcess::processData(const QString &line) -{ - Q_UNUSED(line); -} - -void BlackBerryNdkProcess::resetResults() -{ -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryndkprocess.h b/src/plugins/qnx/blackberryndkprocess.h deleted file mode 100644 index b7322997380..00000000000 --- a/src/plugins/qnx/blackberryndkprocess.h +++ /dev/null @@ -1,98 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYNDKPROCESS_H -#define QNX_INTERNAL_BLACKBERRYNDKPROCESS_H - -#include <QObject> -#include <QProcess> -#include <QMap> - -namespace Qnx { -namespace Internal { - -class BlackBerryNdkProcess : public QObject -{ - Q_OBJECT - -public: - enum ProcessStatus - { - Success, - FailedToStartInferiorProcess, - InferiorProcessTimedOut, - InferiorProcessCrashed, - InferiorProcessWriteError, - InferiorProcessReadError, - UnknownError, - UserStatus - }; - - /** - * @brief Resolves full path to an NDK cmd-line tool. - * @return a full-path to the NDK cmd-line tool; - * or empty QString when no default QNX configuration is found. - */ - static const QString resolveNdkToolPath(const QString &tool); - -signals: - void finished(int status); - void started(); - -protected: - explicit BlackBerryNdkProcess(const QString &command, QObject *parent = 0); - - void start(const QStringList &arguments); - void addErrorStringMapping(const QString &message, int errorCode); - - QString command() const; - -private slots: - void processFinished(); - void processError(QProcess::ProcessError error); - -private: - int errorLineToReturnStatus(const QString &line) const; - virtual void processData(const QString &line); - virtual void resetResults(); - - QProcess *m_process; - - QString m_command; - - QMap<QString, int> m_errorStringMap; -}; - -} -} - -#endif // QNX_INTERNAL_BLACKBERRYNDKPROCESS_H diff --git a/src/plugins/qnx/blackberryndksettingspage.cpp b/src/plugins/qnx/blackberryndksettingspage.cpp deleted file mode 100644 index 9d74e55e129..00000000000 --- a/src/plugins/qnx/blackberryndksettingspage.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryndksettingspage.h" -#include "blackberryndksettingswidget.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" -#include "qnxconstants.h" - -#include <projectexplorer/projectexplorerconstants.h> - -#include <QCoreApplication> - -namespace Qnx { -namespace Internal { - -BlackBerryNDKSettingsPage::BlackBerryNDKSettingsPage(QObject *parent) : - Core::IOptionsPage(parent) -{ - setId(Core::Id(Constants::QNX_BB_NDK_SETTINGS_ID)); - setDisplayName(tr("API Levels and Runtimes")); - setCategory(Constants::QNX_BB_CATEGORY); - setDisplayCategory(QCoreApplication::translate("BlackBerry", - Constants::QNX_BB_CATEGORY_TR)); - setCategoryIcon(QLatin1String(Constants::QNX_BB_CATEGORY_ICON)); -} - -QWidget *BlackBerryNDKSettingsPage::widget() -{ - if (!m_widget) - m_widget = new BlackBerryNDKSettingsWidget; - return m_widget; -} - -void BlackBerryNDKSettingsPage::apply() -{ - foreach (BlackBerryApiLevelConfiguration* config, m_widget->activatedApiLevels()) { - if (!config->isActive()) - config->activate(); - } - - foreach (BlackBerryApiLevelConfiguration* config, m_widget->deactivatedApiLevels()) { - if (config->isActive()) - config->deactivate(); - } - - BlackBerryConfigurationManager::instance()->setDefaultConfiguration(m_widget->defaultApiLevel()); -} - -void BlackBerryNDKSettingsPage::finish() -{ - delete m_widget; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryndksettingspage.h b/src/plugins/qnx/blackberryndksettingspage.h deleted file mode 100644 index 1593bdd9593..00000000000 --- a/src/plugins/qnx/blackberryndksettingspage.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYNDKSETTINGSPAGE_H -#define BLACKBERRYNDKSETTINGSPAGE_H - -#include <coreplugin/dialogs/ioptionspage.h> - -#include <QPointer> - -namespace Qnx { -namespace Internal { - -class BlackBerryNDKSettingsWidget; - -class BlackBerryNDKSettingsPage : public Core::IOptionsPage -{ - Q_OBJECT -public: - explicit BlackBerryNDKSettingsPage(QObject *parent = 0); - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<BlackBerryNDKSettingsWidget> m_widget; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYNDKSETTINGSPAGE_H diff --git a/src/plugins/qnx/blackberryndksettingswidget.cpp b/src/plugins/qnx/blackberryndksettingswidget.cpp deleted file mode 100644 index a80b9f16b24..00000000000 --- a/src/plugins/qnx/blackberryndksettingswidget.cpp +++ /dev/null @@ -1,464 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryndksettingswidget.h" -#include "ui_blackberryndksettingswidget.h" -#include "qnxutils.h" -#include "blackberrysigningutils.h" - -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" -#include "blackberryruntimeconfiguration.h" - -#include <utils/pathchooser.h> - -#include <coreplugin/coreconstants.h> -#include <coreplugin/icore.h> - -#include <QMessageBox> -#include <QFileDialog> - -#include <QStandardItemModel> -#include <QTreeWidgetItem> - -namespace Qnx { -namespace Internal { - -static QIcon invalidConfigIcon(QString::fromLatin1(Core::Constants::ICON_ERROR)); - -BlackBerryNDKSettingsWidget::BlackBerryNDKSettingsWidget(QWidget *parent) : - QWidget(parent), - m_ui(new Ui_BlackBerryNDKSettingsWidget), - m_bbConfigManager(BlackBerryConfigurationManager::instance()), - m_autoDetectedNdks(0), - m_manualApiLevel(0) -{ - m_ui->setupUi(this); - - updateInfoTable(0); - - m_activatedApiLevel << m_bbConfigManager->activeApiLevels(); - - m_ui->ndksTreeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); - m_ui->ndksTreeWidget->header()->setStretchLastSection(false); - m_ui->ndksTreeWidget->setHeaderItem(new QTreeWidgetItem(QStringList() << tr("Configuration"))); - m_ui->ndksTreeWidget->setTextElideMode(Qt::ElideNone); - m_ui->ndksTreeWidget->setColumnCount(1); - - m_apiLevels = new QTreeWidgetItem(m_ui->ndksTreeWidget); - m_apiLevels->setText(0, tr("API Levels")); - m_runtimes = new QTreeWidgetItem(m_ui->ndksTreeWidget); - m_runtimes->setText(0, tr("Runtimes")); - - m_autoDetectedNdks = new QTreeWidgetItem(m_apiLevels); - m_autoDetectedNdks->setText(0, tr("Auto-Detected")); - m_autoDetectedNdks->setFirstColumnSpanned(true); - m_autoDetectedNdks->setFlags(Qt::ItemIsEnabled); - m_manualApiLevel = new QTreeWidgetItem(m_apiLevels); - m_manualApiLevel->setText(0, tr("Manual")); - m_manualApiLevel->setFirstColumnSpanned(true); - m_manualApiLevel->setFlags(Qt::ItemIsEnabled); - - m_ui->ndksTreeWidget->expandAll(); - - connect(m_ui->addConfigButton, SIGNAL(clicked()), this, SLOT(addConfiguration())); - connect(m_ui->removeConfigButton, SIGNAL(clicked()), this, SLOT(removeConfiguration())); - connect(m_ui->activateNdkTargetButton, SIGNAL(clicked()), this, SLOT(activateApiLevel())); - connect(m_ui->deactivateNdkTargetButton, SIGNAL(clicked()), this, SLOT(deactivateApiLevel())); - - connect(m_ui->cleanUpButton, SIGNAL(clicked()), this, SLOT(cleanUp())); - connect(m_ui->ndksTreeWidget, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateInfoTable(QTreeWidgetItem*))); - connect(this, SIGNAL(configurationsUpdated()), this, SLOT(populateDefaultConfigurationCombo())); - - // BlackBerryConfigurationManager.settingsChanged signal may be emitted multiple times - // during the same event handling. This would result in multiple updatePage() calls even through - // just one is needed. - // QTimer allows to merge those multiple signal emits into a single updatePage() call. - m_timer.setSingleShot(true); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(updatePage())); - - updatePage(); - connect(m_bbConfigManager, SIGNAL(settingsChanged()), &m_timer, SLOT(start())); -} - -bool BlackBerryNDKSettingsWidget::hasActiveNdk() const -{ - return !m_bbConfigManager->apiLevels().isEmpty(); -} - -QList<BlackBerryApiLevelConfiguration *> BlackBerryNDKSettingsWidget::activatedApiLevels() -{ - return m_activatedApiLevel; -} - -QList<BlackBerryApiLevelConfiguration *> BlackBerryNDKSettingsWidget::deactivatedApiLevels() -{ - return m_deactivatedApiLevel; -} - -BlackBerryApiLevelConfiguration *BlackBerryNDKSettingsWidget::defaultApiLevel() const -{ - const int currentIndex = m_ui->apiLevelCombo->currentIndex(); - - return static_cast<BlackBerryApiLevelConfiguration*>( - m_ui->apiLevelCombo->itemData(currentIndex).value<void*>()); -} - -void BlackBerryNDKSettingsWidget::updateInfoTable(QTreeWidgetItem* currentItem) -{ - updateUi(currentItem); - if (!currentItem) - return; - - if (currentItem->parent() == m_runtimes) { - BlackBerryRuntimeConfiguration *runtime = static_cast<BlackBerryRuntimeConfiguration*>( - currentItem->data(0, Qt::UserRole).value<void*>()); - if (runtime) { - m_ui->baseName->setText(runtime->displayName()); - m_ui->version->setText(runtime->version().toString()); - m_ui->path->setText(runtime->path()); - - m_ui->removeConfigButton->setEnabled(runtime); - m_ui->activateNdkTargetButton->setEnabled(false); - m_ui->deactivateNdkTargetButton->setEnabled(false); - } - - return; - } else if (currentItem->parent() == m_autoDetectedNdks || currentItem->parent() == m_manualApiLevel) { - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - currentItem->data(0, Qt::UserRole).value<void*>()); - - m_ui->path->setText(config->envFile().toString()); - m_ui->baseName->setText(config->displayName()); - m_ui->host->setText(QDir::toNativeSeparators(config->qnxHost().toString())); - m_ui->target->setText(QDir::toNativeSeparators(config->sysRoot().toString())); - m_ui->version->setText(config->version().toString()); - } -} - -void BlackBerryNDKSettingsWidget::updateConfigurationList() -{ - m_activatedApiLevel.clear(); - m_activatedApiLevel << m_bbConfigManager->activeApiLevels(); - m_deactivatedApiLevel.clear(); - - qDeleteAll(m_autoDetectedNdks->takeChildren()); - qDeleteAll(m_manualApiLevel->takeChildren()); - qDeleteAll(m_runtimes->takeChildren()); - - bool enableCleanUp = false; - foreach (BlackBerryApiLevelConfiguration *config, m_bbConfigManager->apiLevels()) { - QTreeWidgetItem *parent = config->isAutoDetected() ? m_autoDetectedNdks : m_manualApiLevel; - QTreeWidgetItem *item = new QTreeWidgetItem(parent); - item->setText(0, config->displayName()); - item->setData(0, Qt::UserRole, QVariant::fromValue(static_cast<void*>(config))); - QFont font; - font.setBold(config->isActive() || m_activatedApiLevel.contains(config)); - item->setFont(0, font); - item->setIcon(0, config->isValid() ? QIcon() : invalidConfigIcon); - // TODO: Do the same if qmake, qcc, debugger are no longer detected... - if (!config->isValid()) { - QString toolTip = tr("Invalid target %1:").arg(config->targetName()); - if (config->isAutoDetected() && !config->autoDetectionSource().exists()) - toolTip += QLatin1Char('\n') + tr("- Target no longer installed."); - - if (!config->envFile().exists()) - toolTip += QLatin1Char('\n') + tr("- No NDK environment file found."); - - if (config->qmake4BinaryFile().isEmpty() - && config->qmake5BinaryFile().isEmpty()) - toolTip += QLatin1Char('\n') + tr("- No Qt version found."); - - if (config->qccCompilerPath().isEmpty()) - toolTip += QLatin1Char('\n') + tr("- No compiler found."); - - if (config->armDebuggerPath().isEmpty()) - toolTip += QLatin1Char('\n') + tr("- No debugger found for device."); - - if (config->x86DebuggerPath().isEmpty()) - toolTip += QLatin1Char('\n') + tr("- No debugger found for simulator."); - - item->setToolTip(0, toolTip); - enableCleanUp = true; - } - } - - foreach (BlackBerryRuntimeConfiguration *runtime, m_bbConfigManager->runtimes()) { - QTreeWidgetItem *item = new QTreeWidgetItem(m_runtimes); - item->setText(0, runtime->displayName()); - item->setData(0, Qt::UserRole, QVariant::fromValue(static_cast<void*>(runtime))); - } - - m_ui->ndksTreeWidget->setCurrentItem(m_autoDetectedNdks->child(0)); - m_ui->cleanUpButton->setEnabled(enableCleanUp); -} - -void BlackBerryNDKSettingsWidget::addConfiguration() -{ - launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::InstallMode, BlackBerryInstallerDataHandler::ApiLevel); - emit configurationsUpdated(); -} - -void BlackBerryNDKSettingsWidget::removeConfiguration() -{ - QTreeWidgetItem * current = m_ui->ndksTreeWidget->currentItem(); - if (!current) - return; - - if (current->parent() == m_runtimes) { - uninstallConfiguration(BlackBerryInstallerDataHandler::Runtime); - emit configurationsUpdated(); - } else { - const QString ndk = m_ui->ndksTreeWidget->currentItem()->text(0); - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - current->data(0, Qt::UserRole).value<void*>()); - if (config->isAutoDetected()) { - uninstallConfiguration(BlackBerryInstallerDataHandler::ApiLevel); - emit configurationsUpdated(); - return; - } - - QMessageBox::StandardButton button = - QMessageBox::question(Core::ICore::mainWindow(), - tr("Clean BlackBerry 10 Configuration"), - tr("Are you sure you want to remove:\n %1?").arg(ndk), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - m_activatedApiLevel.removeOne(config); - m_deactivatedApiLevel.removeOne(config); - m_bbConfigManager->removeApiLevel(config); - m_manualApiLevel->removeChild(m_ui->ndksTreeWidget->currentItem()); - emit configurationsUpdated(); - } - } -} - -void BlackBerryNDKSettingsWidget::activateApiLevel() -{ - if (!m_ui->ndksTreeWidget->currentItem()) - return; - - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - m_ui->ndksTreeWidget->currentItem()->data(0, Qt::UserRole).value<void*>()); - - if (!m_activatedApiLevel.contains(config)) { - m_activatedApiLevel << config; - if (m_deactivatedApiLevel.contains(config)) - m_deactivatedApiLevel.removeAt(m_deactivatedApiLevel.indexOf(config)); - - updateUi(m_ui->ndksTreeWidget->currentItem()); - emit configurationsUpdated(); - } -} - -void BlackBerryNDKSettingsWidget::deactivateApiLevel() -{ - if (!m_ui->ndksTreeWidget->currentItem()) - return; - - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - m_ui->ndksTreeWidget->currentItem()->data(0, Qt::UserRole).value<void*>()); - if (m_activatedApiLevel.contains(config)) { - m_deactivatedApiLevel << config; - m_activatedApiLevel.removeAt(m_activatedApiLevel.indexOf(config)); - updateUi(m_ui->ndksTreeWidget->currentItem()); - emit configurationsUpdated(); - } -} - -void BlackBerryNDKSettingsWidget::updateUi(QTreeWidgetItem *item) -{ - if (!item || (item->parent() != m_runtimes && - item->parent() != m_autoDetectedNdks && - item->parent() != m_manualApiLevel )) { - m_ui->removeConfigButton->setEnabled(false); - m_ui->activateNdkTargetButton->setEnabled(false); - m_ui->deactivateNdkTargetButton->setEnabled(false); - m_ui->informationBox->setVisible(false); - return; - } - - const bool isRuntimeItem = item->parent() == m_runtimes; - // Update the infornation to show in the information panel - m_ui->informationBox->setVisible(true); - m_ui->informationBox->setTitle(isRuntimeItem ? - tr("Runtime Information") : tr("API Level Information")); - m_ui->pathLabel->setText(isRuntimeItem ? tr("Path:") : tr("Environment file:")); - m_ui->hostLabel->setVisible(!isRuntimeItem); - m_ui->host->setVisible(!isRuntimeItem); - m_ui->targetLabel->setVisible(!isRuntimeItem); - m_ui->target->setVisible(!isRuntimeItem); - - if (!isRuntimeItem) { - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - item->data(0, Qt::UserRole).value<void*>()); - const bool contains = m_activatedApiLevel.contains(config); - QFont font; - font.setBold(contains); - item->setFont(0, font); - - m_ui->activateNdkTargetButton->setEnabled(!contains); - m_ui->deactivateNdkTargetButton->setEnabled(contains); - // Disable remove button for auto detected pre-10.2 NDKs (uninstall wizard doesn't handle them) - m_ui->removeConfigButton->setEnabled(!(config->isAutoDetected() - && QnxUtils::sdkInstallerPath(config->ndkPath()).isEmpty())); - } -} - -void BlackBerryNDKSettingsWidget::uninstallConfiguration(BlackBerryInstallerDataHandler::Target target) -{ - const QMessageBox::StandardButton answer = QMessageBox::question(this, tr("Confirmation"), - tr("Are you sure you want to uninstall %1?"). - arg(m_ui->baseName->text()), - QMessageBox::Yes | QMessageBox::No); - - if (answer == QMessageBox::Yes) { - if (target == BlackBerryInstallerDataHandler::ApiLevel) { - launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::UninstallMode, - BlackBerryInstallerDataHandler::ApiLevel, m_ui->version->text()); - } else if (target == BlackBerryInstallerDataHandler::Runtime) { - if (m_ui->ndksTreeWidget->currentItem()) { - launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::UninstallMode, - BlackBerryInstallerDataHandler::Runtime, - m_ui->ndksTreeWidget->currentItem()->text(0)); - } - } - - } -} - -void BlackBerryNDKSettingsWidget::cleanUp() -{ - foreach (BlackBerryApiLevelConfiguration *config, m_bbConfigManager->apiLevels()) { - if (!config->isValid()) { - m_activatedApiLevel.removeOne(config); - m_deactivatedApiLevel.removeOne(config); - m_bbConfigManager->removeApiLevel(config); - } - } - - updateConfigurationList(); -} - -void BlackBerryNDKSettingsWidget::handleInstallationFinished() -{ - m_bbConfigManager->loadAutoDetectedConfigurations( - BlackBerryConfigurationManager::ApiLevel | BlackBerryConfigurationManager::Runtime); -} - -void BlackBerryNDKSettingsWidget::handleUninstallationFinished() -{ - QTreeWidgetItem *current = m_ui->ndksTreeWidget->currentItem(); - if (!current) - return; - - if (current->parent() == m_runtimes) { - BlackBerryRuntimeConfiguration *runtime = static_cast<BlackBerryRuntimeConfiguration*>( - current->data(0, Qt::UserRole).value<void*>()); - m_bbConfigManager->removeRuntime(runtime); - updateConfigurationList(); - return; - } - - const QString targetName = current->text(0); - // Check if the target is corrrecly uninstalled - foreach (const ConfigInstallInformation &ndk, QnxUtils::installedConfigs()) { - if (ndk.name == targetName) - return; - } - - BlackBerryApiLevelConfiguration *config = static_cast<BlackBerryApiLevelConfiguration*>( - current->data(0, Qt::UserRole).value<void*>()); - if (m_activatedApiLevel.contains(config)) - m_activatedApiLevel.removeAt(m_activatedApiLevel.indexOf(config)); - else if (m_deactivatedApiLevel.contains(config)) - m_deactivatedApiLevel.removeAt(m_deactivatedApiLevel.indexOf(config)); - - m_bbConfigManager->removeApiLevel(config); - - updateConfigurationList(); -} - -void BlackBerryNDKSettingsWidget::populateDefaultConfigurationCombo() -{ - // prevent QComboBox::currentIndexChanged() from being emitted - m_ui->apiLevelCombo->clear(); - - QList<BlackBerryApiLevelConfiguration*> configurations = m_bbConfigManager->apiLevels(); - - m_ui->apiLevelCombo->addItem(tr("Newest Version"), - QVariant::fromValue(static_cast<void*>(0))); - - if (configurations.isEmpty()) - return; - - int configIndex = 0; - - BlackBerryApiLevelConfiguration *defaultConfig = m_bbConfigManager->defaultApiLevel(); - - foreach (BlackBerryApiLevelConfiguration *config, configurations) { - m_ui->apiLevelCombo->addItem(config->displayName(), - QVariant::fromValue(static_cast<void*>(config))); - - if (config == defaultConfig) - configIndex = m_ui->apiLevelCombo->count() - 1; - } - - const int currentIndex = (m_bbConfigManager->newestApiLevelEnabled()) ? 0 : configIndex; - - m_ui->apiLevelCombo->setCurrentIndex(currentIndex); -} - -void BlackBerryNDKSettingsWidget::launchBlackBerryInstallerWizard( - BlackBerryInstallerDataHandler::Mode mode, - BlackBerryInstallerDataHandler::Target target, - const QString& targetVersion) -{ - BlackBerryInstallWizard wizard(mode, target, targetVersion, this); - if (mode == BlackBerryInstallerDataHandler::InstallMode) - connect(&wizard, SIGNAL(processFinished()), this, SLOT(handleInstallationFinished())); - else - connect(&wizard, SIGNAL(processFinished()), this, SLOT(handleUninstallationFinished())); - - wizard.exec(); -} - -void BlackBerryNDKSettingsWidget::updatePage() -{ - updateConfigurationList(); - populateDefaultConfigurationCombo(); -} - -} // namespace Internal -} // namespace Qnx - diff --git a/src/plugins/qnx/blackberryndksettingswidget.h b/src/plugins/qnx/blackberryndksettingswidget.h deleted file mode 100644 index 3f782beab17..00000000000 --- a/src/plugins/qnx/blackberryndksettingswidget.h +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYNDKSETTINGSWIDGET_H -#define BLACKBERRYNDKSETTINGSWIDGET_H - -#include "blackberryinstallwizard.h" - -#include <QWidget> -#include <QTimer> - -QT_BEGIN_NAMESPACE -class QStandardItemModel; -class QTreeWidgetItem; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryApiLevelConfiguration; -class BlackBerryConfigurationManager; -class Ui_BlackBerryNDKSettingsWidget; - -class BlackBerryNDKSettingsWidget : public QWidget -{ - Q_OBJECT -public: - explicit BlackBerryNDKSettingsWidget(QWidget *parent = 0); - - bool hasActiveNdk() const; - - QList<BlackBerryApiLevelConfiguration *> activatedApiLevels(); - QList<BlackBerryApiLevelConfiguration *> deactivatedApiLevels(); - - BlackBerryApiLevelConfiguration *defaultApiLevel() const; - -signals: - void configurationsUpdated(); - -public slots: - void updateInfoTable(QTreeWidgetItem* currentItem); - void updateConfigurationList(); - void addConfiguration(); - void removeConfiguration(); - void activateApiLevel(); - void deactivateApiLevel(); - void uninstallConfiguration(BlackBerryInstallerDataHandler::Target target); - void cleanUp(); - void handleInstallationFinished(); - void handleUninstallationFinished(); - void updateUi(QTreeWidgetItem* item); - void populateDefaultConfigurationCombo(); - void updatePage(); - -private: - void launchBlackBerryInstallerWizard(BlackBerryInstallerDataHandler::Mode mode, - BlackBerryInstallerDataHandler::Target target, - const QString& tagetVersion = QString()); - - Ui_BlackBerryNDKSettingsWidget *m_ui; - BlackBerryConfigurationManager *m_bbConfigManager; - - QTreeWidgetItem *m_apiLevels; - QTreeWidgetItem *m_runtimes; - - QTreeWidgetItem *m_autoDetectedNdks; - QTreeWidgetItem *m_manualApiLevel; - - QList<BlackBerryApiLevelConfiguration *> m_activatedApiLevel; - QList<BlackBerryApiLevelConfiguration *> m_deactivatedApiLevel; - - QTimer m_timer; -}; - -} // namespace Internal -} // namespeace Qnx - -#endif // BLACKBERRYNDKSETTINGSWIDGET_H diff --git a/src/plugins/qnx/blackberryndksettingswidget.ui b/src/plugins/qnx/blackberryndksettingswidget.ui deleted file mode 100644 index 587209caa6d..00000000000 --- a/src/plugins/qnx/blackberryndksettingswidget.ui +++ /dev/null @@ -1,227 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryNDKSettingsWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryNDKSettingsWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>773</width> - <height>412</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Default API level:</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="apiLevelCombo"/> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="1" column="0"> - <widget class="QTreeWidget" name="ndksTreeWidget"> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - <item row="1" column="1" rowspan="2"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addConfigButton"> - <property name="text"> - <string>Add...</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeConfigButton"> - <property name="text"> - <string>Remove</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_2"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>13</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="activateNdkTargetButton"> - <property name="text"> - <string>Activate</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deactivateNdkTargetButton"> - <property name="text"> - <string>Deactivate</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>13</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="cleanUpButton"> - <property name="text"> - <string>Clean Up</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="0"> - <widget class="QGroupBox" name="informationBox"> - <property name="title"> - <string>GroupBox</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="2" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="text"> - <string>Path:</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="path"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="baseNameLabel"> - <property name="text"> - <string>Name:</string> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="baseName"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="4" column="0"> - <widget class="QLabel" name="versionLabel"> - <property name="text"> - <string>Version:</string> - </property> - </widget> - </item> - <item row="5" column="0"> - <widget class="QLabel" name="hostLabel"> - <property name="text"> - <string>Host:</string> - </property> - </widget> - </item> - <item row="5" column="1"> - <widget class="QLabel" name="host"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="targetLabel"> - <property name="text"> - <string>Target:</string> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="QLabel" name="target"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QLabel" name="version"> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberrypotentialkit.cpp b/src/plugins/qnx/blackberrypotentialkit.cpp deleted file mode 100644 index 6d53f225e5d..00000000000 --- a/src/plugins/qnx/blackberrypotentialkit.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrypotentialkit.h" - -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" -#include "qnxconstants.h" - -#include <coreplugin/coreconstants.h> -#include <coreplugin/icore.h> - -#include <QGridLayout> -#include <QLabel> -#include <QList> -#include <QPushButton> - -using namespace Qnx::Internal; - -QString BlackBerryPotentialKit::displayName() const -{ - return tr("Configure BlackBerry..."); -} - -void BlackBerryPotentialKit::executeFromMenu() -{ - openSettings(); -} - -QWidget *BlackBerryPotentialKit::createWidget(QWidget *parent) const -{ - return shouldShow() ? new BlackBerryPotentialKitWidget(parent) : 0; -} - -bool BlackBerryPotentialKit::isEnabled() const -{ - return shouldShow(); -} - -bool BlackBerryPotentialKit::shouldShow() -{ - QList<BlackBerryApiLevelConfiguration *> configs = - BlackBerryConfigurationManager::instance()->apiLevels(); - if (configs.isEmpty()) - return false; // do not display when we do not have any BlackBerry API Level registered - foreach (BlackBerryApiLevelConfiguration *config, configs) { - if (config->isValid() && config->isActive()) - return false; // do not display when there is at least one valid and active API Level - } - return true; -} - -void BlackBerryPotentialKit::openSettings(QWidget *parent) -{ - Core::ICore::showOptionsDialog(Qnx::Constants::QNX_BB_SETUP_ID, parent); -} - -BlackBerryPotentialKitWidget::BlackBerryPotentialKitWidget(QWidget *parent) - : Utils::DetailsWidget(parent) -{ - setSummaryText(tr("<b>BlackBerry has not been configured. Create BlackBerry kits.</b>")); - setIcon(QIcon(QLatin1String(Core::Constants::ICON_WARNING))); - QWidget *mainWidget = new QWidget(this); - setWidget(mainWidget); - - QGridLayout *layout = new QGridLayout(mainWidget); - layout->setMargin(0); - QLabel *label = new QLabel; - label->setText(tr("Qt Creator needs additional settings to enable BlackBerry support." - " You can configure those settings in the Options dialog.")); - label->setWordWrap(true); - layout->addWidget(label, 0, 0, 1, 2); - - QPushButton *openOptions = new QPushButton; - openOptions->setText(Core::ICore::msgShowOptionsDialog()); - openOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - layout->addWidget(openOptions, 1, 1); - - connect(openOptions, SIGNAL(clicked()), this, SLOT(openOptions())); - connect(BlackBerryConfigurationManager::instance(), SIGNAL(settingsChanged()), - this, SLOT(recheck())); -} - -void BlackBerryPotentialKitWidget::openOptions() -{ - BlackBerryPotentialKit::openSettings(this); -} - -void BlackBerryPotentialKitWidget::recheck() -{ - setVisible(BlackBerryPotentialKit::shouldShow()); -} diff --git a/src/plugins/qnx/blackberrypotentialkit.h b/src/plugins/qnx/blackberrypotentialkit.h deleted file mode 100644 index b9c1d529b83..00000000000 --- a/src/plugins/qnx/blackberrypotentialkit.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYPOTENTIALKIT_H -#define BLACKBERRYPOTENTIALKIT_H - -#include <projectexplorer/ipotentialkit.h> -#include <utils/detailswidget.h> - -class BlackBerryPotentialKit : public ProjectExplorer::IPotentialKit -{ - Q_OBJECT -public: - QString displayName() const; - void executeFromMenu(); - QWidget *createWidget(QWidget *parent) const; - bool isEnabled() const; - - static bool shouldShow(); - static void openSettings(QWidget *parent = 0); -}; - -class BlackBerryPotentialKitWidget : public Utils::DetailsWidget -{ - Q_OBJECT -public: - explicit BlackBerryPotentialKitWidget(QWidget *parent); - -public slots: - void openOptions(); - void recheck(); - -}; - -#endif // BLACKBERRYPOTENTIALKIT_H diff --git a/src/plugins/qnx/blackberryprocessparser.cpp b/src/plugins/qnx/blackberryprocessparser.cpp deleted file mode 100644 index fd393c111fb..00000000000 --- a/src/plugins/qnx/blackberryprocessparser.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryprocessparser.h" - -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/task.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const char ERROR_MESSAGE_START[] = "Error: "; -const char WARNING_MESSAGE_START[] = "Warning: "; -const char PROGRESS_MESSAGE_START[] = "Info: Progress "; -const char PID_MESSAGE_START[] = "result::"; -const char APPLICATION_ID_MESSAGE_START[] = "Info: Launching "; - -const char AUTHENTICATION_ERROR[] = "Authentication failed."; -} - -BlackBerryProcessParser::BlackBerryProcessParser() -{ - m_messageReplacements[QLatin1String(AUTHENTICATION_ERROR)] = - tr("Authentication failed. Please make sure the password for the device is correct."); -} - -void BlackBerryProcessParser::stdOutput(const QString &line) -{ - parse(line); - IOutputParser::stdOutput(line); -} - -void BlackBerryProcessParser::stdError(const QString &line) -{ - parse(line); - IOutputParser::stdError(line); -} - -void BlackBerryProcessParser::parse(const QString &line) -{ - bool isErrorMessage = line.startsWith(QLatin1String(ERROR_MESSAGE_START)); - bool isWarningMessage = line.startsWith(QLatin1String(WARNING_MESSAGE_START)); - if (isErrorMessage || isWarningMessage) - parseErrorAndWarningMessage(line, isErrorMessage); - else if (line.startsWith(QLatin1String(PROGRESS_MESSAGE_START))) - parseProgress(line); - else if (line.startsWith(QLatin1String(PID_MESSAGE_START))) - parsePid(line); - else if (line.startsWith(QLatin1String(APPLICATION_ID_MESSAGE_START))) - parseApplicationId(line); -} - -void BlackBerryProcessParser::parseErrorAndWarningMessage(const QString &line, bool isErrorMessage) -{ - QString message = line.mid(line.indexOf(QLatin1String(": ")) + 2).trimmed(); - - foreach (const QString &key, m_messageReplacements.keys()) { - if (message.startsWith(key)) { - message = m_messageReplacements[key]; - break; - } - } - - ProjectExplorer::Task task(isErrorMessage ? ProjectExplorer::Task::Error : ProjectExplorer::Task::Warning, - message, - Utils::FileName(), - -1, - Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); - emit addTask(task); -} - -void BlackBerryProcessParser::parseProgress(const QString &line) -{ - const QString startOfLine = QLatin1String(PROGRESS_MESSAGE_START); - - const int percentPos = line.indexOf(QLatin1Char('%')); - const QString progressStr = line.mid(startOfLine.length(), percentPos - startOfLine.length()); - - bool ok; - const int progress = progressStr.toInt(&ok); - if (ok) - emit progressParsed(progress); -} - -void BlackBerryProcessParser::parsePid(const QString &line) -{ - int pidIndex = -1; - if (line.contains(QLatin1String("running"))) // "result::running,<pid>" - pidIndex = 16; - else // "result::<pid>" - pidIndex = 8; - - bool ok; - const qint64 pid = line.mid(pidIndex).toInt(&ok); - if (ok) - emit pidParsed(pid); -} - -void BlackBerryProcessParser::parseApplicationId(const QString &line) -{ - const int endOfId = line.indexOf(QLatin1String("...")); - const QString applicationId = line.mid(16, endOfId - 16); - emit applicationIdParsed(applicationId); -} diff --git a/src/plugins/qnx/blackberryprocessparser.h b/src/plugins/qnx/blackberryprocessparser.h deleted file mode 100644 index 50aeb4a12af..00000000000 --- a/src/plugins/qnx/blackberryprocessparser.h +++ /dev/null @@ -1,70 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H -#define QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H - -#include <projectexplorer/ioutputparser.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryProcessParser : public ProjectExplorer::IOutputParser -{ - Q_OBJECT - -public: - BlackBerryProcessParser(); - - void stdOutput(const QString &line); - void stdError(const QString &line); - -signals: - void progressParsed(int progress); - void pidParsed(qint64 pid); - void applicationIdParsed(const QString &applicationId); - -private: - void parse(const QString &line); - - void parseErrorAndWarningMessage(const QString &line, bool isErrorMessage); - void parseProgress(const QString &line); - void parsePid(const QString &line); - void parseApplicationId(const QString &line); - - QMap<QString, QString> m_messageReplacements; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYPROCESSPARSER_H diff --git a/src/plugins/qnx/blackberryqtversion.cpp b/src/plugins/qnx/blackberryqtversion.cpp deleted file mode 100644 index 1c2cd2e6e77..00000000000 --- a/src/plugins/qnx/blackberryqtversion.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryqtversion.h" - -#include "qnxutils.h" -#include "qnxconstants.h" - -#include <coreplugin/featureprovider.h> -#include <utils/environment.h> -#include <utils/hostosinfo.h> -#include <utils/qtcassert.h> - -#include <qtsupport/qtsupportconstants.h> - -#include <QFileInfo> -#include <QTextStream> - -using namespace Qnx; -using namespace Qnx::Internal; - -namespace { -const QLatin1String NndkEnvFile("ndkEnvFile"); -} - -BlackBerryQtVersion::BlackBerryQtVersion() - : QnxAbstractQtVersion() -{ -} - -BlackBerryQtVersion::BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource, const QString &sdkPath) - : QnxAbstractQtVersion(arch, path, isAutoDetected, autoDetectionSource) -{ - if (!sdkPath.isEmpty()) { - if (QFileInfo(sdkPath).isDir()) { - setSdkPath(sdkPath); - } else { - m_ndkEnvFile = sdkPath; - setSdkPath(QFileInfo(sdkPath).absolutePath()); - } - - } else { - setDefaultSdkPath(); - } -} - -BlackBerryQtVersion::~BlackBerryQtVersion() -{ - -} - -BlackBerryQtVersion *BlackBerryQtVersion::clone() const -{ - return new BlackBerryQtVersion(*this); -} - -QString BlackBerryQtVersion::type() const -{ - return QLatin1String(Constants::QNX_BB_QT); -} - -QString BlackBerryQtVersion::description() const -{ - return tr("BlackBerry %1", "Qt Version is meant for BlackBerry").arg(archString()); -} - -QVariantMap BlackBerryQtVersion::toMap() const -{ - QVariantMap result = QnxAbstractQtVersion::toMap(); - result.insert(NndkEnvFile, m_ndkEnvFile); - return result; -} - -void BlackBerryQtVersion::fromMap(const QVariantMap &map) -{ - QnxAbstractQtVersion::fromMap(map); - m_ndkEnvFile = map.value(NndkEnvFile).toString(); -} - -QList<Utils::EnvironmentItem> BlackBerryQtVersion::environment() const -{ - QTC_CHECK(!sdkPath().isEmpty()); - if (sdkPath().isEmpty()) - return QList<Utils::EnvironmentItem>(); - - QString envFile = m_ndkEnvFile.isEmpty() ? QnxUtils::envFilePath(sdkPath()) : m_ndkEnvFile; - QList<Utils::EnvironmentItem> env = QnxUtils::qnxEnvironmentFromEnvFile(envFile); - - // BB NDK Host is having qmake executable which is using qt.conf file to specify - // base information. The qt.conf file is using 'CPUVARDIR' environment variable - // to provide correct information for both x86 and armle-v7 architectures. - // BlackBerryQtVersion represents as specific environment for each Qt4/Qt5 - // and x86/armle-v7 combination. Therefore we need to explicitly specify - // CPUVARDIR to match expected architecture() otherwise qmake environment is - // always resolved to be for armle-v7 architecture only as it is specified - // BB NDK environment file. - - env.append(Utils::EnvironmentItem(QLatin1String("CPUVARDIR"), - architecture() == X86 ? QLatin1String("x86") : QLatin1String("armle-v7"))); - - return env; -} - -void BlackBerryQtVersion::setDefaultSdkPath() -{ - QHash<QString, QString> info = versionInfo(); - QString qtHostPrefix; - if (info.contains(QLatin1String("QT_HOST_PREFIX"))) - qtHostPrefix = info.value(QLatin1String("QT_HOST_PREFIX")); - else - return; - - if (QnxUtils::isValidNdkPath(qtHostPrefix)) - setSdkPath(qtHostPrefix); -} - -Core::FeatureSet BlackBerryQtVersion::availableFeatures() const -{ - Core::FeatureSet features = QnxAbstractQtVersion::availableFeatures(); - features |= Core::FeatureSet(Constants::QNX_BB_FEATURE); - features.remove(Core::Feature(QtSupport::Constants::FEATURE_QT_CONSOLE)); - features.remove(Core::Feature(QtSupport::Constants::FEATURE_QT_WEBKIT)); - return features; -} - -QString BlackBerryQtVersion::platformName() const -{ - return QLatin1String(Constants::QNX_BB_PLATFORM_NAME); -} - -QString BlackBerryQtVersion::platformDisplayName() const -{ - return tr("BlackBerry"); -} - -QString BlackBerryQtVersion::sdkDescription() const -{ - return tr("BlackBerry Native SDK:"); -} diff --git a/src/plugins/qnx/blackberryqtversion.h b/src/plugins/qnx/blackberryqtversion.h deleted file mode 100644 index 90e588ec08e..00000000000 --- a/src/plugins/qnx/blackberryqtversion.h +++ /dev/null @@ -1,77 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYQTVERSION_H -#define QNX_INTERNAL_BLACKBERRYQTVERSION_H - -#include "qnxconstants.h" -#include "qnxabstractqtversion.h" - -namespace Qnx { -namespace Internal { - -class BlackBerryQtVersion : public QnxAbstractQtVersion -{ - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::BlackBerryQtVersion) -public: - BlackBerryQtVersion(); - BlackBerryQtVersion(QnxArchitecture arch, const Utils::FileName &path, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString(), - const QString &sdkPath = QString()); - BlackBerryQtVersion *clone() const; - ~BlackBerryQtVersion(); - - QString type() const; - - QString description() const; - - QVariantMap toMap() const; - void fromMap(const QVariantMap &map); - - Core::FeatureSet availableFeatures() const; - QString platformName() const; - QString platformDisplayName() const; - - QString sdkDescription() const; - -private: - QList<Utils::EnvironmentItem> environment() const; - void setDefaultSdkPath(); - - QString m_ndkEnvFile; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYQTVERSION_H diff --git a/src/plugins/qnx/blackberryqtversionfactory.cpp b/src/plugins/qnx/blackberryqtversionfactory.cpp deleted file mode 100644 index 4bc9759eaaa..00000000000 --- a/src/plugins/qnx/blackberryqtversionfactory.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryqtversionfactory.h" - -#include "qnxconstants.h" -#include "blackberryqtversion.h" -#include "qnxutils.h" - -#include <qtsupport/profilereader.h> - -#include <QFileInfo> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryQtVersionFactory::BlackBerryQtVersionFactory(QObject *parent) : - QtSupport::QtVersionFactory(parent) -{ -} - -BlackBerryQtVersionFactory::~BlackBerryQtVersionFactory() -{ -} - -bool BlackBerryQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::QNX_BB_QT); -} - -QtSupport::BaseQtVersion *BlackBerryQtVersionFactory::restore(const QString &type, const QVariantMap &data) -{ - if (!canRestore(type)) - return 0; - BlackBerryQtVersion *v = new BlackBerryQtVersion(); - v->fromMap(data); - return v; -} - -int BlackBerryQtVersionFactory::priority() const -{ - return Constants::QNX_BB_QT_FACTORY_PRIO; -} - -QtSupport::BaseQtVersion *BlackBerryQtVersionFactory::create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected, - const QString &autoDetectionSource) -{ - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return 0; - - if (evaluator->values(QLatin1String("CONFIG")).contains(QLatin1String("blackberry")) || - evaluator->values(QLatin1String("QMAKE_PLATFORM")).contains(QLatin1String("blackberry"))) { - QString cpuDir = evaluator->value(QLatin1String("QNX_CPUDIR")); - return new BlackBerryQtVersion(QnxUtils::cpudirToArch(cpuDir), qmakePath, - isAutoDetected, autoDetectionSource); - } - - return 0; -} diff --git a/src/plugins/qnx/blackberryqtversionfactory.h b/src/plugins/qnx/blackberryqtversionfactory.h deleted file mode 100644 index acbd1f15107..00000000000 --- a/src/plugins/qnx/blackberryqtversionfactory.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYQTVERSIONFACTORY_H -#define QNX_INTERNAL_BLACKBERRYQTVERSIONFACTORY_H - -#include <qtsupport/qtversionfactory.h> - -namespace Qnx { -namespace Internal { - -class BlackBerryQtVersionFactory : public QtSupport::QtVersionFactory -{ - Q_OBJECT -public: - explicit BlackBerryQtVersionFactory(QObject *parent = 0); - ~BlackBerryQtVersionFactory(); - - virtual bool canRestore(const QString &type); - virtual QtSupport::BaseQtVersion *restore(const QString &type, const QVariantMap &data); - - virtual int priority() const; - virtual QtSupport::BaseQtVersion *create(const Utils::FileName &qmakePath, - ProFileEvaluator *evaluator, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYQTVERSIONFACTORY_H diff --git a/src/plugins/qnx/blackberryrunconfiguration.cpp b/src/plugins/qnx/blackberryrunconfiguration.cpp deleted file mode 100644 index aca6eda098b..00000000000 --- a/src/plugins/qnx/blackberryrunconfiguration.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryrunconfiguration.h" -#include "qnxconstants.h" -#include "blackberrydeployconfiguration.h" -#include "blackberryrunconfigurationwidget.h" -#include "blackberrydeployinformation.h" - -#include <projectexplorer/buildtargetinfo.h> -#include <projectexplorer/target.h> -#include <ssh/sshconnection.h> - -#include <QFileInfo> - -using namespace Qnx; -using namespace Qnx::Internal; -using namespace ProjectExplorer; - -BlackBerryRunConfiguration::BlackBerryRunConfiguration(Target *parent, Core::Id id, const Utils::FileName &path) - : RunConfiguration(parent, id) - , m_proFilePath(path) -{ - init(); -} - -BlackBerryRunConfiguration::BlackBerryRunConfiguration(Target *parent, - BlackBerryRunConfiguration *source) - : RunConfiguration(parent, source) - , m_proFilePath(source->m_proFilePath) -{ - init(); -} - -void BlackBerryRunConfiguration::init() -{ - updateDisplayName(); - - connect(deployConfiguration()->deploymentInfo(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SIGNAL(targetInformationChanged())); - connect(deployConfiguration()->deploymentInfo(), SIGNAL(modelReset()), this, SIGNAL(targetInformationChanged())); -} - -void BlackBerryRunConfiguration::updateDisplayName() -{ - if (!m_proFilePath.isEmpty()) - setDefaultDisplayName(m_proFilePath.toFileInfo().completeBaseName()); - else - setDefaultDisplayName(tr("Run on BlackBerry device")); -} - -QWidget *BlackBerryRunConfiguration::createConfigurationWidget() -{ - return new BlackBerryRunConfigurationWidget(this); -} - -Utils::FileName BlackBerryRunConfiguration::proFilePath() const -{ - return m_proFilePath; -} - -QString BlackBerryRunConfiguration::deviceName() const -{ - BlackBerryDeviceConfiguration::ConstPtr device - = BlackBerryDeviceConfiguration::device(target()->kit()); - if (!device) - return QString(); - - return device->displayName(); -} - -Utils::FileName BlackBerryRunConfiguration::barPackage() const -{ - BlackBerryDeployConfiguration *dc = deployConfiguration(); - if (!dc) - return Utils::FileName(); - - QList<BarPackageDeployInformation> packages = dc->deploymentInfo()->enabledPackages(); - foreach (const BarPackageDeployInformation package, packages) { - if (package.proFilePath == proFilePath()) - return package.packagePath(); - } - return Utils::FileName(); -} - -QString BlackBerryRunConfiguration::localExecutableFilePath() const -{ - return target()->applicationTargets().targetForProject(m_proFilePath).toString(); -} - -bool BlackBerryRunConfiguration::fromMap(const QVariantMap &map) -{ - if (!RunConfiguration::fromMap(map)) - return false; - - m_proFilePath = Utils::FileName::fromUserInput( - map.value(QLatin1String(Constants::QNX_PROFILEPATH_KEY)).toString()); - if (m_proFilePath.isEmpty() || !m_proFilePath.exists()) - return false; - - init(); - return true; -} - -QVariantMap BlackBerryRunConfiguration::toMap() const -{ - QVariantMap map(RunConfiguration::toMap()); - map.insert(QLatin1String(Constants::QNX_PROFILEPATH_KEY), m_proFilePath.toString()); - return map; -} - -BlackBerryDeployConfiguration *BlackBerryRunConfiguration::deployConfiguration() const -{ - return qobject_cast<BlackBerryDeployConfiguration *>(target()->activeDeployConfiguration()); -} - -QString BlackBerryRunConfiguration::key() const -{ - return barPackage().toString() + QLatin1Char('_') - + BlackBerryDeviceConfiguration::device(target()->kit())->sshParameters().host; -} diff --git a/src/plugins/qnx/blackberryrunconfiguration.h b/src/plugins/qnx/blackberryrunconfiguration.h deleted file mode 100644 index daf3fcc892d..00000000000 --- a/src/plugins/qnx/blackberryrunconfiguration.h +++ /dev/null @@ -1,94 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYRUNCONFIGURATION_H -#define QNX_INTERNAL_BLACKBERRYRUNCONFIGURATION_H - -#include <projectexplorer/runconfiguration.h> - -#include <utils/fileutils.h> - -namespace ProjectExplorer { class Target; } - -namespace QmakeProjectManager { -class QmakeBuildConfiguration; -class QmakeProject; -} - -namespace Qnx { -namespace Internal { - -class BlackBerryDeployConfiguration; - -class BlackBerryRunConfiguration : public ProjectExplorer::RunConfiguration -{ - Q_OBJECT - friend class BlackBerryRunConfigurationFactory; - -public: - explicit BlackBerryRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, - const Utils::FileName &path); - - QWidget *createConfigurationWidget(); - - Utils::FileName proFilePath() const; - - QString deviceName() const; - Utils::FileName barPackage() const; - - QString localExecutableFilePath() const; - - bool fromMap(const QVariantMap &map); - QVariantMap toMap() const; - - BlackBerryDeployConfiguration *deployConfiguration() const; - QmakeProjectManager::QmakeBuildConfiguration *activeQmakeBuildConfiguration() const; - - QString key() const; - -signals: - void targetInformationChanged(); - -protected: - BlackBerryRunConfiguration(ProjectExplorer::Target *parent, BlackBerryRunConfiguration *source); - -private: - void init(); - void updateDisplayName(); - - Utils::FileName m_proFilePath; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYRUNCONFIGURATION_H diff --git a/src/plugins/qnx/blackberryrunconfigurationfactory.cpp b/src/plugins/qnx/blackberryrunconfigurationfactory.cpp deleted file mode 100644 index f8d2160f908..00000000000 --- a/src/plugins/qnx/blackberryrunconfigurationfactory.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryrunconfigurationfactory.h" -#include "qnxconstants.h" -#include "blackberryrunconfiguration.h" -#include "blackberrydeviceconfigurationfactory.h" - -#include <projectexplorer/kitinformation.h> -#include <projectexplorer/target.h> -#include <qmakeprojectmanager/qmakeproject.h> -#include <qmakeprojectmanager/qmakenodes.h> - -using namespace Qnx; -using namespace Qnx::Internal; - -static Utils::FileName pathFromId(Core::Id id) -{ - return Utils::FileName::fromString(id.suffixAfter(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)); -} - -BlackBerryRunConfigurationFactory::BlackBerryRunConfigurationFactory(QObject *parent) : - ProjectExplorer::IRunConfigurationFactory(parent) -{ -} - -QList<Core::Id> BlackBerryRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const -{ - using QmakeProjectManager::QmakeProject; - if (!canHandle(parent)) - return QList<Core::Id>(); - - QmakeProject *qt4Project = qobject_cast<QmakeProject *>(parent->project()); - if (!qt4Project) - return QList<Core::Id>(); - - QList<QmakeProjectManager::QmakeProFileNode *> nodes = qt4Project->applicationProFiles(); - if (mode == AutoCreate) - nodes = QmakeProject::nodesWithQtcRunnable(nodes); - return QmakeProject::idsForNodes(Core::Id(Constants::QNX_BB_RUNCONFIGURATION_PREFIX), - nodes); -} - -QString BlackBerryRunConfigurationFactory::displayNameForId(Core::Id id) const -{ - const Utils::FileName path = pathFromId(id); - if (path.isEmpty()) - return QString(); - - if (id.name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)) - return path.toFileInfo().completeBaseName(); - - return QString(); -} - -bool BlackBerryRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, Core::Id id) const -{ - if (!canHandle(parent)) - return false; - - QmakeProjectManager::QmakeProject *qt4Project = qobject_cast<QmakeProjectManager::QmakeProject *>(parent->project()); - if (!qt4Project) - return false; - - if (!id.name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX)) - return false; - - return qt4Project->hasApplicationProFile(pathFromId(id)); -} - -ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, - const Core::Id id) -{ - return new BlackBerryRunConfiguration(parent, id, pathFromId(id)); -} - -bool BlackBerryRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, - const QVariantMap &map) const -{ - if (!canHandle(parent)) - return false; - - return ProjectExplorer::idFromMap(map).name().startsWith(Constants::QNX_BB_RUNCONFIGURATION_PREFIX); -} - -ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::doRestore( - ProjectExplorer::Target *parent, - const QVariantMap &map) -{ - Q_UNUSED(map); - return new BlackBerryRunConfiguration(parent, Core::Id(Constants::QNX_BB_RUNCONFIGURATION_PREFIX), - Utils::FileName()); -} - -bool BlackBerryRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, - ProjectExplorer::RunConfiguration *source) const -{ - return canCreate(parent, source->id()); -} - -ProjectExplorer::RunConfiguration *BlackBerryRunConfigurationFactory::clone( - ProjectExplorer::Target *parent, - ProjectExplorer::RunConfiguration *source) -{ - if (!canClone(parent, source)) - return 0; - - BlackBerryRunConfiguration *old = static_cast<BlackBerryRunConfiguration *>(source); - return new BlackBerryRunConfiguration(parent, old); - -} - -bool BlackBerryRunConfigurationFactory::canHandle(ProjectExplorer::Target *t) const -{ - if (!t->project()->supportsKit(t->kit())) - return false; - if (!qobject_cast<QmakeProjectManager::QmakeProject *>(t->project())) - return false; - - Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(t->kit()); - if (deviceType != BlackBerryDeviceConfigurationFactory::deviceType()) - return false; - - return true; -} diff --git a/src/plugins/qnx/blackberryrunconfigurationfactory.h b/src/plugins/qnx/blackberryrunconfigurationfactory.h deleted file mode 100644 index c19a6e33a0d..00000000000 --- a/src/plugins/qnx/blackberryrunconfigurationfactory.h +++ /dev/null @@ -1,71 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONFACTORY_H -#define QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONFACTORY_H - -#include <projectexplorer/runconfiguration.h> - -namespace QmakeProjectManager { class QmakeProFileNode; } - -namespace Qnx { -namespace Internal { - -class BlackBerryRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory -{ - Q_OBJECT -public: - explicit BlackBerryRunConfigurationFactory(QObject *parent = 0); - - QList<Core::Id> availableCreationIds(ProjectExplorer::Target *parent, CreationMode mode) const; - QString displayNameForId(Core::Id id) const; - - bool canCreate(ProjectExplorer::Target *parent, Core::Id id) const; - ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, Core::Id id); - - bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const; - - bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const; - ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, - ProjectExplorer::RunConfiguration *source); - -private: - bool canHandle(ProjectExplorer::Target *t) const; - - ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, - const QVariantMap &map); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONFACTORY_H diff --git a/src/plugins/qnx/blackberryrunconfigurationwidget.cpp b/src/plugins/qnx/blackberryrunconfigurationwidget.cpp deleted file mode 100644 index 0cebcc9105c..00000000000 --- a/src/plugins/qnx/blackberryrunconfigurationwidget.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryrunconfigurationwidget.h" -#include "ui_blackberryrunconfigurationwidget.h" -#include "blackberryrunconfiguration.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryRunConfigurationWidget::BlackBerryRunConfigurationWidget(BlackBerryRunConfiguration *config, QWidget *parent) - : QWidget(parent) - , m_ui(new Ui::BlackBerryRunConfigurationWidget) - , m_runConfiguration(config) -{ - m_ui->setupUi(this); - - updateUi(); - - connect(m_runConfiguration, SIGNAL(targetInformationChanged()), this, SLOT(updateUi())); -} - -BlackBerryRunConfigurationWidget::~BlackBerryRunConfigurationWidget() -{ - delete m_ui; -} - -void BlackBerryRunConfigurationWidget::updateUi() -{ - m_ui->deviceLabel->setText(m_runConfiguration->deviceName()); - m_ui->packageLabel->setText(m_runConfiguration->barPackage().toString()); -} diff --git a/src/plugins/qnx/blackberryrunconfigurationwidget.h b/src/plugins/qnx/blackberryrunconfigurationwidget.h deleted file mode 100644 index 38a82566471..00000000000 --- a/src/plugins/qnx/blackberryrunconfigurationwidget.h +++ /dev/null @@ -1,65 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONWIDGET_H -#define QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONWIDGET_H - -#include <QWidget> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BlackBerryRunConfigurationWidget; } - -class BlackBerryRunConfiguration; - -class BlackBerryRunConfigurationWidget : public QWidget -{ - Q_OBJECT - -public: - explicit BlackBerryRunConfigurationWidget(BlackBerryRunConfiguration *config, QWidget *parent = 0); - ~BlackBerryRunConfigurationWidget(); - -private slots: - void updateUi(); - -private: - Ui::BlackBerryRunConfigurationWidget *m_ui; - - BlackBerryRunConfiguration *m_runConfiguration; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYRUNCONFIGURATIONWIDGET_H diff --git a/src/plugins/qnx/blackberryrunconfigurationwidget.ui b/src/plugins/qnx/blackberryrunconfigurationwidget.ui deleted file mode 100644 index a76e316cd37..00000000000 --- a/src/plugins/qnx/blackberryrunconfigurationwidget.ui +++ /dev/null @@ -1,38 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerryRunConfigurationWidget</class> - <widget class="QWidget" name="Qnx::Internal::BlackBerryRunConfigurationWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>374</width> - <height>53</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Device:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="deviceLabel"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Package:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="packageLabel"/> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/blackberryruncontrol.cpp b/src/plugins/qnx/blackberryruncontrol.cpp deleted file mode 100644 index b14983e1e21..00000000000 --- a/src/plugins/qnx/blackberryruncontrol.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryruncontrol.h" -#include "blackberryapplicationrunner.h" -#include "blackberryrunconfiguration.h" -#include "blackberrydeviceconnectionmanager.h" - -#include <QIcon> -#include <QTimer> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerryRunControl::BlackBerryRunControl(BlackBerryRunConfiguration *runConfiguration) - : ProjectExplorer::RunControl(runConfiguration, ProjectExplorer::NormalRunMode) -{ - setIcon(QLatin1String(ProjectExplorer::Constants::ICON_RUN_SMALL)); - - m_runner = new BlackBerryApplicationRunner(BlackBerryApplicationRunner::LaunchFlags(), runConfiguration, this); - - connect(m_runner, SIGNAL(started()), this, SIGNAL(started())); - connect(m_runner, SIGNAL(finished()), this, SIGNAL(finished())); - connect(m_runner, SIGNAL(output(QString,Utils::OutputFormat)), - this, SLOT(appendMessage(QString,Utils::OutputFormat))); - connect(m_runner, SIGNAL(startFailed(QString)), this, SLOT(handleStartFailed(QString))); -} - -void BlackBerryRunControl::start() -{ - m_runner->start(); -} - -ProjectExplorer::RunControl::StopResult BlackBerryRunControl::stop() -{ - return m_runner->stop(); -} - -bool BlackBerryRunControl::isRunning() const -{ - return m_runner->isRunning(); -} - -void BlackBerryRunControl::handleStartFailed(const QString &message) -{ - appendMessage(message, Utils::StdErrFormat); -} diff --git a/src/plugins/qnx/blackberryruncontrol.h b/src/plugins/qnx/blackberryruncontrol.h deleted file mode 100644 index b9a3ccc5ebe..00000000000 --- a/src/plugins/qnx/blackberryruncontrol.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYRUNCONTROL_H -#define QNX_INTERNAL_BLACKBERRYRUNCONTROL_H - -#include <projectexplorer/runconfiguration.h> - -namespace QmakeProjectManager { class QmakeBuildConfiguration; } - -namespace Qnx { -namespace Internal { - -class BlackBerryConnect; -class BlackBerryRunConfiguration; -class BlackBerryApplicationRunner; - -class BlackBerryRunControl : public ProjectExplorer::RunControl -{ - Q_OBJECT -public: - explicit BlackBerryRunControl(BlackBerryRunConfiguration *runConfiguration); - - void start(); - ProjectExplorer::RunControl::StopResult stop(); - bool isRunning() const; - -private slots: - void handleStartFailed(const QString &message); - -private: - BlackBerryApplicationRunner *m_runner; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYRUNCONTROL_H diff --git a/src/plugins/qnx/blackberryruncontrolfactory.cpp b/src/plugins/qnx/blackberryruncontrolfactory.cpp deleted file mode 100644 index 1ef762d3c94..00000000000 --- a/src/plugins/qnx/blackberryruncontrolfactory.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryruncontrolfactory.h" -#include "blackberryrunconfiguration.h" -#include "blackberryruncontrol.h" -#include "blackberrydeployconfiguration.h" -#include "blackberrydebugsupport.h" -#include "blackberryqtversion.h" -#include "blackberrydeviceconnectionmanager.h" -#include "blackberryapplicationrunner.h" -#include "qnxutils.h" - -#include <debugger/debuggerplugin.h> -#include <debugger/debuggerrunconfigurationaspect.h> -#include <debugger/debuggerruncontrol.h> -#include <debugger/debuggerkitinformation.h> -#include <projectexplorer/deployconfiguration.h> -#include <projectexplorer/project.h> -#include <projectexplorer/target.h> -#include <projectexplorer/toolchain.h> -#include <qmakeprojectmanager/qmakebuildconfiguration.h> -#include <qtsupport/qtkitinformation.h> -#include <analyzerbase/analyzerstartparameters.h> -#include <analyzerbase/analyzermanager.h> -#include <analyzerbase/analyzerruncontrol.h> -#include <coreplugin/messagemanager.h> - -using namespace Analyzer; -using namespace Debugger; -using namespace ProjectExplorer; - -namespace Qnx { -namespace Internal { - -BlackBerryRunControlFactory::BlackBerryRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ -} - -bool BlackBerryRunControlFactory::canRun(RunConfiguration *runConfiguration, RunMode mode) const -{ - Q_UNUSED(mode); - - BlackBerryRunConfiguration *rc = qobject_cast<BlackBerryRunConfiguration *>(runConfiguration); - if (!rc) - return false; - - BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(rc->target()->kit()); - if (!device) - return false; - - // The device can only run the same application once, any subsequent runs will - // not launch a second instance. Disable the Run button if the application is already - // running on the device. - if (m_activeRunControls.contains(rc->key())) { - QPointer<RunControl> activeRunControl = m_activeRunControls[rc->key()]; - if (activeRunControl && activeRunControl.data()->isRunning()) - return false; - else - m_activeRunControls.remove(rc->key()); - } - - BlackBerryDeployConfiguration *activeDeployConf = qobject_cast<BlackBerryDeployConfiguration *>( - rc->target()->activeDeployConfiguration()); - return activeDeployConf != 0; -} - -static void createAnalyzerStartParameters(AnalyzerStartParameters *pStartParameters, BlackBerryRunConfiguration* runConfiguration, RunMode mode) -{ - QTC_ASSERT(pStartParameters, return); - pStartParameters->runMode = mode; - if (mode == QmlProfilerRunMode) - pStartParameters->startMode = StartLocal; - - Target *target = runConfiguration->target(); - Kit *kit = target->kit(); - - IDevice::ConstPtr device = DeviceKitInformation::device(kit); - if (device) { - pStartParameters->connParams = device->sshParameters(); - pStartParameters->analyzerHost = device->qmlProfilerHost(); - } - pStartParameters->sysroot = SysRootKitInformation::sysRoot(kit).toString(); - - DebuggerRunConfigurationAspect *aspect = runConfiguration->extraAspect<DebuggerRunConfigurationAspect>(); - if (aspect) - pStartParameters->analyzerPort = aspect->qmlDebugServerPort(); -} - -static DebuggerStartParameters startParameters(BlackBerryRunConfiguration *runConfig) -{ - DebuggerStartParameters params; - Target *target = runConfig->target(); - Kit *k = target->kit(); - - params.startMode = AttachToRemoteServer; - params.debuggerCommand = DebuggerKitInformation::debuggerCommand(k).toString(); - params.sysRoot = SysRootKitInformation::sysRoot(k).toString(); - params.useCtrlCStub = true; - params.runConfiguration = runConfig; - - if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) - params.toolChainAbi = tc->targetAbi(); - - params.executable = runConfig->localExecutableFilePath(); - params.displayName = runConfig->displayName(); - params.remoteSetupNeeded = true; - - DebuggerRunConfigurationAspect *aspect = runConfig->extraAspect<DebuggerRunConfigurationAspect>(); - if (aspect->useQmlDebugger()) { - BlackBerryDeviceConfiguration::ConstPtr device = BlackBerryDeviceConfiguration::device(runConfig->target()->kit()); - if (device) { - params.qmlServerAddress = device->sshParameters().host; - params.qmlServerPort = aspect->qmlDebugServerPort(); - params.languages |= QmlLanguage; - } - } - if (aspect->useCppDebugger()) - params.languages |= CppLanguage; - - if (const Project *project = runConfig->target()->project()) { - params.projectSourceDirectory = project->projectDirectory().toString(); - if (const BuildConfiguration *buildConfig = runConfig->target()->activeBuildConfiguration()) - params.projectBuildDirectory = buildConfig->buildDirectory().toString(); - params.projectSourceFiles = project->files(Project::ExcludeGeneratedFiles); - } - - BlackBerryQtVersion *qtVersion = - dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtKitInformation::qtVersion(k)); - if (qtVersion) - params.solibSearchPath = QnxUtils::searchPaths(qtVersion); - - return params; -} - -RunControl *BlackBerryRunControlFactory::create(RunConfiguration *runConfiguration, - RunMode mode, QString *errorMessage) -{ - BlackBerryRunConfiguration *rc = qobject_cast<BlackBerryRunConfiguration *>(runConfiguration); - if (!rc) - return 0; - - BlackBerryDeployConfiguration *activeDeployConf = qobject_cast<BlackBerryDeployConfiguration *>( - rc->target()->activeDeployConfiguration()); - if (!activeDeployConf) { - if (errorMessage) - *errorMessage = tr("No active deploy configuration"); - return 0; - } - - if (mode == NormalRunMode) { - BlackBerryRunControl *runControl = new BlackBerryRunControl(rc); - m_activeRunControls[rc->key()] = runControl; - return runControl; - } - if (mode == QmlProfilerRunMode) { - QtSupport::BaseQtVersion *qtVer = QtSupport::QtKitInformation::qtVersion(rc->target()->kit()); - if (qtVer && qtVer->qtVersion() <= QtSupport::QtVersionNumber(4, 8, 6)) - Core::MessageManager::write(tr("Target Qt version (%1) might not support QML profiling. " - "Cascades applications are not affected and should work as expected. " - "For more info see http://wiki.qt.io/Qt_Creator_with_BlackBerry_10") - .arg(qtVer->qtVersionString()), Core::MessageManager::Flash - ); - - AnalyzerStartParameters params; - createAnalyzerStartParameters(¶ms, rc, mode); - - AnalyzerRunControl *runControl = AnalyzerManager::createRunControl(params, runConfiguration); - BlackBerryApplicationRunner::LaunchFlags launchFlags(BlackBerryApplicationRunner::QmlDebugLaunch - | BlackBerryApplicationRunner::QmlDebugLaunchBlocking - | BlackBerryApplicationRunner::QmlProfilerLaunch); - BlackBerryApplicationRunner *runner = new BlackBerryApplicationRunner(launchFlags, rc, runControl); - - connect(runner, SIGNAL(finished()), runControl, SLOT(notifyRemoteFinished())); - connect(runner, SIGNAL(output(QString,Utils::OutputFormat)), - runControl, SLOT(logApplicationMessage(QString,Utils::OutputFormat))); - connect(runControl, SIGNAL(starting(const Analyzer::AnalyzerRunControl*)), - runner, SLOT(start())); - connect(runControl, SIGNAL(finished()), runner, SLOT(stop())); - return runControl; - } - - DebuggerRunControl *runControl = DebuggerRunControlFactory::doCreate(startParameters(rc), errorMessage); - if (!runControl) - return 0; - - new BlackBerryDebugSupport(rc, runControl); - m_activeRunControls[rc->key()] = runControl; - return runControl; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberryruncontrolfactory.h b/src/plugins/qnx/blackberryruncontrolfactory.h deleted file mode 100644 index 04fcdc2b2bf..00000000000 --- a/src/plugins/qnx/blackberryruncontrolfactory.h +++ /dev/null @@ -1,67 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYRUNCONTROLFACTORY_H -#define QNX_INTERNAL_BLACKBERRYRUNCONTROLFACTORY_H - -#include <debugger/debuggerstartparameters.h> - -#include <projectexplorer/runconfiguration.h> - -namespace RemoteLinux { class RemoteLinuxRunConfiguration; } - -namespace Qnx { -namespace Internal { - -class BlackBerryRunConfiguration; - -class BlackBerryRunControlFactory : public ProjectExplorer::IRunControlFactory -{ - Q_OBJECT - -public: - BlackBerryRunControlFactory(QObject *parent = 0); - - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode) const; - ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - ProjectExplorer::RunMode mode, - QString *errorMessage); - -private: - mutable QMap<QString, QPointer<ProjectExplorer::RunControl> > m_activeRunControls; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYRUNCONTROLFACTORY_H diff --git a/src/plugins/qnx/blackberryruntimeconfiguration.cpp b/src/plugins/qnx/blackberryruntimeconfiguration.cpp deleted file mode 100644 index 19c11887452..00000000000 --- a/src/plugins/qnx/blackberryruntimeconfiguration.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberryruntimeconfiguration.h" - -#include "qnxconstants.h" - -#include <QVariantMap> -#include <QFileInfo> -#include <QCoreApplication> - -namespace Qnx { -namespace Internal { - -const QLatin1String PathKey("Path"); -const QLatin1String DisplayNameKey("DisplayName"); -const QLatin1String VersionKey("Version"); - -BlackBerryRuntimeConfiguration::BlackBerryRuntimeConfiguration( - const QString &path, - const QnxVersionNumber &version) - : m_path(path) -{ - if (!version.isEmpty()) - m_version = version; - else - m_version = QnxVersionNumber::fromFileName(QFileInfo(path).baseName(), - QRegExp(QLatin1String("^runtime_(.*)$"))); - - m_displayName = QCoreApplication::translate("Qnx::Internal::BlackBerryRuntimeConfiguration", "Runtime %1").arg(m_version.toString()); -} - -BlackBerryRuntimeConfiguration::BlackBerryRuntimeConfiguration(const QVariantMap &data) -{ - m_path = data.value(QLatin1String(PathKey)).toString(); - m_displayName = data.value(QLatin1String(DisplayNameKey)).toString(); - m_version = QnxVersionNumber(data.value(QLatin1String(VersionKey)).toString()); -} - -QString BlackBerryRuntimeConfiguration::path() const -{ - return m_path; -} - -QString BlackBerryRuntimeConfiguration::displayName() const -{ - return m_displayName; -} - -QnxVersionNumber BlackBerryRuntimeConfiguration::version() const -{ - return m_version; -} - -QVariantMap BlackBerryRuntimeConfiguration::toMap() const -{ - QVariantMap data; - data.insert(QLatin1String(Qnx::Constants::QNX_BB_KEY_CONFIGURATION_TYPE), - QLatin1String(Qnx::Constants::QNX_BB_RUNTIME_TYPE)); - data.insert(QLatin1String(PathKey), m_path); - data.insert(QLatin1String(DisplayNameKey), m_displayName); - data.insert(QLatin1String(VersionKey), m_version.toString()); - return data; -} - -} -} diff --git a/src/plugins/qnx/blackberryruntimeconfiguration.h b/src/plugins/qnx/blackberryruntimeconfiguration.h deleted file mode 100644 index 24a5c3bf726..00000000000 --- a/src/plugins/qnx/blackberryruntimeconfiguration.h +++ /dev/null @@ -1,63 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYRUNTIMECONFIGURATION_H -#define BLACKBERRYRUNTIMECONFIGURATION_H - -#include "qnxversionnumber.h" - -#include <QVariantMap> - -namespace Qnx { -namespace Internal { -class BlackBerryRuntimeConfiguration -{ -public: - BlackBerryRuntimeConfiguration(const QString &path, - const QnxVersionNumber &version = QnxVersionNumber()); - BlackBerryRuntimeConfiguration(const QVariantMap &data); - - QString path() const; - QString displayName() const; - QnxVersionNumber version() const; - QVariantMap toMap() const; - -private: - QString m_path; - QString m_displayName; - QnxVersionNumber m_version; -}; - -} -} - -#endif // BLACKBERRYRUNTIMECONFIGURATION_H diff --git a/src/plugins/qnx/blackberrysetuppage.cpp b/src/plugins/qnx/blackberrysetuppage.cpp deleted file mode 100644 index 6e19183a056..00000000000 --- a/src/plugins/qnx/blackberrysetuppage.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrysetuppage.h" -#include "blackberrysetupwidget.h" -#include "qnxconstants.h" - -#include <QCoreApplication> - -namespace Qnx { -namespace Internal { - -BlackBerrySetupPage::BlackBerrySetupPage(QObject *parent) - : Core::IOptionsPage(parent) -{ - setId(Core::Id(Constants::QNX_BB_SETUP_ID)); - setDisplayName(tr("Setup")); - setCategory(Constants::QNX_BB_CATEGORY); - setDisplayCategory(QCoreApplication::translate("BlackBerry", Constants::QNX_BB_CATEGORY_TR)); - setCategoryIcon(QLatin1String(Constants::QNX_BB_CATEGORY_ICON)); -} - -QWidget *BlackBerrySetupPage::widget() -{ - if (!m_widget) - m_widget = new BlackBerrySetupWidget; - return m_widget; -} - -void BlackBerrySetupPage::apply() -{ -} - -void BlackBerrySetupPage::finish() -{ - delete m_widget; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrysetuppage.h b/src/plugins/qnx/blackberrysetuppage.h deleted file mode 100644 index 466ab7806bf..00000000000 --- a/src/plugins/qnx/blackberrysetuppage.h +++ /dev/null @@ -1,60 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYSETUPPAGE_H -#define BLACKBERRYSETUPPAGE_H - -#include <coreplugin/dialogs/ioptionspage.h> - -#include <QPointer> - -namespace Qnx { -namespace Internal { - -class BlackBerrySetupWidget; - -class BlackBerrySetupPage : public Core::IOptionsPage -{ - Q_OBJECT -public: - explicit BlackBerrySetupPage(QObject *parent = 0); - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<BlackBerrySetupWidget> m_widget; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYSETUPPAGE_H diff --git a/src/plugins/qnx/blackberrysetupwidget.cpp b/src/plugins/qnx/blackberrysetupwidget.cpp deleted file mode 100644 index 379d48db432..00000000000 --- a/src/plugins/qnx/blackberrysetupwidget.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrysetupwidget.h" - -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" -#include "blackberrysigningutils.h" -#include "blackberrydeviceconfigurationwizard.h" -#include "blackberryinstallwizard.h" -#include "blackberrycertificate.h" -#include "qnxconstants.h" - -#include <coreplugin/coreconstants.h> -#include <projectexplorer/devicesupport/devicemanager.h> - -#include <QFileInfo> -#include <QFrame> -#include <QHBoxLayout> -#include <QLabel> -#include <QPushButton> -#include <QDesktopServices> -#include <QWizard> -#include <QUrl> -#include <QMessageBox> - -namespace Qnx { -namespace Internal { - -SetupItem::SetupItem(const QString &desc, QWidget *parent) -: QFrame(parent) -{ - m_timer.setSingleShot(true); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(validate())); - - setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); - QVBoxLayout *frameLayout = new QVBoxLayout(this); - - QHBoxLayout *childLayout = new QHBoxLayout; - frameLayout->addLayout(childLayout); - - m_icon = new QLabel; - childLayout->addWidget(m_icon); - - m_label = new QLabel; - m_label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - childLayout->addWidget(m_label); - - m_button = new QPushButton; - childLayout->addWidget(m_button); - QObject::connect(m_button, SIGNAL(clicked()), this, SLOT(onFixPressed())); - - if (!desc.isEmpty()) { - m_desc = new QLabel(desc); - m_desc->setWordWrap(true); - QFont font = m_desc->font(); - font.setItalic(true); - m_desc->setFont(font); - frameLayout->addWidget(m_desc); - } -} - -void SetupItem::set(Status status, const QString &message, const QString &fixText) -{ - QString icon; - switch (status) { - case Ok: - icon = QLatin1String(Qnx::Constants::QNX_OK_ICON); - break; - case Info: - icon = QLatin1String(Core::Constants::ICON_INFO); - break; - case Warning: - icon = QLatin1String(Core::Constants::ICON_WARNING); - break; - case Error: - icon = QLatin1String(Core::Constants::ICON_ERROR); - break; - } - m_icon->setPixmap(QPixmap(icon)); - m_label->setText(message); - m_button->setVisible(!fixText.isEmpty()); - m_button->setText(fixText); -} - -void SetupItem::onFixPressed() -{ - fix(); - validate(); -} - -void SetupItem::validateLater() -{ - // BlackBerryConfigurationManager.settingsChanged and DeviceManager.updated signals - // may be emitted multiple times during the same event handling. This would result in multiple - // validation() calls even through just one is needed. - // QTimer allows to merge those multiple signal emits into a single validate() call. - m_timer.start(); -} - -APILevelSetupItem::APILevelSetupItem(QWidget *parent) -: SetupItem(tr("API Level defines kits, Qt versions, compilers, debuggers needed" - " for building BlackBerry applications."), parent) -{ - validate(); - connect(BlackBerryConfigurationManager::instance(), SIGNAL(settingsChanged()), - this, SLOT(validateLater())); -} - -void APILevelSetupItem::validate() -{ - FoundTypes found = resolvedFoundType(); - if (!found.testFlag(Any)) - set(Error, tr("No API Level is installed."), tr("Install")); - else if (!found.testFlag(Valid)) - set(Error, tr("No valid API Level is installed."), tr("Install")); - else if (!found.testFlag(Active)) - set(Error, tr("Valid API Level is not activated."), tr("Activate")); - else if (!found.testFlag(V_10_2)) - set(Warning, tr("Valid API Level 10.2 or newer is not installed."), tr("Install")); - else if (!found.testFlag(V_10_2_AS_DEFAULT)) - set(Warning, tr("Valid API Level 10.2 or newer is not set as default."), tr("Set")); - else - set(Ok, tr("API Level is configured.")); - // TODO: should we check something more e.g. BB10 kits are valid? -} - -void APILevelSetupItem::fix() -{ - FoundTypes found = resolvedFoundType(); - if (!found.testFlag(Any) || !found.testFlag(Valid)) { - installAPILevel(); - } else if (!found.testFlag(Active)) { - foreach (BlackBerryApiLevelConfiguration *config, - BlackBerryConfigurationManager::instance()->apiLevels()) { - if (config->isValid() && !config->isActive()) { - config->activate(); - break; - } - } - } else if (!found.testFlag(V_10_2)) { - // TODO: install filter for 10.2 only - installAPILevel(); - } else if (!found.testFlag(V_10_2_AS_DEFAULT)) { - BlackBerryConfigurationManager::instance()->setDefaultConfiguration(0); - } -} - -APILevelSetupItem::FoundTypes APILevelSetupItem::resolvedFoundType() -{ - FoundTypes found; - - // TODO: for now, all Trunk versions are understood as 10.2 compliant - QnxVersionNumber version_10_2(QLatin1String("10.2.0.0")); - foreach (BlackBerryApiLevelConfiguration *config, - BlackBerryConfigurationManager::instance()->apiLevels()) { - found |= Any; - if (config->isValid()) { - found |= Valid; - if (config->isActive()) - found |= Active; - if (config->version() > version_10_2) - found |= V_10_2; - } - } - - BlackBerryApiLevelConfiguration *config = - BlackBerryConfigurationManager::instance()->defaultApiLevel(); - if (config && config->version() > version_10_2) - found |= V_10_2_AS_DEFAULT; - - return found; -} - -void APILevelSetupItem::installAPILevel() -{ - BlackBerryInstallWizard wizard( - BlackBerryInstallerDataHandler::InstallMode, - BlackBerryInstallerDataHandler::ApiLevel, QString(), this); - connect(&wizard, SIGNAL(processFinished()), this, SLOT(handleInstallationFinished())); - wizard.exec(); -} - -void APILevelSetupItem::handleInstallationFinished() -{ - // manually-added API Levels are automatically registered by BlackBerryInstallWizard - // auto-detected API Levels needs to reloaded explicitly - BlackBerryConfigurationManager::instance()->loadAutoDetectedConfigurations( - BlackBerryConfigurationManager::ApiLevel); - validate(); -} - -SigningKeysSetupItem::SigningKeysSetupItem(QWidget *parent) -: SetupItem(tr("Signing keys are needed for signing BlackBerry applications" - " and managing debug tokens."), parent) -{ - validate(); - connect(&BlackBerrySigningUtils::instance(), SIGNAL(defaultCertificateLoaded(int)), - this, SLOT(validate())); -} - -void SigningKeysSetupItem::validate() -{ - BlackBerrySigningUtils &utils = BlackBerrySigningUtils::instance(); - if (utils.hasLegacyKeys()) - set(Error, tr("Found legacy BlackBerry signing keys."), tr("Update")); - else if (!utils.hasRegisteredKeys()) - set(Error, tr("Cannot find BlackBerry signing keys."), tr("Request")); - else if (!QFileInfo::exists(BlackBerryConfigurationManager::instance()->defaultKeystorePath())) - set(Error, tr("Cannot find developer certificate."), tr("Create")); - else if (utils.defaultCertificateOpeningStatus() != BlackBerrySigningUtils::Opened) - set(Info, tr("Developer certificate is not opened."), tr("Open")); - else - set(Ok, tr("Signing keys are ready to use.")); -} - -void SigningKeysSetupItem::fix() -{ - BlackBerrySigningUtils &utils = BlackBerrySigningUtils::instance(); - if (utils.hasLegacyKeys()) { - QDesktopServices::openUrl(QUrl(QLatin1String(Qnx::Constants::QNX_LEGACY_KEYS_URL))); - } else if (!utils.hasRegisteredKeys()) { - QDesktopServices::openUrl(QUrl(QLatin1String(Qnx::Constants::QNX_REGISTER_KEYS_URL))); - } else if (!QFileInfo::exists(BlackBerryConfigurationManager::instance()->defaultKeystorePath())) { - set(Info, tr("Opening certificate...")); - utils.createCertificate(); - } else if (utils.defaultCertificateOpeningStatus() != BlackBerrySigningUtils::Opened) { - connect(&utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(defaultCertificateLoaded(int))); - utils.openDefaultCertificate(this); - } -} - -void SigningKeysSetupItem::defaultCertificateLoaded(int status) -{ - BlackBerrySigningUtils &utils = BlackBerrySigningUtils::instance(); - disconnect(&utils, SIGNAL(defaultCertificateLoaded(int)), this, SLOT(defaultCertificateLoaded(int))); - switch (status) { - case BlackBerryCertificate::Success: - // handled by the connect in ctor already - break; - case BlackBerryCertificate::WrongPassword: - QMessageBox::critical(this, tr("Qt Creator"), tr("Invalid certificate password.")); - break; - case BlackBerryCertificate::Busy: - case BlackBerryCertificate::InvalidOutputFormat: - case BlackBerryCertificate::Error: - QMessageBox::critical(this, tr("Qt Creator"), tr("Error loading certificate.")); - break; - } -} - -DeviceSetupItem::DeviceSetupItem(QWidget *parent) -: SetupItem(tr("BlackBerry 10 device or simulator is needed for running BlackBerry applications."), - parent) -{ - validate(); - connect(ProjectExplorer::DeviceManager::instance(), SIGNAL(updated()), - this, SLOT(validateLater())); -} - -void DeviceSetupItem::validate() -{ - bool found = false; - ProjectExplorer::DeviceManager *manager = ProjectExplorer::DeviceManager::instance(); - for (int i = 0; i < manager->deviceCount(); i ++) { - ProjectExplorer::IDevice::ConstPtr device = manager->deviceAt(i); - if (device->type() == Constants::QNX_BB_OS_TYPE) { - found = true; - break; - } - } - if (!found) - set(Error, tr("No BlackBerry 10 device or simulator is registered."), tr("Add")); - else - set(Ok, tr("BlackBerry 10 device or simulator is registered.")); - // TODO: check for existence of an API Level matching a device? -} - -void DeviceSetupItem::fix() -{ - BlackBerryDeviceConfigurationWizard wizard(this); - if (wizard.exec() == QDialog::Accepted) - ProjectExplorer::DeviceManager::instance()->addDevice(wizard.device()); -} - -BlackBerrySetupWidget::BlackBerrySetupWidget(QWidget *parent) - : QWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - setLayout(layout); - - layout->addWidget(new APILevelSetupItem); - layout->addWidget(new SigningKeysSetupItem); - layout->addWidget(new DeviceSetupItem); - - layout->addStretch(); - - QLabel *howTo = new QLabel; - howTo->setTextFormat(Qt::RichText); - howTo->setTextInteractionFlags(Qt::TextBrowserInteraction); - howTo->setOpenExternalLinks(true); - howTo->setText(tr("<a href=\"%1\">How to Setup Qt Creator for BlackBerry 10 development</a>") - .arg(QLatin1String(Qnx::Constants::QNX_BLACKBERRY_SETUP_URL))); - layout->addWidget(howTo); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/blackberrysetupwidget.h b/src/plugins/qnx/blackberrysetupwidget.h deleted file mode 100644 index fdc3a10ef31..00000000000 --- a/src/plugins/qnx/blackberrysetupwidget.h +++ /dev/null @@ -1,144 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BLACKBERRYSETUPWIDGET_H -#define BLACKBERRYSETUPWIDGET_H - -#include <QFrame> -#include <QWidget> -#include <QCoreApplication> -#include <QTimer> - -QT_BEGIN_NAMESPACE -class QLabel; -class QPushButton; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - - -class SetupItem : public QFrame { - Q_OBJECT - -public: - enum Status { - Ok, Info, Warning, Error - }; - - SetupItem(const QString &desc = QString(), QWidget *parent = 0); - -protected: - void set(Status status, const QString &message, const QString &fixText = QString()); - Q_SLOT virtual void validate() = 0; - virtual void fix() = 0; - -private slots: - void onFixPressed(); - void validateLater(); - -private: - QLabel *m_icon; - QLabel *m_label; - QPushButton *m_button; - QLabel *m_desc; - QTimer m_timer; -}; - -class APILevelSetupItem : public SetupItem -{ - Q_OBJECT - -public: - APILevelSetupItem(QWidget *parent = 0); - - enum FoundType { - Any = (1 << 0), - Valid = (1 << 1), - Active = (1 << 2), - V_10_2 = (1 << 3), - V_10_2_AS_DEFAULT = (1 << 4) - }; - Q_DECLARE_FLAGS(FoundTypes, FoundType) - -protected: - virtual void validate(); - virtual void fix(); - -private slots: - void handleInstallationFinished(); - -private: - FoundTypes resolvedFoundType(); - void installAPILevel(); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(APILevelSetupItem::FoundTypes) - -class SigningKeysSetupItem : public SetupItem -{ - Q_OBJECT - -public: - SigningKeysSetupItem(QWidget *parent = 0); - -protected: - virtual void validate(); - virtual void fix(); - -private slots: - void defaultCertificateLoaded(int status); -}; - -class DeviceSetupItem : public SetupItem -{ - Q_OBJECT - -public: - DeviceSetupItem(QWidget *parent = 0); - -protected: - virtual void validate(); - virtual void fix(); -}; - -class BlackBerrySetupWidget : public QWidget -{ - Q_OBJECT - -public: - explicit BlackBerrySetupWidget(QWidget *parent = 0); -}; - -} // namespace Internal -} // namespeace Qnx - -#endif // BLACKBERRYSETUPWIDGET_H diff --git a/src/plugins/qnx/blackberrysetupwizardpages.cpp b/src/plugins/qnx/blackberrysetupwizardpages.cpp deleted file mode 100644 index b6bbf30872d..00000000000 --- a/src/plugins/qnx/blackberrysetupwizardpages.cpp +++ /dev/null @@ -1,345 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrysetupwizardpages.h" -#include "blackberryndksettingswidget.h" -#include "blackberrysigningutils.h" -#include "ui_blackberrysetupwizardkeyspage.h" -#include "ui_blackberrysetupwizardcertificatepage.h" -#include "ui_blackberrysetupwizarddevicepage.h" -#include "ui_blackberrysetupwizardfinishpage.h" - -#include <QVBoxLayout> -#include <QFileInfo> -#include <QLabel> -#include <QVBoxLayout> -#include <QMessageBox> -#include <QAbstractButton> -#include <QDesktopServices> -#include <QUrl> - -#include <QDebug> - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerrySetupWizardWelcomePage::BlackBerrySetupWizardWelcomePage(QWidget *parent) : - QWizardPage(parent) -{ - const QString welcomeMessage = - tr("Welcome to the BlackBerry Development " - "Environment Setup Wizard.\nThis wizard will guide you through " - "the essential steps to deploy a ready-to-go development environment " - "for BlackBerry 10 devices."); - - setTitle(tr("BlackBerry Development Environment Setup")); - - QLabel *label = new QLabel(this); - label->setWordWrap(true); - label->setText(welcomeMessage); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addStretch(); - layout->addWidget(label); - layout->addStretch(); - - setLayout(layout); -} - -//----------------------------------------------------------------------------- - -BlackBerrySetupWizardNdkPage::BlackBerrySetupWizardNdkPage(QWidget *parent) : - QWizardPage(parent), - m_widget(0) -{ - setTitle(tr("Configure the NDK Path")); - - m_widget = new BlackBerryNDKSettingsWidget(this); - m_widget->setWizardMessageVisible(false); - - connect(m_widget, SIGNAL(targetsUpdated()), this, SIGNAL(completeChanged())); - connect(m_widget, SIGNAL(targetsUpdated()), this, SIGNAL(targetsUpdated())); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(m_widget); - - setLayout(layout); -} - -BlackBerrySetupWizardNdkPage::~BlackBerrySetupWizardNdkPage() -{ -} - -bool BlackBerrySetupWizardNdkPage::isComplete() const -{ - return m_widget->hasActiveNdk(); -} - -//----------------------------------------------------------------------------- - -BlackBerrySetupWizardKeysPage::BlackBerrySetupWizardKeysPage(QWidget *parent) : - QWizardPage(parent), - m_ui(0), - m_complete(false) -{ - setTitle(tr("Setup Signing Keys")); - - initUi(); -} - -BlackBerrySetupWizardKeysPage::~BlackBerrySetupWizardKeysPage() -{ - delete m_ui; - m_ui = 0; -} - -void BlackBerrySetupWizardKeysPage::showKeysMessage(const QString &url) -{ - const QMessageBox::StandardButton button = QMessageBox::question(this, - tr("Qt Creator"), - tr("This wizard will be closed and you will be taken to the BlackBerry " - "key request web page. Do you want to continue?"), - QMessageBox::Yes | QMessageBox::No); - - if (button == QMessageBox::Yes) { - QDesktopServices::openUrl(QUrl(url)); - wizard()->reject(); - } -} - -bool BlackBerrySetupWizardKeysPage::isComplete() const -{ - return m_complete; -} - -void BlackBerrySetupWizardKeysPage::initUi() -{ - BlackBerrySigningUtils &utils = BlackBerrySigningUtils::instance(); - - m_ui = new Ui::BlackBerrySetupWizardKeysPage; - m_ui->setupUi(this); - - if (utils.hasLegacyKeys()) { - m_ui->linkLabel->setVisible(false); - m_ui->legacyLabel->setVisible(true); - m_ui->statusLabel->setVisible(false); - - setComplete(false); - } else if (utils.hasRegisteredKeys()) { - m_ui->linkLabel->setVisible(false); - m_ui->legacyLabel->setVisible(false); - m_ui->statusLabel->setVisible(true); - - setComplete(true); - } else { - m_ui->linkLabel->setVisible(true); - m_ui->legacyLabel->setVisible(false); - m_ui->statusLabel->setVisible(false); - - setComplete(false); - } - - connect(m_ui->linkLabel, SIGNAL(linkActivated(QString)), - this, SLOT(showKeysMessage(QString))); - connect(m_ui->legacyLabel, SIGNAL(linkActivated(QString)), - this, SLOT(showKeysMessage(QString))); - connect(m_ui->helpLabel, SIGNAL(linkActivated(QString)), - this, SLOT(showKeysMessage(QString))); -} - -void BlackBerrySetupWizardKeysPage::setComplete(bool complete) -{ - if (m_complete != complete) { - m_complete = complete; - m_ui->linkLabel->setVisible(!complete); - m_ui->statusLabel->setVisible(complete); - emit completeChanged(); - } -} - -//----------------------------------------------------------------------------- - -const char BlackBerrySetupWizardCertificatePage::AuthorField[] = "CertificatePage::Author"; -const char BlackBerrySetupWizardCertificatePage::PasswordField[] = "CertificatePage::Password"; -const char BlackBerrySetupWizardCertificatePage::PasswordField2[] = "CertificatePage::Password2"; - -BlackBerrySetupWizardCertificatePage::BlackBerrySetupWizardCertificatePage(QWidget *parent) - : QWizardPage(parent), - m_ui(0), - m_complete(false) -{ - setTitle(tr("Create Developer Certificate")); - - initUi(); -} - -bool BlackBerrySetupWizardCertificatePage::isComplete() const -{ - return m_complete; -} - -void BlackBerrySetupWizardCertificatePage::validate() -{ - if (m_ui->author->text().isEmpty() - || m_ui->password->text().isEmpty() - || m_ui->password2->text().isEmpty()) { - m_ui->status->clear(); - setComplete(false); - return; - } - - if (m_ui->password->text() != m_ui->password2->text()) { - m_ui->status->setText(tr("The entered passwords do not match.")); - setComplete(false); - return; - } - - if (m_ui->password->text().size() < 6) { - // TODO: Use tr() once string freeze is over - m_ui->status->setText(QCoreApplication::translate("Qnx::Internal::BlackBerryCreateCertificateDialog", "Password must be at least 6 characters long.")); - setComplete(false); - return; - } - - m_ui->status->clear(); - setComplete(true); -} - -void BlackBerrySetupWizardCertificatePage::checkBoxChanged(int state) -{ - if (state == Qt::Checked) { - m_ui->password->setEchoMode(QLineEdit::Normal); - m_ui->password2->setEchoMode(QLineEdit::Normal); - } else { - m_ui->password->setEchoMode(QLineEdit::Password); - m_ui->password2->setEchoMode(QLineEdit::Password); - } -} - -void BlackBerrySetupWizardCertificatePage::setComplete(bool complete) -{ - if (m_complete != complete) { - m_complete = complete; - emit completeChanged(); - } -} - -void BlackBerrySetupWizardCertificatePage::initUi() -{ - m_ui = new Ui::BlackBerrySetupWizardCertificatePage; - m_ui->setupUi(this); - m_ui->status->clear(); - - connect(m_ui->author, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->password, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->password2, SIGNAL(textChanged(QString)), - this, SLOT(validate())); - connect(m_ui->showPassword, SIGNAL(stateChanged(int)), - this, SLOT(checkBoxChanged(int))); - - registerField(QLatin1String(AuthorField) + QLatin1Char('*'), m_ui->author); - registerField(QLatin1String(PasswordField) + QLatin1Char('*'), m_ui->password); - registerField(QLatin1String(PasswordField2) + QLatin1Char('*'), m_ui->password2); -} - -//----------------------------------------------------------------------------- - -const char BlackBerrySetupWizardDevicePage::NameField[] = "DevicePage::Name"; -const char BlackBerrySetupWizardDevicePage::IpAddressField[] = "DevicePage::IpAddress"; -const char BlackBerrySetupWizardDevicePage::PasswordField[] = "DevicePage::PasswordField"; -const char BlackBerrySetupWizardDevicePage::PhysicalDeviceField[] = "DevicePage::PhysicalDeviceField"; - - -BlackBerrySetupWizardDevicePage::BlackBerrySetupWizardDevicePage(QWidget *parent) - : QWizardPage(parent), - m_ui(0) -{ - setTitle(tr("Configure BlackBerry Device Connection")); - - m_ui = new Ui::BlackBerrySetupWizardDevicePage; - m_ui->setupUi(this); - - m_ui->deviceName->setText(tr("BlackBerry Device")); - m_ui->ipAddress->setText(QLatin1String("169.254.0.1")); - - connect(m_ui->deviceName, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->ipAddress, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->password, SIGNAL(textChanged(QString)), this, SIGNAL(completeChanged())); - connect(m_ui->physicalDevice, SIGNAL(toggled(bool)), this, SIGNAL(completeChanged())); - - registerField(QLatin1String(NameField) + QLatin1Char('*'), m_ui->deviceName); - registerField(QLatin1String(IpAddressField) + QLatin1Char('*'), m_ui->ipAddress); - registerField(QLatin1String(PasswordField), m_ui->password); - registerField(QLatin1String(PhysicalDeviceField), m_ui->physicalDevice); -} - -bool BlackBerrySetupWizardDevicePage::isComplete() const -{ - if (m_ui->deviceName->text().isEmpty() || m_ui->ipAddress->text().isEmpty()) - return false; - - const bool passwordMandatory = m_ui->physicalDevice->isChecked(); - - if (passwordMandatory && m_ui->password->text().isEmpty()) - return false; - - return true; -} - -//----------------------------------------------------------------------------- - -BlackBerrySetupWizardFinishPage::BlackBerrySetupWizardFinishPage(QWidget *parent) - : QWizardPage(parent), - m_ui(0) -{ - setTitle(tr("Your environment is ready to be configured.")); - - m_ui = new Ui::BlackBerrySetupWizardFinishPage; - m_ui->setupUi(this); - setProgress(QString(), -1); -} - -void BlackBerrySetupWizardFinishPage::setProgress(const QString &status, int progress) -{ - if (progress < 0) { - m_ui->progressBar->hide(); - m_ui->statusLabel->clear(); - return; - } else if (!m_ui->progressBar->isVisible()) { - m_ui->progressBar->show(); - } - - m_ui->statusLabel->setText(status); - m_ui->progressBar->setValue(progress); -} diff --git a/src/plugins/qnx/blackberrysigningpasswordsdialog.cpp b/src/plugins/qnx/blackberrysigningpasswordsdialog.cpp deleted file mode 100644 index 316bfba9568..00000000000 --- a/src/plugins/qnx/blackberrysigningpasswordsdialog.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrysigningpasswordsdialog.h" -#include "ui_blackberrysigningpasswordsdialog.h" - -using namespace Qnx; -using namespace Qnx::Internal; - -BlackBerrySigningPasswordsDialog::BlackBerrySigningPasswordsDialog(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::BlackBerrySigningPasswordsDialog) -{ - m_ui->setupUi(this); -} - -BlackBerrySigningPasswordsDialog::~BlackBerrySigningPasswordsDialog() -{ - delete m_ui; -} - -void BlackBerrySigningPasswordsDialog::setCskPassword(const QString &cskPassword) -{ - m_ui->cskPassword->setText(cskPassword); -} - -void BlackBerrySigningPasswordsDialog::setStorePassword(const QString &storePassword) -{ - m_ui->storePassword->setText(storePassword); -} - -QString BlackBerrySigningPasswordsDialog::cskPassword() const -{ - return m_ui->cskPassword->text(); -} - -QString BlackBerrySigningPasswordsDialog::storePassword() const -{ - return m_ui->storePassword->text(); -} diff --git a/src/plugins/qnx/blackberrysigningpasswordsdialog.h b/src/plugins/qnx/blackberrysigningpasswordsdialog.h deleted file mode 100644 index 43e254e579d..00000000000 --- a/src/plugins/qnx/blackberrysigningpasswordsdialog.h +++ /dev/null @@ -1,64 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYSIGNINGPASSWORDSDIALOG_H -#define QNX_INTERNAL_BLACKBERRYSIGNINGPASSWORDSDIALOG_H - -#include <QDialog> - -namespace Qnx { -namespace Internal { - -namespace Ui { class BlackBerrySigningPasswordsDialog; } - -class BlackBerrySigningPasswordsDialog : public QDialog -{ - Q_OBJECT - -public: - explicit BlackBerrySigningPasswordsDialog(QWidget *parent = 0); - ~BlackBerrySigningPasswordsDialog(); - - void setCskPassword(const QString &cskPassword); - void setStorePassword(const QString &storePassword); - - QString cskPassword() const; - QString storePassword() const; - -private: - Ui::BlackBerrySigningPasswordsDialog *m_ui; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYSIGNINGPASSWORDSDIALOG_H diff --git a/src/plugins/qnx/blackberrysigningpasswordsdialog.ui b/src/plugins/qnx/blackberrysigningpasswordsdialog.ui deleted file mode 100644 index 38715caf0f5..00000000000 --- a/src/plugins/qnx/blackberrysigningpasswordsdialog.ui +++ /dev/null @@ -1,96 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::BlackBerrySigningPasswordsDialog</class> - <widget class="QDialog" name="Qnx::Internal::BlackBerrySigningPasswordsDialog"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>313</width> - <height>89</height> - </rect> - </property> - <property name="windowTitle"> - <string>Package signing passwords</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <layout class="QFormLayout" name="formLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>CSK password:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="cskPassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="text"> - <string>Keystore password:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="storePassword"> - <property name="echoMode"> - <enum>QLineEdit::Password</enum> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>buttonBox</sender> - <signal>accepted()</signal> - <receiver>Qnx::Internal::BlackBerrySigningPasswordsDialog</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>buttonBox</sender> - <signal>rejected()</signal> - <receiver>Qnx::Internal::BlackBerrySigningPasswordsDialog</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/src/plugins/qnx/blackberrysigningutils.cpp b/src/plugins/qnx/blackberrysigningutils.cpp deleted file mode 100644 index ad830f11721..00000000000 --- a/src/plugins/qnx/blackberrysigningutils.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "blackberrysigningutils.h" -#include "blackberrycertificate.h" -#include "blackberryconfigurationmanager.h" -#include "blackberrycreatecertificatedialog.h" -#include "blackberrydebugtokenreader.h" - -#include <coreplugin/icore.h> - -#include <QDialog> -#include <QFileInfo> -#include <QString> -#include <QFile> -#include <QTextStream> -#include <QInputDialog> - -using namespace Qnx::Internal; - -namespace { -const QLatin1String DebugTokensGroup("DebugTokens"); -const QLatin1String DebugTokensPath("DebugTokenPath"); -} - -BlackBerrySigningUtils & BlackBerrySigningUtils::instance() -{ - static BlackBerrySigningUtils utils; - - return utils; -} - -BlackBerrySigningUtils::BlackBerrySigningUtils(QObject *parent) : - QObject(parent), - m_defaultCertificate(0), - m_defaultCertificateStatus(NotOpened) -{ - loadDebugTokens(); -} - -bool BlackBerrySigningUtils::hasRegisteredKeys() -{ - return QFileInfo::exists(BlackBerryConfigurationManager::instance()->idTokenPath()); -} - -bool BlackBerrySigningUtils::hasLegacyKeys() -{ - return QFileInfo::exists(BlackBerryConfigurationManager::instance()->barsignerCskPath()); -} - -bool BlackBerrySigningUtils::hasDefaultCertificate() -{ - return QFileInfo::exists(BlackBerryConfigurationManager::instance()->defaultKeystorePath()); -} - -QString BlackBerrySigningUtils::cskPassword(QWidget *passwordPromptParent, bool *ok) -{ - if (m_cskPassword.isEmpty()) - m_cskPassword = promptPassword(tr("Please provide your BlackBerry ID Token PIN."), passwordPromptParent, ok); - else if (ok) - *ok = true; - - return m_cskPassword; -} - -QString BlackBerrySigningUtils::certificatePassword(QWidget *passwordPromptParent, bool *ok) -{ - if (m_certificatePassword.isEmpty()) { - m_certificatePassword = - promptPassword(tr("Please enter your certificate password."), passwordPromptParent, ok); - } else if (ok) { - *ok = true; - } - - return m_certificatePassword; -} - -const BlackBerryCertificate * BlackBerrySigningUtils::defaultCertificate() const -{ - return m_defaultCertificate; -} - -BlackBerrySigningUtils::Status BlackBerrySigningUtils::defaultCertificateOpeningStatus() const -{ - return m_defaultCertificateStatus; -} - -void BlackBerrySigningUtils::openDefaultCertificate(QWidget *passwordPromptParent) -{ - switch (m_defaultCertificateStatus) { - case Opening: - return; - case Opened: - emit defaultCertificateLoaded(BlackBerryCertificate::Success); - return; - default: - m_defaultCertificateStatus = Opening; - } - - bool ok; - const QString password = certificatePassword(passwordPromptParent, &ok); - - // action has been canceled - if (!ok) { - m_defaultCertificateStatus = NotOpened; - return; - } - - if (m_defaultCertificate) - m_defaultCertificate->deleteLater(); - - m_defaultCertificate = new BlackBerryCertificate(BlackBerryConfigurationManager::instance()->defaultKeystorePath(), - QString(), password, this); - - connect(m_defaultCertificate, SIGNAL(finished(int)), this, SLOT(certificateLoaded(int))); - - m_defaultCertificate->load(); -} - -void BlackBerrySigningUtils::setDefaultCertificate(BlackBerryCertificate *certificate) -{ - if (m_defaultCertificate) - m_defaultCertificate->deleteLater(); - - certificate->setParent(this); - m_defaultCertificate = certificate; - m_defaultCertificateStatus = Opened; -} - -void BlackBerrySigningUtils::clearCskPassword() -{ - m_cskPassword.clear(); -} - -void BlackBerrySigningUtils::clearCertificatePassword() -{ - m_certificatePassword.clear(); -} - -void BlackBerrySigningUtils::deleteDefaultCertificate() -{ - clearCertificatePassword(); - m_defaultCertificate->deleteLater(); - m_defaultCertificate = 0; - m_defaultCertificateStatus = NotOpened; - - QFile::remove(BlackBerryConfigurationManager::instance()->defaultKeystorePath()); -} - -QStringList BlackBerrySigningUtils::debugTokens() const -{ - return m_debugTokens; -} - -void BlackBerrySigningUtils::addDebugToken(const QString &dt) -{ - if (m_debugTokens.contains(dt) || !QFileInfo(dt).exists()) - return; - - m_debugTokens << dt; - emit debugTokenListChanged(); -} - -void BlackBerrySigningUtils::removeDebugToken(const QString &dt) -{ - m_debugTokens.removeOne(dt); - emit debugTokenListChanged(); -} - -bool BlackBerrySigningUtils::createCertificate() -{ - BlackBerryCreateCertificateDialog dialog; - - const int result = dialog.exec(); - - if (result == QDialog::Rejected) - return false; - - BlackBerryCertificate *certificate = dialog.certificate(); - - if (certificate) - setDefaultCertificate(certificate); - - return certificate; -} - -void BlackBerrySigningUtils::certificateLoaded(int status) -{ - if (status != BlackBerryCertificate::Success) { - m_defaultCertificateStatus = NotOpened; - m_defaultCertificate->deleteLater(); - m_defaultCertificate = 0; - - // we have clear the password under any error since we are not able to distinquish - // if password is correct or not in case BlackBerryCertificate::Error status happens - clearCertificatePassword(); - } else - m_defaultCertificateStatus = Opened; - - - emit defaultCertificateLoaded(status); -} - -void BlackBerrySigningUtils::saveDebugTokens() -{ - if (m_debugTokens.isEmpty()) - return; - - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(DebugTokensGroup); - - int count = 0; - foreach (const QString &dt, m_debugTokens) { - settings->beginGroup(QString::fromLatin1("debugToken_%1").arg(++count)); - settings->setValue(DebugTokensPath, dt); - settings->endGroup(); - } - - settings->endGroup(); -} - -void BlackBerrySigningUtils::loadDebugTokens() -{ - QSettings *settings = Core::ICore::settings(); - settings->beginGroup(DebugTokensGroup); - - foreach (const QString &dt, settings->childGroups()) { - settings->beginGroup(dt); - m_debugTokens << settings->value(DebugTokensPath).toString(); - settings->endGroup(); - } - - settings->endGroup(); -} - -QString BlackBerrySigningUtils::promptPassword(const QString &message, - QWidget *dialogParent, bool *ok) const -{ - QInputDialog dialog(dialogParent); - dialog.setWindowTitle(tr("Qt Creator")); - dialog.setInputMode(QInputDialog::TextInput); - dialog.setLabelText(message); - dialog.setTextEchoMode(QLineEdit::Password); - - if (dialog.exec() == QDialog::Rejected) { - if (ok) - *ok = false; - - return QString(); - } - - if (ok) - *ok = true; - - return dialog.textValue(); -} diff --git a/src/plugins/qnx/blackberrysigningutils.h b/src/plugins/qnx/blackberrysigningutils.h deleted file mode 100644 index cc8df11939f..00000000000 --- a/src/plugins/qnx/blackberrysigningutils.h +++ /dev/null @@ -1,113 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H -#define QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H - -#include <QtGlobal> -#include <QObject> -#include <QStringList> - -QT_BEGIN_NAMESPACE -class QString; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BlackBerryCertificate; - -class BlackBerrySigningUtils : public QObject -{ - Q_OBJECT - -public: - enum Status { - NotOpened, - Opening, - Opened - }; - - static BlackBerrySigningUtils &instance(); - - bool hasRegisteredKeys(); - bool hasLegacyKeys(); - bool hasDefaultCertificate(); - - QString cskPassword(QWidget *passwordPromptParent = 0, bool *ok = 0); - QString certificatePassword(QWidget *passwordPromptParent = 0, bool *ok = 0); - - const BlackBerryCertificate *defaultCertificate() const; - Status defaultCertificateOpeningStatus() const; - - void openDefaultCertificate(QWidget *passwordPromptParent = 0); - void setDefaultCertificate(BlackBerryCertificate *certificate); - void clearCskPassword(); - void clearCertificatePassword(); - void deleteDefaultCertificate(); - bool createCertificate(); - void addDebugToken(const QString &dt); - void removeDebugToken(const QString &dt); - - QStringList debugTokens() const; - -signals: - void defaultCertificateLoaded(int status); - void debugTokenListChanged(); - -public slots: - void saveDebugTokens(); - -private slots: - void certificateLoaded(int status); - void loadDebugTokens(); - -private: - Q_DISABLE_COPY(BlackBerrySigningUtils) - - BlackBerrySigningUtils(QObject *parent = 0); - - QString promptPassword(const QString &message, QWidget *dialogParent = 0, bool *ok = 0) const; - - BlackBerryCertificate *m_defaultCertificate; - Status m_defaultCertificateStatus; - - QString m_cskPassword; - QString m_certificatePassword; - - QStringList m_debugTokens; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_BLACKBERRYSIGNINGUTILS_H diff --git a/src/plugins/qnx/blackberrysshkeysgenerator.cpp b/src/plugins/qnx/blackberrysshkeysgenerator.cpp deleted file mode 100644 index ae298b7cc7c..00000000000 --- a/src/plugins/qnx/blackberrysshkeysgenerator.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#include "blackberrysshkeysgenerator.h" - -#include <ssh/sshkeygenerator.h> - -using namespace Qnx::Internal; - -BlackBerrySshKeysGenerator::BlackBerrySshKeysGenerator() - : QThread(0) - , m_keyGen(new QSsh::SshKeyGenerator) -{ - connect(this, SIGNAL(finished()), this, SLOT(deleteLater())); -} - -BlackBerrySshKeysGenerator::~BlackBerrySshKeysGenerator() -{ - delete m_keyGen; - m_keyGen = 0; -} - -void BlackBerrySshKeysGenerator::run() -{ - const bool success = m_keyGen->generateKeys(QSsh::SshKeyGenerator::Rsa, - QSsh::SshKeyGenerator::Mixed, 4096, - QSsh::SshKeyGenerator::DoNotOfferEncryption); - if (success) { - // BB10 devices allow to use public key with no comment - // or a comment in username@hostname format - // QSsh::SshKeyGenerator class creates comments in 'QtCreator/TIMEZONE' format - // therefore stripping this comment out - QByteArray publicKey = m_keyGen->publicKey(); - int firstSpace = publicKey.indexOf(' '); - if (firstSpace >= 0) { - int secondSpace = publicKey.indexOf(' ', firstSpace + 1); - if (secondSpace >= 0) - publicKey.truncate(secondSpace); - } - - emit sshKeysGenerationFinished(m_keyGen->privateKey(), publicKey); - } else - emit sshKeysGenerationFailed(m_keyGen->error()); -} diff --git a/src/plugins/qnx/blackberrysshkeysgenerator.h b/src/plugins/qnx/blackberrysshkeysgenerator.h deleted file mode 100644 index 4b340395faf..00000000000 --- a/src/plugins/qnx/blackberrysshkeysgenerator.h +++ /dev/null @@ -1,61 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ -#ifndef BLACKBERRYSSHKEYSGENERATOR_H -#define BLACKBERRYSSHKEYSGENERATOR_H - -#include <QThread> - -namespace QSsh { class SshKeyGenerator; } - -namespace Qnx { -namespace Internal { - -class BlackBerrySshKeysGenerator : public QThread -{ - Q_OBJECT -public: - BlackBerrySshKeysGenerator(); - ~BlackBerrySshKeysGenerator(); - -signals: - void sshKeysGenerationFailed(const QString &error); - void sshKeysGenerationFinished(const QByteArray &privateKey, const QByteArray &publicKey); - -private: - QSsh::SshKeyGenerator *m_keyGen; - void run(); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // BLACKBERRYSSHKEYSGENERATOR_H diff --git a/src/plugins/qnx/cascadesimport/bardescriptorconverter.cpp b/src/plugins/qnx/cascadesimport/bardescriptorconverter.cpp deleted file mode 100644 index ce8e0813fca..00000000000 --- a/src/plugins/qnx/cascadesimport/bardescriptorconverter.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "bardescriptorconverter.h" - -#include <coreplugin/generatedfile.h> -#include <utils/qtcassert.h> - -#include <QDomDocument> - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// BarDescriptorConverter -// -////////////////////////////////////////////////////////////////////////////// -static const char S_ASSET[] = "asset"; -static const char S_PATH[] = "path"; -static const char S_SRC_DIR[] = "%SRC_DIR%/"; - -BarDescriptorConverter::BarDescriptorConverter(ConvertedProjectContext &ctx) - : FileConverter(ctx) -{ -} - -QString BarDescriptorConverter::projectName() const -{ - return convertedProjectContext().projectName(); -} - -QString BarDescriptorConverter::applicationBinaryName() const -{ - return projectName(); -} - -QString BarDescriptorConverter::applicationBinaryPath() const -{ - return projectName(); -} - -QDomElement BarDescriptorConverter::findElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue) -{ - QDomElement ret; - QTC_ASSERT(!tagName.isEmpty(), return ret); - QDomElement rootElement = doc.documentElement(); - static const QLatin1String elementTextFakeAttributeNameString("S_ELEMENT_TEXT_FAKE_ATTRIBUTE_NAME"); - bool isFindText = (attributeName == elementTextFakeAttributeNameString); - QRegExp rxAttrValue; - if (!isFindText && !attributeValue.isEmpty()) - rxAttrValue = QRegExp(attributeValue, Qt::CaseSensitive, QRegExp::Wildcard); - for (QDomElement el = rootElement.firstChildElement(tagName); - !el.isNull(); el = el.nextSiblingElement(tagName)) { - if (attributeName.isEmpty()) { - // take first matching tag name - ret = el; - break; - } else if (isFindText) { - QString s = el.text(); - if (s == attributeValue) { - ret = el; - break; - } - } else if (el.hasAttribute(attributeName)) { - if (attributeValue.isEmpty() || rxAttrValue.exactMatch(el.attribute(attributeName))) { - ret = el; - break; - } - } - } - return ret; -} - -QDomElement BarDescriptorConverter::ensureElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue) -{ - QDomElement ret = findElement(doc, tagName, attributeName, attributeValue); - if (ret.isNull()) { - QDomElement rootElement = doc.documentElement(); - ret = rootElement.appendChild(doc.createElement(tagName)).toElement(); - QTC_ASSERT(!ret.isNull(), return ret); - } - if (!attributeName.isEmpty()) - ret.setAttribute(attributeName, attributeValue); - return ret; -} - -QDomElement BarDescriptorConverter::removeElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue) -{ - QDomElement ret = findElement(doc, tagName, attributeName, attributeValue); - if (!ret.isNull()) { - QDomNode nd = ret.parentNode(); - QTC_ASSERT(!nd.isNull(), return ret); - nd.removeChild(ret); - } - return ret; -} - -void BarDescriptorConverter::setEnv(QDomDocument &doc, const QString &name, const QString &value) -{ - QDomElement el = ensureElement(doc, QLatin1String("env"), QLatin1String("var"), name); - QTC_ASSERT(!el.isNull(), return); - el.setAttribute(QString::fromLatin1("value"), value); -} - -void BarDescriptorConverter::setAsset(QDomDocument &doc, const QString &srcPath, - const QString &destPath, const QString &type, bool isEntry) -{ - ImportLog &log = convertedProjectContext().importLog(); - log.logInfo(tr("Setting asset path: %1 to %2 type: %3 entry point: %4") - .arg(srcPath).arg(destPath).arg(type).arg(isEntry)); - QDomElement assetElement = ensureElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), srcPath); - QTC_ASSERT(!assetElement.isNull(), return); - while (assetElement.hasChildNodes()) { - QDomNode nd = assetElement.firstChild(); - assetElement.removeChild(nd); - } - assetElement.appendChild(doc.createTextNode(destPath)); - - const QString typeString = QLatin1String("type"); - QString s = assetElement.attribute(typeString); - if (s != type) - assetElement.setAttribute(typeString, type); - - const QString entryString = QLatin1String("entry"); - s = assetElement.attribute(entryString); - bool b = (s.compare(QLatin1String("true"), Qt::CaseInsensitive) == 0) - || (s.compare(QLatin1String("1")) == 0); - if (b != isEntry) - assetElement.setAttribute(entryString, QVariant(isEntry).toString()); -} - -void BarDescriptorConverter::removeAsset(QDomDocument &doc, const QString &srcPath) -{ - ImportLog &log = convertedProjectContext().importLog(); - log.logInfo(tr("Removing asset path: %1").arg(srcPath)); - removeElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), srcPath); -} - -void BarDescriptorConverter::replaceAssetSourcePath(QDomDocument &doc, const QString &oldSrcPath, - const QString &newSrcPath) -{ - ImportLog &log = convertedProjectContext().importLog(); - QDomElement el = ensureElement(doc, QLatin1String(S_ASSET), QLatin1String(S_PATH), oldSrcPath); - if (!el.isNull()) { - log.logInfo(tr("Replacing asset source path: %1 -> %2").arg(oldSrcPath).arg(newSrcPath)); - el.setAttribute(QLatin1String(S_PATH), newSrcPath); - } -} - -void BarDescriptorConverter::fixImageAsset(QDomDocument &doc, const QString &definitionElementName) -{ - ImportLog &log = convertedProjectContext().importLog(); - QString target; - QDomElement el = findElement(doc, definitionElementName, QString(), QString()); - if (!el.isNull()) { - const QString imageString = QLatin1String("image"); - for (QDomElement imageElement = el.firstChildElement(imageString); !imageElement.isNull(); - imageElement = imageElement.nextSiblingElement(imageString)) { - target = imageElement.text(); - if (!target.isEmpty()) - replaceAssetSourcePath(doc, target, QLatin1String(S_SRC_DIR) + target); - } - } else { - log.logWarning(tr("Cannot find image asset definition: <%1>").arg(definitionElementName)); - } -} - -void BarDescriptorConverter::fixIconAsset(QDomDocument &doc) -{ - const QString iconString = QString::fromLatin1("icon"); - fixImageAsset(doc, iconString); -} - -void BarDescriptorConverter::fixSplashScreensAsset(QDomDocument &doc) -{ - const QString splashScreensString = QString::fromLatin1("splashScreens"); - fixImageAsset(doc, splashScreensString); -} - -bool BarDescriptorConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage) -{ - FileConverter::convertFile(file, errorMessage); - if (errorMessage.isEmpty()) { - QDomDocument doc; - if (!doc.setContent(file.binaryContents(), &errorMessage)) { - errorMessage = tr("Error parsing XML file \"%1\": %2").arg(file.path()).arg(errorMessage); - return false; - } - - // remove <configuration> elements, since they are Momentics specific - QDomElement rootElement = doc.documentElement(); - const QString configurationString = QLatin1String("configuration"); - while (true) { - QDomElement el = rootElement.firstChildElement(configurationString); - if (el.isNull()) - break; - rootElement.removeChild(el); - } - - // remove obsolete assets - removeAsset(doc, QLatin1String("translations")); - removeAsset(doc, QLatin1String("translations/*")); - // assets - setAsset(doc, applicationBinaryPath(), applicationBinaryName(), - QLatin1String("Qnx/Elf"), true); - const QString assetsString = QLatin1String("assets"); - replaceAssetSourcePath(doc, assetsString, QLatin1String(S_SRC_DIR) + assetsString); - fixIconAsset(doc); - fixSplashScreensAsset(doc); - - file.setBinaryContents(doc.toByteArray(4)); - } - return errorMessage.isEmpty(); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/bardescriptorconverter.h b/src/plugins/qnx/cascadesimport/bardescriptorconverter.h deleted file mode 100644 index 0342d0c12f4..00000000000 --- a/src/plugins/qnx/cascadesimport/bardescriptorconverter.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H - -#include "fileconverter.h" - -#include <QCoreApplication> - -QT_BEGIN_NAMESPACE -class QDomElement; -class QDomDocument; -QT_END_NAMESPACE - -namespace Qnx { -namespace Internal { - -class BarDescriptorConverter : public FileConverter -{ - Q_DECLARE_TR_FUNCTIONS(BarDescriptorConverter); -public: - BarDescriptorConverter(ConvertedProjectContext &ctx); - virtual ~BarDescriptorConverter() {} - - bool convertFile(Core::GeneratedFile &file, QString &errorMessage); -private: - QString projectName() const; - QString applicationBinaryName() const; - QString applicationBinaryPath() const; - - QDomElement findElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue); - QDomElement ensureElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue); - QDomElement removeElement(QDomDocument &doc, const QString &tagName, - const QString &attributeName, const QString &attributeValue); - - void fixImageAsset(QDomDocument &doc, const QString &definitionElementName); - void fixIconAsset(QDomDocument &doc); - void fixSplashScreensAsset(QDomDocument &doc); - - void setEnv(QDomDocument &doc, const QString &name, const QString &value); - void setAsset(QDomDocument &doc, const QString &srcPath, const QString &destPath, const QString &type = QString(), bool isEntry = false); - void removeAsset(QDomDocument &doc, const QString &srcPath); - void replaceAssetSourcePath(QDomDocument &doc, const QString &oldSrcPath, const QString &newSrcPath); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_BARDESCRIPTORCONVERTER_H diff --git a/src/plugins/qnx/cascadesimport/cascadesimport.pri b/src/plugins/qnx/cascadesimport/cascadesimport.pri deleted file mode 100644 index d8a10931035..00000000000 --- a/src/plugins/qnx/cascadesimport/cascadesimport.pri +++ /dev/null @@ -1,25 +0,0 @@ -SOURCES += \ - $$PWD/cascadesimportwizard.cpp \ - $$PWD/srcprojectwizardpage.cpp \ - $$PWD/srcprojectpathchooser.cpp \ - $$PWD/fileconverter.cpp \ - $$PWD/bardescriptorconverter.cpp \ - $$PWD/projectfileconverter.cpp \ - $$PWD/importlogconverter.cpp \ - $$PWD/importlog.cpp \ - -HEADERS += \ - $$PWD/cascadesimportwizard.h \ - $$PWD/srcprojectwizardpage.h \ - $$PWD/srcprojectpathchooser.h \ - $$PWD/fileconverter.h \ - $$PWD/bardescriptorconverter.h \ - $$PWD/projectfileconverter.h \ - $$PWD/importlogconverter.h \ - $$PWD/importlog.h \ - -FORMS += \ - $$PWD/srcprojectwizardpage.ui \ - -RESOURCES += \ - $$PWD/cascadesimport.qrc \ diff --git a/src/plugins/qnx/cascadesimport/cascadesimport.qrc b/src/plugins/qnx/cascadesimport/cascadesimport.qrc deleted file mode 100644 index da52ad2e547..00000000000 --- a/src/plugins/qnx/cascadesimport/cascadesimport.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<RCC> - <qresource prefix="/qnx/cascadesimport"> - <file>resources/templates/project.pro</file> - </qresource> -</RCC> diff --git a/src/plugins/qnx/cascadesimport/cascadesimportwizard.cpp b/src/plugins/qnx/cascadesimport/cascadesimportwizard.cpp deleted file mode 100644 index c2e624f393e..00000000000 --- a/src/plugins/qnx/cascadesimport/cascadesimportwizard.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "cascadesimportwizard.h" -#include "srcprojectwizardpage.h" -#include "bardescriptorconverter.h" -#include "importlogconverter.h" -#include "projectfileconverter.h" - -#include <qnx/qnxconstants.h> - -#include <coreplugin/icore.h> -#include <projectexplorer/projectexplorerconstants.h> -#include <projectexplorer/customwizard/customwizard.h> -#include <coreplugin/coreconstants.h> -#include <coreplugin/documentmanager.h> - -#include <utils/projectintropage.h> - -#include <utils/qtcassert.h> - -#include <QDir> -#include <QFileInfo> -#include <QPainter> -#include <QPixmap> -#include <QIcon> -#include <QStringBuilder> -#include <QDirIterator> - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// CascadesImportWizardDialog -// -////////////////////////////////////////////////////////////////////////////// - -CascadesImportWizardDialog::CascadesImportWizardDialog(QWidget *parent) : - Core::BaseFileWizard(parent) -{ - setWindowTitle(tr("Import Existing Momentics Cascades Project")); - - m_srcProjectPage = new SrcProjectWizardPage(this); - m_srcProjectPage->setTitle(tr("Momentics Cascades Project Name and Location")); - addPage(m_srcProjectPage); - - m_destProjectPage = new Utils::ProjectIntroPage(this); - m_destProjectPage->setTitle(tr("Project Name and Location")); - m_destProjectPage->setPath(Core::DocumentManager::projectsDirectory()); - const int destProjectPageId = addPage(m_destProjectPage); - wizardProgress()->item(destProjectPageId)->setTitle(tr("Qt Creator")); // Override default name - - connect(m_srcProjectPage, SIGNAL(validPathChanged(QString)), this, SLOT(onSrcProjectPathChanged(QString))); -} - -QString CascadesImportWizardDialog::srcProjectPath() const -{ - return m_srcProjectPage->path(); -} - -QString CascadesImportWizardDialog::destProjectPath() const -{ - return m_destProjectPage->path() % QLatin1Char('/') % projectName(); -} - -QString CascadesImportWizardDialog::projectName() const -{ - return m_destProjectPage->projectName(); -} - -void CascadesImportWizardDialog::onSrcProjectPathChanged(const QString &path) -{ - Q_UNUSED(path); - m_destProjectPage->setProjectName(m_srcProjectPage->projectName()); -} - -////////////////////////////////////////////////////////////////////////////// -// -// Wizard -// -////////////////////////////////////////////////////////////////////////////// -static const char IMPORT_LOG_FILE_NAME[] = "import.log"; - -CascadesImportWizard::CascadesImportWizard() -{ - setWizardKind(ProjectWizard); - setIcon(QPixmap(QLatin1String(Qnx::Constants::QNX_BB_CATEGORY_ICON))); - setDisplayName(tr("Momentics Cascades Project")); - setId(QLatin1String("Q.QnxBlackBerryCascadesApp")); - setRequiredFeatures(Core::FeatureSet(Constants::QNX_BB_FEATURE)); - setDescription(tr("Imports existing Cascades projects created within QNX Momentics IDE. " - "This allows you to use the project in Qt Creator.")); - setCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY)); - setDisplayCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY_DISPLAY)); -} - -Core::BaseFileWizard *CascadesImportWizard::create(QWidget *parent, - const Core::WizardDialogParameters ¶meters) const -{ - CascadesImportWizardDialog *wizard = new CascadesImportWizardDialog(parent); - - foreach (QWizardPage *p, parameters.extensionPages()) - wizard->addPage(p); - - return wizard; -} - -bool CascadesImportWizard::convertFile(Core::GeneratedFile &file, - ConvertedProjectContext &projectContext, QString &errorMessage) const -{ - bool ret = false; - if (convertFileContent(file, projectContext, errorMessage)) - if (convertFilePath(file, projectContext, errorMessage)) - ret = true; - return ret; -} - -bool CascadesImportWizard::convertFileContent(Core::GeneratedFile &file, - ConvertedProjectContext &projectContext, QString &errorMessage) const -{ - QString filePath = file.path(); - QString fileName = filePath.section(QLatin1Char('/'), -1); - bool isRootFile = (fileName == filePath); - QString fileExtension = fileName.section(QLatin1Char('.'), -1).toLower(); - bool useFileConverter = true; - if (isRootFile) { - if (fileName == QLatin1String("bar-descriptor.xml")) { - BarDescriptorConverter conv(projectContext); - conv.convertFile(file, errorMessage); - useFileConverter = false; - } else if (fileName == QLatin1String(IMPORT_LOG_FILE_NAME)) { - ImportLogConverter conv(projectContext); - conv.convertFile(file, errorMessage); - useFileConverter = false; - } else if (fileExtension == QLatin1String("pro")) { - ProjectFileConverter conv(projectContext); - conv.convertFile(file, errorMessage); - useFileConverter = false; - } - } - if (useFileConverter) { - FileConverter conv(projectContext); - conv.convertFile(file, errorMessage); - } - return errorMessage.isEmpty(); -} - -bool CascadesImportWizard::convertFilePath(Core::GeneratedFile &file, - ConvertedProjectContext &projectContext, QString &errorMessage) const -{ - Q_UNUSED(errorMessage); - const QString destProjectPath = projectContext.destProjectPath(); - file.setPath(destProjectPath % QLatin1Char('/') % file.path()); - return true; -} - -void CascadesImportWizard::collectFiles_helper(QStringList &filePaths, - ConvertedProjectContext &projectContext, const QString &rootPath, - const QList< QRegExp > &blackList) const -{ - const QString srcProjectPath = projectContext.srcProjectPath(); - bool isProjectRoot = (rootPath.length() == srcProjectPath.length()); - QDirIterator it(rootPath, QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs); - while (it.hasNext()) { - it.next(); - bool isBlacklisted = false; - QString fileName = it.fileName(); - foreach (const QRegExp &rx, blackList) { - QString pattern = rx.pattern(); - if (pattern.at(0) == QLatin1Char('/')) { - if (isProjectRoot) { - QString fn = QLatin1Char('/') % fileName; - if (rx.exactMatch(fn)) { - isBlacklisted = true; - break; - } - } - } else { - if (rx.exactMatch(fileName)) { - isBlacklisted = true; - break; - } - } - } - if (!isBlacklisted) { - QFileInfo fi = it.fileInfo(); - if (fi.isFile()) - filePaths << it.filePath().mid(srcProjectPath.length() + 1); - else if (fi.isDir()) - collectFiles_helper(filePaths, projectContext, it.filePath(), blackList); - } - } -} - -bool CascadesImportWizard::collectFiles(ConvertedProjectContext &projectContext, QString &errorMessage) const -{ - static QList<QRegExp> blackList; - if (blackList.isEmpty()) { - blackList << QRegExp(QLatin1String("/arm"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("/x86"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("/translations"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("Makefile"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("Makefile.*"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("/config.pri"), Qt::CaseInsensitive, QRegExp::Wildcard) - << QRegExp(QLatin1String("/precompiled.h"), Qt::CaseInsensitive, QRegExp::Wildcard); - } - QStringList filePaths; - collectFiles_helper(filePaths, projectContext, projectContext.srcProjectPath(), blackList); - filePaths << QLatin1String(IMPORT_LOG_FILE_NAME); - projectContext.setCollectedFiles(filePaths); - return errorMessage.isEmpty(); -} - -Core::GeneratedFiles CascadesImportWizard::generateFiles(const QWizard *w, QString *pErrorMessage) const -{ - Core::GeneratedFiles files; - QString errorMessage; - - const CascadesImportWizardDialog *wizardDialog = qobject_cast<const CascadesImportWizardDialog *>(w); - if (wizardDialog) { - ConvertedProjectContext projectContext; - projectContext.setSrcProjectPath(wizardDialog->srcProjectPath()); - projectContext.setDestProjectPath(wizardDialog->destProjectPath()); - - if (collectFiles(projectContext, errorMessage)) { - foreach (const QString &filePath, projectContext.collectedFiles()) { - Core::GeneratedFile file(filePath); - if (convertFile(file, projectContext, errorMessage)) { - if (!file.path().isEmpty()) - files << file; - } - if (!errorMessage.isEmpty()) { - errorMessage = tr("Error generating file \"%1\": %2").arg(filePath).arg(errorMessage); - break; - } - } - } - } - - - if (!errorMessage.isEmpty()) - if (pErrorMessage) - *pErrorMessage = errorMessage; - return files; -} - -bool CascadesImportWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) -{ - Q_UNUSED(w); - return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l, errorMessage); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/cascadesimportwizard.h b/src/plugins/qnx/cascadesimport/cascadesimportwizard.h deleted file mode 100644 index 78e8e8f21f5..00000000000 --- a/src/plugins/qnx/cascadesimport/cascadesimportwizard.h +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H -#define QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H - -#include "fileconverter.h" - -#include <coreplugin/basefilewizard.h> -#include <coreplugin/basefilewizardfactory.h> -#include <utils/wizard.h> - -namespace Utils { class ProjectIntroPage; } - -namespace Qnx { -namespace Internal { - -class SrcProjectWizardPage; - -class CascadesImportWizardDialog : public Core::BaseFileWizard -{ - Q_OBJECT -public: - CascadesImportWizardDialog(QWidget *parent = 0); - - QString srcProjectPath() const; - QString destProjectPath() const; - - QString projectName() const; -private slots: - void onSrcProjectPathChanged(const QString &path); -private: - SrcProjectWizardPage *m_srcProjectPage; - Utils::ProjectIntroPage *m_destProjectPage; -}; - -class CascadesImportWizard : public Core::BaseFileWizardFactory -{ - Q_OBJECT -public: - CascadesImportWizard(); - -protected: - Core::BaseFileWizard *create(QWidget *parent, const Core::WizardDialogParameters ¶meters) const; - Core::GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const; - bool postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage); -private: - bool collectFiles(ConvertedProjectContext &projectContext, QString &errorMessage) const; - void collectFiles_helper(QStringList &filePaths, ConvertedProjectContext &projectContext, - const QString &rootPath, const QList< QRegExp > &blackList) const; - bool convertFile(Core::GeneratedFile &file, ConvertedProjectContext &projectContext, - QString &errorMessage) const; - bool convertFilePath(Core::GeneratedFile &file, ConvertedProjectContext &projectContext, - QString &errorMessage) const; - bool convertFileContent(Core::GeneratedFile &file, ConvertedProjectContext &projectContext, - QString &errorMessage) const; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESIMPORT_WIZARD_H diff --git a/src/plugins/qnx/cascadesimport/fileconverter.cpp b/src/plugins/qnx/cascadesimport/fileconverter.cpp deleted file mode 100644 index 57faafc5115..00000000000 --- a/src/plugins/qnx/cascadesimport/fileconverter.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "fileconverter.h" - -#include <utils/fileutils.h> -#include <coreplugin/generatedfile.h> - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// ConvertedProjectContext -// -////////////////////////////////////////////////////////////////////////////// -QString ConvertedProjectContext::projectName() const -{ - return destProjectPath().section(QLatin1Char('/'), -1); -} - -////////////////////////////////////////////////////////////////////////////// -// -// FileConverter -// -////////////////////////////////////////////////////////////////////////////// -bool FileConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage) -{ - ImportLog &log = convertedProjectContext().importLog(); - log.logInfo(tr("===== Converting file: %1").arg(file.path())); - loadFileContent(file, errorMessage); - if (!errorMessage.isEmpty()) - logError(errorMessage); - return errorMessage.isEmpty(); -} - -QByteArray FileConverter::loadFileContent(const QString &filePath, QString &errorMessage) -{ - QByteArray ret; - Utils::FileReader fr; - QString absFilePath = filePath; - if (!filePath.startsWith(QLatin1String(":/"))) { - const QString srcProjectPath = convertedProjectContext().srcProjectPath(); - absFilePath = srcProjectPath + QLatin1Char('/') + filePath; - } - fr.fetch(absFilePath); - if (!fr.errorString().isEmpty()) - errorMessage = fr.errorString(); - else - ret = fr.data(); - return ret; -} - -bool FileConverter::loadFileContent(Core::GeneratedFile &file, QString &errorMessage) -{ - if (file.binaryContents().isEmpty()) { - // virtual files have some content set already - QString filePath = file.path(); - QByteArray ba = loadFileContent(filePath, errorMessage); - file.setBinaryContents(ba); - } - return errorMessage.isEmpty(); -} - -void FileConverter::logError(const QString &errorMessage) -{ - if (!errorMessage.isEmpty()) - convertedProjectContext().importLog().logError(errorMessage); -} - -} // namespace Internal -} // namespace Qnx - diff --git a/src/plugins/qnx/cascadesimport/fileconverter.h b/src/plugins/qnx/cascadesimport/fileconverter.h deleted file mode 100644 index 7dce7c73fd1..00000000000 --- a/src/plugins/qnx/cascadesimport/fileconverter.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H - -#include "importlog.h" - -#include <QStringList> -#include <QCoreApplication> - -namespace Core { class GeneratedFile; } - -namespace Qnx { -namespace Internal { - -class ConvertedProjectContext -{ -public: - void setSrcProjectPath(const QString &p) {m_srcProjectPath = p;} - QString srcProjectPath() const {return m_srcProjectPath;} - void setDestProjectPath(const QString &p) {m_destProjectPath = p;} - QString destProjectPath() const {return m_destProjectPath;} - - QString projectName() const; - const QStringList& collectedFiles() const {return m_collectedFiles;} - void setCollectedFiles(const QStringList &files) {m_collectedFiles = files;} - ImportLog& importLog() {return m_importLog;} -private: - QString m_srcProjectPath; - QString m_destProjectPath; - ImportLog m_importLog; - QStringList m_collectedFiles; -}; - -class FileConverter -{ - Q_DECLARE_TR_FUNCTIONS(FileConverter); -public: - FileConverter(ConvertedProjectContext &ctx) : m_convertedProjectContext(ctx) {} - virtual ~FileConverter() {} - - virtual bool convertFile(Core::GeneratedFile &file, QString &errorMessage); -protected: - ConvertedProjectContext& convertedProjectContext() const {return m_convertedProjectContext;} - - bool loadFileContent(Core::GeneratedFile &file, QString &errorMessage); - QByteArray loadFileContent(const QString &filePath, QString &errorMessage); - void logError(const QString &errorMessage); - - ConvertedProjectContext &m_convertedProjectContext; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_FILECONVERTER_H diff --git a/src/plugins/qnx/cascadesimport/importlog.cpp b/src/plugins/qnx/cascadesimport/importlog.cpp deleted file mode 100644 index 02d2be7aea3..00000000000 --- a/src/plugins/qnx/cascadesimport/importlog.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "importlog.h" - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// ImportLogEntry -// -////////////////////////////////////////////////////////////////////////////// -static const char S_ERROR[] = "error"; -static const char S_WARNING[] = "warning"; -static const char S_INFO[] = "info"; -static const char S_DEBUG[] = "debug"; -static const char S_UNDEFINED[] = "undefined"; - -ImportLogEntry::ImportLogEntry(int sev, const QString &msg, const QString &context) -: QVariantList() -{ - reserve(UnusedIx); - append(sev); - append(msg); - append(context); -} - -static const char* severityEnumToStr(ImportLogEntry::Severity sev) -{ - switch (sev) { - case ImportLogEntry::Error: - return S_ERROR; - case ImportLogEntry::Warning: - return S_WARNING; - case ImportLogEntry::Info: - return S_INFO; - case ImportLogEntry::Debug: - return S_DEBUG; - default: - break; - } - return S_UNDEFINED; -} - -ImportLogEntry::Severity ImportLogEntry::severity() const -{ - if (isValid()) - return (Severity)(at(SeverityIx).toInt()); - return Undefined; -} - -QString ImportLogEntry::severityStr() const -{ - return QLatin1String(severityEnumToStr(severity())); -} - -QChar ImportLogEntry::severityAbbr() const -{ - return severityStr().at(0).toUpper(); -} - -QString ImportLogEntry::message() const -{ - if (isValid()) - return at(MessageIx).toString(); - return QString(); -} - -QString ImportLogEntry::context() const -{ - if (isValid()) - return at(ContextIx).toString(); - return QString(); -} - -QString ImportLogEntry::toString() const -{ - QString ret; - if (severity() == Undefined) - ret = message(); - else - ret = QString::fromLatin1("[%1]%2 %3").arg(severityAbbr()).arg(context()).arg(message()); - return ret; -} - -////////////////////////////////////////////////////////////////////////////// -// -// ImportLog -// -////////////////////////////////////////////////////////////////////////////// -QString ImportLog::toString() const -{ - QString ret; - foreach (const ImportLogEntry &sle, *this) - ret += sle.toString() + QLatin1Char('\n'); - return ret; -} - -ImportLog& ImportLog::logError(const QString &msg, const QString &context) -{ - append(ImportLogEntry(ImportLogEntry::Error, msg, context)); - return *this; -} - -ImportLog& ImportLog::logWarning(const QString &msg, const QString &context) -{ - append(ImportLogEntry(ImportLogEntry::Warning, msg, context)); - return *this; -} - -ImportLog& ImportLog::logInfo(const QString &msg, const QString &context) -{ - append(ImportLogEntry(ImportLogEntry::Info, msg, context)); - return *this; -} - -ImportLog& ImportLog::logDebug(const QString &msg, const QString &context) -{ - append(ImportLogEntry(ImportLogEntry::Debug, msg, context)); - return *this; -} - -} // namespace Internal -} // namespace Qnx - diff --git a/src/plugins/qnx/cascadesimport/importlog.h b/src/plugins/qnx/cascadesimport/importlog.h deleted file mode 100644 index 69b7aa521e4..00000000000 --- a/src/plugins/qnx/cascadesimport/importlog.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H - -#include <QVariantList> - -namespace Qnx { -namespace Internal { - -class ImportLogEntry : public QVariantList -{ -public: - enum Severity {Undefined = 0, Debug, Info, Warning, Error}; - - ImportLogEntry() : QVariantList() {} - ImportLogEntry(int sev, const QString &msg, const QString &context = QString()); - ImportLogEntry(const QVariantList &l) : QVariantList(l) {} - - bool isValid() const {return (count() >= UnusedIx);} - Severity severity() const; - QString severityStr() const; - QChar severityAbbr() const; - QString message() const; - QString context() const; - QString toString() const; -private: - enum FieldIndexes {SeverityIx = 0, MessageIx, ContextIx, UnusedIx}; -}; - -class ImportLog : public QList<ImportLogEntry> ///< error list -{ -public: - QString toString() const; - - ImportLog& logError(const QString &msg, const QString &context = QString()); - ImportLog& logWarning(const QString &msg, const QString &context = QString()); - ImportLog& logInfo(const QString &msg, const QString &context = QString()); - ImportLog& logDebug(const QString &msg, const QString &context = QString()); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOG_H diff --git a/src/plugins/qnx/cascadesimport/importlogconverter.cpp b/src/plugins/qnx/cascadesimport/importlogconverter.cpp deleted file mode 100644 index 4a76181d2a6..00000000000 --- a/src/plugins/qnx/cascadesimport/importlogconverter.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "importlogconverter.h" - -#include <qnx/qnxconstants.h> - -#include <utils/qtcassert.h> -#include <coreplugin/generatedfile.h> - -#include <QDateTime> - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// ImportLogConverter -// -////////////////////////////////////////////////////////////////////////////// -ImportLogConverter::ImportLogConverter(ConvertedProjectContext &ctx) -: FileConverter(ctx) -{ -} - -bool ImportLogConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage) -{ - Q_UNUSED(errorMessage); - QString content; - content += QLatin1String("========================================================\n"); - content += tr("Generated by cascades importer ver: %1, %2") - .arg(QLatin1String(Qnx::Constants::QNX_BLACKBERRY_CASCADESIMPORTER_VERSION)) - .arg(QDateTime::currentDateTime().toString(Qt::ISODate)); - content += QLatin1String("\n========================================================\n\n"); - content += convertedProjectContext().importLog().toString(); - file.setContents(content); - file.setAttributes(file.attributes() | Core::GeneratedFile::OpenEditorAttribute); - return true; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/importlogconverter.h b/src/plugins/qnx/cascadesimport/importlogconverter.h deleted file mode 100644 index 3e2e7d228f8..00000000000 --- a/src/plugins/qnx/cascadesimport/importlogconverter.h +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H - -#include "fileconverter.h" - -namespace Qnx { -namespace Internal { - -class ImportLogConverter : public FileConverter -{ - Q_DECLARE_TR_FUNCTIONS(ImportLogConverter); -public: - ImportLogConverter(ConvertedProjectContext &ctx); - virtual ~ImportLogConverter() {} - - bool convertFile(Core::GeneratedFile &file, QString &errorMessage); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_IMPORTLOGCONVERTER_H diff --git a/src/plugins/qnx/cascadesimport/projectfileconverter.cpp b/src/plugins/qnx/cascadesimport/projectfileconverter.cpp deleted file mode 100644 index b0c0bef2397..00000000000 --- a/src/plugins/qnx/cascadesimport/projectfileconverter.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "projectfileconverter.h" - -#include <qnx/qnxconstants.h> - -#include <coreplugin/generatedfile.h> -#include <utils/qtcassert.h> - -#include <QDateTime> -#include <QSet> - -namespace Qnx { -namespace Internal { - -////////////////////////////////////////////////////////////////////////////// -// -// ProjectFileConverter -// -////////////////////////////////////////////////////////////////////////////// -ProjectFileConverter::ProjectFileConverter(ConvertedProjectContext &ctx) -: FileConverter(ctx) -{ -} - -static QMap<QString, QString> scanForDefinedVariables(const Core::GeneratedFile &file) -{ - QMap<QString, QString> ret; - QString origContent = file.contents(); - QStringList lines = origContent.split(QLatin1Char('\n'), QString::KeepEmptyParts); - QString line; - foreach (QString ln, lines) { - ln = ln.trimmed(); - if (ln.length() && (ln.at(0) == QLatin1Char('#'))) - continue; - if ((line.length() > 0) && (line.at(line.length() - 1) == QLatin1Char('\\'))) { - line = line.mid(line.length() - 1); - line += ln; - } else { - line = ln; - } - if ((line.length() > 0) && (line.at(line.length() - 1) != QLatin1Char('\\'))) { - int ix1 = line.indexOf(QLatin1Char('=')); - if (ix1 > 0) { - int ix2 = (line.at(ix1 - 1) == QLatin1Char('+'))? ix1 - 1: ix1; - QString k = line.mid(0, ix2).trimmed().toUpper(); - QString v = line.mid(ix1 + 1).trimmed(); - if (ix1 != ix2) - v = ret.value(k) + QLatin1Char(' ') + v; - ret[k] = v; - } - } - } - return ret; -} - -static QSet<QString> parseVariable(const QString &varStr) -{ - QStringList sl = varStr.split(QLatin1Char(' '), QString::SkipEmptyParts); - QSet<QString> ret = QSet<QString>::fromList(sl); - return ret; -} - -static QString updateVariable(const QString &varStr, const QString &varsToAdd, - const QString &varsToRemove) -{ - QSet<QString> var = parseVariable(varStr); - - QSet<QString> ss = parseVariable(varsToAdd); - foreach (const QString &s, ss) - var << s; - - ss = parseVariable(varsToRemove); - foreach (const QString &s, ss) - var.remove(s); - - QStringList sl = QStringList::fromSet(var); - return sl.join(QLatin1Char(' ')); -} - -bool ProjectFileConverter::convertFile(Core::GeneratedFile &file, QString &errorMessage) -{ - if (!FileConverter::convertFile(file, errorMessage)) - return false; - - ImportLog &log = convertedProjectContext().importLog(); - QMap<QString, QString> origProjectVariables = scanForDefinedVariables(file); - QString fileContent; - - QLatin1String path( ":/qnx/cascadesimport/resources/templates/project.pro"); - QByteArray ba = loadFileContent(path, errorMessage); - if (!errorMessage.isEmpty()) - return false; - fileContent = QString::fromUtf8(ba); - - QStringList headers; - QStringList sources; - QStringList resources; - QStringList otherFiles; - - foreach (const QString &filePath, convertedProjectContext().collectedFiles()) { - QString ext = filePath.section(QLatin1Char('.'), -1); - if (ext.compare(QLatin1String("c"), Qt::CaseInsensitive) == 0) - sources << filePath; - else if (ext.compare(QLatin1String("cc"), Qt::CaseInsensitive) == 0) - sources << filePath; - else if (ext.compare(QLatin1String("cpp"), Qt::CaseInsensitive) == 0) - sources << filePath; - else if (ext.compare(QLatin1String("h"), Qt::CaseInsensitive) == 0) - headers << filePath; - else if (ext.compare(QLatin1String("hh"), Qt::CaseInsensitive) == 0) - headers << filePath; - else if (ext.compare(QLatin1String("hpp"), Qt::CaseInsensitive) == 0) - headers << filePath; - else if (ext.compare(QLatin1String("qrc"), Qt::CaseInsensitive) == 0) - resources << filePath; - else if (ext.compare(QLatin1String("qml"), Qt::CaseInsensitive) == 0) - otherFiles << filePath; - else if (ext.compare(QLatin1String("js"), Qt::CaseInsensitive) == 0) - otherFiles << filePath; - else if (ext.compare(QLatin1String("ts"), Qt::CaseInsensitive) == 0) - otherFiles << filePath; - else if (ext.compare(QLatin1String("pro"), Qt::CaseInsensitive) == 0) - otherFiles << filePath; - else if (filePath.compare(QLatin1String("bar-descriptor.xml"), Qt::CaseInsensitive) == 0) - otherFiles << filePath; - else if (filePath.startsWith(QLatin1String("assets/"), Qt::CaseInsensitive)) - // include all the content of the assets directory - otherFiles << filePath; - else if (filePath.startsWith(QLatin1String("src/"), Qt::CaseInsensitive)) - // include all the content of the src directory - otherFiles << filePath; - else if (ext.compare(QLatin1String("log"), Qt::CaseInsensitive) != 0) - log.logWarning(tr("File \"%1\" not listed in \"%2\" file, should it be?") - .arg(filePath).arg(file.path())); - } - - fileContent.replace(QLatin1String("%HEADERS%"), headers.join(QLatin1String(" \\\n "))); - fileContent.replace(QLatin1String("%SOURCES%"), sources.join(QLatin1String(" \\\n "))); - fileContent.replace(QLatin1String("%RESOURCES%"), resources.join(QLatin1String(" \\\n "))); - fileContent.replace(QLatin1String("%DISTFILES%"), otherFiles.join(QLatin1String(" \\\n "))); - fileContent.replace(QLatin1String("%PROJECT_NAME%"), convertedProjectContext().projectName()); - fileContent.replace(QLatin1String("%TARGET%"), origProjectVariables.value(QLatin1String("TARGET"), - convertedProjectContext().projectName())); - fileContent.replace(QLatin1String("%EXTRA_LIBS%"), origProjectVariables.value(QLatin1String("LIBS"))); - fileContent.replace(QLatin1String("%IMPORTER_VERSION%"), - QLatin1String(Qnx::Constants::QNX_BLACKBERRY_CASCADESIMPORTER_VERSION)); - fileContent.replace(QLatin1String("%DATE_TIME%"), - QDateTime::currentDateTime().toString(Qt::ISODate)); - fileContent.replace(QLatin1String("%QT%"), - updateVariable(origProjectVariables.value(QLatin1String("QT")), - QLatin1String("declarative script svg sql network xml xmlpatterns"), - QString() - )); - fileContent.replace(QLatin1String("%CONFIG%"), - updateVariable(origProjectVariables.value(QLatin1String("CONFIG")), - QLatin1String("qt warn_on"), - QLatin1String("debug release debug_and_release cascades cascades10") - )); - fileContent.replace(QLatin1String("%MOBILITY%"), origProjectVariables.value(QLatin1String("MOBILITY"))); - file.setContents(fileContent); - file.setAttributes(file.attributes() | Core::GeneratedFile::OpenProjectAttribute); - return errorMessage.isEmpty(); -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/projectfileconverter.h b/src/plugins/qnx/cascadesimport/projectfileconverter.h deleted file mode 100644 index bc69fac78d1..00000000000 --- a/src/plugins/qnx/cascadesimport/projectfileconverter.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H - -#include "fileconverter.h" - -#include <QCoreApplication> - -#include <QMap> -#include <QString> - -namespace Qnx { -namespace Internal { - -class ProjectFileConverter : public FileConverter -{ - Q_DECLARE_TR_FUNCTIONS(ProjectFileConverter); -public: - ProjectFileConverter(ConvertedProjectContext &ctx); - virtual ~ProjectFileConverter() {} - - bool convertFile(Core::GeneratedFile &file, QString &errorMessage); -private: - QMap<QString, QString> definedVariables(const Core::GeneratedFile &file); -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_PROJECTFILECONVERTER_H diff --git a/src/plugins/qnx/cascadesimport/resources/templates/project.pro b/src/plugins/qnx/cascadesimport/resources/templates/project.pro deleted file mode 100644 index 39960ad38e8..00000000000 --- a/src/plugins/qnx/cascadesimport/resources/templates/project.pro +++ /dev/null @@ -1,46 +0,0 @@ -#======================================================================================== -# generated by CascadesProjectImporter ver. %IMPORTER_VERSION% - %DATE_TIME% -#======================================================================================== - -TEMPLATE = app -TARGET = %TARGET% - -CONFIG += %CONFIG% - -# For cascades integration, some additional libraries are needed -# and the library path needs to be set -LIBS += -lbb -lbbcascades -LIBS += %EXTRA_LIBS% - -QT -= gui -QT += %QT% - -MOBILITY += %MOBILITY% - -QMAKE_CFLAGS += -Wno-psabi -QMAKE_CXXFLAGS += -Wno-psabi - -CONFIG(release, debug|release) { - zygotize { - TEMPLATE = lib - QMAKE_CFLAGS += -fstack-protector-strong -fvisibility=hidden -mthumb -Os - QMAKE_CXXFLAGS += -fstack-protector-strong -fvisibility=hidden -mthumb -Os - QMAKE_LFLAGS += -Wl,-z,relro - DEFINES += _FORTIFY_SOURCE=2 - } -} - -INCLUDEPATH += src - -HEADERS += \ - %HEADERS% - -SOURCES += \ - %SOURCES% - -RESOURCES += \ - %RESOURCES% - -DISTFILES += \ - bar-descriptor.xml \ - %DISTFILES% diff --git a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp deleted file mode 100644 index 529a58d8935..00000000000 --- a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "srcprojectpathchooser.h" - -#include <QDirIterator> - -namespace Qnx { -namespace Internal { - -SrcProjectPathChooser::SrcProjectPathChooser(QWidget *parent) : - Utils::PathChooser(parent) -{ - setPromptDialogTitle(tr("Choose imported Cascades project directory")); - setExpectedKind(Utils::PathChooser::ExistingDirectory); -} - -SrcProjectPathChooser::~SrcProjectPathChooser() -{ -} - -bool SrcProjectPathChooser::validatePath(const QString &path, QString *errorMessage) -{ - if (!Utils::PathChooser::validatePath(path, errorMessage)) - return false; - - bool proFound = false; - bool barDescriptorFound = false; - QDirIterator di(path); - while (di.hasNext()) { - di.next(); - QFileInfo fi = di.fileInfo(); - if (fi.isFile()) { - if (fi.fileName() == QLatin1String("bar-descriptor.xml")) - barDescriptorFound = true; - else if (fi.fileName().endsWith(QLatin1String(".pro"))) - proFound = true; - } - if (barDescriptorFound && proFound) - break; - } - const bool ret = barDescriptorFound && proFound; - if (!ret && errorMessage) - *errorMessage = tr("Directory does not seem to be a valid Cascades project."); - return ret; -} - - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h b/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h deleted file mode 100644 index d2b781794f6..00000000000 --- a/src/plugins/qnx/cascadesimport/srcprojectpathchooser.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef SRCPROJECTPATHCHOOSER_H -#define SRCPROJECTPATHCHOOSER_H - -#include <utils/pathchooser.h> - -namespace Qnx { -namespace Internal { - -class SrcProjectPathChooser : public Utils::PathChooser -{ - Q_OBJECT -public: - explicit SrcProjectPathChooser(QWidget *parent = 0); - virtual ~SrcProjectPathChooser(); - - virtual bool validatePath(const QString &path, QString *errorMessage = 0); -}; - -} // namespace Internal -} // namespace Qnx - - -#endif // SRCPROJECTPATHCHOOSER_H diff --git a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.cpp b/src/plugins/qnx/cascadesimport/srcprojectwizardpage.cpp deleted file mode 100644 index 57636cce79a..00000000000 --- a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "srcprojectwizardpage.h" -#include "ui_srcprojectwizardpage.h" - -#include <utils/wizard.h> - -#include <QDir> - -namespace Qnx { -namespace Internal { - -SrcProjectWizardPage::SrcProjectWizardPage(QWidget *parent) - : QWizardPage(parent), m_complete(false) -{ - ui = new Ui::SrcProjectWizardPage; - ui->setupUi(this); - - connect(ui->pathChooser, SIGNAL(pathChanged(QString)), this, SLOT(onPathChooserPathChanged(QString))); - - setPath(QDir::homePath()); - - setProperty(Utils::SHORT_TITLE_PROPERTY, tr("Momentics")); -} - -SrcProjectWizardPage::~SrcProjectWizardPage() -{ - delete ui; -} - -void SrcProjectWizardPage::onPathChooserPathChanged(const QString &newPath) -{ - bool newComplete = ui->pathChooser->isValid(); - if (newComplete != m_complete) { - m_complete = newComplete; - emit completeChanged(); - } - if (newComplete) emit validPathChanged(newPath); -} - -QString SrcProjectWizardPage::projectName() const -{ - return path().section(QLatin1Char('/'), -1); -} - -QString SrcProjectWizardPage::path() const -{ - return Utils::FileName::fromUserInput(ui->pathChooser->path()).toString(); -} - -void SrcProjectWizardPage::setPath(const QString &path) -{ - ui->pathChooser->setPath(path); -} - -bool SrcProjectWizardPage::isComplete() const -{ - return m_complete; -} - -} // namespace Internal -} // namespace Qnx diff --git a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.h b/src/plugins/qnx/cascadesimport/srcprojectwizardpage.h deleted file mode 100644 index eb08e00b1ff..00000000000 --- a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** Contact: BlackBerry Limited (blackberry-qt@qnx.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H -#define QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H - -#include <QWizardPage> - -namespace Qnx { -namespace Internal { - -namespace Ui { class SrcProjectWizardPage; } - -class SrcProjectWizardPage : public QWizardPage -{ - Q_OBJECT -public: - explicit SrcProjectWizardPage(QWidget *parent = 0); - virtual ~SrcProjectWizardPage(); - - QString projectName() const; - QString path() const; - void setPath(const QString &path); - - bool isComplete() const; -signals: - void validPathChanged(const QString &path); -private slots: - void onPathChooserPathChanged(const QString &newPath); -private: - Ui::SrcProjectWizardPage *ui; - bool m_complete; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_BLACKBERRY_CASCADESPROJECTIMPORT_SRCPROJECTWIZARDPAGE_H diff --git a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui b/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui deleted file mode 100644 index e29f3d6fae2..00000000000 --- a/src/plugins/qnx/cascadesimport/srcprojectwizardpage.ui +++ /dev/null @@ -1,42 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::SrcProjectWizardPage</class> - <widget class="QWizardPage" name="Qnx::Internal::SrcProjectWizardPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>520</width> - <height>147</height> - </rect> - </property> - <property name="title"> - <string>Choose the Location</string> - </property> - <layout class="QFormLayout" name="formLayout"> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::ExpandingFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="text"> - <string>Project path:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Qnx::Internal::SrcProjectPathChooser" name="pathChooser" native="true"/> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Qnx::Internal::SrcProjectPathChooser</class> - <extends>QWidget</extends> - <header location="global">qnx/cascadesimport/srcprojectpathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/images/ok.png b/src/plugins/qnx/images/ok.png Binary files differdeleted file mode 100644 index e5d13cd47c0..00000000000 --- a/src/plugins/qnx/images/ok.png +++ /dev/null diff --git a/src/plugins/qnx/images/target-small.png b/src/plugins/qnx/images/target-small.png Binary files differdeleted file mode 100644 index c8ead87cdf9..00000000000 --- a/src/plugins/qnx/images/target-small.png +++ /dev/null diff --git a/src/plugins/qnx/images/target.png b/src/plugins/qnx/images/target.png Binary files differdeleted file mode 100644 index 5260eb64d91..00000000000 --- a/src/plugins/qnx/images/target.png +++ /dev/null diff --git a/src/plugins/qnx/qnx.pro b/src/plugins/qnx/qnx.pro index 94b7092b6cf..0e4cb42a580 100644 --- a/src/plugins/qnx/qnx.pro +++ b/src/plugins/qnx/qnx.pro @@ -3,30 +3,8 @@ QT += network xml include(../../qtcreatorplugin.pri) SOURCES += qnxplugin.cpp \ - blackberryqtversionfactory.cpp \ - blackberryqtversion.cpp \ qnxbaseqtconfigwidget.cpp \ - blackberrydeployconfigurationfactory.cpp \ - blackberrydeployconfiguration.cpp \ - blackberrycreatepackagestep.cpp \ - blackberrycreatepackagestepconfigwidget.cpp \ - blackberrycreatepackagestepfactory.cpp \ - blackberrydeploystep.cpp \ - blackberrydeployconfigurationwidget.cpp \ - blackberrydeploystepconfigwidget.cpp \ - blackberrydeviceconfigurationfactory.cpp \ - blackberrydeviceconfigurationwizard.cpp \ - blackberrydeviceconfigurationwizardpages.cpp \ - blackberrydeploystepfactory.cpp \ - blackberryrunconfiguration.cpp \ - blackberryrunconfigurationwidget.cpp \ - blackberryrunconfigurationfactory.cpp \ - blackberryruncontrolfactory.cpp \ - blackberryruncontrol.cpp \ - blackberrydebugsupport.cpp \ - blackberryapplicationrunner.cpp \ qnxutils.cpp \ - blackberrydeviceconfigurationwidget.cpp \ qnxdeviceconfigurationfactory.cpp \ qnxdeviceconfigurationwizard.cpp \ qnxdeviceconfigurationwizardpages.cpp \ @@ -41,70 +19,17 @@ SOURCES += qnxplugin.cpp \ qnxruncontrol.cpp \ qnxqtversionfactory.cpp \ qnxqtversion.cpp \ - qnxabstractqtversion.cpp \ - blackberrydeviceconfiguration.cpp \ qnxdeployconfiguration.cpp \ qnxdeviceconfiguration.cpp \ - blackberrydeployinformation.cpp \ pathchooserdelegate.cpp \ - blackberryabstractdeploystep.cpp \ - blackberryndksettingswidget.cpp \ - blackberryndksettingspage.cpp \ - bardescriptoreditorfactory.cpp \ - bardescriptoreditor.cpp \ - bardescriptoreditorwidget.cpp \ - bardescriptordocument.cpp \ - bardescriptorpermissionsmodel.cpp \ - blackberrykeyswidget.cpp \ - blackberrykeyspage.cpp \ - blackberrycertificate.cpp \ - blackberryimportcertificatedialog.cpp \ - blackberrycreatecertificatedialog.cpp \ - blackberrydebugtokenrequester.cpp \ - blackberrydebugtokenrequestdialog.cpp \ - blackberrydebugtokenuploader.cpp \ - blackberrydebugtokenreader.cpp \ - blackberryndkprocess.cpp \ - blackberrydeviceconnection.cpp \ - blackberrydeviceconnectionmanager.cpp \ - blackberrydeviceinformation.cpp \ - blackberrysshkeysgenerator.cpp \ - blackberryprocessparser.cpp \ - blackberrysigningpasswordsdialog.cpp \ - bardescriptoreditorpackageinformationwidget.cpp \ - bardescriptoreditorauthorinformationwidget.cpp \ - bardescriptoreditorentrypointwidget.cpp \ - bardescriptoreditorgeneralwidget.cpp \ - bardescriptoreditorpermissionswidget.cpp \ - bardescriptoreditorenvironmentwidget.cpp \ - bardescriptoreditorassetswidget.cpp \ - bardescriptoreditorabstractpanelwidget.cpp \ - blackberrysigningutils.cpp \ qnxdevicetester.cpp \ - blackberryconfigurationmanager.cpp \ - blackberrydevicelistdetector.cpp \ - blackberrylogprocessrunner.cpp \ - blackberryinstallwizardpages.cpp \ - blackberryinstallwizard.cpp \ qnxdeviceprocesssignaloperation.cpp \ qnxdeviceprocesslist.cpp \ qnxtoolchain.cpp \ slog2inforunner.cpp \ - blackberrydebugtokenpinsdialog.cpp \ - blackberrycheckdevicestatusstepfactory.cpp \ - blackberrycheckdevicestatusstepconfigwidget.cpp \ - blackberrycheckdevicestatusstep.cpp \ qnxattachdebugsupport.cpp \ qnxattachdebugdialog.cpp \ - blackberrysetuppage.cpp \ - blackberrysetupwidget.cpp \ - blackberryruntimeconfiguration.cpp \ - blackberryapilevelconfiguration.cpp \ - blackberrypotentialkit.cpp \ - bardescriptorfilenode.cpp \ - bardescriptorfilenodemanager.cpp \ qnxconfiguration.cpp \ - qnxbaseconfiguration.cpp \ qnxsettingswidget.cpp \ qnxconfigurationmanager.cpp \ qnxsettingspage.cpp \ @@ -113,30 +38,8 @@ SOURCES += qnxplugin.cpp \ HEADERS += qnxplugin.h\ qnxconstants.h \ - blackberryqtversionfactory.h \ - blackberryqtversion.h \ qnxbaseqtconfigwidget.h \ - blackberrydeployconfigurationfactory.h \ - blackberrydeployconfiguration.h \ - blackberrycreatepackagestep.h \ - blackberrycreatepackagestepconfigwidget.h \ - blackberrycreatepackagestepfactory.h \ - blackberrydeploystep.h \ - blackberrydeployconfigurationwidget.h \ - blackberrydeploystepconfigwidget.h \ - blackberrydeviceconfigurationfactory.h \ - blackberrydeviceconfigurationwizard.h \ - blackberrydeviceconfigurationwizardpages.h \ - blackberrydeploystepfactory.h \ - blackberryrunconfiguration.h \ - blackberryrunconfigurationwidget.h \ - blackberryrunconfigurationfactory.h \ - blackberryruncontrolfactory.h \ - blackberryruncontrol.h \ - blackberrydebugsupport.h \ - blackberryapplicationrunner.h \ qnxutils.h \ - blackberrydeviceconfigurationwidget.h \ qnxdeviceconfigurationfactory.h \ qnxdeviceconfigurationwizard.h \ qnxdeviceconfigurationwizardpages.h \ @@ -151,70 +54,17 @@ HEADERS += qnxplugin.h\ qnxruncontrol.h \ qnxqtversionfactory.h \ qnxqtversion.h \ - qnxabstractqtversion.h \ - blackberrydeviceconfiguration.h \ qnxdeployconfiguration.h \ qnxdeviceconfiguration.h \ - blackberrydeployinformation.h \ pathchooserdelegate.h \ - blackberryabstractdeploystep.h \ - blackberryndksettingswidget.h \ - blackberryndksettingspage.h \ - bardescriptoreditorfactory.h \ - bardescriptoreditor.h \ - bardescriptoreditorwidget.h \ - bardescriptordocument.h \ - bardescriptorpermissionsmodel.h \ - blackberrykeyswidget.h \ - blackberrykeyspage.h \ - blackberrycertificate.h \ - blackberryimportcertificatedialog.h \ - blackberrycreatecertificatedialog.h \ - blackberrydebugtokenrequester.h \ - blackberrydebugtokenrequestdialog.h \ - blackberrydebugtokenuploader.h \ - blackberrydebugtokenreader.h \ - blackberryndkprocess.h \ - blackberrydeviceconnection.h \ - blackberrydeviceconnectionmanager.h \ - blackberrydeviceinformation.h \ - blackberrysshkeysgenerator.h \ - blackberryprocessparser.h \ - blackberrysigningpasswordsdialog.h \ - bardescriptoreditorpackageinformationwidget.h \ - bardescriptoreditorauthorinformationwidget.h \ - bardescriptoreditorentrypointwidget.h \ - bardescriptoreditorgeneralwidget.h \ - bardescriptoreditorpermissionswidget.h \ - bardescriptoreditorenvironmentwidget.h \ - bardescriptoreditorassetswidget.h \ - bardescriptoreditorabstractpanelwidget.h \ - blackberrysigningutils.h \ qnxdevicetester.h \ - blackberryconfigurationmanager.h \ - blackberrydevicelistdetector.h \ - blackberrylogprocessrunner.h \ - blackberryinstallwizardpages.h \ - blackberryinstallwizard.h \ qnxdeviceprocesssignaloperation.h \ qnxdeviceprocesslist.h \ qnxtoolchain.h \ slog2inforunner.h \ - blackberrydebugtokenpinsdialog.h \ - blackberrycheckdevicestatusstep.h \ - blackberrycheckdevicestatusstepfactory.h \ - blackberrycheckdevicestatusstepconfigwidget.h \ qnxattachdebugsupport.h \ qnxattachdebugdialog.h \ - blackberrysetuppage.h \ - blackberrysetupwidget.h \ - blackberryruntimeconfiguration.h \ - blackberryapilevelconfiguration.h \ - blackberrypotentialkit.h \ - bardescriptorfilenode.h \ - bardescriptorfilenodemanager.h \ qnxconfiguration.h \ - qnxbaseconfiguration.h \ qnxsettingswidget.h \ qnxconfigurationmanager.h \ qnxsettingspage.h \ @@ -222,38 +72,9 @@ HEADERS += qnxplugin.h\ qnxdeployqtlibrariesdialog.h FORMS += \ - blackberrydeviceconfigurationwizardsetuppage.ui \ - blackberryrunconfigurationwidget.ui \ - blackberrydeployconfigurationwidget.ui \ - blackberrydeviceconfigurationwidget.ui \ - qnxbaseqtconfigwidget.ui \ - blackberryndksettingswidget.ui \ - blackberrykeyswidget.ui \ - blackberryimportcertificatedialog.ui \ - blackberrycreatecertificatedialog.ui \ - blackberrydebugtokenrequestdialog.ui \ - blackberrycreatepackagestepconfigwidget.ui \ - blackberrysigningpasswordsdialog.ui \ - bardescriptoreditorpackageinformationwidget.ui \ - bardescriptoreditorauthorinformationwidget.ui \ - bardescriptoreditorentrypointwidget.ui \ - bardescriptoreditorgeneralwidget.ui \ - bardescriptoreditorpermissionswidget.ui \ - bardescriptoreditorenvironmentwidget.ui \ - bardescriptoreditorassetswidget.ui \ - blackberrydeviceconfigurationwizardconfigpage.ui \ - blackberrydeviceconfigurationwizardquerypage.ui \ - blackberryinstallwizardtargetpage.ui \ - blackberryinstallwizardndkpage.ui \ - blackberryinstallwizardprocesspage.ui \ - blackberryinstallwizardoptionpage.ui \ - blackberrydebugtokenpinsdialog.ui \ - blackberrycheckdevicestatusstepconfigwidget.ui \ qnxsettingswidget.ui \ qnxdeployqtlibrariesdialog.ui -include(./cascadesimport/cascadesimport.pri) - QT += gui-private DEFINES += QNX_ZIP_FILE_SUPPORT diff --git a/src/plugins/qnx/qnx.qbs b/src/plugins/qnx/qnx.qbs index 5dd0558617e..3e3791166d1 100644 --- a/src/plugins/qnx/qnx.qbs +++ b/src/plugins/qnx/qnx.qbs @@ -15,200 +15,22 @@ QtcPlugin { Depends { name: "QtSupport" } Depends { name: "QmakeProjectManager" } Depends { name: "RemoteLinux" } - Depends { name: "TextEditor" } files: [ - "bardescriptordocument.cpp", - "bardescriptordocument.h", - "bardescriptoreditor.cpp", - "bardescriptoreditor.h", - "bardescriptoreditorabstractpanelwidget.cpp", - "bardescriptoreditorabstractpanelwidget.h", - "bardescriptoreditorassetswidget.cpp", - "bardescriptoreditorassetswidget.h", - "bardescriptoreditorassetswidget.ui", - "bardescriptoreditorauthorinformationwidget.cpp", - "bardescriptoreditorauthorinformationwidget.h", - "bardescriptoreditorauthorinformationwidget.ui", - "bardescriptoreditorentrypointwidget.cpp", - "bardescriptoreditorentrypointwidget.h", - "bardescriptoreditorentrypointwidget.ui", - "bardescriptoreditorenvironmentwidget.cpp", - "bardescriptoreditorenvironmentwidget.h", - "bardescriptoreditorenvironmentwidget.ui", - "bardescriptoreditorfactory.cpp", - "bardescriptoreditorfactory.h", - "bardescriptoreditorgeneralwidget.cpp", - "bardescriptoreditorgeneralwidget.h", - "bardescriptoreditorgeneralwidget.ui", - "bardescriptoreditorpackageinformationwidget.cpp", - "bardescriptoreditorpackageinformationwidget.h", - "bardescriptoreditorpackageinformationwidget.ui", - "bardescriptoreditorpermissionswidget.cpp", - "bardescriptoreditorpermissionswidget.h", - "bardescriptoreditorpermissionswidget.ui", - "bardescriptoreditorwidget.cpp", - "bardescriptoreditorwidget.h", - "bardescriptorfilenode.cpp", - "bardescriptorfilenode.h", - "bardescriptorfilenodemanager.cpp", - "bardescriptorfilenodemanager.h", - "bardescriptorpermissionsmodel.cpp", - "bardescriptorpermissionsmodel.h", - "blackberryabstractdeploystep.cpp", - "blackberryabstractdeploystep.h", - "blackberryapplicationrunner.cpp", - "blackberryapplicationrunner.h", - "blackberrycheckdevicestatusstep.cpp", - "blackberrycheckdevicestatusstep.h", - "blackberrycheckdevicestatusstepconfigwidget.cpp", - "blackberrycheckdevicestatusstepconfigwidget.h", - "blackberrycheckdevicestatusstepconfigwidget.ui", - "blackberrycheckdevicestatusstepfactory.cpp", - "blackberrycheckdevicestatusstepfactory.h", - "blackberryconfigurationmanager.cpp", - "blackberryconfigurationmanager.h", - "blackberrycreatepackagestep.cpp", - "blackberrycreatepackagestep.h", - "blackberrycreatepackagestepconfigwidget.cpp", - "blackberrycreatepackagestepconfigwidget.h", - "blackberrycreatepackagestepconfigwidget.ui", - "blackberrycreatepackagestepfactory.cpp", - "blackberrycreatepackagestepfactory.h", - "blackberrydebugsupport.cpp", - "blackberrydebugsupport.h", - "blackberrydeployconfiguration.cpp", - "blackberrydeployconfiguration.h", - "blackberrydeployconfigurationfactory.cpp", - "blackberrydeployconfigurationfactory.h", - "blackberrydeployconfigurationwidget.cpp", - "blackberrydeployconfigurationwidget.h", - "blackberrydeployconfigurationwidget.ui", - "blackberrydeployinformation.cpp", - "blackberrydeployinformation.h", "qnxdeployqtlibrariesdialog.cpp", "qnxdeployqtlibrariesdialog.h", "qnxdeployqtlibrariesdialog.ui", - "blackberrydeploystep.cpp", - "blackberrydeploystep.h", - "blackberrydeploystepconfigwidget.cpp", - "blackberrydeploystepconfigwidget.h", - "blackberrydeploystepfactory.cpp", - "blackberrydeploystepfactory.h", - "blackberrydebugtokenreader.cpp", - "blackberrydebugtokenreader.h", - "blackberrydeviceconfiguration.cpp", - "blackberrydeviceconfiguration.h", - "blackberrydeviceinformation.cpp", - "blackberrydeviceinformation.h", - "blackberrydeviceconfigurationfactory.cpp", - "blackberrydeviceconfigurationfactory.h", - "blackberrydeviceconfigurationwidget.cpp", - "blackberrydeviceconfigurationwidget.h", - "blackberrydeviceconfigurationwidget.ui", - "blackberrydeviceconfigurationwizard.cpp", - "blackberrydeviceconfigurationwizard.h", - "blackberrydeviceconfigurationwizardconfigpage.ui", - "blackberrydeviceconfigurationwizardpages.cpp", - "blackberrydeviceconfigurationwizardpages.h", - "blackberrydeviceconfigurationwizardquerypage.ui", - "blackberrydeviceconfigurationwizardsetuppage.ui", - "blackberrydeviceconnection.cpp", - "blackberrydeviceconnection.h", - "blackberrydeviceconnectionmanager.cpp", - "blackberrydeviceconnectionmanager.h", - "blackberrydevicelistdetector.cpp", - "blackberrydevicelistdetector.h", - "blackberryinstallwizard.cpp", - "blackberryinstallwizard.h", - "blackberryinstallwizardndkpage.ui", - "blackberryinstallwizardoptionpage.ui", - "blackberryinstallwizardpages.cpp", - "blackberryinstallwizardpages.h", - "blackberryinstallwizardprocesspage.ui", - "blackberryinstallwizardtargetpage.ui", - "blackberrylogprocessrunner.cpp", - "blackberrylogprocessrunner.h", - "blackberryqtversion.cpp", - "blackberryqtversion.h", - "blackberryqtversionfactory.cpp", - "blackberryqtversionfactory.h", - "blackberrypotentialkit.cpp", - "blackberrypotentialkit.h", - "blackberryprocessparser.cpp", - "blackberryprocessparser.h", - "blackberryrunconfiguration.cpp", - "blackberryrunconfiguration.h", - "blackberryrunconfigurationfactory.cpp", - "blackberryrunconfigurationfactory.h", - "blackberryrunconfigurationwidget.cpp", - "blackberryrunconfigurationwidget.h", - "blackberryrunconfigurationwidget.ui", - "blackberryruncontrol.cpp", - "blackberryruncontrol.h", - "blackberryruncontrolfactory.cpp", - "blackberryruncontrolfactory.h", - "blackberrysetuppage.cpp", - "blackberrysetuppage.h", - "blackberrysetupwidget.cpp", - "blackberrysetupwidget.h", - "blackberrysigningpasswordsdialog.h", - "blackberrysigningpasswordsdialog.cpp", - "blackberrysigningpasswordsdialog.ui", - "blackberryndksettingswidget.cpp", - "blackberryndksettingswidget.h", - "blackberryndksettingswidget.ui", - "blackberryndksettingspage.cpp", - "blackberryndksettingspage.h", - "blackberryapilevelconfiguration.cpp", - "blackberryapilevelconfiguration.h", - "blackberryruntimeconfiguration.cpp", - "blackberryruntimeconfiguration.h", - "blackberrycertificate.cpp", - "blackberrycertificate.h", - "blackberrykeyspage.cpp", - "blackberrykeyspage.h", - "blackberrykeyswidget.cpp", - "blackberrykeyswidget.h", - "blackberrykeyswidget.ui", - "blackberryimportcertificatedialog.cpp", - "blackberryimportcertificatedialog.h", - "blackberryimportcertificatedialog.ui", - "blackberrycreatecertificatedialog.cpp", - "blackberrycreatecertificatedialog.h", - "blackberrycreatecertificatedialog.ui", - "blackberrydebugtokenpinsdialog.cpp", - "blackberrydebugtokenpinsdialog.h", - "blackberrydebugtokenpinsdialog.ui", - "blackberrydebugtokenrequester.cpp", - "blackberrydebugtokenrequester.h", - "blackberrydebugtokenrequestdialog.cpp", - "blackberrydebugtokenrequestdialog.h", - "blackberrydebugtokenrequestdialog.ui", - "blackberrydebugtokenuploader.cpp", - "blackberrydebugtokenuploader.h", - "blackberryndkprocess.cpp", - "blackberryndkprocess.h", - "blackberrysshkeysgenerator.cpp", - "blackberrysshkeysgenerator.h", - "blackberrysigningutils.cpp", - "blackberrysigningutils.h", "pathchooserdelegate.cpp", "pathchooserdelegate.h", "qnxtoolchain.cpp", "qnxtoolchain.h", "qnx.qrc", - "qnxabstractqtversion.cpp", - "qnxabstractqtversion.h", "qnxattachdebugsupport.cpp", "qnxattachdebugsupport.h", "qnxattachdebugdialog.cpp", "qnxattachdebugdialog.h", - "qnxbaseconfiguration.cpp", - "qnxbaseconfiguration.h", "qnxbaseqtconfigwidget.cpp", "qnxbaseqtconfigwidget.h", - "qnxbaseqtconfigwidget.ui", "qnxconstants.h", "qnxconfiguration.cpp", "qnxconfiguration.h", @@ -265,36 +87,5 @@ QtcPlugin { "qnxutils.h", "slog2inforunner.cpp", "slog2inforunner.h", - "images/target-small.png", - "images/target.png", ] - - Group { - name: "CascadesImport" - prefix: "cascadesimport/" - files: [ - "cascadesimport.qrc", - - "srcprojectwizardpage.ui", - - "cascadesimportwizard.cpp", - "srcprojectwizardpage.cpp", - "srcprojectpathchooser.cpp", - "fileconverter.cpp", - "bardescriptorconverter.cpp", - "projectfileconverter.cpp", - "importlogconverter.cpp", - "importlog.cpp", - - "cascadesimportwizard.h", - "srcprojectwizardpage.h", - "srcprojectpathchooser.h", - "fileconverter.h", - "bardescriptorconverter.h", - "projectfileconverter.h", - "importlogconverter.h", - "importlog.h", - ] - } - } diff --git a/src/plugins/qnx/qnx.qrc b/src/plugins/qnx/qnx.qrc index 4f87659716d..97a16398cc7 100644 --- a/src/plugins/qnx/qnx.qrc +++ b/src/plugins/qnx/qnx.qrc @@ -1,9 +1,5 @@ <RCC> <qresource prefix="/qnx"> - <file>images/target-small.png</file> - <file>images/target.png</file> - <file>images/ok.png</file> <file>images/qnx-target.png</file> - <file>Qnx.mimetypes.xml</file> </qresource> </RCC> diff --git a/src/plugins/qnx/qnx_dependencies.pri b/src/plugins/qnx/qnx_dependencies.pri index 7bc06be9c01..8e94a8dc69d 100644 --- a/src/plugins/qnx/qnx_dependencies.pri +++ b/src/plugins/qnx/qnx_dependencies.pri @@ -11,5 +11,4 @@ QTC_PLUGIN_DEPENDS += \ projectexplorer \ qmakeprojectmanager \ qtsupport \ - remotelinux \ - texteditor + remotelinux diff --git a/src/plugins/qnx/qnxabstractqtversion.cpp b/src/plugins/qnx/qnxabstractqtversion.cpp deleted file mode 100644 index 2134cf24d78..00000000000 --- a/src/plugins/qnx/qnxabstractqtversion.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qnxabstractqtversion.h" -#include "qnxbaseqtconfigwidget.h" - -#include "qnxutils.h" - -#include <utils/environment.h> -#include <utils/hostosinfo.h> - -#include <QDir> - -using namespace Qnx; -using namespace Qnx::Internal; - -QnxAbstractQtVersion::QnxAbstractQtVersion() - : QtSupport::BaseQtVersion() - , m_arch(UnknownArch) -{ -} - -QnxAbstractQtVersion::QnxAbstractQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource) - : QtSupport::BaseQtVersion(path, isAutoDetected, autoDetectionSource) - , m_arch(arch) -{ -} - -QnxArchitecture QnxAbstractQtVersion::architecture() const -{ - return m_arch; -} - -QString QnxAbstractQtVersion::archString() const -{ - switch (m_arch) { - case X86: - return QLatin1String("x86"); - case ArmLeV7: - return QLatin1String("ARMle-v7"); - case UnknownArch: - return QString(); - } - return QString(); -} - -QVariantMap QnxAbstractQtVersion::toMap() const -{ - QVariantMap result = BaseQtVersion::toMap(); - result.insert(QLatin1String("SDKPath"), sdkPath()); - result.insert(QLatin1String("Arch"), m_arch); - return result; -} - -void QnxAbstractQtVersion::fromMap(const QVariantMap &map) -{ - BaseQtVersion::fromMap(map); - setSdkPath(QDir::fromNativeSeparators(map.value(QLatin1String("SDKPath")).toString())); - m_arch = static_cast<QnxArchitecture>(map.value(QLatin1String("Arch"), UnknownArch).toInt()); -} - -QList<ProjectExplorer::Abi> QnxAbstractQtVersion::detectQtAbis() const -{ - ensureMkSpecParsed(); - return qtAbisFromLibrary(qtCorePaths(versionInfo(), qtVersionString())); -} - -void QnxAbstractQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const -{ - QtSupport::BaseQtVersion::addToEnvironment(k, env); - updateEnvironment(); - env.modify(m_qnxEnv); - - env.prependOrSetLibrarySearchPath(versionInfo().value(QLatin1String("QT_INSTALL_LIBS"))); -} - -Utils::Environment QnxAbstractQtVersion::qmakeRunEnvironment() const -{ - if (!sdkPath().isEmpty()) - updateEnvironment(); - - Utils::Environment env = Utils::Environment::systemEnvironment(); - env.modify(m_qnxEnv); - - return env; -} - -QString QnxAbstractQtVersion::sdkPath() const -{ - return m_sdkPath; -} - -void QnxAbstractQtVersion::setSdkPath(const QString &sdkPath) -{ - if (m_sdkPath == sdkPath) - return; - - m_sdkPath = sdkPath; - m_environmentUpToDate = false; -} - -void QnxAbstractQtVersion::updateEnvironment() const -{ - if (!m_environmentUpToDate) { - m_qnxEnv = environment(); - m_environmentUpToDate = true; - } -} - -QString QnxAbstractQtVersion::qnxHost() const -{ - if (!m_environmentUpToDate) - updateEnvironment(); - - foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { - if (item.name == QLatin1String(Constants::QNX_HOST_KEY)) - return item.value; - } - - return QString(); -} - -QString QnxAbstractQtVersion::qnxTarget() const -{ - if (!m_environmentUpToDate) - updateEnvironment(); - - foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { - if (item.name == QLatin1String(Constants::QNX_TARGET_KEY)) - return item.value; - } - - return QString(); -} - -QtSupport::QtConfigWidget *QnxAbstractQtVersion::createConfigurationWidget() const -{ - return new QnxBaseQtConfigWidget(const_cast<QnxAbstractQtVersion *>(this)); -} - -bool QnxAbstractQtVersion::isValid() const -{ - return QtSupport::BaseQtVersion::isValid() && !sdkPath().isEmpty(); -} - -QString QnxAbstractQtVersion::invalidReason() const -{ - if (sdkPath().isEmpty()) - return tr("No SDK path set"); - return QtSupport::BaseQtVersion::invalidReason(); -} - diff --git a/src/plugins/qnx/qnxabstractqtversion.h b/src/plugins/qnx/qnxabstractqtversion.h deleted file mode 100644 index 21d66af323d..00000000000 --- a/src/plugins/qnx/qnxabstractqtversion.h +++ /dev/null @@ -1,96 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2012 - 2014 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** Contact: KDAB (info@kdab.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNX_INTERNAL_QNXABSTRACTQTVERSION_H -#define QNX_INTERNAL_QNXABSTRACTQTVERSION_H - -#include "qnxconstants.h" - -#include <qtsupport/baseqtversion.h> - -#include <utils/environment.h> - -#include <QCoreApplication> - -namespace Qnx { -namespace Internal { - -class QnxAbstractQtVersion : public QtSupport::BaseQtVersion -{ - friend class QnxBaseQtConfigWidget; - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxAbstractQtVersion) -public: - QnxAbstractQtVersion(); - QnxAbstractQtVersion(QnxArchitecture arch, const Utils::FileName &path, - bool isAutoDetected = false, - const QString &autoDetectionSource = QString()); - - QString qnxHost() const; - QString qnxTarget() const; - - QnxArchitecture architecture() const; - QString archString() const; - - QVariantMap toMap() const; - void fromMap(const QVariantMap &map); - - QList<ProjectExplorer::Abi> detectQtAbis() const; - - void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const; - Utils::Environment qmakeRunEnvironment() const; - - QtSupport::QtConfigWidget *createConfigurationWidget() const; - - bool isValid() const; - QString invalidReason() const; - - virtual QString sdkDescription() const = 0; - -protected: - QString sdkPath() const; - void setSdkPath(const QString &sdkPath); - -private: - void updateEnvironment() const; - virtual QList<Utils::EnvironmentItem> environment() const = 0; - - QnxArchitecture m_arch; - QString m_sdkPath; - - mutable bool m_environmentUpToDate; - mutable QList<Utils::EnvironmentItem> m_qnxEnv; -}; - -} // namespace Internal -} // namespace Qnx - -#endif // QNX_INTERNAL_QNXABSTRACTQTVERSION_H diff --git a/src/plugins/qnx/qnxbaseconfiguration.cpp b/src/plugins/qnx/qnxbaseconfiguration.cpp deleted file mode 100644 index f98a7eb5b74..00000000000 --- a/src/plugins/qnx/qnxbaseconfiguration.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "qnxbaseconfiguration.h" -#include "qnxutils.h" -#include "qnxtoolchain.h" - -#include <projectexplorer/toolchain.h> -#include <projectexplorer/toolchainmanager.h> - -#include <debugger/debuggerkitinformation.h> -#include <debugger/debuggeritem.h> - -#include <coreplugin/icore.h> - -#include <QVariantMap> -#include <QFileInfo> -#include <QMessageBox> - -namespace Qnx { -namespace Internal { - -const QLatin1String QNXEnvFileKey("EnvFile"); -const QLatin1String QNXVersionKey("QNXVersion"); -// For backward compatibility -const QLatin1String NDKEnvFileKey("NDKEnvFile"); - - -using namespace Utils; -using namespace ProjectExplorer; - -QnxBaseConfiguration::QnxBaseConfiguration() -{ -} - -QnxBaseConfiguration::QnxBaseConfiguration(const FileName &envFile) -{ - ctor(envFile); -} - -QnxBaseConfiguration::QnxBaseConfiguration(const QVariantMap &data) -{ - QString envFilePath = data.value(QNXEnvFileKey).toString(); - if (envFilePath.isEmpty()) - envFilePath = data.value(NDKEnvFileKey).toString(); - - m_version = QnxVersionNumber(data.value(QNXVersionKey).toString()); - ctor(FileName::fromString(envFilePath)); -} - -QnxBaseConfiguration::~QnxBaseConfiguration() -{ -} - -FileName QnxBaseConfiguration::envFile() const -{ - return m_envFile; -} - -FileName QnxBaseConfiguration::qnxTarget() const -{ - return m_qnxTarget; -} - -FileName QnxBaseConfiguration::qnxHost() const -{ - return m_qnxHost; -} - -FileName QnxBaseConfiguration::qccCompilerPath() const -{ - return m_qccCompiler; -} - -FileName QnxBaseConfiguration::armDebuggerPath() const -{ - return m_armlev7Debugger; -} - -FileName QnxBaseConfiguration::x86DebuggerPath() const -{ - return m_x86Debugger; -} - -QList<EnvironmentItem> QnxBaseConfiguration::qnxEnv() const -{ - return m_qnxEnv; -} - -QnxVersionNumber QnxBaseConfiguration::version() const -{ - return m_version; -} - -QVariantMap QnxBaseConfiguration::toMap() const -{ - QVariantMap data; - data.insert(QLatin1String(QNXEnvFileKey), m_envFile.toString()); - data.insert(QLatin1String(QNXVersionKey), m_version.toString()); - return data; -} - -bool QnxBaseConfiguration::isValid() const -{ - return !m_qccCompiler.isEmpty() - && !m_armlev7Debugger.isEmpty() - && !m_x86Debugger.isEmpty(); -} - -void QnxBaseConfiguration::ctor(const FileName &envScript) -{ - QTC_ASSERT(!envScript.isEmpty(), return); -#if !defined(WITH_TESTS) - QTC_ASSERT(envScript.exists(), return); -#endif - m_envFile = envScript; - m_qnxEnv = QnxUtils::qnxEnvironmentFromEnvFile(m_envFile.toString()); - foreach (const EnvironmentItem &item, m_qnxEnv) { - if (item.name == QLatin1String("QNX_TARGET")) - m_qnxTarget = FileName::fromString(item.value); - - else if (item.name == QLatin1String("QNX_HOST")) - m_qnxHost = FileName::fromString(item.value); - } - - FileName qccPath = FileName::fromString(HostOsInfo::withExecutableSuffix( - m_qnxHost.toString() + QLatin1String("/usr/bin/qcc"))); - FileName armlev7GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( - m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarm-gdb"))); - if (!armlev7GdbPath.exists()) { - armlev7GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( - m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarmv7-gdb"))); - } - - FileName x86GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( - m_qnxHost.toString() + QLatin1String("/usr/bin/ntox86-gdb"))); - - if (qccPath.exists()) - m_qccCompiler = qccPath; - - if (armlev7GdbPath.exists()) - m_armlev7Debugger = armlev7GdbPath; - - if (x86GdbPath.exists()) - m_x86Debugger = x86GdbPath; -} - -QVariant QnxBaseConfiguration::createDebuggerItem(QnxArchitecture arch, - const QString &displayName) -{ - FileName command = (arch == X86) ? x86DebuggerPath() : armDebuggerPath(); - Debugger::DebuggerItem debugger; - debugger.setCommand(command); - debugger.setEngineType(Debugger::GdbEngineType); - debugger.setAbi(Abi(arch == Qnx::ArmLeV7 ? Abi::ArmArchitecture : Abi::X86Architecture, - Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); - debugger.setAutoDetected(true); - debugger.setUnexpandedDisplayName(displayName); - return Debugger::DebuggerItemManager::registerDebugger(debugger); -} - -QnxToolChain *QnxBaseConfiguration::createToolChain(QnxArchitecture arch, - const QString &displayName, - const QString &ndkPath) -{ - QnxToolChain *toolChain = new QnxToolChain(ToolChain::AutoDetection); - toolChain->resetToolChain(m_qccCompiler); - toolChain->setTargetAbi(Abi((arch == Qnx::ArmLeV7) ? Abi::ArmArchitecture : Abi::X86Architecture, - Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); - toolChain->setDisplayName(displayName); - toolChain->setNdkPath(ndkPath); - ToolChainManager::registerToolChain(toolChain); - return toolChain; -} - -QStringList QnxBaseConfiguration::validationErrors() const -{ - QStringList errorStrings; - if (m_qccCompiler.isEmpty()) - errorStrings << tr("- No GCC compiler found."); - - if (m_armlev7Debugger.isEmpty()) - errorStrings << tr("- No GDB debugger found for armvle7."); - - if (m_x86Debugger.isEmpty()) - errorStrings << tr("- No GDB debugger found for x86."); - - return errorStrings; -} - -void QnxBaseConfiguration::setVersion(const QnxVersionNumber &version) -{ - m_version = version; -} - -} -} diff --git a/src/plugins/qnx/qnxbaseconfiguration.h b/src/plugins/qnx/qnxbaseconfiguration.h deleted file mode 100644 index 3aec2ddc2cc..00000000000 --- a/src/plugins/qnx/qnxbaseconfiguration.h +++ /dev/null @@ -1,104 +0,0 @@ -/************************************************************************** -** -** Copyright (C) 2015 BlackBerry Limited. All rights reserved. -** -** Contact: BlackBerry (qt@blackberry.com) -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef QNXBASECONFIGURATION_H -#define QNXBASECONFIGURATION_H - -#include "qnxconstants.h" -#include "qnxutils.h" -#include "qnxversionnumber.h" - -#include <utils/fileutils.h> -#include <utils/environment.h> - -#include <projectexplorer/abi.h> - -#include <debugger/debuggeritemmanager.h> - -#include <qvariant.h> - -namespace Qnx { -namespace Internal { - -class QnxToolChain; - -class QnxBaseConfiguration -{ - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxBaseConfiguration) - -public: - QnxBaseConfiguration(); - QnxBaseConfiguration(const Utils::FileName &envFile); - QnxBaseConfiguration(const QVariantMap &data); - virtual ~QnxBaseConfiguration(); - Utils::FileName envFile() const; - Utils::FileName qnxTarget() const; - Utils::FileName qnxHost() const; - Utils::FileName qccCompilerPath() const; - Utils::FileName armDebuggerPath() const; - Utils::FileName x86DebuggerPath() const; - QList<Utils::EnvironmentItem> qnxEnv() const; - QnxVersionNumber version() const; - QVariantMap toMap() const; - - virtual bool isValid() const; - virtual bool isActive() const = 0; - - virtual bool activate() = 0; - virtual void deactivate() = 0; - -protected: - QVariant createDebuggerItem(Qnx::QnxArchitecture arch, - const QString &displayName); - QnxToolChain* createToolChain(Qnx::QnxArchitecture arch, - const QString &displayName, - const QString &ndkPath); - - virtual QStringList validationErrors() const; - void setVersion(const QnxVersionNumber& version); -private: - Utils::FileName m_envFile; - Utils::FileName m_qnxTarget; - Utils::FileName m_qnxHost; - Utils::FileName m_qccCompiler; - Utils::FileName m_armlev7Debugger; - Utils::FileName m_x86Debugger; - QList<Utils::EnvironmentItem> m_qnxEnv; - QnxVersionNumber m_version; - - void ctor(const Utils::FileName &envFile); - -}; - -} -} - -#endif // QNXBASECONFIGURATION_H diff --git a/src/plugins/qnx/qnxbaseqtconfigwidget.cpp b/src/plugins/qnx/qnxbaseqtconfigwidget.cpp index 66c79e84ed1..b53d9ed8c20 100644 --- a/src/plugins/qnx/qnxbaseqtconfigwidget.cpp +++ b/src/plugins/qnx/qnxbaseqtconfigwidget.cpp @@ -31,38 +31,33 @@ ****************************************************************************/ #include "qnxbaseqtconfigwidget.h" -#include "ui_qnxbaseqtconfigwidget.h" -#include "qnxabstractqtversion.h" +#include "qnxqtversion.h" #include <utils/pathchooser.h> +#include <utils/qtcassert.h> #include <QDir> -#include <QFormLayout> +#include <QHBoxLayout> -using namespace Qnx; -using namespace Qnx::Internal; +namespace Qnx { +namespace Internal { -QnxBaseQtConfigWidget::QnxBaseQtConfigWidget(QnxAbstractQtVersion *version) - : QtSupport::QtConfigWidget() - , m_version(version) +QnxBaseQtConfigWidget::QnxBaseQtConfigWidget(QnxQtVersion *version) : + m_version(version), + m_sdkPathChooser(new Utils::PathChooser) { - m_ui = new Ui::QnxBaseQtConfigWidget; - m_ui->setupUi(this); + QTC_ASSERT(version, return); - m_ui->sdkLabel->setText(version->sdkDescription()); + QHBoxLayout *layout = new QHBoxLayout(this); + layout->addWidget(m_sdkPathChooser); - m_ui->sdkPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); - m_ui->sdkPath->setHistoryCompleter(QLatin1String("Qnx.Sdk.History")); - m_ui->sdkPath->setPath(version->sdkPath()); + m_sdkPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); + m_sdkPathChooser->setHistoryCompleter(QLatin1String("Qnx.Sdk.History")); + m_sdkPathChooser->setPath(version->sdkPath()); - connect(m_ui->sdkPath, SIGNAL(changed(QString)), this, SLOT(updateSdkPath(QString))); -} - -QnxBaseQtConfigWidget::~QnxBaseQtConfigWidget() -{ - delete m_ui; - m_ui = 0; + connect(m_sdkPathChooser, &Utils::PathChooser::changed, + this, &QnxBaseQtConfigWidget::updateSdkPath); } void QnxBaseQtConfigWidget::updateSdkPath(const QString &path) @@ -70,3 +65,6 @@ void QnxBaseQtConfigWidget::updateSdkPath(const QString &path) m_version->setSdkPath(path); emit changed(); } + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxbaseqtconfigwidget.h b/src/plugins/qnx/qnxbaseqtconfigwidget.h index c01ec71b96e..6db1c757716 100644 --- a/src/plugins/qnx/qnxbaseqtconfigwidget.h +++ b/src/plugins/qnx/qnxbaseqtconfigwidget.h @@ -35,26 +35,26 @@ #include <qtsupport/qtconfigwidget.h> +namespace Utils { class PathChooser; } + namespace Qnx { namespace Internal { -namespace Ui { class QnxBaseQtConfigWidget; } -class QnxAbstractQtVersion; +class QnxQtVersion; class QnxBaseQtConfigWidget : public QtSupport::QtConfigWidget { Q_OBJECT + public: - explicit QnxBaseQtConfigWidget(QnxAbstractQtVersion *version); - ~QnxBaseQtConfigWidget(); + explicit QnxBaseQtConfigWidget(QnxQtVersion *version); private slots: void updateSdkPath(const QString &path); private: - QnxAbstractQtVersion *m_version; - - Ui::QnxBaseQtConfigWidget *m_ui; + QnxQtVersion *m_version; + Utils::PathChooser *m_sdkPathChooser; }; } // namespace Internal diff --git a/src/plugins/qnx/qnxbaseqtconfigwidget.ui b/src/plugins/qnx/qnxbaseqtconfigwidget.ui deleted file mode 100644 index 8b00c1e0d3f..00000000000 --- a/src/plugins/qnx/qnxbaseqtconfigwidget.ui +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Qnx::Internal::QnxBaseQtConfigWidget</class> - <widget class="QWidget" name="Qnx::Internal::QnxBaseQtConfigWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>778</width> - <height>23</height> - </rect> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="sdkPath" native="true"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="sdkLabel"> - <property name="text"> - <string>SDK:</string> - </property> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/qnx/qnxconfiguration.cpp b/src/plugins/qnx/qnxconfiguration.cpp index 775db6b15db..e8f1aaa4e25 100644 --- a/src/plugins/qnx/qnxconfiguration.cpp +++ b/src/plugins/qnx/qnxconfiguration.cpp @@ -36,7 +36,10 @@ #include "debugger/debuggeritem.h" +#include <coreplugin/icore.h> + #include <projectexplorer/toolchainmanager.h> +#include <projectexplorer/toolchain.h> #include <projectexplorer/kit.h> #include <projectexplorer/kitmanager.h> @@ -46,6 +49,7 @@ #include <qmakeprojectmanager/qmakekitinformation.h> +#include <debugger/debuggeritem.h> #include <debugger/debuggeritemmanager.h> #include <debugger/debuggerkitinformation.h> @@ -61,18 +65,88 @@ using namespace Debugger; namespace Qnx { namespace Internal { + +const QLatin1String QNXEnvFileKey("EnvFile"); +const QLatin1String QNXVersionKey("QNXVersion"); +// For backward compatibility +const QLatin1String NDKEnvFileKey("NDKEnvFile"); + +QnxConfiguration::QnxConfiguration() +{ } + QnxConfiguration::QnxConfiguration(const FileName &sdpEnvFile) - : QnxBaseConfiguration(sdpEnvFile) { + setDefaultConfiguration(sdpEnvFile); readInformation(); } QnxConfiguration::QnxConfiguration(const QVariantMap &data) - : QnxBaseConfiguration(data) { + QString envFilePath = data.value(QNXEnvFileKey).toString(); + if (envFilePath.isEmpty()) + envFilePath = data.value(NDKEnvFileKey).toString(); + + m_version = QnxVersionNumber(data.value(QNXVersionKey).toString()); + + setDefaultConfiguration(FileName::fromString(envFilePath)); readInformation(); } +FileName QnxConfiguration::envFile() const +{ + return m_envFile; +} + +FileName QnxConfiguration::qnxTarget() const +{ + return m_qnxTarget; +} + +FileName QnxConfiguration::qnxHost() const +{ + return m_qnxHost; +} + +FileName QnxConfiguration::qccCompilerPath() const +{ + return m_qccCompiler; +} + +FileName QnxConfiguration::armDebuggerPath() const +{ + return m_armlev7Debugger; +} + +FileName QnxConfiguration::x86DebuggerPath() const +{ + return m_x86Debugger; +} + +QList<EnvironmentItem> QnxConfiguration::qnxEnv() const +{ + return m_qnxEnv; +} + +QnxVersionNumber QnxConfiguration::version() const +{ + return m_version; +} + +QVariantMap QnxConfiguration::toMap() const +{ + QVariantMap data; + data.insert(QLatin1String(QNXEnvFileKey), m_envFile.toString()); + data.insert(QLatin1String(QNXVersionKey), m_version.toString()); + return data; +} + +bool QnxConfiguration::isValid() const +{ + return !m_qccCompiler.isEmpty() + && !m_armlev7Debugger.isEmpty() + && !m_x86Debugger.isEmpty(); +} + QString QnxConfiguration::displayName() const { return m_configName; @@ -84,33 +158,45 @@ bool QnxConfiguration::activate() return true; if (!isValid()) { - QString errorMessage = tr("The following errors occurred while activating the QNX configuration:"); + QString errorMessage + = QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "The following errors occurred while activating the QNX configuration:"); foreach (const QString &error, validationErrors()) errorMessage += QLatin1String("\n") + error; - QMessageBox::warning(Core::ICore::mainWindow(), tr("Cannot Set Up QNX Configuration"), + QMessageBox::warning(Core::ICore::mainWindow(), + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "Cannot Set Up QNX Configuration"), errorMessage, QMessageBox::Ok); return false; } // Create and register toolchain QnxToolChain *armTc = createToolChain(ArmLeV7, - tr("QCC for %1 (armv7)").arg(displayName()), + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "QCC for %1 (armv7)").arg(displayName()), sdpPath().toString()); QnxToolChain *x86Tc = createToolChain(X86, - tr("QCC for %1 (x86)").arg(displayName()), + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "QCC for %1 (x86)").arg(displayName()), sdpPath().toString()); // Create and register debuggers QVariant armDebuggerId = createDebuggerItem(ArmLeV7, - tr("Debugger for %1 (armv7)").arg(displayName())); + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "Debugger for %1 (armv7)").arg(displayName())); QVariant x86DebuggerId = createDebuggerItem(X86, - tr("Debugger for %1 (x86)").arg(displayName())); + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "Debugger for %1 (x86)").arg(displayName())); // Create and register kits - createKit(ArmLeV7, armTc, armDebuggerId, tr("Kit for %1 (armv7)").arg(displayName())); - createKit(X86, x86Tc, x86DebuggerId, tr("Kit for %1 (x86)").arg(displayName())); + createKit(ArmLeV7, armTc, armDebuggerId, + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "Kit for %1 (armv7)").arg(displayName())); + createKit(X86, x86Tc, x86DebuggerId, + QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "Kit for %1 (x86)").arg(displayName())); return true; } @@ -137,7 +223,7 @@ void QnxConfiguration::deactivate() foreach (Kit *kit, KitManager::kits()) { if (kit->isAutoDetected() - && DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_BB_OS_TYPE + && DeviceTypeKitInformation::deviceTypeId(kit) == Constants::QNX_QNX_OS_TYPE && toolChainsToRemove.contains(ToolChainKitInformation::toolChain(kit))) KitManager::deregisterKit(kit); } @@ -146,24 +232,21 @@ void QnxConfiguration::deactivate() ToolChainManager::deregisterToolChain(tc); foreach (DebuggerItem debuggerItem, debuggersToRemove) - DebuggerItemManager:: - deregisterDebugger(debuggerItem.id()); + DebuggerItemManager::deregisterDebugger(debuggerItem.id()); } bool QnxConfiguration::isActive() const { bool hasToolChain = false; bool hasDebugger = false; - foreach (ToolChain *tc, - ToolChainManager::toolChains()) { + foreach (ToolChain *tc, ToolChainManager::toolChains()) { if (tc->compilerCommand() == qccCompilerPath()) { hasToolChain = true; break; } } - foreach (DebuggerItem debuggerItem, - DebuggerItemManager::debuggers()) { + foreach (DebuggerItem debuggerItem, DebuggerItemManager::debuggers()) { if (debuggerItem.command() == armDebuggerPath() || debuggerItem.command() == x86DebuggerPath()) { hasDebugger = true; @@ -200,6 +283,32 @@ QnxQtVersion* QnxConfiguration::qnxQtVersion(QnxArchitecture arch) const return 0; } +QVariant QnxConfiguration::createDebuggerItem(QnxArchitecture arch, const QString &displayName) +{ + FileName command = (arch == X86) ? x86DebuggerPath() : armDebuggerPath(); + Debugger::DebuggerItem debugger; + debugger.setCommand(command); + debugger.setEngineType(Debugger::GdbEngineType); + debugger.setAbi(Abi(arch == Qnx::ArmLeV7 ? Abi::ArmArchitecture : Abi::X86Architecture, + Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); + debugger.setAutoDetected(true); + debugger.setUnexpandedDisplayName(displayName); + return Debugger::DebuggerItemManager::registerDebugger(debugger); +} + +QnxToolChain *QnxConfiguration::createToolChain(QnxArchitecture arch, const QString &displayName, + const QString &ndkPath) +{ + QnxToolChain *toolChain = new QnxToolChain(ToolChain::AutoDetection); + toolChain->resetToolChain(m_qccCompiler); + toolChain->setTargetAbi(Abi((arch == Qnx::ArmLeV7) ? Abi::ArmArchitecture : Abi::X86Architecture, + Abi::LinuxOS, Abi::GenericLinuxFlavor, Abi::ElfFormat, 32)); + toolChain->setDisplayName(displayName); + toolChain->setNdkPath(ndkPath); + ToolChainManager::registerToolChain(toolChain); + return toolChain; +} + Kit *QnxConfiguration::createKit(QnxArchitecture arch, QnxToolChain *toolChain, const QVariant &debuggerItemId, @@ -247,6 +356,29 @@ Kit *QnxConfiguration::createKit(QnxArchitecture arch, return kit; } +QStringList QnxConfiguration::validationErrors() const +{ + QStringList errorStrings; + if (m_qccCompiler.isEmpty()) + errorStrings << QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "- No GCC compiler found."); + + if (m_armlev7Debugger.isEmpty()) + errorStrings << QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "- No GDB debugger found for armvle7."); + + if (m_x86Debugger.isEmpty()) + errorStrings << QCoreApplication::translate("Qnx::Internal::QnxConfiguration", + "- No GDB debugger found for x86."); + + return errorStrings; +} + +void QnxConfiguration::setVersion(const QnxVersionNumber &version) +{ + m_version = version; +} + void QnxConfiguration::readInformation() { QString qConfigPath = sdpPath().toString() + QLatin1String("/.qnx/qconfig"); @@ -261,5 +393,40 @@ void QnxConfiguration::readInformation() setVersion(QnxVersionNumber(installInfo.version)); } +void QnxConfiguration::setDefaultConfiguration(const Utils::FileName &envScript) +{ + QTC_ASSERT(!envScript.isEmpty(), return); + m_envFile = envScript; + m_qnxEnv = QnxUtils::qnxEnvironmentFromEnvFile(m_envFile.toString()); + foreach (const EnvironmentItem &item, m_qnxEnv) { + if (item.name == QLatin1String("QNX_TARGET")) + m_qnxTarget = FileName::fromString(item.value); + + else if (item.name == QLatin1String("QNX_HOST")) + m_qnxHost = FileName::fromString(item.value); + } + + FileName qccPath = FileName::fromString(HostOsInfo::withExecutableSuffix( + m_qnxHost.toString() + QLatin1String("/usr/bin/qcc"))); + FileName armlev7GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( + m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarm-gdb"))); + if (!armlev7GdbPath.exists()) { + armlev7GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( + m_qnxHost.toString() + QLatin1String("/usr/bin/ntoarmv7-gdb"))); + } + + FileName x86GdbPath = FileName::fromString(HostOsInfo::withExecutableSuffix( + m_qnxHost.toString() + QLatin1String("/usr/bin/ntox86-gdb"))); + + if (qccPath.exists()) + m_qccCompiler = qccPath; + + if (armlev7GdbPath.exists()) + m_armlev7Debugger = armlev7GdbPath; + + if (x86GdbPath.exists()) + m_x86Debugger = x86GdbPath; } -} + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxconfiguration.h b/src/plugins/qnx/qnxconfiguration.h index 28c252aded9..61f152c30c9 100644 --- a/src/plugins/qnx/qnxconfiguration.h +++ b/src/plugins/qnx/qnxconfiguration.h @@ -32,21 +32,46 @@ #ifndef QNXCONFIGURATION_H #define QNXCONFIGURATION_H -#include "qnxbaseconfiguration.h" +#include "qnxconstants.h" +#include "qnxutils.h" #include "qnxversionnumber.h" +#include <utils/fileutils.h> +#include <utils/environment.h> + +#include <projectexplorer/abi.h> + +#include <debugger/debuggeritemmanager.h> + +#include <QVariant> + namespace ProjectExplorer { class Kit; } namespace Qnx { namespace Internal { + +class QnxToolChain; class QnxQtVersion; -class QnxConfiguration : public QnxBaseConfiguration -{ - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxConfiguration) +class QnxConfiguration +{ public: + QnxConfiguration(); QnxConfiguration(const Utils::FileName &sdpEnvFile); QnxConfiguration(const QVariantMap &data); + + Utils::FileName envFile() const; + Utils::FileName qnxTarget() const; + Utils::FileName qnxHost() const; + Utils::FileName qccCompilerPath() const; + Utils::FileName armDebuggerPath() const; + Utils::FileName x86DebuggerPath() const; + QList<Utils::EnvironmentItem> qnxEnv() const; + QnxVersionNumber version() const; + QVariantMap toMap() const; + + bool isValid() const; + QString displayName() const; bool activate(); void deactivate(); @@ -56,15 +81,35 @@ public: QnxQtVersion* qnxQtVersion(QnxArchitecture arch) const; private: - QString m_configName; + QVariant createDebuggerItem(Qnx::QnxArchitecture arch, + const QString &displayName); + QnxToolChain* createToolChain(Qnx::QnxArchitecture arch, + const QString &displayName, + const QString &ndkPath); ProjectExplorer::Kit *createKit(QnxArchitecture arch, QnxToolChain *toolChain, const QVariant &debuggerItemId, const QString &displayName); + QStringList validationErrors() const; + + void setVersion(const QnxVersionNumber& version); + void readInformation(); + void setDefaultConfiguration(const Utils::FileName &envScript); + + QString m_configName; + + Utils::FileName m_envFile; + Utils::FileName m_qnxTarget; + Utils::FileName m_qnxHost; + Utils::FileName m_qccCompiler; + Utils::FileName m_armlev7Debugger; + Utils::FileName m_x86Debugger; + QList<Utils::EnvironmentItem> m_qnxEnv; + QnxVersionNumber m_version; }; } // Internal diff --git a/src/plugins/qnx/qnxconstants.h b/src/plugins/qnx/qnxconstants.h index d448808be3e..32f1ec3f870 100644 --- a/src/plugins/qnx/qnxconstants.h +++ b/src/plugins/qnx/qnxconstants.h @@ -45,99 +45,35 @@ enum QnxArchitecture { namespace Constants { -const int QNX_BB_QT_FACTORY_PRIO = 60; -const int QNX_QNX_QT_FACTORY_PRIO = 50; - const char QNX_TARGET_KEY[] = "QNX_TARGET"; const char QNX_HOST_KEY[] = "QNX_HOST"; -const char QNX_BB_QT[] = "Qt4ProjectManager.QtVersion.QNX.BlackBerry"; const char QNX_QNX_QT[] = "Qt4ProjectManager.QtVersion.QNX.QNX"; -const char QNX_BB_FEATURE[] = "QtSupport.Wizards.FeatureBlackBerry"; const char QNX_QNX_FEATURE[] = "QtSupport.Wizards.FeatureQNX"; -const char QNX_BB_X86_TARGET_ID[] = "Qt4ProjectManager.Target.QNX.BBX86Target"; -const char QNX_BB_ARMLEV7_TARGET_ID[] = "Qt4ProjectManager.Target.QNX.BBArmLeV7Target"; -const char QNX_QNX_X86_TARGET_ID[] = "Qt4ProjectManager.Target.QNX.QNXX86Target"; -const char QNX_QNX_ARMLEV7_TARGET_ID[] = "Qt4ProjectManager.Target.QNX.QNXArmLeV7Target"; - -const char QNX_BB_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.QNX.BBDeployConfiguration"; -const char QNX_QNX_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.QNX.QNXDeployConfiguration"; +const char QNX_QNX_DEPLOYCONFIGURATION_ID[] = "Qt4ProjectManager.QNX.QNXDeployConfiguration"; -const char QNX_BB_RUNCONFIGURATION_PREFIX[] = "Qt4ProjectManager.QNX.BBRunConfiguration."; const char QNX_QNX_RUNCONFIGURATION_PREFIX[] = "Qt4ProjectManager.QNX.QNXRunConfiguration."; -const char QNX_CREATE_PACKAGE_BS_ID[] = "Qt4ProjectManager.QnxCreatePackageBuildStep"; -const char QNX_DEPLOY_PACKAGE_BS_ID[] = "Qt4ProjectManager.QnxDeployPackageBuildStep"; -const char QNX_CHECK_DEVICE_STATUS_BS_ID[] = "Qt4ProjectManager.QnxCheckDeviceStatusBuildStep"; - -const char QNX_PROFILEPATH_KEY[] = "Qt4ProjectManager.QnxRunConfiguration.ProFilePath"; - -const char QNX_BB_OS_TYPE[] = "BBOsType"; const char QNX_QNX_OS_TYPE[] = "QnxOsType"; -const char QNX_DEBUG_TOKEN_KEY[] = "debugToken"; - -const char QNX_BLACKBERRY_CASCADES_WIZARD_ID[] = "Q.QnxBlackBerryCascadesApp"; -const char QNX_BAR_DESCRIPTOR_WIZARD_ID[] = "Q.QnxBlackBerryBarDescriptor"; -const char QNX_BLACKBERRY_QTQUICK_APP_WIZARD_ID[] = "Q.QnxBlackBerryQQApp"; -const char QNX_BLACKBERRY_QTQUICK2_APP_WIZARD_ID[] = "Q.QnxBlackBerryQQ2App"; -const char QNX_BLACKBERRY_GUI_APP_WIZARD_ID[] = "Q.QnxBlackBerryGuiApp"; -const char QNX_BLACKBERRY_SETUP_WIZARD_ID[] = "Q.QnxBlackBerrySetupWizardId"; - const char QNX_QNX_PLATFORM_NAME[] = "QNX"; -const char QNX_BB_PLATFORM_NAME[] = "BlackBerry"; const char QNX_DEBUG_EXECUTABLE[] = "pdebug"; const char QNX_TOOLCHAIN_ID[] = "Qnx.QccToolChain"; -// BlackBerry settings constants -const char QNX_BB_CATEGORY[] = "XF.BlackBerry"; +// QNX settings constants const char QNX_CATEGORY[] = "XF.Qnx"; -const char QNX_BB_CATEGORY_TR[] = QT_TRANSLATE_NOOP("BlackBerry", "BlackBerry"); const char QNX_CATEGORY_TR[] = QT_TRANSLATE_NOOP("QNX", "QNX"); -const char QNX_BB_CATEGORY_ICON[] = ":/qnx/images/target.png"; const char QNX_CATEGORY_ICON[] = ":/qnx/images/qnx-target.png"; -const char QNX_BB_SETUP_ID[] = "ZA.BlackBerry Setup"; -const char QNX_BB_NDK_SETTINGS_ID[] = "ZZ.BlackBerry NDK Configuration"; const char QNX_SETTINGS_ID[] = "ZZ.Qnx Configuration"; -const char QNX_BB_SIGNING_ID[] = "ZZ.BlackBerry Signing Infrastructure Configuration"; - -const char QNX_BAR_DESCRIPTOR_MIME_TYPE[] = "application/vnd.rim.qnx.bar_descriptor"; -const char QNX_BAR_DESCRIPTOR_EDITOR_ID[] = "Qnx.BarDescriptorEditor"; -const char QNX_BAR_DESCRIPTOR_EDITOR_CONTEXT[] = "Qnx.BarDescriptorEditor"; - -const char QNX_TASK_CATEGORY_BARDESCRIPTOR[] = "Task.Category.BarDescriptor"; -const char QNX_KEY_AUTHOR[] = "author"; -const char QNX_KEY_PATH[] = "path"; -const char QNX_KEY_ACTIVE[] = "active"; - -const char QNX_BLACKBERRY_DEPLOY_CMD[] = "blackberry-deploy"; - -const char QNX_BLACKBERRY_CASCADESIMPORTER_VERSION[] = "0.0.1"; - -const char QNX_BLACKBERRY_CONFIGS_FILENAME[] = "bbndkconfigurations.xml"; const char QNX_CONFIGS_FILENAME[] = "qnxconfigurations.xml"; const char QNX_DEBUGGING_GROUP[] = "Debugger.Group.Qnx"; -const char QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH[] = "/accounts/devuser/"; - -const char QNX_OK_ICON[] = ":/qnx/images/ok.png"; - -const char QNX_BLACKBERRY_SETUP_URL[] = "http://wiki.qt.io/Qt_Creator_with_BlackBerry_10"; -const char QNX_LEGACY_KEYS_URL[] = "https://developer.blackberry.com/native/documentation/core" - "/com.qnx.doc.ide.userguide/topic/signing_and_publishing.html"; -const char QNX_REGISTER_KEYS_URL[] = "https://www.blackberry.com/SignedKeys/codesigning.html"; - -const char QNX_BB_KEY_CONFIGURATION_TYPE[] = "BBConfigurationType"; - -const char QNX_BB_APILEVEL_TYPE[] = "BBApiLevel"; -const char QNX_BB_RUNTIME_TYPE[] = "BBRuntime"; - } // namespace Constants } // namespace Qnx diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp index 49a252d3152..ba327d2085c 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.cpp @@ -33,7 +33,6 @@ #include "qnxdeployqtlibrariesdialog.h" #include "ui_qnxdeployqtlibrariesdialog.h" -#include "blackberryqtversion.h" #include "qnxqtversion.h" #include <projectexplorer/deployablefile.h> @@ -45,39 +44,32 @@ #include <QDir> #include <QMessageBox> -using namespace Qnx; -using namespace Qnx::Internal; - -QnxDeployQtLibrariesDialog::QnxDeployQtLibrariesDialog( - const ProjectExplorer::IDevice::ConstPtr &device, Target target, QWidget *parent) - : QDialog(parent) - , m_ui(new Ui::QnxDeployQtLibrariesDialog) - , m_device(device) - , m_progressCount(0) - , m_state(Inactive) - , m_target(target) +using namespace QtSupport; + +namespace Qnx { +namespace Internal { + +QnxDeployQtLibrariesDialog::QnxDeployQtLibrariesDialog(const ProjectExplorer::IDevice::ConstPtr &device, + QWidget *parent) : + QDialog(parent), + m_ui(new Ui::QnxDeployQtLibrariesDialog), + m_device(device), + m_progressCount(0), + m_state(Inactive) { m_ui->setupUi(this); - QList<QtSupport::BaseQtVersion*> qtVersions = QtSupport::QtVersionManager::validVersions(); - foreach (QtSupport::BaseQtVersion *qtVersion, qtVersions) { - QnxAbstractQtVersion *qnxQt; - if (m_target == BB10) - qnxQt = dynamic_cast<BlackBerryQtVersion *>(qtVersion); - else - qnxQt = dynamic_cast<QnxQtVersion *>(qtVersion); - + QList<BaseQtVersion*> qtVersions = QtVersionManager::validVersions(); + foreach (BaseQtVersion *qtVersion, qtVersions) { + QnxQtVersion *qnxQt = dynamic_cast<QnxQtVersion *>(qtVersion); if (!qnxQt) continue; m_ui->qtLibraryCombo->addItem(qnxQt->displayName(), qnxQt->uniqueId()); - } - m_ui->basePathLabel->setText(m_target == BB10 ? - QLatin1String(Constants::QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH) : - QString()); - m_ui->remoteDirectory->setText(m_target == BB10 ? QLatin1String("qt") : QLatin1String("/qt")); + m_ui->basePathLabel->setText(QString()); + m_ui->remoteDirectory->setText(QLatin1String("/qt")); m_uploadService = new RemoteLinux::GenericDirectUploadService(this); m_uploadService->setDevice(m_device); @@ -237,11 +229,7 @@ QList<ProjectExplorer::DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles() m_ui->qtLibraryCombo->itemData(m_ui->qtLibraryCombo->currentIndex()).toInt(); - QnxAbstractQtVersion *qtVersion; - if (m_target == BB10) - qtVersion = dynamic_cast<BlackBerryQtVersion *>(QtSupport::QtVersionManager::version(qtVersionId)); - else - qtVersion = dynamic_cast<QnxQtVersion *>(QtSupport::QtVersionManager::version(qtVersionId)); + QnxQtVersion *qtVersion = dynamic_cast<QnxQtVersion *>(QtVersionManager::version(qtVersionId)); QTC_ASSERT(qtVersion, return result); @@ -298,11 +286,7 @@ QList<ProjectExplorer::DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles( QString QnxDeployQtLibrariesDialog::fullRemoteDirectory() const { - QString basePath; - if (m_target == BB10) - basePath = QLatin1String(Constants::QNX_BLACKBERRY_DEFAULT_DEPLOY_QT_BASEPATH); - - return basePath + m_ui->remoteDirectory->text(); + return m_ui->remoteDirectory->text(); } void QnxDeployQtLibrariesDialog::checkRemoteDirectoryExistance() @@ -329,3 +313,6 @@ void QnxDeployQtLibrariesDialog::removeRemoteDirectory() const QByteArray cmd = "rm -rf " + fullRemoteDirectory().toLatin1(); m_processRunner->run(cmd, m_device->sshParameters()); } + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxdeployqtlibrariesdialog.h b/src/plugins/qnx/qnxdeployqtlibrariesdialog.h index 10d41613ea0..38f8f015923 100644 --- a/src/plugins/qnx/qnxdeployqtlibrariesdialog.h +++ b/src/plugins/qnx/qnxdeployqtlibrariesdialog.h @@ -65,14 +65,8 @@ public: Uploading }; - enum Target { - BB10, - QNX - }; - explicit QnxDeployQtLibrariesDialog(const ProjectExplorer::IDevice::ConstPtr &device, - Target target = QNX, - QWidget *parent = 0); + QWidget *parent = 0); ~QnxDeployQtLibrariesDialog(); int execAndDeploy(int qtVersionId, const QString &remoteDirectory); @@ -109,10 +103,8 @@ private: int m_progressCount; State m_state; - Target m_target; }; - } // namespace Internal } // namespace Qnx #endif // QNX_INTERNAL_QNXDEPLOYQTLIBRARIESDIALOG_H diff --git a/src/plugins/qnx/qnxdeviceconfiguration.cpp b/src/plugins/qnx/qnxdeviceconfiguration.cpp index 2b518dd8fe2..06998bc8015 100644 --- a/src/plugins/qnx/qnxdeviceconfiguration.cpp +++ b/src/plugins/qnx/qnxdeviceconfiguration.cpp @@ -263,7 +263,7 @@ void QnxDeviceConfiguration::executeAction(Core::Id actionId, QWidget *parent) const QnxDeviceConfiguration::ConstPtr device = sharedFromThis().staticCast<const QnxDeviceConfiguration>(); if (actionId == Core::Id(DeployQtLibrariesActionId)) { - QnxDeployQtLibrariesDialog dialog(device, QnxDeployQtLibrariesDialog::QNX, parent); + QnxDeployQtLibrariesDialog dialog(device, parent); dialog.exec(); } else { RemoteLinux::LinuxDevice::executeAction(actionId, parent); diff --git a/src/plugins/qnx/qnxdeviceprocesssignaloperation.cpp b/src/plugins/qnx/qnxdeviceprocesssignaloperation.cpp index 795bd94c2e2..ab3524a2256 100644 --- a/src/plugins/qnx/qnxdeviceprocesssignaloperation.cpp +++ b/src/plugins/qnx/qnxdeviceprocesssignaloperation.cpp @@ -62,30 +62,3 @@ QString QnxDeviceProcessSignalOperation::interruptProcessByNameCommandLine( { return signalProcessByNameQnxCommandLine(filePath, 2); } - - -BlackBerryDeviceProcessSignalOperation::BlackBerryDeviceProcessSignalOperation( - const QSsh::SshConnectionParameters &sshParameters) - : RemoteLinux::RemoteLinuxSignalOperation(sshParameters) -{ -} - -static QString signalProcessByNameBlackBerryCommandLine(const QString &filePath, int sig) -{ - QString executable = filePath; - return QString::fromLatin1("for PID in $(pidin -F \"%a %A\" | grep \"%1\" | awk '/%1/ {print $1}'); " - "do " - "kill -%2 $PID; " - "done").arg(executable.replace(QLatin1String("/"), QLatin1String("\\/"))).arg(sig); -} - -QString BlackBerryDeviceProcessSignalOperation::killProcessByNameCommandLine(const QString &filePath) const -{ - return QString::fromLatin1("%1; %2").arg(signalProcessByNameBlackBerryCommandLine(filePath, 15), - signalProcessByNameBlackBerryCommandLine(filePath, 9)); -} - -QString BlackBerryDeviceProcessSignalOperation::interruptProcessByNameCommandLine(const QString &filePath) const -{ - return signalProcessByNameBlackBerryCommandLine(filePath, 2); -} diff --git a/src/plugins/qnx/qnxdeviceprocesssignaloperation.h b/src/plugins/qnx/qnxdeviceprocesssignaloperation.h index c72fc6d2eb9..99b64324977 100644 --- a/src/plugins/qnx/qnxdeviceprocesssignaloperation.h +++ b/src/plugins/qnx/qnxdeviceprocesssignaloperation.h @@ -51,19 +51,6 @@ private: friend class QnxDeviceConfiguration; }; -class BlackBerryDeviceProcessSignalOperation : public RemoteLinux::RemoteLinuxSignalOperation -{ - Q_OBJECT -protected: - explicit BlackBerryDeviceProcessSignalOperation(const QSsh::SshConnectionParameters &sshParameters); - -private: - QString killProcessByNameCommandLine(const QString &filePath) const; - QString interruptProcessByNameCommandLine(const QString &filePath) const; - - friend class BlackBerryDeviceConfiguration; -}; - } // namespace Internal } // namespace Qnx diff --git a/src/plugins/qnx/qnxplugin.cpp b/src/plugins/qnx/qnxplugin.cpp index 8d499e7f559..d920785f407 100644 --- a/src/plugins/qnx/qnxplugin.cpp +++ b/src/plugins/qnx/qnxplugin.cpp @@ -32,14 +32,7 @@ #include "qnxplugin.h" -#include "blackberrydeviceconfigurationfactory.h" #include "qnxconstants.h" -#include "blackberryqtversionfactory.h" -#include "blackberrydeployconfigurationfactory.h" -#include "blackberrycreatepackagestepfactory.h" -#include "blackberrydeploystepfactory.h" -#include "blackberryrunconfigurationfactory.h" -#include "blackberryruncontrolfactory.h" #include "qnxattachdebugsupport.h" #include "qnxdeviceconfigurationfactory.h" #include "qnxruncontrolfactory.h" @@ -47,21 +40,10 @@ #include "qnxdeployconfigurationfactory.h" #include "qnxrunconfigurationfactory.h" #include "qnxqtversionfactory.h" -#include "blackberrysetuppage.h" -#include "blackberryndksettingspage.h" #include "qnxsettingspage.h" -#include "bardescriptoreditorfactory.h" -#include "blackberrykeyspage.h" -#include "blackberrycheckdevicestatusstepfactory.h" -#include "blackberrydeviceconnectionmanager.h" -#include "blackberryconfigurationmanager.h" #include "qnxconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" -#include "cascadesimport/cascadesimportwizard.h" #include "qnxtoolchain.h" #include "qnxattachdebugsupport.h" -#include "blackberrypotentialkit.h" -#include "bardescriptorfilenodemanager.h" #include <coreplugin/actionmanager/actioncontainer.h> #include <coreplugin/actionmanager/actionmanager.h> @@ -73,7 +55,6 @@ #include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/taskhub.h> #include <projectexplorer/kitmanager.h> -#include <utils/mimetypes/mimedatabase.h> #include <QAction> #include <QtPlugin> @@ -81,40 +62,14 @@ using namespace ProjectExplorer; using namespace Qnx::Internal; -QnxPlugin::QnxPlugin() - : m_debugSeparator(0) - , m_attachToQnxApplication(0) -{ -} - -QnxPlugin::~QnxPlugin() -{ - delete BlackBerryDeviceConnectionManager::instance(); -} +QnxPlugin::QnxPlugin() : m_debugSeparator(0) , m_attachToQnxApplication(0) +{ } bool QnxPlugin::initialize(const QStringList &arguments, QString *errorString) { Q_UNUSED(arguments) Q_UNUSED(errorString) - // Handles BlackBerry - addAutoReleasedObject(new BlackBerryConfigurationManager); - addAutoReleasedObject(new BlackBerryQtVersionFactory); - addAutoReleasedObject(new BlackBerryDeployConfigurationFactory); - addAutoReleasedObject(new BlackBerryDeviceConfigurationFactory); - addAutoReleasedObject(new BlackBerryCreatePackageStepFactory); - addAutoReleasedObject(new BlackBerryDeployStepFactory); - addAutoReleasedObject(new BlackBerryRunConfigurationFactory); - addAutoReleasedObject(new BlackBerryRunControlFactory); - addAutoReleasedObject(new BlackBerrySetupPage); - addAutoReleasedObject(new BlackBerryNDKSettingsPage); - addAutoReleasedObject(new BlackBerryKeysPage); - addAutoReleasedObject(new BlackBerryCheckDeviceStatusStepFactory); - addAutoReleasedObject(new CascadesImportWizard); - addAutoReleasedObject(new BlackBerryPotentialKit); - addAutoReleasedObject(new BarDescriptorFileNodeManager); - BlackBerryDeviceConnectionManager::instance()->initialize(); - // Handles QNX addAutoReleasedObject(new QnxConfigurationManager); addAutoReleasedObject(new QnxQtVersionFactory); @@ -128,20 +83,11 @@ bool QnxPlugin::initialize(const QStringList &arguments, QString *errorString) // Handle Qcc Compiler addAutoReleasedObject(new QnxToolChainFactory); - Utils::MimeDatabase::addMimeTypes(QLatin1String(":qnx/Qnx.mimetypes.xml")); - - addAutoReleasedObject(new BarDescriptorEditorFactory); - - connect(KitManager::instance(), SIGNAL(kitsLoaded()), - BlackBerryConfigurationManager::instance(), SLOT(loadSettings())); - return true; } void QnxPlugin::extensionsInitialized() { - TaskHub::addCategory(Constants::QNX_TASK_CATEGORY_BARDESCRIPTOR, tr("BAR Descriptor")); - // Debug support QnxAttachDebugSupport *debugSupport = new QnxAttachDebugSupport(this); @@ -179,345 +125,3 @@ void QnxPlugin::updateDebuggerActions() m_attachToQnxApplication->setVisible(hasValidQnxKit); m_debugSeparator->setVisible(hasValidQnxKit); } - -#ifdef WITH_TESTS -#include <QTest> - -#include "bardescriptordocument.h" - -void QnxPlugin::testBarDescriptorDocumentSetValue_data() -{ - QTest::addColumn<BarDescriptorDocument::Tag>("tag"); - QTest::addColumn<QVariant>("value"); - QTest::addColumn<QString>("baseXml"); - QTest::addColumn<QString>("xml"); - QTest::addColumn<bool>("compareResultValue"); - - QTest::newRow("new-id") << BarDescriptorDocument::id - << QVariant(QString::fromLatin1("my-application-id")) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <id>my-application-id</id>\n" - "</qnx>\n") - << true; - - QTest::newRow("changed-id") << BarDescriptorDocument::id - << QVariant(QString::fromLatin1("my-application-id")) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <id>some-application-id</id>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <id>my-application-id</id>\n" - "</qnx>\n") - << true; - - - QTest::newRow("removed-id") << BarDescriptorDocument::id - << QVariant(QString::fromLatin1("")) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <id>some-application-id</id>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << true; - - QStringList splashScreens; - splashScreens << QLatin1String("image1.png") - << QLatin1String("image2.png"); - QTest::newRow("new-splashScreens") << BarDescriptorDocument::splashScreens - << QVariant(splashScreens) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <splashScreens>\n" - " <image>image1.png</image>\n" - " <image>image2.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << true; - - QTest::newRow("changed-splashScreens") << BarDescriptorDocument::splashScreens - << QVariant(splashScreens) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <splashScreens>\n" - " <image>image3.png</image>\n" - " <image>image4.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <splashScreens>\n" - " <image>image1.png</image>\n" - " <image>image2.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << true; - - QTest::newRow("removed-splashScreens") << BarDescriptorDocument::splashScreens - << QVariant(QStringList()) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <splashScreens>\n" - " <image>image1.png</image>\n" - " <image>image2.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << true; - - BarDescriptorAsset asset1; - asset1.source = QLatin1String("/path/to/file"); - asset1.destination = QLatin1String("file"); - asset1.entry = false; - - BarDescriptorAsset asset2; - asset2.source = QLatin1String("/path/to/file2"); - asset2.destination = QLatin1String("file2"); - asset2.entry = false; // Cannot test "true", as "type" and "entry" attributes show up in seemingly arbitrary order - - BarDescriptorAssetList assetList1; - assetList1 << asset1 << asset2; - - QVariant assets; - assets.setValue(assetList1); - - QTest::newRow("new-assets") << BarDescriptorDocument::asset - << assets - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <asset path=\"/path/to/file\">file</asset>\n" - " <asset path=\"/path/to/file2\">file2</asset>\n" - "</qnx>\n") - << false; - - asset2.destination = QLatin1String("file3"); - BarDescriptorAssetList assetList2; - assetList2 << asset1 << asset2; - assets.setValue(assetList2); - - QTest::newRow("changed-assets") << BarDescriptorDocument::asset - << assets - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <asset path=\"/path/to/file\">file</asset>\n" - " <asset path=\"/path/to/file2\">file2</asset>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <asset path=\"/path/to/file\">file</asset>\n" - " <asset path=\"/path/to/file2\">file3</asset>\n" - "</qnx>\n") - << false; - - QTest::newRow("maintain-position") << BarDescriptorDocument::id - << QVariant(QString::fromLatin1("my-application-id")) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <asset path=\"/path/to/file\">file</asset>\n" - " <asset path=\"/path/to/file2\">file2</asset>\n" - " <id>some-application-id</id>\n" - " <splashScreens>\n" - " <image>image1.png</image>\n" - " <image>image2.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <asset path=\"/path/to/file\">file</asset>\n" - " <asset path=\"/path/to/file2\">file2</asset>\n" - " <id>my-application-id</id>\n" - " <splashScreens>\n" - " <image>image1.png</image>\n" - " <image>image2.png</image>\n" - " </splashScreens>\n" - "</qnx>\n") - << true; - - QTest::newRow("removed-icon") << BarDescriptorDocument::icon - << QVariant(QString()) - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\">\n" - " <icon>\n" - " <image>icon1.png</image>\n" - " </icon>\n" - "</qnx>\n") - << QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>\n" - "<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>\n") - << true; -} - -void QnxPlugin::testBarDescriptorDocumentSetValue() -{ - QFETCH(BarDescriptorDocument::Tag, tag); - QFETCH(QVariant, value); - QFETCH(QString, baseXml); - QFETCH(QString, xml); - QFETCH(bool, compareResultValue); - - BarDescriptorDocument doc; - doc.loadContent(baseXml, false); - QCOMPARE(doc.xmlSource(), baseXml); - - doc.setValue(tag, value); - QCOMPARE(doc.xmlSource(), xml); - QCOMPARE(doc.isModified(), true); - if (compareResultValue) - QCOMPARE(doc.value(tag), value); -} - -void QnxPlugin::testBarDescriptorDocumentSetBannerComment_data() -{ - QTest::addColumn<QString>("comment"); - QTest::addColumn<QString>("baseXml"); - QTest::addColumn<QString>("xml"); - - QString procInstr = QString::fromLatin1("<?xml version='1.0' encoding='UTF-8' standalone='no'?>"); - QString comment = QString::fromLatin1("This file is autogenerated, any change will be ..."); - QString xmlComment = QString::fromLatin1("<!--%1-->").arg(comment); - QString oldXmlComment = QString::fromLatin1("<!-- Some old banner comment -->"); - QString docRoot = QString::fromLatin1("<qnx xmlns=\"http://www.qnx.com/schemas/application/1.0\"/>"); - QChar lf = QChar::fromLatin1('\n'); - - QTest::newRow("new-comment") - << comment - << QString(procInstr + lf + docRoot + lf) - << QString(procInstr + lf + xmlComment + lf + docRoot + lf); - - QTest::newRow("new-comment-noproc") - << comment - << QString(docRoot + lf) - << QString(xmlComment + lf + docRoot + lf); - - QTest::newRow("replace-comment") - << comment - << QString(procInstr + lf + oldXmlComment + lf + docRoot + lf) - << QString(procInstr + lf + xmlComment + lf + docRoot + lf); - - QTest::newRow("replace-comment-noproc") - << comment - << QString(oldXmlComment + lf + docRoot + lf) - << QString(xmlComment + lf + docRoot + lf); - - QTest::newRow("remove-comment") - << QString() - << QString(procInstr + lf + oldXmlComment + lf + docRoot + lf) - << QString(procInstr + lf + docRoot + lf); - - QTest::newRow("remove-comment-noproc") - << QString() - << QString(oldXmlComment + lf + docRoot + lf) - << QString(docRoot + lf); - -} - -void QnxPlugin::testBarDescriptorDocumentSetBannerComment() -{ - QFETCH(QString, comment); - QFETCH(QString, baseXml); - QFETCH(QString, xml); - - BarDescriptorDocument doc; - doc.loadContent(baseXml, false); - QCOMPARE(doc.xmlSource(), baseXml); - - doc.setBannerComment(comment); - QCOMPARE(doc.xmlSource(), xml); - QCOMPARE(doc.isModified(), true); - QCOMPARE(doc.bannerComment(), comment); -} - -void QnxPlugin::testConfigurationManager_data() -{ - const QLatin1String NDKEnvFileKey("NDKEnvFile"); - const QLatin1String NDKPathKey("NDKPath"); - const QLatin1String NDKDisplayNameKey("NDKDisplayName"); - const QLatin1String NDKTargetKey("NDKTarget"); - const QLatin1String NDKHostKey("NDKHost"); - const QLatin1String NDKVersionKey("NDKVersion"); - const QLatin1String NDKAutoDetectionSourceKey("NDKAutoDetectionSource"); - const QLatin1String NDKAutoDetectedKey("NDKAutoDetectedKey"); - - QTest::addColumn<QVariantMap>("newerConfiguration"); - QTest::addColumn<QVariantMap>("olderConfiguration"); - - QVariantMap newerConfiguration; - newerConfiguration.insert(NDKEnvFileKey, QLatin1String("bbndk-env.sh")); - newerConfiguration.insert(NDKPathKey, QLatin1String("NDKPath")); - newerConfiguration.insert(NDKDisplayNameKey, QLatin1String("NDKDisplayName")); - newerConfiguration.insert(NDKTargetKey, QLatin1String("NDKTarget")); - newerConfiguration.insert(NDKHostKey, QLatin1String("NDKHost")); - newerConfiguration.insert(NDKVersionKey, QLatin1String("10.1.0.1008")); - newerConfiguration.insert(NDKAutoDetectionSourceKey, QLatin1String("NDKAutoDetectionSource")); - newerConfiguration.insert(NDKAutoDetectedKey, QLatin1String("NDKAutoDetectedKey")); - - QVariantMap olderConfiguration; - olderConfiguration.insert(NDKEnvFileKey, QLatin1String("bbndk-env2.sh")); - olderConfiguration.insert(NDKPathKey, QLatin1String("NDKPath")); - olderConfiguration.insert(NDKDisplayNameKey, QLatin1String("NDKDisplayName")); - olderConfiguration.insert(NDKTargetKey, QLatin1String("NDKTarget")); - olderConfiguration.insert(NDKHostKey, QLatin1String("NDKHost")); - newerConfiguration.insert(NDKVersionKey, QLatin1String("10.2.0.1008")); - olderConfiguration.insert(NDKAutoDetectionSourceKey, QLatin1String("NDKAutoDetectionSource")); - olderConfiguration.insert(NDKAutoDetectedKey, QLatin1String("NDKAutoDetectedKey")); - - QTest::newRow("configurations") << newerConfiguration << olderConfiguration;; -} - -void QnxPlugin::testConfigurationManager() -{ - BlackBerryConfigurationManager *manager = BlackBerryConfigurationManager::instance(); - manager->initUnitTest(); - - QCOMPARE(manager->apiLevels().count(), 0); - QCOMPARE(manager->activeApiLevels().count(), 0); - QCOMPARE(manager->defaultApiLevel(), static_cast<BlackBerryApiLevelConfiguration*>(0)); - QVERIFY(manager->newestApiLevelEnabled()); - - QFETCH(QVariantMap, newerConfiguration); - QFETCH(QVariantMap, olderConfiguration); - - BlackBerryApiLevelConfiguration::setFakeConfig(true); - BlackBerryApiLevelConfiguration *newerConfig = - new BlackBerryApiLevelConfiguration(newerConfiguration); - BlackBerryApiLevelConfiguration *oldConfig = - new BlackBerryApiLevelConfiguration(olderConfiguration); - - QVERIFY(manager->addApiLevel(oldConfig)); - QVERIFY(manager->newestApiLevelEnabled()); - QCOMPARE(manager->defaultApiLevel(), oldConfig); - - manager->setDefaultConfiguration(oldConfig); - - QCOMPARE(manager->defaultApiLevel(), oldConfig); - QCOMPARE(manager->apiLevels().first(), oldConfig); - QVERIFY(!manager->newestApiLevelEnabled()); - - QVERIFY(manager->addApiLevel(newerConfig)); - QCOMPARE(manager->apiLevels().first(), newerConfig); - QCOMPARE(manager->defaultApiLevel(), oldConfig); - - manager->setDefaultConfiguration(0); - QVERIFY(manager->newestApiLevelEnabled()); - QCOMPARE(manager->defaultApiLevel(), newerConfig); - - manager->setDefaultConfiguration(oldConfig); - manager->removeApiLevel(oldConfig); - QCOMPARE(manager->defaultApiLevel(), newerConfig); - QVERIFY(manager->newestApiLevelEnabled()); - - manager->removeApiLevel(newerConfig); - QCOMPARE(manager->defaultApiLevel(), static_cast<BlackBerryApiLevelConfiguration*>(0)); - QVERIFY(manager->newestApiLevelEnabled()); -} - -#endif diff --git a/src/plugins/qnx/qnxplugin.h b/src/plugins/qnx/qnxplugin.h index 69825e5222b..b666a57bec2 100644 --- a/src/plugins/qnx/qnxplugin.h +++ b/src/plugins/qnx/qnxplugin.h @@ -49,7 +49,6 @@ class QnxPlugin : public ExtensionSystem::IPlugin public: QnxPlugin(); - ~QnxPlugin(); bool initialize(const QStringList &arguments, QString *errorString); void extensionsInitialized(); @@ -57,16 +56,6 @@ public: private slots: void updateDebuggerActions(); -#ifdef WITH_TESTS - void testBarDescriptorDocumentSetValue_data(); - void testBarDescriptorDocumentSetValue(); - - void testBarDescriptorDocumentSetBannerComment_data(); - void testBarDescriptorDocumentSetBannerComment(); - - void testConfigurationManager_data(); - void testConfigurationManager(); -#endif private: QAction *m_debugSeparator; diff --git a/src/plugins/qnx/qnxqtversion.cpp b/src/plugins/qnx/qnxqtversion.cpp index a90424dc6c7..16c2563da16 100644 --- a/src/plugins/qnx/qnxqtversion.cpp +++ b/src/plugins/qnx/qnxqtversion.cpp @@ -32,25 +32,30 @@ #include "qnxqtversion.h" +#include "qnxbaseqtconfigwidget.h" #include "qnxconstants.h" - #include "qnxutils.h" #include <coreplugin/featureprovider.h> +#include <qtsupport/qtsupportconstants.h> +#include <utils/environment.h> #include <utils/hostosinfo.h> -#include <qtsupport/qtsupportconstants.h> +#include <QDir> -using namespace Qnx; -using namespace Qnx::Internal; +namespace Qnx { +namespace Internal { -QnxQtVersion::QnxQtVersion() - : QnxAbstractQtVersion() -{ -} +static char SDK_PATH_KEY[] = "SDKPath"; +static char ARCH_KEY[] = "Arch"; + +QnxQtVersion::QnxQtVersion() : m_arch(UnknownArch) +{ } -QnxQtVersion::QnxQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, const QString &autoDetectionSource) - : QnxAbstractQtVersion(arch, path, isAutoDetected, autoDetectionSource) +QnxQtVersion::QnxQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected, + const QString &autoDetectionSource) : + QtSupport::BaseQtVersion(path, isAutoDetected, autoDetectionSource), + m_arch(arch) { setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); } @@ -60,10 +65,6 @@ QnxQtVersion *QnxQtVersion::clone() const return new QnxQtVersion(*this); } -QnxQtVersion::~QnxQtVersion() -{ -} - QString QnxQtVersion::type() const { return QLatin1String(Constants::QNX_QNX_QT); @@ -72,12 +73,12 @@ QString QnxQtVersion::type() const QString QnxQtVersion::description() const { //: Qt Version is meant for QNX - return tr("QNX %1").arg(archString()); + return QCoreApplication::translate("Qnx::Internal::QnxQtVersion", "QNX %1").arg(archString()); } Core::FeatureSet QnxQtVersion::availableFeatures() const { - Core::FeatureSet features = QnxAbstractQtVersion::availableFeatures(); + Core::FeatureSet features = QtSupport::BaseQtVersion::availableFeatures(); features |= Core::FeatureSet(Constants::QNX_QNX_FEATURE); features.remove(Core::Feature(QtSupport::Constants::FEATURE_QT_CONSOLE)); features.remove(Core::Feature(QtSupport::Constants::FEATURE_QT_WEBKIT)); @@ -91,15 +92,137 @@ QString QnxQtVersion::platformName() const QString QnxQtVersion::platformDisplayName() const { - return tr("QNX"); + return QCoreApplication::translate("Qnx::Internal::QnxQtVersion", "QNX"); +} + +QString QnxQtVersion::qnxHost() const +{ + if (!m_environmentUpToDate) + updateEnvironment(); + + foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { + if (item.name == QLatin1String(Constants::QNX_HOST_KEY)) + return item.value; + } + + return QString(); +} + +QString QnxQtVersion::qnxTarget() const +{ + if (!m_environmentUpToDate) + updateEnvironment(); + + foreach (const Utils::EnvironmentItem &item, m_qnxEnv) { + if (item.name == QLatin1String(Constants::QNX_TARGET_KEY)) + return item.value; + } + + return QString(); +} + +QnxArchitecture QnxQtVersion::architecture() const +{ + return m_arch; +} + +QString QnxQtVersion::archString() const +{ + switch (m_arch) { + case X86: + return QLatin1String("x86"); + case ArmLeV7: + return QLatin1String("ARMle-v7"); + case UnknownArch: + return QString(); + } + return QString(); +} + +QVariantMap QnxQtVersion::toMap() const +{ + QVariantMap result = BaseQtVersion::toMap(); + result.insert(QLatin1String(SDK_PATH_KEY), sdkPath()); + result.insert(QLatin1String(ARCH_KEY), m_arch); + return result; +} + +void QnxQtVersion::fromMap(const QVariantMap &map) +{ + BaseQtVersion::fromMap(map); + setSdkPath(QDir::fromNativeSeparators(map.value(QLatin1String(SDK_PATH_KEY)).toString())); + m_arch = static_cast<QnxArchitecture>(map.value(QLatin1String(ARCH_KEY), UnknownArch).toInt()); +} + +QList<ProjectExplorer::Abi> QnxQtVersion::detectQtAbis() const +{ + ensureMkSpecParsed(); + return qtAbisFromLibrary(qtCorePaths(versionInfo(), qtVersionString())); +} + +void QnxQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const +{ + QtSupport::BaseQtVersion::addToEnvironment(k, env); + updateEnvironment(); + env.modify(m_qnxEnv); + + env.prependOrSetLibrarySearchPath(versionInfo().value(QLatin1String("QT_INSTALL_LIBS"))); +} + +Utils::Environment QnxQtVersion::qmakeRunEnvironment() const +{ + if (!sdkPath().isEmpty()) + updateEnvironment(); + + Utils::Environment env = Utils::Environment::systemEnvironment(); + env.modify(m_qnxEnv); + + return env; +} + +QtSupport::QtConfigWidget *QnxQtVersion::createConfigurationWidget() const +{ + return new QnxBaseQtConfigWidget(const_cast<QnxQtVersion *>(this)); +} + +bool QnxQtVersion::isValid() const +{ + return QtSupport::BaseQtVersion::isValid() && !sdkPath().isEmpty(); } -QString QnxQtVersion::sdkDescription() const +QString QnxQtVersion::invalidReason() const { - return tr("QNX Software Development Platform:"); + if (sdkPath().isEmpty()) + return QCoreApplication::translate("Qnx::Internal::QnxQtVersion", "No SDK path was set up"); + return QtSupport::BaseQtVersion::invalidReason(); +} + +QString QnxQtVersion::sdkPath() const +{ + return m_sdkPath; +} + +void QnxQtVersion::setSdkPath(const QString &sdkPath) +{ + if (m_sdkPath == sdkPath) + return; + + m_sdkPath = sdkPath; + m_environmentUpToDate = false; +} + +void QnxQtVersion::updateEnvironment() const +{ + if (!m_environmentUpToDate) { + m_qnxEnv = environment(); + m_environmentUpToDate = true; + } } QList<Utils::EnvironmentItem> QnxQtVersion::environment() const { return QnxUtils::qnxEnvironment(sdkPath()); } + +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxqtversion.h b/src/plugins/qnx/qnxqtversion.h index 9e1bf702dcc..13decd0d0b2 100644 --- a/src/plugins/qnx/qnxqtversion.h +++ b/src/plugins/qnx/qnxqtversion.h @@ -34,34 +34,64 @@ #define QNX_INTERNAL_QNXQTVERSION_H #include "qnxconstants.h" -#include "qnxabstractqtversion.h" +#include "qnxqtversion.h" + +#include <qtsupport/baseqtversion.h> + +#include <utils/environment.h> namespace Qnx { namespace Internal { -class QnxQtVersion : public QnxAbstractQtVersion +class QnxQtVersion : public QtSupport::BaseQtVersion { - Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxQtVersion) public: QnxQtVersion(); QnxQtVersion(QnxArchitecture arch, const Utils::FileName &path, bool isAutoDetected = false, const QString &autoDetectionSource = QString()); - QnxQtVersion *clone() const; - ~QnxQtVersion(); + QnxQtVersion *clone() const override; + + QString type() const override; + + QString description() const override; + + Core::FeatureSet availableFeatures() const override; + QString platformName() const override; + QString platformDisplayName() const override; + + QString qnxHost() const; + QString qnxTarget() const; - QString type() const; + QnxArchitecture architecture() const; + QString archString() const; - QString description() const; + QVariantMap toMap() const override; + void fromMap(const QVariantMap &map) override; - Core::FeatureSet availableFeatures() const; - QString platformName() const; - QString platformDisplayName() const; + QList<ProjectExplorer::Abi> detectQtAbis() const override; - QString sdkDescription() const; + void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const override; + Utils::Environment qmakeRunEnvironment() const override; + + QtSupport::QtConfigWidget *createConfigurationWidget() const override; + + bool isValid() const; + QString invalidReason() const; + + QString sdkPath() const; + void setSdkPath(const QString &sdkPath); private: + void updateEnvironment() const; + QList<Utils::EnvironmentItem> environment() const; + + QnxArchitecture m_arch; + QString m_sdkPath; + + mutable bool m_environmentUpToDate; + mutable QList<Utils::EnvironmentItem> m_qnxEnv; }; } // namespace Internal diff --git a/src/plugins/qnx/qnxqtversionfactory.cpp b/src/plugins/qnx/qnxqtversionfactory.cpp index e1a90441ef6..da9e0a1bb62 100644 --- a/src/plugins/qnx/qnxqtversionfactory.cpp +++ b/src/plugins/qnx/qnxqtversionfactory.cpp @@ -68,7 +68,7 @@ QtSupport::BaseQtVersion *QnxQtVersionFactory::restore(const QString &type, cons int QnxQtVersionFactory::priority() const { - return Constants::QNX_QNX_QT_FACTORY_PRIO; + return 50; } QtSupport::BaseQtVersion *QnxQtVersionFactory::create(const Utils::FileName &qmakePath, diff --git a/src/plugins/qnx/qnxsettingswidget.cpp b/src/plugins/qnx/qnxsettingswidget.cpp index 7b04b20e04b..f37ab39cdec 100644 --- a/src/plugins/qnx/qnxsettingswidget.cpp +++ b/src/plugins/qnx/qnxsettingswidget.cpp @@ -149,7 +149,7 @@ void QnxSettingsWidget::updateInformation() m_ui->generateKitsCheckBox->setChecked(config ? config->isActive() : false); // update information - m_ui->configName->setText(config? config->displayName() : QString()); + m_ui->configName->setText(config ? config->displayName() : QString()); m_ui->configVersion->setText(config ? config->version().toString() : QString()); m_ui->configHost->setText(config ? config->qnxHost().toString() : QString()); m_ui->configTarget->setText(config ? config->qnxTarget().toString() : QString()); @@ -187,8 +187,7 @@ void QnxSettingsWidget::setConfigState(QnxConfiguration *config, } foreach (const ConfigState &configState, m_changedConfigs) { - if (configState.config == config - && configState.state == stateToRemove) + if (configState.config == config && configState.state == stateToRemove) m_changedConfigs.removeAll(configState); } @@ -218,5 +217,5 @@ void QnxSettingsWidget::applyChanges() m_changedConfigs.clear(); } -} -} +} // namespace Internal +} // namespace Qnx diff --git a/src/plugins/qnx/qnxtoolchain.cpp b/src/plugins/qnx/qnxtoolchain.cpp index e21b9b0829d..6d59cea7b48 100644 --- a/src/plugins/qnx/qnxtoolchain.cpp +++ b/src/plugins/qnx/qnxtoolchain.cpp @@ -34,9 +34,6 @@ #include "qnxconstants.h" #include "qnxutils.h" -#include "blackberryconfigurationmanager.h" -#include "blackberryapilevelconfiguration.h" - #include <utils/pathchooser.h> #include <QFormLayout> @@ -88,14 +85,6 @@ ToolChainConfigWidget *QnxToolChain::configurationWidget() void QnxToolChain::addToEnvironment(Utils::Environment &env) const { - foreach (BlackBerryApiLevelConfiguration *config, - BlackBerryConfigurationManager::instance()->apiLevels()) { - if (config->qccCompilerPath() == compilerCommand()) { - setQnxEnvironment(env, config->qnxEnv()); - break; - } - } - if (env.value(QLatin1String("QNX_HOST")).isEmpty() || env.value(QLatin1String("QNX_TARGET")).isEmpty()) setQnxEnvironment(env, QnxUtils::qnxEnvironment(m_ndkPath)); @@ -109,9 +98,6 @@ QList<Utils::FileName> QnxToolChain::suggestedMkspecList() const mkspecList << Utils::FileName::fromLatin1("qnx-armv7le-qcc"); mkspecList << Utils::FileName::fromLatin1("qnx-armle-v7-qcc"); mkspecList << Utils::FileName::fromLatin1("qnx-x86-qcc"); - mkspecList << Utils::FileName::fromLatin1("blackberry-armv7le-qcc"); - mkspecList << Utils::FileName::fromLatin1("blackberry-armle-v7-qcc"); - mkspecList << Utils::FileName::fromLatin1("blackberry-x86-qcc"); return mkspecList; } diff --git a/src/plugins/qnx/qnxutils.cpp b/src/plugins/qnx/qnxutils.cpp index 3472f8ec959..b61afe28252 100644 --- a/src/plugins/qnx/qnxutils.cpp +++ b/src/plugins/qnx/qnxutils.cpp @@ -31,7 +31,7 @@ ****************************************************************************/ #include "qnxutils.h" -#include "qnxabstractqtversion.h" +#include "qnxqtversion.h" #include <utils/hostosinfo.h> #include <utils/synchronousprocess.h> @@ -68,7 +68,7 @@ QnxArchitecture QnxUtils::cpudirToArch(const QString &cpuDir) return UnknownArch; } -QStringList QnxUtils::searchPaths(QnxAbstractQtVersion *qtVersion) +QStringList QnxUtils::searchPaths(QnxQtVersion *qtVersion) { const QDir pluginDir(qtVersion->versionInfo().value(QLatin1String("QT_INSTALL_PLUGINS"))); const QStringList pluginSubDirs = pluginDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); diff --git a/src/plugins/qnx/qnxutils.h b/src/plugins/qnx/qnxutils.h index 6fe75425a87..32842081873 100644 --- a/src/plugins/qnx/qnxutils.h +++ b/src/plugins/qnx/qnxutils.h @@ -45,7 +45,7 @@ namespace Qnx { namespace Internal { -class QnxAbstractQtVersion; +class QnxQtVersion; class ConfigInstallInformation { @@ -66,7 +66,7 @@ class QnxUtils public: static QString addQuotes(const QString &string); static Qnx::QnxArchitecture cpudirToArch(const QString &cpuDir); - static QStringList searchPaths(QnxAbstractQtVersion *qtVersion); + static QStringList searchPaths(Qnx::Internal::QnxQtVersion *qtVersion); static QList<Utils::EnvironmentItem> qnxEnvironmentFromEnvFile(const QString &fileName); static bool isValidNdkPath(const QString & ndkPath); static QString envFilePath(const QString & ndkPath, const QString& targetVersion = QString()); diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index 4e63381c514..7a8d69e52ca 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -236,24 +236,80 @@ void BaseQtVersion::ctor(const FileName &qmakePath) void BaseQtVersion::setupExpander() { m_expander.setDisplayName( - QCoreApplication::translate("QtSupport::QtKitInformation", "Qt version")); + QtKitInformation::tr("Qt version")); m_expander.registerVariable("Qt:Version", - QCoreApplication::translate("QtSupport::QtKitInformation", "The version string of the current Qt version."), - [this]() { return qtVersionString(); }); + QtKitInformation::tr("The version string of the current Qt version."), + [this] { return qtVersionString(); }); m_expander.registerVariable("Qt:Type", - QCoreApplication::translate("QtSupport::QtKitInformation", "The type of the current Qt version."), - [this]() { return type(); }); + QtKitInformation::tr("The type of the current Qt version."), + [this] { return type(); }); m_expander.registerVariable("Qt:Mkspec", - QCoreApplication::translate("QtSupport::QtKitInformation", "The mkspec of the current Qt version."), - [this]() { return mkspec().toUserOutput(); }); + QtKitInformation::tr("The mkspec of the current Qt version."), + [this] { return mkspec().toUserOutput(); }); + + m_expander.registerVariable("Qt:QT_INSTALL_PREFIX", + QtKitInformation::tr("The installation prefix of the current Qt version."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_PREFIX"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_DATA", + QtKitInformation::tr("The installation location of the current Qt version's data."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_DATA"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_HEADERS", + QtKitInformation::tr("The installation location of the current Qt version's header files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_HEADERS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_LIBS", + QtKitInformation::tr("The installation location of the current Qt version's library files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_LIBS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_DOCS", + QtKitInformation::tr("The installation location of the current Qt version's documentation files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_DOCS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_BINS", + QtKitInformation::tr("The installation location of the current Qt version's executable files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_BINS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_PLUGINS", + QtKitInformation::tr("The installation location of the current Qt version's plugins."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_PLUGINS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_IMPORTS", + QtKitInformation::tr("The installation location of the current Qt version's imports."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_IMPORTS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_TRANSLATIONS", + QtKitInformation::tr("The installation location of the current Qt version's translation files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_TRANSLATIONS"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_CONFIGURATION", + QtKitInformation::tr("The installation location of the current Qt version's translation files."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_CONFIGURATION"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_EXAMPLES", + QtKitInformation::tr("The installation location of the current Qt version's examples."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_EXAMPLES"); }); + + m_expander.registerVariable("Qt:QT_INSTALL_DEMOS", + QtKitInformation::tr("The installation location of the current Qt version's demos."), + [this] { return qmakeProperty(m_versionInfo, "QT_INSTALL_DEMOS"); }); + + m_expander.registerVariable("Qt:QMAKE_MKSPECS", + QtKitInformation::tr("The current Qt version's default mkspecs."), + [this] { return qmakeProperty(m_versionInfo, "QMAKE_MKSPECS"); }); + + m_expander.registerVariable("Qt:QMAKE_VERSION", + QtKitInformation::tr("The current Qt's qmake version."), + [this] { return qmakeProperty(m_versionInfo, "QMAKE_VERSION"); }); // FIXME: Re-enable once we can detect expansion loops. // m_expander.registerVariable("Qt:Name", -// QCoreApplication::translate("QtSupport::QtKitInformation", "The display name of the current Qt version."), -// [this]() { return displayName(); }); +// QtKitInformation::tr("The display name of the current Qt version."), +// [this] { return displayName(); }); } BaseQtVersion::~BaseQtVersion() @@ -1127,14 +1183,6 @@ MacroExpander *BaseQtVersion::macroExpander() const return &m_expander; } -QList<HeaderPath> BaseQtVersion::systemHeaderPathes(const Kit *k) const -{ - Q_UNUSED(k); - QList<HeaderPath> result; - result.append(HeaderPath(mkspecPath().toString(), HeaderPath::GlobalHeaderPath)); - return result; -} - void BaseQtVersion::addToEnvironment(const Kit *k, Environment &env) const { Q_UNUSED(k); diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index 728466ab8a2..8c354fe555c 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -146,7 +146,6 @@ public: bool hasDemos() const; QString demosPath() const; - virtual QList<ProjectExplorer::HeaderPath> systemHeaderPathes(const ProjectExplorer::Kit *k) const; virtual QString frameworkInstallPath() const; // former local functions diff --git a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp index 1f105805a72..12410cbe2aa 100644 --- a/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp +++ b/src/plugins/qtsupport/customexecutableconfigurationwidget.cpp @@ -33,8 +33,10 @@ #include <coreplugin/variablechooser.h> #include <projectexplorer/environmentaspect.h> +#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> #include <projectexplorer/project.h> +#include <projectexplorer/runconfigurationaspects.h> #include <utils/detailswidget.h> #include <utils/pathchooser.h> @@ -45,12 +47,16 @@ #include <QLabel> #include <QLineEdit> +using namespace ProjectExplorer; namespace QtSupport { namespace Internal { CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode) - : m_ignoreChange(false), m_runConfiguration(rc) + : m_ignoreChange(false), + m_runConfiguration(rc), + m_temporaryArgumentsAspect(0), + m_temporaryTerminalAspect(0) { QFormLayout *layout = new QFormLayout; layout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); @@ -61,9 +67,15 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE m_executableChooser->setExpectedKind(Utils::PathChooser::Command); layout->addRow(tr("Executable:"), m_executableChooser); - m_commandLineArgumentsLineEdit = new QLineEdit(this); - m_commandLineArgumentsLineEdit->setMinimumWidth(200); // this shouldn't be fixed here... - layout->addRow(tr("Arguments:"), m_commandLineArgumentsLineEdit); + ArgumentsAspect *argumentsAspect = rc->extraAspect<ArgumentsAspect>(); + if (mode == InstantApply) { + argumentsAspect->addToMainConfigurationWidget(this, layout); + } else { + m_temporaryArgumentsAspect = argumentsAspect->clone(rc); + m_temporaryArgumentsAspect->addToMainConfigurationWidget(this, layout); + connect(m_temporaryArgumentsAspect, &ArgumentsAspect::argumentsChanged, + this, &CustomExecutableConfigurationWidget::validChanged); + } m_workingDirectory = new Utils::PathChooser(this); m_workingDirectory->setHistoryCompleter(QLatin1String("Qt.WorkingDir.History")); @@ -72,8 +84,15 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE layout->addRow(tr("Working directory:"), m_workingDirectory); - m_useTerminalCheck = new QCheckBox(tr("Run in &terminal"), this); - layout->addRow(QString(), m_useTerminalCheck); + TerminalAspect *terminalAspect = rc->extraAspect<TerminalAspect>(); + if (mode == InstantApply) { + terminalAspect->addToMainConfigurationWidget(this, layout); + } else { + m_temporaryTerminalAspect = terminalAspect->clone(rc); + m_temporaryTerminalAspect->addToMainConfigurationWidget(this, layout); + connect(m_temporaryTerminalAspect, &TerminalAspect::useTerminalChanged, + this, &CustomExecutableConfigurationWidget::validChanged); + } QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); @@ -91,21 +110,13 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE if (mode == InstantApply) { connect(m_executableChooser, SIGNAL(changed(QString)), this, SLOT(executableEdited())); - connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)), - this, SLOT(argumentsEdited(QString))); connect(m_workingDirectory, SIGNAL(changed(QString)), this, SLOT(workingDirectoryEdited())); - connect(m_useTerminalCheck, SIGNAL(toggled(bool)), - this, SLOT(termToggled(bool))); } else { connect(m_executableChooser, SIGNAL(changed(QString)), this, SIGNAL(validChanged())); - connect(m_commandLineArgumentsLineEdit, SIGNAL(textEdited(QString)), - this, SIGNAL(validChanged())); connect(m_workingDirectory, SIGNAL(changed(QString)), this, SIGNAL(validChanged())); - connect(m_useTerminalCheck, SIGNAL(toggled(bool)), - this, SIGNAL(validChanged())); } ProjectExplorer::EnvironmentAspect *aspect = rc->extraAspect<ProjectExplorer::EnvironmentAspect>(); @@ -123,6 +134,12 @@ CustomExecutableConfigurationWidget::CustomExecutableConfigurationWidget(CustomE Core::VariableChooser::addSupportForChildWidgets(this, m_runConfiguration->macroExpander()); } +CustomExecutableConfigurationWidget::~CustomExecutableConfigurationWidget() +{ + delete m_temporaryArgumentsAspect; + delete m_temporaryTerminalAspect; +} + void CustomExecutableConfigurationWidget::environmentWasChanged() { ProjectExplorer::EnvironmentAspect *aspect @@ -138,12 +155,7 @@ void CustomExecutableConfigurationWidget::executableEdited() m_runConfiguration->setExecutable(m_executableChooser->rawPath()); m_ignoreChange = false; } -void CustomExecutableConfigurationWidget::argumentsEdited(const QString &arguments) -{ - m_ignoreChange = true; - m_runConfiguration->setCommandLineArguments(arguments); - m_ignoreChange = false; -} + void CustomExecutableConfigurationWidget::workingDirectoryEdited() { m_ignoreChange = true; @@ -151,14 +163,6 @@ void CustomExecutableConfigurationWidget::workingDirectoryEdited() m_ignoreChange = false; } -void CustomExecutableConfigurationWidget::termToggled(bool on) -{ - m_ignoreChange = true; - m_runConfiguration->setRunMode(on ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui); - m_ignoreChange = false; -} - void CustomExecutableConfigurationWidget::changed() { // We triggered the change, don't update us @@ -166,20 +170,16 @@ void CustomExecutableConfigurationWidget::changed() return; m_executableChooser->setPath(m_runConfiguration->rawExecutable()); - m_commandLineArgumentsLineEdit->setText(m_runConfiguration->rawCommandLineArguments()); m_workingDirectory->setPath(m_runConfiguration->baseWorkingDirectory()); - m_useTerminalCheck->setChecked(m_runConfiguration->runMode() - == ProjectExplorer::ApplicationLauncher::Console); } void CustomExecutableConfigurationWidget::apply() { m_ignoreChange = true; m_runConfiguration->setExecutable(m_executableChooser->rawPath()); - m_runConfiguration->setCommandLineArguments(m_commandLineArgumentsLineEdit->text()); + m_runConfiguration->setCommandLineArguments(m_temporaryArgumentsAspect->unexpandedArguments()); m_runConfiguration->setBaseWorkingDirectory(m_workingDirectory->rawPath()); - m_runConfiguration->setRunMode(m_useTerminalCheck->isChecked() ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui); + m_runConfiguration->setRunMode(m_temporaryTerminalAspect->runMode()); m_ignoreChange = false; } diff --git a/src/plugins/qtsupport/customexecutableconfigurationwidget.h b/src/plugins/qtsupport/customexecutableconfigurationwidget.h index e31664404a0..3668c09ff7e 100644 --- a/src/plugins/qtsupport/customexecutableconfigurationwidget.h +++ b/src/plugins/qtsupport/customexecutableconfigurationwidget.h @@ -46,6 +46,11 @@ class DetailsWidget; class PathChooser; } +namespace ProjectExplorer { +class ArgumentsAspect; +class TerminalAspect; +} + namespace QtSupport { class CustomExecutableRunConfiguration; @@ -58,6 +63,8 @@ class CustomExecutableConfigurationWidget : public QWidget public: enum ApplyMode { InstantApply, DelayedApply}; CustomExecutableConfigurationWidget(CustomExecutableRunConfiguration *rc, ApplyMode mode); + ~CustomExecutableConfigurationWidget(); + void apply(); // only used for DelayedApply bool isValid() const; @@ -68,18 +75,16 @@ private slots: void changed(); void executableEdited(); - void argumentsEdited(const QString &arguments); void workingDirectoryEdited(); - void termToggled(bool); void environmentWasChanged(); private: bool m_ignoreChange; CustomExecutableRunConfiguration *m_runConfiguration; + ProjectExplorer::ArgumentsAspect *m_temporaryArgumentsAspect; + ProjectExplorer::TerminalAspect *m_temporaryTerminalAspect; Utils::PathChooser *m_executableChooser; - QLineEdit *m_commandLineArgumentsLineEdit; Utils::PathChooser *m_workingDirectory; - QCheckBox *m_useTerminalCheck; Utils::DetailsWidget *m_detailsContainer; }; diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp index 229751b5d93..a96077bf85b 100644 --- a/src/plugins/qtsupport/customexecutablerunconfiguration.cpp +++ b/src/plugins/qtsupport/customexecutablerunconfiguration.cpp @@ -35,6 +35,7 @@ #include <projectexplorer/buildconfiguration.h> #include <projectexplorer/localenvironmentaspect.h> #include <projectexplorer/project.h> +#include <projectexplorer/runconfigurationaspects.h> #include <projectexplorer/target.h> #include <projectexplorer/abi.h> @@ -59,9 +60,7 @@ namespace { const char CUSTOM_EXECUTABLE_ID[] = "ProjectExplorer.CustomExecutableRunConfiguration"; const char EXECUTABLE_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Executable"; -const char ARGUMENTS_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.Arguments"; const char WORKING_DIRECTORY_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"; -const char USE_TERMINAL_KEY[] = "ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"; } void CustomExecutableRunConfiguration::ctor() @@ -72,11 +71,11 @@ void CustomExecutableRunConfiguration::ctor() CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *parent) : LocalApplicationRunConfiguration(parent, Core::Id(CUSTOM_EXECUTABLE_ID)), m_workingDirectory(QLatin1String(Constants::DEFAULT_WORKING_DIR)), - m_runMode(ProjectExplorer::ApplicationLauncher::Gui), m_dialog(0) { addExtraAspect(new LocalEnvironmentAspect(this)); - + addExtraAspect(new ArgumentsAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.Arguments"))); + addExtraAspect(new TerminalAspect(this, QStringLiteral("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"))); if (!parent->activeBuildConfiguration()) m_workingDirectory = QLatin1String(Constants::DEFAULT_WORKING_DIR_ALTERNATE); ctor(); @@ -87,8 +86,6 @@ CustomExecutableRunConfiguration::CustomExecutableRunConfiguration(Target *paren LocalApplicationRunConfiguration(parent, source), m_executable(source->m_executable), m_workingDirectory(source->m_workingDirectory), - m_cmdArguments(source->m_cmdArguments), - m_runMode(source->m_runMode), m_dialog(0) { ctor(); @@ -246,7 +243,7 @@ bool CustomExecutableRunConfiguration::isConfigured() const ApplicationLauncher::Mode CustomExecutableRunConfiguration::runMode() const { - return m_runMode; + return extraAspect<TerminalAspect>()->runMode(); } QString CustomExecutableRunConfiguration::workingDirectory() const @@ -265,12 +262,7 @@ QString CustomExecutableRunConfiguration::baseWorkingDirectory() const QString CustomExecutableRunConfiguration::commandLineArguments() const { - return macroExpander()->expandProcessArgs(m_cmdArguments); -} - -QString CustomExecutableRunConfiguration::rawCommandLineArguments() const -{ - return m_cmdArguments; + return extraAspect<ArgumentsAspect>()->arguments(); } QString CustomExecutableRunConfiguration::defaultDisplayName() const @@ -285,21 +277,14 @@ QVariantMap CustomExecutableRunConfiguration::toMap() const { QVariantMap map(LocalApplicationRunConfiguration::toMap()); map.insert(QLatin1String(EXECUTABLE_KEY), m_executable); - map.insert(QLatin1String(ARGUMENTS_KEY), m_cmdArguments); map.insert(QLatin1String(WORKING_DIRECTORY_KEY), m_workingDirectory); - map.insert(QLatin1String(USE_TERMINAL_KEY), - m_runMode == ProjectExplorer::ApplicationLauncher::Console); return map; } bool CustomExecutableRunConfiguration::fromMap(const QVariantMap &map) { m_executable = map.value(QLatin1String(EXECUTABLE_KEY)).toString(); - m_cmdArguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString(); m_workingDirectory = map.value(QLatin1String(WORKING_DIRECTORY_KEY)).toString(); - m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() - ? ProjectExplorer::ApplicationLauncher::Console - : ProjectExplorer::ApplicationLauncher::Gui; setDefaultDisplayName(defaultDisplayName()); return LocalApplicationRunConfiguration::fromMap(map); @@ -316,7 +301,7 @@ void CustomExecutableRunConfiguration::setExecutable(const QString &executable) void CustomExecutableRunConfiguration::setCommandLineArguments(const QString &commandLineArguments) { - m_cmdArguments = commandLineArguments; + extraAspect<ArgumentsAspect>()->setArguments(commandLineArguments); emit changed(); } @@ -328,7 +313,7 @@ void CustomExecutableRunConfiguration::setBaseWorkingDirectory(const QString &wo void CustomExecutableRunConfiguration::setRunMode(ApplicationLauncher::Mode runMode) { - m_runMode = runMode; + extraAspect<TerminalAspect>()->setRunMode(runMode); emit changed(); } diff --git a/src/plugins/qtsupport/customexecutablerunconfiguration.h b/src/plugins/qtsupport/customexecutablerunconfiguration.h index 3f4fb84c3b3..2e6817db4b3 100644 --- a/src/plugins/qtsupport/customexecutablerunconfiguration.h +++ b/src/plugins/qtsupport/customexecutablerunconfiguration.h @@ -94,7 +94,6 @@ private: void setExecutable(const QString &executable); QString rawExecutable() const; void setCommandLineArguments(const QString &commandLineArguments); - QString rawCommandLineArguments() const; void setBaseWorkingDirectory(const QString &workingDirectory); QString baseWorkingDirectory() const; void setUserName(const QString &name); @@ -103,7 +102,6 @@ private: QString m_executable; QString m_workingDirectory; - QString m_cmdArguments; ProjectExplorer::ApplicationLauncher::Mode m_runMode; QWidget *m_dialog; }; diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 7a6ab92ff68..4268c645ccc 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -403,9 +403,13 @@ void ExamplesWelcomePage::openProject(const QString &projectFile, if (!proFileInfo.exists()) return; + QFileInfo pathInfo(proFileInfo.path()); // If the Qt is a distro Qt on Linux, it will not be writable, hence compilation will fail - if (!proFileInfo.isWritable()) + if (!proFileInfo.isWritable() + || !pathInfo.isWritable() /* path of .pro file */ + || !QFileInfo(pathInfo.path()).isWritable() /* shadow build directory */) { proFile = copyToAlternativeLocation(proFileInfo, filesToOpen, dependencies); + } // don't try to load help and files if loading the help request is being cancelled QString errorMessage; diff --git a/src/plugins/qtsupport/qmldumptool.cpp b/src/plugins/qtsupport/qmldumptool.cpp index 29ff55b8038..de4bf8725ab 100644 --- a/src/plugins/qtsupport/qmldumptool.cpp +++ b/src/plugins/qtsupport/qmldumptool.cpp @@ -196,10 +196,9 @@ bool QmlDumpTool::canBuild(const BaseQtVersion *qtVersion, QString *reason) { const QString installHeaders = qtVersion->qmakeProperty("QT_INSTALL_HEADERS"); - if (qtVersion->type() != QLatin1String(Constants::DESKTOPQT) - && qtVersion->type() != QLatin1String(Constants::SIMULATORQT)) { + if (qtVersion->type() != QLatin1String(Constants::DESKTOPQT)) { if (reason) - *reason = QCoreApplication::translate("QmakeProjectManager::QmlDumpTool", "Only available for Qt for Desktop and Qt for Qt Simulator."); + *reason = QCoreApplication::translate("QmakeProjectManager::QmlDumpTool", "Only available for Qt for Desktop."); return false; } if (qtVersion->qtVersion() < QtVersionNumber(4, 7, 1)) { diff --git a/src/plugins/qtsupport/qtparser.cpp b/src/plugins/qtsupport/qtparser.cpp index 79b031abe72..7ceb11ac6e4 100644 --- a/src/plugins/qtsupport/qtparser.cpp +++ b/src/plugins/qtsupport/qtparser.cpp @@ -66,7 +66,7 @@ void QtParser::stdError(const QString &line) Utils::FileName::fromUserInput(m_mocRegExp.cap(1)) /* filename */, lineno, ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } if (m_translationRegExp.indexIn(lne) > -1) { @@ -77,7 +77,7 @@ void QtParser::stdError(const QString &line) Utils::FileName::fromUserInput(m_translationRegExp.cap(3)) /* filename */, -1, ProjectExplorer::Constants::TASK_CATEGORY_COMPILE); - emit addTask(task); + emit addTask(task, 1); return; } IOutputParser::stdError(line); diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro index 94c772e2d4b..d88624a2b02 100644 --- a/src/plugins/qtsupport/qtsupport.pro +++ b/src/plugins/qtsupport/qtsupport.pro @@ -32,9 +32,7 @@ HEADERS += \ screenshotcropper.h \ qtconfigwidget.h \ desktopqtversionfactory.h \ - simulatorqtversionfactory.h \ desktopqtversion.h \ - simulatorqtversion.h \ winceqtversionfactory.h \ winceqtversion.h @@ -62,9 +60,7 @@ SOURCES += \ screenshotcropper.cpp \ qtconfigwidget.cpp \ desktopqtversionfactory.cpp \ - simulatorqtversionfactory.cpp \ desktopqtversion.cpp \ - simulatorqtversion.cpp \ winceqtversionfactory.cpp \ winceqtversion.cpp diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs index 9b43f4bb98b..038d9a43421 100644 --- a/src/plugins/qtsupport/qtsupport.qbs +++ b/src/plugins/qtsupport/qtsupport.qbs @@ -4,7 +4,6 @@ QtcPlugin { name: "QtSupport" Depends { name: "Qt"; submodules: ["quick", "widgets", "xml"]; } - Depends { name: "Aggregation" } Depends { name: "QmlJS" } Depends { name: "Utils" } @@ -115,8 +114,6 @@ QtcPlugin { files: [ "desktopqtversion.cpp", "desktopqtversion.h", "desktopqtversionfactory.cpp", "desktopqtversionfactory.h", - "simulatorqtversion.cpp", "simulatorqtversion.h", - "simulatorqtversionfactory.cpp", "simulatorqtversionfactory.h", "winceqtversion.cpp", "winceqtversion.h", "winceqtversionfactory.cpp", "winceqtversionfactory.h", ] diff --git a/src/plugins/qtsupport/qtsupport_dependencies.pri b/src/plugins/qtsupport/qtsupport_dependencies.pri index 9adcd996e94..65916934676 100644 --- a/src/plugins/qtsupport/qtsupport_dependencies.pri +++ b/src/plugins/qtsupport/qtsupport_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = QtSupport QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ qmljs \ utils diff --git a/src/plugins/qtsupport/qtsupportconstants.h b/src/plugins/qtsupport/qtsupportconstants.h index 58f9067766f..941a58d8f54 100644 --- a/src/plugins/qtsupport/qtsupportconstants.h +++ b/src/plugins/qtsupport/qtsupportconstants.h @@ -43,7 +43,6 @@ const char CODEGEN_SETTINGS_PAGE_NAME[] = QT_TRANSLATE_NOOP("QtSupport", "Qt Cla // QtVersions const char DESKTOPQT[] = "Qt4ProjectManager.QtVersion.Desktop"; -const char SIMULATORQT[] = "Qt4ProjectManager.QtVersion.Simulator"; const char WINCEQT[] = "Qt4ProjectManager.QtVersion.WinCE"; // BaseQtVersion settings @@ -94,11 +93,6 @@ const char WINDOWS_PHONE_PLATFORM_TR[] = QT_TRANSLATE_NOOP("QtSupport", "Windows const char ANDROID_PLATFORM_TR[] = QT_TRANSLATE_NOOP("QtSupport", "Android"); const char IOS_PLATFORM_TR[] = QT_TRANSLATE_NOOP("QtSupport", "iOS"); -// QML wizard icon -// both the qmakeprojectmanager and the qmlprojectmanager do have qt quick wizards -// so we define the icon here -const char QML_WIZARD_ICON[] = ":/qmlproject/images/qml_wizard.png"; - const char ICON_QT_PROJECT[] = ":/qtsupport/images/qt_project.png"; } // namepsace Constants diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 8de3090decf..fd7ba562f9b 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -38,7 +38,6 @@ #include "qtkitinformation.h" #include "qtoptionspage.h" #include "qtversionmanager.h" -#include "simulatorqtversionfactory.h" #include "uicodemodelsupport.h" #include "winceqtversionfactory.h" @@ -77,7 +76,6 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes addAutoReleasedObject(new QtVersionManager); addAutoReleasedObject(new DesktopQtVersionFactory); - addAutoReleasedObject(new SimulatorQtVersionFactory); addAutoReleasedObject(new WinCeQtVersionFactory); addAutoReleasedObject(new UiCodeModelManager); diff --git a/src/plugins/qtsupport/qtversionmanager.cpp b/src/plugins/qtsupport/qtversionmanager.cpp index f4daf2a5e14..7298eb319e8 100644 --- a/src/plugins/qtsupport/qtversionmanager.cpp +++ b/src/plugins/qtsupport/qtversionmanager.cpp @@ -54,6 +54,7 @@ #include <QDir> #include <QFile> #include <QSettings> +#include <QStandardPaths> #include <QTextStream> #include <QStringList> #include <QTimer> @@ -397,17 +398,67 @@ static void saveQtVersions() m_writer->save(data, Core::ICore::mainWindow()); } +// Executes qtchooser with arguments in a process and returns its output +static QList<QByteArray> runQtChooser(const QString &qtchooser, const QStringList &arguments) +{ + QProcess p; + p.start(qtchooser, arguments); + p.waitForFinished(); + const bool success = p.exitCode() == 0; + return success ? p.readAllStandardOutput().split('\n') : QList<QByteArray>(); +} + +// Asks qtchooser for the qmake path of a given version +static QString qmakePath(const QString &qtchooser, const QString &version) +{ + QList<QByteArray> outputs = runQtChooser(qtchooser, QStringList() + << QStringLiteral("-qt=%1").arg(version) + << QStringLiteral("-print-env")); + foreach (const QByteArray &output, outputs) { + if (output.startsWith("QTTOOLDIR=\"")) { + QByteArray withoutVarName = output.mid(11); // remove QTTOOLDIR=" + withoutVarName.chop(1); // remove trailing quote + return QStandardPaths::findExecutable(QStringLiteral("qmake"), QStringList() + << QString::fromLocal8Bit(withoutVarName)); + } + } + return QString(); +} + +static FileNameList gatherQmakePathsFromQtChooser() +{ + const QString qtchooser = QStandardPaths::findExecutable(QStringLiteral("qtchooser")); + if (qtchooser.isEmpty()) + return FileNameList(); + + QList<QByteArray> versions = runQtChooser(qtchooser, QStringList() << QStringLiteral("-l")); + QSet<FileName> foundQMakes; + foreach (const QByteArray &version, versions) { + FileName possibleQMake = FileName::fromString( + qmakePath(qtchooser, QString::fromLocal8Bit(version))); + if (!possibleQMake.isEmpty()) + foundQMakes << possibleQMake; + } + return foundQMakes.toList(); +} + static void findSystemQt() { + FileNameList systemQMakes; FileName systemQMakePath = BuildableHelperLibrary::findSystemQt(Environment::systemEnvironment()); - if (systemQMakePath.isNull()) - return; - - BaseQtVersion *version - = QtVersionFactory::createQtVersionFromQMakePath(systemQMakePath, false, QLatin1String("PATH")); - if (version) { - version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(systemQMakePath, true)); - m_versions.insert(version->uniqueId(), version); + if (!systemQMakePath.isEmpty()) + systemQMakes << systemQMakePath; + + systemQMakes.append(gatherQmakePathsFromQtChooser()); + systemQMakes.removeDuplicates(); + + foreach (const FileName &qmakePath, systemQMakes) { + BaseQtVersion *version + = QtVersionFactory::createQtVersionFromQMakePath(qmakePath, false, QLatin1String("PATH")); + if (version) { + version->setUnexpandedDisplayName(BaseQtVersion::defaultUnexpandedDisplayName(qmakePath, true)); + m_versions.insert(version->uniqueId(), version); + } } } diff --git a/src/plugins/qtsupport/simulatorqtversion.cpp b/src/plugins/qtsupport/simulatorqtversion.cpp deleted file mode 100644 index 49840f80399..00000000000 --- a/src/plugins/qtsupport/simulatorqtversion.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "simulatorqtversion.h" -#include "qtsupportconstants.h" - -#include <coreplugin/featureprovider.h> - -#include <QCoreApplication> - -using namespace QtSupport; -using namespace QtSupport::Internal; - -SimulatorQtVersion::SimulatorQtVersion() - : BaseQtVersion() -{ - -} - -SimulatorQtVersion::SimulatorQtVersion(const Utils::FileName &path, bool isAutodetected, const QString &autodetectionSource) - : BaseQtVersion(path, isAutodetected, autodetectionSource) -{ - setUnexpandedDisplayName(defaultUnexpandedDisplayName(path, false)); -} - -SimulatorQtVersion *SimulatorQtVersion::clone() const -{ - return new SimulatorQtVersion(*this); -} - -QString SimulatorQtVersion::type() const -{ - return QLatin1String(Constants::SIMULATORQT); -} - -QStringList SimulatorQtVersion::warningReason() const -{ - QStringList ret = BaseQtVersion::warningReason(); - if (qtVersion() >= QtVersionNumber(5, 0, 0) && qmlsceneCommand().isEmpty()) - ret << QCoreApplication::translate("QtVersion", "No qmlscene installed."); - if (qtVersion() >= QtVersionNumber(4, 7, 0) && qmlviewerCommand().isEmpty()) - ret << QCoreApplication::translate("QtVersion", "No qmlviewer installed."); - return ret; -} - -QList<ProjectExplorer::Abi> SimulatorQtVersion::detectQtAbis() const -{ - ensureMkSpecParsed(); - return qtAbisFromLibrary(qtCorePaths(versionInfo(), qtVersionString())); -} - -QString SimulatorQtVersion::description() const -{ - return QCoreApplication::translate("QtVersion", "Qt Simulator", "Qt Version is meant for Qt Simulator"); -} - -Core::FeatureSet SimulatorQtVersion::availableFeatures() const -{ - Core::FeatureSet features = BaseQtVersion::availableFeatures(); - features |= Core::FeatureSet(Constants::FEATURE_MOBILE); - return features; -} - -bool SimulatorQtVersion::supportsPlatform(const QString &platformName) const -{ - return platformName.isEmpty(); -} diff --git a/src/plugins/qtsupport/simulatorqtversion.h b/src/plugins/qtsupport/simulatorqtversion.h deleted file mode 100644 index 2ff61536dce..00000000000 --- a/src/plugins/qtsupport/simulatorqtversion.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef SIMULATORQTVERSION_H -#define SIMULATORQTVERSION_H - -#include "baseqtversion.h" - -namespace QtSupport { -namespace Internal { - -class SimulatorQtVersion : public BaseQtVersion -{ -public: - SimulatorQtVersion(); - SimulatorQtVersion(const Utils::FileName &path, bool isAutodetected = false, const QString &autodetectionSource = QString()); - SimulatorQtVersion *clone() const; - - QString type() const; - - QStringList warningReason() const; - - QList<ProjectExplorer::Abi> detectQtAbis() const; - - QString description() const; - - Core::FeatureSet availableFeatures() const; - bool supportsPlatform(const QString &platformName) const; -}; - -} // Internal -} // QtSupport - -#endif // SIMULATORQTVERSION_H diff --git a/src/plugins/qtsupport/simulatorqtversionfactory.cpp b/src/plugins/qtsupport/simulatorqtversionfactory.cpp deleted file mode 100644 index 67d4b19b19a..00000000000 --- a/src/plugins/qtsupport/simulatorqtversionfactory.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "simulatorqtversionfactory.h" -#include "simulatorqtversion.h" -#include "qtsupportconstants.h" -#include "profilereader.h" - -#include <QFileInfo> - -using namespace QtSupport; -using namespace QtSupport::Internal; - -SimulatorQtVersionFactory::SimulatorQtVersionFactory(QObject *parent) - : QtVersionFactory(parent) -{ - -} - -SimulatorQtVersionFactory::~SimulatorQtVersionFactory() -{ - -} - -bool SimulatorQtVersionFactory::canRestore(const QString &type) -{ - return type == QLatin1String(Constants::SIMULATORQT); -} - -BaseQtVersion *SimulatorQtVersionFactory::restore(const QString &type, const QVariantMap &data) -{ - if (!canRestore(type)) - return 0; - BaseQtVersion *v = new SimulatorQtVersion; - v->fromMap(data); - return v; -} - - -int SimulatorQtVersionFactory::priority() const -{ - return 50; -} - -BaseQtVersion *SimulatorQtVersionFactory::create(const Utils::FileName &qmakePath, ProFileEvaluator *evaluator, bool isAutoDetected, const QString &autoDetectionSource) -{ - QFileInfo fi = qmakePath.toFileInfo(); - if (!fi.exists() || !fi.isExecutable() || !fi.isFile()) - return 0; - QStringList configValues = evaluator->values(QLatin1String("CONFIG")); - if (!configValues.contains(QLatin1String("simulator"))) - return 0; - - return new SimulatorQtVersion(qmakePath, isAutoDetected, autoDetectionSource); -} diff --git a/src/plugins/remotelinux/abstractpackagingstep.cpp b/src/plugins/remotelinux/abstractpackagingstep.cpp index e41486ed797..c4babae8290 100644 --- a/src/plugins/remotelinux/abstractpackagingstep.cpp +++ b/src/plugins/remotelinux/abstractpackagingstep.cpp @@ -170,16 +170,18 @@ void AbstractPackagingStep::setDeploymentDataModified() void AbstractPackagingStep::raiseError(const QString &errorMessage) { + Task task = Task(Task::Error, errorMessage, Utils::FileName(), -1, + Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task); emit addOutput(errorMessage, BuildStep::ErrorOutput); - emit addTask(Task(Task::Error, errorMessage, Utils::FileName(), -1, - Constants::TASK_CATEGORY_DEPLOYMENT)); } void AbstractPackagingStep::raiseWarning(const QString &warningMessage) { + Task task = Task(Task::Warning, warningMessage, Utils::FileName(), -1, + Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task); emit addOutput(warningMessage, ErrorMessageOutput); - emit addTask(Task(Task::Warning, warningMessage, Utils::FileName(), -1, - Constants::TASK_CATEGORY_DEPLOYMENT)); } } // namespace RemoteLinux diff --git a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp index 2c4365ac80b..c1f4d03e13f 100644 --- a/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp +++ b/src/plugins/remotelinux/abstractremotelinuxdeploystep.cpp @@ -131,17 +131,19 @@ void AbstractRemoteLinuxDeployStep::handleProgressMessage(const QString &message void AbstractRemoteLinuxDeployStep::handleErrorMessage(const QString &message) { + ProjectExplorer::Task task = Task(Task::Error, message, Utils::FileName(), -1, + Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task, 1); // TODO correct? emit addOutput(message, ErrorMessageOutput); - emit addTask(Task(Task::Error, message, Utils::FileName(), -1, - Constants::TASK_CATEGORY_DEPLOYMENT)); d->hasError = true; } void AbstractRemoteLinuxDeployStep::handleWarningMessage(const QString &message) { + ProjectExplorer::Task task = Task(Task::Warning, message, Utils::FileName(), -1, + Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task, 1); // TODO correct? emit addOutput(message, ErrorMessageOutput); - emit addTask(Task(Task::Warning, message, Utils::FileName(), -1, - Constants::TASK_CATEGORY_DEPLOYMENT)); } void AbstractRemoteLinuxDeployStep::handleFinished() diff --git a/src/plugins/subversion/checkoutwizard.cpp b/src/plugins/subversion/checkoutwizard.cpp deleted file mode 100644 index c7b655d65ad..00000000000 --- a/src/plugins/subversion/checkoutwizard.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "checkoutwizard.h" -#include "checkoutwizardpage.h" -#include "subversionconstants.h" -#include "subversionplugin.h" -#include "subversionclient.h" - -#include <coreplugin/iversioncontrol.h> -#include <vcsbase/vcscommand.h> -#include <vcsbase/vcsbaseconstants.h> -#include <vcsbase/wizard/vcsconfigurationpage.h> -#include <utils/qtcassert.h> - -using namespace Utils; -using namespace VcsBase; - -namespace Subversion { -namespace Internal { - -// -------------------------------------------------------------------- -// CheckoutWizard: -// -------------------------------------------------------------------- - -CheckoutWizard::CheckoutWizard(const FileName &path, QWidget *parent) : - BaseCheckoutWizard(path, parent) -{ - const Core::IVersionControl *vc = SubversionPlugin::instance()->versionControl(); - if (!vc->isConfigured()) { - auto configPage = new VcsConfigurationPage; - configPage->setVersionControl(vc); - addPage(configPage); - } - auto cwp = new CheckoutWizardPage; - cwp->setPath(path.toString()); - addPage(cwp); -} - -VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir) -{ - // Collect parameters for the checkout command. - const CheckoutWizardPage *cwp = 0; - foreach (int pageId, pageIds()) { - if ((cwp = qobject_cast<const CheckoutWizardPage *>(page(pageId)))) - break; - } - QTC_ASSERT(cwp, return 0); - - const SubversionSettings settings = SubversionPlugin::instance()->settings(); - const FileName binary = settings.binaryPath(); - const QString directory = cwp->directory(); - QStringList args; - args << QLatin1String("checkout"); - args << SubversionClient::addAuthenticationOptions(settings); - args << QLatin1String(Constants::NON_INTERACTIVE_OPTION); - if (cwp->trustServerCert()) - args << QLatin1String("--trust-server-cert"); - args << cwp->repository() << directory; - const QString workingDirectory = cwp->path(); - *checkoutDir = FileName::fromString(workingDirectory + QLatin1Char('/') + directory); - - auto command = new VcsCommand(binary, workingDirectory, - QProcessEnvironment::systemEnvironment()); - command->addJob(args, -1); - return command; -} - -} // namespace Internal -} // namespace Subversion diff --git a/src/plugins/subversion/checkoutwizard.h b/src/plugins/subversion/checkoutwizard.h deleted file mode 100644 index 4bdd9a79fce..00000000000 --- a/src/plugins/subversion/checkoutwizard.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CHECKOUTWIZARD_H -#define CHECKOUTWIZARD_H - -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> - -namespace Subversion { -namespace Internal { - -class CheckoutWizard : public VcsBase::BaseCheckoutWizard -{ - Q_OBJECT - -public: - CheckoutWizard(const Utils::FileName &path, QWidget *parent = 0); - -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir); -}; - -} // namespace Internal -} // namespace Subversion - -#endif // CHECKOUTWIZARD_H diff --git a/src/plugins/subversion/checkoutwizardpage.cpp b/src/plugins/subversion/checkoutwizardpage.cpp deleted file mode 100644 index 0f96b798137..00000000000 --- a/src/plugins/subversion/checkoutwizardpage.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "checkoutwizardpage.h" - -#include <QCheckBox> - -namespace Subversion { -namespace Internal { - -CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) : - VcsBase::BaseCheckoutWizardPage(parent), - m_trustServerCertBox(new QCheckBox(tr("Trust Server Certificate"))) -{ - setTitle(tr("Location")); - setSubTitle(tr("Specify repository URL, checkout directory and path.")); - setRepositoryLabel(tr("Repository:")); - setBranchSelectorVisible(false); - - addLocalControl(m_trustServerCertBox); -} - -bool CheckoutWizardPage::trustServerCert() const -{ - return m_trustServerCertBox->isChecked(); -} - -QString CheckoutWizardPage::directoryFromRepository(const QString &repoIn) const -{ - /* Try to figure out a good directory name from something like: - * "svn://<server>/path1/project" -> project */ - - QString repo = repoIn.trimmed(); - const QChar slash = QLatin1Char('/'); - // remove host - const int slashPos = repo.lastIndexOf(slash); - if (slashPos != -1) - repo.remove(0, slashPos + 1); - // fix invalid characters - repo.replace(QLatin1Char('.'), QLatin1Char('-')); - return repo; -} - -} // namespace Internal -} // namespace Subversion diff --git a/src/plugins/subversion/checkoutwizardpage.h b/src/plugins/subversion/checkoutwizardpage.h deleted file mode 100644 index 7d941563fe8..00000000000 --- a/src/plugins/subversion/checkoutwizardpage.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef CHECKOUTWIZARDPAGE_H -#define CHECKOUTWIZARDPAGE_H - -#include <vcsbase/basecheckoutwizardpage.h> - -QT_BEGIN_NAMESPACE -class QCheckBox; -QT_END_NAMESPACE - -namespace Subversion { -namespace Internal { - -class CheckoutWizardPage : public VcsBase::BaseCheckoutWizardPage { - Q_OBJECT -public: - CheckoutWizardPage(QWidget *parent = 0); - - bool trustServerCert() const; - -protected: - QString directoryFromRepository(const QString &r) const; - -private: - QCheckBox *m_trustServerCertBox; -}; - -} // namespace Internal -} // namespace Subversion -#endif // CHECKOUTWIZARDPAGE_H diff --git a/src/plugins/subversion/images/subversion.png b/src/plugins/subversion/images/subversion.png Binary files differdeleted file mode 100644 index 17308b5ebb1..00000000000 --- a/src/plugins/subversion/images/subversion.png +++ /dev/null diff --git a/src/plugins/subversion/settingspage.cpp b/src/plugins/subversion/settingspage.cpp index 6f2bfa9994d..548212d744a 100644 --- a/src/plugins/subversion/settingspage.cpp +++ b/src/plugins/subversion/settingspage.cpp @@ -29,8 +29,10 @@ ****************************************************************************/ #include "settingspage.h" -#include "subversionsettings.h" + +#include "subversionclient.h" #include "subversionplugin.h" +#include "subversionsettings.h" #include <coreplugin/icore.h> #include <extensionsystem/pluginmanager.h> @@ -43,9 +45,9 @@ using namespace Subversion::Internal; using namespace Utils; +using namespace VcsBase; -SettingsPageWidget::SettingsPageWidget(QWidget *parent) : - QWidget(parent) +SettingsPageWidget::SettingsPageWidget(QWidget *parent) : VcsClientOptionsPageWidget(parent) { m_ui.setupUi(this); m_ui.pathChooser->setExpectedKind(PathChooser::ExistingCommand); @@ -53,7 +55,7 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) : m_ui.pathChooser->setPromptDialogTitle(tr("Subversion Command")); } -SubversionSettings SettingsPageWidget::settings() const +VcsBase::VcsBaseClientSettings SettingsPageWidget::settings() const { SubversionSettings rc; rc.setValue(SubversionSettings::binaryPathKey, m_ui.pathChooser->rawPath()); @@ -70,7 +72,7 @@ SubversionSettings SettingsPageWidget::settings() const return rc; } -void SettingsPageWidget::setSettings(const SubversionSettings &s) +void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s) { m_ui.pathChooser->setFileName(s.binaryPath()); m_ui.usernameLineEdit->setText(s.stringValue(SubversionSettings::userKey)); @@ -83,28 +85,10 @@ void SettingsPageWidget::setSettings(const SubversionSettings &s) m_ui.logCountSpinBox->setValue(s.intValue(SubversionSettings::logCountKey)); } -SettingsPage::SettingsPage() : - m_widget(0) +SettingsPage::SettingsPage(Core::IVersionControl *control) : + VcsClientOptionsPage(control, SubversionPlugin::instance()->client()) { setId(VcsBase::Constants::VCS_ID_SUBVERSION); setDisplayName(tr("Subversion")); -} - -QWidget *SettingsPage::widget() -{ - if (!m_widget) { - m_widget = new SettingsPageWidget; - m_widget->setSettings(SubversionPlugin::instance()->settings()); - } - return m_widget; -} - -void SettingsPage::apply() -{ - SubversionPlugin::instance()->setSettings(m_widget->settings()); -} - -void SettingsPage::finish() -{ - delete m_widget; + setWidgetFactory([]() { return new SettingsPageWidget; }); } diff --git a/src/plugins/subversion/settingspage.h b/src/plugins/subversion/settingspage.h index c705122e75d..068cb8591c5 100644 --- a/src/plugins/subversion/settingspage.h +++ b/src/plugins/subversion/settingspage.h @@ -46,36 +46,27 @@ QT_END_NAMESPACE namespace Subversion { namespace Internal { -class SubversionSettings; - -class SettingsPageWidget : public QWidget +class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget { Q_OBJECT public: explicit SettingsPageWidget(QWidget *parent = 0); - SubversionSettings settings() const; - void setSettings(const SubversionSettings &); + VcsBase::VcsBaseClientSettings settings() const; + void setSettings(const VcsBase::VcsBaseClientSettings &s); private: Ui::SettingsPage m_ui; }; -class SettingsPage : public VcsBase::VcsBaseOptionsPage +class SettingsPage : public VcsBase::VcsClientOptionsPage { Q_OBJECT public: - SettingsPage(); - - QWidget *widget(); - void apply(); - void finish(); - -private: - QPointer<SettingsPageWidget> m_widget; + SettingsPage(Core::IVersionControl *control); }; } // namespace Subversion diff --git a/src/plugins/subversion/subversion.pro b/src/plugins/subversion/subversion.pro index ae8e211b62d..ebf878474ba 100644 --- a/src/plugins/subversion/subversion.pro +++ b/src/plugins/subversion/subversion.pro @@ -8,8 +8,6 @@ HEADERS += annotationhighlighter.h \ subversioneditor.h \ subversionsubmiteditor.h \ subversionsettings.h \ - checkoutwizard.h \ - checkoutwizardpage.h \ subversionconstants.h SOURCES += annotationhighlighter.cpp \ @@ -19,9 +17,7 @@ SOURCES += annotationhighlighter.cpp \ settingspage.cpp \ subversioneditor.cpp \ subversionsubmiteditor.cpp \ - subversionsettings.cpp \ - checkoutwizard.cpp \ - checkoutwizardpage.cpp + subversionsettings.cpp FORMS += settingspage.ui diff --git a/src/plugins/subversion/subversion.qbs b/src/plugins/subversion/subversion.qbs index dd38509ad51..1a6244a946b 100644 --- a/src/plugins/subversion/subversion.qbs +++ b/src/plugins/subversion/subversion.qbs @@ -14,10 +14,6 @@ QtcPlugin { files: [ "annotationhighlighter.cpp", "annotationhighlighter.h", - "checkoutwizard.cpp", - "checkoutwizard.h", - "checkoutwizardpage.cpp", - "checkoutwizardpage.h", "settingspage.cpp", "settingspage.h", "settingspage.ui", diff --git a/src/plugins/subversion/subversion.qrc b/src/plugins/subversion/subversion.qrc index ca81748ffb0..b23e6dbb973 100644 --- a/src/plugins/subversion/subversion.qrc +++ b/src/plugins/subversion/subversion.qrc @@ -1,7 +1,4 @@ <RCC> - <qresource prefix="/subversion"> - <file>images/subversion.png</file> - </qresource> <qresource prefix="/trolltech.subversion"> <file>Subversion.mimetypes.xml</file> </qresource> diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index bce6f4016bb..8bfa03249a8 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -41,7 +41,6 @@ #include <utils/qtcassert.h> #include <utils/synchronousprocess.h> #include <diffeditor/diffeditorcontroller.h> -#include <diffeditor/diffeditormanager.h> #include <diffeditor/diffutils.h> #include <coreplugin/editormanager/editormanager.h> @@ -62,24 +61,18 @@ class SubversionLogParameterWidget : public VcsBaseEditorParameterWidget { Q_OBJECT public: - SubversionLogParameterWidget(SubversionSettings *settings, QWidget *parent = 0) : + SubversionLogParameterWidget(VcsBaseClientSettings &settings, QWidget *parent = 0) : VcsBaseEditorParameterWidget(parent) { mapSetting(addToggleButton(QLatin1String("--verbose"), tr("Verbose"), tr("Show files changed in each revision")), - settings->boolPointer(SubversionSettings::logVerboseKey)); + settings.boolPointer(SubversionSettings::logVerboseKey)); } }; -SubversionClient::SubversionClient(SubversionSettings *settings) : - VcsBaseClient(settings) +SubversionClient::SubversionClient() : VcsBaseClient(new SubversionSettings) { - setLogParameterWidgetCreator([=] { return new SubversionLogParameterWidget(settings); }); -} - -SubversionSettings *SubversionClient::settings() const -{ - return dynamic_cast<SubversionSettings *>(VcsBaseClient::settings()); + setLogParameterWidgetCreator([this] { return new SubversionLogParameterWidget(settings()); }); } VcsCommand *SubversionClient::createCommitCmd(const QString &repositoryRoot, @@ -89,15 +82,15 @@ VcsCommand *SubversionClient::createCommitCmd(const QString &repositoryRoot, { const QStringList svnExtraOptions = QStringList(extraOptions) - << SubversionClient::addAuthenticationOptions(*settings()) + << SubversionClient::addAuthenticationOptions(settings()) << QLatin1String(Constants::NON_INTERACTIVE_OPTION) << QLatin1String("--encoding") << QLatin1String("utf8") << QLatin1String("--file") << commitMessageFile; VcsCommand *cmd = createCommand(repositoryRoot); - cmd->addFlags(VcsBasePlugin::ShowStdOutInLogWindow); + cmd->addFlags(VcsCommand::ShowStdOut); QStringList args(vcsCommandString(CommitCommand)); - cmd->addJob(args << svnExtraOptions << files); + cmd->addJob(vcsBinary(), args << svnExtraOptions << files); return cmd; } @@ -124,9 +117,9 @@ Id SubversionClient::vcsEditorKind(VcsCommandTag cmd) const } // Add authorization options to the command line arguments. -QStringList SubversionClient::addAuthenticationOptions(const SubversionSettings &settings) +QStringList SubversionClient::addAuthenticationOptions(const VcsBaseClientSettings &settings) { - if (!settings.hasAuthentication()) + if (!static_cast<const SubversionSettings &>(settings).hasAuthentication()) return QStringList(); const QString userName = settings.stringValue(SubversionSettings::userKey); @@ -156,7 +149,7 @@ QString SubversionClient::synchronousTopic(const QString &repository) const QString revisionString = QLatin1String("Revision: "); // stdOut is ASCII only (at least in those areas we care about). - QString output = SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(stdOut)); + QString output = commandOutputFromLocal8Bit(stdOut); foreach (const QString &line, output.split(QLatin1Char('\n'))) { if (line.startsWith(revisionString)) return QString::fromLatin1("r") + line.mid(revisionString.count()); @@ -182,8 +175,6 @@ private slots: private: QString getDescription() const; void postCollectTextualDiffOutput(); - int timeout() const; - FileName subversionPath() const; QProcessEnvironment processEnvironment() const; const SubversionClient *m_client; @@ -201,16 +192,6 @@ DiffController::DiffController(IDocument *document, const SubversionClient *clie forceContextLineCount(3); // SVN can not change that when using internal diff } -int DiffController::timeout() const -{ - return m_client->settings()->intValue(VcsBaseClientSettings::timeoutKey); -} - -FileName DiffController::subversionPath() const -{ - return m_client->settings()->binaryPath(); -} - QProcessEnvironment DiffController::processEnvironment() const { return m_client->processEnvironment(); @@ -235,13 +216,13 @@ void DiffController::setChangeNumber(int changeNumber) QString DiffController::getDescription() const { QStringList args(QLatin1String("log")); - args << SubversionClient::addAuthenticationOptions(*m_client->settings()); + args << SubversionClient::addAuthenticationOptions(m_client->settings()); args << QLatin1String("-r"); args << QString::number(m_changeNumber); const SubversionResponse logResponse = SubversionPlugin::instance()->runSvn(m_workingDirectory, args, - m_client->settings()->timeOutMs(), - VcsBasePlugin::SshPasswordPrompt); + m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt); if (logResponse.error) return QString(); @@ -251,15 +232,14 @@ QString DiffController::getDescription() const void DiffController::postCollectTextualDiffOutput() { - auto command = new VcsCommand(subversionPath(), m_workingDirectory, processEnvironment()); + auto command = new VcsCommand(m_workingDirectory, processEnvironment()); command->setCodec(EditorManager::defaultTextCodec()); - connect(command, SIGNAL(output(QString)), - this, SLOT(slotTextualDiffOutputReceived(QString))); + connect(command, &VcsCommand::stdOutText, this, &DiffController::slotTextualDiffOutputReceived); // command->addFlags(diffExecutionFlags()); QStringList args; args << QLatin1String("diff"); - args << m_client->addAuthenticationOptions(*m_client->settings()); + args << m_client->addAuthenticationOptions(m_client->settings()); args << QLatin1String("--internal-diff"); if (ignoreWhitespace()) args << QLatin1String("-x") << QLatin1String("-uw"); @@ -270,7 +250,7 @@ void DiffController::postCollectTextualDiffOutput() args << m_filesList; } - command->addJob(args, timeout()); + command->addJob(m_client->vcsBinary(), args, m_client->vcsTimeoutS()); command->execute(); } @@ -297,8 +277,9 @@ DiffController *SubversionClient::findOrCreateDiffEditor(const QString &document const QString &title, const QString &workingDirectory) const { - IDocument *document = DiffEditorManager::findOrCreate(documentId, title); - DiffController *controller = qobject_cast<DiffController *>(DiffEditorManager::controller(document)); + IDocument *document = DiffEditorController::findOrCreateDocument(documentId, title); + DiffController *controller = qobject_cast<DiffController *>( + DiffEditorController::controller(document)); if (!controller) controller = new DiffController(document, this, workingDirectory); VcsBasePlugin::setSource(document, source); @@ -324,10 +305,10 @@ void SubversionClient::log(const QString &workingDir, const QStringList &extraOptions, bool enableAnnotationContextMenu) { - const auto logCount = settings()->intValue(SubversionSettings::logCountKey); + const auto logCount = settings().intValue(SubversionSettings::logCountKey); QStringList svnExtraOptions = QStringList(extraOptions) - << SubversionClient::addAuthenticationOptions(*settings()); + << SubversionClient::addAuthenticationOptions(settings()); if (logCount > 0) svnExtraOptions << QLatin1String("-l") << QString::number(logCount); diff --git a/src/plugins/subversion/subversionclient.h b/src/plugins/subversion/subversionclient.h index 5db0327b169..cd34bb779ca 100644 --- a/src/plugins/subversion/subversionclient.h +++ b/src/plugins/subversion/subversionclient.h @@ -48,9 +48,7 @@ class SubversionClient : public VcsBase::VcsBaseClient Q_OBJECT public: - SubversionClient(SubversionSettings *settings); - - SubversionSettings *settings() const; + SubversionClient(); VcsBase::VcsCommand *createCommitCmd(const QString &repositoryRoot, const QStringList &files, @@ -75,7 +73,7 @@ public: StatusItem parseStatusLine(const QString &line) const; // Add authorization options to the command line arguments. - static QStringList addAuthenticationOptions(const SubversionSettings &settings); + static QStringList addAuthenticationOptions(const VcsBase::VcsBaseClientSettings &settings); QString synchronousTopic(const QString &repository); diff --git a/src/plugins/subversion/subversioncontrol.cpp b/src/plugins/subversion/subversioncontrol.cpp index 052abac0eb4..90175620215 100644 --- a/src/plugins/subversion/subversioncontrol.cpp +++ b/src/plugins/subversion/subversioncontrol.cpp @@ -29,10 +29,14 @@ ****************************************************************************/ #include "subversioncontrol.h" + +#include "subversionclient.h" +#include "subversionconstants.h" #include "subversionplugin.h" #include "subversionsettings.h" #include <vcsbase/vcsbaseconstants.h> +#include <vcsbase/vcsbaseclientsettings.h> #include <utils/fileutils.h> @@ -80,7 +84,7 @@ Core::Id SubversionControl::id() const bool SubversionControl::isConfigured() const { - const Utils::FileName binary = m_plugin->settings().binaryPath(); + const Utils::FileName binary = m_plugin->client()->vcsBinary(); if (binary.isEmpty()) return false; QFileInfo fi = binary.toFileInfo(); @@ -95,6 +99,7 @@ bool SubversionControl::supportsOperation(Operation operation) const case DeleteOperation: case MoveOperation: case AnnotateOperation: + case InitialCheckoutOperation: break; case CreateRepositoryOperation: case SnapshotOperations: @@ -151,6 +156,24 @@ bool SubversionControl::vcsAnnotate(const QString &file, int line) return true; } +Core::ShellCommand *SubversionControl::createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) +{ + SubversionClient *client = m_plugin->client(); + + QStringList args; + args << QLatin1String("checkout"); + args << SubversionClient::addAuthenticationOptions(client->settings()); + args << QLatin1String(Subversion::Constants::NON_INTERACTIVE_OPTION); + args << extraArgs << url << localName; + + auto command = new VcsBase::VcsCommand(baseDirectory.toString(), client->processEnvironment()); + command->addJob(client->vcsBinary(), args, -1); + return command; +} + void SubversionControl::emitRepositoryChanged(const QString &s) { emit repositoryChanged(s); @@ -161,10 +184,5 @@ void SubversionControl::emitFilesChanged(const QStringList &l) emit filesChanged(l); } -void SubversionControl::emitConfigurationChanged() -{ - emit configurationChanged(); -} - } // namespace Internal } // namespace Subversion diff --git a/src/plugins/subversion/subversioncontrol.h b/src/plugins/subversion/subversioncontrol.h index a6530ed6957..f05185ac1ed 100644 --- a/src/plugins/subversion/subversioncontrol.h +++ b/src/plugins/subversion/subversioncontrol.h @@ -44,25 +44,29 @@ class SubversionControl : public Core::IVersionControl Q_OBJECT public: explicit SubversionControl(SubversionPlugin *plugin); - QString displayName() const; - Core::Id id() const; + QString displayName() const override; + Core::Id id() const override; - bool managesDirectory(const QString &directory, QString *topLevel = 0) const; - bool managesFile(const QString &workingDirectory, const QString &fileName) const; + bool managesDirectory(const QString &directory, QString *topLevel = 0) const override; + bool managesFile(const QString &workingDirectory, const QString &fileName) const override; - bool isConfigured() const; - bool supportsOperation(Operation operation) const; - bool vcsOpen(const QString &fileName); - bool vcsAdd(const QString &fileName); - bool vcsDelete(const QString &filename); - bool vcsMove(const QString &from, const QString &to); - bool vcsCreateRepository(const QString &directory); + bool isConfigured() const override; + bool supportsOperation(Operation operation) const override; + bool vcsOpen(const QString &fileName) override; + bool vcsAdd(const QString &fileName) override; + bool vcsDelete(const QString &filename) override; + bool vcsMove(const QString &from, const QString &to) override; + bool vcsCreateRepository(const QString &directory) override; - bool vcsAnnotate(const QString &file, int line); + bool vcsAnnotate(const QString &file, int line) override; + + Core::ShellCommand *createInitialCheckoutCommand(const QString &url, + const Utils::FileName &baseDirectory, + const QString &localName, + const QStringList &extraArgs) override; void emitRepositoryChanged(const QString &); void emitFilesChanged(const QStringList &); - void emitConfigurationChanged(); private: SubversionPlugin *m_plugin; diff --git a/src/plugins/subversion/subversioneditor.cpp b/src/plugins/subversion/subversioneditor.cpp index 57e5050d7ba..f67c30499a9 100644 --- a/src/plugins/subversion/subversioneditor.cpp +++ b/src/plugins/subversion/subversioneditor.cpp @@ -35,7 +35,7 @@ #include "subversionconstants.h" #include <utils/qtcassert.h> -#include <vcsbase/diffhighlighter.h> +#include <vcsbase/diffandloghighlighter.h> #include <QDebug> #include <QFileInfo> diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index d34593ce50a..f83252c497f 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -37,7 +37,6 @@ #include "subversionclient.h" #include "subversionconstants.h" #include "subversioncontrol.h" -#include "checkoutwizard.h" #include <vcsbase/basevcseditorfactory.h> #include <vcsbase/vcscommand.h> @@ -247,10 +246,9 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e Utils::MimeDatabase::addMimeTypes(QLatin1String(":/trolltech.subversion/Subversion.mimetypes.xml")); - m_settings.readSettings(ICore::settings()); - m_client = new SubversionClient(&m_settings); + m_client = new SubversionClient; - addAutoReleasedObject(new SettingsPage); + addAutoReleasedObject(new SettingsPage(versionControl())); addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new SubversionSubmitEditor(&submitParameters); })); @@ -261,16 +259,6 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e for (int i = 0; i < editorCount; i++) addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot)); - auto checkoutWizardFactory = new BaseCheckoutWizardFactory; - checkoutWizardFactory->setId(QLatin1String(VcsBase::Constants::VCS_ID_SUBVERSION)); - checkoutWizardFactory->setIcon(QIcon(QLatin1String(":/subversion/images/subversion.png"))); - checkoutWizardFactory->setDescription(tr("Checks out a Subversion repository and tries to load the contained project.")); - checkoutWizardFactory->setDisplayName(tr("Subversion Checkout")); - checkoutWizardFactory->setWizardCreator([this] (const FileName &path, QWidget *parent) { - return new CheckoutWizard(path, parent); - }); - addAutoReleasedObject(checkoutWizardFactory); - const QString prefix = QLatin1String("svn"); m_commandLocator = new CommandLocator("Subversion", prefix, prefix); addAutoReleasedObject(m_commandLocator); @@ -451,6 +439,12 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e return true; } +SubversionClient *SubversionPlugin::client() const +{ + QTC_CHECK(m_client); + return m_client; +} + bool SubversionPlugin::submitEditorAboutToClose() { if (!isCommitEditorOpen()) @@ -470,7 +464,7 @@ bool SubversionPlugin::submitEditorAboutToClose() // Prompt user. Force a prompt unless submit was actually invoked (that // is, the editor was closed or shutdown). - SubversionSettings newSettings = m_settings; + VcsBaseClientSettings &newSettings = client()->settings(); const VcsBaseSubmitEditor::PromptSubmitResult answer = editor->promptSubmit(tr("Closing Subversion Editor"), tr("Do you want to commit the change?"), @@ -487,7 +481,6 @@ bool SubversionPlugin::submitEditorAboutToClose() default: break; } - setSettings(newSettings); // in case someone turned prompting off const QStringList fileList = editor->checkedFiles(); bool closeEditor = true; if (!fileList.empty()) { @@ -578,11 +571,11 @@ void SubversionPlugin::revertAll() // NoteL: Svn "revert ." doesn not work. QStringList args; args << QLatin1String("revert"); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args << QLatin1String("--recursive") << state.topLevel(); - const SubversionResponse revertResponse = - runSvn(state.topLevel(), args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + const SubversionResponse revertResponse + = runSvn(state.topLevel(), args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (revertResponse.error) QMessageBox::warning(ICore::dialogParent(), title, tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok); @@ -596,11 +589,11 @@ void SubversionPlugin::revertCurrentFile() QTC_ASSERT(state.hasFile(), return); QStringList args(QLatin1String("diff")); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args.push_back(state.relativeCurrentFile()); - const SubversionResponse diffResponse = - runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMs(), 0); + const SubversionResponse diffResponse + = runSvn(state.currentFileTopLevel(), args, m_client->vcsTimeoutS(), 0); if (diffResponse.error) return; @@ -617,12 +610,12 @@ void SubversionPlugin::revertCurrentFile() // revert args.clear(); args << QLatin1String("revert"); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args << state.relativeCurrentFile(); - const SubversionResponse revertResponse = - runSvn(state.currentFileTopLevel(), args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + const SubversionResponse revertResponse + = runSvn(state.currentFileTopLevel(), args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (!revertResponse.error) subVersionControl()->emitFilesChanged(QStringList(state.currentFile())); @@ -680,11 +673,11 @@ void SubversionPlugin::startCommit(const QString &workingDir, const QStringList } QStringList args(QLatin1String("status")); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args += files; - const SubversionResponse response = - runSvn(workingDir, args, m_settings.timeOutMs(), 0); + const SubversionResponse response + = runSvn(workingDir, args, m_client->vcsTimeoutS(), 0); if (response.error) return; @@ -760,12 +753,12 @@ void SubversionPlugin::svnStatus(const QString &workingDir, const QString &relat const VcsBasePluginState state = currentState(); QTC_ASSERT(state.hasTopLevel(), return); QStringList args(QLatin1String("status")); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); if (!relativePath.isEmpty()) args.append(relativePath); VcsOutputWindow::setRepository(workingDir); - runSvn(workingDir, args, m_settings.timeOutMs(), - ShowStdOutInLogWindow|ShowSuccessMessage); + runSvn(workingDir, args, m_client->vcsTimeoutS(), + VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage); VcsOutputWindow::clearRepository(); } @@ -786,13 +779,13 @@ void SubversionPlugin::updateProject() void SubversionPlugin::svnUpdate(const QString &workingDir, const QString &relativePath) { QStringList args(QLatin1String("update")); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args.push_back(QLatin1String(Constants::NON_INTERACTIVE_OPTION)); if (!relativePath.isEmpty()) args.append(relativePath); - const SubversionResponse response = - runSvn(workingDir, args, 10 * m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + const SubversionResponse response + = runSvn(workingDir, args, 10 * m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); if (!response.error) subVersionControl()->emitRepositoryChanged(workingDir); } @@ -813,24 +806,25 @@ void SubversionPlugin::annotateVersion(const QString &workingDirectory, } void SubversionPlugin::vcsAnnotate(const QString &workingDir, const QString &file, - const QString &revision /* = QString() */, - int lineNumber /* = -1 */) + const QString &revision /* = QString() */, + int lineNumber /* = -1 */) { const QString source = VcsBaseEditor::getSource(workingDir, file); QTextCodec *codec = VcsBaseEditor::getCodec(source); QStringList args(QLatin1String("annotate")); - args << SubversionClient::addAuthenticationOptions(settings()); - if (m_settings.boolValue(SubversionSettings::spaceIgnorantAnnotationKey)) + const VcsBaseClientSettings &s = client()->settings(); + args << SubversionClient::addAuthenticationOptions(s); + if (s.boolValue(SubversionSettings::spaceIgnorantAnnotationKey)) args << QLatin1String("-x") << QLatin1String("-uw"); if (!revision.isEmpty()) args << QLatin1String("-r") << revision; args.push_back(QLatin1String("-v")); args.append(QDir::toNativeSeparators(file)); - const SubversionResponse response = - runSvn(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ForceCLocale, codec); + const SubversionResponse response + = runSvn(workingDir, args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, codec); if (response.error) return; @@ -910,10 +904,11 @@ void SubversionPlugin::submitCurrentLog() } SubversionResponse SubversionPlugin::runSvn(const QString &workingDir, - const QStringList &arguments, int timeOut, - unsigned flags, QTextCodec *outputCodec) const + const QStringList &arguments, + int timeOutS, unsigned flags, + QTextCodec *outputCodec) const { - const FileName executable = m_settings.binaryPath(); + const FileName executable = client()->vcsBinary(); SubversionResponse response; if (executable.isEmpty()) { response.error = true; @@ -922,12 +917,12 @@ SubversionResponse SubversionPlugin::runSvn(const QString &workingDir, } const SynchronousProcessResponse sp_resp = - VcsBasePlugin::runVcs(workingDir, executable, arguments, timeOut, + VcsBasePlugin::runVcs(workingDir, executable, arguments, timeOutS, flags, outputCodec); response.error = sp_resp.result != SynchronousProcessResponse::Finished; if (response.error) - response.message = sp_resp.exitMessage(executable.toString(), timeOut); + response.message = sp_resp.exitMessage(executable.toString(), timeOutS); response.stdErr = sp_resp.stdErr; response.stdOut = sp_resp.stdOut; return response; @@ -960,20 +955,6 @@ IEditor *SubversionPlugin::showOutputInEditor(const QString &title, const QStrin return editor; } -SubversionSettings SubversionPlugin::settings() const -{ - return m_settings; -} - -void SubversionPlugin::setSettings(const SubversionSettings &s) -{ - if (s != m_settings) { - m_settings = s; - m_settings.writeSettings(ICore::settings()); - subVersionControl()->emitConfigurationChanged(); - } -} - SubversionPlugin *SubversionPlugin::instance() { QTC_ASSERT(m_subversionPluginInstance, return m_subversionPluginInstance); @@ -1004,11 +985,11 @@ bool SubversionPlugin::vcsAdd(const QString &workingDir, const QString &rawFileN const QString file = QDir::toNativeSeparators(rawFileName); QStringList args; args << QLatin1String("add") - << SubversionClient::addAuthenticationOptions(settings()) + << SubversionClient::addAuthenticationOptions(client()->settings()) << QLatin1String("--parents") << file; - const SubversionResponse response = - runSvn(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + const SubversionResponse response + = runSvn(workingDir, args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return !response.error; } @@ -1018,22 +999,24 @@ bool SubversionPlugin::vcsDelete(const QString &workingDir, const QString &rawFi QStringList args; args << QLatin1String("delete"); - args << SubversionClient::addAuthenticationOptions(settings()) << QLatin1String("--force") << file; + args << SubversionClient::addAuthenticationOptions(client()->settings()) + << QLatin1String("--force") << file; - const SubversionResponse response = - runSvn(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow); + const SubversionResponse response + = runSvn(workingDir, args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut); return !response.error; } bool SubversionPlugin::vcsMove(const QString &workingDir, const QString &from, const QString &to) { QStringList args(QLatin1String("move")); - args << SubversionClient::addAuthenticationOptions(settings()); + args << SubversionClient::addAuthenticationOptions(client()->settings()); args << QDir::toNativeSeparators(from) << QDir::toNativeSeparators(to); - const SubversionResponse response = - runSvn(workingDir, args, m_settings.timeOutMs(), - SshPasswordPrompt|ShowStdOutInLogWindow|FullySynchronously); + const SubversionResponse response + = runSvn(workingDir, args, m_client->vcsTimeoutS(), + VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut + | VcsCommand::FullySynchronously); return !response.error; } @@ -1059,9 +1042,8 @@ bool SubversionPlugin::vcsCheckout(const QString &directory, const QByteArray &u args << QLatin1String(tempUrl.toEncoded()) << directory; - const SubversionResponse response = runSvn(directory, args, - 10 * m_settings.timeOutMs(), - VcsBasePlugin::SshPasswordPrompt); + const SubversionResponse response + = runSvn(directory, args, 10 * m_client->vcsTimeoutS(), VcsCommand::SshPasswordPrompt); return !response.error; } @@ -1093,9 +1075,9 @@ bool SubversionPlugin::managesFile(const QString &workingDirectory, const QStrin { QStringList args; args << QLatin1String("status"); - args << SubversionClient::addAuthenticationOptions(settings()) << fileName; - SubversionResponse response = - runSvn(workingDirectory, args, m_settings.timeOutMs(), 0); + args << SubversionClient::addAuthenticationOptions(client()->settings()) << fileName; + SubversionResponse response + = runSvn(workingDirectory, args, m_client->vcsTimeoutS(), 0); return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?'); } diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index 0a6eb5d5715..dcc16c3f715 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -75,10 +75,9 @@ public: bool initialize(const QStringList &arguments, QString *errorMessage); - SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName); + SubversionClient *client() const; - SubversionSettings settings() const; - void setSettings(const SubversionSettings &s); + SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName); // IVersionControl bool vcsAdd(const QString &workingDir, const QString &fileName); @@ -93,7 +92,7 @@ public: QString monitorFile(const QString &repository) const; QString synchronousTopic(const QString &repository) const; SubversionResponse runSvn(const QString &workingDir, - const QStringList &arguments, int timeOut, + const QStringList &arguments, int timeOutS, unsigned flags, QTextCodec *outputCodec = 0) const; public slots: @@ -112,7 +111,8 @@ private slots: void revertAll(); void filelogCurrentFile(); void annotateCurrentFile(); - void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); + void annotateVersion(const QString &workingDirectory, const QString &file, + const QString &revision, int lineNumber); void projectStatus(); void describe(const QString &source, const QString &changeNr); void slotDescribe(); @@ -134,9 +134,9 @@ protected: private: inline bool isCommitEditorOpen() const; - Core::IEditor * showOutputInEditor(const QString& title, const QString &output, - int editorType, const QString &source, - QTextCodec *codec); + Core::IEditor *showOutputInEditor(const QString &title, const QString &output, + int editorType, const QString &source, + QTextCodec *codec); void filelog(const QString &workingDir, const QString &file = QString(), @@ -149,7 +149,6 @@ private: const QStringList m_svnDirectories; - SubversionSettings m_settings; SubversionClient *m_client; QString m_commitMessageFileName; QString m_commitRepository; @@ -180,7 +179,7 @@ private: QAction *m_submitUndoAction; QAction *m_submitRedoAction; QAction *m_menuAction; - bool m_submitActionTriggered; + bool m_submitActionTriggered; static SubversionPlugin *m_subversionPluginInstance; }; diff --git a/src/plugins/subversion/subversionsettings.cpp b/src/plugins/subversion/subversionsettings.cpp index 89247465e42..1dd5b20e9dd 100644 --- a/src/plugins/subversion/subversionsettings.cpp +++ b/src/plugins/subversion/subversionsettings.cpp @@ -63,11 +63,6 @@ bool SubversionSettings::hasAuthentication() const return boolValue(useAuthenticationKey) && !stringValue(userKey).isEmpty(); } -int SubversionSettings::timeOutMs() const -{ - return 1000 * intValue(timeoutKey); -} - void SubversionSettings::readLegacySettings(const QSettings *settings) { const QString keyRoot = settingsGroup() + QLatin1Char('/'); diff --git a/src/plugins/subversion/subversionsettings.h b/src/plugins/subversion/subversionsettings.h index 3c00a126646..015b5f2b673 100644 --- a/src/plugins/subversion/subversionsettings.h +++ b/src/plugins/subversion/subversionsettings.h @@ -49,8 +49,6 @@ public: SubversionSettings(); bool hasAuthentication() const; - int timeOutMs() const; - protected: void readLegacySettings(const QSettings *settings); }; diff --git a/src/plugins/subversion/subversionsubmiteditor.cpp b/src/plugins/subversion/subversionsubmiteditor.cpp index 21186879c86..3a74cfda656 100644 --- a/src/plugins/subversion/subversionsubmiteditor.cpp +++ b/src/plugins/subversion/subversionsubmiteditor.cpp @@ -50,6 +50,17 @@ void SubversionSubmitEditor::setStatusList(const QList<StatusFilePair> &statusOu // Hack to allow completion in "description" field : completion needs a root repository, the // checkScriptWorkingDirectory property is fine (at this point it was set by SubversionPlugin) model->setRepositoryRoot(checkScriptWorkingDirectory()); + model->setFileStatusQualifier([](const QString &status, const QVariant &) + -> VcsBase::SubmitFileModel::FileStatusHint + { + if (status == QLatin1String("A")) + return VcsBase::SubmitFileModel::FileAdded; + if (status == QLatin1String("M")) + return VcsBase::SubmitFileModel::FileModified; + if (status == QLatin1String("D")) + return VcsBase::SubmitFileModel::FileDeleted; + return VcsBase::SubmitFileModel::FileStatusUnknown; + } ); const ConstIterator cend = statusOutput.constEnd(); for (ConstIterator it = statusOutput.constBegin(); it != cend; ++it) diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp index ba48357bb41..9caaaaf3db6 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp @@ -209,6 +209,11 @@ QChar KeywordsCompletionAssistProcessor::startOfCommentChar() const return QLatin1Char('#'); } +void KeywordsCompletionAssistProcessor::setKeywords(Keywords keywords) +{ + m_keywords = keywords; +} + bool KeywordsCompletionAssistProcessor::acceptsIdleEditor() { const int pos = m_interface->position(); diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.h b/src/plugins/texteditor/codeassist/keywordscompletionassist.h index 7cf303085fd..1161038ef9d 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.h +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.h @@ -92,6 +92,9 @@ public: IAssistProposal *perform(const AssistInterface *interface) Q_DECL_OVERRIDE; QChar startOfCommentChar() const; +protected: + void setKeywords (Keywords keywords); + private: bool acceptsIdleEditor(); int findStartOfName(int pos = -1); diff --git a/src/plugins/texteditor/findincurrentfile.cpp b/src/plugins/texteditor/findincurrentfile.cpp index c68b459c0cc..da18ab7b441 100644 --- a/src/plugins/texteditor/findincurrentfile.cpp +++ b/src/plugins/texteditor/findincurrentfile.cpp @@ -70,7 +70,7 @@ Utils::FileIterator *FindInCurrentFile::files(const QStringList &nameFilters, QTextCodec *codec = openEditorEncodings.value(fileName); if (!codec) codec = Core::EditorManager::defaultTextCodec(); - return new Utils::FileIterator(QStringList() << fileName, QList<QTextCodec *>() << codec); + return new Utils::FileListIterator(QStringList(fileName), QList<QTextCodec *>() << codec); } QVariant FindInCurrentFile::additionalParameters() const diff --git a/src/plugins/texteditor/findinopenfiles.cpp b/src/plugins/texteditor/findinopenfiles.cpp index 200dd192346..3e2a63c6fe3 100644 --- a/src/plugins/texteditor/findinopenfiles.cpp +++ b/src/plugins/texteditor/findinopenfiles.cpp @@ -81,7 +81,7 @@ Utils::FileIterator *FindInOpenFiles::files(const QStringList &nameFilters, } } - return new Utils::FileIterator(fileNames, codecs); + return new Utils::FileListIterator(fileNames, codecs); } QVariant FindInOpenFiles::additionalParameters() const diff --git a/src/plugins/texteditor/fontsettings.cpp b/src/plugins/texteditor/fontsettings.cpp index 08d6a63f5f1..daf50dc5657 100644 --- a/src/plugins/texteditor/fontsettings.cpp +++ b/src/plugins/texteditor/fontsettings.cpp @@ -179,7 +179,8 @@ QTextCharFormat FontSettings::toTextCharFormat(TextStyle category) const && category != C_OCCURRENCES && category != C_OCCURRENCES_RENAME && category != C_OCCURRENCES_UNUSED - && category != C_SEARCH_RESULT) + && category != C_SEARCH_RESULT + && category != C_PARENTHESES_MISMATCH) tf.setForeground(f.foreground()); if (f.background().isValid() && (category == C_TEXT || f.background() != m_scheme.formatFor(C_TEXT).background())) tf.setBackground(f.background()); diff --git a/src/plugins/texteditor/fontsettingspage.cpp b/src/plugins/texteditor/fontsettingspage.cpp index 3be594711a2..73a7bcf12ce 100644 --- a/src/plugins/texteditor/fontsettingspage.cpp +++ b/src/plugins/texteditor/fontsettingspage.cpp @@ -271,6 +271,8 @@ QColor FormatDescription::background() const return QColor(0xffef0b); } else if (m_id == C_PARENTHESES) { return QColor(0xb4, 0xee, 0xb4); + } else if (m_id == C_PARENTHESES_MISMATCH) { + return QColor(Qt::magenta); } else if (m_id == C_CURRENT_LINE || m_id == C_SEARCH_SCOPE) { const QPalette palette = QApplication::palette(); const QColor &fg = palette.color(QPalette::Highlight); @@ -337,11 +339,7 @@ QWidget *FontSettingsPage::widget() d_ptr->m_ui->setupUi(d_ptr->m_widget); d_ptr->m_ui->schemeComboBox->setModel(d_ptr->m_schemeListModel); - QFontDatabase db; - const QStringList families = db.families(); - d_ptr->m_ui->familyComboBox->addItems(families); - const int idx = families.indexOf(d_ptr->m_value.family()); - d_ptr->m_ui->familyComboBox->setCurrentIndex(idx); + d_ptr->m_ui->fontComboBox->setCurrentFont(d_ptr->m_value.family()); d_ptr->m_ui->antialias->setChecked(d_ptr->m_value.antialias()); d_ptr->m_ui->zoomSpinBox->setValue(d_ptr->m_value.fontZoom()); @@ -350,13 +348,23 @@ QWidget *FontSettingsPage::widget() d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font()); d_ptr->m_ui->schemeEdit->setColorScheme(d_ptr->m_value.colorScheme()); - connect(d_ptr->m_ui->familyComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontFamilySelected(QString))); - connect(d_ptr->m_ui->sizeComboBox, SIGNAL(currentIndexChanged(QString)), this, SLOT(fontSizeSelected(QString))); - connect(d_ptr->m_ui->zoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(fontZoomChanged())); - connect(d_ptr->m_ui->antialias, SIGNAL(toggled(bool)), this, SLOT(antialiasChanged())); - connect(d_ptr->m_ui->schemeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(colorSchemeSelected(int))); - connect(d_ptr->m_ui->copyButton, SIGNAL(clicked()), this, SLOT(copyColorScheme())); - connect(d_ptr->m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(confirmDeleteColorScheme())); + connect(d_ptr->m_ui->fontComboBox, &QFontComboBox::currentFontChanged, + this, &FontSettingsPage::fontSelected); + connect(d_ptr->m_ui->sizeComboBox, + static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged), + this, &FontSettingsPage::fontSizeSelected); + connect(d_ptr->m_ui->zoomSpinBox, + static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), + this, &FontSettingsPage::fontZoomChanged); + connect(d_ptr->m_ui->antialias, &QCheckBox::toggled, + this, &FontSettingsPage::antialiasChanged); + connect(d_ptr->m_ui->schemeComboBox, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &FontSettingsPage::colorSchemeSelected); + connect(d_ptr->m_ui->copyButton, &QPushButton::clicked, + this, &FontSettingsPage::openCopyColorSchemeDialog); + connect(d_ptr->m_ui->deleteButton, &QPushButton::clicked, + this, &FontSettingsPage::confirmDeleteColorScheme); updatePointSizes(); @@ -366,10 +374,10 @@ QWidget *FontSettingsPage::widget() return d_ptr->m_widget; } -void FontSettingsPage::fontFamilySelected(const QString &family) +void FontSettingsPage::fontSelected(const QFont &font) { - d_ptr->m_value.setFamily(family); - d_ptr->m_ui->schemeEdit->setBaseFont(d_ptr->m_value.font()); + d_ptr->m_value.setFamily(font.family()); + d_ptr->m_ui->schemeEdit->setBaseFont(font); updatePointSizes(); } @@ -393,7 +401,7 @@ void FontSettingsPage::updatePointSizes() QList<int> FontSettingsPage::pointSizesForSelectedFont() const { QFontDatabase db; - const QString familyName = d_ptr->m_ui->familyComboBox->currentText(); + const QString familyName = d_ptr->m_ui->fontComboBox->currentFont().family(); QList<int> sizeLst = db.pointSizes(familyName); if (!sizeLst.isEmpty()) return sizeLst; @@ -446,7 +454,7 @@ void FontSettingsPage::colorSchemeSelected(int index) d_ptr->m_ui->schemeEdit->setReadOnly(readOnly); } -void FontSettingsPage::copyColorScheme() +void FontSettingsPage::openCopyColorSchemeDialog() { QInputDialog *dialog = new QInputDialog(d_ptr->m_ui->copyButton->window()); dialog->setAttribute(Qt::WA_DeleteOnClose); diff --git a/src/plugins/texteditor/fontsettingspage.h b/src/plugins/texteditor/fontsettingspage.h index ee7b7bd7900..af5370c5252 100644 --- a/src/plugins/texteditor/fontsettingspage.h +++ b/src/plugins/texteditor/fontsettingspage.h @@ -107,12 +107,12 @@ signals: private slots: void delayedChange(); - void fontFamilySelected(const QString &family); + void fontSelected(const QFont &font); void fontSizeSelected(const QString &sizeString); void fontZoomChanged(); void antialiasChanged(); void colorSchemeSelected(int index); - void copyColorScheme(); + void openCopyColorSchemeDialog(); void copyColorScheme(const QString &name); void confirmDeleteColorScheme(); void deleteColorScheme(); diff --git a/src/plugins/texteditor/fontsettingspage.ui b/src/plugins/texteditor/fontsettingspage.ui index 529deccde6e..59246bbea6e 100644 --- a/src/plugins/texteditor/fontsettingspage.ui +++ b/src/plugins/texteditor/fontsettingspage.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>521</width> + <width>547</width> <height>306</height> </rect> </property> @@ -17,30 +17,7 @@ <string>Font</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="familyLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>Family:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="familyComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>2</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="0" column="2"> + <item row="0" column="6"> <spacer> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -56,30 +33,14 @@ </property> </spacer> </item> - <item row="0" column="3"> - <widget class="QLabel" name="sizeLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <item row="1" column="0" colspan="3"> + <widget class="QCheckBox" name="antialias"> <property name="text"> - <string>Size:</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <widget class="QComboBox" name="sizeComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>1</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <string>Antialias</string> </property> </widget> </item> - <item row="0" column="5"> + <item row="0" column="3"> <spacer> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -95,14 +56,20 @@ </property> </spacer> </item> - <item row="1" column="0" colspan="2"> - <widget class="QCheckBox" name="antialias"> + <item row="0" column="0"> + <widget class="QLabel" name="familyLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> <property name="text"> - <string>Antialias</string> + <string>Family:</string> </property> </widget> </item> - <item row="0" column="7"> + <item row="0" column="8"> <widget class="QSpinBox" name="zoomSpinBox"> <property name="suffix"> <string>%</string> @@ -121,7 +88,37 @@ </property> </widget> </item> - <item row="0" column="8"> + <item row="0" column="7"> + <widget class="QLabel" name="zoomLabel"> + <property name="text"> + <string>Zoom:</string> + </property> + </widget> + </item> + <item row="0" column="4"> + <widget class="QLabel" name="sizeLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Size:</string> + </property> + </widget> + </item> + <item row="0" column="5"> + <widget class="QComboBox" name="sizeComboBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>1</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="0" column="9"> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -134,12 +131,8 @@ </property> </spacer> </item> - <item row="0" column="6"> - <widget class="QLabel" name="zoomLabel"> - <property name="text"> - <string>Zoom:</string> - </property> - </widget> + <item row="0" column="1"> + <widget class="QFontComboBox" name="fontComboBox"/> </item> </layout> </widget> diff --git a/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp b/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp index 6050f83766b..5b983a3d9a8 100644 --- a/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp +++ b/src/plugins/texteditor/generichighlighter/definitiondownloader.cpp @@ -41,8 +41,22 @@ #include <utils/networkaccessmanager.h> -using namespace TextEditor; -using namespace Internal; +namespace TextEditor { +namespace Internal { + +static QNetworkReply *getData(const QUrl &url) +{ + Utils::NetworkAccessManager *manager = Utils::NetworkAccessManager::instance(); + + QNetworkRequest request(url); + QNetworkReply *reply = manager->get(request); + + QEventLoop eventLoop; + QObject::connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit); + eventLoop.exec(); + + return reply; +} DefinitionDownloader::DefinitionDownloader(const QUrl &url, const QString &localPath) : m_url(url), m_localPath(localPath), m_status(Unknown) @@ -50,12 +64,10 @@ DefinitionDownloader::DefinitionDownloader(const QUrl &url, const QString &local void DefinitionDownloader::run() { - Utils::NetworkAccessManager *manager = Utils::NetworkAccessManager::instance(); - int currentAttempt = 0; const int maxAttempts = 5; while (currentAttempt < maxAttempts) { - QScopedPointer<QNetworkReply> reply(getData(manager)); + QScopedPointer<QNetworkReply> reply(getData(m_url)); if (reply->error() != QNetworkReply::NoError) { m_status = NetworkError; return; @@ -72,18 +84,6 @@ void DefinitionDownloader::run() } } -QNetworkReply *DefinitionDownloader::getData(QNetworkAccessManager *manager) const -{ - QNetworkRequest request(m_url); - QNetworkReply *reply = manager->get(request); - - QEventLoop eventLoop; - connect(reply, SIGNAL(finished()), &eventLoop, SLOT(quit())); - eventLoop.exec(); - - return reply; -} - void DefinitionDownloader::saveData(QNetworkReply *reply) { const QString &urlPath = m_url.path(); @@ -106,3 +106,6 @@ void DefinitionDownloader::saveData(QNetworkReply *reply) DefinitionDownloader::Status DefinitionDownloader::status() const { return m_status; } + +} // namespace Internal +} // namespace TextEditor diff --git a/src/plugins/texteditor/generichighlighter/definitiondownloader.h b/src/plugins/texteditor/generichighlighter/definitiondownloader.h index 336188c3262..67417ba737d 100644 --- a/src/plugins/texteditor/generichighlighter/definitiondownloader.h +++ b/src/plugins/texteditor/generichighlighter/definitiondownloader.h @@ -37,7 +37,6 @@ QT_BEGIN_NAMESPACE class QNetworkReply; -class QNetworkAccessManager; QT_END_NAMESPACE namespace TextEditor { @@ -63,7 +62,6 @@ signals: void foundReferencedDefinition(const QString &name); private: - QNetworkReply *getData(QNetworkAccessManager *manager) const; void saveData(QNetworkReply *reply); QUrl m_url; diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp index ea904d7286e..fd5a41649a3 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp +++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.cpp @@ -98,11 +98,11 @@ QWidget *HighlighterSettingsPage::widget() m_d->m_page->definitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); m_d->m_page->definitionFilesPath->setHistoryCompleter(QLatin1String("TextEditor.Highlighter.History")); m_d->m_page->definitionFilesPath->addButton(tr("Download Definitions..."), this, - SLOT(requestAvailableDefinitionsMetaData())); + [this] { requestAvailableDefinitionsMetaData(); }); m_d->m_page->fallbackDefinitionFilesPath->setExpectedKind(Utils::PathChooser::ExistingDirectory); m_d->m_page->fallbackDefinitionFilesPath->setHistoryCompleter(QLatin1String("TextEditor.Highlighter.History")); m_d->m_page->fallbackDefinitionFilesPath->addButton(tr("Autodetect"), this, - SLOT(resetDefinitionsLocation())); + [this] { resetDefinitionsLocation(); }); settingsToUI(); diff --git a/src/plugins/texteditor/generichighlighter/highlightersettingspage.h b/src/plugins/texteditor/generichighlighter/highlightersettingspage.h index 4c19e67fd05..2cc35af0b82 100644 --- a/src/plugins/texteditor/generichighlighter/highlightersettingspage.h +++ b/src/plugins/texteditor/generichighlighter/highlightersettingspage.h @@ -57,8 +57,6 @@ public: const HighlighterSettings &highlighterSettings() const; private slots: - void resetDefinitionsLocation(); - void requestAvailableDefinitionsMetaData(); void manageDefinitions(const QList<Internal::DefinitionMetaDataPtr> &metaData); void showError(); void ignoreDownloadReply(); @@ -66,6 +64,8 @@ private slots: void setDownloadDefinitionsState(bool valid); private: + void resetDefinitionsLocation(); + void requestAvailableDefinitionsMetaData(); void settingsFromUI(); void settingsToUI(); diff --git a/src/plugins/texteditor/generichighlighter/manager.h b/src/plugins/texteditor/generichighlighter/manager.h index 22de4bbf42a..c760a16a490 100644 --- a/src/plugins/texteditor/generichighlighter/manager.h +++ b/src/plugins/texteditor/generichighlighter/manager.h @@ -55,7 +55,6 @@ namespace TextEditor { namespace Internal { class HighlightDefinition; -class DefinitionDownloader; class ManagerProcessor; class MultiDefinitionDownloader; diff --git a/src/plugins/texteditor/textdocumentlayout.cpp b/src/plugins/texteditor/textdocumentlayout.cpp index 4187ef31e0b..861260ac3bb 100644 --- a/src/plugins/texteditor/textdocumentlayout.cpp +++ b/src/plugins/texteditor/textdocumentlayout.cpp @@ -498,7 +498,7 @@ void TextDocumentLayout::setFoldingIndent(const QTextBlock &block, int indent) if (TextBlockUserData *userData = testUserData(block)) userData->setFoldingIndent(0); } else { - userData(block)->setFoldingIndent(qMax(0,indent)); + userData(block)->setFoldingIndent(indent); } } diff --git a/src/plugins/texteditor/textdocumentlayout.h b/src/plugins/texteditor/textdocumentlayout.h index eaf018d82a7..72f5632f8e3 100644 --- a/src/plugins/texteditor/textdocumentlayout.h +++ b/src/plugins/texteditor/textdocumentlayout.h @@ -45,14 +45,14 @@ typedef QVector<Parenthesis> Parentheses; struct TEXTEDITOR_EXPORT Parenthesis { - enum Type { Opened, Closed }; + enum Type : char { Opened, Closed }; - inline Parenthesis() : type(Opened), pos(-1) {} + inline Parenthesis() : pos(-1), type(Opened) {} inline Parenthesis(Type t, QChar c, int position) - : type(t), chr(c), pos(position) {} - Type type; - QChar chr; + : pos(position), chr(c), type(t) {} int pos; + QChar chr; + Type type; }; class TEXTEDITOR_EXPORT CodeFormatterData @@ -66,13 +66,13 @@ class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData public: inline TextBlockUserData() - : m_folded(false), - m_ifdefedOut(false), - m_foldingIndent(0), - m_lexerState(0), - m_foldingStartIncluded(false), - m_foldingEndIncluded(false), - m_codeFormatterData(0) + : m_foldingIndent(0) + , m_folded(false) + , m_ifdefedOut(false) + , m_lexerState(0) + , m_foldingStartIncluded(false) + , m_foldingEndIncluded(false) + , m_codeFormatterData(0) {} ~TextBlockUserData(); @@ -138,9 +138,9 @@ public: private: TextMarks m_marks; + int m_foldingIndent : 16; uint m_folded : 1; uint m_ifdefedOut : 1; - uint m_foldingIndent : 16; uint m_lexerState : 8; uint m_foldingStartIncluded : 1; uint m_foldingEndIncluded : 1; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index af407726bc4..5c0fcbf7956 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -298,9 +298,6 @@ public: void transformSelection(TransformationMethod method); void transformBlockSelection(TransformationMethod method); - bool inFindScope(const QTextCursor &cursor); - bool inFindScope(int selectionStart, int selectionEnd); - void slotUpdateExtraAreaWidth(); void slotUpdateRequest(const QRect &r, int dy); void slotUpdateBlockNotify(const QTextBlock &); @@ -344,7 +341,6 @@ public: // parentheses matcher bool m_formatRange; - QTextCharFormat m_mismatchFormat; QTimer m_parenthesesMatchingTimer; // end parentheses matcher @@ -393,6 +389,7 @@ public: TextEditorWidget::Link m_currentLink; bool m_linkPressed; + TextEditorWidget::Link m_lastLinkUnderCursor; QRegExp m_searchExpr; FindFlags m_findFlags; @@ -662,8 +659,6 @@ void TextEditorWidgetPrivate::ctor(const QSharedPointer<TextDocument> &doc) // parentheses matcher m_formatRange = true; - m_mismatchFormat.setBackground(q->palette().color(QPalette::Base).value() < 128 - ? Qt::darkMagenta : Qt::magenta); m_parenthesesMatchingTimer.setSingleShot(true); QObject::connect(&m_parenthesesMatchingTimer, &QTimer::timeout, this, &TextEditorWidgetPrivate::_q_matchParentheses); @@ -2151,7 +2146,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e) && d->m_inBlockSelectionMode) { QPlainTextEdit::keyPressEvent(e); d->m_blockSelection.positionBlock = QPlainTextEdit::textCursor().blockNumber(); - setTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); + doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); viewport()->update(); e->accept(); return; @@ -2234,7 +2229,7 @@ void TextEditorWidget::keyPressEvent(QKeyEvent *e) break; } d->resetCursorFlashTimer(); - setTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); + doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); viewport()->update(); e->accept(); return; @@ -2422,7 +2417,7 @@ void TextEditorWidgetPrivate::universalHelper() // give it proper scrutiny before pushing it onto others. } -void TextEditorWidget::setTextCursor(const QTextCursor &cursor, bool keepBlockSelection) +void TextEditorWidget::doSetTextCursor(const QTextCursor &cursor, bool keepBlockSelection) { // workaround for QTextControl bug bool selectionChange = cursor.hasSelection() || textCursor().hasSelection(); @@ -2430,14 +2425,14 @@ void TextEditorWidget::setTextCursor(const QTextCursor &cursor, bool keepBlockSe d->disableBlockSelection(false); QTextCursor c = cursor; c.setVisualNavigation(true); - QPlainTextEdit::setTextCursor(c); + QPlainTextEdit::doSetTextCursor(c); if (selectionChange) d->slotSelectionChanged(); } -void TextEditorWidget::setTextCursor(const QTextCursor &cursor) +void TextEditorWidget::doSetTextCursor(const QTextCursor &cursor) { - setTextCursor(cursor, false); + doSetTextCursor(cursor, false); } void TextEditorWidget::gotoLine(int line, int column, bool centerLine) @@ -3142,7 +3137,7 @@ void TextEditorWidgetPrivate::highlightSearchResults(const QTextBlock &block, || (idx + l < text.length() && text.at(idx + l).isLetterOrNumber()))) continue; - if (!inFindScope(blockPosition + idx, blockPosition + idx + l)) + if (!q->inFindScope(blockPosition + idx, blockPosition + idx + l)) continue; const QTextCharFormat &searchResultFormat @@ -3308,7 +3303,7 @@ void TextEditorWidgetPrivate::insertIntoBlockSelection(const QString &text) column += textLength; m_blockSelection.fromPostition(positionBlock, column, anchorBlock, column); - q->setTextCursor(m_blockSelection.selection(m_document.data()), true); + q->doSetTextCursor(m_blockSelection.selection(m_document.data()), true); } void TextEditorWidgetPrivate::removeBlockSelection() @@ -3350,7 +3345,7 @@ void TextEditorWidgetPrivate::removeBlockSelection() cursor.endEditBlock(); m_blockSelection.fromPostition(positionBlock, firstColumn, anchorBlock, firstColumn); cursor = m_blockSelection.selection(m_document.data()); - q->setTextCursor(cursor, m_blockSelection.hasSelection()); + q->doSetTextCursor(cursor, m_blockSelection.hasSelection()); } void TextEditorWidgetPrivate::enableBlockSelection(const QTextCursor &cursor) @@ -3375,7 +3370,7 @@ void TextEditorWidgetPrivate::enableBlockSelection(int positionBlock, int positi m_blockSelection.fromPostition(positionBlock, anchorColumn, anchorBlock, positionColumn); resetCursorFlashTimer(); m_inBlockSelectionMode = true; - q->setTextCursor(m_blockSelection.selection(m_document.data()), true); + q->doSetTextCursor(m_blockSelection.selection(m_document.data()), true); q->viewport()->update(); } @@ -3472,8 +3467,8 @@ void TextEditorWidget::paintEvent(QPaintEvent *e) // draw backgrond to the right of the wrap column before everything else qreal lineX = 0; QPointF offset(contentOffset()); - QRect viewportRect = viewport()->rect(); - QRect er = e->rect(); + const QRect &viewportRect = viewport()->rect(); + const QRect &er = e->rect(); const FontSettings &fs = textDocument()->fontSettings(); const QTextCharFormat &searchScopeFormat = fs.toTextCharFormat(C_SEARCH_SCOPE); @@ -3827,6 +3822,12 @@ void TextEditorWidget::paintEvent(QPaintEvent *e) QColor color = fs.toTextCharFormat(C_CURRENT_LINE).background().color(); // set alpha, otherwise we cannot see block highlighting and find scope underneath color.setAlpha(128); + if (!editable && !er.contains(rr.toRect())) { + QRect updateRect = er; + updateRect.setLeft(0); + updateRect.setRight(viewportRect.width() - offset.x()); + viewport()->update(updateRect); + } painter.fillRect(rr, color); } @@ -4355,6 +4356,31 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e) painter.setPen(pal.color(QPalette::Dark)); + if (d->m_lineNumbersVisible) { + const QString &number = lineNumber(blockNumber); + bool selected = ( + (selStart < block.position() + block.length() + + && selEnd > block.position()) + || (selStart == selEnd && selStart == block.position()) + ); + if (selected) { + painter.save(); + QFont f = painter.font(); + const QTextCharFormat ¤tLineNumberFormat + = textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER); + f.setBold(currentLineNumberFormat.font().bold()); + f.setItalic(currentLineNumberFormat.font().italic()); + painter.setFont(f); + painter.setPen(currentLineNumberFormat.foreground().color()); + if (currentLineNumberFormat.background() != Qt::NoBrush) + painter.fillRect(QRect(0, top, extraAreaWidth, height), currentLineNumberFormat.background().color()); + } + painter.drawText(QRectF(markWidth, top, extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number); + if (selected) + painter.restore(); + } + if (d->m_codeFoldingVisible || d->m_marksVisible) { painter.save(); painter.setRenderHint(QPainter::Antialiasing, false); @@ -4452,31 +4478,6 @@ void TextEditorWidget::extraAreaPaintEvent(QPaintEvent *e) painter.restore(); } - if (d->m_lineNumbersVisible) { - const QString &number = lineNumber(blockNumber); - bool selected = ( - (selStart < block.position() + block.length() - - && selEnd > block.position()) - || (selStart == selEnd && selStart == block.position()) - ); - if (selected) { - painter.save(); - QFont f = painter.font(); - const QTextCharFormat ¤tLineNumberFormat - = textDocument()->fontSettings().toTextCharFormat(C_CURRENT_LINE_NUMBER); - f.setBold(currentLineNumberFormat.font().bold()); - f.setItalic(currentLineNumberFormat.font().italic()); - painter.setFont(f); - painter.setPen(currentLineNumberFormat.foreground().color()); - if (currentLineNumberFormat.background() != Qt::NoBrush) - painter.fillRect(QRect(0, top, extraAreaWidth, height), currentLineNumberFormat.background().color()); - } - painter.drawText(QRectF(markWidth, top, extraAreaWidth - markWidth - 4, height), Qt::AlignRight, number); - if (selected) - painter.restore(); - } - block = nextVisibleBlock; blockNumber = nextVisibleBlockNumber; } @@ -4770,7 +4771,7 @@ void TextEditorWidget::mouseMoveEvent(QMouseEvent *e) d->m_blockSelection.positionBlock = cursor.blockNumber(); d->m_blockSelection.positionColumn = column; - setTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); + doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); viewport()->update(); } } else if (d->m_inBlockSelectionMode) { @@ -4811,7 +4812,7 @@ void TextEditorWidget::mousePressEvent(QMouseEvent *e) d->m_blockSelection.positionBlock = block; d->m_blockSelection.positionColumn = column; - setTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); + doSetTextCursor(d->m_blockSelection.selection(d->m_document.data()), true); viewport()->update(); } else { d->enableBlockSelection(block, column, block, column); @@ -5385,9 +5386,9 @@ bool TextEditorWidget::openLink(const Link &link, bool inNextSplit) void TextEditorWidgetPrivate::updateLink(QMouseEvent *e) { - bool linkFound = false; - - if (q->mouseNavigationEnabled() && e->modifiers() & Qt::ControlModifier) { + if (!q->mouseNavigationEnabled()) + return; + if (e->modifiers() & Qt::ControlModifier) { // Link emulation behaviour for 'go to definition' const QTextCursor cursor = q->cursorForPosition(e->pos()); @@ -5399,16 +5400,22 @@ void TextEditorWidgetPrivate::updateLink(QMouseEvent *e) onText = q->cursorRect(nextPos).right() >= e->x(); } - const TextEditorWidget::Link link = q->findLinkAt(cursor, false); - - if (onText && link.hasValidLinkText()) { - showLink(link); - linkFound = true; + if (cursor.position() < m_lastLinkUnderCursor.linkTextStart + || cursor.position() > m_lastLinkUnderCursor.linkTextEnd) { + m_lastLinkUnderCursor = q->findLinkAt(cursor, false); } - } - if (!linkFound) + if (onText && m_lastLinkUnderCursor.hasValidLinkText()) { + showLink(m_lastLinkUnderCursor); + } else { + clearLink(); + // setting position to prevent multiple calls to findLinkAt for the same position + m_lastLinkUnderCursor.linkTextStart = cursor.position(); + m_lastLinkUnderCursor.linkTextEnd = cursor.position(); + } + } else { clearLink(); + } } void TextEditorWidgetPrivate::showLink(const TextEditorWidget::Link &link) @@ -5430,6 +5437,7 @@ void TextEditorWidgetPrivate::showLink(const TextEditorWidget::Link &link) void TextEditorWidgetPrivate::clearLink() { + m_lastLinkUnderCursor = TextEditorWidget::Link(); if (!m_currentLink.hasValidLinkText()) return; @@ -5594,12 +5602,14 @@ void TextEditorWidgetPrivate::_q_matchParentheses() const QTextCharFormat &matchFormat = q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES); + const QTextCharFormat &mismatchFormat + = q->textDocument()->fontSettings().toTextCharFormat(C_PARENTHESES_MISMATCH); int animatePosition = -1; if (backwardMatch.hasSelection()) { QTextEdit::ExtraSelection sel; if (backwardMatchType == TextBlockUserData::Mismatch) { sel.cursor = backwardMatch; - sel.format = m_mismatchFormat; + sel.format = mismatchFormat; extraSelections.append(sel); } else { @@ -5623,7 +5633,7 @@ void TextEditorWidgetPrivate::_q_matchParentheses() QTextEdit::ExtraSelection sel; if (forwardMatchType == TextBlockUserData::Mismatch) { sel.cursor = forwardMatch; - sel.format = m_mismatchFormat; + sel.format = mismatchFormat; extraSelections.append(sel); } else { @@ -5792,7 +5802,7 @@ void TextEditorWidget::copyLine() copy(); if (!prevCursor.hasSelection()) prevCursor.movePosition(QTextCursor::StartOfBlock); - setTextCursor(prevCursor, d->m_inBlockSelectionMode); + doSetTextCursor(prevCursor, d->m_inBlockSelectionMode); } void TextEditorWidget::deleteLine() @@ -6909,30 +6919,30 @@ void TextBlockSelection::fromPostition(int positionBlock, int positionColumn, this->anchorColumn = anchorColumn; } -bool TextEditorWidgetPrivate::inFindScope(const QTextCursor &cursor) +bool TextEditorWidget::inFindScope(const QTextCursor &cursor) { if (cursor.isNull()) return false; return inFindScope(cursor.selectionStart(), cursor.selectionEnd()); } -bool TextEditorWidgetPrivate::inFindScope(int selectionStart, int selectionEnd) +bool TextEditorWidget::inFindScope(int selectionStart, int selectionEnd) { - if (m_findScopeStart.isNull()) + if (d->m_findScopeStart.isNull()) return true; // no scope, everything is included - if (selectionStart < m_findScopeStart.position()) + if (selectionStart < d->m_findScopeStart.position()) return false; - if (selectionEnd > m_findScopeEnd.position()) + if (selectionEnd > d->m_findScopeEnd.position()) return false; - if (m_findScopeVerticalBlockSelectionFirstColumn < 0) + if (d->m_findScopeVerticalBlockSelectionFirstColumn < 0) return true; - QTextBlock block = q->document()->findBlock(selectionStart); - if (block != q->document()->findBlock(selectionEnd)) + QTextBlock block = document()->findBlock(selectionStart); + if (block != document()->findBlock(selectionEnd)) return false; QString text = block.text(); - const TabSettings &ts = m_document->tabSettings(); - int startPosition = ts.positionAtColumn(text, m_findScopeVerticalBlockSelectionFirstColumn); - int endPosition = ts.positionAtColumn(text, m_findScopeVerticalBlockSelectionLastColumn); + const TabSettings &ts = d->m_document->tabSettings(); + int startPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionFirstColumn); + int endPosition = ts.positionAtColumn(text, d->m_findScopeVerticalBlockSelectionLastColumn); if (selectionStart - block.position() < startPosition) return false; if (selectionEnd - block.position() > endPosition) @@ -7084,6 +7094,27 @@ void TextEditorWidget::inSnippetMode(bool *active) *active = d->m_snippetOverlay->isVisible(); } +QTextBlock TextEditorWidget::blockForVisibleRow(int row) const +{ + const int count = rowCount(); + if (row < 0 && row >= count) + return QTextBlock(); + + QTextBlock block = firstVisibleBlock(); + for (int i = 0; i < count; ++i) { + if (!block.isValid() || i == row) + return block; + + while (block.isValid()) { + block = block.next(); + if (block.isVisible()) + break; + } + } + return QTextBlock(); + +} + void TextEditorWidget::invokeAssist(AssistKind kind, IAssistProvider *provider) { if (kind == QuickFix && d->m_snippetOverlay->isVisible()) { @@ -7213,6 +7244,33 @@ void TextEditorWidget::configureGenericHighlighter() updateEditorInfoBar(this); } +int TextEditorWidget::lineForVisibleRow(int row) const +{ + QTextBlock block = blockForVisibleRow(row); + return block.isValid() ? block.blockNumber() : -1; +} + +int TextEditorWidget::firstVisibleLine() const +{ + return lineForVisibleRow(0); +} + +int TextEditorWidget::lastVisibleLine() const +{ + QTextBlock block = blockForVisibleRow(rowCount() - 1); + if (!block.isValid()) + block.previous(); + return block.isValid() ? block.blockNumber() : -1; +} + +int TextEditorWidget::centerVisibleLine() const +{ + QTextBlock block = blockForVisibleRow(rowCount() / 2); + if (!block.isValid()) + block.previous(); + return block.isValid() ? block.blockNumber() : -1; +} + bool TextEditorWidget::isMissingSyntaxDefinition() const { return d->m_isMissingSyntaxDefinition; @@ -7341,29 +7399,29 @@ TextEditorFactory::~TextEditorFactory() delete d; } -void TextEditorFactory::setDocumentCreator(const DocumentCreator &creator) +void TextEditorFactory::setDocumentCreator(DocumentCreator &&creator) { - d->m_documentCreator = creator; + d->m_documentCreator = std::move(creator); } -void TextEditorFactory::setEditorWidgetCreator(const EditorWidgetCreator &creator) +void TextEditorFactory::setEditorWidgetCreator(EditorWidgetCreator &&creator) { - d->m_widgetCreator = creator; + d->m_widgetCreator = std::move(creator); } -void TextEditorFactory::setEditorCreator(const EditorCreator &creator) +void TextEditorFactory::setEditorCreator(EditorCreator &&creator) { - d->m_editorCreator = creator; + d->m_editorCreator = std::move(creator); } -void TextEditorFactory::setIndenterCreator(const IndenterCreator &creator) +void TextEditorFactory::setIndenterCreator(IndenterCreator &&creator) { - d->m_indenterCreator = creator; + d->m_indenterCreator = std::move(creator); } -void TextEditorFactory::setSyntaxHighlighterCreator(const SyntaxHighLighterCreator &creator) +void TextEditorFactory::setSyntaxHighlighterCreator(SyntaxHighLighterCreator &&creator) { - d->m_syntaxHighlighterCreator = creator; + d->m_syntaxHighlighterCreator = std::move(creator); } void TextEditorFactory::setUseGenericHighlighter(bool enabled) @@ -7371,9 +7429,9 @@ void TextEditorFactory::setUseGenericHighlighter(bool enabled) d->m_useGenericHighlighter = enabled; } -void TextEditorFactory::setAutoCompleterCreator(const AutoCompleterCreator &creator) +void TextEditorFactory::setAutoCompleterCreator(AutoCompleterCreator &&creator) { - d->m_autoCompleterCreator = creator; + d->m_autoCompleterCreator = std::move(creator); } void TextEditorFactory::setEditorActionHandlers(Id contextId, uint optionalActions) diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h index 9ddaa159d56..9df1fab3a40 100644 --- a/src/plugins/texteditor/texteditor.h +++ b/src/plugins/texteditor/texteditor.h @@ -284,9 +284,6 @@ public: void setReadOnly(bool b); - void setTextCursor(const QTextCursor &cursor, bool keepBlockSelection); - void setTextCursor(const QTextCursor &cursor); - void insertCodeSnippet(const QTextCursor &cursor, const QString &snippet); void setBlockSelection(bool on); @@ -466,6 +463,21 @@ public: Q_INVOKABLE void inSnippetMode(bool *active); // Used by FakeVim. + /*! Returns the document line number for the visible \a row. + * + * The first visible row is 0, the last visible row is rowCount() - 1. + * + * Any invalid row will return -1 as line number. + */ + int lineForVisibleRow(int row) const; + + /*! Returns the first visible line of the document. */ + int firstVisibleLine() const; + /*! Returns the last visible line of the document. */ + int lastVisibleLine() const; + /*! Returns the line visible closest to the vertical center of the editor. */ + int centerVisibleLine() const; + signals: void assistFinished(); // Used in tests. void readOnlyChanged(); @@ -475,6 +487,7 @@ signals: void requestBlockUpdate(const QTextBlock &); protected: + QTextBlock blockForVisibleRow(int row) const; bool event(QEvent *e); void inputMethodEvent(QInputMethodEvent *e); void keyPressEvent(QKeyEvent *e); @@ -589,7 +602,8 @@ protected: QPointF offset, const QRect &clip); int visibleFoldedBlockNumber() const; - + void doSetTextCursor(const QTextCursor &cursor) override; + void doSetTextCursor(const QTextCursor &cursor, bool keepBlockSelection); signals: void markRequested(TextEditor::TextEditorWidget *widget, @@ -607,6 +621,9 @@ protected slots: virtual void slotCursorPositionChanged(); // Used in VcsBase virtual void slotCodeStyleSettingsChanged(const QVariant &); // Used in CppEditor + bool inFindScope(const QTextCursor &cursor); + bool inFindScope(int selectionStart, int selectionEnd); + void doFoo(); private: @@ -652,13 +669,13 @@ public: typedef std::function<Indenter *()> IndenterCreator; typedef std::function<AutoCompleter *()> AutoCompleterCreator; - void setDocumentCreator(const DocumentCreator &creator); - void setEditorWidgetCreator(const EditorWidgetCreator &creator); - void setEditorCreator(const EditorCreator &creator); - void setIndenterCreator(const IndenterCreator &creator); - void setSyntaxHighlighterCreator(const SyntaxHighLighterCreator &creator); + void setDocumentCreator(DocumentCreator &&creator); + void setEditorWidgetCreator(EditorWidgetCreator &&creator); + void setEditorCreator(EditorCreator &&creator); + void setIndenterCreator(IndenterCreator &&creator); + void setSyntaxHighlighterCreator(SyntaxHighLighterCreator &&creator); void setUseGenericHighlighter(bool enabled); - void setAutoCompleterCreator(const AutoCompleterCreator &creator); + void setAutoCompleterCreator(AutoCompleterCreator &&creator); void setEditorActionHandlers(Core::Id contextId, uint optionalActions); void setEditorActionHandlers(uint optionalActions); diff --git a/src/plugins/texteditor/texteditorconstants.cpp b/src/plugins/texteditor/texteditorconstants.cpp index d1796ea76aa..71f6aa3583f 100644 --- a/src/plugins/texteditor/texteditorconstants.cpp +++ b/src/plugins/texteditor/texteditorconstants.cpp @@ -46,6 +46,7 @@ const char *nameForStyle(TextStyle style) case C_SEARCH_RESULT: return "SearchResult"; case C_SEARCH_SCOPE: return "SearchScope"; case C_PARENTHESES: return "Parentheses"; + case C_PARENTHESES_MISMATCH:return "ParenthesesMismatch"; case C_CURRENT_LINE: return "CurrentLine"; case C_CURRENT_LINE_NUMBER: return "CurrentLineNumber"; case C_OCCURRENCES: return "Occurrences"; @@ -96,6 +97,8 @@ const char *nameForStyle(TextStyle style) case C_DIFF_DEST_LINE: return "DiffDestLine"; case C_DIFF_DEST_CHAR: return "DiffDestChar"; + case C_LOG_CHANGE_LINE: return "LogChangeLine"; + case C_LAST_STYLE_SENTINEL: return "LastStyleSentinel"; } @@ -108,7 +111,7 @@ TextStyle styleFromName(const char *name) if (qstrcmp(name, nameForStyle(TextStyle(i))) == 0) return TextStyle(i); } - return TextStyle(); + return C_LAST_STYLE_SENTINEL; } } // namespace Constants diff --git a/src/plugins/texteditor/texteditorconstants.h b/src/plugins/texteditor/texteditorconstants.h index 3bdf5c2b2ca..4433ad04b03 100644 --- a/src/plugins/texteditor/texteditorconstants.h +++ b/src/plugins/texteditor/texteditorconstants.h @@ -45,6 +45,7 @@ enum TextStyle { C_SEARCH_RESULT, C_SEARCH_SCOPE, C_PARENTHESES, + C_PARENTHESES_MISMATCH, C_CURRENT_LINE, C_CURRENT_LINE_NUMBER, C_OCCURRENCES, @@ -95,6 +96,8 @@ enum TextStyle { C_DIFF_DEST_LINE, C_DIFF_DEST_CHAR, + C_LOG_CHANGE_LINE, + C_LAST_STYLE_SENTINEL }; diff --git a/src/plugins/texteditor/texteditorsettings.cpp b/src/plugins/texteditor/texteditorsettings.cpp index fd3bf12b1c0..838d69102c3 100644 --- a/src/plugins/texteditor/texteditorsettings.cpp +++ b/src/plugins/texteditor/texteditorsettings.cpp @@ -117,6 +117,9 @@ TextEditorSettings::TextEditorSettings(QObject *parent) formatDescr.append(FormatDescription(C_PARENTHESES, tr("Parentheses"), tr("Displayed when matching parentheses, square brackets " "or curly brackets are found."))); + formatDescr.append(FormatDescription(C_PARENTHESES_MISMATCH, tr("Mismatched Parentheses"), + tr("Displayed when mismatched parentheses, " + "square brackets, or curly brackets are found."))); formatDescr.append(FormatDescription(C_CURRENT_LINE, tr("Current Line"), tr("Line where the cursor is placed in."))); @@ -268,6 +271,10 @@ TextEditorSettings::TextEditorSettings(QObject *parent) "in differences (in side-by-side diff editor)."), Format(QColor(), QColor(175, 255, 175)))); + formatDescr.append(FormatDescription(C_LOG_CHANGE_LINE, tr("Log Change Line"), + tr("Applied to lines describing changes in VCS log"), + Format(QColor(192, 0, 0), QColor()))); + d->m_fontSettingsPage = new FontSettingsPage(formatDescr, Constants::TEXT_EDITOR_FONT_SETTINGS, this); diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 222a0ba06f7..748f95eb22d 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -44,12 +44,13 @@ using namespace TextEditor::Internal; namespace TextEditor { -TextMark::TextMark(const QString &fileName, int lineNumber) +TextMark::TextMark(const QString &fileName, int lineNumber, Id category) : m_baseTextDocument(0), m_fileName(fileName), m_lineNumber(lineNumber), m_priority(NormalPriority), m_visible(true), + m_category(category), m_widthFactor(1.0) { if (!m_fileName.isEmpty()) @@ -116,6 +117,16 @@ void TextMark::setIcon(const QIcon &icon) m_icon = icon; } +Theme::Color TextMark::categoryColor(Id category) +{ + return TextEditorPlugin::baseTextMarkRegistry()->categoryColor(category); +} + +void TextMark::setCategoryColor(Id category, Theme::Color color) +{ + TextEditorPlugin::baseTextMarkRegistry()->setCategoryColor(category, color); +} + void TextMark::updateMarker() { if (m_baseTextDocument) @@ -144,6 +155,11 @@ void TextMark::setVisible(bool visible) m_baseTextDocument->updateMark(this); } +Id TextMark::category() const +{ + return m_category; +} + double TextMark::widthFactor() const { return m_widthFactor; @@ -209,6 +225,18 @@ bool TextMarkRegistry::remove(TextMark *mark) return m_marks[FileName::fromString(mark->fileName())].remove(mark); } +Theme::Color TextMarkRegistry::categoryColor(Id category) +{ + return m_colors.value(category, Theme::ProjectExplorer_TaskWarn_TextMarkColor); +} + +void TextMarkRegistry::setCategoryColor(Id category, Theme::Color color) +{ + if (m_colors[category] == color) + return; + m_colors[category] = color; +} + void TextMarkRegistry::editorOpened(IEditor *editor) { auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0); diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index 85726d521c3..e91ba41da34 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -33,6 +33,9 @@ #include "texteditor_global.h" +#include <coreplugin/id.h> +#include <utils/theme/theme.h> + #include <QIcon> QT_BEGIN_NAMESPACE @@ -51,7 +54,7 @@ namespace Internal { class TextMarkRegistry; } class TEXTEDITOR_EXPORT TextMark { public: - TextMark(const QString &fileName, int lineNumber); + TextMark(const QString &fileName, int lineNumber, Core::Id category); virtual ~TextMark(); // determine order on markers on the same line. @@ -77,6 +80,8 @@ public: virtual bool isDraggable() const; virtual void dragToLine(int lineNumber); + static Utils::Theme::Color categoryColor(Core::Id category); + static void setCategoryColor(Core::Id category, Utils::Theme::Color color); void setIcon(const QIcon &icon); // call this if the icon has changed. void updateMarker(); @@ -84,6 +89,7 @@ public: void setPriority(Priority prioriy); bool isVisible() const; void setVisible(bool isVisible); + Core::Id category() const; double widthFactor() const; void setWidthFactor(double factor); @@ -100,6 +106,8 @@ private: Priority m_priority; bool m_visible; QIcon m_icon; + QColor m_color; + Core::Id m_category; double m_widthFactor; }; diff --git a/src/plugins/texteditor/textmarkregistry.h b/src/plugins/texteditor/textmarkregistry.h index 052627b9afb..8231aab051b 100644 --- a/src/plugins/texteditor/textmarkregistry.h +++ b/src/plugins/texteditor/textmarkregistry.h @@ -33,10 +33,14 @@ #include <utils/fileutils.h> -#include <QObject> +#include <QColor> #include <QHash> +#include <QObject> #include <QSet> +#include <coreplugin/id.h> +#include <utils/theme/theme.h> + namespace Core { class IEditor; class IDocument; @@ -54,12 +58,15 @@ public: void add(TextMark *mark); bool remove(TextMark *mark); + Utils::Theme::Color categoryColor(Core::Id category); + void setCategoryColor(Core::Id category, Utils::Theme::Color color); private slots: void editorOpened(Core::IEditor *editor); void documentRenamed(Core::IDocument *document, const QString &oldName, const QString &newName); void allDocumentsRenamed(const QString &oldName, const QString &newName); private: QHash<Utils::FileName, QSet<TextMark *> > m_marks; + QHash<Core::Id, Utils::Theme::Color> m_colors; }; } // namespace Internal diff --git a/src/plugins/todo/todo.pro b/src/plugins/todo/todo.pro index eb5e38916a8..f430c04daf0 100644 --- a/src/plugins/todo/todo.pro +++ b/src/plugins/todo/todo.pro @@ -15,7 +15,8 @@ HEADERS += todoplugin.h \ cpptodoitemsscanner.h \ qmljstodoitemsscanner.h \ lineparser.h \ - todooutputtreeview.h + todooutputtreeview.h \ + todooutputtreeviewdelegate.h SOURCES += todoplugin.cpp \ keyword.cpp \ todooutputpane.cpp \ @@ -29,7 +30,8 @@ SOURCES += todoplugin.cpp \ cpptodoitemsscanner.cpp \ qmljstodoitemsscanner.cpp \ lineparser.cpp \ - todooutputtreeview.cpp + todooutputtreeview.cpp \ + todooutputtreeviewdelegate.cpp RESOURCES += \ todoplugin.qrc diff --git a/src/plugins/todo/todo.qbs b/src/plugins/todo/todo.qbs index 78640179250..cfeae575cdd 100644 --- a/src/plugins/todo/todo.qbs +++ b/src/plugins/todo/todo.qbs @@ -43,6 +43,8 @@ QtcPlugin { "todooutputpane.h", "todooutputtreeview.cpp", "todooutputtreeview.h", + "todooutputtreeviewdelegate.cpp", + "todooutputtreeviewdelegate.h", "todoplugin.cpp", "todoplugin.h", "todoplugin.qrc", diff --git a/src/plugins/todo/todooutputtreeview.cpp b/src/plugins/todo/todooutputtreeview.cpp index 612d1761b1f..3039c324e44 100644 --- a/src/plugins/todo/todooutputtreeview.cpp +++ b/src/plugins/todo/todooutputtreeview.cpp @@ -28,7 +28,9 @@ ** ****************************************************************************/ + #include "todooutputtreeview.h" +#include "todooutputtreeviewdelegate.h" #include "constants.h" #include <coreplugin/icore.h> @@ -50,6 +52,7 @@ TodoOutputTreeView::TodoOutputTreeView(QWidget *parent) : setSortingEnabled(true); setAttribute(Qt::WA_MacShowFocusRect, false); setSelectionBehavior(QTreeView::SelectRows); + setItemDelegate(new TodoOutputTreeViewDelegate(this)); header()->setSectionResizeMode(QHeaderView::Interactive); header()->setStretchLastSection(true); diff --git a/src/plugins/cvs/checkoutwizardpage.cpp b/src/plugins/todo/todooutputtreeviewdelegate.cpp index 2aa4bc6e859..5af37fbfa6e 100644 --- a/src/plugins/cvs/checkoutwizardpage.cpp +++ b/src/plugins/todo/todooutputtreeviewdelegate.cpp @@ -1,4 +1,4 @@ -/**************************************************************************** +/************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing @@ -27,21 +27,24 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#include "todooutputtreeviewdelegate.h" +#include "constants.h" -#include "checkoutwizardpage.h" - -namespace Cvs { +namespace Todo { namespace Internal { -CheckoutWizardPage::CheckoutWizardPage(QWidget *parent) : - VcsBase::BaseCheckoutWizardPage(parent) +TodoOutputTreeViewDelegate::TodoOutputTreeViewDelegate(QObject *parent) : + QStyledItemDelegate(parent) { - setTitle(tr("Location")); - setSubTitle(tr("Specify repository and path.")); - setRepositoryLabel(tr("Repository:")); - setDirectoryVisible(false); - setBranchSelectorVisible(false); +} + +void TodoOutputTreeViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QStyleOptionViewItem newOption = option; + newOption.textElideMode = index.column() == Constants::OUTPUT_COLUMN_FILE ? Qt::ElideLeft : Qt::ElideRight; + QStyledItemDelegate::paint(painter, newOption, index); } } // namespace Internal -} // namespace Cvs +} // namespace Todo + diff --git a/src/plugins/cvs/checkoutwizard.h b/src/plugins/todo/todooutputtreeviewdelegate.h index 5738c472b0f..9202cdc8255 100644 --- a/src/plugins/cvs/checkoutwizard.h +++ b/src/plugins/todo/todooutputtreeviewdelegate.h @@ -1,4 +1,4 @@ -/**************************************************************************** +/************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing @@ -27,28 +27,23 @@ ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ +#ifndef TODO_INTERNAL_TODOOUTPUTTREEVIEWDELEGATE_H +#define TODO_INTERNAL_TODOOUTPUTTREEVIEWDELEGATE_H -#ifndef CHECKOUTWIZARD_H -#define CHECKOUTWIZARD_H +#include <QStyledItemDelegate> -#include <vcsbase/basecheckoutwizardfactory.h> -#include <vcsbase/basecheckoutwizard.h> - -namespace Cvs { +namespace Todo { namespace Internal { -class CheckoutWizard : public VcsBase::BaseCheckoutWizard +class TodoOutputTreeViewDelegate : public QStyledItemDelegate { Q_OBJECT - public: - CheckoutWizard(const Utils::FileName &path, QWidget *parent = 0); - -protected: - VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir); + explicit TodoOutputTreeViewDelegate(QObject *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; }; } // namespace Internal -} // namespace Cvs +} // namespace Todo -#endif // CHECKOUTWIZARD_H +#endif // TODO_INTERNAL_TODOOUTPUTTREEVIEWDELEGATE_H diff --git a/src/plugins/valgrind/callgrindtextmark.cpp b/src/plugins/valgrind/callgrindtextmark.cpp index 064025268e4..058871047d7 100644 --- a/src/plugins/valgrind/callgrindtextmark.cpp +++ b/src/plugins/valgrind/callgrindtextmark.cpp @@ -43,9 +43,12 @@ using namespace Valgrind::Internal; using namespace Valgrind::Callgrind; +namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; } + CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index, const QString &fileName, int lineNumber) - : TextEditor::TextMark(fileName, lineNumber), m_modelIndex(index) + : TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY) + , m_modelIndex(index) { setPriority(TextEditor::TextMark::HighPriority); setWidthFactor(4.0); diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index ebee6c1c3b1..b5ec4840334 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -177,13 +177,10 @@ bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModel return true; } -static void initKindFilterAction(QAction *action, const QList<int> &kinds) +static void initKindFilterAction(QAction *action, const QVariantList &kinds) { action->setCheckable(true); - QVariantList data; - foreach (int kind, kinds) - data << kind; - action->setData(data); + action->setData(kinds); } MemcheckTool::MemcheckTool(QObject *parent) @@ -208,21 +205,21 @@ MemcheckTool::MemcheckTool(QObject *parent) tr("These suppression files were used in the last memory analyzer run.")); QAction *a = new QAction(tr("Definite Memory Leaks"), this); - initKindFilterAction(a, QList<int>() << Leak_DefinitelyLost << Leak_IndirectlyLost); + initKindFilterAction(a, { Leak_DefinitelyLost, Leak_IndirectlyLost }); m_errorFilterActions.append(a); a = new QAction(tr("Possible Memory Leaks"), this); - initKindFilterAction(a, QList<int>() << Leak_PossiblyLost << Leak_StillReachable); + initKindFilterAction(a, { Leak_PossiblyLost, Leak_StillReachable }); m_errorFilterActions.append(a); a = new QAction(tr("Use of Uninitialized Memory"), this); - initKindFilterAction(a, QList<int>() << InvalidRead << InvalidWrite << InvalidJump << Overlap - << InvalidMemPool << UninitCondition << UninitValue - << SyscallParam << ClientCheck); + initKindFilterAction(a, { InvalidRead, InvalidWrite, InvalidJump, Overlap, + InvalidMemPool, UninitCondition, UninitValue, + SyscallParam, ClientCheck }); m_errorFilterActions.append(a); a = new QAction(tr("Invalid Calls to \"free()\""), this); - initKindFilterAction(a, QList<int>() << InvalidFree << MismatchedFree); + initKindFilterAction(a, { InvalidFree, MismatchedFree }); m_errorFilterActions.append(a); } diff --git a/src/plugins/valgrind/valgrindruncontrolfactory.cpp b/src/plugins/valgrind/valgrindruncontrolfactory.cpp index a7aa0c1b4a9..b5aac27838e 100644 --- a/src/plugins/valgrind/valgrindruncontrolfactory.cpp +++ b/src/plugins/valgrind/valgrindruncontrolfactory.cpp @@ -124,15 +124,14 @@ public: resetProjectToGlobalSettings(); } - IRunConfigurationAspect *create(RunConfiguration *parent) const + ValgrindRunConfigurationAspect *create(RunConfiguration *parent) const override { return new ValgrindRunConfigurationAspect(parent); } - RunConfigWidget *createConfigurationWidget() + RunConfigWidget *createConfigurationWidget() override { return new AnalyzerRunConfigWidget(this); - } }; diff --git a/src/plugins/vcsbase/basecheckoutwizard.cpp b/src/plugins/vcsbase/basecheckoutwizard.cpp deleted file mode 100644 index 1d48b588af5..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizard.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "basecheckoutwizard.h" -#include "basecheckoutwizardfactory.h" -#include "checkoutprogresswizardpage.h" - -#include <utils/qtcassert.h> - -#include <QPushButton> - -/*! - \class VcsBase::Internal::CheckoutWizardDialog - - Dialog used by \sa VcsBase::BaseCheckoutWizard. Overwrites reject() to first - kill the checkout and then close. - */ - -namespace VcsBase { - -BaseCheckoutWizard::BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent) : - Utils::Wizard(parent), - m_progressPage(new Internal::CheckoutProgressWizardPage), - m_progressPageId(-1) -{ - Q_UNUSED(path); - connect(this, &QWizard::currentIdChanged, this, &BaseCheckoutWizard::slotPageChanged); - connect(m_progressPage, &Internal::CheckoutProgressWizardPage::terminated, - this, &BaseCheckoutWizard::slotTerminated); - setOption(QWizard::NoBackButtonOnLastPage); -} - -void BaseCheckoutWizard::setTitle(const QString &title) -{ - m_progressPage->setTitle(title); -} - -void BaseCheckoutWizard::setStartedStatus(const QString &title) -{ - m_progressPage->setStartedStatus(title); -} - -void BaseCheckoutWizard::slotPageChanged(int id) -{ - if (id != m_progressPageId) - return; - - VcsBase::VcsCommand *cmd = createCommand(&m_checkoutDir); - QTC_ASSERT(cmd, done(QDialog::Rejected)); - - // No "back" available while running. - button(QWizard::BackButton)->setEnabled(false); - m_progressPage->start(cmd); -} - -void BaseCheckoutWizard::slotTerminated(bool success) -{ - // Allow to correct parameters - if (!success) - button(QWizard::BackButton)->setEnabled(true); -} - -Utils::FileName BaseCheckoutWizard::run() -{ - m_progressPageId = addPage(m_progressPage); - if (Utils::Wizard::exec() == QDialog::Accepted) - return m_checkoutDir; - else - return Utils::FileName(); -} - -void BaseCheckoutWizard::reject() -{ - // First click kills, 2nd closes - if (currentId() == m_progressPageId && m_progressPage->isRunning()) - m_progressPage->terminate(); - else - QWizard::reject(); -} - -} // namespace VcsBase diff --git a/src/plugins/vcsbase/basecheckoutwizard.h b/src/plugins/vcsbase/basecheckoutwizard.h deleted file mode 100644 index 0b362c6284c..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizard.h +++ /dev/null @@ -1,72 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BASECHECKOUTWIZARD_H -#define BASECHECKOUTWIZARD_H - -#include "vcsbase_global.h" - -#include <utils/fileutils.h> -#include <utils/wizard.h> - -namespace VcsBase { -class VcsCommand; - -namespace Internal { class CheckoutProgressWizardPage; } - -class VCSBASE_EXPORT BaseCheckoutWizard : public Utils::Wizard -{ - Q_OBJECT - -public: - explicit BaseCheckoutWizard(const Utils::FileName &path, QWidget *parent = 0); - - void setTitle(const QString &title); - void setStartedStatus(const QString &title); - - Utils::FileName run(); - -protected: - virtual VcsBase::VcsCommand *createCommand(Utils::FileName *checkoutDir) = 0; - -private slots: - void slotPageChanged(int id); - void slotTerminated(bool success); - virtual void reject(); - -private: - Internal::CheckoutProgressWizardPage *m_progressPage; - int m_progressPageId; - Utils::FileName m_checkoutDir; -}; - -} // namespace VcsBase - -#endif // BASECHECKOUTWIZARD_H diff --git a/src/plugins/vcsbase/basecheckoutwizardfactory.cpp b/src/plugins/vcsbase/basecheckoutwizardfactory.cpp deleted file mode 100644 index dfb29ccc6b9..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizardfactory.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "basecheckoutwizardfactory.h" -#include "basecheckoutwizard.h" - -#include <coreplugin/icontext.h> -#include <coreplugin/icore.h> -#include <coreplugin/featureprovider.h> - -#include <projectexplorer/projectexplorer.h> - -#include <utils/fileutils.h> -#include <utils/qtcassert.h> - -#include <QCoreApplication> -#include <QDir> -#include <QMessageBox> -#include <QScopedPointer> - -/*! - \class VcsBase::BaseCheckoutWizard - - \brief The BaseCheckoutWizard class implements a wizard for initially - checking out a project using a version control system. - - Implements all of Core::IWizard with the exception of - name()/description() and icon(). - - Pops up a QWizard consisting of a Parameter Page which is created - by a virtual factory function and a progress - page containing a log text. The factory function createJob() - creates a job with the output connected to the log window, - returning the path to the checkout. - - On success, the wizard tries to locate a project file - and open it. - - \sa VcsBase::BaseCheckoutWizardPage -*/ - -namespace VcsBase { - -BaseCheckoutWizardFactory::BaseCheckoutWizardFactory() -{ - setWizardKind(IWizardFactory::ProjectWizard); - setCategory(QLatin1String(ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY)); - setDisplayCategory(QCoreApplication::translate("ProjectExplorer", - ProjectExplorer::Constants::IMPORT_WIZARD_CATEGORY_DISPLAY)); - setFlags(Core::IWizardFactory::PlatformIndependent); -} - -void BaseCheckoutWizardFactory::runWizard(const QString &path, QWidget *parent, const QString &platform, - const QVariantMap &extraValues) -{ - Q_UNUSED(platform); - Q_UNUSED(extraValues); - // Create dialog and launch - - Utils::FileName checkoutPath; - { - QScopedPointer<BaseCheckoutWizard> wizard(m_wizardCreator(Utils::FileName::fromString(path), parent)); - wizard->setWindowTitle(displayName()); - Core::ICore::registerWindow(wizard.data(), Core::Context("New.CheckoutWizard")); - checkoutPath = wizard->run(); - } - - if (checkoutPath.isEmpty()) - return; - - // Now try to find the project file and open - QString errorMessage; - const QString projectFile = openProject(checkoutPath, &errorMessage); - if (projectFile.isEmpty()) { - QMessageBox msgBox(QMessageBox::Warning, tr("Cannot Open Project"), - tr("Failed to open project in \"%1\".").arg(checkoutPath.toUserOutput())); - msgBox.setDetailedText(errorMessage); - msgBox.addButton(QMessageBox::Ok); - msgBox.exec(); - } -} - -static inline QString msgNoProjectFiles(const QDir &dir, const QStringList &patterns) -{ - return BaseCheckoutWizardFactory::tr("Could not find any project files matching (%1) in the directory \"%2\".").arg(patterns.join(QLatin1String(", ")), QDir::toNativeSeparators(dir.absolutePath())); -} - -// Try to find the project files in a project directory with some smartness -static QFileInfoList findProjectFiles(const QDir &projectDir, QString *errorMessage) -{ - const QStringList projectFilePatterns = ProjectExplorer::ProjectExplorerPlugin::projectFilePatterns(); - // Project directory - QFileInfoList projectFiles = projectDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); - if (!projectFiles.empty()) - return projectFiles; - // Try a 'src' directory - QFileInfoList srcDirs = projectDir.entryInfoList(QStringList(QLatin1String("src")), QDir::Dirs|QDir::NoDotAndDotDot|QDir::Readable); - if (srcDirs.empty()) { - *errorMessage = msgNoProjectFiles(projectDir, projectFilePatterns); - return QFileInfoList(); - } - const QDir srcDir = QDir(srcDirs.front().absoluteFilePath()); - projectFiles = srcDir.entryInfoList(projectFilePatterns, QDir::Files|QDir::NoDotAndDotDot|QDir::Readable); - if (projectFiles.empty()) { - *errorMessage = msgNoProjectFiles(srcDir, projectFilePatterns); - return QFileInfoList(); - } - return projectFiles; -} - -QString BaseCheckoutWizardFactory::openProject(const Utils::FileName &path, QString *errorMessage) -{ - // Search the directory for project files - const QDir dir(path.toString()); - if (!dir.exists()) { - *errorMessage = tr("\"%1\" does not exist."). - arg(path.toUserOutput()); // Should not happen - return QString(); - } - QFileInfoList projectFiles = findProjectFiles(dir, errorMessage); - if (projectFiles.empty()) - return QString(); - // Open. Do not use a busy cursor here as additional wizards might pop up - const QString projectFile = projectFiles.front().absoluteFilePath(); - if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(projectFile, errorMessage)) - return QString(); - - return projectFile; -} - -void BaseCheckoutWizardFactory::setWizardCreator(const BaseCheckoutWizardFactory::WizardCreator &creator) -{ - m_wizardCreator = creator; -} - -} // namespace VcsBase diff --git a/src/plugins/vcsbase/basecheckoutwizardfactory.h b/src/plugins/vcsbase/basecheckoutwizardfactory.h deleted file mode 100644 index 46dcb74563a..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizardfactory.h +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef BASECHECKOUTWIZARDFACTORY_H -#define BASECHECKOUTWIZARDFACTORY_H - -#include "vcsbase_global.h" -#include <coreplugin/iwizardfactory.h> - -#include <functional> - -namespace Utils { class FileName; } -namespace VcsBase { -class BaseCheckoutWizard; -class VcsCommand; - -class VCSBASE_EXPORT BaseCheckoutWizardFactory : public Core::IWizardFactory -{ - Q_OBJECT - -public: - BaseCheckoutWizardFactory(); - - void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues); - - static QString openProject(const Utils::FileName &path, QString *errorMessage); - - typedef std::function<BaseCheckoutWizard *(const Utils::FileName &path, QWidget *parent)> WizardCreator; - void setWizardCreator(const WizardCreator &creator); - -private: - WizardCreator m_wizardCreator; -}; - -} // namespace VcsBase - -#endif // BASECHECKOUTWIZARDFACTORY_H diff --git a/src/plugins/vcsbase/basecheckoutwizardpage.cpp b/src/plugins/vcsbase/basecheckoutwizardpage.cpp deleted file mode 100644 index 82e061d6899..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizardpage.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "basecheckoutwizardpage.h" -#include "ui_basecheckoutwizardpage.h" - -#include <QDir> -#include <QIcon> - -/*! - \class VcsBase::BaseCheckoutWizardPage - - \brief The BaseCheckoutWizardPage class is the base class for a parameter - page of a checkout wizard. - - Lets the user specify the repository, a checkout directory and - the path. Contains a virtual to derive the checkout directory - from the repository as it is entered. - - \sa VcsBase::BaseCheckoutWizard -*/ - -namespace VcsBase { -namespace Internal { - -class BaseCheckoutWizardPagePrivate -{ -public: - BaseCheckoutWizardPagePrivate() : m_valid(false), m_directoryEdited(false) {} - - Internal::Ui::BaseCheckoutWizardPage ui; - bool m_valid; - bool m_directoryEdited; -}; - -} // namespace Internal - -BaseCheckoutWizardPage::BaseCheckoutWizardPage(QWidget *parent) : - QWizardPage(parent), - d(new Internal::BaseCheckoutWizardPagePrivate) -{ - d->ui.setupUi(this); - - connect(d->ui.repositoryLineEdit, &QLineEdit::textChanged, - this, &BaseCheckoutWizardPage::slotRepositoryChanged); - - connect(d->ui.checkoutDirectoryLineEdit, &QLineEdit::textChanged, - this, &BaseCheckoutWizardPage::slotChanged); - connect(d->ui.checkoutDirectoryLineEdit, &QLineEdit::textEdited, - this, &BaseCheckoutWizardPage::slotDirectoryEdited); - connect(d->ui.branchComboBox, - static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), - this, &BaseCheckoutWizardPage::slotChanged); - - d->ui.pathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory); - d->ui.pathChooser->setHistoryCompleter(QLatin1String("Vcs.CheckoutDir.History")); - connect(d->ui.pathChooser, &Utils::PathChooser::validChanged, - this, &BaseCheckoutWizardPage::slotChanged); - - d->ui.branchComboBox->setEnabled(false); - d->ui.branchRefreshToolButton->setIcon(QIcon(QLatin1String(":/locator/images/reload.png"))); - connect(d->ui.branchRefreshToolButton, &QAbstractButton::clicked, - this, &BaseCheckoutWizardPage::slotRefreshBranches); -} - -BaseCheckoutWizardPage::~BaseCheckoutWizardPage() -{ - delete d; -} - -void BaseCheckoutWizardPage::addLocalControl(QWidget *w) -{ - d->ui.localLayout->addRow(w); -} - -void BaseCheckoutWizardPage::addLocalControl(QString &description, QWidget *w) -{ - d->ui.localLayout->addRow(description, w); -} - -void BaseCheckoutWizardPage::addRepositoryControl(QWidget *w) -{ - d->ui.repositoryLayout->addRow(w); -} - -bool BaseCheckoutWizardPage::checkIsValid() const -{ - if (!d->ui.pathChooser->isValid() || d->ui.repositoryLineEdit->text().isEmpty()) - return false; - - const QString checkoutDirectory = d->ui.checkoutDirectoryLineEdit->text(); - if (checkoutDirectory.isEmpty()) - return false; - const QDir dir(d->ui.pathChooser->path() + QLatin1Char('/') + checkoutDirectory); - return !dir.exists() || (dir.count() <= 2); -} - -void BaseCheckoutWizardPage::addRepositoryControl(QString &description, QWidget *w) -{ - d->ui.repositoryLayout->addRow(description, w); -} - -bool BaseCheckoutWizardPage::isBranchSelectorVisible() const -{ - return d->ui.branchComboBox->isVisible(); -} - -void BaseCheckoutWizardPage::setBranchSelectorVisible(bool v) -{ - d->ui.branchComboBox->setVisible(v); - d->ui.branchRefreshToolButton->setVisible(v); - d->ui.branchLabel->setVisible(v); -} - -void BaseCheckoutWizardPage::setRepositoryLabel(const QString &l) -{ - d->ui.repositoryLabel->setText(l); -} - -bool BaseCheckoutWizardPage::isRepositoryReadOnly() const -{ - return d->ui.repositoryLineEdit->isReadOnly(); -} - -void BaseCheckoutWizardPage::setRepositoryReadOnly(bool v) -{ - d->ui.repositoryLineEdit->setReadOnly(v); -} - -QString BaseCheckoutWizardPage::path() const -{ - return d->ui.pathChooser->path(); -} - -void BaseCheckoutWizardPage::setPath(const QString &p) -{ - d->ui.pathChooser->setPath(p); -} - -QString BaseCheckoutWizardPage::directory() const -{ - return d->ui.checkoutDirectoryLineEdit->text(); -} - -void BaseCheckoutWizardPage::setDirectory(const QString &dir) -{ - d->ui.checkoutDirectoryLineEdit->setText(dir); -} - -void BaseCheckoutWizardPage::setDirectoryVisible(bool v) -{ - d->ui.checkoutDirectoryLabel->setVisible(v); - d->ui.checkoutDirectoryLineEdit->setVisible(v); -} - -QString BaseCheckoutWizardPage::repository() const -{ - return d->ui.repositoryLineEdit->text().trimmed(); -} - -void BaseCheckoutWizardPage::setRepository(const QString &r) -{ - d->ui.repositoryLineEdit->setText(r); -} - -QString BaseCheckoutWizardPage::branch() const -{ - return d->ui.branchComboBox->currentText(); -} - -void BaseCheckoutWizardPage::setBranch(const QString &b) -{ - const int index = d->ui.branchComboBox->findText(b); - if (index != -1) - d->ui.branchComboBox->setCurrentIndex(index); -} - -void BaseCheckoutWizardPage::slotRefreshBranches() -{ - if (!isBranchSelectorVisible()) - return; - // Refresh branch list on demand. This is hard to make - // automagically since there can be network slowness/timeouts, etc. - int current; - const QStringList branchList = branches(repository(), ¤t); - d->ui.branchComboBox->clear(); - d->ui.branchComboBox->setEnabled(branchList.size() > 1); - if (!branchList.isEmpty()) { - d->ui.branchComboBox->addItems(branchList); - if (current >= 0 && current < branchList.size()) - d->ui.branchComboBox->setCurrentIndex(current); - } - slotChanged(); -} - -void BaseCheckoutWizardPage::slotRepositoryChanged(const QString &repo) -{ - // Derive directory name from repository unless user manually edited it. - if (!d->m_directoryEdited) - d->ui.checkoutDirectoryLineEdit->setText(directoryFromRepository(repo)); - slotChanged(); -} - -QString BaseCheckoutWizardPage::directoryFromRepository(const QString &r) const -{ - return r; -} - -QStringList BaseCheckoutWizardPage::branches(const QString &, int *) -{ - return QStringList(); -} - -void BaseCheckoutWizardPage::slotDirectoryEdited() -{ - d->m_directoryEdited = true; - slotChanged(); -} - -bool BaseCheckoutWizardPage::isComplete() const -{ - return d->m_valid; -} - -void BaseCheckoutWizardPage::slotChanged() -{ - const bool valid = checkIsValid(); - - if (valid != d->m_valid) { - d->m_valid = valid; - emit completeChanged(); - } -} - -} // namespace VcsBase diff --git a/src/plugins/vcsbase/basecheckoutwizardpage.h b/src/plugins/vcsbase/basecheckoutwizardpage.h deleted file mode 100644 index b4074ce7724..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizardpage.h +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#ifndef VCSBASE_CHECKOUTWIZARDPAGE_H -#define VCSBASE_CHECKOUTWIZARDPAGE_H - -#include "vcsbase_global.h" - -#include <QWizardPage> - -namespace VcsBase { - -namespace Internal { -class BaseCheckoutWizardPagePrivate; - -namespace Ui { class BaseCheckoutWizardPage; } -} // namespace Internal - - -class VCSBASE_EXPORT BaseCheckoutWizardPage : public QWizardPage -{ - Q_OBJECT - Q_PROPERTY(bool isBranchSelectorVisible READ isBranchSelectorVisible - WRITE setBranchSelectorVisible) - -public: - BaseCheckoutWizardPage(QWidget *parent = 0); - ~BaseCheckoutWizardPage(); - - QString path() const; - void setPath(const QString &); - - QString directory() const; - void setDirectory(const QString &d); - - QString repository() const; - void setRepository(const QString &r); - - bool isRepositoryReadOnly() const; - void setRepositoryReadOnly(bool v); - - QString branch() const; - void setBranch(const QString &); - - virtual bool isComplete() const; - - bool isBranchSelectorVisible() const; - -protected: - void setRepositoryLabel(const QString &l); - void setDirectoryVisible(bool v); - void setBranchSelectorVisible(bool v); - - // Determine a checkout directory name from - // repository URL, that is, "protocol:/project" -> "project". - virtual QString directoryFromRepository(const QString &r) const; - - // Return list of branches of that repository, defaults to empty. - virtual QStringList branches(const QString &repository, int *current); - - // Add additional controls. - void addLocalControl(QWidget *w); - void addLocalControl(QString &description, QWidget *w); - - void addRepositoryControl(QWidget *w); - void addRepositoryControl(QString &description, QWidget *w); - - // Override validity information. - virtual bool checkIsValid() const; - -private slots: - void slotRepositoryChanged(const QString &url); - void slotDirectoryEdited(); - void slotChanged(); - void slotRefreshBranches(); - -private: - Internal::BaseCheckoutWizardPagePrivate *const d; -}; - -} // namespace VcsBase - -#endif // VCSBASE_CHECKOUTWIZARDPAGE_H diff --git a/src/plugins/vcsbase/basecheckoutwizardpage.ui b/src/plugins/vcsbase/basecheckoutwizardpage.ui deleted file mode 100644 index edf34f080b0..00000000000 --- a/src/plugins/vcsbase/basecheckoutwizardpage.ui +++ /dev/null @@ -1,156 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>VcsBase::Internal::BaseCheckoutWizardPage</class> - <widget class="QWizardPage" name="VcsBase::Internal::BaseCheckoutWizardPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>483</width> - <height>237</height> - </rect> - </property> - <property name="windowTitle"> - <string>WizardPage</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QGroupBox" name="repositoryGroupBox"> - <property name="title"> - <string>Repository</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <layout class="QFormLayout" name="repositoryLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="repositoryLabel"/> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="repositoryLineEdit"> - <property name="toolTip"> - <string>The remote repository to check out.</string> - </property> - <property name="whatsThis"> - <string/> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="branchLabel"> - <property name="text"> - <string>Branch:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <layout class="QHBoxLayout" name="branchHorizontalLayout"> - <item> - <widget class="QComboBox" name="branchComboBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>The development branch in the remote repository to check out.</string> - </property> - <property name="whatsThis"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="branchRefreshToolButton"> - <property name="toolTip"> - <string>Retrieve list of branches in repository.</string> - </property> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="localGroupBox"> - <property name="title"> - <string>Working Copy</string> - </property> - <property name="flat"> - <bool>true</bool> - </property> - <layout class="QFormLayout" name="localLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="pathLabel"> - <property name="toolTip"> - <string>The path in which the directory containing the checkout will be created.</string> - </property> - <property name="text"> - <string>Path:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="Utils::PathChooser" name="pathChooser" native="true"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="checkoutDirectoryLabel"> - <property name="toolTip"> - <string>The local directory that will contain the code after the checkout.</string> - </property> - <property name="text"> - <string>Directory:</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="checkoutDirectoryLineEdit"> - <property name="toolTip"> - <string>The local directory that will contain the code after the checkout.</string> - </property> - <property name="whatsThis"> - <string/> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>Utils::PathChooser</class> - <extends>QWidget</extends> - <header location="global">utils/pathchooser.h</header> - <container>1</container> - <slots> - <signal>editingFinished()</signal> - <signal>browsingFinished()</signal> - </slots> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp b/src/plugins/vcsbase/checkoutprogresswizardpage.cpp deleted file mode 100644 index 4efaee4b155..00000000000 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms and -** conditions see http://www.qt.io/terms-conditions. For further information -** use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -****************************************************************************/ - -#include "checkoutprogresswizardpage.h" -#include "vcscommand.h" -#include "vcsbaseplugin.h" - -#include <utils/outputformatter.h> -#include <utils/qtcassert.h> - -#include <QApplication> -#include <QLabel> -#include <QPlainTextEdit> -#include <QVBoxLayout> - -/*! - \class VcsBase::Internal::CheckoutProgressWizardPage - - \brief The CheckoutProgressWizardPage implements a page showing the - progress of an initial project checkout. - - Turns complete when the job succeeds. - - \sa VcsBase::BaseCheckoutWizard -*/ - -namespace VcsBase { -namespace Internal { - -CheckoutProgressWizardPage::CheckoutProgressWizardPage(QWidget *parent) : - QWizardPage(parent), - m_startedStatus(tr("Checkout started...")), - m_overwriteOutput(false), - m_state(Idle) -{ - resize(264, 200); - auto verticalLayout = new QVBoxLayout(this); - m_logPlainTextEdit = new QPlainTextEdit; - m_formatter = new Utils::OutputFormatter; - m_logPlainTextEdit->setReadOnly(true); - m_formatter->setPlainTextEdit(m_logPlainTextEdit); - - verticalLayout->addWidget(m_logPlainTextEdit); - - m_statusLabel = new QLabel; - verticalLayout->addWidget(m_statusLabel); - setTitle(tr("Checkout")); -} - -CheckoutProgressWizardPage::~CheckoutProgressWizardPage() -{ - QTC_ASSERT(m_state != Running, QApplication::restoreOverrideCursor()); - delete m_formatter; -} - -void CheckoutProgressWizardPage::setStartedStatus(const QString &startedStatus) -{ - m_startedStatus = startedStatus; -} - -void CheckoutProgressWizardPage::start(VcsCommand *command) -{ - if (!command) { - m_logPlainTextEdit->setPlainText(tr("No job running, please abort.")); - return; - } - - QTC_ASSERT(m_state != Running, return); - m_command = command; - command->setProgressiveOutput(true); - connect(command, &VcsCommand::output, this, &CheckoutProgressWizardPage::reportStdOut); - connect(command, &VcsCommand::errorText, this, &CheckoutProgressWizardPage::reportStdErr); - connect(command, &VcsCommand::finished, this, &CheckoutProgressWizardPage::slotFinished); - QApplication::setOverrideCursor(Qt::WaitCursor); - m_logPlainTextEdit->clear(); - m_overwriteOutput = false; - m_statusLabel->setText(m_startedStatus); - m_statusLabel->setPalette(QPalette()); - m_state = Running; - command->execute(); -} - -void CheckoutProgressWizardPage::slotFinished(bool ok, int exitCode, const QVariant &) -{ - QTC_ASSERT(m_state == Running, return); - - const bool success = (ok && exitCode == 0); - QString message; - QPalette palette; - - if (success) { - m_state = Succeeded; - message = tr("Succeeded."); - palette.setColor(QPalette::Active, QPalette::Text, Qt::green); - } else { - m_state = Failed; - message = tr("Failed."); - palette.setColor(QPalette::Active, QPalette::Text, Qt::red); - } - - m_statusLabel->setText(message); - m_statusLabel->setPalette(palette); - - QApplication::restoreOverrideCursor(); - - if (success) - emit completeChanged(); - emit terminated(success); -} - -void CheckoutProgressWizardPage::reportStdOut(const QString &text) -{ - m_formatter->appendMessage(text, Utils::StdOutFormat); -} - -void CheckoutProgressWizardPage::reportStdErr(const QString &text) -{ - m_formatter->appendMessage(text, Utils::StdErrFormat); -} - -void CheckoutProgressWizardPage::terminate() -{ - if (m_command) - m_command->cancel(); -} - -bool CheckoutProgressWizardPage::isComplete() const -{ - return m_state == Succeeded; -} - -} // namespace Internal -} // namespace VcsBase diff --git a/src/plugins/vcsbase/diffhighlighter.cpp b/src/plugins/vcsbase/diffandloghighlighter.cpp index 342451a7093..f1f1b857c88 100644 --- a/src/plugins/vcsbase/diffhighlighter.cpp +++ b/src/plugins/vcsbase/diffandloghighlighter.cpp @@ -28,7 +28,7 @@ ** ****************************************************************************/ -#include "diffhighlighter.h" +#include "diffandloghighlighter.h" #include <texteditor/textdocumentlayout.h> @@ -38,11 +38,11 @@ #include <QRegExp> /*! - \class VcsBase::DiffHighlighter + \class VcsBase::DiffAndLogHighlighter - \brief The DiffHighlighter class provides a highlighter for diffs. + \brief The DiffAndLogHighlighter class provides a highlighter for diffs and log editors. - Parametrizable by the file indicator, which is for example '^====' in case of p4: + Diff is parametrizable by the file indicator, which is for example '^====' in case of p4: \code ==== //depot/research/main/qdynamicmainwindow3/qdynamicdockwidgetlayout_p.h#34 (text) ==== \endcode @@ -56,6 +56,12 @@ @@ -10,6 +10,7 @@ SUBDIRS = plugin_coreplugin \endcode + Log is parametrizable by change indicator. For example '^commit ([0-9a-f]{8})[0-9a-f]{32}' + in Git: + \code + commit a3398841a24b24c73b47759c4bffdc8b78a34936 (HEAD, master) + \code + Also highlights trailing blanks. */ @@ -66,13 +72,14 @@ static const int LOCATION_LEVEL = 2; namespace VcsBase { namespace Internal { -// Formats used by DiffHighlighter +// Formats used by DiffAndLogHighlighter enum DiffFormats { DiffTextFormat, DiffInFormat, DiffOutFormat, DiffFileFormat, - DiffLocationFormat + DiffLocationFormat, + ChangeTextFormat }; enum FoldingState { @@ -92,18 +99,19 @@ static inline QTextCharFormat invertedColorFormat(const QTextCharFormat &in) return rc; } -// --- DiffHighlighterPrivate -class DiffHighlighterPrivate +// --- DiffAndLogHighlighterPrivate +class DiffAndLogHighlighterPrivate { - DiffHighlighter *q_ptr; - Q_DECLARE_PUBLIC(DiffHighlighter) + DiffAndLogHighlighter *q_ptr; + Q_DECLARE_PUBLIC(DiffAndLogHighlighter) public: - DiffHighlighterPrivate(const QRegExp &filePattern); + DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern); Internal::DiffFormats analyzeLine(const QString &block) const; void updateOtherFormats(); mutable QRegExp m_filePattern; + mutable QRegExp m_changePattern; const QString m_locationIndicator; const QChar m_diffInIndicator; const QChar m_diffOutIndicator; @@ -112,9 +120,10 @@ public: Internal::FoldingState m_foldingState; }; -DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) : +DiffAndLogHighlighterPrivate::DiffAndLogHighlighterPrivate(const QRegExp &filePattern, const QRegExp &changePattern) : q_ptr(0), m_filePattern(filePattern), + m_changePattern(changePattern), m_locationIndicator(QLatin1String("@@")), m_diffInIndicator(QLatin1Char('+')), m_diffOutIndicator(QLatin1Char('-')), @@ -123,12 +132,14 @@ DiffHighlighterPrivate::DiffHighlighterPrivate(const QRegExp &filePattern) : QTC_CHECK(filePattern.isValid()); } -Internal::DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) const +Internal::DiffFormats DiffAndLogHighlighterPrivate::analyzeLine(const QString &text) const { // Do not match on git "--- a/" as a deleted line, check // file first if (m_filePattern.indexIn(text) == 0) return Internal::DiffFileFormat; + if (m_changePattern.indexIn(text) == 0) + return Internal::ChangeTextFormat; if (text.startsWith(m_diffInIndicator)) return Internal::DiffInFormat; if (text.startsWith(m_diffOutIndicator)) @@ -138,21 +149,21 @@ Internal::DiffFormats DiffHighlighterPrivate::analyzeLine(const QString &text) c return Internal::DiffTextFormat; } -void DiffHighlighterPrivate::updateOtherFormats() +void DiffAndLogHighlighterPrivate::updateOtherFormats() { - Q_Q(DiffHighlighter); + Q_Q(DiffAndLogHighlighter); m_addedTrailingWhiteSpaceFormat = invertedColorFormat(q->formatForCategory(Internal::DiffInFormat)); } -// --- DiffHighlighter -DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) : +// --- DiffAndLogHighlighter +DiffAndLogHighlighter::DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern) : TextEditor::SyntaxHighlighter(static_cast<QTextDocument *>(0)), - d_ptr(new DiffHighlighterPrivate(filePattern)) + d_ptr(new DiffAndLogHighlighterPrivate(filePattern, changePattern)) { d_ptr->q_ptr = this; - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); static QVector<TextEditor::TextStyle> categories; if (categories.isEmpty()) { @@ -160,13 +171,14 @@ DiffHighlighter::DiffHighlighter(const QRegExp &filePattern) : << TextEditor::C_ADDED_LINE << TextEditor::C_REMOVED_LINE << TextEditor::C_DIFF_FILE - << TextEditor::C_DIFF_LOCATION; + << TextEditor::C_DIFF_LOCATION + << TextEditor::C_LOG_CHANGE_LINE; } setTextFormatCategories(categories); d->updateOtherFormats(); } -DiffHighlighter::~DiffHighlighter() +DiffAndLogHighlighter::~DiffAndLogHighlighter() { } @@ -185,9 +197,9 @@ static inline int trimmedLength(const QString &in) * 1 for all the following lines of the diff header and all @@ lines. * 2 for everything else */ -void DiffHighlighter::highlightBlock(const QString &text) +void DiffAndLogHighlighter::highlightBlock(const QString &text) { - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); if (text.isEmpty()) return; @@ -265,9 +277,9 @@ void DiffHighlighter::highlightBlock(const QString &text) } } -void DiffHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) +void DiffAndLogHighlighter::setFontSettings(const TextEditor::FontSettings &fontSettings) { - Q_D(DiffHighlighter); + Q_D(DiffAndLogHighlighter); SyntaxHighlighter::setFontSettings(fontSettings); d->updateOtherFormats(); } diff --git a/src/plugins/vcsbase/diffhighlighter.h b/src/plugins/vcsbase/diffandloghighlighter.h index a2259abf403..7406a91f4c9 100644 --- a/src/plugins/vcsbase/diffhighlighter.h +++ b/src/plugins/vcsbase/diffandloghighlighter.h @@ -28,8 +28,8 @@ ** ****************************************************************************/ -#ifndef DIFFHIGHLIGHTER_H -#define DIFFHIGHLIGHTER_H +#ifndef DIFFANDLOGHIGHLIGHTER_H +#define DIFFANDLOGHIGHLIGHTER_H #include "vcsbase_global.h" @@ -45,24 +45,24 @@ namespace TextEditor { class FontSettingsPage; } namespace VcsBase { -class DiffHighlighterPrivate; +class DiffAndLogHighlighterPrivate; -class VCSBASE_EXPORT DiffHighlighter : public TextEditor::SyntaxHighlighter +class VCSBASE_EXPORT DiffAndLogHighlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT - Q_DECLARE_PRIVATE(DiffHighlighter) + Q_DECLARE_PRIVATE(DiffAndLogHighlighter) public: - explicit DiffHighlighter(const QRegExp &filePattern); - ~DiffHighlighter(); + explicit DiffAndLogHighlighter(const QRegExp &filePattern, const QRegExp &changePattern); + ~DiffAndLogHighlighter(); void highlightBlock(const QString &text); virtual void setFontSettings(const TextEditor::FontSettings &fontSettings); private: - QScopedPointer<DiffHighlighterPrivate> d_ptr; + QScopedPointer<DiffAndLogHighlighterPrivate> d_ptr; }; } // namespace VcsBase -#endif // DIFFHIGHLIGHTER_H +#endif // DIFFANDLOGHIGHLIGHTER_H diff --git a/src/plugins/vcsbase/submiteditorwidget.cpp b/src/plugins/vcsbase/submiteditorwidget.cpp index a9bd53cbc06..380525e1d14 100644 --- a/src/plugins/vcsbase/submiteditorwidget.cpp +++ b/src/plugins/vcsbase/submiteditorwidget.cpp @@ -561,6 +561,11 @@ void SubmitEditorWidget::insertTopWidget(QWidget *w) d->m_ui.vboxLayout->insertWidget(0, w); } +void SubmitEditorWidget::insertLeftWidget(QWidget *w) +{ + d->m_ui.splitter->insertWidget(0, w); +} + void SubmitEditorWidget::addSubmitButtonMenu(QMenu *menu) { d->m_submitButton->setMenu(menu); diff --git a/src/plugins/vcsbase/submiteditorwidget.h b/src/plugins/vcsbase/submiteditorwidget.h index e44082345b7..9a4843a416d 100644 --- a/src/plugins/vcsbase/submiteditorwidget.h +++ b/src/plugins/vcsbase/submiteditorwidget.h @@ -122,6 +122,7 @@ protected: virtual QString cleanupDescription(const QString &) const; virtual QString commitName() const; void insertTopWidget(QWidget *w); + void insertLeftWidget(QWidget *w); void addSubmitButtonMenu(QMenu *menu); void hideDescription(); diff --git a/src/plugins/vcsbase/submitfilemodel.cpp b/src/plugins/vcsbase/submitfilemodel.cpp index 8bfbba6036f..08802da5097 100644 --- a/src/plugins/vcsbase/submitfilemodel.cpp +++ b/src/plugins/vcsbase/submitfilemodel.cpp @@ -32,6 +32,7 @@ #include <coreplugin/fileiconprovider.h> #include <utils/qtcassert.h> +#include <utils/theme/theme.h> #include <QStandardItem> #include <QFileInfo> @@ -43,11 +44,36 @@ namespace VcsBase { // Helpers: // -------------------------------------------------------------------------- -enum { fileColumn = 1 }; +enum { stateColumn = 0, fileColumn = 1 }; + +static QBrush fileStatusTextForeground(SubmitFileModel::FileStatusHint statusHint) +{ + using Utils::Theme; + Theme::Color statusTextColor = Theme::VcsBase_FileStatusUnknown_TextColor; + switch (statusHint) { + case SubmitFileModel::FileStatusUnknown: + statusTextColor = Theme::VcsBase_FileStatusUnknown_TextColor; + break; + case SubmitFileModel::FileAdded: + statusTextColor = Theme::VcsBase_FileAdded_TextColor; + break; + case SubmitFileModel::FileModified: + statusTextColor = Theme::VcsBase_FileModified_TextColor; + break; + case SubmitFileModel::FileDeleted: + statusTextColor = Theme::VcsBase_FileDeleted_TextColor; + break; + case SubmitFileModel::FileRenamed: + statusTextColor = Theme::VcsBase_FileRenamed_TextColor; + break; + } + return QBrush(Utils::creatorTheme()->color(statusTextColor)); +} static QList<QStandardItem *> createFileRow(const QString &repositoryRoot, const QString &fileName, const QString &status, + SubmitFileModel::FileStatusHint statusHint, CheckMode checked, const QVariant &v) { @@ -68,6 +94,11 @@ static QList<QStandardItem *> createFileRow(const QString &repositoryRoot, fileItem->setIcon(Core::FileIconProvider::icon(fi)); QList<QStandardItem *> row; row << statusItem << fileItem; + if (statusHint != SubmitFileModel::FileStatusUnknown) { + const QBrush textForeground = fileStatusTextForeground(statusHint); + foreach (QStandardItem *item, row) + item->setForeground(textForeground); + } return row; } @@ -106,7 +137,10 @@ void SubmitFileModel::setRepositoryRoot(const QString &repoRoot) QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const QString &status, CheckMode checkMode, const QVariant &v) { - const QList<QStandardItem *> row = createFileRow(m_repositoryRoot, fileName, status, checkMode, v); + const FileStatusHint statusHint = + m_fileStatusQualifier ? m_fileStatusQualifier(status, v) : FileStatusUnknown; + const QList<QStandardItem *> row = + createFileRow(m_repositoryRoot, fileName, status, statusHint, checkMode, v); appendRow(row); return row; } @@ -207,4 +241,24 @@ void SubmitFileModel::updateSelections(SubmitFileModel *source) } } +const SubmitFileModel::FileStatusQualifier &SubmitFileModel::fileStatusQualifier() const +{ + return m_fileStatusQualifier; +} + +void SubmitFileModel::setFileStatusQualifier(FileStatusQualifier &&func) +{ + const int topLevelRowCount = rowCount(); + const int topLevelColCount = columnCount(); + for (int row = 0; row < topLevelRowCount; ++row) { + const QStandardItem *statusItem = item(row, stateColumn); + const FileStatusHint statusHint = + func ? func(statusItem->text(), statusItem->data()) : FileStatusUnknown; + const QBrush textForeground = fileStatusTextForeground(statusHint); + for (int col = 0; col < topLevelColCount; ++col) + item(row, col)->setForeground(textForeground); + } + m_fileStatusQualifier = func; +} + } // namespace VcsBase diff --git a/src/plugins/vcsbase/submitfilemodel.h b/src/plugins/vcsbase/submitfilemodel.h index db5bec44a27..6dd85ebf246 100644 --- a/src/plugins/vcsbase/submitfilemodel.h +++ b/src/plugins/vcsbase/submitfilemodel.h @@ -35,6 +35,8 @@ #include <QStandardItemModel> +#include <functional> + namespace VcsBase { enum CheckMode @@ -73,8 +75,27 @@ public: virtual void updateSelections(SubmitFileModel *source); + enum FileStatusHint + { + FileStatusUnknown, + FileAdded, + FileModified, + FileDeleted, + FileRenamed + }; + + // Function that converts(qualifies) a QString/QVariant pair to FileStatusHint + // 1st arg is the file status string as passed to addFile() + // 2nd arg is the file extra data as passed to addFile() + typedef std::function<FileStatusHint (const QString &, const QVariant &)> + FileStatusQualifier; + + const FileStatusQualifier &fileStatusQualifier() const; + void setFileStatusQualifier(FileStatusQualifier &&func); + private: QString m_repositoryRoot; + FileStatusQualifier m_fileStatusQualifier; }; } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsbase.pro b/src/plugins/vcsbase/vcsbase.pro index 5f4eae91c02..b433f817433 100644 --- a/src/plugins/vcsbase/vcsbase.pro +++ b/src/plugins/vcsbase/vcsbase.pro @@ -4,12 +4,13 @@ HEADERS += vcsbase_global.h \ vcsbaseconstants.h \ vcsprojectcache.h \ wizard/vcsconfigurationpage.h \ + wizard/vcscommandpage.h \ wizard/vcsjsextension.h \ vcsplugin.h \ corelistener.h \ vcsbaseplugin.h \ baseannotationhighlighter.h \ - diffhighlighter.h \ + diffandloghighlighter.h \ vcsbaseeditor.h \ vcsbasesubmiteditor.h \ basevcseditorfactory.h \ @@ -19,10 +20,6 @@ HEADERS += vcsbase_global.h \ commonvcssettings.h \ commonsettingspage.h \ nicknamedialog.h \ - basecheckoutwizardfactory.h \ - basecheckoutwizard.h \ - checkoutprogresswizardpage.h \ - basecheckoutwizardpage.h \ vcsoutputwindow.h \ cleandialog.h \ vcsbaseoptionspage.h \ @@ -37,10 +34,11 @@ SOURCES += vcsplugin.cpp \ vcsbaseplugin.cpp \ vcsprojectcache.cpp \ wizard/vcsconfigurationpage.cpp \ + wizard/vcscommandpage.cpp \ wizard/vcsjsextension.cpp \ corelistener.cpp \ baseannotationhighlighter.cpp \ - diffhighlighter.cpp \ + diffandloghighlighter.cpp \ vcsbaseeditor.cpp \ vcsbasesubmiteditor.cpp \ basevcseditorfactory.cpp \ @@ -50,10 +48,6 @@ SOURCES += vcsplugin.cpp \ commonvcssettings.cpp \ commonsettingspage.cpp \ nicknamedialog.cpp \ - basecheckoutwizardfactory.cpp \ - basecheckoutwizard.cpp \ - checkoutprogresswizardpage.cpp \ - basecheckoutwizardpage.cpp \ vcsoutputwindow.cpp \ cleandialog.cpp \ vcsbaseoptionspage.cpp \ @@ -68,6 +62,5 @@ RESOURCES += vcsbase.qrc FORMS += commonsettingspage.ui \ nicknamedialog.ui \ - basecheckoutwizardpage.ui \ cleandialog.ui \ submiteditorwidget.ui diff --git a/src/plugins/vcsbase/vcsbase.qbs b/src/plugins/vcsbase/vcsbase.qbs index 111ec889628..d2782082248 100644 --- a/src/plugins/vcsbase/vcsbase.qbs +++ b/src/plugins/vcsbase/vcsbase.qbs @@ -16,19 +16,10 @@ QtcPlugin { files: [ "baseannotationhighlighter.cpp", "baseannotationhighlighter.h", - "basecheckoutwizard.cpp", - "basecheckoutwizard.h", - "basecheckoutwizardfactory.cpp", - "basecheckoutwizardfactory.h", - "basecheckoutwizardpage.cpp", - "basecheckoutwizardpage.h", - "basecheckoutwizardpage.ui", "basevcseditorfactory.cpp", "basevcseditorfactory.h", "basevcssubmiteditorfactory.cpp", "basevcssubmiteditorfactory.h", - "checkoutprogresswizardpage.cpp", - "checkoutprogresswizardpage.h", "cleandialog.cpp", "cleandialog.h", "cleandialog.ui", @@ -39,8 +30,8 @@ QtcPlugin { "commonvcssettings.h", "corelistener.cpp", "corelistener.h", - "diffhighlighter.cpp", - "diffhighlighter.h", + "diffandloghighlighter.cpp", + "diffandloghighlighter.h", "nicknamedialog.cpp", "nicknamedialog.h", "nicknamedialog.ui", @@ -83,6 +74,8 @@ QtcPlugin { "images/submit.png", "wizard/vcsconfigurationpage.cpp", "wizard/vcsconfigurationpage.h", + "wizard/vcscommandpage.cpp", + "wizard/vcscommandpage.h", "wizard/vcsjsextension.cpp", "wizard/vcsjsextension.h", ] diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 31509def769..327d1dfa6ef 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -67,8 +67,6 @@ \sa VcsBase::VcsJobRunner */ -Q_DECLARE_METATYPE(QVariant) - static Core::IEditor *locateEditor(const char *property, const QString &entry) { foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) @@ -79,29 +77,19 @@ static Core::IEditor *locateEditor(const char *property, const QString &entry) namespace VcsBase { -class VcsBaseClientPrivate +class VcsBaseClientImplPrivate { public: - VcsBaseClientPrivate(VcsBaseClient *client, VcsBaseClientSettings *settings); + VcsBaseClientImplPrivate(VcsBaseClientImpl *client, VcsBaseClientSettings *settings); + ~VcsBaseClientImplPrivate(); void bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWidget *editor); - VcsBaseEditorParameterWidget *createDiffEditor(); - VcsBaseEditorParameterWidget *createLogEditor(); - VcsBaseClientSettings *m_clientSettings; QSignalMapper *m_cmdFinishedMapper; - - VcsBaseClient::ParameterWidgetCreator m_diffParamWidgetCreator; - VcsBaseClient::ParameterWidgetCreator m_logParamWidgetCreator; }; -VcsBaseClientPrivate::VcsBaseClientPrivate(VcsBaseClient *client, VcsBaseClientSettings *settings) : - m_clientSettings(settings), - m_cmdFinishedMapper(new QSignalMapper(client)) -{ } - -void VcsBaseClientPrivate::bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWidget *editor) +void VcsBaseClientImplPrivate::bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWidget *editor) { editor->setCommand(cmd); QObject::connect(cmd, &VcsCommand::finished, @@ -109,6 +97,212 @@ void VcsBaseClientPrivate::bindCommandToEditor(VcsCommand *cmd, VcsBaseEditorWid m_cmdFinishedMapper->setMapping(cmd, editor); } +VcsBaseClientImplPrivate::VcsBaseClientImplPrivate(VcsBaseClientImpl *client, + VcsBaseClientSettings *settings) : + m_clientSettings(settings), + m_cmdFinishedMapper(new QSignalMapper(client)) +{ + m_clientSettings->readSettings(Core::ICore::settings()); +} + +VcsBaseClientImplPrivate::~VcsBaseClientImplPrivate() +{ + delete m_clientSettings; +} + +VcsBaseClientImpl::VcsBaseClientImpl(VcsBaseClientImpl *client, VcsBaseClientSettings *settings) : + d(new VcsBaseClientImplPrivate(client, settings)) +{ + connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested, + this, &VcsBaseClientImpl::saveSettings); + + connect(d->m_cmdFinishedMapper, static_cast<void (QSignalMapper::*)(QWidget*)>(&QSignalMapper::mapped), + this, &VcsBaseClientImpl::commandFinishedGotoLine); +} + +VcsBaseClientImpl::~VcsBaseClientImpl() +{ + delete d; +} + +VcsBaseClientSettings &VcsBaseClientImpl::settings() const +{ + return *d->m_clientSettings; +} + +Utils::FileName VcsBaseClientImpl::vcsBinary() const +{ + return settings().binaryPath(); +} + +VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory, + VcsBaseEditorWidget *editor, + JobOutputBindMode mode) const +{ + auto cmd = new VcsCommand(workingDirectory, processEnvironment()); + cmd->setDefaultTimeoutS(vcsTimeoutS()); + if (editor) + d->bindCommandToEditor(cmd, editor); + if (mode == VcsWindowOutputBind) { + cmd->addFlags(VcsCommand::ShowStdOut); + if (editor) // assume that the commands output is the important thing + cmd->addFlags(VcsCommand::SilentOutput); + } else if (editor) { + connect(cmd, &VcsCommand::stdOutText, editor, &VcsBaseEditorWidget::setPlainText); + } + + return cmd; +} + +void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args, + Utils::ExitCodeInterpreter *interpreter) +{ + cmd->addJob(vcsBinary(), args, vcsTimeoutS(), interpreter); + cmd->execute(); +} + +QProcessEnvironment VcsBaseClientImpl::processEnvironment() const +{ + QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); + VcsBasePlugin::setProcessEnvironment(&environment, false); + return environment; +} + +QString VcsBaseClientImpl::commandOutputFromLocal8Bit(const QByteArray &a) +{ + return Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a)); +} + +QStringList VcsBaseClientImpl::commandOutputLinesFromLocal8Bit(const QByteArray &a) +{ + QString output = commandOutputFromLocal8Bit(a); + const QChar newLine = QLatin1Char('\n'); + if (output.endsWith(newLine)) + output.truncate(output.size() - 1); + if (output.isEmpty()) + return QStringList(); + return output.split(newLine); +} + +void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir) +{ + Core::VcsManager::resetVersionControlForDirectory(workingDir); +} + +void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirectory, + const QString &file, const QString &change, + int line) +{ + QString changeCopy = change; + // This might be invoked with a verbose revision description + // "SHA1 author subject" from the annotation context menu. Strip the rest. + const int blankPos = changeCopy.indexOf(QLatin1Char(' ')); + if (blankPos != -1) + changeCopy.truncate(blankPos); + annotate(workingDirectory, file, changeCopy, line); +} + +bool VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, + QByteArray *outputData, QByteArray *errorData, + unsigned flags) const +{ + QByteArray internalErrorData; + QScopedPointer<VcsCommand> command(createCommand(workingDir)); + command->addFlags(flags); + bool result = command->runFullySynchronous(vcsBinary(), args, vcsTimeoutS(), outputData, + errorData ? errorData : &internalErrorData); + if (!internalErrorData.isEmpty() && !(flags & VcsCommand::SuppressStdErr)) + VcsOutputWindow::appendError(commandOutputFromLocal8Bit(internalErrorData)); + return result; +} + +VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments, + VcsBaseEditorWidget *editor, bool useOutputToWindow, + unsigned additionalFlags, const QVariant &cookie) +{ + VcsCommand *command = createCommand(workingDirectory, editor, + useOutputToWindow ? VcsWindowOutputBind : NoOutputBind); + command->setCookie(cookie); + command->addFlags(additionalFlags); + enqueueJob(command, arguments); + return command; +} + +Utils::SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &workingDir, + const QStringList &args, + unsigned flags, + QTextCodec *outputCodec) const +{ + return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags, + outputCodec, processEnvironment()); +} + +int VcsBaseClientImpl::vcsTimeoutS() const +{ + return settings().intValue(VcsBaseClientSettings::timeoutKey); +} + +VcsBaseEditorWidget *VcsBaseClientImpl::createVcsEditor(Core::Id kind, QString title, + const QString &source, QTextCodec *codec, + const char *registerDynamicProperty, + const QString &dynamicPropertyValue) const +{ + VcsBaseEditorWidget *baseEditor = 0; + Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue); + const QString progressMsg = tr("Working..."); + if (outputEditor) { + // Exists already + outputEditor->document()->setContents(progressMsg.toUtf8()); + baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); + QTC_ASSERT(baseEditor, return 0); + Core::EditorManager::activateEditor(outputEditor); + } else { + outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8()); + outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); + baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); + QTC_ASSERT(baseEditor, return 0); + connect(baseEditor, &VcsBaseEditorWidget::annotateRevisionRequested, + this, &VcsBaseClientImpl::annotateRevisionRequested); + baseEditor->setSource(source); + if (codec) + baseEditor->setCodec(codec); + } + + baseEditor->setForceReadOnly(true); + return baseEditor; +} + +void VcsBaseClientImpl::saveSettings() +{ + settings().writeSettings(Core::ICore::settings()); +} + +void VcsBaseClientImpl::commandFinishedGotoLine(QWidget *editorObject) +{ + VcsBaseEditorWidget *editor = qobject_cast<VcsBaseEditorWidget *>(editorObject); + VcsCommand *cmd = qobject_cast<VcsCommand *>(d->m_cmdFinishedMapper->mapping(editor)); + if (editor && cmd) { + if (!cmd->lastExecutionSuccess()) { + editor->reportCommandFinished(false, cmd->lastExecutionExitCode(), cmd->cookie()); + } else if (cmd->cookie().type() == QVariant::Int) { + const int line = cmd->cookie().toInt(); + if (line >= 0) + editor->gotoLine(line); + } + d->m_cmdFinishedMapper->removeMappings(cmd); + } +} + +class VcsBaseClientPrivate +{ +public: + VcsBaseEditorParameterWidget *createDiffEditor(); + VcsBaseEditorParameterWidget *createLogEditor(); + + VcsBaseClient::ParameterWidgetCreator m_diffParamWidgetCreator; + VcsBaseClient::ParameterWidgetCreator m_logParamWidgetCreator; +}; + VcsBaseEditorParameterWidget *VcsBaseClientPrivate::createDiffEditor() { return m_diffParamWidgetCreator ? m_diffParamWidgetCreator() : 0; @@ -124,13 +318,10 @@ VcsBaseClient::StatusItem::StatusItem(const QString &s, const QString &f) : { } VcsBaseClient::VcsBaseClient(VcsBaseClientSettings *settings) : - d(new VcsBaseClientPrivate(this, settings)) + VcsBaseClientImpl(this, settings), + d(new VcsBaseClientPrivate) { qRegisterMetaType<QVariant>(); - connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested, - this, &VcsBaseClient::saveSettings); - connect(d->m_cmdFinishedMapper, static_cast<void (QSignalMapper::*)(QWidget*)>(&QSignalMapper::mapped), - this, &VcsBaseClient::commandFinishedGotoLine); } VcsBaseClient::~VcsBaseClient() @@ -146,8 +337,7 @@ bool VcsBaseClient::synchronousCreateRepository(const QString &workingDirectory, QByteArray outputData; if (!vcsFullySynchronousExec(workingDirectory, args, &outputData)) return false; - VcsOutputWindow::append( - Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(outputData))); + VcsOutputWindow::append(commandOutputFromLocal8Bit(outputData)); resetCachedVcsInfo(workingDirectory); @@ -204,9 +394,9 @@ bool VcsBaseClient::synchronousPull(const QString &workingDir, args << vcsCommandString(PullCommand) << extraOptions << srcLocation; // Disable UNIX terminals to suppress SSH prompting const unsigned flags = - VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ShowSuccessMessage; + VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ShowSuccessMessage; const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished; if (ok) @@ -222,63 +412,13 @@ bool VcsBaseClient::synchronousPush(const QString &workingDir, args << vcsCommandString(PushCommand) << extraOptions << dstLocation; // Disable UNIX terminals to suppress SSH prompting const unsigned flags = - VcsBasePlugin::SshPasswordPrompt - | VcsBasePlugin::ShowStdOutInLogWindow - | VcsBasePlugin::ShowSuccessMessage; + VcsCommand::SshPasswordPrompt + | VcsCommand::ShowStdOut + | VcsCommand::ShowSuccessMessage; const Utils::SynchronousProcessResponse resp = vcsSynchronousExec(workingDir, args, flags); return resp.result == Utils::SynchronousProcessResponse::Finished; } -bool VcsBaseClient::vcsFullySynchronousExec(const QString &workingDir, - const QStringList &args, - QByteArray *output) const -{ - QProcess vcsProcess; - if (!workingDir.isEmpty()) - vcsProcess.setWorkingDirectory(workingDir); - vcsProcess.setProcessEnvironment(processEnvironment()); - - const Utils::FileName binary = settings()->binaryPath(); - - VcsOutputWindow::appendCommand(workingDir, binary, args); - - vcsProcess.start(binary.toString(), args); - - if (!vcsProcess.waitForStarted()) { - VcsOutputWindow::appendError(tr("Unable to start process \"%1\": %2") - .arg(binary.toUserOutput(), vcsProcess.errorString())); - return false; - } - - vcsProcess.closeWriteChannel(); - - QByteArray stdErr; - const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey); - if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, timeoutSec * 1000, - output, &stdErr, true)) { - Utils::SynchronousProcess::stopProcess(vcsProcess); - VcsOutputWindow::appendError(tr("Timed out after %1s waiting for the process %2 to finish.") - .arg(timeoutSec).arg(binary.toUserOutput())); - return false; - } - if (!stdErr.isEmpty()) - VcsOutputWindow::appendError(QString::fromLocal8Bit(stdErr)); - - return vcsProcess.exitStatus() == QProcess::NormalExit && vcsProcess.exitCode() == 0; -} - -Utils::SynchronousProcessResponse VcsBaseClient::vcsSynchronousExec( - const QString &workingDirectory, - const QStringList &args, - unsigned flags, - QTextCodec *outputCodec) const -{ - const Utils::FileName binary = settings()->binaryPath(); - const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey); - return VcsBasePlugin::runVcs(workingDirectory, binary, args, - timeoutSec * 1000, flags, outputCodec); -} - void VcsBaseClient::annotate(const QString &workingDir, const QString &file, const QString &revision /* = QString() */, int lineNumber /* = -1 */, @@ -292,7 +432,8 @@ void VcsBaseClient::annotate(const QString &workingDir, const QString &file, const QString title = vcsEditorTitle(vcsCmdString, id); const QString source = VcsBaseEditor::getSource(workingDir, file); - VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true, + VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, + VcsBaseEditor::getCodec(source), vcsCmdString.toLatin1().constData(), id); VcsCommand *cmd = createCommand(workingDir, editor); @@ -308,7 +449,8 @@ void VcsBaseClient::diff(const QString &workingDir, const QStringList &files, const QString id = VcsBaseEditor::getTitleId(workingDir, files); const QString title = vcsEditorTitle(vcsCmdString, id); const QString source = VcsBaseEditor::getSource(workingDir, files); - VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true, + VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, + VcsBaseEditor::getCodec(source), vcsCmdString.toLatin1().constData(), id); editor->setWorkingDirectory(workingDir); @@ -340,7 +482,8 @@ void VcsBaseClient::log(const QString &workingDir, const QStringList &files, const QString id = VcsBaseEditor::getTitleId(workingDir, files); const QString title = vcsEditorTitle(vcsCmdString, id); const QString source = VcsBaseEditor::getSource(workingDir, files); - VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true, + VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, + VcsBaseEditor::getCodec(source), vcsCmdString.toLatin1().constData(), id); editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu); @@ -402,7 +545,7 @@ void VcsBaseClient::emitParsedStatus(const QString &repository, const QStringLis QStringList args(vcsCommandString(StatusCommand)); args << extraOptions; VcsCommand *cmd = createCommand(repository); - connect(cmd, &VcsCommand::output, this, &VcsBaseClient::statusParser); + connect(cmd, &VcsCommand::stdOutText, this, &VcsBaseClient::statusParser); enqueueJob(cmd, args); } @@ -461,7 +604,8 @@ void VcsBaseClient::view(const QString &source, const QString &id, const Core::Id kind = vcsEditorKind(DiffCommand); const QString title = vcsEditorTitle(vcsCommandString(LogCommand), id); - VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, true, "view", id); + VcsBaseEditorWidget *editor = createVcsEditor(kind, title, source, + VcsBaseEditor::getCodec(source), "view", id); const QFileInfo fi(source); const QString workingDirPath = fi.isFile() ? fi.absolutePath() : source; @@ -500,87 +644,13 @@ void VcsBaseClient::commit(const QString &repositoryRoot, enqueueJob(cmd, args); } -VcsBaseClientSettings *VcsBaseClient::settings() const -{ - return d->m_clientSettings; -} - QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const { - const Utils::FileName binary = settings()->binaryPath(); - return binary.toFileInfo().baseName() + + return vcsBinary().toFileInfo().baseName() + QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') + Utils::FileName::fromString(sourceId).fileName(); } -VcsBaseEditorWidget *VcsBaseClient::createVcsEditor(Core::Id kind, QString title, - const QString &source, bool setSourceCodec, - const char *registerDynamicProperty, - const QString &dynamicPropertyValue) const -{ - VcsBaseEditorWidget *baseEditor = 0; - Core::IEditor *outputEditor = locateEditor(registerDynamicProperty, dynamicPropertyValue); - const QString progressMsg = tr("Working..."); - if (outputEditor) { - // Exists already - outputEditor->document()->setContents(progressMsg.toUtf8()); - baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); - QTC_ASSERT(baseEditor, return 0); - Core::EditorManager::activateEditor(outputEditor); - } else { - outputEditor = Core::EditorManager::openEditorWithContents(kind, &title, progressMsg.toUtf8()); - outputEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue); - baseEditor = VcsBaseEditor::getVcsBaseEditor(outputEditor); - connect(baseEditor, &VcsBaseEditorWidget::annotateRevisionRequested, - this, &VcsBaseClient::annotateRevision); - QTC_ASSERT(baseEditor, return 0); - baseEditor->setSource(source); - if (setSourceCodec) - baseEditor->setCodec(VcsBaseEditor::getCodec(source)); - } - - baseEditor->setForceReadOnly(true); - return baseEditor; -} - -QProcessEnvironment VcsBaseClient::processEnvironment() const -{ - QProcessEnvironment environment = QProcessEnvironment::systemEnvironment(); - VcsBasePlugin::setProcessEnvironment(&environment, false); - return environment; -} - -VcsCommand *VcsBaseClient::createCommand(const QString &workingDirectory, - VcsBaseEditorWidget *editor, - JobOutputBindMode mode) const -{ - auto cmd = new VcsCommand(d->m_clientSettings->binaryPath(), workingDirectory, - processEnvironment()); - cmd->setDefaultTimeout(d->m_clientSettings->intValue(VcsBaseClientSettings::timeoutKey)); - if (editor) - d->bindCommandToEditor(cmd, editor); - if (mode == VcsWindowOutputBind) { - cmd->addFlags(VcsBasePlugin::ShowStdOutInLogWindow); - if (editor) // assume that the commands output is the important thing - cmd->addFlags(VcsBasePlugin::SilentOutput); - } else if (editor) { - connect(cmd, &VcsCommand::output, editor, &VcsBaseEditorWidget::setPlainText); - } - - return cmd; -} - -void VcsBaseClient::enqueueJob(VcsCommand *cmd, const QStringList &args, Utils::ExitCodeInterpreter *interpreter) -{ - cmd->addJob(args, interpreter); - cmd->execute(); -} - -void VcsBaseClient::resetCachedVcsInfo(const QString &workingDir) -{ - Core::VcsManager::resetVersionControlForDirectory(workingDir); -} - void VcsBaseClient::statusParser(const QString &text) { QList<VcsBaseClient::StatusItem> lineInfoList; @@ -596,39 +666,6 @@ void VcsBaseClient::statusParser(const QString &text) emit parsedStatus(lineInfoList); } -void VcsBaseClient::annotateRevision(const QString &workingDirectory, const QString &file, - const QString& change, int lineNumber) -{ - QString changeCopy = change; - // This might be invoked with a verbose revision description - // "SHA1 author subject" from the annotation context menu. Strip the rest. - const int blankPos = changeCopy.indexOf(QLatin1Char(' ')); - if (blankPos != -1) - changeCopy.truncate(blankPos); - annotate(workingDirectory, file, changeCopy, lineNumber); -} - -void VcsBaseClient::saveSettings() -{ - settings()->writeSettings(Core::ICore::settings()); -} - -void VcsBaseClient::commandFinishedGotoLine(QWidget *editorObject) -{ - VcsBaseEditorWidget *editor = qobject_cast<VcsBaseEditorWidget *>(editorObject); - VcsCommand *cmd = qobject_cast<VcsCommand *>(d->m_cmdFinishedMapper->mapping(editor)); - if (editor && cmd) { - if (!cmd->lastExecutionSuccess()) { - editor->reportCommandFinished(false, cmd->lastExecutionExitCode(), cmd->cookie()); - } else if (cmd->cookie().type() == QVariant::Int) { - const int line = cmd->cookie().toInt(); - if (line >= 0) - editor->gotoLine(line); - } - d->m_cmdFinishedMapper->removeMappings(cmd); - } -} - } // namespace VcsBase #include "moc_vcsbaseclient.cpp" diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index 37f355e2aeb..8fdf6971f2c 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -33,6 +33,8 @@ #include "vcsbase_global.h" +#include <utils/fileutils.h> + #include <QObject> #include <QStringList> @@ -57,10 +59,82 @@ class VcsCommand; class VcsBaseEditorWidget; class VcsBaseClientSettings; class VcsJob; +class VcsBaseClientImplPrivate; class VcsBaseClientPrivate; class VcsBaseEditorParameterWidget; -class VCSBASE_EXPORT VcsBaseClient : public QObject +class VCSBASE_EXPORT VcsBaseClientImpl : public QObject +{ + Q_OBJECT + +public: + explicit VcsBaseClientImpl(VcsBaseClientImpl *client, VcsBaseClientSettings *settings); + ~VcsBaseClientImpl(); + + VcsBaseClientSettings &settings() const; + + virtual Utils::FileName vcsBinary() const; + int vcsTimeoutS() const; + + enum JobOutputBindMode { + NoOutputBind, + VcsWindowOutputBind + }; + + VcsBaseEditorWidget *createVcsEditor(Core::Id kind, QString title, + const QString &source, QTextCodec *codec, + const char *registerDynamicProperty, + const QString &dynamicPropertyValue) const; + + VcsCommand *createCommand(const QString &workingDirectory, + VcsBaseEditorWidget *editor = 0, + JobOutputBindMode mode = NoOutputBind) const; + + void enqueueJob(VcsCommand *cmd, const QStringList &args, + Utils::ExitCodeInterpreter *interpreter = 0); + + virtual QProcessEnvironment processEnvironment() const; + + // VCS functionality: + virtual void annotate(const QString &workingDir, const QString &file, + const QString &revision = QString(), int lineNumber = -1, + const QStringList &extraOptions = QStringList()) = 0; + + // Return converted command output, remove '\r' read on Windows + static QString commandOutputFromLocal8Bit(const QByteArray &a); + // Return converted command output split into lines + static QStringList commandOutputLinesFromLocal8Bit(const QByteArray &a); + +protected: + void resetCachedVcsInfo(const QString &workingDir); + virtual void annotateRevisionRequested(const QString &workingDirectory, const QString &file, + const QString &change, int line); + + // Fully synchronous VCS execution (QProcess-based) + bool vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, + QByteArray *outputData, QByteArray *errorData = 0, + unsigned flags = 0) const; + + // Simple helper to execute a single command using createCommand and enqueueJob. + VcsCommand *vcsExec(const QString &workingDirectory, const QStringList &arguments, + VcsBaseEditorWidget *editor = 0, bool useOutputToWindow = false, + unsigned additionalFlags = 0, const QVariant &cookie = QVariant()); + + // Synchronous VCS execution using Utils::SynchronousProcess, with + // log windows updating (using VcsBasePlugin::runVcs with flags) + Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir, + const QStringList &args, + unsigned flags = 0, + QTextCodec *outputCodec = 0) const; + +private: + void saveSettings(); + void commandFinishedGotoLine(QWidget*); + + VcsBaseClientImplPrivate *d; +}; + +class VCSBASE_EXPORT VcsBaseClient : public VcsBaseClientImpl { Q_OBJECT @@ -122,9 +196,6 @@ public: virtual QString findTopLevelForFile(const QFileInfo &file) const = 0; - virtual VcsBaseClientSettings *settings() const; - virtual QProcessEnvironment processEnvironment() const; - signals: void parsedStatus(const QList<VcsBase::VcsBaseClient::StatusItem> &statusList); // Passes on changed signals from VcsJob to Control @@ -166,38 +237,9 @@ protected: virtual StatusItem parseStatusLine(const QString &line) const = 0; QString vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const; - // Fully synchronous VCS execution (QProcess-based) - bool vcsFullySynchronousExec(const QString &workingDir, - const QStringList &args, - QByteArray *output) const; - // Synchronous VCS execution using Utils::SynchronousProcess, with - // log windows updating (using VcsBasePlugin::runVcs with flags) - Utils::SynchronousProcessResponse vcsSynchronousExec(const QString &workingDir, - const QStringList &args, - unsigned flags = 0, - QTextCodec *outputCodec = 0) const; - VcsBaseEditorWidget *createVcsEditor(Core::Id kind, QString title, - const QString &source, bool setSourceCodec, - const char *registerDynamicProperty, - const QString &dynamicPropertyValue) const; - - enum JobOutputBindMode { - NoOutputBind, - VcsWindowOutputBind - }; - - VcsCommand *createCommand(const QString &workingDirectory, - VcsBaseEditorWidget *editor = 0, - JobOutputBindMode mode = NoOutputBind) const; - void enqueueJob(VcsCommand *cmd, const QStringList &args, Utils::ExitCodeInterpreter *interpreter = 0); - - void resetCachedVcsInfo(const QString &workingDir); private: void statusParser(const QString&); - void annotateRevision(const QString&, const QString&, const QString&, int); - void saveSettings(); - void commandFinishedGotoLine(QWidget*); friend class VcsBaseClientPrivate; VcsBaseClientPrivate *d; diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 7499d8b836c..8fe872caedd 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -29,7 +29,7 @@ ****************************************************************************/ #include "vcsbaseeditor.h" -#include "diffhighlighter.h" +#include "diffandloghighlighter.h" #include "baseannotationhighlighter.h" #include "basevcseditorfactory.h" #include "vcsbaseplugin.h" @@ -736,7 +736,7 @@ void VcsBaseEditorWidget::init() break; } if (hasDiff()) { - auto dh = new DiffHighlighter(d->m_diffFilePattern); + auto dh = new DiffAndLogHighlighter(d->m_diffFilePattern, d->m_logEntryPattern); setCodeFoldingSupported(true); textDocument()->setSyntaxHighlighter(dh); } @@ -1120,9 +1120,11 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor) const QChar deletionIndicator = QLatin1Char('-'); // find nearest change hunk QTextBlock block = cursor.block(); - if (TextDocumentLayout::foldingIndent(block) <= 1) - /* We are in a diff header, do not jump anywhere. DiffHighlighter sets the foldingIndent for us. */ + if (TextDocumentLayout::foldingIndent(block) <= 1) { + // We are in a diff header, do not jump anywhere. + // DiffAndLogHighlighter sets the foldingIndent for us. return; + } for ( ; block.isValid() ; block = block.previous()) { const QString line = block.text(); if (checkChunkLine(line, &chunkStart)) { @@ -1159,9 +1161,11 @@ DiffChunk VcsBaseEditorWidget::diffChunk(QTextCursor cursor) const QTC_ASSERT(hasDiff(), return rc); // Search back for start of chunk. QTextBlock block = cursor.block(); - if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) - /* We are in a diff header, not in a chunk! DiffHighlighter sets the foldingIndent for us. */ + if (block.isValid() && TextDocumentLayout::foldingIndent(block) <= 1) { + // We are in a diff header, not in a chunk! + // DiffAndLogHighlighter sets the foldingIndent for us. return rc; + } int chunkStart = 0; for ( ; block.isValid() ; block = block.previous()) { @@ -1283,7 +1287,16 @@ int VcsBaseEditor::lineNumberOfCurrentEditor(const QString ¤tFile) const BaseTextEditor *eda = qobject_cast<const BaseTextEditor *>(ed); if (!eda) return -1; - return eda->currentLine(); + const int cursorLine = eda->currentLine(); + auto const edw = qobject_cast<const TextEditorWidget *>(ed->widget()); + if (edw) { + const int firstLine = edw->firstVisibleLine(); + const int lastLine = edw->lastVisibleLine(); + if (firstLine <= cursorLine && cursorLine < lastLine) + return cursorLine; + return edw->centerVisibleLine(); + } + return cursorLine; } bool VcsBaseEditor::gotoLineOfEditor(Core::IEditor *e, int lineNumber) @@ -1382,6 +1395,11 @@ void VcsBaseEditorWidget::setCommand(VcsCommand *command) } } +void VcsBaseEditorWidget::setPlainText(const QString &text) +{ + TextEditorWidget::setPlainText(text); +} + // Find the complete file from a diff relative specification. QString VcsBaseEditorWidget::findDiffFile(const QString &f) const { diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h index 1f17da7c139..8aaf906fb76 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.h +++ b/src/plugins/vcsbase/vcsbaseeditor.h @@ -213,6 +213,9 @@ public: VcsBaseEditorParameterWidget *configurationWidget() const; void setCommand(VcsCommand *command); + + virtual void setPlainText(const QString &text); + signals: // These signals also exist in the opaque editable (IEditor) that is // handled by the editor manager for convenience. They are emitted diff --git a/src/plugins/vcsbase/vcsbaseoptionspage.cpp b/src/plugins/vcsbase/vcsbaseoptionspage.cpp index 7920cbf5881..9f67c7d3af9 100644 --- a/src/plugins/vcsbase/vcsbaseoptionspage.cpp +++ b/src/plugins/vcsbase/vcsbaseoptionspage.cpp @@ -30,8 +30,14 @@ #include "vcsbaseoptionspage.h" +#include "vcsbaseclient.h" #include "vcsbaseconstants.h" +#include <coreplugin/icore.h> +#include <coreplugin/iversioncontrol.h> + +#include <utils/qtcassert.h> + #include <QCoreApplication> /*! @@ -43,12 +49,58 @@ namespace VcsBase { -VcsBaseOptionsPage::VcsBaseOptionsPage(QObject *parent) : - Core::IOptionsPage(parent) +VcsBaseOptionsPage::VcsBaseOptionsPage(QObject *parent) : Core::IOptionsPage(parent) { setCategory(Constants::VCS_SETTINGS_CATEGORY); setDisplayCategory(QCoreApplication::translate("VcsBase", Constants::VCS_SETTINGS_TR_CATEGORY)); setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_VCS_ICON)); } +VcsClientOptionsPageWidget::VcsClientOptionsPageWidget(QWidget *parent) : QWidget(parent) +{ } + +VcsClientOptionsPage::VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientImpl *client, + QObject *parent) : + VcsBaseOptionsPage(parent), + m_widget(0), + m_client(client) +{ + QTC_CHECK(m_client); + connect(this, &VcsClientOptionsPage::settingsChanged, + control, &Core::IVersionControl::configurationChanged); +} + +void VcsClientOptionsPage::setWidgetFactory(VcsClientOptionsPage::WidgetFactory factory) +{ + QTC_ASSERT(!m_factory, return); + m_factory = factory; +} + +VcsClientOptionsPageWidget *VcsClientOptionsPage::widget() +{ + QTC_ASSERT(m_factory, return 0); + if (!m_widget) + m_widget = m_factory(); + QTC_ASSERT(m_widget, return 0); + m_widget->setSettings(m_client->settings()); + return m_widget; +} + +void VcsClientOptionsPage::apply() +{ + QTC_ASSERT(m_widget, return); + const VcsBaseClientSettings newSettings = m_widget->settings(); + VcsBaseClientSettings &s = m_client->settings(); + if (s != newSettings) { + s = newSettings; + emit settingsChanged(); + } +} + +void VcsClientOptionsPage::finish() +{ + delete m_widget; + m_widget = 0; +} + } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsbaseoptionspage.h b/src/plugins/vcsbase/vcsbaseoptionspage.h index e1c867d6ecd..d0587ae1a53 100644 --- a/src/plugins/vcsbase/vcsbaseoptionspage.h +++ b/src/plugins/vcsbase/vcsbaseoptionspage.h @@ -33,8 +33,16 @@ #include "vcsbase_global.h" +#include "vcsbaseclientsettings.h" + #include <coreplugin/dialogs/ioptionspage.h> +#include <QWidget> + +#include <functional> + +namespace Core { class IVersionControl; } + namespace VcsBase { class VCSBASE_EXPORT VcsBaseOptionsPage : public Core::IOptionsPage @@ -43,6 +51,44 @@ public: explicit VcsBaseOptionsPage(QObject *parent = 0); }; +class VcsBaseClientImpl; + +class VCSBASE_EXPORT VcsClientOptionsPageWidget : public QWidget +{ + Q_OBJECT + +public: + VcsClientOptionsPageWidget(QWidget *parent = 0); + + virtual void setSettings(const VcsBaseClientSettings &s) = 0; + virtual VcsBaseClientSettings settings() const = 0; +}; + +class VCSBASE_EXPORT VcsClientOptionsPage : public VcsBaseOptionsPage +{ + Q_OBJECT + +public: + using WidgetFactory = std::function<VcsClientOptionsPageWidget *()>; + + explicit VcsClientOptionsPage(Core::IVersionControl *control, VcsBaseClientImpl *client, QObject *parent = 0); + + VcsClientOptionsPageWidget *widget(); + virtual void apply(); + virtual void finish(); + +signals: + void settingsChanged(); + +protected: + void setWidgetFactory(WidgetFactory factory); + +private: + WidgetFactory m_factory; + VcsClientOptionsPageWidget *m_widget; + VcsBaseClientImpl *const m_client; +}; + } // namespace VcsBase #endif // VCSBASEOPTIONSPAGE_H diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 366f76d51f6..0e8910ada9f 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -804,16 +804,15 @@ void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e, SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir, const FileName &binary, const QStringList &arguments, - int timeOutMS, + int timeOutS, unsigned flags, QTextCodec *outputCodec, const QProcessEnvironment &env) { - VcsCommand command(binary, workingDir, - env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env); + VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env); command.addFlags(flags); command.setCodec(outputCodec); - return command.runVcs(arguments, timeOutMS); + return command.runCommand(binary, arguments, timeOutS); } } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h index 3b92423518d..81128df6f12 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.h +++ b/src/plugins/vcsbase/vcsbaseplugin.h @@ -167,28 +167,10 @@ public: // Returns the source of editor contents. static QString source(Core::IDocument *document); - // Convenience to synchronously run VCS commands - enum RunVcsFlags { - ShowStdOutInLogWindow = 0x1, // Append standard output to VCS output window. - MergeOutputChannels = 0x2, // see QProcess: Merge stderr/stdout. - SshPasswordPrompt = 0x4, // Disable terminal on UNIX to force graphical prompt. - SuppressStdErrInLogWindow = 0x8, // No standard error output to VCS output window. - SuppressFailMessageInLogWindow = 0x10, // No message VCS about failure in VCS output window. - SuppressCommandLogging = 0x20, // No command log entry in VCS output window. - ShowSuccessMessage = 0x40, // Show message about successful completion in VCS output window. - ForceCLocale = 0x80, // Force C-locale for commands whose output is parsed. - FullySynchronously = 0x100, // Suppress local event loop (in case UI actions are - // triggered by file watchers). - ExpectRepoChanges = 0x200, // Expect changes in repository by the command - SilentOutput = 0x400, // With ShowStdOutInLogWindow - append output silently - NoOutput = SuppressStdErrInLogWindow | SuppressFailMessageInLogWindow - | SuppressCommandLogging - }; - static Utils::SynchronousProcessResponse runVcs(const QString &workingDir, const Utils::FileName &binary, const QStringList &arguments, - int timeOutMS, + int timeOutS, unsigned flags = 0, QTextCodec *outputCodec = 0, const QProcessEnvironment &env = QProcessEnvironment()); diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp index 2b40ceb67ea..b87c0f1d4d8 100644 --- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp +++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp @@ -709,7 +709,7 @@ bool VcsBaseSubmitEditor::runSubmitMessageCheckScript(const QString &checkScript } QByteArray stdOutData; QByteArray stdErrData; - if (!SynchronousProcess::readDataFromProcess(checkProcess, 30000, &stdOutData, &stdErrData, false)) { + if (!SynchronousProcess::readDataFromProcess(checkProcess, 30, &stdOutData, &stdErrData, false)) { SynchronousProcess::stopProcess(checkProcess); *errorMessage = tr("The check script \"%1\" timed out."). arg(QDir::toNativeSeparators(checkScript)); diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 1f6c3de5334..0491b0f7fa1 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -53,595 +53,84 @@ #include <QTextCodec> #include <QMutex> -Q_DECLARE_METATYPE(QVariant) - -enum { debugExecution = 0 }; - -/*! - \fn void VcsBase::ProgressParser::parseProgress(const QString &text) - - Reimplement to parse progress as it appears in the standard output. - If a progress string is detected, call \c setProgressAndMaximum() to update - the progress bar accordingly. - - \sa VcsBase::ProgressParser::setProgressAndMaximum() -*/ - -/*! - \fn void VcsBase::ProgressParser::setProgressAndMaximum(int value, int maximum) - - Sets progress \a value and \a maximum for current command. Called by \c parseProgress() - when a progress string is detected. -*/ - namespace VcsBase { -namespace Internal { - -class VcsCommandPrivate -{ -public: - struct Job { - explicit Job(const QStringList &a, int t, Utils::ExitCodeInterpreter *interpreter = 0); - - QStringList arguments; - int timeout; - Utils::ExitCodeInterpreter *exitCodeInterpreter; - }; - - VcsCommandPrivate(const Utils::FileName &binary, - const QString &workingDirectory, - const QProcessEnvironment &environment); - ~VcsCommandPrivate(); - - const Utils::FileName m_binaryPath; - const QString m_workingDirectory; - const QProcessEnvironment m_environment; - QVariant m_cookie; - int m_defaultTimeout; - unsigned m_flags; - QTextCodec *m_codec; - const QString m_sshPasswordPrompt; - ProgressParser *m_progressParser; - bool m_progressiveOutput; - bool m_hadOutput; - bool m_preventRepositoryChanged; - bool m_aborted; - QFutureWatcher<void> m_watcher; - - QList<Job> m_jobs; - - bool m_lastExecSuccess; - int m_lastExecExitCode; -}; - -VcsCommandPrivate::VcsCommandPrivate(const Utils::FileName &binary, - const QString &workingDirectory, - const QProcessEnvironment &environment) : - m_binaryPath(binary), - m_workingDirectory(workingDirectory), - m_environment(environment), - m_defaultTimeout(10), - m_flags(0), - m_codec(0), - m_sshPasswordPrompt(VcsBasePlugin::sshPrompt()), - m_progressParser(0), - m_progressiveOutput(false), - m_hadOutput(false), - m_preventRepositoryChanged(false), - m_aborted(false), - m_lastExecSuccess(false), - m_lastExecExitCode(-1) -{ -} - -VcsCommandPrivate::~VcsCommandPrivate() -{ - delete m_progressParser; -} -VcsCommandPrivate::Job::Job(const QStringList &a, int t, Utils::ExitCodeInterpreter *interpreter) : - arguments(a), - timeout(t), - exitCodeInterpreter(interpreter) -{ - // Finished cookie is emitted via queued slot, needs metatype - static const int qvMetaId = qRegisterMetaType<QVariant>(); - Q_UNUSED(qvMetaId) -} - -} // namespace Internal - -VcsCommand::VcsCommand(const Utils::FileName &binary, - const QString &workingDirectory, +VcsCommand::VcsCommand(const QString &workingDirectory, const QProcessEnvironment &environment) : - d(new Internal::VcsCommandPrivate(binary, workingDirectory, environment)) -{ - connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose, - this, &VcsCommand::coreAboutToClose); -} - -VcsCommand::~VcsCommand() -{ - delete d; -} - -const Utils::FileName &VcsCommand::binaryPath() const -{ - return d->m_binaryPath; -} - -const QString &VcsCommand::workingDirectory() const -{ - return d->m_workingDirectory; -} - -const QProcessEnvironment &VcsCommand::processEnvironment() const -{ - return d->m_environment; -} - -int VcsCommand::defaultTimeout() const -{ - return d->m_defaultTimeout; -} - -void VcsCommand::setDefaultTimeout(int timeout) -{ - d->m_defaultTimeout = timeout; -} - -unsigned VcsCommand::flags() const -{ - return d->m_flags; -} - -void VcsCommand::addFlags(unsigned f) -{ - d->m_flags |= f; -} - -void VcsCommand::addJob(const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter) -{ - addJob(arguments, defaultTimeout(), interpreter); -} - -void VcsCommand::addJob(const QStringList &arguments, int timeout, Utils::ExitCodeInterpreter *interpreter) -{ - d->m_jobs.push_back(Internal::VcsCommandPrivate::Job(arguments, timeout, interpreter)); -} - -void VcsCommand::execute() -{ - d->m_lastExecSuccess = false; - d->m_lastExecExitCode = -1; - - if (d->m_jobs.empty()) - return; - - // For some reason QtConcurrent::run() only works on this - QFuture<void> task = QtConcurrent::run(&VcsCommand::run, this); - d->m_watcher.setFuture(task); - connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &VcsCommand::cancel); - QString binary = d->m_binaryPath.toFileInfo().baseName(); - if (!binary.isEmpty()) - binary = binary.replace(0, 1, binary[0].toUpper()); // Upper the first letter - const QString taskName = binary + QLatin1Char(' ') + d->m_jobs.front().arguments.at(0); - - Core::ProgressManager::addTask(task, taskName, - Core::Id::fromString(binary + QLatin1String(".action"))); -} - -void VcsCommand::abort() -{ - d->m_aborted = true; - d->m_watcher.future().cancel(); -} - -void VcsCommand::cancel() -{ - emit terminate(); -} - -bool VcsCommand::lastExecutionSuccess() const -{ - return d->m_lastExecSuccess; -} - -int VcsCommand::lastExecutionExitCode() const -{ - return d->m_lastExecExitCode; -} - -void VcsCommand::run(QFutureInterface<void> &future) -{ - // Check that the binary path is not empty - if (binaryPath().isEmpty()) { - emit errorText(tr("Unable to start process, binary is empty")); - return; - } - - QString stdOut; - QString stdErr; - - if (d->m_progressParser) - d->m_progressParser->setFuture(&future); - else - future.setProgressRange(0, 1); - const int count = d->m_jobs.size(); - d->m_lastExecExitCode = -1; - d->m_lastExecSuccess = true; - for (int j = 0; j < count; j++) { - const Internal::VcsCommandPrivate::Job &job = d->m_jobs.at(j); - const int timeOutSeconds = job.timeout; - Utils::SynchronousProcessResponse resp = runVcs( - job.arguments, - timeOutSeconds >= 0 ? timeOutSeconds * 1000 : -1, - job.exitCodeInterpreter); - stdOut += resp.stdOut; - stdErr += resp.stdErr; - d->m_lastExecExitCode = resp.exitCode; - d->m_lastExecSuccess = resp.result == Utils::SynchronousProcessResponse::Finished; - if (!d->m_lastExecSuccess) - break; - } - - if (!d->m_aborted) { - if (!d->m_progressiveOutput) { - emit output(stdOut); - if (!stdErr.isEmpty()) - emit errorText(stdErr); - } - - emit finished(d->m_lastExecSuccess, d->m_lastExecExitCode, cookie()); - if (d->m_lastExecSuccess) - emit success(cookie()); - future.setProgressValue(future.progressMaximum()); - } - - if (d->m_progressParser) - d->m_progressParser->setFuture(0); - // As it is used asynchronously, we need to delete ourselves - this->deleteLater(); -} - -class OutputProxy : public QObject -{ - Q_OBJECT - - friend class VcsCommand; - -public: - OutputProxy() - { - // Users of this class can either be in the GUI thread or in other threads. - // Use Qt::AutoConnection to always append in the GUI thread (directly or queued) - VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); - connect(this, &OutputProxy::append, - outputWindow, [](const QString &txt) { VcsOutputWindow::append(txt); }); - connect(this, &OutputProxy::appendSilently, outputWindow, &VcsOutputWindow::appendSilently); - connect(this, &OutputProxy::appendError, outputWindow, &VcsOutputWindow::appendError); - connect(this, &OutputProxy::appendCommand, outputWindow, &VcsOutputWindow::appendCommand); - connect(this, &OutputProxy::appendMessage, outputWindow, &VcsOutputWindow::appendMessage); - } - -signals: - void append(const QString &text); - void appendSilently(const QString &text); - void appendError(const QString &text); - void appendCommand(const QString &workingDirectory, - const Utils::FileName &binary, - const QStringList &args); - void appendMessage(const QString &text); -}; - -Utils::SynchronousProcessResponse VcsCommand::runVcs(const QStringList &arguments, int timeoutMS, - Utils::ExitCodeInterpreter *interpreter) -{ - Utils::SynchronousProcessResponse response; - OutputProxy outputProxy; - - if (d->m_binaryPath.isEmpty()) { - response.result = Utils::SynchronousProcessResponse::StartFailed; - return response; - } - - if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging)) - emit outputProxy.appendCommand(d->m_workingDirectory, d->m_binaryPath, arguments); - - const bool sshPromptConfigured = !d->m_sshPasswordPrompt.isEmpty(); - if (debugExecution) { - QDebug nsp = qDebug().nospace(); - nsp << "Command::runVcs" << d->m_workingDirectory << d->m_binaryPath << arguments - << timeoutMS; - if (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow) - nsp << "stdout"; - if (d->m_flags & VcsBasePlugin::SuppressStdErrInLogWindow) - nsp << "suppress_stderr"; - if (d->m_flags & VcsBasePlugin::SuppressFailMessageInLogWindow) - nsp << "suppress_fail_msg"; - if (d->m_flags & VcsBasePlugin::MergeOutputChannels) - nsp << "merge_channels"; - if (d->m_flags & VcsBasePlugin::SshPasswordPrompt) - nsp << "ssh (" << sshPromptConfigured << ')'; - if (d->m_flags & VcsBasePlugin::SuppressCommandLogging) - nsp << "suppress_log"; - if (d->m_flags & VcsBasePlugin::ForceCLocale) - nsp << "c_locale"; - if (d->m_flags & VcsBasePlugin::FullySynchronously) - nsp << "fully_synchronously"; - if (d->m_flags & VcsBasePlugin::ExpectRepoChanges) - nsp << "expect_repo_changes"; - if (d->m_codec) - nsp << " Codec: " << d->m_codec->name(); - } - - // TODO tell the document manager about expected repository changes - // if (d->m_flags & ExpectRepoChanges) - // Core::DocumentManager::expectDirectoryChange(d->m_workingDirectory); - if (d->m_flags & VcsBasePlugin::FullySynchronously) { - response = runSynchronous(arguments, timeoutMS, interpreter); - } else { - Utils::SynchronousProcess process; - process.setExitCodeInterpreter(interpreter); - connect(this, &VcsCommand::terminate, &process, &Utils::SynchronousProcess::terminate); - if (!d->m_workingDirectory.isEmpty()) - process.setWorkingDirectory(d->m_workingDirectory); - - QProcessEnvironment env = d->m_environment; - VcsBasePlugin::setProcessEnvironment(&env, - (d->m_flags & VcsBasePlugin::ForceCLocale), - d->m_sshPasswordPrompt); - process.setProcessEnvironment(env); - process.setTimeout(timeoutMS); - if (d->m_codec) - process.setCodec(d->m_codec); - - // Suppress terminal on UNIX for ssh prompts if it is configured. - if (sshPromptConfigured && (d->m_flags & VcsBasePlugin::SshPasswordPrompt)) - process.setFlags(Utils::SynchronousProcess::UnixTerminalDisabled); - - // connect stderr to the output window if desired - if (d->m_flags & VcsBasePlugin::MergeOutputChannels) { - process.setProcessChannelMode(QProcess::MergedChannels); - } else if (d->m_progressiveOutput - || !(d->m_flags & VcsBasePlugin::SuppressStdErrInLogWindow)) { - process.setStdErrBufferedSignalsEnabled(true); - connect(&process, &Utils::SynchronousProcess::stdErrBuffered, - this, &VcsCommand::bufferedError); - } - - // connect stdout to the output window if desired - if (d->m_progressParser || d->m_progressiveOutput - || (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow)) { - process.setStdOutBufferedSignalsEnabled(true); - connect(&process, &Utils::SynchronousProcess::stdOutBuffered, - this, &VcsCommand::bufferedOutput); - } - - process.setTimeOutMessageBoxEnabled(true); - - // Run! - response = process.run(d->m_binaryPath.toString(), arguments); - } - - if (!d->m_aborted) { - // Success/Fail message in appropriate window? - if (response.result == Utils::SynchronousProcessResponse::Finished) { - if (d->m_flags & VcsBasePlugin::ShowSuccessMessage) { - emit outputProxy.appendMessage(response.exitMessage(d->m_binaryPath.toUserOutput(), - timeoutMS)); - } - } else if (!(d->m_flags & VcsBasePlugin::SuppressFailMessageInLogWindow)) { - emit outputProxy.appendError(response.exitMessage(d->m_binaryPath.toUserOutput(), - timeoutMS)); - } - } + Core::ShellCommand(workingDirectory, environment), + m_preventRepositoryChanged(false) +{ + setOutputProxyFactory([this]() -> Utils::OutputProxy * { + auto proxy = new Utils::OutputProxy; + VcsOutputWindow *outputWindow = VcsOutputWindow::instance(); + + connect(proxy, &Utils::OutputProxy::append, + outputWindow, [](const QString &txt) { VcsOutputWindow::append(txt); }, + Qt::QueuedConnection); + connect(proxy, &Utils::OutputProxy::appendSilently, + outputWindow, &VcsOutputWindow::appendSilently, + Qt::QueuedConnection); + connect(proxy, &Utils::OutputProxy::appendError, + outputWindow, &VcsOutputWindow::appendError, + Qt::QueuedConnection); + connect(proxy, &Utils::OutputProxy::appendCommand, + outputWindow, &VcsOutputWindow::appendCommand, + Qt::QueuedConnection); + connect(proxy, &Utils::OutputProxy::appendMessage, + outputWindow, &VcsOutputWindow::appendMessage, + Qt::QueuedConnection); + + return proxy; + }); +} + +const QProcessEnvironment VcsCommand::processEnvironment() const +{ + QProcessEnvironment env = Core::ShellCommand::processEnvironment(); + VcsBasePlugin::setProcessEnvironment(&env, flags() & ForceCLocale, VcsBasePlugin::sshPrompt()); + return env; +} + +Utils::SynchronousProcessResponse VcsCommand::runCommand(const Utils::FileName &binary, + const QStringList &arguments, int timeoutS, + Utils::ExitCodeInterpreter *interpreter) +{ + Utils::SynchronousProcessResponse response + = Core::ShellCommand::runCommand(binary, arguments, timeoutS, interpreter); emitRepositoryChanged(); - return response; } -Utils::SynchronousProcessResponse VcsCommand::runSynchronous(const QStringList &arguments, - int timeoutMS, - Utils::ExitCodeInterpreter *interpreter) +bool VcsCommand::runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, + int timeoutS, QByteArray *outputData, QByteArray *errorData) { - Utils::SynchronousProcessResponse response; - - // Set up process - unsigned processFlags = 0; - if (!d->m_sshPasswordPrompt.isEmpty() && (d->m_flags & VcsBasePlugin::SshPasswordPrompt)) - processFlags |= Utils::SynchronousProcess::UnixTerminalDisabled; - QSharedPointer<QProcess> process = Utils::SynchronousProcess::createProcess(processFlags); - if (!d->m_workingDirectory.isEmpty()) - process->setWorkingDirectory(d->m_workingDirectory); - QProcessEnvironment env = d->m_environment; - VcsBasePlugin::setProcessEnvironment(&env, - (d->m_flags & VcsBasePlugin::ForceCLocale), - d->m_sshPasswordPrompt); - process->setProcessEnvironment(env); - if (d->m_flags & VcsBasePlugin::MergeOutputChannels) - process->setProcessChannelMode(QProcess::MergedChannels); - - // Start - process->start(d->m_binaryPath.toString(), arguments, QIODevice::ReadOnly); - process->closeWriteChannel(); - if (!process->waitForStarted()) { - response.result = Utils::SynchronousProcessResponse::StartFailed; - return response; - } - - // process output - QByteArray stdOut; - QByteArray stdErr; - const bool timedOut = - !Utils::SynchronousProcess::readDataFromProcess(*process.data(), timeoutMS, - &stdOut, &stdErr, true); - - if (!d->m_aborted) { - OutputProxy outputProxy; - if (!stdErr.isEmpty()) { - response.stdErr = Utils::SynchronousProcess::normalizeNewlines( - d->m_codec ? d->m_codec->toUnicode(stdErr) : QString::fromLocal8Bit(stdErr)); - if (!(d->m_flags & VcsBasePlugin::SuppressStdErrInLogWindow)) - emit outputProxy.append(response.stdErr); - } - - if (!stdOut.isEmpty()) { - response.stdOut = Utils::SynchronousProcess::normalizeNewlines( - d->m_codec ? d->m_codec->toUnicode(stdOut) : QString::fromLocal8Bit(stdOut)); - if (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow) { - if (d->m_flags & VcsBasePlugin::SilentOutput) - emit outputProxy.appendSilently(response.stdOut); - else - emit outputProxy.append(response.stdOut); - } - } - } - - Utils::ExitCodeInterpreter defaultInterpreter(this); - Utils::ExitCodeInterpreter *currentInterpreter = interpreter ? interpreter : &defaultInterpreter; - // Result - if (timedOut) - response.result = Utils::SynchronousProcessResponse::Hang; - else if (process->exitStatus() != QProcess::NormalExit) - response.result = Utils::SynchronousProcessResponse::TerminatedAbnormally; - else - response.result = currentInterpreter->interpretExitCode(process->exitCode()); - return response; + bool result = Core::ShellCommand::runFullySynchronous(binary, arguments, timeoutS, + outputData, errorData); + emitRepositoryChanged(); + return result; } void VcsCommand::emitRepositoryChanged() { - if (d->m_preventRepositoryChanged || !(d->m_flags & VcsBasePlugin::ExpectRepoChanges)) + if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges)) return; // TODO tell the document manager that the directory now received all expected changes // Core::DocumentManager::unexpectDirectoryChange(d->m_workingDirectory); - Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory); + Core::VcsManager::emitRepositoryChanged(workingDirectory()); } -bool VcsCommand::runFullySynchronous(const QStringList &arguments, int timeoutMS, - QByteArray *outputData, QByteArray *errorData) +unsigned VcsCommand::processFlags() const { - if (d->m_binaryPath.isEmpty()) - return false; - - OutputProxy outputProxy; - if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging)) - emit outputProxy.appendCommand(d->m_workingDirectory, d->m_binaryPath, arguments); - - // TODO tell the document manager about expected repository changes - // if (d->m_flags & ExpectRepoChanges) - // Core::DocumentManager::expectDirectoryChange(workingDirectory); - QProcess process; - process.setWorkingDirectory(d->m_workingDirectory); - process.setProcessEnvironment(d->m_environment); - - process.start(d->m_binaryPath.toString(), arguments); - process.closeWriteChannel(); - if (!process.waitForStarted()) { - if (errorData) { - const QString msg = QString::fromLatin1("Unable to execute \"%1\": %2:") - .arg(d->m_binaryPath.toUserOutput(), process.errorString()); - *errorData = msg.toLocal8Bit(); - } - return false; - } - - if (!Utils::SynchronousProcess::readDataFromProcess(process, timeoutMS, outputData, errorData, true)) { - if (errorData) - errorData->append(tr("Error: Executable timed out after %1s.").arg(timeoutMS / 1000).toLocal8Bit()); - Utils::SynchronousProcess::stopProcess(process); - return false; - } - - emitRepositoryChanged(); - return process.exitStatus() == QProcess::NormalExit && process.exitCode() == 0; -} - -void VcsCommand::bufferedOutput(const QString &text) -{ - if (d->m_progressParser) - d->m_progressParser->parseProgress(text); - if (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow) - VcsOutputWindow::append(text); - if (d->m_progressiveOutput) { - emit output(text); - d->m_hadOutput = true; - } -} - -void VcsCommand::bufferedError(const QString &text) -{ - if (!(d->m_flags & VcsBasePlugin::SuppressStdErrInLogWindow)) - VcsOutputWindow::appendError(text); - if (d->m_progressiveOutput) - emit errorText(text); + unsigned processFlags = 0; + if (!VcsBasePlugin::sshPrompt().isEmpty() && (flags() & SshPasswordPrompt)) + processFlags |= Utils::SynchronousProcess::UnixTerminalDisabled; + return processFlags; } void VcsCommand::coreAboutToClose() { - d->m_preventRepositoryChanged = true; + m_preventRepositoryChanged = true; abort(); } -const QVariant &VcsCommand::cookie() const -{ - return d->m_cookie; -} - -void VcsCommand::setCookie(const QVariant &cookie) -{ - d->m_cookie = cookie; -} - -QTextCodec *VcsCommand::codec() const -{ - return d->m_codec; -} - -void VcsCommand::setCodec(QTextCodec *codec) -{ - d->m_codec = codec; -} - -//! Use \a parser to parse progress data from stdout. Command takes ownership of \a parser -void VcsCommand::setProgressParser(ProgressParser *parser) -{ - QTC_ASSERT(!d->m_progressParser, return); - d->m_progressParser = parser; -} - -void VcsCommand::setProgressiveOutput(bool progressive) -{ - d->m_progressiveOutput = progressive; -} - -ProgressParser::ProgressParser() : - m_future(0), - m_futureMutex(new QMutex) -{ -} - -ProgressParser::~ProgressParser() -{ - delete m_futureMutex; -} - -void ProgressParser::setProgressAndMaximum(int value, int maximum) -{ - QMutexLocker lock(m_futureMutex); - if (!m_future) - return; - m_future->setProgressRange(0, maximum); - m_future->setProgressValue(value); -} - -void ProgressParser::setFuture(QFutureInterface<void> *future) -{ - QMutexLocker lock(m_futureMutex); - m_future = future; -} - } // namespace VcsBase - -#include "vcscommand.moc" diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index f2eea82553d..ee5d424aaa5 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -33,112 +33,37 @@ #include "vcsbase_global.h" -#include <QObject> - -QT_BEGIN_NAMESPACE -class QMutex; -class QStringList; -class QVariant; -class QProcessEnvironment; -template <typename T> -class QFutureInterface; -QT_END_NAMESPACE - -namespace Utils { -struct SynchronousProcessResponse; -class ExitCodeInterpreter; -class FileName; -} +#include <coreplugin/shellcommand.h> namespace VcsBase { -namespace Internal { class VcsCommandPrivate; } - -class VCSBASE_EXPORT ProgressParser -{ -public: - ProgressParser(); - virtual ~ProgressParser(); - -protected: - virtual void parseProgress(const QString &text) = 0; - void setProgressAndMaximum(int value, int maximum); - -private: - void setFuture(QFutureInterface<void> *future); - - QFutureInterface<void> *m_future; - QMutex *m_futureMutex; - friend class VcsCommand; -}; - -class VCSBASE_EXPORT VcsCommand : public QObject +class VCSBASE_EXPORT VcsCommand : public Core::ShellCommand { Q_OBJECT public: - VcsCommand(const Utils::FileName &binary, - const QString &workingDirectory, - const QProcessEnvironment &environment); - ~VcsCommand(); - - void addJob(const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter = 0); - void addJob(const QStringList &arguments, int timeout, Utils::ExitCodeInterpreter *interpreter = 0); - void execute(); - void abort(); - bool lastExecutionSuccess() const; - int lastExecutionExitCode() const; - - const Utils::FileName &binaryPath() const; - const QString &workingDirectory() const; - const QProcessEnvironment &processEnvironment() const; - - int defaultTimeout() const; - void setDefaultTimeout(int timeout); - - unsigned flags() const; - void addFlags(unsigned f); + enum VcsRunFlags { + SshPasswordPrompt = 0x1000, // Disable terminal on UNIX to force graphical prompt. + ExpectRepoChanges = 0x2000, // Expect changes in repository by the command + }; - const QVariant &cookie() const; - void setCookie(const QVariant &cookie); + VcsCommand(const QString &workingDirectory, const QProcessEnvironment &environment); - QTextCodec *codec() const; - void setCodec(QTextCodec *codec); + const QProcessEnvironment processEnvironment() const; - void setProgressParser(ProgressParser *parser); - void setProgressiveOutput(bool progressive); - - Utils::SynchronousProcessResponse runVcs(const QStringList &arguments, int timeoutMS, - Utils::ExitCodeInterpreter *interpreter = 0); - // Make sure to not pass through the event loop at all: - bool runFullySynchronous(const QStringList &arguments, int timeoutMS, - QByteArray *outputData, QByteArray *errorData); + Utils::SynchronousProcessResponse runCommand(const Utils::FileName &binary, + const QStringList &arguments, int timeoutS, + Utils::ExitCodeInterpreter *interpreter = 0); + bool runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, + int timeoutS, QByteArray *outputData, QByteArray *errorData); private: - void run(QFutureInterface<void> &future); - Utils::SynchronousProcessResponse runSynchronous(const QStringList &arguments, int timeoutMS, - Utils::ExitCodeInterpreter *interpreter = 0); + unsigned processFlags() const; void emitRepositoryChanged(); -public slots: - void cancel(); - -signals: - void output(const QString &); - void errorText(const QString &); - void finished(bool ok, int exitCode, const QVariant &cookie); - void success(const QVariant &cookie); - -private slots: - void bufferedOutput(const QString &text); - void bufferedError(const QString &text); void coreAboutToClose(); -signals: - void terminate(); // Internal - -private: - class Internal::VcsCommandPrivate *const d; + bool m_preventRepositoryChanged; }; } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsplugin.cpp b/src/plugins/vcsbase/vcsplugin.cpp index e6fc52782fb..49037559cbf 100644 --- a/src/plugins/vcsbase/vcsplugin.cpp +++ b/src/plugins/vcsbase/vcsplugin.cpp @@ -37,6 +37,7 @@ #include "vcsoutputwindow.h" #include "vcsprojectcache.h" #include "corelistener.h" +#include "wizard/vcscommandpage.h" #include "wizard/vcsconfigurationpage.h" #include "wizard/vcsjsextension.h" @@ -93,6 +94,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage) slotSettingsChanged(); JsonWizardFactory::registerPageFactory(new Internal::VcsConfigurationPageFactory); + JsonWizardFactory::registerPageFactory(new Internal::VcsCommandPageFactory); JsExpander::registerQObjectForJs(QLatin1String("Vcs"), new VcsJsExtension); diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.cpp b/src/plugins/vcsbase/wizard/vcscommandpage.cpp new file mode 100644 index 00000000000..d8d488eda2b --- /dev/null +++ b/src/plugins/vcsbase/wizard/vcscommandpage.cpp @@ -0,0 +1,265 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms and +** conditions see http://www.qt.io/terms-conditions. For further information +** use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "vcscommandpage.h" + +#include <coreplugin/id.h> +#include <coreplugin/iversioncontrol.h> +#include <coreplugin/shellcommand.h> +#include <coreplugin/vcsmanager.h> +#include <projectexplorer/jsonwizard/jsonwizard.h> + +#include <utils/algorithm.h> +#include <utils/qtcassert.h> + +#include <QDir> +#include <QDebug> +#include <QTimer> + +using namespace Core; +using namespace ProjectExplorer; + +namespace VcsBase { +namespace Internal { + +static char VCSCOMMAND_VCSID[] = "vcsId"; +static char VCSCOMMAND_RUN_MESSAGE[] = "trRunMessage"; +static char VCSCOMMAND_REPO[] = "repository"; +static char VCSCOMMAND_DIR[] = "baseDirectory"; +static char VCSCOMMAND_EXTRA_ARGS[] = "extraArguments"; +static char VCSCOMMAND_CHECKOUTNAME[] = "checkoutName"; + +// ---------------------------------------------------------------------- +// VcsCommandPageFactory: +// ---------------------------------------------------------------------- + +VcsCommandPageFactory::VcsCommandPageFactory() +{ + setTypeIdsSuffix(QLatin1String("VcsCommand")); +} + +Utils::WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, + const QVariant &data) +{ + Q_UNUSED(wizard); + + QTC_ASSERT(canCreate(typeId), return 0); + + QVariantMap tmp = data.toMap(); + + auto page = new VcsCommandPage; + page->setVersionControlId(tmp.value(QLatin1String(VCSCOMMAND_VCSID)).toString()); + page->setRunMessage(tmp.value(QLatin1String(VCSCOMMAND_RUN_MESSAGE)).toString()); + + QStringList args; + const QVariant argsVar = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); + if (!argsVar.isNull()) { + if (argsVar.type() == QVariant::String) { + args << argsVar.toString(); + } else if (argsVar.type() == QVariant::List) { + args = Utils::transform(argsVar.toList(), [](const QVariant &in) { + return in.toString(); + }); + } else { + return 0; + } + } + + page->setCheckoutData(tmp.value(QLatin1String(VCSCOMMAND_REPO)).toString(), + tmp.value(QLatin1String(VCSCOMMAND_DIR)).toString(), + tmp.value(QLatin1String(VCSCOMMAND_CHECKOUTNAME)).toString(), + args); + + return page; +} + +bool VcsCommandPageFactory::validateData(Id typeId, const QVariant &data, QString *errorMessage) +{ + QTC_ASSERT(canCreate(typeId), return false); + + QString em; + if (data.type() != QVariant::Map) + em = tr("\"data\" is no json object in \"VcsCommand\" page."); + + if (em.isEmpty()) { + const QVariantMap tmp = data.toMap(); + + QString str = tmp.value(QLatin1String(VCSCOMMAND_VCSID)).toString(); + if (str.isEmpty()) { + em = tr("\"%1\" not set in \"data\" section of \"VcsCommand\" page.") + .arg(QLatin1String(VCSCOMMAND_VCSID)); + } + str = tmp.value(QLatin1String(VCSCOMMAND_REPO)).toString(); + if (str.isEmpty()) { + em = tr("\"%1\" not set in \"data\" section of \"VcsCommand\" page.") + .arg(QLatin1String(VCSCOMMAND_REPO)); + } + str = tmp.value(QLatin1String(VCSCOMMAND_DIR)).toString(); + if (str.isEmpty()) { + em = tr("\"%1\" not set in \"data\" section of \"VcsCommand\" page.") + .arg(QLatin1String(VCSCOMMAND_DIR));; + } + str = tmp.value(QLatin1String(VCSCOMMAND_CHECKOUTNAME)).toString(); + if (str.isEmpty()) { + em = tr("\"%1\" not set in \"data\" section of \"VcsCommand\" page.") + .arg(QLatin1String(VCSCOMMAND_CHECKOUTNAME)); + } + + str = tmp.value(QLatin1String(VCSCOMMAND_RUN_MESSAGE)).toString(); + if (str.isEmpty()) { + em = tr("\"%1\" not set in \"data\" section of \"VcsCommand\" page.") + .arg(QLatin1String(VCSCOMMAND_RUN_MESSAGE)); + } + + const QVariant extra = tmp.value(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); + if (!extra.isNull() && extra.type() != QVariant::String && extra.type() != QVariant::List) { + em = tr("\"%1\" in \"data\" section of \"VcsCommand\" page has unexpected type (unset, String or List).") + .arg(QLatin1String(VCSCOMMAND_EXTRA_ARGS)); + } + } + + if (errorMessage) + *errorMessage = em; + + return em.isEmpty(); +} + +// ---------------------------------------------------------------------- +// VcsCommandPage: +// ---------------------------------------------------------------------- + +VcsCommandPage::VcsCommandPage() +{ + setTitle(tr("Checkout")); +} + +void VcsCommandPage::initializePage() +{ + // Delay real initialization till after QWizard is done with its setup. + // Otherwise QWizard will reset our disabled back button again. + QTimer::singleShot(0, this, &VcsCommandPage::delayedInitialize); +} + +void VcsCommandPage::delayedInitialize() +{ + auto wiz = qobject_cast<JsonWizard *>(wizard()); + QTC_ASSERT(wiz, return); + + const QString vcsId = wiz->expander()->expand(m_vcsId); + IVersionControl *vc = VcsManager::versionControl(Id::fromString(vcsId)); + if (!vc) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "\"%1\" (%2) not found.") + .arg(QLatin1String(VCSCOMMAND_VCSID), vcsId); + return; + } + if (!vc->isConfigured()) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "Version control \"%1\" is not configured.") + .arg(vcsId); + return; + } + if (!vc->supportsOperation(IVersionControl::InitialCheckoutOperation)) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "Version control \"%1\" does not support initial checkouts.") + .arg(vcsId); + return; + } + + const QString repo = wiz->expander()->expand(m_repository); + if (repo.isEmpty()) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "\"%1\" is empty when trying to run checkout.") + .arg(QLatin1String(VCSCOMMAND_REPO)); + return; + } + + const QString base = wiz->expander()->expand(m_directory); + if (!QDir(base).exists()) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "\"%1\" (%2) does not exist.") + .arg(QLatin1String(VCSCOMMAND_DIR), base); + return; + } + + const QString name = wiz->expander()->expand(m_name); + if (name.isEmpty()) { + qWarning() << QCoreApplication::translate("VcsBase::VcsCommandPage", + "\"%1\" is empty when trying to run checkout.") + .arg(QLatin1String(VCSCOMMAND_CHECKOUTNAME)); + return; + } + + const QString runMessage = wiz->expander()->expand(m_runMessage); + if (!runMessage.isEmpty()) + setStartedStatus(runMessage); + + QStringList extraArgs; + foreach (const QString &in, m_arguments) { + const QString tmp = wiz->expander()->expand(in); + if (tmp.isEmpty()) + continue; + if (tmp == QStringLiteral("\"\"")) + extraArgs << QString(); + extraArgs << tmp; + } + + ShellCommand *command + = vc->createInitialCheckoutCommand(repo, Utils::FileName::fromString(base), + name, extraArgs); + start(command); +} + +void VcsCommandPage::setCheckoutData(const QString &repo, const QString &baseDir, const QString &name, + const QStringList &args) +{ + m_repository = repo; + m_directory = baseDir; + m_name = name; + m_arguments = args; +} + +void VcsCommandPage::appendJob(bool skip, const QStringList &command) +{ + m_additionalJobs.append(JobData(skip, command)); +} + +void VcsCommandPage::setVersionControlId(const QString &id) +{ + m_vcsId = id; +} + +void VcsCommandPage::setRunMessage(const QString &msg) +{ + m_runMessage = msg; +} + +} // namespace Internal +} // namespace VcsBase diff --git a/src/plugins/vcsbase/checkoutprogresswizardpage.h b/src/plugins/vcsbase/wizard/vcscommandpage.h index 13c7e18217e..860f9f265b8 100644 --- a/src/plugins/vcsbase/checkoutprogresswizardpage.h +++ b/src/plugins/vcsbase/wizard/vcscommandpage.h @@ -28,63 +28,67 @@ ** ****************************************************************************/ -#ifndef CHECKOUTPROGRESSWIZARDPAGE_H -#define CHECKOUTPROGRESSWIZARDPAGE_H +#ifndef VCSCOMMANDPAGE_H +#define VCSCOMMANDPAGE_H -#include <QSharedPointer> -#include <QWizardPage> +#include "../vcsbase_global.h" -QT_BEGIN_NAMESPACE -class QPlainTextEdit; -class QLabel; -QT_END_NAMESPACE +#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h> -namespace Utils { class OutputFormatter; } +#include <utils/shellcommandpage.h> -namespace VcsBase { -class VcsCommand; +#include <QCoreApplication> +namespace VcsBase { namespace Internal { -class CheckoutProgressWizardPage : public QWizardPage +class VcsCommandPageFactory : public ProjectExplorer::JsonWizardPageFactory { - Q_OBJECT + Q_DECLARE_TR_FUNCTIONS(VcsBase::Internal::VcsCommandPage) public: - enum State { Idle, Running, Failed, Succeeded }; + VcsCommandPageFactory(); - explicit CheckoutProgressWizardPage(QWidget *parent = 0); - ~CheckoutProgressWizardPage(); + Utils::WizardPage *create(ProjectExplorer::JsonWizard *wizard, Core::Id typeId, + const QVariant &data); + bool validateData(Core::Id typeId, const QVariant &data, QString *errorMessage); +}; - void setStartedStatus(const QString &startedStatus); - void start(VcsCommand *command); +class VcsCommandPage : public Utils::ShellCommandPage +{ + Q_OBJECT - virtual bool isComplete() const; - bool isRunning() const{ return m_state == Running; } +public: + VcsCommandPage(); - void terminate(); + void initializePage(); -signals: - void terminated(bool success); + void setCheckoutData(const QString &repo, const QString &baseDir, const QString &name, + const QStringList &args); + void appendJob(bool skip, const QStringList &command); + void setVersionControlId(const QString &id); + void setRunMessage(const QString &msg); private slots: - void slotFinished(bool ok, int exitCode, const QVariant &cookie); - void reportStdOut(const QString &text); - void reportStdErr(const QString &text); + void delayedInitialize(); private: - QPlainTextEdit *m_logPlainTextEdit; - Utils::OutputFormatter *m_formatter; - QLabel *m_statusLabel; - - VcsCommand *m_command; - QString m_startedStatus; - bool m_overwriteOutput; - - State m_state; + QString m_vcsId; + QString m_repository; + QString m_directory; + QString m_name; + QString m_runMessage; + QStringList m_arguments; + + struct JobData { + JobData(bool s, const QStringList &c) : job(c), skipEmptyArguments(s) { } + QStringList job; + bool skipEmptyArguments = false; + }; + QList<JobData> m_additionalJobs; }; } // namespace Internal } // namespace VcsBase -#endif // CHECKOUTPROGRESSWIZARDPAGE_H +#endif // VCSCOMMANDPAGE_H diff --git a/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp b/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp index c12703e661f..94f14677fc3 100644 --- a/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp +++ b/src/plugins/vcsbase/wizard/vcsconfigurationpage.cpp @@ -118,8 +118,6 @@ VcsConfigurationPage::VcsConfigurationPage() : d(new Internal::VcsConfigurationP auto verticalLayout = new QVBoxLayout(this); verticalLayout->addWidget(d->m_configureButton); - connect(d->m_versionControl, &IVersionControl::configurationChanged, - this, &QWizardPage::completeChanged); connect(d->m_configureButton, &QAbstractButton::clicked, this, &VcsConfigurationPage::openConfiguration); } @@ -145,6 +143,11 @@ void VcsConfigurationPage::setVersionControlId(const QString &id) void VcsConfigurationPage::initializePage() { + if (d->m_versionControl) { + disconnect(d->m_versionControl, &IVersionControl::configurationChanged, + this, &QWizardPage::completeChanged); + } + if (!d->m_versionControlId.isEmpty()) { auto jw = qobject_cast<JsonWizard *>(wizard()); if (!jw) { @@ -167,6 +170,9 @@ void VcsConfigurationPage::initializePage() } } + connect(d->m_versionControl, &IVersionControl::configurationChanged, + this, &QWizardPage::completeChanged); + d->m_configureButton->setEnabled(d->m_versionControl); if (d->m_versionControl) setSubTitle(tr("Please configure <b>%1</b> now.").arg(d->m_versionControl->displayName())); diff --git a/src/plugins/welcome/welcome.pro b/src/plugins/welcome/welcome.pro index 250dbda65da..50ad9f9fdee 100644 --- a/src/plugins/welcome/welcome.pro +++ b/src/plugins/welcome/welcome.pro @@ -1,15 +1,15 @@ QT += quick -!isEmpty(USE_QUICK_WIDGET) { - QT += quickwidgets - DEFINES += USE_QUICK_WIDGET -} - QML_IMPORT_PATH=../../../share/qtcreator/welcomescreen include(../../qtcreatorplugin.pri) +!isEmpty(USE_QUICK_WIDGET)|minQtVersion(5, 5, 0) { + QT += quickwidgets + DEFINES += USE_QUICK_WIDGET +} + HEADERS += welcomeplugin.h SOURCES += welcomeplugin.cpp diff --git a/src/plugins/welcome/welcome.qbs b/src/plugins/welcome/welcome.qbs index 4d3067c0eca..b43b2414da4 100644 --- a/src/plugins/welcome/welcome.qbs +++ b/src/plugins/welcome/welcome.qbs @@ -5,7 +5,6 @@ QtcPlugin { Depends { name: "Qt"; submodules: ["widgets", "network"] } Depends { name: "Qt.quick"; condition: product.condition; } - Depends { name: "Aggregation" } Depends { name: "Utils" } Depends { name: "Core" } diff --git a/src/plugins/welcome/welcome_dependencies.pri b/src/plugins/welcome/welcome_dependencies.pri index 79306957db3..c9a5fc67e18 100644 --- a/src/plugins/welcome/welcome_dependencies.pri +++ b/src/plugins/welcome/welcome_dependencies.pri @@ -1,6 +1,5 @@ QTC_PLUGIN_NAME = Welcome QTC_LIB_DEPENDS += \ - aggregation \ extensionsystem \ utils QTC_PLUGIN_DEPENDS += \ diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index 651194e31ad..4ae5c96c4af 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -215,7 +215,7 @@ void WelcomeMode::facilitateQml(QQmlEngine *engine) ctx->setContextProperty(QLatin1String("creatorTheme"), &m_themeProperties); -#if defined(USE_QUICK_WIDGET) +#if defined(USE_QUICK_WIDGET) && (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) bool useNativeText = !HostOsInfo::isMacHost(); #else bool useNativeText = true; diff --git a/src/plugins/winrt/winrtpackagedeploymentstep.cpp b/src/plugins/winrt/winrtpackagedeploymentstep.cpp index 4d0fca6e9df..c93adbe80e1 100644 --- a/src/plugins/winrt/winrtpackagedeploymentstep.cpp +++ b/src/plugins/winrt/winrtpackagedeploymentstep.cpp @@ -243,16 +243,18 @@ QString WinRtPackageDeploymentStep::defaultWinDeployQtArguments() const void WinRtPackageDeploymentStep::raiseError(const QString &errorMessage) { + ProjectExplorer::Task task = Task(Task::Error, errorMessage, Utils::FileName(), -1, + ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task, 1); emit addOutput(errorMessage, BuildStep::ErrorMessageOutput); - emit addTask(Task(Task::Error, errorMessage, Utils::FileName(), -1, - ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); } void WinRtPackageDeploymentStep::raiseWarning(const QString &warningMessage) { + ProjectExplorer::Task task = Task(Task::Warning, warningMessage, Utils::FileName(), -1, + ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT); + emit addTask(task, 1); emit addOutput(warningMessage, BuildStep::MessageOutput); - emit addTask(Task(Task::Warning, warningMessage, Utils::FileName(), -1, - ProjectExplorer::Constants::TASK_CATEGORY_DEPLOYMENT)); } bool WinRtPackageDeploymentStep::fromMap(const QVariantMap &map) |