压力算法移植前
This commit is contained in:
@@ -0,0 +1,559 @@
|
||||
#include "formscenedlg.h"
|
||||
#include "ui_formscenedlg.h"
|
||||
#include <QTimer>
|
||||
#include <QStackedWidget>
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
#include "MyInputMethod.h"
|
||||
|
||||
FormScenedlg::FormScenedlg(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FormScenedlg),pPicScene(0),tabMainWindow(0),dialogFileOperation(0),textEdit(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
SWmaximumSize1={};
|
||||
SWgeometry1={};
|
||||
FVgeometry2={};
|
||||
GVgeometry3={};
|
||||
|
||||
|
||||
QPushButton *btnArray[]={
|
||||
// ui->KeyDown,
|
||||
// ui->KeyLeft,
|
||||
// ui->KeyRight,
|
||||
// ui->KeyUp,
|
||||
ui->itemLast,
|
||||
ui->itemFirst,
|
||||
ui->saveAsButton,
|
||||
ui->saveButton,
|
||||
ui->addButton,
|
||||
//ui->itemPrev,
|
||||
//ui->itemNext,
|
||||
ui->previewButton,
|
||||
ui->newfileButton,
|
||||
ui->openfileButton,
|
||||
ui->delButton,
|
||||
ui->EditItemButton,
|
||||
ui->insertImage,
|
||||
ui->reduceButton,
|
||||
ui->enlargeButton,
|
||||
ui->ZoomOrigin
|
||||
};
|
||||
|
||||
const QString sysfamily=qApp->font().family();
|
||||
|
||||
for(int i=0;i<sizeof(btnArray)/sizeof(*btnArray);i++)
|
||||
{
|
||||
QFont font = ui->ZoomOrigin->font(); // 获取当前字体
|
||||
const int defaultPointSize=16;//font.pointSize()<10?10:font.pointSize();
|
||||
|
||||
if(Public::ReadLanguageName()=="English"){
|
||||
font.setFamily("Arial");
|
||||
}
|
||||
// font.setFamily("WenQuanYiMH");
|
||||
//font.setFamily("wenquanyi");
|
||||
font.setBold(true);
|
||||
font.setPointSize(1*defaultPointSize); // 设置字体大小为12点
|
||||
font.setWeight(QFont::Black);
|
||||
btnArray[i]->setFont(font); // 应用新字体到按钮
|
||||
}
|
||||
|
||||
//不显示测试按钮
|
||||
ui->itemPrev->setVisible(false);
|
||||
ui->itemNext->setVisible(false);
|
||||
ui->ZoomOrigin->setVisible(false);
|
||||
ui->btn_test2->setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
FormScenedlg::~FormScenedlg()
|
||||
{
|
||||
delete ui;
|
||||
delete dialogFileOperation;
|
||||
dialogFileOperation=0;
|
||||
}
|
||||
void FormScenedlg::horizontalScrollBar_valueChanged(int value)
|
||||
{
|
||||
QTimer::singleShot(100,this,SLOT(sceneRectChanged_timerHandler()));
|
||||
}
|
||||
|
||||
void FormScenedlg::verticalScrollBar_valueChanged(int value)
|
||||
{
|
||||
QTimer::singleShot(100,this,SLOT(sceneRectChanged_timerHandler()));
|
||||
}
|
||||
|
||||
void FormScenedlg::bindScene(PicScene *pPicScene, QGraphicsView *pGraphicViewer,QTextEdit *pTextEdit){
|
||||
this->pPicScene = pPicScene;
|
||||
this->pViewer = pGraphicViewer;
|
||||
this->textEdit = pTextEdit;
|
||||
|
||||
QObject::connect(pViewer->verticalScrollBar(), SIGNAL(valueChanged(int)), this,SLOT(verticalScrollBar_valueChanged(int)));
|
||||
QObject::connect(pViewer->horizontalScrollBar(), SIGNAL(valueChanged(int)), this,SLOT(horizontalScrollBar_valueChanged(int)));
|
||||
|
||||
dialogFileOperation = new DialogFileOperation(0);
|
||||
dialogFileOperation->setWindowTitle(tr("插入图片"));
|
||||
// connect(dialogFileOperation,SIGNAL(openFile(QString,bool)),this,SLOT(onFileOpen(QString,bool)));
|
||||
//Scene Test
|
||||
connect(dialogFileOperation,SIGNAL(openFile(QString,bool)),this,SIGNAL(insertImage(QString,bool)));
|
||||
|
||||
|
||||
|
||||
//edit@12-12读取旧的布局信息
|
||||
const QStackedWidget* pStackedWidget= static_cast<QStackedWidget*>(this->pViewer->parentWidget()->parentWidget());
|
||||
const QWidget* fileSceneViewer = static_cast<QWidget*>(this->pViewer->parentWidget());
|
||||
if(pStackedWidget && fileSceneViewer)
|
||||
{
|
||||
tabMainWindow=fileSceneViewer->parentWidget()->parentWidget();
|
||||
SWmaximumSize1=pStackedWidget->maximumSize();
|
||||
SWgeometry1=pStackedWidget->geometry();
|
||||
|
||||
//QSize FVmaximumSize=fileSceneViewer->maximumSize();
|
||||
FVgeometry2=fileSceneViewer->geometry();
|
||||
|
||||
//QSize GVmaximumSize=this->pViewer->maximumSize();
|
||||
GVgeometry3=this->pViewer->geometry();
|
||||
|
||||
//qDebug()<<"1-2-3-size="<<SWmaximumSize1<<", "<<SWgeometry1<<", "<<FVgeometry2<<", "<<GVgeometry3;
|
||||
}
|
||||
}
|
||||
void FormScenedlg::sceneRectChanged_timerHandler()
|
||||
{
|
||||
// if(this->pViewer && this->pPicScene)
|
||||
// {
|
||||
// const QPoint originScene=pViewer->mapFromScene(0,0);
|
||||
// if(originScene!=lastOriginScene)
|
||||
// {
|
||||
// lastOriginScene=originScene;
|
||||
this->pPicScene->update();
|
||||
// //qDebug()<<"sceneRectChanged-update="<<lastOriginScene;
|
||||
// }
|
||||
// //qDebug()<<"sceneRectChanged="<<this->pPicScene->sceneRect();
|
||||
// }
|
||||
}
|
||||
|
||||
//edit@12-12 改变布局
|
||||
void FormScenedlg::Layout_ToNew()
|
||||
{
|
||||
QStackedWidget* pStackedWidget= static_cast<QStackedWidget*>(this->pViewer->parentWidget()->parentWidget());
|
||||
QWidget* fileSceneViewer = static_cast<QWidget*>(this->pViewer->parentWidget());
|
||||
|
||||
//QWidget *tabMainWindow=fileSceneViewer->parentWidget()->parentWidget();
|
||||
QHBoxLayout *horizontalLayout=dynamic_cast<QHBoxLayout*>(FormScenedlg::findChildAll(tabMainWindow->layout(),"horizontalLayout"));//edit@12-14 信息提示栏
|
||||
FormScenedlg::showQLayout(horizontalLayout,false);
|
||||
|
||||
if(pStackedWidget && fileSceneViewer)
|
||||
{
|
||||
pStackedWidget->setMaximumSize(SWmaximumSize1.width(),SWmaximumSize1.height()+150);
|
||||
pStackedWidget->setGeometry(SWgeometry1.x(),SWgeometry1.y(),SWgeometry1.width(),SWgeometry1.height()+150);
|
||||
fileSceneViewer->setGeometry(FVgeometry2.x(),FVgeometry2.y(),FVgeometry2.width(),FVgeometry2.height()+150);
|
||||
this->pViewer->setGeometry(GVgeometry3.x(),GVgeometry3.y(),GVgeometry3.width(),GVgeometry3.height()+80);
|
||||
}
|
||||
|
||||
}
|
||||
//edit@12-12 恢复布局
|
||||
void FormScenedlg::Layout_ToDefault()
|
||||
{
|
||||
QStackedWidget* pStackedWidget= static_cast<QStackedWidget*>(this->pViewer->parentWidget()->parentWidget());
|
||||
QWidget* fileSceneViewer = static_cast<QWidget*>(this->pViewer->parentWidget());
|
||||
|
||||
//QWidget *tabMainWindow=fileSceneViewer->parentWidget()->parentWidget();
|
||||
QHBoxLayout *horizontalLayout=dynamic_cast<QHBoxLayout*>(FormScenedlg::findChildAll(tabMainWindow->layout(),"horizontalLayout"));//edit@12-14 信息提示栏
|
||||
FormScenedlg::showQLayout(horizontalLayout,true);
|
||||
|
||||
if(pStackedWidget && fileSceneViewer)
|
||||
{
|
||||
pStackedWidget->setMaximumSize(SWmaximumSize1);
|
||||
pStackedWidget->setGeometry(SWgeometry1);
|
||||
fileSceneViewer->setGeometry(FVgeometry2);
|
||||
this->pViewer->setGeometry(GVgeometry3);
|
||||
}
|
||||
}
|
||||
|
||||
void FormScenedlg::changeEvent(QEvent *e)
|
||||
{
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void FormScenedlg::on_addButton_clicked()
|
||||
{
|
||||
emit addButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_EditItemButton_clicked()
|
||||
{
|
||||
emit EditItemButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_delButton_clicked()
|
||||
{
|
||||
emit delButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_newfileButton_clicked()
|
||||
{
|
||||
emit newfileButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_openfileButton_clicked()
|
||||
{
|
||||
emit openfileButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_previewButton_clicked()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
foreach (QGraphicsItem *item, pPicScene->items()) {
|
||||
item->clearFocus();
|
||||
item->setSelected(false);
|
||||
}
|
||||
//ui->previewButton->setFocus();
|
||||
emit previewButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_saveButton_clicked()
|
||||
{
|
||||
emit saveButton();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_saveAsButton_clicked()
|
||||
{
|
||||
emit saveAsButton();
|
||||
}
|
||||
//edit@12-06 放大
|
||||
void FormScenedlg::on_enlargeButton_clicked()
|
||||
{
|
||||
emit enlargeButton();
|
||||
adjustItemsPos();
|
||||
//QTimer::singleShot(100,this,SLOT(adjustItemsPos()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_reduceButton_clicked()
|
||||
{
|
||||
emit reduceButton();
|
||||
adjustItemsPos();
|
||||
//QTimer::singleShot(100,this,SLOT(adjustItemsPos()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_KeyLeft_clicked()
|
||||
{
|
||||
pViewer->setFocus();
|
||||
#ifndef Q_OS_WIN32
|
||||
//QWSServer::sendKeyEvent(0,Qt::Key_Left,Qt::NoModifier,true,false); //向系统发送键盘事件
|
||||
MyInputMethod::sendEvent(Qt::Key_Left,Qt::NoModifier);
|
||||
#endif
|
||||
//QTimer::singleShot(10,this,SLOT(adjustItemsPosFalse()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_KeyUp_clicked()
|
||||
{
|
||||
pViewer->setFocus();
|
||||
#ifndef Q_OS_WIN32
|
||||
//QWSServer::sendKeyEvent(0,Qt::Key_Up,Qt::NoModifier,true,false); //向系统发送键盘事件
|
||||
MyInputMethod::sendEvent(Qt::Key_Up,Qt::NoModifier);
|
||||
#endif
|
||||
//QTimer::singleShot(10,this,SLOT(adjustItemsPosFalse()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_KeyRight_clicked()
|
||||
{
|
||||
pViewer->setFocus();
|
||||
#ifndef Q_OS_WIN32
|
||||
//QWSServer::sendKeyEvent(0,Qt::Key_Right,Qt::NoModifier,true,false); //向系统发送键盘事件
|
||||
MyInputMethod::sendEvent(Qt::Key_Right,Qt::NoModifier);
|
||||
#endif
|
||||
//QTimer::singleShot(10,this,SLOT(adjustItemsPosFalse()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_KeyDown_clicked()
|
||||
{
|
||||
pViewer->setFocus();
|
||||
#ifndef Q_OS_WIN32
|
||||
//QWSServer::sendKeyEvent(0,Qt::Key_Down,Qt::NoModifier,true,false); //向系统发送键盘事件
|
||||
MyInputMethod::sendEvent(Qt::Key_Down,Qt::NoModifier);
|
||||
#endif
|
||||
//QTimer::singleShot(10,this,SLOT(adjustItemsPosFalse()));
|
||||
}
|
||||
|
||||
void FormScenedlg::on_insertImage_clicked()
|
||||
{
|
||||
if(dialogFileOperation)
|
||||
{
|
||||
dialogFileOperation->refreshListView(PICFILE);
|
||||
dialogFileOperation->exec();
|
||||
}
|
||||
}
|
||||
|
||||
void FormScenedlg::on_ZoomOrigin_clicked()
|
||||
{
|
||||
adjustItemsPos(false);
|
||||
}
|
||||
|
||||
void FormScenedlg::on_btn_test2_clicked()
|
||||
{
|
||||
emit ZoomOrigin();
|
||||
|
||||
}
|
||||
|
||||
//edit@12-11 选中下一个图元
|
||||
void FormScenedlg::on_itemNext_clicked()
|
||||
{
|
||||
QList<QGraphicsItem *> items=pPicScene->items();
|
||||
if(!items.empty())
|
||||
{
|
||||
int index=0;
|
||||
for(index=0;index<items.size();index++)
|
||||
{
|
||||
if(items.at(index)->isSelected())break;
|
||||
}
|
||||
|
||||
pPicScene->clearSelection();
|
||||
if(index+1<items.size())
|
||||
{
|
||||
index+=1;
|
||||
//edit@12-11选中下一个
|
||||
items.at(index)->setSelected(true);
|
||||
items.at(index)->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
//edit@12-11 超范围,滚动到第一个
|
||||
index=0;
|
||||
items.front()->setSelected(true);
|
||||
items.front()->setFocus();
|
||||
}
|
||||
//PrintselectedItemInfo();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//edit@12-11选中上一个图元
|
||||
void FormScenedlg::on_itemPrev_clicked()
|
||||
{
|
||||
QList<QGraphicsItem *> items=pPicScene->items();
|
||||
if(!items.empty())
|
||||
{
|
||||
int index=0;
|
||||
for(index=0;index<items.size();index++)
|
||||
{
|
||||
if(items.at(index)->isSelected())break;
|
||||
}
|
||||
|
||||
pPicScene->clearSelection();
|
||||
if(0<=index-1)
|
||||
{
|
||||
index-=1;
|
||||
//edit@12-11选中前一个
|
||||
items.at(index)->setSelected(true);
|
||||
items.at(index)->setFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
//edit@12-11 超范围,滚动到最后位置
|
||||
index=items.size()-1;
|
||||
items.back()->setSelected(true);
|
||||
items.back()->setFocus();
|
||||
}
|
||||
//PrintselectedItemInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void FormScenedlg::PrintselectedItemInfo()
|
||||
{
|
||||
foreach (QGraphicsItem *item, pPicScene->items()) {
|
||||
if(item->isSelected())
|
||||
{
|
||||
qDebug()<<"PrintselectedItemInfo-pos="<<item->pos();
|
||||
//qDebug()<<"PrintselectedItemInfo-pos="<<pPicScene->views().front()->mapFromScene(item->pos());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//edit@12-11 自动调整元素位置到原点
|
||||
void FormScenedlg::adjustItemsPos(bool bMoveScrollBar)
|
||||
{
|
||||
|
||||
auto items = pPicScene->items();
|
||||
|
||||
// if(!items.isEmpty()){
|
||||
// pViewer->centerOn(items.first());
|
||||
// auto i = items.first();
|
||||
// if(i->flags() & QGraphicsItem::ItemIgnoresTransformations)
|
||||
// qDebug() << "ItemIgnoresTransformations";
|
||||
|
||||
// pPicScene->update();
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(bMoveScrollBar)
|
||||
{
|
||||
pViewer->verticalScrollBar()->setValue(0);
|
||||
pViewer->horizontalScrollBar()->setValue(0);
|
||||
}
|
||||
|
||||
QPointF movePoint;
|
||||
const QRectF sceneRect=pPicScene->sceneRect();
|
||||
qreal left=sceneRect.width(),top=sceneRect.width();
|
||||
foreach (const QGraphicsItem *item, pPicScene->items()) {
|
||||
left=qMin(left,item->pos().x());
|
||||
top=qMin(top,item->pos().y());
|
||||
}
|
||||
foreach (QGraphicsItem *item, pPicScene->items()) {
|
||||
QPointF oldpos=item->pos();
|
||||
//oldpos=QPointF(qCeil(oldpos.x()-left-1),qCeil(oldpos.y()-(top-pViewer->mapToScene(0,0).y()+1)));
|
||||
oldpos=QPointF(qCeil(oldpos.x()-left),qCeil(oldpos.y()-(top-pViewer->mapToScene(0,0).y())));
|
||||
item->setPos(oldpos);
|
||||
if(item->isSelected())movePoint=oldpos;
|
||||
}
|
||||
|
||||
if(bMoveScrollBar)
|
||||
{
|
||||
//pViewer->verticalScrollBar()->setValue(0);
|
||||
//pViewer->horizontalScrollBar()->setValue(0);
|
||||
|
||||
if(0<movePoint.x())
|
||||
{
|
||||
movePoint=pViewer->mapFromScene(movePoint.x(),movePoint.y());
|
||||
//pViewer->verticalScrollBar()->setValue(movePoint.y());
|
||||
pViewer->horizontalScrollBar()->setValue(movePoint.x());
|
||||
}
|
||||
}
|
||||
|
||||
if(!pPicScene->items().empty())pPicScene->update();
|
||||
|
||||
//qDebug()<<"adjustItemsPos="<<bMoveScrollBar;
|
||||
}
|
||||
void FormScenedlg::showQLayout(QLayout *layout,bool visible)
|
||||
{
|
||||
for (int i = 0; i < layout->count(); ++i) {
|
||||
QLayoutItem *item = layout->itemAt(i);
|
||||
if (QWidget *widget = item->widget()) {
|
||||
visible?widget->show():widget->hide();
|
||||
} else if (QLayout *subLayout = item->layout()) {
|
||||
showQLayout(subLayout,visible);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QObject *FormScenedlg::findChildAll(const QLayout *layout,const QString &name)
|
||||
{
|
||||
for (int i = 0; i < layout->count(); ++i) {
|
||||
QLayoutItem *item = layout->itemAt(i);
|
||||
if (QObject *widget = item->widget()) {
|
||||
if(widget->objectName()==name)return widget;
|
||||
} else if (QLayout *subLayout = item->layout()) {
|
||||
if(subLayout->objectName()==name)return subLayout;
|
||||
QObject *q= findChildAll(subLayout,name);
|
||||
if(q)return q;continue;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
void FormScenedlg::onFileOpen(QString filePath,bool ){
|
||||
pPicScene->clearSelection();
|
||||
QString html = "<img src='" + filePath + "'/>";
|
||||
textEdit->setHtml (html);
|
||||
textItem = new PicTextItem();
|
||||
pPicScene->addItem(textItem);
|
||||
QList<QGraphicsItem *> items = pPicScene->items();
|
||||
if(pPicScene->items().count()>1){
|
||||
QRectF itemRect= items.at(1)->boundingRect();
|
||||
textItem->setPos( items.at(1)->scenePos().x()+itemRect.width()+20, items.at(1)->scenePos().y());
|
||||
}
|
||||
else textItem->setPos(this->pViewer->mapToScene(0,0));//edit@12-07
|
||||
textItem->setSelected(true);
|
||||
textItem->setHtml(textEdit->toHtml());
|
||||
}
|
||||
|
||||
void FormScenedlg::reset_showTextWidthHeight()
|
||||
{
|
||||
const QRectF BoundingRect=pPicScene->itemsBoundingRect();
|
||||
QLabel *labelTextWidthHeight=dynamic_cast<QLabel*>(FormScenedlg::findChildAll(tabMainWindow->layout(),"labelTextWidthHeight"));
|
||||
if(labelTextWidthHeight && 1<BoundingRect.height())
|
||||
{
|
||||
qreal bottomItem[2]={-1};//txt,img
|
||||
foreach (QGraphicsItem *item, pPicScene->items()) {
|
||||
if(item->x()<0)item->setX(0);
|
||||
if(item->y()<0)item->setY(0);
|
||||
//const int i=-1==((QGraphicsTextItem*)item)->toHtml().indexOf("img ",0,Qt::CaseInsensitive)?0:1;
|
||||
const int i=-1==((QGraphicsTextItem*)item)->toHtml().indexOf("home/plg/doc/",0,Qt::CaseInsensitive)?0:1;
|
||||
if(item->sceneBoundingRect().bottom()>bottomItem[i])
|
||||
{
|
||||
bottomItem[i]=item->sceneBoundingRect().bottom();
|
||||
}
|
||||
}
|
||||
QString newText;
|
||||
int HighlightedValue= BoundingRect.height();
|
||||
newText = tr("[ %1行 x %2列 ]").arg(HighlightedValue).arg(BoundingRect.width());
|
||||
|
||||
const QString oldText=labelTextWidthHeight->text();
|
||||
if(32<HighlightedValue)
|
||||
{
|
||||
//edit@12-17 超出范围的高亮提示
|
||||
labelTextWidthHeight->setText(tr("<html><head/><body><p>[<span style=\"color:red;font-size:16px;\"> %1行 </span>x %2列 ]</p></body></html>")
|
||||
.arg(HighlightedValue).arg(qCeil(BoundingRect.width())));
|
||||
}
|
||||
else
|
||||
{
|
||||
labelTextWidthHeight->setText(newText);
|
||||
}
|
||||
|
||||
if(oldText!=newText)
|
||||
{
|
||||
//QTimer::singleShot(10,this,SLOT(adjustItemsPos()));
|
||||
QTimer::singleShot(10,this,SLOT(adjustItemsPosFalse()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FormScenedlg::on_itemFirst_clicked()
|
||||
{
|
||||
int index=-1;
|
||||
const QRectF sceneRect=pPicScene->sceneRect();
|
||||
qreal left=sceneRect.width();
|
||||
QList<QGraphicsItem *> allitems=pPicScene->items();
|
||||
for(int i =0;i<allitems.size();i++)
|
||||
{
|
||||
allitems.at(i)->clearFocus();
|
||||
allitems.at(i)->setSelected(false);
|
||||
if(left>allitems.at(i)->pos().x())
|
||||
{
|
||||
index=i;
|
||||
left=allitems.at(i)->pos().x();
|
||||
}
|
||||
}
|
||||
if(-1!=index)pPicScene->items().at(index)->setSelected(true);
|
||||
adjustItemsPos();
|
||||
}
|
||||
|
||||
void FormScenedlg::on_itemLast_clicked()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
int index=-1;
|
||||
const QRectF sceneRect=pPicScene->sceneRect();
|
||||
qreal left=0;
|
||||
QList<QGraphicsItem *> allitems=pPicScene->items();
|
||||
for(int i =0;i<allitems.size();i++)
|
||||
{
|
||||
allitems.at(i)->clearFocus();
|
||||
allitems.at(i)->setSelected(false);
|
||||
if(left<allitems.at(i)->pos().x())
|
||||
{
|
||||
index=i;
|
||||
left=allitems.at(i)->pos().x();
|
||||
}
|
||||
}
|
||||
if(-1!=index)pPicScene->items().at(index)->setSelected(true);
|
||||
adjustItemsPos();
|
||||
}
|
||||
|
||||
//void FormScenedlg::onSceneRectChanged(const QString &text)
|
||||
//{
|
||||
// qDebug()<<"FormScenedlg::sceneRectChanged=";
|
||||
//}
|
||||
Reference in New Issue
Block a user