void FavoriteTagsModelTest::testMoveMiddleTag()
{
    model->appendTag(favoriteTag1);
    model->appendTag(favoriteTag2);
    model->appendTag(favoriteTag3);
    QCOMPARE(model->rowCount(), 3);
    QPersistentModelIndex nameIndex =
        model->index(0, FavoriteTagsModel::COLUMN_NAME);
    QPersistentModelIndex colorIndex =
        model->index(0, FavoriteTagsModel::COLUMN_COLOR);
    QSignalSpy spy(model, SIGNAL(rowsAboutToBeMoved(QModelIndex, int, int, QModelIndex, int)));
    QSignalSpy spy2(model, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)));
    model->moveTag(1, 2);
    QCOMPARE(model->rowCount(), 3);
    QCOMPARE(spy.count(), 1);
    QCOMPARE(ModelMoveEvent(spy.at(0)), ModelMoveEvent(QModelIndex(), 1, 1, QModelIndex(), 3));
    QCOMPARE(spy2.count(), 1);
    QCOMPARE(ModelMoveEvent(spy.at(0)), ModelMoveEvent(QModelIndex(), 1, 1, QModelIndex(), 3));
    COMPARE_ROWNUM(favoriteTag3, 1);
    COMPARE_ROWNUM(favoriteTag1, 0);
    COMPARE_INDEX(favoriteTag1, nameIndex, colorIndex);
    COMPARE_ROWNUM(favoriteTag2, 2);
    model->appendTag(favoriteTag3);
    QCOMPARE(model->rowCount(), 4);
    COMPARE_INDEX(favoriteTag1, nameIndex, colorIndex);
    model->removeTagAt(0);
    QCOMPARE(model->rowCount(), 3);
    QVERIFY(!nameIndex.isValid());
    QVERIFY(!colorIndex.isValid());
}
void
AlbumItemDelegate::doUpdateIndex( const QPersistentModelIndex& idx )
{
    if ( !idx.isValid() )
        return;
    emit updateIndex( idx );
}
void MicroblogDelegate::updateItemWidgets( const QList<QWidget*> widgets,
        const QStyleOptionViewItem &option,
        const QPersistentModelIndex &index ) const
{
    Q_UNUSED( option );
    if ( !index.isValid() ) {
        return;
    }

    const BlogModel* model = static_cast<const BlogModel*>( index.model() );
    int row = index.row();

    QWebView *edit = static_cast<QWebView*>( widgets[0] );
    edit->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
    edit->move( 5, 5 );
    edit->resize( 400,200 );

    QString text;
    text.append( "<table><tr><td><img src=\"" + this->getData( model, row, BlogModel::Picture ).toString() + "\"></td>" );
    text.append( "<td>" + getData( model, row, BlogModel::Date ).toString() );
    text.append( "<Br>" + getData( model, row, BlogModel::User ).toString() );
    text.append( "</td></tr></table>" );
    text.append( "<Br>" + getData( model, row, BlogModel::Text ).toString() );
    //kDebug() << text;
    edit->setHtml( text );
}
MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part, bool requireFormatting):
    QNetworkReply(parent), part(part), formattedBufferContent(0), requireFormatting(requireFormatting)
{
    QUrl url;
    url.setScheme(QLatin1String("trojita-imap"));
    url.setHost(QLatin1String("msg"));
    url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString());
    setUrl(url);

    setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered);
    Q_ASSERT(part.isValid());
    const Mailbox::Model *model = 0;
    Mailbox::Model::realTreeItem(part, &model);
    Q_ASSERT(model);

    connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotModelDataChanged(QModelIndex,QModelIndex)));

    //TODO: fileDownloadProgress signal in model signal the process of the current download.
    //      This reply might not be the current download, but now we assume that because the only use case here
    //      is just see the download progress of attachments that is usually the only downloading event.
    //      Should match message UID and partId and then emit downloadProgress.
    connect(model, SIGNAL(fileDownloadProgress(qint64, qint64)), this, SIGNAL(downloadProgress(qint64,qint64)));

    Mailbox::TreeItemPart *partPtr = dynamic_cast<Mailbox::TreeItemPart *>(static_cast<Mailbox::TreeItem *>(part.internalPointer()));
    Q_ASSERT(partPtr);

    // We have to ask for contents before we check whether it's already fetched
    partPtr->fetch(const_cast<Mailbox::Model *>(model));
    // The part data might be already unavailable or already fetched
    QTimer::singleShot(0, this, SLOT(slotMyDataChanged()));

    buffer.setBuffer(partPtr->dataPtr());
    buffer.open(QIODevice::ReadOnly);
}
void GraphicalModelAssistApi::removeElement(const Id &graphicalId)
{
	const QPersistentModelIndex index = indexById(graphicalId);
	if (graphicalRepoApi().exist(graphicalId) && index.isValid()) {
		mGraphicalModel.removeRow(index.row(), index.parent());
	}
}
MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part):
    QNetworkReply(parent), part(part)
{
    QUrl url;
    url.setScheme(QStringLiteral("trojita-imap"));
    url.setHost(QStringLiteral("msg"));
    url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString());
    setUrl(url);

    setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered);
    Q_ASSERT(part.isValid());

    connect(part.model(), &QAbstractItemModel::dataChanged, this, &MsgPartNetworkReply::slotModelDataChanged);

    // We have to ask for contents before we check whether it's already fetched
    part.data(Imap::Mailbox::RolePartData);

    // The part data might be already unavailable or already fetched
    QTimer::singleShot(0, this, SLOT(slotMyDataChanged()));

    QByteArray* bufferPtr = part.data(Imap::Mailbox::RolePartBufferPtr).value<QByteArray*>();
    Q_ASSERT(bufferPtr);
    buffer.setBuffer(bufferPtr);
    buffer.open(QIODevice::ReadOnly);
}
Exemple #7
0
void TabTreeView::rowsInserted(const QModelIndex &parent, int start, int end)
{
    QTreeView::rowsInserted(parent, start, end);

    if (m_initializing) {
        return;
    }

    // Parent for WebTab is set after insertTab is emitted
    const QPersistentModelIndex index = model()->index(start, 0, parent);
    QTimer::singleShot(0, this, [=]() {
        if (!index.isValid()) {
            return;
        }
        QModelIndex idx = index;
        QVector<QModelIndex> stack;
        do {
            stack.append(idx);
            idx = idx.parent();
        } while (idx.isValid());
        for (const QModelIndex &index : qAsConst(stack)) {
            expand(index);
        }
        if (index.data(TabModel::CurrentTabRole).toBool()) {
            setCurrentIndex(index);
        }
    });
}
void QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
    Q_Q(QIdentityProxyModel);

    foreach(const QPersistentModelIndex &proxyPersistentIndex, q->persistentIndexList()) {
        proxyIndexes << proxyPersistentIndex;
        Q_ASSERT(proxyPersistentIndex.isValid());
        const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
        Q_ASSERT(srcPersistentIndex.isValid());
        layoutChangePersistentIndexes << srcPersistentIndex;
    }

    QList<QPersistentModelIndex> parents;
    parents.reserve(sourceParents.size());
    foreach (const QPersistentModelIndex &parent, sourceParents) {
        if (!parent.isValid()) {
            parents << QPersistentModelIndex();
            continue;
        }
        const QModelIndex mappedParent = q->mapFromSource(parent);
        Q_ASSERT(mappedParent.isValid());
        parents << mappedParent;
    }

    q->layoutAboutToBeChanged(parents, hint);
}
Exemple #9
0
    void ScriptDelegate::updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const
    {
        QCheckBox* check_box = static_cast<QCheckBox*>(widgets[0]);
        check_box->resize(check_box->sizeHint());
        int x = MARGIN;
        check_box->move(x, option.rect.height() / 2 - check_box->sizeHint().height() / 2);

        QPushButton* about_button = static_cast<QPushButton*>(widgets[2]);
        QSize about_size_hint = about_button->sizeHint();
        about_button->resize(about_size_hint);
        x = option.rect.width() - MARGIN - about_size_hint.width();
        about_button->move(x, option.rect.height() / 2 - about_size_hint.height() / 2);

        QPushButton* configure_button = static_cast<QPushButton*>(widgets[1]);
        QSize configure_size_hint = configure_button->sizeHint();
        configure_button->resize(configure_size_hint);
        x = option.rect.width() - MARGIN * 2 - configure_size_hint.width() - about_size_hint.width();
        configure_button->move(x, option.rect.height() / 2 - configure_size_hint.height() / 2);

        if (!index.isValid())
        {
            check_box->setVisible(false);
            about_button->setVisible(false);
            configure_button->setVisible(false);
        }
        else
        {
            check_box->setChecked(index.model()->data(index, Qt::CheckStateRole).toBool());
            check_box->setEnabled(true);
            configure_button->setVisible(true);
            configure_button->setEnabled(index.model()->data(index, ScriptModel::ConfigurableRole).toBool());
        }
    }
