Fixed incorrect cast from ElementCollectionItem to FileElementCollectionItem #4

This commit is contained in:
Pascal Sander 2025-08-22 20:12:27 +02:00
parent 12b33e15a3
commit 27b21b38aa

View File

@ -591,36 +591,31 @@ void ElementsCollectionWidget::resetShowThisDir()
*/ */
void ElementsCollectionWidget::dirProperties() void ElementsCollectionWidget::dirProperties()
{ {
ElementCollectionItem *eci = elementCollectionItemForIndex( ElementCollectionItem* eci =
m_index_at_context_menu); elementCollectionItemForIndex(m_index_at_context_menu);
//When the user right-clicks on the collection tree and
//selects the collection property, the collection name, if (eci && eci->isDir())
//file path and number of elements will be added {
//to the qInfo log file. QString filePath;
qInfo() <<tr("Le dossier") <<(eci->localName())
<<tr("contient")<<eci->elementsChild().size()
<<tr("éléments") <<"\n"<< "Path:"
<<(static_cast<FileElementCollectionItem*>(eci)->fileSystemPath());
if (eci && eci->isDir()) {
QString txt1 = tr("Le dossier %1 contient").arg(
eci->localName());
QString txt2 = tr("%n élément(s), répartie(s)",
"",
eci->elementsChild().size());
QString txt3 = tr("dans %n dossier(s).",
"" ,
eci->directoriesChild().size());
QString txt4 = tr("Chemin de la collection : %1").arg(
eci->collectionPath());
QString txt5;
if (eci->type() == FileElementCollectionItem::Type) { if (eci->type() == FileElementCollectionItem::Type) {
txt5 = tr("Chemin dans le système de fichiers : %1") filePath = tr("Chemin dans le système de fichiers : %1")
.arg(static_cast<FileElementCollectionItem*>(eci)->fileSystemPath()); .arg(
static_cast<FileElementCollectionItem*>(eci)
->fileSystemPath());
} }
QString out =
tr("Le dossier %1 contient").arg(eci->localName()) % " "
% tr("%n élément(s), répartie(s)", "", eci->elementsChild().size())
% " "
% tr("dans %n dossier(s).", "", eci->directoriesChild().size())
% "\n\n"
% tr("Chemin de la collection : %1").arg(eci->collectionPath())
% "\n" % filePath;
qInfo() << out;
QMessageBox::information( QMessageBox::information(
this, this,
tr("Propriété du dossier %1").arg(eci->localName()), tr("Propriété du dossier %1").arg(eci->localName()),
txt1 % " " % txt2 % " " % txt3 % "\n\n" % txt4 % "\n" % txt5); out);
} }
} }