void CalculateAmplitudes::filterView(int startRow, int cnt) { bool showSuccess = _ui.comboFilterState->currentIndex() == 1; bool showErrors = _ui.comboFilterState->currentIndex() == 2; bool showProgress = _ui.comboFilterState->currentIndex() == 3; QString type = _ui.comboFilterType->currentIndex() == 0?"":_ui.comboFilterType->currentText(); int endRow; if ( cnt < 0 ) endRow = _ui.table->rowCount(); else endRow = startRow + cnt; for ( int i = startRow; i < endRow; ++i ) { bool hide = false; if ( showSuccess ) { QProgressBar *progressBar = static_cast<QProgressBar*>(_ui.table->cellWidget(i, 3)); QTableWidgetItem *item = _ui.table->item(i, 3); if ( progressBar != NULL && progressBar->value() < 100 ) hide = true; else if ( item && item->data(Qt::UserRole) == 1 ) hide = true; } if ( showErrors ) { QTableWidgetItem *item = _ui.table->item(i, 3); if ( _ui.table->cellWidget(i, 3) != NULL || (item && item->data(Qt::UserRole) != 1) ) hide = true; } if ( showProgress ) { QProgressBar *progressBar = static_cast<QProgressBar*>(_ui.table->cellWidget(i, 3)); QTableWidgetItem *item = _ui.table->item(i, 3); if ( progressBar == NULL || progressBar->value() == 100 ) hide = true; else if ( item && item->data(Qt::UserRole) == 1 ) hide = true; } if ( !type.isEmpty() ) { if ( _ui.table->item(i, 1)->text() != type ) hide = true; } if ( hide ) _ui.table->hideRow(i); else _ui.table->showRow(i); } }
void ConnectionChecker::timeOut() { i++; if( i > 5000 ) { ui->statusLabel->setText( "No Data Recieved, Change Port" ); timer->stop(); } QProgressBar* bar = ui->statusBar; bar->setValue(bar->value()+1); if( bar->value() > 99 ) bar->setValue(0); }
void dataBase::fillFromJson(const QString &path) { QProgressBar bar; bar.show(); QFile file(path); if(!file.open(QFile::ReadOnly)) { throw std::runtime_error(("No file "+ path).toStdString()); } bool ok = false; QVariantMap map = QtJson::parse(QString::fromUtf8(file.readAll().data()), ok).toMap(); if(!ok) { throw std::runtime_error(("Cant parse "+ path).toStdString()); } for(QVariantMap::const_iterator it = map.begin(); it != map.end(); ++it) { QList<QVariant> list = it.value().toList(); for(QList<QVariant>::const_iterator list_it = list.begin(); list_it != list.end(); ++list_it) { bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1); qApp->processEvents(); QList<QVariant> values = list_it->toList(); QString q_text = QString("INSERT INTO %1 ( coeff, hrn ) VALUES ( '%2', '%3' )") .arg(it.key()) .arg(values.at(0).toString()) .arg(values.at(1).toString()); query(q_text); } } QList<QVariant> regions = map["regions"].toList(); for(QList<QVariant>::const_iterator it = regions.begin(); it!= regions.end(); ++it ) { QList<QVariant> towns = it->toList().at(2).toList(); for(QList<QVariant>::const_iterator town_it = towns.begin(); town_it != towns.end(); ++town_it ) { bar.setValue(bar.value() >= bar.maximum() ? 0 : bar.value()+1); qApp->processEvents(); QList<QVariant> town_desc = town_it->toList(); QString q_text = QString("INSERT INTO towns VALUES ( %1, '%2', %3, %4, %5)") .arg(town_desc.at(0).toInt()) .arg(town_desc.at(1).toString()) .arg(town_desc.at(2).toString()) .arg(town_desc.at(3).toString()) .arg(it->toList().at(0).toInt()); query(q_text); } } bar.close(); }
/** * Sets a new value to the progress bar. * If the new value is non-zero, the progress bar is advanced. Otherwise, the * idle timer is initiated to display a busy indicator. * @param nValue The new value to set. */ void ProgressDlg::setValue(int nValue) { QProgressBar* pProgress; pProgress = progressBar(); if (nValue != 0) { // Do nothing if the value hasn't changed if (nValue == pProgress->value()) return; // Handle first non-zero value if (m_nIdleValue >= 0) { m_pIdleTimer->stop(); m_nIdleValue = -1; pProgress->setTextVisible(true); } // Set the new value pProgress->setValue(nValue); } else if (m_nIdleValue == -1) { // Handle first 0 value pProgress->setValue(0); pProgress->setTextVisible(false); m_nIdleValue = 0; m_pIdleTimer->start(200); } }
void XXPortManager::slotImportJobDone( KJob * ) { if ( !mImportProgressDialog ) { return; } QProgressBar *progressBar = mImportProgressDialog->progressBar(); progressBar->setValue( progressBar->value() + 1 ); // cleanup on last step if ( progressBar->value() == progressBar->maximum() ) { mImportProgressDialog->deleteLater(); mImportProgressDialog = 0; } }
void BackupDialog::backup() { QDir dir; // Compute a default file name & path (eg. "Baskets_2007-01-31.tar.gz"): KConfig *config = KGlobal::config().data(); KConfigGroup configGroup(config, "Backups"); QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/"; QString fileName = i18np("Backup filename (without extension), %1 is the date", "Baskets_%1", QDate::currentDate().toString(Qt::ISODate)); QString url = folder + fileName; // Ask a file name & path to the user: QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); QString destination = url; for (bool askAgain = true; askAgain;) { // Ask: destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Backup Baskets")); // User canceled? if (destination.isEmpty()) return; // File already existing? Ask for overriding: if (dir.exists(destination)) { int result = KMessageBox::questionYesNoCancel( 0, "<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?", KUrl(destination).fileName()), i18n("Override File?"), KGuiItem(i18n("&Override"), "document-save") ); if (result == KMessageBox::Cancel) return; else if (result == KMessageBox::Yes) askAgain = false; } else askAgain = false; } KProgressDialog dialog(0, i18n("Backup Baskets"), i18n("Backing up baskets. Please wait...")); dialog.setModal(true); dialog.setAllowCancel(false); dialog.setAutoClose(true); dialog.show(); QProgressBar *progress = dialog.progressBar(); progress->setRange(0, 0/*Busy/Undefined*/); progress->setValue(0); progress->setTextVisible(false); BackupThread thread(destination, Global::savesFolder()); thread.start(); while (thread.isRunning()) { progress->setValue(progress->value() + 1); // Or else, the animation is not played! kapp->processEvents(); usleep(300); // Not too long because if the backup process is finished, we wait for nothing } Settings::setLastBackup(QDate::currentDate()); Settings::saveConfig(); populateLastBackup(); }
void inc_progress_bar(int, int, void *p) { QProgressBar *bar = (QProgressBar *)p; int value = bar->value(); if (value == bar->maximum()) { bar->reset(); } else { bar->setValue(value +1); } }
ProgressUI::ProgressUI(QWidget *parent) : THWidgetBase(parent) { timerId = -1; gradient = 0; hideTitleBar(); setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool); setWindowModality(Qt::ApplicationModal); QVBoxLayout *v = new QVBoxLayout(this); v->setContentsMargins(5, 5, 5, 5); v->setSpacing(0); lbl = new QLabel(this); lbl->setStyleSheet(QStringLiteral("font-family:΢ÈíÑźÚ;font:12px;color:white;")); QProgressBar *pbar = new QProgressBar(this); pbar->setRange(0, 100); pbar->setValue(0); pbar->setFixedSize(260, 12); QFile file; file.setFileName(":res/css/progressbar.css"); if (file.open(QIODevice::ReadOnly)) { QByteArray ba = file.readAll(); pbar->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba)); } file.close(); v->addWidget(lbl, 1, Qt::AlignCenter); v->addWidget(pbar, 1, Qt::AlignCenter); setFixedSize(280, 50); connect(this, &ProgressUI::setValue, pbar, [=] (int value) { pbar->setValue(value); if (pbar->value() >= 100) { lbl->setText(QStringLiteral("Íê³É")); emit execFinished(); QTimer::singleShot(1000, this, [=] () { disconnect(this, 0, 0, 0); this->close(); this->deleteLater(); }); } }); timerId = startTimer(60/*, Qt::VeryCoarseTimer*/); }
int main(int argc, char **argv) { int p = 0; toConfigurationNew::setQSettingsEnv(); QApplication app(argc, argv); qRegisterMetaType<toQColumnDescriptionList>("toQColumnDescriptionList&"); qRegisterMetaType<ValuesList>("ValuesList&"); qRegisterMetaType<toConnection::exception>("toConnection::exception"); try { toSplash splash(NULL); splash.show(); QList<QString> plugins; // List of all connection provider finders std::vector<std::string> finders = ConnectionProviderFinderFactory::Instance().keys(); // Resulting list of all the providers found toProvidersList &allProviders = toProvidersListSing::Instance(); QProgressBar *progress = splash.progress(); QLabel *label = splash.label(); progress->setRange(1, plugins.size() + finders.size()*2); qApp->processEvents(); Q_FOREACH(QString path, plugins) { label->setText(qApp->translate("main", "Loading plugin %1").arg(path)); qApp->processEvents(); bool success = false; try { QLibrary library(path); success = library.load(); } TOCATCH; if (success) { label->setText(qApp->translate("main", "Loaded plugin %1").arg(path)); TLOG(5, toDecoratorNC, __HERE__) << "Loaded plugin " << path << std::endl; } else { label->setText(qApp->translate("main", "Failed loading plugin %1").arg(path)); TLOG(5, toDecoratorNC, __HERE__) << "Failed loading plugin " << path << std::endl; } progress->setValue(progress->value()+1); qApp->processEvents(); } // Loop over all finders and call their "find" method, each of them can return several locations for (std::vector<std::string>::const_iterator i = finders.begin(); i != finders.end(); ++i) { QString finderName(i->c_str()); label->setText(qApp->translate("main", "Looking for %1").arg(finderName)); qApp->processEvents(); TLOG(5, toDecoratorNC, __HERE__) << "Looking for client: " << *i << std::endl; try { std::unique_ptr<toConnectionProviderFinder> finder = ConnectionProviderFinderFactory::Instance().create(*i, 0); QList<toConnectionProviderFinder::ConnectionProvirerParams> l = finder->find(); allProviders.append(l); finderName = finder->name(); } TOCATCH; progress->setValue(progress->value()+1); qApp->processEvents(); } // Loop over all providers found and try to load desired Oracle client // 1st try to load requested Oracle client(if set) then load thick(TNS) Oracle client QDir oHome = toConfigurationNewSingle::Instance().option(ToConfiguration::Global::OracleHomeDirectory).toString(); Q_FOREACH(toConnectionProviderFinder::ConnectionProvirerParams const& params, allProviders) { QString providerName = params.value("PROVIDER").toString(); if ( params.value("PROVIDER").toString() != ORACLE_PROVIDER) continue; QDir pHome(params.value("ORACLE_HOME").toString()); if (oHome != pHome) continue; try { label->setText(qApp->translate("main", "Loading provider %1").arg(providerName)); qApp->processEvents(); TLOG(5, toDecoratorNC, __HERE__) << "Loading: " << params.value("PATH").toString() << std::endl; toConnectionProviderRegistrySing::Instance().load(params); progress->setValue(progress->value()+1); qApp->processEvents(); break; } TOCATCH; }
void MetaEditorSupportPlugin::generateEditorWithQrmc() { qrmc::MetaCompiler metaCompiler(*mLogicalRepoApi, "."); IdList const metamodels = mLogicalRepoApi->children(Id::rootId()); QProgressBar *progress = new QProgressBar(mMainWindowInterface->windowWidget()); progress->show(); int const progressBarWidth = 240; int const progressBarHeight = 20; QApplication::processEvents(); QRect const screenRect = qApp->desktop()->availableGeometry(); progress->move(screenRect.width() / 2 - progressBarWidth / 2, screenRect.height() / 2 - progressBarHeight / 2); progress->setFixedWidth(progressBarWidth); progress->setFixedHeight(progressBarHeight); progress->setRange(0, 100); int forEditor = 60 / metamodels.size(); foreach (Id const &key, metamodels) { QString const objectType = key.element(); if (objectType == "MetamodelDiagram" && mLogicalRepoApi->isLogicalElement(key)) { QString nameOfTheDirectory = mLogicalRepoApi->stringProperty(key, "name of the directory"); QString nameOfMetamodel = mLogicalRepoApi->stringProperty(key, "name"); QString nameOfPlugin = nameOfTheDirectory.split("/").last(); if (QMessageBox::question(mMainWindowInterface->windowWidget() , tr("loading..") , QString(tr("Do you want to compile and load editor %1?")).arg(nameOfPlugin) , QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { continue; } progress->setValue(5); const QString normalizedName = nameOfMetamodel.at(0).toUpper() + nameOfMetamodel.mid(1); const bool stateOfLoad = mMainWindowInterface->pluginLoaded(normalizedName); if (!mMainWindowInterface->unloadPlugin(normalizedName)) { progress->close(); delete progress; return; } if (!metaCompiler.compile(nameOfMetamodel)) { // generating source code for all metamodels QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("error") , tr("Cannot generate source code for editor ") + nameOfPlugin); continue; } progress->setValue(20); QStringList qmakeArgs; qmakeArgs.append("CONFIG+=" + mLogicalRepoApi->stringProperty(key, "buildConfiguration")); qmakeArgs.append(nameOfMetamodel + ".pro"); QProcess builder; builder.setWorkingDirectory(nameOfTheDirectory); const QStringList environment = QProcess::systemEnvironment(); builder.setEnvironment(environment); builder.start(SettingsManager::value("pathToQmake").toString(), qmakeArgs); qDebug() << "qmake"; if ((builder.waitForFinished()) && (builder.exitCode() == 0)) { progress->setValue(40); builder.start(SettingsManager::value("pathToMake").toString()); bool finished = builder.waitForFinished(100000); qDebug() << "make"; if (finished && (builder.exitCode() == 0)) { if (stateOfLoad) { QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("Attention!"), tr("Please restart QReal.")); progress->close(); delete progress; return; } qDebug() << "make ok"; progress->setValue(progress->value() + forEditor / 2); if (!nameOfMetamodel.isEmpty()) { if (!mMainWindowInterface->unloadPlugin(normalizedName)) { QMessageBox::warning(mMainWindowInterface->windowWidget() , tr("error") , tr("cannot unload plugin ") + normalizedName); progress->close(); delete progress; continue; } } QString suffix = ""; if (mLogicalRepoApi->stringProperty(key, "buildConfiguration") == "debug") { suffix = "-d"; } QString const generatedPluginFileName = SettingsManager::value("prefix").toString() + nameOfMetamodel + suffix + "." + SettingsManager::value("pluginExtension").toString() ; if (mMainWindowInterface->loadPlugin(generatedPluginFileName, normalizedName)) { progress->setValue(progress->value() + forEditor / 2); } } progress->setValue(100); } } }
void BackupDialog::restore() { // Get last backup folder: KConfig *config = KGlobal::config().data(); KConfigGroup configGroup(config, "Backups"); QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/"; // Ask a file name to the user: QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files"); QString path = KFileDialog::getOpenFileName(folder, filter, this, i18n("Open Basket Archive")); if (path.isEmpty()) // User has canceled return; // Before replacing the basket data folder with the backup content, we safely backup the current baskets to the home folder. // So if the backup is corrupted or something goes wrong while restoring (power cut...) the user will be able to restore the old working data: QString safetyPath = Backup::newSafetyFolder(); FormatImporter copier; copier.moveFolder(Global::savesFolder(), safetyPath); // Add the README file for user to cancel a bad restoration: QString readmePath = safetyPath + i18n("README.txt"); QFile file(readmePath); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << i18n("This is a safety copy of your baskets like they were before you started to restore the backup %1.", KUrl(path).fileName()) + "\n\n" << i18n("If the restoration was a success and you restored what you wanted to restore, you can remove this folder.") + "\n\n" << i18n("If something went wrong during the restoration process, you can re-use this folder to store your baskets and nothing will be lost.") + "\n\n" << i18n("Choose \"Basket\" -> \"Backup & Restore...\" -> \"Use Another Existing Folder...\" and select that folder.") + "\n"; file.close(); } QString message = "<p><nobr>" + i18n("Restoring <b>%1</b>. Please wait...", KUrl(path).fileName()) + "</nobr></p><p>" + i18n("If something goes wrong during the restoration process, read the file <b>%1</b>.", readmePath); KProgressDialog *dialog = new KProgressDialog(0, i18n("Restore Baskets"), message); dialog->setModal(/*modal=*/true); dialog->setAllowCancel(false); dialog->setAutoClose(true); dialog->show(); QProgressBar *progress = dialog->progressBar(); progress->setRange(0, 0/*Busy/Undefined*/); progress->setValue(0); progress->setTextVisible(false); // Uncompress: RestoreThread thread(path, Global::savesFolder()); thread.start(); while (thread.isRunning()) { progress->setValue(progress->value() + 1); // Or else, the animation is not played! kapp->processEvents(); usleep(300); // Not too long because if the restore process is finished, we wait for nothing } dialog->hide(); // The restore is finished, do not continue to show it while telling the user the application is going to be restarted delete dialog; // If we only hidden it, it reappeared just after having restored a small backup... Very strange. dialog = 0; // This was annoying since it is modal and the "BasKet Note Pads is going to be restarted" message was not reachable. //kapp->processEvents(); // Check for errors: if (!thread.success()) { // Restore the old baskets: QDir dir; dir.remove(readmePath); copier.moveFolder(safetyPath, Global::savesFolder()); // Tell the user: KMessageBox::error(0, i18n("This archive is either not a backup of baskets or is corrupted. It cannot be imported. Your old baskets have been preserved instead."), i18n("Restore Error")); return; } // Note: The safety backup is not removed now because the code can has been wrong, somehow, or the user perhapse restored an older backup by error... // The restore process will not be called very often (it is possible it will only be called once or twice arround the world during the next years). // So it is rare enough to force the user to remove the safety folder, but keep him in control and let him safely recover from restoration errors. Backup::setFolderAndRestart(Global::savesFolder()/*No change*/, i18n("Your backup has been successfuly restored to <b>%1</b>. %2 is going to be restarted to take this change into account.")); }
QWidget* WidgetStyle::createWidget(const QString& name) { if(name == "CheckBox") { QCheckBox* box = new QCheckBox("CheckBox"); box->setObjectName("CheckBox"); return setLayoutWidget({ box }, { 100, 30 }); } else if(name == "ComboBox") { QComboBox* box = new QComboBox; box->addItem("Item1"); box->addItem("Item3"); box->addItem("Item3"); box->setObjectName("ComboBox"); return setLayoutWidget({ box }, { 70, 30 }); } else if(name == "DateEdit") { QDateEdit* date = new QDateEdit; date->setObjectName("DateEdit"); return setLayoutWidget({ date }, { 110, 40 }); } else if(name == "DateTimeEdit") { QDateTimeEdit* date = new QDateTimeEdit; date->setObjectName("DateTimeEdit"); return setLayoutWidget({ date }, { 160, 30 }); } else if(name == "Dialog") { QDialog* dialog = new QDialog; dialog->setObjectName("Dialog"); return setLayoutWidget({ dialog }, { 160, 110 }); } else if(name == "DockWidget") //? { QDockWidget* widget = new QDockWidget; widget->setObjectName("DockWidget"); widget->resize(61, 22); return widget; } else if(name == "DoubleSpinBox") { QDoubleSpinBox* box = new QDoubleSpinBox; box->setObjectName("DoubleSpinBox"); return setLayoutWidget({ box }, { 90, 40 }); } else if(name == "Frame") //?? { QFrame* frame = new QFrame; frame->setObjectName("Frame"); frame->resize(150, 100); return frame; } else if(name == "GroupBox") { QGroupBox* box = new QGroupBox("GroupBox"); box->setObjectName("GroupBox"); return setLayoutWidget({ box }, { 160, 110 }); } else if(name == "Label") { QLabel* label = new QLabel("Label"); label->setObjectName("Label"); return setLayoutWidget({ label }, { 40, 20}); } else if(name == "LineEdit") { QLineEdit* line = new QLineEdit; line->setObjectName("LineEdit"); return setLayoutWidget({ line }, { 30, 30 }); } else if(name == "ListView") //?? { QListView* view = new QListView; view->setObjectName("ListView"); view->resize(71, 71); return view; } else if(name == "ListWidget") { QListWidget* list = new QListWidget; list->setObjectName("ListWidget"); for(int i = 0; i < 20; i++) list->addItem(QString("Item %1").arg(i)); return setLayoutWidget({ list }, { 80, 80 }); } else if(name == "MainWindow") { QMainWindow* window = new QMainWindow; window->setObjectName("MainWindow"); return setLayoutWidget({ window }, { 160, 110 }); } else if(name == "Menu") { QMenu* parentMenu = new QMenu; parentMenu->setObjectName("Menu"); parentMenu->addMenu("Menu1"); QMenu* menu1 = parentMenu->addMenu("Menu2"); menu1->addMenu("Menu1"); menu1->addMenu("Menu2"); parentMenu->addSeparator(); parentMenu->addMenu("Menu3"); return setLayoutWidget({ parentMenu }, { 160, 110 }); } else if(name == "MenuBar") { QMenuBar* bar = new QMenuBar; bar->setObjectName("QMenuBar"); QMenu* menu1 = bar->addMenu("MenuBar1"); menu1->addMenu("Menu1"); menu1->addSeparator(); menu1->addMenu("Menu2"); QMenu* menu2 = bar->addMenu("MenuBar2"); menu2->addMenu("Menu1"); menu2->addSeparator(); menu2->addMenu("Menu2"); QMenu* menu3 = bar->addMenu("MenuBar3"); menu3->addMenu("Menu1"); menu3->addSeparator(); menu3->addMenu("Menu2"); return setLayoutWidget({ bar }, { 280, 60 }); } else if(name == "ProgressBar") { QProgressBar* bar = new QProgressBar; bar->setObjectName("ProgressBar"); bar->setRange(0, 100); bar->setValue(0); QTimer* timer = new QTimer(bar); this->connect(timer, &QTimer::timeout, this, [bar]() { if(bar->value() == 100) bar->setValue(0); else bar->setValue(bar->value() + 1); }); timer->start(100); return setLayoutWidget({ bar }, { 110, 30 }); } else if(name == "PushButton") { QPushButton* button = new QPushButton("PushButton"); button->setObjectName("PushButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "RadioButton") { QRadioButton* button = new QRadioButton("RadioButton"); button->setObjectName("RadioButton"); return setLayoutWidget({ button }, { 125, 30 }); } else if(name == "ScrollBar") { QScrollBar* barH = new QScrollBar(Qt::Horizontal); QScrollBar* barV = new QScrollBar(Qt::Vertical); barH->setObjectName("ScrollBarH"); barV->setObjectName("ScrollBarV"); return setLayoutWidget({ barH, barV }, { 200, 100 }); } else if(name == "Slider") { QSlider* sliderH = new QSlider(Qt::Horizontal); QSlider* sliderV = new QSlider(Qt::Vertical); sliderH->setObjectName("SliderH"); sliderV->setObjectName("SliderV"); return setLayoutWidget({ sliderH, sliderV }, { 200, 100 }); } else if(name == "SpinBox") { QSpinBox* spinBox = new QSpinBox; spinBox->setObjectName("SpinBox"); return setLayoutWidget({ spinBox }, { 60, 35 }); } else if(name == "Splitter") { QSplitter* splitterV = new QSplitter(Qt::Vertical); QSplitter* splitterH = new QSplitter(Qt::Horizontal); splitterV->setObjectName("SplitterV"); splitterH->setObjectName("SplitterH"); splitterV->addWidget(new QPushButton("PushButton1")); splitterV->addWidget(new QPushButton("PushButton2")); splitterH->addWidget(splitterV); splitterH->addWidget(new QPushButton("PushButton3")); return setLayoutWidget({ splitterH }, { 250, 110 }); } else if(name == "TabWidget") { QTabWidget* tab = new QTabWidget; tab->addTab(new QWidget, "Widget1"); tab->addTab(new QWidget, "Widget2"); tab->addTab(new QWidget, "Widget3"); tab->setObjectName("TabWidget"); return setLayoutWidget({ tab }, { 210, 110 }); } else if(name == "TableView") //? { QTableView* view = new QTableView; view->setObjectName("TableView"); view->resize(200, 100); return view; } else if(name == "TableWidget") { const int n = 100; QStringList list = { "one", "two", "three" }; QTableWidget* table = new QTableWidget(n, n); table->setObjectName("TableWidget"); table->setHorizontalHeaderLabels(list); table->setVerticalHeaderLabels(list); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j))); return setLayoutWidget({ table }, { 210, 110 }); } else if(name == "TextEdit") { QTextEdit* text = new QTextEdit; text->setObjectName("TextEdit"); return setLayoutWidget({ text }, { 80, 80 }); } else if(name == "TimeEdit") { QTimeEdit* time = new QTimeEdit; time->setObjectName("TimeEdit"); return setLayoutWidget({ time }, { 80, 80 }); } else if(name == "ToolButton") { QToolButton* button = new QToolButton; button->setText("ToolButton"); button->setObjectName("ToolButton"); return setLayoutWidget({ button }, { 95, 25 }); } else if(name == "ToolBox") { QToolBox* box = new QToolBox; box->addItem(new QWidget, "Widget1"); box->addItem(new QWidget, "Widget2"); box->addItem(new QWidget, "Widget3"); box->setObjectName("ToolBox"); return setLayoutWidget({ box }, { 110, 180 }); } else if(name == "TreeView") //? { QTreeView* tree = new QTreeView; tree->setObjectName("TreeView"); tree->resize(200, 100); return tree; } else if(name == "TreeWidget") { QTreeWidget* tree = new QTreeWidget; tree->setObjectName("TreeWidget"); tree->setHeaderLabels({ "Folders", "Used Space" }); QTreeWidgetItem* item = new QTreeWidgetItem(tree); item->setText(0, "Local Disk"); for(int i = 1; i < 20; i++) { QTreeWidgetItem* dir = new QTreeWidgetItem(item); dir->setText(0, "Directory" + QString::number(i)); dir->setText(1, QString::number(i) + "MB"); } tree->setItemExpanded(item, true); return setLayoutWidget({ tree }, { 210, 110 }); } else if(name == "Widget") { QWidget* widget = new QWidget; widget->setObjectName("Widget"); return setLayoutWidget({ widget }, { 210, 110 }); } return nullptr; }
void Archive::save(Basket *basket, bool withSubBaskets, const QString &destination) { QDir dir; KProgressDialog dialog(0, i18n("Save as Basket Archive"), i18n("Saving as basket archive. Please wait..."), /*Not modal, for password dialogs!*/false); dialog.showCancelButton(false); dialog.setAutoClose(true); dialog.show(); QProgressBar *progress = dialog.progressBar(); progress->setRange(0,/*Preparation:*/1 + /*Finishing:*/1 + /*Basket:*/1 + /*SubBaskets:*/(withSubBaskets ? Global::bnpView->basketCount(Global::bnpView->listViewItemForBasket(basket)) : 0)); progress->setValue(0); // Create the temporary folder: QString tempFolder = Global::savesFolder() + "temp-archive/"; dir.mkdir(tempFolder); // Create the temporary archive file: QString tempDestination = tempFolder + "temp-archive.tar.gz"; KTar tar(tempDestination, "application/x-gzip"); tar.open(QIODevice::WriteOnly); tar.writeDir("baskets", "", ""); progress->setValue(progress->value()+1); // Preparation finished kDebug() << "Preparation finished out of " << progress->maximum(); // Copy the baskets data into the archive: QStringList backgrounds; Archive::saveBasketToArchive(basket, withSubBaskets, &tar, backgrounds, tempFolder, progress); // Create a Small baskets.xml Document: QDomDocument document("basketTree"); QDomElement root = document.createElement("basketTree"); document.appendChild(root); Global::bnpView->saveSubHierarchy(Global::bnpView->listViewItemForBasket(basket), document, root, withSubBaskets); Basket::safelySaveToFile(tempFolder + "baskets.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + document.toString()); tar.addLocalFile(tempFolder + "baskets.xml", "baskets/baskets.xml"); dir.remove(tempFolder + "baskets.xml"); // Save a Small tags.xml Document: QList<Tag*> tags; listUsedTags(basket, withSubBaskets, tags); Tag::saveTagsTo(tags, tempFolder + "tags.xml"); tar.addLocalFile(tempFolder + "tags.xml", "tags.xml"); dir.remove(tempFolder + "tags.xml"); // Save Tag Emblems (in case they are loaded on a computer that do not have those icons): QString tempIconFile = tempFolder + "icon.png"; for (Tag::List::iterator it = tags.begin(); it != tags.end(); ++it) { State::List states = (*it)->states(); for (State::List::iterator it2 = states.begin(); it2 != states.end(); ++it2) { State *state = (*it2); QPixmap icon = KIconLoader::global()->loadIcon( state->emblem(), KIconLoader::Small, 16, KIconLoader::DefaultState, QStringList(), 0L, true ); if (!icon.isNull()) { icon.save(tempIconFile, "PNG"); QString iconFileName = state->emblem().replace('/', '_'); tar.addLocalFile(tempIconFile, "tag-emblems/" + iconFileName); } } } dir.remove(tempIconFile); // Finish Tar.Gz Exportation: tar.close(); // Computing the File Preview: Basket *previewBasket = basket; // FIXME: Use the first non-empty basket! QPixmap previewPixmap(previewBasket->visibleWidth(), previewBasket->visibleHeight()); QPainter painter(&previewPixmap); // Save old state, and make the look clean ("smile, you are filmed!"): NoteSelection *selection = previewBasket->selectedNotes(); previewBasket->unselectAll(); Note *focusedNote = previewBasket->focusedNote(); previewBasket->setFocusedNote(0); previewBasket->doHoverEffects(0, Note::None); // Take the screenshot: previewBasket->drawContents(&painter, 0, 0, previewPixmap.width(), previewPixmap.height()); // Go back to the old look: previewBasket->selectSelection(selection); previewBasket->setFocusedNote(focusedNote); previewBasket->doHoverEffects(); // End and save our splandid painting: painter.end(); QImage previewImage = previewPixmap.toImage(); const int PREVIEW_SIZE = 256; previewImage = previewImage.scaled(PREVIEW_SIZE, PREVIEW_SIZE, Qt::KeepAspectRatio); previewImage.save(tempFolder + "preview.png", "PNG"); // Finaly Save to the Real Destination file: QFile file(destination); if (file.open(QIODevice::WriteOnly)) { ulong previewSize = QFile(tempFolder + "preview.png").size(); ulong archiveSize = QFile(tempDestination).size(); QTextStream stream(&file); stream.setCodec("ISO-8859-1"); stream << "BasKetNP:archive\n" << "version:0.6.1\n" // << "read-compatible:0.6.1\n" // << "write-compatible:0.6.1\n" << "preview*:" << previewSize << "\n"; stream.flush(); // Copy the Preview File: const unsigned long BUFFER_SIZE = 1024; char *buffer = new char[BUFFER_SIZE]; long sizeRead; QFile previewFile(tempFolder + "preview.png"); if (previewFile.open(QIODevice::ReadOnly)) { while ((sizeRead = previewFile.read(buffer, BUFFER_SIZE)) > 0) file.write(buffer, sizeRead); } stream << "archive*:" << archiveSize << "\n"; stream.flush(); // Copy the Archive File: QFile archiveFile(tempDestination); if (archiveFile.open(QIODevice::ReadOnly)) { while ((sizeRead = archiveFile.read(buffer, BUFFER_SIZE)) > 0) file.write(buffer, sizeRead); } // Clean Up: delete buffer; buffer = 0; file.close(); } progress->setValue(progress->value()+1); // Finishing finished kDebug() << "Finishing finished"; // Clean Up Everything: dir.remove(tempFolder + "preview.png"); dir.remove(tempDestination); dir.rmdir(tempFolder); }
/*! * \brief main * Ejercicio 2 Guia de Trabajos Practicos 1 * \param argc * \param argv * \return */ int main(int argc, char *argv[]) { QApplication a( argc, argv ); QMainWindow main; a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()) ); main.showMaximized(); QMdiArea *mdiArea = new QMdiArea; mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); main.setCentralWidget(mdiArea); //Inicializo con una semilla aleatoria para la generacion de Aleatorios qsrand( QTime::currentTime().msec() ); // Cargo los parametros del ejercicio QSettings parametros( "parametros.cfg", QSettings::IniFormat ); // Archivo de entrada QString archivo = QCoreApplication::applicationDirPath().append( QDir::separator() ).append( parametros.value( "archivo_entrada" ).toString() ); // Cargo los datos de los archivos que corresponda matriz entradas( parametros.value( "cantidad_entradas" ).toInt() ); QVector<int> salidas; qDebug() << endl << "--------------- /Datos del entrenamiento/ -----------------" << endl; qWarning() << "Archivo de lectura de datos originales: "<< archivo; if( ! leer_archivo_entrenamiento( archivo, &entradas, &salidas, parametros.value( "cantidad_entradas" ).toInt() ) ) { qDebug() << "No se pudo encontrar el archivo de entrenamiento! cancelando!"; abort(); } // particionamos los datos Particionador particiones; particiones.setearCantidadDatos( entradas.size() ); particiones.setearCantidadDeParticiones( parametros.value( "cantidad_particiones" ).toInt() ); particiones.setearPorcentajeEntrenamiento( parametros.value( "porcentaje_entrenamiento" ).toDouble() ); particiones.setearPorcentajeValidacion( parametros.value("porcentaje_validacion").toDouble() ); particiones.setearK(parametros.value("k").toInt()); particiones.particionarDatos(); // Inicializo la red neuronal QVector<int> neuronas_por_capas; // Primer parametro es la cantidad de clases neuronas_por_capas << parametros.value( "cant_clases" ).toInt(); neuronas_por_capas << stringAQVector( parametros.value( "codificacion_salida" ).toString() ).size(); // Inicilizo la red radial RedNeuronalRadial red( neuronas_por_capas.at(0), neuronas_por_capas.at(1), parametros.value("cantidad_entradas").toInt(), parametros.value( "cant_clases" ).toInt() ); red.setearTasaAprendizaje( parametros.value( "tasa_aprendizaje" ).toDouble() ); qDebug() << "Tasa de aprendizaje: " << parametros.value( "tasa_aprendizaje" ).toDouble(); red.setearCodificacion( stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); qDebug() << "Codificacion salida: " << red.mostrarCodificacionSalida(); int max_epocas = parametros.value( "epocas_maximas", 20 ).toInt(); qDebug() << "Epocas: " << max_epocas; double tolerancia_error = parametros.value( "tolerancia_error" ).toDouble(); qDebug() << "Error de corte: " << ( tolerancia_error ) << "%"; qDebug() << endl << "---------------- /Comienza el entrenamiento/ ----------------"; int epoca = 0; /* Contador de epocas */ double porcentaje_error = 100.0; /* Mucho sino sale */ int cantidad_particiones_exitosas = 0; GraficadorMdi *graf1 = new GraficadorMdi( mdiArea ); graf1->setearTitulo( QString::fromUtf8( "Porcentaje de error según particion ( entrenamiento )" ) ); graf1->setearTituloEjeX( QString::fromUtf8( "Epoca" ) ); graf1->setearTituloEjeY( QString::fromUtf8( "Porcentaje error" ) ); mdiArea->addSubWindow( graf1 ); mdiArea->tileSubWindows(); if( stringAQVector( parametros.value( "codificacion_salida" ).toString() ).size() <= 2 ) { GraficadorMdi *graf2 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf2 ); graf2->showMaximized(); graf2->setearTitulo( "Datos originales" ); graf2->setearEjesEnGrafico(); graf2->setearTituloEjeX( " X " ); graf2->setearTituloEjeY( " y " ); graf2->agregarPuntosClasificados( entradas, salidas, 0.5 ); mdiArea->tileSubWindows(); } else { matriz entradas1, entradas2; vector salidas1, salidas2; for( int i=0; i < entradas.size(); i++ ) { vector temp; temp.append( entradas.at(i).at(0) ); temp.append( entradas.at(i).at(1) ); entradas1.append( temp ); vector temp2; temp2.append( entradas.at(i).at(2) ); temp2.append( entradas.at(i).at(3) ); entradas2.append( temp2 ); salidas1.append( salidas.at( i ) ); salidas2.append( salidas.at( i ) ); } GraficadorMdi *graf2 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf2 ); graf2->showMaximized(); graf2->setearTitulo( "Datos originales" ); //graf2->setearEjesEnGrafico(); graf2->setearTituloEjeX( "Longitud" ); graf2->setearTituloEjeY( "Ancho" ); graf2->agregarPuntosClasificados( entradas1, salidas1, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); GraficadorMdi *graf3 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf3 ); graf3->showMaximized(); graf3->setearTitulo( "Datos originales" ); graf3->setearTituloEjeX( "Petalos" ); graf3->setearTituloEjeY( "Sepalos" ); graf3->agregarPuntosClasificados( entradas2, salidas2, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); mdiArea->tileSubWindows(); } QDockWidget *dockBarra1 = new QDockWidget( "Progreso de Particiones" ); main.addDockWidget( Qt::BottomDockWidgetArea, dockBarra1 ); QProgressBar *PBParticiones = new QProgressBar( dockBarra1 ); dockBarra1->setWidget( PBParticiones ); QDockWidget *dockBarra2 = new QDockWidget( "Progreso de Epocas" ); main.addDockWidget( Qt::BottomDockWidgetArea, dockBarra2 ); QProgressBar *PBEpocas = new QProgressBar( dockBarra2 ); dockBarra2->setWidget( PBEpocas ); QVector<double> errores_particiones; PBParticiones->setRange( 0, particiones.cantidadDeParticiones() ); PBParticiones->setValue( 0 ); PBParticiones->setFormat( "Particion %v de %m - %p%" ); PBEpocas->setRange( 0, max_epocas ); PBEpocas->setFormat( "Epoca %v de %m - %p%" ); // Mido el tiempo QElapsedTimer medidor_tiempo; medidor_tiempo.start(); // Busco los centroides red.setearDatosOriginales( entradas, &salidas ); red.buscarCentroides(); // Grafico la agrupacion que hizo GraficadorMdi *graf = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf ); graf->setearTitulo( QString( "Agrupamientos según RB" ) ); graf->setearEjesEnGrafico(); graf->setearTituloEjeX( " X " ); graf->setearTituloEjeY( " Y " ); red.graficarClusters( graf ); mdiArea->tileSubWindows(); //return a.exec(); for( int p=0; p<particiones.cantidadDeParticiones(); p++ ) { Particionador::particion part_local = particiones.getParticion( p ); qDebug() << endl << "Utilizando Particion: " << p ; //pongo nuevamente en los valores iniciales las variables de corte para que entre en todas las particiones epoca = 0; porcentaje_error = 100.0; red.inicializarPesos(); QVector<double> errores_epocas; //std::cout << "Epoca: " << std::endl; PBEpocas->setValue( 0 ); while ( epoca < max_epocas && porcentaje_error > tolerancia_error ) { // Inicio la etapa de entrenamiento for(int i = 0; i < part_local.entrenamiento.size(); i++ ) { vector prueba = entradas.at( part_local.entrenamiento.at(i) ); int salida = salidas.at( part_local.entrenamiento.at( i ) ); red.entrenarCapaNeuronalComun( prueba, salida ); } // Verifico el error int errores = 0; int correcto = 0; for( int i = 0; i < part_local.validacion.size(); i++ ) { int pos = part_local.validacion.at( i ); vector entrada_a_evaluar = entradas.at( pos ); int salida_red = red.probarPatron( entrada_a_evaluar ) ; //double salida_mapeada = red.mapeadorSalidas( salida_red ); double salida_deseada = salidas.at( pos ); if( salida_red != salida_deseada ) { errores++; } else { correcto++; } } porcentaje_error = ( (double) errores * 100 ) / (double) part_local.validacion.size(); errores_epocas.push_back( porcentaje_error ); // Aumento el contador de epocas epoca++; PBEpocas->setValue( epoca ); QApplication::processEvents(); } graf1->agregarCurva( errores_epocas, QString( "Particion %1" ).arg( p ) ); qDebug() << " Epoca de finalizacion: " << epoca+1 << " - Error de salida de entrenamiento: " << porcentaje_error << "%"; // Genero las estadisticas con los datos de prueba porcentaje_error = 0.0; int errores = 0; int correcto = 0; for( int i = 0; i < part_local.prueba.size(); i++ ) { if( red.probarPatron( entradas.at( part_local.prueba.at( i ) ) ) != salidas.at( part_local.prueba.at( i ) ) ) { errores++; } else { correcto++; } } porcentaje_error = ( (double) errores * 100 ) / (double) part_local.prueba.size(); errores_particiones.push_back( porcentaje_error ); //Aumento el contador de las no exitosas if (epoca < max_epocas) { cantidad_particiones_exitosas++; } //qDebug() << errores_epocas; qDebug() <<"Terminada particion " << p << "- Error de prueba: " << errores_particiones.at( p ) << "%"; //Calculo el error promedio y la desviacion estandar para la particion // double error_promedio = 0.0; // double desviacion_estandar = 0.0; // double error_aux = 0.0; // for (int i = 0 ; i < errores_epocas.size() ; i++ ) { error_promedio += errores_epocas.at(i);} // error_promedio /= errores_epocas.size(); // qDebug() <<"Error Promedio: " << error_promedio << "%"; // for (int i = 0 ; i < errores_epocas.size() ; i++ ) { error_aux += exp(errores_epocas.at(i) - error_promedio);} // desviacion_estandar = sqrt( (1.0 / (errores_epocas.size() - 1.0) ) * error_aux ); // qDebug() <<"Desviacion Estandar: " << desviacion_estandar << "%"; errores_epocas.clear(); PBParticiones->setValue( PBParticiones->value() + 1 ); QVector<int> nueva_salida; matriz nueva_entrada; for( int i=0; i<part_local.prueba.size(); i++ ) { nueva_salida.append( red.probarPatron( entradas.at( part_local.prueba.at( i ) ) ) ); nueva_entrada.append( entradas.at( part_local.prueba.at( i ) ) ); } /*if( particiones.cantidadDeParticiones() <= 5 ) { GraficadorMdi *graf = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf ); graf->show(); graf->setearTitulo( QString( "Datos de prueba evaluados con red neuronal - Particion %1" ).arg( p+1 ) ); graf->setearEjesEnGrafico(); graf->setearTituloEjeX( " X " ); graf->setearTituloEjeY( " y " ); graf->agregarPuntosClasificados( nueva_entrada, nueva_salida, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); mdiArea->tileSubWindows(); }*/ QApplication::processEvents(); } qint64 milisegundos = medidor_tiempo.elapsed(); //std::cout << std::endl; // Calculo el promedio de todos los errores double sumatoria = 0.0; for( int i=0; i<errores_particiones.size(); i++ ) { sumatoria+=errores_particiones.at(i); } qDebug() << endl << "--------------- /Resumen/ -----------------"; qDebug() << endl << "Error total: " << sumatoria/errores_particiones.size() << "%"; qDebug() << endl << "Cantidad de Particiones que convergen: " << cantidad_particiones_exitosas ; qDebug() << endl << "Cantidad de Particiones sin converger: " << (particiones.cantidadDeParticiones() - cantidad_particiones_exitosas) ; //Calculo el error promedio y la desviacion estandar para todo double error_promedio = sumatoria/errores_particiones.size(); double desviacion_estandar = 0.0; double error_aux = 0.0; for (int i = 0 ; i < errores_particiones.size() ; i++ ) { error_aux += exp(errores_particiones.at(i) - error_promedio);} desviacion_estandar = sqrt( (1.0 / (errores_particiones.size() - 1.0) ) * error_aux ); qDebug() <<"Desviacion Estandar: " << desviacion_estandar << "%"; qDebug() << "Tiempo medido: " << milisegundos << " ms"; if( particiones.cantidadDeParticiones() != 1 ) { GraficadorMdi *graf3 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf3 ); graf3->showMaximized(); graf3->setearTitulo( "Errores por particion( datos de prueba )" ); graf3->setearTituloEjeX( "Particion" ); graf3->setearTituloEjeY( "Error" ); graf3->agregarCurva( errores_particiones, "Errores" ); mdiArea->tileSubWindows(); } QVector<int> nueva_salida; for( int i=0; i<entradas.size(); i++ ) { nueva_salida.append( red.probarPatron( entradas.at(i) ) ); } matriz entradas1, entradas2; vector salidas1, salidas2; for( int i=0; i < entradas.size(); i++ ) { vector temp; temp.append( entradas.at(i).at(0) ); temp.append( entradas.at(i).at(1) ); entradas1.append( temp ); if( entradas.at(i).size() > 2 ) { vector temp2; temp2.append( entradas.at(i).at(2) ); temp2.append( entradas.at(i).at(3) ); entradas2.append( temp2 ); } salidas1.append( nueva_salida.at( i ) ); salidas2.append( nueva_salida.at( i ) ); } if( stringAQVector( parametros.value( "codificacion_salida" ).toString() ).size() == 2 ) { GraficadorMdi *graf4 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf4 ); graf4->showMaximized(); graf4->setearTitulo( "Datos evaluados con red neuronal" ); graf4->setearEjesEnGrafico(); graf4->setearTituloEjeX( " X " ); graf4->setearTituloEjeY( " y " ); graf4->agregarPuntosClasificados( entradas, nueva_salida, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); //graf4->agregarPuntosClasificados( entradas, nueva_salida ); } else if( stringAQVector( parametros.value("codificacion_salida").toString() ).size() == 1 ) { GraficadorMdi *graf4 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf4 ); graf4->showMaximized(); graf4->setearTitulo( "Datos evaluados con red neuronal" ); graf4->setearEjesEnGrafico(); graf4->setearTituloEjeX( " X " ); graf4->setearTituloEjeY( " y " ); //graf4->agregarPuntosClasificados( entradas, nueva_salida, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); graf4->agregarPuntosClasificados( entradas, nueva_salida ); } else { GraficadorMdi *graf4 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf4 ); graf4->showMaximized(); graf4->setearTitulo( "Datos evaluados con red neuronal" ); graf4->setearTituloEjeX( "Largo" ); graf4->setearTituloEjeY( "Ancho" ); graf4->agregarPuntosClasificados( entradas1, salidas1, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); GraficadorMdi *graf5 = new GraficadorMdi( mdiArea ); mdiArea->addSubWindow( graf5 ); graf5->showMaximized(); graf5->setearTitulo( "Datos evaluados con red neuronal" ); graf5->setearTituloEjeX( "Petalos" ); graf5->setearTituloEjeY( "Sepalos" ); graf5->agregarPuntosClasificados( entradas2, salidas2, stringAQVector( parametros.value( "codificacion_salida" ).toString() ) ); } mdiArea->tileSubWindows(); return a.exec(); }