diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2012-04-06 19:01:43 -0500 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2012-04-06 19:01:43 -0500 |
commit | 520b27baef7cd2e3a8b7b757564a9b78cd61e506 (patch) | |
tree | f9b5e700a65cde840fd2325d22bfa664efcfc2bb /kcontrol/hwmanager/deviceiconview.cpp | |
parent | 5e6882c8f936caf15cc98409ecac3817bca2cb49 (diff) | |
parent | 0d6bebc5f5bacd360dcee8f58b93ae3c99028c75 (diff) | |
download | tdebase-520b27baef7cd2e3a8b7b757564a9b78cd61e506.tar.gz tdebase-520b27baef7cd2e3a8b7b757564a9b78cd61e506.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdebase
Diffstat (limited to 'kcontrol/hwmanager/deviceiconview.cpp')
-rw-r--r-- | kcontrol/hwmanager/deviceiconview.cpp | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/kcontrol/hwmanager/deviceiconview.cpp b/kcontrol/hwmanager/deviceiconview.cpp new file mode 100644 index 000000000..f38f35460 --- /dev/null +++ b/kcontrol/hwmanager/deviceiconview.cpp @@ -0,0 +1,108 @@ +/* + Copyright (c) 2000 Matthias Elter <elter@kde.org> + Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> + + 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 <tqheader.h> +#include <tqcursor.h> + +#include <klocale.h> +#include <kstandarddirs.h> +#include <kservicegroup.h> +#include <kiconloader.h> +#include <kmessagebox.h> + +#include <kdebug.h> + +#include "deviceiconview.h" +#include "deviceiconview.moc" + +DeviceIconView::DeviceIconView(TQWidget * parent, const char * name) + : KListView(parent, name) +{ + setSorting(0, true); + addColumn(TQString::null); + + // Show expand/collapse widgets on root items + setRootIsDecorated(true); + + header()->hide(); + + connect(this, TQT_SIGNAL(clicked(TQListViewItem*)), this, TQT_SLOT(slotItemSelected(TQListViewItem*))); + connect(this, TQT_SIGNAL(executed(TQListViewItem*)), this, TQT_SLOT(slotItemDoubleClicked(TQListViewItem*))); +} + +void DeviceIconView::slotItemSelected(TQListViewItem* item) +{ + TQApplication::restoreOverrideCursor(); + if (!item) { + return; + } +} + +void DeviceIconView::slotItemDoubleClicked(TQListViewItem* item) +{ + TQApplication::restoreOverrideCursor(); + if (!item) { + return; + } + + DeviceIconItem* divi = dynamic_cast<DeviceIconItem*>(item); + if (!divi) { + return; + } + + if (divi->device()) { + DevicePropertiesDialog* propsDlg = new DevicePropertiesDialog(divi->device(), this); + propsDlg->exec(); + delete propsDlg; + } + else { + KMessageBox::sorry(this, "Detailed information is not available for this device", "Information Unavailable"); + } +} + +void DeviceIconView::keyPressEvent(TQKeyEvent *e) +{ + if (e->key() == Key_Return + || e->key() == Key_Enter + || e->key() == Key_Space) + { + if (currentItem()) { + slotItemSelected(currentItem()); + } + } + else { + KListView::keyPressEvent(e); + } +} + +TQPixmap DeviceIconView::loadIcon( const TQString &name ) +{ + TQPixmap icon = DesktopIcon( name, iconSize() ); + + if(icon.isNull()) { + icon = DesktopIcon( "misc", iconSize() ); + } + + return icon; +} + +KIcon::StdSizes DeviceIconView::iconSize() { + return KIcon::SizeSmall; +}
\ No newline at end of file |