diff options
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/installer/component.cpp | 21 | ||||
-rw-r--r-- | src/libs/installer/component.h | 1 | ||||
-rw-r--r-- | src/libs/installer/component_p.cpp | 16 | ||||
-rw-r--r-- | src/libs/installer/component_p.h | 6 | ||||
-rw-r--r-- | src/libs/installer/componentmodel.cpp | 3 | ||||
-rw-r--r-- | src/libs/installer/constants.h | 1 | ||||
-rw-r--r-- | src/libs/installer/downloadarchivesjob.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/globals.cpp | 2 | ||||
-rw-r--r-- | src/libs/installer/installercalculator.cpp | 6 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.cpp | 67 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore.h | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 12 | ||||
-rw-r--r-- | src/libs/installer/packagemanagergui.cpp | 14 | ||||
-rw-r--r-- | src/libs/installer/uninstallercalculator.cpp | 2 | ||||
-rw-r--r-- | src/libs/kdtools/localpackagehub.cpp | 9 | ||||
-rw-r--r-- | src/libs/kdtools/localpackagehub.h | 4 | ||||
-rw-r--r-- | src/libs/kdtools/updatefinder.cpp | 56 |
17 files changed, 183 insertions, 43 deletions
diff --git a/src/libs/installer/component.cpp b/src/libs/installer/component.cpp index da0230ade..9be2357cd 100644 --- a/src/libs/installer/component.cpp +++ b/src/libs/installer/component.cpp @@ -66,6 +66,7 @@ static const QLatin1String scUninstalled("Uninstalled"); static const QLatin1String scCurrentState("CurrentState"); static const QLatin1String scForcedInstallation("ForcedInstallation"); static const QLatin1String scCheckable("Checkable"); +static const QLatin1String scExpandedByDefault("ExpandedByDefault"); /*! \inmodule QtInstallerFramework @@ -262,6 +263,7 @@ void Component::loadDataFromPackage(const KDUpdater::LocalPackage &package) setValue(scVirtual, package.virtualComp ? scTrue : scFalse); setValue(scCurrentState, scInstalled); setValue(scCheckable, package.checkable ? scTrue : scFalse); + setValue(scExpandedByDefault, package.expandedByDefault ? scTrue : scFalse); } /*! @@ -295,6 +297,7 @@ void Component::loadDataFromPackage(const Package &package) setValue(scReplaces, package.data(scReplaces).toString()); setValue(scReleaseDate, package.data(scReleaseDate).toString()); setValue(scCheckable, package.data(scCheckable).toString()); + setValue(scExpandedByDefault, package.data(scExpandedByDefault).toString()); QString forced = package.data(scForcedInstallation, scFalse).toString().toLower(); if (PackageManagerCore::noForceInstallation()) @@ -388,6 +391,8 @@ void Component::setValue(const QString &key, const QString &value) d->m_componentName = normalizedValue; if (key == scCheckable) this->setCheckable(normalizedValue.toLower() == scTrue); + if (key == scExpandedByDefault) + this->setExpandedByDefault(normalizedValue.toLower() == scTrue); d->m_vars[key] = normalizedValue; emit valueChanged(key, normalizedValue); @@ -1170,6 +1175,22 @@ QStringList Component::dependencies() const return d->m_vars.value(scDependencies).split(QInstaller::commaRegExp(), QString::SkipEmptyParts); } +/*! + Adds the component specified by \a newDependOn to the automatic depend-on list. + + \sa {component::addAutoDependOn}{component.addAutoDependOn} + \sa dependencies +*/ + +void Component::addAutoDependOn(const QString &newDependOn) +{ + QString oldDependOn = d->m_vars.value(scAutoDependOn); + if (oldDependOn.isEmpty()) + setValue(scAutoDependOn, newDependOn); + else + setValue(scAutoDependOn, oldDependOn + QLatin1String(", ") + newDependOn); +} + QStringList Component::autoDependencies() const { return d->m_vars.value(scAutoDependOn).split(QInstaller::commaRegExp(), QString::SkipEmptyParts); diff --git a/src/libs/installer/component.h b/src/libs/installer/component.h index 01622548f..b11fd4cef 100644 --- a/src/libs/installer/component.h +++ b/src/libs/installer/component.h @@ -154,6 +154,7 @@ public: Q_INVOKABLE void addDependency(const QString &newDependency); QStringList dependencies() const; + Q_INVOKABLE void addAutoDependOn(const QString &newDependOn); QStringList autoDependencies() const; void languageChanged(); diff --git a/src/libs/installer/component_p.cpp b/src/libs/installer/component_p.cpp index 4bf2a4754..5f44f83a4 100644 --- a/src/libs/installer/component_p.cpp +++ b/src/libs/installer/component_p.cpp @@ -198,6 +198,22 @@ void ComponentModelHelper::setSelectable(bool selectable) changeFlags(selectable, Qt::ItemIsSelectable); } +/*! + Returns whether the component is expanded by default. The default value is \c false. +*/ +bool ComponentModelHelper::isExpandedByDefault() const +{ + return data(ComponentModelHelper::ExpandedByDefault).value<bool>(); +} + +/*! + Sets whether the component is expanded by default. The default value is \c false. +*/ +void ComponentModelHelper::setExpandedByDefault(bool expandedByDefault) +{ + setData(QVariant::fromValue<bool>(expandedByDefault), ComponentModelHelper::ExpandedByDefault); +} + ComponentModelHelper::InstallAction ComponentModelHelper::installAction() const { return data(ComponentModelHelper::Action).value<ComponentModelHelper::InstallAction>(); diff --git a/src/libs/installer/component_p.h b/src/libs/installer/component_p.h index 9a5d0fd20..60cbd8075 100644 --- a/src/libs/installer/component_p.h +++ b/src/libs/installer/component_p.h @@ -91,7 +91,8 @@ public: LocalDisplayVersion, RemoteDisplayVersion, ReleaseDate, - UncompressedSize + UncompressedSize, + ExpandedByDefault }; enum InstallAction { @@ -129,6 +130,9 @@ public: bool isSelectable() const; void setSelectable(bool selectable); + bool isExpandedByDefault() const; + void setExpandedByDefault(bool expandedByDefault); + InstallAction installAction() const; void setInstallAction(InstallAction action); diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp index e0cc3fcd8..0f8a47c38 100644 --- a/src/libs/installer/componentmodel.cpp +++ b/src/libs/installer/componentmodel.cpp @@ -227,6 +227,9 @@ QVariant ComponentModel::data(const QModelIndex &index, int role) const if (!component->autoDependencies().isEmpty()) return QVariant(); } + if (role == ComponentModelHelper::ExpandedByDefault) { + return component->isExpandedByDefault(); + } return component->data(role); } return QVariant(); diff --git a/src/libs/installer/constants.h b/src/libs/installer/constants.h index f1eac9926..7f44acbe7 100644 --- a/src/libs/installer/constants.h +++ b/src/libs/installer/constants.h @@ -60,6 +60,7 @@ static const QLatin1String scInstalledVersion("InstalledVersion"); static const QLatin1String scUncompressedSize("UncompressedSize"); static const QLatin1String scUncompressedSizeSum("UncompressedSizeSum"); static const QLatin1String scRequiresAdminRights("RequiresAdminRights"); +static const QLatin1String scSHA1("SHA1"); // constants used throughout the components class static const QLatin1String scVirtual("Virtual"); diff --git a/src/libs/installer/downloadarchivesjob.cpp b/src/libs/installer/downloadarchivesjob.cpp index 8fd8a40a9..80c094ae0 100644 --- a/src/libs/installer/downloadarchivesjob.cpp +++ b/src/libs/installer/downloadarchivesjob.cpp @@ -269,7 +269,7 @@ KDUpdater::FileDownloader *DownloadArchivesJob::setupDownloader(const QString &s { KDUpdater::FileDownloader *downloader = 0; const QFileInfo fi = QFileInfo(m_archivesToDownload.first().first); - const Component *const component = m_core->componentByName(QFileInfo(fi.path()).fileName()); + const Component *const component = m_core->componentByName(PackageManagerCore::checkableName(QFileInfo(fi.path()).fileName())); if (component) { QString fullQueryString; if (!queryString.isEmpty()) diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp index 5f3009905..c059b6630 100644 --- a/src/libs/installer/globals.cpp +++ b/src/libs/installer/globals.cpp @@ -50,7 +50,7 @@ QStringList loggingCategories() return categories; } -Q_GLOBAL_STATIC_WITH_ARGS(QRegExp, staticCommaRegExp, (QLatin1String("\\b(,|, )\\b"))); +Q_GLOBAL_STATIC_WITH_ARGS(QRegExp, staticCommaRegExp, (QLatin1String("(, |,)"))); QRegExp commaRegExp() { return *staticCommaRegExp(); diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index 064dbafa5..d44450eb2 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -173,13 +173,15 @@ bool InstallerCalculator::appendComponentToInstall(Component *component, const Q } //Check if component requires higher version than what might be already installed bool isUpdateRequired = false; - if (dependencyComponentName.contains(QChar::fromLatin1('-')) && + QString requiredName; + QString requiredVersion; + PackageManagerCore::parseNameAndVersion(dependencyComponentName, &requiredName, &requiredVersion); + if (!requiredVersion.isEmpty() && !dependencyComponent->value(scInstalledVersion).isEmpty()) { QRegExp compEx(QLatin1String("([<=>]+)(.*)")); const QString installedVersion = compEx.exactMatch(dependencyComponent->value(scInstalledVersion)) ? compEx.cap(2) : dependencyComponent->value(scInstalledVersion); - QString requiredVersion = dependencyComponentName.section(QLatin1Char('-'), 1); requiredVersion = compEx.exactMatch(requiredVersion) ? compEx.cap(2) : requiredVersion; if (KDUpdater::compareVersion(requiredVersion, installedVersion) >= 1 ) { diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 07afb4c7b..9b9c986e0 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -727,7 +727,7 @@ void PackageManagerCore::rollBackInstallation() const QString componentName = operation->value(QLatin1String("component")).toString(); if (!componentName.isEmpty()) { - Component *component = componentByName(componentName); + Component *component = componentByName(checkableName(componentName)); if (!component) component = d->componentsToReplace().value(componentName).second; if (component) { @@ -1558,12 +1558,9 @@ Component *PackageManagerCore::componentByName(const QString &name, const QList< return 0; QString fixedVersion; - QString fixedName = name; - if (name.contains(QChar::fromLatin1('-'))) { - // the last part is considered to be the version, then - fixedVersion = name.section(QLatin1Char('-'), 1); - fixedName = name.section(QLatin1Char('-'), 0, 0); - } + QString fixedName; + + parseNameAndVersion(name, &fixedName, &fixedVersion); foreach (Component *component, components) { if (componentMatches(component, fixedName, fixedVersion)) @@ -1758,14 +1755,13 @@ QList<Component*> PackageManagerCore::dependees(const Component *_component) con if (availableComponents.isEmpty()) return QList<Component *>(); - const QLatin1Char dash('-'); QList<Component *> dependees; + QString name; + QString version; foreach (Component *component, availableComponents) { const QStringList &dependencies = component->dependencies(); foreach (const QString &dependency, dependencies) { - // the last part is considered to be the version then - const QString name = dependency.contains(dash) ? dependency.section(dash, 0, 0) : dependency; - const QString version = dependency.contains(dash) ? dependency.section(dash, 1) : QString(); + parseNameAndVersion(dependency, &name, &version); if (componentMatches(_component, name, version)) dependees.append(component); } @@ -2952,3 +2948,52 @@ void PackageManagerCore::addFilesForDelayedDeletion(const QStringList &files) { d->m_filesForDelayedDeletion.append(files); } + +QString PackageManagerCore::checkableName(const QString &name) +{ + // to ensure backward compatibility, fix component name with dash (-) symbol + if (!name.contains(QLatin1Char(':'))) + if (name.contains(QLatin1Char('-'))) + return name + QLatin1Char(':'); + + return name; +} + +void PackageManagerCore::parseNameAndVersion(const QString &requirement, QString *name, QString *version) +{ + if (requirement.isEmpty()) { + if (name) + name->clear(); + if (version) + version->clear(); + return; + } + + int pos = requirement.indexOf(QLatin1Char(':')); + // to ensure backward compatibility, check dash (-) symbol too + if (pos == -1) + pos = requirement.indexOf(QLatin1Char('-')); + if (pos != -1) { + if (name) + *name = requirement.left(pos); + if (version) + *version = requirement.mid(pos + 1); + } else { + if (name) + *name = requirement; + if (version) + version->clear(); + } +} + +QStringList PackageManagerCore::parseNames(const QStringList &requirements) +{ + QString name; + QString version; + QStringList names; + foreach (const QString &requirement, requirements) { + parseNameAndVersion(requirement, &name, &version); + names.append(name); + } + return names; +} diff --git a/src/libs/installer/packagemanagercore.h b/src/libs/installer/packagemanagercore.h index 2a235bd44..10aad54d1 100644 --- a/src/libs/installer/packagemanagercore.h +++ b/src/libs/installer/packagemanagercore.h @@ -265,6 +265,10 @@ public: QStringList filesForDelayedDeletion() const; void addFilesForDelayedDeletion(const QStringList &files); + static QString checkableName(const QString &name); + static void parseNameAndVersion(const QString &requirement, QString *name, QString *version); + static QStringList parseNames(const QStringList &requirements); + public Q_SLOTS: bool runInstaller(); bool runUninstaller(); diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index b21b32832..57f430778 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -529,7 +529,7 @@ UninstallerCalculator *PackageManagerCorePrivate::uninstallerCalculator() const QList<Component*> installedComponents; foreach (const QString &name, pmcp->localInstalledPackages().keys()) { - if (Component *component = m_core->componentByName(name)) { + if (Component *component = m_core->componentByName(PackageManagerCore::checkableName(name))) { if (!component->uninstallationRequested()) installedComponents.append(component); } @@ -1651,7 +1651,7 @@ bool PackageManagerCorePrivate::runPackageUpdater() const QString &name = operation->value(QLatin1String("component")).toString(); Component *component = componentsByName.value(name, 0); if (!component) - component = m_core->componentByName(name); + component = m_core->componentByName(PackageManagerCore::checkableName(name)); if (component) componentsByName.insert(name, component); @@ -1931,7 +1931,8 @@ void PackageManagerCorePrivate::installComponent(Component *component, double pr component->isVirtual(), component->value(scUncompressedSize).toULongLong(), component->value(scInheritVersion), - component->isCheckable()); + component->isCheckable(), + component->isExpandedByDefault()); m_localPackageHub->writeToDisk(); component->setInstalled(); @@ -2089,7 +2090,7 @@ void PackageManagerCorePrivate::runUndoOperations(const OperationList &undoOpera else if (button == QMessageBox::Ignore) ignoreError = true; } - Component *component = m_core->componentByName(componentName); + Component *component = m_core->componentByName(PackageManagerCore::checkableName(componentName)); if (!component) component = componentsToReplace().value(componentName).second; if (component) { @@ -2389,11 +2390,10 @@ OperationList PackageManagerCorePrivate::sortOperationsBasedOnComponentDependenc componentOperationHash[componentName].append(operation); } - const QRegExp dash(QLatin1String("-.*")); Graph<QString> componentGraph; // create the complete component graph foreach (const Component* node, m_core->components(PackageManagerCore::ComponentType::All)) { componentGraph.addNode(node->name()); - componentGraph.addEdges(node->name(), node->dependencies().replaceInStrings(dash, QString())); + componentGraph.addEdges(node->name(), m_core->parseNames(node->dependencies())); } const QStringList resolvedComponents = componentGraph.sort(); diff --git a/src/libs/installer/packagemanagergui.cpp b/src/libs/installer/packagemanagergui.cpp index 5ee3d14fc..287bf7d38 100644 --- a/src/libs/installer/packagemanagergui.cpp +++ b/src/libs/installer/packagemanagergui.cpp @@ -1275,19 +1275,19 @@ IntroductionPage::IntroductionPage(PackageManagerCore *core) QWidget *widget = new QWidget(this); QVBoxLayout *boxLayout = new QVBoxLayout(widget); - m_packageManager = new QRadioButton(tr("Add or remove components"), this); + m_packageManager = new QRadioButton(tr("&Add or remove components"), this); m_packageManager->setObjectName(QLatin1String("PackageManagerRadioButton")); boxLayout->addWidget(m_packageManager); m_packageManager->setChecked(core->isPackageManager()); connect(m_packageManager, &QAbstractButton::toggled, this, &IntroductionPage::setPackageManager); - m_updateComponents = new QRadioButton(tr("Update components"), this); + m_updateComponents = new QRadioButton(tr("&Update components"), this); m_updateComponents->setObjectName(QLatin1String("UpdaterRadioButton")); boxLayout->addWidget(m_updateComponents); m_updateComponents->setChecked(core->isUpdater()); connect(m_updateComponents, &QAbstractButton::toggled, this, &IntroductionPage::setUpdater); - m_removeAllComponents = new QRadioButton(tr("Remove all components"), this); + m_removeAllComponents = new QRadioButton(tr("&Remove all components"), this); m_removeAllComponents->setObjectName(QLatin1String("UninstallerRadioButton")); boxLayout->addWidget(m_removeAllComponents); m_removeAllComponents->setChecked(core->isUninstaller()); @@ -1621,7 +1621,7 @@ void IntroductionPage::entering() showWidgets(false); setMessage(QString()); setErrorMessage(QString()); - setButtonText(QWizard::CancelButton, tr("Quit")); + setButtonText(QWizard::CancelButton, tr("&Quit")); m_progressBar->setValue(0); m_progressBar->setRange(0, 0); @@ -1981,6 +1981,12 @@ public: m_currentModel = m_core->isUpdater() ? m_updaterModel : m_allModel; m_treeView->setModel(m_currentModel); m_treeView->setExpanded(m_currentModel->index(0, 0), true); + foreach (Component *component, m_core->components(PackageManagerCore::ComponentType::All)) { + if (component->isExpandedByDefault()) { + const QModelIndex index = m_currentModel->indexFromComponentName(component->name()); + m_treeView->setExpanded(index, true); + } + } const bool installActionColumnVisible = m_core->settings().installActionColumnVisible(); if (!installActionColumnVisible) diff --git a/src/libs/installer/uninstallercalculator.cpp b/src/libs/installer/uninstallercalculator.cpp index 2109cc8b4..9e669c8cf 100644 --- a/src/libs/installer/uninstallercalculator.cpp +++ b/src/libs/installer/uninstallercalculator.cpp @@ -75,7 +75,7 @@ void UninstallerCalculator::appendComponentsToUninstall(const QList<Component*> foreach (Component *component, m_installedComponents) { // If a components is installed and not yet scheduled for un-installation, check for auto depend. if (component->isInstalled() && !m_componentsToUninstall.contains(component)) { - QStringList autoDependencies = component->autoDependencies(); + QStringList autoDependencies = PackageManagerCore::parseNames(component->autoDependencies()); if (autoDependencies.isEmpty()) continue; diff --git a/src/libs/kdtools/localpackagehub.cpp b/src/libs/kdtools/localpackagehub.cpp index 6ac3da803..11ff36a88 100644 --- a/src/libs/kdtools/localpackagehub.cpp +++ b/src/libs/kdtools/localpackagehub.cpp @@ -322,7 +322,8 @@ void LocalPackageHub::addPackage(const QString &name, bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, - bool checkable) + bool checkable, + bool expandedByDefault) { // TODO: This somewhat unexpected, remove? if (d->m_packageInfoMap.contains(name)) { @@ -343,6 +344,7 @@ void LocalPackageHub::addPackage(const QString &name, info.virtualComp = virtualComp; info.uncompressedSize = uncompressedSize; info.checkable = checkable; + info.expandedByDefault = expandedByDefault; d->m_packageInfoMap.insert(name, info); } d->modified = true; @@ -416,6 +418,8 @@ void LocalPackageHub::writeToDisk() addTextChildHelper(&package, QLatin1String("Virtual"), QLatin1String("true")); if (info.checkable) addTextChildHelper(&package, QLatin1String("Checkable"), QLatin1String("true")); + if (info.expandedByDefault) + addTextChildHelper(&package, QLatin1String("ExpandedByDefault"), QLatin1String("true")); root.appendChild(package); } @@ -444,6 +448,7 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag info.forcedInstallation = false; info.virtualComp = false; info.checkable = false; + info.expandedByDefault = false; for (int i = 0; i < childNodes.count(); i++) { QDomNode childNode = childNodes.item(i); QDomElement childNodeE = childNode.toElement(); @@ -478,6 +483,8 @@ void LocalPackageHub::PackagesInfoData::addPackageFrom(const QDomElement &packag info.installDate = QDate::fromString(childNodeE.text(), Qt::ISODate); else if (childNodeE.tagName() == QLatin1String("Checkable")) info.checkable = childNodeE.text().toLower() == QLatin1String("true") ? true : false; + else if (childNodeE.tagName() == QLatin1String("ExpandedByDefault")) + info.expandedByDefault = childNodeE.text().toLower() == QLatin1String("true") ? true : false; } m_packageInfoMap.insert(info.name, info); } diff --git a/src/libs/kdtools/localpackagehub.h b/src/libs/kdtools/localpackagehub.h index f5c7b7623..7a067e73e 100644 --- a/src/libs/kdtools/localpackagehub.h +++ b/src/libs/kdtools/localpackagehub.h @@ -53,6 +53,7 @@ struct KDTOOLS_EXPORT LocalPackage bool virtualComp; quint64 uncompressedSize; bool checkable; + bool expandedByDefault; }; class KDTOOLS_EXPORT LocalPackageHub @@ -104,7 +105,8 @@ public: bool virtualComp, quint64 uncompressedSize, const QString &inheritVersionFrom, - bool checkable); + bool checkable, + bool expandedByDefault); bool removePackage(const QString &pkgName); void refresh(); diff --git a/src/libs/kdtools/updatefinder.cpp b/src/libs/kdtools/updatefinder.cpp index ec1be8a4e..b64f922c3 100644 --- a/src/libs/kdtools/updatefinder.cpp +++ b/src/libs/kdtools/updatefinder.cpp @@ -590,34 +590,62 @@ int KDUpdater::compareVersion(const QString &v1, const QString &v2) if (v1 == v2) return 0; - // Split version numbers across "." - const QStringList v1_comps = v1.split(QRegExp(QLatin1String( "\\.|-"))); - const QStringList v2_comps = v2.split(QRegExp(QLatin1String( "\\.|-"))); + // Split version components across ".", "-" or "_" + QStringList v1_comps = v1.split(QRegExp(QLatin1String( "\\.|-|_"))); + QStringList v2_comps = v2.split(QRegExp(QLatin1String( "\\.|-|_"))); // Check each component of the version int index = 0; while (true) { - if (index == v1_comps.count() && index < v2_comps.count()) - return -1; - if (index < v1_comps.count() && index == v2_comps.count()) - return +1; + bool v1_ok = false; + bool v2_ok = false; + + if (index == v1_comps.count() && index < v2_comps.count()) { + v2_comps.at(index).toInt(&v2_ok); + return v2_ok ? -1 : +1; + } + if (index < v1_comps.count() && index == v2_comps.count()) { + v1_comps.at(index).toInt(&v1_ok); + return v1_ok ? +1 : -1; + } if (index >= v1_comps.count() || index >= v2_comps.count()) break; - bool v1_ok, v2_ok; - int v1_comp = v1_comps[index].toInt(&v1_ok); - int v2_comp = v2_comps[index].toInt(&v2_ok); + int v1_comp = v1_comps.at(index).toInt(&v1_ok); + int v2_comp = v2_comps.at(index).toInt(&v2_ok); if (!v1_ok) { - if (v1_comps[index] == QLatin1String("x")) + if (v1_comps.at(index) == QLatin1String("x")) return 0; } if (!v2_ok) { - if (v2_comps[index] == QLatin1String("x")) + if (v2_comps.at(index) == QLatin1String("x")) return 0; } - if (!v1_ok && !v2_ok) - return v1_comps[index].compare(v2_comps[index]); + if (!v1_ok && !v2_ok) { + // try remove equal start + int i = 0; + while (i < v1_comps.at(index).size() + && i < v2_comps.at(index).size() + && v1_comps.at(index).at(i) == v2_comps.at(index).at(i)) { + ++i; + } + if (i > 0) { + v1_comps[index] = v1_comps.at(index).mid(i); + v2_comps[index] = v2_comps.at(index).mid(i); + // compare again + continue; + } + } + if (!v1_ok || !v2_ok) { + int res = v1_comps.at(index).compare(v2_comps.at(index)); + if (res == 0) { + // v1_comps.at(index) == v2_comps(index) + ++index; + continue; + } + return res > 0 ? +1 : -1; + } if (v1_comp < v2_comp) return -1; |