Sankore smart button

preferencesAboutTextFull
Ivan Ilyin 12 years ago
parent 8be4c32bd8
commit a60439302c
  1. 3
      src/core/UB.h
  2. 16
      src/domain/UBGraphicsPolygonItem.cpp
  3. 2
      src/domain/UBGraphicsPolygonItem.h
  4. 66
      src/domain/UBGraphicsScene.cpp
  5. 3
      src/domain/UBGraphicsScene.h
  6. 9
      src/domain/ubgraphicsgroupcontaineritem.cpp
  7. 8
      src/domain/ubgraphicsgroupcontaineritem.h
  8. 1
      src/tools/UBGraphicsCompass.cpp
  9. 1
      src/tools/UBGraphicsProtractor.cpp
  10. 2
      src/tools/UBGraphicsProtractor.h
  11. 3
      src/tools/UBGraphicsRuler.cpp
  12. 1
      src/tools/UBGraphicsTriangle.cpp

@ -123,7 +123,8 @@ struct UBGraphicsItemType
StrokeItemType,
TriangleItemType,
MagnifierItemType,
cacheItemType
cacheItemType,
groupContainerType
};
};

@ -184,18 +184,18 @@ void UBGraphicsPolygonItem::paint ( QPainter * painter, const QStyleOptionGraphi
QGraphicsPolygonItem::paint(painter, option, widget);
}
QPainterPath UBGraphicsPolygonItem::shape() const
{
//QPainterPath UBGraphicsPolygonItem::shape() const
//{
QPainterPath path;
path.addRect(boundingRect());
// QPainterPath path;
// path.addRect(boundingRect());
return path;
// return path;
// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
//// static QPainterPath shapePath = QGraphicsPolygonItem::shape();
// return shapePath;
}
//// return shapePath;
//}
UBGraphicsScene* UBGraphicsPolygonItem::scene()

@ -115,7 +115,7 @@ class UBGraphicsPolygonItem : public QGraphicsPolygonItem, public UBItem
protected:
void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget);
QPainterPath shape () const;
// QPainterPath shape () const;
private:

