Exemple #1
0
void
AnimatorScene::mouseDoubleClickEvent (QGraphicsSceneMouseEvent *event)
{
  QList <QGraphicsItem *> list = items (event->scenePos ());
  foreach (QGraphicsItem * i, list)
    {
      if (i->type () == ANIMNODE_TYPE)
        {

          AnimNode * animNode = qgraphicsitem_cast <AnimNode *> (i);
          if (animNode)
            {
              AnimPropertyBroswer::getInstance ()->setCurrentNodeId (animNode->getNodeId ());
              AnimatorMode::getInstance ()->openPropertyBroswer ();
              break;
            }
        }
    }
}
Exemple #2
0
QRect Scene::realItemsBoundingRect() const
{
	int maxX = std::numeric_limits<int>::min();
	int maxY = std::numeric_limits<int>::min();
	int minY = std::numeric_limits<int>::max();
	int minX = std::numeric_limits<int>::max();
	QList<QGraphicsItem *> list = items();
	foreach (QGraphicsItem *graphicsItem, list) {
		Item* item = dynamic_cast<Item*>(graphicsItem);
		if (item != NULL) {
			if (dynamic_cast<Text*>(item))
				continue;
			QRectF itemRect = item->realBoundingRect();
			maxX = qMax(static_cast<int>(itemRect.right()), maxX);
			maxY = qMax(static_cast<int>(itemRect.bottom()), maxY);
			minX = qMin(static_cast<int>(itemRect.left()), minX);
			minY = qMin(static_cast<int>(itemRect.top()), minY);
		}
	}
Exemple #3
0
int main() {
    std::vector<int> keys ( 1000 );
    std::vector<int> items( keys.size() );
    for( unsigned i = 0; i < keys.size(); ++i ) {
        keys [ i ] = rand() % ( keys.size() / 2 );
        items[ i ] = keys [ i ];
    }

    HashMap<int,int,16> hash_map;

    for( unsigned i = 0; i < keys.size(); ++i )
        hash_map.add( keys[ i ], &items[ i ] );

    for( unsigned i = 0; i < keys.size(); ++i )
        if ( int *it = hash_map.find( keys[ i ] )  )
            ASSERT( keys[ i ] == *it, "..." );
        else
            ERROR( "not found" );
}
void QtFallbackWebPopup::showS60BrowserDialog()
{
    static MBrCtlDialogsProvider* dialogs = CBrowserDialogsProvider::NewL(0);
    if (!dialogs)
        return;

    int size = itemCount();
    CArrayFix<TBrCtlSelectOptionData>* options = new CArrayFixFlat<TBrCtlSelectOptionData>(qMax(1, size));
    RPointerArray<HBufC> items(qMax(1, size));
    CleanupStack::PushL(TCleanupItem(&ResetAndDestroy, &items));

    for (int i = 0; i < size; i++) {
        if (itemType(i) == Separator) {
            TBrCtlSelectOptionData data(_L("----------"), false, false, false);
            options->AppendL(data);
        } else {
            HBufC16* itemStr = HBufC16::NewL(itemText(i).length());
            itemStr->Des().Copy((const TUint16*)itemText(i).utf16(), itemText(i).length());
            CleanupStack::PushL(itemStr);
            TBrCtlSelectOptionData data(*itemStr, i == currentIndex(), false, itemIsEnabled(i));
            options->AppendL(data);
            items.AppendL(itemStr);
            CleanupStack::Pop();
        }
    }

    dialogs->DialogSelectOptionL(KNullDesC(), (TBrCtlSelectOptionType)(ESelectTypeSingle | ESelectTypeWithFindPane), *options);

    CleanupStack::PopAndDestroy(&items);

    int newIndex;
    for (newIndex = 0; newIndex < options->Count() && !options->At(newIndex).IsSelected(); newIndex++) {}
    if (newIndex == options->Count())
        newIndex = currentIndex();
    
    m_popupVisible = false;
    popupDidHide();

    if (currentIndex() != newIndex && newIndex >= 0)
        valueChanged(newIndex);

    delete options;
}
Exemple #5
0
bool panel_list(PANEL *p, char* (*items)(int), int def, bool (*cb)(PANEL*,int)) {
    int i, len, k, x, y, top, bottom;
    char* txt;
    bool emode;
    panel_write(p,"\n");
    panel_getcursorpos(p,&x,&top);
    p->attr[PANEL_MGR_STORE] = top;
    p->attr[PANEL_MGR_STORE+2] = (int)cb;
    p->attr[PANEL_MGR_STORE+3] = (int)items;
    for(i=0; (txt=items(i))!=0; i++) {
        panel_write(p,txt);
        panel_write(p,"\n");
    }
    p->attr[PANEL_MGR_STORE+1] = i;
    panel_setcursorpos(p,x,top+def);
    panel_writeattr(p,menu_highlight,20);
    panel_display(p);
    return true;
}
void SimpleGraphicsView::mouseMoveEvent(QMouseEvent* e) {
    QList<QGraphicsItem*> graphicsItems =items(e->pos());

    if (e->button()==Qt::LeftButton) {
        //graphicsItems.size()==1 because of background pixmap item
        for (auto& graphicsItem : graphicsItems) {
            QGraphicsRectItem* rectItem = qgraphicsitem_cast<QGraphicsRectItem*>(graphicsItem);

            if (rectItem == currentRectItem_) {
                //LogWarn("Rect Item Move");
                setCurrentLabelPositionToTextField();
            }
        }

        //e->accept();
    }

    QGraphicsView::mouseMoveEvent(e);
}
/*
 * This is reimplemented because of a bug in Qt 4.3 QGraphicScene in the
 * way it handles context menu events.  The docs say that if an item ignores
 * this event that it'll be passed down to the next item underneath.  However,
 * this does not happen in the default implementation.
 */
void Scene::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
  QList<QGraphicsItem*> list = items(event->scenePos());
  if (list.isEmpty()) {
    if (View *view = qobject_cast<View*>(parent())) {
      view->contextMenuEvent();
    }
  } else {
    foreach (QGraphicsItem *item, list) {
      ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
      if (!viewItem)
        continue;

      if (viewItem->acceptsContextMenuEvents()) {
          event->setPos(viewItem->mapFromScene(event->scenePos()));
          if (viewItem->doSceneEvent(event))
            return;
      }
    }
  }
void UBDocumentThumbnailWidget::mouseMoveEvent(QMouseEvent *event)
{
    if (!dragEnabled())
    {
        event->ignore();
        return;
    }

    if (!(event->buttons() & Qt::LeftButton))
        return;

    if ((event->pos() - mMousePressPos).manhattanLength()
             < QApplication::startDragDistance())
             return;

    QList<QGraphicsItem*> graphicsItems = items(mMousePressPos);

    UBSceneThumbnailPixmap* sceneItem = 0;

    while (!graphicsItems.isEmpty() && !sceneItem)
    {
        sceneItem = dynamic_cast<UBSceneThumbnailPixmap*>(graphicsItems.takeFirst());
    }

    if (sceneItem)
    {
        QDrag *drag = new QDrag(this);
        QList<UBMimeDataItem> mimeDataItems;
        foreach (QGraphicsItem *item, selectedItems())
            mimeDataItems.append(UBMimeDataItem(sceneItem->proxy(), mGraphicItems.indexOf(item)));
        UBMimeData *mime = new UBMimeData(mimeDataItems);
        drag->setMimeData(mime);

        drag->setPixmap(sceneItem->pixmap().scaledToWidth(100));
        drag->setHotSpot(QPoint(drag->pixmap().width()/2,
                                     drag->pixmap().height() / 2));

        drag->exec(Qt::MoveAction);
    }

    UBThumbnailWidget::mouseMoveEvent(event);
}
Exemple #9
0
void OSItemList::setItemIds(const std::vector<OSItemId>& itemIds)
{
  if (qobject_cast<ScriptsListView*>(this)) {
    std::vector<OSItem*> myItems = items();
    size_t n = myItems.size();
    if ((n > 0) && (itemIds.size() == n)) {
      bool doNothing = true;
      for (size_t i = 0; i < n; ++i) {
        if (std::find(itemIds.begin(),itemIds.end(),myItems[i]->itemId()) == itemIds.end()) {
          doNothing = false;
          break;
        }
      }
      if (doNothing) {
        return;
      }
    }
  }

  QLayoutItem* child;
  while( (child = m_vLayout->takeAt(0)) != nullptr ){
    QWidget* widget = child->widget();
    if (widget){
      delete widget;
    }
    delete child;
  }
  m_vLayout->addStretch();

  m_selectedItem = nullptr;
  
  for (const OSItemId& itemId : itemIds){
    OSItem* item = OSItem::makeItem(itemId, OSItemType::ListItem);
    if (item){
      addItem(item, false);
    }
  }
  selectItem(firstItem());

  m_dirty = true;
  QTimer::singleShot(0, this, SLOT(refresh()));
}
Exemple #10
0
void PatchScene::zoom_fit()
{
#define qreal_null -0xfffe
    qreal min_x, min_y, max_x, max_y;
    min_x = min_y = max_x = max_y = qreal_null;
    QList<QGraphicsItem*> items_list = items();

    if (items_list.count() > 0)
    {
        for (int i=0; i < items_list.count(); i++)
        {
            if (items_list[i]->isVisible() and items_list[i]->type() == CanvasBoxType)
            {
                QPointF pos = items_list[i]->scenePos();
                QRectF rect = items_list[i]->boundingRect();

                if (min_x == qreal_null)
                    min_x = pos.x();
                else if (pos.x() < min_x)
                    min_x = pos.x();

                if (min_y == qreal_null)
                    min_y = pos.y();
                else if (pos.y() < min_y)
                    min_y = pos.y();

                if (max_x == qreal_null)
                    max_x = pos.x()+rect.width();
                else if (pos.x()+rect.width() > max_x)
                    max_x = pos.x()+rect.width();

                if (max_y == qreal_null)
                    max_y = pos.y()+rect.height();
                else if (pos.y()+rect.height() > max_y)
                    max_y = pos.y()+rect.height();
            }
        }

        views().at(0)->fitInView(min_x, min_y, abs(max_x-min_x), abs(max_y-min_y), Qt::KeepAspectRatio);
        fixScaleFactor();
    }
}
Exemple #11
0
void PatchScene::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
    if (fake_selection)
    {
        QList<QGraphicsItem*> items_list = items();
        if (items_list.count() > 0)
        {
            for (int i=0; i < items_list.count(); i++)
            {
                if (items_list[i]->isVisible() && items_list[i]->type() == CanvasBoxType)
                {
                    QRectF item_rect = items_list[i]->sceneBoundingRect();
                    if ( fake_rubberband->contains(QPointF(item_rect.x(), item_rect.y())) &&
                         fake_rubberband->contains(QPointF(item_rect.x()+item_rect.width(), item_rect.y()+item_rect.height())) )
                        items_list[i]->setSelected(true);
                }
            }

            fake_rubberband->hide();
            fake_rubberband->setRect(0, 0, 0, 0);
            fake_selection = false;
        }
    }
    else
    {
        QList<QGraphicsItem*> items_list = selectedItems();

        for (int i=0; i < items_list.count(); i++)
        {
            if (items_list[i]->isVisible() && items_list[i]->type() == CanvasBoxType)
            {
                CanvasBox* cbox = (CanvasBox*)items_list[i];
                cbox->checkItemPos();
                //emit(SIGNAL(sceneGroupMoved(int, PortMode, QPointF)), cbox->getGroupId(), cbox->getSplittedMode(), cbox->scenePos());
            }
        }
    }

    mouse_down_init = false;
    mouse_rubberband = false;
    QGraphicsScene::mouseReleaseEvent(event);
}
Exemple #12
0
void AcceptLanguageDialog::addLanguage(const QString &language)
{
	if (!m_model->match(m_model->index(0, 0), Qt::UserRole, language).isEmpty())
	{
		return;
	}

	QString text;

	if (language == QLatin1String("*"))
	{
		text = tr("Any other");
	}
	else if (language == QLatin1String("system"))
	{
		text = tr("System language (%1 - %2)").arg(QLocale::system().nativeLanguageName()).arg(QLocale::system().nativeCountryName());
	}
	else
	{
		const QLocale locale(language);

		if (locale == QLocale::c())
		{
			text = tr("Custom");
		}
		else if (locale.nativeCountryName().isEmpty() || locale.nativeLanguageName().isEmpty())
		{
			text = tr("Unknown");
		}
		else
		{
			text = locale.nativeLanguageName() + QLatin1String(" - ") + locale.nativeCountryName();
		}
	}

	QList<QStandardItem*> items({new QStandardItem(text), new QStandardItem((language == QLatin1String("system")) ? QLocale::system().bcp47Name() : language)});
	items[0]->setData(language, Qt::UserRole);
	items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemNeverHasChildren);
	items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled | Qt::ItemNeverHasChildren);

	m_model->appendRow(items);
}
/**
 * Return all items in the stem.
 *
 * @return An array of all items in the stem.
 */
