Skip to content
Permalink
Browse files

QgsWebView renamed to QgsIdentifyResultsWebView

  • Loading branch information
blazek committed Apr 15, 2013
1 parent ce4ab58 commit ea694c7d2fc8b056b255e37067676238b01a65e7
Showing with 17 additions and 18 deletions.
  1. +13 −13 src/app/qgsidentifyresultsdialog.cpp
  2. +4 −5 src/app/qgsidentifyresultsdialog.h
@@ -50,7 +50,7 @@
#include <QComboBox>
#include <QWebFrame>

QgsWebView::QgsWebView( QWidget *parent ) : QWebView( parent )
QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QWebView( parent )
{
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
page()->setNetworkAccessManager( QgsNetworkAccessManager::instance() );
@@ -65,7 +65,7 @@ QgsWebView::QgsWebView( QWidget *parent ) : QWebView( parent )
this, SLOT( loadFinished( bool ) ) );
}

void QgsWebView::print( void )
void QgsIdentifyResultsWebView::print( void )
{
QPrinter printer;
QPrintDialog *dialog = new QPrintDialog( &printer );
@@ -75,7 +75,7 @@ void QgsWebView::print( void )
}
}

void QgsWebView::contextMenuEvent( QContextMenuEvent *e )
void QgsIdentifyResultsWebView::contextMenuEvent( QContextMenuEvent *e )
{
QMenu *menu = page()->createStandardContextMenu();
if ( menu )
@@ -88,16 +88,16 @@ void QgsWebView::contextMenuEvent( QContextMenuEvent *e )
}
}

// QgsWebView size:
// QgsIdentifyResultsWebView size:
// ---------------
//
// 1) QTreeWidget is not able to scroll continuously through the content of large widgets
// inserted into items via setItemWidget, it always jumps to the top of next
// item and it is not able to scroll to the bottom of an inserted large
// widget (until the QTreeWidget itself is large enough to show the whole
// inserted widget). => We have to keep the height of QgsWebView smaller
// inserted widget). => We have to keep the height of QgsIdentifyResultsWebView smaller
// than the height of QTreeWidget so that a user can see it entire, even if
// this height is smaller than QgsWebView content (i.e. QgsWebView scroolbar
// this height is smaller than QgsIdentifyResultsWebView content (i.e. QgsIdentifyResultsWebView scroolbar
// is added). We make it even a bit smaller so that a user can see a bit of
// context (items above/below) when scrolling which is more pleasant.
//
@@ -106,25 +106,25 @@ void QgsWebView::contextMenuEvent( QContextMenuEvent *e )
// after setHtml(), otherwise the contentSize() is 0,0 until the page is
// loaded and contentsSizeChanged () is emited.
//
// 3) If QgsWebView is resized (on page load) after it was inserted into
// 3) If QgsIdentifyResultsWebView is resized (on page load) after it was inserted into
// QTreeWidget, the row does not reflect that change automaticaly and
// consecutive resize of QTreeWidget will cause to shrink QgsWebView to the
// consecutive resize of QTreeWidget will cause to shrink QgsIdentifyResultsWebView to the
// original row height. That is expected, Qt: "setItemWidget() should only
// be used to display static content... => we must not change QgsWebView
// be used to display static content... => we must not change QgsIdentifyResultsWebView
// size after it was inserted to QTreeWidget

// TODO(?): Sometimes it may happen that if multiple QgsWebView are inserted to
// TODO(?): Sometimes it may happen that if multiple QgsIdentifyResultsWebView are inserted to
// QTreeWidget for the first time, and both share the same external source
// (image) the layout gets somehow confused - wrong positions, overlapped (Qt
// bug?) until next QTreeWidget resize.

// TODO(?): if the results dialog is resized to smaller heigh, existing
// QgsWebView are not (and must not be!) resized and scrolling becomes a bit
// QgsIdentifyResultsWebView are not (and must not be!) resized and scrolling becomes a bit
// unpleasant until next identify. AFAIK it could only be solved using
// QItemDelegate.

// size hint according to content
QSize QgsWebView::sizeHint() const
QSize QgsIdentifyResultsWebView::sizeHint() const
{
QSize s = this->page()->mainFrame()->contentsSize();
QgsDebugMsg( QString( "content size: %1 x %2" ).arg( s.width() ).arg( s.height() ) );
@@ -187,7 +187,7 @@ void QgsIdentifyResultsWebViewItem::setHtml( const QString &html )

QgsIdentifyResultsWebViewItem::QgsIdentifyResultsWebViewItem( QTreeWidget *treeWidget )
{
mWebView = new QgsWebView( treeWidget );
mWebView = new QgsIdentifyResultsWebView( treeWidget );
mWebView->hide();
setText( 0, tr( "Loading..." ) );
connect( mWebView, SIGNAL( loadFinished( bool ) ) ,
@@ -41,17 +41,16 @@ class QgsRasterLayer;
class QgsHighlight;
class QgsMapCanvas;
class QDockWidget;
class QgsWebView;

/**
*@author Gary E.Sherman
*/

class QgsWebView : public QWebView
class QgsIdentifyResultsWebView : public QWebView
{
Q_OBJECT;
public:
QgsWebView( QWidget *parent = 0 );
QgsIdentifyResultsWebView( QWidget *parent = 0 );
QSize sizeHint() const;
public slots:
void print( void );
@@ -79,14 +78,14 @@ class QgsIdentifyResultsWebViewItem: public QObject, public QTreeWidgetItem

public:
QgsIdentifyResultsWebViewItem( QTreeWidget *treeWidget = 0 );
QgsWebView *webView() { return mWebView; }
QgsIdentifyResultsWebView *webView() { return mWebView; }
void setHtml( const QString &html );

public slots:
void loadFinished( bool ok );

private:
QgsWebView *mWebView;
QgsIdentifyResultsWebView *mWebView;
};

class QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase

0 comments on commit ea694c7

Please sign in to comment.
You can’t perform that action at this time.