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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Feb 18 10:18:10 EST 2011


Author: timlinux
Date: 2011-02-18 07:18:10 -0800 (Fri, 18 Feb 2011)
New Revision: 15198

Added:
   trunk/qgis/src/app/qgstip.h
   trunk/qgis/src/app/qgstipfactory.cpp
   trunk/qgis/src/app/qgstipfactory.h
   trunk/qgis/src/app/qgstipgui.cpp
   trunk/qgis/src/app/qgstipgui.h
   trunk/qgis/src/ui/qgstipguibase.ui
Log:
[FEATURE] Not sure how we coped without this till now...we now have a tip presented at startup. You can en/disable tips in the options panel. To contribute more tips, please add them to src/app/qgstipfactory.cpp

Added: trunk/qgis/src/app/qgstip.h
===================================================================
--- trunk/qgis/src/app/qgstip.h	                        (rev 0)
+++ trunk/qgis/src/app/qgstip.h	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,64 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Tim Sutton   *
+ *   tim at linfiniti.com   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef QGSTIP
+#define QGSTIP
+
+#include <QObject>
+#include <QString>
+
+/** \ingroup app
+* \brief An QgsTip represents a tip generated by the 
+* QgsTipFactory factory class to serve up tips to the user.
+* Tips can be generic, in which case they make no mention of
+* gui dialogs etc, or gui-secific in which case they may allude
+* to features of the graphical user interface.
+* @see also QgsTipOfTheDay, QgsTipFactory
+*/
+
+class QgsTip 
+{
+  public:
+    /** Constructor */
+    QgsTip() {};
+    /**Destructor */
+    ~QgsTip() {};
+    //
+    // Accessors
+    //
+    /** Get the tip title */
+    QString title() {return mTitle;};
+    /** Get the tip content */
+    QString content() {return mContent;}
+    
+    //
+    // Mutators
+    //
+    /** Set the tip title */
+    void setTitle(QString theTitle) {mTitle = theTitle;};
+    /** Set the tip content*/
+    void setContent(QString theContent) {mContent = theContent;};
+  private:
+    QString mTitle;
+    QString mContent;
+};
+
+#endif //QGSTIP
+

