Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
138221ac
Commit
138221ac
authored
15 years ago
by
Erik Verbruggen
Browse files
Options
Downloads
Patches
Plain Diff
Add missing qmljsmetatypesystem.*
Done-with: ckamm
parent
f753d332
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/qmljs/qmljsmetatypesystem.cpp
+87
-0
87 additions, 0 deletions
src/libs/qmljs/qmljsmetatypesystem.cpp
src/libs/qmljs/qmljsmetatypesystem.h
+58
-0
58 additions, 0 deletions
src/libs/qmljs/qmljsmetatypesystem.h
with
145 additions
and
0 deletions
src/libs/qmljs/qmljsmetatypesystem.cpp
0 → 100644
+
87
−
0
View file @
138221ac
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include
"qmljsinterpreter.h"
#include
"qmljsmetatypesystem.h"
#ifndef NO_DECLARATIVE_BACKEND
#include
<QtDeclarative/QmlType>
#include
<QtDeclarative/QmlMetaType>
#endif // NO_DECLARATIVE_BACKEND
using
namespace
QmlJS
;
using
namespace
QmlJS
::
Interpreter
;
void
MetaTypeSystem
::
reload
(
Interpreter
::
Engine
*
interpreter
)
{
_importedTypes
.
clear
();
#ifndef NO_DECLARATIVE_BACKEND
foreach
(
QmlType
*
type
,
QmlMetaType
::
qmlTypes
())
{
const
QString
fqType
=
type
->
qmlTypeName
();
const
int
sepIdx
=
fqType
.
lastIndexOf
(
QLatin1Char
(
'/'
));
QString
typeName
;
QString
package
;
if
(
sepIdx
==
-
1
)
{
typeName
=
fqType
;
}
else
{
typeName
=
fqType
.
mid
(
sepIdx
+
1
);
package
=
fqType
.
left
(
sepIdx
);
}
_importedTypes
[
package
].
append
(
interpreter
->
newQmlObject
(
typeName
,
package
,
type
->
majorVersion
(),
type
->
minorVersion
()));
}
}
QList
<
QmlObjectValue
*>
MetaTypeSystem
::
staticTypesForImport
(
const
QString
&
prefix
,
int
majorVersion
,
int
minorVersion
)
const
{
QMap
<
QString
,
QmlObjectValue
*>
objectValuesByName
;
foreach
(
QmlObjectValue
*
qmlObjectValue
,
_importedTypes
[
prefix
])
{
if
(
qmlObjectValue
->
majorVersion
()
<
majorVersion
||
(
qmlObjectValue
->
majorVersion
()
==
majorVersion
&&
qmlObjectValue
->
minorVersion
()
<=
minorVersion
))
{
// we got a candidate.
const
QString
typeName
=
qmlObjectValue
->
qmlTypeName
();
QmlObjectValue
*
previousCandidate
=
objectValuesByName
.
value
(
typeName
,
0
);
if
(
previousCandidate
)
{
// check if our new candidate is newer than the one we found previously
if
(
qmlObjectValue
->
majorVersion
()
>
previousCandidate
->
majorVersion
()
||
(
qmlObjectValue
->
majorVersion
()
==
previousCandidate
->
majorVersion
()
&&
qmlObjectValue
->
minorVersion
()
>
previousCandidate
->
minorVersion
()))
{
// the new candidate has a higher version no. than the one we found previously, so replace it
objectValuesByName
.
insert
(
typeName
,
qmlObjectValue
);
}
}
else
{
objectValuesByName
.
insert
(
typeName
,
qmlObjectValue
);
}
}
}
return
objectValuesByName
.
values
();
#endif // NO_DECLARATIVE_BACKEND
}
This diff is collapsed.
Click to expand it.
src/libs/qmljs/qmljsmetatypesystem.h
0 → 100644
+
58
−
0
View file @
138221ac
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef QMLJSMETATYPESYSTEM_H
#define QMLJSMETATYPESYSTEM_H
#include
<QtCore/QHash>
#include
<QtCore/QString>
namespace
QmlJS
{
namespace
Interpreter
{
class
Engine
;
class
QmlObjectValue
;
}
// namespace Interpreter
class
MetaTypeSystem
{
public:
void
reload
(
Interpreter
::
Engine
*
interpreter
);
#ifndef NO_DECLARATIVE_BACKEND
QList
<
Interpreter
::
QmlObjectValue
*>
staticTypesForImport
(
const
QString
&
prefix
,
int
majorVersion
,
int
minorVersion
)
const
;
#endif // NO_DECLARATIVE_BACKEND
private:
QHash
<
QString
,
QList
<
Interpreter
::
QmlObjectValue
*>
>
_importedTypes
;
};
}
// namespace QmlJS
#endif // QMLJSMETATYPESYSTEM_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment