enum SetResponse accountingPeriod::set(const ParameterList &pParams) { XDialog::set(pParams); QVariant param; bool valid; param = pParams.value("period_id", &valid); if (valid) { _periodid = param.toInt(); populate(); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; _name->setFocus(); q.exec("SELECT period_id " "FROM period " "WHERE (period_closed); "); if (q.first()) _startDate->setEnabled(false); q.exec("SELECT (LAST(period_end) + 1) AS start_date " "FROM (SELECT period_end " " FROM period " " ORDER BY period_end) AS data; "); if (q.first()) { _startDate->setDate(q.value("start_date").toDate()); int pmonth = _startDate->date().month(); QDate pdate = _startDate->date(); while (pmonth == _startDate->date().month()) { _endDate->setDate(pdate); pdate = pdate.addDays(1); pmonth = pdate.month(); } } } else if (param.toString() == "edit") { _mode = cEdit; _startDate->setFocus(); } else if (param.toString() == "view") { _mode = cView; _name->setEnabled(FALSE); _startDate->setEnabled(FALSE); _endDate->setEnabled(FALSE); _closed->setEnabled(FALSE); _frozen->setEnabled(FALSE); _close->setText(tr("&Close")); _save->hide(); _close->setFocus(); } } return NoError; }
void PlotDataSelectWidget::functionSelect() { PlotDataSelect* plotDataSelect = dynamic_cast<PlotDataSelect*>(processor_); QVariant x = dynamic_cast<QAction*>(sender())->data(); plotDataSelect->selectFunctionalityType(static_cast<FunctionLibrary::ProcessorFunctionalityType>(x.toInt())); }
/* * loads the parameters from the QSettings into the 2 lats tabs */ void MainWindow::loadSettings() { QSettings settings; QVariant var; ui->comboBox_language->setCurrentIndex (settings.value("LANGUAGE").toInt()); QString computer_path = settings.value("COMPUTER_PATH").toString(); if (computer_path.isEmpty()) { computer_path = QString(DEFAULT_COMPUTER_PATH); settings.setValue("COMPUTER_PATH", computer_path); } ui->LineEdit_computer->setText(computer_path); if((var = settings.value("LAST_PATH")) == QVariant()) currentWorkingDir = QString(); else currentWorkingDir = var.toString(); ui->radioButtonStones_real->setChecked(true); ui->radioButtonStones_2D->setChecked((settings.value("STONES_LOOK")==1)); ui->radioButtonStones_3D->setChecked((settings.value("STONES_LOOK")==2)); ui->radioButton_allGameSound->setChecked(true); ui->radioButton_noSound->setChecked((settings.value("SOUND")==1)); ui->radioButton_myGamesSound->setChecked((settings.value("SOUND")==2)); ui->LineEdit_goban->setText(settings.value("SKIN").toString()); ui->LineEdit_table->setText(settings.value("SKIN_TABLE").toString()); ui->timerComboBox->setCurrentIndex(settings.value("TIMER_INTERVAL").toInt()); ui->komarkerCB->setChecked((settings.value("KOMARKER") == 1)); ui->numberCurrentMoveCB->setChecked((settings.value("NUMBER_CURRENT_MOVE") == 1)); #ifdef UNNECESSARY ui->warnOnCloseEditedCB->setChecked((settings.value("WARNONCLOSEEDITED") == 1)); ui->warnOnCloseEngineCB->setChecked((settings.value("WARNONCLOSENGINE") == 1)); #endif //UNNECESSARY if(settings.value("TERR_STONE_MARK").toBool()) ui->terrStoneRB->setChecked(true); else ui->terrCrossRB->setChecked(true); ui->simplePlayerNamesCB->setChecked((settings.value("SIMPLEPLAYERNAMES") == 1)); ui->observeOutsideCB->setChecked((settings.value("OBSERVEOUTSIDE") == 1)); bool b = (settings.value("ALTERNATELISTCOLORS") == 1); ui->alternateListColorsCB->setChecked(b); ui->connectionWidget->slot_alternateListColorsCB(b); //ui->connectionWidget->ui->serverComboBox->setCurrentIndex(settings.value("ACCOUNT").toInt()); //server games default values if((var = settings.value("DEFAULT_KOMI")) == QVariant()) var = 5.5; ui->komiSpinDefault->setValue(var.toInt()); if((var = settings.value("DEFAULT_SIZE")) == QVariant()) var = 19; ui->boardSizeSpin->setValue(var.toInt()); ui->timeSpin->setValue(settings.value("DEFAULT_TIME").toInt()); ui->BYSpin->setValue(settings.value("DEFAULT_BY").toInt()); ui->checkBox_Nmatch_Black->setChecked(settings.value("NMATCH_BLACK", QVariant(true)).toBool()); ui->checkBox_Nmatch_White->setChecked(settings.value("NMATCH_WHITE", QVariant(true)).toBool()); ui->checkBox_Nmatch_Nigiri->setChecked(settings.value("NMATCH_NIGIRI", QVariant(true)).toBool()); ui->HandicapSpin_Nmatch->setValue(settings.value("NMATCH_HANDICAP", QVariant(8)).toInt()); ui->timeSpin_Nmatch->setValue(settings.value("NMATCH_MAIN_TIME", QVariant(99)).toInt()); ui->BYSpin_Nmatch->setValue(settings.value("NMATCH_BYO_TIME", QVariant(60)).toInt()); ui->CheckBox_autoSave->setChecked(settings.value("AUTOSAVE").toBool()); ui->CheckBox_autoSave_Played->setChecked(settings.value("AUTOSAVE_PLAYED").toBool()); //server byo yomi warning ui->ByoSoundWarning->setChecked(settings.value("BYO_SOUND_WARNING").toBool()); ui->ByoSecWarning->setValue(settings.value("BYO_SEC_WARNING").toInt()); preferences.fill(); }
static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size ) { const QRect r( 0, 0, size.width(), size.height() ); QPainterPath borderPath; ( void )QMetaObject::invokeMethod( const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection, Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) ); if ( borderPath.isEmpty() ) { if ( canvas->contentsRect() == canvas->rect() ) return QBitmap(); QBitmap mask( size ); mask.fill( Qt::color0 ); QPainter painter( &mask ); painter.fillRect( canvas->contentsRect(), Qt::color1 ); return mask; } QImage image( size, QImage::Format_ARGB32_Premultiplied ); image.fill( Qt::color0 ); QPainter painter( &image ); painter.setClipPath( borderPath ); painter.fillRect( r, Qt::color1 ); // now erase the frame painter.setCompositionMode( QPainter::CompositionMode_DestinationOut ); if ( canvas->testAttribute(Qt::WA_StyledBackground ) ) { QStyleOptionFrame opt; opt.initFrom(canvas); opt.rect = r; canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas ); } else { const QVariant borderRadius = canvas->property( "borderRadius" ); const QVariant frameWidth = canvas->property( "frameWidth" ); if ( borderRadius.type() == QVariant::Double && frameWidth.type() == QVariant::Int ) { const double br = borderRadius.toDouble(); const int fw = frameWidth.toInt(); if ( br > 0.0 && fw > 0 ) { painter.setPen( QPen( Qt::color1, fw ) ); painter.setBrush( Qt::NoBrush ); painter.setRenderHint( QPainter::Antialiasing, true ); painter.drawPath( borderPath ); } } } painter.end(); const QImage mask = image.createMaskFromColor( QColor( Qt::color1 ).rgb(), Qt::MaskOutColor ); return QBitmap::fromImage( mask ); }
void ProgressInformationWidget::updateStatus(WebWidget::PageInformation key, const QVariant &value) { switch (m_type) { case DocumentProgressType: if (key == WebWidget::DocumentLoadingProgressInformation) { const bool isValid(value.toInt() >= 0); m_progressBar->setFormat(isValid ? tr("Document: %p%") : tr("Document: ?")); m_progressBar->setValue(isValid ? value.toInt() : 0); } break; case TotalProgressType: if (key == WebWidget::TotalLoadingProgressInformation) { m_progressBar->setFormat((value.toInt() < 0) ? tr("Total: ?") : tr("Total: %p%")); m_progressBar->setValue(value.toInt()); } break; case TotalSizeType: if (key == WebWidget::BytesReceivedInformation) { m_label->setText(tr("Total: %1").arg(Utils::formatUnit(value.toULongLong(), false, 1))); } break; case ElementsType: if (key == WebWidget::RequestsFinishedInformation) { m_label->setText(tr("Elements: %1/%2").arg(value.toInt()).arg(m_window ? m_window->getContentsWidget()->getPageInformation(WebWidget::RequestsStartedInformation).toInt() : 0)); } break; case SpeedType: if (key == WebWidget::LoadingSpeedInformation) { m_label->setText(tr("Speed: %1").arg(Utils::formatUnit(value.toULongLong(), true, 1))); } break; case ElapsedTimeType: if (key == WebWidget::LoadingTimeInformation) { int minutes(value.toInt() / 60); int seconds(value.toInt() - (minutes * 60)); m_label->setText(tr("Time: %1").arg(QStringLiteral("%1:%2").arg(minutes).arg(seconds, 2, 10, QLatin1Char('0')))); } break; case MessageType: if (key == WebWidget::LoadingMessageInformation) { m_label->setText(value.toString()); } break; default: break; } }
enum SetResponse todoItem::set(const ParameterList &pParams) { XDialog::set(pParams); QVariant param; bool valid; param = pParams.value("username", &valid); if (valid) _assignedTo->setUsername(param.toString()); param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; q.exec("SELECT NEXTVAL('todoitem_todoitem_id_seq') AS todoitem_id"); if (q.first()) { _todoitemid = q.value("todoitem_id").toInt(); _alarms->setId(_todoitemid); _comments->setId(_todoitemid); _recurring->setParent(_todoitemid, "TODO"); } _name->setFocus(); _assignedTo->setEnabled(_privileges->check("MaintainOtherTodoLists") || _privileges->check("ReassignTodoListItem")); } else if (param.toString() == "edit") { _mode = cEdit; _name->setEnabled(FALSE); _incident->setEnabled(FALSE); _ophead->setEnabled(FALSE); _assigned->setEnabled(FALSE); _due->setEnabled(FALSE); _assignedTo->setEnabled(_privileges->check("MaintainOtherTodoLists") || _privileges->check("ReassignTodoListItem")); _description->setEnabled(FALSE); _name->setFocus(); } else if (param.toString() == "view") { _mode = cView; _owner->setEnabled(FALSE); _name->setEnabled(FALSE); _priority->setEnabled(FALSE); _incident->setEnabled(FALSE); _ophead->setEnabled(FALSE); _started->setEnabled(FALSE); _assigned->setEnabled(FALSE); _due->setEnabled(FALSE); _completed->setEnabled(FALSE); _pending->setEnabled(FALSE); _deferred->setEnabled(FALSE); _neither->setEnabled(FALSE); _assignedTo->setEnabled(FALSE); _description->setEnabled(FALSE); _notes->setEnabled(FALSE); _alarms->setReadOnly(TRUE); _comments->setReadOnly(true); _close->setText(tr("&Close")); _save->hide(); _close->setFocus(); } } param = pParams.value("incdt_id", &valid); if (valid) _incident->setId(param.toInt()); param = pParams.value("priority_id", &valid); if (valid) _priority->setId(param.toInt()); param = pParams.value("ophead_id", &valid); if (valid) _ophead->setId(param.toInt()); param = pParams.value("crmacct_id", &valid); if (valid) { _crmacct->setId(param.toInt()); _crmacct->setEnabled(false); _incident->setExtraClause(QString(" (incdt_crmacct_id=%1) ") .arg(_crmacct->id())); _ophead->setExtraClause(QString(" (ophead_crmacct_id=%1) ") .arg(_crmacct->id())); } param = pParams.value("todoitem_id", &valid); if (valid) { _todoitemid = param.toInt(); sPopulate(); } return NoError; }
QRect KisFilterWave::neededRect(const QRect& rect, const KisFilterConfiguration* config) const { QVariant value; int horizontalamplitude = (config && config->getProperty("horizontalamplitude", value)) ? value.toInt() : 4; int verticalamplitude = (config && config->getProperty("verticalamplitude", value)) ? value.toInt() : 4; return rect.adjusted(-horizontalamplitude, -verticalamplitude, horizontalamplitude, verticalamplitude); }
void QgsLabelPropertyDialog::setDataDefinedValues( QgsVectorLayer *vlayer ) { //loop through data defined properties and set all the GUI widget values. We can do this //even if the data defined property is set to an expression, as it's useful to show //users what the evaluated property is... QgsExpressionContext context; context << QgsExpressionContextUtils::globalScope() << QgsExpressionContextUtils::projectScope( QgsProject::instance() ) << QgsExpressionContextUtils::atlasScope( nullptr ) << QgsExpressionContextUtils::mapSettingsScope( QgisApp::instance()->mapCanvas()->mapSettings() ) << QgsExpressionContextUtils::layerScope( vlayer ); context.setFeature( mCurLabelFeat ); Q_FOREACH ( int key, mDataDefinedProperties.propertyKeys() ) { if ( !mDataDefinedProperties.isActive( key ) ) continue; //TODO - pass expression context QVariant result = mDataDefinedProperties.value( key, context ); if ( !result.isValid() || result.isNull() ) { //could not evaluate data defined value continue; } bool ok = false; switch ( key ) { case QgsPalLayerSettings::Show: { int showLabel = result.toInt( &ok ); mShowLabelChkbx->setChecked( !ok || showLabel != 0 ); break; } case QgsPalLayerSettings::AlwaysShow: mAlwaysShowChkbx->setChecked( result.toBool() ); break; case QgsPalLayerSettings::MinimumScale: { double minScale = result.toDouble( &ok ); if ( ok ) { mMinScaleWidget->setScale( minScale ); } break; } case QgsPalLayerSettings::MaximumScale: { double maxScale = result.toDouble( &ok ); if ( ok ) { mMaxScaleWidget->setScale( maxScale ); } break; } case QgsPalLayerSettings::BufferSize: { double bufferSize = result.toDouble( &ok ); if ( ok ) { mBufferSizeSpinBox->setValue( bufferSize ); } break; } case QgsPalLayerSettings::PositionX: { double posX = result.toDouble( &ok ); if ( ok ) { mXCoordSpinBox->setValue( posX ); } break; } case QgsPalLayerSettings::PositionY: { double posY = result.toDouble( &ok ); if ( ok ) { mYCoordSpinBox->setValue( posY ); } break; } case QgsPalLayerSettings::LabelDistance: { double labelDist = result.toDouble( &ok ); if ( ok ) { mLabelDistanceSpinBox->setValue( labelDist ); } break; } case QgsPalLayerSettings::Hali: mHaliComboBox->setCurrentIndex( mHaliComboBox->findData( result.toString() ) ); break; case QgsPalLayerSettings::Vali: mValiComboBox->setCurrentIndex( mValiComboBox->findData( result.toString() ) ); break; case QgsPalLayerSettings::BufferColor: mBufferColorButton->setColor( QColor( result.toString() ) ); break; case QgsPalLayerSettings::Color: mFontColorButton->setColor( QColor( result.toString() ) ); break; case QgsPalLayerSettings::LabelRotation: { double rot = result.toDouble( &ok ); if ( ok ) { mRotationSpinBox->setValue( rot ); } break; } case QgsPalLayerSettings::Size: { double size = result.toDouble( &ok ); if ( ok ) { mFontSizeSpinBox->setValue( size ); } else { mFontSizeSpinBox->setValue( 0 ); } break; } default: break; } } }
enum SetResponse project::set(const ParameterList &pParams) { QVariant param; bool valid; param = pParams.value("usr_id", &valid); if (valid) _assignedTo->setId(param.toInt()); param = pParams.value("prj_id", &valid); if (valid) { _prjid = param.toInt(); populate(); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; connect(_prjtask, SIGNAL(valid(bool)), _editTask, SLOT(setEnabled(bool))); connect(_prjtask, SIGNAL(valid(bool)), _deleteTask, SLOT(setEnabled(bool))); connect(_prjtask, SIGNAL(itemSelected(int)), _editTask, SLOT(animateClick())); q.exec("SELECT NEXTVAL('prj_prj_id_seq') AS prj_id;"); if (q.first()) _prjid = q.value("prj_id").toInt(); else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } _comments->setId(_prjid); _assignedTo->setEnabled(_privileges->check("MaintainOtherTodoLists") || _privileges->check("ReassignTodoListItem")); } else if (param.toString() == "edit") { _mode = cEdit; _number->setEnabled(FALSE); connect(_prjtask, SIGNAL(valid(bool)), _editTask, SLOT(setEnabled(bool))); connect(_prjtask, SIGNAL(valid(bool)), _deleteTask, SLOT(setEnabled(bool))); connect(_prjtask, SIGNAL(itemSelected(int)), _editTask, SLOT(animateClick())); _assignedTo->setEnabled(_privileges->check("MaintainOtherTodoLists") || _privileges->check("ReassignTodoListItem")); } else if (param.toString() == "view") { _mode = cView; _owner->setEnabled(FALSE); _number->setEnabled(FALSE); _status->setEnabled(FALSE); _name->setEnabled(FALSE); _descrip->setEnabled(FALSE); _so->setEnabled(FALSE); _wo->setEnabled(FALSE); _po->setEnabled(FALSE); _assignedTo->setEnabled(FALSE); _newTask->setEnabled(FALSE); connect(_prjtask, SIGNAL(itemSelected(int)), _viewTask, SLOT(animateClick())); _comments->setReadOnly(TRUE); _started->setEnabled(FALSE); _assigned->setEnabled(FALSE); _due->setEnabled(FALSE); _completed->setEnabled(FALSE); } } return NoError; }
enum SetResponse apOpenItem::set(const ParameterList &pParams) { QVariant param; bool valid; param = pParams.value("docType", &valid); if (valid) { if (param.toString() == "creditMemo") { setWindowTitle(caption() + tr(" - Enter Misc. Credit Memo")); _docType->setCurrentIndex(0); } else if (param.toString() == "debitMemo") { setWindowTitle(caption() + tr(" - Enter Misc. Debit Memo")); _docType->setCurrentIndex(1); } else if (param.toString() == "voucher") _docType->setCurrentIndex(2); else return UndefinedError; // ToDo - better error return types _docType->setEnabled(FALSE); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; q.exec("SELECT fetchAPMemoNumber() AS number;"); if (q.first()) _docNumber->setText(q.value("number").toString()); // ToDo _paid->clear(); _save->setText(tr("Post")); } else if (param.toString() == "edit") { _mode = cEdit; _vend->setReadOnly(TRUE); _docDate->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _docType->setEnabled(FALSE); _docNumber->setEnabled(FALSE); _poNumber->setEnabled(FALSE); _journalNumber->setEnabled(FALSE); _terms->setEnabled(FALSE); _notes->setReadOnly(FALSE); _altPrepaid->setEnabled(FALSE); } else if (param.toString() == "view") { _mode = cView; _vend->setReadOnly(TRUE); _docDate->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _docType->setEnabled(FALSE); _docNumber->setEnabled(FALSE); _poNumber->setEnabled(FALSE); _journalNumber->setEnabled(FALSE); _amount->setEnabled(FALSE); _terms->setEnabled(FALSE); _terms->setType(XComboBox::Terms); _notes->setReadOnly(TRUE); _altPrepaid->setEnabled(FALSE); _save->hide(); _close->setText(tr("&Close")); } } param = pParams.value("vend_id", &valid); if (valid) _vend->setId(param.toInt()); param = pParams.value("apopen_id", &valid); if (valid) { _apopenid = param.toInt(); populate(); } return NoError; }
static QCFType<CFPropertyListRef> macValue(const QVariant &value) { CFPropertyListRef result = 0; switch (value.type()) { case QVariant::ByteArray: { QByteArray ba = value.toByteArray(); result = CFDataCreate(kCFAllocatorDefault, reinterpret_cast<const UInt8 *>(ba.data()), CFIndex(ba.size())); } break; // should be same as below (look for LIST) case QVariant::List: case QVariant::StringList: case QVariant::Polygon: result = macList(value.toList()); break; case QVariant::Map: { /* QMap<QString, QVariant> is potentially a multimap, whereas CFDictionary is a single-valued map. To allow for multiple values with the same key, we store multiple values in a CFArray. To avoid ambiguities, we also wrap lists in a CFArray singleton. */ QMap<QString, QVariant> map = value.toMap(); QMap<QString, QVariant>::const_iterator i = map.constBegin(); int maxUniqueKeys = map.size(); int numUniqueKeys = 0; QVarLengthArray<QCFType<CFPropertyListRef> > cfkeys(maxUniqueKeys); QVarLengthArray<QCFType<CFPropertyListRef> > cfvalues(maxUniqueKeys); while (i != map.constEnd()) { const QString &key = i.key(); QList<QVariant> values; do { values << i.value(); ++i; } while (i != map.constEnd() && i.key() == key); bool singleton = (values.count() == 1); if (singleton) { switch (values.first().type()) { // should be same as above (look for LIST) case QVariant::List: case QVariant::StringList: case QVariant::Polygon: singleton = false; default: ; } } cfkeys[numUniqueKeys] = QCFString::toCFStringRef(key); cfvalues[numUniqueKeys] = singleton ? macValue(values.first()) : macList(values); ++numUniqueKeys; } result = CFDictionaryCreate(kCFAllocatorDefault, reinterpret_cast<const void **>(cfkeys.data()), reinterpret_cast<const void **>(cfvalues.data()), CFIndex(numUniqueKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } break; case QVariant::DateTime: { /* CFDate, unlike QDateTime, doesn't store timezone information. */ QDateTime dt = value.toDateTime(); if (dt.timeSpec() == Qt::LocalTime) { QDateTime reference; reference.setTime_t((uint)kCFAbsoluteTimeIntervalSince1970); result = CFDateCreate(kCFAllocatorDefault, CFAbsoluteTime(reference.secsTo(dt))); } else { goto string_case; } } break; case QVariant::Bool: result = value.toBool() ? kCFBooleanTrue : kCFBooleanFalse; break; case QVariant::Int: case QVariant::UInt: { int n = value.toInt(); result = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &n); } break; case QVariant::Double: { double n = value.toDouble(); result = CFNumberCreate(kCFAllocatorDefault, kCFNumberDoubleType, &n); } break; case QVariant::LongLong: case QVariant::ULongLong: { qint64 n = value.toLongLong(); result = CFNumberCreate(0, kCFNumberLongLongType, &n); } break; case QVariant::String: string_case: default: result = QCFString::toCFStringRef(QSettingsPrivate::variantToString(value)); } return result; }
QString QgsProcessingUtils::variantToPythonLiteral( const QVariant &value ) { if ( !value.isValid() ) return QStringLiteral( "None" ); if ( value.canConvert<QgsProperty>() ) return QStringLiteral( "QgsProperty.fromExpression('%1')" ).arg( value.value< QgsProperty >().asExpression() ); else if ( value.canConvert<QgsCoordinateReferenceSystem>() ) { if ( !value.value< QgsCoordinateReferenceSystem >().isValid() ) return QStringLiteral( "QgsCoordinateReferenceSystem()" ); else return QStringLiteral( "QgsCoordinateReferenceSystem('%1')" ).arg( value.value< QgsCoordinateReferenceSystem >().authid() ); } else if ( value.canConvert< QgsRectangle >() ) { QgsRectangle r = value.value<QgsRectangle>(); return QStringLiteral( "'%1, %3, %2, %4'" ).arg( qgsDoubleToString( r.xMinimum() ), qgsDoubleToString( r.yMinimum() ), qgsDoubleToString( r.xMaximum() ), qgsDoubleToString( r.yMaximum() ) ); } else if ( value.canConvert< QgsReferencedRectangle >() ) { QgsReferencedRectangle r = value.value<QgsReferencedRectangle>(); return QStringLiteral( "'%1, %3, %2, %4 [%5]'" ).arg( qgsDoubleToString( r.xMinimum() ), qgsDoubleToString( r.yMinimum() ), qgsDoubleToString( r.xMaximum() ), qgsDoubleToString( r.yMaximum() ), r.crs().authid() ); } else if ( value.canConvert< QgsPointXY >() ) { QgsPointXY r = value.value<QgsPointXY>(); return QStringLiteral( "'%1,%2'" ).arg( qgsDoubleToString( r.x() ), qgsDoubleToString( r.y() ) ); } else if ( value.canConvert< QgsReferencedPointXY >() ) { QgsReferencedPointXY r = value.value<QgsReferencedPointXY>(); return QStringLiteral( "'%1,%2 [%3]'" ).arg( qgsDoubleToString( r.x() ), qgsDoubleToString( r.y() ), r.crs().authid() ); } switch ( value.type() ) { case QVariant::Bool: return value.toBool() ? QStringLiteral( "True" ) : QStringLiteral( "False" ); case QVariant::Double: return QString::number( value.toDouble() ); case QVariant::Int: case QVariant::UInt: return QString::number( value.toInt() ); case QVariant::LongLong: case QVariant::ULongLong: return QString::number( value.toLongLong() ); case QVariant::List: { QStringList parts; const QVariantList vl = value.toList(); for ( const QVariant &v : vl ) { parts << variantToPythonLiteral( v ); } return parts.join( ',' ).prepend( '[' ).append( ']' ); } default: break; } return QgsProcessingUtils::stringToPythonLiteral( value.toString() ); }
bool DlgFilletEdges::accept() { if (!d->object) { QMessageBox::warning(this, tr("No shape selected"), tr("No valid shape is selected.\n" "Please select a valid shape in the drop-down box first.")); return false; } App::Document* activeDoc = App::GetApplication().getActiveDocument(); QAbstractItemModel* model = ui->treeView->model(); bool end_radius = !ui->treeView->isColumnHidden(2); bool todo = false; QString shape, type, name; std::string fillet = getFilletType(); int index = ui->shapeObject->currentIndex(); shape = ui->shapeObject->itemData(index).toString(); type = QString::fromAscii("Part::%1").arg(QString::fromAscii(fillet.c_str())); if (d->fillet) name = QString::fromAscii(d->fillet->getNameInDocument()); else name = QString::fromAscii(activeDoc->getUniqueObjectName(fillet.c_str()).c_str()); activeDoc->openTransaction(fillet.c_str()); QString code; if (!d->fillet) { code = QString::fromAscii( "FreeCAD.ActiveDocument.addObject(\"%1\",\"%2\")\n" "FreeCAD.ActiveDocument.%2.Base = FreeCAD.ActiveDocument.%3\n") .arg(type).arg(name).arg(shape); } code += QString::fromAscii("__fillets__ = []\n"); for (int i=0; i<model->rowCount(); ++i) { QVariant value = model->index(i,0).data(Qt::CheckStateRole); Qt::CheckState checkState = static_cast<Qt::CheckState>(value.toInt()); // is item checked if (checkState & Qt::Checked) { // the index value of the edge int id = model->index(i,0).data(Qt::UserRole).toInt(); double r1 = model->index(i,1).data().toDouble(); double r2 = r1; if (end_radius) r2 = model->index(i,2).data().toDouble(); code += QString::fromAscii( "__fillets__.append((%1,%2,%3))\n") .arg(id).arg(r1,0,'f',2).arg(r2,0,'f',2); todo = true; } } if (!todo) { QMessageBox::warning(this, tr("No edge selected"), tr("No edge entity is checked to fillet.\n" "Please check one or more edge entities first.")); return false; } Gui::WaitCursor wc; code += QString::fromAscii( "FreeCAD.ActiveDocument.%1.Edges = __fillets__\n" "del __fillets__\n" "FreeCADGui.ActiveDocument.%2.Visibility = False\n") .arg(name).arg(shape); Gui::Application::Instance->runPythonCode((const char*)code.toAscii()); activeDoc->commitTransaction(); activeDoc->recompute(); if (d->fillet) { Gui::ViewProvider* vp; vp = Gui::Application::Instance->getViewProvider(d->fillet); if (vp) vp->show(); } QByteArray to = name.toAscii(); QByteArray from = shape.toAscii(); Gui::Command::copyVisual(to, "ShapeColor", from); Gui::Command::copyVisual(to, "LineColor", from); Gui::Command::copyVisual(to, "PointColor", from); return true; }
enum SetResponse dspInventoryHistoryByParameterList::set(const ParameterList &pParams) { XWidget::set(pParams); QVariant param; bool valid; param = pParams.value("classcode_id", &valid); if (valid) { _parameter->setType(ParameterGroup::ClassCode); _parameter->setId(param.toInt()); } param = pParams.value("classcode_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::ClassCode); _parameter->setPattern(param.toString()); } param = pParams.value("classcode", &valid); if (valid) _parameter->setType(ParameterGroup::ClassCode); param = pParams.value("plancode_id", &valid); if (valid) { _parameter->setType(ParameterGroup::PlannerCode); _parameter->setId(param.toInt()); } param = pParams.value("plancode_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::PlannerCode); _parameter->setPattern(param.toString()); } param = pParams.value("plancode", &valid); if (valid) _parameter->setType(ParameterGroup::PlannerCode); param = pParams.value("itemgrp_id", &valid); if (valid) { _parameter->setType(ParameterGroup::ItemGroup); _parameter->setId(param.toInt()); } param = pParams.value("itemgrp_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::ItemGroup); _parameter->setPattern(param.toString()); } param = pParams.value("itemgrp", &valid); if (valid) _parameter->setType(ParameterGroup::ItemGroup); param = pParams.value("warehous_id", &valid); if (valid) _warehouse->setId(param.toInt()); param = pParams.value("startDate", &valid); if (valid) _dates->setStartDate(param.toDate()); param = pParams.value("endDate", &valid); if (valid) _dates->setEndDate(param.toDate()); param = pParams.value("transtype", &valid); if (valid) { QString transtype = param.toString(); if (transtype == "R") _transType->setCurrentIndex(1); else if (transtype == "I") _transType->setCurrentIndex(2); else if (transtype == "S") _transType->setCurrentIndex(3); else if (transtype == "A") _transType->setCurrentIndex(4); else if (transtype == "T") _transType->setCurrentIndex(5); else if (transtype == "SC") _transType->setCurrentIndex(6); } param = pParams.value("ordertype", &valid); if (valid) { QString ordertype = param.toString(); if (ordertype == "SO") _orderType->setCurrentIndex(1); else if (ordertype == "PO") _orderType->setCurrentIndex(2); else if (ordertype == "WO") _orderType->setCurrentIndex(3); else if (ordertype == "TO") _orderType->setCurrentIndex(4); } if (pParams.inList("run")) sFillList(); switch (_parameter->type()) { case ParameterGroup::ClassCode: setWindowTitle(tr("Inventory History by Class Code")); break; case ParameterGroup::PlannerCode: setWindowTitle(tr("Inventory History by Planner Code")); break; case ParameterGroup::ItemGroup: setWindowTitle(tr("Inventory History by Item Group")); break; default: break; } return NoError; }
/*! Renders the delegate using the given \a painter and style \a option for the item specified by \a index. When reimplementing this function in a subclass, you should update the area held by the option's \l{QStyleOption::rect}{rect} variable, using the option's \l{QStyleOption::state}{state} variable to determine the state of the item to be displayed, and adjust the way it is painted accordingly. For example, a selected item may need to be displayed differently to unselected items, as shown in the following code: \snippet itemviews/pixelator/pixeldelegate.cpp 2 \dots After painting, you should ensure that the painter is returned to its the state it was supplied in when this function was called. For example, it may be useful to call QPainter::save() before painting and QPainter::restore() afterwards. \sa QStyle::State */ void QItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_D(const QItemDelegate); Q_ASSERT(index.isValid()); QStyleOptionViewItem opt = setOptions(index, option); // prepare painter->save(); if (d->clipPainting) painter->setClipRect(opt.rect); // get the data and the rectangles QVariant value; QPixmap pixmap; QRect decorationRect; value = index.data(Qt::DecorationRole); if (value.isValid()) { // ### we need the pixmap to call the virtual function pixmap = decoration(opt, value); if (value.type() == QVariant::Icon) { d->tmp.icon = qvariant_cast<QIcon>(value); d->tmp.mode = d->iconMode(option.state); d->tmp.state = d->iconState(option.state); const QSize size = d->tmp.icon.actualSize(option.decorationSize, d->tmp.mode, d->tmp.state); decorationRect = QRect(QPoint(0, 0), size); } else { d->tmp.icon = QIcon(); decorationRect = QRect(QPoint(0, 0), pixmap.size()); } } else { d->tmp.icon = QIcon(); decorationRect = QRect(); } QString text; QRect displayRect; value = index.data(Qt::DisplayRole); if (value.isValid() && !value.isNull()) { text = QItemDelegatePrivate::valueToText(value, opt); displayRect = textRectangle(painter, d->textLayoutBounds(opt), opt.font, text); } QRect checkRect; Qt::CheckState checkState = Qt::Unchecked; value = index.data(Qt::CheckStateRole); if (value.isValid()) { checkState = static_cast<Qt::CheckState>(value.toInt()); checkRect = doCheck(opt, opt.rect, value); } // do the layout doLayout(opt, &checkRect, &decorationRect, &displayRect, false); // draw the item drawBackground(painter, opt, index); drawCheck(painter, opt, checkRect, checkState); drawDecoration(painter, opt, decorationRect, pixmap); drawDisplay(painter, opt, displayRect, text); drawFocus(painter, opt, displayRect); // done painter->restore(); }
enum SetResponse voucher::set(const ParameterList &pParams) { QVariant param; bool valid; param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; q.exec("SELECT NEXTVAL('vohead_vohead_id_seq') AS vohead_id"); if (q.first()) _voheadid = q.value("vohead_id").toInt(); else { systemError(this, tr("A System Error occurred at %1::%2.") .arg(__FILE__) .arg(__LINE__) ); return UndefinedError; } if (_metrics->value("VoucherNumberGeneration") == "A") { populateNumber(); _poNumber->setFocus(); } else _voucherNumber->setFocus(); q.prepare("INSERT INTO vohead (vohead_id, vohead_number, vohead_posted)" " VALUES (:vohead_id, :vohead_number, false);" ); q.bindValue(":vohead_id", _voheadid); q.bindValue(":vohead_number", _voucherNumber->text().toInt()); q.exec(); if (q.lastError().type() != QSqlError::None) { systemError(this, q.lastError().databaseText(), __FILE__, __LINE__); return UndefinedError; } } else if (param.toString() == "edit") { _mode = cEdit; _voucherNumber->setEnabled(FALSE); _poNumber->setEnabled(FALSE); _poList->hide(); _save->setFocus(); } else if (param.toString() == "view") { _mode = cView; _poNumber->setType(0); // allow any potype when viewing _voucherNumber->setEnabled(FALSE); _poNumber->setEnabled(FALSE); _poList->hide(); _amountToDistribute->setEnabled(FALSE); _distributionDate->setEnabled(FALSE); _invoiceDate->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _invoiceNum->setEnabled(FALSE); _reference->setEnabled(FALSE); _poitem->setEnabled(FALSE); _distributions->setEnabled(FALSE); _miscDistrib->setEnabled(FALSE); _new->setEnabled(FALSE); _terms->setEnabled(FALSE); _close->setText(tr("&Close")); _save->hide(); _close->setFocus(); } } param = pParams.value("vohead_id", &valid); if (valid) { _voheadid = param.toInt(); populate(); } return NoError; }
enum SetResponse itemPricingScheduleItem::set(const ParameterList &pParams) { XDialog::set(pParams); QVariant param; bool valid; param = pParams.value("ipshead_id", &valid); if (valid) _ipsheadid = param.toInt(); param = pParams.value("curr_id", &valid); if (valid) { _price->setId(param.toInt()); _priceFreight->setId(param.toInt()); } param = pParams.value("updated", &valid); if (valid) { _price->setEffective(param.toDate()); _priceFreight->setEffective(param.toDate()); } param = pParams.value("ipsitem_id", &valid); if (valid) { _ipsitemid = param.toInt(); q.prepare("SELECT ipsitem_qtybreak, " " ipsitem_discntprcnt, " " ipsitem_fixedamtdiscount " "FROM ipsiteminfo " "WHERE (ipsitem_id = :ipsitem_id) "); q.bindValue(":ipsitem_id", _ipsitemid); q.exec(); if (q.first()) { if(q.value("ipsitem_discntprcnt").toDouble() != 0.0 || q.value("ipsitem_fixedamtdiscount").toDouble() != 0.0) { _discountSelected->setChecked(true); _dscbyItem->setChecked(true); } else { _itemSelected->setChecked(true); } populate(); } } param = pParams.value("ipsprodcat_id", &valid); if (valid) { _ipsprodcatid = param.toInt(); _discountSelected->setChecked(true); _dscbyprodcat->setChecked(true); populate(); } param = pParams.value("ipsfreight_id", &valid); if (valid) { _ipsfreightid = param.toInt(); _freightSelected->setChecked(true); populate(); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; _item->setFocus(); } else if (param.toString() == "edit") { _mode = cEdit; _item->setReadOnly(TRUE); _prodcat->setEnabled(FALSE); _typeGroup->setEnabled(FALSE); _dscitem->setReadOnly(TRUE); _discountBy->setEnabled(FALSE); if(_ipsitemid != -1) _qtyBreak->setFocus(); else if(_ipsprodcatid != -1) _qtyBreakCat->setFocus(); } else if (param.toString() == "view") { _mode = cView; _item->setReadOnly(TRUE); _prodcat->setEnabled(FALSE); _qtyBreak->setEnabled(FALSE); _qtyBreakCat->setEnabled(FALSE); _qtyBreakFreight->setEnabled(FALSE); _price->setEnabled(FALSE); _discount->setEnabled(FALSE); _fixedAmtDiscount->setEnabled(FALSE); _priceFreight->setEnabled(FALSE); _typeGroup->setEnabled(FALSE); _typeFreightGroup->setEnabled(FALSE); _siteFreight->setEnabled(FALSE); _zoneFreightGroup->setEnabled(FALSE); _shipViaFreightGroup->setEnabled(FALSE); _freightClassGroup->setEnabled(FALSE); _dscitem->setReadOnly(TRUE); _discountBy->setEnabled(FALSE); _buttonBox->setStandardButtons(QDialogButtonBox::Close); } } return NoError; }
enum SetResponse dspSalesHistoryByParameterList::set(const ParameterList &pParams) { QVariant param; bool valid; param = pParams.value("prodcat", &valid); if (valid) _parameter->setType(ParameterGroup::ProductCategory); param = pParams.value("prodcat_id", &valid); if (valid) { _parameter->setType(ParameterGroup::ProductCategory); _parameter->setId(param.toInt()); } param = pParams.value("prodcat_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::ProductCategory); _parameter->setPattern(param.toString()); } param = pParams.value("custtype", &valid); if (valid) _parameter->setType(ParameterGroup::CustomerType); param = pParams.value("custtype_id", &valid); if (valid) { _parameter->setType(ParameterGroup::CustomerType); _parameter->setId(param.toInt()); } param = pParams.value("custtype_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::CustomerType); _parameter->setPattern(param.toString()); } param = pParams.value("custgrp", &valid); if (valid) _parameter->setType(ParameterGroup::CustomerGroup); param = pParams.value("custgrp_id", &valid); if (valid) { _parameter->setType(ParameterGroup::CustomerGroup); _parameter->setId(param.toInt()); } param = pParams.value("custgrp_pattern", &valid); if (valid) { _parameter->setType(ParameterGroup::CustomerGroup); _parameter->setPattern(param.toString()); } param = pParams.value("warehous_id", &valid); if (valid) _warehouse->setId(param.toInt()); param = pParams.value("startDate", &valid); if (valid) _dates->setStartDate(param.toDate()); param = pParams.value("endDate", &valid); if (valid) _dates->setEndDate(param.toDate()); if (pParams.inList("run")) { sFillList(); return NoError_Run; } if (_parameter->type() == ParameterGroup::ProductCategory) setWindowTitle(tr("Sales History by Product Category")); if (_parameter->type() == ParameterGroup::CustomerType) setWindowTitle(tr("Sales History by Customer Type")); if (_parameter->type() == ParameterGroup::CustomerGroup) setWindowTitle(tr("Sales History by Customer Group")); return NoError; }
enum SetResponse workOrder::set(const ParameterList &pParams) { _captive = TRUE; QString returnValue; QVariant param; bool valid; param = pParams.value("itemsite_id", &valid); if (valid) { _item->setItemsiteid(param.toInt()); _item->setEnabled(FALSE); _warehouse->setEnabled(FALSE); _qty->setFocus(); } param = pParams.value("qty", &valid); if (valid) _qty->setText(formatQty(param.toDouble())); param = pParams.value("dueDate", &valid); if (valid) { _dueDate->setDate(param.toDate()); sUpdateStartDate(); } param = pParams.value("wo_id", &valid); if (valid) _woid = param.toInt(); param = pParams.value("planord_id", &valid); if (valid) _planordid = param.toInt(); param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2," " item_active, item_config, item_type, uom_name " "FROM item JOIN uom ON (item_inv_uom_id=uom_id) " "WHERE (item_type IN ('M', 'B') " "AND (item_active)) "); _qtyReceivedLit->clear(); _tabs->removePage(_tabs->page(3)); populateWoNumber(); } else if (param.toString() == "edit") { _mode = cEdit; _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2," " item_active, item_config, item_type, uom_name " "FROM item JOIN uom ON (item_inv_uom_id=uom_id) " "WHERE (item_type IN ('M', 'B', 'J')) "); XSqlQuery wo; wo.prepare( "SELECT wo_itemsite_id, wo_priority, wo_status," " formatWoNumber(wo_id) AS f_wonumber," " formatQty(wo_qtyord) AS f_ordered," " formatQty(wo_qtyrcv) AS f_received," " wo_startdate, wo_duedate," " formatMoney(wo_wipvalue) AS f_wipvalue," " formatMoney(wo_postedvalue) AS f_postedvalue," " formatMoney(wo_postedvalue-wo_wipvalue) AS f_rcvdvalue," " wo_prodnotes, wo_prj_id, " " wo_bom_rev_id, wo_boo_rev_id, " " wo_cosmethod " "FROM wo " "WHERE (wo_id=:wo_id);" ); wo.bindValue(":wo_id", _woid); wo.exec(); if (wo.first()) { _oldPriority = wo.value("wo_priority").toInt(); _oldStartDate = wo.value("wo_startdate").toDate(); _oldDueDate = wo.value("wo_duedate").toDate(); _oldQty = wo.value("f_ordered").toString(); _woNumber->setText(wo.value("f_wonumber").toString()); _item->setItemsiteid(wo.value("wo_itemsite_id").toInt()); _priority->setValue(_oldPriority); _postedValue->setText(wo.value("f_postedvalue").toString()); _rcvdValue->setText(wo.value("f_rcvdvalue").toString()); _wipValue->setText(wo.value("f_wipvalue").toString()); _qty->setText(wo.value("f_ordered").toString()); _qtyReceived->setText(wo.value("f_received").toString()); _startDate->setDate(_oldStartDate); _dueDate->setDate(_oldDueDate); _productionNotes->setText(wo.value("wo_prodnotes").toString()); _comments->setId(_woid); _project->setId(wo.value("wo_prj_id").toInt()); _bomRevision->setId(wo.value("wo_bom_rev_id").toInt()); _booRevision->setId(wo.value("wo_boo_rev_id").toInt()); if (wo.value("wo_cosmethod").toString() == "D") _todate->setChecked(TRUE); else if (wo.value("wo_cosmethod").toString() == "P") _proportional->setChecked(TRUE); else _jobCosGroup->hide(); // If the W/O is closed or Released don't allow changing some items. if(wo.value("wo_status").toString() == "C" || wo.value("wo_status") == "R") { _priority->setEnabled(false); _qty->setEnabled(false); _dueDate->setEnabled(false); _startDate->setEnabled(false); } _startDate->setEnabled(true); _woNumber->setEnabled(false); _item->setReadOnly(true); _bomRevision->setEnabled(wo.value("wo_status").toString() == "O"); _booRevision->setEnabled(wo.value("wo_status").toString() == "O"); _warehouse->setEnabled(false); _comments->setReadOnly(false); _leadTimeLit->hide(); _leadTime->hide(); _daysLit->hide(); _printTraveler->hide(); _bottomSpacer->hide(); _create->setText(tr("&Save")); _close->setFocus(); } else { systemError(this, tr("A System Error occurred at %1::%2, W/O ID %3.") .arg(__FILE__) .arg(__LINE__) .arg(_woid) ); close(); } } else if (param.toString() == "view") { _mode = cView; _item->setQuery("SELECT DISTINCT item_id, item_number, item_descrip1, item_descrip2," " item_active, item_config, item_type, uom_name " "FROM item JOIN uom ON (item_inv_uom_id=uom_id) " "WHERE (item_type IN ('M', 'B', 'J')) "); XSqlQuery wo; wo.prepare( "SELECT wo_itemsite_id, wo_priority," " formatWoNumber(wo_id) AS f_wonumber," " formatQty(wo_qtyord) AS f_ordered," " formatQty(wo_qtyrcv) AS f_received," " wo_startdate, wo_duedate," " formatMoney(wo_wipvalue) AS f_wipvalue," " formatMoney(wo_postedvalue) AS f_postedvalue," " formatMoney(wo_postedvalue-wo_wipvalue) AS f_rcvdvalue," " wo_prodnotes, wo_prj_id, wo_bom_rev_id, " " wo_boo_rev_id, wo_cosmethod " "FROM wo " "WHERE (wo_id=:wo_id);" ); wo.bindValue(":wo_id", _woid); wo.exec(); if (wo.first()) { _mode = cView; _woNumber->setText(wo.value("f_wonumber").toString()); _item->setItemsiteid(wo.value("wo_itemsite_id").toInt()); _priority->setValue(wo.value("wo_priority").toInt()); _postedValue->setText(wo.value("f_postedvalue").toString()); _rcvdValue->setText(wo.value("f_rcvdvalue").toString()); _wipValue->setText(wo.value("f_wipvalue").toString()); _qty->setText(wo.value("f_ordered").toString()); _qtyReceived->setText(wo.value("f_received").toString()); _startDate->setDate(wo.value("wo_startdate").toDate()); _dueDate->setDate(wo.value("wo_duedate").toDate()); _productionNotes->setText(wo.value("wo_prodnotes").toString()); _comments->setId(_woid); _project->setId(wo.value("wo_prj_id").toInt()); _bomRevision->setId(wo.value("wo_bom_rev_id").toInt()); _booRevision->setId(wo.value("wo_boo_rev_id").toInt()); if (wo.value("wo_cosmethod").toString() == "D") _todate->setChecked(TRUE); else if (wo.value("wo_cosmethod").toString() == "P") _proportional->setChecked(TRUE); else _jobCosGroup->hide(); _woNumber->setEnabled(FALSE); _item->setReadOnly(TRUE); _bomRevision->setEnabled(FALSE); _booRevision->setEnabled(FALSE); _warehouse->setEnabled(FALSE); _priority->setEnabled(FALSE); _qty->setEnabled(FALSE); _startDate->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _productionNotes->setReadOnly(TRUE); _create->hide(); _leadTimeLit->hide(); _leadTime->hide(); _daysLit->hide(); _printTraveler->hide(); _bottomSpacer->hide(); _close->setText(tr("&Close")); _project->setEnabled(FALSE); _itemcharView->setEnabled(false); _jobCosGroup->setEnabled(FALSE); _close->setFocus(); } else { systemError(this, tr("A System Error occurred at %1::%2, W/O ID %3.") .arg(__FILE__) .arg(__LINE__) .arg(_woid) ); close(); } } else if (param.toString() == "release") { _mode = cRelease; _tabs->removePage(_tabs->page(3)); q.prepare( "SELECT planord_itemsite_id, planord_duedate," " CASE WHEN(planord_mps) THEN 'P'" " ELSE 'M'" " END AS sourcetype," " CASE WHEN(planord_mps) THEN planord_pschitem_id" " ELSE planord_id" " END AS sourceid," " formatQty(planord_qty) AS qty " "FROM planord " "WHERE (planord_id=:planord_id);" ); q.bindValue(":planord_id", _planordid); q.exec(); if (q.first()) { _item->setReadOnly(TRUE); _warehouse->setEnabled(FALSE); _planordtype=q.value("sourcetype").toString(); _sourceid=q.value("sourceid").toInt(); _qty->setText(q.value("qty").toString()); _dueDate->setDate(q.value("planord_duedate").toDate()); _item->setItemsiteid(q.value("planord_itemsite_id").toInt()); sUpdateStartDate(); populateWoNumber(); _qty->setEnabled(FALSE); _qtyReceivedLit->clear(); _startDate->setEnabled(FALSE); _dueDate->setEnabled(FALSE); _wipValueLit->hide(); _wipValue->hide(); _leadTimeLit->hide(); _leadTime->hide(); _daysLit->hide(); _create->setFocus(); } else { systemError(this, tr("A System Error occurred at %1::%2, Planned Order ID %3.") .arg(__FILE__) .arg(__LINE__) .arg(_planordid) ); close(); } } } return NoError; }
enum SetResponse address::set(const ParameterList &pParams) { XDialog::set(pParams); QVariant param; bool valid; param = pParams.value("addr_id", &valid); if (valid) { _captive = TRUE; _addr->setId(param.toInt()); sPopulate(); } param = pParams.value("mode", &valid); if (valid) { if (param.toString() == "new") { _mode = cNew; q.exec("SELECT fetchNextNumber('AddressNumber') AS result;"); q.first(); _addr->setNumber(q.value("result").toString()); _addr->setLine1("Address" + QDateTime::currentDateTime().toString()); int addrSaveResult = _addr->save(AddressCluster::CHANGEONE); if (addrSaveResult < 0) { systemError(this, tr("There was an error creating a new address (%).\n" "Check the database server log for errors.") .arg(addrSaveResult), __FILE__, __LINE__); return UndefinedError; } _comments->setId(_addr->id()); _addr->setLine1(""); connect(_charass, SIGNAL(valid(bool)), _editCharacteristic, SLOT(setEnabled(bool))); connect(_charass, SIGNAL(valid(bool)), _deleteCharacteristic, SLOT(setEnabled(bool))); _addr->setFocus(); } else if (param.toString() == "edit") { _mode = cEdit; connect(_charass, SIGNAL(valid(bool)), _editCharacteristic, SLOT(setEnabled(bool))); connect(_charass, SIGNAL(valid(bool)), _deleteCharacteristic, SLOT(setEnabled(bool))); } else if (param.toString() == "view") { _mode = cView; _editAddrUse->hide(); disconnect(_uses, SIGNAL(itemSelected(int)), _editAddrUse, SLOT(animateClick())); connect(_uses, SIGNAL(itemSelected(int)), _viewAddrUse, SLOT(animateClick())); _addr->setEnabled(FALSE); _notes->setEnabled(FALSE); _comments->setEnabled(FALSE); _newCharacteristic->setEnabled(FALSE); _editCharacteristic->setEnabled(FALSE); _deleteCharacteristic->setEnabled(FALSE); _editAddrUse->setEnabled(FALSE); _charass->setEnabled(FALSE); _buttonBox->setStandardButtons(QDialogButtonBox::Close); } } return NoError; }
/*! Render the canvas into a given rectangle. \param plot Plot widget \param painter Painter \param map Maps mapping between plot and paint device coordinates \param canvasRect Canvas rectangle */ void QwtPlotRenderer::renderCanvas( const QwtPlot *plot, QPainter *painter, const QRectF &canvasRect, const QwtScaleMapTable &mapTable ) const { const QWidget *canvas = plot->canvas(); QRectF r = canvasRect.adjusted( 0.0, 0.0, -1.0, -1.0 ); if ( d_data->layoutFlags & FrameWithScales ) { painter->save(); r.adjust( -1.0, -1.0, 1.0, 1.0 ); painter->setPen( QPen( Qt::black ) ); if ( !( d_data->discardFlags & DiscardCanvasBackground ) ) { const QBrush bgBrush = canvas->palette().brush( plot->backgroundRole() ); painter->setBrush( bgBrush ); } QwtPainter::drawRect( painter, r ); painter->restore(); painter->save(); painter->setClipRect( canvasRect ); plot->drawItems( painter, canvasRect, mapTable ); painter->restore(); } else if ( canvas->testAttribute( Qt::WA_StyledBackground ) ) { QPainterPath clipPath; painter->save(); if ( !( d_data->discardFlags & DiscardCanvasBackground ) ) { QwtPainter::drawBackgound( painter, r, canvas ); clipPath = qwtCanvasClip( canvas, canvasRect ); } painter->restore(); painter->save(); if ( clipPath.isEmpty() ) painter->setClipRect( canvasRect ); else painter->setClipPath( clipPath ); plot->drawItems( painter, canvasRect, mapTable ); painter->restore(); } else { QPainterPath clipPath; int frameWidth = 0; if ( !( d_data->discardFlags & DiscardCanvasFrame ) ) { const QVariant fw = canvas->property( "frameWidth" ); if ( fw.type() == QVariant::Int ) frameWidth = fw.toInt(); clipPath = qwtCanvasClip( canvas, canvasRect ); } QRectF innerRect = canvasRect.adjusted( frameWidth, frameWidth, -frameWidth, -frameWidth ); painter->save(); if ( clipPath.isEmpty() ) { painter->setClipRect( innerRect ); } else { painter->setClipPath( clipPath ); } if ( !( d_data->discardFlags & DiscardCanvasBackground ) ) { QwtPainter::drawBackgound( painter, innerRect, canvas ); } plot->drawItems( painter, innerRect, mapTable ); painter->restore(); if ( frameWidth > 0 ) { painter->save(); const int frameStyle = canvas->property( "frameShadow" ).toInt() | canvas->property( "frameShape" ).toInt(); const int frameWidth = canvas->property( "frameWidth" ).toInt(); const QVariant borderRadius = canvas->property( "borderRadius" ); if ( borderRadius.type() == QVariant::Double && borderRadius.toDouble() > 0.0 ) { const double r = borderRadius.toDouble(); QwtPainter::drawRoundedFrame( painter, canvasRect, r, r, canvas->palette(), frameWidth, frameStyle ); } else { const int midLineWidth = canvas->property( "midLineWidth" ).toInt(); QwtPainter::drawFrame( painter, canvasRect, canvas->palette(), canvas->foregroundRole(), frameWidth, midLineWidth, frameStyle ); } painter->restore(); } } }
static QVariantList qml_from_dbus(QVariant v) { QVariantList r; const char *type=v.typeName(); switch (v.type()) { case QVariant::ULongLong: r.append("uint64"); r.append(v.toULongLong()); break; case QVariant::UInt: r.append("uint32"); r.append(v.toUInt()); break; case QVariant::Int: r.append("int32"); r.append(v.toInt()); break; case QMetaType::UShort: r.append("uint16"); r.append(v.toUInt()); break; case QMetaType::UChar: r.append("uint8"); r.append(v.toUInt()); break; case QVariant::String: r.append("string"); r.append(v.toString()); break; case QVariant::Bool: r.append("bool"); r.append(v.toBool()); break; case QVariant::Double: r.append("double"); r.append(v.toDouble()); break; case QVariant::UserType: if (!strcmp(type,"QDBusArgument")) { const QDBusArgument arg=v.value < QDBusArgument>(); QVariantList rl; switch(arg.currentType()) { case QDBusArgument::ArrayType: r.append("array"); arg.beginArray(); while (!arg.atEnd()) { rl.append(qml_from_dbus(arg.asVariant())); } r.append(QVariant(rl)); break; case QDBusArgument::StructureType: r.append("structure"); arg.beginStructure(); while (!arg.atEnd()) { rl.append(qml_from_dbus(arg.asVariant())); } arg.endStructure(); r.append(QVariant(rl)); break; case QDBusArgument::MapType: r.append("map"); arg.beginMap(); while (!arg.atEnd()) { arg.beginMapEntry(); rl.append(qml_from_dbus(arg.asVariant())); rl.append(qml_from_dbus(arg.asVariant())); arg.endMapEntry(); } arg.endMap(); r.append(QVariant(rl)); break; case QDBusArgument::UnknownType: break; default: printf("Unknown type %d\n",arg.currentType()); break; } } else if (!strcmp(type,"QDBusVariant")) { const QDBusVariant arg=v.value < QDBusVariant>(); QVariantList rl; r.append("variant"); rl.append(qml_from_dbus(arg.variant())); r.append(QVariant(rl)); } else { printf("User type %s\n",v.typeName()); } break; default: fprintf(stderr,"Unsupported Arg %s(%d)\n",type,v.type()); } return r; }
// write QSettings values bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) { bool successful = true; /* set to false on parse error */ if(role == Qt::EditRole) { QSettings settings; switch(index.row()) { case StartAtStartup: successful = GUIUtil::SetStartOnSystemStartup(value.toBool()); break; case MinimizeToTray: fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; case MapPortUPnP: // core option - can be changed on-the-fly settings.setValue("fUseUPnP", value.toBool()); MapPort(value.toBool()); break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); break; // default proxy case ProxyUse: if (settings.value("fUseProxy") != value) { settings.setValue("fUseProxy", value.toBool()); setRestartRequired(true); } break; case ProxyIP: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrProxy") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port QString strNewValue = value.toString() + ":" + strlIpPort.at(1); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } break; case ProxyPort: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrProxy").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrProxy") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port QString strNewValue = strlIpPort.at(0) + ":" + value.toString(); settings.setValue("addrProxy", strNewValue); setRestartRequired(true); } } break; // separate Tor proxy case ProxyUseTor: if (settings.value("fUseSeparateProxyTor") != value) { settings.setValue("fUseSeparateProxyTor", value.toBool()); setRestartRequired(true); } break; case ProxyIPTor: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed IP if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(0) != value.toString()) { // construct new value from new IP and current port QString strNewValue = value.toString() + ":" + strlIpPort.at(1); settings.setValue("addrSeparateProxyTor", strNewValue); setRestartRequired(true); } } break; case ProxyPortTor: { // contains current IP at index 0 and current port at index 1 QStringList strlIpPort = settings.value("addrSeparateProxyTor").toString().split(":", QString::SkipEmptyParts); // if that key doesn't exist or has a changed port if (!settings.contains("addrSeparateProxyTor") || strlIpPort.at(1) != value.toString()) { // construct new value from current IP and new port QString strNewValue = strlIpPort.at(0) + ":" + value.toString(); settings.setValue("addrSeparateProxyTor", strNewValue); setRestartRequired(true); } } break; #ifdef ENABLE_WALLET case SpendZeroConfChange: if (settings.value("bSpendZeroConfChange") != value) { settings.setValue("bSpendZeroConfChange", value); setRestartRequired(true); } break; #endif case AdvertisedBalance: nAdvertisedBalance = value.toInt(); settings.setValue("nAdvertisedBalance", (int) nAdvertisedBalance); emit advertisedBalanceChanged(nAdvertisedBalance); break; case DisplayUnit: setDisplayUnit(value); break; case DisplayAddresses: bDisplayAddresses = value.toBool(); settings.setValue("bDisplayAddresses", bDisplayAddresses); break; case ThirdPartyTxUrls: if (strThirdPartyTxUrls != value.toString()) { strThirdPartyTxUrls = value.toString(); settings.setValue("strThirdPartyTxUrls", strThirdPartyTxUrls); setRestartRequired(true); } break; case Language: if (settings.value("language") != value) { settings.setValue("language", value); setRestartRequired(true); } break; case DarksendRounds: nDarksendRounds = value.toInt(); settings.setValue("nDarksendRounds", nDarksendRounds); emit darksendRoundsChanged(nDarksendRounds); break; case anonymizeBitcreditAmount: nAnonymizeBitcreditAmount = value.toInt(); settings.setValue("nAnonymizeBitcreditAmount", nAnonymizeBitcreditAmount); emit anonymizeBitcreditAmountChanged(nAnonymizeBitcreditAmount); break; case CoinControlFeatures: fCoinControlFeatures = value.toBool(); settings.setValue("fCoinControlFeatures", fCoinControlFeatures); emit coinControlFeaturesChanged(fCoinControlFeatures); break; case DatabaseCache: if (settings.value("nDatabaseCache") != value) { settings.setValue("nDatabaseCache", value); setRestartRequired(true); } break; case ThreadsScriptVerif: if (settings.value("nThreadsScriptVerif") != value) { settings.setValue("nThreadsScriptVerif", value); setRestartRequired(true); } break; case Listen: if (settings.value("fListen") != value) { settings.setValue("fListen", value); setRestartRequired(true); } break; default: break; } } emit dataChanged(index, index); return successful; }
static bool dbus_iter_append_from_qml(DBusMessageIter *iter, QVariant t, QVariant v) { DBusMessageIter sub; QString type=t.toString(); if (type == "boolean") { dbus_bool_t val=v.toInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val)) return false; } else if (type == "double") { double val=v.toDouble(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_DOUBLE, &val)) return false; } else if (type == "int16") { dbus_int16_t val=v.toInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_INT16, &val)) return false; } else if (type == "int32") { dbus_int32_t val=v.toInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_INT32, &val)) return false; } else if (type == "string") { QByteArray b=v.toString().toUtf8(); const char *val=(const char *)b; if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &val)) return false; } else if (type == "uint8") { char val=v.toUInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &val)) return false; } else if (type == "uint16") { dbus_uint16_t val=v.toUInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &val)) return false; } else if (type == "uint32") { dbus_uint32_t val=v.toUInt(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT32, &val)) return false; } else if (type == "uint64") { dbus_uint64_t val=v.toULongLong(); if (!dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT64, &val)) return false; } else if (type == "variant") { QVariantList va=v.value <QVariantList>(); if (va.size() != 2) { qDebug() << "variant must have 2 elements, not " << va.size(); throw("variant must have 2 elements"); } if (!dbus_message_iter_open_container(iter, DBUS_TYPE_VARIANT, signature_from_qml(va[0],va[1]).toLatin1(), &sub)) return false; if (!dbus_iter_append_from_qml(&sub, va[0], va[1])) return false; if (!dbus_message_iter_close_container(iter, &sub)) return false; } else if (type == "array") { QVariantList a=v.value <QVariantList>(); if (a.size()%2) { qDebug() << "array must have even number of elements, not " << a.size(); throw("array must have even number of elements"); } if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, signature_from_qml(a[0],a[1]).toLatin1(), &sub)) return false; for (int i = 0; i < a.size(); i+=2) { if (!dbus_iter_append_from_qml(&sub, a[i], a[i+1])) return false; } if (!dbus_message_iter_close_container(iter, &sub)) return false; } else if (type == "structure") { QVariantList s=v.value <QVariantList>(); if (s.size()%2) { qDebug() << "structure must have even number of elements, not " << s.size(); throw("structure must have even number of elements"); } /* //scan the structure to build the signature ? to be tested QString signature = QString(DBUS_STRUCT_BEGIN_CHAR); for (int i = 0; i < s.size(); i+=2) { signature += signature_from_qml(s[i],s[i+1]); } signature += QString(DBUS_STRUCT_END_CHAR); */ if (!dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &sub)) return false; for (int i = 0; i < s.size(); i+=2) { if (!dbus_iter_append_from_qml(&sub, s[i], s[i+1])) return false; } if (!dbus_message_iter_close_container(iter, &sub)) return false; } else if (type == "map") { QVariantList m=v.value <QVariantList>(); if (m.size()%4) { qDebug() << "map must have multiple of four elements, not " << m.size(); throw("map must have multiple of four elements"); } if (!dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, ("{"+signature_from_qml(m[0],m[1])+signature_from_qml(m[2],m[3])+"}").toLatin1(), &sub)) return false; for (int i = 0; i < m.size(); i+=4) { DBusMessageIter entry; if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_DICT_ENTRY, NULL, &entry)) return false; if (!dbus_iter_append_from_qml(&entry, m[i], m[i+1])) return false; if (!dbus_iter_append_from_qml(&entry, m[i+2], m[i+3])) return false; if (!dbus_message_iter_close_container(&sub, &entry)) return false; } if (!dbus_message_iter_close_container(iter, &sub)) return false; } else { qDebug() << "append:Unknown type" << type; throw("wrong type"); } return true; }
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; }
bool dspGLTransactions::setParams(ParameterList ¶ms) { if (!display::setParams(params)) return false; bool valid; QVariant param; param = params.value("accnttype_id", &valid); if (valid) { int typid = param.toInt(); QString type; if (typid == 1) type = "A"; else if (typid ==2) type = "E"; else if (typid ==3) type = "L"; else if (typid ==4) type = "Q"; else if (typid ==5) type = "R"; params.append("accntType", type); } param = params.value("source_id", &valid); if (valid) params.append("source", _sources.at(param.toInt())); param = params.value("num_id", &valid); if (valid) { XSqlQuery num; num.prepare("SELECT accnt_number " "FROM accnt " "WHERE (accnt_id=:accnt_id);"); num.bindValue(":accnt_id", params.value("num_id").toInt()); num.exec(); if (num.first()) params.append("accnt_number", num.value("accnt_number").toString()); } param = params.value("accnt_id", &valid); if (valid) { if (_showRunningTotal->isChecked() && _showRunningTotal->isVisible()) { double beginning = 0; QDate periodStart = params.value("startDate").toDate(); XSqlQuery begq; begq.prepare("SELECT " " CASE WHEN accnt_type IN ('A','E') THEN " " trialbal_beginning * -1 " " ELSE trialbal_beginning END AS trialbal_beginning," " period_start " "FROM trialbal " " JOIN accnt ON (trialbal_accnt_id=accnt_id), " " period " "WHERE ((trialbal_period_id=period_id)" " AND (trialbal_accnt_id=:accnt_id)" " AND (:start BETWEEN period_start AND period_end));"); begq.bindValue(":accnt_id", params.value("accnt_id").toInt()); begq.bindValue(":start", params.value("startDate").toDate()); begq.exec(); if (begq.first()) { beginning = begq.value("trialbal_beginning").toDouble(); periodStart = begq.value("period_start").toDate(); } else if (begq.lastError().type() != QSqlError::NoError) { systemError(this, begq.lastError().databaseText(), __FILE__, __LINE__); return false; } XSqlQuery glq; glq.prepare("SELECT CASE WHEN accnt_type IN ('A','E') THEN " " COALESCE(SUM(gltrans_amount),0) * -1" " ELSE COALESCE(SUM(gltrans_amount),0) END AS glamount " "FROM gltrans " " JOIN accnt ON (gltrans_accnt_id=accnt_id) " "WHERE ((gltrans_date BETWEEN :periodstart AND date :querystart - interval '1 day')" " AND (gltrans_accnt_id=:accnt_id)" " AND (NOT gltrans_deleted)) " "GROUP BY accnt_type;"); glq.bindValue(":periodstart", periodStart); glq.bindValue(":querystart", params.value("startDate").toDate()); glq.bindValue(":accnt_id", params.value("accnt_id").toInt()); glq.exec(); if (glq.first()) beginning += glq.value("glamount").toDouble(); else if (glq.lastError().type() != QSqlError::NoError) { systemError(this, glq.lastError().databaseText(), __FILE__, __LINE__); return false; } params.append("beginningBalance", beginning); } } return true; }
void QSpinField::setValue(QVariant value) { spin->setValue(value.toInt()); }
void WebRequester::Private::requestFinished() { QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); QNetworkReply::NetworkError networkError = reply->error(); if (networkError == QNetworkReply::NoError) { QJsonParseError jsonError; QByteArray data = reply->readAll(); QJsonDocument document = QJsonDocument::fromJson(data, &jsonError); if (jsonError.error == QJsonParseError::NoError) { QJsonObject root = document.object(); QString replyError = root.value("error").toString(); if (replyError.isEmpty()) { jsonData = root; if (!response.isNull()) { if (response->fillFromVariant(root.toVariantMap())) { response->finished(); setStatus(WebRequester::Finished); } else { setStatus(WebRequester::Error); } } else { LOG_WARNING("No response object set"); setStatus(WebRequester::Finished); } } else { errorString = replyError; LOG_WARNING(QString("Error from server: %1").arg(errorString)); setStatus(WebRequester::Error); } } else { if (!data.isEmpty()) { errorString = jsonError.errorString(); LOG_WARNING(QString("JsonParseError: %1 (%2)").arg(errorString).arg(QString(data))); setStatus(WebRequester::Error); } else // empty data is okay if no network error occured (= 2xx response code) { if (!response.isNull()) { response->finished(); } setStatus(WebRequester::Finished); } } } else { if (!timer.isActive()) { errorString = tr("Operation timed out"); } else { QVariant statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ); if (statusCode.isValid() && statusCode.toInt() == 401) { errorString = tr("Email or Password wrong"); } else { errorString = reply->errorString(); } QJsonParseError jsonError; QByteArray data = reply->readAll(); QJsonDocument document = QJsonDocument::fromJson(data, &jsonError); if (jsonError.error == QJsonParseError::NoError) { QJsonObject root = document.object(); QString replyError = root.value("error_message").toString(); // in some django replys its error, in some its error_message if (!replyError.isEmpty()) { LOG_WARNING(QString("Error message: %1").arg(replyError)); errorString = replyError; } replyError = root.value("error").toString(); if (!replyError.isEmpty()) { LOG_WARNING(QString("Error message: %1").arg(replyError)); errorString = replyError; } } } setStatus(WebRequester::Error); } // Always stop the timeout timer timer.stop(); reply->deleteLater(); }
void QQmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) { Q_ASSERT(m->as<QQmlValueTypeWrapper>()); ExecutionEngine *v4 = static_cast<QQmlValueTypeWrapper *>(m)->engine(); Scope scope(v4); if (scope.hasException()) return; Scoped<QQmlValueTypeWrapper> r(scope, static_cast<QQmlValueTypeWrapper *>(m)); Scoped<QQmlValueTypeReference> reference(scope, m->d()); int writeBackPropertyType = -1; if (reference) { QMetaProperty writebackProperty = reference->d()->object->metaObject()->property(reference->d()->property); if (!writebackProperty.isWritable() || !reference->readReferenceValue()) return; writeBackPropertyType = writebackProperty.userType(); } const QMetaObject *metaObject = r->d()->propertyCache->metaObject(); const QQmlPropertyData *pd = r->d()->propertyCache->property(name, 0, 0); if (!pd) return; QMetaProperty property = metaObject->property(pd->coreIndex); Q_ASSERT(property.isValid()); if (reference) { QV4::ScopedFunctionObject f(scope, value); if (f) { if (!f->isBinding()) { // assigning a JS function to a non-var-property is not allowed. QString error = QStringLiteral("Cannot assign JavaScript function to value-type property"); ScopedString e(scope, v4->newString(error)); v4->throwError(e); return; } QQmlContextData *context = v4->callingQmlContext(); QQmlPropertyData cacheData; cacheData.setFlags(QQmlPropertyData::IsWritable | QQmlPropertyData::IsValueTypeVirtual); cacheData.propType = writeBackPropertyType; cacheData.coreIndex = reference->d()->property; cacheData.valueTypeFlags = 0; cacheData.valueTypeCoreIndex = pd->coreIndex; cacheData.valueTypePropType = property.userType(); QV4::Scoped<QQmlBindingFunction> bindingFunction(scope, (const Value &)f); bindingFunction->initBindingLocation(); QQmlBinding *newBinding = new QQmlBinding(value, reference->d()->object, context); newBinding->setTarget(reference->d()->object, cacheData); QQmlPropertyPrivate::setBinding(newBinding); return; } else { QQmlPropertyPrivate::removeBinding(reference->d()->object, QQmlPropertyData::encodeValueTypePropertyIndex(reference->d()->property, pd->coreIndex)); } } QVariant v = v4->toVariant(value, property.userType()); if (property.isEnumType() && (QMetaType::Type)v.type() == QMetaType::Double) v = v.toInt(); void *gadget = r->d()->gadgetPtr; property.writeOnGadget(gadget, v); if (reference) { if (writeBackPropertyType == QMetaType::QVariant) { QVariant variantReferenceValue = r->d()->toVariant(); int flags = 0; int status = -1; void *a[] = { &variantReferenceValue, 0, &status, &flags }; QMetaObject::metacall(reference->d()->object, QMetaObject::WriteProperty, reference->d()->property, a); } else { int flags = 0; int status = -1; void *a[] = { r->d()->gadgetPtr, 0, &status, &flags }; QMetaObject::metacall(reference->d()->object, QMetaObject::WriteProperty, reference->d()->property, a); } } }
void QAccessibleAbstractSlider::setCurrentValue(const QVariant &value) { abstractSlider()->setValue(value.toInt()); }