diff options
| author | Peter Penz <[email protected]> | 2012-04-24 23:16:35 +0200 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2012-04-24 23:18:34 +0200 |
| commit | d9de39172033c28b8f9a7c1573130cf2124b4f7a (patch) | |
| tree | 8292181d95b92f9a5cb9544bd62d83ca8189c1a1 /src/kitemviews/kfileitemlistgroupheader.cpp | |
| parent | ba2593247b7f11c68419bf1fc24cc5ddcaf8e69f (diff) | |
Provide additional default groups for the Places Panel
If Nepomuk is enabled, it is now possible to easily search for
some most common queries by having additional groups.
Diffstat (limited to 'src/kitemviews/kfileitemlistgroupheader.cpp')
| -rw-r--r-- | src/kitemviews/kfileitemlistgroupheader.cpp | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/src/kitemviews/kfileitemlistgroupheader.cpp b/src/kitemviews/kfileitemlistgroupheader.cpp deleted file mode 100644 index 0c940ed28..000000000 --- a/src/kitemviews/kfileitemlistgroupheader.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2011 by Peter Penz <[email protected]> * - * * - * Based on the Itemviews NG project from Trolltech Labs: * - * http://qt.gitorious.org/qt-labs/itemviews-ng * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#include "kfileitemlistgroupheader.h" - -#include <kratingpainter.h> -#include <QPainter> - -KFileItemListGroupHeader::KFileItemListGroupHeader(QGraphicsWidget* parent) : - KItemListGroupHeader(parent), - m_dirtyCache(true), - m_text(), - m_pixmap() -{ - m_text.setTextFormat(Qt::PlainText); - m_text.setPerformanceHint(QStaticText::AggressiveCaching); -} - -KFileItemListGroupHeader::~KFileItemListGroupHeader() -{ -} - -void KFileItemListGroupHeader::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) -{ - KItemListGroupHeader::paint(painter, option, widget); - - if (m_dirtyCache) { - updateCache(); - } - - if (m_pixmap.isNull()) { - painter->setPen(roleColor()); - painter->drawStaticText(roleBounds().topLeft(), m_text); - } else { - painter->drawPixmap(roleBounds().topLeft(), m_pixmap); - } -} - -void KFileItemListGroupHeader::roleChanged(const QByteArray ¤t, const QByteArray &previous) -{ - Q_UNUSED(current); - Q_UNUSED(previous); - m_dirtyCache = true; -} - -void KFileItemListGroupHeader::dataChanged(const QVariant& current, const QVariant& previous) -{ - Q_UNUSED(current); - Q_UNUSED(previous); - m_dirtyCache = true; -} - -void KFileItemListGroupHeader::resizeEvent(QGraphicsSceneResizeEvent* event) -{ - QGraphicsWidget::resizeEvent(event); - m_dirtyCache = true; -} - -void KFileItemListGroupHeader::updateCache() -{ - Q_ASSERT(m_dirtyCache); - m_dirtyCache = false; - - const qreal maxWidth = size().width() - 4 * styleOption().padding; - - if (role() == "rating") { - m_text = QString(); - - const qreal height = styleOption().fontMetrics.ascent(); - const QSizeF pixmapSize(qMin(height * 5, maxWidth), height); - - m_pixmap = QPixmap(pixmapSize.toSize()); - m_pixmap.fill(Qt::transparent); - - QPainter painter(&m_pixmap); - const QRect rect(0, 0, m_pixmap.width(), m_pixmap.height()); - const int rating = data().toInt(); - KRatingPainter::paintRating(&painter, rect, Qt::AlignJustify | Qt::AlignVCenter, rating); - } else { - m_pixmap = QPixmap(); - - QFontMetricsF fontMetrics(font()); - const QString text = fontMetrics.elidedText(data().toString(), Qt::ElideRight, maxWidth); - m_text.setText(text); - } -} - -#include "kfileitemlistgroupheader.moc" |
