本文整理汇总了C++中endMoveRows函数的典型用法代码示例。如果您正苦于以下问题:C++ endMoveRows函数的具体用法?C++ endMoveRows怎么用?C++ endMoveRows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了endMoveRows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
}
}
示例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();
}
示例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();
}
示例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;
}
}
}
示例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();
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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 );
}
}
示例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);
}