mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-27 11:20:54 +00:00
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);
|
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
||||||
Q_FOREACH(QGraphicsItem *item, listItems)
|
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<QGraphicsPixmapItem *>(item) != 0)
|
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||||
{
|
{
|
||||||
removeItem(item);
|
removeItem(item);
|
||||||
delete item;
|
delete item;
|
||||||
|
@ -295,8 +295,6 @@ void LandscapeSceneBase::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
qreal y = mouseEvent->scenePos().y();
|
qreal y = mouseEvent->scenePos().y();
|
||||||
m_posX = sint32(floor(x / m_cellSize));
|
m_posX = sint32(floor(x / m_cellSize));
|
||||||
m_posY = sint32(-floor(y / m_cellSize));
|
m_posY = sint32(-floor(y / m_cellSize));
|
||||||
|
|
||||||
m_mouseButton = mouseEvent->button();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
|
@ -310,20 +308,22 @@ void LandscapeSceneBase::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
||||||
QGraphicsScene::mouseMoveEvent(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)
|
bool LandscapeSceneBase::checkUnderZone(const int posX, const int posY)
|
||||||
{
|
{
|
||||||
QList<QGraphicsItem *> listItems = items(QPointF(posX * m_cellSize + 10, abs(posY) * m_cellSize + 10),
|
// TODO: Why crash program?
|
||||||
Qt::IntersectsItemBoundingRect, Qt::AscendingOrder);
|
// 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)
|
Q_FOREACH(QGraphicsItem *item, listItems)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<QGraphicsPixmapItem *>(item) != 0)
|
if (item->pos() == point)
|
||||||
return true;
|
{
|
||||||
|
if (qgraphicsitem_cast<QGraphicsPixmapItem *>(item) != 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,6 @@ public Q_SLOTS:
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
||||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkUnderZone(const int posX, const int posY);
|
bool checkUnderZone(const int posX, const int posY);
|
||||||
|
@ -72,7 +71,6 @@ private:
|
||||||
int m_cellSize;
|
int m_cellSize;
|
||||||
qreal m_mouseX, m_mouseY;
|
qreal m_mouseX, m_mouseY;
|
||||||
sint32 m_posX, m_posY;
|
sint32 m_posX, m_posY;
|
||||||
Qt::MouseButton m_mouseButton;
|
|
||||||
ZoneBuilderBase *m_zoneBuilderBase;
|
ZoneBuilderBase *m_zoneBuilderBase;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ void LandscapeView::mouseMoveEvent(QMouseEvent *event)
|
||||||
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
void LandscapeView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
m_lastPanPoint = QPoint();
|
m_lastPanPoint = QPoint();
|
||||||
QApplication::restoreOverrideCursor();
|
setCursor(Qt::ArrowCursor);
|
||||||
QGraphicsView::mouseReleaseEvent(event);
|
QGraphicsView::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,13 @@
|
||||||
|
|
||||||
// Project includes
|
// Project includes
|
||||||
#include "ui_project_settings_dialog.h"
|
#include "ui_project_settings_dialog.h"
|
||||||
#include "landscape_editor_global.h"
|
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
|
||||||
namespace LandscapeEditor
|
namespace LandscapeEditor
|
||||||
{
|
{
|
||||||
|
|
||||||
class LANDSCAPE_EDITOR_EXPORT ProjectSettingsDialog: public QDialog
|
class ProjectSettingsDialog: public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>419</width>
|
<width>419</width>
|
||||||
<height>93</height>
|
<height>67</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -38,20 +38,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0" colspan="3">
|
||||||
<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">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
|
Loading…
Reference in a new issue