Active Topics

 



Notices


Reply
Thread Tools
olf's Avatar
Posts: 87 | Thanked: 313 times | Joined on Aug 2015
#11
Originally Posted by pichlo View Post
Off-topic, but just out of curiosity, why would people insist on top-posting like e.g. rfa in post #8 above?

It's annoying enough in emails I have to deal with every day at work but there I can at least accept people being clueless/careless/lazy (delete as appropriate) and just typing wherever Holy Microsoft has put the cursor. But to reply to a TMO post and still top post means going out of one's way to do it on purpose, since TMO is civil enough to place your cursor below the quoted text where it belongs.

I am not asking people to change their ways, that would be too much to ask. Just a simple rationale would do. As I say, out of curiosity.
@pichlo, you just outed yourself as a structure-nazi.
And I am absolutely with you.

But I already guessed that the answer is the obvious one: This is what many are accustomed to, i.e. what they perceive as usual (/ "normal") style.
But @rfa also provided a rationale, which I heard a couple of times from regular OL users reasoning for their email reply style, when using different clients than Outlook.

Originally Posted by rfa View Post
[...]I'm sorry if I've broken any rules
Don't worry, you did not "break any rules".
It is just an etiquette. Plus for "defenders of the right style", a convention.

I think a proper take away from @pichlo's injunction may be:
Do not top-post in Unix-centric environments.

Last edited by olf; 2018-03-13 at 20:18.
 

The Following 4 Users Say Thank You to olf For This Useful Post:
Posts: 174 | Thanked: 139 times | Joined on May 2010 @ Sunny Woollahra
#12
so, is it possible to use any of the weather patches or clock settings to show dawn & dusk times on the forecast and / or clock?
__________________
I think there should be another word for mondegreen
 

The Following User Says Thank You to rfa For This Useful Post:
Ancelad's Avatar
Posts: 1,443 | Thanked: 2,678 times | Joined on Jun 2012 @ Russia, 96
#13
Originally Posted by rfa View Post
so, is it possible to use any of the weather patches or clock settings to show dawn & dusk times on the forecast and / or clock?
Currently no
__________________
Twitter: @iAncelad
Try my SailfishOS theme for Nokia N9
 

The Following 2 Users Say Thank You to Ancelad For This Useful Post:
Markkyboy's Avatar
Posts: 256 | Thanked: 324 times | Joined on Oct 2012 @ location, location
#14
Right, fair enough. Moving on, same matter, different slant; As I cannot get live weather data (windspeed/direction) on the lockscreen, id like to try and get wind direction to show as intended, by that I mean, labelled "N" or "NE" and so on. I thought using an else/if type statement would make this happen and I'm halfway there, but still no cigar - the aim ultimately being to get this working and then going back to getting such data to show on lockscreen.

The file I'm editing is /usr/lib/qt5/qml/Sailfish/Weather/WeatherDetailsHeader.qml and this is what I've added so far,

Code:
        DetailItem {
            //% "WindDirection"
            label: qsTrId("Wind direction")
            value: {
                var windDirectionText
                var windDirection = 0
                if      (weather.windDirection=0)   windDirectionText='N';
                else if (weather.windDirection=45)  windDirectionText='NE';
                else if (weather.windDirection=90)  windDirectionText='E';
                else if (weather.windDirection=135) windDirectionText='SE';
                else if (weather.windDirection=180) windDirectionText='S';
                else if (weather.windDirection=225) windDirectionText='SW';
                else if (weather.windDirection=270) windDirectionText='W';
                else if (weather.windDirection=315) windDirectionText='NW';
            }
        }
Problem is, my output text is stuck on "NE" and does not change when selecting different days, so clearly there is something wrong with my code, but I have no idea what, so any clues here would be appreciated.

This is how the data above looks on the device (see "Wind direction" near the bottom of the screen but notice the position of the arrow at the top of the screen pointing from south);
Attached Images
 
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
Posts: 275 | Thanked: 1,239 times | Joined on Oct 2013 @ France
#15
Originally Posted by Markkyboy View Post
Code:
if (weather.windDirection=0) windDirectionText='N';
Shouldn't the test in the if be done using the comparison operator '==' (or '===' as QtCreator usually proposes when editing QML for a reason I forgot), and not the assignement operator '=' ?

