Esempio n. 1
0
AbstractXmlItemObject * FoldersModel::newItem()
{
    Folder *newItem = new Folder(this);
    connect(newItem, SIGNAL(idChanged()), this, SLOT(itemDataChanged()));
    connect(newItem, SIGNAL(additionalDataChanged()), this, SLOT(itemDataChanged()));

    connect(newItem, SIGNAL(nameChanged()), this, SLOT(itemDataChanged()));
    newItem->filesModel()->setItemAdditionalData(m_fileAdditionalData);
    return newItem;
}
Esempio n. 2
0
void FoldersModel::setFileAdditionalData(QQmlComponent *fileAdditionalData)
{
    if (m_fileAdditionalData != fileAdditionalData) {
        m_fileAdditionalData = fileAdditionalData;

        //Установим новые дополнительные данные для всех существующих объектов
        for (int i = 0; i < rowCount(); i++) {
            Folder *folder = qobject_cast<Folder* >(get(i));
            if (folder)
                folder->filesModel()->setItemAdditionalData(fileAdditionalData);
        }

        emit fileAdditionalDataChanged();
    }
}
Esempio n. 3
0
QVariant FoldersModel::data(const QModelIndex &index, int role) const
{
    Folder * item = qobject_cast<Folder *>(get(index.row()));
    if (!item)
        return QVariant();

    switch (role) {
    case Id:
        return item->id();
        break;
    case Name:
        return item->name();
        break;
    case AdditionalData:
        return QVariant::fromValue(item->additionalData());
        break;
    case FilesModel:
        return QVariant::fromValue(item->filesModel());
        break;
    }

    return QVariant();
}