The fruitful summer of 2015 to now

Screenshot from 2015-12-29 11:43:42

Basically the graph here has been my progress so far. Back in June and July I conceived the idea of creating an application. In August I made my first commits using Qt Widgets but as it stood it wasn’t easy to provide animations and transitions with widgets so I contemplated about using QML/QtQuick, to tackle two different languages took a toll on me I had to take breaks for a few days. I barely knew C++, heck, I still don’t know much about it but most of its syntax I can recognize and digest compared to when I started. And QML is sort of like a this weird technology that is so implicit in nature it drives you insane, at the same time the more you use QML the more you realize that your whole application can react to practically anything, it’s like using Qt’s connect on steroids, seriously.

And that’s what so scary about QML in a way. When I started writing QML I always overdid my QML types to the point I had to refactor or rewrite it again. Now in December I use less built-in types and do more in a way because I’m aware of QML’s behavior and how most of the anchors/layouts lays/positions itself.

If you notice, there aren’t almost any commits in the month of November I’d say I was taking care of personal issues and dealing with college that kept me away from programming. I was also really burnt out due to dealing with two languages so there’s that.

Well, I hope I can start this January of 2016 with a bang finally releasing my app.

Synchronize everything!

I think today is the first time I’ve felt that I’m halfway done with my application. It’s a very intoxicating feeling and at the same time there’s a lot to be done in the user interface area, like really a lot to be done.

I spent most of the day fixing a few icky issues with the model I’m using because as of now I’m using it for general purposes since I didn’t want to create another model that basically does the same thing, the exception happens if I need to work with a very specialized visual that needs its own model. Thankfully I was able to cram all the necessary roles in the model and I don’t have to maintain to different models because while there aren’t much to models… they can get slightly confusing to work with.

Each day that passes and I make progress there are times that makes me wonder if this is all worth it, for all I know my app could be a dud. There’s also the experience gained from doing it… well, it’s all uncertain I guess no use thinking about it.

Either way, I may end up refactoring and tearing down a lot of useless and questionable design decisions let’s see how it goes.

6 months ago I started this personal project

It feels like forever.

Even if it’s all I talk about in this blog I have I decided to keep going with this as if I kept pondering whether to do it or not I would have never been at this stage.

2015-12-25

I refactored and added plenty of code this week. Refactoring because let’s be honest when I’m faced with a new framework and a new language I’m bound to code little building blocks of what we call “experiments”, the very nature of not knowing pushes you to make spaghetti code in some aspect but you must be always willing to part ways with your old code and refactor as much as you can.

View post on imgur.com

Yes, yes. Give into the “Yes!” chants. (Daniel Bryan if in case you aren’t into the whole wrestling thing).

After refactoring, implementing new code, and deleting old code it feels oh so much better than before to the point that I feel pretty satisfied of my work so far in the app. I think what I’ve learned throughout the whole journey of this will be invaluable in the future if you consider the investment in C++ and Qt worth it that is, which to me it is.

With the changes I’ve done I can finally concentrate on the interactions between the database backend and the models involved so it’s always synchronized.

In a related note, I must say I’m impressed by the blazing speed of SQLite/Qt in general. I still have a few worries about it but… so far it’s been a pretty darn straightforward easy to use abstraction.

Thing is I’m doing my best to keep a good pace and finally finish it. I hope all my efforts eventually pays off, if not… I won’t really call it a failure as I gained so much in the process.

Time will tell..

Paths

You know, never in my life I considered myself a classical music (using the term as macro) guy in the term that I never spared a thought about it. These days I would take my time going through the various artists Spotify lines up in their “Related artists” section. Amusingly all began in a “silly way”, I was binge watching Your Lie in April and some of the works that were performed during the series were to my liking. I should say that when I say “silly” I think there’s this preconceived notion that if you are inspired through a medium that is meant to be pure entertainment somehow it makes your experience “less” than others.

I say this because obviously I wasn’t raised listening to many classical figures–that at a mere second of playing the tune many in the scene would recognize it–no, nothing of the sort. I got interested in it because I watched a anime series, which I recommend to anyone with an interest in the medium.

In the past though, I have shown great affinity to progressive metal, jazz… so thinking about it it might not have been as incidental as I previously thought, or maybe it was. Who’s to know.

20151222_143838

I started cleaning today found textbooks lying in my shelve and on the floor I was quite surprised that there were some I’ve forgotten about like Mastering Regular Expressions and Guide to Japanese Grammar. At some point in my life I do want to learn Japanese, like any language it’s overwhelmingly complex; I know there are people born with that gift of learning any language in a short time, sadly I wasn’t born with a gift like that. This year my goals strays far away from learning Japanese, sadly, mostly because I have to focus on other matters I want to take care of.

Translator available

