1 /***************************************************************************
2 * Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
20 #include "dolphinfileitemlistwidget.h"
22 #include <kversioncontrolplugin.h>
27 DolphinFileItemListWidget::DolphinFileItemListWidget(QGraphicsItem
* parent
) :
28 KFileItemListWidget(parent
)
32 DolphinFileItemListWidget::~DolphinFileItemListWidget()
36 void DolphinFileItemListWidget::dataChanged(const QHash
<QByteArray
, QVariant
>& current
, const QSet
<QByteArray
>& roles
)
38 KFileItemListWidget::dataChanged(current
, roles
);
41 if (roles
.contains("version")) {
42 // The item is under version control. Apply the text color corresponding
43 // to its version state.
44 const KVersionControlPlugin::VersionState version
= static_cast<KVersionControlPlugin::VersionState
>(current
.value("version").toInt());
45 if (version
!= KVersionControlPlugin::UnversionedVersion
) {
46 const QColor textColor
= styleOption().palette
.text().color();
47 QColor tintColor
= textColor
;
49 // Using hardcoded colors is generally a bad idea. In this case the colors just act
50 // as tint colors and are mixed with the current set text color. The tint colors
51 // have been optimized for the base colors of the corresponding Oxygen emblems.
53 case KVersionControlPlugin::UpdateRequiredVersion
: tintColor
= Qt::yellow
; break;
54 case KVersionControlPlugin::LocallyModifiedUnstagedVersion
: tintColor
= Qt::darkGreen
; break;
55 case KVersionControlPlugin::LocallyModifiedVersion
: tintColor
= Qt::green
; break;
56 case KVersionControlPlugin::AddedVersion
: tintColor
= Qt::green
; break;
57 case KVersionControlPlugin::RemovedVersion
: tintColor
= Qt::darkRed
; break;
58 case KVersionControlPlugin::ConflictingVersion
: tintColor
= Qt::red
; break;
59 case KVersionControlPlugin::UnversionedVersion
:
60 case KVersionControlPlugin::NormalVersion
:
62 // use the default text color
66 color
= QColor((tintColor
.red() + textColor
.red()) / 2,
67 (tintColor
.green() + textColor
.green()) / 2,
68 (tintColor
.blue() + textColor
.blue()) / 2,
69 (tintColor
.alpha() + textColor
.alpha()) / 2);
76 #include "dolphinfileitemlistwidget.moc"