Source Code (Use browser search to find items of interest.)

Class Index

ksysctrl'DeviceManagerTab (./kdeadmin/ksysctrl/ksysctrl/devmantab.h:30)

class DeviceManagerTab : public QWidget
{
  Q_OBJECT
  
  public:
  
    DeviceManagerTab(QWidget *parent = 0L, const char *name = 0L);
    ~DeviceManagerTab() {}
    
  private:
  
    QListView    *_listview;
    QPushButton  *_pushprop, *_pushrefresh;
    
    void  fillIn();
    void  visualizeConflict(QPixmap&);
    
  private slots:
  
    void  slotCurrentChanged(QListViewItem *);
    void  slotProperties();
    void  slotRefresh();
};


ksysctrl'DeviceManagerTab::DeviceManagerTab() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:38)

DeviceManagerTab::DeviceManagerTab(QWidget *parent, const char *name) : QWidget(parent, name)
{
  _listview = new QListView(this, "listview");
  _listview->setFrameStyle(QFrame::Panel | QFrame::Sunken);
  _listview->setLineWidth(2);
  _listview->setAllColumnsShowFocus(true);
  _listview->setRootIsDecorated(true);
  _listview->setItemMargin(2);
  _listview->addColumn(i18n("Device"));
  connect(_listview, SIGNAL(currentChanged(QListViewItem *)), SLOT(slotCurrentChanged(QListViewItem *)));
  
  QVBoxLayout  *toplayout = new QVBoxLayout(this, 16, 4, "toplayout");
  toplayout->addWidget(_listview);
  toplayout->addSpacing(4);
  
  _pushprop = new QPushButton(i18n("&Properties"), this, "pushprop");
  _pushprop->adjustSize();
  connect(_pushprop, SIGNAL(clicked()), SLOT(slotProperties()));
  
  _pushrefresh = new QPushButton(i18n("&Refresh"), this, "pushrefresh");
  _pushrefresh->adjustSize();
  connect(_pushrefresh, SIGNAL(clicked()), SLOT(slotRefresh()));  
  
  QHBoxLayout  *butlayout = new QHBoxLayout(toplayout, 4, "butlayout");
  butlayout->addWidget(_pushprop);
  butlayout->addWidget(_pushrefresh);
  butlayout->addStretch(1);
  
  fillIn();
  slotCurrentChanged(_listview->firstChild());
  
  toplayout->activate();
}


/*
 * Private methods
 ******************/
 

ksysctrl'DeviceManagerTab::fillIn() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:77)

void  DeviceManagerTab::fillIn()
{
  DeviceEntry  *deventry, *parent, *newentry;
  QPixmap      parentxpm, childxpm;
  Device       *device;
  
  _listview->clear();
  
  for (device = devicelist->first(); device; device = devicelist->next())
  {
    for (deventry = (DeviceEntry *) _listview->firstChild(); deventry; deventry = (DeviceEntry *) deventry->nextSibling())
      if (!deventry->device() && (device->deviceBaseClass() == deventry->deviceBaseClass())) break;
 
    parent    = (deventry) ? deventry : new DeviceEntry(_listview, device->deviceBaseClass(),
  								   device->deviceBaseClassName());
    newentry  = new DeviceEntry(parent, device);
    parentxpm = childxpm = BarIcon(device->smallPixmapFile());
 
    if (device->conflict() || parent->conflict()) 
    {
      visualizeConflict(parentxpm);
      parent->setConflict(true);
      parent->setOpen(true);
      
      if (device->conflict()) visualizeConflict(childxpm);
    }
    
    parent->setPixmap(0,   parentxpm);
    newentry->setPixmap(0, childxpm);
  }
}



ksysctrl'DeviceManagerTab::visualizeConflict() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:110)

void  DeviceManagerTab::visualizeConflict(QPixmap& pixmap)
{
  QPixmap  confmark = BarIcon("confmark");
  
  bitBlt(&pixmap, 0, 0, &confmark, 0, 0, 10, 10, CopyROP);
}


/*
 * Private slots
 ****************/
 

ksysctrl'DeviceManagerTab::slotCurrentChanged() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:122)

void  DeviceManagerTab::slotCurrentChanged(QListViewItem *item)
{
  _pushprop->setEnabled(((DeviceEntry *) item)->device());
} 



ksysctrl'DeviceManagerTab::slotProperties() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:128)

void  DeviceManagerTab::slotProperties()
{
  PropertiesDialog  *propdialog;
  DeviceEntry       *deventry = (DeviceEntry *) _listview->currentItem();
  Device            *device;
  
  if (deventry)
  {
    propdialog = new PropertiesDialog(device = deventry->device(), this, "propdialog");  
    
    if (propdialog->exec() == QDialog::Accepted)
    {
      QString  tmp;
      
      tmp  = i18n("You are about to change device resource\n"
                  "settings which may affect stability of\n"
                  "your system.\n"
                  "Do you really want the changes to take\n"
                  "effect?");
      
      if (!QMessageBox::warning(this, i18n("Change resource settings"), tmp, 
      	  i18n("&Yes"), i18n("&No"), 0, 1, 1))
      {
        device->changePhysicalResources(propdialog->resourceList());      
        devicelist->rescan(false);
        fillIn();
      }
    }
    
    delete propdialog;
  }
}



ksysctrl'DeviceManagerTab::slotRefresh() (./kdeadmin/ksysctrl/ksysctrl/devmantab.cpp:162)

void  DeviceManagerTab::slotRefresh()
{
  devicelist->rescan(true);
  fillIn();
}