Changed: #1302 Landscape scene works correctly in world editor plugin. Replaced dynamic_cast on more faster qgraphicsitem_cast.
--HG-- branch : gsoc2011-worldeditorqt
This commit is contained in:
parent
4c9614d841
commit
b93f59ae10
5 changed files with 17 additions and 33 deletions
|
@ -206,7 +206,7 @@ void LandscapeSceneBase::deleteItemZone(const ZonePosition &zonePos)
|
|||
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||
{
|
||||
if (dynamic_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||
{
|
||||
removeItem(item);
|
||||
delete item;
|
||||
|
@ -295,8 +295,6 @@ void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||
qreal y = mouseEvent->scenePos().y();
|
||||
m_posX = sint32(floor(x / m_cellSize));
|
||||
m_posY = sint32(-floor(y / m_cellSize));
|
||||
|
||||
m_mouseButton = mouseEvent->button();
|
||||
}
|
||||
|
||||
void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||
|
@ -310,21 +308,23 @@ void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|||
QGraphicsScene::mouseMoveEvent(mouseEvent);
|
||||
}
|
||||
|
||||
void LandscapeSceneBase::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||
{
|
||||
QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
||||
m_mouseButton = Qt::NoButton;
|
||||
}
|
||||
|
||||
bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY)
|
||||
{
|
||||
QList<QGraphicsItem *> listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10),
|
||||
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||
// TODO: Why crash program?
|
||||
// QList<QGraphicsItem *> listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10),
|
||||
// Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||
|
||||
QList<QGraphicsItem *> listItems = items();
|
||||
|
||||
QPointF point(posX, abs(posY));
|
||||
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||
{
|
||||
if (dynamic_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||
if (item->pos() == point)
|
||||
{
|
||||
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,6 @@ public Q_SLOTS:
|
|||
protected:
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||
|
||||
private:
|
||||
bool checkUnderZone(const int posX, const int posY);
|
||||
|
@ -72,7 +71,6 @@ private:
|
|||
int m_cellSize;
|
||||
qreal m_mouseX, m_mouseY;
|
||||
sint32 m_posX, m_posY;
|
||||
Qt::MouseButton m_mouseButton;
|
||||
ZoneBuilderBase *m_zoneBuilderBase;
|
||||
};
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ void LandscapeView::mouseMoveEvent(QMouseEvent *event)
|
|||
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_lastPanPoint = QPoint();
|
||||
QApplication::restoreOverrideCursor();
|
||||
setCursor(Qt::ArrowCursor);
|
||||
QGraphicsView::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,14 +20,13 @@
|
|||
|
||||
// Project includes
|
||||
#include "ui_project_settings_dialog.h"
|
||||
#include "landscape_editor_global.h"
|
||||
|
||||
// Qt includes
|
||||
|
||||
namespace LandscapeEditor
|
||||
{
|
||||
|
||||
class LANDSCAPE_EDITOR_EXPORT ProjectSettingsDialog: public QDialog
|
||||
class ProjectSettingsDialog: public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>419</width>
|
||||
<height>93</height>
|
||||
<height>67</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -38,20 +38,7 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Context:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>contextComboBox</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="contextComboBox"/>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
|
Loading…
Reference in a new issue