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
1 merge request!11Cellframe clone
......@@ -7,6 +7,8 @@ DapConsoleRightPanelForm
property string commandQuery
///@detalis historyQuery Text of command from the command history.
property string historyQuery
///@detalis historyQueryIndex Index of command from the command history.
property string historyQueryIndex
///@detalis historySize Num of history command at right panel.
property int historySize: 10
......@@ -23,7 +25,6 @@ DapConsoleRightPanelForm
//Returns true if item 'someElement' is already exist at list 'someModel'.
function findElement(someModel, someElement)
{
console.log("someElement.query", someElement.query)
for(var i = 0; i < someModel.count; ++i)
if(someModel.get(i).query === someElement.query)
{
......@@ -36,22 +37,28 @@ DapConsoleRightPanelForm
onCommandQueryChanged:
{
console.log("commandQuery", commandQuery)
//Adding only new element
if(!findElement(modelHistoryConsole, {query: commandQuery}))
{
if(commandQuery !== "")
{
modelHistoryConsole.insert(0, {query: commandQuery});
}
}
else
modelHistoryConsole.insert(0, {query: commandQuery});
//History is limited by historySize and realized as FIFO
if(historySize < modelHistoryConsole.count)
{
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
{
id: historyQueryMouseArea
anchors.fill: textCommand
onDoubleClicked: historyQuery = textCommand.text
onDoubleClicked: historyQueryIndex = index
}
}
//It allows to see last element of list by default
......
......@@ -19,6 +19,8 @@ DapConsoleScreenForm
{
//The start point for using history
consoleHistoryIndex = modelConsoleCommand.count
//Set focus to console input
consoleInput.forceActiveFocus()
}
QtObject
......@@ -75,19 +77,21 @@ DapConsoleScreenForm
if(sendedCommand != "")
{
sendCommand = sendedCommand;
consoleHistoryIndex = modelConsoleCommand.count;
consoleHistoryIndex = modelConsoleCommand.count + 1;
runCommand(sendCommand)
sendedCommand = "";
currentCommand = sendedCommand;
}
}
//Send command fron right history panel
onHistoryCommandChanged:
{
sendCommand = historyCommand;
runCommand(sendCommand)
consoleHistoryIndex = modelConsoleCommand.count;
runCommand(sendCommand);
consoleHistoryIndex = modelConsoleCommand.count + 1;
consoleInput.forceActiveFocus();
}
//Using KeyUp and KeyDown to serf on console history
......@@ -97,7 +101,6 @@ DapConsoleScreenForm
{
if(consoleHistoryIndex >= modelConsoleCommand.count)
{
consoleHistoryIndex = modelConsoleCommand.count;
currentCommand = "";
return;
}
......@@ -107,4 +110,5 @@ DapConsoleScreenForm
currentCommand = modelConsoleCommand.get(consoleHistoryIndex).query;
return;
}
}
......@@ -16,6 +16,8 @@ DapAbstractScreen
property alias currentCommand: consoleCmd.text
///@detalis consoleHistoryIndex Index for using KeyUp and KeyDown to the navigation in console history.
property int consoleHistoryIndex
///@detalis consoleInput Reference to console input area
property alias consoleInput: consoleCmd
Rectangle
{
......@@ -26,20 +28,22 @@ DapAbstractScreen
anchors.rightMargin: 20 * pt
anchors.bottomMargin: 20 * pt
ListView
{
id: listViewConsoleCommand
anchors.top: parent.top
anchors.left: parent.left
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
model: modelConsoleCommand
delegate: delegateConsoleCommand
currentIndex: count - 1
highlightFollowsCurrentItem: true
highlightRangeMode: ListView.ApplyRange
DapScrollViewHandling
{
id: scrollHandler
......@@ -75,13 +79,20 @@ DapAbstractScreen
selectByMouse: true
focus: true
font: themeConsole.inputCommandFont
Keys.onReturnPressed: text.length > 0 ? sendedCommand = text : sendedCommand = ""
Keys.onEnterPressed: text.length > 0 ? sendedCommand = text : sendedCommand = ""
Keys.onUpPressed: consoleHistoryIndex -= 1
Keys.onDownPressed: consoleHistoryIndex += 1
}
Keys.onReturnPressed: text.length > 0 ?
sendedCommand = text :
sendedCommand = ""
Keys.onEnterPressed: text.length > 0 ?
sendedCommand = text :
sendedCommand = ""
Keys.onUpPressed: (consoleHistoryIndex > 0) ?
consoleHistoryIndex -= 1 :
null
Keys.onDownPressed: (consoleHistoryIndex < modelConsoleCommand.count) ?
consoleHistoryIndex += 1 :
null
}
}
}
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