本文整理汇总了C++中DataModel::load方法的典型用法代码示例。如果您正苦于以下问题:C++ DataModel::load方法的具体用法?C++ DataModel::load怎么用?C++ DataModel::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataModel
的用法示例。
在下文中一共展示了DataModel::load方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stmt
void
UpdateScreen::slotUpdate()
{
QString from = _fromVersion->text();
QString to = _toVersion->currentText();
if (from == to) {
qApp->beep();
QString message = tr("Versions must be different");
QMessageBox::critical(this, tr("Error"), message);
return;
}
// Connect to company database
Driver* driver = Driver::getDriver(_company.dbType());
if (driver == NULL) {
qApp->beep();
QString message = tr("Get driver failed: %1").arg(driver->lastError());
QMessageBox::critical(this, tr("Error"), message);
return;
}
_connection = driver->allocConnection();
if (!_connection->dbaConnect(_company.database())) {
qApp->beep();
QString message = tr("Open company failed: %1")
.arg(_connection->lastError());
QMessageBox::critical(this, tr("Error"), message);
return;
}
ServerConfig config;
config.load();
QString dataDir = parseDir(config.dataDir);
QString version = to;
QValueVector<DataModel> models;
while (true) {
QString filePath = dataDir + "/models/" + version + ".xml";
DataModel model;
if (!model.load(filePath)) {
qApp->beep();
QString message = tr("Failed loading model: %1").arg(filePath);
QMessageBox::critical(this, tr("Error"), message);
return;
}
if (model.fromVersion.isEmpty()) {
qApp->beep();
QString message = tr("Didn't find version: " + from);
QMessageBox::critical(this, tr("Error"), message);
return;
}
models.push_back(model);
version = model.fromVersion;
if (version == from) break;
}
if (models.size() == 0) {
qApp->beep();
QString message = tr("No models found for update use");
QMessageBox::critical(this, tr("Error"), message);
return;
}
QString dbType = _company.dbType();
for (int i = models.size() - 1; i >= 0; --i) {
DataModel& model = models[i];
bool good = true;
QValueVector<UpdateDefn> completed;
for (unsigned int j = 0; j < model.updates.size(); ++j) {
UpdateDefn& update = model.updates[j];
// Only run update if its for All or the right type
if (!update.databases.contains("All"))
if (!update.databases.contains(dbType))
continue;
// Run update commands catching errors
for (unsigned int k = 0; k < update.updateCmds.size(); ++k) {
QString cmd = update.updateCmds[k];
Stmt stmt(_connection, cmd);
if (!stmt.execute()) {
qWarning(stmt.lastError());
good = false;
break;
}
}
completed.push_back(update);
}
// If good then try to run cleanup commands
if (good) {
for (unsigned int j = 0; j < completed.size(); ++j) {
UpdateDefn& update = completed[j];
//.........这里部分代码省略.........