Example #1
0
void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
{
    Q_D(QCupsPrintEngine);

    switch (int(key)) {
    case PPK_PaperSize:
        d->printerPaperSize = QPrinter::PaperSize(value.toInt());
        d->setPaperSize();
        break;
    case PPK_CupsPageRect:
        d->cupsPageRect = value.toRect();
        break;
    case PPK_CupsPaperRect:
        d->cupsPaperRect = value.toRect();
        break;
    case PPK_CupsOptions:
        d->cupsOptions = value.toStringList();
        break;
    case PPK_CupsStringPageSize:
        d->cupsStringPageSize = value.toString();
        break;
    case PPK_PrinterName:
        // prevent setting the defaults again for the same printer
        if (d->printerName != value.toString()) {
            d->printerName = value.toString();
            d->setCupsDefaults();
        }
        break;
    default:
        QPdfPrintEngine::setProperty(key, value);
        break;
    }
}
void	LabelPrintEngine::setProperty ( PrintEnginePropertyKey key, const QVariant & value )
{
  switch(key) {
  case  QPrintEngine::PPK_PrinterName:
    m_printerName = value.toString();
    break;
  case  QPrintEngine::PPK_DocumentName:
    m_docName = value.toString();
    break;
  case  QPrintEngine::PPK_CustomPaperSize:
    m_paperSize = value.toSizeF();
    m_paperRect = QRect(QPoint(0,0),m_paperSize.toSize());
    break;
  case  QPrintEngine::PPK_PaperRect:
  case  QPrintEngine::PPK_PageRect:
    m_paperSize = value.toRect().size();
    m_paperRect = value.toRect();
    break;
  case  QPrintEngine::PPK_PageSize:
    // not implemented
    break;
  case  QPrintEngine::PPK_Resolution:
    m_resolution = value.toInt();
    break;
  default: break;
  }
}
Example #3
0
void DummyAnimation::updateCurrentValue(const QVariant &value)
{
    if (state() == Stopped)
        return;
    if (m_dummy)
        m_dummy->setRect(value.toRect());
}
void HappyPropertySheetExtension::setProperty(int index, const QVariant &value)
{
    if ( index == 0 )
    {
        m_widget->setObjectName( value.toString() );
    }
    else if ( index == 1 )
    {
        m_widget->setGeometry( value.toRect() );
    }
    else if ( index == 2 )
    {
        m_widget->setDiameterInPixels( value.toInt() );
    }
    else if ( index == 3 )
    {
        m_widget->setColour( value.toString() );
    }
    else if ( index == 4 )
    {
//        m_widget->setScalpHair( value.value<ImaginativeThinking::Hair>() );
    }
    else if ( index == 5 )
    {
//        m_widget->setScalpHair( value.value<ImaginativeThinking::Hair>() );
    }
}
Example #5
0
/*!
*  Initialisation du module
*
*/
void CRaspiGPIO::init(CApplication *application)
{
  CModule::init(application);
  setGUI(&m_ihm); // indique à la classe de base l'IHM

  // Gère les actions sur clic droit sur le panel graphique du module
  m_ihm.setContextMenuPolicy(Qt::CustomContextMenu);
  connect(&m_ihm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onRightClicGUI(QPoint)));
  
  // Restore la taille de la fenêtre
  QVariant val;
  val = m_application->m_eeprom->read(getName(), "geometry", QRect(50, 50, 150, 150));
  m_ihm.setGeometry(val.toRect());
  // Restore le fait que la fenêtre est visible ou non
  val = m_application->m_eeprom->read(getName(), "visible", QVariant(true));
  if (val.toBool()) { m_ihm.show(); }
  else              { m_ihm.hide(); }
  // Restore le niveau d'affichage
  val = m_application->m_eeprom->read(getName(), "niveau_trace", QVariant(MSG_TOUS));
  setNiveauTrace(val.toUInt());
  // Restore la couleur de fond
  val = m_application->m_eeprom->read(getName(), "background_color", QVariant(DEFAULT_MODULE_COLOR));
  setBackgroundColor(val.value<QColor>());

  wiringPiSetupGpio(); // Utilise la numérotation de pin BCM

  for (unsigned int i=0; i<MAX_GPIO_COUNT; i++) {
      // Recherche dans le fichier EEPROM une configuration de type "gpio_<i>=input pull down"
      // gpio_17 = input
      QString eeprom_config_name = "gpio_" + QString::number(i);
      val = m_application->m_eeprom->read(getName(), eeprom_config_name, QVariant());
      if (val != QVariant()) {  // le paramètre a été trouvé -> le GPIO est utilisé et doit être configuré
          configPinMode(i, val.toString());
      }

      // Initialise la liste des GPIO dans la liste déroulante de configuration
      // on part des contrôles affichés sur l'interface et on récupère les numéros
      // Rensigne dans la liste déroulante des GPIO tous les numéros possibles de GPIO
      QLabel *lbl = m_ihm.findChild<QLabel*>(PREFIX_MODE_GPIO + QString::number(i)); // "mode_GPIO_<i>" c'est le nom de tous les labels des GPIO sur l'IHM pour indiquer si c'est une entrée / sortie / ...
      if (lbl) {
          m_ihm.ui.configChoixGPIO->addItem("GPIO " + QString::number(i));
      }
      // connexion signal/slot avec toutes les checkbox qui permettent d'écrire sur le port
      // on repert toutes les checkbox par leur nom "write_GPIO_<i>"
      QCheckBox *checkbox = m_ihm.findChild<QCheckBox*>(PREFIX_CHECKBOX_WRITE + QString::number(i));
      if (checkbox) {
          connect(checkbox, SIGNAL(clicked(bool)), this, SLOT(onWritePinChange(bool)));
      }
  }

  // Renseigne dans la liste déroulante des configurations possibles
  QStringList list_modes;
  list_modes << "" << "Input" << "Input pull down" << "Input pull up" << "Output" << "PWM Output";
  m_ihm.ui.configChoixMode->addItems(list_modes);

  connect(m_ihm.ui.configChoixGPIO, SIGNAL(activated(int)), this, SLOT(onChoixConfigGPIO()));
  connect(m_ihm.ui.configChoixMode, SIGNAL(activated(QString)), this, SLOT(onChoixConfigMode(QString)));
  connect(&m_timer_read, SIGNAL(timeout()), this, SLOT(readAllInputs()));
  m_timer_read.start(100);
}
/*!
    \internal

    Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
    reimplementation QGraphicsProxyWidget::inputMethodQuery().
*/
QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
{
    Q_Q(const QGraphicsProxyWidget);
    if (!widget || !q->hasFocus())
        return QVariant();

    QWidget *focusWidget = widget->focusWidget();
    if (!focusWidget)
        focusWidget = widget;
    QVariant v = focusWidget->inputMethodQuery(query);
    QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
    switch (v.type()) {
    case QVariant::RectF:
        v = v.toRectF().translated(focusWidgetPos);
        break;
    case QVariant::PointF:
        v = v.toPointF() + focusWidgetPos;
        break;
    case QVariant::Rect:
        v = v.toRect().translated(focusWidgetPos.toPoint());
        break;
    case QVariant::Point:
        v = v.toPoint() + focusWidgetPos.toPoint();
        break;
    default:
        break;
    }
    return v;
}
Example #7
0
void QRectProperty::setValue(const QVariant &value)
{
    disconnectUpdateValue();
    QRect re = value.toRect();

    if(m_x->getVisible())
    {
        m_x->setValue(re.x());
        m_y->setValue(re.y());
    }
    else
    {
        m_x->setValue(0);
        m_y->setValue(0);
    }
    m_width->setValue(re.width());
    m_height->setValue(re.height());

    re.setRect(m_x->getValue().toInt(),m_y->getValue().toInt(),
               m_width->getValue().toInt(),m_height->getValue().toInt());

    connectUpdateValue();
    QAbstractProperty::setValue(re);

}
Example #8
0
File: app.cpp Project: speakman/qlc
/**
 * Main initialization function
 */
