Added User search support

This commit is contained in:
Dusko Angirevic 2017-10-27 16:44:35 +02:00
parent 539e681331
commit 10f27b9d50
10 changed files with 144 additions and 97 deletions

View file

@ -62,6 +62,7 @@ OTHER_FILES += qml/harbour-tooter.qml \
qml/pages/components/VisualContainer.qml \
qml/pages/components/MiniStatus.qml \
qml/pages/components/MiniHeader.qml \
qml/pages/components/ItemUser.qml \
harbour-tooter.desktop
SAILFISHAPP_ICONS = 86x86 108x108 128x128 256x256

View file

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.1, 2017-10-25T00:36:59. -->
<!-- Written by QtCreator 4.0.1, 2017-10-27T16:44:08. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{41ec03ca-9430-48f3-b421-990d428b2838}</value>
<value type="QByteArray">{25497605-1bff-4134-a878-76c1475dd8e3}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -61,12 +61,12 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">SailfishOS-i486 (in Sailfish OS Build Engine)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">SailfishOS-i486 (in Sailfish OS Build Engine)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{2b6dd414-d640-472a-9475-472ab2c5e22e}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c5294635-b154-4f12-9c01-f8fe0f997f49}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -138,7 +138,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -210,7 +210,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_i486_in_Sailfish_OS_Build_Engine-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -396,7 +396,7 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>
@ -414,7 +414,7 @@
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">true</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
</valuemap>
@ -426,12 +426,12 @@
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">SailfishOS-armv7hl (in Sailfish OS Build Engine)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">SailfishOS-armv7hl (in Sailfish OS Build Engine)</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{e475a8ea-d9f2-4d35-b4f0-1f1076cd8d23}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{c33e8913-ac83-4c44-be39-b4748ccc7738}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -503,7 +503,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -575,7 +575,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Profile</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-SailfishOS_armv7hl_in_Sailfish_OS_Build_Engine-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -761,7 +761,7 @@
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>

View file