ArrayClass *StemClass::allItems()
{
    // now we know how big the return result will be, get an array and
    // populate it, using the same traversal logic as before
    ArrayClass *array = new_array(items());
    // we index the array with a origin-one index, so we start with one this time
    size_t count = 1;

    CompoundTableElement *variable = tails.first();
    while (variable != OREF_NULL)
    {
        // only add the real values
        if (variable->getVariableValue() != OREF_NULL)
        {
            array->put(variable->getVariableValue(), count++);
        }
        variable = tails.next(variable);
    }
    return array;    // tada, finished
}
Exemple #14
0
QList<QGraphicsEllipseItem*> GameBoardScene::getTwoNearestPoints(const QPointF &pos) const
{
	QList<QGraphicsItem*> itemList = items();
	QList<QGraphicsEllipseItem*> connectList;
	for (int i = 0; i < itemList.size(); ++i) 
	{
		if (itemList.at(i)->type() == QGraphicsEllipseItemType)
		{
			//cout << "itemList.at(i)->scenePos():" << qgraphicsitem_cast<QGraphicsEllipseItem*>(itemList.at(i))->scenePos().x() << "," << qgraphicsitem_cast<QGraphicsEllipseItem*>(itemList.at(i))->scenePos().y() << endl;
			QPointF dist(pos - itemList.at(i)->scenePos());
			qreal distMod = sqrt(dist.x()*dist.x() + dist.y()*dist.y());
			//if (distMod < (spacing*0.7071))	//there will only ever be either 1 or 2 items that fulfil this [0.7071 ~ 2^(-0.5)]
			if (distMod < spacing-5)
			{
				connectList << qgraphicsitem_cast<QGraphicsEllipseItem*>(itemList.at(i));
			}
		}
	}
	return connectList;
}
Exemple #15
0
QList<ControlProxy*> Viewport::getProxiesAtPosition(QPoint pos) const
{
    QSet<Node*> used;
    QList<ControlProxy*> out;

    for (auto i : items(pos))
    {
        auto c = dynamic_cast<ControlProxy*>(i);
        if (c)
        {
            auto n = c->getNode();
            if (!used.contains(n))
            {
                used << n;
                out << c;
             }
        }
    }
    return out;
}
Exemple #16
0
void Scene::clearTextures()
{
    QList<QGraphicsItem *> textures = items();
    QList<QGraphicsPixmapItem *> returnedItems;

    for (auto i = textures.begin(); i != textures.end(); i++) {
        // Создаем копии всех текстур
        returnedItems.push_back(dynamic_cast<QGraphicsPixmapItem *>(*i));

        // Удаляем текстуры с атласа
        removeItem(*i);
    }

    // Удаляем все изображения, которые могли сохранитья в алгоритмах
    for (AlgoBase *a : algorithms)
        a->clearTexturesList();

    // Возвращаем в список изображения
    emit returnItems(returnedItems);
}
QGraphicsPixmapItem *OverlayEditorScene::childAt(const QPointF &pos) {
	QGraphicsItem *item = NULL;

	if (qgriSelected->isVisible()) {
		if (qgriSelected->rect().contains(pos)) {
			return qgpiSelected;
		}
	}

	foreach(QGraphicsItem *qgi, items(Qt::AscendingOrder)) {
		if (!qgi->isVisible() || ! qgraphicsitem_cast<QGraphicsPixmapItem *>(qgi))
			continue;

		QPointF qp = pos - qgi->pos();
		if (qgi->contains(qp)) {
			item = qgi;
		}
	}
	return static_cast<QGraphicsPixmapItem *>(item);
}
void SearchPopupMenuWin::loadRecentSearches(const AtomicString& name, Vector<String>& searchItems)
{
    if (name.isEmpty())
        return;

#if USE(CF)
    searchItems.clear();
    RetainPtr<CFArrayRef> items(AdoptCF, reinterpret_cast<CFArrayRef>(CFPreferencesCopyAppValue(autosaveKey(name).get(), kCFPreferencesCurrentApplication)));

    if (!items || CFGetTypeID(items.get()) != CFArrayGetTypeID())
        return;

    size_t size = CFArrayGetCount(items.get());
    for (size_t i = 0; i < size; ++i) {
        CFStringRef item = (CFStringRef)CFArrayGetValueAtIndex(items.get(), i);
        if (CFGetTypeID(item) == CFStringGetTypeID())
            searchItems.append(item);
    }
#endif
}
Exemple #19
0
void FileTransferManager::updateProgress()
{
	auto transferredSize = 0ul;
	auto totalSize = 0ul;

	for (auto &&fileTransfer : items())
		if (FileTransferStatus::Transfer == fileTransfer.transferStatus())
		{
			transferredSize += fileTransfer.transferredSize();
			totalSize += fileTransfer.fileSize();
		}

	if (totalSize == 0 || totalSize == transferredSize)
	{
		setTotalProgress(100);
		return;
	}

	setTotalProgress(100 * transferredSize / totalSize);
}
Exemple #20
0
const QgsComposerMap* QgsComposition::getComposerMapById( int id ) const
{
  QList<const QgsComposerMap*> resultList;

  QList<QGraphicsItem *> itemList = items();
  QList<QGraphicsItem *>::iterator itemIt = itemList.begin();
  for ( ; itemIt != itemList.end(); ++itemIt )
  {
    const QgsComposerMap* composerMap = dynamic_cast<const QgsComposerMap *>( *itemIt );
    if ( composerMap )
    {
      if ( composerMap->id() == id )
      {
        return composerMap;
      }
    }
  }

  return 0;
}
Exemple #21
0
	virtual void clientMouseDown(const twPoint& pt, twMouseButton mb){
        if(mb!=twMB_left)
            return;
        
        twSetCapture(this);
        
        m_drag=-1;
        
        twRect rt(twPoint(0,0),getClientRect().size());
        if(rt&&pt){
            m_drag=pt.y/m_rowHeight;
            assert(m_drag>=0);
            assert(m_drag<(int)items().size());
            m_hover=true;
            invalidateClientRect(rectForItem(m_drag));
        }
        
        
        
    }
