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

Class Index

kcontrol'DockContainer (./kdebase/kcontrol/kcontrol/dockcontainer.h:28)

class DockContainer : public QWidget
{
  Q_OBJECT

public:
  DockContainer(QWidget *parent=0, const char *name=0);

  void setBaseWidget(QWidget *widget);
  void dockModule(ConfigModule *module);

protected slots:
  void removeModule();

protected:
  void resizeEvent (QResizeEvent *);

signals:
  void newModule(const QString &name, const QString &quickhelp);

private:
  QWidget      *_basew;
  QLabel       *_busy;
  ConfigModule *_module;

};

kcontrol'DockContainer::DockContainer() (./kdebase/kcontrol/kcontrol/dockcontainer.cpp:34)

DockContainer::DockContainer(QWidget *parent, const char *name)
  : QWidget(parent, name)
  , _basew(0L)
  , _module(0L)
{
  _busy = new QLabel(i18n("Loading..."), this);
  _busy->setAlignment(AlignCenter);
  _busy->setGeometry(0,0, width(), height());
  _busy->hide();
}


kcontrol'DockContainer::setBaseWidget() (./kdebase/kcontrol/kcontrol/dockcontainer.cpp:45)

void DockContainer::setBaseWidget(QWidget *widget)
{
  if (!widget) return;
  
  _basew = widget;
  _basew->reparent(this, 0 , QPoint(0,0), true);
  resize(_basew->sizeHint());
  emit newModule(widget->caption(), "");
}


kcontrol'DockContainer::dockModule() (./kdebase/kcontrol/kcontrol/dockcontainer.cpp:55)

void DockContainer::dockModule(ConfigModule *module)
{
  if (!module) return;
  if (_module == module) return;

  if (_module && _module->isChanged())
    {	  	  
      int res = KMessageBox::warningYesNo(0,i18n("There are unsaved changes in the "
                                                 "active module.\n"
                                                 "Do you want to apply the changes "
                                                 "before running\n"
                                                 "the new module or forget the changes?"),
                                          i18n("Unsaved changes"),
                                          i18n("&Apply"),
                                          i18n("&Forget"));
      if (res == KMessageBox::Yes)
        _module->module()->applyClicked();
    }
  
  _busy->raise();
  _busy->show();
  _busy->repaint();
  QApplication::setOverrideCursor( waitCursor );
  ProxyWidget *widget = module->module();

  if (widget)
    {
      if (_module)
        _module->deleteClient();

      _module = module;
      connect(_module, SIGNAL(childClosed()),
              this, SLOT(removeModule()));
      
      widget->reparent(this, 0 , QPoint(0,0), false);
      widget->resize(size());
      
      emit newModule(widget->caption(), widget->quickHelp());
      QApplication::restoreOverrideCursor();
    }
  else
    {
      QApplication::restoreOverrideCursor();
      KMessageBox::sorry(0, i18n("Sorry, the control module \"%1\" could not be loaded.\n"
                                 "Perhaps it is not installed.").arg(module->name())
                         , i18n("Could not load control module."));
    }

  if (widget) widget->show();
  _busy->hide();
}


kcontrol'DockContainer::removeModule() (./kdebase/kcontrol/kcontrol/dockcontainer.cpp:107)

void DockContainer::removeModule()
{
  _module = 0L;
  resizeEvent(0L);
  
  if (_basew)
	emit newModule(_basew->caption(), "");
  else
	emit newModule("", "");
}


kcontrol'DockContainer::resizeEvent() (./kdebase/kcontrol/kcontrol/dockcontainer.cpp:118)

void DockContainer::resizeEvent(QResizeEvent *)
{
  _busy->resize(width(), height());
  if (_module)
	{
	  _module->module()->resize(size());
	  _basew->hide();
	}
  else
	{
	  _basew->resize(size());
	  _basew->show();
	}
}