• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ endMoveRows函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中endMoveRows函数的典型用法代码示例。如果您正苦于以下问题:C++ endMoveRows函数的具体用法?C++ endMoveRows怎么用?C++ endMoveRows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了endMoveRows函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Q_UNUSED

bool LauncherModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count,
                             const QModelIndex &destinationParent, int destinationChild)
{
    QList<Application *> tmp;

    Q_UNUSED(sourceParent);
    Q_UNUSED(destinationParent);

    if (sourceRow + count - 1 < destinationChild) {
        beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(),
                      destinationChild + 1);
        for (int i = sourceRow; i < sourceRow + count; i++) {
            Q_ASSERT(m_list[i]);
            tmp << m_list.takeAt(i);
        }
        for (int i = 0; i < count; i++) {
            Q_ASSERT(tmp[i]);
            m_list.insert(destinationChild - count + 2 + i, tmp[i]);
        }
        endMoveRows();
    } else if (sourceRow > destinationChild) {
        beginMoveRows(QModelIndex(), sourceRow, sourceRow + count - 1, QModelIndex(),
                      destinationChild);
        for (int i = sourceRow; i < sourceRow + count; i++) {
            Q_ASSERT(m_list[i]);
            tmp << m_list.takeAt(i);
        }
        for (int i = 0; i < count; i++) {
            Q_ASSERT(tmp[i]);
            m_list.insert(destinationChild + i, tmp[i]);
        }
        endMoveRows();
    }
    return true;
}
开发者ID:papyros,项目名称:protoshell,代码行数:35,代码来源:launchermodel.cpp


示例2: itemFromIndex

QModelIndex ListModel::moveItemHorizontal(const QModelIndex& index, int direction)
{
    ListItem* item = itemFromIndex(index);
    if (!item)
        return index;

    ListItem* parent = item->parent();
    int row = item->row();

    if (direction == App::Left) { // reparent as child of parent's parent
        if (!parent || parent->isRoot()) // already top level item
            return index;

        ListItem* newParent = parent->parent();
        int newRow = parent->row() + 1;

        QSqlDatabase db = QSqlDatabase::database();
        db.transaction();
        if (parent->takeChildDb(row) &&
            item->setParentDb(newParent, newRow)) {
            db.commit();
            if (beginMoveRows(indexFromItem(parent), row, row, indexFromItem(newParent), newRow)) {
                newParent->insertChild(newRow, parent->takeChild(row));
                endMoveRows();
            }
            return indexFromItem(item);
        } else {
            db.rollback();
            return index;
        }
    } else { // move as child of previous sibling
        ListItem* newParent = parent->child(row - 1);
        if (!newParent)
            return index;

        QSqlDatabase db = QSqlDatabase::database();
        db.transaction();
        if (parent->takeChildDb(row) &&
            item->setParentDb(newParent, newParent->childCount())) {
            db.commit();
            if (beginMoveRows(indexFromItem(parent), row, row, indexFromItem(newParent), newParent->childCount())) {
                newParent->appendChild(parent->takeChild(row));
                endMoveRows();
            }
            newParent->setExpanded(true);
            return indexFromItem(item);
        } else {
            db.rollback();
            return index;
        }
    }
}
开发者ID:Pandahisham,项目名称:outliner,代码行数:52,代码来源:listmodel.cpp


示例3: index

void RSSModel::itemPathChanged(RSS::Item *rssItem)
{
    const auto itemIndex = index(rssItem);
    const auto parentIndex = itemIndex.parent();
    beginMoveRows(itemIndex.parent(), itemIndex.row(), itemIndex.row(), parentIndex, 0);
    endMoveRows();
}
开发者ID:glassez,项目名称:qBittorrent,代码行数:7,代码来源:rssmodel.cpp


示例4: beginMoveRows

void RecentProjectsModel::setLastRecentProject(const FilePath& filepath)
{
    // if the filepath is already in the list, we just have to move it to the top of the list
    for (int i = 0; i < mRecentProjects.count(); i++)
    {
        if (mRecentProjects.at(i).toStr() == filepath.toStr())
        {
            if (i == 0)
                return; // the filename is already on top of the list, so nothing to do here...

            beginMoveRows(QModelIndex(), i, i, QModelIndex(), 0);
            mRecentProjects.move(i, 0);
            endMoveRows();
            save();
            return;
        }
    }

    // limit the maximum count of entries in the list
    while (mRecentProjects.count() >= 5)
    {
        beginRemoveRows(QModelIndex(), mRecentProjects.count()-1, mRecentProjects.count()-1);
        mRecentProjects.takeLast();
        endRemoveRows();
    }

    // add the new filepath to the list
    beginInsertRows(QModelIndex(), 0, 0);
    mRecentProjects.prepend(filepath);
    endInsertRows();
    save();
}
开发者ID:nemofisch,项目名称:LibrePCB,代码行数:32,代码来源:recentprojectsmodel.cpp


