Warning, file /office/calligra/libs/widgets/KoResourceItemView.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2008 Jan Hambrecht <jaham@gmx.net>
0003  * Copyright (c) 2011 José Luis Vergara <pentalis@gmail.com
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #include "KoResourceItemView.h"
0022 #include <QEvent>
0023 #include <QHelpEvent>
0024 
0025 #include <QDebug>
0026 
0027 KoResourceItemView::KoResourceItemView(QWidget *parent)
0028     : KoTableView(parent)
0029 {
0030 }
0031 
0032 bool KoResourceItemView::viewportEvent(QEvent *event)
0033 {
0034     if (event->type() == QEvent::ToolTip && model()) {
0035         QHelpEvent *he = static_cast<QHelpEvent *>(event);
0036         QStyleOptionViewItem option = viewOptions();
0037         QModelIndex index = model()->buddy(indexAt(he->pos()));
0038         if (index.isValid()) {
0039             option.rect = visualRect(index);
0040             m_tip.showTip(this, he->pos(), option, index);
0041             return true;
0042         }
0043     }
0044 
0045     return QTableView::viewportEvent(event);
0046 }
0047 
0048 
0049 void KoResourceItemView::selectionChanged(const QItemSelection &selected, const QItemSelection &/*deselected*/)
0050 {
0051     if (!selected.isEmpty())
0052         emit currentResourceChanged(selected.indexes().first());
0053 }
0054 
0055 void KoResourceItemView::contextMenuEvent(QContextMenuEvent *event)
0056 {
0057     QTableView::contextMenuEvent(event);
0058     emit contextMenuRequested(event->globalPos());
0059 }