-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
625 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/*************************************************************************** | ||
QgsHTMLAnnotationDialog.cpp | ||
--------------------- | ||
begin : March 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco dot hugentobler at sourcepole dot ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#include "qgshtmlannotationdialog.h" | ||
#include "qgsannotationwidget.h" | ||
#include "qgsvectorlayer.h" | ||
#include <QFileDialog> | ||
#include <QFileInfo> | ||
#include <QGraphicsScene> | ||
|
||
QgsHtmlAnnotationDialog::QgsHtmlAnnotationDialog( QgsHtmlAnnotationItem* item, QWidget * parent, Qt::WindowFlags f ) | ||
: QDialog( parent, f ), mItem( item ), mEmbeddedWidget( 0 ) | ||
{ | ||
setupUi( this ); | ||
mEmbeddedWidget = new QgsAnnotationWidget( mItem ); | ||
mEmbeddedWidget->show(); | ||
mStackedWidget->addWidget( mEmbeddedWidget ); | ||
mStackedWidget->setCurrentWidget( mEmbeddedWidget ); | ||
|
||
if ( item ) | ||
{ | ||
mFileLineEdit->setText( item->htmlPage() ); | ||
} | ||
|
||
QObject::connect( mButtonBox, SIGNAL( accepted() ), this, SLOT( applySettingsToItem() ) ); | ||
QPushButton* deleteButton = new QPushButton( tr( "Delete" ) ); | ||
QObject::connect( deleteButton, SIGNAL( clicked() ), this, SLOT( deleteItem() ) ); | ||
mButtonBox->addButton( deleteButton, QDialogButtonBox::RejectRole ); | ||
} | ||
|
||
QgsHtmlAnnotationDialog::~QgsHtmlAnnotationDialog() | ||
{ | ||
|
||
} | ||
|
||
void QgsHtmlAnnotationDialog::applySettingsToItem() | ||
{ | ||
//apply settings from embedded item widget | ||
if ( mEmbeddedWidget ) | ||
{ | ||
mEmbeddedWidget->apply(); | ||
} | ||
|
||
if ( mItem ) | ||
{ | ||
mItem->setHTMLPage( mFileLineEdit->text() ); | ||
QgsVectorLayer* layer = mItem->vectorLayer(); | ||
if ( layer ) | ||
{ | ||
//set last used annotation form as default for the layer | ||
//layer->setAnnotationForm( mFileLineEdit->text() ); | ||
} | ||
mItem->update(); | ||
} | ||
} | ||
|
||
void QgsHtmlAnnotationDialog::on_mBrowseToolButton_clicked() | ||
{ | ||
QString directory; | ||
QFileInfo fi( mFileLineEdit->text() ); | ||
if ( fi.exists() ) | ||
{ | ||
directory = fi.absolutePath(); | ||
} | ||
QString filename = QFileDialog::getOpenFileName( 0, tr( "html" ), directory, "*.html" ); | ||
mFileLineEdit->setText( filename ); | ||
} | ||
|
||
void QgsHtmlAnnotationDialog::deleteItem() | ||
{ | ||
QGraphicsScene* scene = mItem->scene(); | ||
if ( scene ) | ||
{ | ||
scene->removeItem( mItem ); | ||
} | ||
delete mItem; | ||
mItem = 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/*************************************************************************** | ||
qgsformannotationdialog.h | ||
--------------------- | ||
begin : March 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco dot hugentobler at sourcepole dot ch | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
#ifndef QgsHTMLAnnotationDialog_H | ||
#define QgsHTMLAnnotationDialog_H | ||
|
||
#include "ui_qgsformannotationdialogbase.h" | ||
#include "qgshtmlannotationitem.h" | ||
|
||
class QgsAnnotationWidget; | ||
|
||
class QgsHtmlAnnotationDialog: public QDialog, private Ui::QgsFormAnnotationDialogBase | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsHtmlAnnotationDialog( QgsHtmlAnnotationItem* item, QWidget * parent = 0, Qt::WindowFlags f = 0 ); | ||
~QgsHtmlAnnotationDialog(); | ||
|
||
private: | ||
QgsHtmlAnnotationItem* mItem; | ||
QgsAnnotationWidget* mEmbeddedWidget; | ||
|
||
private slots: | ||
void applySettingsToItem(); | ||
void on_mBrowseToolButton_clicked(); | ||
void deleteItem(); | ||
}; | ||
|
||
#endif // QgsHTMLAnnotationDialog_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgsmaptoolformannotation.cpp | ||
------------------------------- | ||
begin : February 9, 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco dot hugentobler at hugis dot net | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsmaptoolhtmlannotation.h" | ||
#include "qgshtmlannotationitem.h" | ||
#include "qgsmapcanvas.h" | ||
#include "qgsvectorlayer.h" | ||
#include <QMouseEvent> | ||
|
||
QgsMapToolHtmlAnnotation::QgsMapToolHtmlAnnotation( QgsMapCanvas* canvas ): QgsMapToolAnnotation( canvas ) | ||
{ | ||
|
||
} | ||
|
||
QgsMapToolHtmlAnnotation::~QgsMapToolHtmlAnnotation() | ||
{ | ||
|
||
} | ||
|
||
QgsAnnotationItem* QgsMapToolHtmlAnnotation::createItem( QMouseEvent* e ) | ||
{ | ||
//try to associate the current vector layer and a feature to the form item | ||
QgsVectorLayer* currentVectorLayer = 0; | ||
if ( mCanvas ) | ||
{ | ||
QgsMapLayer* mLayer = mCanvas->currentLayer(); | ||
if ( mLayer ) | ||
{ | ||
currentVectorLayer = dynamic_cast<QgsVectorLayer*>( mLayer ); | ||
} | ||
} | ||
|
||
QgsHtmlAnnotationItem* formItem = new QgsHtmlAnnotationItem( mCanvas, currentVectorLayer ); | ||
formItem->setMapPosition( toMapCoordinates( e->pos() ) ); | ||
formItem->setSelected( true ); | ||
formItem->setFrameSize( QSizeF( 200, 100 ) ); | ||
return formItem; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/*************************************************************************** | ||
QgsMapToolHtmlAnnotation.h | ||
----------------------------- | ||
begin : February 9, 2010 | ||
copyright : (C) 2010 by Marco Hugentobler | ||
email : marco dot hugentobler at hugis dot net | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSMAPTOOLHTMLANNOTATION_H | ||
#define QGSMAPTOOLHTMLANNOTATION_H | ||
|
||
#include "qgsmaptoolannotation.h" | ||
|
||
class QgsMapToolHtmlAnnotation: public QgsMapToolAnnotation | ||
{ | ||
public: | ||
QgsMapToolHtmlAnnotation( QgsMapCanvas* canvas ); | ||
~QgsMapToolHtmlAnnotation(); | ||
|
||
protected: | ||
QgsAnnotationItem* createItem( QMouseEvent* e ); | ||
}; | ||
|
||
#endif // QgsMapToolHtmlAnnotation_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7298e73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of the master 26 July 2013, I found the html annotation worked but did not update the field data used in expressions so show the data for the current feature record. Data for the first record in the table was being shown no matter which feature was clicked. The same html code works correctly for html tips. The test code was:
where URL is the file address for an image such as "c:\photos\img1.jpg". I have tried the using double quotes and single quotes to ensure that it is not just an issue with how quotes are used.
I am applying the html by double clicking an existing blank annotation and importing a html file each time I add an annotation. Is this how the tools is meant to be used, or is there some place that I should be putting the html before starting to use the tool?
7298e73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have read the source code and can't quite figure it out but it appears that a single feature ID is used to look up the DOM and get attributes. In my photographic data, which is geotagged using a time-based track log from a Garmin GPS, is it common for photos to be stacked on top of each other. Even if this was not the case, I often stand in one spot and take photos upstream, downstream and across the stream. Handling of multiple features at the same point is likely to be an issue. The only solution I can think of would be to have a preview in the dialog that has forwards and backwards butttons to allow the user to choose which of the coincident records to display.
7298e73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes currently it's a limitation of the tool. I doesn't support stacked features well or at all.
This should be opened as a bug on hub.qgis.org
7298e73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7298e73
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi
@AndrewM- QtCreator is the defacto IDE for Qt related development and works great for QGIS. You can debug etc nicely with it (in partiular under linux).
Tim