void App::init()
{
	QSettings settings;

	setWindowIcon(QIcon(":/qlc.png"));

#ifndef __APPLE__
	/* MDI Area */
	setCentralWidget(new QMdiArea(this));
	centralWidget()->setContextMenuPolicy(Qt::CustomContextMenu);
	connect(centralWidget(),
		SIGNAL(customContextMenuRequested(const QPoint&)),
		this,
		SLOT(slotCustomContextMenuRequested(const QPoint&)));

	/* Workspace background */
	setBackgroundImage(settings.value("/workspace/background").toString());

	/* Application geometry and window state */
	QVariant var;
	var = settings.value(KXMLQLCGeometry, QRect(0, 0, 800, 600));
	if (var.isValid() == true)
		setGeometry(var.toRect());
	var = settings.value(KXMLQLCWindowState, Qt::WindowNoState);
	if (var.isValid() == true)
		setWindowState(Qt::WindowState(var.toInt()));
#else
	/* App is just a toolbar, we only need it to be the size of the
	   toolbar's buttons */
	resize(600, 32);
	move(0, 22);
#endif

	/* Input & output mappers and their plugins */
	initOutputMap();
	initInputMap();

	/* Function running engine/master timer */
	m_masterTimer = new MasterTimer(this, m_outputMap);
	m_masterTimer->start();

	/* Buses */
	Bus::init(this);

	/* Fixture definitions */
	loadFixtureDefinitions();

	// The main view
	initStatusBar();
	initActions();
	initMenuBar();
	initToolBar();

	// Document
	initDoc();

	// Start up in non-modified state
	m_doc->resetModified();
}
Example #9
0
/**
  * Plot with plotter, using the painter.
  * To be called from QML
  */
