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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Feb 20 17:28:27 EST 2011


Author: jef
Date: 2011-02-20 14:28:27 -0800 (Sun, 20 Feb 2011)
New Revision: 15225

Modified:
   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:
apply (slightly modified) #3512

Modified: trunk/qgis/src/app/qgstip.h
===================================================================
--- trunk/qgis/src/app/qgstip.h	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/app/qgstip.h	2011-02-20 22:28:27 UTC (rev 15225)
@@ -1,6 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim Sutton   *
- *   tim at linfiniti.com   *
+ *   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  *
@@ -25,7 +25,7 @@
 #include <QString>
 
 /** \ingroup app
-* \brief An QgsTip represents a tip generated by the 
+* \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
@@ -33,7 +33,7 @@
 * @see also QgsTipOfTheDay, QgsTipFactory
 */
 
-class QgsTip 
+class QgsTip
 {
   public:
     /** Constructor */
@@ -47,14 +47,14 @@
     QString title() {return mTitle;};
     /** Get the tip content */
     QString content() {return mContent;}
-    
+
     //
     // Mutators
     //
     /** Set the tip title */
-    void setTitle(QString theTitle) {mTitle = theTitle;};
+    void setTitle( QString theTitle ) {mTitle = theTitle;};
     /** Set the tip content*/
-    void setContent(QString theContent) {mContent = theContent;};
+    void setContent( QString theContent ) {mContent = theContent;};
   private:
     QString mTitle;
     QString mContent;

Modified: trunk/qgis/src/app/qgstipfactory.cpp
===================================================================
--- trunk/qgis/src/app/qgstipfactory.cpp	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/app/qgstipfactory.cpp	2011-02-20 22:28:27 UTC (rev 15225)
@@ -1,6 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim Sutton   *
- *   tim at linfiniti.com   *
+ *   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  *
@@ -27,66 +27,66 @@
 
 QgsTipFactory::QgsTipFactory() : QObject()
 {
-  // Im just doing this in a simple way so
+  // I'm 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...
   QgsTip myTip;
-  myTip.setTitle(tr("Quantum GIS is open source"));
-  myTip.setContent(tr("Quantum GIS 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 Quantum GIS project, and "
-        " that you can not create a new version of Quantum GIS under a "
-        " 'closed source' license. Visit <a href=\"http://qgis.org\">"
-        " the QGIS home page (http://qgis.org)</a> for more"
-        " information."));
-  addGenericTip(myTip);
+  myTip.setTitle( tr( "Quantum GIS is open source" ) );
+  myTip.setContent( tr( "Quantum GIS 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 Quantum GIS project, and "
+                        " that you can not create a new version of Quantum GIS under a "
+                        " 'closed source' license. Visit <a href=\"http://qgis.org\">"
+                        " the QGIS home page (http://qgis.org)</a> for more"
+                        " information." ) );
+  addGenericTip( myTip );
   //
-  myTip.setTitle(tr("QGIS Publications"));
-  myTip.setContent(tr("If you write a scientific paper or any other article"
-        " that refers to QGIS we would love to include your work"
-        " in the <a href=\"http://www.qgis.org/en/community/qgis-case-studies.html\">case studies section</a> of"
-        " the Quantum GIS home page (http://http://www.qgis.org/en/community/qgis-case-studies.html)."
-        ));
-  addGenericTip(myTip);
-  myTip.setTitle(tr("Become an QGIS translator"));
-  myTip.setContent(tr("Would you like to see QGIS"
-        " 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 "
-        " QGIS wiki"
-        " <a href=\"http://www.qgis.org/wiki/GUI_Translation\">translator's page (http://www.qgis.org/wiki/GUI_Translation).</a>"
-        ));
-  addGuiTip(myTip);
-  myTip.setTitle(tr("QGIS Mailing lists"));
-  myTip.setContent(tr("If you need help using QGIS"
-        " we have a 'users'  mailing list where users help each other with issues"
-        " related to using our sofware. We also have a 'developers' mailing list."
-        " for those wanting help and to discuss things relating the the QGIS code base."
-        " Details on how to subscribe are in the <a href=\"http://www.qgis.org/en/community/mailing-lists.html\">community section</a> of"
-        " the QGIS home page (http://www.qgis.org/en/community/mailing-lists.html)."
-        ));
-  addGuiTip(myTip);
-  myTip.setTitle(tr("Is it 'QGIS' or 'Quantum GIS'?"));
-  myTip.setContent(tr("Both are correct. For articles we suggest you write 'Quantum GIS (QGIS) is ....'"
-        " and then refer to it as QGIS thereafter."
-        ));
-  addGenericTip(myTip);
-  myTip.setTitle(tr("How do I refer to Quantum GIS?"));
-  myTip.setContent(tr("QGIS is spelled in all caps."
-        " We have various subprojects of the QGIS project "
-        " and it will help to avoid confusion if you refer to each by"
-        " its name:"
-        "<ul>"
-        "<li>QGIS Library - this is the C++ library that contains"
-        " the core logic that is used to build the QGIS user interface and other applications.</li>"
-        "<li>QGIS Application - this is the desktop application that you know and love so much :-).</li>"
-        "<li>QGIS Mapserver - this is a server-side application based on the QGIS Library"
-        " that will serve up your .qgs projects using the WMS protocol.</li>"
-        "</ul>"
-        ));
-  addGenericTip(myTip);
+  myTip.setTitle( tr( "QGIS Publications" ) );
+  myTip.setContent( tr( "If you write a scientific paper or any other article"
+                        " that refers to QGIS we would love to include your work"
+                        " in the <a href=\"http://www.qgis.org/en/community/qgis-case-studies.html\">case studies section</a> of"
+                        " the Quantum GIS home page (http://http://www.qgis.org/en/community/qgis-case-studies.html)."
+                      ) );
+  addGenericTip( myTip );
+  myTip.setTitle( tr( "Become an QGIS translator" ) );
+  myTip.setContent( tr( "Would you like to see QGIS"
+                        " 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 "
+                        " QGIS wiki"
+                        " <a href=\"http://www.qgis.org/wiki/GUI_Translation\">translator's page (http://www.qgis.org/wiki/GUI_Translation).</a>"
+                      ) );
+  addGuiTip( myTip );
+  myTip.setTitle( tr( "QGIS Mailing lists" ) );
+  myTip.setContent( tr( "If you need help using QGIS"
+                        " we have a 'users'  mailing list where users help each other with issues"
+                        " related to using our sofware. We also have a 'developers' mailing list."
+                        " for those wanting help and to discuss things relating the the QGIS code base."
+                        " Details on how to subscribe are in the <a href=\"http://www.qgis.org/en/community/mailing-lists.html\">community section</a> of"
+                        " the QGIS home page (http://www.qgis.org/en/community/mailing-lists.html)."
+                      ) );
+  addGuiTip( myTip );
+  myTip.setTitle( tr( "Is it 'QGIS' or 'Quantum GIS'?" ) );
+  myTip.setContent( tr( "Both are correct. For articles we suggest you write 'Quantum GIS (QGIS) is ....'"
+                        " and then refer to it as QGIS thereafter."
+                      ) );
+  addGenericTip( myTip );
+  myTip.setTitle( tr( "How do I refer to Quantum GIS?" ) );
+  myTip.setContent( tr( "QGIS is spelled in all caps."
+                        " We have various subprojects of the QGIS project "
+                        " and it will help to avoid confusion if you refer to each by"
+                        " its name:"
+                        "<ul>"
+                        "<li>QGIS Library - this is the C++ library that contains"
+                        " the core logic that is used to build the QGIS user interface and other applications.</li>"
+                        "<li>QGIS Application - this is the desktop application that you know and love so much :-).</li>"
+                        "<li>QGIS Mapserver - this is a server-side application based on the QGIS Library"
+                        " that will serve up your .qgs projects using the WMS protocol.</li>"
+                        "</ul>"
+                      ) );
+  addGenericTip( myTip );
   /* Template for adding more tips
   myTip.setTitle(tr(""));
   myTip.setContent(tr(""
@@ -100,48 +100,65 @@
 
 }
 //private helper method
-void QgsTipFactory::addGuiTip(QgsTip theTip)
+void QgsTipFactory::addGuiTip( QgsTip theTip )
 {
   mGuiTips << theTip;
   mAllTips << theTip;
 }
 //private helper method
-void QgsTipFactory::addGenericTip(QgsTip theTip)
+void QgsTipFactory::addGenericTip( QgsTip theTip )
 {
   mGenericTips << theTip;
   mAllTips << theTip;
 }
 QgsTip QgsTipFactory::getTip()
 {
-  srand(QTime::currentTime().msec());
+  srand( QTime::currentTime().msec() );
   int myRand = rand();
-  int myValue = static_cast<int> (myRand % mAllTips.count()); //range [0,(count-1)]
-  QgsTip myTip = mAllTips.at(myValue);
+  int myValue = static_cast<int>( myRand % mAllTips.count() ); //range [0,(count-1)]
+  QgsTip myTip = mAllTips.at( myValue );
   return myTip;
 }
-QgsTip QgsTipFactory::getTip(int thePosition)
+QgsTip QgsTipFactory::getTip( int thePosition )
 {
-  QgsTip myTip = mAllTips.at(thePosition);
+  QgsTip myTip = mAllTips.at( thePosition );
   return myTip;
 }
 QgsTip QgsTipFactory::getGenericTip()
 {
-  srand(QTime::currentTime().msec());
+  srand( QTime::currentTime().msec() );
   int myRand = rand();
-  int myValue = static_cast<int> (myRand % mGenericTips.count()); //range [0,(count-1)]
-  QgsTip myTip = mGenericTips.at(myValue);
+  int myValue = static_cast<int>( myRand % mGenericTips.count() ); //range [0,(count-1)]
+  QgsTip myTip = mGenericTips.at( myValue );
   return myTip;
 }
 QgsTip QgsTipFactory::getGuiTip()
 {
-  srand(QTime::currentTime().msec());
+  srand( QTime::currentTime().msec() );
   int myRand = rand();
-  int myValue = static_cast<int> (myRand % mGuiTips.count()); //range [0,(count-1)]
-  QgsTip myTip = mGuiTips.at(myValue);
+  int myValue = static_cast<int>( myRand % mGuiTips.count() ); //range [0,(count-1)]
+  QgsTip myTip = mGuiTips.at( myValue );
   return myTip;
 }
-int QgsTipFactory::randomNumber(int theMax)
+int QgsTipFactory::randomNumber( int theMax )
 {
   return 0;
 }
 
+int QgsTipFactory::position( QgsTip tip )
+{
+  for ( int i = 0; i < mAllTips.count(); ++i )
+  {
+    QgsTip myTip = mAllTips.at( i );
+    if ( myTip.title() == tip.title() )
+    {
+      return i;
+    }
+  }
+  return -1;
+}
+
+int QgsTipFactory::count()
+{
+  return mAllTips.count();
+}

Modified: trunk/qgis/src/app/qgstipfactory.h
===================================================================
--- trunk/qgis/src/app/qgstipfactory.h	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/app/qgstipfactory.h	2011-02-20 22:28:27 UTC (rev 15225)
@@ -1,6 +1,6 @@
 /***************************************************************************
- *   Copyright (C) 2007 by Tim Sutton   *
- *   tim at linfiniti.com   *
+ *   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  *
@@ -32,9 +32,9 @@
 * @see also QgsTipOfTheDay, QgsTip
 */
 
-class QgsTipFactory : public QObject 
+class QgsTipFactory : public QObject
 {
-  Q_OBJECT; //used for tr() so we dont need to do QObject::tr()
+    Q_OBJECT //used for tr() so we dont need to do QObject::tr()
   public:
     /** Constructor */
     QgsTipFactory();
@@ -45,13 +45,13 @@
      */
     QgsTip getTip();
     /** Get a specific tip (generic or gui-centric).
-     * @param thePosition The tip returned will be based on the 
+     * @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 
+     *        position is invalid, an empty string will be
      *        returned.
      * @return An QgsTip containing the tip
      */
-    QgsTip getTip(int thePosition);
+    QgsTip getTip( int thePosition );
     /** Get a random generic tip
      * @return An QgsTip containing the tip
      */
@@ -61,10 +61,13 @@
      */
     QgsTip getGuiTip();
 
+    int position( QgsTip );
+    int count();
+
   private:
-    void addGenericTip(QgsTip);
-    void addGuiTip(QgsTip);
-    int randomNumber(int theMax);
+    void addGenericTip( QgsTip );
+    void addGuiTip( QgsTip );
+    int randomNumber( int theMax );
     //@TODO move tipts into a sqlite db
     QList <QgsTip> mGenericTips;
     QList <QgsTip> mGuiTips;

Modified: trunk/qgis/src/app/qgstipgui.cpp
===================================================================
--- trunk/qgis/src/app/qgstipgui.cpp	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/app/qgstipgui.cpp	2011-02-20 22:28:27 UTC (rev 15225)
@@ -17,6 +17,8 @@
 /* $Id$ */
 
 #include <QSettings>
+#include <QPushButton>
+
 #include "qgstipgui.h"
 #include "qgsapplication.h"
 #include <qgstip.h>
@@ -46,16 +48,51 @@
   qgisIcon->setPixmap( icon );
   QgsTipFactory myFactory;
   QgsTip myTip = myFactory.getTip();
-  lblTitle->setText(myTip.title());
-  txtTip->setHtml(myTip.content());
+  mTipPosition = myFactory.position( myTip );
+  lblTitle->setText( myTip.title() );
+  txtTip->setHtml( myTip.content() );
 
+  QPushButton *pb;
+  pb = new QPushButton( tr( "&Previous" ) );
+  connect( pb, SIGNAL( clicked() ), this, SLOT( prevClicked() ) );
+  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
+
+  pb = new QPushButton( tr( "&Next" ) );
+  connect( pb, SIGNAL( clicked() ), this, SLOT( nextClicked() ) );
+  buttonBox->addButton( pb, QDialogButtonBox::ActionRole );
 }
 
-void QgsTipGui::on_cbxDisableTips_toggled(bool theFlag)
+void QgsTipGui::on_cbxDisableTips_toggled( bool theFlag )
 {
   QSettings settings;
-  //note the ! below as when the cbx is checked (true) we want to 
+  //note the ! below as when the cbx is checked (true) we want to
   //change the setting to false
   settings.setValue( "/qgis/showTips", !theFlag );
   hide();
 }
+
+void QgsTipGui::nextClicked()
+{
+  mTipPosition += 1;
+  QgsTipFactory myFactory;
+  if ( mTipPosition >= myFactory.count() )
+  {
+    mTipPosition = 0;
+  }
+  QgsTip myTip = myFactory.getTip( mTipPosition );
+  lblTitle->setText( myTip.title() );
+  txtTip->setHtml( myTip.content() );
+}
+
+void QgsTipGui::prevClicked()
+{
+  mTipPosition -= 1;
+  QgsTipFactory myFactory;
+  if ( mTipPosition < 0 )
+  {
+    mTipPosition = myFactory.count() - 1;
+  }
+  QgsTip myTip = myFactory.getTip( mTipPosition );
+  lblTitle->setText( myTip.title() );
+  txtTip->setHtml( myTip.content() );
+}

Modified: trunk/qgis/src/app/qgstipgui.h
===================================================================
--- trunk/qgis/src/app/qgstipgui.h	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/app/qgstipgui.h	2011-02-20 22:28:27 UTC (rev 15225)
@@ -30,8 +30,12 @@
   private:
     void init();
 
+    int mTipPosition;
+
   private slots:
-    void on_cbxDisableTips_toggled(bool theFlag);
+    void on_cbxDisableTips_toggled( bool theFlag );
+    void prevClicked();
+    void nextClicked();
 };
 
 #endif

Modified: trunk/qgis/src/ui/qgstipguibase.ui
===================================================================
--- trunk/qgis/src/ui/qgstipguibase.ui	2011-02-20 21:43:59 UTC (rev 15224)
+++ trunk/qgis/src/ui/qgstipguibase.ui	2011-02-20 22:28:27 UTC (rev 15225)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>492</width>
+    <width>560</width>
     <height>283</height>
    </rect>
   </property>
@@ -21,7 +21,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1">
+   <item row="0" column="1" colspan="2">
     <widget class="QLabel" name="lblTitle">
      <property name="styleSheet">
       <string notr="true">font-weight: bold; </string>
@@ -34,7 +34,7 @@
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="1" column="1" colspan="3">
     <widget class="QTextBrowser" name="txtTip">
      <property name="sizePolicy">
       <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@@ -46,22 +46,22 @@
       <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>
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Wine Sans Serif'; font-size:12pt; 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;&lt;span style=&quot; font-family:'Ubuntu'; font-size:10pt;&quot;&gt;A nice tip goes here...&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
      </property>
      <property name="openExternalLinks">
       <bool>true</bool>
      </property>
     </widget>
    </item>
-   <item row="2" column="1">
+   <item row="2" column="1" colspan="3">
     <widget class="QCheckBox" name="cbxDisableTips">
      <property name="text">
       <string>I've had enough tips, don't show this on start up any more!</string>
      </property>
     </widget>
    </item>
-   <item row="3" column="1">
+   <item row="3" column="1" colspan="3">
     <widget class="QDialogButtonBox" name="buttonBox">
      <property name="orientation">
       <enum>Qt::Horizontal</enum>



More information about the QGIS-commit mailing list