mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Use range-based loops in GuiView
This commit is contained in:
parent
b56a64a8ef
commit
d8e8a93a58
@ -207,9 +207,9 @@ public:
|
|||||||
int wline = 0;
|
int wline = 0;
|
||||||
int hline = fm.maxHeight();
|
int hline = fm.maxHeight();
|
||||||
QStringList::const_iterator sit;
|
QStringList::const_iterator sit;
|
||||||
for (sit = titlesegs.constBegin(); sit != titlesegs.constEnd(); ++sit) {
|
for (QString const & seg : titlesegs) {
|
||||||
if (fm.width(*sit) > wline)
|
if (fm.width(seg) > wline)
|
||||||
wline = fm.width(*sit);
|
wline = fm.width(seg);
|
||||||
}
|
}
|
||||||
// The longest line in the reference font (for English)
|
// The longest line in the reference font (for English)
|
||||||
// is 180. Calculate scale factor from that.
|
// is 180. Calculate scale factor from that.
|
||||||
@ -831,13 +831,11 @@ void GuiView::saveUISettings() const
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
|
||||||
// Save the toolbar private states
|
// Save the toolbar private states
|
||||||
ToolbarMap::iterator end = d.toolbars_.end();
|
for (auto const & tb_p : d.toolbars_)
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
tb_p.second->saveSession(settings);
|
||||||
it->second->saveSession(settings);
|
|
||||||
// Now take care of all other dialogs
|
// Now take care of all other dialogs
|
||||||
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
for (auto const & dlg_p : d.dialogs_)
|
||||||
for (; it!= d.dialogs_.end(); ++it)
|
dlg_p.second->saveSession(settings);
|
||||||
it->second->saveSession(settings);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -892,12 +890,10 @@ bool GuiView::restoreLayout()
|
|||||||
initToolbars();
|
initToolbars();
|
||||||
|
|
||||||
// init the toolbars that have not been restored
|
// init the toolbars that have not been restored
|
||||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
for (auto const & tb_p : guiApp->toolbars()) {
|
||||||
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
GuiToolbar * tb = toolbar(tb_p.name);
|
||||||
for (; cit != end; ++cit) {
|
|
||||||
GuiToolbar * tb = toolbar(cit->name);
|
|
||||||
if (tb && !tb->isRestored())
|
if (tb && !tb->isRestored())
|
||||||
initToolbar(cit->name);
|
initToolbar(tb_p.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update lock (all) toolbars positions
|
// update lock (all) toolbars positions
|
||||||
@ -932,9 +928,8 @@ void GuiView::updateLockToolbars()
|
|||||||
|
|
||||||
void GuiView::constructToolbars()
|
void GuiView::constructToolbars()
|
||||||
{
|
{
|
||||||
ToolbarMap::iterator it = d.toolbars_.begin();
|
for (auto const & tb_p : d.toolbars_)
|
||||||
for (; it != d.toolbars_.end(); ++it)
|
delete tb_p.second;
|
||||||
delete it->second;
|
|
||||||
d.toolbars_.clear();
|
d.toolbars_.clear();
|
||||||
|
|
||||||
// I don't like doing this here, but the standard toolbar
|
// I don't like doing this here, but the standard toolbar
|
||||||
@ -944,20 +939,16 @@ void GuiView::constructToolbars()
|
|||||||
d.layout_->move(0,0);
|
d.layout_->move(0,0);
|
||||||
|
|
||||||
// extracts the toolbars from the backend
|
// extracts the toolbars from the backend
|
||||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
for (ToolbarInfo const & inf : guiApp->toolbars())
|
||||||
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
d.toolbars_[inf.name] = new GuiToolbar(inf, *this);
|
||||||
for (; cit != end; ++cit)
|
|
||||||
d.toolbars_[cit->name] = new GuiToolbar(*cit, *this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::initToolbars()
|
void GuiView::initToolbars()
|
||||||
{
|
{
|
||||||
// extracts the toolbars from the backend
|
// extracts the toolbars from the backend
|
||||||
Toolbars::Infos::iterator cit = guiApp->toolbars().begin();
|
for (ToolbarInfo const & inf : guiApp->toolbars())
|
||||||
Toolbars::Infos::iterator end = guiApp->toolbars().end();
|
initToolbar(inf.name);
|
||||||
for (; cit != end; ++cit)
|
|
||||||
initToolbar(cit->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1169,12 +1160,9 @@ void GuiView::dropEvent(QDropEvent * event)
|
|||||||
vector<const Format *> found_formats;
|
vector<const Format *> found_formats;
|
||||||
|
|
||||||
// Find all formats that have the correct extension.
|
// Find all formats that have the correct extension.
|
||||||
vector<const Format *> const & import_formats
|
for (const Format * fmt : theConverters().importableFormats())
|
||||||
= theConverters().importableFormats();
|
if (fmt->hasExtension(ext))
|
||||||
vector<const Format *>::const_iterator it = import_formats.begin();
|
found_formats.push_back(fmt);
|
||||||
for (; it != import_formats.end(); ++it)
|
|
||||||
if ((*it)->hasExtension(ext))
|
|
||||||
found_formats.push_back(*it);
|
|
||||||
|
|
||||||
FuncRequest cmd;
|
FuncRequest cmd;
|
||||||
if (!found_formats.empty()) {
|
if (!found_formats.empty()) {
|
||||||
@ -1405,10 +1393,9 @@ bool GuiView::event(QEvent * e)
|
|||||||
if (lyxrc.full_screen_menubar)
|
if (lyxrc.full_screen_menubar)
|
||||||
menuBar()->hide();
|
menuBar()->hide();
|
||||||
if (lyxrc.full_screen_toolbars) {
|
if (lyxrc.full_screen_toolbars) {
|
||||||
ToolbarMap::iterator end = d.toolbars_.end();
|
for (auto const & tb_p : d.toolbars_)
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
if (tb_p.second->isVisibiltyOn() && tb_p.second->isVisible())
|
||||||
if (it->second->isVisibiltyOn() && it->second->isVisible())
|
tb_p.second->hide();
|
||||||
it->second->hide();
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i != d.splitter_->count(); ++i)
|
for (int i = 0; i != d.splitter_->count(); ++i)
|
||||||
d.tabWorkArea(i)->setFullScreen(true);
|
d.tabWorkArea(i)->setFullScreen(true);
|
||||||
@ -1423,10 +1410,9 @@ bool GuiView::event(QEvent * e)
|
|||||||
if (lyxrc.full_screen_menubar && !menuBar()->isVisible())
|
if (lyxrc.full_screen_menubar && !menuBar()->isVisible())
|
||||||
menuBar()->show();
|
menuBar()->show();
|
||||||
if (lyxrc.full_screen_toolbars) {
|
if (lyxrc.full_screen_toolbars) {
|
||||||
ToolbarMap::iterator end = d.toolbars_.end();
|
for (auto const & tb_p : d.toolbars_)
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
if (tb_p.second->isVisibiltyOn() && !tb_p.second->isVisible())
|
||||||
if (it->second->isVisibiltyOn() && !it->second->isVisible())
|
tb_p.second->show();
|
||||||
it->second->show();
|
|
||||||
//updateToolbars();
|
//updateToolbars();
|
||||||
}
|
}
|
||||||
for (int i = 0; i != d.splitter_->count(); ++i)
|
for (int i = 0; i != d.splitter_->count(); ++i)
|
||||||
@ -1708,7 +1694,6 @@ void GuiView::updateLayoutList()
|
|||||||
|
|
||||||
void GuiView::updateToolbars()
|
void GuiView::updateToolbars()
|
||||||
{
|
{
|
||||||
ToolbarMap::iterator end = d.toolbars_.end();
|
|
||||||
if (d.current_work_area_) {
|
if (d.current_work_area_) {
|
||||||
int context = 0;
|
int context = 0;
|
||||||
if (d.current_work_area_->bufferView().cursor().inMathed()
|
if (d.current_work_area_->bufferView().cursor().inMathed()
|
||||||
@ -1733,11 +1718,11 @@ void GuiView::updateToolbars()
|
|||||||
minibuffer_focus_ = false;
|
minibuffer_focus_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
for (auto const & tb_p : d.toolbars_)
|
||||||
it->second->update(context);
|
tb_p.second->update(context);
|
||||||
} else
|
} else
|
||||||
for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
|
for (auto const & tb_p : d.toolbars_)
|
||||||
it->second->update();
|
tb_p.second->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2510,8 +2495,8 @@ static bool import(GuiView * lv, FileName const & filename,
|
|||||||
if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
|
if (find(loaders.begin(), loaders.end(), format) == loaders.end()) {
|
||||||
vector<string>::const_iterator it = loaders.begin();
|
vector<string>::const_iterator it = loaders.begin();
|
||||||
vector<string>::const_iterator en = loaders.end();
|
vector<string>::const_iterator en = loaders.end();
|
||||||
for (; it != en; ++it) {
|
for (string const & loader : loaders) {
|
||||||
if (!theConverters().isReachable(format, *it))
|
if (!theConverters().isReachable(format, loader))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
string const tofile =
|
string const tofile =
|
||||||
@ -3225,11 +3210,7 @@ bool GuiView::closeWorkArea(GuiWorkArea * wa, bool close_buffer)
|
|||||||
bool GuiView::closeBuffer(Buffer & buf)
|
bool GuiView::closeBuffer(Buffer & buf)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
ListOfBuffers clist = buf.getChildren();
|
for (Buffer * child_buf : buf.getChildren()) {
|
||||||
ListOfBuffers::const_iterator it = clist.begin();
|
|
||||||
ListOfBuffers::const_iterator const bend = clist.end();
|
|
||||||
for (; it != bend; ++it) {
|
|
||||||
Buffer * child_buf = *it;
|
|
||||||
if (theBufferList().isOthersChild(&buf, child_buf)) {
|
if (theBufferList().isOthersChild(&buf, child_buf)) {
|
||||||
child_buf->setParent(nullptr);
|
child_buf->setParent(nullptr);
|
||||||
continue;
|
continue;
|
||||||
@ -3480,10 +3461,7 @@ bool GuiView::reloadBuffer(Buffer & buf)
|
|||||||
|
|
||||||
void GuiView::checkExternallyModifiedBuffers()
|
void GuiView::checkExternallyModifiedBuffers()
|
||||||
{
|
{
|
||||||
BufferList::iterator bit = theBufferList().begin();
|
for (Buffer * buf : theBufferList()) {
|
||||||
BufferList::iterator const bend = theBufferList().end();
|
|
||||||
for (; bit != bend; ++bit) {
|
|
||||||
Buffer * buf = *bit;
|
|
||||||
if (buf->fileName().exists() && buf->isChecksumModified()) {
|
if (buf->fileName().exists() && buf->isChecksumModified()) {
|
||||||
docstring text = bformat(_("Document \n%1$s\n has been externally modified."
|
docstring text = bformat(_("Document \n%1$s\n has been externally modified."
|
||||||
" Reload now? Any local changes will be lost."),
|
" Reload now? Any local changes will be lost."),
|
||||||
@ -4915,21 +4893,15 @@ void GuiView::disconnectDialog(string const & name)
|
|||||||
|
|
||||||
void GuiView::hideAll() const
|
void GuiView::hideAll() const
|
||||||
{
|
{
|
||||||
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
for(auto const & dlg_p : d.dialogs_)
|
||||||
map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
|
dlg_p.second->hideView();
|
||||||
|
|
||||||
for(; it != end; ++it)
|
|
||||||
it->second->hideView();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiView::updateDialogs()
|
void GuiView::updateDialogs()
|
||||||
{
|
{
|
||||||
map<string, DialogPtr>::const_iterator it = d.dialogs_.begin();
|
for(auto const & dlg_p : d.dialogs_)
|
||||||
map<string, DialogPtr>::const_iterator end = d.dialogs_.end();
|
Dialog * dialog = dlg_p.second.get();
|
||||||
|
|
||||||
for(; it != end; ++it) {
|
|
||||||
Dialog * dialog = it->second.get();
|
|
||||||
if (dialog) {
|
if (dialog) {
|
||||||
if (dialog->needBufferOpen() && !documentBufferView())
|
if (dialog->needBufferOpen() && !documentBufferView())
|
||||||
hideDialog(fromqstr(dialog->name()), nullptr);
|
hideDialog(fromqstr(dialog->name()), nullptr);
|
||||||
|
Loading…
Reference in New Issue
Block a user