本文整理汇总了C++中KateMainWindow::activeDocumentUrl方法的典型用法代码示例。如果您正苦于以下问题:C++ KateMainWindow::activeDocumentUrl方法的具体用法?C++ KateMainWindow::activeDocumentUrl怎么用?C++ KateMainWindow::activeDocumentUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KateMainWindow
的用法示例。
在下文中一共展示了KateMainWindow::activeDocumentUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exec
bool KateAppCommands::exec(KTextEditor::View *view, const QString &cmd, QString &msg)
{
QStringList args(cmd.split( QRegExp("\\s+"), QString::SkipEmptyParts)) ;
QString command( args.takeFirst() );
KateMainWindow *mainWin = KateApp::self()->activeMainWindow();
if (re_write.exactMatch(command)) { //TODO: handle writing to specific file
if (!re_write.cap(1).isEmpty()) { // [a]ll
KateDocManager::self()->saveAll();
msg = i18n("All documents written to disk");
} else {
view->document()->documentSave();
msg = i18n("Document written to disk");
}
}
// Other buffer commands are implemented by the KateFileTree plugin
else if (re_close.exactMatch(command)) {
QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
}
else if (re_quit.exactMatch(command)) {
if (!re_quit.cap(2).isEmpty()) { // a[ll]
if (!re_quit.cap(1).isEmpty()) { // [w]rite
KateDocManager::self()->saveAll();
}
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
} else {
if (!re_quit.cap(1).isEmpty() && view->document()->isModified()) { // [w]rite
view->document()->documentSave();
}
if (mainWin->viewManager()->count() > 1) {
QTimer::singleShot(0, mainWin->viewManager(), SLOT(slotCloseCurrentViewSpace()));
} else {
if (KateDocManager::self()->documents() > 1)
QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
else
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
}
}
} else if (re_exit.exactMatch(command)) {
if (!re_exit.cap(1).isEmpty()) { // a[ll]
KateDocManager::self()->saveAll();
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
} else {
if (view->document()->isModified()) {
view->document()->documentSave();
}
if (KateDocManager::self()->documents() > 1)
QTimer::singleShot(0, mainWin, SLOT(slotFileClose()));
else
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
}
QTimer::singleShot(0, mainWin, SLOT(slotFileQuit()));
}
else if (re_edit.exactMatch(command)) {
QString argument = args.join(QString(' '));
if (argument.isEmpty() || argument == "!") {
view->document()->documentReload();
} else {
KUrl base = mainWin->activeDocumentUrl();
KUrl url;
KUrl arg2path(argument);
if (base.isValid()) { // first try to use the same path as the current open document has
url = KUrl(base.resolved(arg2path)); //resolved handles the case where the args is a relative path, and is the same as using KUrl(args) elsewise
} else { // else use the cwd
url = KUrl(KUrl(QDir::currentPath() + "/").resolved(arg2path)); // + "/" is needed because of http://lists.qt.nokia.com/public/qt-interest/2011-May/033913.html
}
QFileInfo file( url.toLocalFile() );
KTextEditor::Document *doc = KateDocManager::self()->findDocument( url );
if (doc) {
mainWin->viewManager()->activateView( doc );
} else if (file.exists()) {
mainWin->viewManager()->openUrl( url, QString(), true );
} else {
mainWin->viewManager()->openUrl( KUrl(), QString(), true )->saveAs ( url );
}
}
}
else if (re_new.exactMatch(command)) {
if (re_new.cap(1) == "v") { // vertical split
mainWin->viewManager()->slotSplitViewSpaceVert();
} else { // horizontal split
mainWin->viewManager()->slotSplitViewSpaceHoriz();
}
mainWin->viewManager()->slotDocumentNew();
}
else if (command == "enew") {
mainWin->viewManager()->slotDocumentNew();
}
else if (re_split.exactMatch(command)) {
mainWin->viewManager()->slotSplitViewSpaceHoriz();
}
else if (re_vsplit.exactMatch(command)) {
mainWin->viewManager()->slotSplitViewSpaceVert();
} else if (re_only.exactMatch(command)) {
mainWin->viewManager()->slotCloseOtherViews();
}
//.........这里部分代码省略.........