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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Feb 16 14:34:27 EST 2008


Author: gsherman
Date: 2008-02-16 14:34:27 -0500 (Sat, 16 Feb 2008)
New Revision: 8163

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
   trunk/qgis/src/app/qgsoptions.cpp
   trunk/qgis/src/app/qgsoptions.h
   trunk/qgis/src/ui/qgsoptionsbase.ui
Log:
Remove need for specifying the web browser. QDesktopServices are used instead.

Drag and drop implementation.



Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2008-02-16 03:11:09 UTC (rev 8162)
+++ trunk/qgis/src/app/qgisapp.cpp	2008-02-16 19:34:27 UTC (rev 8163)
@@ -31,6 +31,7 @@
 #include <QClipboard>
 #include <QColor>
 #include <QCursor>
+#include <QDesktopServices>
 #include <QDesktopWidget>
 #include <QDialog>
 #include <QDir>
@@ -401,6 +402,10 @@
   mSplash->showMessage(tr("QGIS Ready!"), Qt::AlignHCenter | Qt::AlignBottom);
 
   mMapTipsVisible = false;
+
+  // setup drag drop 
+  setAcceptDrops(true);
+
   mFullScreenMode = false;
   showNormal();
   qApp->processEvents();
@@ -439,6 +444,43 @@
   QgsApplication::exitQgis();
 }
 
+void QgisApp::dragEnterEvent(QDragEnterEvent *event)
+{
+  if (event->mimeData()->hasUrls())
+  {
+    event->acceptProposedAction();
+  }
+}
+
+void QgisApp::dropEvent(QDropEvent *event)
+{
+  // get the file list
+  QList<QUrl>::iterator i;
+  QList<QUrl>urls = event->mimeData()->urls();
+  for (i = urls.begin(); i != urls.end(); i++)
+  {
+    QUrl mUrl = *i;
+    // seems that some drag and drop operations include an empty url
+    // so we test for length to make sure we have something
+    if( mUrl.path().length() > 0)
+    {
+      // check to see if we are opening a project file
+      QFileInfo fi(mUrl.path());
+      if( fi.completeSuffix() == "qgs" )
+      {
+        QgsDebugMsg("Opening project " + mUrl.path());
+      }
+      else
+      {
+        QgsDebugMsg("Adding " + mUrl.path() + " to the map canvas");
+        openLayer(mUrl.path());
+      }
+    }
+  }
+  event->acceptProposedAction();
+}
+
+
 // restore any application settings stored in QSettings
 void QgisApp::readSettings()
 {
@@ -4259,47 +4301,7 @@
   status = 0; //avoid compiler warning
   CFRelease(urlRef);
 #else
-  // find a browser
-  QSettings settings;
-  QString browser = settings.readEntry("/qgis/browser");
-  if (browser.length() == 0)
-  {
-    // ask user for browser and use it
-    bool ok;
-    QString myHeading = tr("QGIS Browser Selection");
-    QString myMessage = tr("Enter the name of a web browser to use (eg. konqueror).\n");
-    myMessage += tr("Enter the full path if the browser is not in your PATH.\n");
-    myMessage += tr("You can change this option later by selecting Options from the Settings menu (Help Browser tab).");
-    QString text = QInputDialog::getText(myHeading,
-        myMessage,
-        QLineEdit::Normal,
-        QString::null, &ok, this);
-    if (ok && !text.isEmpty())
-    {
-      // user entered something and pressed OK
-      browser = text;
-      // save the setting
-      settings.writeEntry("/qgis/browser", browser);
-    }
-    else
-    {
-      browser = "";
-    }
-
-  }
-  if (browser.length() > 0)
-  {
-    // find the installed location of the help files
-    // open index.html using browser
-    //XXX for debug on win32      QMessageBox::information(this,"Help opening...", browser + " - " + url);
-    QProcess *helpProcess = new QProcess(this);
-    QStringList myArgs;
-    myArgs << url;
-    helpProcess->start(browser,myArgs);
-  }
-  /*  mHelpViewer = new QgsHelpViewer(this,"helpviewer",false);
-      mHelpViewer->showContent(QgsApplication::prefixPath() +"/share/doc","index.html");
-      mHelpViewer->show(); */
+  QDesktopServices::openUrl(url);
 #endif
 }
 

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2008-02-16 03:11:09 UTC (rev 8162)
+++ trunk/qgis/src/app/qgisapp.h	2008-02-16 19:34:27 UTC (rev 8163)
@@ -145,6 +145,10 @@
   //! Returns a pointer to the internal clipboard
   QgsClipboard * clipboard();
 
+  void dragEnterEvent(QDragEnterEvent *);
+
+  void dropEvent(QDropEvent *);
+
 //private slots:
 public slots:
   //! About QGis

Modified: trunk/qgis/src/app/qgsoptions.cpp
===================================================================
--- trunk/qgis/src/app/qgsoptions.cpp	2008-02-16 03:11:09 UTC (rev 8162)
+++ trunk/qgis/src/app/qgsoptions.cpp	2008-02-16 19:34:27 UTC (rev 8163)
@@ -53,8 +53,6 @@
   qparent = parent;
   // read the current browser and set it
   QSettings settings;
