本文整理汇总了C++中ktexteditor::View::document方法的典型用法代码示例。如果您正苦于以下问题:C++ View::document方法的具体用法?C++ View::document怎么用?C++ View::document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::View
的用法示例。
在下文中一共展示了View::document方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: docUrl
QUrl KateBuildView::docUrl()
{
KTextEditor::View *kv = m_win->activeView();
if (!kv) {
qDebug() << "no KTextEditor::View" << endl;
return QUrl();
}
if (kv->document()->isModified()) kv->document()->save();
return kv->document()->url();
}
示例2: slotDocChanged
void KatePluginSymbolViewerView::slotDocChanged()
{
slotRefreshSymbol();
KTextEditor::View *view = m_mainWindow->activeView();
//qDebug()<<"Document changed !!!!" << view;
if (view) {
connect(view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)),
this, SLOT(cursorPositionChanged()), Qt::UniqueConnection);
if (view->document()) {
connect(view->document(), SIGNAL(textChanged(KTextEditor::Document*)),
this, SLOT(slotDocEdited()), Qt::UniqueConnection);
}
}
示例3: sync
void Konsole::sync()
{
if(!KileConfig::syncConsoleDirWithTabs()) {
return;
}
KTextEditor::Document *doc = m_ki->activeTextDocument();
KTextEditor::View *view = Q_NULLPTR;
if(doc) {
view = doc->views().first();
}
if(view) {
QString finame;
QUrl url = view->document()->url();
if(url.path().isEmpty()) {
return;
}
QFileInfo fic(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path());
if(fic.isReadable()) {
setDirectory(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path());
}
}
}
示例4: cursorContextDeclaration
///The first definition that belongs to a context that surrounds the current cursor
Declaration* cursorContextDeclaration() {
KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView();
if(!view)
return nullptr;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
TopDUContext* ctx = DUChainUtils::standardContextForUrl(view->document()->url());
if(!ctx)
return nullptr;
KTextEditor::Cursor cursor(view->cursorPosition());
DUContext* subCtx = ctx->findContext(ctx->transformToLocalRevision(cursor));
while(subCtx && !subCtx->owner())
subCtx = subCtx->parentContext();
Declaration* definition = nullptr;
if(!subCtx || !subCtx->owner())
definition = DUChainUtils::declarationInLine(cursor, ctx);
else
definition = subCtx->owner();
if(!definition)
return nullptr;
return definition;
}
示例5: cursorDeclaration
Declaration* cursorDeclaration() {
KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView();
if(!view)
return nullptr;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
return DUChainUtils::declarationForDefinition( DUChainUtils::itemUnderCursor( view->document()->url(), KTextEditor::Cursor(view->cursorPosition()) ).declaration );
}
示例6: run
void View::run()
{
KTextEditor::View *view = mw->activeView();
if (!view) {
return;
}
if (m_global.saveBeforeRun) {
view->document()->save();
}
KTextEditor::Document *doc = view->document();
QString filename = doc->url().path();
QString directory = doc->url().directory();
kDebug() << filename << "-" << directory;
QString cmd = txtCommand->text();
cmd = cmd.replace("%filename", filename).replace("%directory", directory);
execute(cmd);
}
示例7: displayBuildResult
void KateBuildView::displayBuildResult(const QString &msg, KTextEditor::Message::MessageType level)
{
KTextEditor::View *kv = m_win->activeView();
if (!kv) return;
delete m_infoMessage;
m_infoMessage = new KTextEditor::Message(xi18nc("@info", "<title>Make Results:</title><nl/>%1", msg), level);
m_infoMessage->setWordWrap(true);
m_infoMessage->setPosition(KTextEditor::Message::BottomInView);
m_infoMessage->setAutoHide(5000);
m_infoMessage->setAutoHideMode(KTextEditor::Message::Immediate);
m_infoMessage->setView(kv);
kv->document()->postMessage(m_infoMessage);
}
示例8: currentWord
QString KateCTagsView::currentWord( )
{
KTextEditor::View *kv = mainWindow()->activeView();
if (!kv) {
kDebug() << "no KTextEditor::View" << endl;
return QString();
}
if (kv->selection()) {
return kv->selectionText();
}
if (!kv->cursorPosition().isValid()) {
kDebug() << "cursor not valid!" << endl;
return QString();
}
int line = kv->cursorPosition().line();
int col = kv->cursorPosition().column();
bool includeColon = m_ctagsUi.cmdEdit->text().contains("--extra=+q");
QString linestr = kv->document()->line(line);
int startPos = qMax(qMin(col, linestr.length()-1), 0);
int endPos = startPos;
while (startPos >= 0 && (linestr[startPos].isLetterOrNumber() ||
(linestr[startPos] == ':' && includeColon) ||
linestr[startPos] == '_' ||
linestr[startPos] == '~'))
{
startPos--;
}
while (endPos < (int)linestr.length() && (linestr[endPos].isLetterOrNumber() ||
(linestr[endPos] == ':' && includeColon) ||
linestr[endPos] == '_')) {
endPos++;
}
if (startPos == endPos) {
kDebug() << "no word found!" << endl;
return QString();
}
//kDebug() << linestr.mid(startPos+1, endPos-startPos-1);
return linestr.mid(startPos+1, endPos-startPos-1);
}
示例9: cg
KTextEditor::View *KateViewSpace::createView(KTextEditor::Document *doc)
{
// should only be called if a view does not yet exist
Q_ASSERT(! m_docToView.contains(doc));
/**
* Create a fresh view
*/
KTextEditor::View *v = doc->createView(stack, m_viewManager->mainWindow()->wrapper());
// set status bar to right state
v->setStatusBarEnabled(m_viewManager->mainWindow()->showStatusBar());
// restore the config of this view if possible
if (!m_group.isEmpty()) {
QString fn = v->document()->url().toString();
if (! fn.isEmpty()) {
QString vgroup = QString::fromLatin1("%1 %2").arg(m_group).arg(fn);
KateSession::Ptr as = KateApp::self()->sessionManager()->activeSession();
if (as->config() && as->config()->hasGroup(vgroup)) {
KConfigGroup cg(as->config(), vgroup);
v->readSessionConfig(cg);
}
}
}
// register document, it is shown below through showView() then
if (! m_lruDocList.contains(doc)) {
registerDocument(doc);
Q_ASSERT(m_lruDocList.contains(doc));
}
// insert View into stack
stack->addWidget(v);
m_docToView[doc] = v;
showView(v);
return v;
}
示例10: slotDocumentOpen
void KateViewManager::slotDocumentOpen ()
{
KTextEditor::View *cv = activeView();
if (cv)
{
KEncodingFileDialog::Result r = KEncodingFileDialog::getOpenUrlsAndEncoding(
KateDocManager::self()->editor()->defaultEncoding(),
cv->document()->url().url(),
QString(), m_mainWindow, i18n("Open File"));
KateDocumentInfo docInfo;
docInfo.openedByUser = true;
KTextEditor::Document *lastID = 0;
for (KUrl::List::Iterator i = r.URLs.begin(); i != r.URLs.end(); ++i)
lastID = openUrl( *i, r.encoding, false, false, docInfo);
if (lastID)
activateView (lastID);
}
}
示例11: createDocument
void EditorTabWidget::createDocument(KURL url/*, const QString& text*/)
{
/*
KTextEditor::PopupMenuInterface* popupIf = dynamic_cast<KTextEditor::PopupMenuInterface*>(w->view());
if (popupIf)
popupIf->installPopup((QPopupMenu *)quantaApp->factory()->container("popup_editor", quantaApp));
*/
KTextEditor::View *view;
if((view = openKDocument(url)) == NULL) return;
KTextEditor::MarkInterfaceExtension* imarkex =
dynamic_cast<KTextEditor::MarkInterfaceExtension*>(view->document());
if(imarkex) {
KIconLoader *loader = KGlobal::iconLoader();
#if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3)
imarkex->setPixmap(KTextEditor::MarkInterface::Execution, loader->loadIcon(
"executionpoint", KIcon::Small));
#else
imarkex->setPixmap(KTextEditor::MarkInterface::markType05, loader->loadIcon(
"executionpoint", KIcon::Small));
#endif
imarkex->setPixmap(KTextEditor::MarkInterface::markType08, loader->loadIcon(
"preexecutionpoint", KIcon::Small));
#if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3)
imarkex->setPixmap(KTextEditor::MarkInterface::BreakpointActive, loader->loadIcon(
"activebreakpoint",KIcon::Small));
#else
imarkex->setPixmap(KTextEditor::MarkInterface::markType02, loader->loadIcon(
"activebreakpoint", KIcon::Small));
#endif
#if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3)
imarkex->setPixmap(KTextEditor::MarkInterface::BreakpointDisabled, loader->loadIcon(
"disabledbreakpoint",KIcon::Small));
#else
imarkex->setPixmap(KTextEditor::MarkInterface::markType04, loader->loadIcon(
"disabledbreakpoint", KIcon::Small));
#endif
#if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3)
imarkex->setDescription(KTextEditor::MarkInterface::BreakpointActive, "Breakpoint");
#else
imarkex->setDescription(KTextEditor::MarkInterface::markType02, "Breakpoint");
#endif
#if (KDE_VERSION_MAJOR >= 3) && (KDE_VERSION_MINOR >= 3)
imarkex->setMarksUserChangable(KTextEditor::MarkInterface::Bookmark + KTextEditor::MarkInterface::BreakpointActive);
#else
imarkex->setMarksUserChangable(KTextEditor::MarkInterface::markType01 + KTextEditor::MarkInterface::markType02);
#endif
}
connect(view->document(), SIGNAL(marksChanged()), this, SLOT(slotMarkChanged()));
connect(view->document(), SIGNAL(undoChanged()), this, SLOT(slotUndoChanged()));
Document_t d;
d.path = url.path();
d.view = view;
d.hasUndo = false;
d.hasRedo = false;
//d.marks = imark->marks();
m_docList.append(d);
disableUndoAction();
disableRedoAction();
}
示例12: slotValidate
bool PluginKateXMLCheckView::slotValidate()
{
qDebug() << "slotValidate()";
m_mainWindow->showToolView (dock);
m_validating = false;
m_dtdname = "";
KTextEditor::View *kv = m_mainWindow->activeView();
if( ! kv )
return false;
delete m_tmp_file;
m_tmp_file = new QTemporaryFile();
if( !m_tmp_file->open() ) {
qDebug() << "Error (slotValidate()): could not create '" << m_tmp_file->fileName() << "': " << m_tmp_file->errorString();
KMessageBox::error(0, i18n("<b>Error:</b> Could not create "
"temporary file '%1'.", m_tmp_file->fileName()));
delete m_tmp_file;
m_tmp_file=0L;
return false;
}
QTextStream s ( m_tmp_file );
s << kv->document()->text();
s.flush();
QString exe = QStandardPaths::findExecutable("xmllint");
if( exe.isEmpty() ) {
exe = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, "xmllint");
}
//qDebug() << "exe=" <<exe;
// // use catalogs for KDE docbook:
// if( ! getenv("XML_CATALOG_FILES") ) {
// KComponentData ins("katexmlcheckplugin");
// QString catalogs;
// catalogs += ins.dirs()->findResource("data", "ksgmltools2/customization/catalog.xml");
// qDebug() << "catalogs: " << catalogs;
// setenv("XML_CATALOG_FILES", QFile::encodeName( catalogs ).data(), 1);
// }
//qDebug() << "**catalogs: " << getenv("XML_CATALOG_FILES");
QStringList args;
args << "--noout";
// tell xmllint the working path of the document's file, if possible.
// otherweise it will not find relative DTDs
// I should give path to location of file, but remove filename
// I can make QUrl.adjusted(rm filename).path()
// or QUrl.toString(rm filename|rm schema)
// Result is the same. Which variant should I choose?
//QString path = kv->document()->url().adjusted(QUrl::RemoveFilename).path();
// xmllint uses space- or colon-separated path option, so spaces should be encoded to %20. It is done with EncodeSpaces.
// Now what about colons in file names or paths?
// This way xmllint works normally:
// xmllint --noout --path "/home/user/my/with:colon/" --valid "/home/user/my/with:colon/demo-1.xml"
// but because this plugin makes temp file path to file is another and this way xmllint refuses to find dtd:
// xmllint --noout --path "/home/user/my/with:colon/" --valid "/tmp/kate.X23725"
// As workaround we can encode ':' with %3A
QString path = kv->document()->url().toString(QUrl::RemoveFilename|QUrl::PreferLocalFile|QUrl::EncodeSpaces);
path.replace(":","%3A");
// because of such inconvinience with xmllint and pathes, maybe switch to xmlstarlet?
qDebug() << "path=" << path;
if (!path.isEmpty()) {
args << "--path" << path;
}
// heuristic: assume that the doctype is in the first 10,000 bytes:
QString text_start = kv->document()->text().left(10000);
// remove comments before looking for doctype (as a doctype might be commented out
// and needs to be ignored then):
QRegExp re("<!--.*-->");
re.setMinimal(true);
text_start.remove(re);
QRegExp re_doctype("<!DOCTYPE\\s+(.*)\\s+(?:PUBLIC\\s+[\"'].*[\"']\\s+[\"'](.*)[\"']|SYSTEM\\s+[\"'](.*)[\"'])", Qt::CaseInsensitive);
re_doctype.setMinimal(true);
if( re_doctype.indexIn(text_start) != -1 ) {
QString dtdname;
if( ! re_doctype.cap(2).isEmpty() ) {
dtdname = re_doctype.cap(2);
} else {
dtdname = re_doctype.cap(3);
}
if( !dtdname.startsWith("http:") ) { // todo: u_dtd.isLocalFile() doesn't work :-(
// a local DTD is used
m_validating = true;
args << "--valid";
} else {
m_validating = true;
args << "--valid";
}
} else if( text_start.indexOf("<!DOCTYPE") != -1 ) {
// DTD is inside the XML file
m_validating = true;
args << "--valid";
}
//.........这里部分代码省略.........