本文整理汇总了C++中QStandardItem::index方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::index方法的具体用法?C++ QStandardItem::index怎么用?C++ QStandardItem::index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyFilter
// private
void FilesWidget::applyFilter()
{
QStandardItem *root = m_model.invisibleRootItem();
int parentRowCount = root->rowCount();
for (int parentRow = 0; parentRow < parentRowCount; ++parentRow) {
QStandardItem *parent = root->child(parentRow);
int childRowCount = parent->rowCount();
bool hideParent = true;
for (int childRow = 0; childRow < childRowCount; ++childRow) {
QStandardItem *child = parent->child(childRow);
bool hideChild = !filterAcceptsChild(child->index());
if (!hideChild) {
hideParent = false;
}
m_treeFiles->setRowHidden(childRow, parent->index(), hideChild);
}
updateParentItemMarkers(parent);
m_treeFiles->setRowHidden(parentRow, root->index(), hideParent);
}
}
示例2: row
void
MSCalibrationForm::OnMSReferencesUpdated( const QModelIndex& index )
{
QStandardItemModel& model = *pModel_;
QStandardItem * item = model.itemFromIndex( index );
const adcontrols::MSReferences& refs = pMethod_->references();
if ( item->rowCount() )
item->removeRows( 0, item->rowCount() );
size_t row(0);
for ( adcontrols::MSReferences::vector_type::const_iterator it = refs.begin(); it != refs.end(); ++it, ++row ) {
int col = 0;
std::wstring formula = it->formula();
if ( ! it->adduct_or_loss().empty() )
formula += std::wstring( it->polarityPositive() ? L" + " : L" - ") + it->adduct_or_loss();
StandardItemHelper::appendRow( item, formula, true );
col++;
if ( item->columnCount() < col + 1 )
model.insertColumn( item->columnCount(), item->index() );
model.setData( model.index( row, col, index ), it->exactMass() );
col++;
if ( item->columnCount() < col + 1 )
model.insertColumn( item->columnCount(), item->index() );
model.setData( model.index( row, col, index ), it->enable() );
}
}
示例3: MoveDown
void EditTOC::MoveDown()
{
QModelIndex index = CheckSelection(0);
if (!index.isValid()) {
return;
}
QStandardItem *item = m_TableOfContents->itemFromIndex(index);
QStandardItem *parent_item = item->parent();
if (!parent_item) {
parent_item = m_TableOfContents->invisibleRootItem();
}
int item_row = item->row();
// Can't move down if this row is already the last one of its parent
if (item_row == parent_item->rowCount() - 1) {
return;
}
QList<QStandardItem *> row_items = parent_item->takeRow(item_row);
parent_item->insertRow(item_row + 1, row_items);
// Reselect the item
ui.TOCTree->selectionModel()->clear();
ui.TOCTree->setCurrentIndex(item->index());
ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
ExpandChildren(item);
}
示例4: setCurrentChild
// private slot
void FilesWidget::setCurrentChild(Document *document)
{
// Set current child and parent back to normal
if (m_currentChild != NULL) {
markItemAsCurrent(m_currentChild, false);
QStandardItem *parent = m_currentChild->parent();
m_currentChild = NULL;
updateParentItemMarkers(parent);
}
// Mark new current child as current
if (document != NULL) {
QStandardItem *child = m_children.value(document, NULL);
Q_ASSERT(child != NULL);
QStandardItem *parent = child->parent();
Q_ASSERT(parent != NULL);
m_treeFiles->expand(parent->index());
m_treeFiles->scrollTo(child->index());
m_treeFiles->selectionModel()->select(child->index(), QItemSelectionModel::ClearAndSelect);
m_currentChild = child;
markItemAsCurrent(m_currentChild, true);
updateParentItemMarkers(parent);
}
}
示例5: MoveRight
void EditTOC::MoveRight()
{
QModelIndex index = CheckSelection(0);
if (!index.isValid()) {
return;
}
QStandardItem *item = m_TableOfContents->itemFromIndex(index);
int item_row = item->row();
// Can't indent if row above is already parent
if (item_row == 0) {
return;
}
QStandardItem *parent_item = item->parent();
if (!parent_item) {
parent_item = m_TableOfContents->invisibleRootItem();
}
// Make the item above the parent of this item
QList<QStandardItem *> row_items = parent_item->takeRow(item_row);
QStandardItem *new_parent = parent_item->child(item_row - 1, 0);
new_parent->insertRow(new_parent->rowCount(), row_items);
QStandardItem *new_item = new_parent->child(new_parent->rowCount() - 1, 0);
// Reselect the item
ui.TOCTree->selectionModel()->clear();
ui.TOCTree->setCurrentIndex(item->index());
ui.TOCTree->selectionModel()->select(item->index(), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
ExpandChildren(new_item);
}
示例6: on_addPushButton_clicked
void ItemListWidget::on_addPushButton_clicked()
{
QStandardItem *newItem = new QStandardItem();
mModel->appendRow(newItem);
ui->itemsListView->edit(newItem->index());
ui->itemsListView->setCurrentIndex(newItem->index());
}
示例7: addSpike
void SpikeNoteWidget::addSpike() {
QStandardItem* i = new QStandardItem("Edit Text");
SpikePtr s(new Spike());
stm_->appendRow(i, s);
ui_.spikestreeview->setCurrentIndex(i->index());
ui_.spikestreeview->edit(i->index());
selectIndex(i->index());
}
示例8: addDocument
// private slot
void FilesWidget::addDocument(Document *document)
{
Q_ASSERT(document != NULL);
Q_ASSERT(document != DocumentManager::current());
const Location &location = document->location();
const QString &filePath = location.filePath("unnamed");
const QString &directoryPath = location.directoryPath("unnamed");
const QString &fileName = location.fileName("unnamed");
// Find or create parent item
const QModelIndexList &parents = m_model.match(m_model.index(0, 0, QModelIndex()), DirectoryPathRole,
directoryPath, 1, Qt::MatchExactly);
QStandardItem *parent;
if (parents.isEmpty()) {
parent = new QStandardItem(QIcon(":/icons/16x16/folder.png"), directoryPath);
parent->setToolTip(directoryPath);
parent->setData(directoryPath, DirectoryPathRole);
parent->setData(location.isEmpty() ? "" : directoryPath.toLower(), LowerCaseNameRole);
m_model.appendRow(parent);
m_model.sort(0);
} else {
parent = m_model.itemFromIndex(parents.first());
}
// Create child item
QStandardItem *child = new QStandardItem(QIcon(":/icons/16x16/file.png"), fileName);
child->setToolTip(filePath);
child->setData(qVariantFromValue((void *)document), DocumentPointerRole);
child->setData(fileName, FileNameRole);
child->setData(location.isEmpty() ? "" : fileName.toLower(), LowerCaseNameRole);
m_children.insert(document, child);
parent->appendRow(child);
parent->sortChildren(0);
connect(document, &Document::locationChanged, this, &FilesWidget::updateLocationOfSender);
connect(document, &Document::modificationChanged, this, &FilesWidget::updateModificationMarkerOfSender);
// Apply current filter
if (!filterAcceptsChild(child->index())) {
m_treeFiles->setRowHidden(child->row(), parent->index(), true);
if (parent->rowCount() == 1) {
m_treeFiles->setRowHidden(parent->row(), m_model.invisibleRootItem()->index(), true);
}
}
// Show modification marker, if necessary
updateModificationMarker(document);
updateParentItemMarkers(parent);
}
示例9: removeCookies
void CookiesContentsWidget::removeCookies()
{
const QModelIndexList indexes = m_ui->cookiesView->selectionModel()->selectedIndexes();
if (indexes.isEmpty())
{
return;
}
QNetworkCookieJar *cookieJar = NetworkManagerFactory::getCookieJar();
QList<QNetworkCookie> cookies;
for (int i = 0; i < indexes.count(); ++i)
{
if (!indexes.at(i).isValid())
{
continue;
}
if (indexes.at(i).data(Qt::UserRole).toString().isEmpty())
{
QStandardItem *domainItem = m_model->itemFromIndex(indexes.at(i));
if (!domainItem)
{
continue;
}
for (int j = 0; j < domainItem->rowCount(); ++j)
{
QStandardItem *cookieItem = domainItem->child(j, 0);
if (cookieItem)
{
cookies.append(getCookie((cookieItem->index())));
}
}
}
else
{
QStandardItem *cookieItem = m_model->itemFromIndex(indexes.at(i));
if (cookieItem)
{
cookies.append(getCookie(cookieItem->index()));
}
}
}
for (int i = 0; i < cookies.count(); ++i)
{
cookieJar->deleteCookie(cookies.at(i));
}
}
示例10: addWidget
void CurtainWidget::addWidget(QWidget* widget)
{
int lastRow = mModel->rowCount()-1;
if (lastRow < 0)
return;
QStandardItem *item = mModel->item(lastRow, 0);
QStandardItem *child = new QStandardItem;
item->appendRow(child);
this->setIndexWidget(child->index(), widget);
this->expand(child->index().parent());
}
示例11: addNetwork
/*!
* \param name Name of network
* \param server Default server details
*
* Adds a network to the model.
*/
void ServerModel::addNetwork(QString name, QString server)
{
QStandardItem *root = invisibleRootItem();
QStandardItem *pname = new QStandardItem(QIcon(":/options/gfx/network.png"), name);
QStandardItem *phost = new QStandardItem(server);
QList<QStandardItem*> list;
list << pname << phost;
root->appendRow(list);
hostmap.insert(server, pname->index());
netmap.insert(name, pname->index());
}
示例12:
void
MSPeakSummary::setResult( int row, const std::vector<double>& coeffs, double sd )
{
QStandardItemModel& model = *model_;
QStandardItem * parent = model.itemFromIndex( model.index( r_result, 0 ) );
if ( row >= parent->rowCount() )
parent->setRowCount( row + 1 );
model.setData( model.index( row, c_mspeaksummary_mode, parent->index() ), row );
model.setData( model.index( row, c_mspeaksummary_coeffs + 0, parent->index() ), coeffs[0] );
model.setData( model.index( row, c_mspeaksummary_coeffs + 1, parent->index() ), coeffs[1] );
model.setData( model.index( row, c_mspeaksummary_sd, parent->index() ), sd );
// model.setData( model.index( row, c_mspeaksummary_t0, parent->index() ), t0 );
}
示例13: AddGroup
bool ProgramsModel::AddGroup(QModelIndex &index, int row)
{
int groupId = myHost->programsModel->GetNextGroupId();
QString name("New grp");
//create the group
QStandardItem *groupItem = new QStandardItem( name );
groupItem->setData(GroupNode,NodeType);
groupItem->setData(groupId,ProgramId);
#ifndef QT_NO_DEBUG
groupItem->setData(groupId,Qt::ToolTipRole);
#endif
groupItem->setDragEnabled(true);
groupItem->setDropEnabled(false);
groupItem->setEditable(true);
if(row==-1)
row=rowCount();
insertRow( row, groupItem );
index = groupItem->index();
return true;
}
示例14: AddProgram
bool ProgramsModel::AddProgram(int groupNum, QModelIndex &index, int row)
{
QStandardItem *groupItem = item(groupNum);
//if the group was disabled re-enable it
if(groupItem->rowCount()==0) {
groupItem->setBackground(Qt::transparent);
groupItem->setToolTip("");
}
int progId = myHost->programsModel->GetNextProgId();
QString name("New prog");
//create the program item
QStandardItem *prgItem = new QStandardItem( name );
prgItem->setData(ProgramNode,NodeType);
prgItem->setData(progId,ProgramId);
#ifndef QT_NO_DEBUG
prgItem->setData(progId,Qt::ToolTipRole);
#endif
prgItem->setDragEnabled(true);
prgItem->setDropEnabled(false);
prgItem->setEditable(true);
if(row==-1)
row=groupItem->rowCount();
groupItem->insertRow(row, prgItem);
index = prgItem->index();
// ValidateProgChange(index);
return true;
}
示例15: addProperty
void EPropertySheet::addProperty ( const char* categoryName, const char* propName, EPropertyVar* propVar )
{
QStandardItem* categoryItem = getCategory ( categoryName );
int curRow = 0;
if ( !categoryItem )
{
curRow = mTreeModel->rowCount();
mTreeModel->setRowCount ( curRow + 1 );
categoryItem = new QStandardItem ( categoryName );
mTreeModel->setItem ( curRow, 0, categoryItem );
categoryItem->setEditable ( false );
mTreeView->expand ( categoryItem->index() );
}
QList<QStandardItem*> lists;
EPropertySheetTreeItem* item = new EPropertySheetTreeItem ( propName );
item->setBackground ( QBrush ( Qt::lightGray ) );
item->setEditable ( false );
lists.push_back ( item );
item = new EPropertySheetTreeItem();
item->SetExtraData ( propVar );
QVariant var;
toQVariant ( propVar->mProp, var );
item->setData ( var, Qt::EditRole );
//item->setWhatsThis("WhatsThis");
//item->setStatusTip("StatusTip");
item->setToolTip("ToolTip");
//item->setData ( Qt::EditRole ,var);
lists.push_back ( item );
categoryItem->appendRow ( lists );
}