mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +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()) {
|
if (!doc_buffer->isClean()) {
|
||||||
docstring const file =
|
docstring const file =
|
||||||
makeDisplayPath(doc_buffer->absFileName(), 20);
|
makeDisplayPath(doc_buffer->absFileName(), 20);
|
||||||
doc_buffer->notifiesExternalModification();
|
|
||||||
docstring text = doc_buffer->notifiesExternalModification() ?
|
docstring text = doc_buffer->notifiesExternalModification() ?
|
||||||
_("Any changes will be lost. "
|
_("Any changes will be lost. "
|
||||||
"Are you sure you want to load the version on disk "
|
"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)
|
QWidget * w = QTabWidget::widget(index);
|
||||||
return 0;
|
if (!w)
|
||||||
|
return nullptr;
|
||||||
GuiWorkAreaContainer * wac =
|
GuiWorkAreaContainer * wac = dynamic_cast<GuiWorkAreaContainer *>(w);
|
||||||
dynamic_cast<GuiWorkAreaContainer *>(currentWidget());
|
|
||||||
LATTEST(wac);
|
LATTEST(wac);
|
||||||
GuiWorkArea * wa = wac->workArea();
|
return wac;
|
||||||
LATTEST(wa);
|
|
||||||
return wa;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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.
|
// showing the same buffer.
|
||||||
for (int i = 0; i != count(); ++i) {
|
for (int i = 0; i != count(); ++i) {
|
||||||
GuiWorkArea * wa = workArea(i);
|
GuiWorkArea * wa = workArea(i);
|
||||||
@ -2220,9 +2226,6 @@ GuiWorkAreaContainer::GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent)
|
|||||||
|
|
||||||
void GuiWorkAreaContainer::updateDisplay()
|
void GuiWorkAreaContainer::updateDisplay()
|
||||||
{
|
{
|
||||||
if (!wa_)
|
|
||||||
notificationFrame->hide();
|
|
||||||
|
|
||||||
Buffer const & buf = wa_->bufferView().buffer();
|
Buffer const & buf = wa_->bufferView().buffer();
|
||||||
notificationFrame->setHidden(!buf.notifiesExternalModification());
|
notificationFrame->setHidden(!buf.notifiesExternalModification());
|
||||||
QString const label = QString("<b>The file \"%1\" changed on disk.</b>")
|
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
|
void GuiWorkAreaContainer::dispatch(FuncRequest f) const
|
||||||
{
|
{
|
||||||
if (!wa_)
|
|
||||||
return;
|
|
||||||
lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
|
lyx::dispatch(FuncRequest(LFUN_BUFFER_SWITCH,
|
||||||
wa_->bufferView().buffer().absFileName()));
|
wa_->bufferView().buffer().absFileName()));
|
||||||
lyx::dispatch(f);
|
lyx::dispatch(f);
|
||||||
|
@ -193,6 +193,8 @@ private:
|
|||||||
}; // EmbeddedWorkArea
|
}; // EmbeddedWorkArea
|
||||||
|
|
||||||
|
|
||||||
|
class GuiWorkAreaContainer;
|
||||||
|
|
||||||
/// A tabbed set of GuiWorkAreas.
|
/// A tabbed set of GuiWorkAreas.
|
||||||
class TabWorkArea : public QTabWidget
|
class TabWorkArea : public QTabWidget
|
||||||
{
|
{
|
||||||
@ -200,6 +202,10 @@ class TabWorkArea : public QTabWidget
|
|||||||
public:
|
public:
|
||||||
TabWorkArea(QWidget * parent = 0);
|
TabWorkArea(QWidget * parent = 0);
|
||||||
|
|
||||||
|
/// hide QTabWidget methods
|
||||||
|
GuiWorkAreaContainer * currentWidget() const;
|
||||||
|
GuiWorkAreaContainer * widget(int index) const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void setFullScreen(bool full_screen);
|
void setFullScreen(bool full_screen);
|
||||||
void showBar(bool show);
|
void showBar(bool show);
|
||||||
@ -207,10 +213,9 @@ public:
|
|||||||
bool setCurrentWorkArea(GuiWorkArea *);
|
bool setCurrentWorkArea(GuiWorkArea *);
|
||||||
GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
|
GuiWorkArea * addWorkArea(Buffer & buffer, GuiView & view);
|
||||||
bool removeWorkArea(GuiWorkArea *);
|
bool removeWorkArea(GuiWorkArea *);
|
||||||
GuiWorkArea * currentWorkArea();
|
GuiWorkArea * currentWorkArea() const;
|
||||||
GuiWorkArea * workArea(Buffer & buffer);
|
GuiWorkArea * workArea(Buffer & buffer) const;
|
||||||
GuiWorkArea const * workArea(int index) const;
|
GuiWorkArea * workArea(int index) const;
|
||||||
GuiWorkArea * workArea(int index);
|
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
@ -245,6 +250,9 @@ private Q_SLOTS:
|
|||||||
int indexOfWorkArea(GuiWorkArea * w) const;
|
int indexOfWorkArea(GuiWorkArea * w) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
using QTabWidget::addTab;
|
||||||
|
using QTabWidget::insertTab;
|
||||||
|
|
||||||
/// true if position is a tab (rather than the blank space in tab bar)
|
/// true if position is a tab (rather than the blank space in tab bar)
|
||||||
bool posIsTab(QPoint position);
|
bool posIsTab(QPoint position);
|
||||||
|
|
||||||
@ -286,6 +294,7 @@ Q_SIGNALS:
|
|||||||
class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
|
class GuiWorkAreaContainer : public QWidget, public Ui::WorkAreaUi
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
// non-null
|
||||||
GuiWorkArea * const wa_;
|
GuiWorkArea * const wa_;
|
||||||
void dispatch(FuncRequest f) const;
|
void dispatch(FuncRequest f) const;
|
||||||
|
|
||||||
@ -298,8 +307,9 @@ protected:
|
|||||||
void mouseDoubleClickEvent(QMouseEvent * event); //override
|
void mouseDoubleClickEvent(QMouseEvent * event); //override
|
||||||
|
|
||||||
public:
|
public:
|
||||||
///
|
/// wa != 0
|
||||||
GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
|
GuiWorkAreaContainer(GuiWorkArea * wa, QWidget * parent = 0);
|
||||||
|
/// non-null
|
||||||
GuiWorkArea * workArea() const { return wa_; }
|
GuiWorkArea * workArea() const { return wa_; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user