[QGIS Commit] r15250 - in trunk/qgis/src: app ui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Wed Feb 23 16:10:52 EST 2011


Author: timlinux
Date: 2011-02-23 13:10:52 -0800 (Wed, 23 Feb 2011)
New Revision: 15250

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/app/qgsoptions.h
   trunk/qgis/src/app/qgspluginregistry.cpp
   trunk/qgis/src/app/qgspluginregistry.h
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
[FEATURE] Added option to load c++ plugins from user specified directories. Requires application restart to activate.

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/app/qgisapp.cpp	2011-02-23 21:10:52 UTC (rev 15250)
@@ -490,6 +490,16 @@
     QgsPluginRegistry::instance()->restoreSessionPlugins( QgsApplication::pluginPath() );
   }
 
+  // Also restore plugins from user specified plugin directories - added for 1.7
+  QSettings settings;
+  QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
+  if ( !myPaths.isEmpty() )
+  {
+    QStringList myPathList = myPaths.split( "|" );
+    QgsPluginRegistry::instance()->restoreSessionPlugins( myPathList );
+    QMessageBox::critical( this, tr( "Plugin paths" ), myPaths );
+  }
+
   mSplash->showMessage( tr( "Initializing file filters" ), Qt::AlignHCenter | Qt::AlignBottom );
   qApp->processEvents();
   // now build vector file filter
@@ -541,7 +551,6 @@
   mMapCanvas->mapRenderer()->setLabelingEngine( mLBL );
 
   // Show a nice tip of the day
-  QSettings settings;
   if ( settings.value( "/qgis/showTips", 1 ).toBool() )
   {
     mSplash->hide();

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/app/qgsoptions.cpp	2011-02-23 21:10:52 UTC (rev 15250)
@@ -79,9 +79,23 @@
   spinBoxIdentifyValue->setMinimum( 0.01 );
   spinBoxIdentifyValue->setValue( identifyValue );
 
+  //local directories to search when loading c++ plugins 
+  QString myPaths = settings.value( "plugins/searchPathsForPlugins", "" ).toString();
+  if ( !myPaths.isEmpty() )
+  {
+    QStringList myPathList = myPaths.split( "|" );
+    QStringList::const_iterator pathIt = myPathList.constBegin();
+    for ( ; pathIt != myPathList.constEnd(); ++pathIt )
+    {
+      QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths );
+      newItem->setText( *pathIt );
+      newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+      mListPluginPaths->addItem( newItem );
+    }
+  }
 
   //local directories to search when looking for an SVG with a given basename
