Skip to content

Commit 0e6fe39

Browse files
author
timlinux
committed
[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@15198 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1edaeca commit 0e6fe39

File tree

6 files changed

+510
-0
lines changed

6 files changed

+510
-0
lines changed

src/app/qgstip.h

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/***************************************************************************
2+
* Copyright (C) 2007 by Tim Sutton *
3+
* tim@linfiniti.com *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify *
6+
* it under the terms of the GNU General Public License as published by *
7+
* the Free Software Foundation; either version 2 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the GNU General Public License *
16+
* along with this program; if not, write to the *
17+
* Free Software Foundation, Inc., *
18+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19+
***************************************************************************/
20+
21+
#ifndef QGSTIP
22+
#define QGSTIP
23+
24+
#include <QObject>
25+
#include <QString>
26+
27+
/** \ingroup app
28+
* \brief An QgsTip represents a tip generated by the
29+
* QgsTipFactory factory class to serve up tips to the user.
30+
* Tips can be generic, in which case they make no mention of
31+
* gui dialogs etc, or gui-secific in which case they may allude
32+
* to features of the graphical user interface.
33+
* @see also QgsTipOfTheDay, QgsTipFactory
34+
*/
35+
36+
class QgsTip
37+
{
38+
public:
39+
/** Constructor */
40+
QgsTip() {};
41+
/**Destructor */
42+
~QgsTip() {};
43+
//
44+
// Accessors
45+
//
46+
/** Get the tip title */
47+
QString title() {return mTitle;};
48+
/** Get the tip content */
49+
QString content() {return mContent;}
50+
51+
//
52+
// Mutators
53+
//
54+
/** Set the tip title */
55+
void setTitle(QString theTitle) {mTitle = theTitle;};
56+
/** Set the tip content*/
57+
void setContent(QString theContent) {mContent = theContent;};
58+
private:
59+
QString mTitle;
60+
QString mContent;
61+
};
62+
63+
#endif //QGSTIP
64+

src/app/qgstipfactory.cpp

+176
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
/***************************************************************************
2+
* Copyright (C) 2007 by Tim Sutton *
3+
* tim@linfiniti.com *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify *
6+
* it under the terms of the GNU General Public License as published by *
7+
* the Free Software Foundation; either version 2 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the GNU General Public License *
16+
* along with this program; if not, write to the *
17+
* Free Software Foundation, Inc., *
18+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19+
***************************************************************************/
20+
21+
22+
#include "omgtipfactory.h"
23+
#include <QTime>
24+
//for rand & srand
25+
#include <cstdlib>
26+
27+
28+
OmgTipFactory::OmgTipFactory() : QObject()
29+
{
30+
// Im just doing this in a simple way so
31+
// its easy for translators...later
32+
// it its worth the time Ill move this data
33+
// into a sqlite database...
34+
OmgTip myTip;
35+
myTip.setTitle(tr("openModeller is open source"));
36+
myTip.setContent(tr("openModeller is open source software."
37+
" This means that the software source code can be freely viewed "
38+
" and modified. The GPL places a restriction that any modifications "
39+
" you make must be made available to the openModeller project, and "
40+
" that you can not create a new version of openModeller under a "
41+
" 'closed source' license. Visit <a href=\"http://openModeller.sf.net\">"
42+
" the openModeller home page (http://openModeller.sf.net)</a> for more"
43+
" information."));
44+
addGenericTip(myTip);
45+
//
46+
myTip.setTitle(tr("openModeller Publications"));
47+
myTip.setContent(tr("If you write a scientific paper or any other article"
48+
" that refers to openModeller we would love to include your work"
49+
" in the references section of "
50+
" the openModeller home page (http://openModeller.sf.net).</a>"
51+
));
52+
addGenericTip(myTip);
53+
myTip.setTitle(tr("Become an openModeller Desktop translator"));
54+
myTip.setContent(tr("Would you like to see openModeller Desktop"
55+
" in your native language? We are looking for more translators"
56+
" and would appreciate your help! The translation process is "
57+
" fairly straight forward - instructions are available in the "
58+
" resources section of "
59+
" the openModeller home page (http://openModeller.sf.net).</a>"
60+
));
61+
addGuiTip(myTip);
62+
myTip.setTitle(tr("openModeller Mailing lists"));
63+
myTip.setContent(tr("If you need help using openModeller Desktop"
64+
" we have a mailing list where users help each other with issues"
65+
" related to niche modelling and using openModeller Desktop."
66+
" Details on how to subscribe are in the resources section of"
67+
" the openModeller home page (http://openModeller.sf.net).</a>"
68+
));
69+
addGuiTip(myTip);
70+
myTip.setTitle(tr("Is it 'modelling' or 'modeling'?"));
71+
myTip.setContent(tr("Both spellings are correct. For openModeller"
72+
" we use the former spelling."
73+
));
74+
addGenericTip(myTip);
75+
myTip.setTitle(tr("How do I refer to openModeller?"));
76+
myTip.setContent(tr("openModeller is spelled with a lower case"
77+
" 'o' at the start of the word - even if its the beginning"
78+
" of a sentance. We have various subprojects of the openModeller "
79+
" project and it will help to avoid confusion if you refer to each by"
80+
" its name:"
81+
"<ul>"
82+
"<li>openModeller Library - this is the C++ library that contains"
83+
" the core logic for carrying out niche modelling"
84+
"<li>openModeller Console - these are a collection of command"
85+
" line tools that allow you to run niche models from a unix or"
86+
" DOS shell, or from a scripting environment."
87+
"<li>openModeller Web Service - The openModeller Web Service"
88+
" allows for remote execution of niche models."
89+
"<li>openModeller Desktop - the openModeller Desktop provides"
90+
" a graphical user interface for the openModeller Library. It"
91+
" also includes the capability to run models using the"
92+
" openModeller Web Service (though this is still considered"
93+
" experimental)."
94+
"</ul>"
95+
));
96+
addGenericTip(myTip);
97+
myTip.setTitle(tr("How can I improve model execution times?"));
98+
myTip.setContent(tr("Model processing time is typically determined by"
99+
"<ul>"
100+
"<li>the algorithm you select,</li>"
101+
"<li>the number, extents and spatial resolution of your format and environmental layers,</li>"
102+
"<li>the number of cells excluded by your mask (if any),</li>"
103+
"<li>in some cases the number of presence and absence points (e.g. distance algs),</li>"
104+
"<li>the speed of the computer the model is running on (CPU, disk access etc).</li>"
105+
"</ul>"
106+
"So if you want to improve model processing times you need to adjust "
107+
"one of these variables. One thing noticed quite commonly is that people "
108+
"use extremely high resolution datasets that often carry little "
109+
"additional information over lower resolution equivalents. For example "
110+
"interpolating widely dispersed weather station data to produce a 50cm "
111+
"raster probably carries little additional value over for example using "
112+
"10m2 pixels.<br>"
113+
"Another area of performance improvement you can look at is "
114+
"preselecting environmental variables using techniques such as Chi "
115+
"Square test. Future versions of openModeller will integrate the ability "
116+
"to do this type of preselection."
117+
));
118+
addGenericTip(myTip);
119+
/* Template for adding more tips
120+
myTip.setTitle(tr(""));
121+
myTip.setContent(tr(""
122+
));
123+
addGenericTip(myTip);
124+
*/
125+
}
126+
127+
OmgTipFactory::~OmgTipFactory()
128+
{
129+
130+
}
131+
//private helper method
132+
void OmgTipFactory::addGuiTip(OmgTip theTip)
133+
{
134+
mGuiTips << theTip;
135+
mAllTips << theTip;
136+
}
137+
//private helper method
138+
void OmgTipFactory::addGenericTip(OmgTip theTip)
139+
{
140+
mGenericTips << theTip;
141+
mAllTips << theTip;
142+
}
143+
OmgTip OmgTipFactory::getTip()
144+
{
145+
srand(QTime::currentTime().msec());
146+
int myRand = rand();
147+
int myValue = static_cast<int> (myRand % mAllTips.count()); //range [0,(count-1)]
148+
OmgTip myTip = mAllTips.at(myValue);
149+
return myTip;
150+
}
151+
OmgTip OmgTipFactory::getTip(int thePosition)
152+
{
153+
OmgTip myTip = mAllTips.at(thePosition);
154+
return myTip;
155+
}
156+
OmgTip OmgTipFactory::getGenericTip()
157+
{
158+
srand(QTime::currentTime().msec());
159+
int myRand = rand();
160+
int myValue = static_cast<int> (myRand % mGenericTips.count()); //range [0,(count-1)]
161+
OmgTip myTip = mGenericTips.at(myValue);
162+
return myTip;
163+
}
164+
OmgTip OmgTipFactory::getGuiTip()
165+
{
166+
srand(QTime::currentTime().msec());
167+
int myRand = rand();
168+
int myValue = static_cast<int> (myRand % mGuiTips.count()); //range [0,(count-1)]
169+
OmgTip myTip = mGuiTips.at(myValue);
170+
return myTip;
171+
}
172+
int OmgTipFactory::randomNumber(int theMax)
173+
{
174+
return 0;
175+
}
176+

src/app/qgstipfactory.h

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/***************************************************************************
2+
* Copyright (C) 2007 by Tim Sutton *
3+
* tim@linfiniti.com *
4+
* *
5+
* This program is free software; you can redistribute it and/or modify *
6+
* it under the terms of the GNU General Public License as published by *
7+
* the Free Software Foundation; either version 2 of the License, or *
8+
* (at your option) any later version. *
9+
* *
10+
* This program is distributed in the hope that it will be useful, *
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13+
* GNU General Public License for more details. *
14+
* *
15+
* You should have received a copy of the GNU General Public License *
16+
* along with this program; if not, write to the *
17+
* Free Software Foundation, Inc., *
18+
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19+
***************************************************************************/
20+
21+
#ifndef OMGTIPFACTORY
22+
#define OMGTIPFACTORY
23+
24+
#include "omgtip.h"
25+
#include <QList>
26+
27+
/** \ingroup lib
28+
* \brief A factory class to serve up tips to the user.
29+
* Tips can be generic, in which case they make no mention of
30+
* gui dialogs etc, or gui-secific in which case they may allude
31+
* to features of the graphical user interface.
32+
* @see also OmgTipOfTheDay, OmgTip
33+
*/
34+
35+
class OMG_LIB_EXPORT OmgTipFactory : public QObject
36+
{
37+
Q_OBJECT; //used for tr() so we dont need to do QObject::tr()
38+
public:
39+
/** Constructor */
40+
OmgTipFactory();
41+
/** Destructor */
42+
~OmgTipFactory();
43+
/** Get a random tip (generic or gui-centric)
44+
* @return An OmgTip containing the tip
45+
*/
46+
OmgTip getTip();
47+
/** Get a specific tip (generic or gui-centric).
48+
* @param thePosition The tip returned will be based on the
49+
* number passed in as thePosition. If the
50+
* position is invalid, an empty string will be
51+
* returned.
52+
* @return An OmgTip containing the tip
53+
*/
54+
OmgTip getTip(int thePosition);
55+
/** Get a random generic tip
56+
* @return An OmgTip containing the tip
57+
*/
58+
OmgTip getGenericTip();
59+
/** Get a random gui-centric tip
60+
* @return An OmgTip containing the tip
61+
*/
62+
OmgTip getGuiTip();
63+
64+
private:
65+
void addGenericTip(OmgTip);
66+
void addGuiTip(OmgTip);
67+
int randomNumber(int theMax);
68+
//@TODO move tipts into a sqlite db
69+
QList <OmgTip> mGenericTips;
70+
QList <OmgTip> mGuiTips;
71+
QList <OmgTip> mAllTips;
72+
};
73+
#endif //OMGTIPFACTORY
74+

src/app/qgstipgui.cpp

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/***************************************************************************
2+
qgstipgui.cpp - description
3+
-------------------
4+
begin : Sat Aug 10 2002
5+
copyright : (C) 2002 by Gary E.Sherman
6+
email : sherman at mrcc.com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
/* $Id$ */
18+
19+
#include <QSettings>
20+
#include "qgstipgui.h"
21+
#include "qgsapplication.h"
22+
#include <qgstip.h>
23+
#include <qgstipfactory.h>
24+
25+
#ifdef Q_OS_MACX
26+
QgsTipGui::QgsTipGui()
27+
: QDialog( NULL, Qt::WindowSystemMenuHint ) // Modeless dialog with close button only
28+
#else
29+
QgsTipGui::QgsTipGui()
30+
: QDialog( NULL ) // Normal dialog in non Mac-OS
31+
#endif
32+
{
33+
setupUi( this );
34+
init();
35+
}
36+
37+
QgsTipGui::~QgsTipGui()
38+
{
39+
}
40+
41+
void QgsTipGui::init()
42+
{
43+
44+
// set the 60x60 icon pixmap
45+
QPixmap icon( QgsApplication::iconsPath() + "qgis-icon-60x60.png" );
46+
qgisIcon->setPixmap( icon );
47+
QgsTipFactory myFactory;
48+
QgsTip myTip = myFactory.getTip();
49+
lblTitle->setText(myTip.title());
50+
txtTip->setHtml(myTip.content());
51+
52+
}
53+
54+
void QgsTipGui::on_cbxDisableTips_toggled(bool theFlag)
55+
{
56+
QSettings settings;
57+
//note the ! below as when the cbx is checked (true) we want to
58+
//change the setting to false
59+
settings.setValue( "/qgis/showTips", !theFlag );
60+
hide();
61+
}

0 commit comments

Comments
 (0)