Image dialogs

Posted on November 4, 2008, under FocusWriter, Tetzle

I’ve replaced Tetzle’s add image dialog with the dialog from FocusWriter. When I wrote Tetzle’s dialog, I had not investigated the Model/View classes enough, and I had come to the erroneous conclusion that there was no easy way to replace QDirModel’s icons. The solution is so obvious that I can’t believe I didn’t think of it: derive a new model from QDirModel! Following that logic, I wrote a fresh version of the add image dialog for FocusWriter. The code is cleaner because of the Model/View split, and faster because I use QImageReader to scale the images (I’m not sure I can get it noticeably faster using Qt, any suggestions are most welcome).

This updating all started with an add image dialog in my recipe manager. I had originally used Tetzle’s dialog, but I replaced it with the improved dialog from FocusWriter. I fixed some bugs, and made a minor enhancement (double clicking an image selects it and closes the dialog). Once I had done that, I couldn’t leave Tetzle with an inferior dialog, so I had to update its dialog. Of course, I made changes to the dialog to make it work in Tetzle, so I had to copy my changes back to FocusWriter.

Now I’ve got three copies of the exact same code in three different projects, and that’s the path to madness and bugs. I’m trying to find a simple solution to share the code. I could go the traditional C++ route and make a library, but that seems a bit overkill for a single dialog. I’m also considering creating a separate git project for the dialog, and using it as a git submodule in my other projects. My hesitation about that is wherever I place my image dialog repository is the “master”. I like the fact that every git repository is equal in authority, and having all git repositories of a project point to the same repository for a submodule rubs me the wrong way. I’m sure I’ll think of something.

Categories