I had to remove Bing translator… not because it’s bad but because the widget sucks so much. If a user uses the widget Bing provided on the following visit he/she will get a floating box and that box would hinder the experience of the user, the box pretty much follows you anywhere. I prefer Google’s dropdown as you just select it and it doesn’t become intrusive.

Screenshot from 2015-12-21 13:11:59

Cheers.

The progress so far in 2015…

It’s been undoubtedly a hell of a year, where hell isn’t a synonym to “awesome”, “terrific” etc as some would expect. This year acted as a pandora box back in January and February dealing with a lot of issues. It was also the year I had to leave online communities and focus solely on myself due to health issues, and said health issues I’m still taking care of.

I made myself a goal, and that goal was to push myself to learn C++ and to delve into C. I’m rather proud that I’ve kept that goal up to this day. This blog’s C++ speaks volumes rather than me saying it. It was never about quality posts regarding C++ as a language, but a continuous effort to keep myself engaged in the language. As I kept learning I pushed myself to learn Qt which some of you have seen me talking about in the past.

As to why I’ve been pushing myself to learn C++, well, months ago I was talking about not being satisfied in web development. I wanted more, I wanted to push myself to the traditional desktop and being able to contribute to C/C++ related projects. The journey was hard but not impossible, even now I’m not an expert at all just another person striving to learn more about the language.

And with that I’ve forgotten on how to learn a language. When I say this I say it in the way that the last language I learned was Python and I’m really rusty at it since I don’t write python code. C++ has a lot of pitfalls and convoluted subjects like const-correctness which can be quite messy, passing by reference or value when it comes to it and believe me even if it sounds absurd it can save you memory to being with. It’s not the same referencing to an array pointer containing 500,000 elements and passing an array of 500,000 elements.

I’m a persistent person, I think that’s one of my qualities and yet one of my downfalls. Debugging and understanding most of the time goes together, when I don’t understand something I must “take it apart” and “look at how things are done” specific breakpoints. This was the case with QAbstractItemModel and it wasn’t really your typical “model” in terms of web development but something that was engineered to be the base of all models in Qt.

I haven’t had any type of trouble in college. My grades are pretty steady, and I feel like the remainder of my bachelor’s degree is going to be pretty neat as the courses left aren’t hard to deal.

The growing fear always been once I’m done if I’m just that guy that can get into software development shop, a part of me tells me yes, while the other says probably not.

Talking about fears I’ve wanted to take control of a few aspects of my life such as health, while I’m not going to spend my time being vague about the issues I’ll just say that I hope to conquer a lot of things in this 2016 and put my life back on track. Part of me leaving online communities was because I became too dependent of forums looking for social interactions. Truth is I needed to go out there, the real world not in a bubble where you find like-minded individuals to share things on a daily basis. Not that I’m the type of person to debate or bring “controversy”… I’m too lazy for that.

And yet I’m not satisfied with my progress. I fall back to old habits that I must get rid of as soon as possible. I need know when to leave an ongoing problem alone, I need to know my limits of when it tackling programming issues as I think as many of you programmers out there sometimes a bug happens and you just keep thinking about it and your special one is upset because your work is invading family time.

My goal isn’t perfection…. never has been even though sometimes I think I’m being too harsh on myself. It just that I have a great appreciation to an individual, and said individual has achieved a lot in such a short time that I can’t help but not call quits. And maybe, just maybe I’m holding that individual on a high pedestal but the person has given me every reason to believe a lot of things can be achieved.

And yet here we are.

All in all, it’s been a crazy, really crazy ride for me. All I know is that I must work twice as harder in 2016 to regain the trust of some individuals, and to excuse myself for some actions I have done in the past in real life. I guess you could say to be a “better person” whatever that is nowadays. More thinking before talking, more pacing yourself, just a bit more of everything that requires interaction with other people.

The list of things I want to improve myself is long, 1,000,000,000,000,000,000 pages long. Point is, if I complete at least 50% of what I proposed myself since this year, and the new goals I have set in motion in 2016 then I would be very proud of myself. I guess I could just sum it up in wanting a more active life than being in front of a computer in my free time.

But you know, it’s easy to do the talk, gotta do that walk as well. So, we’ll see how things go from here.

A tiny bite of GTK3

Update: I was able to fix YCM. Pretty happy about that 🙂

What a day it has been for me. I’m totally wasted after pretty much driving all day, I had no real plans for today either way but I wanted to get a bit of a head start with GTK3.

I’m a vim user, wait, I was a vim user. I’m not sure if it’s my disdain of spending too much time trying to get things to work but as of late Vim with YouCompleteMe has been completely crap, no iostream, no gtk, no sdl, nothing, nada. I’ve been left completely in the dark by YouCompleteMe. After some basic debugging and working with paths and realizing that compile_commands.json wasn’t making the cut as YCM wouldn’t bother checking ALL the methods available; I gave up, really. Opened CLion and with the same, unique header of #include <gtk/gtk.h> I was able to get all the methods, even the deprecated ones.

