Compare commits
2 Commits
492f0a12d7
...
3edca0287b
Author | SHA1 | Date |
---|---|---|
karlis | 3edca0287b | |
karlis | d1aeb28b97 |
|
@ -309,9 +309,8 @@ void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool for
|
|||
return;
|
||||
LayerWrapper::paint(painter, transform, force);
|
||||
transform = property.transform * transform;
|
||||
//qDebug() << transform;
|
||||
for (auto& child : children)
|
||||
child->paint(painter, transform, force);
|
||||
for (auto it = children.rbegin(); it != children.rend(); ++it)
|
||||
(*it)->paint(painter, transform, force);
|
||||
}
|
||||
|
||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QMenu>
|
||||
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
||||
#include <QTimer>
|
||||
#include <QKeyEvent>
|
||||
|
||||
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||
{
|
||||
|
@ -131,4 +132,75 @@ void LayerTreeWidget::onRenameEvent()
|
|||
|
||||
void LayerTreeWidget::refresh() {
|
||||
this->root->refreshTreeItem();
|
||||
}
|
||||
|
||||
void LayerTreeWidget::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
if (QApplication::keyboardModifiers() == Qt::ALT)
|
||||
{
|
||||
if (event->key() == Qt::Key_Up)
|
||||
{
|
||||
pushUpLayer();
|
||||
}
|
||||
else if (event->key() == Qt::Key_Down)
|
||||
{
|
||||
pushDownLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayerTreeWidget::pushUpLayer()
|
||||
{
|
||||
if (this->selectedItem == nullptr)
|
||||
return;
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
if (layer == nullptr)
|
||||
return;
|
||||
auto parent = layer->getParent();
|
||||
int index = -1;
|
||||
for (int i = 0; i < parent->children.size(); i++)
|
||||
{
|
||||
if (parent->children[i].get() == layer)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1 || index == 0)
|
||||
return;
|
||||
auto temp = parent->children[index - 1];
|
||||
parent->children[index - 1] = parent->children[index];
|
||||
parent->children[index] = temp;
|
||||
layer->qTreeWidgetItem->parent()->removeChild(layer->qTreeWidgetItem);
|
||||
parent->qTreeWidgetItem->insertChild(index - 1, layer->qTreeWidgetItem);
|
||||
this->setCurrentItem(layer->qTreeWidgetItem);
|
||||
emit triggerCentralRefresh();
|
||||
}
|
||||
|
||||
void LayerTreeWidget::pushDownLayer()
|
||||
{
|
||||
if (this->selectedItem == nullptr)
|
||||
return;
|
||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
if (layer == nullptr)
|
||||
return;
|
||||
auto parent = layer->getParent();
|
||||
int index = -1;
|
||||
for (int i = 0; i < parent->children.size(); i++)
|
||||
{
|
||||
if (parent->children[i].get() == layer)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (index == -1 || index == parent->children.size() - 1)
|
||||
return;
|
||||
auto temp = parent->children[index + 1];
|
||||
parent->children[index + 1] = parent->children[index];
|
||||
parent->children[index] = temp;
|
||||
layer->qTreeWidgetItem->parent()->removeChild(layer->qTreeWidgetItem);
|
||||
parent->qTreeWidgetItem->insertChild(index + 1, layer->qTreeWidgetItem);
|
||||
this->setCurrentItem(layer->qTreeWidgetItem);
|
||||
emit triggerCentralRefresh();
|
||||
}
|
|
@ -9,6 +9,8 @@ class LayerTreeWidget : public QTreeWidget
|
|||
private:
|
||||
QTreeWidgetItem *selectedItem;
|
||||
LayerWrapper *copiedItem;
|
||||
void pushUpLayer();
|
||||
void pushDownLayer();
|
||||
|
||||
public:
|
||||
ElementManager* elementManager;
|
||||
|
@ -17,6 +19,7 @@ class LayerTreeWidget : public QTreeWidget
|
|||
void onRenameEvent();
|
||||
void popMenu(const QPoint &pos);
|
||||
void refresh();
|
||||
void keyPressEvent(QKeyEvent* event) override;
|
||||
// void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
// void onItemDoubleClicked(QTreeWidgetItem *item, int column = 0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue