mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
Transfer some code from GuiView to TabWorkArea.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20806 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
24cf8ce58f
commit
769185bc90
@ -868,13 +868,7 @@ void GuiViewBase::setCurrentWorkArea(WorkArea * work_area)
|
||||
|
||||
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(work_area);
|
||||
BOOST_ASSERT(wa);
|
||||
if (wa != d.tab_widget_->currentWidget())
|
||||
// Switch to the work area.
|
||||
d.tab_widget_->setCurrentWidget(wa);
|
||||
else
|
||||
// Make sure the work area is up to date.
|
||||
d.tab_widget_->on_currentTabChanged(d.tab_widget_->currentIndex());
|
||||
wa->setFocus();
|
||||
d.tab_widget_->setCurrentWorkArea(wa);
|
||||
}
|
||||
|
||||
|
||||
@ -891,26 +885,14 @@ void GuiViewBase::removeWorkArea(WorkArea * work_area)
|
||||
updateToc();
|
||||
|
||||
GuiWorkArea * gwa = dynamic_cast<GuiWorkArea *>(work_area);
|
||||
gwa->setUpdatesEnabled(false);
|
||||
BOOST_ASSERT(gwa);
|
||||
int index = d.tab_widget_->indexOf(gwa);
|
||||
d.tab_widget_->removeTab(index);
|
||||
|
||||
delete gwa;
|
||||
|
||||
if (d.tab_widget_->count()) {
|
||||
// make sure the next work area is enabled.
|
||||
d.tab_widget_->currentWidget()->setUpdatesEnabled(true);
|
||||
// Hide tabbar if there's only one tab.
|
||||
d.tab_widget_->showBar(d.tab_widget_->count() > 1);
|
||||
return;
|
||||
}
|
||||
d.tab_widget_->removeWorkArea(gwa);
|
||||
|
||||
getDialogs().hideBufferDependent();
|
||||
if (d.stack_widget_) {
|
||||
|
||||
if (d.tab_widget_->count() == 0 && d.stack_widget_)
|
||||
// No more work area, switch to the background widget.
|
||||
d.setBackground();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -728,6 +728,46 @@ void TabWorkArea::showBar(bool show)
|
||||
}
|
||||
|
||||
|
||||
bool TabWorkArea::setCurrentWorkArea(GuiWorkArea * work_area)
|
||||
{
|
||||
BOOST_ASSERT(work_area);
|
||||
int index = indexOf(work_area);
|
||||
if (index == -1)
|
||||
return false;
|
||||
|
||||
if (index == currentIndex())
|
||||
// Make sure the work area is up to date.
|
||||
on_currentTabChanged(index);
|
||||
else
|
||||
// Switch to the work area.
|
||||
setCurrentIndex(index);
|
||||
work_area->setFocus();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool TabWorkArea::removeWorkArea(GuiWorkArea * work_area)
|
||||
{
|
||||
BOOST_ASSERT(work_area);
|
||||
int index = indexOf(work_area);
|
||||
if (index == -1)
|
||||
return false;
|
||||
|
||||
work_area->setUpdatesEnabled(false);
|
||||
removeTab(index);
|
||||
delete work_area;
|
||||
|
||||
if (count()) {
|
||||
// make sure the next work area is enabled.
|
||||
currentWidget()->setUpdatesEnabled(true);
|
||||
// Hide tabbar if there's only one tab.
|
||||
showBar(count() > 1);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void TabWorkArea::on_currentTabChanged(int i)
|
||||
{
|
||||
GuiWorkArea * wa = dynamic_cast<GuiWorkArea *>(widget(i));
|
||||
|
@ -180,6 +180,8 @@ class TabWorkArea : public QTabWidget
|
||||
public:
|
||||
TabWorkArea(QWidget * parent = 0);
|
||||
void showBar(bool show);
|
||||
bool setCurrentWorkArea(GuiWorkArea *);
|
||||
bool removeWorkArea(GuiWorkArea *);
|
||||
|
||||
Q_SIGNALS:
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user