本文整理汇总了C++中removeRow函数的典型用法代码示例。如果您正苦于以下问题:C++ removeRow函数的具体用法?C++ removeRow怎么用?C++ removeRow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了removeRow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectedItems
void Table::keyPressEvent(QKeyEvent *event)
{
// Delete's all the selected rows for use with polygons only
if (event->key() == Qt::Key_Delete && mType == PolyEdit::Polygon)
{
QList<QTableWidgetItem *> selected = selectedItems();
int lastRow = -1;
for(auto i : selected)
{
int r = i->row();
if(lastRow == -1)
{
lastRow = r;
removeRow(r);
}
else if(lastRow != r)
removeRow(r);
}
// Ensure we have atleast one row
if (rowCount() == 0)
insertRow(rowCount());
}
}
示例2: switch
void MessageListModel::append(QString message, MessageStatus messageStatus, bool newLine) {
QStandardItem* item = new QStandardItem;
switch(messageStatus) {
case MessageStatus::Information:
item->setData(message, MessageItemDelegate::InformationRole);
break;
case MessageStatus::Success:
item->setData(message, MessageItemDelegate::SuccessRole);
break;
case MessageStatus::Warning:
item->setData(message, MessageItemDelegate::WarningRole);
break;
case MessageStatus::Error:
item->setData(message, MessageItemDelegate::ErrorRole);
break;
case MessageStatus::Download:
item->setData(message, MessageItemDelegate::DownloadRole);
break;
default:
item->setData(message, MessageItemDelegate::DownloadRole);
break;
}
while (rowCount() > _maxLines)
removeRow(0);
if (!newLine)
removeRow(rowCount()-1);
appendRow(item);
emit scrollToBottomRequested();
}
示例3: QDialog
MetaEditor::MetaEditor(QWidget *parent)
: QDialog(parent),
m_mainWindow(qobject_cast<MainWindow *>(parent)),
m_Relator(MarcRelators::instance()),
m_RemoveRow(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Delete),this, 0, 0, Qt::WidgetWithChildrenShortcut))
{
setupUi(this);
m_book = m_mainWindow->GetCurrentBook();
m_version = m_book->GetConstOPF()->GetEpubVersion();
m_opfdata = m_book->GetOPF()->GetText();
QStringList headers;
headers << tr("Name") << tr("Value");
QString data = GetOPFMetadata();
TreeModel *model = new TreeModel(headers, data);
view->setModel(model);
for (int column = 0; column < model->columnCount(); ++column)
view->resizeColumnToContents(column);
if (!isVisible()) {
ReadSettings();
}
if (m_version.startsWith('3')) {
loadMetadataElements();
loadMetadataProperties();
} else {
loadE2MetadataElements();
loadE2MetadataProperties();
}
connect(view->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &,
const QItemSelection &)),
this, SLOT(updateActions()));
connect(delButton, SIGNAL(clicked()), this, SLOT(removeRow()));
connect(tbMoveUp, SIGNAL(clicked()), this, SLOT(moveRowUp()));
connect(tbMoveDown, SIGNAL(clicked()), this, SLOT(moveRowDown()));
connect(m_RemoveRow, SIGNAL(activated()), this, SLOT(removeRow()));
if (m_version.startsWith('3')) {
connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectElement()));
connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectProperty()));
} else {
connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectE2Element()));
connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectE2Property()));
}
connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveData()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
updateActions();
}
示例4: getClass
/**----------------------------------------------------------------
* Create the output from a single ChebfunWorkspace.
*/
void ChebfunToTable::fromChebWorkspace()
{
ChebfunWorkspace_sptr cws = getClass("InputWorkspace");
Numeric::FunctionDomain1D_sptr domain;
size_t n = (int)get("N");
if (n < 2)
{// if n has default value (0) use the x-points of the chebfuns
domain = cws->fun().createDomainFromXPoints();
n = domain->size();
}
else
{// otherwise create a regular comb
domain = cws->fun().createDomain( n );
}
Numeric::FunctionValues values( *domain );
cws->fun().function(*domain, values);
auto tws = API::TableWorkspace_ptr(dynamic_cast<API::TableWorkspace*>(
API::WorkspaceFactory::instance().create("TableWorkspace"))
);
tws->addColumn("double","X");
tws->addColumn("double","Y");
tws->setRowCount(n);
auto xColumn = static_cast<API::TableColumn<double>*>(tws->getColumn("X").get());
xColumn->asNumeric()->setPlotRole(API::NumericColumn::X);
auto& x = xColumn->data();
auto yColumn = static_cast<API::TableColumn<double>*>(tws->getColumn("Y").get());
yColumn->asNumeric()->setPlotRole(API::NumericColumn::Y);
auto& y = yColumn->data();
for(size_t i = 0; i < domain->size(); ++i)
{
x[i] = (*domain)[i];
y[i] = values.getCalculated(i);
}
bool dropXInf = get("DropXInf");
if ( dropXInf )
{
if ( fabs( x.front() ) == inf )
{
tws->removeRow( 0 );
}
if ( fabs( x.back() ) == inf )
{
tws->removeRow( tws->rowCount() - 1 );
}
}
setProperty("OutputWorkspace",tws);
}
示例5: Q_D
bool PersonsTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_D(PersonsTableModel);
if(!(index.row() < d->persons.size()))
return false;
if(index.column() == 0) {
if(role == Qt::DisplayRole
|| role == Qt::EditRole) {
if(value.toString().isEmpty()) {
return removeRow(index.row());
}
d->persons[index.row()].setName(value.toString());
emit dataChanged(index, index);
return true;
}
}
else {
if(role == Qt::CheckStateRole) {
Qt::CheckState check = (Qt::CheckState)value.toInt();
switch (check) {
case Qt::Unchecked:
d->persons[index.row()].removeDate(d->columns.at(index.column()-1));
break;
default:
d->persons[index.row()].addDate(d->columns.at(index.column()-1));
break;
}
emit dataChanged(index, index);
return true;
}
}
return false;
}
示例6: clearContents
void pTableWidget::removeAll()
{
clearContents();
while(rowCount() > 0)
removeRow(0);
}
示例7: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
setupUi(this);
QStringList headers;
headers << tr("Title") << tr("Description");
QFile file(":/default.txt");
file.open(QIODevice::ReadOnly);
TreeModel *model = new TreeModel(headers, file.readAll());
file.close();
view->setModel(model);
for (int column = 0; column < model->columnCount(); ++column)
view->resizeColumnToContents(column);
connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(view->selectionModel(),
SIGNAL(selectionChanged(const QItemSelection &,
const QItemSelection &)),
this, SLOT(updateActions()));
connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions()));
connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow()));
connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn()));
connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn()));
connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));
updateActions();
}
示例8: removeRow
void GameSettings::removeScriptTag(std::string const & key)
{
std::string key2 = key;
boost::to_lower(key2);
removeRow(key2);
}
示例9: dropMimeData
/*!
Add urls \a list into the list at \a row. If move then movie
existing ones to row.
\sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
if (row == -1)
row = rowCount();
row = qMin(row, rowCount());
for (int i = list.count() - 1; i >= 0; --i) {
QUrl url = list.at(i);
if (!url.isValid() || url.scheme() != QLatin1String("file"))
continue;
//this makes sure the url is clean
const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
url = QUrl::fromLocalFile(cleanUrl);
for (int j = 0; move && j < rowCount(); ++j) {
const QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
if (local == cleanUrl) {
removeRow(j);
if (j <= row)
row--;
break;
}
}
row = qMax(row, 0);
const QModelIndex idx = fileSystemModel->index(cleanUrl);
if (!fileSystemModel->isDir(idx))
continue;
insertRows(row, 1);
setUrl(index(row, 0), url, idx);
watching.append(qMakePair(idx, cleanUrl));
}
}
示例10: foreach
void DirectoryNode::refresh()
{
QFileInfoList fileList = _dirObject.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries, QDir::DirsFirst | QDir::Name);
QMap<Id, DirectoryNode*> subfolders;
QMap<Id, FileNode*> files;
// FIXME
foreach (QFileInfo fileInfo, fileList) {
if(fileInfo.isDir()){
QString dirName = fileInfo.fileName();
DirectoryNode *node;
if(_subFolderNodes.contains(dirName)){
node = _subFolderNodes.take(dirName);
}else{
node = new DirectoryNode(FileName::fromString(fileInfo.filePath()));
appendRow(node);
}
subfolders.insert(dirName, node);
}else if(fileInfo.isFile()){
QString fileName = fileInfo.fileName();
FileNode* node;
if(_fileNodes.contains(fileName)){
node = _fileNodes.take(fileName);
}else{
node = new FileNode(FileName::fromString(fileInfo.filePath()));
appendRow(node);
}
files.insert(fileName, node);
}
}
foreach (DirectoryNode* item, _subFolderNodes) {
removeRow(item->row());
}
示例11: dropMimeData
/*!
Add urls \a list into the list at \a row. If move then movie
existing ones to row.
\sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
if (row == -1)
row = rowCount();
row = qMin(row, rowCount());
for (int i = list.count() - 1; i >= 0; --i) {
QUrl url = list.at(i);
if (!url.isValid() || url.scheme() != QLatin1String("file"))
continue;
for (int j = 0; move && j < rowCount(); ++j) {
if (index(j, 0).data(UrlRole) == url) {
removeRow(j);
if (j <= row)
row--;
break;
}
}
row = qMax(row, 0);
QModelIndex idx = fileSystemModel->index(url.toLocalFile());
if (!fileSystemModel->isDir(idx))
continue;
insertRows(row, 1);
setUrl(index(row, 0), url, idx);
watching.append(QPair<QModelIndex, QString>(idx, url.toLocalFile()));
}
}
示例12: vlc_array_new
bool MLModel::event( QEvent *event )
{
if ( event->type() == MLEvent::MediaAdded_Type )
{
event->accept();
MLEvent *e = static_cast<MLEvent *>(event);
vlc_array_t* p_result = vlc_array_new();
if ( ml_FindMedia( e->p_ml, p_result, ML_ID, e->ml_media_id ) == VLC_SUCCESS )
{
insertResultArray( p_result );
ml_DestroyResultArray( p_result );
}
vlc_array_destroy( p_result );
return true;
}
else if( event->type() == MLEvent::MediaRemoved_Type )
{
event->accept();
MLEvent *e = static_cast<MLEvent *>(event);
removeRow( getIndexByMLID( e->ml_media_id ).row() );
return true;
}
else if( event->type() == MLEvent::MediaUpdated_Type )
{
event->accept();
/* Never implemented... */
return true;
}
return VLCModel::event( event );
}
示例13: removeRow
void AgentsModel::removeAgentConfig(const QString &agent_id)
{
if (m_row2id.contains(agent_id)) {
int removedRow = m_row2id.indexOf(agent_id);
removeRow(removedRow);
}
}
示例14: setCellContentFromEditor
void TableEditor::endEdit(int row,int col,bool accept,bool replace)
{
Q3Table::endEdit(row,col,accept,replace);
setCellContentFromEditor(row,col);
if(isEmptyRow(row)) if(numRows()>1) removeRow(row);
if(!isEmptyRow(numRows()-1)) addEmptyRow();
}
示例15: watchedDirectoriesChanged
void ResourceLoader::handleDirectoryChanged (const QString& path)
{
emit watchedDirectoriesChanged ();
for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
i->removeAll (path);
QFileInfo fi (path);
if (fi.exists () &&
fi.isDir () &&
fi.isReadable ())
ScanPath (path);
QStringList toRemove;
for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
if (i->isEmpty ())
toRemove << i.key ();
Q_FOREACH (const auto& entry, toRemove)
{
Entry2Paths_.remove (entry);
auto items = SubElemModel_->findItems (entry);
Q_FOREACH (auto item, SubElemModel_->findItems (entry))
SubElemModel_->removeRow (item->row ());
}