本文整理汇总了C++中ConnectionSettings::setEventName方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionSettings::setEventName方法的具体用法?C++ ConnectionSettings::setEventName怎么用?C++ ConnectionSettings::setEventName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionSettings
的用法示例。
在下文中一共展示了ConnectionSettings::setEventName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveSettings
void ConnectDbDialogWidget::saveSettings()
{
ConnectionSettings settings;
settings.setEventName(ui->edEventName->text());
settings.setConnectionType(static_cast<Event::EventPlugin::ConnectionType>(ui->tabWidget->currentIndex()));
settings.setServerHost(ui->edServerHost->text());
settings.setServerPort(ui->edServerPort->value());
settings.setServerUser(ui->edServerUser->text());
settings.setServerPassword(ui->edServerPassword->text());
settings.setSingleWorkingDir(ui->edSingleWorkingDir->text());
}
示例2: openEvent
bool EventPlugin::openEvent(const QString &_event_name)
{
closeEvent();
//return true;
qff::MainWindow *fwk = qff::MainWindow::frameWork();
QString event_name = _event_name;
ConnectionSettings connection_settings;
ConnectionType connection_type = connection_settings.connectionType();
//console.debug("openEvent()", "event_name:", event_name, "connection_type:", connection_type);
bool ok = false;
if(connection_type == ConnectionType::SqlServer) {
//console.debug(db);
QStringList event_names = existingSqlEventNames();
if(!event_names.contains(event_name))
event_name = QString();
ok = !event_name.isEmpty();
if(!ok) {
event_name = QInputDialog::getItem(fwk, tr("Query"), tr("Open event"), event_names, 0, false, &ok);
}
//Log.info(event_name, typeof event_name, (event_name)? "T": "F");
ok = ok && !event_name.isEmpty();
if(ok) {
qfs::Connection conn(QSqlDatabase::database());
if(conn.setCurrentSchema(event_name)) {
ConnectionSettings settings;
settings.setEventName(event_name);
ok = true;
}
}
}
else if(connection_type == ConnectionType::SingleFile) {
QString event_fn;
if(!event_name.isEmpty()) {
event_fn = eventNameToFileName(event_name);
if(!QFile::exists(event_fn)) {
event_fn = event_name = QString();
}
}
if(event_name.isEmpty()) {
QStringList event_names = existingFileEventNames(connection_settings.singleWorkingDir());
event_name = QInputDialog::getItem(fwk, tr("Query"), tr("Open event"), event_names, 0, false, &ok);
//event_fn = qfd::FileDialog::getOpenFileName(fwk, tr("Select event"), connection_settings.singleWorkingDir(), tr("Quick Event files (*%1)").arg(qbe_ext));
if(ok && !event_name.isEmpty()) {
event_fn = eventNameToFileName(event_name);
}
}
//Log.info(event_name, typeof event_name, (event_name)? "T": "F");
{
QString conn_name;
{
qfs::Connection conn(QSqlDatabase::database());
conn_name = conn.connectionName();
conn.close();
}
qfInfo() << "removing database:" << conn_name;
QSqlDatabase::removeDatabase(conn_name);
QSqlDatabase::addDatabase("QSQLITE");
}
if(event_fn.isEmpty()) {
ok = false;
}
else {
if(QFile::exists(event_fn)) {
qfs::Connection conn(QSqlDatabase::database());
conn.setDatabaseName(event_fn);
qfInfo() << "Opening database file" << event_fn;
if(conn.open()) {
qfs::Query q(conn);
ok = q.exec("PRAGMA foreign_keys=ON");
}
else {
qfd::MessageBox::showError(fwk, tr("Open Database Error: %1").arg(conn.errorString()));
}
}
else {
qfd::MessageBox::showError(fwk, tr("Database file %1 doesn't exist.").arg(event_fn));
}
}
}
else {
qfError() << "Invalid connection type:" << static_cast<int>(connection_type);
}
if(ok) {
eventConfig(true);
connection_settings.setEventName(event_name);
setEventName(event_name);
emit eventOpened(eventName());
//emit reloadDataRequest();
}
return ok;
}