Harsh J

Memoirs of a QWERTY Keyboard

Archive for the ‘C’ tag

Scratching my itch

4 comments

If you like open source software, you end up doing that someday sooner or later – you scratch your itch and make a contribution. That’s how it rolls. Well unless you’re sponsored to do so, of course.

I did the same for KDE, having had an on/off relationship with it since 3.x, and finally settling onto 4.3, I managed to get into writing code for it. Although not a fan of the entire desktop, it is what I use on a daily basis and I do feel the lack of a few things sometimes. There’s already too much to customize; and am sure I don’t know the half of it yet.

I read a lot of comic books in my free time, on the PC. While I do have my collections named and arranged neatly, it has always been hard finding a particular file since there were no previews of its covers on KDE 4. Since Okular, KDE’s magnificent all-in-one document reader, reads the files (.cbr, .cbz type) why not also preview it. That became my itch, my want. And I scratched it with copious amounts of help provided by its development community. However, I’d be glad if some artist came along and gave the format an Oxygen-style icon as well – since it still lacks one.

In KDE 4.4, you will have comic book previews which would show you the comic book covers in its file manager’s preview mode. This should make your life easier. However, for .cbr thumbnails to work, you’d need the non-free version of unrar cause the free ones don’t do version 3+ files well. It isn’t a hard dependency, and .cbz ZIP files would work just fine without unrar. I’d also written support for .cbt, but it’d have to wait until KDE 4.5 cause of their ‘feature freeze’.

Since I made it this far, I also fixed certain minor annoyances – some reported by other people as well. A small list:

I’ll be more than glad to hammer more bugs, once the feature freeze melts. Go here to read about what’s new in KDE 4.4.

Written by Harsh

December 8th, 2009 at 12:04 am

Sorting entries in a QStringList Case-insensitively

4 comments

This post is simply a snippet-post for the users of Nokia’s Qt C++ cross-platform toolkit.

While writing some C++ code (after 2 long years since I last wrote them for academic reasons), I had this simple issue of sorting a QStringList in a case-insensitive manner. Normally, there exists a QStringList::sort() function that does the sorting of the strings stored in it in a case-sensitive manner, and is very fast at it. But Qt does not provide a way to perform the sort in a non case-sensitive manner, although it has hints on how to in the class’ documentation.

Being mostly a PyQt/PySide user who uses inbuilt Python lists to do all list-work, here’s how its apparently done in Qt/C++, using a QtCore class called QMap:

#include <QtCore/QStringList>
#include <QtCore/QMap>

void sortNonCaseSensitive( QStringList &sList ) {
    ///  Sorts the passed sList non-case-sensitively.
    ///  (Preserves the cases! Just doesn't use them
    ///  while sorting.)
    QMap<QString, QString> strMap;
    foreach ( QString str, sList ) {
        strMap.insert( str.toLower(), str );
    }
    sList = strMap.values();
}

That’s it.

Written by Harsh

October 24th, 2009 at 10:54 pm

Odd days

one comment

There are days where you wake up normally, read about some violence, politics and gossip. There are other days where you wake up to stuff like this.

Anyways, my semester exams are nearing and here are the announced dates for B.Tech IT (The course I am in)

Anna University Timetable for U.G. (B.Tech IT) 5th semester

  • 06/11/08 – Telecommunication Systems
  • 10/11/08 – Database Management Systems [DBMS]
  • 13/11/08 – Object Oriented Analysis and Design [OOAD]
  • 17/11/08 – Operating Systems [OS]
  • 20/11/08 – Computer Networks
  • 24/11/08 – Environmental Science and Engineering [EVS]

The resulting pattern is oddly nice, 3-2-3-2-3 day gaps.

I’ve been busy being lazy lately, and very lazy indeed. Though I managed to finish up my lab work and other things, I’ve not written down even a small function for self’s sake. While resolving that now, I’ve also moved from Gentoo to ArchLinux having learnt enough and wanting a functional distro now rather than a testing one.

Arch is very fast at installing things, too fast to even compare it with something! But I could be wrong, having not used any other distro for like 8 months now. But comparing to how apt, yum and smart had behaved on my system earlier, pacman is the creamy layer on the cake!

I need to do some serious studying on system calls and the memory management parts of Operating Systems, else this semester would seem a total waste for me. Telecommunication Systems didn’t turn out to be bad at all, its very interesting, being application-oriented. OOAD and DBMS passed by without notice since they are more necessities to learn than something you can ‘try and experiment’ with. Networks has me in a puzzle with so many header formats, but it was great to finally learn something in that field. I’ve got to implement programs to understand the standards more, which I haven’t till date. The EVS class ender with ‘An Inconvinient Truth’ being played was a fantastic way. That pretty much sums up my current semester. The semester where I literally fell asleep in class twice.

Now onto implementing some system calls in C, for the OS lab examinations.

Written by Harsh

October 6th, 2008 at 11:12 am