-  QString myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
+  myPaths = settings.value( "svg/searchPathsForSVG", "" ).toString();
   if ( !myPaths.isEmpty() )
   {
     QStringList myPathList = myPaths.split( "|" );
@@ -479,8 +493,20 @@
 {
   QSettings settings;
 
+  //search directories for user plugins
+  QString myPaths;
+  for ( int i = 0; i < mListPluginPaths->count(); ++i )
+  {
+    if ( i != 0 )
+    {
+      myPaths += "|";
+    }
+    myPaths += mListPluginPaths->item( i )->text();
+  }
+  settings.setValue( "plugins/searchPathsForPlugins", myPaths );
+
   //search directories for svgs
-  QString myPaths;
+  myPaths;
   for ( int i = 0; i < mListSVGPaths->count(); ++i )
   {
     if ( i != 0 )
@@ -881,6 +907,33 @@
   return myList;
 }
 
+void QgsOptions::on_mBtnAddPluginPath_clicked()
+{
+  QString myDir = QFileDialog::getExistingDirectory(
+                    this,
+                    tr( "Choose a directory" ),
+                    QDir::toNativeSeparators( QDir::homePath() ),
+                    QFileDialog::ShowDirsOnly
+                  );
+
+  if ( ! myDir.isEmpty() )
+  {
+    QListWidgetItem* newItem = new QListWidgetItem( mListPluginPaths );
+    newItem->setText( myDir );
+    newItem->setFlags( Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable );
+    mListPluginPaths->addItem( newItem );
+    mListPluginPaths->setCurrentItem( newItem );
+  }
+}
+
+void QgsOptions::on_mBtnRemovePluginPath_clicked()
+{
+  int currentRow = mListPluginPaths->currentRow();
+  QListWidgetItem* itemToRemove = mListPluginPaths->takeItem( currentRow );
+  delete itemToRemove;
+}
+
+
 void QgsOptions::on_mBtnAddSVGPath_clicked()
 {
   QString myDir = QFileDialog::getExistingDirectory(

Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/app/qgsoptions.h	2011-02-23 21:10:52 UTC (rev 15250)
@@ -91,6 +91,18 @@
     void on_mRemoveUrlPushButton_clicked();
 
     /* Let the user add a path to the list of search paths
+     * used for finding user Plugin libs.
+     * @note added in QGIS 1.7
+     */
+    void on_mBtnAddPluginPath_clicked();
+
+    /* Let the user remove a path to the list of search paths
+     * used for finding Plugin libs.
+     * @note added in QGIS 1.7
+     */
+    void on_mBtnRemovePluginPath_clicked();
+
+    /* Let the user add a path to the list of search paths
      * used for finding SVG files.
      * @note added in QGIS 1.4
      */

Modified: trunk/qgis/src/app/qgspluginregistry.cpp
===================================================================
--- trunk/qgis/src/app/qgspluginregistry.cpp	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/app/qgspluginregistry.cpp	2011-02-23 21:10:52 UTC (rev 15250)
@@ -356,10 +356,18 @@
       QgsDebugMsg( "Plugin " + theFullPathName + " did not return a valid type and cannot be loaded" );
       break;
   }
+}
 
+//overloaded version of the next method that will load from multiple directories not just one
+void QgsPluginRegistry::restoreSessionPlugins( QStringList thePluginDirList )
+{
+  QStringListIterator myIterator( thePluginDirList );
+  while ( myIterator.hasNext() )
+  {
+    restoreSessionPlugins( myIterator.next() );
+  }
 }
 
-
 void QgsPluginRegistry::restoreSessionPlugins( QString thePluginDirString )
 {
   QSettings mySettings;

Modified: trunk/qgis/src/app/qgspluginregistry.h
===================================================================
--- trunk/qgis/src/app/qgspluginregistry.h	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/app/qgspluginregistry.h	2011-02-23 21:10:52 UTC (rev 15250)
@@ -30,7 +30,7 @@
 
 /**
 * \class QgsPluginRegistry
-* \brief This class tracks plugins that are currently loaded an provides
+* \brief This class tracks plugins that are currently loaded and provides
 * a means to fetch a pointer to a plugin and unload it
 *
 * plugin key is:
@@ -78,6 +78,8 @@
     //! Python plugin loader
     void loadPythonPlugin( QString packageName );
 
+    //! Overloaded version of the next method that will load from multiple directories not just one
+    void restoreSessionPlugins( QStringList thePluginDirList );
     //! Load any plugins used in the last qgis session
     void restoreSessionPlugins( QString thePluginDirString );
 

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2011-02-23 20:45:46 UTC (rev 15249)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2011-02-23 21:10:52 UTC (rev 15250)
@@ -59,9 +59,9 @@
           <property name="geometry">
            <rect>
             <x>0</x>
-            <y>-155</y>
+            <y>-369</y>
             <width>746</width>
-            <height>640</height>
+            <height>827</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_12">
@@ -168,8 +168,8 @@
              <property name="title">
               <string>Application</string>
              </property>
-             <layout class="QVBoxLayout" name="verticalLayout_2">
-              <item>
+             <layout class="QGridLayout" name="gridLayout">
+              <item row="0" column="0">
                <layout class="QHBoxLayout" name="horizontalLayout_3">
                 <item>
                  <widget class="QLabel" name="textLabel1_4">
@@ -211,7 +211,7 @@
                 </item>
                </layout>
               </item>
-              <item>
+              <item row="1" column="0">
                <layout class="QHBoxLayout" name="horizontalLayout_7">
                 <item>
                  <widget class="QLabel" name="textLabel1_5">
@@ -248,77 +248,77 @@
                 </item>
                </layout>
               </item>
-              <item>
+              <item row="2" column="0">
                <widget class="QCheckBox" name="capitaliseCheckBox">
                 <property name="text">
                  <string>Capitalise layer names in legend</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="3" column="0">
                <widget class="QCheckBox" name="cbxLegendClassifiers">
                 <property name="text">
                  <string>Display classification attribute names in legend</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="4" column="0">
                <widget class="QCheckBox" name="cbxCreateRasterLegendIcons">
                 <property name="text">
                  <string>Create raster icons in legend</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="5" column="0">
                <widget class="QCheckBox" name="cbxHideSplash">
                 <property name="text">
                  <string>Hide splash screen at startup</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="6" column="0">
                <widget class="QCheckBox" name="cbxShowTips">
                 <property name="text">
                  <string>Show tips at start up</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="7" column="0">
                <widget class="QCheckBox" name="cbxIdentifyResultsDocked">
                 <property name="text">
                  <string>Open identify results in a dock window (QGIS restart required)</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="8" column="0">
                <widget class="QCheckBox" name="cbxSnappingOptionsDocked">
                 <property name="text">
                  <string>Open snapping options  in a dock window (QGIS restart required)</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="9" column="0">
                <widget class="QCheckBox" name="cbxAttributeTableDocked">
                 <property name="text">
                  <string>Open attribute table in a dock window (QGIS restart required)</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="10" column="0">
                <widget class="QCheckBox" name="cbxAddPostgisDC">
                 <property name="text">
                  <string>Add PostGIS layers with double click and select in extended mode</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="11" column="0">
                <widget class="QCheckBox" name="cbxAddNewLayersToCurrentGroup">
                 <property name="text">
                  <string>Add new layers to selected group</string>
                 </property>
                </widget>
               </item>
-              <item>
+              <item row="12" column="0">
                <layout class="QHBoxLayout" name="horizontalLayout_5">
                 <item>
                  <widget class="QLabel" name="textLabel1_7">
@@ -360,7 +360,7 @@
                 </item>
                </layout>
               </item>
-              <item>
+              <item row="13" column="0">
                <layout class="QHBoxLayout" name="horizontalLayout_6">
                 <item>
                  <widget class="QLabel" name="label_14">
@@ -387,6 +387,52 @@
                 </item>
                </layout>
               </item>
+              <item row="14" column="0">
+               <widget class="QGroupBox" name="groupBox_4">
+                <property name="title">
+                 <string>Plugin paths</string>
+                </property>
+                <layout class="QGridLayout" name="_2">
+                 <item row="0" column="0">
+                  <widget class="QLabel" name="mSVGLabel_2">
+                   <property name="text">
+                    <string>Path(s) to search for additional C++ plugins libraries</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="0" column="1">
+                  <spacer>
+                   <property name="orientation">
+                    <enum>Qt::Horizontal</enum>
+                   </property>
+                   <property name="sizeHint" stdset="0">
+                    <size>
+                     <width>31</width>
+                     <height>20</height>
+                    </size>
+                   </property>
+                  </spacer>
+                 </item>
+                 <item row="0" column="2">
+                  <widget class="QPushButton" name="mBtnAddPluginPath">
+                   <property name="text">
+                    <string>Add</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="0" column="3">
+                  <widget class="QPushButton" name="mBtnRemovePluginPath">
+                   <property name="text">
+                    <string>Remove</string>
+                   </property>
+                  </widget>
+                 </item>
+                 <item row="1" column="0" colspan="4">
+                  <widget class="QListWidget" name="mListPluginPaths"/>
+                 </item>
+                </layout>
+               </widget>
+              </item>
              </layout>
             </widget>
            </item>
@@ -416,7 +462,7 @@
             <x>0</x>
             <y>0</y>
             <width>746</width>
-            <height>466</height>
+            <height>479</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_8">
@@ -587,7 +633,7 @@
             <x>0</x>
             <y>0</y>
             <width>746</width>
-            <height>480</height>
+            <height>500</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_4">
@@ -941,8 +987,8 @@
            <rect>
             <x>0</x>
             <y>0</y>
-            <width>762</width>
-            <height>458</height>
+            <width>746</width>
+            <height>462</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_13">
@@ -1272,7 +1318,7 @@
             <x>0</x>
             <y>0</y>
             <width>746</width>
-            <height>527</height>
+            <height>531</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_15">
@@ -1368,7 +1414,7 @@
             <x>0</x>
             <y>0</y>
             <width>746</width>
-            <height>545</height>
+            <height>552</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_17">
@@ -1459,7 +1505,7 @@
             <x>0</x>
             <y>0</y>
             <width>746</width>
-            <height>531</height>
+            <height>548</height>
            </rect>
           </property>
           <layout class="QGridLayout" name="gridLayout_20">



More information about the QGIS-commit mailing list