Beispiel #1
0
bool ItemSyncSaver::saveItems(const QString &tabName, const QAbstractItemModel &model, QIODevice *file)
{
    // Don't save items if path is empty.
    if (!m_watcher) {
        writeConfiguration(file, QStringList());
        return true;
    }

    const QString path = m_watcher->path();
    QStringList savedFiles;

    if ( !m_watcher->isValid() ) {
        log( tr("Failed to synchronize tab \"%1\" with directory \"%2\"!")
             .arg(tabName, path),
             LogError );
        return false;
    }

    QDir dir(path);

    for (int row = 0; row < model.rowCount(); ++row) {
        const QModelIndex index = model.index(row, 0);
        const QVariantMap itemData = index.data(contentType::data).toMap();
        const QVariantMap mimeToExtension = itemData.value(mimeExtensionMap).toMap();
        const QString baseName = FileWatcher::getBaseName(index);
        const QString filePath = dir.absoluteFilePath(baseName);

        for (const auto &ext : mimeToExtension)
            savedFiles.prepend( filePath + ext.toString() );
    }

    writeConfiguration(file, savedFiles);

    return true;
}
Beispiel #2
0
manageROM::manageROM(
    unsigned long da,
    unsigned long ma,
    unsigned long dm,
    unsigned long dh,
    unsigned long dhs,
    unsigned long pot,
    unsigned long lot,
    unsigned long lst,
    unsigned long cd,
    unsigned long mi,
    unsigned long hi,
    unsigned long ti,
    unsigned long hmi) {
  DEBUG("Initializing device");
  configuration.initialized = INITIALIZATION_CODE;
  configuration.desiredAirTemp = da;
  configuration.maxAirTemp = da;
  configuration.desiredMoisture = dm;
  configuration.desiredHumidity = dh;
  configuration.pumpOnTime = pot;
  configuration.lightOnTime = lot;
  configuration.lightStartTime = lst;
  configuration.moistureInterval = mi;
  configuration.heightInterval = hi;
  configuration.tempInterval = ti;
  configuration.humidityInterval = hmi;
  writeConfiguration();
}
Beispiel #3
0
void GameSettings::OnClose(wxCloseEvent& event)
{
    int msgRet;
    msgRet = wxMessageBox(_T("You've made changes to the configuration options. Do you want to store these changes?\n")
            _T("If you answer Yes, the previous configuration file will be replaced with the new settings you've selected."),
            _T("Save KeeperFX configuration"), wxYES_NO | wxCANCEL | wxYES_DEFAULT | wxICON_QUESTION, this);
    switch (msgRet)
    {
      case wxYES:      // Save, then quit dialog
          writeConfiguration();
          wxLogMessage(wxT("Configuration saved."));
        break;
      case wxNO:       // Don't save; just quit dialog
          wxLogMessage(wxT("Changed discarded."));
        break;
      case wxCANCEL:   // Do nothing - so don't quit dialog
      default:
        if (event.CanVeto()) {
            event.Veto();     // Notify the calling code that we didn't agreed to quit
            return;
        }
        break;
    }

    GetParent()->Enable(true);

    event.Skip();
    EndModal(1);
}
bool PointCloudFrameGenerator::setParameters(uint32_t left, uint32_t top, uint32_t width, uint32_t height, 
                                             uint32_t rowsToMerge, uint32_t columnsToMerge,
                                             float fx, float fy, float cx, float cy, float k1, float k2, float k3, float p1, float p2)
{
  if(_pointCloudTransform)
  {
    if(_pointCloudTransform->left == left && _pointCloudTransform->top == top &&
      _pointCloudTransform->height == height && _pointCloudTransform->width == width &&
      _pointCloudTransform->rowsToMerge == rowsToMerge && _pointCloudTransform->columnsToMerge == columnsToMerge &&
      _pointCloudTransform->fx == fx && _pointCloudTransform->fy == fy &&
      _pointCloudTransform->cx == cx && _pointCloudTransform->cy == cy &&
      _pointCloudTransform->k1 == k1 && _pointCloudTransform->k2 == k2 && _pointCloudTransform->k3 == k3 &&
      _pointCloudTransform->p1 == p1 && _pointCloudTransform->p2 == p2)
      return true; // No need to change anything
  }
  
  if(left < 0 || top < 0 || height < 0 || width < 0 || rowsToMerge < 0 || columnsToMerge < 0)
  {
    logger(LOG_ERROR) << "PointCloudFrameGenerator: Parameters values are invalid. "
      << "left = " << left << ", "
      << "top = " << top << ", "
      << "width = " << width << ", "
      << "height = " << height << ", "
      << "rowsToMerge = " << rowsToMerge << ", "
      << "columnsToMerge = " << columnsToMerge << std::endl;
    return false;
  }
  
  _pointCloudTransform = Ptr<PointCloudTransform>(new PointCloudTransform(left, top, width, height, rowsToMerge, columnsToMerge, fx, fy, cx, cy, k1, k2, k3, p1, p2));
  return writeConfiguration();
}
Beispiel #5
0
void ExtScript::readConfiguration()
{
    AbstractExtItem::readConfiguration();

    for (int i = directories().count() - 1; i >= 0; i--) {
        if (!QDir(directories().at(i))
                 .entryList(QDir::Files)
                 .contains(fileName()))
            continue;
        QSettings settings(
            QString("%1/%2").arg(directories().at(i)).arg(fileName()),
            QSettings::IniFormat);

        settings.beginGroup(QString("Desktop Entry"));
        setExecutable(settings.value(QString("Exec"), m_executable).toString());
        setPrefix(settings.value(QString("X-AW-Prefix"), m_prefix).toString());
        setStrRedirect(
            settings.value(QString("X-AW-Redirect"), strRedirect()).toString());
        // api == 3
        setFilters(settings.value(QString("X-AW-Filters"), m_filters)
                       .toString()
                       .split(QChar(','), QString::SkipEmptyParts));
        settings.endGroup();
    }

    // update for current API
    if ((apiVersion() > 0) && (apiVersion() < AWESAPI)) {
        qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to"
                           << AWESAPI;
        setApiVersion(AWESAPI);
        writeConfiguration();
    }
}
KisPropertiesConfiguration*  KisHatchingPaintOpSettingsWidget::configuration() const
{
    KisHatchingPaintOpSettings* config = new KisHatchingPaintOpSettings();
    config->setOptionsWidget(const_cast<KisHatchingPaintOpSettingsWidget*>(this));
    config->setProperty("paintop", "hatchingbrush"); // XXX: make this a const id string
    writeConfiguration(config);
    return config;
}
KisPropertiesConfiguration* KisDuplicateOpSettingsWidget::configuration() const
{
    KisDuplicateOpSettings *config = new KisDuplicateOpSettings(0);
    config->setOptionsWidget(const_cast<KisDuplicateOpSettingsWidget*>(this));
    config->setProperty("paintop", "duplicate"); // XXX: make this a const id string
    writeConfiguration(config);
    return config;
}
KisPropertiesConfiguration*  MyPaintSettingsWidget::configuration() const
{
    MyPaintSettings* settings = new MyPaintSettings();
    settings->setOptionsWidget(const_cast<MyPaintSettingsWidget*>(this));
    writeConfiguration(settings);

    settings->dump();
    return settings;
}
Beispiel #9
0
/**
 * @brief destructor of OpenBeaconUSBStrategy class
 * @return
 * 	void
 */
