Monday, 30 January 2012

What a game!!!

I've been playing around, pro-actively for a change, with Qt and coding for my phone: over the holidays I created a SDA hymnal app for my phone. I don't mean to brag but the Mrs and an aunt were both jealous enough to request that I port it to work on their Symbian phones. I plan to blog about my experience learning Qt maybe once every blue moon.

Actually I'll start right now and talk about event filters. There's code out there that serves as an example of how event filters work but I strongly doubt that the availability tutorials have reached a level of verbosity that can render my own take on the topic redundant. On the N900 (hildon/maemo 5), there are a few applications that have this nifty search functionality where once you slide open the keyboard and start typing the application starts to search for what you are typing. I wanted that functionality on the aforementioned hymnal. For this to work I first attempted to override the keyPressEvent method of the main window but found out that the QListView on the main window actually was stopping the key press event from getting to the main window. To handle scenarios like this on possible solution is to use event filters implemented by two functions - installEventFilter and eventFilter - that together allow a widget to pass responsibility for handling events to some other widget.

So with the QListView example above, let's assume the instance of the QListView is called listView and the instance of the QMainWindow on which the listView is displayed is called mainWindow. Then to redirect listView's events to mainWindow you have to call listView.installEventFilter(mainWindow). A way of understanding the installEventFilter function is that you've installed a siphon in the process by which listView usually handles it's events so that listView's events now slip out of its hands into mainWindow's. You then have to get mainWindow to handle the events that come its way from listView - this is where eventFilter method comes in. You have to override mainWindow's eventFilter method such that you do any event specific checks and target object checks.


I've included the code portion based on the example in the documentation here for for the fun of it. Now this is not my code o. I copied it almost verbatim from the Qt documentation but added some comments that may be useful if you read the epistle leading up to this paragraph

//within MainWindow's constructor set up the siphon filter
listView->installEventFilter(this); 

//then you override the eventFilter method
bool MainWindow::eventFilter(QObject *object, QEvent *event)
 {
     if (object == target && event->type() == QEvent::KeyPress) {
         QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
         if (keyEvent->key() == Qt::Key_Tab) {
             // Special tab handling
             return true;
         } else
             return false;
     }
     return false;
 }



Now that you've read this you can now go on and read the Qt documentation here (http://developer.qt.nokia.com/doc/qt-4.8/eventsandfilters.html#event-filters) for actual code.

Monday, 19 December 2011

Olufunmi - ish

The last time I was in 9ja, I went out shopping for 9ja music - you know like Lara George. After walking around for a while I finally ask one of the CD hawkers specifically for Lara George-ish artists and the guy said - in geek speak - error! It reminds me of how when I was about to leave 9ja in 2006, I went about looking for Olufunmi's "Go Quick" CD. You see, I had the tape and if cassette players could complain that cassette would have force the issue. Needless to say I didn't find the CD. I think there's probably like one or two artists every year that come out with really good quality stuff gospel wise - like that one year when it was Midnight Crew and the other one when it was Infinity. I liked Estar (of the Chinwe Ike fame) too. She reminds me of Sixpence none the richer's Leigh Nash - and on that note I think she solo album was a disappointment.

Anyway I was finally forced coerced into singing a special song in Church some days back - cue more hair pulling and heart wrenching. I first decided on Sanctus Real's "Whatever you are doing" or Brian McKnight's "home" - lofty dreams I know but at least the fact that I live in the land of dreams has to count for something. But Qemi felt "Home" was too R 'n' B - ish (which brings up the issue of why do I listen to her sef?) and I wasn't feeling the former song on my guitar. Eventually I settled for Olufunmi's "Oluwa oni dehin". I say settle in the sense that once it was impressed on my mind there was no going back - I can be impulsive sometimes. It's sad how hard it is to find somewhere to buy her songs (the fact that styl-plus has a song called Olufunmi doesn't help) online. Anyway I wrote out the words of the song as I heard them and I figured I'll share it here in case anyone needs them. There's also a link to Olufunmi's original version. I think she sings it in C# or so... but I played in it D. When I get the time I'll update the lyrics with the chords and maybe even upload my pitiful cover of the song. The cool thing about singing in church is that you are singing for/to God and if you give it your best shot He appreciates it regardless :)

Intro:
Oluwa oni dehin lehin mi o
Ewo ni mo gbojule
Ewo ni mo fihinti
la to wuro titi d'ale
Oluwa oni dehin lehin mi o

Verse 1
bi mo ba ji
bi mo ji lowuro
ma k'aleluya
patewo yin baba l'ogo
ma'a mura fun se
ise ojo mi
ti n'ba ti jade
ma k'aleluya fun baba
to ba mi se

Chorus:
Baba ba mi se
Oni se iyanu
Titi ra ye ra ye
ni mo ma yin o o Baba
Baba ba mi se
Oni se iyanu
Titi ra ye ra ye
ni mo ma yin o o Baba

Verse 2:
bi mo ba se de b'ise
ma'a yin o o Baba
gbogbo ohun t'o da l'aye
lo fi tan ona mi Jesu
ohun ko hun ti'n ba se laye mi
ma fi yin o l'ogo
ti mo ba ti wa pari ise mi
ma k'aleluya fun Baba
to ba mi se

CHORUS
INTERLUDE


Verse 3:
Mo tun pa da de le
Ogo ni fun oruko re
O wa wa pe lu mi
bi mo se n se to idi le
O wa pelu mi l'aro l'osan
 ti ti d'ale
Kin to lo sun
ma k'aleluya fun Baba

aaaaaaaaaaaaaaa

Outro:
Oluwa oni dehin lehim mi o