>Skoda Fabia

>Last week I had my car on service and was given a fairly new Skoda Fabia as a replacement car for the day. I live in Sweden, so I had the car fitted with spiked tires, just in case. As you might already be aware – these tires adds some extra noise, compared to ordinary friction tires or summer tires. Anyway – I just could not understand why the car was fitted with a stereo. Especially as I had to rev it over 4000 rpm to get a decent high-way speed.

But all is not bad – having to rev means having to shift alot and that makes the driving more challenging. To sum thing up, it is slow, noisy and requires quite alot of shifting – but also kind of fun in that regard. It felt good to get my own car back.

>Selecting

>I ran into something peculiar today when using the Model/View classes in Qt 4.2 – probably something related to TaskTracker issue 143383. To demonstrate, let’s start with a minimal model that can be reset from a public method:

class MyStringListModel : public QStringListModel
{
public:
MyStringListModel( const QStringList &items ) : QStringListModel( items, 0 ) {}

void resetModel() { reset(); }
};

I start by initializing the model and viewing it through a QListView:

  QListView listView;
QStringList items;
items << "Kalle" << "Olle" << "Albert" << "Sven" << "Anders" << "Markus";
MyStringListModel model( items );
listView.setModel( &model );

Then I set the current index and select it – this is equvalent to picking it with the mouse (that was how I ran into the issue):

  listView.selectionModel()->setCurrentIndex(
model.index( 3, 0, QModelIndex() ),
QItemSelectionModel::SelectCurrent );

This gives us the following state:

  listView.selectionModel()->hasSelection() == true
listView.selectionModel()->selectedIndexes().count() == 1
listView.selectionModel()->currentIndex().isValue == true

Now, I reset the model:

  model.resetModel();

The situation changes to:

  listView.selectionModel()->hasSelection() == true
listView.selectionModel()->selectedIndexes().count() == 0
listView.selectionModel()->currentIndex().isValue == false

The same thing happens when using select instead of setCurrentIndex. When using the following line…

  listView.selectionModel()->select(
model.index( 3, 0, QModelIndex() ),
QItemSelectionModel::SelectCurrent );

… you get the following:

  listView.selectionModel()->hasSelection() == true
listView.selectionModel()->selectedIndexes().count() == 1
listView.selectionModel()->currentIndex().isValue == false

And after resetting the model it looks like this:

  listView.selectionModel()->hasSelection() == true
listView.selectionModel()->selectedIndexes().count() == 0
listView.selectionModel()->currentIndex().isValue == false

The TaskTracker entry says that the bug is fixed, so this is likely to have been fixed in the Qt 4.3 snapshots. If you’re using an earlier release it looks as if the selectedIndexes().count() is a better way to determine if something is selected.

>I visited the BitSim headquarters yesterday and got a chance to see the spring in Stockholm. It was nice to notice that it is slightly warmer in Gothenburg – but still far too cold for my taste – around 8 dgC.

It it would have been raining it would have been dangerously close to the Swedish standard temperature. It is 12 dgC. Combined with rain this is the Swedish standard weather. It is called just that because it could be chistmas eve or midsummer. It is is 12 dgC and raining you cannot tell.

Now it may sound as if Sweden is permanently cold and rainy. That is quite far from the truth. I’ve seen beautiful winterdays in the north with temperatures close to -35 dgC. In the summer we can reach around 30 dgC some days – and that is a bit too hot for my taste. I prefer around 25-27 dgC if I can be picky :-)

Anyway, enough about the weather. Stockholm was nice as always and it is always fun to visit the headquarters. This time I got a chance to have a closer look at the Badger demo – it was really cool. Live video, alphablended graphics and nearly no CPU load – it impressed the geek in me :-)

>My Collection of Gems

>I recently blogged about the way that GCC sometimes can write poetry. This has resulted in a small collection of gems and solutions: GCC Compiler Errors (and their meaning). Enjoy! If you want me to add something, do tell me. Either through a comment, or just mail me. I’m e8johan and use GMail.

The page is a part of the new wiki-based digitalfanatics.org – and the style sheets will need some more love before all is done. It is readable – but sometimes mixes colours that where not intended to be mixed. We’re currently in the process of moving contents to the wiki, so there will be changes but the links posted here aught to stay valid.