From 37333bf25ad9a4c538250f5af2f9f1d666362883 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeadmin@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- .../knetworkconf/kprofileslistviewtooltip.h | 139 +++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 knetworkconf/knetworkconf/kprofileslistviewtooltip.h (limited to 'knetworkconf/knetworkconf/kprofileslistviewtooltip.h') diff --git a/knetworkconf/knetworkconf/kprofileslistviewtooltip.h b/knetworkconf/knetworkconf/kprofileslistviewtooltip.h new file mode 100644 index 0000000..c0c6bce --- /dev/null +++ b/knetworkconf/knetworkconf/kprofileslistviewtooltip.h @@ -0,0 +1,139 @@ +/*************************************************************************** + kprofileslistviewtooltip.h - description + ------------------- + begin : Wed Aug 24 2005 + copyright : (C) 2005 by Juan Luis Baptiste + email : juan.baptiste@kdemail.net + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ +#ifndef KPROFILESLISTVIEWTOOLTIP_H +#define KPROFILESLISTVIEWTOOLTIP_H + +#include +#include +#include +#include + +#include "knetworkinfo.h" +#include "knetworkconfigparser.h" + +class KProfilesListViewToolTip : public QToolTip +{ +public: + KProfilesListViewToolTip(QListView* parent); + void setProfiles(QPtrList profiles_); + ~KProfilesListViewToolTip(); + +protected: + void maybeTip( const QPoint& p ); + KNetworkInfo *getProfile(QPtrList profilesList, QString selectedProfile); +private: + QListView* listView; + //KNetworkConf* conf; + QPtrList profiles; + +}; + +inline void KProfilesListViewToolTip::setProfiles(QPtrList profiles_) +{ + profiles = profiles_; +} + +inline KProfilesListViewToolTip::KProfilesListViewToolTip( QListView* parent ):QToolTip( parent->viewport() ), listView( parent ) {} + +inline void KProfilesListViewToolTip::maybeTip( const QPoint& p ) +{ + + if ( !listView ) + return; + + const QListViewItem* item = listView->itemAt( p ); + + if ( !item ) + return; + + const QRect itemRect = listView->itemRect( item ); + + if ( !itemRect.isValid() ) + return; + + const int col = listView->header()->sectionAt( p.x() ); + + if ( col == -1 ) + return; + + const QRect headerRect = listView->header()->sectionRect( col ); + + if ( !headerRect.isValid() ) + return; + + const QRect cellRect( headerRect.left(), itemRect.top(),headerRect.width() + 60, itemRect.height() ); + + QString tipStr; + + if( col == 0 ) + { + tipStr = QString(i18n("Network Configuration of this Profile:" )); + KNetworkInfo *profile = getProfile(profiles,item->text(0)); + if (profile != NULL) + { + QPtrList devices = profile->getDeviceList(); + KNetworkInterface *device = NULL; + for (device = devices.first(); device; device = devices.next()) + { + if (device->getType() != LOOPBACK_IFACE_TYPE) + { + tipStr.append(i18n("

Interface: %1").arg(device->getDeviceName().latin1())); + tipStr.append(i18n("
Type: %1").arg(device->getType())); + QString bootProto; + if (device->getBootProto() == "none") + bootProto = "Manual"; + else + bootProto = device->getBootProto(); + tipStr.append(i18n("
Boot Protocol: %1").arg(bootProto)); + if (bootProto != "dhcp") + { + tipStr.append(i18n("
IP Address: %1").arg(device->getIpAddress())); + tipStr.append(i18n("
Broadcast Address: %1").arg(device->getBroadcast())); + } + tipStr.append(i18n("
On Boot: %1").arg(device->getOnBoot())); + } + } + KRoutingInfo *route = profile->getRoutingInfo(); + tipStr.append(i18n("

Default Gateway: %1").arg(route->getGateway())); + KDNSInfo *dns = profile->getDNSInfo(); + tipStr.append(i18n("
Domain Name: %1").arg(dns->getDomainName())); + tipStr.append(i18n("
Machine Name: %1").arg(dns->getMachineName())); + QStringList nameServers = dns->getNameServers(); + for ( QStringList::Iterator it = nameServers.begin(); it != nameServers.end(); ++it) + { + tipStr.append(i18n("
DNS Name Server: %1").arg((*it))); + } + } + } + tip( cellRect, tipStr ); +} + +inline KNetworkInfo *KProfilesListViewToolTip::getProfile(QPtrList profilesList, QString selectedProfile) +{ + QPtrListIterator it(profilesList); + KNetworkInfo *net = NULL; + + while ((net = it.current()) != 0) + { + ++it; + if (net->getProfileName() == selectedProfile) + break; + } + return net; +} + +#endif -- cgit v1.2.3