kivio

layerlisttooltip.cpp
1/*
2 * Kivio - Visual Modelling and Flowcharting
3 * Copyright (C) 2006 Peter Simonsson <psn@linux.se>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19#include "layerlisttooltip.h"
20
21#include <tqheader.h>
22
23#include <tdelocale.h>
24
25#include "kivio_layer_panel.h"
26#include "kivio_layer.h"
27
28namespace Kivio {
29
30LayerListToolTip::LayerListToolTip(TQWidget* parent, TQListView* listView)
31 : TQToolTip(parent)
32{
33 m_listView = listView;
34}
35
36LayerListToolTip::~LayerListToolTip()
37{
38}
39
40void LayerListToolTip::maybeTip(const TQPoint& pos)
41{
42 if(!m_listView) {
43 return;
44 }
45
46 KivioLayerItem* item = dynamic_cast<KivioLayerItem*>(m_listView->itemAt(pos));
47
48 if(!item) {
49 return;
50 }
51
52 TQRect itemRect = m_listView->itemRect(item);
53 TQString toolTip = "<b>" + item->layer()->name() + "</b><br>";
54 toolTip += i18n("Visible: ") + (item->layer()->visible() ? i18n("Yes") : i18n("No")) + "<br>";
55 toolTip += i18n("Printable: ") + (item->layer()->printable() ? i18n("Yes") : i18n("No")) + "<br>";
56 toolTip += i18n("Editable: ") + (item->layer()->editable() ? i18n("Yes") : i18n("No")) + "<br>";
57 toolTip += i18n("Connectable: ") + (item->layer()->connectable() ? i18n("Yes") : i18n("No"));
58 tip(itemRect, toolTip);
59}
60
61}