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
c72043f5
Commit
c72043f5
authored
14 years ago
by
Lasse Holmstedt
Browse files
Options
Downloads
Patches
Plain Diff
Sorting to QML project file selector, and update when files change
Task-number: BAUHAUS-548 Reviewed-by: kkoehne
parent
ccfc4de1
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
+42
-29
42 additions, 29 deletions
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
+10
-0
10 additions, 0 deletions
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
with
52 additions
and
29 deletions
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp
+
42
−
29
View file @
c72043f5
...
...
@@ -31,6 +31,7 @@
#include
"qmlprojectmanagerconstants.h"
#include
"qmlprojectrunconfiguration.h"
#include
"qmlprojecttarget.h"
#include
"projectexplorer/projectexplorer.h"
#include
<coreplugin/mimedatabase.h>
#include
<projectexplorer/buildconfiguration.h>
...
...
@@ -46,6 +47,7 @@
#include
<QCoreApplication>
#include
<QLineEdit>
#include
<QSpinBox>
#include
<QStringListModel>
#include
<QDebug>
namespace
QmlProjectManager
{
...
...
@@ -54,6 +56,7 @@ QmlProjectRunConfiguration::QmlProjectRunConfiguration(Internal::QmlProjectTarge
ProjectExplorer
::
RunConfiguration
(
parent
,
QLatin1String
(
Constants
::
QML_RC_ID
)),
m_debugServerAddress
(
"127.0.0.1"
),
m_debugServerPort
(
Constants
::
QML_DEFAULT_DEBUG_SERVER_PORT
),
m_fileListModel
(
new
QStringListModel
(
this
)),
m_projectTarget
(
parent
),
m_usingCurrentFile
(
true
),
m_isEnabled
(
false
)
...
...
@@ -161,35 +164,12 @@ QWidget *QmlProjectRunConfiguration::configurationWidget()
QWidget
*
config
=
new
QWidget
;
QFormLayout
*
form
=
new
QFormLayout
(
config
);
QComboBox
*
combo
=
new
QComboBox
;
m_fileListCombo
=
new
QComboBox
;
m_fileListCombo
.
data
()
->
setModel
(
m_fileListModel
);
updateFileComboBox
();
QDir
projectDir
=
qmlTarget
()
->
qmlProject
()
->
projectDir
();
QStringList
files
;
files
.
append
(
CURRENT_FILE
);
int
currentIndex
=
-
1
;
QStringList
sortedFiles
=
qmlTarget
()
->
qmlProject
()
->
files
();
qStableSort
(
sortedFiles
.
begin
(),
sortedFiles
.
end
(),
caseInsensitiveLessThan
);
foreach
(
const
QString
&
fn
,
sortedFiles
)
{
QFileInfo
fileInfo
(
fn
);
if
(
fileInfo
.
suffix
()
!=
QLatin1String
(
"qml"
))
continue
;
QString
fileName
=
projectDir
.
relativeFilePath
(
fn
);
if
(
fileName
==
m_scriptFile
)
currentIndex
=
files
.
size
();
files
.
append
(
fileName
);
}
combo
->
addItems
(
files
);
if
(
currentIndex
!=
-
1
)
combo
->
setCurrentIndex
(
currentIndex
);
connect
(
combo
,
SIGNAL
(
activated
(
QString
)),
this
,
SLOT
(
setMainScript
(
QString
)));
connect
(
m_fileListCombo
.
data
(),
SIGNAL
(
activated
(
QString
)),
this
,
SLOT
(
setMainScript
(
QString
)));
connect
(
ProjectExplorer
::
ProjectExplorerPlugin
::
instance
(),
SIGNAL
(
fileListChanged
()),
SLOT
(
updateFileComboBox
()));
Utils
::
PathChooser
*
qmlViewer
=
new
Utils
::
PathChooser
;
qmlViewer
->
setExpectedKind
(
Utils
::
PathChooser
::
Command
);
...
...
@@ -212,13 +192,14 @@ QWidget *QmlProjectRunConfiguration::configurationWidget()
form
->
addRow
(
tr
(
"QML Runtime"
),
qmlViewer
);
form
->
addRow
(
tr
(
"QML Runtime arguments:"
),
qmlViewerArgs
);
form
->
addRow
(
tr
(
"Main QML File:"
),
combo
);
form
->
addRow
(
tr
(
"Main QML File:"
),
m_fileListCombo
.
data
()
);
form
->
addRow
(
tr
(
"Debugging Address:"
),
debugServer
);
form
->
addRow
(
tr
(
"Debugging Port:"
),
debugPort
);
return
config
;
}
QString
QmlProjectRunConfiguration
::
mainScript
()
const
{
if
(
m_usingCurrentFile
)
...
...
@@ -227,6 +208,38 @@ QString QmlProjectRunConfiguration::mainScript() const
return
m_mainScriptFilename
;
}
void
QmlProjectRunConfiguration
::
updateFileComboBox
()
{
if
(
m_fileListCombo
.
isNull
())
return
;
QDir
projectDir
=
qmlTarget
()
->
qmlProject
()
->
projectDir
();
QStringList
files
;
files
.
append
(
CURRENT_FILE
);
int
currentIndex
=
-
1
;
QStringList
sortedFiles
=
qmlTarget
()
->
qmlProject
()
->
files
();
qStableSort
(
sortedFiles
.
begin
(),
sortedFiles
.
end
(),
caseInsensitiveLessThan
);
foreach
(
const
QString
&
fn
,
sortedFiles
)
{
QFileInfo
fileInfo
(
fn
);
if
(
fileInfo
.
suffix
()
!=
QLatin1String
(
"qml"
))
continue
;
QString
fileName
=
projectDir
.
relativeFilePath
(
fn
);
if
(
fileName
==
m_scriptFile
)
currentIndex
=
files
.
size
();
files
.
append
(
fileName
);
}
m_fileListModel
->
setStringList
(
files
);
if
(
currentIndex
!=
-
1
)
m_fileListCombo
.
data
()
->
setCurrentIndex
(
currentIndex
);
else
m_fileListCombo
.
data
()
->
setCurrentIndex
(
0
);
}
void
QmlProjectRunConfiguration
::
onDebugServerAddressChanged
()
{
if
(
QLineEdit
*
lineEdit
=
qobject_cast
<
QLineEdit
*>
(
sender
()))
...
...
This diff is collapsed.
Click to expand it.
src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h
+
10
−
0
View file @
c72043f5
...
...
@@ -32,6 +32,10 @@
#include
"qmlprojectmanager_global.h"
#include
<projectexplorer/runconfiguration.h>
#include
<QWeakPointer>
#include
<QComboBox>
QT_FORWARD_DECLARE_CLASS
(
QStringListModel
);
namespace
Core
{
class
IEditor
;
...
...
@@ -79,12 +83,14 @@ private slots:
QString
mainScript
()
const
;
void
setMainScript
(
const
QString
&
scriptFile
);
void
updateFileComboBox
();
void
onViewerChanged
();
void
onViewerArgsChanged
();
void
onDebugServerAddressChanged
();
void
onDebugServerPortChanged
();
protected:
QmlProjectRunConfiguration
(
Internal
::
QmlProjectTarget
*
parent
,
QmlProjectRunConfiguration
*
source
);
virtual
bool
fromMap
(
const
QVariantMap
&
map
);
...
...
@@ -104,6 +110,10 @@ private:
QString
m_qmlViewerArgs
;
QString
m_debugServerAddress
;
uint
m_debugServerPort
;
QStringListModel
*
m_fileListModel
;
// weakpointer is used to make sure we don't try to manipulate
// widget which was deleted already, as can be the case here.
QWeakPointer
<
QComboBox
>
m_fileListCombo
;
Internal
::
QmlProjectTarget
*
m_projectTarget
;
...
...
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