+void InformationPanel::contextMenuEvent(QContextMenuEvent* event)
+{
+ Panel::contextMenuEvent(event);
+
+#ifdef HAVE_NEPOMUK
+ if (showMultipleSelectionInfo()) {
+ return;
+ }
+
+ KMenu popup(this);
+
+ QAction* ratingAction = popup.addAction(i18nc("@action:inmenu", "Rating"));
+ ratingAction->setCheckable(true);
+ ratingAction->setChecked(InformationPanelSettings::showRating());
+
+ QAction* commentAction = popup.addAction(i18nc("@action:inmenu", "Comment"));
+ commentAction->setCheckable(true);
+ commentAction->setChecked(InformationPanelSettings::showComment());
+
+ QAction* tagsAction = popup.addAction(i18nc("@action:inmenu", "Tags"));
+ tagsAction->setCheckable(true);
+ tagsAction->setChecked(InformationPanelSettings::showTags());
+
+ KConfig config("kmetainformationrc", KConfig::NoGlobals);
+ KConfigGroup settings = config.group("Show");
+ initMetaInfoSettings(settings);
+
+ QList<QAction*> actions;
+
+ // Get all meta information labels that are available for
+ // the currently shown file item and add them to the popup.
+ Nepomuk::Resource res(fileItem().url());
+ QHash<QUrl, Nepomuk::Variant> properties = res.properties();
+ QHash<QUrl, Nepomuk::Variant>::const_iterator it = properties.constBegin();
+ while (it != properties.constEnd()) {
+ Nepomuk::Types::Property prop(it.key());
+ const QString key = prop.label();
+
+ // Meta information provided by Nepomuk that is already
+ // available from KFileItem should not be configurable.
+ bool skip = (key == "fileExtension") ||
+ (key == "name") ||
+ (key == "sourceModified") ||
+ (key == "size") ||
+ (key == "mime type");
+ if (!skip) {
+ // Check whether there is already a meta information
+ // having the same label. In this case don't show it
+ // twice in the menu.
+ foreach (const QAction* action, actions) {
+ if (action->data().toString() == key) {
+ skip = true;
+ break;
+ }
+ }
+ }
+
+ if (!skip) {
+ const QString label = key; // TODO
+ QAction* action = new QAction(label, &popup);
+ action->setCheckable(true);
+ action->setChecked(settings.readEntry(key, true));
+ action->setData(key);
+ actions.append(action);
+ }
+
+ ++it;
+ }
+
+ if (actions.count() > 0) {
+ popup.addSeparator();
+
+ // add all items alphabetically sorted to the popup
+ qSort(actions.begin(), actions.end(), lessThan);
+ foreach (QAction* action, actions) {
+ popup.addAction(action);
+ }
+ }
+
+ // Open the popup and adjust the settings for the
+ // selected action.
+ QAction* action = popup.exec(QCursor::pos());
+ if (action == 0) {
+ return;
+ }
+
+ if (action == ratingAction) {
+ // TODO
+ } else if (action == commentAction) {
+ // TODO
+ } else if (action == tagsAction) {
+ // TODO
+ } else {
+ settings.writeEntry(action->data().toString(), action->isChecked());
+ settings.sync();
+ showMetaInfo();
+ }
+#endif
+}
+