示例5: validIndeces

void ClipboardModel::sortItems(const QModelIndexList &indexList, CompareItems *compare)
{
    QList<QPersistentModelIndex> list = validIndeces(indexList);
    qSort( list.begin(), list.end(), compare );

    int targetRow = topMostRow(list);

    foreach (const QPersistentModelIndex &ind, list) {
        if (ind.isValid()) {
            const int sourceRow = ind.row();

            if (targetRow != sourceRow) {
                beginMoveRows(QModelIndex(), sourceRow, sourceRow, QModelIndex(), targetRow);
                m_clipboardList.move(sourceRow, targetRow);
                endMoveRows();

                // If the moved item was removed or moved further (as reaction on moving the item),
                // stop sorting.
                if (!ind.isValid() || ind.row() != targetRow)
                    break;
            }

            ++targetRow;
        }
    }
}
开发者ID:GabLeRoux,项目名称:CopyQ,代码行数:26,代码来源:clipboardmodel.cpp


示例6: privMoveObject

void Timeline::
privMoveObject(int source, int dest)
{
  QModelIndex parent;

  /* FIXME: currently ignoring the 'n' parameter */
  /* FIXME: there's something I don't understand about the API,
     because it seems to be impossible to increment an item's position
     by one. So if the destination is one greater than the source,
     swap dest and source. It seems to work fine.
  */

  if (dest == (source + 1))
  {
    swap(source, dest);
  }

  qDebug() << source << dest;
  if (!beginMoveRows(parent, source, source, parent, dest))
  {
    qDebug() << "early exit";
    return;
  }
  endMoveRows();
}
开发者ID:emdash,项目名称:QT-GES-Demo,代码行数:25,代码来源:timeline.cpp


示例7: stream

bool CategoryModel::dropMimeData(const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) {
    if (action == Qt::IgnoreAction)
        return true;

    if (!data->hasFormat("application/editor.categorymodel.index"))
        return false;

    QByteArray encodedData = data->data("application/editor.categorymodel.index");
    QDataStream stream(&encodedData, QIODevice::ReadOnly);

    QList<Item*> items;

    while (!stream.atEnd()) {
        quint64 address;
        stream >> address;
        Item* item = reinterpret_cast<Item*>(address);
        items.push_back(item);
    }

    Category* category = static_cast<Category*>(parent.internalPointer());

    for (QList<Item*>::const_iterator it = items.begin(); it != items.end(); ++it) {
        Item* item = *it;
        if (!item->isCategory() || !item->toCategory()->isAncestorOf(category)) {
            QModelIndex parentIndex = createIndex(item->parent()->childNumber(), 1, item->parent());
            if (parentIndex != parent) {
                beginMoveRows(parentIndex, item->childNumber(), item->childNumber(), parent, rowCount(parent));
                category->addChild(item);
                endMoveRows();
            }
        }
    }

    return true;
}
开发者ID:lawadr,项目名称:gridiron,代码行数:35,代码来源:CategoryModel.cpp


示例8: beginMoveRows

Q_INVOKABLE void ApplicationListModel::moveItem(int row, int destination)
{
    if (row < 0 || destination < 0 || row >= m_applicationList.length() ||
        destination >= m_applicationList.length() || row == destination) {
        return;
    }
    if (destination > row) {
        ++destination;
    }

    beginMoveRows(QModelIndex(), row, row, QModelIndex(), destination);
    if (destination > row) {
        ApplicationData data = m_applicationList.at(row);
        m_applicationList.insert(destination, data);
        m_applicationList.takeAt(row);
    } else {
        ApplicationData data = m_applicationList.takeAt(row);
        m_applicationList.insert(destination, data);
    }


    m_appOrder.clear();
    m_appPositions.clear();
    int i = 0;
    for (auto app : m_applicationList) {
        m_appOrder << app.storageId;
        m_appPositions[app.storageId] = i;
        ++i;
    }


    emit appOrderChanged();
    endMoveRows();
}
开发者ID:KDE,项目名称:plasma-phone-components,代码行数:34,代码来源:applicationlistmodel.cpp