OpenBeaconUSBStrategy::~OpenBeaconUSBStrategy ()
{
	disconnectDevices ();
	writeConfiguration ();

	devices.clear ();
	deviceInfos.clear ();

	if (settings)
		delete (settings);
}
Beispiel #10
0
void
OptionsCont::writeXMLHeader(std::ostream& os) {
    time_t rawtime;
    char buffer [80];

    os << "<?xml version=\"1.0\"" << SUMOSAXAttributes::ENCODING << "?>\n\n";
    time(&rawtime);
    strftime(buffer, 80, "<!-- generated on %c by ", localtime(&rawtime));
    os << buffer << myFullName << "\n";
    writeConfiguration(os, true, false, false);
    os << "-->\n\n";
}
void AbstractExtItem::bumpApi(const int _newVer)
{
    qCDebug(LOG_LIB) << "Bump API using new version" << _newVer;

    // update for current API
    if ((apiVersion() > 0) && (apiVersion() < _newVer)) {
        qCWarning(LOG_LIB) << "Bump API version from" << apiVersion() << "to"
                           << _newVer;
        setApiVersion(_newVer);
        writeConfiguration();
    }
}
void
OptionsCont::writeXMLHeader(std::ostream &os, const bool writeConfig) throw() {
    time_t rawtime;
    char buffer [80];

    os << "<?xml version=\"1.0\"?>\n\n";
    time(&rawtime);
    strftime(buffer, 80, "<!-- generated on %c by ", localtime(&rawtime));
    os << buffer << myFullName << "\n";
    if (writeConfig) {
        writeConfiguration(os, true, false, false);
    }
    os << "-->\n\n";
}
Beispiel #13
0
void updateConfiguration()
{
	if(conf.brewPoint != 0.0f && conf.steamPoint != 0.0f)
	{
		logger.info("Saving configuration");
		writeConfiguration("main.brew_setpoint",conf.brewPoint);
		writeConfiguration("main.steam_setpoint",conf.steamPoint);
		writeConfiguration("main.boiler_offset",conf.offset);
		writeConfiguration("main.p_const",conf.pgain);
		writeConfiguration("main.i_const",conf.igain);
		writeConfiguration("main.d_const",conf.dgain);
		writeConfiguration("commit",0);
	}
	else 
		logger.info("Not updating configuration");
}
Beispiel #14
0
int ExtScript::showConfiguration(const QVariant args)
{
    Q_UNUSED(args)

    ui->lineEdit_name->setText(name());
    ui->lineEdit_comment->setText(comment());
    ui->label_numberValue->setText(QString("%1").arg(number()));
    ui->lineEdit_command->setText(m_executable);
    ui->lineEdit_prefix->setText(m_prefix);
    ui->checkBox_active->setCheckState(isActive() ? Qt::Checked
                                                  : Qt::Unchecked);
    ui->comboBox_redirect->setCurrentIndex(static_cast<int>(m_redirect));
    ui->spinBox_interval->setValue(interval());
    // filters
    ui->checkBox_colorFilter->setCheckState(
        m_filters.contains(QString("color")) ? Qt::Checked : Qt::Unchecked);
    ui->checkBox_linesFilter->setCheckState(
        m_filters.contains(QString("newline")) ? Qt::Checked : Qt::Unchecked);
    ui->checkBox_spaceFilter->setCheckState(
        m_filters.contains(QString("space")) ? Qt::Checked : Qt::Unchecked);

    int ret = exec();
    if (ret != 1)
        return ret;
    setName(ui->lineEdit_name->text());
    setComment(ui->lineEdit_comment->text());
    setNumber(ui->label_numberValue->text().toInt());
    setApiVersion(AWESAPI);
    setExecutable(ui->lineEdit_command->text());
    setPrefix(ui->lineEdit_prefix->text());
    setActive(ui->checkBox_active->checkState() == Qt::Checked);
    setStrRedirect(ui->comboBox_redirect->currentText());
    setInterval(ui->spinBox_interval->value());
    // filters
    updateFilter(QString("color"),
                 ui->checkBox_colorFilter->checkState() == Qt::Checked);
    updateFilter(QString("newline"),
                 ui->checkBox_linesFilter->checkState() == Qt::Checked);
    updateFilter(QString("space"),
                 ui->checkBox_spaceFilter->checkState() == Qt::Checked);

    writeConfiguration();
    return ret;
}
void AbstractExtItem::setNumber(int _number)
{
    qCDebug(LOG_LIB) << "Number" << _number;
    bool generateNumber = (_number == -1);
    if (generateNumber) {
        _number = []() {
            qCWarning(LOG_LIB) << "Number is empty, generate new one";
            // we suppose that currentTIme().msec() is always valid time
            qsrand(static_cast<uint>(QTime::currentTime().msec()));
            int n = qrand() % 1000;
            qCInfo(LOG_LIB) << "Generated number is" << n;
            return n;
        }();
    }

    m_number = _number;
    if (generateNumber)
        writeConfiguration();
}
Beispiel #16
0
std::unique_ptr<TestNode> TestNetwork::startDaemon(const TestNodeConfiguration& cfg) {
  if (!boost::filesystem::exists(cfg.daemonPath)) {
    throw std::runtime_error("daemon binary wasn't found");
  }

  writeConfiguration(cfg.dataDir + "/daemon.conf", cfg);

  Process process;
  std::vector<std::string> daemonArgs = { "--data-dir=" + cfg.dataDir, "--config-file=daemon.conf" };

  if (cfg.testnet) {
    daemonArgs.emplace_back("--testnet");
  }

  process.startChild(cfg.daemonPath, daemonArgs);

  std::unique_ptr<TestNode> node(new RPCTestNode(cfg.rpcPort, m_dispatcher));
  m_daemons.push_back(process);

  return node;
}
Beispiel #17
0
void StreamlineSetup::handleDeliver(char* xml) {
	mxml_node_t *tree;

	// Determine xml type
	tree = mxmlLoadString(NULL, xml, MXML_NO_CALLBACK);
	if (mxmlFindElement(tree, tree, TAG_SESSION, NULL, NULL, MXML_DESCEND_FIRST)) {
		// Session XML
		gSessionData.parseSessionXML(xml);
		sendData(NULL, 0, RESPONSE_ACK);
		logg.logMessage("Received session xml");
	} else if (mxmlFindElement(tree, tree, TAG_CONFIGURATIONS, NULL, NULL, MXML_DESCEND_FIRST)) {
		// Configuration XML
		writeConfiguration(xml);
		sendData(NULL, 0, RESPONSE_ACK);
		logg.logMessage("Received configuration xml");
	} else {
		// Unknown XML
		logg.logMessage("Received unknown XML delivery type");
		sendData(NULL, 0, RESPONSE_NAK);
	}

	mxmlDelete(tree);
}
Beispiel #18
0
void manageROM::reset(void) {
    DEBUG("Resetting ROM");
    configuration.initialized = INITIALIZATION_CODE;
    configuration.desiredAirTemp = DESIRED_AIR_TEMP;
    configuration.maxAirTemp = MAX_AIR_TEMP;
    configuration.desiredMoisture = DESIRED_MOISTURE;
    configuration.desiredHumiditySpread = DESIRED_HUMIDITY_SPREAD;
/*    
    configuration.desiredHumidity = DESIRED_HUMIDITY_FLOWER;
    configuration.lightOnTime = LIGHT_ON_TIME_FLOWER;
    configuration.lightStartTime = LIGHT_START_TIME_FLOWER;
*/    
    configuration.desiredHumidity = DESIRED_HUMIDITY_VEG;
    configuration.lightOnTime = LIGHT_ON_TIME_VEG;
    configuration.lightStartTime = LIGHT_START_TIME_VEG;

    configuration.pumpOnTime = PUMP_ON_TIME;
    configuration.moistureInterval = CHECK_MOISTURE_INTERVAL;
    configuration.heightInterval = CHECK_HEIGHT_INTERVAL;
    configuration.tempInterval = CHECK_TEMP_INTERVAL;
    configuration.humidityInterval = CHECK_HUMIDITY_INTERVAL;
    writeConfiguration();
}
Beispiel #19
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: messageSignal((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 1: checkPage((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: checkPage(); break;
        case 3: cancelcheckPage(); break;
        case 4: httpRequestFinished((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break;
        case 5: httpResponseHeaderReceived((*reinterpret_cast< const QHttpResponseHeader(*)>(_a[1]))); break;
        case 6: httpDataReadProgress((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 7: messageSlot((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2]))); break;
        case 8: setRandomNumbers(); break;
        case 9: clickAdd((*reinterpret_cast< const bool(*)>(_a[1]))); break;
        case 10: clickAdd(); break;
        case 11: clickDelete(); break;
        case 12: setCheckBoxState((*reinterpret_cast< const bool(*)>(_a[1]))); break;
        case 13: showOrHideDrawingFormMenuAction((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: showOrHideDrawingFormMenuAction(); break;
        case 15: showOrHideFormMenuAction((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: showOrHideFormMenuAction(); break;
        case 17: startNewTimer(); break;
        case 18: changeColorAndValue(); break;
        case 19: showAbout(); break;
        case 20: showAboutAction(); break;
        case 21: readConfiguration(); break;
        case 22: writeConfiguration(); break;
        default: ;
        }
        _id -= 23;
    }
    return _id;
}
ColumnarTableWidget::~ColumnarTableWidget() {
  if (m_settings != 0) {
    writeConfiguration();
    delete m_settings;
  }
}
Beispiel #21
0
void manageROM::setPumpOnTime(unsigned long v) {
  configuration.pumpOnTime = v;
  writeConfiguration();
}
Beispiel #22
0
static void cb_Apply(Fl_Button*, void*) {
  writeConfiguration();
  applyConfiguration();
}
Beispiel #23
0
unsigned long manageROM::setHeightInterval(unsigned long v) {
  configuration.heightInterval = v;
  writeConfiguration();
}
Beispiel #24
0
static void cb_OK(Fl_Button*, void*) {
  writeConfiguration();
  applyConfiguration();
  exit(0);
}
Beispiel #25
0
unsigned long manageROM::setMoistureInterval(unsigned long v) {
  configuration.moistureInterval = v;
  writeConfiguration();
}
Beispiel #26
0
bool
OptionsCont::processMetaOptions(bool missingOptions) {
    if (missingOptions) {
        // no options are given
        std::cout << myFullName << std::endl;
        std::cout << " Build features: " << HAVE_ENABLED << std::endl;
        for (std::vector<std::string>::const_iterator it =
                    myCopyrightNotices.begin(); it != myCopyrightNotices.end(); ++it) {
            std::cout << " " << *it << std::endl;
        }
        std::cout << " License GPLv3+: GNU GPL Version 3 or later <http://gnu.org/licenses/gpl.html>\n";
        std::cout << " Use --help to get the list of options." << std::endl;
        return true;
    }

    // check whether the help shall be printed
    if (getBool("help")) {
        std::cout << myFullName << std::endl;
        for (std::vector<std::string>::const_iterator it =
                    myCopyrightNotices.begin(); it != myCopyrightNotices.end(); ++it) {
            std::cout << " " << *it << std::endl;
        }
        printHelp(std::cout);
        return true;
    }
    // check whether the help shall be printed
    if (getBool("version")) {
        std::cout << myFullName << std::endl;
        std::cout << " Build features: " << HAVE_ENABLED << std::endl;
        for (std::vector<std::string>::const_iterator it =
                    myCopyrightNotices.begin(); it != myCopyrightNotices.end(); ++it) {
            std::cout << " " << *it << std::endl;
        }
        std::cout << "\n" << myFullName << " is part of SUMO.\n";
        std::cout << "SUMO is free software: you can redistribute it and/or modify\n";
        std::cout << "it under the terms of the GNU General Public License as published by\n";
        std::cout << "the Free Software Foundation, either version 3 of the License, or\n";
        std::cout << "(at your option) any later version.\n\n";
        std::cout << "This program is distributed in the hope that it will be useful,\n";
        std::cout << "but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
        std::cout << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n";
        std::cout << "GNU General Public License for more details.\n\n";
        std::cout << "You should have received a copy of the GNU General Public License\n";
        std::cout << "along with this program. If not, see http://www.gnu.org/licenses/gpl.html" << std::endl;
        return true;
    }
    // check whether the settings shall be printed
    if (exists("print-options") && getBool("print-options")) {
        std::cout << (*this);
    }
    // check whether something has to be done with options
    // whether the current options shall be saved
    if (isSet("save-configuration", false)) { // sumo-gui does not register these
        if (getString("save-configuration") == "-" || getString("save-configuration") == "stdout") {
            writeConfiguration(std::cout, true, false, getBool("save-commented"));
            return true;
        }
        std::ofstream out(getString("save-configuration").c_str());
        if (!out.good()) {
            throw ProcessError("Could not save configuration to '" + getString("save-configuration") + "'");
        } else {
            writeConfiguration(out, true, false, getBool("save-commented"));
            if (getBool("verbose")) {
                WRITE_MESSAGE("Written configuration to '" + getString("save-configuration") + "'");
            }
            return true;
        }
    }
    // whether the template shall be saved
    if (isSet("save-template", false)) { // sumo-gui does not register these
        if (getString("save-template") == "-" || getString("save-template") == "stdout") {
            writeConfiguration(std::cout, false, true, getBool("save-commented"));
            return true;
        }
        std::ofstream out(getString("save-template").c_str());
        if (!out.good()) {
            throw ProcessError("Could not save template to '" + getString("save-template") + "'");
        } else {
            writeConfiguration(out, false, true, getBool("save-commented"));
            if (getBool("verbose")) {
                WRITE_MESSAGE("Written template to '" + getString("save-template") + "'");
            }
            return true;
        }
    }
    if (isSet("save-schema", false)) { // sumo-gui does not register these
        if (getString("save-schema") == "-" || getString("save-schema") == "stdout") {
            writeSchema(std::cout, getBool("save-commented"));
            return true;
        }
        std::ofstream out(getString("save-schema").c_str());
        if (!out.good()) {
            throw ProcessError("Could not save schema to '" + getString("save-schema") + "'");
        } else {
            writeSchema(out, getBool("save-commented"));
            if (getBool("verbose")) {
                WRITE_MESSAGE("Written schema to '" + getString("save-schema") + "'");
            }
            return true;
        }
    }
    return false;
}
Beispiel #27
0
void manageROM::setLightStartTime(unsigned long v) {
  configuration.lightStartTime = v;
  writeConfiguration();
}
Beispiel #28
0
unsigned long manageROM::setHumidityInterval(unsigned long v) {
  configuration.humidityInterval = v;
  writeConfiguration();
}
Beispiel #29
0
void manageROM::setDesiredHumiditySpread(unsigned long v) {
  configuration.desiredHumiditySpread = v;
  writeConfiguration();
}
Beispiel #30
0
unsigned long manageROM::setTempInterval(unsigned long v) {
  configuration.tempInterval = v;
  writeConfiguration();
}