Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
qplanetosm
提交
ac3511ed
qplanetosm
项目概览
colorEagleStdio
/
qplanetosm
通知
119
Star
10
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qplanetosm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
ac3511ed
编写于
2月 08, 2016
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add save and load icon function.
上级
2b33ba4d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
222 addition
and
6 deletion
+222
-6
qtvplugin_geomarker/qtvplugin_geomarker.h
qtvplugin_geomarker/qtvplugin_geomarker.h
+5
-0
qtvplugin_geomarker/qtvplugin_geomarker.ui
qtvplugin_geomarker/qtvplugin_geomarker.ui
+35
-4
qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp
qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp
+40
-2
qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp
qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp
+142
-0
未找到文件。
qtvplugin_geomarker/qtvplugin_geomarker.h
浏览文件 @
ac3511ed
...
...
@@ -103,6 +103,9 @@ private:
bool
xml_readProps
(
QXmlStreamReader
&
reader
,
tag_xml_mark
&
mark
,
QString
&
errMsg
);
QMap
<
QString
,
QString
>
xml_attribs_map
(
const
QXmlStreamAttributes
&
ats
);
bool
xml_icon_save
(
QString
xml
);
bool
xml_icon_load
(
QString
xml
);
//UI refreshing functions
private:
void
scheduleRefreshMarks
();
...
...
@@ -180,6 +183,8 @@ protected slots:
void
on_pushButton_save_clicked
();
void
on_pushButton_load_clicked
();
void
on_pushButton_import_icon_clicked
();
void
on_pushButton_load_icons_clicked
();
void
on_pushButton_save_icons_clicked
();
};
template
<
class
T
>
...
...
qtvplugin_geomarker/qtvplugin_geomarker.ui
浏览文件 @
ac3511ed
...
...
@@ -6,8 +6,8 @@
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
505
</width>
<height>
4
26
</height>
<width>
446
</width>
<height>
4
44
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
...
...
@@ -174,7 +174,7 @@
<number>
0
</number>
</property>
<property
name=
"currentIndex"
>
<number>
0
</number>
<number>
3
</number>
</property>
<widget
class=
"QWidget"
name=
"page_points"
>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
...
...
@@ -461,7 +461,7 @@
<item>
<widget
class=
"QPushButton"
name=
"pushButton_import_icon"
>
<property
name=
"text"
>
<string>
import
</string>
<string>
add
</string>
</property>
</widget>
</item>
...
...
@@ -515,6 +515,37 @@
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_20"
>
<item>
<spacer
name=
"horizontalSpacer_3"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
40
</width>
<height>
20
</height>
</size>
</property>
</spacer>
</item>
<item>
<widget
class=
"QPushButton"
name=
"pushButton_load_icons"
>
<property
name=
"text"
>
<string>
load
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"pushButton_save_icons"
>
<property
name=
"text"
>
<string>
save
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
...
...
qtvplugin_geomarker/qtvplugin_geomarker_uimethods.cpp
浏览文件 @
ac3511ed
...
...
@@ -659,7 +659,7 @@ void qtvplugin_geomarker::on_pushButton_save_clicked()
if
(
true
==
xml_save
(
newfm
))
{
settings
.
setValue
(
"history/last_save_xml_dir"
,
newfm
);
QMessageBox
::
information
(
this
,
tr
(
"succeed"
),
tr
(
"Successfully saved XML file"
)
+
newfm
);
//
QMessageBox::information(this,tr("succeed"),tr("Successfully saved XML file") + newfm);
}
else
QMessageBox
::
warning
(
this
,
tr
(
"failed"
),
tr
(
"Save XML file"
)
+
newfm
+
tr
(
" Failed"
));
...
...
@@ -678,7 +678,7 @@ void qtvplugin_geomarker::on_pushButton_load_clicked()
if
(
true
==
xml_load
(
newfm
))
{
settings
.
setValue
(
"history/last_open_xml_dir"
,
newfm
);
QMessageBox
::
information
(
this
,
tr
(
"succeed"
),
tr
(
"Successfully load XML file"
)
+
newfm
);
//
QMessageBox::information(this,tr("succeed"),tr("Successfully load XML file") + newfm);
}
else
QMessageBox
::
warning
(
this
,
tr
(
"failed"
),
tr
(
"Load XML file"
)
+
newfm
+
tr
(
" Failed"
));
...
...
@@ -696,3 +696,41 @@ void qtvplugin_geomarker::on_pushButton_import_icon_clicked()
refreshIconModel
();
}
}
void
qtvplugin_geomarker
::
on_pushButton_load_icons_clicked
()
{
QSettings
settings
(
ini_file
(),
QSettings
::
IniFormat
);
QString
strLastSaveImgDir
=
settings
.
value
(
"history/last_load_icon_xml_dir"
,
"./"
).
toString
();
QString
newfm
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"load from xml"
),
strLastSaveImgDir
,
"xml (*.xml);;All files(*.*)"
);
if
(
newfm
.
size
()
>
2
)
{
if
(
true
==
xml_icon_load
(
newfm
))
{
settings
.
setValue
(
"history/last_load_icon_xml_dir"
,
newfm
);
//QMessageBox::information(this,tr("succeed"),tr("Successfully load XML file") + newfm);
}
else
QMessageBox
::
warning
(
this
,
tr
(
"failed"
),
tr
(
"Load XML file"
)
+
newfm
+
tr
(
" Failed"
));
}
this
->
refreshIconModel
();
}
void
qtvplugin_geomarker
::
on_pushButton_save_icons_clicked
()
{
QSettings
settings
(
ini_file
(),
QSettings
::
IniFormat
);
QString
strLastSaveImgDir
=
settings
.
value
(
"history/last_save_icon_xml_dir"
,
"./"
).
toString
();
QString
newfm
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"save to xml"
),
strLastSaveImgDir
,
"xml (*.xml);;All files(*.*)"
);
if
(
newfm
.
size
()
>
2
)
{
if
(
true
==
xml_icon_save
(
newfm
))
{
settings
.
setValue
(
"history/last_save_icon_xml_dir"
,
newfm
);
//QMessageBox::information(this,tr("succeed"),tr("Successfully saved XML file") + newfm);
}
else
QMessageBox
::
warning
(
this
,
tr
(
"failed"
),
tr
(
"Save XML file"
)
+
newfm
+
tr
(
" Failed"
));
}
}
qtvplugin_geomarker/qtvplugin_geomarker_xml.cpp
浏览文件 @
ac3511ed
...
...
@@ -9,6 +9,7 @@
#include <QDebug>
#include <QXmlStreamAttributes>
#include <QMap>
#include <QFileInfo>
bool
qtvplugin_geomarker
::
xml_save
(
QString
xml
)
{
QFile
fp
(
xml
);
...
...
@@ -464,3 +465,144 @@ bool qtvplugin_geomarker::xml_update_mark(tag_xml_mark & mark)
return
true
;
}
bool
qtvplugin_geomarker
::
xml_icon_save
(
QString
xml
)
{
QFile
fp
(
xml
);
QFileInfo
smlinfo
(
xml
);
if
(
fp
.
open
(
QIODevice
::
WriteOnly
)
==
false
)
return
false
;
QXmlStreamWriter
stream
(
&
fp
);
stream
.
setAutoFormatting
(
true
);
//0. Start Document
stream
.
writeStartDocument
();
stream
.
writeStartElement
(
"geomarker_icons"
);
stream
.
writeAttribute
(
"version"
,
"1.0"
);
//1. for each icon, write a root element
QList
<
QString
>
keys
=
m_map_icons
.
keys
();
foreach
(
QString
keystr
,
keys
)
{
const
QTVP_GEOMARKER
::
tag_icon
&
item
=
m_map_icons
[
keystr
];
//1.1. icon
stream
.
writeStartElement
(
"icon"
);
stream
.
writeAttribute
(
"name"
,
item
.
name
);
//1.1.1 center
stream
.
writeTextElement
(
"centerx"
,
QString
(
"%1"
).
arg
(
item
.
centerx
));
stream
.
writeTextElement
(
"centery"
,
QString
(
"%1"
).
arg
(
item
.
centery
));
QString
fmSave
=
smlinfo
.
absoluteFilePath
()
+
"_"
+
item
.
name
+
".png"
;
QString
fmRel
=
item
.
name
+
".png"
;
stream
.
writeTextElement
(
"filename"
,
fmRel
);
item
.
icon
.
save
(
fmSave
);
// 1.1mark
stream
.
writeEndElement
();
}
stream
.
writeEndElement
();
//0. End Document
stream
.
writeEndDocument
();
fp
.
flush
();
fp
.
close
();
return
true
;
}
bool
qtvplugin_geomarker
::
xml_icon_load
(
QString
xmlfile
)
{
bool
res
=
true
;
QString
errMessage
;
QFile
fp
(
xmlfile
);
QFileInfo
smlinfo
(
xmlfile
);
if
(
fp
.
open
(
QIODevice
::
ReadOnly
)
==
false
)
return
false
;
QXmlStreamReader
xml
(
&
fp
);
if
(
xml
.
readNextStartElement
())
{
if
(
xml
.
name
()
==
"geomarker_icons"
)
{
QMap
<
QString
,
QString
>
att_geoMarker
=
xml_attribs_map
(
xml
.
attributes
());
if
(
att_geoMarker
[
"version"
].
toDouble
()
>=
1
)
{
while
(
!
xml
.
atEnd
()
&&
res
)
{
xml
.
readNext
();
if
(
xml
.
tokenType
()
==
QXmlStreamReader
::
StartElement
)
{
if
(
xml
.
name
()
==
"icon"
)
{
QTVP_GEOMARKER
::
tag_icon
icon
;
//icon
QMap
<
QString
,
QString
>
att_marker
=
xml_attribs_map
(
xml
.
attributes
());
icon
.
name
=
att_marker
[
"name"
];
if
(
icon
.
name
.
size
()
==
0
)
{
errMessage
=
tr
(
"icon name is null or type error ."
);
res
=
false
;
}
else
{
while
(
xml
.
readNextStartElement
()
&&
res
)
{
if
(
xml
.
name
()
==
"centerx"
)
{
icon
.
centerx
=
xml
.
readElementText
().
toInt
();
}
else
if
(
xml
.
name
()
==
"centery"
)
{
icon
.
centery
=
xml
.
readElementText
().
toInt
();
}
else
if
(
xml
.
name
()
==
"filename"
)
{
QString
fm
=
xml
.
readElementText
();
QString
fmOpen
=
smlinfo
.
absoluteFilePath
()
+
"_"
+
fm
;
if
(
icon
.
icon
.
load
(
fmOpen
)
==
false
)
res
=
false
;
else
icon
.
filename
=
fmOpen
;
}
else
;
}
//end while next start element
if
(
res
)
m_map_icons
[
icon
.
name
]
=
icon
;
}
//end if name is valide
}
//end if ele is "icon:"
}
//end if start Doc
}
//end while is not end of file
}
else
{
res
=
false
;
errMessage
=
tr
(
"Version must >=1.0."
);
}
}
//end if version is valid
else
{
res
=
false
;
errMessage
=
tr
(
"This XML is not a geomarker_icons format file."
);
}
// version is not valis
}
//end if file is not empty
else
{
res
=
false
;
errMessage
=
tr
(
"Empty XML."
);
}
fp
.
close
();
if
(
res
==
false
)
{
QMap
<
QString
,
QVariant
>
evt_error
;
evt_error
[
"source"
]
=
get_name
();
evt_error
[
"destin"
]
=
"ALL"
;
evt_error
[
"name"
]
=
"error"
;
evt_error
[
"class"
]
=
"QXmlStreamReader"
;
evt_error
[
"file"
]
=
xmlfile
;
evt_error
[
"detail"
]
=
errMessage
;
m_pVi
->
post_event
(
evt_error
);
}
return
res
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录