And by the way, what do you do with the variable 'windDirectionText' ? I can't see it used anywhere except for setting its value ?
 

The Following 2 Users Say Thank You to Zeta For This Useful Post:
Markkyboy's Avatar
Posts: 256 | Thanked: 324 times | Joined on Oct 2012 @ location, location
#16
Originally Posted by Zeta View Post
Shouldn't the test in the if be done using the comparison operator '==' (or '===' as QtCreator usually proposes when editing QML for a reason I forgot), and not the assignement operator '=' ?

And by the way, what do you do with the variable 'windDirectionText' ? I can't see it used anywhere except for setting its value ?
Quite right Zeta on some points, especially windDirectionText...a remnant of other code I was playing with.
I'm not using QtCreator, the editing is done directly on the device via ssh. What you say about the operators is not strictly true. I have used different variations with success, here's one example using a single '=' operator with success.

Once again, it's clear to me that I don;t quite know what I'm doing!
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
Posts: 275 | Thanked: 1,239 times | Joined on Oct 2013 @ France
#17
I am not sure I understand.
Originally Posted by Markkyboy View Post
I have used different variations with success, here's one example using a single '=' operator with success.
While the previous message you said it didn't work:
Originally Posted by Markkyboy View Post
Problem is, my output text is stuck on "NE" and does not change when selecting different days, so clearly there is something wrong with my code, but I have no idea what, so any clues here would be appreciated.
So what is this success you are talking about ?

From what I understand (I am more of a C developer than JS...):
First test : the test is using the assignment operator and not the comparison one, so you are actually setting the variable weather.windDirection to 0.
I assume in JS its behavior is like in C, where the whole instruction returns the value that was assigned, so "if(weather.windDirection=0)" is then evaluated to " if(0)" which is false.
So it takes the first else. There the variable is assigned to 45, and likewise the tests is "if(45)" which is true (not 0), so it take the instruction windDirectionText='NE', which probably return the result of this assignement as the return value of the block, so it is always showing "NE", no matter the variable weather.windDirection which gets overwritten constantly by each "test".

I could be wrong in this analysis, but something like the following should be better:
Code:
DetailItem {
            //% "WindDirection"
            label: qsTrId("Wind direction")
            value: {
                if      (weather.windDirection == 0) return 'N';
                else if (weather.windDirection == 45) return 'NE';
                else if (weather.windDirection == 90) return 'E';
                else if (weather.windDirection == 135) return 'SE';
                else if (weather.windDirection == 180) return 'S';
                else if (weather.windDirection == 225) return 'SW';
                else if (weather.windDirection == 270) return 'W';
                else if (weather.windDirection == 315) return 'NW';
            }
        }
I am not sure of the need of the "return" here, I usually use ternary operator for this kind of tests, which gets ugly fast.

Are the only possible values those 45 degrees multiples ? If not, you should use "<=" comparison for it to work for other values (and adding 22.5 degrees to each value).
 

The Following 3 Users Say Thank You to Zeta For This Useful Post:
Markkyboy's Avatar
Posts: 256 | Thanked: 324 times | Joined on Oct 2012 @ location, location
#18
Hi, thanks for replying....
apologies, my life is upside down here as I am about to move.

My reference to success came without a link to another page here on TJC, to show different ways operators can work, this is the reference; http://talk.maemo.org/showpost.php?p...22&postcount=5

Looking at that page now, I can see '=' has not been used alone. I should also make it clear that I'm no expert in any coding field, I simply enjoy tinkering, guessing, playing around until something works, then within that journey, I learn.

I tried your code, sadly it yields an undesired result, no data is displayed but by removing '==' and replacing with '=', I then get "NE" always displayed, so no change

Yes, the WeatherModel.js file shows that the angles of wind direction are indeed all at/of 45 degree increments.

Thanks for your input.

Regards,
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!
 