void Calculator::plot(QVariant painter, const QVariant plotArea)
{
    QPainter * thePainter;
    uint uintPainter = painter.toUInt();
    thePainter = (QPainter *)uintPainter;
    QRect thePlotArea = plotArea.toRect();
    plotter.plot(thePainter, thePlotArea);
}
Example #10
0
QString RectDelegate::displayText( const QVariant& value ) const
{
    const QRect r(value.toRect());
    return QString::fromLatin1(RECTEDIT_MASK)
        .arg(r.x())
        .arg(r.y())
        .arg(r.width())
        .arg(r.height());
}
Example #11
0
void RectComposedProperty::setValue(Property *property,
    const QVariant &value, bool rememberOldValue)
{
    const QRect r( value.toRect() );
    property->child("x")->setValue(r.x(), rememberOldValue, false);
    property->child("y")->setValue(r.y(), rememberOldValue, false);
    property->child("width")->setValue(r.width(), rememberOldValue, false);
    property->child("height")->setValue(r.height(), rememberOldValue, false);
}
Example #12
0
QString write(const QVariant &variant)
{
    if (!variant.isValid()) {
        qWarning() << "Trying to serialize invalid QVariant";
        return QString();
    }
    QString value;
    switch (variant.type()) {
    case QMetaType::QPoint:
    {
        QPoint p = variant.toPoint();
        value = QString("%1,%2").arg(QString::number(p.x()), QString::number(p.y()));
        break;
    }
    case QMetaType::QPointF:
    {
        QPointF p = variant.toPointF();
        value = QString("%1,%2").arg(QString::number(p.x(), 'f'), QString::number(p.y(), 'f'));
        break;
    }
    case QMetaType::QSize:
    {
        QSize s = variant.toSize();
        value = QString("%1x%2").arg(QString::number(s.width()), QString::number(s.height()));
        break;
    }
    case QMetaType::QSizeF:
    {
        QSizeF s = variant.toSizeF();
        value = QString("%1x%2").arg(QString::number(s.width(), 'f'), QString::number(s.height(), 'f'));
        break;
    }
    case QMetaType::QRect:
    {
        QRect r = variant.toRect();
        value = QString("%1,%2,%3x%4").arg(QString::number(r.x()), QString::number(r.y()),
                                           QString::number(r.width()), QString::number(r.height()));
        break;
    }
    case QMetaType::QRectF:
    {
        QRectF r = variant.toRectF();
        value = QString("%1,%2,%3x%4").arg(QString::number(r.x(), 'f'), QString::number(r.y(), 'f'),
                                           QString::number(r.width(), 'f'), QString::number(r.height(), 'f'));
        break;
    }
    default:
        QVariant strVariant = variant;
        strVariant.convert(QVariant::String);
        if (!strVariant.isValid())
            qWarning() << Q_FUNC_INFO << "cannot serialize type " << QMetaType::typeName(variant.type());
        value = strVariant.toString();
    }

    return value;
}
void QSvgIOHandler::setOption(ImageOption option, const QVariant & value)
{
    switch(option) {
    case ClipRect:
        d->clipRect = value.toRect();
        break;
    case ScaledSize:
        d->scaledSize = value.toSize();
        break;
    case ScaledClipRect:
        d->scaledClipRect = value.toRect();
        break;
    case BackgroundColor:
        d->backColor = value.value<QColor>();
        break;
    default:
        break;
    }
}
Example #14
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QSettings settings;

    QVariant val = settings.value("Geometry",
                                  QRect(50, 50, 200, 200));
    setGeometry(val.toRect());
}
Example #15
0
QString VariantDelegate::displayText(const QVariant &value)
{
    switch (value.type()) {
    case QVariant::Bool:
    case QVariant::ByteArray:
    case QVariant::Char:
    case QVariant::Double:
    case QVariant::Int:
    case QVariant::LongLong:
    case QVariant::String:
    case QVariant::UInt:
    case QVariant::ULongLong:
        return value.toString();
    case QVariant::Color:
        {
            QColor color = qvariant_cast<QColor>(value);
            return QString("(%1,%2,%3,%4)")
                   .arg(color.red()).arg(color.green())
                   .arg(color.blue()).arg(color.alpha());
        }
    case QVariant::Date:
        return value.toDate().toString(Qt::ISODate);
    case QVariant::DateTime:
        return value.toDateTime().toString(Qt::ISODate);
    case QVariant::Invalid:
        return "<Invalid>";
    case QVariant::Point:
        {
            QPoint point = value.toPoint();
            return QString("(%1,%2)").arg(point.x()).arg(point.y());
        }
    case QVariant::Rect:
        {
            QRect rect = value.toRect();
            return QString("(%1,%2,%3,%4)")
                   .arg(rect.x()).arg(rect.y())
                   .arg(rect.width()).arg(rect.height());
        }
    case QVariant::Size:
        {
            QSize size = value.toSize();
            return QString("(%1,%2)").arg(size.width()).arg(size.height());
        }
    case QVariant::StringList:
        return value.toStringList().join(',');
    case QVariant::Time:
        return value.toTime().toString(Qt::ISODate);
    default:
        break;
    }
    return QString("<%1>").arg(value.typeName());
}
Example #16
0
void PredictiveKeyboard::queryResponse ( int property, const QVariant & result )
{
    if(property == Qt::ImMicroFocus) {
        QRect r = result.toRect();
        QPoint p = r.center();

        if(mActive) {
            QPoint bp = mActive->requestedRegion().boundingRect().topLeft();
            p += bp;
        }

        mKeyboard->setAcceptDest(p);
    }
};
Example #17
0
void Keyboard::queryResponse ( int property, const QVariant & result )
{
    if(property==Qt::ImMicroFocus){
        QRect resultRect = result.toRect();
        if(resultRect.isValid()){
            microX = resultRect.x();
            microY = resultRect.y();
            if(keyboardFrame->obscures(QPoint(microX, microY)))
                keyboardFrame->swapPosition();
        }
        //microFocusPending = false;
        //if (showPending) show();
    }

};
Example #18
0
bool QWSInputContext::translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e)
{
    Qt::InputMethodQuery type = static_cast<Qt::InputMethodQuery>(e->simpleData.property);
    QVariant result = w->inputMethodQuery(type);
    QWidget *tlw = w->window();
    int winId = tlw->winId();

    if ( type == Qt::ImMicroFocus ) {
        // translate to relative to tlw
        QRect mf = result.toRect();
        mf.moveTopLeft(w->mapTo(tlw,mf.topLeft()));
        result = mf;
    }

    QPaintDevice::qwsDisplay()->sendIMResponse(winId, e->simpleData.property, result);

    return false;
}
Example #19
0
void MainWindow::readSettings()
{
	mSettings->beginGroup(settingsGroup);
	const QVariant geom = mSettings->value(geometryKey);
	if(geom.isValid())
		setGeometry(geom.toRect());
	if (mSettings->value(maximizeKey, false).toBool())
		setWindowState(Qt::WindowMaximized);
	const QVariant theme = mSettings->value(themeKey);
	mSettings->endGroup();

	mOptions->readSettings(mSettings);

	if(theme.isValid())
		setTheme(theme.toString());
	else
		setTheme("clean");
}
Example #20
0
/*!
*  Initialisation du module
*
*/
void CXbeeNetworkMessenger::init(CApplication *application)
{
  CModule::init(application);
  setGUI(&m_ihm); // indique à la classe de base l'IHM

  // Gère les actions sur clic droit sur le panel graphique du module
  m_ihm.setContextMenuPolicy(Qt::CustomContextMenu);
  connect(&m_ihm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onRightClicGUI(QPoint)));

  // Restore la taille de la fenêtre
  QVariant val;
  val = m_application->m_eeprom->read(getName(), "geometry", QRect(50, 50, 150, 150));
  m_ihm.setGeometry(val.toRect());
  // Restore le fait que la fenêtre est visible ou non
  val = m_application->m_eeprom->read(getName(), "visible", QVariant(true));
  if (val.toBool()) { m_ihm.show(); }
  else              { m_ihm.hide(); }
  // Restore le niveau d'affichage
  val = m_application->m_eeprom->read(getName(), "niveau_trace", QVariant(MSG_TOUS));
  setNiveauTrace(val.toUInt());
  // Restore la couleur de fond
  val = m_application->m_eeprom->read(getName(), "background_color", QVariant(DEFAULT_MODULE_COLOR));
  setBackgroundColor(val.value<QColor>());

  val = m_application->m_eeprom->read(getName(), "trace_active", QVariant(false));
  m_trace_active = val.toBool();
  m_ihm.ui.trace_active->setChecked(m_trace_active);

  m_xbee_messenger.initApp(m_application);

  connect(m_application->m_XBEE, SIGNAL(readyBytes(QByteArray,unsigned short)), this, SLOT(Xbee_readyBytes(QByteArray,unsigned short)));
  connect(m_ihm.ui.clear_trace, SIGNAL(released()), this, SLOT(on_clear_trace()));

  connect(m_ihm.ui.message_list, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_message_name_changed(QString)));
  connect(m_ihm.ui.ID, SIGNAL(editingFinished()), this, SLOT(on_message_id_changed()));
  connect(m_ihm.ui.send, SIGNAL(released()), this, SLOT(on_send_message()));
  connect(m_ihm.ui.trace_active, SIGNAL(clicked(bool)), this, SLOT(on_trace_active_changed(bool)));

  initDiagPresencePage();
  initGeneratorPage();

  connect(&m_timer, SIGNAL(timeout()), this, SLOT(on_timer_tick()));
  m_timer.start(MESSENGER_REFRESH_PERIOD);
}
Example #21
0
void DbSettings::setValue(const QString &key, const QVariant &value)
{
	QMutexLocker lock(&value_lock);
	QSqlDatabase db = QSqlDatabase::database(settings_db);
	if (!db.isOpen())
		return;

	QSqlQuery q(db);
	q.prepare("SELECT value FROM settings WHERE key=?");
	q.addBindValue(key);
	if (q.exec()) {
		QString string_value;

		if (value.canConvert<QString>()) {
			string_value = QLatin1String("@String ") + value.toString();
		}
		else if (value.canConvert<QRect>()) {
			QTextStream out(&string_value, QIODevice::WriteOnly);
			const QRect r = value.toRect();

			out << rect_key << " "
			    << r.left() << ", "
			    << r.top() << ", "
			    << r.width() << ", "
			    << r.height();
		}
		else
			Q_ASSERT(false);

		value_map[key] = value;

		if (q.next())
			// update query
			q.prepare("UPDATE settings SET value=? WHERE key=?");
		else
			// insert query
			q.prepare("INSERT INTO settings (value, key) VALUES (?,?)");

		q.addBindValue(string_value);
		q.addBindValue(key);
		q.exec();
	}
}
void PoItemDelegate::paint (QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    if (index.column() != ProjectModel::Graph)
        return QStyledItemDelegate::paint(painter,option,index);

    QVariant graphData = index.data(Qt::DisplayRole);
    if (KDE_ISUNLIKELY( !graphData.isValid()))
    {
        painter->fillRect(option.rect,Qt::transparent);
        return;
    }

    QRect rect = graphData.toRect();
    int translated = rect.left();
    int untranslated = rect.top();
    int fuzzy = rect.width();
    int total = translated + untranslated + fuzzy;

    if (total > 0)
    {
        painter->setPen(Qt::white);
        QRect myRect(option.rect);
        myRect.setWidth(option.rect.width() * translated / total);
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::PositiveText));
        //painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.left()));

        myRect.setLeft(myRect.left() + myRect.width());
        myRect.setWidth(option.rect.width() * fuzzy / total);
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::NeutralText));
        // painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.width()));

        myRect.setLeft(myRect.left() + myRect.width());
        myRect.setWidth(option.rect.width() - myRect.left() + option.rect.left());
        painter->fillRect(myRect, m_colorScheme.foreground(KColorScheme::NegativeText));
        // painter->drawText(myRect,Qt::AlignRight,QString("%1").arg(data.top()));
    }
    else if (total == -1)
        painter->fillRect(option.rect,Qt::transparent);
    else if (total == 0)
        painter->fillRect(option.rect,QBrush(Qt::gray));
}
Example #23
0
void KNMusicHeaderPlayer::onActionMouseInOut(const QVariant &value)
{
    //Translate the value to rect.
    QRect currentPos=value.toRect();
    //Calculate the opacity.
    qreal opacity=qAbs(currentPos.height()==0?
                           1:(qreal)currentPos.y()/(qreal)currentPos.height());
    //Make sure the opacity is in the range.
    if(opacity>1.0)
    {
        opacity=1.0;
    }
    else if(opacity<0.0)
    {
        opacity=0.0;
    }
    //Apply the opacity to album art, title and artist-album labels.
    m_informationEffect->setOpacity(opacity);
    m_title->setOpacity(opacity);
    m_artistAlbum->setOpacity(opacity);
    //Update the duration label.
    updateDurationPalette((1.0-opacity)*255.0);
}
Example #24
0
void
RectCustomProperty::setValue(const QVariant &value, bool rememberOldValue)
{
	if(!m_property)
		return;

	if(m_property->parent()) {
		QRect r = m_property->parent()->value().toRect();

		if(m_property->type() == Rect_X) {
			//changing x component of Rect shouldn't change width
			const int delta = value.toInt() - r.x();
			r.setX(value.toInt());
			r.setWidth(r.width()+delta);
		}
		else if(m_property->type() == Rect_Y) {
			//changing y component of Rect shouldn't change height
			const int delta = value.toInt() - r.y();
			r.setY(value.toInt());
			r.setHeight(r.height()+delta);
		}
		else if(m_property->type() == Rect_Width)
			r.setWidth(value.toInt());
		else if(m_property->type() == Rect_Height)
			r.setHeight(value.toInt());

		m_property->parent()->setValue(r, true, false);
	}
	else {
		QRect r = value.toRect();
		m_property->child("x")->setValue(r.x(), rememberOldValue, false);
		m_property->child("y")->setValue(r.y(), rememberOldValue, false);
		m_property->child("width")->setValue(r.width(), rememberOldValue, false);
		m_property->child("height")->setValue(r.height(), rememberOldValue, false);
	}
}
bool QHangulPlatformInputContext::popupCandidateList() {
    const ucschar *text = hangul_ic_get_preedit_string(m_hic);
    if (text != NULL && *text != 0) {
	QString str;
	str += QChar(text[0]);
	HanjaList *list = hanja_table_match_suffix(hanjaTable, str.toUtf8());

	if (m_candidateList == NULL)
	    m_candidateList = new CandidateList();

	QPoint p(0, 0);

	QWidget *focus = qobject_cast<QWidget *>(m_focusObject);
	if (focus != NULL) {
	    QVariant v = focus->inputMethodQuery(Qt::ImMicroFocus);
	    QRect r = v.toRect();
	    p = focus->mapToGlobal(QPoint(r.right(), r.bottom()));
	}

	m_candidateList->open(list, p.x(), p.y());
    }

    return false;
}
Example #26
0
QString PropertyField::valueToString(QVariant val)
{
    QString text;
    switch (val.type()) {
    case QVariant::Double:
        text = QString("%1").arg(val.toReal(), 0, 'f', 4);
        break;
    case QVariant::Size:
        text = QString("%1 x %2").arg(val.toSize().width()).arg(val.toSize().height());
        break;
    case QVariant::SizeF:
        text = QString("%1 x %2").arg(val.toSizeF().width()).arg(val.toSizeF().height());
        break;
    case QVariant::Rect: {
        QRect rect = val.toRect();
        text = QString("%1 x %2 %3%4 %5%6").arg(rect.width())
                .arg(rect.height()).arg(rect.x() < 0 ? "" : "+").arg(rect.x())
                .arg(rect.y() < 0 ? "" : "+").arg(rect.y());
        } break;
    default:
        text = val.toString();
    }
    return text;
}
Example #27
0
bool GCF::Message::encodeVariant(QDataStream& ds, const QVariant& value)
{
    QString typeName;

    if( value.isValid() )
    {
        typeName = QString(value.typeName());
        if( typeName.isEmpty() )
            return false;
    }
    else
        typeName = "Invalid";

    if( value.type() >= QVariant::UserType )
        return false;

    // Prepare the typename in-case of bool, char, int, double
    switch(value.type())
    {
    case QVariant::Int:
        typeName = is32Bit() ? "qint32" : "qint64";
        break;
    case QVariant::Char:
        typeName = "quint8";
        break;
    case QVariant::UInt:
        typeName = is32Bit() ? "quint32" : "quint64";
        break;
    default:
        break;
    }

    // Serialize value on to the byte array
    switch( value.type() )
    {
    case QVariant::Invalid:
        ds << typeName;
        ds << qint32(0);
        break;
    case QVariant::Bool:
        ds << typeName;
        ds << value.toBool();
        break;
    case QVariant::Char:
        ds << typeName;
        ds << value.toChar();
        break;
    case QVariant::Color:
        ds << typeName;
        ds << value.value<QColor>();
        break;
    case QVariant::Date:
        ds << typeName;
        ds << value.toDate();
        break;
    case QVariant::DateTime:
        ds << typeName;
        ds << value.toDateTime();
        break;
    case QVariant::Double:
        ds << typeName;
        ds << value.toDouble();
        break;
    case QVariant::Int:
        ds << typeName;
        if( is32Bit() )
            ds << (qint32)value.toInt();
        else
            ds << (qint64)value.toInt();
        break;
    case QVariant::Time:
        ds << typeName;
        ds << value.toTime();
        break;
    case QVariant::UInt:
        ds << typeName;
        if( is32Bit() )
            ds << (quint32)value.toUInt();
        else
            ds << (quint64)value.toUInt();
        break;
    case QVariant::String:
        ds << typeName;
        ds << value.toString();
        break;
    case QVariant::Pixmap:
        ds << typeName;
        ds << value.value<QPixmap>();
        break;
    case QVariant::ByteArray:
        ds << typeName;
        ds << value.toByteArray();
        break;
    case QVariant::BitArray:
        ds << typeName;
        ds << value.toBitArray();
        break;
    case QVariant::Image:
        ds << typeName;
        ds << value.value<QImage>();
        break;
    case QVariant::Url:
        ds << typeName;
        ds << value.toUrl();
        break;
    case QVariant::StringList:
        ds << typeName;
        ds << value.toStringList();
        break;
    case QVariant::SizePolicy:
        ds << typeName;
        ds << value.value<QSizePolicy>();
        break;
    case QVariant::SizeF:
        ds << typeName;
        ds << value.toSizeF();
        break;
    case QVariant::Size:
        ds << typeName;
        ds << value.toSize();
        break;
    case QVariant::RegExp:
        ds << typeName;
        ds << value.toRegExp();
        break;
    case QVariant::RectF:
        ds << typeName;
        ds << value.toRectF();
        break;
    case QVariant::Rect:
        ds << typeName;
        ds << value.toRect();
        break;
    case QVariant::Polygon:
        ds << typeName;
        ds << value.value<QPolygon>();
        break;
    case QVariant::PointF:
        ds << typeName;
        ds << value.toPointF();
        break;
    case QVariant::Point:
        ds << typeName;
        ds << value.toPoint();
        break;
    case QVariant::Matrix:
        ds << typeName;
        ds << value.value<QMatrix>();
        break;
    case QVariant::LineF:
        ds << typeName;
        ds << value.toLineF();
        break;
    case QVariant::Line:
        ds << typeName;
        ds << value.toLine();
        break;
    case QVariant::Brush:
        ds << typeName;
        ds << value.value<QBrush>();
        break;
    case QVariant::Bitmap:
        ds << typeName;
        ds << value.value<QBitmap>();
        break;
    case QVariant::Transform:
        ds << typeName;
        ds << value.value<QTransform>();
        break;
    default:
        // Other types will be supported shortly.
        // TODO: support user defined types.
        return false;
    }

    return true;
}
Example #28
0
QString VariantHandler::displayString(const QVariant& value)
{
  switch (value.type()) {
#ifndef QT_NO_CURSOR
  case QVariant::Cursor:
  {
    const QCursor cursor = value.value<QCursor>();
    return Util::enumToString(QVariant::fromValue<int>(cursor.shape()), "Qt::CursorShape");
  }
#endif
  case QVariant::Icon:
  {
    const QIcon icon = value.value<QIcon>();
    if (icon.isNull()) {
      return QObject::tr("<no icon>");
    }
    QStringList l;
    foreach (const QSize &size, icon.availableSizes()) {
      l.push_back(displayString(size));
    }
    return l.join(QLatin1String(", "));
  }
  case QVariant::Line:
    return
      QString::fromUtf8("%1 x %2 → %3 x %4").
        arg(value.toLine().x1()).arg(value.toLine().y1()).
        arg(value.toLine().x2()).arg(value.toLine().y2());

  case QVariant::LineF:
    return
      QString::fromUtf8("%1 x %2 → %3 x %4").
        arg(value.toLineF().x1()).arg(value.toLineF().y1()).
        arg(value.toLineF().x2()).arg(value.toLineF().y2());

  case QVariant::Locale:
    return value.value<QLocale>().name();

  case QVariant::Point:
    return
      QString::fromLatin1("%1x%2").
        arg(value.toPoint().x()).
        arg(value.toPoint().y());

  case QVariant::PointF:
    return
      QString::fromLatin1("%1x%2").
        arg(value.toPointF().x()).
        arg(value.toPointF().y());

  case QVariant::Rect:
    return
      QString::fromLatin1("%1x%2 %3x%4").
        arg(value.toRect().x()).
        arg(value.toRect().y()).
        arg(value.toRect().width()).
        arg(value.toRect().height());

  case QVariant::RectF:
    return
      QString::fromLatin1("%1x%2 %3x%4").
        arg(value.toRectF().x()).
        arg(value.toRectF().y()).
        arg(value.toRectF().width()).
        arg(value.toRectF().height());

  case QVariant::Region:
  {
    const QRegion region = value.value<QRegion>();
    if (region.isEmpty()) {
      return QLatin1String("<empty>");
    }
    if (region.rectCount() == 1) {
      return displayString(region.rects().first());
    } else {
      return QString::fromLatin1("<%1 rects>").arg(region.rectCount());
    }
  }

  case QVariant::Palette:
  {
    const QPalette pal = value.value<QPalette>();
    if (pal == qApp->palette()) {
      return QLatin1String("<inherited>");
    }
    return QLatin1String("<custom>");
  }

  case QVariant::Size:
    return
      QString::fromLatin1("%1x%2").
        arg(value.toSize().width()).
        arg(value.toSize().height());

  case QVariant::SizeF:
    return
      QString::fromLatin1("%1x%2").
        arg(value.toSizeF().width()).
        arg(value.toSizeF().height());

  case QVariant::StringList:
    return value.toStringList().join(", ");

  case QVariant::Transform:
  {
    const QTransform t = value.value<QTransform>();
    return
      QString::fromLatin1("[%1 %2 %3, %4 %5 %6, %7 %8 %9]").
        arg(t.m11()).arg(t.m12()).arg(t.m13()).
        arg(t.m21()).arg(t.m22()).arg(t.m23()).
        arg(t.m31()).arg(t.m32()).arg(t.m33());
  }
  default:
    break;
  }

  // types with dynamic type ids
  if (value.type() == (QVariant::Type)qMetaTypeId<QTextLength>()) {
    const QTextLength l = value.value<QTextLength>();
    QString typeStr;
    switch (l.type()) {
    case QTextLength::VariableLength:
      typeStr = QObject::tr("variable");
      break;
    case QTextLength::FixedLength:
      typeStr = QObject::tr("fixed");
      break;
    case QTextLength::PercentageLength:
      typeStr = QObject::tr("percentage");
      break;
    }
    return QString::fromLatin1("%1 (%2)").arg(l.rawValue()).arg(typeStr);
  }

  if (value.userType() == qMetaTypeId<QPainterPath>()) {
    const QPainterPath path = value.value<QPainterPath>();
    if (path.isEmpty()) {
      return QObject::tr("<empty>");
    }
    return QObject::tr("<%1 elements>").arg(path.elementCount());
  }

  if (value.userType() == qMetaTypeId<QMargins>()) {
    const QMargins margins = value.value<QMargins>();
    return QObject::tr("left: %1, top: %2, right: %3, bottom: %4")
       .arg(margins.left()).arg(margins.top())
       .arg(margins.right()).arg(margins.bottom());
  }

  if (value.canConvert<QObject*>()) {
    return Util::displayString(value.value<QObject*>());
  }

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
  if (value.userType() == qMetaTypeId<QSet<QByteArray> >()) {
    const QSet<QByteArray> set = value.value<QSet<QByteArray> >();
    QStringList l;
    foreach (const QByteArray &b, set)
      l.push_back(QString::fromUtf8(b));
    return l.join(", ");
  }

  if (value.userType() == qMetaTypeId<QSurfaceFormat>()) {
    const QSurfaceFormat format = value.value<QSurfaceFormat>();
    QString s;
    switch (format.renderableType()) {
      case QSurfaceFormat::DefaultRenderableType: s += "Default"; break;
      case QSurfaceFormat::OpenGL: s += "OpenGL"; break;
      case QSurfaceFormat::OpenGLES: s += "OpenGL ES"; break;
      case QSurfaceFormat::OpenVG: s += "OpenVG"; break;
    }

    s += " (" + QString::number(format.majorVersion()) + "." + QString::number(format.minorVersion());
    switch (format.profile()) {
      case QSurfaceFormat::CoreProfile: s += " core"; break;
      case QSurfaceFormat::CompatibilityProfile: s += " compat"; break;
      case QSurfaceFormat::NoProfile: break;
    }
    s += ")";

    s += " RGBA: " + QString::number(format.redBufferSize()) + "/" + QString::number(format.greenBufferSize())
      + "/" + QString::number(format.blueBufferSize()) + "/" + QString::number(format.alphaBufferSize());

    s += " Depth: " + QString::number(format.depthBufferSize());
    s += " Stencil: " + QString::number(format.stencilBufferSize());

    s += " Buffer: ";
    switch (format.swapBehavior()) {
      case QSurfaceFormat::DefaultSwapBehavior: s += "default"; break;
      case QSurfaceFormat::SingleBuffer: s += "single"; break;
      case QSurfaceFormat::DoubleBuffer: s += "double"; break;
      case QSurfaceFormat::TripleBuffer: s += "triple"; break;
      default: s += "unknown";
    }

    return s;
  }

  if (value.userType() == qMetaTypeId<QSurface::SurfaceClass>()) {
    const QSurface::SurfaceClass sc = value.value<QSurface::SurfaceClass>();
    switch (sc) {
      case QSurface::Window: return QObject::tr("Window");
#if QT_VERSION > QT_VERSION_CHECK(5, 1, 0)
      case QSurface::Offscreen: return QObject::tr("Offscreen");
#endif
      default: return QObject::tr("Unknown Surface Class");
    }
  }

  if (value.userType() == qMetaTypeId<QSurface::SurfaceType>()) {
    const QSurface::SurfaceType type = value.value<QSurface::SurfaceType>();
    switch (type) {
      case QSurface::RasterSurface: return QObject::tr("Raster");
      case QSurface::OpenGLSurface: return QObject::tr("OpenGL");
      default: return QObject::tr("Unknown Surface Type");
    }
  }

#endif

  // enums
  const QString enumStr = Util::enumToString(value);
  if (!enumStr.isEmpty()) {
    return enumStr;
  }

  // custom converters
  const QHash<int, Converter<QString>*>::const_iterator it = s_variantHandlerRepository()->stringConverters.constFind(value.userType());
  if (it != s_variantHandlerRepository()->stringConverters.constEnd()) {
    return (*it.value())(value);
  }

  return value.toString();
}
Example #29
0
PyObject* scribus_getproperty(PyObject* /*self*/, PyObject* args, PyObject* kw)
{
	PyObject* objArg = NULL;
	char* propertyName = NULL;
	char* kwargs[] = {const_cast<char*>("object"),
					  const_cast<char*>("property"),
					  NULL};
	if (!PyArg_ParseTupleAndKeywords(args, kw, "Oes", kwargs,
				&objArg, "ascii", &propertyName))
		return NULL;

	// Get the QObject* the object argument refers to
	QObject* obj = getQObjectFromPyArg(objArg);
	if (!obj)
		return NULL;
	objArg = NULL; // no need to decref, it's borrowed

	// Get the QMetaProperty for the property, so we can check
	// if it's a set/enum and do name/value translation.
/*qt4 FIXME	const QMetaObject* objmeta = obj->metaObject();
	int i = objmeta->findProperty(propertyName, true);
	if (i == -1)
	{
		PyErr_SetString(PyExc_ValueError,
				QObject::tr("Property not found"));
		return NULL;
	}

	const QMetaProperty* propmeta = objmeta->property(i, true);
	assert(propmeta);
*/
	// Get the property value as a variant type
	QVariant prop = obj->property(propertyName);

	// Convert the property to an instance of the closest matching Python type.
	PyObject* resultobj = NULL;
	// NUMERIC TYPES
	if (prop.type() == QVariant::Int)
		resultobj = PyLong_FromLong(prop.toInt());
	else if (prop.type() == QVariant::Double)
		resultobj = PyFloat_FromDouble(prop.toDouble());
	// BOOLEAN
	else if (prop.type() == QVariant::Bool)
		resultobj = PyBool_FromLong(prop.toBool());
	// STRING TYPES
	else if (prop.type() == QVariant::ByteArray)
		resultobj = PyString_FromString(prop.toByteArray().data());
	else if (prop.type() == QVariant::String)
		resultobj = PyString_FromString(prop.toString().toUtf8().data());
	// HIGHER ORDER TYPES
	else if (prop.type() == QVariant::Point)
	{
		// Return a QPoint as an (x,y) tuple.
		QPoint pt = prop.toPoint();
		return Py_BuildValue("(ii)", pt.x(), pt.y());
	}
	else if (prop.type() == QVariant::Rect)
	{
		// Return a QRect as an (x,y,width,height) tuple.
		// FIXME: We should really construct and return an object that
		// matches the API of QRect and has properties to keep
		// left/top/right/bottom and x/y/width/height in sync.
		QRect r = prop.toRect();
		return Py_BuildValue("(iiii)", r.x(), r.y(), r.width(), r.height());
	}
	else if (prop.type() == QVariant::StringList)
	{
		QStringList tmp = prop.toStringList();
		return convert_QStringList_to_PyListObject(tmp);
	}
	// UNHANDLED TYPE
	else
	{
		PyErr_SetString(PyExc_TypeError, QObject::tr("Couldn't convert result type '%1'.").arg(prop.typeName()).toLocal8Bit().constData() );
		return NULL;
	}

	// Return the resulting Python object
	if (resultobj == NULL)
	{
		// An exception was set while assigning to resultobj
		assert(PyErr_Occurred());
		return NULL;
	}
	else
		return resultobj;
}
Example #30
0
// Apply a simple variant type to a DOM property
static bool applySimpleProperty(const QVariant &v, bool translateString, DomProperty *dom_prop)
{
    switch (v.type()) {
    case QVariant::String: {
        DomString *str = new DomString();
        str->setText(v.toString());
        if (!translateString)
            str->setAttributeNotr(QStringLiteral("true"));
        dom_prop->setElementString(str);
    }
        return true;

    case QVariant::ByteArray:
        dom_prop->setElementCstring(QString::fromUtf8(v.toByteArray()));
        return true;

    case QVariant::Int:
        dom_prop->setElementNumber(v.toInt());
        return true;

    case QVariant::UInt:
        dom_prop->setElementUInt(v.toUInt());
        return true;

    case QVariant::LongLong:
        dom_prop->setElementLongLong(v.toLongLong());
        return true;

    case QVariant::ULongLong:
        dom_prop->setElementULongLong(v.toULongLong());
        return true;

    case QVariant::Double:
        dom_prop->setElementDouble(v.toDouble());
        return true;

    case QVariant::Bool:
        dom_prop->setElementBool(v.toBool() ? QFormBuilderStrings::instance().trueValue : QFormBuilderStrings::instance().falseValue);
        return true;

    case QVariant::Char: {
        DomChar *ch = new DomChar();
        const QChar character = v.toChar();
        ch->setElementUnicode(character.unicode());
        dom_prop->setElementChar(ch);
    }
        return true;

    case QVariant::Point: {
        DomPoint *pt = new DomPoint();
        const QPoint point = v.toPoint();
        pt->setElementX(point.x());
        pt->setElementY(point.y());
        dom_prop->setElementPoint(pt);
    }
        return true;

    case QVariant::PointF: {
        DomPointF *ptf = new DomPointF();
        const QPointF pointf = v.toPointF();
        ptf->setElementX(pointf.x());
        ptf->setElementY(pointf.y());
        dom_prop->setElementPointF(ptf);
    }
        return true;

    case QVariant::Color: {
        DomColor *clr = new DomColor();
        const QColor color = qvariant_cast<QColor>(v);
        clr->setElementRed(color.red());
        clr->setElementGreen(color.green());
        clr->setElementBlue(color.blue());
        const int alphaChannel = color.alpha();
        if (alphaChannel != 255)
            clr->setAttributeAlpha(alphaChannel);
        dom_prop->setElementColor(clr);
    }
        return true;

    case QVariant::Size: {
        DomSize *sz = new DomSize();
        const QSize size = v.toSize();
        sz->setElementWidth(size.width());
        sz->setElementHeight(size.height());
        dom_prop->setElementSize(sz);
    }
        return true;

    case QVariant::SizeF: {
        DomSizeF *szf = new DomSizeF();
        const QSizeF sizef = v.toSizeF();
        szf->setElementWidth(sizef.width());
        szf->setElementHeight(sizef.height());
        dom_prop->setElementSizeF(szf);
    }
        return true;

    case QVariant::Rect: {
        DomRect *rc = new DomRect();
        const QRect rect = v.toRect();
        rc->setElementX(rect.x());
        rc->setElementY(rect.y());
        rc->setElementWidth(rect.width());
        rc->setElementHeight(rect.height());
        dom_prop->setElementRect(rc);
    }
        return true;

    case QVariant::RectF: {
        DomRectF *rcf = new DomRectF();
        const QRectF rectf = v.toRectF();
        rcf->setElementX(rectf.x());
        rcf->setElementY(rectf.y());
        rcf->setElementWidth(rectf.width());
        rcf->setElementHeight(rectf.height());
        dom_prop->setElementRectF(rcf);
    }
        return true;

    case QVariant::Font: {
        DomFont *fnt = new DomFont();
        const QFont font = qvariant_cast<QFont>(v);
        const uint mask = font.resolve();
        if (mask & QFont::WeightResolved) {
            fnt->setElementBold(font.bold());
            fnt->setElementWeight(font.weight());
        }
        if (mask & QFont::FamilyResolved)
            fnt->setElementFamily(font.family());
        if (mask & QFont::StyleResolved)
            fnt->setElementItalic(font.italic());
        if (mask & QFont::SizeResolved)
            fnt->setElementPointSize(font.pointSize());
        if (mask & QFont::StrikeOutResolved)
            fnt->setElementStrikeOut(font.strikeOut());
        if (mask & QFont::UnderlineResolved)
            fnt->setElementUnderline(font.underline());
        if (mask & QFont::KerningResolved)
            fnt->setElementKerning(font.kerning());
        if (mask & QFont::StyleStrategyResolved) {
            const QMetaEnum styleStrategy_enum = metaEnum<QAbstractFormBuilderGadget>("styleStrategy");
            fnt->setElementStyleStrategy(QLatin1String(styleStrategy_enum.valueToKey(font.styleStrategy())));
        }
        dom_prop->setElementFont(fnt);
    }
        return true;

#ifndef QT_NO_CURSOR
    case QVariant::Cursor: {
        const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape");
        dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape())));
        }
        return true;