I hacked CMakeLists.txt to support c and find the right GTK3 headers and in less than 5 minutes I was already writing C with GTK3.

Screenshot from 2015-12-20 10:29:57

I’m honestly not sure how to feel about it. What I mean is that GTK3 design feels … weird in almost every account compared to Qt4 or Qt5. I’m more familiar with how things are laid out in Qt and this isn’t because I’ve been developing an application with Qt but because I’ve used other frameworks with a similar per module design. The classes makes sense, there’s nothing funky going out you also don’t have to write gtk_label_new() followed with a gtk_label_set_text() (yes, there’s gtk_label_new_with_text()) the whole “zen” is gone.

QLabel label("Hello");
label.setText("Hello there");

I’m biased as I like working with Qt, and not only that I’m probably being unfair as GTK3 design is meant to be different as it’s targeted (mainly) for C, and doesn’t support an object oriented approach unless you use gtkmm, which I could I guess.

This is just playing with GTK though, honestly I think I would go with Qt in the end. I WOULD like to write a minor app with Gtk3 some time in the future though.

Lesson learned: Always use layouts, _always use layouts_

Ever since I got myself started using QML I have run into some funny business dealing with certain margin sizes. One of my oh so bad ideas was to recalculate the margin of an Item that’s already in a layout totally disregarding the Layout.margins property that’s available in every Layout container. This sounds all simple, seriously, it feels like one of those things that you wouldn’t expect to do but to those who are still digesting QML it’s a very big miss.

Anyways, always use layouts and its available properties or you’ll be in a world of pain.

Well, let’s keep it minty?

Screenshot from 2015-12-16 00:57:50

I’ve been dual booting to Linux Mint in my laptop for a few days. As to why Linux Mint… I’m interested in elementaryOS in general, but as I see it right now eOS isn’t ready and Linux Mint provides a full fledged desktop and a solid experience. If you have heard me talk about linux then you’ll know I will always put stability over cutting-edge (rolling release).

Although honestly, as time passes I just don’t care anymore. As long as I can do my daily stuff, and that my OS let me develop however I want? I’m happy anything that works and doesn’t require more than 20-30 minutes per whatever issue.

When I start doing platform integration though… that’s another story.

as for dropbox… I have moved all my sensitive files to sync

Implementing TreeView expandAll/collapseAll starting on top-levels

I should start by a disclaimer that I’m neither a C++ or Qt expert, there may be better or elegant ways to do it and I have found this implementation is more straightforward than digging in TreeView’s QML source code.

So we have a small problem, the TreeView in QML doesn’t provide any way to expand or collapse items. Alright, what would be the best way to tackle this? Let’s look at the available options at our hands:

  • TreeView QML provides the following methods:
    • expand (QModelIndex)
    • collapse (…)
    • others …

And then we have implemented the AbstractItemModel. If you sit for a moment and think we can actually aggregate new methods to our AbstractItemModel with Q_INVOKABLE and call them in our QML code.

So we will implement a new method called getChildrenIndexes (that of course is sort of a bad name when I think about it).

QVariantList GenericModel::getChildrenIndexes()
{
    QVariantList indexes;
    GenericNode *parent = rootItem->child(0)->parent();

    for(int i = 0; i != parent->childCount(); ++i) {
        GenericNode *child = parent->child(i);
        indexes.push_back(createIndex(i,0, reinterpret_cast<quintptr>(child)));
    }

    //reinterpret_cast<quintptr>(c) ( found in inners of QModelIndex)



    return indexes;

}

Then put the Q_INVOKABLE QVariantList getChildrenIndexes(); in your model header.

In our QML code it will go like this:

                onAssignSubscriptionModel: {
                    treeView.model = model; // TODO: throw a WorkerScript at it. 
                    var someIndexes = treeView.model.getChildrenIndexes();
                    console.log(someIndexes); // Our QVariantList gets converted to an array
                    for(var i = 0; i <= someIndexes.length - 1; i++) {
                        treeView.expand(someIndexes[i]);
                        //console.log(treeView.isExpanded(itemIndex));
                    }
                    someIndexes = undefined; // not sure if effective but I want it garbage collected afterwards. 

                }

After that? Your items should be automatically expanded. Note that this is an expensive process, it’s not much about creating the indexes but more that it will tax the QML engine side if you have a lot of items. At the same time I’d like to say that I did go through it with around 13k items in my database and didn’t notice any slow down, keep your eyes open though.

A quick summary? We got the indexes of our top-level items. Do remember that the root item is always invisible. Which brings me to

remember to adapt this to whatever node structure or container you have nobody should expect rootItem->child(0)->parent(); line in anyone’s AbstractItemModel meaning, you probably don’t have a child or parent method, maybe.