void KexiDBImageBox::updateActionStrings() { if (!m_contextMenu) return; if (designMode()) { /* QString titleString( i18n("Image Box") ); if (!dataSource().isEmpty()) titleString.prepend(dataSource() + " : "); m_contextMenu->changeTitle(m_contextMenu->idAt(0), m_contextMenu->titlePixmap(m_contextMenu->idAt(0)), titleString);*/ } else { //update title in data view mode, based on the data source if (columnInfo()) { KexiImageContextMenu::updateTitle(m_contextMenu, columnInfo()->captionOrAliasOrName(), KexiFormManager::self()->library()->iconName(metaObject()->className())); } } if (m_chooser) { if (popupMenuAvailable() && dataSource().isEmpty()) { //this may work in the future (see @todo below) m_chooser->setToolTip(i18n("Click to show actions for this image box")); } else { QString beautifiedImageBoxName; if (designMode()) { beautifiedImageBoxName = dataSource(); } else { beautifiedImageBoxName = columnInfo() ? columnInfo()->captionOrAliasOrName() : QString(); /*! @todo look at makeFirstCharacterUpperCaseInCaptions setting [bool] (see doc/dev/settings.txt) */ beautifiedImageBoxName = beautifiedImageBoxName[0].toUpper() + beautifiedImageBoxName.mid(1); } m_chooser->setToolTip( i18n("Click to show actions for \"%1\" image box", beautifiedImageBoxName)); } } }
void KexiDBImageBox::handlePasteAction() { if (isReadOnly() || (!designMode() && !hasFocus())) return; QPixmap pm(qApp->clipboard()->pixmap(QClipboard::Clipboard)); if (dataSource().isEmpty()) { //static mode KexiBLOBBuffer::Handle h = KexiBLOBBuffer::self()->insertPixmap(pm); if (!h) return; setData(h); } else { //db-aware mode m_pixmap = pm; QByteArray ba; QBuffer buffer(&ba); buffer.open(IO_WriteOnly); if (m_pixmap.save(&buffer, "PNG")) { // write pixmap into ba in PNG format setValueInternal(ba, true, false/* !loadPixmap */); m_currentScaledPixmap = QPixmap(); // clear cache } else { setValueInternal(QByteArray(), true); } } repaint(); if (!dataSource().isEmpty()) { // emit pixmapChanged(); signalValueChanged(); } }
bool DataMatrix::isValid() const { if (dataSource()) { dataSource()->readLock(); bool fieldValid = dataSource()->matrix().isValid(_field); dataSource()->unlock(); return fieldValid; } return false; }
/** return true if it has a valid file and field, or false otherwise */ bool VScalar::isValid() const { if (dataSource()) { dataSource()->readLock(); bool rc = dataSource()->vector().isValid(_field); dataSource()->unlock(); return rc; } return false; }
/** return the name of the file */ QString VScalar::filename() const { QString rc; if (dataSource()) { dataSource()->readLock(); rc = dataSource()->fileName(); dataSource()->unlock(); } return rc; }
void DataMatrix::reload() { Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED); if (dataSource()) { dataSource()->writeLock(); dataSource()->reset(); dataSource()->unlock(); reset(); } }
void KexiDBImageBox::slotUpdateActionsAvailabilityRequested(bool& valueIsNull, bool& valueIsReadOnly) { valueIsNull = !( (dataSource().isEmpty() && !pixmap().isNull()) /*static pixmap available*/ || (!dataSource().isEmpty() && !this->valueIsNull()) /*db-aware pixmap available*/ ); // read-only if static pixmap or db-aware pixmap for read-only widget: valueIsReadOnly = (!designMode() && dataSource().isEmpty()) || (!dataSource().isEmpty() && isReadOnly()) || (designMode() && !dataSource().isEmpty()); }
/** Update a data Scalar */ void VScalar::internalUpdate() { if (dataSource()) { int f0; if (_f0<0) { f0 = dataSource()->vector().dataInfo(_field).frameCount-1; } else { f0 = _f0; } dataSource()->writeLock(); DataVector::ReadInfo p = {&_value, f0, -1, -1}; dataSource()->vector().read(_field, p); dataSource()->unlock(); } }
void DataMatrix::reset() { // must be called with a lock Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED); if (dataSource()) { const DataInfo info = dataSource()->matrix().dataInfo(_field); _samplesPerFrameCache = info.samplesPerFrame; _invertXHint = info.invertXHint; _invertYHint = info.invertYHint; } resizeZ(0); _NS = 0; _nX = 1; _nY = 0; _resetFieldMetadata(); }
void DataMatrix::changeFile(DataSourcePtr in_file) { Q_ASSERT(myLockStatus() == KstRWLock::WRITELOCKED); if (!in_file) { Debug::self()->log(i18n("Data file for vector %1 was not opened.", Name()), Debug::Warning); } setDataSource(in_file); if (dataSource()) { dataSource()->writeLock(); } reset(); if (dataSource()) { dataSource()->unlock(); } }
QVariant StudentsModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) if (source){ if (source->open(QIODevice::ReadOnly)){ Student st; QDataStream dataSource(source); source->seek(index.row()*sizeof(Student)); dataSource.readRawData(reinterpret_cast<char *>(&st), sizeof(Student)); source->close(); // если файл заполнялся с консоли // понадобится смена кодировки QTextCodec *codec = QTextCodec::codecForName("IBM866"); switch(index.column()){ case Student::Name: return codec->toUnicode(QByteArray(st.name)); case Student::Course: return QString::number(st.cource); case Student::Group: return QString::number(st.group); default: return QVariant(); } } } return QVariant(); }
int main(int argc, char *argv[]) { // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. QApplication app(argc, argv); QQuickView viewer; // The following are needed to make examples run without having to install the module // in desktop environments. #ifdef Q_OS_WIN QString extraImportPath(QStringLiteral("%1/../../../../%2")); #else QString extraImportPath(QStringLiteral("%1/../../../%2")); #endif viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), QString::fromLatin1("qml"))); QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); viewer.setTitle(QStringLiteral("QML Oscilloscope")); DataSource dataSource(&viewer); viewer.rootContext()->setContextProperty("dataSource", &dataSource); viewer.setSource(QUrl("qrc:/qml/qmloscilloscope/main.qml")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.setColor(QColor("#404040")); viewer.show(); return app.exec(); }
void KexiDBImageBox::handleCutAction() { if (!dataSource().isEmpty() && isReadOnly()) return; handleCopyAction(); clear(); }
bool SingleLayerPluginContent::init() { CCDictionary* dataSource(NetworkState::sharedInstance()->getSubDictionary(SL_SERIALIZEKEY_PLUGIN_GLOBAL_SETTINGS)); // plugin information dataSource->setObject(CCString::create( "sample of a single layer implementation" ),SL_SERIALIZEKEY_PLUGIN_INFO_BRIEF); dataSource->setObject(CCString::create( "Nothing special\n" ),SL_SERIALIZEKEY_PLUGIN_INFO_DETAIL); // task information dataSource->setObject(CCString::create( "Nothing special\n" ),SL_SERIALIZEKEY_PLUGIN_TASKS); dataSource->setObject(CCString::create( "Nothing special\n" ),SL_SERIALIZEKEY_PLUGIN_TASK_HINTS); return SLBaseClass::init(); }
void KexiDBImageBox::setDataSource(const QString &ds) { KexiFormDataItemInterface::setDataSource(ds); setData(KexiBLOBBuffer::Handle()); updateActionStrings(); KexiFrame::setFocusPolicy(focusPolicy()); //set modified policy if (m_chooser) { m_chooser->setEnabled(popupMenuAvailable()); if (m_dropDownButtonVisible && popupMenuAvailable()) { m_chooser->show(); } else { m_chooser->hide(); } } // update some properties not changed by user // //! @todo get default line width from global style settings // if (!m_lineWidthChanged) { // KexiFrame::setLineWidth(ds.isEmpty() ? 0 : 1); // } if (!m_paletteBackgroundColorChanged && parentWidget()) { KexiFrame::setPaletteBackgroundColor( dataSource().isEmpty() ? parentWidget()->paletteBackgroundColor() : palette().active().base()); } }
void KexiDBAutoField::setColumnInfoInternal(KexiDB::QueryColumnInfo* cinfo, KexiDB::QueryColumnInfo* visibleColumnInfo) { // change widget type depending on field type if (d->widgetType_property == Auto) { WidgetType newWidgetType = Auto; KexiDB::Field::Type fieldType; if (cinfo) fieldType = visibleColumnInfo->field->type(); else if (dataSource().isEmpty()) fieldType = KexiDB::Field::InvalidType; else fieldType = KexiDB::Field::Text; if (fieldType != KexiDB::Field::InvalidType) { newWidgetType = KexiDBAutoField::widgetTypeForFieldType(fieldType); } if (d->widgetType != newWidgetType || newWidgetType == Auto) { d->widgetType = newWidgetType; createEditor(); } } // update label's text changeText((cinfo && d->autoCaption) ? cinfo->captionOrAliasOrName() : d->caption); KexiFormDataItemInterface *iface = dynamic_cast<KexiFormDataItemInterface*>((QWidget*)subwidget()); if (iface) iface->setColumnInfo(visibleColumnInfo); }
void QgsProjectBadLayerHandler::handleBadLayers( const QList<QDomNode> &layers ) { QgsApplication::messageLog()->logMessage( QObject::tr( "%1 bad layers dismissed:" ).arg( layers.size() ) ); Q_FOREACH ( const QDomNode &layer, layers ) { QgsApplication::messageLog()->logMessage( QObject::tr( " * %1" ).arg( dataSource( layer ) ) ); }
bool KexiDBCheckBox::isTristateInternal() const { if (m_tristate == TristateDefault) return !dataSource().isEmpty(); return m_tristate == TristateOn; }
void QgsAmsLegendFetcher::handleFinished() { // Parse result QJson::Parser parser; bool ok = false; QVariantMap queryResults = parser.parse( mQueryReply, &ok ).toMap(); if ( !ok ) { emit error( QString( "Parsing error at line %1: %2" ).arg( parser.errorLine() ).arg( parser.errorString() ) ); } QgsDataSourceURI dataSource( mProvider->dataSourceUri() ); QList< QPair<QString, QImage> > legendEntries; foreach ( const QVariant& result, queryResults["layers"].toList() ) { QVariantMap queryResultMap = result.toMap(); QString layerId = queryResultMap["layerId"].toString(); if ( layerId != dataSource.param( "layer" ) && !mProvider->subLayers().contains( layerId ) ) { continue; } QVariantList legendSymbols = queryResultMap["legend"].toList(); foreach ( const QVariant& legendEntry, legendSymbols ) { QVariantMap legendEntryMap = legendEntry.toMap(); QString label = legendEntryMap["label"].toString(); if ( label.isEmpty() && legendSymbols.size() == 1 ) label = queryResultMap["layerName"].toString(); QByteArray imageData = QByteArray::fromBase64( legendEntryMap["imageData"].toByteArray() ); legendEntries.append( qMakePair( label, QImage::fromData( imageData ) ) ); } }
QVariant MapBrowserWidget::value() { if (dataSource().isEmpty()){ return serializeData(0.0, 0.0, 1100); } return serializeData(centerLatitude(), centerLongitude(), zoom()); }
QgsAmsProvider::QgsAmsProvider( const QString &uri, const ProviderOptions &options ) : QgsRasterDataProvider( uri, options ) { mLegendFetcher = new QgsAmsLegendFetcher( this ); QgsDataSourceUri dataSource( dataSourceUri() ); const QString authcfg = dataSource.authConfigId(); mServiceInfo = QgsArcGisRestUtils::getServiceInfo( dataSource.param( QStringLiteral( "url" ) ), authcfg, mErrorTitle, mError ); mLayerInfo = QgsArcGisRestUtils::getLayerInfo( dataSource.param( QStringLiteral( "url" ) ) + "/" + dataSource.param( QStringLiteral( "layer" ) ), authcfg, mErrorTitle, mError ); const QVariantMap extentData = mLayerInfo.value( QStringLiteral( "extent" ) ).toMap(); mExtent.setXMinimum( extentData[QStringLiteral( "xmin" )].toDouble() ); mExtent.setYMinimum( extentData[QStringLiteral( "ymin" )].toDouble() ); mExtent.setXMaximum( extentData[QStringLiteral( "xmax" )].toDouble() ); mExtent.setYMaximum( extentData[QStringLiteral( "ymax" )].toDouble() ); mCrs = QgsArcGisRestUtils::parseSpatialReference( extentData[QStringLiteral( "spatialReference" )].toMap() ); if ( !mCrs.isValid() ) { appendError( QgsErrorMessage( tr( "Could not parse spatial reference" ), QStringLiteral( "AMSProvider" ) ) ); return; } const QVariantList subLayersList = mLayerInfo.value( QStringLiteral( "subLayers" ) ).toList(); mSubLayers.reserve( subLayersList.size() ); for ( const QVariant &sublayer : subLayersList ) { mSubLayers.append( sublayer.toMap()[QStringLiteral( "id" )].toString() ); mSubLayerVisibilities.append( true ); } mTimestamp = QDateTime::currentDateTime(); mValid = true; }
bool KexiDBImageBox::popupMenuAvailable() { /*! @todo add kexi-global setting which anyway, allows to show this button (read-only actions like copy/save as/print can be available) */ //chooser button can be only visible when data source is specified return !dataSource().isEmpty(); }
void DataMatrix::_resetFieldStrings() { const QMap<QString, QString> meta_strings = dataSource()->matrix().metaStrings(_field); QStringList fieldStringKeys = _fieldStrings.keys(); // remove field strings that no longer need to exist readLock(); for (int i=0; i<fieldStringKeys.count(); i++) { QString key = fieldStringKeys.at(i); if (!meta_strings.contains(key)) { StringPtr sp = _fieldStrings[key]; _fieldStrings.remove(key); sp = 0L; } } // find or insert strings, to set their value QMapIterator<QString, QString> it(meta_strings); while (it.hasNext()) { it.next(); QString key = it.key(); StringPtr sp; if (!_fieldStrings.contains(key)) { // insert a new one _fieldStrings.insert(key, sp = store()->createObject<String>()); sp->setProvider(this); sp->setSlaveName(key); } else { // find it sp = _fieldStrings[key]; } sp->setValue(it.value()); } unlock(); }
void QgsAmsLegendFetcher::handleFinished() { // Parse result QJsonParseError err; QJsonDocument doc = QJsonDocument::fromJson( mQueryReply, &err ); if ( doc.isNull() ) { emit error( QStringLiteral( "Parsing error:" ).arg( err.errorString() ) ); } QVariantMap queryResults = doc.object().toVariantMap(); QgsDataSourceUri dataSource( mProvider->dataSourceUri() ); QVector< QPair<QString, QImage> > legendEntries; foreach ( const QVariant &result, queryResults["layers"].toList() ) { QVariantMap queryResultMap = result.toMap(); QString layerId = queryResultMap[QStringLiteral( "layerId" )].toString(); if ( layerId != dataSource.param( QStringLiteral( "layer" ) ) && !mProvider->subLayers().contains( layerId ) ) { continue; } QVariantList legendSymbols = queryResultMap[QStringLiteral( "legend" )].toList(); foreach ( const QVariant &legendEntry, legendSymbols ) { QVariantMap legendEntryMap = legendEntry.toMap(); QString label = legendEntryMap[QStringLiteral( "label" )].toString(); if ( label.isEmpty() && legendSymbols.size() == 1 ) label = queryResultMap[QStringLiteral( "layerName" )].toString(); QByteArray imageData = QByteArray::fromBase64( legendEntryMap[QStringLiteral( "imageData" )].toByteArray() ); legendEntries.append( qMakePair( label, QImage::fromData( imageData ) ) ); } }
void DataMatrix::changeFrames(int xStart, int yStart, int xNumSteps, int yNumSteps, bool doAve, bool doSkip, int skip, double minX, double minY, double stepX, double stepY) { KstWriteLocker l(this); commonConstructor(dataSource(), _field, xStart, yStart, xNumSteps, yNumSteps, doAve, doSkip, skip, minX, minY, stepX, stepY); }
void KexiDBAutoField::updateInformationAboutUnboundField() { if ((d->autoCaption && (dataSource().isEmpty() || dataSourcePluginId().isEmpty())) || (!d->autoCaption && d->caption.isEmpty())) { d->label->setText(futureI18nc2("Unbound Auto Field", "%1 (unbound)", objectName())); } }
void KexiDBAutoField::updateInformationAboutUnboundField() { if ((d->autoCaption && (dataSource().isEmpty() || dataSourcePartClass().isEmpty())) || (!d->autoCaption && d->caption.isEmpty())) { d->label->setText(objectName() + " " + i18nc("Unbound Auto Field", " (unbound)")); } }
QString DataMatrix::descriptionTip() const { return i18n( "Data Matrix: %1\n" " %2\n" " Field: %3\n" " %4 x %5" ).arg(Name()).arg(dataSource()->fileName()).arg(field()).arg(_nX).arg(_nY); }
Clock::Clock(QObject *parent) : PlexyDesk::ControllerInterface (parent) { clock = new ClockWidget(QRectF(0, 0, 210, 210)); if (connectToDataSource("timerengine")) { connect(dataSource(), SIGNAL(sourceUpdated(QVariantMap)), this, SLOT(onDataUpdated(QVariantMap))); } }
uint KexiDBImageBox::storedPixmapId() const { if (dataSource().isEmpty() && m_data.stored()) { //not db-aware return m_data.id(); } return 0; }