mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 08:15:32 -04:00
Add hasChild function to check for a child in a QObject tree.
This commit is contained in:
parent
246bc0115e
commit
f8e2c95162
2 changed files with 15 additions and 0 deletions
|
@ -38,4 +38,17 @@ QString humanReadableFileSize(qint64 bytes)
|
||||||
return QString("%1 %2").arg(QLocale().toString(size, 'f', 2), units.at(i));
|
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
|
} // namespace Tools
|
||||||
|
|
|
@ -18,11 +18,13 @@
|
||||||
#ifndef KEEPASSX_TOOLS_H
|
#ifndef KEEPASSX_TOOLS_H
|
||||||
#define KEEPASSX_TOOLS_H
|
#define KEEPASSX_TOOLS_H
|
||||||
|
|
||||||
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
|
|
||||||
namespace Tools {
|
namespace Tools {
|
||||||
|
|
||||||
QString humanReadableFileSize(qint64 bytes);
|
QString humanReadableFileSize(qint64 bytes);
|
||||||
|
bool hasChild(const QObject* parent, const QObject* child);
|
||||||
|
|
||||||
} // namespace Tools
|
} // namespace Tools
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue