Crawler::Crawler(QObject *parent) : QObject(parent) { activeDownloads = 0; QThreadPool::globalInstance() ->setMaxThreadCount(MAX_CONCURRENT_REQUESTS); connect(this, SIGNAL(done()), this, SLOT(handleDone())); }
short ExExeUtilHiveQueryTcb::work() { short rc = 0; Lng32 cliRC = 0; if (qparent_.down->isEmpty()) return WORK_OK; if (qparent_.up->isFull()) return WORK_OK; ex_queue_entry * pentry_down = qparent_.down->getHeadEntry(); ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate); while (1) { switch (step_) { case INITIAL_: { step_ = PROCESS_QUERY_; } break; case PROCESS_QUERY_: { if (HiveClient_JNI::executeHiveSQL(htTdb().getHiveQuery()) != HVC_OK) { ExRaiseSqlError(getHeap(), &diagsArea_, -1214, NULL, NULL, NULL, getSqlJniErrorStr(), htTdb().getHiveQuery()); step_ = ERROR_; break; } step_ = DONE_; } break; case ERROR_: { if (handleError()) return WORK_OK; step_ = DONE_; } break; case DONE_: { if (handleDone()) return WORK_OK; step_ = INITIAL_; return WORK_OK; } break; } // switch } // while }
void HttpServerTask::handleJobRequest(HttpJobRequest* jobRequest) { httpJobRequest = jobRequest; #ifdef ENABLE_TEST_MODE // timing cell values job p3t::PTS_Timer<p3t::PTS_TSCount> t; if( httpJobRequest->getName() == "/cell/values" || httpJobRequest->getName() == "/cell/area" || httpJobRequest->getName() == "/dimension/dfilter" || jobRequest->getName() == "/view/calculate") { Logger::info << "#####################################################################################" << endl; Logger::info << "Start handleJobRequest (" << httpJobRequest->getName() << ")" << endl; t.start(); } #endif if (!jobRequest->isDone()) { // convert request into job Job* job = analyzer->analyse(jobRequest); job->setTask(this); // the algorithm behind analyzer->analyze ensures that job != 0; if (job->initialize()) { job->work(); } jobRequest->handleDone(job); bShutdown = job->getShutdown(); job->cleanup(); } #ifdef ENABLE_TEST_MODE // timing cell values job if( httpJobRequest->getName() == "/cell/values" || httpJobRequest->getName() == "/cell/area" || httpJobRequest->getName() == "/dimension/dfilter" || jobRequest->getName() == "/view/calculate") { t.stop(); double request_time_ms = t.elapsed()*1000.0; Logger::info << "handleJobRequest ("<< httpJobRequest->getName() <<") took " << request_time_ms << " ms to finish." << endl; Logger::info << "#####################################################################################" << endl; } #endif handleDone(); }
bool HttpServerTask::processRead() { if (httpRequestPending) { return true; } bool handleRequest = false; try { if (!readRequestBody) { const char * ptr = readBuffer.c_str() + readPosition; const char * end = readBuffer.end() - 3; for (; ptr < end; ptr++) { if (ptr[0] == '\r' && ptr[1] == '\n' && ptr[2] == '\r' && ptr[3] == '\n') { break; } } if (ptr < end) { readPosition = ptr - readBuffer.c_str() + 4; string url = extractRequestPath(); httpRequest = server->createHttpRequest(url); httpRequest->extractHeader(readBuffer.str(), readBuffer.str() + readPosition); bodyPosition = readPosition; switch (httpRequest->getRequestType()) { case HttpRequest::HTTP_REQUEST_GET: handleRequest = true; break; case HttpRequest::HTTP_REQUEST_POST: bodyLength = httpRequest->getContentLength(); if (bodyLength > 0) { readRequestBody = true; } else { handleRequest = true; } break; default: Logger::warning << "got corrupted HTTP request" << endl; //handleHangup(); //handleRequest = true; return false; } } else { if (readBuffer.c_str() < end) { readPosition = end - readBuffer.c_str(); } } } // readRequestBody might have changed, so cannot use else if (readRequestBody) { if (readBuffer.length() - bodyPosition < bodyLength) { return true; } // read "bodyLength" from read buffer and add this body to "httpRequest" httpRequest->extractBody(readBuffer.str() + bodyPosition, readBuffer.str() + bodyPosition + bodyLength); // handle request readRequestBody = false; handleRequest = true; } if (handleRequest) { httpRequestPending = true; server->handleRequest(this, httpRequest); } } catch (const ErrorException& e) { httpJobRequest = server->handleException(e, httpRequest); handleDone(); } return true; }
////////////////////////////////////////////////////// // work() for ExExeUtilHiveTruncateTcb ////////////////////////////////////////////////////// short ExExeUtilHiveTruncateTcb::work() { short rc = 0; Lng32 cliRC = 0; // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; // if no room in up queue, won't be able to return data/status. // Come back later. if (qparent_.up->isFull()) return WORK_OK; ex_queue_entry * pentry_down = qparent_.down->getHeadEntry(); ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate); while (1) { switch (step_) { case INITIAL_: { // if 'if exists' clause was specified and table does not exist // during compile phase, return. // If table was missing during compile and was created before // execute, then QI/AQR/Timestamp check will recompile. if (htTdb().getIfExists() && htTdb().getTableNotExists()) { step_ = DONE_; break; } if (htTdb().getIsExternal()) step_ = ALTER_TO_MANAGED_; else step_ = TRUNCATE_TABLE_; } break; case ALTER_TO_MANAGED_: { // A Hive table can be an External or Managed table. // Currently, an External Hive table cannot be truncated. // Maybe some future Hive version will allow that. // Temporarily change the table attribute to be Managed, // truncate the table and then change it back to be External. NAString alterStmt("alter table "); alterStmt += htTdb().getHiveTableName(); alterStmt += " set tblproperties ('EXTERNAL'='False')"; if (HiveClient_JNI::executeHiveSQL(alterStmt.data()) != HVC_OK) { // alter failed ExRaiseSqlError(getHeap(), &diagsArea_, -1214, NULL, NULL, NULL, getSqlJniErrorStr(), htTdb().getHiveTruncQuery()); step_ = ERROR_; break; } step_ = TRUNCATE_TABLE_; } break; case TRUNCATE_TABLE_: { if (HiveClient_JNI::executeHiveSQL(htTdb().getHiveTruncQuery()) != HVC_OK) { ExRaiseSqlError(getHeap(), &diagsArea_, -1214, NULL, NULL, NULL, getSqlJniErrorStr(), htTdb().getHiveTruncQuery()); if (htTdb().getIsExternal()) { step_ = ALTER_TO_EXTERNAL_AND_ERROR_; break; } step_ = ERROR_; break; } if (htTdb().getIsExternal()) step_ = ALTER_TO_EXTERNAL_; else step_= DONE_; } break; case ALTER_TO_EXTERNAL_: case ALTER_TO_EXTERNAL_AND_ERROR_: { // table was altered to Managed. Alter it back to External. NAString alterStmt("alter table "); alterStmt += htTdb().getHiveTableName(); alterStmt += " set tblproperties ('EXTERNAL'='TRUE')"; if (HiveClient_JNI::executeHiveSQL(alterStmt.data()) != HVC_OK) { // alter failed ExRaiseSqlError(getHeap(), &diagsArea_, -1214, NULL, NULL, NULL, getSqlJniErrorStr(), alterStmt.data()); step_ = ERROR_; break; } if (step_ == ALTER_TO_EXTERNAL_AND_ERROR_) step_ = ERROR_; else step_ = DONE_; } break; case ERROR_: { if (handleError()) return WORK_OK; step_ = DONE_; } break; case DONE_: { if (handleDone()) return WORK_OK; step_ = INITIAL_; return WORK_OK; } break; } // switch } // while }
////////////////////////////////////////////////////// // work() for ExExeUtilHiveTruncateLegacyTcb ////////////////////////////////////////////////////// short ExExeUtilHiveTruncateLegacyTcb::work() { short rc = 0; Lng32 cliRC = 0; // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; // if no room in up queue, won't be able to return data/status. // Come back later. if (qparent_.up->isFull()) return WORK_OK; ex_queue_entry * pentry_down = qparent_.down->getHeadEntry(); ExExeUtilPrivateState & pstate = *((ExExeUtilPrivateState*) pentry_down->pstate); while (1) { switch (step_) { case INITIAL_: { step_ = EMPTY_DIRECTORY_; } break; case EMPTY_DIRECTORY_: { cliRC = ExpLOBinterfaceEmptyDirectory( lobGlob_, (char*)"", //name is empty (htTdb().getPartnLocation() ? htTdb().getPartnLocation() : htTdb().getTableLocation()), Lob_HDFS_File, htTdb().getHdfsHost(), htTdb().getHdfsPort(), 0 , 1 , 0); if (cliRC != 0) { Lng32 cliError = 0; Lng32 intParam1 = -cliRC; ExRaiseSqlError(getHeap(), &diagsArea_, (ExeErrorCode)(EXE_ERROR_FROM_LOB_INTERFACE), NULL, &intParam1, &cliError, NULL, "HDFS", (char*)"ExpLOBInterfaceEmptyDirectory", getLobErrStr(intParam1)); char reason[200]; strcpy(reason, " "); if (intParam1 == LOB_DIR_NAME_ERROR) { if (htTdb().getPartnLocation()) strcpy(reason, "Reason: specified partition does not exist"); else strcpy(reason, "Reason: specified table location does not exist"); } else if (intParam1 == LOB_DATA_FILE_DELETE_ERROR) { strcpy(reason, "Reason: error occurred during deletion of one or more files at the specified location"); } ExRaiseSqlError(getHeap(), &diagsArea_, (ExeErrorCode)(EXE_HIVE_TRUNCATE_ERROR), NULL, NULL, NULL, NULL, reason, NULL, NULL); step_ = ERROR_; } else { step_= DONE_; } } break; case ERROR_: { if (handleError()) return WORK_OK; step_ = DONE_; } break; case DONE_: { if (handleDone()) return WORK_OK; step_ = INITIAL_; return WORK_OK; } break; } // switch } // while }
ExWorkProcRetcode ExHbaseAccessDDLTcb::work() { short retcode = 0; short rc = 0; // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; while (1) { switch (step_) { case NOT_STARTED: { matches_ = 0; if (hbaseAccessTdb().accessType_ == ComTdbHbaseAccess::CREATE_) step_ = CREATE_TABLE; else if (hbaseAccessTdb().accessType_ == ComTdbHbaseAccess::DROP_) step_ = DROP_TABLE; else step_ = HANDLE_ERROR; } break; case CREATE_TABLE: { table_.val = hbaseAccessTdb().getTableName(); table_.len = strlen(hbaseAccessTdb().getTableName()); Queue * cfnl = hbaseAccessTdb().getColFamNameList(); cfnl->position(); HBASE_NAMELIST colFamList; HbaseStr colFam; while(NOT cfnl->atEnd()) { char * cfName = (char*)cfnl->getCurr(); colFam.val = cfName; colFam.len = strlen(cfName); colFamList.insert(colFam); cfnl->advance(); } step_ = DONE; } break; case DROP_TABLE: { step_ = DONE; } break; case HANDLE_ERROR: { if (handleError(rc)) return rc; step_ = DONE; } break; case DONE: { if (handleDone(rc)) return rc; step_ = NOT_STARTED; return WORK_OK; } break; }// switch } // while }
ExWorkProcRetcode ExHbaseAccessBulkLoadTaskTcb::work() { short retcode = 0; short rc = 0; ExMasterStmtGlobals *g = getGlobals()->castToExExeStmtGlobals()->castToExMasterStmtGlobals(); // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; while (1) { switch (step_) { case NOT_STARTED: { matches_ = 0; retcode = ehi_->initHBLC(); if (setupError(retcode, "ExpHbaseInterface::initHBLC")) { step_ = HANDLE_ERROR_AND_CLOSE; break; } table_.val = hbaseAccessTdb().getTableName(); table_.len = strlen(hbaseAccessTdb().getTableName()); hBulkLoadPrepPath_ = std::string(((ExHbaseAccessTdb&) hbaseAccessTdb()).getLoadPrepLocation()) + ((ExHbaseAccessTdb&) hbaseAccessTdb()).getTableName(); if (((ExHbaseAccessTdb&) hbaseAccessTdb()).getIsTrafLoadCleanup()) step_ = LOAD_CLEANUP; else step_ = COMPLETE_LOAD; } break; case LOAD_CLEANUP: { //cleanup retcode = ehi_->bulkLoadCleanup(table_, hBulkLoadPrepPath_); if (setupError(retcode, "ExpHbaseInterface::bulkLoadCleanup")) { step_ = HANDLE_ERROR_AND_CLOSE; break; } step_ = LOAD_CLOSE; } break; case COMPLETE_LOAD: { Text tabName = ((ExHbaseAccessTdb&) hbaseAccessTdb()).getTableName(); retcode = ehi_->doBulkLoad(table_, hBulkLoadPrepPath_, tabName, hbaseAccessTdb().getUseQuasiSecure(), hbaseAccessTdb().getTakeSnapshot()); if (setupError(retcode, "ExpHbaseInterface::doBulkLoad")) { step_ = HANDLE_ERROR_AND_CLOSE; break; } if (((ExHbaseAccessTdb&) hbaseAccessTdb()).getIsTrafLoadKeepHFiles()) { step_ = LOAD_CLOSE; break; } step_ = LOAD_CLEANUP; } break; case LOAD_CLOSE: { retcode = ehi_->close(); if (setupError(retcode, "ExpHbaseInterface::close")) { step_ = HANDLE_ERROR; break; } step_ = DONE; } break; case HANDLE_ERROR: case HANDLE_ERROR_AND_CLOSE: { if (handleError(rc)) return rc; if (step_==HANDLE_ERROR_AND_CLOSE) { step_ = LOAD_CLOSE; break; } step_ = DONE; } break; case DONE: { if (handleDone(rc)) return rc; step_ = NOT_STARTED; retcode = ehi_->close(); return WORK_OK; } break; } // switch } // while }
ExWorkProcRetcode ExHbaseAccessGetTablesTcb::work() { Lng32 retcode = 0; short rc = 0; // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; while (1) { switch (step_) { case NOT_STARTED: { matches_ = 0; step_ = GET_TABLE; } break; case GET_TABLE: { retcode = ehi_->getTable(table_); if (retcode == HBASE_ACCESS_EOD) { step_ = CLOSE; break; } if (setupError(retcode, "ExpHbaseInterface::getTable")) step_ = HANDLE_ERROR; else step_ = RETURN_ROW; } break; case RETURN_ROW: { char * ptr = table_.val; short len = (short)table_.len; if (moveRowToUpQueue(ptr, len, &rc, TRUE)) { return rc; } step_ = GET_TABLE; } break; case CLOSE: { step_ = DONE; } break; case HANDLE_ERROR: { if (handleError(rc)) return rc; step_ = DONE; } break; case DONE: { if (handleDone(rc)) return rc; step_ = NOT_STARTED; return WORK_OK; } break; }// switch } // while }
ExWorkProcRetcode ExHbaseAccessInitMDTcb::work() { short retcode = 0; short rc = 0; Lng32 cliRC = 0; ExExeStmtGlobals *exeGlob = getGlobals()->castToExExeStmtGlobals(); ExMasterStmtGlobals *masterGlob = exeGlob->castToExMasterStmtGlobals(); ComDiagsArea *da = exeGlob->getDiagsArea(); // if no parent request, return if (qparent_.down->isEmpty()) return WORK_OK; ex_queue_entry *pentry_down = qparent_.down->getHeadEntry(); while (1) { switch (step_) { case NOT_STARTED: { if (! masterGlob) { step_ = HANDLE_ERROR; break; } matches_ = 0; if (hbaseAccessTdb().accessType_ == ComTdbHbaseAccess::INIT_MD_) step_ = INIT_MD; else if (hbaseAccessTdb().accessType_ == ComTdbHbaseAccess::DROP_MD_) step_ = DROP_MD; else step_ = HANDLE_ERROR; } break; case INIT_MD: { step_ = UPDATE_MD; } break; case UPDATE_MD: { step_ = DONE; } break; case DROP_MD: { step_ = DONE; } break; case HANDLE_ERROR: { if (handleError(rc)) return rc; step_ = DONE; } break; case DONE: { if (handleDone(rc)) return rc; step_ = NOT_STARTED; return WORK_OK; } break; }// switch } // while }
int main(int argc, char *argv[]) { KCmdLineOptions options; options.add("+file", ki18n("URL to open")); KCmdLineArgs::init(argc, argv, "testkhtml", 0, ki18n("Testkhtml"), "1.0", ki18n("a basic web browser using the KHTML library")); KCmdLineArgs::addCmdLineOptions(options); KApplication a; KCmdLineArgs *args = KCmdLineArgs::parsedArgs( ); if ( args->count() == 0 ) { KCmdLineArgs::usage(); ::exit( 1 ); } new KHTMLGlobal; KXmlGuiWindow *toplevel = new KXmlGuiWindow(); KHTMLPart *doc = new KHTMLPart( toplevel, toplevel, KHTMLPart::BrowserViewGUI ); Dummy *dummy = new Dummy( doc ); QObject::connect( doc->browserExtension(), SIGNAL(openUrlRequest(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), dummy, SLOT(slotOpenURL(KUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)) ); QObject::connect( doc, SIGNAL(completed()), dummy, SLOT(handleDone()) ); if (args->url(0).url().right(4).toLower() == ".xml") { KParts::OpenUrlArguments args(doc->arguments()); args.setMimeType("text/xml"); doc->setArguments(args); } doc->openUrl( args->url(0) ); toplevel->setCentralWidget( doc->widget() ); toplevel->resize( 800, 600); QDomDocument d = doc->domDocument(); QDomElement viewMenu = d.documentElement().firstChild().childNodes().item( 2 ).toElement(); QDomElement e = d.createElement( "action" ); e.setAttribute( "name", "debugRenderTree" ); viewMenu.appendChild( e ); e = d.createElement( "action" ); e.setAttribute( "name", "debugDOMTree" ); viewMenu.appendChild( e ); e = d.createElement( "action" ); e.setAttribute( "name", "debugDoBenchmark" ); viewMenu.appendChild( e ); QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement(); e = d.createElement( "action" ); e.setAttribute( "name", "editable" ); toolBar.insertBefore( e, toolBar.firstChild() ); e = d.createElement( "action" ); e.setAttribute( "name", "navigable" ); toolBar.insertBefore( e, toolBar.firstChild() ); e = d.createElement( "action" ); e.setAttribute( "name", "reload" ); toolBar.insertBefore( e, toolBar.firstChild() ); e = d.createElement( "action" ); e.setAttribute( "name", "print" ); toolBar.insertBefore( e, toolBar.firstChild() ); KAction *action = new KAction(KIcon("view-refresh"), "Reload", doc ); doc->actionCollection()->addAction( "reload", action ); QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload())); action->setShortcut(Qt::Key_F5); KAction *bench = new KAction( KIcon(), "Benchmark...", doc ); doc->actionCollection()->addAction( "debugDoBenchmark", bench ); QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark())); KAction *kprint = new KAction(KIcon("document-print"), "Print", doc ); doc->actionCollection()->addAction( "print", kprint ); QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print())); kprint->setEnabled(true); KToggleAction *ta = new KToggleAction( KIcon("edit-rename"), "Navigable", doc ); doc->actionCollection()->addAction( "navigable", ta ); ta->setShortcuts( KShortcut() ); ta->setChecked(doc->isCaretMode()); QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool))); ta = new KToggleAction( KIcon("document-properties"), "Editable", doc ); doc->actionCollection()->addAction( "editable", ta ); ta->setShortcuts( KShortcut() ); ta->setChecked(doc->isEditable()); QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool))); toplevel->guiFactory()->addClient( doc ); doc->setJScriptEnabled(true); doc->setJavaEnabled(true); doc->setPluginsEnabled( true ); doc->setURLCursor(QCursor(Qt::PointingHandCursor)); a.setTopWidget(doc->widget()); QWidget::connect(doc, SIGNAL(setWindowCaption(QString)), doc->widget()->topLevelWidget(), SLOT(setCaption(QString))); doc->widget()->show(); toplevel->show(); doc->view()->viewport()->show(); doc->view()->widget()->show(); int ret = a.exec(); return ret; }
int main(int argc, char *argv[]) { QApplication a(argc, argv); if (a.arguments().count() <= 1) { qWarning() << "Argument expected: url to open"; return 1; } new KHTMLGlobal; KXmlGuiWindow *toplevel = new KXmlGuiWindow(); KHTMLPart *doc = new KHTMLPart(toplevel, toplevel, KHTMLPart::BrowserViewGUI); Dummy *dummy = new Dummy(doc); QObject::connect(doc->browserExtension(), SIGNAL(openUrlRequest(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments)), dummy, SLOT(slotOpenURL(QUrl,KParts::OpenUrlArguments,KParts::BrowserArguments))); QObject::connect(doc, SIGNAL(completed()), dummy, SLOT(handleDone())); QUrl url = QUrl::fromUserInput(a.arguments().at(1)); // TODO support for relative paths if (url.path().right(4).toLower() == ".xml") { KParts::OpenUrlArguments args(doc->arguments()); args.setMimeType("text/xml"); doc->setArguments(args); } doc->openUrl(url); toplevel->setCentralWidget(doc->widget()); toplevel->resize(800, 600); QDomDocument d = doc->domDocument(); QDomElement viewMenu = d.documentElement().firstChild().childNodes().item(2).toElement(); QDomElement e = d.createElement("action"); e.setAttribute("name", "debugRenderTree"); viewMenu.appendChild(e); e = d.createElement("action"); e.setAttribute("name", "debugDOMTree"); viewMenu.appendChild(e); e = d.createElement("action"); e.setAttribute("name", "debugDoBenchmark"); viewMenu.appendChild(e); QDomElement toolBar = d.documentElement().firstChild().nextSibling().toElement(); e = d.createElement("action"); e.setAttribute("name", "editable"); toolBar.insertBefore(e, toolBar.firstChild()); e = d.createElement("action"); e.setAttribute("name", "navigable"); toolBar.insertBefore(e, toolBar.firstChild()); e = d.createElement("action"); e.setAttribute("name", "reload"); toolBar.insertBefore(e, toolBar.firstChild()); e = d.createElement("action"); e.setAttribute("name", "print"); toolBar.insertBefore(e, toolBar.firstChild()); QAction *action = new QAction(QIcon::fromTheme("view-refresh"), "Reload", doc); doc->actionCollection()->addAction("reload", action); QObject::connect(action, SIGNAL(triggered(bool)), dummy, SLOT(reload())); doc->actionCollection()->setDefaultShortcut(action, Qt::Key_F5); QAction *bench = new QAction(QIcon(), "Benchmark...", doc); doc->actionCollection()->addAction("debugDoBenchmark", bench); QObject::connect(bench, SIGNAL(triggered(bool)), dummy, SLOT(doBenchmark())); QAction *kprint = new QAction(QIcon::fromTheme("document-print"), "Print", doc); doc->actionCollection()->addAction("print", kprint); QObject::connect(kprint, SIGNAL(triggered(bool)), doc->browserExtension(), SLOT(print())); kprint->setEnabled(true); KToggleAction *ta = new KToggleAction(QIcon::fromTheme("edit-rename"), "Navigable", doc); doc->actionCollection()->addAction("navigable", ta); ta->setShortcuts(QList<QKeySequence>()); ta->setChecked(doc->isCaretMode()); QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleNavigable(bool))); ta = new KToggleAction(QIcon::fromTheme("document-properties"), "Editable", doc); doc->actionCollection()->addAction("editable", ta); ta->setShortcuts(QList<QKeySequence>()); ta->setChecked(doc->isEditable()); QWidget::connect(ta, SIGNAL(toggled(bool)), dummy, SLOT(toggleEditable(bool))); toplevel->guiFactory()->addClient(doc); doc->setJScriptEnabled(true); doc->setJavaEnabled(true); doc->setPluginsEnabled(true); doc->setURLCursor(QCursor(Qt::PointingHandCursor)); a.setActiveWindow(doc->widget()); QWidget::connect(doc, SIGNAL(setWindowCaption(QString)), doc->widget()->topLevelWidget(), SLOT(setCaption(QString))); doc->widget()->show(); toplevel->show(); doc->view()->viewport()->show(); doc->view()->widget()->show(); int ret = a.exec(); return ret; }