#endif

    case QVariant::KeySequence: {
        DomString *s = new DomString();
        s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText));
        dom_prop->setElementString(s);
        }
        return true;

    case QVariant::Locale: {
        DomLocale *dom = new DomLocale();
        const QLocale locale = qvariant_cast<QLocale>(v);

        const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language");
        const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country");

        dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language())));
        dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country())));

        dom_prop->setElementLocale(dom);
        }
        return true;

    case QVariant::SizePolicy: {
        DomSizePolicy *dom = new DomSizePolicy();
        const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v);

        dom->setElementHorStretch(sizePolicy.horizontalStretch());
        dom->setElementVerStretch(sizePolicy.verticalStretch());

        const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");

        dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy())));
        dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy())));

        dom_prop->setElementSizePolicy(dom);
    }
        return true;

    case QVariant::Date: {
        DomDate *dom = new DomDate();
        const QDate date = qvariant_cast<QDate>(v);

        dom->setElementYear(date.year());
        dom->setElementMonth(date.month());
        dom->setElementDay(date.day());

        dom_prop->setElementDate(dom);
        }
        return true;

    case QVariant::Time: {
        DomTime *dom = new DomTime();
        const QTime time = qvariant_cast<QTime>(v);

        dom->setElementHour(time.hour());
        dom->setElementMinute(time.minute());
        dom->setElementSecond(time.second());

        dom_prop->setElementTime(dom);
        }
        return true;

    case QVariant::DateTime: {
        DomDateTime *dom = new DomDateTime();
        const QDateTime dateTime = qvariant_cast<QDateTime>(v);

        dom->setElementHour(dateTime.time().hour());
        dom->setElementMinute(dateTime.time().minute());
        dom->setElementSecond(dateTime.time().second());
        dom->setElementYear(dateTime.date().year());
        dom->setElementMonth(dateTime.date().month());
        dom->setElementDay(dateTime.date().day());

        dom_prop->setElementDateTime(dom);
    }
        return true;

    case QVariant::Url: {
        DomUrl *dom = new DomUrl();
        const QUrl url = v.toUrl();

        DomString *str = new DomString();
        str->setText(url.toString());
        dom->setElementString(str);

        dom_prop->setElementUrl(dom);
    }
        return true;

    case QVariant::StringList: {
        DomStringList *sl = new DomStringList;
        sl->setElementString(qvariant_cast<QStringList>(v));
        dom_prop->setElementStringList(sl);
    }
        return true;

    default:
        break;
    }

    return false;
}