┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp17
-rw-r--r--src/kitemviews/kfileitemmodel.h2
-rw-r--r--src/kitemviews/kfileitemmodelrolesupdater.cpp2
-rw-r--r--src/kitemviews/kitemlistgroupheader.cpp4
-rw-r--r--src/kitemviews/kitemliststyleoption.cpp20
-rw-r--r--src/kitemviews/kitemliststyleoption.h5
-rw-r--r--src/kitemviews/kitemlistview.cpp4
-rw-r--r--src/kitemviews/kitemlistwidget.cpp5
-rw-r--r--src/kitemviews/kstandarditemlistview.cpp9
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp16
-rw-r--r--src/kitemviews/private/kbaloorolesprovider.cpp28
11 files changed, 61 insertions, 51 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index b6a001642..844954d6a 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -1846,16 +1846,10 @@ int KFileItemModel::sortRoleCompare(const ItemData* a, const ItemData* b, const
break;
}
- case RatingRole: {
- result = a->values.value("rating").toInt() - b->values.value("rating").toInt();
- break;
- }
-
- case ImageSizeRole: {
- // Alway use a natural comparing to interpret the numbers of a string like
- // "1600 x 1200" for having a correct sorting.
- result = collator.compare(a->values.value("imageSize").toString(),
- b->values.value("imageSize").toString());
+ case RatingRole:
+ case WidthRole:
+ case HeightRole: {
+ result = a->values.value(roleForType(m_sortRole)).toInt() - b->values.value(roleForType(m_sortRole)).toInt();
break;
}
@@ -2305,7 +2299,8 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
{ "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 },
- { "imageSize", ImageSizeRole, I18N_NOOP2_NOSTRIP("@label", "Image Size"), 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 },
diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h
index 75953f0b7..134c50245 100644
--- a/src/kitemviews/kfileitemmodel.h
+++ b/src/kitemviews/kfileitemmodel.h
@@ -286,7 +286,7 @@ private:
NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
// User visible roles available with Baloo:
- CommentRole, TagsRole, RatingRole, ImageSizeRole, ImageDateTimeRole, OrientationRole,
+ CommentRole, TagsRole, RatingRole, WidthRole, HeightRole, ImageDateTimeRole, OrientationRole,
WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
BitrateRole, OriginUrlRole,
// Non-visible roles:
diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp
index 6c96a08d1..544d88040 100644
--- a/src/kitemviews/kfileitemmodelrolesupdater.cpp
+++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp
@@ -497,7 +497,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi
const QString mimeType = item.mimetype();
const int slashIndex = mimeType.indexOf(QLatin1Char('/'));
- const bool isFontPreview = mimeType.right(slashIndex).contains(QLatin1String("font"));
+ const bool isFontPreview = mimeType.rightRef(slashIndex).contains(QLatin1String("font"));
const bool isFolderPreview = item.isDir();
const bool isWindowsExePreview = mimeType == QLatin1String("application/x-ms-dos-executable") ||
mimeType == QLatin1String("application/x-msdownload");
diff --git a/src/kitemviews/kitemlistgroupheader.cpp b/src/kitemviews/kitemlistgroupheader.cpp
index fb9298989..06a32484a 100644
--- a/src/kitemviews/kitemlistgroupheader.cpp
+++ b/src/kitemviews/kitemlistgroupheader.cpp
@@ -78,6 +78,10 @@ QVariant KItemListGroupHeader::data() const
void KItemListGroupHeader::setStyleOption(const KItemListStyleOption& option)
{
+ if (m_styleOption == option) {
+ return;
+ }
+
const KItemListStyleOption previous = m_styleOption;
m_styleOption = option;
m_dirtyCache = true;
diff --git a/src/kitemviews/kitemliststyleoption.cpp b/src/kitemviews/kitemliststyleoption.cpp
index 1ebcad141..bcfb86064 100644
--- a/src/kitemviews/kitemliststyleoption.cpp
+++ b/src/kitemviews/kitemliststyleoption.cpp
@@ -53,3 +53,23 @@ KItemListStyleOption::KItemListStyleOption(const KItemListStyleOption& other) :
KItemListStyleOption::~KItemListStyleOption()
{
}
+
+bool KItemListStyleOption::operator==(const KItemListStyleOption& other) const
+{
+ return rect == other.rect
+ && font == other.font
+ && fontMetrics == other.fontMetrics
+ && palette == other.palette
+ && padding == other.padding
+ && horizontalMargin == other.horizontalMargin
+ && verticalMargin == other.verticalMargin
+ && iconSize == other.iconSize
+ && extendedSelectionRegion == other.extendedSelectionRegion
+ && maxTextLines == other.maxTextLines
+ && maxTextWidth == other.maxTextWidth;
+}
+
+bool KItemListStyleOption::operator!=(const KItemListStyleOption& other) const
+{
+ return !(*this == other);
+}
diff --git a/src/kitemviews/kitemliststyleoption.h b/src/kitemviews/kitemliststyleoption.h
index 09b787c27..93aafac1f 100644
--- a/src/kitemviews/kitemliststyleoption.h
+++ b/src/kitemviews/kitemliststyleoption.h
@@ -45,6 +45,11 @@ public:
bool extendedSelectionRegion;
int maxTextLines;
int maxTextWidth;
+
+ bool operator==(const KItemListStyleOption& other) const;
+ bool operator!=(const KItemListStyleOption& other) const;
+
+
};
#endif
diff --git a/src/kitemviews/kitemlistview.cpp b/src/kitemviews/kitemlistview.cpp
index 489c6f9b6..f0647fb3e 100644
--- a/src/kitemviews/kitemlistview.cpp
+++ b/src/kitemviews/kitemlistview.cpp
@@ -752,6 +752,10 @@ void KItemListView::setItemSize(const QSizeF& size)
void KItemListView::setStyleOption(const KItemListStyleOption& option)
{
+ if (m_styleOption == option) {
+ return;
+ }
+
const KItemListStyleOption previousOption = m_styleOption;
m_styleOption = option;
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index 61dd7256e..28b374620 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -191,10 +191,13 @@ qreal KItemListWidget::columnWidth(const QByteArray& role) const
void KItemListWidget::setStyleOption(const KItemListStyleOption& option)
{
+ if (m_styleOption == option) {
+ return;
+ }
+
const KItemListStyleOption previous = m_styleOption;
clearHoverCache();
m_styleOption = option;
-
styleOptionChanged(option, previous);
update();
}
diff --git a/src/kitemviews/kstandarditemlistview.cpp b/src/kitemviews/kstandarditemlistview.cpp
index ee1c06103..929ee1da8 100644
--- a/src/kitemviews/kstandarditemlistview.cpp
+++ b/src/kitemviews/kstandarditemlistview.cpp
@@ -146,27 +146,20 @@ void KStandardItemListView::applyDefaultStyleOption(int iconSize,
{
KItemListStyleOption option = styleOption();
- bool changed = false;
if (option.iconSize < 0) {
option.iconSize = iconSize;
- changed = true;
}
if (option.padding < 0) {
option.padding = padding;
- changed = true;
}
if (option.horizontalMargin < 0) {
option.horizontalMargin = horizontalMargin;
- changed = true;
}
if (option.verticalMargin < 0) {
option.verticalMargin = verticalMargin;
- changed = true;
}
- if (changed) {
- setStyleOption(option);
- }
+ setStyleOption(option);
}
void KStandardItemListView::updateLayoutOfVisibleItems()
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 1aca250dd..bc3bb29de 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -1015,15 +1015,21 @@ void KStandardItemListWidget::updatePixmapCache()
if (iconOnTop) {
// Center horizontally and align on bottom within the icon-area
- m_pixmapPos.setX((widgetSize.width() - m_scaledPixmapSize.width()) / 2);
+ m_pixmapPos.setX((widgetSize.width() - m_scaledPixmapSize.width()) / 2.0);
m_pixmapPos.setY(padding + scaledIconSize - m_scaledPixmapSize.height());
} else {
// Center horizontally and vertically within the icon-area
const TextInfo* textInfo = m_textInfo.value("text");
- m_pixmapPos.setX(textInfo->pos.x() - 2 * padding
- - (scaledIconSize + m_scaledPixmapSize.width()) / 2);
- m_pixmapPos.setY(padding
- + (scaledIconSize - m_scaledPixmapSize.height()) / 2);
+ m_pixmapPos.setX(textInfo->pos.x() - 2.0 * padding
+ - (scaledIconSize + m_scaledPixmapSize.width()) / 2.0);
+
+ // Derive icon's vertical center from the center of the text frame, including
+ // any necessary adjustment if the font's midline is offset from the frame center
+ const qreal midlineShift = m_customizedFontMetrics.height() / 2.0
+ - m_customizedFontMetrics.descent()
+ - m_customizedFontMetrics.capHeight() / 2.0;
+ m_pixmapPos.setY(m_textRect.center().y() + midlineShift - m_scaledPixmapSize.height() / 2.0);
+
}
m_iconRect = QRectF(m_pixmapPos, QSizeF(m_scaledPixmapSize));
diff --git a/src/kitemviews/private/kbaloorolesprovider.cpp b/src/kitemviews/private/kbaloorolesprovider.cpp
index bbd0927f2..3d3923b1b 100644
--- a/src/kitemviews/private/kbaloorolesprovider.cpp
+++ b/src/kitemviews/private/kbaloorolesprovider.cpp
@@ -56,9 +56,6 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
{
QHash<QByteArray, QVariant> values;
- int width = -1;
- int height = -1;
-
QMapIterator<KFileMetaData::Property::Property, QVariant> it(file.properties());
while (it.hasNext()) {
it.next();
@@ -72,23 +69,7 @@ QHash<QByteArray, QVariant> KBalooRolesProvider::roleValues(const Baloo::File& f
const QVariant value = it.value();
- if (role == "imageSize") {
- // Merge the two properties for width and height
- // as one string into the "imageSize" role
- if (property == QLatin1String("width")) {
- width = value.toInt();
- }
- else if (property == QLatin1String("height")) {
- height = value.toInt();
- }
-
- if (width >= 0 && height >= 0) {
- QString widthAndHeight = QString::number(width);
- widthAndHeight += QLatin1String(" x ");
- widthAndHeight += QString::number(height);
- values.insert(role, widthAndHeight);
- }
- } else if (role == "orientation") {
+ if (role == "orientation") {
const QString orientation = orientationFromValue(value.toInt());
values.insert(role, orientation);
} else if (role == "duration") {
@@ -135,8 +116,7 @@ KBalooRolesProvider::KBalooRolesProvider() :
};
// Mapping from the URIs to the KFileItemModel roles. Note that this must not be
- // a 1:1 mapping: One role may contain several URI-values (e.g. the URIs for height and
- // width of an image are mapped to the role "imageSize")
+ // a 1:1 mapping: One role may contain several URI-values
static const PropertyInfo propertyInfoList[] = {
{ "rating", "rating" },
{ "tag", "tags" },
@@ -144,8 +124,8 @@ KBalooRolesProvider::KBalooRolesProvider() :
{ "title", "title" },
{ "wordCount", "wordCount" },
{ "lineCount", "lineCount" },
- { "width", "imageSize" },
- { "height", "imageSize" },
+ { "width", "width" },
+ { "height", "height" },
{ "imageDateTime", "imageDateTime"},
{ "nexif.orientation", "orientation", },
{ "artist", "artist" },