Exemple #22
0
void QgsLayout::clear()
{
  deleteAndRemoveMultiFrames();

  //delete all non paper items
  const QList<QGraphicsItem *> itemList = items();
  for ( QGraphicsItem *item : itemList )
  {
    QgsLayoutItem *cItem = dynamic_cast<QgsLayoutItem *>( item );
    QgsLayoutItemPage *pItem = dynamic_cast<QgsLayoutItemPage *>( item );
    if ( cItem && !pItem )
    {
      removeLayoutItemPrivate( cItem );
    }
  }
  mItemsModel->clear();

  mPageCollection->clear();
  mUndoStack->stack()->clear();
}
Exemple #23
0
void MoveTool::keyPressEvent(QKeyEvent *event)
{
    switch (event->key()) {
        case Qt::Key_Shift:
        case Qt::Key_Alt:
        case Qt::Key_Control:
        case Qt::Key_AltGr:
            event->setAccepted(false);
            return;
    }

    double moveStep = 1.0;

    if (event->modifiers().testFlag(Qt::ShiftModifier))
        moveStep = 10.0;

    if (!event->isAutoRepeat()) {
        QList<FormEditorItem*> movableItems(movingItems(items()));
        if (movableItems.isEmpty())
            return;

        m_moveManipulator.setItems(movableItems);
//        m_selectionIndicator.hide();
        m_resizeIndicator.hide();
        m_anchorIndicator.hide();
        m_bindingIndicator.hide();
        m_moveManipulator.beginRewriterTransaction();
    }

    switch (event->key()) {
        case Qt::Key_Left: m_moveManipulator.moveBy(-moveStep, 0.0); break;
        case Qt::Key_Right: m_moveManipulator.moveBy(moveStep, 0.0); break;
        case Qt::Key_Up: m_moveManipulator.moveBy(0.0, -moveStep); break;
        case Qt::Key_Down: m_moveManipulator.moveBy(0.0, moveStep); break;
    }

    if (event->key() == Qt::Key_Escape && !m_movingItems.isEmpty()) {
       event->accept();
       view()->changeToSelectionTool();
    }
}
void ObjectDiagramView::save(QTextStream & st, QString & warning,
                             bool copy) const
{
    DiagramItemList items(canvas()->items());

    if (!copy)
        // sort is useless for a copy
        items.sort();

    st << "format " << api_format() << "\n";

    // save first the packages fragment, classes instances, notes, icons and text

    foreach (DiagramItem *di, items) {
        switch (di->typeUmlCode()) {
        case UmlPackage:
        case UmlFragment:
        case UmlClassInstance:
        case UmlNote:
        case UmlText:
        case UmlImage:
        case UmlIcon:
            if (!copy || di->copyable())
                di->save(st, FALSE, warning);

            // no break
        default:
            break;
        }
    }

    // then save links

    foreach (DiagramItem *di, items) {
        UmlCode k = di->typeUmlCode();

        if (IsaRelation(k) || (k == UmlObjectLink)) {
            if (!copy || di->copyable())
                di->save(st, FALSE, warning);
        }
    }
Exemple #25
0
//------------------------------------------------------------------------------
// Clear
//
void TimelineScene::Clear()
{
  Reset();

  // Delete Graphics Items before TimelineEvents because Items have a ref to TimelineEvent
  foreach (QGraphicsItem* item, items())
  {
    if (TimelineEventItem* e = qgraphicsitem_cast<TimelineEventItem*>(item))
      removeItem(e);
  }

  m_eventPairHash.clear();
  m_eventHash.clear();

  qDeleteAll(m_events);
  m_events.clear();

  m_eventModel.clear();

  //delete m_timelineClockForm;
}
Exemple #26
0
SyncItems Communicator::syncitems(const QString &lastsync)
{
    QVariantList params = authParams();
    if (params.size() == 0)
        return SyncItems();

    if (!lastsync.isEmpty()) {
        // Modify params by adding the lastsync time.
        QMap<QString, QVariant> param = params.takeAt(0).toMap();
        param["lastsync"] = lastsync;
        params.push_back(param);
    }

    request("LJ.XMLRPC.syncitems", params);

    std::auto_ptr<QBuffer> buffer(m_responses.take(m_currentRequestId));
    QByteArray buf = buffer->buffer();

    SyncItems items(buf);
    return items;
}
Exemple #27
0
Process* ProcessMonitor::getSelectedProcess(QTableWidgetItem* item)
{
   QTableWidget* table(m_ui.processTable);
   
   if (item == 0) {
      QList<QTableWidgetItem*> items(table->selectedItems());
      if (items.isEmpty()) return 0;
      item = items.first();
   }

   int row(item->row());
   item = table->item(row,0);
   ProcessList list(s_processMap.keys(item));

   if (list.isEmpty()) {
      qDebug() << "Way not up with the where now??";
      return 0;
   }

   return list.first();  // and only
}
Exemple #28
0
void SimpleGraphicsView::hideLabels(bool hide) {
    hideLabels_ = hide;
    QList<QGraphicsItem*> graphicsItems = items();

    if (hideLabels_) {
        for (auto& graphicsItem : graphicsItems) {
            SimpleWithRectangleLabel* rectItem =
                qgraphicsitem_cast<SimpleWithRectangleLabel*>(graphicsItem);

            if (rectItem) rectItem->hide();
        }
    }
    else {
        for (auto& graphicsItem : graphicsItems) {
            SimpleWithRectangleLabel* rectItem =
                qgraphicsitem_cast<SimpleWithRectangleLabel*>(graphicsItem);

            if (rectItem) rectItem->show();
        }
    }
}
/*! Reimplemets the QGraphicsView::mousePressEvent() 
*/
void SchematicSceneViewer::mousePressEvent(QMouseEvent *me)
{
	m_buttonState = me->button();
	m_oldWinPos = me->pos();
	m_oldScenePos = mapToScene(m_oldWinPos);

	bool drawRect = true;
	QList<QGraphicsItem *> pointedItems = items(me->pos());
	int i;
	for (i = 0; i < pointedItems.size(); i++) {
		SchematicWindowEditor *editor = dynamic_cast<SchematicWindowEditor *>(pointedItems[i]);
		if (!editor) {
			drawRect = false;
			break;
		}
	}

	if (m_buttonState == Qt::LeftButton && drawRect)
		setDragMode(QGraphicsView::RubberBandDrag);
	QGraphicsView::mousePressEvent(me);
}
Exemple #30
0
void TileScene::ToggleSelectionMode(bool selection)
{
    QList<QGraphicsItem*> childrenList = items();

    //make every current item selectable
    if(selection)
    {
        for(int i = 0; i < childrenList.count(); i++)
            childrenList[i]->setFlag(QGraphicsItem::ItemIsSelectable);

        tileController->EndPaintOperation();
    }
    //make all items non-selectable
    else
    {
        for(int i = 0; i < childrenList.count(); i++)
            childrenList[i]->setFlag(QGraphicsItem::ItemIsSelectable, false);

        ClearPreview();
    }
}