Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Marble
Commits
37977619
Commit
37977619
authored
Apr 16, 2013
by
Adrian Draghici
Committed by
Dennis Nienhüser
Apr 16, 2013
Browse files
KML Editor Dock Widget
REVIEW: 110019
BUG: 317791
parent
ea4fbd5f
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/QtMainWindow.cpp
View file @
37977619
...
...
@@ -149,6 +149,7 @@ MainWindow::MainWindow(const QString& marbleDataPath, const QVariantMap& cmdLine
createStatusBar
();
if
(
!
smallscreen
)
{
createDockWidgets
();
createPluginDockWidgets
();
}
connect
(
m_controlView
->
marbleWidget
(),
SIGNAL
(
themeChanged
(
QString
)),
...
...
@@ -605,6 +606,23 @@ void MainWindow::createPluginMenus()
// FIXME: load the menus once the method has been settled on
}
void
MainWindow
::
createPluginDockWidgets
()
{
QList
<
RenderPlugin
*>
renderPluginList
=
m_controlView
->
marbleWidget
()
->
renderPlugins
();
QList
<
RenderPlugin
*>::
const_iterator
i
=
renderPluginList
.
constBegin
();
QList
<
RenderPlugin
*>::
const_iterator
const
end
=
renderPluginList
.
constEnd
();
for
(;
i
!=
end
;
++
i
)
{
QDockWidget
*
dock
=
(
*
i
)
->
createDockWidget
();
if
(
dock
)
{
dock
->
setParent
(
marbleWidget
()
);
this
->
addDockWidget
(
Qt
::
LeftDockWidgetArea
,
dock
);
m_panelMenu
->
addAction
(
dock
->
toggleViewAction
()
);
}
}
}
void
MainWindow
::
createStatusBar
()
{
statusBar
()
->
showMessage
(
tr
(
"Ready"
));
...
...
src/QtMainWindow.h
View file @
37977619
...
...
@@ -107,6 +107,7 @@ private Q_SLOTS:
void
lockPosition
(
bool
);
void
createPluginsMenus
();
void
createPluginMenus
();
void
createPluginDockWidgets
();
void
showClouds
(
bool
);
void
controlSun
();
void
controlTime
();
...
...
src/lib/BranchFilterProxyModel.h
View file @
37977619
...
...
@@ -18,7 +18,7 @@
namespace
Marble
{
class
BranchFilterProxyModel
:
public
QSortFilterProxyModel
class
MARBLE_EXPORT
BranchFilterProxyModel
:
public
QSortFilterProxyModel
{
public:
explicit
BranchFilterProxyModel
(
QObject
*
parent
=
0
);
...
...
src/lib/RenderPlugin.cpp
View file @
37977619
...
...
@@ -103,6 +103,11 @@ const QList<QActionGroup*>* RenderPlugin::toolbarActionGroups() const
return
0
;
}
QDockWidget
*
RenderPlugin
::
createDockWidget
()
{
return
0
;
}
QStandardItem
*
RenderPlugin
::
item
()
{
d
->
m_item
.
setIcon
(
icon
()
);
...
...
src/lib/RenderPlugin.h
View file @
37977619
...
...
@@ -25,6 +25,7 @@
class
QAction
;
class
QActionGroup
;
class
QStandardItem
;
class
QDockWidget
;
namespace
Marble
{
...
...
@@ -125,6 +126,16 @@ class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
*/
virtual
const
QList
<
QActionGroup
*>*
toolbarActionGroups
()
const
;
/**
* @brief Creating a dock widget using plugin specific actions
*
* This method return a dock widget containing the specific actions for
* the plugin or 0 if a dock widget is not needed.
*
* @return a dock widget defined by the plugin
*/
virtual
QDockWidget
*
createDockWidget
();
/**
* @brief is enabled
*
...
...
@@ -136,6 +147,7 @@ class MARBLE_EXPORT RenderPlugin : public QObject, public RenderPluginInterface
* @return enableability of the plugin
* @see setEnabled
*/
bool
enabled
()
const
;
/**
...
...
src/plugins/render/annotate/AnnotatePlugin.cpp
View file @
37977619
...
...
@@ -28,6 +28,7 @@
#include "MarbleModel.h"
#include "MarbleWidget.h"
#include "PlacemarkTextAnnotation.h"
#include "BranchFilterProxyModel.h"
#include <QtGui/QFileDialog>
#include <QtGui/QAction>
...
...
@@ -35,6 +36,10 @@
#include <QtNetwork/QNetworkReply>
#include <QtNetwork/QNetworkRequest>
#include <QtGui/QMessageBox>
#include <QtGui/QTreeView>
#include <QtGui/QDockWidget>
#include <QtGui/QToolBar>
#include <QtGui/QVBoxLayout>
namespace
Marble
{
...
...
@@ -43,6 +48,8 @@ AnnotatePlugin::AnnotatePlugin( const MarbleModel *model )
:
RenderPlugin
(
model
),
m_widgetInitialized
(
false
),
m_marbleWidget
(
0
),
m_treeView
(
0
),
m_treeViewModel
(
0
),
m_annotationDocument
(
new
GeoDataDocument
),
m_polygon_placemark
(
0
),
m_selectedItem
(
0
),
...
...
@@ -168,7 +175,36 @@ const QList<QActionGroup*>* AnnotatePlugin::actionGroups() const
const
QList
<
QActionGroup
*>*
AnnotatePlugin
::
toolbarActionGroups
()
const
{
return
&
m_toolbarActions
;
return
0
;
}
QDockWidget
*
AnnotatePlugin
::
createDockWidget
()
{
QDockWidget
*
dockWidget
=
new
QDockWidget
(
tr
(
"KML Editor"
)
);
dockWidget
->
setObjectName
(
QString
(
"annotateDock"
)
);
dockWidget
->
setAllowedAreas
(
Qt
::
LeftDockWidgetArea
|
Qt
::
RightDockWidgetArea
);
QToolBar
*
toolbar
=
new
QToolBar
(
dockWidget
);
toolbar
->
setObjectName
(
QString
(
"annotateDockToolbar"
)
);
setupActions
();
foreach
(
QActionGroup
*
ag
,
m_toolbarActions
)
{
toolbar
->
addActions
(
ag
->
actions
()
);
}
Q_ASSERT
(
!
m_treeView
);
m_treeView
=
new
QTreeView
;
QVBoxLayout
*
layout
=
new
QVBoxLayout
;
layout
->
addWidget
(
toolbar
);
layout
->
addWidget
(
m_treeView
);
layout
->
setContentsMargins
(
0
,
0
,
0
,
0
);
QWidget
*
container
=
new
QWidget
;
container
->
setLayout
(
layout
);
dockWidget
->
setWidget
(
container
);
return
dockWidget
;
}
bool
AnnotatePlugin
::
render
(
GeoPainter
*
painter
,
ViewportParams
*
viewport
,
const
QString
&
renderPos
,
GeoSceneLayer
*
layer
)
...
...
@@ -189,11 +225,11 @@ void AnnotatePlugin::enableModel( bool enabled )
{
if
(
enabled
)
{
if
(
m_marbleWidget
)
{
setupActions
(
m_marbleWidget
);
m_marbleWidget
->
model
()
->
treeModel
()
->
addDocument
(
m_annotationDocument
);
GeoDataTreeModel
*
treeModel
=
m_marbleWidget
->
model
()
->
treeModel
();
treeModel
->
addDocument
(
m_annotationDocument
);
m_treeViewModel
->
setBranchIndex
(
treeModel
,
treeModel
->
index
(
m_annotationDocument
)
);
}
}
else
{
setupActions
(
0
);
if
(
m_marbleWidget
)
{
m_marbleWidget
->
model
()
->
treeModel
()
->
removeDocument
(
m_annotationDocument
);
}
...
...
@@ -319,9 +355,11 @@ void AnnotatePlugin::clearAnnotations()
m_polygon_placemark
=
0
;
qDeleteAll
(
m_graphicsItems
);
m_graphicsItems
.
clear
();
m_marbleWidget
->
model
()
->
treeModel
()
->
removeDocument
(
m_annotationDocument
);
GeoDataTreeModel
*
treeModel
=
m_marbleWidget
->
model
()
->
treeModel
();
treeModel
->
removeDocument
(
m_annotationDocument
);
m_annotationDocument
->
clear
();
m_marbleWidget
->
model
()
->
treeModel
()
->
addDocument
(
m_annotationDocument
);
treeModel
->
addDocument
(
m_annotationDocument
);
m_treeViewModel
->
setBranchIndex
(
treeModel
,
treeModel
->
index
(
m_annotationDocument
)
);
}
}
...
...
@@ -397,8 +435,13 @@ bool AnnotatePlugin::eventFilter(QObject* watched, QEvent* event)
MarbleWidget
*
marbleWidget
=
qobject_cast
<
MarbleWidget
*>
(
watched
);
if
(
marbleWidget
)
{
m_marbleWidget
=
marbleWidget
;
setupActions
(
marbleWidget
);
m_marbleWidget
->
model
()
->
treeModel
()
->
addDocument
(
m_annotationDocument
);
GeoDataTreeModel
*
treeModel
=
m_marbleWidget
->
model
()
->
treeModel
();
Q_ASSERT
(
!
m_treeViewModel
);
m_treeViewModel
=
new
BranchFilterProxyModel
;
m_treeViewModel
->
setSourceModel
(
treeModel
);
m_treeViewModel
->
setBranchIndex
(
treeModel
,
treeModel
->
index
(
m_annotationDocument
)
);
m_treeView
->
setModel
(
m_treeViewModel
);
m_widgetInitialized
=
true
;
}
}
...
...
@@ -450,7 +493,7 @@ bool AnnotatePlugin::eventFilter(QObject* watched, QEvent* event)
const
int
result
=
QMessageBox
::
question
(
m_marbleWidget
,
QObject
::
tr
(
"Remove current item"
),
QObject
::
tr
(
"Are you sure you want to remove the current item?"
),
QMessageBox
::
Yes
|
QMessageBox
::
Yes
);
QMessageBox
::
Yes
|
QMessageBox
::
No
);
if
(
result
==
QMessageBox
::
Yes
)
{
m_selectedItem
=
0
;
...
...
@@ -506,103 +549,91 @@ bool AnnotatePlugin::eventFilter(QObject* watched, QEvent* event)
return
false
;
}
void
AnnotatePlugin
::
setupActions
(
MarbleWidget
*
widget
)
void
AnnotatePlugin
::
setupActions
()
{
qDeleteAll
(
m_actions
);
m_actions
.
clear
();
m_toolbarActions
.
clear
();
if
(
widget
)
{
QActionGroup
*
group
=
new
QActionGroup
(
0
);
group
->
setExclusive
(
false
);
QActionGroup
*
nonExclusiveGroup
=
new
QActionGroup
(
0
);
nonExclusiveGroup
->
setExclusive
(
false
);
QAction
*
enableInputAction
=
new
QAction
(
this
);
enableInputAction
->
setToolTip
(
tr
(
"Enable Moving Map"
));
enableInputAction
->
setCheckable
(
true
);
enableInputAction
->
setChecked
(
true
);
enableInputAction
->
setIcon
(
QIcon
(
":/icons/hand.png"
)
);
connect
(
enableInputAction
,
SIGNAL
(
toggled
(
bool
)),
widget
,
SLOT
(
setInputEnabled
(
bool
))
);
QAction
*
addPlacemark
=
new
QAction
(
this
);
addPlacemark
->
setToolTip
(
tr
(
"Add Placemark"
)
);
addPlacemark
->
setCheckable
(
true
);
addPlacemark
->
setIcon
(
QIcon
(
":/icons/draw-placemark.png"
)
);
connect
(
addPlacemark
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setAddingPlacemark
(
bool
))
);
connect
(
this
,
SIGNAL
(
placemarkAdded
())
,
addPlacemark
,
SLOT
(
toggle
())
);
QAction
*
drawPolygon
=
new
QAction
(
this
);
drawPolygon
->
setToolTip
(
tr
(
"Add Polygon"
)
);
drawPolygon
->
setCheckable
(
true
);
drawPolygon
->
setIcon
(
QIcon
(
":/icons/draw-polygon.png"
)
);
connect
(
drawPolygon
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setDrawingPolygon
(
bool
))
);
QAction
*
removeItem
=
new
QAction
(
this
);
removeItem
->
setToolTip
(
tr
(
"Remove Item"
)
);
removeItem
->
setCheckable
(
true
);
removeItem
->
setIcon
(
QIcon
(
":/icons/edit-delete-shred.png"
)
);
connect
(
removeItem
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setRemovingItems
(
bool
))
);
connect
(
this
,
SIGNAL
(
itemRemoved
()),
removeItem
,
SLOT
(
toggle
())
);
QAction
*
loadAnnotationFile
=
new
QAction
(
this
);
loadAnnotationFile
->
setToolTip
(
tr
(
"Load Annotation File"
)
);
loadAnnotationFile
->
setIcon
(
QIcon
(
":/icons/document-import.png"
)
);
connect
(
loadAnnotationFile
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadAnnotationFile
())
);
QAction
*
saveAnnotationFile
=
new
QAction
(
this
);
saveAnnotationFile
->
setToolTip
(
tr
(
"Save Annotation File"
)
);
saveAnnotationFile
->
setIcon
(
QIcon
(
":/icons/document-export.png"
)
);
connect
(
saveAnnotationFile
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
saveAnnotationFile
())
);
QAction
*
clearAnnotations
=
new
QAction
(
this
);
clearAnnotations
->
setToolTip
(
tr
(
"Clear all Annotations"
)
);
clearAnnotations
->
setIcon
(
QIcon
(
":/icons/remove.png"
)
);
connect
(
drawPolygon
,
SIGNAL
(
toggled
(
bool
)),
clearAnnotations
,
SLOT
(
setDisabled
(
bool
))
);
connect
(
clearAnnotations
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
clearAnnotations
())
);
QAction
*
beginSeparator
=
new
QAction
(
this
);
beginSeparator
->
setSeparator
(
true
);
QAction
*
endSeparator
=
new
QAction
(
this
);
endSeparator
->
setSeparator
(
true
);
// QAction* downloadOsm = new QAction( this );
// downloadOsm->setText( tr("Download Osm File") );
// downloadOsm->setToolTip(tr("Download Osm File for selected area"));
// connect( downloadOsm, SIGNAL(triggered()),
// this, SLOT(downloadOsmFile()) );
group
->
addAction
(
enableInputAction
);
group
->
addAction
(
beginSeparator
);
group
->
addAction
(
addPlacemark
);
group
->
addAction
(
drawPolygon
);
group
->
addAction
(
removeItem
);
group
->
addAction
(
loadAnnotationFile
);
group
->
addAction
(
saveAnnotationFile
);
group
->
addAction
(
clearAnnotations
);
group
->
addAction
(
endSeparator
);
// nonExclusiveGroup->addAction( downloadOsm );
m_actions
.
append
(
group
);
m_actions
.
append
(
nonExclusiveGroup
);
m_toolbarActions
.
append
(
group
);
m_toolbarActions
.
append
(
nonExclusiveGroup
);
}
QActionGroup
*
group
=
new
QActionGroup
(
0
);
group
->
setExclusive
(
false
);
QActionGroup
*
nonExclusiveGroup
=
new
QActionGroup
(
0
);
nonExclusiveGroup
->
setExclusive
(
false
);
QAction
*
addPlacemark
=
new
QAction
(
this
);
addPlacemark
->
setToolTip
(
tr
(
"Add Placemark"
)
);
addPlacemark
->
setCheckable
(
true
);
addPlacemark
->
setIcon
(
QIcon
(
":/icons/draw-placemark.png"
)
);
connect
(
addPlacemark
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setAddingPlacemark
(
bool
))
);
connect
(
this
,
SIGNAL
(
placemarkAdded
())
,
addPlacemark
,
SLOT
(
toggle
())
);
QAction
*
drawPolygon
=
new
QAction
(
this
);
drawPolygon
->
setToolTip
(
tr
(
"Add Polygon"
)
);
drawPolygon
->
setCheckable
(
true
);
drawPolygon
->
setIcon
(
QIcon
(
":/icons/draw-polygon.png"
)
);
connect
(
drawPolygon
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setDrawingPolygon
(
bool
))
);
QAction
*
removeItem
=
new
QAction
(
this
);
removeItem
->
setToolTip
(
tr
(
"Remove Item"
)
);
removeItem
->
setCheckable
(
true
);
removeItem
->
setIcon
(
QIcon
(
":/icons/edit-delete-shred.png"
)
);
connect
(
removeItem
,
SIGNAL
(
toggled
(
bool
)),
this
,
SLOT
(
setRemovingItems
(
bool
))
);
connect
(
this
,
SIGNAL
(
itemRemoved
()),
removeItem
,
SLOT
(
toggle
())
);
QAction
*
loadAnnotationFile
=
new
QAction
(
this
);
loadAnnotationFile
->
setToolTip
(
tr
(
"Load Annotation File"
)
);
loadAnnotationFile
->
setIcon
(
QIcon
(
":/icons/document-import.png"
)
);
connect
(
loadAnnotationFile
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
loadAnnotationFile
())
);
QAction
*
saveAnnotationFile
=
new
QAction
(
this
);
saveAnnotationFile
->
setToolTip
(
tr
(
"Save Annotation File"
)
);
saveAnnotationFile
->
setIcon
(
QIcon
(
":/icons/document-export.png"
)
);
connect
(
saveAnnotationFile
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
saveAnnotationFile
())
);
QAction
*
clearAnnotations
=
new
QAction
(
this
);
clearAnnotations
->
setToolTip
(
tr
(
"Clear all Annotations"
)
);
clearAnnotations
->
setIcon
(
QIcon
(
":/icons/remove.png"
)
);
connect
(
drawPolygon
,
SIGNAL
(
toggled
(
bool
)),
clearAnnotations
,
SLOT
(
setDisabled
(
bool
))
);
connect
(
clearAnnotations
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
clearAnnotations
())
);
QAction
*
beginSeparator
=
new
QAction
(
this
);
beginSeparator
->
setSeparator
(
true
);
QAction
*
endSeparator
=
new
QAction
(
this
);
endSeparator
->
setSeparator
(
true
);
// QAction* downloadOsm = new QAction( this );
// downloadOsm->setText( tr("Download Osm File") );
// downloadOsm->setToolTip(tr("Download Osm File for selected area"));
// connect( downloadOsm, SIGNAL(triggered()),
// this, SLOT(downloadOsmFile()) );
group
->
addAction
(
beginSeparator
);
group
->
addAction
(
addPlacemark
);
group
->
addAction
(
drawPolygon
);
group
->
addAction
(
removeItem
);
group
->
addAction
(
loadAnnotationFile
);
group
->
addAction
(
saveAnnotationFile
);
group
->
addAction
(
clearAnnotations
);
group
->
addAction
(
endSeparator
);
// nonExclusiveGroup->addAction( downloadOsm );
m_actions
.
append
(
group
);
m_actions
.
append
(
nonExclusiveGroup
);
m_toolbarActions
.
append
(
group
);
m_toolbarActions
.
append
(
nonExclusiveGroup
);
emit
actionGroupsChanged
();
}
...
...
src/plugins/render/annotate/AnnotatePlugin.h
View file @
37977619
...
...
@@ -25,6 +25,7 @@
class
QNetworkAccessManager
;
class
QNetworkReply
;
class
QTreeView
;
namespace
Marble
...
...
@@ -34,6 +35,7 @@ class PlacemarkTextAnnotation;
class
GeoDataDocument
;
class
GeoDataLinearRing
;
class
GeoDataLineString
;
class
BranchFilterProxyModel
;
/**
* @short The class that specifies the Marble layer interface of a plugin.
...
...
@@ -80,6 +82,7 @@ class AnnotatePlugin : public RenderPlugin
virtual
const
QList
<
QActionGroup
*>*
actionGroups
()
const
;
virtual
const
QList
<
QActionGroup
*>*
toolbarActionGroups
()
const
;
virtual
QDockWidget
*
createDockWidget
();
bool
render
(
GeoPainter
*
painter
,
ViewportParams
*
viewport
,
const
QString
&
renderPos
,
GeoSceneLayer
*
layer
=
0
);
...
...
@@ -105,7 +108,7 @@ public slots:
protected:
bool
eventFilter
(
QObject
*
watched
,
QEvent
*
event
);
private:
void
setupActions
(
MarbleWidget
*
m
);
void
setupActions
();
// void readOsmFile( QIODevice* device, bool flyToFile );
bool
m_widgetInitialized
;
...
...
@@ -113,6 +116,8 @@ private:
QList
<
QActionGroup
*>
m_actions
;
QList
<
QActionGroup
*>
m_toolbarActions
;
QTreeView
*
m_treeView
;
BranchFilterProxyModel
*
m_treeViewModel
;
GeoDataDocument
*
m_annotationDocument
;
QList
<
SceneGraphicsItem
*>
m_graphicsItems
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment