コード例 #1
0
ファイル: qjsondocument.cpp プロジェクト: ghjinlei/qt5
/*!
 Creates a QJsonDocument from the QVariant \a variant.

 If the \a variant contains any other type than a QVariant::Map,
 QVariant::List or QVariant::StringList, the returned document
 document is invalid.

 \sa toVariant()
 */
QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{
    QJsonDocument doc;
    if (variant.type() == QVariant::Map) {
        doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
    } else if (variant.type() == QVariant::List) {
        doc.setArray(QJsonArray::fromVariantList(variant.toList()));
    } else if (variant.type() == QVariant::StringList) {
        doc.setArray(QJsonArray::fromStringList(variant.toStringList()));
    }
    return doc;
}
コード例 #2
0
QString CurrencyPane::SaveCurrencyHistoryPoint()
{
    QJsonObject point;
    double time = (double)QDateTime(QDate::currentDate()).toTime_t();
    point.insert("value", totalValue);
    point.insert("time", time);

    QByteArray data = QByteArray::fromStdString(app_->data_manager().Get("currency_history"));
    QJsonDocument doc = QJsonDocument::fromJson(data);
    QJsonArray array;
    if (!doc.isNull() && doc.isArray()) {
        array = doc.array();
    }
    bool insert = true;
    for (QJsonValue val : array) {
        if (val.isObject() && val.toObject().value("time").toDouble() == time) {
            insert = false;
            break;
        }
    }
    if (insert) array.append(point);
    doc.setArray(array);

    QString newData = doc.toJson(QJsonDocument::Compact);
    app_->data_manager().Set("currency_history", newData.toStdString());
    LoadCurrencyHistory(newData);
    return newData;
}
コード例 #3
0
void NewWakuSettingsWindow::savePresets()
{
  QStringList dir = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
  if (dir.empty()) {
    mwin->insLog("save directory is not available");
    QMessageBox::information(this, "Viqo", "保存領域がないので保存できません");
    return;
  }

  QJsonArray pages;

  for (int i = 0; i < ui->presetes->count(); ++i) {
    QJsonObject page;
    page["title"] = ui->presetes->itemText(i);
    page["data"] = ui->presetes->itemData(i).toJsonObject();
    pages << page;
  }

  QJsonDocument jsd;
  jsd.setArray(pages);

  QFile file(dir[0] + "/newWakuSettings.json");
  if (!file.open(QIODevice::WriteOnly)) {
    file.close();
    mwin->insLog("opening settings file failed");
    QMessageBox::information(this, "Viqo", "設定ファイルに書き込めません");
    return;
  }
  QTextStream out(&file);
  out << jsd.toJson(QJsonDocument::Compact);
  file.close();
}
コード例 #4
0
ファイル: JSONDataSource.cpp プロジェクト: sjjh/guidev2
void JSONDataSource::save()
{
    if(!isLoaded)
    {
        return;
    }
    
    QJsonDocument doc;
    QJsonArray pupilArray;
    
    for(int i = 0; i < pupils->length();i++)
    {
        pupilArray.append(encodePupil(pupils->at(i)));
    }
    
    doc.setArray(pupilArray);
    
    QFile file(QDir::toNativeSeparators(QDir::homePath())  + "/" + FILENAME);
    if (!file.open(QIODevice::WriteOnly))
    {
        return;
    }
    else
    {        
        file.write(doc.toJson());
        file.close();
    }
}
コード例 #5
0
ファイル: jsonhelper.cpp プロジェクト: RostaTasha/xpiks
    void mergeJson(const QJsonDocument &mergeFrom, QJsonDocument &mergeTo, bool overwrite, CompareValuesJson &comparer) {
        if (mergeFrom.isNull()) {
            LOG_WARNING << "attempted to merge with Null json document";
            return;
        }

        if (overwrite || mergeTo.isNull()) {
            LOG_DEBUG << "Overwriting the document";
            mergeTo = mergeFrom;
        } else {
            if (mergeFrom.isArray()) {
                QJsonArray arrayFrom = mergeFrom.array();
                QJsonArray arrayTo = mergeTo.array();

                if (mergeJsonArrays(arrayFrom, arrayTo, comparer)) {
                    mergeTo.setArray(arrayTo);
                }
            } else {
                QJsonObject objectFrom = mergeFrom.object();
                QJsonObject objectTo = mergeTo.object();

                if (mergeJsonObjects(objectFrom, objectTo, comparer)) {
                    mergeTo.setObject(objectTo);
                }
            }
        }
    }