示例9: it

bool QgsComposerModel::reorderItemToBottom( QgsComposerItem *item )
{
  if ( !item || !mItemsInScene.contains( item ) )
  {
    return false;
  }

  if ( mItemsInScene.last() == item )
  {
    //item is already lowest item present in scene, nothing to do
    return false;
  }

  //move item in z list
  QMutableListIterator<QgsComposerItem *> it( mItemZList );
  if ( it.findNext( item ) )
  {
    it.remove();
  }
  mItemZList.push_back( item );

  //also move item in scene items z list and notify of model changes
  QModelIndex itemIndex = indexForItem( item );
  if ( !itemIndex.isValid() )
  {
    return true;
  }

  //move item to bottom
  int row = itemIndex.row();
  beginMoveRows( QModelIndex(), row, row, QModelIndex(), rowCount() );
  refreshItemsInScene();
  endMoveRows();
  return true;
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:35,代码来源:qgscomposermodel.cpp


示例10: getCellByIndex

bool CellModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
{
    Cell* srcCell;
    Cell* desCell;
    bool result = true;

    if (!sourceParent.isValid())
        srcCell = topCell;
    else
        srcCell = getCellByIndex(sourceParent);

    if (!destinationParent.isValid())
        desCell = topCell;
    else
        desCell = getCellByIndex(destinationParent);

    if (sourceRow+count-1 > srcCell->childCount() || destinationChild > desCell->childCount())
        return false;

    beginMoveRows(sourceParent,sourceRow,sourceRow+count-1,destinationParent,destinationChild);
        for (int i=0; i<count; i++){
            result &= desCell->insertChildren(destinationChild,1,srcCell->getChild(sourceRow));
            result &= srcCell->removeChildren(sourceRow,1,false);
        }
    endMoveRows();

    return result;
}
开发者ID:EPRC,项目名称:project_kagami,代码行数:28,代码来源:cellmodel.cpp


示例11: beginMoveRows

bool SceneFilter::moveRows(const QModelIndex &sourceParent, int sourceRow,
                           int count, const QModelIndex &destinationParent,
                           int destinationChild)
{
    beginMoveRows(sourceParent, sourceRow, sourceRow+(count-1), destinationParent,
                  destinationChild);

    endMoveRows();
}
开发者ID:freckles-the-pirate,项目名称:plotline,代码行数:9,代码来源:scenefilter.cpp


示例12: qMin

void PagedProxyModel::sourceRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
{
    const int pageStart = (m_currentPage*m_pageSize);
    int newStart = qMin(m_pageSize, qMax(0, sourceStart - pageStart));
    int newEnd = qMin(m_pageSize, newStart + (sourceEnd - sourceStart));
    int newDestinationRow = qMin(m_pageSize, qMax(0, destinationRow - pageStart));

    emit beginMoveRows(sourceParent, newStart, newEnd, destinationParent, newDestinationRow);
    endMoveRows();
}
开发者ID:AnadoluPanteri,项目名称:plasma-mobile,代码行数:10,代码来源:pagedproxymodel.cpp


示例13: beginMoveRows

void IOSignalModel::down(int index)
{
    if(index < 0 || index >= (mIOSignals.count() - 1))
        return;

    beginMoveRows(QModelIndex(), index + 1, index + 1, QModelIndex(), index);
    IOSignal *sig = mIOSignals.at(index);
    mIOSignals[index] = mIOSignals.at(index + 1);
    mIOSignals[index + 1] = sig;
    endMoveRows();
}
开发者ID:erikku,项目名称:state_of_flux,代码行数:11,代码来源:IOSignalModel.cpp


示例14: moveRow

    void moveRow( int from, int to ) {
        if ( from == to ) return;
        if ( from >= m_tasks.size() || to >= m_tasks.size()+1 ) return;

        if ( beginMoveRows( QModelIndex(), from, from, QModelIndex(), to ) ) {
            m_tasks.move( from, to );
            endMoveRows();
        } else {
            assert( 0 );
        }
    }
开发者ID:KDE,项目名称:kdiagram,代码行数:11,代码来源:main.cpp


示例15: EditorException

/**
 * @brief Moves a direction.
 * @param index Index of the direction to move.
 * @param new_direction_nb The new number of the direction.
 * @throws EditorException in case of error.
 */
void SpriteModel::move_direction(const Index& index, int new_direction_nb) {

  if (new_direction_nb == index.direction_nb) {
    // Nothing to do.
    return;
  }

  // Make some checks first.
  if (!direction_exists(index)) {
      QString nb = std::to_string(index.direction_nb).c_str();
      throw EditorException(
            tr("Direction %1 don't exists in animation '%2'").arg(
              nb, index.animation_name));
  }

  // Save and clear the selection.
  Index selection = get_selected_index();
  clear_selection();

  // Move the direction in the sprite file.
  get_animation(index).move_direction(index.direction_nb, new_direction_nb);

  // Call beginMoveRows() as requested by QAbstractItemModel.
  int above_row = new_direction_nb;
  if (new_direction_nb > index.direction_nb) {
    ++above_row;
  }
  QModelIndex model_index = get_model_index(Index(index.animation_name));
  beginMoveRows(model_index, index.direction_nb, index.direction_nb,
                model_index, above_row);

  // Update our animation model list.
  int animation_nb = get_animation_nb(index);
  animations[animation_nb].directions.move(index.direction_nb, new_direction_nb);

  // Update direction model indexes.
  int num_dir = animations[animation_nb].directions.size();
  for (int nb = 0; nb < num_dir; nb++) {
    animations[animation_nb].directions[nb].index->direction_nb = nb;
  }

  endMoveRows();

  // Notify people before restoring the selection, so that they have a
  // chance to know new indexes before receiving selection signals.
  emit direction_deleted(index);

  // Restore the selection.
  if (selection.direction_nb == index.direction_nb) {
    selection.direction_nb = new_direction_nb;
  }

  set_selected_index(selection);
}
开发者ID:Renkineko,项目名称:solarus-quest-editor,代码行数:60,代码来源:sprite_model.cpp


示例16: levelFromIndex

void LevelListModel::up(const QModelIndex &idx) {
    Level *l = levelFromIndex(idx);
    int row = idx.row();
    if (idx.isValid() && row > 0) {
        beginMoveRows(QModelIndex(),row,row,QModelIndex(),row-1);
        Level *before = (*levels)[row-1];
        (*levels)[row-1] = l;
        (*levels)[row] = before;
        endMoveRows();
    }
}
开发者ID:utamons,项目名称:reditor,代码行数:11,代码来源:levellistmodel.cpp


示例17: beginMoveRows

void DataStore::moveItemDown( int row )
{
    if ( row >= 0 && row < m_datasetList.size() - 1 )
    {
        beginMoveRows( index( row, 0 ), row, row, index( row + 1, 0 ), row + 1 );
        m_datasetList.swap( row, row + 1 );
        endMoveRows();
        updateGlobals( row );
        emit ( dataChanged( index( 0, 0 ), index( 0, 0 ) ) );
    }
}
开发者ID:yangguang-ecnu,项目名称:fibernavigator2,代码行数:11,代码来源:datastore.cpp


示例18: endMoveRows

void NmProxy::onSourceRowsMoved( const QModelIndex &sourceParent, int, int, const QModelIndex &destinationParent, int)
{
    if (root == sourceParent)
    {
        if (root == destinationParent)
            endMoveRows();
        else
            endRemoveRows();
    } else if (root == destinationParent)
        endInsertRows();
}
开发者ID:palinek,项目名称:nm-tray,代码行数:11,代码来源:nmproxy.cpp


示例19: beginMoveRows

bool PlaylistModel::removeRows(int row, int count, const QModelIndex& parent)
{
    if (!m_playlist) return false;
    if (row == m_dropRow) return false;
    beginMoveRows(parent, row, row, parent, m_dropRow);
    m_playlist->move(row, m_dropRow);
    endMoveRows();
    m_dropRow = -1;
    emit modified();
    return true;
}
开发者ID:deedos,项目名称:shotcut,代码行数:11,代码来源:playlistmodel.cpp


示例20: Q_D

bool PersonsTableModel::moveDown(const QModelIndex &index)
{
    Q_D(PersonsTableModel);
    if(index.row() == d->persons.size()-1)
        return false;
    if(!beginMoveRows(QModelIndex(), index.row(), index.row(), QModelIndex(), index.row()+2))
        return false;
    d->persons.swap(index.row(), index.row()+1);
    endMoveRows();
    return true;
}
开发者ID:comargo,项目名称:dutylist,代码行数:11,代码来源:personstablemodel.cpp



注:本文中的endMoveRows函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ endParagraph函数代码示例发布时间:2022-05-30
下一篇:
C++ endLink函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap