Example #1
0
bool
StdWidgetFactory::readSpecialProperty(const QCString &classname, QDomElement &node, QWidget *w, KFormDesigner::ObjectTreeItem *)
{
	QString tag = node.tagName();
	QString name = node.attribute("name");

	if((tag == "item") && (classname == "KComboBox"))
	{
		KComboBox *combo = (KComboBox*)w;
		QVariant val = KFormDesigner::FormIO::readPropertyValue(node.firstChild().firstChild(), w, name);
		if(val.canCast(QVariant::Pixmap))
			combo->insertItem(val.toPixmap());
		else
			combo->insertItem(val.toString());
		return true;
	}

	if((tag == "item") && (classname == "KListBox"))
	{
		KListBox *listbox = (KListBox*)w;
		QVariant val = KFormDesigner::FormIO::readPropertyValue(node.firstChild().firstChild(), w, name);
		if(val.canCast(QVariant::Pixmap))
			listbox->insertItem(val.toPixmap());
		else
			listbox->insertItem(val.toString());
		return true;
	}

	if((tag == "column") && (classname == "KListView"))
	{
		KListView *listview = (KListView*)w;
		int id=0;
		for(QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling())
		{
			QString prop = n.toElement().attribute("name");
			QVariant val = KFormDesigner::FormIO::readPropertyValue(n.firstChild(), w, name);
			if(prop == "text")
				id = listview->addColumn(val.toString());
			else if(prop == "width")
				listview->setColumnWidth(id, val.toInt());
			else if(prop == "resizable")
				listview->header()->setResizeEnabled(val.toBool(), id);
			else if(prop == "clickable")
				listview->header()->setClickEnabled(val.toBool(), id);
			else if(prop == "fullwidth")
				listview->header()->setStretchEnabled(val.toBool(), id);
		}
		return true;
	}
	else if((tag == "item") && (classname == "KListView"))
	{
		KListView *listview = (KListView*)w;
		readListItem(node, 0, listview);
		return true;
	}

	return false;
}
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 PComboBox::setValue(const QVariant &value, bool emitChange)
{
#if QT_VERSION >= 0x030100
    if (!value.isNull())
#else
    if (value.canCast(QVariant::String))
#endif
    {
        disconnect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
        m_edit->setCurrentText(findDescription(value));
        connect(m_edit, SIGNAL(activated(int)), this, SLOT(updateProperty(int)));
        if (emitChange)
            emit propertyChanged(m_property, value);
    }
Example #6
0
bool Matrix::calculate(int startRow, int endRow, int startCol, int endCol)
{
  QApplication::setOverrideCursor(waitCursor);

  Script *script = scriptEnv->newScript(formula_str, this, QString("<%1>").arg(name()));
  connect(script, SIGNAL(error(const QString&,const QString&,int)), scriptEnv, SIGNAL(error(const QString&,const QString&,int))); 
  connect(script, SIGNAL(print(const QString&)), parent()->parent()->parent(), SLOT(scriptPrint(const QString&)));
  if (!script->compile())
  {
    QApplication::restoreOverrideCursor();
    return false;
  }

  int rows=d_table->numRows();
  int cols=d_table->numCols();
  if (endCol >= cols)
    d_table->setNumCols(endCol+1);
  if (endRow >= rows)
    d_table->setNumRows(endRow+1);

  QVariant ret;
  saveCellsToMemory();
  for (int row=startRow; row<=endRow; row++)
    for (int col=startCol; col<=endCol; col++)
    {
      script->setInt(row+1, "i");
      script->setInt(row+1, "row");
      script->setInt(col+1, "j");
      script->setInt(col+1, "col");
      ret = script->eval();
      if (ret.type()==QVariant::Int || ret.type()==QVariant::UInt || ret.type()==QVariant::LongLong || ret.type()==QVariant::ULongLong)
	d_table->setText(row, col, ret.toString());
      else if(ret.canCast(QVariant::Double))
	d_table->setText(row,col,QString::number(ret.toDouble(),txt_format, num_precision));
      else {
	d_table->setText(row,col,"");
	QApplication::restoreOverrideCursor();
	return false;
      }
    }
  forgetSavedCells();
  
  emit modifiedWindow(this);
  QApplication::restoreOverrideCursor();
  return true;
}
Example #7
0
void
KexiBlobTableEdit::setupContents( QPainter *p, bool focused, const QVariant& val, 
	QString &txt, int &align, int &x, int &y_offset, int &w, int &h )
{
	Q_UNUSED(focused);
	Q_UNUSED(txt);
	Q_UNUSED(align);

//! @todo optimize: load to m_pixmap, downsize
	QPixmap pixmap;
	x = 0;
	w -= 1; //a place for border
	h -= 1; //a place for border
	if (p && val.canCast(QVariant::ByteArray) && pixmap.loadFromData(val.toByteArray())) {
		KexiUtils::drawPixmap( *p, 0/*lineWidth*/, QRect(x, y_offset, w, h), 
			pixmap, Qt::AlignCenter, true/*scaledContents*/, true/*keepAspectRatio*/);
	}
}
Example #8
0
void Matrix::cellEdited(int row,int col)
{
Script *script = scriptEnv->newScript(d_table->text(row,col),this,QString("<%1_%2_%3>").arg(name()).arg(row).arg(col));
connect(script, SIGNAL(error(const QString&,const QString&,int)), scriptEnv, SIGNAL(error(const QString&,const QString&,int)));

script->setInt(row+1, "row");
script->setInt(row+1, "i");
script->setInt(col+1, "col");
script->setInt(col+1, "j");
QVariant ret = script->eval();
if(ret.type()==QVariant::Int || ret.type()==QVariant::UInt || ret.type()==QVariant::LongLong || ret.type()==QVariant::ULongLong)
	d_table->setText(row, col, ret.toString());
else if(ret.canCast(QVariant::Double))
	d_table->setText(row, col, QString::number(ret.toDouble(), txt_format, num_precision));
else
	d_table->setText(row, col, "");

emit modifiedWindow(this);
}