Exemple #10
0
void MainWindow::slotAltitudeRequestsReady(const QList<int>& readyRequests)
{
    qDebug() << readyRequests.count() << " items ready!";
    LookupAltitude* const myAltitudeLookup = qobject_cast<LookupAltitude*>(sender());

    if (!myAltitudeLookup)
    {
        return;
    }

    for (int i = 0; i < readyRequests.count(); ++i)
    {
        const GeoIface::LookupAltitude::Request& myLookup = myAltitudeLookup->getRequest(readyRequests.at(i));
        const QPersistentModelIndex markerIndex          = myLookup.data.value<QPersistentModelIndex>();

        if (!markerIndex.isValid())
        {
            continue;
        }

        /// @todo Why does the index return a const model???
        const QAbstractItemModel* const itemModel = markerIndex.model();
        const_cast<QAbstractItemModel*>(itemModel)->setData(markerIndex, QVariant::fromValue(myLookup.coordinates), RoleCoordinates);
    }
}
Exemple #11
0
void KDescendantsProxyModelPrivate::processPendingParents()
{
    Q_Q(KDescendantsProxyModel);
    const QVector<QPersistentModelIndex>::iterator begin = m_pendingParents.begin();
    QVector<QPersistentModelIndex>::iterator it = begin;

    const QVector<QPersistentModelIndex>::iterator end = m_pendingParents.end();

    QVector<QPersistentModelIndex> newPendingParents;

    while (it != end && it != m_pendingParents.end()) {
        const QModelIndex sourceParent = *it;
        if (!sourceParent.isValid() && m_rowCount > 0) {
            // It was removed from the source model before it was inserted.
            it = m_pendingParents.erase(it);
            continue;
        }
        const int rowCount = q->sourceModel()->rowCount(sourceParent);

        Q_ASSERT(rowCount > 0);
        const QPersistentModelIndex sourceIndex = q->sourceModel()->index(rowCount - 1, 0, sourceParent);

        Q_ASSERT(sourceIndex.isValid());

        const QModelIndex proxyParent = q->mapFromSource(sourceParent);

        Q_ASSERT(sourceParent.isValid() == proxyParent.isValid());
        const int proxyEndRow = proxyParent.row() + rowCount;
        const int proxyStartRow = proxyEndRow - rowCount + 1;

        if (!m_relayouting) {
            q->beginInsertRows(QModelIndex(), proxyStartRow, proxyEndRow);
        }

        updateInternalIndexes(proxyStartRow, rowCount);
        m_mapping.insert(sourceIndex, proxyEndRow);
        it = m_pendingParents.erase(it);
        m_rowCount += rowCount;

        if (!m_relayouting) {
            q->endInsertRows();
        }

        for (int sourceRow = 0; sourceRow < rowCount; ++sourceRow) {
            static const int column = 0;
            const QModelIndex child = q->sourceModel()->index(sourceRow, column, sourceParent);
            Q_ASSERT(child.isValid());

            if (q->sourceModel()->hasChildren(child)) {
                Q_ASSERT(q->sourceModel()->rowCount(child) > 0);
                newPendingParents.append(child);
            }
        }
    }
    m_pendingParents += newPendingParents;
    if (!m_pendingParents.isEmpty()) {
        processPendingParents();
    }
//   scheduleProcessPendingParents();
}
Exemple #12
0
void TrayPrivate::setShown(QPersistentModelIndex const & index)
{
    mShownConnection = index;
    mIcon2Show = mShownConnection.isValid()
        ? static_cast<icons::Icon>(mActiveConnections.data(mShownConnection, NmModel::IconTypeRole).toInt()) : icons::NETWORK_OFFLINE;
    //postpone setting the icon (for case we change the icon in till our event is finished)
    mIconTimer.start();
}
Exemple #13
0
void ContactList::loadContactsDataIntoModel()
{
    QPersistentModelIndex currentIndex = ui->contactList->currentIndex();

    contactListModel->setJsonArray(document->array());

    if(currentIndex.isValid())
        ui->contactList->setCurrentIndex(currentIndex);
}
 foreach (const QPersistentModelIndex &parent, sourceParents) {
     if (!parent.isValid()) {
         parents << QPersistentModelIndex();
         continue;
     }
     const QModelIndex mappedParent = q->mapFromSource(parent);
     Q_ASSERT(mappedParent.isValid());
     parents << mappedParent;
 }
