Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
89506207
Unverified
Commit
89506207
authored
May 26, 2018
by
Beat Küng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mavlink Console: add command history
parent
156338c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
5 deletions
+79
-5
MavlinkConsoleController.cc
src/AnalyzeView/MavlinkConsoleController.cc
+53
-0
MavlinkConsoleController.h
src/AnalyzeView/MavlinkConsoleController.h
+17
-5
MavlinkConsolePage.qml
src/AnalyzeView/MavlinkConsolePage.qml
+9
-0
No files found.
src/AnalyzeView/MavlinkConsoleController.cc
View file @
89506207
...
@@ -33,12 +33,25 @@ MavlinkConsoleController::~MavlinkConsoleController()
...
@@ -33,12 +33,25 @@ MavlinkConsoleController::~MavlinkConsoleController()
void
void
MavlinkConsoleController
::
sendCommand
(
QString
command
)
MavlinkConsoleController
::
sendCommand
(
QString
command
)
{
{
_history
.
append
(
command
);
command
.
append
(
"
\n
"
);
command
.
append
(
"
\n
"
);
_sendSerialData
(
qPrintable
(
command
));
_sendSerialData
(
qPrintable
(
command
));
_cursor_home_pos
=
-
1
;
_cursor_home_pos
=
-
1
;
_cursor
=
rowCount
();
_cursor
=
rowCount
();
}
}
QString
MavlinkConsoleController
::
historyUp
(
const
QString
&
current
)
{
return
_history
.
up
(
current
);
}
QString
MavlinkConsoleController
::
historyDown
(
const
QString
&
current
)
{
return
_history
.
down
(
current
);
}
void
void
MavlinkConsoleController
::
_setActiveVehicle
(
Vehicle
*
vehicle
)
MavlinkConsoleController
::
_setActiveVehicle
(
Vehicle
*
vehicle
)
{
{
...
@@ -192,3 +205,43 @@ MavlinkConsoleController::writeLine(int line, const QByteArray &text)
...
@@ -192,3 +205,43 @@ MavlinkConsoleController::writeLine(int line, const QByteArray &text)
auto
idx
=
index
(
line
);
auto
idx
=
index
(
line
);
setData
(
idx
,
data
(
idx
,
Qt
::
DisplayRole
).
toString
()
+
text
);
setData
(
idx
,
data
(
idx
,
Qt
::
DisplayRole
).
toString
()
+
text
);
}
}
void
MavlinkConsoleController
::
CommandHistory
::
append
(
const
QString
&
command
)
{
if
(
command
.
length
()
>
0
)
{
// do not append duplicates
if
(
_history
.
length
()
==
0
||
_history
.
last
()
!=
command
)
{
if
(
_history
.
length
()
>=
maxHistoryLength
)
{
_history
.
removeFirst
();
}
_history
.
append
(
command
);
}
}
_index
=
_history
.
length
();
}
QString
MavlinkConsoleController
::
CommandHistory
::
up
(
const
QString
&
current
)
{
if
(
_index
<=
0
)
return
current
;
--
_index
;
if
(
_index
<
_history
.
length
())
{
return
_history
[
_index
];
}
return
""
;
}
QString
MavlinkConsoleController
::
CommandHistory
::
down
(
const
QString
&
current
)
{
if
(
_index
>=
_history
.
length
())
return
current
;
++
_index
;
if
(
_index
<
_history
.
length
())
{
return
_history
[
_index
];
}
return
""
;
}
src/AnalyzeView/MavlinkConsoleController.h
View file @
89506207
...
@@ -27,13 +27,12 @@ class MavlinkConsoleController : public QStringListModel
...
@@ -27,13 +27,12 @@ class MavlinkConsoleController : public QStringListModel
public:
public:
MavlinkConsoleController
();
MavlinkConsoleController
();
~
MavlinkConsoleController
();
virtual
~
MavlinkConsoleController
();
public
slots
:
Q_INVOKABLE
void
sendCommand
(
QString
command
);
void
sendCommand
(
QString
command
);
signals:
Q_INVOKABLE
QString
historyUp
(
const
QString
&
current
);
void
cursorChanged
(
i
nt
);
Q_INVOKABLE
QString
historyDown
(
const
QString
&
curre
nt
);
private
slots
:
private
slots
:
void
_setActiveVehicle
(
Vehicle
*
vehicle
);
void
_setActiveVehicle
(
Vehicle
*
vehicle
);
...
@@ -44,10 +43,23 @@ private:
...
@@ -44,10 +43,23 @@ private:
void
_sendSerialData
(
QByteArray
,
bool
close
=
false
);
void
_sendSerialData
(
QByteArray
,
bool
close
=
false
);
void
writeLine
(
int
line
,
const
QByteArray
&
text
);
void
writeLine
(
int
line
,
const
QByteArray
&
text
);
class
CommandHistory
{
public:
void
append
(
const
QString
&
command
);
QString
up
(
const
QString
&
current
);
QString
down
(
const
QString
&
current
);
private:
static
constexpr
int
maxHistoryLength
=
100
;
QList
<
QString
>
_history
;
int
_index
=
0
;
};
int
_cursor_home_pos
;
int
_cursor_home_pos
;
int
_cursor
;
int
_cursor
;
QByteArray
_incoming_buffer
;
QByteArray
_incoming_buffer
;
Vehicle
*
_vehicle
;
Vehicle
*
_vehicle
;
QList
<
QMetaObject
::
Connection
>
_uas_connections
;
QList
<
QMetaObject
::
Connection
>
_uas_connections
;
CommandHistory
_history
;
};
};
src/AnalyzeView/MavlinkConsolePage.qml
View file @
89506207
...
@@ -96,6 +96,15 @@ AnalyzePage {
...
@@ -96,6 +96,15 @@ AnalyzePage {
conController
.
sendCommand
(
text
)
conController
.
sendCommand
(
text
)
text
=
""
text
=
""
}
}
Keys.onPressed
:
{
if
(
event
.
key
==
Qt
.
Key_Up
)
{
text
=
conController
.
historyUp
(
text
);
event
.
accepted
=
true
;
}
else
if
(
event
.
key
==
Qt
.
Key_Down
)
{
text
=
conController
.
historyDown
(
text
);
event
.
accepted
=
true
;
}
}
}
}
QGCButton
{
QGCButton
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment