diff options
author | Daniel Molkentin <daniel.molkentin@nokia.com> | 2011-07-22 14:29:14 +0200 |
---|---|---|
committer | Daniel Molkentin <daniel.molkentin@nokia.com> | 2011-07-22 18:29:40 +0200 |
commit | 26851ec3fa57bdb05b12a4262cf0bcf8b27591f1 (patch) | |
tree | 5824980a8865eaf2ee0f811d44c23c324fa3a9d5 /share | |
parent | e6dbfb2d1a31bb6fdb8cb99463387b974a066f26 (diff) |
WelcomeScreen: Implementing proper search lexer/parser for the lineedit.
Now copes with quotes and "tag:" prefixes.
Change-Id: I348e533ab290242fd05a034a2912cc95f0a9a3da
Done-with: Roberto Raggi
Reviewed-on: http://codereview.qt.nokia.com/2038
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
Diffstat (limited to 'share')
-rw-r--r-- | share/qtcreator/welcomescreen/widgets/ExampleBrowser.qml | 20 | ||||
-rw-r--r-- | share/qtcreator/welcomescreen/widgets/ExampleDelegate.qml | 47 |
2 files changed, 49 insertions, 18 deletions
diff --git a/share/qtcreator/welcomescreen/widgets/ExampleBrowser.qml b/share/qtcreator/welcomescreen/widgets/ExampleBrowser.qml index c81c6e31a16..87c742be237 100644 --- a/share/qtcreator/welcomescreen/widgets/ExampleBrowser.qml +++ b/share/qtcreator/welcomescreen/widgets/ExampleBrowser.qml @@ -36,10 +36,18 @@ import widgets 1.0 as Widgets Item { id: exampleBrowserRoot + function appendTag(tag) { + var tagStr = "tag:" + '"' + tag + '"' + if (lineEdit.text == "") + lineEdit.text = tagStr + else + lineEdit.text += " " + tagStr + } + Rectangle { - color:"#f4f4f4" id : lineEditRoot + color:"#f4f4f4" width: parent.width height: lineEdit.height + 6 anchors.bottom: parent.bottom @@ -50,14 +58,14 @@ Item { anchors.rightMargin: scrollArea.verticalScrollBar.visible ? 0 : -8 Widgets.LineEdit { + id: lineEdit placeholderText: !checkBox.checked ? qsTr("Search in Tutorials") : qsTr("Search in Tutorials, Examples and Demos") focus: true - id: lineEdit anchors.left: parent.left anchors.leftMargin:4 anchors.verticalCenter: parent.verticalCenter width: Math.max(lineEditRoot.width - checkBox.width - 28 - tagFilterButton.width, 100) - onTextChanged: examplesModel.filterRegExp = RegExp('.*'+text, "im") + onTextChanged: examplesModel.parseSearchString(text) } CheckBox { @@ -74,12 +82,12 @@ Item { Button { id: tagFilterButton property string tag - onTagChanged: { examplesModel.filterTag = tag; examplesModel.updateFilter() } + onTagChanged: exampleBrowserRoot.appendTag(tag) anchors.left: checkBox.right anchors.leftMargin: 6 anchors.verticalCenter: lineEdit.verticalCenter visible: !examplesModel.showTutorialsOnly - text: tag === "" ? qsTr("Filter by Tag") : qsTr("Tag Filter: %1").arg(tag) + text: qsTr("Tag List") onClicked: { tagBrowserLoader.source = "TagBrowser.qml" tagBrowserLoader.item.visible = true @@ -96,7 +104,7 @@ Item { Repeater { id: repeater model: examplesModel - delegate: ExampleDelegate { width: scrollArea.width } + delegate: ExampleDelegate { width: scrollArea.width; onTagClicked: exampleBrowserRoot.appendTag(tag) } } } Component.onCompleted: verticalScrollBar.anchors.bottomMargin = -(scrollArea.anchors.bottomMargin + 8) diff --git a/share/qtcreator/welcomescreen/widgets/ExampleDelegate.qml b/share/qtcreator/welcomescreen/widgets/ExampleDelegate.qml index 8aa5d48893c..21106ca15e5 100644 --- a/share/qtcreator/welcomescreen/widgets/ExampleDelegate.qml +++ b/share/qtcreator/welcomescreen/widgets/ExampleDelegate.qml @@ -37,6 +37,8 @@ Rectangle { id: root height: Math.max(image.height-20, description.paintedHeight) + 68 color: "#00ffffff" + property variant tags : model.tags + signal tagClicked(string tag) Components.QStyleItem { cursor: "pointinghandcursor" ; anchors.fill: parent } @@ -96,17 +98,6 @@ Rectangle { color:"#444" } - Row { - id: tagLine; - anchors.top: description.bottom - anchors.left: parent.left - anchors.topMargin: 5 - anchors.leftMargin: 10 - anchors.rightMargin: 26 - Text { id: labelText; text: "Tags: " ; color: "#999"; font.pixelSize: 11} - Text { text: model.tags.join(", "); color: "#bbb"; font.pixelSize: 11} - } - MouseArea { id: mouseArea anchors.fill: parent @@ -121,7 +112,39 @@ Rectangle { onExited: parent.state = "" } - + Row { + id: tagLine; + anchors.bottomMargin: 20 + anchors.top: description.bottom + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.rightMargin: 26 + spacing: 4 + Text { id: labelText; text: qsTr("Tags:") ; color: "#999"; font.pixelSize: 11} + Repeater { + model: tags; + Text { + states: [ State { name: "hover"; PropertyChanges { target: tagText; color: "black" } } ] + id: tagText + text: model.modelData + color: "#bbb" + font.pixelSize: 11 + MouseArea { + anchors.fill: parent; + hoverEnabled: true; + onEntered: { + root.state = "hover" + parent.state = "hover" + } + onExited:{ + root.state = "" + parent.state = "" + } + onClicked: root.tagClicked(model.modelData) + } + } + } + } states: [ State { name: "hover"; PropertyChanges { target: root; color: "#f9f9f9" } } ] } |