Example #1
0
void PColorButton::setValue(const QVariant& value, bool emitChange)
{
#ifndef PURE_QT
    disconnect(m_edit, SIGNAL(changed(const QColor&)), this, SLOT(updateProperty(const QColor&)));
    m_edit->setColor(value.toColor());
    connect(m_edit, SIGNAL(changed(const QColor&)), this, SLOT(updateProperty(const QColor&)));
#else
    m_color = value.toColor();
    m_edit->setText(m_color.name());
    QPixmap px;
    px.resize(14,14);
    px.fill(m_color);
    m_edit->setIconSet(px);
#endif
    if (emitChange)
        emit propertyChanged(m_property, value);

}
Example #2
0
void KstBindLegend::setTextColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    return createPropertyTypeError(exec);
  }
  KstViewLegendPtr d = makeLegend(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setForegroundColor(cv.toColor());
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
Example #3
0
void KstBindCurve::setColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstVCurvePtr d = makeCurve(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setColor(cv.toColor());
  }
}
void KstBindEllipse::setBorderColor(KJS::ExecState *exec, const KJS::Value& value) {
  QVariant cv = KJSEmbed::convertToVariant(exec, value);
  if (!cv.canCast(QVariant::Color)) {
    KJS::Object eobj = KJS::Error::create(exec, KJS::TypeError);
    exec->setException(eobj);
    return;
  }
  KstViewEllipsePtr d = makeEllipse(_d);
  if (d) {
    KstWriteLocker rl(d);
    d->setBorderColor(cv.toColor());
    KstApp::inst()->paintAll(KstPainter::P_PAINT);
  }
}
Example #5
0
void PColorButton::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
{
/*    p->setBrush(value.toColor());
    p->setPen(Qt::NoPen);
    p->drawRect(r);*/
    p->setPen(Qt::NoPen);
    p->setBrush(cg.background());
    p->drawRect(r);

    p->setBrush(value.toColor());
    p->setPen(Qt::SolidLine);
    QRect r2(r);
    r2.setTopLeft(r.topLeft() + QPoint(5,5));
    r2.setBottomRight(r.bottomRight() - QPoint(5,5));
    p->drawRect(r2);
}
Example #6
0
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e)
{
  bool ok = true;

  clearAttributes(e);

  switch (v.type())
  {
  case QVariant::String:
    e.setTagName("string");
    e.setAttribute("value", v.toString().utf8());
    break;
  case QVariant::CString:
    e.setTagName("string");
    e.setAttribute("value", v.toCString());
    break;
  case QVariant::Int:
    e.setTagName("int");
    e.setAttribute("value", v.toInt());
    break;
  case QVariant::UInt:
    e.setTagName("uint");
    e.setAttribute("value", v.toUInt());
    break;
  case QVariant::Double:
    e.setTagName("double");
    e.setAttribute("value", v.toDouble());
    break;
  case QVariant::Bool:
    e.setTagName("bool");
    e.setAttribute("value", boolString(v.toBool()));
    break;
  case QVariant::Color:
    {
      e.setTagName("color");
      QColor color = v.toColor();
      e.setAttribute("red", color.red());
      e.setAttribute("green", color.green());
      e.setAttribute("blue", color.blue());
    }
    break;
  case QVariant::Pen:
    {
      e.setTagName("pen");
      QPen pen = v.toPen();
      e.setAttribute("red", pen.color().red());
      e.setAttribute("green", pen.color().green());
      e.setAttribute("blue", pen.color().blue());
      e.setAttribute("style", pen.style());
      e.setAttribute("cap", pen.capStyle());
      e.setAttribute("join", pen.joinStyle());
    }
    break;
  case QVariant::Brush:
    {
      e.setTagName("brush");
      QBrush brush = v.toBrush();
      e.setAttribute("red", brush.color().red());
      e.setAttribute("green", brush.color().green());
      e.setAttribute("blue", brush.color().blue());
      e.setAttribute("style", brush.style());
    }
    break;
  case QVariant::Point:
    {
      e.setTagName("point");
      QPoint point = v.toPoint();
      e.setAttribute("x", point.x());
      e.setAttribute("y", point.y());
    }
    break;
  case QVariant::Rect:
    {
      e.setTagName("rect");
      QRect rect = v.toRect();
      e.setAttribute("x", rect.x());
      e.setAttribute("y", rect.y());
      e.setAttribute("width", rect.width());
      e.setAttribute("height", rect.height());
    }
    break;
  case QVariant::Size:
    {
      e.setTagName("size");
      QSize qsize = v.toSize();
      e.setAttribute("width", qsize.width());
      e.setAttribute("height", qsize.height());
    }
    break;
  case QVariant::Font:
    {
      e.setTagName("font");
      QFont f(v.toFont());
      e.setAttribute("family", f.family());
      e.setAttribute("pointsize", f.pointSize());
      e.setAttribute("bold", boolString(f.bold()));
      e.setAttribute("italic", boolString(f.italic()));
      e.setAttribute("underline", boolString(f.underline()));
      e.setAttribute("strikeout", boolString(f.strikeOut()));
    }
    break;
  case QVariant::SizePolicy:
    {
      e.setTagName("sizepolicy");
      QSizePolicy sp(v.toSizePolicy());
      e.setAttribute("hsizetype", sp.horData());
      e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
      e.setAttribute("horstretch", sp.horStretch());
      e.setAttribute("verstretch", sp.verStretch());
#endif
    }
    break;
  case QVariant::Cursor:
    e.setTagName("cursor");
    e.setAttribute("shape", v.toCursor().shape());
    break;

  case QVariant::StringList:
    {
      e.setTagName("stringlist");
      uint j;
      
      QDomNode n;
      QDomNodeList stringNodeList = e.elementsByTagName("string");
      QDomElement stringElem;
      QStringList stringList = v.toStringList();
      QStringList::Iterator it = stringList.begin();

      for (j = 0; 
	   ((j < stringNodeList.length()) && (it != stringList.end()));
	   j++)
      {
	// get the current string element
	stringElem = stringNodeList.item(j).toElement();

	// set it to the current string
	variantToElement(QVariant(*it), stringElem);

	// iterate to the next string
	++it;
      }
      
      // more nodes in previous stringlist then current, remove excess nodes
      if (stringNodeList.count() > stringList.count())
      {
	while (j < stringNodeList.count())
	  e.removeChild(stringNodeList.item(j).toElement());
      }
      else if (j <stringList.count())
      {
	while (it != stringList.end())
	{
	  // create a new element
	  stringElem = m_doc.createElement("string");
	
	  // set it to the currentstring
	  variantToElement(QVariant(*it), stringElem);

	  // append it to the current element
	  e.appendChild(stringElem);

	  // iterate to the next string
	  ++it;
	}
      }
    }
    break;

#if QT_VERSION >= 300
  case QVariant::KeySequence:
    e.setTagName("key");
    e.setAttribute("sequence", (QString)v.toKeySequence());
    break;
#endif

  case QVariant::ByteArray: // this is only for [u]int64_t
    {
      e.setTagName("uint64");
      QByteArray ba = v.toByteArray();

      // make sure this only handles [u]int64_t's
      if (ba.size() != sizeof(uint64_t))
      {
	qWarning("Don't know how to persist variant of type: %s (%d) (size=%d)!",
		 v.typeName(), v.type(), ba.size());
	ok = false;
	break;
      }

      // convert the data back into a uint64_t
      uint64_t num = *(uint64_t*)ba.data();
      
      QChar buff[33];
      QChar* p = &buff[32];
      const char* digitSet = "0123456789abcdef";
      int len = 0;

      // construct the string
      do 
      {
        *--p = digitSet[((int)(num%16))];
        num = num >> 4; // divide by 16
        len++;
      } while ( num );

      // store it in a QString
      QString storage;
      storage.setUnicode(p, len);
      
      // set the value
      e.setAttribute("value", storage);
    }
    break;

#if 0
  case QVariant::List:
  case QVaraint::Map:
#endif
  default:
    qWarning("Don't know how to persist variant of type: %s (%d)!",
	     v.typeName(), v.type());
    ok = false;
    break;
  }

  return ok;
}
Example #7
0
bool Slider::onPropertyChanged(const QString& name, const QVariant& val)
{
    
    if ( VtlWidget::onPropertyChanged(name, val) )
      return TRUE;

    VtlActionHandler* actHandler = ((VtlWindow*)this->parentWidget())->actionHandler();  

    if (name == (QString) "PROCNAME") {
      processName = val.toString();
    }  
    else if (name == (QString) "ORIENTATION") {
           actHandler->setProperty(this, name, QVariant(orientation), val);
           setOrientation(val.toInt());
    }
    else if (name == (QString) "MINVALUE") {
           actHandler->setProperty(this, name, QVariant(minValue), val);
           setMinValue(val.toDouble());
    }
    else if (name == (QString) "MAXVALUE") {
           actHandler->setProperty(this, name, QVariant(maxValue), val);
           setMaxValue(val.toDouble());
    }
    else if (name == (QString) "DIRECTION") {
           actHandler->setProperty(this, name, QVariant(direction), val);
           setDirection(val.toInt());
    }
    else if (name == (QString )"SOURCER") {
      if ( val.toString() != "None" ) {
        _sourcer = SourcerConnector<VtlWidget>::change (this, _sourcer, val.toString() );
      }
      else 
        _sourcer = 0;
    }
    else if (name == (QString) "TRACKING") {
           actHandler->setProperty(this, name, QVariant(tracking), val);
           setTracking(val.toInt());
    }
    else if (name == (QString) "TICKMARKS") {
           actHandler->setProperty(this, name, QVariant(tickmarks), val);
           setTickmarks(val.toInt());
    }
    else if (name == (QString) "TICKINTERVAL") {
           actHandler->setProperty(this, name, QVariant(tickInterval), val);
           setTickInterval(val.toInt());
    }
    else if (name == (QString) "LINESTEP") {
           actHandler->setProperty(this, name, QVariant(lineStep), val);
           setLineStep(val.toDouble());
    }
    else if (name == (QString) "PAGESTEP") {
           actHandler->setProperty(this, name, QVariant(pageStep), val);
           setPageStep(val.toInt());
    }
    else if (name == (QString) "MAIN_COLOR") {
           actHandler->setProperty(this, name, QVariant(mainColor), val);
           setMainColor(val.toColor());
    }
    else if (name == (QString) "TICKMARKS_COLOR") {
           actHandler->setProperty(this, name, QVariant(tickmarksColor), val);
           setTickmarksColor(val.toColor());
    }
    else if (name == (QString) "PRECISION") {
           actHandler->setProperty(this, name, QVariant(precision), val);
           setPrecision(val.toInt());
    }

    repaint();
    return TRUE;
}
Example #8
0
void KConfigBase::writeEntry(const char *pKey, const QVariant &prop, bool bPersistent, bool bGlobal, bool bNLS)
{
    switch(prop.type())
    {
        case QVariant::Invalid:
            writeEntry(pKey, "", bPersistent, bGlobal, bNLS);
            return;
        case QVariant::String:
            writeEntry(pKey, prop.toString(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::StringList:
            writeEntry(pKey, prop.toStringList(), ',', bPersistent, bGlobal, bNLS);
            return;
        case QVariant::List:
        {
            QValueList< QVariant > list = prop.toList();
            QValueList< QVariant >::ConstIterator it = list.begin();
            QValueList< QVariant >::ConstIterator end = list.end();
            QStringList strList;

            for(; it != end; ++it)
                strList.append((*it).toString());

            writeEntry(pKey, strList, ',', bPersistent, bGlobal, bNLS);

            return;
        }
        case QVariant::Font:
            writeEntry(pKey, prop.toFont(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Point:
            writeEntry(pKey, prop.toPoint(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Rect:
            writeEntry(pKey, prop.toRect(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Size:
            writeEntry(pKey, prop.toSize(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Color:
            writeEntry(pKey, prop.toColor(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Int:
            writeEntry(pKey, prop.toInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::UInt:
            writeEntry(pKey, prop.toUInt(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::LongLong:
            writeEntry(pKey, prop.toLongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::ULongLong:
            writeEntry(pKey, prop.toULongLong(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Bool:
            writeEntry(pKey, prop.toBool(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Double:
            writeEntry(pKey, prop.toDouble(), bPersistent, bGlobal, 'g', 6, bNLS);
            return;
        case QVariant::DateTime:
            writeEntry(pKey, prop.toDateTime(), bPersistent, bGlobal, bNLS);
            return;
        case QVariant::Date:
            writeEntry(pKey, QDateTime(prop.toDate()), bPersistent, bGlobal, bNLS);
            return;

        case QVariant::Pixmap:
        case QVariant::Image:
        case QVariant::Brush:
        case QVariant::Palette:
        case QVariant::ColorGroup:
        case QVariant::Map:
        case QVariant::IconSet:
        case QVariant::CString:
        case QVariant::PointArray:
        case QVariant::Region:
        case QVariant::Bitmap:
        case QVariant::Cursor:
        case QVariant::SizePolicy:
        case QVariant::Time:
        case QVariant::ByteArray:
        case QVariant::BitArray:
        case QVariant::KeySequence:
        case QVariant::Pen:
            break;
    }

    Q_ASSERT(0);
}
Example #9
0
  void process(const QObject * obj){
	if(obj != NULL){
	  QListViewItem * buf = __current;
	  __current = new QListViewItem(__current,obj->className(),QString(obj->name()));
	  __current->setPixmap(0,__pixgeom);
	  QMetaObject* _m = obj->metaObject();
	  QListViewItem * att = NULL;
	  if(_m != NULL){
		QString _superclass(_m->superClassName());
		if(!_superclass.isEmpty()){
		  att = new QListViewItem(__current,"Inherit",_superclass);
		  att->setPixmap(0,__pixattptr);
		  QMetaObject* _meta = _m->superClass();
		  QListViewItem * att4 = NULL;
		  while((_meta = _meta->superClass())!= NULL){
			att4 = new QListViewItem(att,att4,QString(_meta->className()));
			att4->setPixmap(0,__pixatt);
		  }
		}
		att = new QListViewItem(__current,att,"Priority",(obj->highPriority()?"High":"Normal"));
		att->setPixmap(0,__pixatt);
		att = new QListViewItem(__current,att,"Widget",(obj->isWidgetType()?"True":"False"));
		att->setPixmap(0,__pixatt);
		QStrList _slots = _m->slotNames(true);
		if(!_slots.isEmpty()){
		  att = new QListViewItem(__current,att,"Slots");
		  att->setPixmap(0,__pixtransf);
		  uint sl_size = _slots.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < sl_size; j++ ){
			att2 = new QListViewItem(att,att2,_slots.at(j));
			att2->setPixmap(0,__pixatt);
		  }
		}
		QStrList _signals = _m->signalNames(true);
		if(!_signals.isEmpty()){
		  att = new QListViewItem(__current,att,"Signals");
		  att->setPixmap(0,__pixtransf);
		  uint si_size = _signals.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < si_size; j++ ){
			att2 = new QListViewItem(att,att2,_signals.at(j));
			att2->setPixmap(0,__pixatt);
		  }
		}
		int numCInfo = _m->numClassInfo(true);
		if(numCInfo !=0){
		  att = new QListViewItem(__current,att,"ClassInfo","List<Info>["+QString::number(numCInfo)+']');
		  att->setPixmap(0,__pixtransf);
		  QListViewItem * att2 = NULL;
		  for(int j = 0; j < numCInfo; j++ ){
			const QClassInfo * _inf = _m->classInfo(j);
			if(_inf != NULL){
			  att2 = new QListViewItem(att,att2,QString(_inf->name),QString(_inf->value));
			  att2->setPixmap(0,__pixatt);
			}
		  }
		}
		QStrList _props = _m->propertyNames(true);
		if(!_props.isEmpty()){
		  att = new QListViewItem(__current,att,"Properties");
		  att->setPixmap(0,__pixtransf);
		  uint p_size = _props.count();
		  QListViewItem * att2 = NULL;
		  for(uint j = 0; j < p_size; j++ ){
			att2 = new QListViewItem(att,att2,_props.at(j));
			att2->setPixmap(0,__pixatt);
			
			QVariant val;
			QString propname(_props.at(j));
#if QT_VERSION >= 300
			const QMetaProperty*  prop = _m->property (j,true);
#else
			const QMetaProperty*  prop = _m->property (propname,true);
#endif
			QString proptype;
			if(prop){
			  proptype = prop->type();
			  att2->setText(2,proptype);
			  /*
			  QListViewItem * att3 = new QListViewItem(att2,"Writable",(prop->writable()?"True":"False"));
			  att3->setPixmap(0,__pixatt);
			  att3 = new QListViewItem(att2,att3,"Designable",(prop->designable()?"True":"False"));
			  att3->setPixmap(0,__pixatt);
			  */
			}
			
			val = obj->property(propname);
			
			if(!val.isValid())att2->setText(1,"Invalid");
			else if(prop->isEnumType()){
			  att2->setText(1,prop->valueToKey(val.toInt()));
			}
			else if(prop->isSetType()){
			  QStrList st = prop->valueToKeys(val.toInt());
			  QString t = st.at(0);
			  for(uint i= 1; i < st.count(); i++)t+='/'+st.at(i);
			  att2->setText(1,t);
			}
			else if(val.type() == QVariant::String)att2->setText(1,'"'+val.toString()+'"');
			else if(val.type() == QVariant::CString)att2->setText(1,'"'+val.toCString()+'"');
			else if(val.type() == QVariant::Bool){
			  if(val.toBool())att2->setText(1,"True");
			  else att2->setText(1,"False");
			}
			else if(val.type() == QVariant::Int)att2->setText(1,QString::number(val.toInt()));
			else if(val.type() == QVariant::UInt)att2->setText(1,QString::number(val.toUInt()));
			else if(val.type() == QVariant::Double)att2->setText(1,QString::number(val.toDouble()));
			else if(val.type() == QVariant::Rect){
			  const QRect r = val.toRect();
			  att2->setText(1,'[' + QString::number(r.left())  + ',' + QString::number(r.top())+
				',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+']');
			}
			else if(val.type() == QVariant::Region){
			  const QRegion reg = val.toRegion();
			  QRect r = reg.boundingRect();
			  att2->setText(1,'[' + QString::number(r.left())  + ',' + QString::number(r.top())+
				',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+"],");
			}
			else if(val.type() == QVariant::Size){
			  const QSize s = val.toSize();
			  att2->setText(1,'[' + QString::number(s.width())  + ',' + QString::number(s.height())+']');
			}
			else if(val.type() == QVariant::Point){
			  const QPoint p = val.toPoint();
			  att2->setText(1,'[' + QString::number(p.x())  + ',' + QString::number(p.y())+']');
			}
			else if(val.type() == QVariant::Color){
			  const QColor c = val.toColor();
			  att2->setText(1,'[' + QString::number(c.red())   + ',' +
				QString::number(c.green()) + ',' +
				QString::number(c.blue())  + ']');
			}
			else if(val.type() == QVariant::ColorGroup){
			  const QColorGroup cg = val.toColorGroup();
			  QColor c  = cg.base();
			  att2->setText(1,'[' + QString::number(c.red())   + ',' +
				QString::number(c.green()) + ',' +
				QString::number(c.blue())  + "], ...");
			}
			else if(val.type() == QVariant::Font){
			  const QFont f = val.toFont();
			  QString text = '\'' + f.family()   + "', " + QString::number(f.pointSize())
				+ ", " + QString::number(f.weight());
			  if(f.italic())text+=", italic";
			  att2->setText(1,text);
			}
			else if(val.type() == QVariant::SizePolicy){
			  QSizePolicy sp = val.toSizePolicy();
			  QString text;
			  if(sp.horData() == QSizePolicy::Fixed)text+="Fixed";
			  else if(sp.horData() == QSizePolicy::Minimum )text+="Minimum";
			  else if(sp.horData() == QSizePolicy::Maximum )text+="Maximum";
			  else if(sp.horData() == QSizePolicy::Preferred )text+="Preferred";
			  else if(sp.horData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
			  else if(sp.horData() == QSizePolicy::Expanding )text+="Expanding";
			  text +='/';
			  if(sp.verData() == QSizePolicy::Fixed)text+="Fixed";
			  else if(sp.verData() == QSizePolicy::Minimum )text+="Minimum";
			  else if(sp.verData() == QSizePolicy::Maximum )text+="Maximum";
			  else if(sp.verData() == QSizePolicy::Preferred )text+="Preferred";
			  else if(sp.verData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
			  else if(sp.verData() == QSizePolicy::Expanding )text+="Expanding";
			  
			  att2->setText(1,text);
			}
			else if(val.type() == QVariant::Pixmap){
			  QPixmap pix = val.toPixmap();
			  if(!pix.isNull())att2->setPixmap(1,pix);
			}
			else if(val.type() == QVariant::Cursor){
			  const QCursor cur = val.toCursor();
			  const QBitmap * pix = cur.bitmap();
			  if(pix && !pix->isNull())att2->setPixmap(1,*pix);
			  else att2->setText(1,QString::number(cur.shape()));
			}
		  }
		}
       }

	   const QObjectList * roots = obj->children();
	   if(roots != NULL){
		 __current = new QListViewItem(__current,att,"children","ptr="+QString::number((unsigned long)roots),
		   "List<QObject>["+QString::number(roots->count())+"]");
		 __current->setPixmap(0,__pixappe);
		 QObjectList r(*roots);
		 uint size = r.count();
		 for(uint i = 0; i < size; i++ ){
		   QObject * _obj = r.at(i);
		   process(_obj);
		 }
		 
	   }
	   __current = buf;
       }
    }
Example #10
0
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e)
{
  bool ok = true;

  clearAttributes(e);

  switch (v.type())
  {
  case QVariant::String:
    e.setTagName("string");
    e.setAttribute("value", v.toString().utf8());
    break;
  case QVariant::CString:
    e.setTagName("string");
    e.setAttribute("value", v.toCString());
    break;
  case QVariant::Int:
    e.setTagName("int");
    e.setAttribute("value", v.toInt());
    break;
  case QVariant::UInt:
    e.setTagName("uint");
    e.setAttribute("value", v.toUInt());
    break;
  case QVariant::Double:
    e.setTagName("double");
    e.setAttribute("value", v.toDouble());
    break;
  case QVariant::Bool:
    e.setTagName("bool");
    e.setAttribute("value", boolString(v.toBool()));
    break;
  case QVariant::Color:
    {
      e.setTagName("color");
      QColor color = v.toColor();
      e.setAttribute("red", color.red());
      e.setAttribute("green", color.green());
      e.setAttribute("blue", color.blue());
    }
    break;
  case QVariant::Point:
    {
      e.setTagName("point");
      QPoint point = v.toPoint();
      e.setAttribute("x", point.x());
      e.setAttribute("y", point.y());
    }
    break;
  case QVariant::Rect:
    {
      e.setTagName("rect");
      QRect rect = v.toRect();
      e.setAttribute("x", rect.x());
      e.setAttribute("y", rect.y());
      e.setAttribute("width", rect.width());
      e.setAttribute("height", rect.height());
    }
    break;
  case QVariant::Size:
    {
      e.setTagName("size");
      QSize qsize = v.toSize();
      e.setAttribute("width", qsize.width());
      e.setAttribute("height", qsize.height());
    }
    break;
  case QVariant::Font:
    {
      e.setTagName("font");
      QFont f(v.toFont());
      e.setAttribute("family", f.family());
      e.setAttribute("pointsize", f.pointSize());
      e.setAttribute("bold", boolString(f.bold()));
      e.setAttribute("italic", boolString(f.italic()));
      e.setAttribute("underline", boolString(f.underline()));
      e.setAttribute("strikeout", boolString(f.strikeOut()));
    }
    break;
  case QVariant::SizePolicy:
    {
      e.setTagName("sizepolicy");
      QSizePolicy sp(v.toSizePolicy());
      e.setAttribute("hsizetype", sp.horData());
      e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
      e.setAttribute("horstretch", sp.horStretch());
      e.setAttribute("verstretch", sp.verStretch());
#endif
    }
    break;
  case QVariant::Cursor:
    e.setTagName("cursor");
    e.setAttribute("shape", v.toCursor().shape());
    break;

  case QVariant::StringList:
    {
      e.setTagName("stringlist");
      uint j;
      
      QDomNode n;
      QDomNodeList stringNodeList = e.elementsByTagName("string");
      QDomElement stringElem;
      QStringList stringList = v.toStringList();
      QStringList::Iterator it = stringList.begin();

      for (j = 0; 
	   ((j < stringNodeList.length()) && (it != stringList.end()));
	   j++)
      {
	// get the current string element
	stringElem = stringNodeList.item(j).toElement();

	// set it to the current string
	variantToElement(QVariant(*it), stringElem);

	// iterate to the next string
	++it;
      }
      
      // more nodes in previous stringlist then current, remove excess nodes
      if (stringNodeList.count() > stringList.count())
      {
	while (j < stringNodeList.count())
	  e.removeChild(stringNodeList.item(j).toElement());
      }
      else if (j <stringList.count())
      {
	while (it != stringList.end())
	{
	  // create a new element
	  stringElem = m_doc.createElement("string");
	
	  // set it to the currentstring
	  variantToElement(QVariant(*it), stringElem);

	  // append it to the current element
	  e.appendChild(stringElem);

	  // iterate to the next string
	  ++it;
	}
      }
    }
    break;

#if QT_VERSION >= 300
  case QVariant::KeySequence:
    e.setTagName("key");
    e.setAttribute("sequence", (QString)v.toKeySequence());
    break;
#endif

#if 0
  case QVariant::List:
  case QVaraint::Map:
#endif
  default:
    qWarning("Don't know how to persist variant of type: %s (%d)!",
	     v.typeName(), v.type());
    ok = false;
    break;
  }

  return ok;
}