本文整理汇总了C++中QSharedPointer类的典型用法代码示例。如果您正苦于以下问题:C++ QSharedPointer类的具体用法?C++ QSharedPointer怎么用?C++ QSharedPointer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSharedPointer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: data
QVariant SearchTrackModel::data(const QModelIndex &index, int role) const
{
QSharedPointer<SongView> s = mMatchingSongs.at(index.row());
return QVariant::fromValue(s.data());
}
示例2: prependShape
void RPolyline::appendShape(const RShape& shape, bool prepend) {
// const RDirected* directed = dynamic_cast<const RDirected*>(&shape);
// if (directed==NULL) {
// qWarning() << "RPolyline::appendShape: shape is not a line, arc or polyline: " << shape;
// return;
// }
const RPolyline* pl = dynamic_cast<const RPolyline*>(&shape);
if (pl!=NULL) {
if (prepend) {
for (int i=pl->countSegments()-1; i>=0; --i) {
QSharedPointer<RShape> s = pl->getSegmentAt(i);
if (s.isNull()) {
continue;
}
prependShape(*s);
}
}
else {
for (int i=0; i<pl->countSegments(); ++i) {
QSharedPointer<RShape> s = pl->getSegmentAt(i);
if (s.isNull()) {
continue;
}
appendShape(*s);
}
}
return;
}
const RDirected* directed = NULL;
double bulge = 0.0;
const RLine* line = dynamic_cast<const RLine*>(&shape);
if (line!=NULL) {
directed = line;
}
else {
const RArc* arc = dynamic_cast<const RArc*>(&shape);
if (arc!=NULL) {
bulge = arc->getBulge();
directed = arc;
}
}
if (directed==NULL) {
qWarning() << "RPolyline::appendShape: shape is not a line, arc or polyline: " << shape;
return;
}
RVector connectionPoint;
RVector nextPoint;
double gap;
if (prepend) {
connectionPoint = directed->getEndPoint();
nextPoint = directed->getStartPoint();
if (vertices.size()==0) {
appendVertex(connectionPoint);
}
gap = vertices.first().getDistanceTo(connectionPoint);
}
else {
connectionPoint = directed->getStartPoint();
nextPoint = directed->getEndPoint();
if (vertices.size()==0) {
appendVertex(connectionPoint);
}
gap = vertices.last().getDistanceTo(connectionPoint);
}
if (!RMath::fuzzyCompare(gap, 0.0, 1.0e-4)) {
qWarning() << "RPolyline::appendShape: arc or line not connected to polyline, gap: " << gap;
}
if (prepend) {
prependVertex(nextPoint);
setBulgeAt(0, bulge);
}
else {
appendVertex(nextPoint);
setBulgeAt(bulges.size()-2, bulge);
}
}
示例3: qDebug
void UserTaskDeadlineEmailGenerator::run()
{
qDebug() << "EmailGenerator: Generating UserClaimedTaskDeadlinePassed email";
UserClaimedTaskDeadlinePassed email_message;
email_message.ParseFromString(this->protoBody.toStdString());
ConfigParser settings;
QString error = "";
QSharedPointer<Email> email = QSharedPointer<Email>(new Email);
QSharedPointer<User> user = QSharedPointer<User>();
QSharedPointer<Task> task = QSharedPointer<Task>();
QSharedPointer<MySQLHandler> db = MySQLHandler::getInstance();
user = UserDao::getUser(db, email_message.translator_id());
task = TaskDao::getTask(db, email_message.task_id());
if(!user || !task) {
error = "Failed to generate UserClaimedTaskDeadlinePassed email: Unable to find relevant ";
error += "data in the Database. Searched for User ID ";
error += QString::number(email_message.translator_id()) + " and Task ID ";
error += QString::number(email_message.task_id()) + ".";
}
if(error.compare("") == 0) {
ctemplate::TemplateDictionary dict("user_claimed_task_deadline_exceeded");
if(user->display_name() != "") {
dict.ShowSection("USER_HAS_NAME");
dict.SetValue("USERNAME", user->display_name());
} else {
dict.ShowSection("NO_USER_NAME");
}
dict.SetValue("TASK_TITLE", task->title());
dict.SetValue("SITE_NAME", settings.get("site.name").toStdString());
QString task_type = "Translation";
switch(task->tasktype())
{
case 1:
task_type = "Segmentation";
break;
case 2:
task_type = "Translation";
break;
case 3:
task_type = "Proofreading";
break;
case 4:
task_type = "Desegmentation";
break;
}
dict.SetValue("TASK_TYPE", task_type.toStdString());
Locale taskSourceLocale = task->sourcelocale();
Locale taskTargetLocale = task->targetlocale();
dict.SetValue("SOURCE_LANGUAGE",taskSourceLocale.languagename());
dict.SetValue("TARGET_LANGUAGE",taskTargetLocale.languagename());
bool footer_enabled=(QString::compare("y", settings.get("email-footer.enabled")) == 0);
if (footer_enabled)
{
QString donate_link = settings.get("email-footer.donate_link");
ctemplate::TemplateDictionary* footer_dict = dict.AddIncludeDictionary("FOOTER");
QString footer_location = QString(TEMPLATE_DIRECTORY) + "emails/footer.tpl";
footer_dict -> SetValue("DONATE_LINK",donate_link.toStdString());
footer_dict -> SetFilename(footer_location.toStdString());
}
std::string email_body;
QString template_location = QString(TEMPLATE_DIRECTORY) + "emails/user-claimed-task-deadline-passed.tpl";
ctemplate::ExpandTemplate(template_location.toStdString(), ctemplate::DO_NOT_STRIP, &dict, &email_body);
email->setSender(settings.get("site.system_email_address"));;
email->addRecipient(QString::fromStdString(user->email()));
email->setSubject(settings.get("site.name") + ": Task Deadline Passed");
email->setBody(QString::fromUtf8(email_body.c_str()));
} else {
email = this->generateErrorEmail(error);
}
this->emailQueue->insert(email, currentMessage);
}
示例4: getStartLevel
//----------------------------------------------------------------------------
void ctkPluginPrivate::update0(const QUrl& updateLocation, bool wasActive)
{
const bool wasResolved = state == ctkPlugin::RESOLVED;
const int oldStartLevel = getStartLevel();
QSharedPointer<ctkPluginArchive> newArchive;
operation.fetchAndStoreOrdered(UPDATING);
try
{
// New plugin as stream supplied?
QUrl updateUrl(updateLocation);
if (updateUrl.isEmpty())
{
// Try Plugin-UpdateLocation
QString update = archive != 0 ? archive->getAttribute(ctkPluginConstants::PLUGIN_UPDATELOCATION) : QString();
if (update.isEmpty())
{
// Take original location
updateUrl = location;
}
}
if(updateUrl.scheme() != "file")
{
QString msg = "Unsupported update URL:";
msg += updateUrl.toString();
throw ctkPluginException(msg);
}
newArchive = fwCtx->storage->updatePluginArchive(archive, updateUrl, updateUrl.toLocalFile());
//checkCertificates(newArchive);
checkManifestHeaders();
newArchive->setStartLevel(oldStartLevel);
fwCtx->storage->replacePluginArchive(archive, newArchive);
}
catch (const std::exception& e)
{
if (!newArchive.isNull())
{
newArchive->purge();
}
operation.fetchAndStoreOrdered(IDLE);
if (wasActive)
{
try
{
this->q_func().data()->start();
}
catch (const ctkPluginException& pe)
{
fwCtx->listeners.frameworkError(this->q_func(), pe);
}
}
try
{
const ctkPluginException& pe = dynamic_cast<const ctkPluginException&>(e);
throw pe;
}
catch (std::bad_cast)
{
throw ctkPluginException(QString("Failed to get update plugin: ") + e.what(),
ctkPluginException::UNSPECIFIED);
}
}
bool purgeOld = false;
// TODO: check if dependent plug-ins are started. If not, set purgeOld to true.
// Activate new plug-in
QSharedPointer<ctkPluginArchive> oldArchive = archive;
archive = newArchive;
cachedRawHeaders.clear();
state = ctkPlugin::INSTALLED;
// Purge old archive
if (purgeOld)
{
//secure.purge(this, oldProtectionDomain);
if (oldArchive != 0)
{
oldArchive->purge();
}
}
// Broadcast events
if (wasResolved)
{
// TODO: use plugin threading
//bundleThread().bundleChanged(new BundleEvent(BundleEvent.UNRESOLVED, this));
fwCtx->listeners.emitPluginChanged(ctkPluginEvent(ctkPluginEvent::UNRESOLVED, this->q_func()));
}
//bundleThread().bundleChanged(new BundleEvent(BundleEvent.UPDATED, this));
fwCtx->listeners.emitPluginChanged(ctkPluginEvent(ctkPluginEvent::UPDATED, this->q_func()));
operation.fetchAndStoreOrdered(IDLE);
// Restart plugin previously stopped in the operation
if (wasActive)
{
try
//.........这里部分代码省略.........
示例5: newTagQuery
QSharedPointer<DataMark> QueryExecutor::insertNewTag(const QSharedPointer<DataMark>& tag)
{
bool result;
QSqlQuery newTagQuery(m_database);
qlonglong newId = nextTagKey();
newTagQuery.prepare("insert into tag (latitude, longitude, label, description, url, user_id, time, id) "
" values(:latitude,:longitude,:label,:description,:url,:user_id,:time,:id);");
newTagQuery.bindValue(":latitude", tag->getLatitude());
newTagQuery.bindValue(":longitude", tag->getLongitude());
newTagQuery.bindValue(":label", tag->getLabel().isEmpty()? "New Mark" : tag->getLabel());
newTagQuery.bindValue(":description", tag->getDescription());
newTagQuery.bindValue(":url", tag->getUrl());
newTagQuery.bindValue(":user_id", tag->getUser()->getId());
newTagQuery.bindValue(":time", tag->getTime().toUTC());
newTagQuery.bindValue(":id", newId);
QSqlQuery putTagToChannelQuery(m_database);
putTagToChannelQuery.prepare("insert into tags (tag_id,channel_id) values(:tag_id,:channel_id);");
putTagToChannelQuery.bindValue(":tag_id",newId);
putTagToChannelQuery.bindValue(":channel_id",tag->getChannel()->getId());
m_database.transaction();
result = newTagQuery.exec();
if(!result)
{
m_database.rollback();
return QSharedPointer<DataMark>(NULL);
}
result = putTagToChannelQuery.exec();
if(!result)
{
m_database.rollback();
return QSharedPointer<DataMark>(NULL);
}
m_database.commit();
QSharedPointer<DataMark> t(
new DbDataMark(newId,tag->getLatitude(),tag->getLongitude(),tag->getLabel(),
tag->getDescription(),tag->getUrl(),tag->getTime(),tag->getUser()->getId()));
t->setUser(tag->getUser());
t->setChannel(tag->getChannel());
return t;
}
示例6: type
//.........这里部分代码省略.........
\value WriteWithResponse If a characteristic is written using this mode, the peripheral
shall send a write confirmation. If the operation is
successful, the confirmation is emitted via the
\l characteristicWritten() signal. Otherwise the
\l CharacteristicWriteError is emitted.
A characteristic must have set the
\l QLowEnergyCharacteristic::Write property to support this
write mode.
\value WriteWithoutResponse If a characteristic is written using this mode, the remote peripheral
shall not send a write confirmation. The operation's success
cannot be determined and the payload must not be longer than 20 bytes.
A characteristic must have set the
\l QLowEnergyCharacteristic::WriteNoResponse property to support this
write mode. Its adavantage is a quicker
write operation as it may happen in between other
device interactions.
*/
/*!
\fn void QLowEnergyService::stateChanged(QLowEnergyService::ServiceState newState)
This signal is emitted when the service's state changes. The \a newState can also be
retrieved via \l state().
\sa state()
*/
/*!
\fn void QLowEnergyService::error(QLowEnergyService::ServiceError newError)
This signal is emitted when an error occurrs. The \a newError parameter
describes the error that occurred.
*/
/*!
\fn void QLowEnergyService::characteristicWritten(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
This signal is emitted when the value of \a characteristic
is successfully changed to \a newValue. The change must have been triggered
by calling \l writeCharacteristic(). If the write operation is not successful,
the \l error() signal is emitted using the \l CharacteristicWriteError flag.
\note If \l writeCharacteristic() is called using the \l WriteWithoutResponse mode,
this signal and the \l error() are never emitted.
\sa writeCharacteristic()
*/
/*!
\fn void QLowEnergyService::characteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &newValue);
This signal is emitted when the value of \a characteristic is changed
by an event on the peripheral. The \a newValue parameter contains the
updated value of the \a characteristic.
The signal emission implies that change notifications must
have been activated via the characteristic's
\l {QBluetoothUuid::ClientCharacteristicConfiguration}{ClientCharacteristicConfiguration}
descriptor prior to the change event on the peripheral. More details on how this might be
done can be found further \l{notifications}{above}.
*/
/*!
\fn void QLowEnergyService::descriptorWritten(const QLowEnergyDescriptor &descriptor, const QByteArray &newValue)
This signal is emitted when the value of \a descriptor
is successfully changed to \a newValue. The change must have been caused
by calling \l writeDescriptor().
\sa writeDescriptor()
*/
/*!
\internal
QLowEnergyControllerPrivate creates instances of this class.
The user gets access to class instances via
\l QLowEnergyController::services().
*/
QLowEnergyService::QLowEnergyService(QSharedPointer<QLowEnergyServicePrivate> p,
QObject *parent)
: QObject(parent),
d_ptr(p)
{
qRegisterMetaType<QLowEnergyService::ServiceState>("QLowEnergyService::ServiceState");
qRegisterMetaType<QLowEnergyService::ServiceError>("QLowEnergyService::ServiceError");
connect(p.data(), SIGNAL(error(QLowEnergyService::ServiceError)),
this, SIGNAL(error(QLowEnergyService::ServiceError)));
connect(p.data(), SIGNAL(stateChanged(QLowEnergyService::ServiceState)),
this, SIGNAL(stateChanged(QLowEnergyService::ServiceState)));
connect(p.data(), SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)),
this, SIGNAL(characteristicChanged(QLowEnergyCharacteristic,QByteArray)));
connect(p.data(), SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)),
this, SIGNAL(characteristicWritten(QLowEnergyCharacteristic,QByteArray)));
connect(p.data(), SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)),
this, SIGNAL(descriptorWritten(QLowEnergyDescriptor,QByteArray)));
}
示例7: queryEntityDirect
bool RMemoryStorage::isSelected(REntity::Id entityId) {
QSharedPointer<REntity> e = queryEntityDirect(entityId);
return (!e.isNull() && e->isSelected());
}
示例8: queryObjectDirect
void RMemoryStorage::toggleUndoStatus(RObject::Id objectId) {
QSharedPointer<RObject> obj = queryObjectDirect(objectId);
if (!obj.isNull()) {
obj->setUndone(!obj->isUndone());
}
}
示例9: getLayerId
bool RMemoryStorage::saveObject(QSharedPointer<RObject> object, bool checkBlockRecursion, bool keepHandles) {
if (object.isNull()) {
return false;
}
// never allow two layers with identical names, update layer instead:
QSharedPointer<RLayer> layer = object.dynamicCast<RLayer>();
if (!layer.isNull()) {
RLayer::Id id = getLayerId(layer->getName());
if (id != RLayer::INVALID_ID) {
setObjectId(*layer, id);
}
}
// never allow two blocks with identical names, update block instead:
QSharedPointer<RBlock> block = object.dynamicCast<RBlock> ();
if (!block.isNull()) {
RBlock::Id id = getBlockId(block->getName());
if (id != RBlock::INVALID_ID) {
setObjectId(*block, id);
}
}
// avoid block recursions:
if (checkBlockRecursion) {
/*
QSharedPointer<RBlockReferenceEntity> blockRef = object.dynamicCast<RBlockReferenceEntity> ();
if (!blockRef.isNull()) {
RBlock::Id id = blockRef->getBlockId();
RBlock::Id refId = blockRef->getReferencedBlockId();
// check if block with 'id' may contain a block reference which refers to
// block with 'refid':
// 201308: too slow for large, complex drawings:
if (checkRecursion(id, refId)) {
qCritical("RMemoryStorage::saveObject: recursion found");
return false;
}
}
*/
}
QSharedPointer<REntity> entity = object.dynamicCast<REntity> ();
// assign new object ID to new objects:
if (object->getId() == RObject::INVALID_ID) {
setObjectId(*object, getNewObjectId());
// only set new handle if handle is not set already:
if (!keepHandles || object->getHandle()==RObject::INVALID_HANDLE) {
setObjectHandle(*object, getNewObjectHandle());
}
// assign draw order to new entities:
if (!entity.isNull()) {
entity->setDrawOrder(getMaxDrawOrder());
setMaxDrawOrder(getMaxDrawOrder()+1);
}
}
// TODO: save original object for rollback:
//if (inTransaction) {
//transactionObjectMap[object->getId()] = object;
//}
objectMap[object->getId()] = object;
//QSharedPointer<REntity> entity = object.dynamicCast<REntity> ();
if (!entity.isNull()) {
entityMap[entity->getId()] = entity;
blockEntityMap.insert(entity->getBlockId(), entity);
//qDebug() << "added " << entity->getId() << " to block " << entity->getBlockId();
setMaxDrawOrder(qMax(entity->getDrawOrder()+1, getMaxDrawOrder()));
}
if (!layer.isNull()) {
layerMap[object->getId()] = layer;
}
if (!block.isNull()) {
blockMap[object->getId()] = block;
}
return true;
}
示例10: SetSharedPointer
virtual void SetSharedPointer(const QSharedPointer<Filter> &filter)
{
_filter = filter.toWeakRef();
}
示例11: icon
ShareWidget::ShareWidget(QSharedPointer<Share> share,
bool isFile,
QWidget *parent) :
QWidget(parent),
_ui(new Ui::ShareWidget),
_share(share),
_isFile(isFile)
{
_ui->setupUi(this);
_ui->sharedWith->setText(share->getShareWith()->format());
// Create detailed permissions menu
QMenu *menu = new QMenu(this);
_permissionCreate = new QAction(tr("create"), this);
_permissionCreate->setCheckable(true);
_permissionUpdate = new QAction(tr("change"), this);
_permissionUpdate->setCheckable(true);
_permissionDelete = new QAction(tr("delete"), this);
_permissionDelete->setCheckable(true);
menu->addAction(_permissionUpdate);
/*
* Files can't have create or delete permissions
*/
if (!_isFile) {
menu->addAction(_permissionCreate);
menu->addAction(_permissionDelete);
}
_ui->permissionToolButton->setMenu(menu);
_ui->permissionToolButton->setPopupMode(QToolButton::InstantPopup);
QIcon icon(QLatin1String(":/client/resources/more.png"));
_ui->permissionToolButton->setIcon(icon);
// Set the permissions checkboxes
displayPermissions();
connect(_permissionUpdate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
connect(_permissionCreate, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
connect(_permissionDelete, SIGNAL(triggered(bool)), SLOT(slotPermissionsChanged()));
connect(_ui->permissionShare, SIGNAL(clicked(bool)), SLOT(slotPermissionsChanged()));
connect(_ui->permissionsEdit, SIGNAL(clicked(bool)), SLOT(slotEditPermissionsChanged()));
/*
* We don't show permssion share for federated shares
* https://github.com/owncloud/core/issues/22122#issuecomment-185637344
*/
if (share->getShareType() == Share::TypeRemote) {
_ui->permissionShare->setVisible(false);
_ui->permissionToolButton->setVisible(false);
}
connect(share.data(), SIGNAL(permissionsSet()), SLOT(slotPermissionsSet()));
connect(share.data(), SIGNAL(shareDeleted()), SLOT(slotShareDeleted()));
_ui->deleteShareButton->setIcon(QIcon::fromTheme(QLatin1String("user-trash"),
QIcon(QLatin1String(":/client/resources/delete.png"))));
if (!share->account()->capabilities().shareResharing()) {
_ui->permissionShare->hide();
}
}
示例12: qDebug
QSharedPointer<IChatMsg> ConversationService::sendMessage(quint32 conversationId, quint32 userId, const QSharedPointer<QString> & message) const {
qDebug() << "[ConversationService][sendMessage] c: " << conversationId << " u: " << userId << " message: " << *message;
//Filter invalid user
if(userId <= 0){ return manager->getProtocol().createResponse(RequestType::SendMessage, ErrorType::Custom, QStringLiteral("You have to login, before sending messages")); }
//Create new message
StreamableVector messages(new QVector<IStreamable*>());
messages->push_back(new Message());
Message * msg = static_cast<Message*>(messages->last());
msg->message = message;
msg->time = QDateTime::currentDateTime().toTime_t();
msg->conversationId = conversationId;
msg->userId = userId;
//Filter invalid messages
int messageLength = msg->message->length();
if(messageLength < 1 || messageLength > 500){ return manager->getProtocol().createResponse(RequestType::SendMessage, ErrorType::Custom, QStringLiteral("Invalid message size")); }
//Insert new message
QSharedPointer<QSqlQuery> query = manager->getDbService().prepare(
"INSERT INTO message (`message`, `time`, `conversation_id`, `user_id`) "
"VALUES (:message, :time, :conversationid, :userid);");
bool ok = false;
if(!query.isNull()){
query->bindValue(":message", *msg->message);
query->bindValue(":time", msg->time);
query->bindValue(":conversationid", msg->conversationId);
query->bindValue(":userid", msg->userId);
ok = manager->getDbService().exec(query);
}
if(!ok){ return manager->getProtocol().createResponse(RequestType::SendMessage, ErrorType::Internal, QStringLiteral("")); }
msg->id = query->lastInsertId().toInt();
//Get username for this message
QSharedPointer<QSqlQuery> userQuery = manager->getDbService().prepare("SELECT username FROM user WHERE user.id = :userid");
ok = false;
if(!userQuery.isNull()){
userQuery->bindValue(":userid", userId);
ok = manager->getDbService().exec(userQuery);
}
if(!ok || !userQuery->next()){ return manager->getProtocol().createResponse(RequestType::SendMessage, ErrorType::Internal, QStringLiteral("")); }
msg->username = QSharedPointer<QString>(new QString(userQuery->value(0).toString()));
//Send notifications to users
QSharedPointer<IChatMsg> response = manager->getProtocol().createResponseMessages(RequestType::SendMessage, true, messages, conversationId);
emit manager->getNotificationSender().newNotification(*response, QList<int>());
return QSharedPointer<IChatMsg>(); //No direct response; Sending user gets notification as well
}
示例13:
void View3D::setModel(QSharedPointer<Data3DTreeModel> pModel)
{
pModel->getRootEntity()->setParent(m_p3DObjectsEntity);
}
示例14: imgQt
void LayoutTest::layoutToXml() const {
QImage imgQt(mConfig.imagePath());
cv::Mat img = Image::qImage2Mat(imgQt);
Timer dt;
// find super pixels
rdf::SuperPixel superPixel(img);
if (!superPixel.compute())
qWarning() << "could not compute super pixel!";
QVector<QSharedPointer<Pixel> > sp = superPixel.getSuperPixels();
// find local orientation per pixel
rdf::LocalOrientation lo(sp);
if (!lo.compute())
qWarning() << "could not compute local orientation";
// smooth estimation
rdf::GraphCutOrientation pse(sp);
if (!pse.compute())
qWarning() << "could not compute set orientation";
//// find tab stops
//rdf::TabStopAnalysis tabStops(sp);
//if (!tabStops.compute())
// qWarning() << "could not compute text block segmentation!";
// find text lines
rdf::TextLineSegmentation textLines(sp);
if (!textLines.compute())
qWarning() << "could not compute text block segmentation!";
qInfo() << "algorithm computation time" << dt;
// drawing
cv::Mat rImg = img.clone();
// save super pixel image
//rImg = superPixel.drawSuperPixels(rImg);
//rImg = tabStops.draw(rImg);
rImg = textLines.draw(rImg);
QString dstPath = rdf::Utils::instance().createFilePath(mConfig.outputPath(), "-textlines");
rdf::Image::save(rImg, dstPath);
qDebug() << "debug image saved: " << dstPath;
// write XML -----------------------------------
QString loadXmlPath = rdf::PageXmlParser::imagePathToXmlPath(mConfig.imagePath());
rdf::PageXmlParser parser;
parser.read(loadXmlPath);
auto pe = parser.page();
pe->setCreator(QString("CVL"));
pe->setImageSize(QSize(img.rows, img.cols));
pe->setImageFileName(QFileInfo(mConfig.imagePath()).fileName());
// start writing content
auto ps = PixelSet::fromEdges(PixelSet::connect(sp));
if (!ps.empty()) {
QSharedPointer<Region> textRegion = QSharedPointer<Region>(new Region());
textRegion->setType(Region::type_text_region);
textRegion->setPolygon(ps[0]->convexHull());
for (auto tl : textLines.textLines()) {
textRegion->addUniqueChild(tl);
}
pe->rootRegion()->addUniqueChild(textRegion);
}
parser.write(mConfig.xmlPath(), pe);
qDebug() << "results written to" << mConfig.xmlPath();
}
示例15: javascriptDialog
void QWebEnginePagePrivate::javascriptDialog(QSharedPointer<JavaScriptDialogController> controller)
{
Q_Q(QWebEnginePage);
bool accepted = false;
QString promptResult;
switch (controller->type()) {
case AlertDialog:
q->javaScriptAlert(controller->securityOrigin(), controller->message());
accepted = true;
break;
case ConfirmDialog:
accepted = q->javaScriptConfirm(controller->securityOrigin(), controller->message());
break;
case PromptDialog:
accepted = q->javaScriptPrompt(controller->securityOrigin(), controller->message(), controller->defaultPrompt(), &promptResult);
if (accepted)
controller->textProvided(promptResult);
break;
case InternalAuthorizationDialog:
accepted = (QMessageBox::question(view, controller->title(), controller->message(), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes);
break;
default:
Q_UNREACHABLE();
}
if (accepted)
controller->accept();
else
controller->reject();
}