mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Clean up
Only keep one dynamic-cast. This fixes coverity warnings.
This commit is contained in:
parent
5b71349450
commit
340d747fff
@ -3735,7 +3735,6 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
||||
if (!doc_buffer->isClean()) {
|
||||
docstring const file =
|
||||
makeDisplayPath(doc_buffer->absFileName(), 20);
|
||||
doc_buffer->notifiesExternalModification();
|
||||
docstring text = doc_buffer->notifiesExternalModification() ?
|
||||
_("Any changes will be lost. "
|
||||
"Are you sure you want to load the version on disk "
|
||||
|
@ -1683,35 +1683,41 @@ void TabWorkArea::showBar(bool show)
|
||||
}
|
||||
|
||||
|
||||
GuiWorkArea * TabWorkArea::currentWorkArea()
|
||||
GuiWorkAreaContainer * TabWorkArea::widget(int index) const
|
||||
{
|
||||
if (count() == 0)
|
||||
return 0;
|
||||
|
||||
GuiWorkAreaContainer * wac =
|
||||
dynamic_cast<GuiWorkAreaContainer *>(currentWidget());
|
||||
QWidget * w = QTabWidget::widget(index);
|
||||
if (!w)
|
||||
return nullptr;
|
||||
GuiWorkAreaContainer * wac = dynamic_cast<GuiWorkAreaContainer *>(w);
|
||||
LATTEST(wac);
|
||||
GuiWorkArea * wa = wac->workArea();
|
||||
LATTEST(wa);
|
||||
return wa;
|
||||
return wac;
|
||||
}
|
||||
|
||||
|
||||
GuiWorkArea const * TabWorkArea::workArea(int index) const
|
||||
GuiWorkAreaContainer * TabWorkArea::currentWidget() const
|
||||
{
|
||||
return (dynamic_cast<GuiWorkAreaContainer *>(widget(index)))->workArea();
|
||||
return widget(currentIndex());
|
||||
}
|
||||
|
||||
|
||||
GuiWorkArea * TabWorkArea::workArea(int index)
|
||||
GuiWorkArea * TabWorkArea::workArea(int index) const
|
||||
{
|
||||
return (dynamic_cast<GuiWorkAreaContainer *>(widget(index)))->workArea();
|
||||
GuiWorkAreaContainer * w = widget(index);
|
||||
if (!w)
|
||||
return nullptr;
|
||||
return w->workArea();
|
||||
}
|
||||
|
||||
|
||||
GuiWorkArea * TabWorkArea::workArea(Buffer & buffer)
|
||||
GuiWorkArea * TabWorkArea::currentWorkArea() const
|
||||
{
|
||||
// FIXME: this method doesn't work if we have more than work area
|
||||
return workArea(currentIndex());
|
||||
}
|
||||
|
||||
|
||||
GuiWorkArea * TabWorkArea::workArea(Buffer & buffer) const
|
||||
{
|
||||
// FIXME: this method doesn't work if we have more than one work area
|
||||
// showing the same buffer.
|
||||
for (int i = 0; i != count(); ++i) {
|
||||
GuiWorkArea * wa = workArea(i);
|
||||
@ -2220,9 +2226,6 @@ GuiWorkAreaContainer::GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent)
|
||||
|
||||
void GuiWorkAreaContainer::updateDisplay()
|
||||
{
|
||||
if (!wa_)
|
||||
notificationFrame->hide();
|
||||
|
||||
Buffer const & buf = wa_->bufferView().buffer();
|
||||
notificationFrame->setHidden(!buf.notifiesExternalModification());
|
||||
QString const label = QString("<b>The file \"%1\" changed on disk.</b>")
|
||||
@ -2233,8 +2236,6 @@ void GuiWorkAreaContainer::updateDisplay()
|
||||
|
||||
void GuiWorkAreaContainer::dispatch(FuncRequest f) const
|
||||
{
|
||||
if (!wa_)
|
||||
return;
|
||||
lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
|
||||
wa_->bufferView().buffer().absFileName()));
|
||||
lyx::dispatch(f);
|
||||
|
@ -193,6 +193,8 @@ private:
|
||||
}; // EmbeddedWorkArea
|
||||
|
||||
|
||||
class GuiWorkAreaContainer;
|
||||
|
||||
/// A tabbed set of GuiWorkAreas.
|
||||
class TabWorkArea : public QTabWidget
|
||||
{
|
||||
@ -200,6 +202,10 @@ class TabWorkArea : public QTabWidget
|
||||
public:
|
||||
TabWorkArea(QWidget * parent = 0);
|
||||
|
||||
/// hide QTabWidget methods
|
||||
GuiWorkAreaContainer * currentWidget() const;
|
||||
GuiWorkAreaContainer * widget(int index) const;
|
||||
|
||||
///
|
||||
void setFullScreen(bool full_screen);
|
||||
void showBar(bool show);
|
||||
@ -207,10 +213,9 @@ public:
|
||||
bool setCurrentWorkArea(GuiWorkArea *);
|
||||
GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
|
||||
bool removeWorkArea(GuiWorkArea *);
|
||||
GuiWorkArea * currentWorkArea();
|
||||
GuiWorkArea * workArea(Buffer & buffer);
|
||||
GuiWorkArea const * workArea(int index) const;
|
||||
GuiWorkArea * workArea(int index);
|
||||
GuiWorkArea * currentWorkArea() const;
|
||||
GuiWorkArea * workArea(Buffer & buffer) const;
|
||||
GuiWorkArea * workArea(int index) const;
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
Q_SIGNALS:
|
||||
@ -230,7 +235,7 @@ public Q_SLOTS:
|
||||
void moveTab(int fromIndex, int toIndex);
|
||||
///
|
||||
void updateTabTexts();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
///
|
||||
void on_currentTabChanged(int index);
|
||||
@ -245,6 +250,9 @@ private Q_SLOTS:
|
||||
int indexOfWorkArea(GuiWorkArea * w) const;
|
||||
|
||||
private:
|
||||
using QTabWidget::addTab;
|
||||
using QTabWidget::insertTab;
|
||||
|
||||
/// true if position is a tab (rather than the blank space in tab bar)
|
||||
bool posIsTab(QPoint position);
|
||||
|
||||
@ -286,6 +294,7 @@ Q_SIGNALS:
|
||||
class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
|
||||
{
|
||||
Q_OBJECT
|
||||
// non-null
|
||||
GuiWorkArea * const wa_;
|
||||
void dispatch(FuncRequest f) const;
|
||||
|
||||
@ -298,8 +307,9 @@ protected:
|
||||
void mouseDoubleClickEvent(QMouseEvent * event); //override
|
||||
|
||||
public:
|
||||
///
|
||||
/// wa != 0
|
||||
GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
|
||||
/// non-null
|
||||
GuiWorkArea * workArea() const { return wa_; }
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user