本文整理汇总了C++中removeRows函数的典型用法代码示例。如果您正苦于以下问题:C++ removeRows函数的具体用法?C++ removeRows怎么用?C++ removeRows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeRows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findElement
// The actual magic shouldn't be hard. Once we trap the signal, find the
// recipe, remove it from the parent and add it to the target folder.
// It is not easy. Indexes are ephemeral things. We MUST calculate the insert
// index after we have removed the recipe. BAD THINGS happen otherwise.
//
void BtTreeModel::folderChanged(QString name)
{
BeerXMLElement* test = qobject_cast<BeerXMLElement*>(sender());
QModelIndex ndx, pIndex;
bool expand = true;
if ( ! test )
return;
// Find it.
ndx = findElement(test);
if ( ! ndx.isValid() )
{
Brewtarget::logW("folderChanged:: could not find element");
return;
}
pIndex = parent(ndx); // Get the parent
// If the parent isn't valid, its the root
if ( ! pIndex.isValid() )
pIndex = createIndex(0,0,rootItem->child(0));
int i = item(ndx)->childNumber();
// Remove it
if ( ! removeRows(i, 1, pIndex) )
{
Brewtarget::logW("folderChanged:: could not remove row");
return;
}
// Find the new parent
// That's awkward, but dropping a folder prolly does need a the folder
// created.
QModelIndex newNdx = findFolder(test->folder(), rootItem->child(0), true);
if ( ! newNdx.isValid() )
{
newNdx = createIndex(0,0,rootItem->child(0));
expand = false;
}
BtTreeItem* local = item(newNdx);
int j = local->childCount();
if ( ! insertRow(j,newNdx,test,_type) )
{
Brewtarget::logW("folderChanged:: could not insert row");
return;
}
// If we have brewnotes, set them up here.
if ( treeMask & RECIPEMASK )
addBrewNoteSubTree(qobject_cast<Recipe*>(test),j,local);
if ( expand )
emit expandFolder(treeMask,newNdx);
return;
}
示例2: beginInsertRows
void pgpid_item_model::data_updated(std::list<RsPgpId> &new_neighs)
{
//shit code follow (rewrite this please)
size_t old_size = neighs.size(), new_size = 0;
std::list<RsPgpId> old_neighs = neighs;
new_size = new_neighs.size();
//set model data to new cleaned up data
neighs = new_neighs;
neighs.sort();
neighs.unique(); //remove possible dups
//reflect actual row count in model
if(old_size < new_size)
{
beginInsertRows(QModelIndex(), old_size, new_size);
insertRows(old_size, new_size - old_size);
endInsertRows();
}
else if(new_size < old_size)
{
beginRemoveRows(QModelIndex(), new_size, old_size);
removeRows(old_size, old_size - new_size);
endRemoveRows();
}
//update data in ui, to avoid unnecessary redraw and ui updates, updating only changed elements
//TODO: libretroshare should implement a way to obtain only changed elements via some signalling non-blocking api.
{
size_t ii1 = 0;
for(auto i1 = neighs.begin(), end1 = neighs.end(), i2 = old_neighs.begin(), end2 = old_neighs.end(); i1 != end1; ++i1, ++i2, ii1++)
{
if(i2 == end2)
break;
if(*i1 != *i2)
{
QModelIndex topLeft = createIndex(ii1,0), bottomRight = createIndex(ii1, COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight);
}
}
}
if(new_size > old_size)
{
QModelIndex topLeft = createIndex(old_size ? old_size -1 : 0 ,0), bottomRight = createIndex(new_size -1, COLUMN_COUNT-1);
emit dataChanged(topLeft, bottomRight);
}
//dirty solution for initial data fetch
//TODO: do it properly!
if(!old_size)
{
beginResetModel();
endResetModel();
}
//shit code end
}
示例3: while
//SLOT:setVar : changement de l'id de la variable et traçage du Tri à plat
void TaP::setVar(QIntList id)
{
//On prend la première variable si plusieurs sont sélectionnées
var_courante=this->population->pVar(id.at(0));
this->setNom(var_courante->Nom());
this->typeVar=var_courante->Type();
while(columnCount()>3)
{removeColumn(columnCount()-1);}
if(rowCount()>0)
{
removeRows(0,rowCount());
}
setNomVar(0, "Modalités");
setNomVar(1, "Effectifs");
setNomVar(2, "Fréquences");
TAP_DONNEES donnees;
donnees.Charger(var_courante);
switch(typeVar)
{
case TYPES::QUALITATIF_ORDINAL:
addColumn();
setNomVar(3, "Fréquences Cumulées");
setTypeVar(3, TYPES::QUALITATIF_PURE);
break;
case TYPES::QUANTITATIF_DISCRET:
addColumn();
setNomVar(3, "Fréquences Cumulées");
setTypeVar(3, TYPES::QUALITATIF_PURE);
break;
case TYPES::QUANTITATIF_CONTINU_PURE:
addColumn();
setNomVar(3, "Fréquences Cumulées");
setTypeVar(3, TYPES::QUALITATIF_PURE);
break;
}
for(int i=0; i<donnees.Modalites().size();i++)
{
if(i==rowCount())
{
addRows();
}
setData(0, i, donnees.Modalites().at(i));
setData(1, i, donnees.Effectifs().at(i));
setData(2, i, donnees.Frequences().at(i));
if(donnees.FrequencesCumulees().size())
{setData(3,i, donnees.FrequencesCumulees().at(i));}
}
addRows();
setData(0,rowCount()-1,"TOTAL");
setData(1,rowCount()-1,population->NbValideString(id.at(0)));
setData(2,rowCount()-1,"1,00");
}
示例4: searchId
void IdCollection<ESXRecordT>::load (ESM::ESMReader& reader, bool base)
{
std::string id = reader.getHNOString ("NAME");
if (reader.isNextSub ("DELE"))
{
int index = searchId (id);
reader.skipRecord();
if (index==-1)
{
// deleting a record that does not exist
// ignore it for now
/// \todo report the problem to the user
}
else if (base)
{
removeRows (index, 1);
}
else
{
mRecords[index].mState = RecordBase::State_Deleted;
}
}
else
{
ESXRecordT record;
record.mId = id;
record.load (reader);
int index = searchId (record.mId);
if (index==-1)
{
// new record
Record<ESXRecordT> record2;
record2.mState = base ? RecordBase::State_BaseOnly : RecordBase::State_ModifiedOnly;
(base ? record2.mBase : record2.mModified) = record;
appendRecord (record2);
}
else
{
// old record
Record<ESXRecordT>& record2 = mRecords[index];
if (base)
record2.mBase = record;
else
record2.setModified (record);
}
}
}
示例5: rowCount
bool NotifyTableModel::dropMimeData( const QMimeData * data, Qt::DropAction action, int row,
int column, const QModelIndex& parent)
{
if (action == Qt::IgnoreAction)
return true;
if (!data->hasFormat(mime_type_notify_table))
return false;
int beginRow = -1;
if (row != -1)
beginRow = row;
else {
if (parent.isValid())
beginRow = parent.row();
else
beginRow = rowCount(QModelIndex());
}
if (-1 == beginRow)
return false;
QByteArray encodedData = data->data(mime_type_notify_table);
QDataStream stream(&encodedData, QIODevice::ReadOnly);
int rows = beginRow;
// read next item from input MIME and drop into the table line by line
while(!stream.atEnd()) {
quintptr ptr;
stream >> ptr;
NotificationItem* item = reinterpret_cast<NotificationItem*>(ptr);
int dragged = _list.indexOf(item);
// we can drag item from top rows to bottom (DOWN_DIRECTION),
// or from bottom rows to top rows (UP_DIRECTION)
enum { UP_DIRECTION, DOWN_DIRECTION };
int direction = (dragged < rows) ? DOWN_DIRECTION : (dragged += 1, UP_DIRECTION);
// check drop bounds
if (dragged < 0 || ((dragged + 1) >= _list.size() && direction == DOWN_DIRECTION) || dragged == rows) {
qNotifyDebug() << "no such item";
continue;
}
// addiional check in case dropping of multiple rows
if(rows + direction > _list.size()) continue;
Q_ASSERT(insertRows(rows + direction, 1, QModelIndex()));
_list.replace(rows + direction, item);
Q_ASSERT(removeRows(dragged, 1, QModelIndex()));
if (direction == UP_DIRECTION)
++rows;
};
QModelIndex idxTopLeft = index(beginRow, 0, QModelIndex());
QModelIndex idxBotRight = index(beginRow, columnCount(QModelIndex()), QModelIndex());
emit dataChanged(idxTopLeft, idxBotRight);
return true;
}
示例6: removeRows
void LibrarySourcesTableModel::set(const QList<LibrarySource>& sources)
{
if (!this->sources.empty())
removeRows(0, this->sources.size(), QModelIndex());
if (sources.empty())
return;
beginInsertRows(QModelIndex(), 0, sources.size() - 1);
this->sources = sources;
endInsertRows();
}
示例7: insertRows
void ConfMat::setRowCount(int newRowCount)
{
int curRowCount = this->getRowCount();
if (curRowCount == newRowCount)
return;
if (curRowCount < newRowCount)
insertRows(qMax(curRowCount, 0), newRowCount - curRowCount);
else
removeRows(qMax(newRowCount, 0), curRowCount - newRowCount);
}
示例8: qDebug
void ObjectModel::removeItem(QModelIndex &index)
{
if (!index.isValid())
{
return;
}
qDebug() << "removeItem row:" << index.row() << "p:" << index.internalPointer();
removeRows(index.row(), 1, index.parent());
}
示例9: removeRows
void DbGpfsInfo::upsertInfo(SQLHSTMT sqlStmt)
{
removeRows(sqlStmt,tmptableName); //clear all related temp tables at first
fillTable(sqlStmt,tmptableName); //fill temp table
queryTable(sqlStmt,tmptableName,&tempInfo);//query temp table
queryTable(sqlStmt,tableName,&lastInfo); //query regular table
updateRegularTable(sqlStmt,tableName, tempInfo, lastInfo); //update regular table
}
示例10: insertRows
void MagnetModel::onUpdateQueue(bt::Uint32 idx, bt::Uint32 count)
{
int rows = mman->count();
if (currentRows < rows) // add new rows
insertRows(idx, rows - currentRows, QModelIndex());
else if (currentRows > rows) // delete rows
removeRows(idx, currentRows - rows, QModelIndex());
currentRows = rows;
emit dataChanged(index(idx, 0), index(count, columnCount(QModelIndex())));
}
示例11: QAbstractItemModel_removeRows
int QAbstractItemModel_removeRows(lua_State* const state)
{
auto self = lua::get<QAbstractItemModel*>(state, 1);
// virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex())
if (lua_gettop(state) == 3) {
lua::push(state, self->removeRows(
lua::get<int>(state, 2),
lua::get<int>(state, 3)
));
} else {
lua::push(state, self->removeRows(
lua::get<int>(state, 2),
lua::get<int>(state, 3),
lua::get<const QModelIndex&>(state, 4)
));
}
return 1;
}
示例12: removeRows
bool CQCompartmentDM::clear()
{
QModelIndexList rows;
for (int i = 0; i < mpCompartments->size(); i++)
{
rows.append(index(i, 0));
}
return removeRows(rows);
}
示例13: removeRows
void QgsAttributeTableModel::layerDeleted()
{
mLayerCache = nullptr;
removeRows( 0, rowCount() );
mAttributeWidgetCaches.clear();
mAttributes.clear();
mWidgetFactories.clear();
mWidgetConfigs.clear();
mFieldFormatters.clear();
}
示例14: printf
void FXTabSim::sacarCTRL(void) {
printf("indexCtrl: %d tope: %d\n", indexCtrl, tope);
// removeRows(indexCtrl, tope-indexCtrl+1);
removeRows(indexCtrl);
tope = indexCtrl-1;
printf("Nuevo tope: %d\n", tope);
}
示例15: createIndex
/**
* Removes the TreeItem with the given name including all its children
*/
void GeoTreeModel::removeGeoList(const std::string &name, GeoLib::GEOTYPE type)
{
for (size_t i = 0; i < _lists.size(); i++)
if ( name.compare( _lists[i]->data(0).toString().toStdString() ) == 0 )
{
for (int j = 0; j < _lists[i]->childCount(); j++)
if (type ==
static_cast<GeoObjectListItem*>(_lists[i]->child(j))->getType())
{
QModelIndex index = createIndex(j, 0, _lists[i]->child(j));
removeRows(0, _lists[i]->child(j)->childCount(), index);
removeRows(j, 1, parent(index));
break;
}
if (_lists[i]->childCount() == 0)
{
_lists.erase(_lists.begin() + i);
removeRows(i, 1, QModelIndex());
}
}
}