PageRenderTime 71ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 1ms

/src/plugins/projectexplorer/settingsaccessor.cpp

https://bitbucket.org/kpozn/qt-creator-py-reborn
C++ | 2699 lines | 2163 code | 302 blank | 234 comment | 667 complexity | 2a3ed87a9689936f14807bcd35c4bee0 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. /**************************************************************************
  2. **
  3. ** This file is part of Qt Creator
  4. **
  5. ** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
  6. **
  7. ** Contact: Nokia Corporation (qt-info@nokia.com)
  8. **
  9. **
  10. ** GNU Lesser General Public License Usage
  11. **
  12. ** This file may be used under the terms of the GNU Lesser General Public
  13. ** License version 2.1 as published by the Free Software Foundation and
  14. ** appearing in the file LICENSE.LGPL included in the packaging of this file.
  15. ** Please review the following information to ensure the GNU Lesser General
  16. ** Public License version 2.1 requirements will be met:
  17. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  18. **
  19. ** In addition, as a special exception, Nokia gives you certain additional
  20. ** rights. These rights are described in the Nokia Qt LGPL Exception
  21. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  22. **
  23. ** Other Usage
  24. **
  25. ** Alternatively, this file may be used in accordance with the terms and
  26. ** conditions contained in a signed written agreement between you and Nokia.
  27. **
  28. ** If you have questions regarding the use of this file, please contact
  29. ** Nokia at qt-info@nokia.com.
  30. **
  31. **************************************************************************/
  32. #include "settingsaccessor.h"
  33. #include "buildconfiguration.h"
  34. #include "devicesupport/devicemanager.h"
  35. #include "project.h"
  36. #include "projectexplorer.h"
  37. #include "projectexplorersettings.h"
  38. #include "projectexplorerconstants.h"
  39. #include "target.h"
  40. #include "profile.h"
  41. #include "profilemanager.h"
  42. #include <coreplugin/icore.h>
  43. #include <coreplugin/idocument.h>
  44. #include <extensionsystem/pluginmanager.h>
  45. #include <utils/qtcassert.h>
  46. #include <utils/qtcprocess.h>
  47. #include <utils/persistentsettings.h>
  48. #include <QApplication>
  49. #include <QDebug>
  50. #include <QFile>
  51. #include <QMainWindow>
  52. #include <QMessageBox>
  53. namespace ProjectExplorer {
  54. namespace Internal {
  55. // -------------------------------------------------------------------------
  56. // UserFileVersionHandler
  57. // -------------------------------------------------------------------------
  58. class UserFileVersionHandler
  59. {
  60. public:
  61. UserFileVersionHandler();
  62. virtual ~UserFileVersionHandler();
  63. // The user file version this handler accepts for input.
  64. virtual int userFileVersion() const = 0;
  65. virtual QString displayUserFileVersion() const = 0;
  66. // Update from userFileVersion() to userFileVersion() + 1
  67. virtual QVariantMap update(Project *project, const QVariantMap &map) = 0;
  68. protected:
  69. typedef QPair<QLatin1String,QLatin1String> Change;
  70. QVariantMap renameKeys(const QList<Change> &changes, QVariantMap map);
  71. };
  72. UserFileVersionHandler::UserFileVersionHandler()
  73. {
  74. }
  75. UserFileVersionHandler::~UserFileVersionHandler()
  76. {
  77. }
  78. /**
  79. * Performs a simple renaming of the listed keys in \a changes recursively on \a map.
  80. */
  81. QVariantMap UserFileVersionHandler::renameKeys(const QList<Change> &changes, QVariantMap map)
  82. {
  83. foreach (const Change &change, changes) {
  84. QVariantMap::iterator oldSetting = map.find(change.first);
  85. if (oldSetting != map.end()) {
  86. map.insert(change.second, oldSetting.value());
  87. map.erase(oldSetting);
  88. }
  89. }
  90. QVariantMap::iterator i = map.begin();
  91. while (i != map.end()) {
  92. QVariant v = i.value();
  93. if (v.type() == QVariant::Map)
  94. i.value() = renameKeys(changes, v.toMap());
  95. ++i;
  96. }
  97. return map;
  98. }
  99. } // Internal
  100. } // ProjectExplorer
  101. using namespace ProjectExplorer;
  102. using namespace Internal;
  103. using Utils::PersistentSettingsReader;
  104. using Utils::PersistentSettingsWriter;
  105. namespace {
  106. const char VERSION_KEY[] = "ProjectExplorer.Project.Updater.FileVersion";
  107. const char ENVIRONMENT_ID_KEY[] = "ProjectExplorer.Project.Updater.EnvironmentId";
  108. const char USER_STICKY_KEYS_KEY[] = "ProjectExplorer.Project.UserStickyKeys";
  109. const char SHARED_SETTINGS[] = "SharedSettings";
  110. // Version 0 is used in Qt Creator 1.3.x and
  111. // (in a slighly different flavour) post 1.3 master.
  112. class Version0Handler : public UserFileVersionHandler
  113. {
  114. public:
  115. int userFileVersion() const
  116. {
  117. return 0;
  118. }
  119. QString displayUserFileVersion() const
  120. {
  121. return QLatin1String("1.3");
  122. }
  123. QVariantMap update(Project *project, const QVariantMap &map);
  124. private:
  125. QVariantMap convertBuildConfigurations(Project *project, const QVariantMap &map);
  126. QVariantMap convertRunConfigurations(Project *project, const QVariantMap &map);
  127. QVariantMap convertBuildSteps(Project *project, const QVariantMap &map);
  128. };
  129. // Version 1 is used in master post Qt Creator 1.3.x.
  130. // It was never used in any official release but is required for the
  131. // transition to later versions (which introduce support for targets).
  132. class Version1Handler : public UserFileVersionHandler
  133. {
  134. public:
  135. int userFileVersion() const
  136. {
  137. return 1;
  138. }
  139. QString displayUserFileVersion() const
  140. {
  141. return QLatin1String("1.3+git");
  142. }
  143. QVariantMap update(Project *project, const QVariantMap &map);
  144. private:
  145. struct TargetDescription
  146. {
  147. TargetDescription(QString tid, QString dn) :
  148. id(tid),
  149. displayName(dn)
  150. {
  151. }
  152. TargetDescription(const TargetDescription &td) :
  153. id(td.id),
  154. displayName(td.displayName)
  155. {
  156. }
  157. QString id;
  158. QString displayName;
  159. };
  160. };
  161. // Version 2 is used in master post Qt Creator 2.0 alpha.
  162. class Version2Handler : public UserFileVersionHandler
  163. {
  164. public:
  165. int userFileVersion() const
  166. {
  167. return 2;
  168. }
  169. QString displayUserFileVersion() const
  170. {
  171. return QLatin1String("2.0-alpha+git");
  172. }
  173. QVariantMap update(Project *project, const QVariantMap &map);
  174. };
  175. // Version 3 reflect the move of symbian signing from run to build step.
  176. class Version3Handler : public UserFileVersionHandler
  177. {
  178. public:
  179. int userFileVersion() const
  180. {
  181. return 3;
  182. }
  183. QString displayUserFileVersion() const
  184. {
  185. return QLatin1String("2.0-alpha2+git");
  186. }
  187. QVariantMap update(Project *project, const QVariantMap &map);
  188. };
  189. // Version 4 reflects the introduction of deploy steps
  190. class Version4Handler : public UserFileVersionHandler
  191. {
  192. public:
  193. int userFileVersion() const
  194. {
  195. return 4;
  196. }
  197. QString displayUserFileVersion() const
  198. {
  199. return QLatin1String("2.1pre1");
  200. }
  201. QVariantMap update(Project *project, const QVariantMap &map);
  202. };
  203. // Version 5 reflects the introduction of new deploy steps for Symbian/Maemo
  204. class Version5Handler : public UserFileVersionHandler
  205. {
  206. public:
  207. int userFileVersion() const
  208. {
  209. return 5;
  210. }
  211. QString displayUserFileVersion() const
  212. {
  213. return QLatin1String("2.1pre2");
  214. }
  215. QVariantMap update(Project *project, const QVariantMap &map);
  216. };
  217. // Version 6 reflects the introduction of new deploy steps for Symbian/Maemo
  218. class Version6Handler : public UserFileVersionHandler
  219. {
  220. public:
  221. int userFileVersion() const
  222. {
  223. return 6;
  224. }
  225. QString displayUserFileVersion() const
  226. {
  227. return QLatin1String("2.1pre3");
  228. }
  229. QVariantMap update(Project *project, const QVariantMap &map);
  230. };
  231. // Version 7 reflects the introduction of new deploy configuration for Symbian
  232. class Version7Handler : public UserFileVersionHandler
  233. {
  234. public:
  235. int userFileVersion() const
  236. {
  237. return 7;
  238. }
  239. QString displayUserFileVersion() const
  240. {
  241. return QLatin1String("2.1pre4");
  242. }
  243. QVariantMap update(Project *project, const QVariantMap &map);
  244. };
  245. // Version 8 reflects the change of environment variable expansion rules,
  246. // turning some env variables into expandos, the change of argument quoting rules,
  247. // and the change of VariableManager's expansion syntax.
  248. class Version8Handler : public UserFileVersionHandler
  249. {
  250. public:
  251. int userFileVersion() const
  252. {
  253. return 8;
  254. }
  255. QString displayUserFileVersion() const
  256. {
  257. // pre5 because we renamed 2.2 to 2.1 later, so people already have 2.2pre4 files
  258. return QLatin1String("2.2pre5");
  259. }
  260. QVariantMap update(Project *project, const QVariantMap &map);
  261. };
  262. // Version 9 reflects the refactoring of the Maemo deploy step.
  263. class Version9Handler : public UserFileVersionHandler
  264. {
  265. public:
  266. int userFileVersion() const
  267. {
  268. return 9;
  269. }
  270. QString displayUserFileVersion() const
  271. {
  272. return QLatin1String("2.3pre1");
  273. }
  274. QVariantMap update(Project *project, const QVariantMap &map);
  275. };
  276. // Version 10 introduces disabling buildsteps, and handles upgrading custom process steps
  277. class Version10Handler : public UserFileVersionHandler
  278. {
  279. public:
  280. int userFileVersion() const
  281. {
  282. return 10;
  283. }
  284. QString displayUserFileVersion() const
  285. {
  286. return QLatin1String("2.5pre1");
  287. }
  288. QVariantMap update(Project *project, const QVariantMap &map);
  289. };
  290. // Version 10 introduces disabling buildsteps, and handles upgrading custom process steps
  291. class Version11Handler : public UserFileVersionHandler
  292. {
  293. public:
  294. Version11Handler();
  295. ~Version11Handler();
  296. int userFileVersion() const
  297. {
  298. return 11;
  299. }
  300. QString displayUserFileVersion() const
  301. {
  302. return QLatin1String("2.6pre1");
  303. }
  304. QVariantMap update(Project *project, const QVariantMap &map);
  305. private:
  306. void addBuildConfiguration(const QString &origTarget, Profile *p,
  307. bool targetActive,
  308. const QVariantMap &bc, bool bcActive);
  309. void addOtherConfiguration(const QString &origTarget,
  310. const QList<QVariantMap> &dcs, int activeDc,
  311. const QList<QVariantMap> &rcs, int activeRc, const QString &projectDir);
  312. void parseQtversionFile();
  313. void parseToolChainFile();
  314. class ToolChainExtraData {
  315. public:
  316. explicit ToolChainExtraData(const QString &mks = QString(), const QString &d = QString()) :
  317. m_mkspec(mks), m_debugger(d)
  318. { }
  319. QString m_mkspec;
  320. QString m_debugger;
  321. };
  322. QHash<QString, ToolChainExtraData> m_toolChainExtras;
  323. QHash<int, QString> m_qtVersionExtras;
  324. QHash<Profile *, QVariantMap> m_targets;
  325. };
  326. } // namespace
  327. //
  328. // Helper functions:
  329. //
  330. QT_BEGIN_NAMESPACE
  331. class HandlerNode
  332. {
  333. public:
  334. QSet<QString> strings;
  335. QHash<QString, HandlerNode> children;
  336. };
  337. Q_DECLARE_TYPEINFO(HandlerNode, Q_MOVABLE_TYPE);
  338. QT_END_NAMESPACE
  339. static HandlerNode buildHandlerNodes(const char * const **keys)
  340. {
  341. HandlerNode ret;
  342. while (const char *rname = *(*keys)++) {
  343. QString name = QLatin1String(rname);
  344. if (name.endsWith(QLatin1Char('.'))) {
  345. HandlerNode sub = buildHandlerNodes(keys);
  346. foreach (const QString &key, name.split(QLatin1Char('|')))
  347. ret.children.insert(key, sub);
  348. } else {
  349. ret.strings.insert(name);
  350. }
  351. }
  352. return ret;
  353. }
  354. static QVariantMap processHandlerNodes(const HandlerNode &node, const QVariantMap &map,
  355. QVariant (*handler)(const QVariant &var))
  356. {
  357. QVariantMap result;
  358. QMapIterator<QString, QVariant> it(map);
  359. while (it.hasNext()) {
  360. it.next();
  361. const QString &key = it.key();
  362. if (node.strings.contains(key)) {
  363. result.insert(key, handler(it.value()));
  364. goto handled;
  365. }
  366. if (it.value().type() == QVariant::Map)
  367. for (QHash<QString, HandlerNode>::ConstIterator subit = node.children.constBegin();
  368. subit != node.children.constEnd(); ++subit)
  369. if (key.startsWith(subit.key())) {
  370. result.insert(key, processHandlerNodes(subit.value(), it.value().toMap(), handler));
  371. goto handled;
  372. }
  373. result.insert(key, it.value());
  374. handled: ;
  375. }
  376. return result;
  377. }
  378. // -------------------------------------------------------------------------
  379. // UserFileAccessor
  380. // -------------------------------------------------------------------------
  381. SettingsAccessor::SettingsAccessor() :
  382. m_firstVersion(-1),
  383. m_lastVersion(-1),
  384. m_userFileAcessor(QByteArray("qtcUserFileName"),
  385. QLatin1String(".user"),
  386. QString::fromLocal8Bit(qgetenv("QTC_EXTENSION")),
  387. true,
  388. true),
  389. m_sharedFileAcessor(QByteArray("qtcSharedFileName"),
  390. QLatin1String(".shared"),
  391. QString::fromLocal8Bit(qgetenv("QTC_SHARED_EXTENSION")),
  392. false,
  393. false)
  394. {
  395. addVersionHandler(new Version0Handler);
  396. addVersionHandler(new Version1Handler);
  397. addVersionHandler(new Version2Handler);
  398. addVersionHandler(new Version3Handler);
  399. addVersionHandler(new Version4Handler);
  400. addVersionHandler(new Version5Handler);
  401. addVersionHandler(new Version6Handler);
  402. addVersionHandler(new Version7Handler);
  403. addVersionHandler(new Version8Handler);
  404. addVersionHandler(new Version9Handler);
  405. addVersionHandler(new Version10Handler);
  406. addVersionHandler(new Version11Handler);
  407. }
  408. SettingsAccessor::~SettingsAccessor()
  409. {
  410. qDeleteAll(m_handlers);
  411. }
  412. SettingsAccessor *SettingsAccessor::instance()
  413. {
  414. static SettingsAccessor acessor;
  415. return &acessor;
  416. }
  417. namespace {
  418. // It's assumed that the shared map has the same structure as the user map.
  419. template <class Operation_T>
  420. void synchronizeSettings(QVariantMap *userMap,
  421. const QVariantMap &sharedMap,
  422. Operation_T *op)
  423. {
  424. QVariantMap::const_iterator it = sharedMap.begin();
  425. QVariantMap::const_iterator eit = sharedMap.end();
  426. for (; it != eit; ++it) {
  427. const QString &key = it.key();
  428. const QVariant &sharedValue = it.value();
  429. const QVariant &userValue = userMap->value(key);
  430. if (sharedValue.type() == QVariant::Map) {
  431. if (userValue.type() != QVariant::Map) {
  432. // This should happen only if the user manually changed the file in such a way.
  433. continue;
  434. }
  435. QVariantMap nestedUserMap = userValue.toMap();
  436. synchronizeSettings(&nestedUserMap,
  437. sharedValue.toMap(),
  438. op);
  439. userMap->insert(key, nestedUserMap);
  440. } else if (userMap->contains(key) && userValue != sharedValue) {
  441. op->apply(userMap, key, sharedValue);
  442. }
  443. }
  444. }
  445. struct MergeSharedSetting
  446. {
  447. MergeSharedSetting(const QSet<QString> &sticky) : m_userSticky(sticky) {}
  448. void apply(QVariantMap *userMap, const QString &key, const QVariant &sharedValue)
  449. {
  450. if (!m_userSticky.contains(key))
  451. userMap->insert(key, sharedValue);
  452. }
  453. QSet<QString> m_userSticky;
  454. };
  455. // When restoring settings...
  456. // We check whether a .shared file exists. If so, we compare the settings in this file with
  457. // corresponding ones in the .user file. Whenever we identify a corresponding setting which
  458. // has a different value and which is not marked as sticky, we merge the .shared value into
  459. // the .user value.
  460. void mergeSharedSettings(QVariantMap *userMap, const QVariantMap &sharedMap)
  461. {
  462. if (sharedMap.isEmpty())
  463. return;
  464. QSet<QString> stickyKeys;
  465. const QVariant stickyList = userMap->take(QLatin1String(USER_STICKY_KEYS_KEY)).toList();
  466. if (stickyList.isValid()) {
  467. if (stickyList.type() != QVariant::List) {
  468. // File is messed up... The user probably changed something.
  469. return;
  470. }
  471. foreach (const QVariant &v, stickyList.toList())
  472. stickyKeys.insert(v.toString());
  473. }
  474. MergeSharedSetting op(stickyKeys);
  475. synchronizeSettings(userMap, sharedMap, &op);
  476. }
  477. struct TrackUserStickySetting
  478. {
  479. void apply(QVariantMap *, const QString &key, const QVariant &)
  480. {
  481. m_userSticky.insert(key);
  482. }
  483. QSet<QString> m_userSticky;
  484. };
  485. // When saving settings...
  486. // If a .shared file was considered in the previous restoring step, we check whether for
  487. // any of the current .shared settings there's a .user one which is different. If so, this
  488. // means the user explicitly changed it and we mark this setting as sticky.
  489. // Note that settings are considered sticky only when they differ from the .shared ones.
  490. // Although this approach is more flexible than permanent/forever sticky settings, it has
  491. // the side-effect that if a particular value unintentionally becomes the same in both
  492. // the .user and .shared files, this setting will "unstick".
  493. void trackUserStickySettings(QVariantMap *userMap, const QVariantMap &sharedMap)
  494. {
  495. if (sharedMap.isEmpty())
  496. return;
  497. TrackUserStickySetting op;
  498. synchronizeSettings(userMap, sharedMap, &op);
  499. userMap->insert(QLatin1String(USER_STICKY_KEYS_KEY), QVariant(op.m_userSticky.toList()));
  500. }
  501. } // Anonymous
  502. QVariantMap SettingsAccessor::restoreSettings(Project *project) const
  503. {
  504. if (m_lastVersion < 0 || !project)
  505. return QVariantMap();
  506. SettingsData settings;
  507. if (!m_userFileAcessor.readFile(project, &settings))
  508. settings.clear(); // No user settings, but there can still be shared ones.
  509. if (settings.isValid()) {
  510. if (settings.m_version > SettingsAccessor::instance()->m_lastVersion + 1) {
  511. QMessageBox::information(
  512. Core::ICore::mainWindow(),
  513. QApplication::translate("ProjectExplorer::SettingsAccessor",
  514. "Using Old Project Settings File"),
  515. QApplication::translate("ProjectExplorer::SettingsAccessor",
  516. "<html><head/><body><p>A versioned backup of the .user "
  517. "settings file will be used, because the non-versioned "
  518. "file was created by an incompatible newer version of "
  519. "Qt Creator.</p><p>Project settings changes made since "
  520. "the last time this version of Qt Creator was used "
  521. "with this project are ignored, and changes made now "
  522. "will <b>not</b> be propagated to the newer version."
  523. "</p></body></html>"),
  524. QMessageBox::Ok);
  525. }
  526. // Verify environment.
  527. if (!verifyEnvironmentId(settings.m_map.value(QLatin1String(ENVIRONMENT_ID_KEY)).toString())) {
  528. // TODO tr, casing check
  529. QMessageBox msgBox(
  530. QMessageBox::Question,
  531. QApplication::translate("ProjectExplorer::SettingsAccessor",
  532. "Project Settings File from a different Environment?"),
  533. QApplication::translate("ProjectExplorer::SettingsAccessor",
  534. "Qt Creator has found a .user settings file which was "
  535. "created for another development setup, maybe "
  536. "originating from another machine.\n\n"
  537. "The .user settings files contain environment specific "
  538. "settings. They should not be copied to a different "
  539. "environment. \n\n"
  540. "Do you still want to load the settings file?"),
  541. QMessageBox::Yes | QMessageBox::No,
  542. Core::ICore::mainWindow());
  543. msgBox.setDefaultButton(QMessageBox::No);
  544. msgBox.setEscapeButton(QMessageBox::No);
  545. if (msgBox.exec() == QMessageBox::No)
  546. return QVariantMap();
  547. }
  548. // Do we need to generate a backup?
  549. if (settings.m_version < m_lastVersion + 1 && !settings.m_usingBackup) {
  550. const QString &backupFileName = settings.m_fileName
  551. + QLatin1Char('.')
  552. + m_handlers.value(settings.m_version)->displayUserFileVersion();
  553. QFile::remove(backupFileName); // Remove because copy doesn't overwrite
  554. QFile::copy(settings.m_fileName, backupFileName);
  555. }
  556. }
  557. // Time to consider shared settings...
  558. SettingsData sharedSettings;
  559. if (m_sharedFileAcessor.readFile(project, &sharedSettings)) {
  560. bool useSharedSettings = true;
  561. if (sharedSettings.m_version != settings.m_version) {
  562. int baseFileVersion;
  563. if (sharedSettings.m_version > m_lastVersion + 1) {
  564. // The shared file version is newer than Creator... If we have valid user
  565. // settings we prompt the user whether we could try an *unsupported* update.
  566. // This makes sense since the merging operation will only replace shared settings
  567. // that perfectly match corresponding user ones. If we don't have valid user
  568. // settings to compare against, there's nothing we can do.
  569. if (!settings.isValid())
  570. return QVariantMap();
  571. QMessageBox msgBox(
  572. QMessageBox::Question,
  573. QApplication::translate("ProjectExplorer::SettingsAccessor",
  574. "Unsupported Shared Settings File"),
  575. QApplication::translate("ProjectExplorer::SettingsAccessor",
  576. "The version of your .shared file is not yet "
  577. "supported by this Qt Creator version. "
  578. "Only settings that are still compatible "
  579. "will be taken into account.\n\n"
  580. "Do you want to continue?\n\n"
  581. "If you choose not to continue Qt Creator will "
  582. "not try to load the .shared file."),
  583. QMessageBox::Yes | QMessageBox::No,
  584. Core::ICore::mainWindow());
  585. msgBox.setDefaultButton(QMessageBox::No);
  586. msgBox.setEscapeButton(QMessageBox::No);
  587. if (msgBox.exec() == QMessageBox::No)
  588. useSharedSettings = false;
  589. else
  590. baseFileVersion = m_lastVersion + 1;
  591. } else {
  592. baseFileVersion = qMax(settings.m_version, sharedSettings.m_version);
  593. }
  594. if (useSharedSettings) {
  595. // We now update the user and shared settings so they are compatible.
  596. for (int i = sharedSettings.m_version; i < baseFileVersion; ++i)
  597. sharedSettings.m_map = m_handlers.value(i)->update(project, sharedSettings.m_map);
  598. if (!settings.isValid()) {
  599. project->setProperty(SHARED_SETTINGS, sharedSettings.m_map);
  600. return sharedSettings.m_map;
  601. }
  602. for (int i = settings.m_version; i < baseFileVersion; ++i)
  603. settings.m_map = m_handlers.value(i)->update(project, settings.m_map);
  604. settings.m_version = baseFileVersion;
  605. }
  606. }
  607. if (useSharedSettings) {
  608. project->setProperty(SHARED_SETTINGS, sharedSettings.m_map);
  609. if (!settings.isValid())
  610. return sharedSettings.m_map;
  611. mergeSharedSettings(&settings.m_map, sharedSettings.m_map);
  612. }
  613. }
  614. if (!settings.isValid())
  615. return QVariantMap();
  616. // Update from the base version to Creator's version.
  617. for (int i = settings.m_version; i <= m_lastVersion; ++i)
  618. settings.m_map = m_handlers.value(i)->update(project, settings.m_map);
  619. return settings.m_map;
  620. }
  621. bool SettingsAccessor::saveSettings(const Project *project, const QVariantMap &map) const
  622. {
  623. if (!project || map.isEmpty())
  624. return false;
  625. SettingsData settings(map);
  626. const QVariant &shared = project->property(SHARED_SETTINGS);
  627. if (shared.isValid())
  628. trackUserStickySettings(&settings.m_map, shared.toMap());
  629. return m_userFileAcessor.writeFile(project, &settings);
  630. }
  631. void SettingsAccessor::addVersionHandler(UserFileVersionHandler *handler)
  632. {
  633. const int version(handler->userFileVersion());
  634. QTC_ASSERT(handler, return);
  635. QTC_ASSERT(version >= 0, return);
  636. QTC_ASSERT(!m_handlers.contains(version), return);
  637. QTC_ASSERT(m_handlers.isEmpty() ||
  638. (version == m_lastVersion + 1 || version == m_firstVersion - 1), return);
  639. if (m_handlers.isEmpty()) {
  640. m_firstVersion = version;
  641. m_lastVersion = version;
  642. } else {
  643. if (version < m_firstVersion)
  644. m_firstVersion = version;
  645. if (version > m_lastVersion)
  646. m_lastVersion = version;
  647. }
  648. m_handlers.insert(version, handler);
  649. // Postconditions:
  650. Q_ASSERT(m_lastVersion >= 0);
  651. Q_ASSERT(m_firstVersion >= 0);
  652. Q_ASSERT(m_lastVersion >= m_firstVersion);
  653. Q_ASSERT(m_handlers.count() == m_lastVersion - m_firstVersion + 1);
  654. for (int i = m_firstVersion; i < m_lastVersion; ++i)
  655. Q_ASSERT(m_handlers.contains(i));
  656. }
  657. bool SettingsAccessor::verifyEnvironmentId(const QString &id)
  658. {
  659. QUuid fileEnvironmentId(id);
  660. if (!fileEnvironmentId.isNull()
  661. && fileEnvironmentId
  662. != ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId) {
  663. return false;
  664. }
  665. return true;
  666. }
  667. // -------------------------------------------------------------------------
  668. // SettingsData
  669. // -------------------------------------------------------------------------
  670. void SettingsAccessor::SettingsData::clear()
  671. {
  672. m_version = -1;
  673. m_usingBackup = false;
  674. m_map.clear();
  675. m_fileName.clear();
  676. }
  677. bool SettingsAccessor::SettingsData::isValid() const
  678. {
  679. return m_version > -1 && !m_fileName.isEmpty();
  680. }
  681. // -------------------------------------------------------------------------
  682. // FileAcessor
  683. // -------------------------------------------------------------------------
  684. SettingsAccessor::FileAccessor::FileAccessor(const QByteArray &id,
  685. const QString &defaultSuffix,
  686. const QString &environmentSuffix,
  687. bool envSpecific,
  688. bool versionStrict)
  689. : m_id(id)
  690. , m_environmentSpecific(envSpecific)
  691. , m_versionStrict(versionStrict)
  692. {
  693. assignSuffix(defaultSuffix, environmentSuffix);
  694. }
  695. void SettingsAccessor::FileAccessor::assignSuffix(const QString &defaultSuffix,
  696. const QString &environmentSuffix)
  697. {
  698. if (!environmentSuffix.isEmpty()) {
  699. m_suffix = environmentSuffix;
  700. m_suffix.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_.-]")), QString(QLatin1Char('_'))); // replace fishy characters:
  701. m_suffix.prepend(QLatin1Char('.'));
  702. } else {
  703. m_suffix = defaultSuffix;
  704. }
  705. }
  706. QString SettingsAccessor::FileAccessor::assembleFileName(const Project *project) const
  707. {
  708. return project->document()->fileName() + m_suffix;
  709. }
  710. bool SettingsAccessor::FileAccessor::findNewestCompatibleSetting(SettingsData *settings) const
  711. {
  712. const QString baseFileName = settings->m_fileName;
  713. const int baseVersion = settings->m_version;
  714. settings->m_fileName.clear();
  715. settings->m_version = -1;
  716. PersistentSettingsReader reader;
  717. SettingsAccessor *acessor = SettingsAccessor::instance();
  718. QFileInfo fileInfo(baseFileName);
  719. QStringList fileNameFilter(fileInfo.fileName() + QLatin1String(".*"));
  720. const QStringList &entryList = fileInfo.absoluteDir().entryList(fileNameFilter);
  721. QStringList candidates;
  722. // First we try to identify the newest old version with a quick check.
  723. foreach (const QString &file, entryList) {
  724. const QString &suffix = file.mid(fileInfo.fileName().length() + 1);
  725. const QString &candidateFileName = baseFileName + QLatin1String(".") + suffix;
  726. candidates.append(candidateFileName);
  727. for (int candidateVersion = acessor->m_lastVersion;
  728. candidateVersion >= acessor->m_firstVersion;
  729. --candidateVersion) {
  730. if (suffix == acessor->m_handlers.value(candidateVersion)->displayUserFileVersion()) {
  731. if (candidateVersion > settings->m_version) {
  732. settings->m_version = candidateVersion;
  733. settings->m_fileName = candidateFileName;
  734. }
  735. break;
  736. }
  737. }
  738. }
  739. if (settings->m_version != -1) {
  740. if (reader.load(settings->m_fileName)) {
  741. settings->m_map = reader.restoreValues();
  742. return true;
  743. }
  744. qWarning() << "Unable to load file" << settings->m_fileName;
  745. }
  746. // If we haven't identified a valid file or if it for any reason failed to load, we
  747. // try a more expensive check (which is actually needed to identify our own and newer
  748. // versions as we don't know what extensions will be assigned in the future).
  749. foreach (const QString &candidateFileName, candidates) {
  750. if (settings->m_fileName == candidateFileName)
  751. continue; // This one has already failed to load.
  752. if (reader.load(candidateFileName)) {
  753. settings->m_map = reader.restoreValues();
  754. int candidateVersion = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
  755. if (candidateVersion == acessor->m_lastVersion + 1) {
  756. settings->m_version = candidateVersion;
  757. settings->m_fileName = candidateFileName;
  758. return true;
  759. }
  760. }
  761. }
  762. // Nothing really worked...
  763. qWarning() << "File version" << baseVersion << "too new.";
  764. return false;
  765. }
  766. bool SettingsAccessor::FileAccessor::readFile(Project *project,
  767. SettingsData *settings) const
  768. {
  769. PersistentSettingsReader reader;
  770. settings->m_fileName = assembleFileName(project);
  771. if (!reader.load(settings->m_fileName))
  772. return false;
  773. settings->m_map = reader.restoreValues();
  774. // Get and verify file version
  775. settings->m_version = settings->m_map.value(QLatin1String(VERSION_KEY), 0).toInt();
  776. if (!m_versionStrict)
  777. return true;
  778. if (settings->m_version < SettingsAccessor::instance()->m_firstVersion) {
  779. qWarning() << "Version" << settings->m_version << "in" << m_suffix << "too old.";
  780. return false;
  781. }
  782. if (settings->m_version > SettingsAccessor::instance()->m_lastVersion + 1) {
  783. if (!findNewestCompatibleSetting(settings))
  784. return false;
  785. settings->m_usingBackup = true;
  786. project->setProperty(m_id.constData(), settings->m_fileName);
  787. }
  788. return true;
  789. }
  790. bool SettingsAccessor::FileAccessor::writeFile(const Project *project,
  791. const SettingsData *settings) const
  792. {
  793. PersistentSettingsWriter writer;
  794. for (QVariantMap::const_iterator i = settings->m_map.constBegin();
  795. i != settings->m_map.constEnd();
  796. ++i) {
  797. writer.saveValue(i.key(), i.value());
  798. }
  799. writer.saveValue(QLatin1String(VERSION_KEY), SettingsAccessor::instance()->m_lastVersion + 1);
  800. if (m_environmentSpecific) {
  801. writer.saveValue(QLatin1String(ENVIRONMENT_ID_KEY),
  802. ProjectExplorerPlugin::instance()->projectExplorerSettings().environmentId.toString());
  803. }
  804. const QString &fileName = project->property(m_id).toString();
  805. return writer.save(fileName.isEmpty() ? assembleFileName(project) : fileName,
  806. QLatin1String("QtCreatorProject"),
  807. Core::ICore::mainWindow());
  808. }
  809. // -------------------------------------------------------------------------
  810. // Version0Handler
  811. // -------------------------------------------------------------------------
  812. QVariantMap Version0Handler::convertBuildConfigurations(Project *project, const QVariantMap &map)
  813. {
  814. Q_ASSERT(project);
  815. QVariantMap result;
  816. // Find a valid Id to use:
  817. QString id;
  818. if (project->id() == Core::Id("GenericProjectManager.GenericProject")) {
  819. id = QLatin1String("GenericProjectManager.GenericBuildConfiguration");
  820. } else if (project->id() == Core::Id("CMakeProjectManager.CMakeProject")) {
  821. id = QLatin1String("CMakeProjectManager.CMakeBuildConfiguration");
  822. } else if (project->id() == Core::Id("Qt4ProjectManager.Qt4Project")) {
  823. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.NeedsV0Update"), QVariant());
  824. id = QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration");
  825. } else {
  826. return QVariantMap(); // QmlProjects do not(/no longer) have BuildConfigurations,
  827. // or we do not know how to handle this.
  828. }
  829. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
  830. for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
  831. if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName")) {
  832. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"),
  833. i.value());
  834. continue;
  835. }
  836. if (id == QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration") ||
  837. id.startsWith(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration."))) {
  838. // Qt4BuildConfiguration:
  839. if (i.key() == QLatin1String("QtVersionId")) {
  840. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId"),
  841. i.value().toInt());
  842. } else if (i.key() == QLatin1String("ToolChain")) {
  843. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ToolChain"),
  844. i.value());
  845. } else if (i.key() == QLatin1String("buildConfiguration")) {
  846. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration"),
  847. i.value());
  848. } else if (i.key() == QLatin1String("userEnvironmentChanges")) {
  849. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UserEnvironmentChanges"),
  850. i.value());
  851. } else if (i.key() == QLatin1String("useShadowBuild")) {
  852. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild"),
  853. i.value());
  854. } else if (i.key() == QLatin1String("clearSystemEnvironment")) {
  855. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.ClearSystemEnvironment"),
  856. i.value());
  857. } else if (i.key() == QLatin1String("buildDirectory")) {
  858. result.insert(QLatin1String("Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory"),
  859. i.value());
  860. } else {
  861. qWarning() << "Unknown Qt4BuildConfiguration Key found:" << i.key() << i.value();
  862. }
  863. continue;
  864. } else if (id == QLatin1String("CMakeProjectManager.CMakeBuildConfiguration")) {
  865. if (i.key() == QLatin1String("userEnvironmentChanges")) {
  866. result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.UserEnvironmentChanges"),
  867. i.value());
  868. } else if (i.key() == QLatin1String("msvcVersion")) {
  869. result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.MsvcVersion"),
  870. i.value());
  871. } else if (i.key() == QLatin1String("buildDirectory")) {
  872. result.insert(QLatin1String("CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory"),
  873. i.value());
  874. } else {
  875. qWarning() << "Unknown CMakeBuildConfiguration Key found:" << i.key() << i.value();
  876. }
  877. continue;
  878. } else if (id == QLatin1String("GenericProjectManager.GenericBuildConfiguration")) {
  879. if (i.key() == QLatin1String("buildDirectory")) {
  880. result.insert(QLatin1String("GenericProjectManager.GenericBuildConfiguration.BuildDirectory"),
  881. i.value());
  882. } else {
  883. qWarning() << "Unknown GenericBuildConfiguration Key found:" << i.key() << i.value();
  884. }
  885. continue;
  886. }
  887. qWarning() << "Unknown BuildConfiguration Key found:" << i.key() << i.value();
  888. qWarning() << "BuildConfiguration Id is:" << id;
  889. }
  890. return result;
  891. }
  892. QVariantMap Version0Handler::convertRunConfigurations(Project *project, const QVariantMap &map)
  893. {
  894. Q_UNUSED(project);
  895. QVariantMap result;
  896. QString id;
  897. // Convert Id:
  898. id = map.value(QLatin1String("Id")).toString();
  899. if (id.isEmpty())
  900. id = map.value(QLatin1String("type")).toString();
  901. if (id.isEmpty())
  902. return QVariantMap();
  903. if (QLatin1String("Qt4ProjectManager.DeviceRunConfiguration") == id)
  904. id = QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration");
  905. if (QLatin1String("Qt4ProjectManager.EmulatorRunConfiguration") == id)
  906. id = QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration");
  907. // no need to change the CMakeRunConfiguration, CustomExecutableRunConfiguration,
  908. // MaemoRunConfiguration or Qt4RunConfiguration
  909. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
  910. // Convert everything else:
  911. for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
  912. if (i.key() == QLatin1String("Id") || i.key() == QLatin1String("type"))
  913. continue;
  914. if (i.key() == QLatin1String("RunConfiguration.name")) {
  915. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"),
  916. i.value());
  917. } else if (QLatin1String("CMakeProjectManager.CMakeRunConfiguration") == id) {
  918. if (i.key() == QLatin1String("CMakeRunConfiguration.Target"))
  919. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.Target"), i.value());
  920. else if (i.key() == QLatin1String("CMakeRunConfiguration.WorkingDirectory"))
  921. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.WorkingDirectory"), i.value());
  922. else if (i.key() == QLatin1String("CMakeRunConfiguration.UserWorkingDirectory"))
  923. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"), i.value());
  924. else if (i.key() == QLatin1String("CMakeRunConfiguration.UseTerminal"))
  925. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UseTerminal"), i.value());
  926. else if (i.key() == QLatin1String("CMakeRunConfiguation.Title"))
  927. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguation.Title"), i.value());
  928. else if (i.key() == QLatin1String("CMakeRunConfiguration.Arguments"))
  929. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.Arguments"), i.value());
  930. else if (i.key() == QLatin1String("CMakeRunConfiguration.UserEnvironmentChanges"))
  931. result.insert(QLatin1String("CMakeProjectManager.CMakeRunConfiguration.UserEnvironmentChanges"), i.value());
  932. else if (i.key() == QLatin1String("BaseEnvironmentBase"))
  933. result.insert(QLatin1String("CMakeProjectManager.BaseEnvironmentBase"), i.value());
  934. else
  935. qWarning() << "Unknown CMakeRunConfiguration key found:" << i.key() << i.value();
  936. } else if (QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration") == id) {
  937. if (i.key() == QLatin1String("ProFile"))
  938. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.ProFile"), i.value());
  939. else if (i.key() == QLatin1String("SigningMode"))
  940. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.SigningMode"), i.value());
  941. else if (i.key() == QLatin1String("CustomSignaturePath"))
  942. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CustomSignaturePath"), i.value());
  943. else if (i.key() == QLatin1String("CustomKeyPath"))
  944. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CustomKeyPath"), i.value());
  945. else if (i.key() == QLatin1String("SerialPortName"))
  946. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.SerialPortName"), i.value());
  947. else if (i.key() == QLatin1String("CommunicationType"))
  948. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CommunicationType"), i.value());
  949. else if (i.key() == QLatin1String("CommandLineArguments"))
  950. result.insert(QLatin1String("Qt4ProjectManager.S60DeviceRunConfiguration.CommandLineArguments"), i.value());
  951. else
  952. qWarning() << "Unknown S60DeviceRunConfiguration key found:" << i.key() << i.value();
  953. } else if (QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration") == id) {
  954. if (i.key() == QLatin1String("ProFile"))
  955. result.insert(QLatin1String("Qt4ProjectManager.S60EmulatorRunConfiguration.ProFile"), i.value());
  956. else
  957. qWarning() << "Unknown S60EmulatorRunConfiguration key found:" << i.key() << i.value();
  958. } else if (QLatin1String("Qt4ProjectManager.Qt4RunConfiguration") == id) {
  959. if (i.key() == QLatin1String("ProFile"))
  960. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.ProFile"), i.value());
  961. else if (i.key() == QLatin1String("CommandLineArguments"))
  962. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"), i.value());
  963. else if (i.key() == QLatin1String("UserSetName"))
  964. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserSetName"), i.value());
  965. else if (i.key() == QLatin1String("UseTerminal"))
  966. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UseTerminal"), i.value());
  967. else if (i.key() == QLatin1String("UseDyldImageSuffix"))
  968. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix"), i.value());
  969. else if (i.key() == QLatin1String("UserEnvironmentChanges"))
  970. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges"), i.value());
  971. else if (i.key() == QLatin1String("BaseEnvironmentBase"))
  972. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase"), i.value());
  973. else if (i.key() == QLatin1String("UserSetWorkingDirectory"))
  974. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory"), i.value());
  975. else if (i.key() == QLatin1String("UserWorkingDirectory"))
  976. result.insert(QLatin1String("Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"), i.value());
  977. else
  978. qWarning() << "Unknown Qt4RunConfiguration key found:" << i.key() << i.value();
  979. } else if (QLatin1String("Qt4ProjectManager.MaemoRunConfiguration") == id) {
  980. if (i.key() == QLatin1String("ProFile"))
  981. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.ProFile"), i.value());
  982. else if (i.key() == QLatin1String("Arguments"))
  983. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Arguments"), i.value());
  984. else if (i.key() == QLatin1String("Simulator"))
  985. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.Simulator"), i.value());
  986. else if (i.key() == QLatin1String("DeviceId"))
  987. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DeviceId"), i.value());
  988. else if (i.key() == QLatin1String("LastDeployed"))
  989. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.LastDeployed"), i.value());
  990. else if (i.key() == QLatin1String("DebuggingHelpersLastDeployed"))
  991. result.insert(QLatin1String("Qt4ProjectManager.MaemoRunConfiguration.DebuggingHelpersLastDeployed"), i.value());
  992. else
  993. qWarning() << "Unknown MaemoRunConfiguration key found:" << i.key() << i.value();
  994. } else if (QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration") == id) {
  995. if (i.key() == QLatin1String("Executable"))
  996. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.Executable"), i.value());
  997. else if (i.key() == QLatin1String("Arguments"))
  998. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.Arguments"), i.value());
  999. else if (i.key() == QLatin1String("WorkingDirectory"))
  1000. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory"), i.value());
  1001. else if (i.key() == QLatin1String("UseTerminal"))
  1002. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal"), i.value());
  1003. else if (i.key() == QLatin1String("UserSetName"))
  1004. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserSetName"), i.value());
  1005. else if (i.key() == QLatin1String("UserName"))
  1006. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserName"), i.value());
  1007. else if (i.key() == QLatin1String("UserEnvironmentChanges"))
  1008. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges"), i.value());
  1009. else if (i.key() == QLatin1String("BaseEnvironmentBase"))
  1010. result.insert(QLatin1String("ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase"), i.value());
  1011. else
  1012. qWarning() << "Unknown CustomExecutableRunConfiguration key found:" << i.key() << i.value();
  1013. } else {
  1014. result.insert(i.key(), i.value());
  1015. }
  1016. }
  1017. return result;
  1018. }
  1019. QVariantMap Version0Handler::convertBuildSteps(Project *project, const QVariantMap &map)
  1020. {
  1021. Q_UNUSED(project);
  1022. QVariantMap result;
  1023. QString id(map.value(QLatin1String("Id")).toString());
  1024. if (QLatin1String("GenericProjectManager.MakeStep") == id)
  1025. id = QLatin1String("GenericProjectManager.GenericMakeStep");
  1026. if (QLatin1String("projectexplorer.processstep") == id)
  1027. id = QLatin1String("ProjectExplorer.ProcessStep");
  1028. if (QLatin1String("trolltech.qt4projectmanager.make") == id)
  1029. id = QLatin1String("Qt4ProjectManager.MakeStep");
  1030. if (QLatin1String("trolltech.qt4projectmanager.qmake") == id)
  1031. id = QLatin1String("QtProjectManager.QMakeBuildStep");
  1032. // No need to change the CMake MakeStep.
  1033. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.Id"), id);
  1034. for (QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i) {
  1035. if (i.key() == QLatin1String("Id"))
  1036. continue;
  1037. if (i.key() == QLatin1String("ProjectExplorer.BuildConfiguration.DisplayName")) {
  1038. // skip this: Not needed.
  1039. continue;
  1040. }
  1041. if (QLatin1String("GenericProjectManager.GenericMakeStep") == id) {
  1042. if (i.key() == QLatin1String("buildTargets"))
  1043. result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.BuildTargets"), i.value());
  1044. else if (i.key() == QLatin1String("makeArguments"))
  1045. result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.MakeArguments"), i.value());
  1046. else if (i.key() == QLatin1String("makeCommand"))
  1047. result.insert(QLatin1String("GenericProjectManager.GenericMakeStep.MakeCommand"), i.value());
  1048. else
  1049. qWarning() << "Unknown GenericMakeStep value found:" << i.key() << i.value();
  1050. continue;
  1051. } else if (QLatin1String("ProjectExplorer.ProcessStep") == id) {
  1052. if (i.key() == QLatin1String("ProjectExplorer.ProcessStep.DisplayName"))
  1053. result.insert(QLatin1String("ProjectExplorer.ProjectConfiguration.DisplayName"), i.value());
  1054. else if (i.key() == QLatin1String("abstractProcess.command"))
  1055. result.insert(QLatin1String("ProjectExplorer.ProcessStep.Command"), i.value());
  1056. else if ((i.key() == QLatin1String("abstractProcess.workingDirectory") ||
  1057. i.key() == QLatin1String("workingDirectory")) &&
  1058. !i.value().toString().isEmpty())
  1059. result.insert(QLatin1String("ProjectExplorer.ProcessStep.WorkingDirectory"), i.value());
  1060. else if (i.key() == QLatin1String("abstractProcess.arguments"))
  1061. result.insert(QLatin1String("ProjectExplorer.ProcessStep.Arguments"), i.value());
  1062. else if (i.key() == QLatin1String("abstractProcess.enabled"))
  1063. result.insert(QLatin1String("Pr…

Large files files are truncated, but you can click here to view the full file