QStandardItem* PlaylistListModel::FolderByPath(const QString& path) { if (path.isEmpty()) { return invisibleRootItem(); } // Walk down from the root until we find the target folder. This is pretty // inefficient but maintaining a path -> item map is difficult. QStandardItem* parent = invisibleRootItem(); const QStringList parts = path.split('/', QString::SkipEmptyParts); for (const QString& part : parts) { QStandardItem* matching_child = nullptr; const int child_count = parent->rowCount(); for (int i = 0; i < child_count; ++i) { if (parent->child(i)->data(Qt::DisplayRole).toString() == part) { matching_child = parent->child(i); break; } } // Does this folder exist already? if (matching_child) { parent = matching_child; } else { QStandardItem* child = NewFolder(part); parent->appendRow(child); parent = child; } } return parent; }
/** Recharge l'arbre des categories */ void ElementsCategoriesList::reload() { GenericPanel::PanelOptions options = display_elements_ ? GenericPanel::AddAllChildElements : GenericPanel::AddChildElementsContainers; options |= GenericPanel::DisplayElementsPreview; foreach(ElementsCollection *collection, QETApp::availableCollections()) { if (collection == QETApp::commonElementsCollection()) continue; if (collection == QETApp::customElementsCollection()) continue; addElementsCollection(collection, invisibleRootItem(), options) -> setExpanded(true); } // chargement des elements de la collection commune si droits d'ecriture if (QETApp::commonElementsCollection() -> isWritable()) { addElementsCollection( QETApp::commonElementsCollection(), invisibleRootItem(), options ) -> setExpanded(true); } // chargement des elements de la collection utilisateur addElementsCollection( QETApp::customElementsCollection(), invisibleRootItem(), options ) -> setExpanded(true); if (first_load) first_load = false; }
void LibraryTreeWidget::importToLibrary() { QTreeWidgetItem* root = invisibleRootItem(); if (selectedItems().empty() == false) root = selectedItems().front(); QString path = QFileInfo(projectFileName_).path(); QDir dir(path); QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import to Library"), path, tr("All Files (*.*)")); QStringList::Iterator it = fileNames.begin(); while(it != fileNames.end()) { QString fileName = dir.relativeFilePath(*it); if (isFileAlreadyImported(fileName)) { QMessageBox::information(this, tr("Gideros"), tr("The file '%1' cannot be added to the library because it is already a member of the library.").arg(fileName)); } else { QTreeWidgetItem *item = createFileItem(fileName); if (root == invisibleRootItem()) root->addChild(item); else root->insertChild(0, item); root->setExpanded(true); } ++it; } checkModification(); }
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QTreeWidget( p ), p_intf(_p_intf) { setIconSize( QSize( 24,24 ) ); // view->setAlternatingRowColors( true ); setIndentation( 10 ); header()->hide(); setRootIsDecorated( false ); // model = new PLModel( THEPL, p_intf, THEPL->p_root_category, 1, this ); // view->setModel( model ); viewport()->setAcceptDrops(true); setDropIndicatorShown(true); invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled ); createItems(); CONNECT( this, itemActivated( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); /* I believe this is unnecessary, seeing QStyle::SH_ItemView_ActivateItemOnSingleClick CONNECT( view, itemClicked( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); */ /* select the first item */ // view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) ); }
void StandardTreeModel::writeTaskAndChildren(QXmlStreamWriter *writer, QStandardItem *root) { if (root != invisibleRootItem()) { StandardItem *item = static_cast<StandardItem*>(root); writer->writeStartElement(TaskTag); writer->writeAttribute(NameAttribute, item->text()); writer->writeAttribute(DoneAttribute, item->checkState() == Qt::Checked ? "1" : "0"); QListIterator< QPair<QDateTime, QDateTime> > i(item->dateTimes()); while (i.hasNext()) { const QPair<QDateTime, QDateTime> &dateTime = i.next(); writer->writeStartElement(WhenTag); writer->writeAttribute(StartAttribute, dateTime.first.toString(Qt::ISODate)); writer->writeAttribute(EndAttribute, dateTime.second.toString(Qt::ISODate)); writer->writeEndElement(); // WHEN } } for (int row = 0; row < root->rowCount(); ++row) writeTaskAndChildren(writer, root->child(row, 0)); if (root != invisibleRootItem()) writer->writeEndElement(); // TASK }
void AccountTreeWidget::dragEnterEvent( QDragEnterEvent *event ) { if ( event->source() == this && (event->proposedAction() == Qt::MoveAction || dragDropMode() == QAbstractItemView::InternalMove) ) { QList<QTreeWidgetItem*> items = selectedItems(); if( items.size() != 1 ) return; bool dragingIdentity = !dynamic_cast<KopeteAccountLVI*>(items.first()); // Set drop flag based on item we drag if ( dragingIdentity ) invisibleRootItem()->setFlags(invisibleRootItem()->flags() | Qt::ItemIsDropEnabled); else invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled); for ( int i = 0; i < this->topLevelItemCount(); i++ ) { QTreeWidgetItem* identityItem = this->topLevelItem( i ); if ( dragingIdentity ) identityItem->setFlags( identityItem->flags() & ~Qt::ItemIsDropEnabled ); else identityItem->setFlags( identityItem->flags() | Qt::ItemIsDropEnabled ); } QTreeWidget::dragEnterEvent(event); } }
bool QgsLegendModel::writeXML( QDomElement& composerLegendElem, QDomDocument& doc ) const { if ( composerLegendElem.isNull() ) { return false; } QDomElement legendModelElem = doc.createElement( "Model" ); legendModelElem.setAttribute( "autoUpdate", mAutoUpdate ); int nTopLevelItems = invisibleRootItem()->rowCount(); QStandardItem* currentItem = 0; QgsComposerLegendItem* currentLegendItem = 0; for ( int i = 0; i < nTopLevelItems; ++i ) { currentItem = invisibleRootItem()->child( i, 0 ); currentLegendItem = dynamic_cast<QgsComposerLegendItem*>( currentItem ); if ( currentLegendItem ) { currentLegendItem->writeXML( legendModelElem, doc ); } } composerLegendElem.appendChild( legendModelElem ); return true; }
void KeepassGroupView::OnSort() { QHash<QTreeWidgetItem*,int> oldIndex; for (int i=0; i<Items.size(); i++) { if (Items[i]->parent()) oldIndex.insert(Items[i], Items[i]->parent()->indexOfChild(Items[i])); else oldIndex.insert(Items[i], invisibleRootItem()->indexOfChild(Items[i])); } sortItems(0, Qt::AscendingOrder); bool modified = false; QMutableHashIterator<QTreeWidgetItem*, int> i(oldIndex); while (i.hasNext()) { i.next(); int newIndex; IGroupHandle* parent; if (i.key()->parent()) { newIndex = i.key()->parent()->indexOfChild(i.key()); parent = static_cast<GroupViewItem*>(i.key()->parent())->GroupHandle; } else { newIndex = invisibleRootItem()->indexOfChild(i.key()); parent = NULL; } if (newIndex != i.value()) { db->moveGroup(static_cast<GroupViewItem*>(i.key())->GroupHandle, parent, newIndex); modified = true; } } if (modified) emit fileModified(); }
bool XbelModel::slot_raschet() { str_mes_pos_ves_model.clear(); str_mes_posl_model.clear(); str_mes_dr_model.clear(); ras_init(invisibleRootItem()); //Приводим к нормальному виду со значениями только в последних child if(!str_mes_posl_model.isNull()) { QMessageBox::about(0,tr("Предупреждение"),tr("Не заполнен показатель эргономичности элемента ").append(str_mes_posl_model)); return false; } if(!str_mes_dr_model.isNull()) { QMessageBox::about(0,tr("Предупреждение"),tr("Заполнен показатель эргономичности элемента ").append(str_mes_dr_model).append(tr(" который должен рассчитываться"))); return false; } if(!str_mes_pos_ves_model.isNull()) { QMessageBox::about(0,tr("Предупреждение"),tr("Не заполнен коэффициент весомости элемента ").append(str_mes_pos_ves_model)); return false; } for(int i =0; i < Vlosh_model; ++i) { ras_func(invisibleRootItem()->child(0,0),invisibleRootItem()->child(0,1)); //расчет value } //расчет number //slot_ras_number(invisibleRootItem()->child(0,0),invisibleRootItem()->child(0,3),invisibleRootItem()->child(0,4)); return true; }
bool TrialTreeModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent) { if (QStandardItemModel::dropMimeData(mimeData, action, row, column, parent)) return true; if (mimeData->hasUrls()) { const QList<QUrl> urls = mimeData->urls(); QStandardItem * dropInto = itemFromIndex(parent); if (dropInto && !dropInto->data().isNull()) { // printf("Dropping onto '%s'\n", dropInto->data().toString().toAscii().data()); QStandardItem * const tmp = new QStandardItem("Group"); QStandardItem * const p = (dropInto->parent() ? dropInto->parent() : invisibleRootItem()); p->insertRow(dropInto->row(), tmp); tmp->setChild(0, 0, dropInto->clone()); p->removeRow(dropInto->row()); dropInto = tmp; } if (!dropInto) dropInto = invisibleRootItem(); int i = 0; for (QList<QUrl>::const_iterator it = urls.begin(); it != urls.end(); ++it, i++) { QFileInfo fileInfo(it->toLocalFile()); QStandardItem * const newItem = new QStandardItem(fileInfo.fileName()); newItem->setData(QDir::current().relativeFilePath(fileInfo.filePath())); newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled/* | Qt::ItemIsDropEnabled*/); dropInto->appendRow(newItem); } return true; } return false; }
/*! \brief TreeModel::deleteAllItems Deletes all items in the QTreeView. */ void TreeModel::deleteAllItems() { while ( invisibleRootItem()->rowCount() > 0 ) { QList<QStandardItem*> childs = invisibleRootItem()->takeRow( 0 ); qDeleteAll( childs ); } }
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QTreeWidget( p ), p_intf(_p_intf) { /* Properties */ setFrameStyle( QFrame::NoFrame ); setAttribute( Qt::WA_MacShowFocusRect, false ); viewport()->setAutoFillBackground( false ); setIconSize( QSize( 24,24 ) ); setIndentation( 12 ); setHeaderHidden( true ); setRootIsDecorated( true ); setAlternatingRowColors( false ); /* drops */ viewport()->setAcceptDrops(true); setDropIndicatorShown(true); invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled ); #ifdef Q_OS_MAC setAutoFillBackground( true ); QPalette palette; palette.setColor( QPalette::Window, QColor(209,215,226) ); setPalette( palette ); #endif setMinimumHeight( 120 ); /* Podcasts */ podcastsParent = NULL; podcastsParentId = -1; /* Podcast connects */ CONNECT( THEMIM, playlistItemAppended( int, int ), this, plItemAdded( int, int ) ); CONNECT( THEMIM, playlistItemRemoved( int ), this, plItemRemoved( int ) ); DCONNECT( THEMIM->getIM(), metaChanged( input_item_t *), this, inputItemUpdate( input_item_t * ) ); createItems(); setRootIsDecorated( false ); setIndentation( 5 ); /* Expand at least to show level 2 */ for ( int i = 0; i < topLevelItemCount(); i++ ) expandItem( topLevelItem( i ) ); /*** * We need to react to both clicks and activation (enter-key) here. * We use curItem to avoid rebuilding twice. * See QStyle::SH_ItemView_ActivateItemOnSingleClick ***/ curItem = NULL; CONNECT( this, itemActivated( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); CONNECT( this, itemClicked( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); }
/** * We need to manually manage these progress widgets because QTreeWidget does a poor job of it. * This should be called when the progress bar instances have changed (new progress, lost a * progress, etc...). This is not necessary when the progress values have changed. * * Failing to call this method results in seg faults when other events occur - such as a * resize event. */ void HistoryTreeWidget::updateProgressWidgets() { for (int i = 0; i < invisibleRootItem()->childCount(); i++) { QTreeWidgetItem *item = invisibleRootItem()->child(i); WorkOrder *workOrder = item->data(0, Qt::UserRole).value<WorkOrder *>(); if (workOrder && itemWidget(item, 1) != workOrder->progressBar()) { setItemWidget(item, 1, workOrder->progressBar()); } } }
SeparatorItem *MiamItemModel::insertSeparator(const QStandardItem *node) { // Items are grouped every ten years in this particular case switch (SettingsPrivate::instance()->insertPolicy()) { case SettingsPrivate::IP_Years: { int year = node->text().toInt(); if (year == 0) { return nullptr; } QString yearStr = QString::number(year - year % 10); if (_letters.contains(yearStr)) { return _letters.value(yearStr); } else { SeparatorItem *separator = new SeparatorItem(yearStr); separator->setData(yearStr, Miam::DF_NormalizedString); invisibleRootItem()->appendRow(separator); _letters.insert(yearStr, separator); return separator; } break; } // Other types of hierarchy, separators are built from letters default: QString c; if (node->data(Miam::DF_CustomDisplayText).toString().isEmpty()) { c = node->text().left(1).normalized(QString::NormalizationForm_KD).toUpper().remove(QRegExp("[^A-Z\\s]")); } else { QString reorderedText = node->data(Miam::DF_CustomDisplayText).toString(); c = reorderedText.left(1).normalized(QString::NormalizationForm_KD).toUpper().remove(QRegExp("[^A-Z\\s]")); } QString letter; bool topLevelLetter = false; if (c.contains(QRegExp("\\w"))) { letter = c; } else { letter = tr("Various"); topLevelLetter = true; } if (_letters.contains(letter)) { return _letters.value(letter); } else { SeparatorItem *separator = new SeparatorItem(letter); if (topLevelLetter) { separator->setData("0", Miam::DF_NormalizedString); } else { separator->setData(letter.toLower(), Miam::DF_NormalizedString); } invisibleRootItem()->appendRow(separator); _letters.insert(letter, separator); return separator; } } return nullptr; }
void YaChatViewModel::addDummyHeader() { if (dummyHeader_) { invisibleRootItem()->removeRow(dummyHeader_->row()); dummyHeader_ = 0; } dummyHeader_ = new QStandardItem(); dummyHeader_->setData(QVariant(DummyHeader), TypeRole); invisibleRootItem()->insertRow(0, dummyHeader_); }
bool SourceFileModel::dropSourceFiles(QMimeData const *data, Qt::DropAction action, int row, QModelIndex const &parent) { if (action != Qt::MoveAction) return QAbstractItemModel::dropMimeData(data, action, row, 0, parent); auto encoded = data->data(mtx::gui::MimeTypes::MergeSourceFileModelItem); QDataStream stream{&encoded, QIODevice::ReadOnly}; while (!stream.atEnd()) { quint64 value; stream >> value; auto sourceFile = m_sourceFileMap[value]; auto sourceIdx = indexFromSourceFile(sourceFile.get()); if (!sourceIdx.isValid()) continue; auto sourceParent = sourceIdx.parent(); auto sourceParentItem = sourceParent.isValid() ? itemFromIndex(sourceParent) : invisibleRootItem(); auto rowItems = sourceParentItem->takeRow(sourceIdx.row()); if (!parent.isValid()) { if ((sourceParent == parent) && (sourceIdx.row() < row)) --row; invisibleRootItem()->insertRow(row, rowItems); ++row; } else { auto parentFile = fromIndex(parent); Q_ASSERT(parentFile); if (sourceFile->isAdditionalPart()) row = std::min(row, parentFile->m_additionalParts.size()); else row = std::max(row, parentFile->m_additionalParts.size()); if ((sourceParent == parent) && (sourceIdx.row() < row)) --row; itemFromIndex(parent)->insertRow(row, rowItems); ++row; } updateSourceFileLists(); } return false; }
QStandardItem* QgsLegendModel::addGroup( QString text, int position ) { QgsComposerGroupItem* groupItem = new QgsComposerGroupItem( text ); if ( position == -1 ) { invisibleRootItem()->insertRow( invisibleRootItem()->rowCount(), groupItem ); } else { invisibleRootItem()->insertRow( position, groupItem ); } return groupItem; }
QList<QStandardItem*> AMWindowPaneModel::headingItems() const { QList<QStandardItem*> headings; for (int i = 0, count = invisibleRootItem()->rowCount(); i < count; i++) { QStandardItem *item = invisibleRootItem()->child(i, 0); if (item) headings << item; } return headings; }
PLSelector::PLSelector( QWidget *p, intf_thread_t *_p_intf ) : QTreeWidget( p ), p_intf(_p_intf) { /* Properties */ setFrameStyle( QFrame::NoFrame ); setAttribute( Qt::WA_MacShowFocusRect, false ); viewport()->setAutoFillBackground( false ); setIconSize( QSize( 24,24 ) ); setIndentation( 12 ); setHeaderHidden( true ); setRootIsDecorated( true ); setAlternatingRowColors( false ); /* drops */ viewport()->setAcceptDrops(true); setDropIndicatorShown(true); invisibleRootItem()->setFlags( invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled ); /* Podcasts */ podcastsParent = NULL; podcastsParentId = -1; /* Podcast connects */ CONNECT( THEMIM, playlistItemAppended( int, int ), this, plItemAdded( int, int ) ); CONNECT( THEMIM, playlistItemRemoved( int ), this, plItemRemoved( int ) ); DCONNECT( THEMIM->getIM(), metaChanged( input_item_t *), this, inputItemUpdate( input_item_t * ) ); createItems(); CONNECT( this, itemActivated( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); CONNECT( this, itemClicked( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); /* I believe this is unnecessary, seeing QStyle::SH_ItemView_ActivateItemOnSingleClick CONNECT( view, itemClicked( QTreeWidgetItem *, int ), this, setSource( QTreeWidgetItem *) ); */ /* select the first item */ // view->setCurrentIndex( model->index( 0, 0, QModelIndex() ) ); #ifdef Q_WS_MAC setAutoFillBackground( true ); QPalette palette; palette.setColor( QPalette::Window, QColor(209,215,226) ); setPalette( palette ); #endif }
void StandardTreeModel::load(const QString &filename) { if (!filename.isEmpty()) m_filename = filename; if (m_filename.isEmpty()) throw AQP::Error(tr("no filename specified")); QFile file(m_filename); if (!file.open(QIODevice::ReadOnly)) throw AQP::Error(file.errorString()); clear(); QStack<QStandardItem*> stack; stack.push(invisibleRootItem()); QXmlStreamReader reader(&file); while (!reader.atEnd()) { reader.readNext(); if (reader.isStartElement()) { if (reader.name() == TaskTag) { const QString name = reader.attributes() .value(NameAttribute).toString(); bool done = reader.attributes().value(DoneAttribute) == "1"; StandardItem *nameItem = createNewTask(stack.top(), name, done); stack.push(nameItem); } else if (reader.name() == WhenTag) { const QDateTime start = QDateTime::fromString( reader.attributes().value(StartAttribute) .toString(), Qt::ISODate); const QDateTime end = QDateTime::fromString( reader.attributes().value(EndAttribute) .toString(), Qt::ISODate); StandardItem *nameItem = static_cast<StandardItem*>( stack.top()); nameItem->addDateTime(start, end); } } else if (reader.isEndElement()) { if (reader.name() == TaskTag) stack.pop(); } } if (reader.hasError()) throw AQP::Error(reader.errorString()); if (stack.count() != 1 || stack.top() != invisibleRootItem()) throw AQP::Error(tr("loading error: possibly corrupt file")); calculateTotalsFor(invisibleRootItem()); }
void XbelModel::createItem(QStandardItem *parent, int level) { if(level > num_max_model) num_max_model = level; QList<QStandardItem*> items; items << new QStandardItem("title"); items << new QStandardItem(""); items << new QStandardItem(""); items << new QStandardItem(""); items << new QStandardItem(QString::number(level)); parent->appendRow(items); slot_ras_number(invisibleRootItem()->child(0,0),invisibleRootItem()->child(0,3),invisibleRootItem()->child(0,4)); }
void TransferListView::setGroupMode(GroupMode mode) { if(mode == mGroupMode) return; mGroupMode = mode; if(mGroupMode == None) { QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> subitems; QList<QTreeWidgetItem *>::iterator sitx; items = invisibleRootItem()->takeChildren (); QList<QTreeWidgetItem *>::iterator itx = items.begin(); for(; itx != items.end(); ++itx) { if ( ! ( *itx)->text(1).isNull()) invisibleRootItem()->addChild(*itx); else { subitems = (*itx)->takeChildren(); sitx = subitems.begin(); for(; sitx != subitems.end(); ++sitx) invisibleRootItem()->addChild(*sitx); } } setRootIsDecorated(false); } else { QList<QTreeWidgetItem *> items; items = invisibleRootItem()->takeChildren (); QList<QTreeWidgetItem *>::iterator itx = items.begin(); for(; itx != items.end(); ++itx) { if ( (*itx)->text(1).isNull()) invisibleRootItem()->addChild(*itx); } itx = items.begin(); for(; itx != items.end(); ++itx) { if (! (*itx)->text(1).isNull()) { TransferListItem *itxx = dynamic_cast<TransferListItem *>(*itx); if (itxx) findParent(itxx->user())->addChild(*itx); } } updateParentsStats(); setRootIsDecorated(true); } }
/** * Get the QTreeWidgetItem associated with the given undo command (work order). Returns NULL if * none found or given NULL. * * @param undoCommand A work order * @return The QTreeWidgetItem that represents (is associated with) the undoCommand */ QTreeWidgetItem *HistoryTreeWidget::undoCommandToTreeItem(const QUndoCommand *undoCommand) { QTreeWidgetItem *result = NULL; if (undoCommand) { for (int i = invisibleRootItem()->childCount() - 1; !result && i >= 0; i--) { QTreeWidgetItem *item = invisibleRootItem()->child(i); WorkOrder *workOrder = item->data(0, Qt::UserRole).value<WorkOrder *>(); if (undoCommand == workOrder) result = item; } } return result; }
void XbelModel::writeFolderElement(QXmlStreamWriter *xmlWriter, QStandardItem *root, QStandardItem *root1,QStandardItem *root2,QStandardItem *root3,QStandardItem *root4) { if (root != invisibleRootItem()) { xmlWriter->writeStartElement("folder"); xmlWriter->writeAttribute("title", root->text()); xmlWriter->writeAttribute("value_ergo", root1->text()); xmlWriter->writeAttribute("value_ves", root2->text()); xmlWriter->writeAttribute("value_number", root3->text()); xmlWriter->writeAttribute("folded", root4->text()); } for (int row = 0; row < root->rowCount(); ++row) writeFolderElement(xmlWriter, root->child(row, 0), root->child(row, 1), root->child(row, 2), root->child(row, 3), root->child(row, 4)); if (root != invisibleRootItem()) xmlWriter->writeEndElement(); }
void QgsLegendModel::setLayerSetAndGroups( const QStringList& layerIds, const QList< GroupLayerInfo >& groupInfo ) { setLayerSet( layerIds ); QStandardItem* currentItem = 0; QStandardItem* currentGroupItem = 0; int i = 0; QList< GroupLayerInfo >::const_iterator infoIt = groupInfo.constBegin(); for ( ; infoIt != groupInfo.constEnd() && i < invisibleRootItem()->rowCount(); ) { currentItem = invisibleRootItem()->child( i, 0 ); QString infoKey = infoIt->first; if ( infoKey.isNull() ) //a toplevel layer { ++i; } else //a group { currentGroupItem = addGroup( infoKey, i ); ++i; QList<QString> layerList = infoIt->second; QList<QString>::const_iterator groupLayerIt = layerList.constBegin(); for ( ; currentItem && ( groupLayerIt != layerList.constEnd() ); ++groupLayerIt ) { //check if current item is contained in this group QgsComposerLayerItem* layerItem = dynamic_cast<QgsComposerLayerItem*>( currentItem ); if ( !layerItem ) { return; //should never happen } //QString layerID = currentItem->data(Qt::UserRole + 2).toString(); QString layerID = layerItem->layerID(); if ( layerList.contains( layerID ) ) { takeRow( i ); currentGroupItem->setChild( currentGroupItem->rowCount(), 0, currentItem ); } else { ++i; } currentItem = invisibleRootItem()->child( i, 0 ); } } ++infoIt; } }
/** * A work order was lost... compensate by removing it from the tree. */ void HistoryTreeWidget::removeFromHistory(QObject *deletedObject) { QTreeWidgetItem *itemToRemove = undoCommandToTreeItem( (QUndoCommand *)((WorkOrder *)deletedObject)); if (itemToRemove) { int indexToDelete = invisibleRootItem()->indexOfChild(itemToRemove); if (indexToDelete < invisibleRootItem()->childCount()) { // Clear progress bar widget setItemWidget(invisibleRootItem()->child(indexToDelete), 1, NULL); // Take & delete the tree item delete invisibleRootItem()->takeChild(indexToDelete); } } }
int Scene::erase(int index) { clear(); index_map.clear(); if(index < 0 || index >= m_entries.size()) return -1; CGAL::Three::Scene_item* item = m_entries[index]; CGAL::Three::Scene_group_item* group = qobject_cast<CGAL::Three::Scene_group_item*>(item); if(group) { m_group_entries.removeAll(group); } Q_FOREACH(CGAL::Three::Scene_group_item* group, m_group_entries) { if(group->getChildren().contains(item)) group->removeChild(item); } Q_EMIT itemAboutToBeDestroyed(item); delete item; m_entries.removeAll(item); selected_item = -1; Q_FOREACH(Scene_item* item, m_entries) { organize_items(item, invisibleRootItem(), 0); }
/* Returns the insertion position for new_row in a sorted list, or -1 if it should be appended */ int mail_item_model::insertion_point(QList<QStandardItem*>& new_row, QStandardItem* parent, int column, Qt::SortOrder order) { const QStandardItem* item_col = new_row[column]; Q_ASSERT(item_col!=NULL); // binary search int l=0; if (!parent) { parent=invisibleRootItem(); } int r=parent->rowCount()-1; while (l<=r) { int mid=(l+r)/2; const QStandardItem* mid_item=parent->child(mid, column); Q_ASSERT(mid_item!=NULL); if (*mid_item < *item_col) { if (order==Qt::AscendingOrder) l=mid+1; else r=mid-1; } else { if (order==Qt::AscendingOrder) r=mid-1; else l=mid+1; } } return l; }
QPair<QtPropertyItem*, QtPropertyItem*> QtPropertyModel::GetProperty(const QString &name, QtPropertyItem* parent/* = NULL*/) { QPair<QtPropertyItem*, QtPropertyItem*> ret(NULL, NULL); QStandardItem* root = (QStandardItem *) parent; if(NULL == root) { root = invisibleRootItem(); } for(DAVA::int32 r = 0; r < root->rowCount(); ++r) { QtPropertyItem *keyItem = (QtPropertyItem *) root->child(r, 0); if(keyItem->GetPropertyData()->GetValue().toString() == name) { QtPropertyItem *dataItem = (QtPropertyItem *) root->child(r, 1); ret.first = keyItem; ret.second = dataItem; break; } } return ret; }
CntGroupEditorModel::CntGroupEditorModel(QContact* aContact) : CntDetailEditorModel(aContact) { QList<QContactName> nameDetails = mContact->details<QContactName>(); if (nameDetails.isEmpty()) { QContactName emptyName; nameDetails.append(emptyName); } QList<QContactPhoneNumber> numberDetails = mContact->details<QContactPhoneNumber>(); if (numberDetails.isEmpty()) { QContactPhoneNumber emptyNumber; numberDetails.append(emptyNumber); } iGroupName = nameDetails.first(); iGroupConfCallNumber = numberDetails.first(); HbDataFormModelItem::DataItemType type = HbDataFormModelItem::TextItem; iNameItem = new HbDataFormModelItem(type, hbTrId("txt_phob_formlabel_group_name")); iNumberItem = new HbDataFormModelItem(type, hbTrId("txt_phob_formlabel_conference_number")); iNameItem->setContentWidgetData("text", iGroupName.customLabel()); iNameItem->setContentWidgetData("maxLength", CNT_GROUPNAME_MAXLENGTH); iNumberItem->setContentWidgetData("text", iGroupConfCallNumber.number() ); iNumberItem->setContentWidgetData("maxLength", CNT_PHONENUMBER_EDITOR_MAXLENGTH); HbDataFormModelItem* root = invisibleRootItem(); appendDataFormItem( iNameItem, root); appendDataFormItem( iNumberItem, root); }