-  QString browser = settings.readEntry("/qgis/browser");
-  cmbBrowser->setCurrentText(browser);
 #ifdef QGISDEBUG
   std::cout << "Standard Identify radius setting: " << QGis::DEFAULT_IDENTIFY_RADIUS << std::endl;
 #endif
@@ -223,7 +221,6 @@
 void QgsOptions::saveOptions()
 {
   QSettings settings;
-  settings.writeEntry("/qgis/browser", cmbBrowser->currentText());
   settings.writeEntry("/Map/identifyRadius", spinBoxIdentifyValue->value());
   settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
   settings.writeEntry("/qgis/new_layers_visible",chkAddedVisibility->isChecked());
@@ -300,26 +297,6 @@
 }
 
 
-void QgsOptions::on_btnFindBrowser_clicked()
-{
-  QString filter;
-#ifdef WIN32
-  filter = "Applications (*.exe)";
-#else
-  filter = "All Files (*)";
-#endif
-  QString browser = QFileDialog::getOpenFileName(
-          this,
-          "Choose a browser",
-          "./",
-          filter );
-  if(browser.length() > 0)
-  {
-    cmbBrowser->setCurrentText(browser);
-  }
-}
-
-
 void QgsOptions::on_pbnSelectProjection_clicked()
 {
   QSettings settings;

Modified: trunk/qgis/src/app/qgsoptions.h
===================================================================
--- trunk/qgis/src/app/qgsoptions.h	2008-02-16 03:11:09 UTC (rev 8162)
+++ trunk/qgis/src/app/qgsoptions.h	2008-02-16 19:34:27 UTC (rev 8163)
@@ -49,7 +49,6 @@
     public slots:
       //! Slot called when user chooses to change the project wide projection.
       void on_pbnSelectProjection_clicked();
-      void on_btnFindBrowser_clicked();
       void on_chkAntiAliasing_stateChanged();
       void on_chkUseQPixmap_stateChanged();
       void saveOptions();

Modified: trunk/qgis/src/ui/qgsoptionsbase.ui
===================================================================
--- trunk/qgis/src/ui/qgsoptionsbase.ui	2008-02-16 03:11:09 UTC (rev 8162)
+++ trunk/qgis/src/ui/qgsoptionsbase.ui	2008-02-16 19:34:27 UTC (rev 8163)
@@ -1021,107 +1021,6 @@
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="tabHelpBrowser" >
-      <attribute name="title" >
-       <string>Help &amp;Browser</string>
-      </attribute>
-      <layout class="QGridLayout" >
-       <property name="margin" >
-        <number>11</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item row="2" column="0" colspan="2" >
-        <spacer>
-         <property name="orientation" >
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" >
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item row="1" column="0" colspan="3" >
-        <widget class="QLabel" name="textLabel1_2" >
-         <property name="text" >
-          <string>&lt;b>Note:&lt;/b> The browser must be in your PATH or you can specify the full path above</string>
-         </property>
-         <property name="wordWrap" >
-          <bool>true</bool>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="2" >
-        <widget class="QPushButton" name="btnFindBrowser" >
-         <property name="maximumSize" >
-          <size>
-           <width>60</width>
-           <height>32767</height>
-          </size>
-         </property>
-         <property name="text" >
-          <string>...</string>
-         </property>
-        </widget>
-       </item>
-       <item row="0" column="1" >
-        <widget class="QComboBox" name="cmbBrowser" >
-         <property name="editable" >
-          <bool>true</bool>
-         </property>
-         <item>
-          <property name="text" >
-           <string>epiphany</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>firefox</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>mozilla-firefox</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>galeon</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>konqueror</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>mozilla</string>
-          </property>
-         </item>
-         <item>
-          <property name="text" >
-           <string>opera</string>
-          </property>
-         </item>
-        </widget>
-       </item>
-       <item row="0" column="0" >
-        <widget class="QLabel" name="textLabel1" >
-         <property name="text" >
-          <string>Open help documents with</string>
-         </property>
-         <property name="buddy" >
-          <cstring>cmbBrowser</cstring>
-         </property>
-        </widget>
-       </item>
-      </layout>
-     </widget>
     </widget>
    </item>
   </layout>
@@ -1136,7 +1035,6 @@
  </customwidgets>
  <tabstops>
   <tabstop>tabWidget</tabstop>
-  <tabstop>btnFindBrowser</tabstop>
   <tabstop>cbxHideSplash</tabstop>
   <tabstop>cmbTheme</tabstop>
   <tabstop>pbnSelectionColour</tabstop>
@@ -1150,7 +1048,6 @@
   <tabstop>radUseGlobalProjection</tabstop>
   <tabstop>txtGlobalWKT</tabstop>
   <tabstop>pbnSelectProjection</tabstop>
-  <tabstop>cmbBrowser</tabstop>
  </tabstops>
  <resources/>
  <connections/>



More information about the QGIS-commit mailing list