示例#1
0
QString EmailSelectDialog::selected()
{
  QButton *button = mButtonGroup->selected();
  if ( button ) return button->text();
  return QString::null;
}
void ElogEntryI::saveSettings() {
  KstELOGAttribStruct	attrib;
  KConfig cfg("kstrc", false, false);
  QButton* button;
  QString str;
  unsigned int i;
  int j;

  _strAttributes.truncate( 0 );
  for( i=0; i<_attribs.count(); i++ ) {
    attrib = _attribs[i];

    switch( attrib.type ) {
      case AttribTypeText:
      str.sprintf( "%s=%s\n", attrib.attribName.latin1(), ((QLineEdit*)(attrib.pWidget))->text().latin1() );
      _strAttributes += str;
      break;

      case AttribTypeBool:
      if( ((QCheckBox*)(attrib.pWidget))->isChecked() ) {
        str.sprintf( "%s=1\n", attrib.attribName.latin1() );
        _strAttributes += str;
      }
      break;

      case AttribTypeCombo:
        str.sprintf( "%s=%s\n", attrib.attribName.latin1(), ((QComboBox*)(attrib.pWidget))->currentText().latin1() );
        _strAttributes += str;
      break;

      case AttribTypeRadio:
      button = ((QHButtonGroup*)(attrib.pWidget))->selected( );
      if( button != NULL ) {
        str.sprintf( "%s=%s\n", attrib.attribName.latin1(), button->text( ).latin1() );
        _strAttributes += str;
      }
      break;

      case AttribTypeCheck:
      for( j=0; j<((QHButtonGroup*)(attrib.pWidget))->count(); j++ ) {
        button = ((QHButtonGroup*)(attrib.pWidget))->find( j );
        if( button != NULL ) {
          if( ((QRadioButton*)button)->isChecked() ) {
            str.sprintf( "%s#%d=%s\n", attrib.attribName.latin1(), j, button->text( ).latin1() );
            _strAttributes += str;
          }
        }
      }
      break;
    }
  }

  _strText = textEditText->text();
  _bIncludeCapture = checkBoxIncludeCapture->isChecked();
  _bIncludeConfiguration = checkBoxIncludeConfiguration->isChecked();
  _bIncludeDebugInfo = checkBoxIncludeDebugInfo->isChecked();

  cfg.setGroup("ELOG");
  str.sprintf( "Attributes:%s:%d:%s", 
               _elog->configuration()->ipAddress().ascii(),
               _elog->configuration()->portNumber(),
               _elog->configuration()->name().ascii() );  
  cfg.writeEntry(str, _strAttributes);
  cfg.writeEntry("IncludeCapture", _bIncludeCapture);
  cfg.writeEntry("IncludeConfiguration", _bIncludeConfiguration);
  cfg.writeEntry("IncludeDebugInfo", _bIncludeDebugInfo);
  cfg.sync();
}