kivio

layerlisttooltip.cpp

00001 /*
00002  * Kivio - Visual Modelling and Flowcharting
00003  * Copyright (C) 2006 Peter Simonsson <psn@linux.se>
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  */
00019 #include "layerlisttooltip.h"
00020 
00021 #include <qheader.h>
00022 
00023 #include <klocale.h>
00024 
00025 #include "kivio_layer_panel.h"
00026 #include "kivio_layer.h"
00027 
00028 namespace Kivio {
00029 
00030 LayerListToolTip::LayerListToolTip(QWidget* parent, QListView* listView)
00031  : QToolTip(parent)
00032 {
00033   m_listView = listView;
00034 }
00035 
00036 LayerListToolTip::~LayerListToolTip()
00037 {
00038 }
00039 
00040 void LayerListToolTip::maybeTip(const QPoint& pos)
00041 {
00042   if(!m_listView) {
00043     return;
00044   }
00045 
00046   KivioLayerItem* item = dynamic_cast<KivioLayerItem*>(m_listView->itemAt(pos));
00047 
00048   if(!item) {
00049     return;
00050   }
00051 
00052   QRect itemRect = m_listView->itemRect(item);
00053   QString toolTip = "<b>" + item->layer()->name() + "</b><br>";
00054   toolTip += i18n("Visible: ") + (item->layer()->visible() ? i18n("Yes") : i18n("No")) + "<br>";
00055   toolTip += i18n("Printable: ") + (item->layer()->printable() ? i18n("Yes") : i18n("No")) + "<br>";
00056   toolTip += i18n("Editable: ") + (item->layer()->editable() ? i18n("Yes") : i18n("No")) + "<br>";
00057   toolTip += i18n("Connectable: ") + (item->layer()->connectable() ? i18n("Yes") : i18n("No"));
00058   tip(itemRect, toolTip);
00059 }
00060 
00061 }
KDE Home | KDE Accessibility Home | Description of Access Keys