void DataImporterImportPage::startWorkerThread() { Q_ASSERT(workerThread == 0); QTimer::singleShot(0, this, SLOT(enableBackButton())); QTimer::singleShot(0, this, SLOT(enableNextButton())); QTimer::singleShot(0, this, SLOT(enableCancelButton())); importedCount = 0; DataImporter *importerWizard = static_cast<DataImporter*>(wizard()); workerThread = new DataImporterThread(field("schemaName").toString().trimmed().toUpper(), this->queryScheduler->getDb(), field("tableName").toString().trimmed().toUpper(), importerWizard->getColumnMappings(), field("beforeImportGroupBox").toBool() ? field("beforeImportQuery").toString().trimmed() : "", field("importQuery").toString(), field("afterImportGroupBox").toBool() ? field("afterImportQuery").toString().trimmed() : "", importerWizard->getImporter(), this); connect(workerThread, SIGNAL(statusChanged(QString)), this, SLOT(setStatus(QString))); connect(workerThread, SIGNAL(chunkImported(int)), this, SLOT(chunkImported(int))); connect(workerThread, SIGNAL(comparisonCompleted()), this, SLOT(importCompleted())); connect(workerThread, SIGNAL(compareError(QString,OciException)), this, SLOT(importError(QString,OciException))); timer.start(); workerThread->start(); stopButton->setEnabled(true); stopButton->setText(tr("Stop")); stopButton->setVisible(true); }
// on "init" you need to initialize your instance bool WaitingRoomLayer::init() { ////////////////////////////// // 1. super init first if ( !GameLayer::init() ) { return false; } Size ws = Director::getInstance()->getWinSize(); float offset = 20; enableBackButton(true); ui::Scale9Sprite *panel1 = ui::Scale9Sprite::createWithSpriteFrameName("ui_panel.png"); addChild(panel1); panel1->setContentSize(Size(0.425*ws.width, 0.5*ws.height)); panel1->setPosition(0.275*ws.width, 0.4*ws.height); ui::Scale9Sprite *panel2 = ui::Scale9Sprite::createWithSpriteFrameName("ui_panel.png"); addChild(panel2); panel2->setContentSize(panel1->getContentSize()); panel2->setPosition(0.725*ws.width, 0.4*ws.height); m_sprUser1Avarta = Sprite::createWithSpriteFrameName("avarta_1.png"); addChild(m_sprUser1Avarta); m_sprUser1Avarta->setPosition(panel1->getPosition()); m_sprUser2Avarta = Sprite::createWithSpriteFrameName("avarta_2.png"); addChild(m_sprUser2Avarta); m_sprUser2Avarta->setPosition(panel2->getPosition()); m_sprUser2Avarta->setVisible(false); m_lblUser1Infor = Label::createWithTTF("Lvl.1 Wonka Thi", "fonts/arial.ttf", 25); addChild(m_lblUser1Infor); m_lblUser1Infor->setAnchorPoint(Point(0.5, 0)); m_lblUser1Infor->setPosition(panel1->getPosition() + Point(0, panel1->getContentSize().height / 2.0f + offset)); m_lblUser2Infor = Label::createWithTTF("Lvl.1 Luffy", "fonts/arial.ttf", 25); addChild(m_lblUser2Infor); m_lblUser2Infor->setAnchorPoint(Point(0.5, 0)); m_lblUser2Infor->setPosition(panel2->getPosition() + Point(0, panel2->getContentSize().height / 2.0f + offset)); m_lblUser2Infor->setVisible(false); m_lblRoomName = Label::createWithTTF("Room Name", "fonts/arial.ttf", 40); addChild(m_lblRoomName); m_lblRoomName->setPosition(ws.width / 2.0f, m_lblUser1Infor->getPositionY() + (m_btnBack->getPositionY() - m_lblUser1Infor->getPositionY()) / 2.0f); m_lblStatus = Label::createWithTTF("Waiting", "fonts/arial.ttf", 30); addChild(m_lblStatus); m_lblStatus->setPosition(panel2->getPosition()); m_btnBack->addTouchEventListener(CC_CALLBACK_2(WaitingRoomLayer::callBackBtn, this)); hide(); return true; }
void DataImporterImportPage::importError(const QString &taskName, const OciException &ex) { deleteWorkerThread(); enableBackButton(true); enableNextButton(false); enableCancelButton(true); QMessageBox::critical(this, tr("Data import error"), tr("Task name: %1\nError: %2").arg(taskName, ex.getErrorMessage())); setStatus(tr("Completed with error")); }
void DataImporterImportPage::importCompleted() { bool stopped = workerThread->isStopped(); deleteWorkerThread(); if(stopped){ setStatus(tr("Data import was cancelled and transaction was rolled back.")); enableBackButton(true); }else{ setStatus(tr("Data import successfully completed. %1 records were imported in %2.\n" "Press Next to review changes and COMMIT/ROLLBACK as necessary.\n" "Press Finish to exit wizard").arg(importedCount).arg(formatMsecs(timer.elapsed(), true))); } enableNextButton(true); enableCancelButton(true); }