Gui: modernize C++: use range-based for loop
This commit is contained in:
@@ -83,40 +83,40 @@ void ToolBoxManager::setup( ToolBarItem* toolBar ) const
|
||||
CommandManager& mgr = Application::Instance->commandManager();
|
||||
QList<ToolBarItem*> items = toolBar->getItems();
|
||||
|
||||
for ( QList<ToolBarItem*>::Iterator item = items.begin(); item != items.end(); ++item )
|
||||
for ( auto item : items )
|
||||
{
|
||||
auto bar = new QToolBar();
|
||||
bar->setOrientation(Qt::Vertical);
|
||||
bar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||
std::string toolbarName = (*item)->command();
|
||||
bar->setObjectName(QString::fromLatin1((*item)->command().c_str()));
|
||||
std::string toolbarName = item->command();
|
||||
bar->setObjectName(QString::fromLatin1(item->command().c_str()));
|
||||
bar->setWindowTitle(QObject::tr(toolbarName.c_str())); // i18n
|
||||
_toolBox->addItem( bar, bar->windowTitle() );
|
||||
|
||||
QList<ToolBarItem*> subitems = (*item)->getItems();
|
||||
for ( QList<ToolBarItem*>::Iterator subitem = subitems.begin(); subitem != subitems.end(); ++subitem )
|
||||
QList<ToolBarItem*> subitems = item->getItems();
|
||||
for (auto subitem : subitems)
|
||||
{
|
||||
if ( (*subitem)->command() == "Separator" ) {
|
||||
if ( subitem->command() == "Separator" ) {
|
||||
//bar->addSeparator();
|
||||
} else {
|
||||
mgr.addTo((*subitem)->command().c_str(), bar);
|
||||
mgr.addTo(subitem->command().c_str(), bar);
|
||||
}
|
||||
}
|
||||
|
||||
// Now set the right size policy for each tool button
|
||||
QList<QToolButton*> tool = bar->findChildren<QToolButton*>();
|
||||
for (QList<QToolButton*>::Iterator it = tool.begin(); it != tool.end(); ++it) {
|
||||
(*it)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
for (auto it : tool) {
|
||||
it->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
// When setting the horizontal size policy but no icon is set we use the following trick
|
||||
// to make the button text left aligned.
|
||||
QIcon icon = (*it)->icon();
|
||||
QIcon icon = it->icon();
|
||||
if (icon.isNull())
|
||||
{
|
||||
// Create an icon filled with the button color
|
||||
int size = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
QPixmap p(size, size);
|
||||
p.fill(Qt::transparent);
|
||||
(*it)->setIcon(p);
|
||||
it->setIcon(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user