Added: trunk/qgis/src/app/qgstipfactory.cpp
===================================================================
--- trunk/qgis/src/app/qgstipfactory.cpp	                        (rev 0)
+++ trunk/qgis/src/app/qgstipfactory.cpp	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,176 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Tim Sutton   *
+ *   tim at linfiniti.com   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+
+#include "omgtipfactory.h"
+#include <QTime>
+//for rand & srand
+#include <cstdlib> 
+
+
+OmgTipFactory::OmgTipFactory() : QObject()
+{
+  // Im just doing this in a simple way so 
+  // its easy for translators...later
+  // it its worth the time Ill move this data
+  // into a sqlite database...
+  OmgTip myTip;
+  myTip.setTitle(tr("openModeller is open source"));
+  myTip.setContent(tr("openModeller is open source software."
+        " This means that the software source code can be freely viewed "
+        " and modified. The GPL places a restriction that any modifications "
+        " you make must be made available to the openModeller project, and "
+        " that you can not create a new version of openModeller under a "
+        " 'closed source' license. Visit <a href=\"http://openModeller.sf.net\">"
+        " the openModeller home page (http://openModeller.sf.net)</a> for more"
+        " information."));
+  addGenericTip(myTip);
+  //
+  myTip.setTitle(tr("openModeller Publications"));
+  myTip.setContent(tr("If you write a scientific paper or any other article"
+        " that refers to openModeller we would love to include your work"
+        " in the references section of "
+        " the openModeller home page (http://openModeller.sf.net).</a>"
+        ));
+  addGenericTip(myTip);
+  myTip.setTitle(tr("Become an openModeller Desktop translator"));
+  myTip.setContent(tr("Would you like to see openModeller Desktop"
+        " in your native language? We are looking for more translators"
+        " and would appreciate your help! The translation process is "
+        " fairly straight forward - instructions are available in the "
+        " resources section of "
+        " the openModeller home page (http://openModeller.sf.net).</a>"
+        ));
+  addGuiTip(myTip);
+  myTip.setTitle(tr("openModeller Mailing lists"));
+  myTip.setContent(tr("If you need help using openModeller Desktop"
+        " we have a mailing list where users help each other with issues"
+        " related to niche modelling and using openModeller Desktop."
+        " Details on how to subscribe are in the resources section of"
+        " the openModeller home page (http://openModeller.sf.net).</a>"
+        ));
+  addGuiTip(myTip);
+  myTip.setTitle(tr("Is it 'modelling' or 'modeling'?"));
+  myTip.setContent(tr("Both spellings are correct. For openModeller"
+        " we use the former spelling."
+        ));
+  addGenericTip(myTip);
+  myTip.setTitle(tr("How do I refer to openModeller?"));
+  myTip.setContent(tr("openModeller is spelled with a lower case"
+        " 'o' at the start of the word - even if its the beginning"
+        " of a sentance. We have various subprojects of the openModeller "
+        " project and it will help to avoid confusion if you refer to each by"
+        " its name:"
+        "<ul>"
+        "<li>openModeller Library - this is the C++ library that contains"
+        " the core logic for carrying out niche modelling"
+        "<li>openModeller Console - these are a collection of command"
+        " line tools that allow you to run niche models from a unix or"
+        " DOS shell, or from a scripting environment."
+        "<li>openModeller Web Service - The openModeller Web Service"
+        " allows for remote execution of niche models."
+        "<li>openModeller Desktop - the openModeller Desktop provides"
+        " a graphical user interface for the openModeller Library. It"
+        " also includes the capability to run models using the"
+        " openModeller Web Service (though this is still considered"
+        " experimental)."
+        "</ul>"
+        ));
+  addGenericTip(myTip);
+  myTip.setTitle(tr("How can I improve model execution times?"));
+  myTip.setContent(tr("Model processing time is typically determined by"
+        "<ul>"
+        "<li>the algorithm you select,</li>"
+        "<li>the number, extents and spatial resolution of your format and environmental layers,</li>" 
+        "<li>the number of cells excluded by your mask (if any),</li>"
+        "<li>in some cases the number of presence and absence points (e.g. distance algs),</li>"
+        "<li>the speed of the computer the model is running on (CPU, disk access etc).</li>"
+        "</ul>"
+        "So if you want to improve model processing times you need to adjust "
+        "one of these variables. One thing noticed quite commonly is that people "
+        "use extremely high resolution datasets that often carry little "
+        "additional information over lower resolution equivalents. For example "
+        "interpolating widely dispersed weather station data to produce a 50cm "
+        "raster probably carries little additional value over for example using "
+        "10m2 pixels.<br>"
+        "Another area of performance improvement you can look at is "
+        "preselecting environmental variables using techniques such as Chi "
+        "Square test. Future versions of openModeller will integrate the ability "
+        "to do this type of preselection."
+        ));
+  addGenericTip(myTip);
+  /* Template for adding more tips
+  myTip.setTitle(tr(""));
+  myTip.setContent(tr(""
+        ));
+  addGenericTip(myTip);
+  */
+}
+
+OmgTipFactory::~OmgTipFactory()
+{
+
+}
+//private helper method
+void OmgTipFactory::addGuiTip(OmgTip theTip)
+{
+  mGuiTips << theTip;
+  mAllTips << theTip;
+}
+//private helper method
+void OmgTipFactory::addGenericTip(OmgTip theTip)
+{
+  mGenericTips << theTip;
+  mAllTips << theTip;
+}
+OmgTip OmgTipFactory::getTip()
+{
+  srand(QTime::currentTime().msec());
+  int myRand = rand();
+  int myValue = static_cast<int> (myRand % mAllTips.count()); //range [0,(count-1)]
+  OmgTip myTip = mAllTips.at(myValue);
+  return myTip;
+}
+OmgTip OmgTipFactory::getTip(int thePosition)
+{
+  OmgTip myTip = mAllTips.at(thePosition);
+  return myTip;
+}
+OmgTip OmgTipFactory::getGenericTip()
+{
+  srand(QTime::currentTime().msec());
+  int myRand = rand();
+  int myValue = static_cast<int> (myRand % mGenericTips.count()); //range [0,(count-1)]
+  OmgTip myTip = mGenericTips.at(myValue);
+  return myTip;
+}
+OmgTip OmgTipFactory::getGuiTip()
+{
+  srand(QTime::currentTime().msec());
+  int myRand = rand();
+  int myValue = static_cast<int> (myRand % mGuiTips.count()); //range [0,(count-1)]
+  OmgTip myTip = mGuiTips.at(myValue);
+  return myTip;
+}
+int OmgTipFactory::randomNumber(int theMax)
+{
+  return 0;
+}
+

