KHDAPSMonitor – monitor for laptops that support the IBM Hard Drive Active Protection System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

80 lines
2.9 KiB

/***************************************************************************
* Copyright (C) 2006 by Roy Marples *
* roy@marples.name *
* *
* 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., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <klocale.h>
#include <qlabel.h>
#include <qlistview.h>
#include <qimage.h>
#include "khdapsmonitorwidget.h"
#include "sysfs.h"
KHDAPSMonitorWidget::KHDAPSMonitorWidget(QWidget* parent, const char* name, WFlags fl)
: KHDAPSMonitorWidgetBase(parent,name,fl)
{
update();
}
KHDAPSMonitorWidget::~KHDAPSMonitorWidget()
{}
void KHDAPSMonitorWidget::update()
{
if (! sysFS.hasHDAPS())
{
keyboardActivity->setText(I18N_NOOP("n/a"));
mouseActivity->setText(I18N_NOOP("n/a"));
position->setText(I18N_NOOP("n/a"));
deviceList->clear();
return;
}
keyboardActivity->setText(sysFS.keyboardActivity() ? I18N_NOOP("Yes") : I18N_NOOP("No"));
mouseActivity->setText(sysFS.mouseActivity() ? I18N_NOOP("Yes") : I18N_NOOP("No"));
position->setText(sysFS.position());
QStringList dList = sysFS.deviceList();
unsigned int i;
QListViewItem * item;
for (i = 0; i < dList.count(); i++)
{
item = deviceList->findItem(dList[i], 0);
if (item == NULL)
item = new QListViewItem(deviceList, dList[i]);
item->setText(1, sysFS.queueProtected(dList[i]) ? I18N_NOOP("Yes") : I18N_NOOP("No"));
}
/* Remove devices from the ListView that we are no longer monitoring
* Is there a better way of doing this? */
item = deviceList->firstChild();
while (item)
{
for (i = 0; i < dList.count(); i++)
if (dList[i] == item->text(0))
break;
QListViewItem * nextItem = item->nextSibling();
if (i >= dList.count())
delete item;
item = nextItem;
}
}
#include "khdapsmonitorwidget.moc"