Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

bool PiecesModel::dropMimeData ( const QMimeData data,
Qt::DropAction  action,
int  row,
int  column,
const QModelIndex parent 
) [virtual]

Reimplemented from QAbstractListModel.

Definition at line 138 of file piecesmodel.cpp.

References QDataStream::atEnd(), QAbstractItemModel::beginInsertRows(), QMimeData::data(), QAbstractItemModel::endInsertRows(), QMimeData::hasFormat(), QList< T >::insert(), QModelIndex::isValid(), QModelIndex::row(), and QList< T >::size().

    if (!data->hasFormat("image/x-puzzle-piece"))
        return false;

    if (action == Qt::IgnoreAction)
        return true;

    if (column > 0)
        return false;

    int endRow;

    if (!parent.isValid()) {
        if (row < 0)
            endRow = pixmaps.size();
            endRow = qMin(row, pixmaps.size());
    } else
        endRow = parent.row();

    QByteArray encodedData = data->data("image/x-puzzle-piece");
    QDataStream stream(&encodedData, QIODevice::ReadOnly);

    while (!stream.atEnd()) {
        QPixmap pixmap;
        QPoint location;
        stream >> pixmap >> location;

        beginInsertRows(QModelIndex(), endRow, endRow);
        pixmaps.insert(endRow, pixmap);
        locations.insert(endRow, location);


    return true;

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index