@ -99,20 +99,20 @@ CoverBackground {
color: Theme.primaryColor
}
/*CoverActionList {
CoverActionList {
id: coverAction
CoverAction {
iconSource: "image://theme/icon-cover-next"
onTriggered: {
label.text = Logic.modelTLhome.count
Logic.conf.notificationLastID = 0;
}
}
CoverAction {
iconSource: "image://theme/icon-cover-pause"
}
}*/
}
function checkNotifications(){
console.log("checkNotifications")
var notificationsNum = 0

View file

@ -10,22 +10,36 @@ Page {
property alias title: header.title
property alias description: header.description
property alias avatar: header.image
property string suggestedUser: ""
property ListModel suggestedModel;
property int toot_id
property ListModel mdl;
allowedOrientations: Orientation.All
onSuggestedUserChanged: {
console.log(suggestedUser)
suggestedModel = Qt.createQmlObject('import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject');
predictionList.visible = false;
if (suggestedUser.length > 0) {
var msg = {
'action' : 'accounts/search',
'method' : 'GET',
'model' : suggestedModel,
'mode' : "append",
'params' : [ {name: "q", data: suggestedUser} ],
'conf' : Logic.conf
};
worker.sendMessage(msg);
predictionList.visible = true;
}
}
ListModel {
id: mediaModel
onCountChanged: {
btnAddImage.enabled = mediaModel.count < 4
}
}
ListModel {
id: suggestedModel
onCountChanged: {
console.log("aaaa " + count)
}
}
WorkerScript {
id: worker
@ -77,44 +91,26 @@ Page {
anchors.bottom: panel.top
anchors.left: parent.left
anchors.right: panel.right
height: Theme.itemSizeMedium * 6
height: suggestedModel.count > 6 ? Theme.itemSizeMedium * 6 : Theme.itemSizeMedium * suggestedModel.count
color: Theme.highlightDimmerColor
ListView {
SilicaListView {
anchors.fill: parent
model: suggestedModel
clip: true
delegate: BackgroundItem {
height: Theme.itemSizeMedium
width: parent.width
Image {
id: avatar
width: Theme.itemSizeSmall
height: width
source: model.account_avatar
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
}
Column {
anchors.left: avatar.right
anchors.leftMargin: Theme.paddingLarge
anchors.verticalCenter: parent.verticalCenter
height: account_acct.height + display_name.height
Label {
id: display_name
text: model.account_display_name+" "
font.pixelSize: Theme.fontSizeMedium
}
Label {
id: account_acct
text: "@"+model.account_acct
color: Theme.secondaryColor
anchors.leftMargin: Theme.paddingMedium
font.pixelSize: Theme.fontSizeExtraSmall
delegate: ItemUser {
onClicked: {
var start = toot.cursorPosition;
while(toot.text[start] !== "@" && start > 0){
start--;
}
textOperations.text = toot.text
textOperations.cursorPosition = toot.cursorPosition
textOperations.moveCursorSelection(start-1,TextInput.SelectWords)
toot.text = textOperations.text.substring(0, textOperations.selectionStart) + ' @'+model.account_acct + ' ' + textOperations.text.substring(textOperations.selectionEnd).trim()
textOperations.text = ""
toot.cursorPosition = toot.text.indexOf('@'+model.account_acct)
}
}
onCountChanged: {
@ -153,6 +149,11 @@ Page {
//tweet()
}
}
TextInput {
id: textOperations
visible: false
}
TextArea {
id: toot
anchors {
@ -164,7 +165,7 @@ Page {
}
autoScrollEnabled: true
labelVisible: false
// focus: true
//focus: true
text: description !== "" && (description.charAt(0) == '@' || description.charAt(0) == '#') ? description+' ' : ''
height: implicitHeight
horizontalAlignment: Text.AlignLeft
@ -172,41 +173,14 @@ Page {
//tweet()
}
onTextChanged: {
var pattern = /\B@[a-z0-9_-]+/gi;
var mentions = text.match(pattern);
if (mentions && mentions.length){
var index = text.indexOf(cursorPosition);
var preText = text.substring(0, cursorPosition);
var current;
if (preText.indexOf(" ") > 0) {
var words = preText.split(" ");
current = words[words.length - 1]; //return last word
}
else {
current = preText;
}
if (current[0] === "@") {
predictionList.visible = true;
var matches = mentions.filter(function(value){
if(value) {
return (value.substring(0, current.length) === current);
}
});
console.log(matches)
var msg = {
'action' : 'accounts/search',
'method' : 'GET',
'model' : suggestedModel,
'mode' : "append",
'params' : [ {name: "q", data: matches[0].substring(1)} ],
'conf' : Logic.conf
};
worker.sendMessage(msg);
} else {
predictionList.visible = false;
}
textOperations.text = toot.text
textOperations.cursorPosition = toot.cursorPosition
textOperations.selectWord()
textOperations.select(textOperations.selectionStart ? textOperations.selectionStart-1 : 0, textOperations.selectionEnd)
console.log(textOperations.text.substr(textOperations.selectionStart, textOperations.selectionEnd))
suggestedUser = ""
if (textOperations.selectedText.charAt(0) === "@") {
suggestedUser = textOperations.selectedText.trim().substring(1);
}
}
}
@ -577,7 +551,9 @@ Page {
text: glyph
}
onClicked: {
toot.text = toot.text + model.glyph
var cursorPosition = toot.cursorPosition
toot.text = toot.text.substring(0, cursorPosition) + model.glyph + toot.text.substring(cursorPosition)
toot.cursorPosition = cursorPosition+model.glyph.length
emoticonsDialog.canAccept = true;
emoticonsDialog.accept()

View file

@ -96,6 +96,12 @@ Page {
tlSearch.type = "timelines/tag/"+search.substring(1)
loadData("append")
}
if (search[0] === "@") {
tlSearch.type = "accounts/search"
tlSearch.params = []
tlSearch.params.push({name: 'q', data: search.substring(1)});
loadData("append")
}
}
onTypeChanged: {
console.log("type changed")
@ -119,9 +125,14 @@ Page {
}
}
ViewPlaceholder {
enabled: tlSearch.mdl === 0
text: "Only #hastag search works"
}
enabled: tlSearch.mdl === 0
text: "Only #hastag search works"
}
delegate: Loader {
width: parent.width
source: tlSearch.search[0] === "@" ? "components/ItemUser.qml" : "components/VisualContainer.qml"
}
}
}

View file

@ -0,0 +1,48 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import QtGraphicalEffects 1.0
BackgroundItem {
id: delegate
//property string text: "0"
height: Theme.itemSizeMedium
width: parent.width
Image {
id: avatar
width: Theme.itemSizeExtraSmall
height: width
source: model.account_avatar
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: Theme.horizontalPageMargin
MouseArea {
anchors.fill: parent
onClicked: pageStack.push(Qt.resolvedUrl("./../Profile.qml"), {
"displayname": model.account_username,
"username": model.account_acct,
"user_id": model.account_id,
"profileImage": model.account_avatar
})
}
}
Column {
anchors.left: avatar.right
anchors.leftMargin: Theme.paddingLarge
anchors.verticalCenter: parent.verticalCenter
height: account_acct.height + display_name.height
Label {
id: display_name
text: model.account_display_name+" "
color: !pressed ? Theme.primaryColor : Theme.highlightColor
font.pixelSize: Theme.fontSizeSmall
}
Label {
id: account_acct
text: "@"+model.account_acct
color: !pressed ? Theme.secondaryColor : Theme.secondaryHighlightColor
anchors.leftMargin: Theme.paddingMedium
font.pixelSize: Theme.fontSizeExtraSmall
}
}
}

View file

@ -166,6 +166,10 @@ SilicaListView {
}
function loadData(mode){
var p = [];
if (params.length)
for(var i = 0; i<params.length; i++)
p.push(params[i])
if (mode === "append" && model.count){
p.push({name: 'max_id', data: model.get(model.count-1).id});
}

View file

@ -44,3 +44,10 @@
- Cover page fix for SailfishX
- Added Copy URL option
- Privacy option in the conversation is now inherited by toot in the thread
* Fri October 27 2017 Dusko Angirevic <dysko@me.com> 0.2.3-0
- Added User autocomplete options
- Added video player options
- Smileys are inserted on the cursor position
- Pintch to zoom photos
- Support for downloading media to the device

View file

@ -13,7 +13,7 @@ Name: harbour-tooter
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Tooter
Version: 0.2.2
Version: 0.2.3
Release: 0
Group: Qt/Qt
License: LICENSE

View file

@ -1,6 +1,6 @@
Name: harbour-tooter
Summary: Tooter
Version: 0.2.2
Version: 0.2.3
Release: 0
# The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS