hlp:桂林国际齿轮泵代码
This commit is contained in:
@@ -0,0 +1,230 @@
|
||||
/****************************************************************************
|
||||
** Meta object code from reading C++ file 'NetworkManager.h'
|
||||
**
|
||||
** Created by: The Qt Meta Object Compiler version 63 (Qt 4.8.5)
|
||||
**
|
||||
** WARNING! All changes made in this file will be lost!
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../Network/NetworkManager.h"
|
||||
#if !defined(Q_MOC_OUTPUT_REVISION)
|
||||
#error "The header file 'NetworkManager.h' doesn't include <QObject>."
|
||||
#elif Q_MOC_OUTPUT_REVISION != 63
|
||||
#error "This file was generated using the moc from 4.8.5. It"
|
||||
#error "cannot be used with the include files from this version of Qt."
|
||||
#error "(The moc has changed too much.)"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_MOC_NAMESPACE
|
||||
static const uint qt_meta_data_NetworkManager[] = {
|
||||
|
||||
// content:
|
||||
6, // revision
|
||||
0, // classname
|
||||
0, 0, // classinfo
|
||||
38, 14, // methods
|
||||
0, 0, // properties
|
||||
0, 0, // enums/sets
|
||||
0, 0, // constructors
|
||||
0, // flags
|
||||
5, // signalCount
|
||||
|
||||
// signals: signature, parameters, type, tag, flags
|
||||
16, 15, 15, 15, 0x05,
|
||||
33, 15, 15, 15, 0x05,
|
||||
50, 15, 15, 15, 0x05,
|
||||
67, 15, 15, 15, 0x05,
|
||||
83, 15, 15, 15, 0x05,
|
||||
|
||||
// slots: signature, parameters, type, tag, flags
|
||||
116, 101, 97, 15, 0x0a,
|
||||
155, 15, 15, 15, 0x0a,
|
||||
170, 15, 15, 15, 0x0a,
|
||||
186, 15, 15, 15, 0x0a,
|
||||
207, 203, 15, 15, 0x0a,
|
||||
227, 203, 15, 15, 0x0a,
|
||||
250, 15, 15, 15, 0x0a,
|
||||
261, 257, 15, 15, 0x0a,
|
||||
279, 15, 15, 15, 0x0a,
|
||||
314, 293, 97, 15, 0x0a,
|
||||
364, 15, 15, 15, 0x0a,
|
||||
377, 15, 15, 15, 0x0a,
|
||||
393, 203, 15, 15, 0x0a,
|
||||
410, 15, 15, 15, 0x0a,
|
||||
417, 15, 15, 15, 0x0a,
|
||||
441, 433, 15, 15, 0x08,
|
||||
474, 433, 15, 15, 0x08,
|
||||
511, 15, 15, 15, 0x08,
|
||||
539, 15, 15, 15, 0x08,
|
||||
570, 15, 15, 15, 0x08,
|
||||
609, 604, 15, 15, 0x08,
|
||||
646, 15, 15, 15, 0x08,
|
||||
681, 15, 15, 15, 0x08,
|
||||
711, 15, 15, 15, 0x08,
|
||||
742, 15, 15, 15, 0x08,
|
||||
762, 15, 15, 15, 0x08,
|
||||
785, 15, 15, 15, 0x08,
|
||||
807, 15, 15, 15, 0x08,
|
||||
841, 15, 15, 15, 0x08,
|
||||
863, 433, 15, 15, 0x08,
|
||||
904, 433, 15, 15, 0x08,
|
||||
940, 433, 15, 15, 0x08,
|
||||
982, 15, 15, 15, 0x08,
|
||||
|
||||
0 // eod
|
||||
};
|
||||
|
||||
static const char qt_meta_stringdata_NetworkManager[] = {
|
||||
"NetworkManager\0\0updateJSONData()\0"
|
||||
"net_startPrint()\0net_pausePrint()\0"
|
||||
"net_stopPrint()\0OpenNewFile()\0int\0"
|
||||
"cmd,buf,buflen\0ctrlRequest(const char*,char*,size_t*)\0"
|
||||
"updateStatus()\0updateResults()\0"
|
||||
"updateNetworks()\0sel\0selectSSID(QString)\0"
|
||||
"selectNetwork(QString)\0scan()\0msg\0"
|
||||
"processMsg(char*)\0receiveMsgs()\0"
|
||||
"id,field,value,quote\0"
|
||||
"setNetworkParam(int,const char*,const char*,bool)\0"
|
||||
"addNetwork()\0triggerUpdate()\0"
|
||||
"authChanged(int)\0ping()\0removeNetwork()\0"
|
||||
"checked\0on_pushButtonSetIP_clicked(bool)\0"
|
||||
"on_pushButtonSetCancel_clicked(bool)\0"
|
||||
"on_pushButtonScan_pressed()\0"
|
||||
"on_pushButtonConnect_pressed()\0"
|
||||
"on_pushButtonDisconnect_pressed()\0"
|
||||
"arg1\0on_scanSSIDSelect_activated(QString)\0"
|
||||
"on_pushButtonAddNetworkd_pressed()\0"
|
||||
"on_pushButtonRemove_pressed()\0"
|
||||
"on_GetJsonpushButton_clicked()\0"
|
||||
"onfinish_get_json()\0onjson_timer_handler()\0"
|
||||
"onjson_server_error()\0"
|
||||
"on_applicate_pushButton_clicked()\0"
|
||||
"ShowNet_dataMessege()\0"
|
||||
"on_checkBoxRemoveDigitCode_clicked(bool)\0"
|
||||
"on_checkBoxRemoveCode_clicked(bool)\0"
|
||||
"on_radioButtonGetDataEnable_clicked(bool)\0"
|
||||
"setEth0StaticIP_Thread()\0"
|
||||
};
|
||||
|
||||
void NetworkManager::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
Q_ASSERT(staticMetaObject.cast(_o));
|
||||
NetworkManager *_t = static_cast<NetworkManager *>(_o);
|
||||
switch (_id) {
|
||||
case 0: _t->updateJSONData(); break;
|
||||
case 1: _t->net_startPrint(); break;
|
||||
case 2: _t->net_pausePrint(); break;
|
||||
case 3: _t->net_stopPrint(); break;
|
||||
case 4: _t->OpenNewFile(); break;
|
||||
case 5: { int _r = _t->ctrlRequest((*reinterpret_cast< const char*(*)>(_a[1])),(*reinterpret_cast< char*(*)>(_a[2])),(*reinterpret_cast< size_t*(*)>(_a[3])));
|
||||
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
|
||||
case 6: _t->updateStatus(); break;
|
||||
case 7: _t->updateResults(); break;
|
||||
case 8: _t->updateNetworks(); break;
|
||||
case 9: _t->selectSSID((*reinterpret_cast< const QString(*)>(_a[1]))); break;
|
||||
case 10: _t->selectNetwork((*reinterpret_cast< const QString(*)>(_a[1]))); break;
|
||||
case 11: _t->scan(); break;
|
||||
case 12: _t->processMsg((*reinterpret_cast< char*(*)>(_a[1]))); break;
|
||||
case 13: _t->receiveMsgs(); break;
|
||||
case 14: { int _r = _t->setNetworkParam((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< const char*(*)>(_a[2])),(*reinterpret_cast< const char*(*)>(_a[3])),(*reinterpret_cast< bool(*)>(_a[4])));
|
||||
if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; } break;
|
||||
case 15: _t->addNetwork(); break;
|
||||
case 16: _t->triggerUpdate(); break;
|
||||
case 17: _t->authChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||
case 18: _t->ping(); break;
|
||||
case 19: _t->removeNetwork(); break;
|
||||
case 20: _t->on_pushButtonSetIP_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
|
||||
case 21: _t->on_pushButtonSetCancel_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
|
||||
case 22: _t->on_pushButtonScan_pressed(); break;
|
||||
case 23: _t->on_pushButtonConnect_pressed(); break;
|
||||
case 24: _t->on_pushButtonDisconnect_pressed(); break;
|
||||
case 25: _t->on_scanSSIDSelect_activated((*reinterpret_cast< const QString(*)>(_a[1]))); break;
|
||||
case 26: _t->on_pushButtonAddNetworkd_pressed(); break;
|
||||
case 27: _t->on_pushButtonRemove_pressed(); break;
|
||||
case 28: _t->on_GetJsonpushButton_clicked(); break;
|
||||
case 29: _t->onfinish_get_json(); break;
|
||||
case 30: _t->onjson_timer_handler(); break;
|
||||
case 31: _t->onjson_server_error(); break;
|
||||
case 32: _t->on_applicate_pushButton_clicked(); break;
|
||||
case 33: _t->ShowNet_dataMessege(); break;
|
||||
case 34: _t->on_checkBoxRemoveDigitCode_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
|
||||
case 35: _t->on_checkBoxRemoveCode_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
|
||||
case 36: _t->on_radioButtonGetDataEnable_clicked((*reinterpret_cast< bool(*)>(_a[1]))); break;
|
||||
case 37: _t->setEth0StaticIP_Thread(); break;
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QMetaObjectExtraData NetworkManager::staticMetaObjectExtraData = {
|
||||
0, qt_static_metacall
|
||||
};
|
||||
|
||||
const QMetaObject NetworkManager::staticMetaObject = {
|
||||
{ &QWidget::staticMetaObject, qt_meta_stringdata_NetworkManager,
|
||||
qt_meta_data_NetworkManager, &staticMetaObjectExtraData }
|
||||
};
|
||||
|
||||
#ifdef Q_NO_DATA_RELOCATION
|
||||
const QMetaObject &NetworkManager::getStaticMetaObject() { return staticMetaObject; }
|
||||
#endif //Q_NO_DATA_RELOCATION
|
||||
|
||||
const QMetaObject *NetworkManager::metaObject() const
|
||||
{
|
||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||
}
|
||||
|
||||
void *NetworkManager::qt_metacast(const char *_clname)
|
||||
{
|
||||
if (!_clname) return 0;
|
||||
if (!strcmp(_clname, qt_meta_stringdata_NetworkManager))
|
||||
return static_cast<void*>(const_cast< NetworkManager*>(this));
|
||||
if (!strcmp(_clname, "ParaSettingUI"))
|
||||
return static_cast< ParaSettingUI*>(const_cast< NetworkManager*>(this));
|
||||
return QWidget::qt_metacast(_clname);
|
||||
}
|
||||
|
||||
int NetworkManager::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
{
|
||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||
if (_id < 0)
|
||||
return _id;
|
||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||
if (_id < 38)
|
||||
qt_static_metacall(this, _c, _id, _a);
|
||||
_id -= 38;
|
||||
}
|
||||
return _id;
|
||||
}
|
||||
|
||||
// SIGNAL 0
|
||||
void NetworkManager::updateJSONData()
|
||||
{
|
||||
QMetaObject::activate(this, &staticMetaObject, 0, 0);
|
||||
}
|
||||
|
||||
// SIGNAL 1
|
||||
void NetworkManager::net_startPrint()
|
||||
{
|
||||
QMetaObject::activate(this, &staticMetaObject, 1, 0);
|
||||
}
|
||||
|
||||
// SIGNAL 2
|
||||
void NetworkManager::net_pausePrint()
|
||||
{
|
||||
QMetaObject::activate(this, &staticMetaObject, 2, 0);
|
||||
}
|
||||
|
||||
// SIGNAL 3
|
||||
void NetworkManager::net_stopPrint()
|
||||
{
|
||||
QMetaObject::activate(this, &staticMetaObject, 3, 0);
|
||||
}
|
||||
|
||||
// SIGNAL 4
|
||||
void NetworkManager::OpenNewFile()
|
||||
{
|
||||
QMetaObject::activate(this, &staticMetaObject, 4, 0);
|
||||
}
|
||||
QT_END_MOC_NAMESPACE
|
||||
@@ -0,0 +1,833 @@
|
||||
#include "SceneEditOption.h"
|
||||
#include "pictextitem.h"
|
||||
#include "ui_sceneEditOption.h"
|
||||
#include <QDir>
|
||||
#include <QStringListModel>
|
||||
#include <SysPara.h>
|
||||
#include <QAbstractItemView>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
#include <Public.h>
|
||||
|
||||
#include <QTextCodec>
|
||||
#include <QByteArray>
|
||||
#include <QDebug>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QLabel>
|
||||
|
||||
#include "myview.h"
|
||||
#include "LogInfo.h"
|
||||
#include <QTextBlockFormat>
|
||||
#include <QTextBlock>
|
||||
#include <QPalette>
|
||||
|
||||
MoveInput* moveInput;
|
||||
SceneEditOption::SceneEditOption(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SceneEditOption),newScene(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
editMode = SCENE;
|
||||
xmlfileName = "";
|
||||
dialogFileOperation = new DialogFileOperation(0);
|
||||
#ifdef MYSAVEFILEDLG
|
||||
dialogSaveFile =new DialogSaveFile(0);
|
||||
//connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
#endif
|
||||
m_CreateImageFlag = false;
|
||||
m_pSavePicScene = new QGraphicsScene();
|
||||
m_pSavePicScene->setSceneRect(QRectF(0, 0, 3200, MAX_PRINT_ROW_NUM)); //生成图片的场景
|
||||
moveInput = new MoveInput(parent);
|
||||
}
|
||||
|
||||
SceneEditOption::~SceneEditOption()
|
||||
{
|
||||
if(m_pSavePicScene)
|
||||
{
|
||||
delete m_pSavePicScene;
|
||||
}
|
||||
if(moveInput)
|
||||
{
|
||||
delete moveInput;
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEditOption::bindStackWidget(QStackedWidget *stackedWidgetOption,QStackedWidget *stackedWidgetText){
|
||||
this->stackedWidgetOption = stackedWidgetOption;// stackedWidgetOption
|
||||
this->stackedWidgetText = stackedWidgetText;
|
||||
connect(this->stackedWidgetOption,SIGNAL(currentChanged(int)),this,SLOT(onStackedWidgetOptionCurrentChanged(int)));
|
||||
}
|
||||
|
||||
void SceneEditOption::bindSysPara(SysPara *sysPara){
|
||||
this->sysPara = sysPara;
|
||||
}
|
||||
void SceneEditOption::enableButtonSave(){
|
||||
if(!ui->saveButton->isEnabled())
|
||||
ui->saveButton->setEnabled(true);
|
||||
}
|
||||
void SceneEditOption::onStackedWidgetOptionCurrentChanged(int index)
|
||||
{
|
||||
const QString objectName=this->stackedWidgetOption->currentWidget()->objectName();
|
||||
// const QString objectName=this->stackedWidgetOption->widget(index)->objectName();
|
||||
qDebug()<<"index="<<index<<", objectName="<<objectName;
|
||||
if(newScene)
|
||||
{
|
||||
if("senceEditOption"==objectName && SCENE==sysPara->para.EditMode)
|
||||
{
|
||||
// qDebug()<<"显示新场景--open";
|
||||
this->pPicScene->setIsdrawBackground(true);
|
||||
this->stackedWidgetOption->hide();
|
||||
// //show_scene_new_dlg();
|
||||
// foreach (QLayout *lay, listQLayout) {
|
||||
// newScene->showQLayout(lay,false);
|
||||
// }
|
||||
newScene->Layout_ToNew();
|
||||
newScene->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// qDebug()<<"隐藏新场景--hide";
|
||||
this->pPicScene->setIsdrawBackground(false);
|
||||
this->stackedWidgetOption->setVisible(true);
|
||||
newScene->hide();
|
||||
newScene->Layout_ToDefault();
|
||||
// foreach (QLayout *lay, listQLayout) {
|
||||
// newScene->showQLayout(lay,true);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEditOption::bindScene(PicScene *pPicScene, QGraphicsView *pGraphicViewer,QTextEdit *pTextEdit){
|
||||
this->pPicScene = pPicScene;
|
||||
this->pViewer = pGraphicViewer;
|
||||
this->textEdit = pTextEdit;
|
||||
//connect(pPicScene,SIGNAL(xmlContentChanged ()),this,SLOT(enableButtonSave()));
|
||||
connect(pPicScene,SIGNAL(selectionChanged()),this,SLOT(enableButtonSave()));
|
||||
|
||||
ui->saveButton->setEnabled(false);
|
||||
connect(dialogFileOperation,SIGNAL(openFile(QString,bool)),this,SLOT(onFileOpen(QString,bool)));
|
||||
connect(dialogFileOperation,SIGNAL(createSceneImage(QString)),this,SLOT(onCreateSceneImage(QString)));
|
||||
#ifdef MYSAVEFILEDLG
|
||||
connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
#endif
|
||||
//edit@12-06 显示网格线
|
||||
this->pPicScene->setIsdrawBackground(true);
|
||||
}
|
||||
|
||||
void SceneEditOption::show_scene_new_dlg()
|
||||
{
|
||||
QWidget *tabMainWindow=this->parentWidget()->parentWidget();
|
||||
|
||||
if(!newScene)
|
||||
{
|
||||
this->stackedWidgetOption->hide();
|
||||
newScene=new FormScenedlg(tabMainWindow);
|
||||
newScene->setObjectName("newScene");
|
||||
|
||||
newScene->setAutoFillBackground(true);
|
||||
newScene->setPalette(tabMainWindow->palette());
|
||||
|
||||
newScene->bindScene(this->pPicScene,this->pViewer,this->textEdit);
|
||||
//edit@12-07另一种信号通信
|
||||
connect(newScene,SIGNAL(delButton()),this,SLOT(on_delButton_pressed()));
|
||||
connect(newScene,SIGNAL(saveButton()),this,SLOT(on_saveButton_pressed()));
|
||||
connect(newScene,SIGNAL(openfileButton()),this,SLOT(on_openfileButton_pressed()));
|
||||
connect(newScene,SIGNAL(previewButton()),this,SLOT(on_previewButton_pressed()));
|
||||
//connect(newScene,SIGNAL(previewButton()),this,SIGNAL(previewScene()));
|
||||
|
||||
connect(newScene,SIGNAL(addButton()),this,SLOT(on_addButton_pressed()));
|
||||
connect(newScene,SIGNAL(EditItemButton()),this,SLOT(on_EditItemButton_pressed()));
|
||||
connect(newScene,SIGNAL(saveAsButton()),this,SLOT(on_saveAsButton_pressed()));
|
||||
connect(newScene,SIGNAL(newfileButton()),this,SLOT(on_newfileButton_pressed()));
|
||||
connect(newScene,SIGNAL(enlargeButton()),this,SLOT(on_enlargeButton_pressed()));
|
||||
connect(newScene,SIGNAL(reduceButton()),this,SLOT(on_reduceButton_pressed()));
|
||||
connect(newScene,SIGNAL(ZoomOrigin()),this,SLOT(on_test_pressed()));
|
||||
connect(newScene,SIGNAL(btn_test2()),this,SLOT(on_btn_test2()));
|
||||
connect(this->pPicScene,SIGNAL(showTextWidthHeight()),newScene,SLOT(reset_showTextWidthHeight()));
|
||||
//connect(this->pPicScene,SIGNAL(adjustItemsPos()),newScene,SLOT(adjustItemsPosFalse()));
|
||||
|
||||
newScene->move(0,270);
|
||||
newScene->Layout_ToNew();
|
||||
}
|
||||
}
|
||||
|
||||
void SceneEditOption::on_previewButton_pressed()
|
||||
{
|
||||
this->pPicScene->setIsdrawBackground(false);
|
||||
emit previewScene();
|
||||
}
|
||||
|
||||
|
||||
void SceneEditOption::on_addButton_pressed()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
#if 0
|
||||
emit addPicTextItem();
|
||||
#else
|
||||
textItem = new PicTextItem();
|
||||
//textItem->setFont(myFont);
|
||||
//textItem->setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
pPicScene->addItem(textItem);
|
||||
//textItem->setDefaultTextColor(myTextColor);
|
||||
//QFont font = textItem->font();
|
||||
//font.setLetterSpacing(QFont::AbsoluteSpacing,sysPara->para.textEditCharSpace);
|
||||
//textItem->setFont(font);
|
||||
|
||||
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(0,0);
|
||||
else textItem->setPos(this->pViewer->mapToScene(0,0));//edit@12-07
|
||||
|
||||
textItem->setPlainText("Vernon Bach Printer");
|
||||
ui->saveButton->setEnabled(true);
|
||||
//qDebug()<<"sysPara->para.textEditCharSpace:"<<sysPara->para.textEditCharSpace;
|
||||
|
||||
//edit@12-12 新的打开方式直接进入编辑模式
|
||||
textItem->setPlainText("");
|
||||
textItem->setSelected(true);
|
||||
on_EditItemButton_pressed();
|
||||
#endif
|
||||
}
|
||||
bool SceneEditOption::maybeSave(){
|
||||
|
||||
if (xmlfileName.startsWith(QLatin1String(":/")))
|
||||
return true;
|
||||
|
||||
QMessageBox msgBox(QMessageBox::Information,tr("提示"),tr("文档已经改变,是否保存?"));
|
||||
QPushButton *saveButton = msgBox.addButton(tr("保存"), QMessageBox::ActionRole);
|
||||
QPushButton *cancleSaveButton = msgBox.addButton(tr("放弃保存"), QMessageBox::ActionRole);
|
||||
QPushButton *abortButton = msgBox.addButton(QMessageBox::Cancel);
|
||||
|
||||
msgBox.exec();
|
||||
|
||||
if (msgBox.clickedButton() == saveButton) {
|
||||
on_saveButton_pressed();
|
||||
return false;
|
||||
} else if (msgBox.clickedButton() == cancleSaveButton) {
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
void SceneEditOption::on_newfileButton_pressed()
|
||||
{
|
||||
if (maybeSave()) {
|
||||
pPicScene->clear();
|
||||
pViewer->viewport()->update();
|
||||
unsigned char SpecialVarEnable = 0;
|
||||
sysPara->devOp->fpgaWr(0xa4b0,(unsigned char *)&SpecialVarEnable,1);
|
||||
xmlfileName = "";
|
||||
QFile file(xmlfileName);
|
||||
emit fileNameChanged(QFileInfo(xmlfileName).fileName());
|
||||
}
|
||||
#ifdef VARCOLOR
|
||||
textEdit->insertHtml(QString("<span style='background:#ffffff;color=#000000;'> <span />"));
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::on_delButton_pressed()
|
||||
{
|
||||
#if 0
|
||||
|
||||
#else
|
||||
foreach (QGraphicsItem *item, pPicScene->selectedItems()) {
|
||||
pPicScene->removeItem(item);
|
||||
delete item;
|
||||
ui->saveButton->setEnabled(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::on_saveAsButton_pressed()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
#ifdef MYSAVEFILEDLG
|
||||
disconnect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),0,0);
|
||||
connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
dialogSaveFile->refreshListView(editMode);
|
||||
dialogSaveFile->show();
|
||||
dialogSaveFile->setEnterFileName("");
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::on_saveButton_pressed()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
#if 0
|
||||
|
||||
#else
|
||||
if(xmlfileName.isEmpty())
|
||||
{
|
||||
qDebug()<<"xml file null";
|
||||
#ifdef MYSAVEFILEDLG
|
||||
disconnect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),0,0);
|
||||
connect(dialogSaveFile,SIGNAL(saveFile(QString,bool)),this,SLOT(onSaveASFile(QString,bool)));
|
||||
dialogSaveFile->refreshListView(editMode);
|
||||
dialogSaveFile->show();
|
||||
dialogSaveFile->setEnterFileName("");
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
pPicScene->update();
|
||||
saveFile();
|
||||
if(sysPara){
|
||||
sysPara->sysFile =xmlfileName;
|
||||
snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",xmlfileName.toAscii().constData());
|
||||
}
|
||||
//snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",xmlfileName.toAscii().constData());
|
||||
ui->saveButton->setEnabled(false);
|
||||
emit fileNameChanged(QFileInfo(xmlfileName).fileName());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::on_openfileButton_pressed()
|
||||
{
|
||||
pPicScene->clearSelection();
|
||||
#if 0
|
||||
}
|
||||
#else
|
||||
dialogFileOperation->refreshListView(editMode);
|
||||
dialogFileOperation->exec();
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::on_EditItemButton_pressed()
|
||||
{
|
||||
#if 0
|
||||
|
||||
#else
|
||||
foreach (QGraphicsItem *item, pPicScene->selectedItems())
|
||||
{
|
||||
if(item)
|
||||
{
|
||||
PicTextItem *pTextItem = (PicTextItem *)item;
|
||||
//qDebug()<<"edit Item";
|
||||
//ui->textEdit->setText(pTextItem->toHtml());
|
||||
textEdit->setHtml(pTextItem->toHtml());
|
||||
//切换到textedit的界面
|
||||
emit editItemMode();
|
||||
//stackedWidgetText->setCurrentWidget(ui->pageTextEdit);
|
||||
//stackedWidgetOption->setCurrentWidget(ui->textEditOption);
|
||||
stackedWidgetText->setCurrentIndex(0);
|
||||
stackedWidgetOption->setCurrentIndex(0);
|
||||
ui->saveButton->setEnabled(true);
|
||||
//edit@12-12
|
||||
pPicScene->clearSelection();
|
||||
item->setSelected(true);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::onEditItemDone()
|
||||
{
|
||||
#if 1
|
||||
//stackedWidgetText->setCurrentWidget(ui->fileSceneViewer);
|
||||
//stackedWidgetOption->setCurrentWidget(ui->senceEditOption);
|
||||
stackedWidgetText->setCurrentIndex(3);
|
||||
stackedWidgetOption->setCurrentIndex(1);
|
||||
foreach (QGraphicsItem *item, pPicScene->selectedItems())
|
||||
{
|
||||
if(item)
|
||||
{
|
||||
PicTextItem *pTextItem = (PicTextItem *)item;
|
||||
//qDebug()<<"edit Item done";
|
||||
QFont font = pTextItem->font();
|
||||
font.setLetterSpacing(QFont::AbsoluteSpacing,sysPara->para.textEditCharSpace);
|
||||
pTextItem->setFont(font);
|
||||
pTextItem->setHtml(textEdit->toHtml());
|
||||
onSceneAccepted(pTextItem);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
void SceneEditOption::onCreateSceneImage(QString filePath)
|
||||
{
|
||||
m_CreateImageFlag = true;
|
||||
m_pSavePicScene->clear();
|
||||
onFileOpen(filePath,false);
|
||||
#if 1
|
||||
m_pSavePicScene->clearSelection();
|
||||
QSize size(m_pSavePicScene->itemsBoundingRect().width(),m_pSavePicScene->itemsBoundingRect().height());
|
||||
QImage image(size,QImage::Format_ARGB32);
|
||||
image.fill(0x00ffffff);//填充白色
|
||||
//image.save("./printScene.jpg");//图片
|
||||
QPainter painter(&image);
|
||||
m_pSavePicScene->render(&painter,QRectF(),m_pSavePicScene->itemsBoundingRect());
|
||||
//qDebug()<<"scene rect:"<<pPicScene->itemsBoundingRect();
|
||||
image.save("./printSceneView.png");//图片
|
||||
|
||||
#endif
|
||||
m_CreateImageFlag = false;
|
||||
}
|
||||
|
||||
extern QStringList stringListRecive;
|
||||
|
||||
void SceneEditOption::parseVbfile(QXmlStreamReader &reader) {
|
||||
// int textItemPosX;
|
||||
// int textItemPosY;
|
||||
// textItemPosX = picText->pos().x() - pPicScene->itemsBoundingRect().x();
|
||||
// textItemPosY = picText->pos().y() - pPicScene->itemsBoundingRect().y();
|
||||
float pos_x,pos_y;
|
||||
bool Condition= false ;
|
||||
int CatchStartValue = -1;
|
||||
int CatchValue = -1;
|
||||
while (!reader.atEnd()) {
|
||||
reader.readNext();
|
||||
if (reader.isStartElement()) { // 开始元素
|
||||
QString strElementName = reader.name().toString();
|
||||
if (QString::compare(strElementName, "VBfile") == 0) {
|
||||
//qDebug() << QString::fromLocal8Bit("********** 开始元素<VBfile> ********** ");
|
||||
} else if (QString::compare(strElementName, QString("pointer_x")) == 0) { // 方式一
|
||||
reader.readNext();
|
||||
if (reader.isCharacters()) {
|
||||
pos_x = reader.text().toString().toDouble();
|
||||
//qDebug() << QString("pointer_x:%1").arg(reader.text().toString());
|
||||
}
|
||||
} else if (QString::compare(strElementName, QString("pointer_y")) == 0) { // 方式二
|
||||
pos_y = reader.readElementText().toDouble();
|
||||
//qDebug() << QString("pointer_y:%1").arg(reader.readElementText());
|
||||
}
|
||||
else if (QString::compare(strElementName, QString("Condition")) == 0) {
|
||||
Condition = reader.readElementText().toInt() ? true : false;
|
||||
}
|
||||
else if (QString::compare(strElementName, QString("CatchStartValue")) == 0) {
|
||||
CatchStartValue = reader.readElementText().toInt();
|
||||
}
|
||||
else if (QString::compare(strElementName, QString("CatchValue")) == 0) {
|
||||
CatchValue = reader.readElementText().toInt();
|
||||
}
|
||||
else if (QString::compare(strElementName, QString("html_src")) == 0) {
|
||||
//qDebug() << QString("html_src:%1").arg(reader.readElementText());
|
||||
}
|
||||
} else if (reader.isEntityReference()) { // 实体引用
|
||||
QString strName = reader.name().toString();
|
||||
QString strText = reader.text().toString();
|
||||
//qDebug() << QString("EntityReference : %1(%2)").arg(strName).arg(strText);
|
||||
} else if (reader.isCDATA()) { // CDATA
|
||||
QString strCDATA = reader.text().toString();
|
||||
//qDebug() << QString("CDATA : %1").arg(strCDATA);
|
||||
PicTextItem *pPictText = new PicTextItem();
|
||||
if(m_CreateImageFlag)
|
||||
{
|
||||
m_pSavePicScene->addItem(pPictText);
|
||||
}
|
||||
else
|
||||
{
|
||||
pPicScene->addItem(pPictText);
|
||||
}
|
||||
QFont font = pPictText->font();
|
||||
font.setLetterSpacing(QFont::AbsoluteSpacing,sysPara->para.textEditCharSpace);
|
||||
pPictText->setFont(font);
|
||||
pPictText->setPos(pos_x,pos_y);
|
||||
pPictText->SpecialConditions = Condition;
|
||||
pPictText->CatchCnt1StartValue = CatchStartValue;
|
||||
pPictText->CatchCnt1CurrValue = CatchValue;
|
||||
// Condition= false ;
|
||||
// CatchValue = -1;
|
||||
//LogInfo::setRunStatusText(tr("接收文件解析::2"));
|
||||
if(!sysPara->status.forTemplateUse || m_CreateImageFlag)
|
||||
{
|
||||
pPictText->setHtml(strCDATA);
|
||||
}
|
||||
else
|
||||
{
|
||||
//qDebug() << tr("接收文件解析:");
|
||||
//LogInfo::setRunStatusText(tr("接收文件解析::3"));
|
||||
//stringListRecive << "aaaa" << "bbbb" << "cccc";
|
||||
if(strCDATA.contains("#1111") || strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#01.bmp\" />"))
|
||||
{
|
||||
if(stringListRecive.size() > 0)
|
||||
{
|
||||
if(strCDATA.contains("#1111"))
|
||||
{
|
||||
strCDATA.replace("#1111",stringListRecive.at(0).toStdString().c_str());
|
||||
}
|
||||
else if(strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#01.bmp\" />"))
|
||||
{
|
||||
emit generateQRCode(stringListRecive.at(0));
|
||||
strCDATA.replace("modbusQR#01.bmp","modbusQR.bmp");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if(strCDATA.contains("#2222") || strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#02.bmp\" />"))
|
||||
{
|
||||
if(stringListRecive.size() > 1)
|
||||
{
|
||||
if(strCDATA.contains("#2222"))
|
||||
{
|
||||
strCDATA.replace("#2222",stringListRecive.at(1).toStdString().c_str());
|
||||
}
|
||||
else if(strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#02.bmp\" />"))
|
||||
{
|
||||
emit generateQRCode(stringListRecive.at(1));
|
||||
strCDATA.replace("modbusQR#02.bmp","modbusQR.bmp");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strCDATA.contains("#3333") || strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#03.bmp\" />"))
|
||||
{
|
||||
if(stringListRecive.size() > 2)
|
||||
{
|
||||
if(strCDATA.contains("#3333"))
|
||||
{
|
||||
strCDATA.replace("#3333",stringListRecive.at(2).toStdString().c_str());
|
||||
}
|
||||
else if(strCDATA.contains("<img src=\"/home/plg/doc/modbusQR#03.bmp\" />"))
|
||||
{
|
||||
emit generateQRCode(stringListRecive.at(2));
|
||||
strCDATA.replace("modbusQR#03.bmp","modbusQR.bmp");
|
||||
}
|
||||
}
|
||||
}
|
||||
pPictText->setHtml(strCDATA);
|
||||
}
|
||||
// if(Condition)
|
||||
// {
|
||||
// SpecialVarPrint specialVarPrint;
|
||||
// specialVarPrint.SpecialVarEnable = Condition;
|
||||
// specialVarPrint.SpecialVarCountStart = CatchStartValue;
|
||||
// specialVarPrint.SpecialVarCountEnd = CatchValue;
|
||||
// specialVarPrint.SpecialVarColStart = 3 + pos_x- pPicScene->itemsBoundingRect().x();
|
||||
// specialVarPrint.SpecialVarColEnd = 3 + pos_x - pPicScene->itemsBoundingRect().x()+ pPictText->boundingRect().width();
|
||||
// specialVarPrint.SpecialVarRowStart = pos_y - pPicScene->itemsBoundingRect().y();
|
||||
// specialVarPrint.SpecialVarRowEnd = pos_y - pPicScene->itemsBoundingRect().y()+ pPictText->boundingRect().height();
|
||||
// sysPara->devOp->fpgaWr(0xa4b0,(unsigned char *)&specialVarPrint,sizeof(SpecialVarPrint)); // Send specialVarPrint 2022-8-6
|
||||
// LogInfo::setRunStatusText(tr("发送特殊变量内容:"));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarEnable:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarEnable)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarCountStart:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarCountStart)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarCountEnd:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarCountEnd)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarColStart:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarColStart)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarColEnd:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarColEnd)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarRowStart:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarRowStart)));
|
||||
// LogInfo::setRunStatusText(tr("SpecialVarRowEnd:%1").arg(QString().sprintf("%02X",specialVarPrint.SpecialVarRowEnd)));
|
||||
// LogInfo::setRunStatusText(tr("itemsBoundingRect().y():%1").arg(QString().sprintf("%02X",pPicScene->itemsBoundingRect().y())));
|
||||
// LogInfo::setRunStatusText(tr("itemsBoundingRect().x():%1").arg(QString().sprintf("%02X",pPicScene->itemsBoundingRect().x())));
|
||||
// }
|
||||
Condition= false ;
|
||||
CatchValue = -1;
|
||||
CatchStartValue = -1;
|
||||
|
||||
reader.readNext();
|
||||
if (reader.isCharacters()) {
|
||||
QString strCharacters = reader.text().toString();
|
||||
//qDebug() << QString("Characters : %1").arg(strCharacters);
|
||||
}
|
||||
} else if (reader.isEndElement()) { // 结束元素
|
||||
QString strElementName = reader.name().toString();
|
||||
if (QString::compare(strElementName, "Blogs") == 0) {
|
||||
//qDebug() << QString::fromLocal8Bit("********** 结束元素<Blogs> ********** ");
|
||||
break; // 跳出循环(解析 QXmlStreamReader::EndDocument)
|
||||
} else if (QString::compare(strElementName, "Blog") == 0) {
|
||||
//qDebug() << QString::fromLocal8Bit("********** 结束元素<Blog> ********** ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 和DialogFileOperation对接
|
||||
* */
|
||||
void SceneEditOption::onFileOpen(QString filePath,bool insertFlag){
|
||||
if(editMode==SCENE) {
|
||||
if(filePath.endsWith(".xml"))
|
||||
{
|
||||
QFile file(filePath);
|
||||
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { // 以只写模式打开文件
|
||||
xmlfileName=filePath;
|
||||
QXmlStreamReader reader(&file);
|
||||
if(!m_CreateImageFlag)
|
||||
{
|
||||
pPicScene->clear();
|
||||
pViewer->viewport()->update();
|
||||
unsigned char SpecialVarEnable = 0;
|
||||
sysPara->devOp->fpgaWr(0xa4b0,(unsigned char *)&SpecialVarEnable,1);
|
||||
}
|
||||
// 解析 XML,直到结束
|
||||
while (!reader.atEnd()) {
|
||||
|
||||
// 读取下一个元素
|
||||
QXmlStreamReader::TokenType nType = reader.readNext();
|
||||
|
||||
switch (nType) {
|
||||
case QXmlStreamReader::StartDocument: { // 开始文档
|
||||
//qDebug() << QString::fromLocal8Bit("********** 开始文档(XML 声明) ********** ");
|
||||
// XML 声明
|
||||
QString strVersion = reader.documentVersion().toString();
|
||||
QString strEncoding = reader.documentEncoding().toString();
|
||||
bool bAlone = reader.isStandaloneDocument();
|
||||
//qDebug() << QString::fromLocal8Bit("版本:%1 编码:%2 Standalone:%3")
|
||||
// .arg(strVersion).arg(strEncoding).arg(bAlone) << "\r\n";
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::Comment: { // 注释
|
||||
//qDebug() << QString::fromLocal8Bit("********** 注释 ********** ");
|
||||
QString strComment = reader.text().toString();
|
||||
//qDebug() << strComment << "\r\n";
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::ProcessingInstruction: { // 处理指令
|
||||
//qDebug() << QString::fromLocal8Bit("********** 处理指令 ********** ");
|
||||
QString strProcInstr = reader.processingInstructionData().toString();
|
||||
//qDebug() << strProcInstr << "\r\n";
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::DTD: { // DTD
|
||||
//qDebug() << QString::fromLocal8Bit("********** DTD ********** ");
|
||||
QString strDTD = reader.text().toString();
|
||||
QXmlStreamNotationDeclarations notationDeclarations = reader.notationDeclarations(); // 符号声明
|
||||
QXmlStreamEntityDeclarations entityDeclarations = reader.entityDeclarations(); // 实体声明
|
||||
// DTD 声明
|
||||
QString strDTDName = reader.dtdName().toString();
|
||||
QString strDTDPublicId = reader.dtdPublicId().toString(); // DTD 公开标识符
|
||||
QString strDTDSystemId = reader.dtdSystemId().toString(); // DTD 系统标识符
|
||||
//qDebug() << QString::fromLocal8Bit("DTD : %1").arg(strDTD);
|
||||
//qDebug() << QString::fromLocal8Bit("DTD 名称 : %1").arg(strDTDName);
|
||||
//qDebug() << QString::fromLocal8Bit("DTD 公开标识符 : %1").arg(strDTDPublicId);
|
||||
//qDebug() << QString::fromLocal8Bit("DTD 系统标识符 : %1").arg(strDTDSystemId);
|
||||
//qDebug() << "\r\n";
|
||||
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::StartElement: { // 开始元素
|
||||
QString strElementName = reader.name().toString();
|
||||
if (QString::compare(strElementName, "VBfiles") == 0) { // 根元素
|
||||
//qDebug() << QString::fromLocal8Bit("********** 开始元素<VBfiles> ********** ");
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
if (attributes.hasAttribute("Version")) {
|
||||
QString strVersion = attributes.value("Version").toString();
|
||||
//qDebug() << QString::fromLocal8Bit("属性:Version(%1)").arg(strVersion);
|
||||
}
|
||||
|
||||
parseVbfile(reader);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QXmlStreamReader::EndDocument: { // 结束文档
|
||||
//qDebug() << QString::fromLocal8Bit("********** 结束文档 ********** ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (reader.hasError()) { // 解析出错
|
||||
//qDebug() << QString::fromLocal8Bit("错误信息:%1 行号:%2 列号:%3 字符位移:%4").arg(reader.errorString()).arg(reader.lineNumber()).arg(reader.columnNumber()).arg(reader.characterOffset());
|
||||
}
|
||||
//qDebug()<<"open done";
|
||||
file.close(); // 关闭文件
|
||||
//snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",filePath.toAscii().constData());
|
||||
if(!m_CreateImageFlag)//生成图片显示
|
||||
{
|
||||
if(sysPara)
|
||||
{
|
||||
sysPara->sysFile =filePath;
|
||||
sysPara->loadParaFromFile();
|
||||
//qDebug()<<"textedit txt mode onFileOpen" << sysPara->sysFile;
|
||||
snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",filePath.toAscii().constData());
|
||||
}
|
||||
|
||||
emit fileNameChanged(QFileInfo(xmlfileName).fileName());
|
||||
ui->saveButton->setEnabled(false);
|
||||
QList<QGraphicsItem *> items = pPicScene->items();
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
PicTextItem *picText = qgraphicsitem_cast<PicTextItem*>(item);
|
||||
onSceneAccepted(picText);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void SceneEditOption::saveFile(){
|
||||
#if 1
|
||||
//qDebug()<<"SceneEditOption save scene start";
|
||||
//QList<QGraphicsItem *> itemList = pPicScene->items();
|
||||
//qDebug()<<"xmlfileName:"<< xmlfileName;
|
||||
|
||||
QFile file(xmlfileName);
|
||||
if (!file.open(QFile::WriteOnly | QFile::Text)) { // 只写模式打开文件
|
||||
qDebug() << QString("Cannot write file %1(%2).").arg(xmlfileName).arg(file.errorString());
|
||||
return;
|
||||
}
|
||||
//qDebug()<<"open xmlfileName successfull";
|
||||
|
||||
QXmlStreamWriter writer(&file);
|
||||
|
||||
// writer.setCodec("GBK"); // XML 编码
|
||||
writer.setAutoFormatting(true); // 自动格式化
|
||||
writer.writeStartDocument("1.0", true); // 开始文档(XML 声明)
|
||||
writer.writeComment(QString::fromLocal8Bit("Vernon Bach graphic scene file")); // 注释
|
||||
//writer.writeProcessingInstruction("xml-stylesheet type=\"text/css\" href=\"style.css\""); // 处理指令
|
||||
|
||||
// DTD <!ELEMENT VBfiles (VBfile) >
|
||||
writer.writeDTD(QString::fromLocal8Bit("<!DOCTYPE VBfiles [ <!ELEMENT VBfiles (VBfile) > <!ELEMENT VBfile (pointer_x,pointer_y,html_src)> <!ELEMENT pointer_x (#PCDATA)><!ELEMENT pointer_y (#PCDATA)><!ELEMENT html_src (#PCDATA)> ]>"));
|
||||
//writer.writeDTD(QString::fromLocal8Bit("<!DOCTYPE Blogs [ <!ENTITY Copyright \"Copyright 2016《Qt实战一二三》\"> <!ELEMENT Blogs (Blog)> <!ELEMENT Blog (作者,主页,个人说明)> <!ELEMENT 作者 (#PCDATA)> <!ELEMENT 主页 (#PCDATA)> <!ELEMENT 个人说明 (#PCDATA)> ]>"));
|
||||
|
||||
writer.writeStartElement("VBfiles"); // 开始根元素 <picscene>
|
||||
writer.writeAttribute("Version", "1.0"); // 属性
|
||||
|
||||
QList<QGraphicsItem *> items = pPicScene->items();
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
PicTextItem *picText = qgraphicsitem_cast<PicTextItem*>(item);
|
||||
//qDebug()<<"item position: "<< picText->pos();
|
||||
writer.writeStartElement("VBfile"); // 开始子元素 <picscene>
|
||||
writer.writeTextElement(QString::fromLocal8Bit("pointer_x"), QString::fromLocal8Bit("%1").arg(picText->pos().x()));
|
||||
writer.writeTextElement(QString::fromLocal8Bit("pointer_y"), QString::fromLocal8Bit("%1").arg(picText->pos().y()));
|
||||
writer.writeTextElement(QString::fromLocal8Bit("Condition"), QString::fromLocal8Bit("%1").arg(picText->SpecialConditions? 1:0));
|
||||
writer.writeTextElement(QString::fromLocal8Bit("CatchStartValue"), QString::fromLocal8Bit("%1").arg(picText->CatchCnt1StartValue));
|
||||
writer.writeTextElement(QString::fromLocal8Bit("CatchValue"), QString::fromLocal8Bit("%1").arg(picText->CatchCnt1CurrValue));
|
||||
//writer.writeEntityReference("Copyright");
|
||||
//writer.writeCDATA(QString::fromLocal8Bit("html code"));
|
||||
writer.writeTextElement(QString::fromLocal8Bit("html_src"), QString::fromLocal8Bit("my_src"));
|
||||
writer.writeCDATA((picText->toHtml()));
|
||||
//qDebug()<<"tohtml"<<picText->toHtml();
|
||||
//writer.writeCharacters(">");
|
||||
//writer.writeEmptyElement(QString::fromLocal8Bit("Empty")); // 空元素
|
||||
writer.writeEndElement(); // 结束子元素 </picscene>
|
||||
}
|
||||
|
||||
writer.writeEndElement(); // 结束根元素 </picscenes>
|
||||
writer.writeEndDocument(); // 结束文档
|
||||
//qDebug()<<"sceneEditOption save done";
|
||||
//#if defined(__CONVERTERBOARD__)|| defined(__VX__)
|
||||
#if 1
|
||||
fsync(file.handle());
|
||||
#endif
|
||||
file.close(); // 关闭文件
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void SceneEditOption::onSaveASFile(QString filename,bool Flag){// use for dialogSaveFile class
|
||||
qDebug()<<filename;
|
||||
xmlfileName = filename;
|
||||
if(!filename.endsWith(".xml",Qt::CaseInsensitive))
|
||||
xmlfileName += ".xml";
|
||||
|
||||
saveFile();
|
||||
if(sysPara){
|
||||
sysPara->sysFile =xmlfileName;
|
||||
snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",xmlfileName.toAscii().constData());
|
||||
}
|
||||
//snprintf(sysPara->para.lastOpenedFileName,sizeof(sysPara->para.lastOpenedFileName),"%s",xmlfileName.toAscii().constData());
|
||||
ui->saveButton->setEnabled(false);
|
||||
emit fileNameChanged(QFileInfo(xmlfileName).fileName());
|
||||
}
|
||||
void SceneEditOption::on_enlargeButton_pressed()
|
||||
{
|
||||
((MyView*)pViewer)->ZoomOut();
|
||||
}
|
||||
void SceneEditOption::on_reduceButton_pressed()
|
||||
{
|
||||
((MyView*)pViewer)->ZoomIn();
|
||||
}
|
||||
|
||||
void SceneEditOption::onSceneAccepted(PicTextItem *pTextItem){
|
||||
//dialogLineSpace->getValue(&sysPara->para.textEditLineSpace,&sysPara->para.textEditCharSpace);
|
||||
for(QTextBlock textBlock = pTextItem->document()->begin();textBlock != pTextItem->document()->end(); textBlock = textBlock.next()){
|
||||
// textBlock.setVisible(false);
|
||||
QTextBlockFormat textBlockFormat = textBlock.blockFormat();
|
||||
textBlockFormat.setAlignment(Qt::AlignTop);
|
||||
textBlockFormat.setTopMargin(-1);
|
||||
//textBlockFormat.setLineHeight(sysPara->para.fontPixelSize + sysPara->para.textEditLineSpace, QTextBlockFormat::FixedHeight);
|
||||
//textBlockFormat.setLineHeight(0, QTextBlockFormat::LineDistanceHeight);
|
||||
textBlockFormat.setBottomMargin(sysPara->para.textEditLineSpace-1);
|
||||
//textBlockFormat.setBottomMargin(-1);
|
||||
QTextCursor textCursor = pTextItem->textCursor();
|
||||
textCursor.setPosition(textBlock.position());
|
||||
textCursor.setBlockFormat(textBlockFormat);
|
||||
pTextItem->setTextCursor(textCursor);
|
||||
}
|
||||
|
||||
// QTextCharFormat fmt;
|
||||
// //fmt.setFontWordSpacing(sysPara->para.textEditCharSpace);
|
||||
// fmt.setFontLetterSpacing(sysPara->para.textEditCharSpace); qDebug() << sysPara->para.textEditCharSpace;
|
||||
// mergeFormatOnWordOrSelection(fmt);
|
||||
QFont font = pTextItem->font();
|
||||
font.setLetterSpacing(QFont::AbsoluteSpacing,sysPara->para.textEditCharSpace);
|
||||
pTextItem->setFont(font);
|
||||
sysPara->saveParaToFile();
|
||||
}
|
||||
|
||||
//edit@12-10
|
||||
void SceneEditOption::on_test_pressed()
|
||||
{
|
||||
const QPoint originScene=pViewer->mapFromScene(0,0);
|
||||
const QRectF sceneRect=pPicScene->sceneRect();
|
||||
const QRectF BoundingRect=pPicScene->itemsBoundingRect();
|
||||
qDebug()<<QString("originScene=(%1,%2)").arg(originScene.x()).arg(originScene.y())<<",sceneRect="<<sceneRect<<",BoundingRect="<<BoundingRect;
|
||||
qDebug()<<"pViewer-geometry="<<pViewer->geometry();
|
||||
qreal bottom=0;
|
||||
bool isTextItem=true;
|
||||
foreach (const QGraphicsItem *item, pPicScene->items()) {
|
||||
if(item->sceneBoundingRect().bottom()>bottom)
|
||||
{
|
||||
bottom=item->sceneBoundingRect().bottom();
|
||||
isTextItem=-1==((QGraphicsTextItem*)item)->toHtml().indexOf("img ",0,Qt::CaseInsensitive)?true:false;
|
||||
}
|
||||
qDebug()<<"item-pos="<<item->pos()
|
||||
<<", isSelected="<<item->isSelected()
|
||||
<<", text="<<((QGraphicsTextItem*)item)->toPlainText()
|
||||
//<<", html="<<((QGraphicsTextItem*)item)->toHtml()
|
||||
<<", type="<<(-1==((QGraphicsTextItem*)item)->toHtml().indexOf("img ",0,Qt::CaseInsensitive)?true:false)
|
||||
<<", button-pos="<<item->sceneBoundingRect().bottom()
|
||||
;
|
||||
}
|
||||
qDebug()<<"bottom="<<bottom<<", isTextItem="<<isTextItem;
|
||||
|
||||
int value=pViewer->horizontalScrollBar()->value();
|
||||
qDebug()<<"pViewer-horizontalScrollBar-value="<<value;
|
||||
|
||||
pPicScene->update();
|
||||
pViewer->update();
|
||||
}
|
||||
//edit@12-10
|
||||
void SceneEditOption::on_btn_test2()
|
||||
{
|
||||
const QPoint originScene=pViewer->mapFromScene(0,0);
|
||||
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=pViewer->mapToScene(oldpos.x()-left,oldpos.y()-top);
|
||||
oldpos=QPointF(oldpos.x()-left,oldpos.y()-(top-pViewer->mapToScene(0,0).y()));
|
||||
item->setPos(oldpos);
|
||||
}
|
||||
pPicScene->update();
|
||||
}
|
||||
|
||||
void SceneEditOption::onInkJetPrinterCurrentChanged(int index)
|
||||
{
|
||||
if(SCENE==sysPara->para.EditMode)
|
||||
{
|
||||
if(0==index)//edit@12-14 mainwindow tab
|
||||
{
|
||||
onStackedWidgetOptionCurrentChanged(1);
|
||||
}
|
||||
else //edit@12-14 other tabs
|
||||
{
|
||||
onStackedWidgetOptionCurrentChanged(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user