Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15198 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed Feb 18, 2011
1 parent 007cc07 commit a9ffeb1
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 0 deletions.
64 changes: 64 additions & 0 deletions src/app/qgstip.h
@@ -0,0 +1,64 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@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

176 changes: 176 additions & 0 deletions src/app/qgstipfactory.cpp
@@ -0,0 +1,176 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@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;
}

74 changes: 74 additions & 0 deletions src/app/qgstipfactory.h
@@ -0,0 +1,74 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@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

61 changes: 61 additions & 0 deletions src/app/qgstipgui.cpp
@@ -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();
}

0 comments on commit a9ffeb1

Please sign in to comment.