~ubuntu-branches/ubuntu/trusty/qgis/trusty

« back to all changes in this revision

Viewing changes to src/plugins/wfs/qgswfsplugin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Johan Van de Wauw
  • Date: 2010-07-11 20:23:24 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100711202324-5ktghxa7hracohmr
Tags: 1.4.0+12730-3ubuntu1
* Merge from Debian unstable (LP: #540941).
* Fix compilation issues with QT 4.7
* Add build-depends on libqt4-webkit-dev 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
                              qgswfsplugin.h    
 
2
                              qgswfsplugin.h
3
3
                              -------------------
4
4
  begin                : July 25, 2006
5
5
  copyright            : (C) 2006 by Marco Hugentobler
15
15
 *                                                                         *
16
16
 ***************************************************************************/
17
17
 
 
18
#include "qgisinterface.h"
 
19
#include "qgsapplication.h"
18
20
#include "qgsproviderregistry.h"
19
21
#include "qgswfssourceselect.h"
20
22
#include "qgssinglesymbolrenderer.h"
21
23
#include "qgsvectorlayer.h"
22
24
#include "qgswfsplugin.h"
23
 
#include "qgswfsprovider.h"
24
 
 
25
 
#include "mIconAddWfsLayer.xpm"
26
 
 
27
 
#ifdef WIN32
28
 
#define QGISEXTERN extern "C" __declspec( dllexport )
29
 
#else
30
 
#define QGISEXTERN extern "C"
31
 
#endif
32
 
 
33
 
static const QString name_ = QObject::tr("WFS plugin");
34
 
static const QString description_ = QObject::tr("Adds WFS layers to the QGIS canvas");
35
 
static const QString version_ = QObject::tr("Version 0.0001");
36
 
 
37
 
QgsWFSPlugin::QgsWFSPlugin(QgisApp* app, QgisIface* iface): QgisPlugin(name_, description_, version_, QgisPlugin::MAPLAYER), mApp(app), mIface(iface), mWfsDialogAction(0)
 
25
 
 
26
#include <QFile>
 
27
#include <QToolBar>
 
28
 
 
29
 
 
30
 
 
31
static const QString name_ = QObject::tr( "WFS plugin" );
 
32
static const QString description_ = QObject::tr( "Adds WFS layers to the QGIS canvas" );
 
33
static const QString version_ = QObject::tr( "Version 0.1" );
 
34
 
 
35
QgsWFSPlugin::QgsWFSPlugin( QgisInterface* iface )
 
36
    : QgisPlugin( name_, description_, version_, QgisPlugin::MAPLAYER ),
 
37
    mIface( iface ), mWfsDialogAction( 0 )
38
38
{
39
39
 
40
40
}
46
46
 
47
47
void QgsWFSPlugin::initGui()
48
48
{
49
 
  if(mIface)
50
 
    {
51
 
      mWfsDialogAction = new QAction(QIcon(mIconAddWfsLayer), tr("&Add WFS layer"), 0);
52
 
      QObject::connect(mWfsDialogAction, SIGNAL(activated()), this, SLOT(showSourceDialog()));
53
 
      mIface->addToolBarIcon(mWfsDialogAction);
54
 
      mIface->addPluginMenu(tr("&Add WFS layer"), mWfsDialogAction);
55
 
    }
 
49
  if ( mIface )
 
50
  {
 
51
    mWfsDialogAction = new QAction( QIcon(), tr( "&Add WFS layer" ), 0 );
 
52
    setCurrentTheme( "" );
 
53
    QObject::connect( mWfsDialogAction, SIGNAL( triggered() ), this, SLOT( showSourceDialog() ) );
 
54
    mIface->layerToolBar()->addAction( mWfsDialogAction );
 
55
    mIface->addPluginToMenu( tr( "&Add WFS layer" ), mWfsDialogAction );
 
56
    // this is called when the icon theme is changed
 
57
    connect( mIface, SIGNAL( currentThemeChanged( QString ) ), this, SLOT( setCurrentTheme( QString ) ) );
 
58
  }
56
59
}
57
60
 
58
61
void QgsWFSPlugin::unload()
59
62
{
60
 
  mIface->removeToolBarIcon(mWfsDialogAction);
61
 
  mIface->removePluginMenu(tr("&Add WFS layer"), mWfsDialogAction);
 
63
  mIface->removeToolBarIcon( mWfsDialogAction );
 
64
  mIface->removePluginMenu( tr( "&Add WFS layer" ), mWfsDialogAction );
62
65
  delete mWfsDialogAction;
63
66
  mWfsDialogAction = 0;
64
67
}
65
68
 
66
69
void QgsWFSPlugin::showSourceDialog()
67
70
{
68
 
  QgsWFSSourceSelect serverDialog(0, mIface);
 
71
  QgsWFSSourceSelect serverDialog( 0, mIface );
69
72
  serverDialog.exec();
70
73
}
71
74
 
72
 
QGISEXTERN QgisPlugin * classFactory(QgisApp * theQGisAppPointer, QgisIface * theQgisInterfacePointer)
73
 
{
74
 
  return new QgsWFSPlugin(theQGisAppPointer, theQgisInterfacePointer);
 
75
//! Set icons to the current theme
 
76
void QgsWFSPlugin::setCurrentTheme( QString theThemeName )
 
77
{
 
78
  QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/wfs.png";
 
79
  QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/wfs.png";
 
80
  QString myQrcPath = ":/wfs.png";
 
81
  if ( QFile::exists( myCurThemePath ) )
 
82
  {
 
83
    mWfsDialogAction->setIcon( QIcon( myCurThemePath ) );
 
84
  }
 
85
  else if ( QFile::exists( myDefThemePath ) )
 
86
  {
 
87
    mWfsDialogAction->setIcon( QIcon( myDefThemePath ) );
 
88
  }
 
89
  else if ( QFile::exists( myQrcPath ) )
 
90
  {
 
91
    mWfsDialogAction->setIcon( QIcon( myQrcPath ) );
 
92
  }
 
93
  else
 
94
  {
 
95
    mWfsDialogAction->setIcon( QIcon() );
 
96
  }
 
97
}
 
98
 
 
99
QGISEXTERN QgisPlugin * classFactory( QgisInterface * theQgisInterfacePointer )
 
100
{
 
101
  return new QgsWFSPlugin( theQgisInterfacePointer );
75
102
}
76
103
 
77
104
QGISEXTERN QString name()
94
121
  return QgisPlugin::UI;
95
122
}
96
123
 
97
 
QGISEXTERN void unload(QgisPlugin* theQgsWFSPluginPointer)
 
124
QGISEXTERN void unload( QgisPlugin* theQgsWFSPluginPointer )
98
125
{
99
126
  delete theQgsWFSPluginPointer;
100
127
}