|
@ -1,6 +1,8 @@ |
|
|
#include "quickpresenter.h" |
|
|
#include "quickpresenter.h" |
|
|
#include "quickpresenter_p.h" |
|
|
#include "quickpresenter_p.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <limits> |
|
|
|
|
|
|
|
|
#include <QtCore/QDir> |
|
|
#include <QtCore/QDir> |
|
|
#include <QtCore/QDirIterator> |
|
|
#include <QtCore/QDirIterator> |
|
|
#include <QtCore/QMetaMethod> |
|
|
#include <QtCore/QMetaMethod> |
|
@ -90,26 +92,32 @@ QUrl QuickPresenter::findViewUrl(const QMetaObject *viewModelType) |
|
|
if(lIndex > 0) |
|
|
if(lIndex > 0) |
|
|
cName.truncate(lIndex); |
|
|
cName.truncate(lIndex); |
|
|
|
|
|
|
|
|
|
|
|
QUrl resUrl; |
|
|
|
|
|
auto shortest = std::numeric_limits<int>::max(); |
|
|
for(auto dir : qAsConst(d->searchDirs)) { |
|
|
for(auto dir : qAsConst(d->searchDirs)) { |
|
|
QDir searchDir(dir, |
|
|
QDir searchDir(dir, |
|
|
QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)), |
|
|
QStringLiteral("%1*.qml").arg(QString::fromLatin1(cName)), |
|
|
QDir::NoSort, |
|
|
QDir::NoSort, |
|
|
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable); |
|
|
QDir::Files | QDir::NoDotAndDotDot | QDir::Readable); |
|
|
QDirIterator iterator(searchDir, QDirIterator::Subdirectories); |
|
|
QDirIterator iterator(searchDir, QDirIterator::Subdirectories); |
|
|
if(iterator.hasNext()) { |
|
|
while(iterator.hasNext()) { |
|
|
iterator.next(); |
|
|
iterator.next(); |
|
|
QUrl resUrl; |
|
|
if(iterator.fileName().size() < shortest) { |
|
|
if(dir.startsWith(QStringLiteral(":"))) { |
|
|
if(dir.startsWith(QStringLiteral(":"))) { |
|
|
resUrl.setScheme(QStringLiteral("qrc")); |
|
|
resUrl.clear(); |
|
|
resUrl.setPath(iterator.filePath().mid(1)); //skip the beginning colon
|
|
|
resUrl.setScheme(QStringLiteral("qrc")); |
|
|
} else |
|
|
resUrl.setPath(iterator.filePath().mid(1)); //skip the beginning colon
|
|
|
resUrl = QUrl::fromLocalFile(iterator.filePath()); |
|
|
} else |
|
|
logDebug() << "Found URL for viewmodel" |
|
|
resUrl = QUrl::fromLocalFile(iterator.filePath()); |
|
|
<< viewModelType->className() |
|
|
} |
|
|
<< "as:" << resUrl; |
|
|
|
|
|
return resUrl; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if(resUrl.isValid()) { |
|
|
|
|
|
logDebug() << "Found URL for viewmodel" |
|
|
|
|
|
<< viewModelType->className() |
|
|
|
|
|
<< "as:" << resUrl; |
|
|
|
|
|
return resUrl; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
currentMeta = currentMeta->superClass(); |
|
|
currentMeta = currentMeta->superClass(); |
|
|