Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
e4fd93ed
Commit
e4fd93ed
authored
Jun 24, 2020
by
Tomaz Canabrava
Browse files
Fix Adding multiple documents / Clicking in the tabbar
parent
e921deff
Changes
3
Hide whitespace changes
Inline
Side-by-side
kate/katetabbar.cpp
View file @
e4fd93ed
...
...
@@ -44,6 +44,7 @@ public:
// pointer to tabbar
KateTabBar
*
q
=
nullptr
;
bool
isActive
=
false
;
KTextEditor
::
Document
*
beingAdded
;
};
/**
...
...
@@ -58,6 +59,7 @@ KateTabBar::KateTabBar(QWidget *parent)
setSizePolicy
(
QSizePolicy
::
Expanding
,
QSizePolicy
::
Minimum
);
setAcceptDrops
(
true
);
setExpanding
(
false
);
}
/**
...
...
@@ -132,7 +134,7 @@ void KateTabBar::mousePressEvent(QMouseEvent *event)
if
(
!
isActive
())
{
emit
activateViewSpaceRequested
();
}
Q
Widget
::
mousePressEvent
(
event
);
Q
TabBar
::
mousePressEvent
(
event
);
}
...
...
@@ -192,5 +194,32 @@ KTextEditor::Document *KateTabBar::tabDocument(int idx)
{
QVariant
data
=
ensureValidTabData
(
idx
);
KateTabButtonData
buttonData
=
data
.
value
<
KateTabButtonData
>
();
return
buttonData
.
doc
;
KTextEditor
::
Document
*
doc
=
nullptr
;
// The tab got activated before the correct finalixation,
// we need to plug the document before returning.
if
(
buttonData
.
doc
==
nullptr
&&
d
->
beingAdded
)
{
setTabDocument
(
idx
,
d
->
beingAdded
);
doc
=
d
->
beingAdded
;
d
->
beingAdded
=
nullptr
;
}
else
{
doc
=
buttonData
.
doc
;
}
return
doc
;
}
int
KateTabBar
::
insertTab
(
int
idx
,
KTextEditor
::
Document
*
doc
)
{
d
->
beingAdded
=
doc
;
return
insertTab
(
idx
,
doc
->
documentName
());
}
void
KateTabBar
::
tabInserted
(
int
idx
)
{
if
(
d
->
beingAdded
)
{
setTabDocument
(
idx
,
d
->
beingAdded
);
}
setTabToolTip
(
idx
,
tabDocument
(
idx
)
->
url
().
toDisplayString
());
d
->
beingAdded
=
nullptr
;
}
kate/katetabbar.h
View file @
e4fd93ed
...
...
@@ -43,6 +43,8 @@ class KateTabBar : public QTabBar
public:
explicit
KateTabBar
(
QWidget
*
parent
=
nullptr
);
~
KateTabBar
()
override
;
int
insertTab
(
int
idx
,
KTextEditor
::
Document
*
doc
);
void
tabInserted
(
int
idx
)
override
;
/**
* Get the ID of the tab that is located left of the current tab.
...
...
@@ -156,6 +158,9 @@ protected:
void
wheelEvent
(
QWheelEvent
*
event
)
override
;
private:
using
QTabBar
::
insertTab
;
using
QTabBar
::
addTab
;
class
KateTabBarPrivate
;
// pimpl data holder
KateTabBarPrivate
*
const
d
;
...
...
kate/kateviewspace.cpp
View file @
e4fd93ed
...
...
@@ -232,7 +232,6 @@ KTextEditor::View *KateViewSpace::createView(KTextEditor::Document *doc)
// insert View into stack
stack
->
addWidget
(
v
);
m_docToView
[
doc
]
=
v
;
showView
(
v
);
return
v
;
}
...
...
@@ -297,10 +296,9 @@ bool KateViewSpace::showView(KTextEditor::Document *document)
return
true
;
}
void
KateViewSpace
::
changeView
(
int
id
)
void
KateViewSpace
::
changeView
(
int
id
x
)
{
#if 0
KTextEditor::Document *doc = m_docToTabId.key(id);
KTextEditor
::
Document
*
doc
=
m_tabBar
->
tabDocument
(
idx
);
Q_ASSERT
(
doc
);
// make sure we open the view in this view space
...
...
@@ -310,7 +308,6 @@ void KateViewSpace::changeView(int id)
// tell the view manager to show the view
m_viewManager
->
activateView
(
doc
);
#endif
}
KTextEditor
::
View
*
KateViewSpace
::
currentView
()
...
...
@@ -343,7 +340,6 @@ void KateViewSpace::makeActive(bool focusCurrentView)
void
KateViewSpace
::
insertTab
(
int
index
,
KTextEditor
::
Document
*
doc
)
{
qDebug
()
<<
"Adding tab "
<<
index
<<
"with doc"
<<
doc
;
if
(
m_tabBar
->
documentIdx
(
doc
)
!=
-
1
)
{
return
;
}
...
...
@@ -351,9 +347,7 @@ void KateViewSpace::insertTab(int index, KTextEditor::Document *doc)
// doc should be in the lru list
Q_ASSERT
(
m_lruDocList
.
contains
(
doc
));
const
int
idx
=
m_tabBar
->
insertTab
(
index
,
doc
->
documentName
());
m_tabBar
->
setTabDocument
(
idx
,
doc
);
m_tabBar
->
setTabToolTip
(
idx
,
doc
->
url
().
toDisplayString
());
m_tabBar
->
insertTab
(
index
,
doc
);
updateDocumentState
(
doc
);
...
...
@@ -403,7 +397,6 @@ void KateViewSpace::removeTabs(int count)
void
KateViewSpace
::
addTabs
(
int
count
)
{
qDebug
()
<<
"Starting with "
<<
count
<<
"new tabs"
;
const
int
start
=
count
;
/// @p count tabs still fit into the tab bar: add as man as possible
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment