diff options
| author | Peter Penz <[email protected]> | 2011-09-08 18:57:52 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-09-08 18:58:59 +0200 |
| commit | be629fe8501941138da849cf1179ad67cd5570cb (patch) | |
| tree | f10197fcac7c698a3768327475ef7b339a2f6397 /src/kitemviews | |
| parent | f8f78f223cf9549556bcbd9214a1e530d5217069 (diff) | |
Version control: Apply text-color if an item is versioned
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 8 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodel.cpp | 19 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemmodel.h | 9 |
3 files changed, 27 insertions, 9 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 8cd124437..8078d0d4d 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -168,12 +168,14 @@ void KFileItemListWidget::setTextColor(const QColor& color) } else { *m_customTextColor = color; } - } else { + updateAdditionalInfoTextColor(); + update(); + } else if (m_customTextColor){ delete m_customTextColor; m_customTextColor = 0; + updateAdditionalInfoTextColor(); + update(); } - updateAdditionalInfoTextColor(); - update(); } QColor KFileItemListWidget::textColor() const diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp index 2a52de986..9de99d8de 100644 --- a/src/kitemviews/kfileitemmodel.cpp +++ b/src/kitemviews/kfileitemmodel.cpp @@ -204,13 +204,22 @@ KFileItem KFileItemModel::fileItem(int index) const return KFileItem(); } +KFileItem KFileItemModel::fileItem(const KUrl& url) const +{ + const int index = m_items.value(url, -1); + if (index >= 0) { + return m_sortedItems.at(index); + } + return KFileItem(); +} + int KFileItemModel::index(const KFileItem& item) const { if (item.isNull()) { return -1; } - return m_items.value(item, -1); + return m_items.value(item.url(), -1); } KUrl KFileItemModel::rootDirectory() const @@ -360,7 +369,7 @@ void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArr int index = 0; foreach (const KFileItem& item, sortedItems) { m_sortedItems.append(item); - m_items.insert(item, index); + m_items.insert(item.url(), index); m_data.append(retrieveData(item)); ++index; @@ -504,7 +513,7 @@ void KFileItemModel::insertItems(const KFileItemList& items) // The indexes of all m_items must be adjusted, not only the index // of the new items for (int i = 0; i < m_sortedItems.count(); ++i) { - m_items.insert(m_sortedItems.at(i), i); + m_items.insert(m_sortedItems.at(i).url(), i); } itemRanges << KItemRange(insertedAtIndex, insertedCount); @@ -566,7 +575,7 @@ void KFileItemModel::removeItems(const KFileItemList& items) // Delete the items for (int i = indexesToRemove.count() - 1; i >= 0; --i) { const int indexToRemove = indexesToRemove.at(i); - m_items.remove(m_sortedItems.at(indexToRemove)); + m_items.remove(m_sortedItems.at(indexToRemove).url()); m_sortedItems.removeAt(indexToRemove); m_data.removeAt(indexToRemove); } @@ -574,7 +583,7 @@ void KFileItemModel::removeItems(const KFileItemList& items) // The indexes of all m_items must be adjusted, not only the index // of the removed items for (int i = 0; i < m_sortedItems.count(); ++i) { - m_items.insert(m_sortedItems.at(i), i); + m_items.insert(m_sortedItems.at(i).url(), i); } if (count() <= 0) { diff --git a/src/kitemviews/kfileitemmodel.h b/src/kitemviews/kfileitemmodel.h index 189c50846..1b7c8bdca 100644 --- a/src/kitemviews/kfileitemmodel.h +++ b/src/kitemviews/kfileitemmodel.h @@ -83,6 +83,13 @@ public: KFileItem fileItem(int index) const; /** + * @return The file-item for the url \a url. If no file-item with the given + * URL is found KFileItem::isNull() will be true for the returned + * file-item. The runtime complexity of this call is O(1). + */ + KFileItem fileItem(const KUrl& url) const; + + /** * @return The index for the file-item \a item. -1 is returned if no file-item * is found or if the file-item is null. The runtime * complexity of this call is O(1). @@ -183,7 +190,7 @@ private: Qt::CaseSensitivity m_caseSensitivity; KFileItemList m_sortedItems; // Allows O(1) access for KFileItemModel::fileItem(int index) - QHash<KFileItem, int> m_items; // Allows O(1) access for KFileItemModel::index(const KFileItem& item) + QHash<KUrl, int> m_items; // Allows O(1) access for KFileItemModel::index(const KFileItem& item) QList<QHash<QByteArray, QVariant> > m_data; bool m_requestRole[RolesCount]; |
