Commit c776efad authored by Christoph Cullmann's avatar Christoph Cullmann 🍨
Browse files

add api to check if document is visible in other windows

use new	api for the viewspace checking
parent 7014499f
Pipeline #253549 passed with stage
in 13 minutes and 51 seconds
......@@ -657,3 +657,13 @@ void KateApp::remoteMessageReceived(quint32, QByteArray message)
activeMainWindow()->activateView(doc);
}
}
bool KateApp::documentVisibleInOtherWindows(KTextEditor::Document *doc, KateMainWindow *window) const
{
for (auto win : m_mainWindows) {
if (win != window && win->viewManager()->viewspaceCountForDoc(doc) > 0) {
return true;
}
}
return false;
}
......@@ -226,6 +226,16 @@ public:
int mainWindowID(KateMainWindow *window);
/**
* Has the given document tabs/views inside main windows
* other then the given one?
*
* @param doc document to check
* @param window window to check
* @return is this document visible as tab/view/... in any other window?
*/
bool documentVisibleInOtherWindows(KTextEditor::Document *doc, KateMainWindow *window) const;
/**
* some stuff for the dcop API
*/
......
......@@ -1172,20 +1172,7 @@ int KateViewManager::viewspaceCountForDoc(KTextEditor::Document *doc) const
bool KateViewManager::docOnlyInOneViewspace(KTextEditor::Document *doc) const
{
auto count = viewspaceCountForDoc(doc);
if (count > 1) {
return false;
}
std::vector<KateMainWindow *> mainWindows;
const auto mws = KateApp::self()->mainWindows();
for (auto *mw : mws) {
auto w = qobject_cast<KateMainWindow *>(mw->window());
if (w && w != m_mainWindow) {
count += w->viewManager()->viewspaceCountForDoc(doc);
}
}
return count == 1;
return (viewspaceCountForDoc(doc) == 1) && !KateApp::self()->documentVisibleInOtherWindows(doc, m_mainWindow);
}
void KateViewManager::setShowUrlNavBar(bool show)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment