Skip to content
Snippets Groups Projects
Commit 06c0edda authored by tatiana.novikova's avatar tatiana.novikova Committed by andrey.daragan
Browse files

[*] Change rules of keyUp and keyDown

[+] Add handler for the doubleClick on right history panel
parent 32de245a
No related branches found
No related tags found
No related merge requests found
...@@ -7,6 +7,8 @@ DapConsoleRightPanelForm ...@@ -7,6 +7,8 @@ DapConsoleRightPanelForm
property string commandQuery property string commandQuery
///@detalis historyQuery Text of command from the command history. ///@detalis historyQuery Text of command from the command history.
property string historyQuery property string historyQuery
///@detalis historyQueryIndex Index of command from the command history.
property string historyQueryIndex
///@detalis historySize Num of history command at right panel. ///@detalis historySize Num of history command at right panel.
property int historySize: 10 property int historySize: 10
...@@ -23,7 +25,6 @@ DapConsoleRightPanelForm ...@@ -23,7 +25,6 @@ DapConsoleRightPanelForm
//Returns true if item 'someElement' is already exist at list 'someModel'. //Returns true if item 'someElement' is already exist at list 'someModel'.
function findElement(someModel, someElement) function findElement(someModel, someElement)
{ {
console.log("someElement.query", someElement.query)
for(var i = 0; i < someModel.count; ++i) for(var i = 0; i < someModel.count; ++i)
if(someModel.get(i).query === someElement.query) if(someModel.get(i).query === someElement.query)
{ {
...@@ -36,22 +37,28 @@ DapConsoleRightPanelForm ...@@ -36,22 +37,28 @@ DapConsoleRightPanelForm
onCommandQueryChanged: onCommandQueryChanged:
{ {
console.log("commandQuery", commandQuery)
//Adding only new element //Adding only new element
if(!findElement(modelHistoryConsole, {query: commandQuery})) if(!findElement(modelHistoryConsole, {query: commandQuery}))
{ {
if(commandQuery !== "") if(commandQuery !== "")
{
modelHistoryConsole.insert(0, {query: commandQuery}); modelHistoryConsole.insert(0, {query: commandQuery});
}
} }
else else
modelHistoryConsole.insert(0, {query: commandQuery}); modelHistoryConsole.insert(0, {query: commandQuery});
//History is limited by historySize and realized as FIFO //History is limited by historySize and realized as FIFO
if(historySize < modelHistoryConsole.count) if(historySize < modelHistoryConsole.count)
{
modelHistoryConsole.remove(modelHistoryConsole.count-1); modelHistoryConsole.remove(modelHistoryConsole.count-1);
}
//Handler for the doubleClick on right history panel
onHistoryQueryIndexChanged:
{
if(historyQueryIndex > -1)
{
historyQuery = modelHistoryConsole.get(historyQueryIndex).query;
historyQueryIndex = -1;
historyQuery = ""
} }
} }
} }
...@@ -65,7 +65,7 @@ DapAbstractRightPanel ...@@ -65,7 +65,7 @@ DapAbstractRightPanel
{ {
id: historyQueryMouseArea id: historyQueryMouseArea
anchors.fill: textCommand anchors.fill: textCommand
onDoubleClicked: historyQuery = textCommand.text onDoubleClicked: historyQueryIndex = index
} }
} }
//It allows to see last element of list by default //It allows to see last element of list by default
......
...@@ -19,6 +19,8 @@ DapConsoleScreenForm ...@@ -19,6 +19,8 @@ DapConsoleScreenForm
{ {
//The start point for using history //The start point for using history
consoleHistoryIndex = modelConsoleCommand.count consoleHistoryIndex = modelConsoleCommand.count
//Set focus to console input
consoleInput.forceActiveFocus()
} }
QtObject QtObject
...@@ -75,19 +77,21 @@ DapConsoleScreenForm ...@@ -75,19 +77,21 @@ DapConsoleScreenForm
if(sendedCommand != "") if(sendedCommand != "")
{ {
sendCommand = sendedCommand; sendCommand = sendedCommand;
consoleHistoryIndex = modelConsoleCommand.count; consoleHistoryIndex = modelConsoleCommand.count + 1;
runCommand(sendCommand) runCommand(sendCommand)
sendedCommand = ""; sendedCommand = "";
currentCommand = sendedCommand; currentCommand = sendedCommand;
} }
} }
//Send command fron right history panel //Send command fron right history panel
onHistoryCommandChanged: onHistoryCommandChanged:
{ {
sendCommand = historyCommand; sendCommand = historyCommand;
runCommand(sendCommand) runCommand(sendCommand);
consoleHistoryIndex = modelConsoleCommand.count; consoleHistoryIndex = modelConsoleCommand.count + 1;
consoleInput.forceActiveFocus();
} }
//Using KeyUp and KeyDown to serf on console history //Using KeyUp and KeyDown to serf on console history
...@@ -97,7 +101,6 @@ DapConsoleScreenForm ...@@ -97,7 +101,6 @@ DapConsoleScreenForm
{ {
if(consoleHistoryIndex >= modelConsoleCommand.count) if(consoleHistoryIndex >= modelConsoleCommand.count)
{ {
consoleHistoryIndex = modelConsoleCommand.count;
currentCommand = ""; currentCommand = "";
return; return;
} }
...@@ -107,4 +110,5 @@ DapConsoleScreenForm ...@@ -107,4 +110,5 @@ DapConsoleScreenForm
currentCommand = modelConsoleCommand.get(consoleHistoryIndex).query; currentCommand = modelConsoleCommand.get(consoleHistoryIndex).query;
return; return;
} }
} }
...@@ -16,6 +16,8 @@ DapAbstractScreen ...@@ -16,6 +16,8 @@ DapAbstractScreen
property alias currentCommand: consoleCmd.text property alias currentCommand: consoleCmd.text
///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history. ///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history.
property int consoleHistoryIndex property int consoleHistoryIndex
///@detalis consoleInput Reference to console input area
property alias consoleInput: consoleCmd
Rectangle Rectangle
{ {
...@@ -26,20 +28,22 @@ DapAbstractScreen ...@@ -26,20 +28,22 @@ DapAbstractScreen
anchors.rightMargin: 20 * pt anchors.rightMargin: 20 * pt
anchors.bottomMargin: 20 * pt anchors.bottomMargin: 20 * pt
ListView ListView
{ {
id: listViewConsoleCommand id: listViewConsoleCommand
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: (contentHeight < consoleRectangle.height - inputCommand.height) ? contentHeight : consoleRectangle.height - inputCommand.height height: (contentHeight < consoleRectangle.height - inputCommand.height) ?
contentHeight :
consoleRectangle.height - inputCommand.height
clip: true clip: true
model: modelConsoleCommand model: modelConsoleCommand
delegate: delegateConsoleCommand delegate: delegateConsoleCommand
currentIndex: count - 1 currentIndex: count - 1
highlightFollowsCurrentItem: true highlightFollowsCurrentItem: true
highlightRangeMode: ListView.ApplyRange highlightRangeMode: ListView.ApplyRange
DapScrollViewHandling DapScrollViewHandling
{ {
id: scrollHandler id: scrollHandler
...@@ -75,13 +79,20 @@ DapAbstractScreen ...@@ -75,13 +79,20 @@ DapAbstractScreen
selectByMouse: true selectByMouse: true
focus: true focus: true
font: themeConsole.inputCommandFont font: themeConsole.inputCommandFont
Keys.onReturnPressed: text.length > 0 ? sendedCommand = text : sendedCommand = "" Keys.onReturnPressed: text.length > 0 ?
Keys.onEnterPressed: text.length > 0 ? sendedCommand = text : sendedCommand = "" sendedCommand = text :
Keys.onUpPressed: consoleHistoryIndex -= 1 sendedCommand = ""
Keys.onDownPressed: consoleHistoryIndex += 1 Keys.onEnterPressed: text.length > 0 ?
} sendedCommand = text :
sendedCommand = ""
Keys.onUpPressed: (consoleHistoryIndex > 0) ?
consoleHistoryIndex -= 1 :
null
Keys.onDownPressed: (consoleHistoryIndex < modelConsoleCommand.count) ?
consoleHistoryIndex += 1 :
null
}
} }
} }
DapScrollView DapScrollView
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment