Posts Tagged ‘ Qt4

Amarok: Recently added ablums

You probably noticed the "Recently added Albums" in the album-applet (to be more specific: the current-view) of the context view while Amarok stops playing. I always thought that this is the only way to track down which albums were recently added to the collection. The problem is, that this applet only shows the last 5 added albums. So I always wait a couple of minutes/seconds and copy the next five albums to the collection-folder, to add these to my daily playlist.

Today I was really upset of this behavior and decided to write my own amarok-script for this purpose. So I cloned the amarok trunk and took a look in the amarok scripting engine. After querying the lastest albums with the Amarok script console (see code-snippet), I asked on #amarok for some information about interacting with the context-view. I also find a wishlist entry on bug.kde.org concerning this topic: https://bugs.kde.org/show_bug.cgi?id=181660.

Amarok.Collection.query("SELECT artist.name, album.name FROM tracks AS track LEFT JOIN artists AS artist ON track.artist=artist.id LEFT JOIN albums AS album ON track.album=album.id GROUP BY album.id ORDER BY track.createdate DESC LIMIT 10")

The solution was easy ... this feature already exists: just use the collection filtering:

  • "added:today" show the tracks/albums added today
  • "added:<2w" in the last 2 weeks
  • "added:<1m" in the last month
  • "added:<2m2w" in the last 2 month and 2 weeks

amarok_filtering

Afterwards I found out that the feature was released in Amarok 2.1 Beta (see changelog) - so .. I really should read the changelogs. ;)

Amarok Scripting:

Gaussian Distribution with QGraphicsView

During my semester-break I've played around with the QGraphicsView component which was introduced a while ago. My goal was to implement the standard-experiment for the Gaussian Distribution (see schema).

gaussdistrI_schema

Imagine you have 1000 balls and throw these (in sequence) in the opening on top of this vessel (see picture). The sum of each stack of balls results in an Gaussian Distribution form (shown at the bottom of the picture: red ball stacks).

I've implemented this behavior with the qrand() function - to decide if the ball goes left or right. After running the application the embedded QGraphicsView animate the results (the ball-stacks) using a QGraphicsItemAnimation. After finishing this results-animation the applications also shows some statistic-values:

average value - μ: (x1+x2+...+xn) / n

standard degression - σ: sqrt((x1-µ)² + (x2-µ)² + ... + (xn-µ)²)

Here is a screenshot of the application GaussDistri:

gaussdistri

As you already suppose the program is written in C++/Qt and based on a qmake-project - using Qt Creator. I provide the source-code later ... ;)

Update: it seems that I've mixed-up μ and σ in the app (see screenshot) ... :)