┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kfileitemlistwidget.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2011-09-06 23:42:42 +0200
committerPeter Penz <[email protected]>2011-09-06 23:45:41 +0200
commitb8c718a6fd9810f9e91303ed50402de4ab417a49 (patch)
treef6e22b028cb0932c44dc29ea6c494f121c6f8dc9 /src/kitemviews/kfileitemlistwidget.cpp
parent7a91492cff931c0c4e0d38dd0aee77d9dcb29373 (diff)
First step to reactivate version control plugin functionality
- Add a DolphinFileItemListWidget that provides icon-overlays and colored text for the version state (implementation is missing yet) - Allow KFileItemListWidget to have custom text colors - Update interface of VersionControlObserver to work with KFileItemModel instead of the old model-interface.
Diffstat (limited to 'src/kitemviews/kfileitemlistwidget.cpp')
-rw-r--r--src/kitemviews/kfileitemlistwidget.cpp57
1 files changed, 44 insertions, 13 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
index 4fc3307ef..8cd124437 100644
--- a/src/kitemviews/kfileitemlistwidget.cpp
+++ b/src/kitemviews/kfileitemlistwidget.cpp
@@ -56,6 +56,7 @@ KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) :
m_textBoundingRect(),
m_sortedVisibleRoles(),
m_expansionArea(),
+ m_customTextColor(0),
m_additionalInfoTextColor()
{
for (int i = 0; i < TextIdCount; ++i) {
@@ -66,6 +67,8 @@ KFileItemListWidget::KFileItemListWidget(QGraphicsItem* parent) :
KFileItemListWidget::~KFileItemListWidget()
{
+ delete m_customTextColor;
+ m_customTextColor = 0;
}
void KFileItemListWidget::setLayout(Layout layout)
@@ -114,7 +117,11 @@ void KFileItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsIte
}
painter->setFont(itemListStyleOption.font);
- painter->setPen(itemListStyleOption.palette.text().color());
+ if (m_customTextColor) {
+ painter->setPen(*m_customTextColor);
+ } else {
+ painter->setPen(itemListStyleOption.palette.text().color());
+ }
painter->drawStaticText(m_textPos[Name], m_text[Name]);
painter->setPen(m_additionalInfoTextColor);
@@ -153,6 +160,27 @@ QRectF KFileItemListWidget::expansionToggleRect() const
return m_isDir ? m_expansionArea : QRectF();
}
+void KFileItemListWidget::setTextColor(const QColor& color)
+{
+ if (color.isValid()) {
+ if (!m_customTextColor) {
+ m_customTextColor = new QColor(color);
+ } else {
+ *m_customTextColor = color;
+ }
+ } else {
+ delete m_customTextColor;
+ m_customTextColor = 0;
+ }
+ updateAdditionalInfoTextColor();
+ update();
+}
+
+QColor KFileItemListWidget::textColor() const
+{
+ return m_customTextColor ? *m_customTextColor : styleOption().palette.text().color();
+}
+
void KFileItemListWidget::dataChanged(const QHash<QByteArray, QVariant>& current,
const QSet<QByteArray>& roles)
{
@@ -215,18 +243,7 @@ void KFileItemListWidget::styleOptionChanged(const KItemListStyleOption& current
const KItemListStyleOption& previous)
{
KItemListWidget::styleOptionChanged(current, previous);
-
- // For the color of the additional info the inactive text color
- // is not used as this might lead to unreadable text for some color schemes. Instead
- // the text color is slightly mixed with the background color.
- const QColor c1 = current.palette.text().color();
- const QColor c2 = current.palette.background().color();
- const int p1 = 70;
- const int p2 = 100 - p1;
- m_additionalInfoTextColor = QColor((c1.red() * p1 + c2.red() * p2) / 100,
- (c1.green() * p1 + c2.green() * p2) / 100,
- (c1.blue() * p1 + c2.blue() * p2) / 100);
-
+ updateAdditionalInfoTextColor();
m_dirtyLayout = true;
}
@@ -602,6 +619,20 @@ void KFileItemListWidget::updateDetailsLayoutTextCache()
}
}
+void KFileItemListWidget::updateAdditionalInfoTextColor()
+{
+ // For the color of the additional info the inactive text color
+ // is not used as this might lead to unreadable text for some color schemes. Instead
+ // the text color is slightly mixed with the background color.
+ const QColor c1 = m_customTextColor ? *m_customTextColor : styleOption().palette.text().color();
+ const QColor c2 = styleOption().palette.background().color();
+ const int p1 = 70;
+ const int p2 = 100 - p1;
+ m_additionalInfoTextColor = QColor((c1.red() * p1 + c2.red() * p2) / 100,
+ (c1.green() * p1 + c2.green() * p2) / 100,
+ (c1.blue() * p1 + c2.blue() * p2) / 100);
+}
+
QString KFileItemListWidget::roleText(TextId textId, const QVariant& roleValue) const
{
QString text;