コード例 #6
0
ファイル: network.cpp プロジェクト: hermixy/Qt5_TCPSocket
void Network::send(QString string)
{
	QJsonDocument doc;
	QJsonArray array;
	array.append(QJsonValue(string));
	doc.setArray(array);
	send(doc);
}
コード例 #7
0
ファイル: iqmeteometar.cpp プロジェクト: 0x6368656174/iqMeteo
QString IqMeteoMetar::textDecorationString() const
{
    QJsonArray textDecorationsArray;
    for (const IqMeteoTextDecoration &textDecoration: m_textDecorations) {
        textDecorationsArray.append(textDecoration.toJson());
    }

    QJsonDocument doc;
    doc.setArray(textDecorationsArray);

    return doc.toJson();
}
コード例 #8
0
static void appendToCacheFile(const QJsonObject& object)
{
    QJsonDocument jsonDocument;
    ReadResult::Tag result = readMetaDataFromCacheFile(jsonDocument);
    if (result == ReadResult::Error)
        return;
    if (result == ReadResult::Empty)
        jsonDocument.setArray(QJsonArray());

    QJsonArray array = jsonDocument.array();
    array.append(object);
    writeToCacheFile(array);
}
コード例 #9
0
ファイル: JsonHelpers.cpp プロジェクト: madmason/q2d
QJsonDocument
q2d::json::exportComponentHierarchy(QStandardItemModel* componentHierarchy) {
    QJsonDocument result = QJsonDocument();
    QJsonArray hierarchy = QJsonArray();

    QStandardItem* rootItem = componentHierarchy->invisibleRootItem();

    for (int rIndex = 0; rIndex < rootItem->rowCount(); ++rIndex) {
        for (int cIndex = 0; cIndex < rootItem->columnCount(); ++cIndex) {
            hierarchy.append(QJsonValue(fromHierarchyEntry(rootItem->child(rIndex, cIndex))));
        }
    }

    result.setArray(hierarchy);
    return result;
}
コード例 #10
0
ファイル: packagejobthread.cpp プロジェクト: KDE/kpackage
bool indexDirectory(const QString& dir, const QString& dest)
{
    QVariantMap vm;
    QVariantMap pluginsVm;
    vm[QStringLiteral("Version")] = QStringLiteral("1.0");
    vm[QStringLiteral("Timestamp")] = QDateTime::currentMSecsSinceEpoch();

    QJsonArray plugins;

    QDirIterator it(dir, *metaDataFiles, QDir::Files, QDirIterator::Subdirectories);
    while (it.hasNext()) {
        it.next();
        const QString path = it.fileInfo().absoluteFilePath();
        QJsonObject obj = KPluginMetaData(path).rawData();
        obj.insert(QStringLiteral("FileName"), path);

        plugins.append(obj);
    }

    // Less than two plugin means it's not worth indexing
    if (plugins.count() < 2) {
        removeIndex(dir);
        return true;
    }

    QString destfile = dest;
    if (!QDir::isAbsolutePath(dest)) {
        destfile = dir + '/' + dest;
    }

    QDir().mkpath(QFileInfo(destfile).dir().absolutePath());
    QFile file(destfile);
    if (!file.open(QIODevice::WriteOnly)) {
        qWarning() << "Failed to open " << destfile;
        return false;
    }

    QJsonDocument jdoc;
    jdoc.setArray(plugins);
//     file.write(jdoc.toJson());
    file.write(jdoc.toBinaryData());
    qWarning() << "Generated " << destfile << " (" << plugins.count() << " plugins)";

    return true;
}
コード例 #11
0
ファイル: reporter.cpp プロジェクト: Antropovi/qreal
void Reporter::reportMessages()
{
	if (!mMessagesFile) {
		return;
	}

	QJsonArray messages;
	for (const QPair<Level, QString> &message : mMessages) {
		messages.append(QJsonObject::fromVariantMap({
			{ "level", message.first == Level::information ? "info" : "error" }
			, { "message", message.second }
		}));
	}

	QJsonDocument document;
	document.setArray(messages);
	report(document.toJson(), mMessagesFile);
}
コード例 #12
0
QString deviceListToJson(QList<DeviceInfo> deviceList)
{
    QJsonArray array;
    for (auto device : deviceList) {
        QJsonObject obj;
        obj.insert("path", device.path);
        obj.insert("label", device.label);
        obj.insert("used", static_cast<int>(device.used));
        obj.insert("total", static_cast<int>(device.total));
        obj.insert("needformat", device.needFormat);
        qDebug() << device.needFormat;
        array.push_back(obj);
    }

    QJsonDocument doc;
    doc.setArray(array);
    return QString::fromUtf8(doc.toJson());
}
コード例 #13
0
QString CurrencyPane::SaveCurrencyRates()
{
    QJsonDocument doc;
    QJsonArray array;
    for (int i = 0; i < ui->currencyTable->rowCount(); i++) {
        QTableWidgetItem* header = ui->currencyTable->verticalHeaderItem(i);

        QWidget* widget = ui->currencyTable->cellWidget(i, 1);
        QSpinBox* currencyBox = widget->findChild<QSpinBox*>("CurrencyCount");
        QSpinBox* chaosBox = widget->findChild<QSpinBox*>("ChaosCount");

        if (currencyBox && chaosBox) {
            QJsonObject obj;
            obj.insert("currency", header->text());
            obj.insert("count", currencyBox->value());
            obj.insert("chaos", chaosBox->value());
            array.append(obj);
        }
    }
    doc.setArray(array);
    return doc.toJson(QJsonDocument::Compact);
}
コード例 #14
0
ファイル: rulelistmodel.cpp プロジェクト: rayfung/excel_json
void RuleListModel::serializeData() const
{
   QJsonDocument doc;
   QJsonArray array;
   QList<RuleData> allRules = getAllRules();

    for(int i = 0; i < allRules.size(); ++i)
    {
        RuleData rule = allRules.at(i);
        QJsonObject data;

        data.insert("enable", rule.isEnabled);
        data.insert("excel_path", rule.excelPath);
        data.insert("json_path", rule.jsonPath);

        array.append(data);
    }
    doc.setArray(array);

    QSettings setting("Ray Fung", "Excel JSON");
    setting.setValue("rule_list", doc.toJson());
}
コード例 #15
0
bool HistoryModel::save(const QString &path) const
{
	if (SessionsManager::isReadOnly())
	{
		return false;
	}

	QSaveFile file(path);

	if (!file.open(QIODevice::WriteOnly))
	{
		return false;
	}

	QJsonArray array;

	for (int i = 0; i < rowCount(); ++i)
	{
		QStandardItem *entry(item(i));

		if (entry)
		{
			QJsonObject object;
			object.insert(QLatin1String("url"), entry->data(UrlRole).toUrl().toString());
			object.insert(QLatin1String("title"), entry->data(TitleRole).toString());
			object.insert(QLatin1String("time"), entry->data(TimeVisitedRole).toDateTime().toString(QLatin1String("yyyy-MM-dd hh:mm:ss")));

			array.prepend(object);
		}
	}

	QJsonDocument document;
	document.setArray(array);

	file.write(document.toJson(QJsonDocument::Indented));

	return file.commit();
}
コード例 #16
0
static PyObject *meth_QJsonDocument_setArray(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        const QJsonArray* a0;
        int a0State = 0;
        QJsonDocument *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "BJ1", &sipSelf, sipType_QJsonDocument, &sipCpp, sipType_QJsonArray,&a0, &a0State))
        {
            sipCpp->setArray(*a0);
            sipReleaseType(const_cast<QJsonArray *>(a0),sipType_QJsonArray,a0State);

            Py_INCREF(Py_None);
            return Py_None;
        }
    }

    /* Raise an exception if the arguments couldn't be parsed. */
    sipNoMethod(sipParseErr, sipName_QJsonDocument, sipName_setArray, doc_QJsonDocument_setArray);

    return NULL;
}
コード例 #17
0
void DataJson::createJson()
{
    QJsonObject ambitCat, ambitEsp, ambitFran;
    QJsonObject ejeCat, ejeEsp,ejeFran;
    QJsonArray ejecutablesCat,ejecutablesEsp,ejecutablesFran;

    //Crear QJsonObject ambitCat
    ambitCat.insert("Nombreambito",QJsonValue(QString("Catalunya lidar 2 metres")));
    ambitCat.insert("Path",QJsonValue(QString(getPathImageMetCat())));
    ambitCat.insert("TamanyoPixel",QJsonValue(int(1)));
    ambitCat.insert("Utm",QJsonValue(int(31)));
    ejeCat.insert("Nombre",QJsonValue(QString("exeExtraction")));
    ejeCat.insert("Path",QJsonValue(QString(getExeExtraction())));
    ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeResize")));
    ejeCat.insert("Path",QJsonValue(QString(getExeResize())));
    ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    ejeCat.insert("Path",QJsonValue(QString(getExeFootPrintMask())));
    ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeSubScene")));
    ejeCat.insert("Path",QJsonValue(QString(getExeSubScene())));
    ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeGeoTransform")));
    ejeCat.insert("Path",QJsonValue(QString(getExeImaOpeGeo())));
    ejecutablesCat.append(ejeCat);
    ambitCat.insert("Ejecutables",ejecutablesCat);

    //Crear QJsonObject ambitEsp
    ambitEsp.insert("Nombreambito",QJsonValue(QString("Espanya 5 metres")));
    ambitEsp.insert("Path",QJsonValue(QString(getPathImageMetEsp())));
    ambitEsp.insert("TamanyoPixel",QJsonValue(int(5)));
    ambitEsp.insert("Utm",QJsonValue(int(30)));
    ejeEsp.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    ejeEsp.insert("Path",QJsonValue(QString(getExeFootPrintMask())));
    ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeResize")));
    ejeEsp.insert("Path",QJsonValue(QString(getExeResize())));
    ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeSubScene")));
    ejeEsp.insert("Path",QJsonValue(QString(getExeSubScene())));
    ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeGeoTransform")));
    ejeEsp.insert("Path",QJsonValue(QString(getExeImaOpeGeo())));
    ejecutablesEsp.append(ejeEsp);
    ambitEsp.insert("Ejecutables",ejecutablesEsp);

    //Crear QJsonObject ambitFran
    ambitFran.insert("Nombreambito",QJsonValue(QString("Francia Farmstar")));
    ambitFran.insert("Path",QJsonValue(QString(getPathImageMetFran())));
    ambitFran.insert("TamanyoPixel",QJsonValue(int(10)));
    ambitFran.insert("Utm",QJsonValue(int(-2)));
    ejeFran.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    ejeFran.insert("Path",QJsonValue(QString(getExeFootPrintMask())));
    ejecutablesFran.append(ejeFran);
    ejeFran.insert("Nombre",QJsonValue(QString("exeResize")));
    ejeFran.insert("Path",QJsonValue(QString(getExeResize())));
    ejecutablesFran.append(ejeFran);
    ejeFran.insert("Nombre",QJsonValue(QString("exeSubScene")));
    ejeFran.insert("Path",QJsonValue(QString(getExeSubScene())));
    ejecutablesFran.append(ejeFran);
    ejeFran.insert("Nombre",QJsonValue(QString("exeResize")));
    ejeFran.insert("Path",QJsonValue(QString(getExeResize())));
    ejecutablesFran.append(ejeFran);
    ambitFran.insert("Ejecutables",ejecutablesFran);

    QJsonArray array;
    array.prepend((ambitCat));
    array.prepend((ambitFran));
    array.prepend((ambitEsp));
    QJsonDocument documento;
    documento.setArray(array);
    QFile documentoTexto;
    QTextStream value;
    QString PathFileJsonDefecto=qApp->applicationDirPath()+"/dataAplicationToolsPcot.txt";
    documentoTexto.setFileName(PathFileJsonDefecto);
    documentoTexto.open(QFile::WriteOnly | QFile::Text);
    value.setDevice(&documentoTexto);
    value << documento.toJson();
}
コード例 #18
0
void DataJson::createJsonStandard()
{
    QJsonObject ambitCat, ambitEsp, ambitFran;
    QJsonObject ejeCat, ejeEsp,ejeFran;
    QJsonArray ejecutablesCat,ejecutablesEsp,ejecutablesFran;

    //Crear QJsonObject ambitCat
    ambitCat.insert("Nombreambito",QJsonValue(QString("Catalunya lidar 2 metres")));
    if(_objectSettingPref->existPathImageCatSett())
    {
        ambitCat.insert("Path",_objectSettingPref->getSettingImageCat());
    }
    else
    {
        ambitCat.insert("Path",QJsonValue(QString("//nas02/treballcompartit/dtmdbdad/BD_CAT2MLID_ET.RF")));
    }
        ambitCat.insert("TamanyoPixel",QJsonValue(int(1)));
    ambitCat.insert("Utm",QJsonValue(int(31)));
    ejeCat.insert("Nombre",QJsonValue(QString("exeExtraction")));
    if(_objectSettingPref->existExeExtraSett())
        {ejeCat.insert("Path",_objectSettingPref->getExeExtraction());}
    else
        {ejeCat.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCDTMOperations/exe/ICCADBDTMEXTRACTIONCONSOLEVERSION.exe")));
    }
            ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeResize")));
    if(_objectSettingPref->existExeResiSett())
        {ejeCat.insert("Path",_objectSettingPref->getExeResize());}
    else
       { ejeCat.insert("Path",QJsonValue(QString("//empuries/PRODUCCIO/DFApplications/ICCImageOperations/exe/ICCImageresize.exe")));
    }
            ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    if(_objectSettingPref->existExeFootPSett())
       { ejeCat.insert("Path",_objectSettingPref->getExeFootPrintMask());}
    else
        {ejeCat.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageFootPrintMask.exe")));
    }
            ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeSubScene")));
    if(_objectSettingPref->existExeSubeSett())
        {ejeCat.insert("Path",_objectSettingPref->getExeSubScene());}
    else
        {ejeCat.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageSubescenes.exe")));
    }
            ejecutablesCat.append(ejeCat);
    ejeCat.insert("Nombre",QJsonValue(QString("exeGeoTransform")));
    if(_objectSettingPref->existExeImaOpeoSett())
        {ejeCat.insert("Path",_objectSettingPref->getExeImaOpeGeo());}
    else
        {ejeCat.insert("Path",QJsonValue(QString("//nas03/geoproces/DFApplications/ICCImageOperationsGeoCorrection/exe/ICCImageGeoTransformation.exe")));
    }
            ejecutablesCat.append(ejeCat);
    ambitCat.insert("Ejecutables",ejecutablesCat);

    //Crear QJsonObject ambitEsp
    ambitEsp.insert("Nombreambito",QJsonValue(QString("Espanya 5 metres")));
    if(_objectSettingPref->existPathImageEspSett())
        {
        ambitEsp.insert("Path",_objectSettingPref->getSettingImageEsp());
    }
    else
       {
        ambitEsp.insert("Path",QJsonValue(QString("//Pedros/Disc_E/Antonio/mosaicMetEspanya.rf")));
    }
    ambitEsp.insert("TamanyoPixel",QJsonValue(int(5)));
    ambitEsp.insert("Utm",QJsonValue(int(30)));
    ejeEsp.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    if(_objectSettingPref->existExeFootPSett())
       { ejeEsp.insert("Path",_objectSettingPref->getExeFootPrintMask());}
    else
        {ejeEsp.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageFootPrintMask.exe")));
    }
            ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeResize")));
    if(_objectSettingPref->existExeResiSett())
       { ejeEsp.insert("Path",_objectSettingPref->getExeResize());}
    else
        {ejeEsp.insert("Path",QJsonValue(QString("//empuries/PRODUCCIO/DFApplications/ICCImageOperations/exe/ICCImageresize.exe")));
    }
            ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeSubScene")));
    if(_objectSettingPref->existExeSubeSett())
       { ejeEsp.insert("Path",_objectSettingPref->getExeSubScene());}
    else
       { ejeEsp.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageSubescenes.exe")));
    }
            ejecutablesEsp.append(ejeEsp);
    ejeEsp.insert("Nombre",QJsonValue(QString("exeGeoTransform")));
    if(_objectSettingPref->existExeImaOpeoSett())
        {ejeEsp.insert("Path",_objectSettingPref->getExeImaOpeGeo());}
    else
        {ejeEsp.insert("Path",QJsonValue(QString("//nas03/geoproces/DFApplications/ICCImageOperationsGeoCorrection/exe/ICCImageGeoTransformation.exe")));
   }
            ejecutablesEsp.append(ejeEsp);
    ambitEsp.insert("Ejecutables",ejecutablesEsp);

    //Crear QJsonObject ambitFran
    ambitFran.insert("Nombreambito",QJsonValue(QString("Francia Farmstar")));
    if(_objectSettingPref->existPathImageFraSett())
       { ambitFran.insert("Path",_objectSettingPref->getSettingImageFran());}
    else
       { ambitFran.insert("Path",QJsonValue(QString("//Pedros/Disc_E/Antonio/MosaicMetFarmstar_NTF_ELIP.rf")));}
    ambitFran.insert("TamanyoPixel",QJsonValue(int(10)));
    ambitFran.insert("Utm",QJsonValue(int(-2)));

    ejeFran.insert("Nombre",QJsonValue(QString("exeFootPrintMask")));
    if(_objectSettingPref->existExeFootPSett())
        {ejeFran.insert("Path",_objectSettingPref->getExeFootPrintMask());}
    else
       { ejeFran.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageFootPrintMask.exe")));
    }
            ejecutablesFran.append(ejeFran);

    ejeFran.insert("Nombre",QJsonValue(QString("exeResize")));
    if(_objectSettingPref->existExeResiSett())
        {ejeFran.insert("Path",_objectSettingPref->getExeResize());}
    else
       { ejeFran.insert("Path",QJsonValue(QString("//empuries/PRODUCCIO/DFApplications/ICCImageOperations/exe/ICCImageresize.exe")));
    }
            ejecutablesFran.append(ejeFran);
    ejeFran.insert("Nombre",QJsonValue(QString("exeSubScene")));
    if(_objectSettingPref->existExeSubeSett())
       { ejeFran.insert("Path",_objectSettingPref->getExeSubScene());}
    else
       { ejeFran.insert("Path",QJsonValue(QString("//nas03/geoproces/dfapplications/ICCImageOperations/exe/ICCImageSubescenes.exe")));
    }
            ejecutablesFran.append(ejeFran);
    ejeFran.insert("Nombre",QJsonValue(QString("exeResize")));
    if(_objectSettingPref->existExeResiSett())
        {ejeFran.insert("Path",_objectSettingPref->getExeResize());}
    else
        {ejeFran.insert("Path",QJsonValue(QString("//empuries/PRODUCCIO/DFApplications/ICCImageOperations/exe/ICCImageresize.exe")));
    }
            ejecutablesFran.append(ejeFran);
    ambitFran.insert("Ejecutables",ejecutablesFran);

    QJsonArray array;
    array.prepend((ambitCat));
    array.prepend((ambitFran));
    array.prepend((ambitEsp));
    QJsonDocument documento;
    documento.setArray(array);
    QFile documentoTexto;
    QTextStream value;
    QString PathFileJsonDefecto=qApp->applicationDirPath()+"/dataAplicationToolsPcot.txt";
    documentoTexto.setFileName(PathFileJsonDefecto);
    documentoTexto.open(QFile::WriteOnly | QFile::Text);
    value.setDevice(&documentoTexto);
    value << documento.toJson();
}
コード例 #19
0
void BookEditDialog::on_btnOk_clicked()  //提交按钮
{

    QString id = ui->idEdit->text().trimmed();
    QString name = ui->nameEdit->text().trimmed();
    QString author = ui->authorEdit->text().trimmed();
    int type = Tool::getInstance()->bookClass[ui->typeBox->currentText()].id;
    QString press = ui->publisherEdit->text().trimmed();
    QString date = ui->dateEdit->date().toString("yyyy-MM-dd");
    if(id==""||name==""||author==""||press==""||ui->priceEdit->text().trimmed()==""||
            ui->pageEdit->text().trimmed()==""||ui->bookCaseEdit->text().trimmed()==""){
        StyleTool::getInstance()->messageBoxError("输入信息不完整!");
    }
    double price = ui->priceEdit->text().trimmed().toDouble();
    int page = ui->pageEdit->text().trimmed().toInt();
    int bookCase = ui->bookCaseEdit->text().trimmed().toInt();
    int num = ui->numLabel->text().toInt();
    QJsonArray array;
    array.append(id);
    array.append(name);
    array.append(type);
    array.append(author);
    array.append(press);
    array.append(date);
    array.append(price);
    array.append(page);
    array.append(bookCase);
    array.append(num);
    if(currentId!="")
    {
        array.append(currentId);
    }
    QJsonDocument document;
    document.setArray(array);
    QString json_str(document.toJson());
    QByteArray postData =  Tool::getInstance()->getRequestData(
                QStringList()<<"data",QStringList()<<json_str);
    QNetworkRequest req;
    if(currentId=="")
        req.setUrl(QUrl(Tool::urlRoot+"book/new"));
    else
        req.setUrl(QUrl(Tool::urlRoot+"book/change"));
    req.setHeader(QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded");
    netManager->post(req,postData);


//    QString sql;
//    if(editType==1){
//        sql = "update 图书 set 书名=:name,图书类型=:type,作者=:author,出版社=:publisher,出版日期=:date,价格=:price,页码=:page,所在书架=:bookCase,馆藏总数=:allNum,在馆数=:nowNum where 图书条形码=:id";
//    }else{
//        sql = "insert into 图书 values(:id,:name,:type,:author,:publisher,:date,:price,:page,:bookCase,:allNum,:nowNum)";
//    }
//    QSqlQuery query(Tool::getInstance()->getDb());
//    query.prepare(sql);
//    query.bindValue(":id",id);
//    query.bindValue(":name",name);
//    query.bindValue(":type",type);
//    query.bindValue(":author",author);
//    query.bindValue(":publisher",publisher);
//    query.bindValue(":date",date);
//    query.bindValue(":price",price);
//    query.bindValue(":page",page);
//    query.bindValue(":bookCase",bookCase);
//    query.bindValue(":allNum",num);
//    if(editType==1)
//        query.bindValue(":nowNum",bookData->nowNum);
//    else
//        query.bindValue(":nowNum",num);
//    query.exec();
//    qDebug()<<query.lastQuery();
//    StyleTool::getInstance()->messageBoxInfo("执行成功!");
//    this->close();
//    done(1);

}