Commit 500f2e5d authored by Olli Werwolff's avatar Olli Werwolff
Browse files

Fixes: Fixed duplicate check when adding files using the resource editor

Task:     238308
RevBy:    eike
AutoTest: -
Details:  Instead of the text and prefix of the file to add, pointers were compared. Thus the function always returned false and duplicates were not recognized. Replaced struct FileList with a class FileList, which is inherited from QList and added the function containsList which checks the needed values.
parent 2932203a
......@@ -54,6 +54,19 @@ TRANSLATOR qdesigner_internal::ResourceModel
namespace qdesigner_internal {
/******************************************************************************
** FileList
*/
bool FileList::containsFile(File *file)
{
foreach(File *tmpFile, *this)
if (tmpFile->name == file->name && tmpFile->prefix() == file->prefix())
return true;
return false;
}
/******************************************************************************
** ResourceFile
*/
......@@ -375,7 +388,7 @@ bool ResourceFile::contains(const QString &prefix, const QString &file) const
Prefix * const p = m_prefix_list.at(pref_idx);
Q_ASSERT(p);
File equalFile(p, absolutePath(file));
return p->file_list.contains(&equalFile);
return p->file_list.containsFile(&equalFile);
}
bool ResourceFile::contains(int pref_idx, const QString &file) const
......@@ -383,7 +396,7 @@ bool ResourceFile::contains(int pref_idx, const QString &file) const
Q_ASSERT(pref_idx >= 0 && pref_idx < m_prefix_list.count());
Prefix * const p = m_prefix_list.at(pref_idx);
File equalFile(p, absolutePath(file));
return p->file_list.contains(&equalFile);
return p->file_list.containsFile(&equalFile);
}
/*static*/ QString ResourceFile::fixPrefix(const QString &prefix)
......
......@@ -90,7 +90,12 @@ struct File : public Node {
QString name;
QString alias;
};
typedef QList<File *> FileList;
class FileList : public QList<File *>
{
public:
bool containsFile(File *file);
};
/*!
\class Prefix
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment