Dedicated bookmarks icon chooser showing standard icons
AcceptedPublic

Authored by tandon on Jan 13 2016, 7:26 PM.

Details

Reviewers
nienhueser
Group Reviewers
Marble
Summary

Bug 345919 - Bookmark icons use absolute paths in any case
https://bugs.kde.org/show_bug.cgi?id=345919

Feature

  • A new dialog added which allows a user to select one of the standard icons for his bookmark.
  • All the predefined icons are in qrc folder qrc:/marble/bookmarks/.
  • Apart from this the user can also use a custom icon for the bookmark.

Usage:

  • Choose Add a new Bookmark/ Edit a bookmark.
  • Click on the button which displays the icon.
  • A new dialog is created using which one of the icons can be choosen.
  • Click on 'Custom' button if a custom icon is to be choosen.
  • Select the appropriate icon and click on 'OK'.
  • Click on 'Cancel' if you want the previous icon to remain unchanged.

Diff Detail

Repository
R34 Marble
Lint
Lint Skipped
Unit
Unit Tests Skipped
tandon updated this revision to Diff 1934.Jan 13 2016, 7:26 PM
tandon retitled this revision from to Dedicated bookmarks icon chooser showing standard icons.
tandon updated this object.
tandon edited the test plan for this revision. (Show Details)
tandon added reviewers: Marble, nienhueser.
tandon set the repository for this revision to R34 Marble.
tandon added a project: Marble.
tandon added subscribers: Marble, nienhueser.
nienhueser edited edge metadata.Jan 13 2016, 8:09 PM

Great patch, just needs some minor tweaks.

src/lib/marble/IconChooserDialog.ui
4 ↗(On Diff #1934)

The base class should be a QDialog, not a QWidget. Please set a layout also such that the listview resizes properly when the dialog is resized, and use a QDialogButtonBox with proper button roles to ensure that e.g. the left/right order of Ok/Cancel is adjusted according to what the desktop environment suggests.

src/lib/marble/IconChooserModel.cpp
45 ↗(On Diff #1934)

Please use Q_UNUSED(parent)

55 ↗(On Diff #1934)

int row = index.row();

60 ↗(On Diff #1934)

This has no effect. You probably want
icon = icon.scaled( ....

89 ↗(On Diff #1934)

This seems to be done in the wrong order: insertRows() above already calls endInsertRows(); which signalizes the attached views that the insertion has finished and they update. In reality though the data is inserted just afterwards in this and the next line.

95 ↗(On Diff #1934)

Q_UNUSED here also

tandon updated this revision to Diff 1954.Jan 14 2016, 10:00 AM
tandon edited edge metadata.
tandon marked 6 inline comments as done.

Updates

  • Changed the base class in IconChooserDialog.ui to QDialog from QWidget
  • Changed the layout in IconChooserDialog.ui so that the list view re-sizes correctly.
  • Replaced OK and Cancel buttons with a QDialog button box.
  • Used Q_UNUSED macro in place where it was required.
  • endInsertRows() is now being called from inside addIcon() instead of insertRows()
nienhueser added inline comments.Jan 17 2016, 9:00 AM
src/lib/marble/IconChooserModel.cpp
89

This is dangerous now: addIcon() calls endInsertRows() and relies on insertRows() to call beginInsertRows(). If insertRows() -- which is virtual -- was called by someone else, there would only be an endInsertRows call without a beginInsertRows call before. The Qt docs say

"If you implement your own model, you can reimplement this function if you want to support insertions. Alternatively, you can provide your own API for altering the data. In either case, you will need to call beginInsertRows() and endInsertRows() to notify other components that the model has changed."

We have a mixture of both now that is not consistent. I'd suggest to remove insertRows() and do all that it currently does inside addIcon.

tandon updated this revision to Diff 1998.Jan 18 2016, 1:50 PM
tandon marked an inline comment as done.

Removed insertRows() and moved all its functionality to addIcon().

nienhueser accepted this revision.Feb 14 2016, 12:34 PM
nienhueser edited edge metadata.

Looks fine. I noticed a minor glitch: Changing the icon does not cause a refresh of the screen. If the bookmark that is being changed is currently displayed, it will only be exchanged later on e.g. when moving the region out of view and back in. However we can work on that after pushing this.

This revision is now accepted and ready to land.Feb 14 2016, 12:34 PM