Exemple #15
0
void GPSCorrelatorWidget::slotItemsCorrelated(const Digikam::TrackCorrelator::Correlation::List& correlatedItems)
{
    qCDebug(DIGIKAM_GENERAL_LOG) << correlatedItems.count();
    d->correlationTriedCount += correlatedItems.count();

    for (int i = 0; i < correlatedItems.count(); ++i)
    {
        const TrackCorrelator::Correlation& itemCorrelation = correlatedItems.at(i);
        const QPersistentModelIndex itemIndex               = itemCorrelation.userData.value<QPersistentModelIndex>();

        if (!itemIndex.isValid())
            continue;

        GPSImageItem* const imageItem                       = d->imageModel->itemFromIndex(itemIndex);

        if (!imageItem)
            continue;

        if (itemCorrelation.flags&TrackCorrelator::CorrelationFlagCoordinates)
        {
            d->correlationCorrelatedCount++;

            GPSDataContainer newData;
            newData.setCoordinates(itemCorrelation.coordinates);

            if (itemCorrelation.nSatellites >= 0)
                newData.setNSatellites(itemCorrelation.nSatellites);

            // if hDop is available, use it
            if (itemCorrelation.hDop >= 0)
                newData.setDop(itemCorrelation.hDop);

            // but if pDop is available, prefer pDop over hDop
            if (itemCorrelation.pDop >= 0)
                newData.setDop(itemCorrelation.pDop);

            if (itemCorrelation.fixType >= 0)
            {
                newData.setFixType(itemCorrelation.fixType);
            }
            if (itemCorrelation.speed >= 0)
            {
                newData.setSpeed(itemCorrelation.speed);
            }

            GPSUndoCommand::UndoInfo undoInfo(itemIndex);
            undoInfo.readOldDataFromItem(imageItem);

            imageItem->setGPSData(newData);
            undoInfo.readNewDataFromItem(imageItem);

            d->correlationUndoCommand->addUndoInfo(undoInfo);
        }
    }

    emit(signalProgressChanged(d->correlationTriedCount));
}
void TilesetEditor::changeSelectedTile (QPersistentModelIndex newTile) {
    if (tileSelectedId >= 0 && tileSelectedId < tiles.size()) {
        if (newTile.isValid() && m_projectWidget->typeOfIndex(newTile) == ProjectWidget::Tile) {
            QImage tmpImage(newTile.data(ProjectWidget::TileRole).value<QImage>());
            tiles[tileSelectedId]->setPixmap(QPixmap::fromImage(tmpImage));
            tilesId[tileSelectedId] = newTile.data(ProjectWidget::IdRole).toInt();
        }
    }
}
Exemple #17
0
int ScriptableProxyHelper::currentItem()
{
    INVOKE(currentItem());
    if (!canUseSelectedItems())
        return -1;

    const QPersistentModelIndex current =
            m_actionData.value(mimeCurrentItem).value<QPersistentModelIndex>();
    return current.isValid() ? current.row() : -1;
}
void QuickItemDelegate::setTextColor(const QVariant &textColor, const QPersistentModelIndex &index)
{
    if (!index.isValid())
        return;

    m_colors[index] = textColor.value<QColor>();

    for (int i = 0; i < m_view->model()->columnCount(); i++)
        m_view->update(index.sibling(index.row(), i));
}
Exemple #19
0
//-----------------------------------------------------------------------------
void ctkModelTester::testPersistentModelIndex(const QPersistentModelIndex& index)const
{
  CTK_D(const ctkModelTester);
  //qDebug() << "Test persistent Index: " << index ;
  this->test(index.isValid(), "Persistent model index can't be invalid");
  // did you forget to call QAbstractItemModel::changePersistentIndex() between 
  // beginLayoutChanged() and changePersistentIndex() ?
  QModelIndex modelIndex = d->Model->index(index.row(), index.column(), index.parent());
  this->test(modelIndex == index, 
             QString("Persistent index (%1, %2) can't be invalid").arg(index.row()).arg(index.column()));
}
XUPItem* XUPDynamicFolderItem::child( int row )
{
    const QPersistentModelIndex index = mFSModel->index( row, 0, mFSRootIndex );
    XUPItem* item = mFSItems.value( index );
    
    if ( !item && index.isValid() ) {
        item = new XUPDynamicFolderChildItem( this, index, this );
    }
    
    return item;
}
void KexiProjectItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
                                    const QModelIndex &index) const
{
    const KexiProjectModel* model = qobject_cast<const KexiProjectModel*>(index.model());
    QPersistentModelIndex highlighted = model->itemWithSearchHighlight();
    QStyleOptionViewItem newOption(option);
    if (highlighted.isValid() && highlighted == index) {
        newOption.state |= QStyle::State_MouseOver;
    }
    QStyledItemDelegate::paint(painter, newOption, index);
}
Exemple #22
0
QModelIndex EntryDialog::depends() const
{
    if ( ui->depends->currentIndex() == 0 )
        return QModelIndex();

    QPersistentModelIndex index = indexList[ ui->depends->currentIndex() - 1 ];
    if ( index.isValid() )
        return index;
    
    return QModelIndex();
}
void KConcatenateRowsProxyModelPrivate::slotSourceLayoutAboutToBeChanged(const QList<QPersistentModelIndex> &sourceParents, QAbstractItemModel::LayoutChangeHint hint)
{
    const QModelIndexList persistentIndexList = q->persistentIndexList();
    layoutChangePersistentIndexes.reserve(persistentIndexList.size());

    foreach (const QPersistentModelIndex &proxyPersistentIndex, persistentIndexList) {
        proxyIndexes << proxyPersistentIndex;
        Q_ASSERT(proxyPersistentIndex.isValid());
        const QPersistentModelIndex srcPersistentIndex = q->mapToSource(proxyPersistentIndex);
        Q_ASSERT(srcPersistentIndex.isValid());
        layoutChangePersistentIndexes << srcPersistentIndex;
    }
QPixmap KipiImageModel::getPixmapForIndex(const QPersistentModelIndex& itemIndex, const int size)
{
    if (itemIndex.isValid()) { Q_ASSERT(itemIndex.model()==this); }

    // TODO: should we cache the pixmap on our own here or does the interface usually cache it for us?
    // TODO: do we need to make sure we do not request the same pixmap twice in a row?
    // construct the key under which we stored the pixmap in the cache:
    KipiImageItem* const imageItem = itemFromIndex(itemIndex);
    if (!imageItem)
        return QPixmap();

    const QString itemKeyString = CacheKeyFromSizeAndUrl(size, imageItem->url());
    QPixmap thumbnailPixmap;
    const bool havePixmapInCache = d->pixmapCache->find(itemKeyString, thumbnailPixmap);
//     kDebug()<<imageItem->url()<<size<<havePixmapInCache<<d->pixmapCache->isEnabled();
    if (havePixmapInCache)
        return thumbnailPixmap;

    // did we already request this pixmap at this size?
    for (int i=0; i<d->requestedPixmaps.count(); ++i)
    {
        if (d->requestedPixmaps.at(i).first==itemIndex)
        {
            if (d->requestedPixmaps.at(i).second==size)
            {
                // the pixmap has already been requested, at this size
                return QPixmap();
            }
        }
    }

    // remember at which size the pixmap was ordered:
    d->requestedPixmaps << QPair<QPersistentModelIndex, int>(itemIndex, size);

    // TODO: what about raw images? The old version of the plugin had a special loading mechanism for those
    if (d->interface)
    {
        d->interface->thumbnails(KUrl::List()<<imageItem->url(), size);
    }
    else
    {
//         KIO::PreviewJob *job = KIO::filePreview(urls, DEFAULTSIZE);
//
//         connect(job, SIGNAL(gotPreview(KFileItem,QPixmap)),
//                 this, SLOT(slotKDEPreview(KFileItem,QPixmap)));
//
//         connect(job, SIGNAL(failed(KFileItem)),
//                 this, SLOT(slotKDEPreviewFailed(KFileItem)));
    }

    return QPixmap();

}
void DirModel::showPreview(const KFileItem &item, const QPixmap &preview)
{
    QPersistentModelIndex index = m_previewJobs.value(item.url());
    m_previewJobs.remove(item.url());

    if (!index.isValid()) {
        return;
    }

    m_imageCache->insertImage(item.url().toString(), preview.toImage());
    //qDebug() << "preview size:" << preview.size();
    emit dataChanged(index, index);
}
void QuickItemDelegate::setTextColor(const QVariant &textColor)
{
  const QPersistentModelIndex index = sender()->property("index").value<QPersistentModelIndex>();
  if (!index.isValid()) {
    return;
  }

  m_colors[index] = textColor.value<QColor>();

  for (int i = 0; i < m_view->model()->columnCount(); i++) {
    m_view->update(index.sibling(index.row(), i));
  }
}
Exemple #27
0
// dirty harry HACK for inline file creation
void QxFileBrowser::createFilePolling()
{
	QPersistentModelIndex index = cwdModel_->index(newFilePath_);
	if (index.isValid() && (index.flags() & Qt::ItemIsEditable)) {
		cwdModel_->sort(0);
		dirView_->setCurrentIndex(index);
		dirView_->edit(index);
		newFilePath_ = QString();
	}
	else {
		QTimer::singleShot(100, this, SLOT(createFilePolling()));
	}
}
Exemple #28
0
    void updateHoverUi(const QModelIndex& index)
    {
        mIndexUnderCursor = index;

        if (mIndexUnderCursor.isValid()) {
            updateToggleSelectionButton();

            const QRect rect = mView->visualRect(mIndexUnderCursor);
            mToggleSelectionButton->move(rect.topLeft() + QPoint(2, 2));
            mToggleSelectionButton->show();
        } else {
            mToggleSelectionButton->hide();
        }
    }
void PersonsModel::removePerson(const QString& id)
{
    Q_D(PersonsModel);

    QPersistentModelIndex index = d->personIndex.value(id);
    if (!index.isValid()) { //item not found
        return;
    }

    beginRemoveRows(QModelIndex(), index.row(), index.row());
    d->personIndex.remove(id);
    d->metacontacts.removeAt(index.row());
    endRemoveRows();
}
Exemple #30
0
void tst_QDirModel::task244669_remove()
{
    QFile f1(SRCDIR "dirtest/f1.txt");
    QVERIFY(f1.open(QIODevice::WriteOnly));
    f1.close();
    QFile f2(SRCDIR "dirtest/f2.txt");
    QVERIFY(f2.open(QIODevice::WriteOnly));
    f2.close();

    QDirModel model;
    model.setReadOnly(false);
    QPersistentModelIndex parent = model.index(SRCDIR "dirtest");
    QPersistentModelIndex index2 = model.index(SRCDIR "dirtest/f2.txt");
    QPersistentModelIndex index1 = model.index(SRCDIR "dirtest/f1.txt");

    QVERIFY(parent.isValid());
    QVERIFY(index1.isValid());
    QVERIFY(index2.isValid());
    QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data());
    QCOMPARE(index1.data() , model.index(SRCDIR "dirtest/f1.txt").data());
    QCOMPARE(index2.data() , model.index(SRCDIR "dirtest/f2.txt").data());

    QVERIFY(model.remove(index1));

    QVERIFY(parent.isValid());
    QVERIFY(!index1.isValid());
    QVERIFY(index2.isValid());
    QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data());
    QCOMPARE(index2.data() , model.index(SRCDIR "dirtest/f2.txt").data());

    QVERIFY(model.remove(index2));

    QVERIFY(parent.isValid());
    QVERIFY(!index2.isValid());
    QVERIFY(!index1.isValid());
    QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data());
}