diff options
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 80 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 2 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistcontroller.cpp | 16 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditem.cpp | 33 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditem.h | 14 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.cpp | 2 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemlistwidget.h | 2 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemmodel.cpp | 2 | ||||
| -rw-r--r-- | src/kitemviews/kstandarditemmodel.h | 2 | ||||
| -rw-r--r-- | src/kitemviews/private/kbaloorolesprovider.cpp | 32 | ||||
| -rw-r--r-- | src/kitemviews/private/kitemlistroleeditor.cpp | 17 |
11 files changed, 104 insertions, 98 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index fc14c79c1..8145a00f1 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -68,16 +68,16 @@ KFileItemModel::KFileItemModel(QObject* parent) : } connect(m_dirLister, &KFileItemModelDirLister::started, this, &KFileItemModel::directoryLoadingStarted); - connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::canceled), this, &KFileItemModel::slotCanceled); - connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&)>(&KFileItemModelDirLister::completed), this, &KFileItemModel::slotCompleted); + connect(m_dirLister, QOverload<>::of(&KCoreDirLister::canceled), this, &KFileItemModel::slotCanceled); + connect(m_dirLister, QOverload<const QUrl&>::of(&KCoreDirLister::completed), this, &KFileItemModel::slotCompleted); connect(m_dirLister, &KFileItemModelDirLister::itemsAdded, this, &KFileItemModel::slotItemsAdded); connect(m_dirLister, &KFileItemModelDirLister::itemsDeleted, this, &KFileItemModel::slotItemsDeleted); connect(m_dirLister, &KFileItemModelDirLister::refreshItems, this, &KFileItemModel::slotRefreshItems); - connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)()>(&KFileItemModelDirLister::clear), this, &KFileItemModel::slotClear); + connect(m_dirLister, QOverload<>::of(&KCoreDirLister::clear), this, &KFileItemModel::slotClear); connect(m_dirLister, &KFileItemModelDirLister::infoMessage, this, &KFileItemModel::infoMessage); connect(m_dirLister, &KFileItemModelDirLister::errorMessage, this, &KFileItemModel::errorMessage); connect(m_dirLister, &KFileItemModelDirLister::percent, this, &KFileItemModel::directoryLoadingProgress); - connect(m_dirLister, static_cast<void(KFileItemModelDirLister::*)(const QUrl&, const QUrl&)>(&KFileItemModelDirLister::redirection), this, &KFileItemModel::directoryRedirection); + connect(m_dirLister, QOverload<const QUrl&, const QUrl&>::of(&KCoreDirLister::redirection), this, &KFileItemModel::directoryRedirection); connect(m_dirLister, &KFileItemModelDirLister::urlIsFileError, this, &KFileItemModel::urlIsFileError); // Apply default roles that should be determined @@ -304,9 +304,9 @@ QString KFileItemModel::roleDescription(const QByteArray& role) const int count = 0; const RoleInfoMap* map = rolesInfoMap(count); for (int i = 0; i < count; ++i) { - if (!map[i].roleTranslation) { - continue; - } + if (!map[i].roleTranslation) { + continue; + } description.insert(map[i].role, i18nc(map[i].roleTranslationContext, map[i].roleTranslation)); } } @@ -2297,38 +2297,40 @@ void KFileItemModel::emitSortProgress(int resolvedCount) const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count) { static const RoleInfoMap rolesInfoMap[] = { - // | role | roleType | role translation | group translation | requires Baloo | requires indexer - { nullptr, NoRole, nullptr, nullptr, nullptr, nullptr, false, false }, - { "text", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), nullptr, nullptr, false, false }, - { "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), nullptr, nullptr, false, false }, - { "modificationtime", ModificationTimeRole, I18N_NOOP2_NOSTRIP("@label", "Modified"), nullptr, nullptr, false, false }, - { "creationtime", CreationTimeRole, I18N_NOOP2_NOSTRIP("@label", "Created"), nullptr, nullptr, false, false }, - { "accesstime", AccessTimeRole, I18N_NOOP2_NOSTRIP("@label", "Accessed"), nullptr, nullptr, false, false }, - { "type", TypeRole, I18N_NOOP2_NOSTRIP("@label", "Type"), nullptr, nullptr, false, false }, - { "rating", RatingRole, I18N_NOOP2_NOSTRIP("@label", "Rating"), nullptr, nullptr, true, false }, - { "tags", TagsRole, I18N_NOOP2_NOSTRIP("@label", "Tags"), nullptr, nullptr, true, false }, - { "comment", CommentRole, I18N_NOOP2_NOSTRIP("@label", "Comment"), nullptr, nullptr, true, false }, - { "title", TitleRole, I18N_NOOP2_NOSTRIP("@label", "Title"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, - { "wordCount", WordCountRole, I18N_NOOP2_NOSTRIP("@label", "Word Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, - { "lineCount", LineCountRole, I18N_NOOP2_NOSTRIP("@label", "Line Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, - { "imageDateTime", ImageDateTimeRole, I18N_NOOP2_NOSTRIP("@label", "Date Photographed"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, - { "width", WidthRole, I18N_NOOP2_NOSTRIP("@label", "Width"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, - { "height", HeightRole, I18N_NOOP2_NOSTRIP("@label", "Height"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, - { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, - { "artist", ArtistRole, I18N_NOOP2_NOSTRIP("@label", "Artist"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, - { "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, - { "deletiontime",DeletionTimeRole,I18N_NOOP2_NOSTRIP("@label", "Deletion Time"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, - { "destination", DestinationRole, I18N_NOOP2_NOSTRIP("@label", "Link Destination"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, - { "originUrl", OriginUrlRole, I18N_NOOP2_NOSTRIP("@label", "Downloaded From"), I18N_NOOP2_NOSTRIP("@label", "Other"), true, false }, - { "permissions", PermissionsRole, I18N_NOOP2_NOSTRIP("@label", "Permissions"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, - { "owner", OwnerRole, I18N_NOOP2_NOSTRIP("@label", "Owner"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, - { "group", GroupRole, I18N_NOOP2_NOSTRIP("@label", "User Group"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + // | role | roleType | role translation | group translation | requires Baloo | requires indexer + { nullptr, NoRole, nullptr, nullptr, nullptr, nullptr, false, false }, + { "text", NameRole, I18N_NOOP2_NOSTRIP("@label", "Name"), nullptr, nullptr, false, false }, + { "size", SizeRole, I18N_NOOP2_NOSTRIP("@label", "Size"), nullptr, nullptr, false, false }, + { "modificationtime", ModificationTimeRole, I18N_NOOP2_NOSTRIP("@label", "Modified"), nullptr, nullptr, false, false }, + { "creationtime", CreationTimeRole, I18N_NOOP2_NOSTRIP("@label", "Created"), nullptr, nullptr, false, false }, + { "accesstime", AccessTimeRole, I18N_NOOP2_NOSTRIP("@label", "Accessed"), nullptr, nullptr, false, false }, + { "type", TypeRole, I18N_NOOP2_NOSTRIP("@label", "Type"), nullptr, nullptr, false, false }, + { "rating", RatingRole, I18N_NOOP2_NOSTRIP("@label", "Rating"), nullptr, nullptr, true, false }, + { "tags", TagsRole, I18N_NOOP2_NOSTRIP("@label", "Tags"), nullptr, nullptr, true, false }, + { "comment", CommentRole, I18N_NOOP2_NOSTRIP("@label", "Comment"), nullptr, nullptr, true, false }, + { "title", TitleRole, I18N_NOOP2_NOSTRIP("@label", "Title"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, + { "wordCount", WordCountRole, I18N_NOOP2_NOSTRIP("@label", "Word Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, + { "lineCount", LineCountRole, I18N_NOOP2_NOSTRIP("@label", "Line Count"), I18N_NOOP2_NOSTRIP("@label", "Document"), true, true }, + { "imageDateTime", ImageDateTimeRole, I18N_NOOP2_NOSTRIP("@label", "Date Photographed"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, + { "width", WidthRole, I18N_NOOP2_NOSTRIP("@label", "Width"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, + { "height", HeightRole, I18N_NOOP2_NOSTRIP("@label", "Height"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, + { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"), I18N_NOOP2_NOSTRIP("@label", "Image"), true, true }, + { "artist", ArtistRole, I18N_NOOP2_NOSTRIP("@label", "Artist"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "genre", GenreRole, I18N_NOOP2_NOSTRIP("@label", "Genre"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "album", AlbumRole, I18N_NOOP2_NOSTRIP("@label", "Album"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "duration", DurationRole, I18N_NOOP2_NOSTRIP("@label", "Duration"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "bitrate", BitrateRole, I18N_NOOP2_NOSTRIP("@label", "Bitrate"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "track", TrackRole, I18N_NOOP2_NOSTRIP("@label", "Track"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "releaseYear", ReleaseYearRole, I18N_NOOP2_NOSTRIP("@label", "Release Year"), I18N_NOOP2_NOSTRIP("@label", "Audio"), true, true }, + { "aspectRatio", AspectRatioRole, I18N_NOOP2_NOSTRIP("@label", "Aspect Ratio"), I18N_NOOP2_NOSTRIP("@label", "Video"), true, true }, + { "frameRate", FrameRateRole, I18N_NOOP2_NOSTRIP("@label", "Frame Rate"), I18N_NOOP2_NOSTRIP("@label", "Video"), true, true }, + { "path", PathRole, I18N_NOOP2_NOSTRIP("@label", "Path"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + { "deletiontime", DeletionTimeRole, I18N_NOOP2_NOSTRIP("@label", "Deletion Time"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + { "destination", DestinationRole, I18N_NOOP2_NOSTRIP("@label", "Link Destination"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + { "originUrl", OriginUrlRole, I18N_NOOP2_NOSTRIP("@label", "Downloaded From"), I18N_NOOP2_NOSTRIP("@label", "Other"), true, false }, + { "permissions", PermissionsRole, I18N_NOOP2_NOSTRIP("@label", "Permissions"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + { "owner", OwnerRole, I18N_NOOP2_NOSTRIP("@label", "Owner"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, + { "group", GroupRole, I18N_NOOP2_NOSTRIP("@label", "User Group"), I18N_NOOP2_NOSTRIP("@label", "Other"), false, false }, }; count = sizeof(rolesInfoMap) / sizeof(RoleInfoMap); diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index d15cfebc1..0f7926aae 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -288,7 +288,7 @@ private: // User visible roles available with Baloo: CommentRole, TagsRole, RatingRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole, WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole, - BitrateRole, OriginUrlRole, + BitrateRole, OriginUrlRole, AspectRatioRole, FrameRateRole, // Non-visible roles: IsDirRole, IsLinkRole, IsHiddenRole, IsExpandedRole, IsExpandableRole, ExpandedParentsCountRole, // Mandatory last entry: diff --git a/src/kitemviews/kitemlistcontroller.cpp b/src/kitemviews/kitemlistcontroller.cpp index d3dbeb35c..6fb6a5132 100644 --- a/src/kitemviews/kitemlistcontroller.cpp +++ b/src/kitemviews/kitemlistcontroller.cpp @@ -231,6 +231,9 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) const bool shiftPressed = event->modifiers() & Qt::ShiftModifier; const bool controlPressed = event->modifiers() & Qt::ControlModifier; const bool shiftOrControlPressed = shiftPressed || controlPressed; + const bool navigationPressed = key == Qt::Key_Home || key == Qt::Key_End || + key == Qt::Key_Up || key == Qt::Key_Down || + key == Qt::Key_Left || key == Qt::Key_Right; const int itemCount = m_model->count(); @@ -246,11 +249,8 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) } } - const bool selectSingleItem = m_selectionBehavior != NoSelection && - itemCount == 1 && - (key == Qt::Key_Home || key == Qt::Key_End || - key == Qt::Key_Up || key == Qt::Key_Down || - key == Qt::Key_Left || key == Qt::Key_Right); + const bool selectSingleItem = m_selectionBehavior != NoSelection && itemCount == 1 && navigationPressed; + if (selectSingleItem) { const int current = m_selectionManager->currentItem(); m_selectionManager->setSelected(current); @@ -458,8 +458,12 @@ bool KItemListController::keyPressEvent(QKeyEvent* event) } break; } + } - m_view->scrollToItem(index); + if (navigationPressed) { + if (index < m_view->firstVisibleIndex() || index > m_view->lastVisibleIndex()) { + m_view->scrollToItem(index); + } } return true; } diff --git a/src/kitemviews/kstandarditem.cpp b/src/kitemviews/kstandarditem.cpp index 4fb3f8f98..b3bbcaa41 100644 --- a/src/kitemviews/kstandarditem.cpp +++ b/src/kitemviews/kstandarditem.cpp @@ -21,16 +21,14 @@ #include "kstandarditemmodel.h" KStandardItem::KStandardItem(KStandardItem* parent) : - m_parent(parent), - m_children(), + QObject(parent), m_model(nullptr), m_data() { } KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) : - m_parent(parent), - m_children(), + QObject(parent), m_model(nullptr), m_data() { @@ -38,8 +36,7 @@ KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) : } KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandardItem* parent) : - m_parent(parent), - m_children(), + QObject(parent), m_model(nullptr), m_data() { @@ -47,14 +44,6 @@ KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandard setText(text); } -KStandardItem::KStandardItem(const KStandardItem& item) : - m_parent(item.m_parent), - m_children(item.m_children), - m_model(item.m_model), - m_data(item.m_data) -{ -} - KStandardItem::~KStandardItem() { } @@ -123,17 +112,6 @@ QVariant KStandardItem::dataValue(const QByteArray& role) const return m_data[role]; } -void KStandardItem::setParent(KStandardItem* parent) -{ - // TODO: not implemented yet - m_parent = parent; -} - -KStandardItem* KStandardItem::parent() const -{ - return m_parent; -} - void KStandardItem::setData(const QHash<QByteArray, QVariant>& values) { const QHash<QByteArray, QVariant> previous = m_data; @@ -146,11 +124,6 @@ QHash<QByteArray, QVariant> KStandardItem::data() const return m_data; } -QList<KStandardItem*> KStandardItem::children() const -{ - return m_children; -} - void KStandardItem::onDataValueChanged(const QByteArray& role, const QVariant& current, const QVariant& previous) diff --git a/src/kitemviews/kstandarditem.h b/src/kitemviews/kstandarditem.h index fec197c06..ad3452d77 100644 --- a/src/kitemviews/kstandarditem.h +++ b/src/kitemviews/kstandarditem.h @@ -24,7 +24,7 @@ #include <QByteArray> #include <QHash> -#include <QList> +#include <QObject> #include <QVariant> class KStandardItemModel; @@ -36,14 +36,13 @@ class KStandardItemModel; * used roles. It is possible to assign values for custom * roles by using setDataValue(). */ -class DOLPHIN_EXPORT KStandardItem +class DOLPHIN_EXPORT KStandardItem : public QObject { - + Q_OBJECT public: explicit KStandardItem(KStandardItem* parent = nullptr); explicit KStandardItem(const QString& text, KStandardItem* parent = nullptr); KStandardItem(const QString& icon, const QString& text, KStandardItem* parent = nullptr); - KStandardItem(const KStandardItem& item); virtual ~KStandardItem(); /** @@ -70,14 +69,9 @@ public: void setDataValue(const QByteArray& role, const QVariant& value); QVariant dataValue(const QByteArray& role) const; - void setParent(KStandardItem* parent); - KStandardItem* parent() const; - void setData(const QHash<QByteArray, QVariant>& values); QHash<QByteArray, QVariant> data() const; - QList<KStandardItem*> children() const; - protected: virtual void onDataValueChanged(const QByteArray& role, const QVariant& current, @@ -87,8 +81,6 @@ protected: const QHash<QByteArray, QVariant>& previous); private: - KStandardItem* m_parent; - QList<KStandardItem*> m_children; KStandardItemModel* m_model; QHash<QByteArray, QVariant> m_data; diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index f56f68ac5..15c01726f 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -1225,7 +1225,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache() textInfo->staticText.setText(elidedText); requiredWidth = m_customizedFontMetrics.width(elidedText); } else if (role == "rating") { - // Use the width of the rating pixmap, because the rating text is empty. + // Use the width of the rating pixmap, because the rating text is empty. requiredWidth = m_rating.width(); } } diff --git a/src/kitemviews/kstandarditemlistwidget.h b/src/kitemviews/kstandarditemlistwidget.h index 220c0ebc3..c8102e421 100644 --- a/src/kitemviews/kstandarditemlistwidget.h +++ b/src/kitemviews/kstandarditemlistwidget.h @@ -80,7 +80,7 @@ protected: }; /** - * @brief Itemlist widget implementation for KStandardItemView and KStandardItemModel. + * @brief Itemlist widget implementation for KStandardItemListView and KStandardItemModel. */ class DOLPHIN_EXPORT KStandardItemListWidget : public KItemListWidget { diff --git a/src/kitemviews/kstandarditemmodel.cpp b/src/kitemviews/kstandarditemmodel.cpp index a4d42b571..d7307c0bd 100644 --- a/src/kitemviews/kstandarditemmodel.cpp +++ b/src/kitemviews/kstandarditemmodel.cpp @@ -112,7 +112,7 @@ void KStandardItemModel::removeItem(int index) onItemRemoved(index, item); - delete item; + item->deleteLater(); item = nullptr; emit itemsRemoved(KItemRangeList() << KItemRange(index, 1)); diff --git a/src/kitemviews/kstandarditemmodel.h b/src/kitemviews/kstandarditemmodel.h index 6685a2038..8643d2e9e 100644 --- a/src/kitemviews/kstandarditemmodel.h +++ b/src/kitemviews/kstandarditemmodel.h @@ -29,7 +29,7 @@ class KStandardItem; /** - * @brief Model counterpart for KStandardItemView. + * @brief Model counterpart for KStandardItemListView. * * Allows to add items to the model in an easy way by the * class KStandardItem. diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp index 0eedf1806..f3671540d 100644 --- a/src/kitemviews/private/kbaloorolesprovider.cpp +++ b/src/kitemviews/private/kbaloorolesprovider.cpp @@ -56,18 +56,34 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f { QHash<QByteArray, QVariant> values; - QMapIterator<KFileMetaData::Property::Property, QVariant> it(file.properties()); - while (it.hasNext()) { - it.next(); + using entry = std::pair<const KFileMetaData::Property::Property&, const QVariant&>; + + const auto& propMap = file.properties(); + auto rangeBegin = propMap.constKeyValueBegin(); + + while (rangeBegin != propMap.constKeyValueEnd()) { + auto key = (*rangeBegin).first; + const KFileMetaData::PropertyInfo propertyInfo(key); + const QByteArray role = roleForProperty(propertyInfo.name()); + + auto rangeEnd = std::find_if(rangeBegin, propMap.constKeyValueEnd(), + [key](const entry& e) { return e.first != key; }); - const KFileMetaData::PropertyInfo pi(it.key()); - const QString property = pi.name(); - const QByteArray role = roleForProperty(property); if (role.isEmpty() || !roles.contains(role)) { + rangeBegin = rangeEnd; continue; } - values.insert(role, pi.formatAsDisplayString(it.value())); + auto distance = std::distance(rangeBegin, rangeEnd); + if (distance > 1) { + QVariantList list; + list.reserve(static_cast<int>(distance)); + std::for_each(rangeBegin, rangeEnd, [&list](const entry& s) { list.append(s.second); }); + values.insert(role, propertyInfo.formatAsDisplayString(list)); + } else { + values.insert(role, propertyInfo.formatAsDisplayString((*rangeBegin).second)); + } + rangeBegin = rangeEnd; } KFileMetaData::UserMetaData md(file.path()); @@ -120,6 +136,8 @@ KBalooRolesProvider::KBalooRolesProvider() : { "album", "album" }, { "duration", "duration" }, { "bitRate", "bitrate" }, + { "aspectRatio", "aspectRatio" }, + { "frameRate", "frameRate" }, { "releaseYear", "releaseYear" }, { "trackNumber", "track" }, { "originUrl", "originUrl" } diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index e79a9f9d1..eb6f1de76 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -107,6 +107,23 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) } break; } + case Qt::Key_Home: + case Qt::Key_End: { + if (event->modifiers() == Qt::NoModifier || event->modifiers() == Qt::ShiftModifier) { + const QTextCursor::MoveOperation op = event->key() == Qt::Key_Home + ? QTextCursor::Start + : QTextCursor::End; + const QTextCursor::MoveMode mode = event->modifiers() == Qt::NoModifier + ? QTextCursor::MoveAnchor + : QTextCursor::KeepAnchor; + QTextCursor cursor = textCursor(); + cursor.movePosition(op, mode); + setTextCursor(cursor); + event->accept(); + return; + } + break; + } default: break; } |
