hlp:荆州版本

This commit is contained in:
kite_lucs
2026-10-19 17:03:47 +08:00
parent e533ea8e0b
commit 065b146998
438 changed files with 163143 additions and 185387 deletions
+100 -100
View File
@@ -1,100 +1,100 @@
#include <QtGui>
#include "pictextitem.h"
#include "picscene.h"
#include "moveinput.h"
extern MoveInput* moveInput;
PicTextItem::PicTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
QGraphicsTextItem(parent)//edit@02-07
{
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsFocusable);
QFont font;
font.setFamily("wenquanyi");
font.setPixelSize(12);
document()->setDefaultStyleSheet("p { margin: 0; }");
document()->setDocumentMargin(0);
SpecialConditions = false;
CatchCnt1CurrValue = -1;
CatchCnt1StartValue = -1;
// 插入的变量贴底部,防止错位,修复打开文件时变量图片的垂直对齐
document()->setDefaultStyleSheet("img { vertical-align: bottom; }");
}
//! [1]
QVariant PicTextItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == ItemSceneChange && scene()) {
QPointF newPos = value.toPoint();
QRectF rect = scene()->sceneRect();
if (!rect.contains(newPos)) {
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
}
}
return QGraphicsItem::itemChange(change, value);
}
//! [1]
//! [2]
void PicTextItem::focusOutEvent(QFocusEvent *event)
{
moveInput->hide();
emit lostFocus(this);
QGraphicsTextItem::focusOutEvent(event);
//
}
//! [2]
//! [5]
void PicTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
//if (textInteractionFlags() == Qt::NoTextInteraction)
// setTextInteractionFlags(Qt::TextEditorInteraction);
//setTextInteractionFlags(Qt::TextBrowserInteraction);
QGraphicsTextItem::mouseDoubleClickEvent(event);
//emit itemEdit(toHtml());
}
//! [5]
//限制图元拖动范围
void PicTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{
//edit@12-07
QPointF newPos = this->pos();
this->setPos(qCeil(newPos.x()),qCeil(newPos.y()));
if(scene())
scene()->update();
QGraphicsTextItem::mouseReleaseEvent(event);
}
void PicTextItem::keyPressEvent(QKeyEvent *event)
{
foreach (QGraphicsItem *item, scene()->selectedItems()) {
if(event->key() == Qt::Key_Left)
{
item->moveBy(-1, 0);
}
else if(event->key() == Qt::Key_Right)
{
item->moveBy(1, 0);
}
else if(event->key() == Qt::Key_Up)
{
item->moveBy(0, -1);
}
else if(event->key() == Qt::Key_Down)
{
item->moveBy(0, 1);
}
}
if(!scene()->selectedItems().empty())
{
scene()->update();
}
QGraphicsTextItem::keyPressEvent(event);
}
#include <QtGui>
#include "pictextitem.h"
#include "picscene.h"
#include "moveinput.h"
extern MoveInput* moveInput;
PicTextItem::PicTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
QGraphicsTextItem(parent)//edit@02-07
{
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setFlag(QGraphicsItem::ItemIsFocusable);
QFont font;
font.setFamily("wenquanyi");
font.setPixelSize(12);
document()->setDefaultStyleSheet("p { margin: 0; }");
document()->setDocumentMargin(0);
SpecialConditions = false;
CatchCnt1CurrValue = -1;
CatchCnt1StartValue = -1;
// 插入的变量贴底部,防止错位,修复打开文件时变量图片的垂直对齐
document()->setDefaultStyleSheet("img { vertical-align: bottom; }");
}
//! [1]
QVariant PicTextItem::itemChange(GraphicsItemChange change,
const QVariant &value)
{
if (change == ItemSceneChange && scene()) {
QPointF newPos = value.toPoint();
QRectF rect = scene()->sceneRect();
if (!rect.contains(newPos)) {
newPos.setX(qMin(rect.right(), qMax(newPos.x(), rect.left())));
newPos.setY(qMin(rect.bottom(), qMax(newPos.y(), rect.top())));
}
}
return QGraphicsItem::itemChange(change, value);
}
//! [1]
//! [2]
void PicTextItem::focusOutEvent(QFocusEvent *event)
{
moveInput->hide();
emit lostFocus(this);
QGraphicsTextItem::focusOutEvent(event);
//
}
//! [2]
//! [5]
void PicTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
//if (textInteractionFlags() == Qt::NoTextInteraction)
// setTextInteractionFlags(Qt::TextEditorInteraction);
//setTextInteractionFlags(Qt::TextBrowserInteraction);
QGraphicsTextItem::mouseDoubleClickEvent(event);
//emit itemEdit(toHtml());
}
//! [5]
//限制图元拖动范围
void PicTextItem::mouseReleaseEvent ( QGraphicsSceneMouseEvent * event )
{
//edit@12-07
QPointF newPos = this->pos();
this->setPos(qCeil(newPos.x()),qCeil(newPos.y()));
if(scene())
scene()->update();
QGraphicsTextItem::mouseReleaseEvent(event);
}
void PicTextItem::keyPressEvent(QKeyEvent *event)
{
foreach (QGraphicsItem *item, scene()->selectedItems()) {
if(event->key() == Qt::Key_Left)
{
item->moveBy(-1, 0);
}
else if(event->key() == Qt::Key_Right)
{
item->moveBy(1, 0);
}
else if(event->key() == Qt::Key_Up)
{
item->moveBy(0, -1);
}
else if(event->key() == Qt::Key_Down)
{
item->moveBy(0, 1);
}
}
if(!scene()->selectedItems().empty())
{
scene()->update();
}
QGraphicsTextItem::keyPressEvent(event);
}