MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part): QNetworkReply(parent), part(part) { QUrl url; url.setScheme(QStringLiteral("trojita-imap")); url.setHost(QStringLiteral("msg")); url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString()); setUrl(url); setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered); Q_ASSERT(part.isValid()); connect(part.model(), &QAbstractItemModel::dataChanged, this, &MsgPartNetworkReply::slotModelDataChanged); // We have to ask for contents before we check whether it's already fetched part.data(Imap::Mailbox::RolePartData); // The part data might be already unavailable or already fetched QTimer::singleShot(0, this, SLOT(slotMyDataChanged())); QByteArray* bufferPtr = part.data(Imap::Mailbox::RolePartBufferPtr).value<QByteArray*>(); Q_ASSERT(bufferPtr); buffer.setBuffer(bufferPtr); buffer.open(QIODevice::ReadOnly); }
void tst_QDirModel::task196768_sorting() { //this task showed that the persistent model indexes got corrupted when sorting QString path = SRCDIR; QDirModel model; /* QDirModel has a bug if we show the content of the subdirectory inside a hidden directory and we don't add QDir::Hidden. But as QDirModel is deprecated, we decided not to fix it. */ model.setFilter(QDir::AllEntries | QDir::Hidden | QDir::AllDirs); QTreeView view; QPersistentModelIndex index = model.index(path); view.setModel(&model); QModelIndex index2 = model.index(path); QCOMPARE(index.data(), index2.data()); view.setRootIndex(index); index2 = model.index(path); QCOMPARE(index.data(), index2.data()); view.setCurrentIndex(index); index2 = model.index(path); QCOMPARE(index.data(), index2.data()); view.setSortingEnabled(true); index2 = model.index(path); QCOMPARE(index.data(), index2.data()); }
void GraphicalModelView::rowsInserted(const QModelIndex &parent, int start, int end) { const QPersistentModelIndex parentIndex = parent.sibling(parent.row(), 0); Id parentLogicalId = parentIndex.data(roles::logicalIdRole).value<Id>(); for (int row = start; row <= end; ++row) { const QPersistentModelIndex current = model()->index(row, 0, parent); const Id logicalId = current.data(roles::logicalIdRole).value<Id>(); if (parentLogicalId.isNull() || parentLogicalId.editor() != "MetaEditor" || logicalId.editor() != "MetaEditor") { parentLogicalId = Id::rootId(); } const QString name = current.data(Qt::DisplayRole).toString(); if (logicalId.isNull()) { // No logical Id for this item, so logical model shouldn't care // about it. continue; } // Add this element to a root for now. To be able to do something // useful, we need to establish a correspondence between logical // and graphical model hierarchy. It is not always easy since // some elements have no correspondences in another model, and tree // structures may be very different by themselves. LogicalModel * const logicalModel = static_cast<LogicalModel *>(mModel); const bool isEdge = mModel->editorManagerInterface().isNodeOrEdge(logicalId.editor(), logicalId.element()); ElementInfo elementInfo(logicalId, logicalId, parentLogicalId, Id(), {{"name", name}}, {}, Id(), isEdge); logicalModel->addElementToModel(elementInfo); } }
void TilesetEditor::changeSelectedTile (QPersistentModelIndex newTile) { if (tileSelectedId >= 0 && tileSelectedId < tiles.size()) { if (newTile.isValid() && m_projectWidget->typeOfIndex(newTile) == ProjectWidget::Tile) { QImage tmpImage(newTile.data(ProjectWidget::TileRole).value<QImage>()); tiles[tileSelectedId]->setPixmap(QPixmap::fromImage(tmpImage)); tilesId[tileSelectedId] = newTile.data(ProjectWidget::IdRole).toInt(); } } }
void NodeTypesDelegate::updateItemWidgets(const QList< QWidget* > widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const { // widgets: // ColorButton | Title | ID if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 4); KColorButton *colorButton = qobject_cast<KColorButton*>(widgets.at(0)); QLineEdit *title = qobject_cast<QLineEdit*>(widgets.at(1)); QLabel *id = qobject_cast<QLabel*>(widgets.at(2)); QToolButton *propertiesButton = qobject_cast<QToolButton*>(widgets.at(3)); Q_ASSERT(title); Q_ASSERT(colorButton); Q_ASSERT(id); Q_ASSERT(propertiesButton); colorButton->setColor(index.data(NodeTypeModel::ColorRole).value<QColor>()); title->setText(index.data(NodeTypeModel::TitleRole).toString()); id->setText(index.data(NodeTypeModel::IdRole).toString()); QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hPadding, m_vPadding, -m_hPadding, -m_vPadding); int colorButtonLeftMargin = contentRect.left(); int colorButtonTopMargin = (outerRect.height() - colorButton->height()) / 2; colorButton->move(colorButtonLeftMargin, colorButtonTopMargin); int titleLeftMargin = colorButtonLeftMargin + colorButton->width() + 10; int titleTopMargin = (outerRect.height() - title->height()) / 2; title->move(titleLeftMargin, titleTopMargin); // construct remaining from right to left int propertiesLeftMargin = contentRect.right() - propertiesButton->width() - m_hPadding; int propertiesTopMargin = (outerRect.height() - propertiesButton->height()) / 2; propertiesButton->move(propertiesLeftMargin, propertiesTopMargin); int idLeftMargin = propertiesLeftMargin - id->width() - 10; int idTopMargin = (outerRect.height() - id->height()) / 2; id->move(idLeftMargin, idTopMargin); // title gets remaining space title->setFixedWidth(qMax(0, idLeftMargin - titleLeftMargin - 10)); }
void TilesetEditor::tileModified(const QPersistentModelIndex &mTile) { if (m_projectWidget->projectOfIndex(mTile) == m_projectWidget->projectOfIndex(m_tilesetIndex)) { int mId = mTile.data(ProjectWidget::IdRole).toInt(); int i=0; while (i<tilesId.size() && tilesId.at(i) != mId) i++; if (i<tilesId.size() && tilesId.at(i) == mId) { QImage tmpImage(mTile.data(ProjectWidget::TileRole).value<QImage>()); if (tmpImage.size() == QSize(wm_tilesWidth->value(), wm_tilesHeight->value())) tiles.at(i)->setPixmap(QPixmap::fromImage(tmpImage)); else { tilesId[i] = -1; tiles.at(i)->clearTile(); } } } }
void MainWindow::slotMarkersMoved(const QList<QPersistentModelIndex>& markerIndices) { // prepare altitude lookups LookupAltitude::Request::List altitudeQueries; for (int i = 0; i < markerIndices.count(); ++i) { const QPersistentModelIndex currentIndex = markerIndices.at(i); const GeoCoordinates newCoordinates = currentIndex.data(RoleCoordinates).value<GeoCoordinates>(); LookupAltitude::Request myLookup; myLookup.coordinates = newCoordinates; myLookup.data = QVariant::fromValue(QPersistentModelIndex(currentIndex)); altitudeQueries << myLookup; } if (!altitudeQueries.isEmpty()) { LookupAltitude* const myAltitudeLookup = LookupFactory::getAltitudeLookup(QString::fromLatin1("geonames"), this); connect(myAltitudeLookup, SIGNAL(signalRequestsReady(QList<int>)), this, SLOT(slotAltitudeRequestsReady(QList<int>))); connect(myAltitudeLookup, SIGNAL(signalDone()), this, SLOT(slotAltitudeLookupDone())); myAltitudeLookup->addRequests(altitudeQueries); d->lookupAltitudeList << myAltitudeLookup; /// @todo Check the return value? myAltitudeLookup->startLookup(); qDebug() << "Starting lookup for " << altitudeQueries.count() << " items!"; } }
MsgPartNetworkReply::MsgPartNetworkReply(MsgPartNetAccessManager *parent, const QPersistentModelIndex &part, bool requireFormatting): QNetworkReply(parent), part(part), formattedBufferContent(0), requireFormatting(requireFormatting) { QUrl url; url.setScheme(QLatin1String("trojita-imap")); url.setHost(QLatin1String("msg")); url.setPath(part.data(Imap::Mailbox::RolePartPathToPart).toString()); setUrl(url); setOpenMode(QIODevice::ReadOnly | QIODevice::Unbuffered); Q_ASSERT(part.isValid()); const Mailbox::Model *model = 0; Mailbox::Model::realTreeItem(part, &model); Q_ASSERT(model); connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotModelDataChanged(QModelIndex,QModelIndex))); //TODO: fileDownloadProgress signal in model signal the process of the current download. // This reply might not be the current download, but now we assume that because the only use case here // is just see the download progress of attachments that is usually the only downloading event. // Should match message UID and partId and then emit downloadProgress. connect(model, SIGNAL(fileDownloadProgress(qint64, qint64)), this, SIGNAL(downloadProgress(qint64,qint64))); Mailbox::TreeItemPart *partPtr = dynamic_cast<Mailbox::TreeItemPart *>(static_cast<Mailbox::TreeItem *>(part.internalPointer())); Q_ASSERT(partPtr); // We have to ask for contents before we check whether it's already fetched partPtr->fetch(const_cast<Mailbox::Model *>(model)); // The part data might be already unavailable or already fetched QTimer::singleShot(0, this, SLOT(slotMyDataChanged())); buffer.setBuffer(partPtr->dataPtr()); buffer.open(QIODevice::ReadOnly); }
void AccountWidget::setupConnections( const QPersistentModelIndex& idx, int accountIdx ) { m_myFactoryIdx = idx; m_myAccountIdx = accountIdx; Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { connect( m_statusToggle, SIGNAL( toggled( bool ) ), this, SLOT( changeAccountConnectionState( bool ) ) ); connect( m_inviteButton, SIGNAL( clicked() ), this, SLOT( sendInvite() ) ); connect( m_inviteEdit, SIGNAL( returnPressed() ), this, SLOT( sendInvite() ) ); if ( account->sipPlugin() ) { m_inviteEdit->setPlaceholderText( account->sipPlugin()->inviteString() ); connect( account->sipPlugin(), SIGNAL( inviteSentSuccess( QString ) ), SLOT( onInviteSentSuccess( QString ) ) ); connect( account->sipPlugin(), SIGNAL( inviteSentFailure( QString ) ), SLOT( onInviteSentFailure( QString ) ) ); } } }
void TabTreeView::rowsInserted(const QModelIndex &parent, int start, int end) { QTreeView::rowsInserted(parent, start, end); if (m_initializing) { return; } // Parent for WebTab is set after insertTab is emitted const QPersistentModelIndex index = model()->index(start, 0, parent); QTimer::singleShot(0, this, [=]() { if (!index.isValid()) { return; } QModelIndex idx = index; QVector<QModelIndex> stack; do { stack.append(idx); idx = idx.parent(); } while (idx.isValid()); for (const QModelIndex &index : qAsConst(stack)) { expand(index); } if (index.data(TabModel::CurrentTabRole).toBool()) { setCurrentIndex(index); } }); }
void ItemsViewDelegate::updateItemWidgets( const QList<QWidget*> widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index ) const { const GluonPlayer::GameItemsModel* model = qobject_cast<const GluonPlayer::GameItemsModel*>( index.model() ); if( !model ) { kDebug() << "Warning - Invalid Model!"; return; } // setup the install button int margin = option.fontMetrics.height() / 2; int right = option.rect.width(); const_cast<QSize&>( m_buttonSize ) = QSize( 32, 32 ); KPushButton* playButton = qobject_cast<KPushButton*>( widgets.at( DelegatePlayButton ) ); if( playButton ) { playButton->setIcon( KIcon( "media-playback-start" ) ); playButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::MinimumExpanding ); playButton->resize( m_buttonSize ); playButton->move( right - playButton->width() - margin, option.fontMetrics.height() + playButton->height() * 0.5 ); } GameTextLabel* gameName = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameName ) ); // gameName->setWordWrap(true); if( gameName ) { gameName->move( margin + m_buttonSize.width() * 3, option.fontMetrics.height() ); gameName->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) ); gameName->setText( index.data( GluonPlayer::GameItemsModel::GameNameRole ).toString() ); } GameTextLabel* gameDescription = qobject_cast<GameTextLabel*>( widgets.at( DelegateGameDescription ) ); // gameName->setWordWrap(true); if( gameDescription ) { gameDescription->move( margin + m_buttonSize.width() * 3, option.fontMetrics.height() * 1 + gameName->size().height() ); gameDescription->resize( QSize( option.rect.width() - ( margin * 4 ) - m_buttonSize.width() * 4, option.fontMetrics.height() * 2 ) ); gameDescription->setText( index.data( GluonPlayer::GameItemsModel::GameDescriptionRole ).toString() ); } }
QList<ListItemElement> MyListWidget::getListItemElements(QPersistentModelIndex index, QRect containingRect){ QList<ListItemElement> res; ListItemElement pinElement; QRect pinRect = IconDelegate::getPinItemRect(containingRect); pinElement.m_rect = pinRect; pinElement.m_toolMessage = PIN_MESSAGE; pinElement.m_actionName = PIN_OPERATION_NAME; res.append(pinElement); ListItemElement depricateElement; QRect depricateRect = IconDelegate::getDepricateItemRect(containingRect); depricateElement.m_rect = depricateRect; depricateElement.m_toolMessage = DEPRICATE_MESSAGE; depricateElement.m_actionName = DEPRICATE_OPERATION_NAME; res.append(depricateElement); if(index.data(ROLE_HAS_PARENT_ELEMENT).toBool()){ ListItemElement parentArrowElement; QRect parentArrowRect = IconDelegate::getParentArrowRect(containingRect); parentArrowElement.m_rect = parentArrowRect; parentArrowElement.m_toolMessage = DEPRICATE_MESSAGE; parentArrowElement.m_actionName = DEPRICATE_OPERATION_NAME; res.append(parentArrowElement); } if(index.data(ROLE_ITEM_TAG_LEVEL).toInt()>= ((int)CatItem::POSSIBLE_TAG) ){ ListItemElement childArrowElement; QRect childArrowRect = IconDelegate::getChildArrowRect(containingRect); childArrowElement.m_rect = childArrowRect; childArrowElement.m_toolMessage = DEPRICATE_MESSAGE; childArrowElement.m_actionName = DEPRICATE_OPERATION_NAME; res.append(childArrowElement); } else if(index.data(ROLE_HAS_CHILDREN).toBool()){ ListItemElement moreItemsElement; QRect moreItemsRect = IconDelegate::getDepricateItemRect(containingRect); moreItemsElement.m_rect = moreItemsRect; moreItemsElement.m_toolMessage = DEPRICATE_MESSAGE; moreItemsElement.m_actionName = DEPRICATE_OPERATION_NAME; res.append(moreItemsElement); } return res; }
void MyListWidget::sendMenuEvent(QContextMenuEvent* event){ QPoint pos = event->pos(); QPersistentModelIndex index = indexAt(pos); QString path = index.data(ROLE_ITEM_PATH).toString(); // QPoint globalPos = QWidget::mapToGlobal(pos); // emit showOptionsMenu(path, globalPos); // QPoint mainWidgetPos = mapTo((QWidget*)gMarginWidget,pos); QPoint mainWidgetPos = this->mapToGlobal(pos); emit showOptionsMenu(path, mainWidgetPos); }
void TilesetEditor::setTilesetIndex(QPersistentModelIndex tilesetIndex) { m_tilesetIndex = tilesetIndex; m_scene->setProjectIndex(m_projectWidget->projectOfIndex(tilesetIndex)); QByteArray data = m_tilesetIndex.data(ProjectWidget::TilesetRole).toByteArray(); QDataStream stream(&data, QIODevice::ReadOnly); QVector<int> list; stream >> list; wm_numberOfTiles->blockSignals(true); wm_tilesHeight->blockSignals(true); wm_tilesWidth->blockSignals(true); wm_numberOfTiles->setValue(list.size()); wm_tilesHeight->setValue(tilesetIndex.data(ProjectWidget::TilesHeightRole).toInt()); wm_tilesWidth->setValue(tilesetIndex.data(ProjectWidget::TilesWidthRole).toInt()); name->setText(tilesetIndex.data(Qt::DisplayRole).toString()); wm_numberOfTiles->blockSignals(false); wm_tilesHeight->blockSignals(false); wm_tilesWidth->blockSignals(false); oldTilesWidth = wm_tilesWidth->value(); oldTilesHeight = wm_tilesHeight->value(); refresh(); }
void tst_QDirModel::task244669_remove() { QFile f1(SRCDIR "dirtest/f1.txt"); QVERIFY(f1.open(QIODevice::WriteOnly)); f1.close(); QFile f2(SRCDIR "dirtest/f2.txt"); QVERIFY(f2.open(QIODevice::WriteOnly)); f2.close(); QDirModel model; model.setReadOnly(false); QPersistentModelIndex parent = model.index(SRCDIR "dirtest"); QPersistentModelIndex index2 = model.index(SRCDIR "dirtest/f2.txt"); QPersistentModelIndex index1 = model.index(SRCDIR "dirtest/f1.txt"); QVERIFY(parent.isValid()); QVERIFY(index1.isValid()); QVERIFY(index2.isValid()); QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data()); QCOMPARE(index1.data() , model.index(SRCDIR "dirtest/f1.txt").data()); QCOMPARE(index2.data() , model.index(SRCDIR "dirtest/f2.txt").data()); QVERIFY(model.remove(index1)); QVERIFY(parent.isValid()); QVERIFY(!index1.isValid()); QVERIFY(index2.isValid()); QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data()); QCOMPARE(index2.data() , model.index(SRCDIR "dirtest/f2.txt").data()); QVERIFY(model.remove(index2)); QVERIFY(parent.isValid()); QVERIFY(!index2.isValid()); QVERIFY(!index1.isValid()); QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data()); }
void MyListWidget::mouseMoveEvent(QMouseEvent * event ){ event->ignore(); QPoint pos = event->pos(); QPersistentModelIndex index = indexAt(pos); QPoint globPos = QWidget::mapToGlobal(pos); QTime now = QTime::currentTime(); m_arrowHover = false; if(m_lastIndex == index){ // if(m_hoveStart.msecsTo(now )< LIST_HOVER_INTERVAL){ // return; // } m_hoveredIndex = index; m_hovered=true; update(index); QRect containingRect = visualRect(index); QRect pinRect = IconDelegate::getPinItemRect(containingRect); if(pinRect.contains(pos)){ QToolTip::showText(globPos, PIN_MESSAGE, this); return; } QRect depRect = IconDelegate::getDepricateItemRect(containingRect); if(depRect.contains(pos)){ QToolTip::showText(globPos, DEPRICATE_MESSAGE, this); return; } QRect childRect = IconDelegate::getChildArrowRect(containingRect); if(childRect.contains(pos)){ QToolTip::showText(globPos, GOTO_CHILDREN_MESSAGE, this); m_arrowHover = true; return; } QToolTip::showText(globPos, index.data(ROLE_DESCRIPTION).toString(), this); } else { if(m_hoveredIndex !=QPersistentModelIndex()){ QPersistentModelIndex oldIndex = m_hoveredIndex; m_hoveredIndex =QPersistentModelIndex(); update(oldIndex); } m_hoveStart = now; m_lastIndex = index; } gMainWidget->m_itemChoiceList->fakeMouseMoveEvent(event); }
void EditorViewMViface::rowsInserted(const QModelIndex &parent, int start, int end) { mScene->setEnabled(true); QList<QPair<NodeElement *, QPersistentModelIndex>> nodes; QList<QPair<EdgeElement *, QPersistentModelIndex>> edges; for (int row = start; row <= end; ++row) { QPersistentModelIndex current = model()->index(row, 0, parent); if (!isDescendentOf(current, rootIndex())) { continue; } Id currentId = current.data(roles::idRole).value<Id>(); if (currentId == Id::rootId()) { continue; } Id parentUuid; if (parent != rootIndex()) { parentUuid = parent.data(roles::idRole).value<Id>(); } if (!parent.isValid()) { setRootIndex(current); continue; } const ElementType &elementType = mLogicalAssistApi->editorManagerInterface().elementType(currentId); Element *elem = elementType.type() == ElementType::Type::node ? static_cast<Element *>(new NodeElement(elementType.toNode(), currentId, mScene->models())) : static_cast<Element *>(new EdgeElement(elementType.toEdge(), currentId, mScene->models())); elem->setController(&mScene->controller()); if (elementType.type() == ElementType::Type::node) { nodes.append(qMakePair(dynamic_cast<NodeElement *>(elem), current)); } else { edges.append(qMakePair(dynamic_cast<EdgeElement *>(elem), current)); } } handleNodeElementsForRowsInserted(nodes, parent); handleEdgeElementsForRowsInserted(edges, parent); QAbstractItemView::rowsInserted(parent, start, end); }
//-------------------------------------------------------------------------------------------------- // FUNCTION: setModelIndex //-------------------------------------------------------------------------------------------------- void QExecutableSettingsDialog::setModelIndex(const QPersistentModelIndex& index) { Q_D(QExecutableSettingsDialog); d->index = index; d->gtestFilterEdit->setText(index.data(QExecutableModel::FilterRole).toString()); d->gtestRepeatLineEdit->setText(index.data(QExecutableModel::RepeatTestsRole).toString()); d->gtestAlsoRunDisabledTestsCheckbox->setCheckState((Qt::CheckState)index.data(QExecutableModel::RunDisabledTestsRole).toInt()); d->gtestShuffleCheckbox->setCheckState((Qt::CheckState)index.data(QExecutableModel::ShuffleRole).toInt()); d->gtestRandomSeedLineEdit->setText(index.data(QExecutableModel::RandomSeedRole).toString()); d->gtestOtherArgsLineEdit->setText(index.data(QExecutableModel::ArgsRole).toString()); }
/*! Set the model index of this object \param index the index */ void ObjectView::SetModelIndex(QPersistentModelIndex index) { ObjectInfo info = index.data(UserRoles::objInfo).value<ObjectInfo>(); if(info.objType == ObjType::dummy) { SetErrorMessage("object not loaded"); } if(info.nodeType != NodeType::bridge) { actRemoveBridge = new QAction(QIcon(":/img16x16/delete.png"),tr("Remove"),this); actRemoveBridge->setShortcutContext(Qt::WidgetShortcut); connect(actRemoveBridge,SIGNAL(triggered()), this,SLOT(RemoveWithBridge())); addAction(actRemoveBridge); actRemove = new QAction(QIcon(":/img16x16/delete.png"),tr("Remove with cables"),this); actRemove->setShortcutContext(Qt::WidgetShortcut); connect(actRemove,SIGNAL(triggered()), this,SLOT(close())); addAction(actRemove); actShowEditor = new QAction(tr("Show Editor"),this); actShowEditor->setShortcutContext(Qt::WidgetWithChildrenShortcut); actShowEditor->setEnabled(false); actShowEditor->setCheckable(true); connect(actShowEditor,SIGNAL(toggled(bool)), this,SLOT(SwitchEditor(bool))); addAction(actShowEditor); actLearnSwitch = new QAction(tr("Learn Mode"),this); actLearnSwitch->setShortcutContext(Qt::WidgetWithChildrenShortcut); actLearnSwitch->setEnabled(false); actLearnSwitch->setCheckable(true); connect(actLearnSwitch,SIGNAL(toggled(bool)), this,SLOT(SwitchLearnMode(bool))); addAction(actLearnSwitch); actToggleBypass = new QAction("Bypass",this); actToggleBypass->setShortcutContext(Qt::WidgetShortcut); actToggleBypass->setEnabled(false); actToggleBypass->setCheckable(true); connect(actToggleBypass,SIGNAL(toggled(bool)), this,SLOT(ToggleBypass(bool))); addAction(actToggleBypass); }
void TilesetEditor::refresh() { if (m_tilesetIndex != QPersistentModelIndex() && m_tilesetIndex.isValid()) { for (int i=0; i<tiles.size(); i++) delete tiles.at(i); tiles.clear(); tilesId.clear(); m_scene->clear(); drawGrid(); //Extraire la liste des tiles du tileset : QByteArray data = m_tilesetIndex.data(ProjectWidget::TilesetRole).toByteArray(); QDataStream stream(&data, QIODevice::ReadOnly); QVector<int> tmpTilesId; stream >> tmpTilesId; QByteArray pData = m_tilesetIndex.data(ProjectWidget::TilesetPropertiesRole).toByteArray(); QDataStream pStream(&pData, QIODevice::ReadOnly); QVector<unsigned char> tmpProperties; pStream >> tmpProperties; QPersistentModelIndex projectIndex = m_projectWidget->projectOfIndex(m_tilesetIndex); for (int i=0; i<tmpTilesId.size(); i++) { addNewTile(tmpTilesId.at(i)); if ((tmpProperties.at(i) & 0x01) == 0x01) tiles.at(i)->setBlocking(true); else tiles.at(i)->setBlocking(false); //Si le tile est lié à un tile du projet, on change l'image du tile pour celle du tile correspondant. if (tilesId.at(i) >= 0) { QPersistentModelIndex tileIndex = m_projectWidget->itemFromTileId(tilesId.at(i), projectIndex); if (tileIndex != QPersistentModelIndex()) { QImage tmpImage(tileIndex.data(ProjectWidget::TileRole).value<QImage>()); if (tmpImage.size() == QSize(wm_tilesWidth->value(), wm_tilesHeight->value())) tiles.at(i)->setPixmap(QPixmap::fromImage(tmpImage)); else { tilesId[i] = -1; } } } } //wm_view->setFixedHeight(((tiles.size()-1)/6+1)*oldTilesHeight*2+10); wm_view->setFixedWidth(oldTilesWidth*6*2+26); m_scene->setSceneRect(0, 0, oldTilesWidth*6, ((tiles.size()-1)/6+1)*oldTilesHeight); } }
void updateItemWidgets(const QList<QWidget*> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { FileItem *fileItem = (FileItem*)index.data().value<void*>(); QWidget* page= widgets[0]; QHBoxLayout* layout = qobject_cast<QHBoxLayout*>(page->layout()); QCheckBox *checkBox = qobject_cast<QCheckBox*>(layout->itemAt(0)->widget()); QLabel *thumbnail = qobject_cast<QLabel*>(layout->itemAt(1)->widget()); QLabel *filename = qobject_cast<QLabel*>(layout->itemAt(2)->widget()); QLabel *modified = qobject_cast<QLabel*>(layout->itemAt(3)->widget()); checkBox->setChecked(fileItem->checked); thumbnail->setPixmap(QPixmap::fromImage(fileItem->thumbnail)); filename->setText(fileItem->name); modified->setText(fileItem->date); // move the page _up_ otherwise it will draw relative to the actual postion page->setGeometry(option.rect.translated(0, -option.rect.y())); }
void EditorViewMViface::handleNodeElementsForRowsInserted( const QList<QPair<NodeElement *, QPersistentModelIndex> > &nodes , const QModelIndex &parent ) { for (const QPair<NodeElement *, QPersistentModelIndex> &p : nodes) { NodeElement *elem = p.first; QPersistentModelIndex current = p.second; Id currentId = current.data(roles::idRole).value<Id>(); bool needToProcessChildren = true; if (elem) { QPointF ePos = model()->data(current, roles::positionRole).toPointF(); // setting position before parent definition 'itemChange' to work correctly elem->setPos(ePos); elem->setGeometry(mGraphicalAssistApi->configuration(elem->id()).boundingRect().translated(ePos.toPoint())); handleAddingSequenceForRowsInserted(parent, elem, current); handleElemDataForRowsInserted(elem, current); if (currentId.element() == "Class" && mGraphicalAssistApi->children(currentId).empty()) { needToProcessChildren = false; for (int i = 0; i < 2; i++) { QString curChildElementType = (i == 0) ? "MethodsContainer" : "FieldsContainer"; Id newUuid = Id("Kernel_metamodel", "Kernel", curChildElementType, QUuid::createUuid().toString()); mGraphicalAssistApi->createElement(currentId, newUuid , false, "(anonymous something)", QPointF(0, 0)); } } } if (needToProcessChildren && model()->hasChildren(current)) { rowsInserted(current, 0, model()->rowCount(current) - 1); } if (elem) { elem->alignToGrid(); } } }
/** * @brief This function retrieves the thumbnail for an index. * @param index The marker's index. * @param size The size of the thumbnail. * @return If the thumbnail has been loaded in the ThumbnailLoadThread instance, it is returned. If not, a QPixmap is returned and ThumbnailLoadThread's signal named signalThumbnailLoaded is emitted when the thumbnail becomes available. */ QPixmap MapViewModelHelper::pixmapFromRepresentativeIndex(const QPersistentModelIndex& index, const QSize& size) { if (index == QPersistentModelIndex()) { return QPixmap(); } switch (d->application) { case MapWidgetView::ApplicationDigikam: { const ImageInfo info = d->model->imageInfo(index); if (!info.isNull()) { QPixmap thumbnail; if (d->thumbnailLoadThread->find(info.thumbnailIdentifier(), thumbnail, qMax(size.width()+2, size.height()+2))) { return thumbnail.copy(1, 1, thumbnail.size().width()-2, thumbnail.size().height()-2); } else { return QPixmap(); } } break; } case MapWidgetView::ApplicationImportUI: { QPixmap thumbnail = index.data(ImportImageModel::ThumbnailRole).value<QPixmap>(); return thumbnail.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation); } } return QPixmap(); }
void KeyboardPage::onListVariantCurrentItemChanged( QListWidgetItem* current, QListWidgetItem* previous ) { Q_UNUSED( previous ); QPersistentModelIndex layoutIndex = ui->listLayout->currentIndex(); LayoutItem* variantItem = dynamic_cast< LayoutItem* >( current ); if ( !layoutIndex.isValid() || !variantItem ) return; QString layout = layoutIndex.data( KeyboardLayoutModel::KeyboardLayoutKeyRole ).toString(); QString variant = variantItem->data; m_keyboardPreview->setLayout( layout ); m_keyboardPreview->setVariant( variant ); //emit checkReady(); // Set Xorg keyboard layout if ( m_setxkbmapTimer.isActive() ) { m_setxkbmapTimer.stop(); m_setxkbmapTimer.disconnect( this ); } connect( &m_setxkbmapTimer, &QTimer::timeout, this, [=] { QProcess::execute( "setxkbmap", xkbmap_args( QStringList(), layout, variant ) ); cDebug() << "xkbmap selection changed to: " << layout << '-' << variant; m_setxkbmapTimer.disconnect( this ); } ); m_setxkbmapTimer.start( QApplication::keyboardInputInterval() ); m_selectedLayout = layout; m_selectedVariant = variant; }
void KeyboardPage::updateVariants( const QPersistentModelIndex& currentItem, QString currentVariant ) { // Block signals ui->listVariant->blockSignals( true ); QMap< QString, QString > variants = currentItem.data( KeyboardLayoutModel::KeyboardVariantsRole ) .value< QMap< QString, QString > >(); QMapIterator< QString, QString > li( variants ); LayoutItem* defaultItem = nullptr; ui->listVariant->clear(); while ( li.hasNext() ) { li.next(); LayoutItem* item = new LayoutItem(); item->setText( li.key() ); item->data = li.value(); ui->listVariant->addItem( item ); // currentVariant defaults to QString(). It is only non-empty during the // initial setup. if ( li.value() == currentVariant ) defaultItem = item; } // Unblock signals ui->listVariant->blockSignals( false ); // Set to default value if ( defaultItem ) ui->listVariant->setCurrentItem( defaultItem ); }
void AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx ) { Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { const QPixmap& pixmap = account->icon(); QSize pixmapSize( 32, 32 ); m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); m_imageLabel->setFixedSize( pixmapSize ); QFontMetrics fm = m_idLabel->fontMetrics(); m_idLabel->setText( account->accountFriendlyName() ); m_idLabel->setToolTip( "<b>" + account->accountServiceName() + "</b><br>" + account->accountFriendlyName() ); //we already know it's a factory because of the FactoryProxy Tomahawk::Accounts::AccountFactory* fac = qobject_cast< Tomahawk::Accounts::AccountFactory* >( idx.data( Tomahawk::Accounts::AccountModel::AccountData ) .value< QObject* >() ); if ( fac->factoryId() == "twitteraccount" ) { m_inviteContainer->setVisible( false ); m_inviteButton->setVisible( false ); } switch ( account->connectionState() ) { case Tomahawk::Accounts::Account::Connected: if ( account->enabled() ) m_statusToggle->setChecked( true ); else qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connected but Disabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( true ); break; case Tomahawk::Accounts::Account::Connecting: if ( !account->enabled() ) qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connecting but Disabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; case Tomahawk::Accounts::Account::Disconnected: if ( !account->enabled() ) m_statusToggle->setChecked( false ); else qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnected but Enabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; case Tomahawk::Accounts::Account::Disconnecting: if ( account->enabled() ) qDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnecting but Enabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( false ); } } }
void AccountWidget::update( const QPersistentModelIndex& idx, int accountIdx ) { Tomahawk::Accounts::Account* account = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().at( accountIdx ); if ( account ) { const QPixmap& pixmap = account->icon(); QSize pixmapSize( scaled( 32, 32 ) ); m_imageLabel->setPixmap( pixmap.scaled( pixmapSize, Qt::KeepAspectRatio, Qt::SmoothTransformation ) ); m_imageLabel->setFixedSize( pixmapSize ); QFontMetrics fm = m_idLabel->fontMetrics(); m_idLabel->setText( account->accountFriendlyName() ); m_idLabel->setToolTip( "<b>" + account->accountServiceName() + "</b><br>" + account->accountFriendlyName() ); switch ( account->connectionState() ) { case Tomahawk::Accounts::Account::Connected: { if ( account->enabled() ) m_statusToggle->setChecked( true ); else tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connected but Disabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( true ); break; } case Tomahawk::Accounts::Account::Connecting: { if ( !account->enabled() ) tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Connecting but Disabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; } case Tomahawk::Accounts::Account::Disconnected: { if ( !account->enabled() ) m_statusToggle->setChecked( false ); else tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnected but Enabled!"; m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); setInviteWidgetsEnabled( false ); break; } case Tomahawk::Accounts::Account::Disconnecting: { if ( account->enabled() ) tDebug() << "AccountWidget warning:" << account->accountFriendlyName() << "is Disconnecting but Enabled!"; m_spinner->fadeIn(); m_statusToggle->setBackChecked( true ); setInviteWidgetsEnabled( false ); } } if ( !account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Disconnected ) { m_spinner->fadeOut(); m_statusToggle->setBackChecked( false ); m_statusToggle->setChecked( false ); setInviteWidgetsEnabled( false ); } else if ( account->enabled() && account->connectionState() == Tomahawk::Accounts::Account::Connected ) { m_spinner->fadeOut(); m_statusToggle->setBackChecked( true ); m_statusToggle->setChecked( true ); setInviteWidgetsEnabled( true ); } } }
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { // draws: // AccountName // Checkbox | Icon | | ConnectionIcon | ConnectionState // errorMessage if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 6); // Get the widgets QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0)); ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1)); QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2)); QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3)); EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4)); QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5)); Q_ASSERT(checkbox); Q_ASSERT(changeIconButton); Q_ASSERT(statusTextLabel); Q_ASSERT(statusIconLabel); Q_ASSERT(displayNameButton); Q_ASSERT(connectionErrorLabel); bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus()); bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool()); KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>()); KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>()); QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString()); QString displayName(index.data(Qt::DisplayRole).toString()); QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString()); Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>()); if (!account->isEnabled()) { connectionError = i18n("Click checkbox to enable"); } QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding // checkbox if (isEnabled) { checkbox->setChecked(true);; checkbox->setToolTip(i18n("Disable account")); } else { checkbox->setChecked(false); checkbox->setToolTip(i18n("Enable account")); } int checkboxLeftMargin = contentRect.left(); int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2; checkbox->move(checkboxLeftMargin, checkboxTopMargin); // changeIconButton changeIconButton->setIcon(accountIcon); changeIconButton->setAccount(account); // At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate // through the QStyleOptionViewItem, therefore we leave default size unless // the user has a more recent version. if (option.decorationSize.width() > -1) { changeIconButton->setButtonIconSize(option.decorationSize.width()); } int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width(); int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2; changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin); // statusTextLabel QFont statusTextFont = option.font; QPalette statusTextLabelPalette = option.palette; if (isEnabled) { statusTextLabel->setEnabled(true); statusTextFont.setItalic(false); } else { statusTextLabel->setDisabled(true); statusTextFont.setItalic(true); } if (isSelected) { statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } statusTextLabel->setPalette(statusTextLabelPalette); statusTextLabel->setFont(statusTextFont); statusTextLabel->setText(statusText); statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(), statusTextLabel->height()); int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width(); int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2; statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin); // statusIconLabel statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall)); statusIconLabel->setFixedSize(statusIconLabel->minimumSizeHint()); int statusIconLabelLeftMargin = contentRect.right() - statusTextLabel->width() - statusIconLabel->width() - 6; int statusIconLabelTopMargin = (outerRect.height() - statusIconLabel->height()) / 2; statusIconLabel->move(statusIconLabelLeftMargin, statusIconLabelTopMargin); QRect innerRect = contentRect.adjusted(changeIconButton->geometry().right() - contentRect.left(), 0, -statusTextLabel->width() - statusIconLabel->width() - 6, 0); // rect containing account name and error message // displayNameButton QFont displayNameButtonFont = option.font; QPalette displayNameButtonPalette = option.palette; if (isEnabled) { displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::Text)); displayNameButtonFont.setBold(true); } else { displayNameButtonFont.setItalic(true); // NOTE: Flat QPushButton use WindowText instead of ButtonText for button text color displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::HighlightedText)); } displayNameButton->setFont(displayNameButtonFont); displayNameButton->setPalette(displayNameButtonPalette); QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); displayNameButton->setText(displayNameButtonText); displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2), displayNameButton->minimumSizeHint().height()); displayNameButton->setAccount(account); int displayNameButtonLeftMargin = innerRect.left(); int displayNameButtonTopMargin = innerRect.top(); displayNameButton->move(displayNameButtonLeftMargin, displayNameButtonTopMargin); // connectionErrorLabel QFont connectionErrorLabelFont = option.font; QPalette connectionErrorLabelPalette = option.palette; if (isEnabled) { connectionErrorLabelPalette.setColor(QPalette::WindowText, connectionErrorLabelPalette.color(QPalette::Active, QPalette::Text)); } else { connectionErrorLabelFont.setItalic(true); connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } connectionErrorLabel->setFont(connectionErrorLabelFont); connectionErrorLabel->setPalette(connectionErrorLabelPalette); QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); connectionErrorLabel->setText(connectionErrorLabelText); connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(), displayNameButton->height()); int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding; int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height(); connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin); }
void MyListWidget::mousePressEvent( QMouseEvent * event ) { QPoint pos = event->pos(); QPersistentModelIndex index = indexAt(pos); QString path = index.data(ROLE_ITEM_PATH).toString(); if(event->button() != Qt::LeftButton){ QPoint globalPos = QWidget::mapToGlobal(pos); emit showOptionsMenu(path,globalPos); //emit pressed(index); return; } //Later... //if(event->button() == Qt::RightButton){ } QRect containingRect = this->geometry(); containingRect.setHeight(UI_DEFAULT_ITEM_HEIGHT); containingRect.moveTop(0); QRect pinRect = IconDelegate::getPinItemRect(containingRect); QListWidgetItem* listWidgetItem = item(index.row()); QPoint localPos = pos; localPos.setY(pos.y() % UI_DEFAULT_ITEM_HEIGHT); if(pinRect.contains(localPos)){ CatItem pinItem(addPrefix(OPERATION_PREFIX,PIN_OPERATION_NAME)); if(!(listWidgetItem->data((ROLE_ITEM_PINNED)).toBool())){ listWidgetItem->setData((ROLE_ITEM_PINNED),true); } else {listWidgetItem->setData((ROLE_ITEM_PINNED),false);} //emit listItemAction(path, pinItem); //frickin signal not going through gMainWidget->operateOnItem(path,pinItem); return; } QRect childRect = IconDelegate::getChildArrowRect(containingRect); if(childRect.contains(pos)){ listWidgetItem->setSelected(true); setCurrentRow(index.row()); CatItem clickItem(addPrefix(OPERATION_PREFIX,GOTO_CHILD_OPERATION)); gMainWidget->operateOnItem(path,clickItem); return; } QRect depRect = IconDelegate::getDepricateItemRect(containingRect); if(depRect.contains(localPos)){ CatItem depricateItem(addPrefix(OPERATION_PREFIX,DEPRICATE_OPERATION_NAME)); //emit listItemAction(path, depricateItem); //fickin signals not going through... gMainWidget->operateOnItem(path,depricateItem); return; } if(listWidgetItem){ listWidgetItem->setSelected(true); setCurrentRow(index.row()); CatItem clickItem(addPrefix(OPERATION_PREFIX,SELECTION_OPERATION_NAME)); gMainWidget->operateOnItem(path,clickItem); } }
void EditorViewMViface::rowsInserted(QModelIndex const &parent, int start, int end) { for (int row = start; row <= end; ++row) { mScene->setEnabled(true); QPersistentModelIndex current = model()->index(row, 0, parent); if (!isDescendentOf(current, rootIndex())) continue; Id currentId = current.data(roles::idRole).value<Id>(); if (currentId == Id::rootId()) continue; Id parentUuid; if (parent != rootIndex()) parentUuid = parent.data(roles::idRole).value<Id>(); if (!parent.isValid()) { setRootIndex(current); continue; } Element* elem = mScene->mainWindow()->manager()->graphicalObject(currentId); if (elem) { elem->setAssistApi(mGraphicalAssistApi, mLogicalAssistApi); } QPointF ePos = model()->data(current, roles::positionRole).toPointF(); bool needToProcessChildren = true; if (elem) { elem->setPos(ePos); //задаем позицию до определения родителя для того, чтобы правильно отработал itemChange elem->setId(currentId); /*commented out because of real sizes of elements are incorrectly changing here into initial sizes*/ // NodeElement* nodeElement = dynamic_cast<NodeElement*>(elem); // if (nodeElement) // nodeElement->storeGeometry(); if (item(parent) != NULL) { elem->setParentItem(item(parent)); QModelIndex next = current.sibling(current.row() + 1, 0); if(next.isValid() && item(next) != NULL) { elem->stackBefore(item(next)); } } else { mScene->addItem(elem); } setItem(current, elem); elem->updateData(); elem->connectToPort(); elem->checkConnectionsToPort(); elem->initPossibleEdges(); elem->initTitles(); // elem->initEmbeddedControls(); //todo: нужно привести в порядок всякие init~() bool isEdgeFromEmbeddedLinker = false; QList<QGraphicsItem*> selectedItems = mScene->selectedItems(); if (selectedItems.size() == 1) { NodeElement* master = dynamic_cast<NodeElement*>(selectedItems.at(0)); if (master && master->connectionInProgress()) { isEdgeFromEmbeddedLinker = true; } } if (!isEdgeFromEmbeddedLinker) { mScene->clearSelection(); elem->setSelected(true); } NodeElement* nodeElem = dynamic_cast<NodeElement*>(elem); if (nodeElem && currentId.element() == "Class" && mGraphicalAssistApi->children(currentId).empty()) { needToProcessChildren = false; for (int i = 0; i < 2; i++) { QString curChildElementType; if (i == 0) curChildElementType = "MethodsContainer"; else curChildElementType = "FieldsContainer"; Id newUuid = Id("Kernel_metamodel", "Kernel", curChildElementType, QUuid::createUuid().toString()); mGraphicalAssistApi->createElement(currentId, newUuid, false, "(anonymous something)", QPointF(0, 0)); } } } if (needToProcessChildren && model()->hasChildren(current)) rowsInserted(current, 0, model()->rowCount(current) - 1); NodeElement * nodeElement = dynamic_cast<NodeElement*>(elem); if (nodeElement) nodeElement->alignToGrid(); } QAbstractItemView::rowsInserted(parent, start, end); }