@ -65,6 +65,9 @@
#include "core/memcheck.h"
const QString groupText = "Group items";
const QString ungroupText = "Ungroup items";
qreal UBZLayerController::errorNumber = -20000001.0;
UBZLayerController::UBZLayerController(QGraphicsScene *scene) :
@ -291,9 +294,9 @@ UBGraphicsScene::UBGraphicsScene(UBDocumentProxy* parent)
}
connect(this, SIGNAL(selectionChanged()), this, SLOT(selectionChangedProcessing()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(enableGroupingButton()));
connect(this, SIGNAL(selectionChanged()), this, SLOT(groupButtonProcessing()));
connect(UBApplication::mainWindow->actionGroupItems, SIGNAL(triggered()), this, SLOT(processGroupItems()));
connect(UBApplication::mainWindow->actionGroupItems, SIGNAL(triggered()), this, SLOT(groupButtonClicked()));
}
UBGraphicsScene::~UBGraphicsScene()
@ -312,15 +315,65 @@ void UBGraphicsScene::selectionChangedProcessing()
UBApplication::showMessage("ZValue is " + QString::number(selectedItems().first()->zValue(), 'f') + "own z value is "
+ QString::number(selectedItems().first()->data(UBGraphicsItemData::ItemOwnZValue).toReal(), 'f'));
}
void UBGraphicsScene::enableGroupingButton()
void UBGraphicsScene::groupButtonProcessing()
{
QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems();
int selCount = selItems.count();
if (selectedItems().count() > 1) {
groupAction->setEnabled(true);
} else {
if (selCount < 1) {
groupAction->setEnabled(false);
groupAction->setText(groupText);
} else if (selCount == 1) {
if (selItems.first()->type() == UBGraphicsGroupContainerItem::Type) {
groupAction->setEnabled(true);
groupAction->setText(ungroupText);
} else {
groupAction->setEnabled(false);
}
} else if (selCount > 1) {
groupAction->setEnabled(true);
groupAction->setText(groupText);
}
}
void UBGraphicsScene::groupButtonClicked()
{
QAction *groupAction = UBApplication::mainWindow->actionGroupItems;
QList<QGraphicsItem*> selItems = selectedItems();
if (!selItems.count()) {
qDebug() << "Got grouping request when there is no any selected item on the scene";
return;
}
if (groupAction->text() == groupText) { //The only way to get information from item, considering using smth else
UBGraphicsGroupContainerItem *groupItem = new UBGraphicsGroupContainerItem();
foreach (QGraphicsItem *item, selItems) {
item->setSelected(false);
item->setFlag(QGraphicsItem::ItemIsSelectable, false);
item->setFlag( QGraphicsItem::ItemIsMovable, false);
item->setFlag(QGraphicsItem::ItemIsFocusable);
groupItem->addToGroup(item);
}
addItem(groupItem);
groupItem->setVisible(true);
groupItem->setFocus();
} else if (groupAction->text() == ungroupText) {
//Considering one selected item and it's a group
if (selItems.count() > 1) {
qDebug() << "can't make sense of ungrouping more then one item. Grouping action should be performed for that purpose";
return;
}
UBGraphicsGroupContainerItem *currentGroup = dynamic_cast<UBGraphicsGroupContainerItem*>(selItems.first());
if (currentGroup) {
currentGroup->destroy();
}
}
}
void UBGraphicsScene::processGroupItems()
{
@ -432,7 +485,6 @@ bool UBGraphicsScene::inputDevicePress(const QPointF& scenePos, const qreal& pre
return accepted;
}
bool UBGraphicsScene::inputDeviceMove(const QPointF& scenePos, const qreal& pressure)
{
bool accepted = false;

@ -305,7 +305,8 @@ public slots:
void setToolCursor(int tool);
void selectionChangedProcessing();
void enableGroupingButton();
void groupButtonProcessing();
void groupButtonClicked();
void processGroupItems();
void moveMagnifier(QPoint newPos);

@ -53,6 +53,15 @@ void UBGraphicsGroupContainerItem::remove()
mDelegate->remove();
}
void UBGraphicsGroupContainerItem::destroy() {
foreach (QGraphicsItem *item, childItems()) {
removeFromGroup(item);
item->setFlag(QGraphicsItem::ItemIsSelectable, true);
}
mDelegate->remove(true);
}
void UBGraphicsGroupContainerItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{

@ -15,6 +15,14 @@ public:
virtual UBGraphicsScene* scene();
virtual UBGraphicsGroupContainerItem *deepCopy() const;
virtual void remove();
enum { Type = UBGraphicsItemType::groupContainerType };
virtual int type() const
{
return Type;
}
void destroy();
protected:

@ -71,6 +71,7 @@ UBGraphicsCompass::UBGraphicsCompass()
unsetCursor();
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
connect(UBApplication::boardController, SIGNAL(penColorChanged()), this, SLOT(penColorChanged()));
connect(UBDrawingController::drawingController(), SIGNAL(lineWidthIndexChanged(int)), this, SLOT(lineWidthChanged()));

@ -64,6 +64,7 @@ UBGraphicsProtractor::UBGraphicsProtractor()
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
scale(1.5, 1.5);
}

@ -28,7 +28,7 @@ class UBGraphicsScene;
class UBGraphicsProtractor : public UBAbstractDrawRuler, public QGraphicsEllipseItem, public UBItem
{
Q_OBJECT;
Q_OBJECT
public:
UBGraphicsProtractor ();

@ -46,7 +46,8 @@ UBGraphicsRuler::UBGraphicsRuler()
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
updateResizeCursor();
setFlag(QGraphicsItem::ItemIsSelectable, false);
updateResizeCursor();
}
void UBGraphicsRuler::updateResizeCursor()

@ -55,6 +55,7 @@ UBGraphicsTriangle::UBGraphicsTriangle()
mRotateSvgItem->setData(UBGraphicsItemData::ItemLayerType, QVariant(UBItemLayerType::Control));
setData(UBGraphicsItemData::itemLayerType, QVariant(itemLayerType::CppTool)); //Necessary to set if we want z value to be assigned correctly
setFlag(QGraphicsItem::ItemIsSelectable, false);
updateResizeCursor();
}

Loading…
Cancel
Save