2010-01-19 09:33:06 +01:00
|
|
|
#include "qmlprojectitem.h"
|
|
|
|
|
#include "filefilteritems.h"
|
|
|
|
|
#include <qdebug.h>
|
|
|
|
|
|
|
|
|
|
namespace QmlProjectManager {
|
|
|
|
|
|
|
|
|
|
class QmlProjectItemPrivate : public QObject {
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
QString sourceDirectory;
|
2010-02-03 08:59:38 +01:00
|
|
|
QStringList libraryPaths;
|
2010-01-19 09:33:06 +01:00
|
|
|
|
|
|
|
|
QList<QmlFileFilterItem*> qmlFileFilters() const;
|
|
|
|
|
|
|
|
|
|
// content property
|
|
|
|
|
QmlConcreteList<QmlProjectContentItem*> content;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
QList<QmlFileFilterItem*> QmlProjectItemPrivate::qmlFileFilters() const
|
|
|
|
|
{
|
|
|
|
|
QList<QmlFileFilterItem*> qmlFilters;
|
|
|
|
|
for (int i = 0; i < content.size(); ++i) {
|
|
|
|
|
QmlProjectContentItem *contentElement = content.at(i);
|
|
|
|
|
QmlFileFilterItem *qmlFileFilter = qobject_cast<QmlFileFilterItem*>(contentElement);
|
|
|
|
|
if (qmlFileFilter) {
|
|
|
|
|
qmlFilters << qmlFileFilter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return qmlFilters;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProjectItem::QmlProjectItem(QObject *parent) :
|
|
|
|
|
QObject(parent),
|
|
|
|
|
d_ptr(new QmlProjectItemPrivate)
|
|
|
|
|
{
|
|
|
|
|
// Q_D(QmlProjectItem);
|
|
|
|
|
//
|
|
|
|
|
// QmlFileFilter *defaultQmlFilter = new QmlFileFilter(this);
|
|
|
|
|
// d->content.append(defaultQmlFilter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlProjectItem::~QmlProjectItem()
|
|
|
|
|
{
|
|
|
|
|
delete d_ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlList<QmlProjectContentItem*> *QmlProjectItem::content()
|
|
|
|
|
{
|
|
|
|
|
Q_D(QmlProjectItem);
|
|
|
|
|
return &d->content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString QmlProjectItem::sourceDirectory() const
|
|
|
|
|
{
|
|
|
|
|
const Q_D(QmlProjectItem);
|
|
|
|
|
return d->sourceDirectory;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-19 13:53:48 +01:00
|
|
|
// kind of initialization
|
2010-01-19 09:33:06 +01:00
|
|
|
void QmlProjectItem::setSourceDirectory(const QString &directoryPath)
|
|
|
|
|
{
|
|
|
|
|
Q_D(QmlProjectItem);
|
|
|
|
|
|
|
|
|
|
if (d->sourceDirectory == directoryPath)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
d->sourceDirectory = directoryPath;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < d->content.size(); ++i) {
|
|
|
|
|
QmlProjectContentItem *contentElement = d->content.at(i);
|
|
|
|
|
FileFilterBaseItem *fileFilter = qobject_cast<FileFilterBaseItem*>(contentElement);
|
2010-01-19 13:53:48 +01:00
|
|
|
if (fileFilter) {
|
2010-01-19 09:33:06 +01:00
|
|
|
fileFilter->setDefaultDirectory(directoryPath);
|
2010-01-19 13:53:48 +01:00
|
|
|
connect(fileFilter, SIGNAL(filesChanged()), this, SIGNAL(qmlFilesChanged()));
|
|
|
|
|
}
|
2010-01-19 09:33:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
emit sourceDirectoryChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-03 08:59:38 +01:00
|
|
|
QStringList QmlProjectItem::libraryPaths() const
|
|
|
|
|
{
|
|
|
|
|
const Q_D(QmlProjectItem);
|
|
|
|
|
return d->libraryPaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlProjectItem::setLibraryPaths(const QStringList &libraryPaths)
|
|
|
|
|
{
|
|
|
|
|
Q_D(QmlProjectItem);
|
|
|
|
|
|
|
|
|
|
if (d->libraryPaths == libraryPaths)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
d->libraryPaths = libraryPaths;
|
|
|
|
|
emit libraryPathsChanged();
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-19 16:56:03 +01:00
|
|
|
/* Returns list of absolute paths */
|
2010-01-28 17:12:07 +01:00
|
|
|
QStringList QmlProjectItem::files() const
|
2010-01-19 09:33:06 +01:00
|
|
|
{
|
|
|
|
|
const Q_D(QmlProjectItem);
|
2010-01-28 17:12:07 +01:00
|
|
|
QStringList files;
|
2010-01-19 09:33:06 +01:00
|
|
|
|
|
|
|
|
for (int i = 0; i < d->content.size(); ++i) {
|
|
|
|
|
QmlProjectContentItem *contentElement = d->content.at(i);
|
2010-01-28 17:12:07 +01:00
|
|
|
FileFilterBaseItem *fileFilter = qobject_cast<FileFilterBaseItem*>(contentElement);
|
|
|
|
|
if (fileFilter) {
|
|
|
|
|
foreach (const QString &file, fileFilter->files()) {
|
|
|
|
|
if (!files.contains(file))
|
|
|
|
|
files << file;
|
2010-01-19 09:33:06 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-28 17:12:07 +01:00
|
|
|
return files;
|
2010-01-19 09:33:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace QmlProjectManager
|
|
|
|
|
|
|
|
|
|
QML_DEFINE_NOCREATE_TYPE(QmlProjectManager::QmlProjectContentItem)
|
|
|
|
|
QML_DEFINE_TYPE(QmlProject,1,0,Project,QmlProjectManager::QmlProjectItem)
|
|
|
|
|
|
|
|
|
|
#include "qmlprojectitem.moc"
|