~ubuntu-branches/ubuntu/wily/qgis/wily

« back to all changes in this revision

Viewing changes to src/core/qgspluginregistry.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
 
/***************************************************************************
2
 
                    QgsPluginRegistry.cpp  -  Singleton class for
3
 
                    tracking registering plugins.
4
 
                             -------------------
5
 
    begin                : Fri Feb 7 2004
6
 
    copyright            : (C) 2004 by Gary E.Sherman
7
 
    email                : sherman at mrcc.com
8
 
 ***************************************************************************/
9
 
 
10
 
/***************************************************************************
11
 
 *                                                                         *
12
 
 *   This program is free software; you can redistribute it and/or modify  *
13
 
 *   it under the terms of the GNU General Public License as published by  *
14
 
 *   the Free Software Foundation; either version 2 of the License, or     *
15
 
 *   (at your option) any later version.                                   *
16
 
 *                                                                         *
17
 
 ***************************************************************************/
18
 
 /* $Id: qgspluginregistry.cpp 6506 2007-02-03 12:35:27Z homann $ */
19
 
 
20
 
#include <iostream>
21
 
#include <qmessagebox.h>
22
 
#include <qstring.h>
23
 
#include <qdir.h>
24
 
#include <qlibrary.h>
25
 
#include <qapplication.h>
26
 
#include "qgsprovidermetadata.h"
27
 
#include "qgspluginmetadata.h"
28
 
#include "qgspluginregistry.h"
29
 
 
30
 
QgsPluginRegistry *QgsPluginRegistry::_instance = 0;
31
 
QgsPluginRegistry *QgsPluginRegistry::instance()
32
 
{
33
 
  if (_instance == 0)
34
 
    {
35
 
      _instance = new QgsPluginRegistry();
36
 
    }
37
 
  return _instance;
38
 
}
39
 
 
40
 
QgsPluginRegistry::QgsPluginRegistry()
41
 
{
42
 
// constructor does nothing
43
 
}
44
 
QString QgsPluginRegistry::library(QString pluginKey)
45
 
{
46
 
  QgsPluginMetadata *pmd = plugins[pluginKey];
47
 
  QString retval;
48
 
  if (pmd)
49
 
    {
50
 
      retval = pmd->library();
51
 
    }
52
 
  return retval;
53
 
}
54
 
 
55
 
QgsPluginMetadata *QgsPluginRegistry::pluginMetadata(QString name)
56
 
{
57
 
  return plugins[name];
58
 
}
59
 
 
60
 
QgisPlugin *QgsPluginRegistry::plugin(QString name)
61
 
{
62
 
  QgsPluginMetadata *pmd = plugins[name];
63
 
  QgisPlugin *retval = 0;
64
 
  if (pmd)
65
 
    {
66
 
      retval = pmd->plugin();
67
 
    }
68
 
  return retval;
69
 
}
70
 
 
71
 
void QgsPluginRegistry::addPlugin(QString library, QString name, QgisPlugin * plugin)
72
 
{
73
 
  plugins[name] = new QgsPluginMetadata(library, name, plugin);
74
 
}
75
 
 
76
 
void QgsPluginRegistry::removePlugin(QString name)
77
 
{
78
 
  plugins.erase(name);
79
 
}