Пример #1
0
void NewForm::slotButtonBoxClicked(QAbstractButton *btn)
{
    switch (m_buttonBox->buttonRole(btn)) {
    case QDialogButtonBox::RejectRole:
        reject();
        break;
    case QDialogButtonBox::ActionRole:
        if (btn != m_recentButton) {
            m_fileName.clear();
            if (m_workbench->actionManager()->openForm(this))
                accept();
        }
        break;
    case QDialogButtonBox::AcceptRole: {
        QString errorMessage;
        if (openTemplate(&errorMessage)) {
            accept();
        }  else {
            QMessageBox::warning(this, tr("Read error"), errorMessage);
        }
    }
        break;
    default:
        break;
    }
}
Пример #2
0
void Cache::update() {
	AllocStack::perform([&] {
		_mutex.lock();
		for (auto &it : _templates) {
			auto mtime = filesystem::mtime(it.first);
			if (mtime != it.second->getMtime()) {
				it.second->release();
				it.second = openTemplate(it.first);
			}
		}
		_mutex.unlock();
	});
}
Пример #3
0
FirstPage::FirstPage(QWidget *parent)
{
	ui.setupUi(this);

	QButtonGroup* btnGroup = new QButtonGroup(this);

	btnGroup->addButton(ui.btn_create);
	btnGroup->addButton(ui.btn_modify);
	ui.btn_create->setChecked(true);

	connect(ui.btnOpen,SIGNAL(clicked()),this,SLOT(openTemplate()));

	registerField("create",ui.btn_create);
	registerField("modify",ui.btn_modify);
	registerField("folder",ui.editFolder);
}
bool DecoderFeatureIndex::open(const Param &param) {
  const std::string modelfile = param.get<std::string>("model");

  CHECK_FALSE(mmap_.open(modelfile.c_str())) << mmap_.what();

  const char *ptr = mmap_.begin();
  unsigned int maxid;
  read_static<unsigned int>(&ptr, maxid);
  maxid_ = static_cast<size_t>(maxid);
  alpha_ = reinterpret_cast<const double *>(ptr);
  ptr += (sizeof(alpha_[0]) * maxid_);
  da_.set_array(reinterpret_cast<void *>(const_cast<char *>(ptr)));

  if (!openTemplate(param)) {
    close();
    return false;
  }

  return true;
}
Пример #5
0
FileRef *Cache::acquireTemplate(const String &path, Request &req) {
	FileRef *tpl = nullptr;

	_mutex.lock();

	auto it = _templates.find(path);
	if (it != _templates.end()) {
		tpl = it->second;
	} else {
		tpl = openTemplate(path);
		AllocStack::perform([&] {
			_templates.emplace(String(path), tpl);
		}, _pool);
	}

	if (tpl) {
		tpl->retain(req);
	}
	_mutex.unlock();

	return tpl;
}
bool EncoderFeatureIndex::open(const Param &param) {
  return openTemplate(param);
}
Пример #7
0
bool EncoderFeatureIndex::open(const char *template_filename,
                               const char *train_filename) {
  check_max_xsize_ = true;
  return openTemplate(template_filename) && openTagSet(train_filename);
}