Sketcher: fix some lint warnings

This commit is contained in:
wmayer
2023-04-02 12:06:08 +02:00
committed by wwmayer
parent c38ef7da53
commit 90c296af6b

View File

@@ -43,8 +43,9 @@ ToolBarItem::ToolBarItem() : visibility(HideStyle::VISIBLE)
ToolBarItem::ToolBarItem(ToolBarItem* item, HideStyle visibility) : visibility(visibility)
{
if ( item )
if (item) {
item->appendItem(this);
}
}
ToolBarItem::~ToolBarItem()
@@ -71,11 +72,11 @@ ToolBarItem* ToolBarItem::findItem(const std::string& name)
{
if ( _name == name ) {
return this;
} else {
for ( QList<ToolBarItem*>::Iterator it = _items.begin(); it != _items.end(); ++it ) {
if ( (*it)->_name == name ) {
return *it;
}
}
for (auto it : qAsConst(_items)) {
if (it->_name == name) {
return it;
}
}
@@ -88,8 +89,8 @@ ToolBarItem* ToolBarItem::copy() const
root->setCommand( command() );
QList<ToolBarItem*> items = getItems();
for ( QList<ToolBarItem*>::Iterator it = items.begin(); it != items.end(); ++it ) {
root->appendItem( (*it)->copy() );
for (auto it : items) {
root->appendItem(it->copy());
}
return root;
@@ -111,21 +112,23 @@ bool ToolBarItem::insertItem( ToolBarItem* before, ToolBarItem* item)
if (pos != -1) {
_items.insert(pos, item);
return true;
} else
return false;
}
return false;
}
void ToolBarItem::removeItem(ToolBarItem* item)
{
int pos = _items.indexOf(item);
if (pos != -1)
if (pos != -1) {
_items.removeAt(pos);
}
}
void ToolBarItem::clear()
{
for ( QList<ToolBarItem*>::Iterator it = _items.begin(); it != _items.end(); ++it ) {
delete *it;
for (auto it : qAsConst(_items)) {
delete it;
}
_items.clear();
@@ -174,11 +177,9 @@ ToolBarManager::~ToolBarManager()
{
}
void ToolBarManager::setup(ToolBarItem* toolBarItems)
namespace {
QPointer<QWidget> createActionWidget()
{
if (!toolBarItems)
return; // empty menu bar
static QPointer<QWidget> _ActionWidget;
if (!_ActionWidget) {
_ActionWidget = new QWidget(getMainWindow());
@@ -192,10 +193,23 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems)
_ActionWidget->move(QPoint(-100,-100));
}
else {
for (auto action : _ActionWidget->actions())
auto actions = _ActionWidget->actions();
for (auto action : actions) {
_ActionWidget->removeAction(action);
}
}
return _ActionWidget;
}
}
void ToolBarManager::setup(ToolBarItem* toolBarItems)
{
if (!toolBarItems)
return; // empty menu bar
QPointer<QWidget> _ActionWidget = createActionWidget();
saveState();
this->toolbarNames.clear();
@@ -242,7 +256,8 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems)
// setup the toolbar
setup(*it, toolbar);
for (auto action : toolbar->actions()) {
auto actions = toolbar->actions();
for (auto action : actions) {
_ActionWidget->addAction(action);
}
@@ -274,7 +289,7 @@ void ToolBarManager::setup(ToolBarItem* toolBarItems)
fw = fw->parentWidget();
}
// ignore toolbars which do not belong to the previously active workbench
QByteArray toolbarName = (*it)->objectName().toUtf8();
//QByteArray toolbarName = (*it)->objectName().toUtf8();
if (!(*it)->toggleViewAction()->isVisible())
continue;
//hPref->SetBool(toolbarName.constData(), (*it)->isVisible());
@@ -341,7 +356,7 @@ void ToolBarManager::saveState() const
}
// If hide style is FORCE_HIDE then never save the state because it's
// alwas controlled by the application.
// always controlled by the application.
auto value = static_cast<ToolBarItem::HideStyle>(property.toInt());
return value == ToolBarItem::HideStyle::FORCE_HIDE;
};