Skip to content
Permalink
Browse files
apply (slightly modified) #3512
git-svn-id: http://svn.osgeo.org/qgis/trunk@15225 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Feb 20, 2011
1 parent 08f207f commit 49cf5a9f871b96157e401eefd8c79d870faa2b11
Showing with 161 additions and 100 deletions.
  1. +7 −7 src/app/qgstip.h
  2. +88 −71 src/app/qgstipfactory.cpp
  3. +13 −10 src/app/qgstipfactory.h
  4. +41 −4 src/app/qgstipgui.cpp
  5. +5 −1 src/app/qgstipgui.h
  6. +7 −7 src/ui/qgstipguibase.ui
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@linfiniti.com *
* 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 *
@@ -25,15 +25,15 @@
#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
* to features of the graphical user interface.
* @see also QgsTipOfTheDay, QgsTipFactory
*/

class QgsTip
class QgsTip
{
public:
/** Constructor */
@@ -47,14 +47,14 @@ class QgsTip
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;
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@linfiniti.com *
* 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 *
@@ -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 @@ QgsTipFactory::~QgsTipFactory()

}
//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();
}
@@ -1,6 +1,6 @@
/***************************************************************************
* Copyright (C) 2007 by Tim Sutton *
* tim@linfiniti.com *
* 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 *
@@ -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 @@ class QgsTipFactory : public QObject
*/
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 @@ class QgsTipFactory : public QObject
*/
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;
@@ -17,6 +17,8 @@
/* $Id$ */

#include <QSettings>
#include <QPushButton>

#include "qgstipgui.h"
#include "qgsapplication.h"
#include <qgstip.h>
@@ -46,16 +48,51 @@ void QgsTipGui::init()
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() );
}
@@ -30,8 +30,12 @@ class QgsTipGui : public QDialog, private Ui::QgsTipGuiBase
private:
void init();

int mTipPosition;

private slots:
void on_cbxDisableTips_toggled(bool theFlag);
void on_cbxDisableTips_toggled( bool theFlag );
void prevClicked();
void nextClicked();
};

#endif

0 comments on commit 49cf5a9

Please sign in to comment.