forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/5.0'
Change-Id: I0ef7cd302ba7cba64fec401f3426dd682b8dc036
This commit is contained in:
@@ -359,8 +359,9 @@ MimeMagicRule::MimeMagicRule(MimeMagicRule::Type theType,
|
||||
}
|
||||
}
|
||||
|
||||
MimeMagicRule::MimeMagicRule(const MimeMagicRule &other) :
|
||||
d(new MimeMagicRulePrivate(*other.d))
|
||||
MimeMagicRule::MimeMagicRule(const MimeMagicRule &other)
|
||||
: m_subMatches(other.m_subMatches)
|
||||
, d(new MimeMagicRulePrivate(*other.d))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -369,13 +370,13 @@ MimeMagicRule::~MimeMagicRule() = default;
|
||||
MimeMagicRule &MimeMagicRule::operator=(const MimeMagicRule &other)
|
||||
{
|
||||
*d = *other.d;
|
||||
m_subMatches = other.m_subMatches;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool MimeMagicRule::operator==(const MimeMagicRule &other) const
|
||||
{
|
||||
return d == other.d ||
|
||||
*d == *other.d;
|
||||
return (d == other.d || *d == *other.d) && m_subMatches == other.m_subMatches;
|
||||
}
|
||||
|
||||
MimeMagicRule::Type MimeMagicRule::type() const
|
||||
|
||||
@@ -407,7 +407,7 @@ void TestTreeModel::synchronizeTestTools()
|
||||
if (project) {
|
||||
const QList<Target *> &allTargets = project->targets();
|
||||
auto target = allTargets.empty() ? nullptr : allTargets.first();
|
||||
if (QTC_GUARD(target)) {
|
||||
if (target) {
|
||||
auto bs = target->buildSystem();
|
||||
for (ITestTool *testTool : newlyAdded) {
|
||||
ITestTreeItem *rootNode = testTool->rootNode();
|
||||
|
||||
@@ -163,8 +163,9 @@ void PropertyEditorView::changeValue(const QString &name)
|
||||
m_locked = true;
|
||||
value->setValue(m_selectedNode.id());
|
||||
m_locked = false;
|
||||
if (!QmlDesigner::ModelNode::isValidId(newId))
|
||||
Core::AsynchronousMessageBox::warning(tr("Invalid ID"), tr("%1 is an invalid ID.").arg(newId));
|
||||
QString errMsg = QmlDesigner::ModelNode::getIdValidityErrorMessage(newId);
|
||||
if (!errMsg.isEmpty())
|
||||
Core::AsynchronousMessageBox::warning(tr("Invalid ID"), errMsg.arg(newId));
|
||||
else
|
||||
Core::AsynchronousMessageBox::warning(tr("Invalid ID"), tr("%1 already exists.").arg(newId));
|
||||
}
|
||||
|
||||
@@ -168,6 +168,8 @@ public:
|
||||
void setIdWithRefactoring(const QString &id);
|
||||
void setIdWithoutRefactoring(const QString &id);
|
||||
static bool isValidId(const QString &id);
|
||||
static QString getIdValidityErrorMessage(const QString &id);
|
||||
|
||||
bool hasId() const;
|
||||
|
||||
Model *model() const;
|
||||
|
||||
@@ -212,6 +212,29 @@ bool ModelNode::isValidId(const QString &id)
|
||||
return id.isEmpty() || (!idContainsWrongLetter(id) && !idIsQmlKeyWord(id) && !isIdToAvoid(id));
|
||||
}
|
||||
|
||||
QString ModelNode::getIdValidityErrorMessage(const QString &id)
|
||||
{
|
||||
if (isValidId(id))
|
||||
return {}; // valid
|
||||
|
||||
if (id.at(0).isUpper())
|
||||
return QObject::tr("ID cannot start with an uppercase character.");
|
||||
|
||||
if (id.at(0).isDigit())
|
||||
return QObject::tr("ID cannot start with a number.");
|
||||
|
||||
if (id.contains(' '))
|
||||
return QObject::tr("ID cannot include whitespace.");
|
||||
|
||||
if (idIsQmlKeyWord(id))
|
||||
return QObject::tr("%1 is a reserved QML keyword.");
|
||||
|
||||
if (isIdToAvoid(id))
|
||||
return QObject::tr("%1 is a reserved property keyword.");
|
||||
|
||||
return QObject::tr("ID includes invalid characters.");
|
||||
}
|
||||
|
||||
bool ModelNode::hasId() const
|
||||
{
|
||||
if (!isValid())
|
||||
|
||||
Reference in New Issue
Block a user