Re: [SailfishDevel] Pagestack problems
On Thu, 10 Jul 2014 15:38:52 +0100 Chris Walker cdw_noki...@the-walker-household.co.uk wrote: On Thu, 10 Jul 2014 16:14:34 +0200 (CEST) sfietkonstan...@free.fr wrote: Hello, looking a bit at your code, you are using a pagestack.push, meaning that you effectively adds another page to your pagestack. For adding a new beer, I think that the best would be using a Dialog component. Ok. I'll take a look at how I might do that. I've finally tried adding a Dialog component but it's not working i.e. it's not opening a new page but the worst bit is that Creator is not telling me what's wrong i.e. it isn't reporting any errors. Here are (what I think) the relevant parts of the code :- Page { id: brewerylistpage ... PullDownMenu { MenuItem { text: qsTr(About); onClicked: { pageStack.push(Qt.resolvedUrl(About.qml)) } } MenuItem { text: Add Brewery onClicked: Qt.createComponent(AddBreweryPage.qml).createObject(brewerylistpage, {}); The AddBreweryPage has already been defined and works but leads to page navigation problems as discussed above. In an effort to resolve my problem, I've been looking at this page - http://qt-project.org/forums/viewthread/26455 but it hasn't helped me fix it. So where have I gone wrong? For reference, I haven't uploaded any of this modified code to git. ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
you do not need to reload page, so there wouldn't any navigation problems at all :) 10.07.2014 19:23, Chris Walker пишет: On Thu, 10 Jul 2014 12:45:46 + fasza2mob...@gmail.com wrote: Hi Chris, Why don't you just update your model when the data changes? The view(s) should update automatically. Ok, but how does that solve the page navigation problem? ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
On Thu, 10 Jul 2014 19:45:28 +0600 Andrey Kozhevnikov coderusin...@gmail.com wrote: you do not need to reload page, so there wouldn't any navigation problems at all :) I'm afraid you have me thoroughly confused now. Can you do me a favour and take a look at my code and let me know where I'm going wrong and what I should be doing? It's here - https://github.com/tonercloud/beertent/tree/master/beertent The only change I've made since I uploaded that is to add #include QQmlContext to beertent.cpp Ta. ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
Hello, looking a bit at your code, you are using a pagestack.push, meaning that you effectively adds another page to your pagestack. For adding a new beer, I think that the best would be using a Dialog component. - Mail original - De: Chris Walker cdw_noki...@the-walker-household.co.uk À: devel@lists.sailfishos.org Envoyé: Jeudi 10 Juillet 2014 15:53:10 Objet: Re: [SailfishDevel] Pagestack problems On Thu, 10 Jul 2014 19:45:28 +0600 Andrey Kozhevnikov coderusin...@gmail.com wrote: you do not need to reload page, so there wouldn't any navigation problems at all :) I'm afraid you have me thoroughly confused now. Can you do me a favour and take a look at my code and let me know where I'm going wrong and what I should be doing? It's here - https://github.com/tonercloud/beertent/tree/master/beertent The only change I've made since I uploaded that is to add #include QQmlContext to beertent.cpp Ta. ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
First off, you should place each class to its own heeader and source file to reduce future compile time. When you change only one class you won't have to recompile everything thus it's easier to find the classes. You should use one of the Qt Sql Model classes: http://qt-project.org/doc/qt-4.8/sql-model.html something like: logic --- qml logic --- databaseManager databaseManager --- databaseModel view --- databaseModel logic has a member function/slot to return a pointer to the model that qml displays in a view. logic also has a function/slot that takes the required data from qml that is needed to add a new entry in the database. This function invokes a member function of databaseManager that does the real work, hence only databaseManager touches the database the view will interact with the model to which it has a pointer from logic which in turn asks for the pointer from databaseManager. When a new entry is added databaseManager updates its model that emits the needed signals that informs any connected views about the changes. On 10 July 2014 15:14, sfietkonstan...@free.fr wrote: Hello, looking a bit at your code, you are using a pagestack.push, meaning that you effectively adds another page to your pagestack. For adding a new beer, I think that the best would be using a Dialog component. - Mail original - De: Chris Walker cdw_noki...@the-walker-household.co.uk À: devel@lists.sailfishos.org Envoyé: Jeudi 10 Juillet 2014 15:53:10 Objet: Re: [SailfishDevel] Pagestack problems On Thu, 10 Jul 2014 19:45:28 +0600 Andrey Kozhevnikov coderusin...@gmail.com wrote: you do not need to reload page, so there wouldn't any navigation problems at all :) I'm afraid you have me thoroughly confused now. Can you do me a favour and take a look at my code and let me know where I'm going wrong and what I should be doing? It's here - https://github.com/tonercloud/beertent/tree/master/beertent The only change I've made since I uploaded that is to add #include QQmlContext to beertent.cpp Ta. ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
On Thu, 10 Jul 2014 16:14:34 +0200 (CEST) sfietkonstan...@free.fr wrote: Hello, looking a bit at your code, you are using a pagestack.push, meaning that you effectively adds another page to your pagestack. For adding a new beer, I think that the best would be using a Dialog component. Ok. I'll take a look at how I might do that. Many thanks for looking. ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
On Thu, 10 Jul 2014 15:45:08 +0100 Krisztian Olah fasza2mob...@gmail.com wrote: First off, you should place each class to its own heeader and source file to reduce future compile time. When you change only one class you won't have to recompile everything thus it's easier to find the classes. You should use one of the Qt Sql Model classes: http://qt-project.org/doc/qt-4.8/sql-model.html something like: logic --- qml logic --- databaseManager databaseManager --- databaseModel view --- databaseModel logic has a member function/slot to return a pointer to the model that qml displays in a view. logic also has a function/slot that takes the required data from qml that is needed to add a new entry in the database. This function invokes a member function of databaseManager that does the real work, hence only databaseManager touches the database the view will interact with the model to which it has a pointer from logic which in turn asks for the pointer from databaseManager. When a new entry is added databaseManager updates its model that emits the needed signals that informs any connected views about the changes. What you describe is exactly what I would like to achieve with the next version of the program but one which uses 2 databases, one provided by an organisation called CAMRA - www.camra.org.uk and my own to record any visits to pubs and the beers I drink there. But that's some way away as I my programming ability needs to improve considerably before I can do such things! When you get to my age, these things don't come easily. Certainly they don't for me. Perhaps I should leave things as they are on this program and concentrate on the new one! ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org
Re: [SailfishDevel] Pagestack problems
The Model View Controller concept is a bit hard to grasp at first, but trust me once you learned it, it will be your prefered method. You will never regret learning it. As for your programming ability, it will improve by time, by setting new challenges you will learn and improve much faster, but you will likely feel that you are no good. The more often you face a problem, the quicker you can solve it. By trying to find always different problems to solve, you increase the chances of meeting a problem you already solved. So, don't be afraid of challenges, they'll be teaching you the most. What I would suggest is that you try to design your programs in a modular way so that you can later easily extend it, and if you know that you will have to add something in the future, try to accommodate it as early as possible. By that I mean make it easy to add. Otherwise there is always the possibility of refactoring. Regards Kris PS.: I think I suck at programming, but I think I suck much less than a year ago, so I guess I have improved. ;) On Thu Jul 10 2014 16:19:10 GMT+0100 (BST), Chris Walker wrote: On Thu, 10 Jul 2014 15:45:08 +0100 Krisztian Olah fasza2mob...@gmail.com wrote: First off, you should place each class to its own heeader and source file to reduce future compile time. When you change only one class you won't have to recompile everything thus it's easier to find the classes. You should use one of the Qt Sql Model classes: http://qt-project.org/doc/qt-4.8/sql-model.html something like: logic --- qml logic --- databaseManager databaseManager --- databaseModel view --- databaseModel logic has a member function/slot to return a pointer to the model that qml displays in a view. logic also has a function/slot that takes the required data from qml that is needed to add a new entry in the database. This function invokes a member function of databaseManager that does the real work, hence only databaseManager touches the database the view will interact with the model to which it has a pointer from logic which in turn asks for the pointer from databaseManager. When a new entry is added databaseManager updates its model that emits the needed signals that informs any connected views about the changes. What you describe is exactly what I would like to achieve with the next version of the program but one which uses 2 databases, one provided by an organisation called CAMRA - www.camra.org.uk and my own to record any visits to pubs and the beers I drink there. But that's some way away as I my programming ability needs to improve considerably before I can do such things! When you get to my age, these things don't come easily. Certainly they don't for me. Perhaps I should leave things as they are on this program and concentrate on the new one! ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org ___ SailfishOS.org Devel mailing list To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org