mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-20 05:16:07 -04:00
Add hasChild function to check for a child in a QObject tree.
This commit is contained in:
parent
246bc0115e
commit
f8e2c95162
@ -38,4 +38,17 @@ QString humanReadableFileSize(qint64 bytes)
|
||||
return QString("%1 %2").arg(QLocale().toString(size, 'f', 2), units.at(i));
|
||||
}
|
||||
|
||||
bool hasChild(const QObject* parent, const QObject* child)
|
||||
{
|
||||
if (!parent || !child) {
|
||||
return false;
|
||||
}
|
||||
Q_FOREACH (QObject* c, parent->children()) {
|
||||
if (child == c || hasChild(c, child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Tools
|
||||
|
@ -18,11 +18,13 @@
|
||||
#ifndef KEEPASSX_TOOLS_H
|
||||
#define KEEPASSX_TOOLS_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QString>
|
||||
|
||||
namespace Tools {
|
||||
|
||||
QString humanReadableFileSize(qint64 bytes);
|
||||
bool hasChild(const QObject* parent, const QObject* child);
|
||||
|
||||
} // namespace Tools
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user