The Following 2 Users Say Thank You to Markkyboy For This Useful Post:
Posts: 275 | Thanked: 1,239 times | Joined on Oct 2013 @ France
#19
OK.

I took some time to create a new empty QML project on Desktop to make some tests and be able to confirm what works and not only giving you some pointers.
To keep it simple (for me...) I used a slider to simulate the values of the weather.windDirection variable, and Text elements to show several solutions that all works for me (With the one you have above, I get the same result : stuck to "NE").

Feel free to choose whichever fits bets your way to code, and adjust it to your variable names (weather.windDirection in place of windDirection.value at least). Maybe some QML expert could point out what is the "QML way" to do this properly, even if they all works.

In order you have :
* if/else blocks with return
* if/else blocks without return
* ternary if operators
* string list based indexing (as wind direction can only be multiples of 45, dividing it by 45 gives a simple 0 based index to lookup in the string list)

If that example is not clear enough, I can try to put that at work directly in place in the patch you want to create, but would need your current code and if there is anything special to install (only Jolla's weather app ?) as I didn't follow all that was done at this point.

Code:
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.3

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")

    ColumnLayout {

        Slider {
            id : windDirection
            value: 180
            minimumValue: 0
            maximumValue: 315
            stepSize: 45
        }

        Text {
            text: {
                if      (windDirection.value == 0) return 'N';
                else if (windDirection.value == 45) return 'NE';
                else if (windDirection.value == 90) return 'E';
                else if (windDirection.value == 135) return 'SE';
                else if (windDirection.value == 180) return 'S';
                else if (windDirection.value == 225) return 'SW';
                else if (windDirection.value == 270) return 'W';
                else if (windDirection.value == 315) return 'NW';
            }
            font.pixelSize: 36
            color: "red"
        }

        Text {
            text: {
                if      (windDirection.value == 0) 'N';
                else if (windDirection.value == 45) 'NE';
                else if (windDirection.value == 90) 'E';
                else if (windDirection.value == 135) 'SE';
                else if (windDirection.value == 180) 'S';
                else if (windDirection.value == 225) 'SW';
                else if (windDirection.value == 270) 'W';
                else if (windDirection.value == 315) 'NW';
            }
            font.pixelSize: 36
            color: "green"
        }


        Text {
            text: (windDirection.value == 0) ? 'N' :
                (windDirection.value == 45) ? 'NE':
                (windDirection.value == 90) ? 'E':
                (windDirection.value == 135) ? 'SE':
                (windDirection.value == 180) ? 'S':
                (windDirection.value == 225) ? 'SW':
                (windDirection.value == 270) ? 'W':
                (windDirection.value == 315) ? 'NW' : '--'
            font.pixelSize: 36
            color: "blue"
        }

        Text {
            text: ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'][windDirection.value/45]
            font.pixelSize: 36
            color: "#FF7F00"
        }

    }
}
Hope this helps !
 

The Following 5 Users Say Thank You to Zeta For This Useful Post:
Markkyboy's Avatar
Posts: 256 | Thanked: 324 times | Joined on Oct 2012 @ location, location
#20
Thank you zeta, your input has helped a great deal and it now basically works as I wanted it, now to duplicate this on the homescreen, shouldn't be too hard to do!

Only modifying WeatherDetailsHeader.qml by adding the following;

Code:
        
        DetailItem {
            id: windDirection
            //% "WindDirection"
            label: qsTrId("Wind direction")
            value: {
                if      (model.windDirection==0)    'N'
                else if (model.windDirection==45)   'NE'
                else if (model.windDirection==90)   'E'
                else if (model.windDirection==135)  'SE'
                else if (model.windDirection==180)  'S'
                else if (model.windDirection==225)  'SW'
                else if (model.windDirection==270)  'W'
                else if (model.windDirection==315)  'NW'
            }
        }
Which yields...
Attached Images
   
__________________
| Openrepos | T.J.C. |

Don't just sit there standing around, pick up a shovel and sweep up!

Last edited by Markkyboy; 2018-04-10 at 15:47.
 

The Following 3 Users Say Thank You to Markkyboy For This Useful Post:
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 11:58.