┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2009-11-11 19:47:07 +0000
committerPeter Penz <[email protected]>2009-11-11 19:47:07 +0000
commit98f0289c767292bf94a6aae85386f8d01d128d28 (patch)
treecfa28b1b16fecff163c339fd2829cb2de07ec5ff /src
parent36ae0b6185e310113e0e31e247919da866d7f91b (diff)
Images: Instead of showing the meta data for "Width:" and "Height:" separately with other items in between, they are merged as "Width x Height:" and added to the top of the sort order.
CCBUG: 193592 svn path=/trunk/KDE/kdebase/apps/; revision=1047680
Diffstat (limited to 'src')
-rw-r--r--src/panels/information/kmetadatawidget.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/src/panels/information/kmetadatawidget.cpp b/src/panels/information/kmetadatawidget.cpp
index f1b0965af..9e995ba0f 100644
--- a/src/panels/information/kmetadatawidget.cpp
+++ b/src/panels/information/kmetadatawidget.cpp
@@ -102,6 +102,11 @@ public:
*/
void startChangeDataJob(KJob* job);
+ /**
+ * Merges items like 'width' and 'height' as one item.
+ */
+ QList<KLoadMetaDataThread::Item> mergedItems(const QList<KLoadMetaDataThread::Item>& items);
+
bool m_sizeVisible;
bool m_readOnly;
MetaDataTypes m_visibleDataTypes;
@@ -341,7 +346,7 @@ void KMetaDataWidget::Private::slotLoadingFinished()
const int rowCount = m_rows.count();
Q_ASSERT(rowCount >= index);
- const QList<KLoadMetaDataThread::Item> items = m_loadMetaDataThread->items();
+ const QList<KLoadMetaDataThread::Item> items = mergedItems(m_loadMetaDataThread->items());
foreach (const KLoadMetaDataThread::Item& item, items) {
if (index < rowCount) {
// adjust texts of the current row
@@ -362,7 +367,7 @@ void KMetaDataWidget::Private::slotLoadingFinished()
}
// remove rows that are not needed anymore
- for (int i = m_rows.count() - 1; i > index; --i) {
+ for (int i = m_rows.count() - 1; i >= index; --i) {
delete m_rows[i].label;
delete m_rows[i].infoWidget;
m_rows.pop_back();
@@ -429,6 +434,55 @@ void KMetaDataWidget::Private::startChangeDataJob(KJob* job)
}
#endif
+QList<KLoadMetaDataThread::Item>
+ KMetaDataWidget::Private::mergedItems(const QList<KLoadMetaDataThread::Item>& items)
+{
+ // TODO: Currently only "width" and "height" are merged as "width x height". If
+ // other kind of merges should be done too, a more general approach is required.
+ QList<KLoadMetaDataThread::Item> mergedItems;
+
+ KLoadMetaDataThread::Item width;
+ KLoadMetaDataThread::Item height;
+
+ foreach (const KLoadMetaDataThread::Item& item, items) {
+ if (item.name == "width") {
+ width = item;
+ } else if (item.name == "height") {
+ height = item;
+ } else {
+ // insert the item sorted by the label
+ bool inserted = false;
+ int i = 0;
+ const int count = mergedItems.count();
+ while (!inserted && (i < count)) {
+ if (item.label < mergedItems[i].label) {
+ mergedItems.insert(i, item);
+ inserted = true;
+ }
+ ++i;
+ }
+ if (!inserted) {
+ mergedItems.append(item);
+ }
+ }
+ }
+
+ const bool foundWidth = !width.name.isEmpty();
+ const bool foundHeight = !height.name.isEmpty();
+ if (foundWidth && !foundHeight) {
+ mergedItems.insert(0, width);
+ } else if (foundHeight && !foundWidth) {
+ mergedItems.insert(0, height);
+ } else if (foundWidth && foundHeight) {
+ KLoadMetaDataThread::Item size;
+ size.label = i18nc("@label", "Width x Height:");
+ size.value = width.value + " x " + height.value;
+ mergedItems.insert(0, size);
+ }
+
+ return mergedItems;
+}
+
KMetaDataWidget::KMetaDataWidget(QWidget* parent) :
QWidget(parent),
d(new Private(this))