Added: trunk/qgis/src/app/qgstipfactory.h
===================================================================
--- trunk/qgis/src/app/qgstipfactory.h	                        (rev 0)
+++ trunk/qgis/src/app/qgstipfactory.h	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,74 @@
+/***************************************************************************
+ *   Copyright (C) 2007 by Tim Sutton   *
+ *   tim at linfiniti.com   *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef OMGTIPFACTORY
+#define OMGTIPFACTORY
+
+#include "omgtip.h"
+#include <QList>
+
+/** \ingroup lib
+* \brief A factory class to serve up tips to the user.
+* Tips can be generic, in which case they make no mention of
+* gui dialogs etc, or gui-secific in which case they may allude
+* to features of the graphical user interface.
+* @see also OmgTipOfTheDay, OmgTip
+*/
+
+class OMG_LIB_EXPORT OmgTipFactory : public QObject 
+{
+  Q_OBJECT; //used for tr() so we dont need to do QObject::tr()
+  public:
+    /** Constructor */
+    OmgTipFactory();
+    /** Destructor */
+    ~OmgTipFactory();
+    /** Get a random tip (generic or gui-centric)
+     * @return An OmgTip containing the tip
+     */
+    OmgTip getTip();
+    /** Get a specific tip (generic or gui-centric).
+     * @param thePosition The tip returned will be based on the 
+     *        number passed in as thePosition. If the
+     *        position is invalid, an empty string will be 
+     *        returned.
+     * @return An OmgTip containing the tip
+     */
+    OmgTip getTip(int thePosition);
+    /** Get a random generic tip
+     * @return An OmgTip containing the tip
+     */
+    OmgTip getGenericTip();
+    /** Get a random gui-centric tip
+     * @return An OmgTip  containing the tip
+     */
+    OmgTip getGuiTip();
+
+  private:
+    void addGenericTip(OmgTip);
+    void addGuiTip(OmgTip);
+    int randomNumber(int theMax);
+    //@TODO move tipts into a sqlite db
+    QList <OmgTip> mGenericTips;
+    QList <OmgTip> mGuiTips;
+    QList <OmgTip> mAllTips;
+};
+#endif //OMGTIPFACTORY
+

Added: trunk/qgis/src/app/qgstipgui.cpp
===================================================================
--- trunk/qgis/src/app/qgstipgui.cpp	                        (rev 0)
+++ trunk/qgis/src/app/qgstipgui.cpp	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,61 @@
+/***************************************************************************
+                          qgstipgui.cpp  -  description
+                             -------------------
+    begin                : Sat Aug 10 2002
+    copyright            : (C) 2002 by Gary E.Sherman
+    email                : sherman at mrcc.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id$ */
+
+#include <QSettings>
+#include "qgstipgui.h"
+#include "qgsapplication.h"
+#include <qgstip.h>
+#include <qgstipfactory.h>
+
+#ifdef Q_OS_MACX
+QgsTipGui::QgsTipGui()
+    : QDialog( NULL, Qt::WindowSystemMenuHint )  // Modeless dialog with close button only
+#else
+QgsTipGui::QgsTipGui()
+    : QDialog( NULL )  // Normal dialog in non Mac-OS
+#endif
+{
+  setupUi( this );
+  init();
+}
+
+QgsTipGui::~QgsTipGui()
+{
+}
+
+void QgsTipGui::init()
+{
+
+  // set the 60x60 icon pixmap
+  QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
+  qgisIcon->setPixmap( icon );
+  QgsTipFactory myFactory;
+  QgsTip myTip = myFactory.getTip();
+  lblTitle->setText(myTip.title());
+  txtTip->setHtml(myTip.content());
+
+}
+
+void QgsTipGui::on_cbxDisableTips_toggled(bool theFlag)
+{
+  QSettings settings;
+  //note the ! below as when the cbx is checked (true) we want to 
+  //change the setting to false
+  settings.setValue( "/qgis/showTips", !theFlag );
+  hide();
+}

Added: trunk/qgis/src/app/qgstipgui.h
===================================================================
--- trunk/qgis/src/app/qgstipgui.h	                        (rev 0)
+++ trunk/qgis/src/app/qgstipgui.h	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,37 @@
+/***************************************************************************
+                          qgstipgui.h  -  description
+                             -------------------
+    begin                : Fri 18 Feb 2011
+    copyright            : (C) 2011 by Tim Sutton
+    email                : tim at linfiniti.com
+ ***************************************************************************/
+
+/***************************************************************************
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ ***************************************************************************/
+/* $Id:$ */
+#ifndef QGSTIPGUI_H
+#define QGSTIPGUI_H
+
+#include "ui_qgstipguibase.h"
+
+class QgsTipGui : public QDialog, private Ui::QgsTipGuiBase
+{
+    Q_OBJECT
+  public:
+    QgsTipGui();
+    ~QgsTipGui();
+
+  private:
+    void init();
+
+  private slots:
+    void on_cbxDisableTips_toggled(bool theFlag);
+};
+
+#endif

Added: trunk/qgis/src/ui/qgstipguibase.ui
===================================================================
--- trunk/qgis/src/ui/qgstipguibase.ui	                        (rev 0)
+++ trunk/qgis/src/ui/qgstipguibase.ui	2011-02-18 15:18:10 UTC (rev 15198)
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QgsTipGuiBase</class>
+ <widget class="QDialog" name="QgsTipGuiBase">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>492</width>
+    <height>283</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>QGIS Tips!</string>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="qgisIcon">
+     <property name="text">
+      <string>TextLabel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" colspan="2">
+    <widget class="QTextBrowser" name="txtTip">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="html">
+      <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;A nice tip goes here...&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+     </property>
+     <property name="openExternalLinks">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" colspan="2">
+    <widget class="QCheckBox" name="checkBox">
+     <property name="text">
+      <string>I've had enough tips, don't show this on start up any more!</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="2">
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>QgsTipGuiBase</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>QgsTipGuiBase</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>



More information about the QGIS-commit mailing list