mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-29 14:14:15 +02:00
34a2ceff70
Saving an element from the element editor calls ElementsCollectionWidget::locationWasSaved(), which runs clearData() on the panel item: the icon is set to a null QIcon. The icon only comes back through FileElementCollectionItem::setUpIcon(), but since the #633 recursion guard that returns for good once m_icon_initialized is set, and nothing ever reset it. The row stayed without an icon until the whole collection was reloaded. #1008 refreshed the picture caches on save, but no one asked them for the new picture, so it could not fix this. Resetting the flag in clearData() lets the next paint rebuild the icon, which then comes from those refreshed caches, so the panel shows the new drawing. The flag is reset after the base clearData(): its setIcon() emits dataChanged(), which re-enters setUpIcon() and must still return early. setUpIcon() sets the flag before its own setIcon(), so the #633 guard is unchanged. The same reset should also bring back a folder's icon after editing its properties (editDirectory() calls clearData() too); read, not tested. Project collection items were never affected: their setUpIcon() guards on icon().isNull(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#ifndef FILEELEMENTCOLLECTIONITEM2_H
|
|
#define FILEELEMENTCOLLECTIONITEM2_H
|
|
|
|
#include "elementcollectionitem.h"
|
|
#include "elementslocation.h"
|
|
|
|
/**
|
|
@brief The FileElementCollectionItem class
|
|
This class specialise ElementCollectionItem for manage a collection in
|
|
a file system. They represente a directory or an element.
|
|
*/
|
|
class FileElementCollectionItem : public ElementCollectionItem
|
|
{
|
|
public:
|
|
FileElementCollectionItem();
|
|
|
|
enum { Type = UserType+2 };
|
|
int type() const override { return Type;}
|
|
|
|
bool setRootPath(const QString& path,
|
|
bool set_data = true,
|
|
bool hide_element = false);
|
|
QString fileSystemPath() const;
|
|
QString dirPath() const;
|
|
|
|
bool isDir() const override;
|
|
bool isElement() const override;
|
|
QString localName() override;
|
|
QString localName(const ElementsLocation &location);
|
|
QString name() const override;
|
|
QString collectionPath() const override;
|
|
bool isCollectionRoot() const override;
|
|
bool isCommonCollection() const;
|
|
bool isCompanyCollection() const;
|
|
bool isCustomCollection() const;
|
|
bool isMacrosCollection() const;
|
|
void addChildAtPath(const QString &collection_name) override;
|
|
|
|
void setUpData() override;
|
|
void setUpIcon() override;
|
|
void clearData() override;
|
|
|
|
private:
|
|
void setPathName(const QString& path_name,
|
|
bool set_data = true,
|
|
bool hide_element = false);
|
|
void populate(bool set_data = true, bool hide_element = false);
|
|
|
|
private:
|
|
QString m_path;
|
|
/// True when this directory's qet_directory file is missing or
|
|
/// unreadable, so setUpData() can say so in the tooltip. Recorded
|
|
/// rather than acted on in localName(), because setUpData() resets
|
|
/// the tooltip afterwards and would otherwise discard it.
|
|
bool m_qet_directory_unreadable = false;
|
|
bool m_icon_initialized = false;
|
|
};
|
|
|
|
#endif // FILEELEMENTCOLLECTIONITEM2_H
|