Skip to content

Commit

Permalink
Made all developer mug shots file system safe
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7814 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Dec 27, 2007
1 parent d3335a1 commit 9c9b592
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
File renamed without changes
File renamed without changes
32 changes: 32 additions & 0 deletions src/app/qgsabout.cpp
Expand Up @@ -18,6 +18,7 @@

#include "qgsabout.h"
#include "qgsapplication.h"
#include "qgslogger.h"
#ifdef Q_WS_MAC
#include <ApplicationServices/ApplicationServices.h>
#else
Expand Down Expand Up @@ -194,6 +195,7 @@ void QgsAbout::on_listBox1_currentItemChanged(QListWidgetItem *theItem)
#endif
QString myString = listBox1->currentItem()->text();
myString = myString.replace(" ","_");
myString = QgsAbout::fileSystemSafe(myString);
#ifdef QGISDEBUG
printf ("Loading mug: %s", (const char *)myString.toLocal8Bit().data());
#endif
Expand Down Expand Up @@ -272,3 +274,33 @@ void QgsAbout::openUrl(QString url)
mHelpViewer->showContent(mAppDir +"/share/doc","index.html");
mHelpViewer->show(); */
}

/*
* The function below makes a name safe for using in most file system
* Step 1: Code QString as UTF-8
* Step 2: Replace all bytes of the UTF-8 above 0x7f with the hexcode in lower case.
* Step 2: Replace all non [a-z][a-Z][0-9] with underscore (backward compatibility)
*/
QString QgsAbout::fileSystemSafe(QString filename)
{
QString result;
QByteArray utf8 = filename.toUtf8();

for (int i = 0; i < utf8.size(); i++)
{
uchar c = utf8[i];

if (c > 0x7f)
{
result = result + QString("%1").arg(c, 2, 16, QChar('0'));
}
else
{
result = result + QString(c);
}
}
result.replace(QRegExp("[^a-z0-9A-Z]"), "_");
QgsDebugMsg(result);

return result;
}
1 change: 1 addition & 0 deletions src/app/qgsabout.h
Expand Up @@ -30,6 +30,7 @@ class QgsAbout : public QDialog, private Ui::QgsAbout
void setURLs(QString urls);
void setWhatsNew(QString txt);
void setPluginInfo(QString txt);
static QString fileSystemSafe(QString string);

private:
void init();
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/CMakeLists.txt
@@ -1,5 +1,5 @@

SUBDIRS (copyright_label delimited_text grid_maker north_arrow scale_bar)
SUBDIRS (copyright_label delimited_text grid_maker north_arrow scale_bar evis)

IF (POSTGRES_FOUND)
SUBDIRS (geoprocessing spit)
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/gps_importer/qgsgpsplugingui.cpp
Expand Up @@ -410,10 +410,10 @@ void QgsGPSPluginGui::populateCONVDialog() {

QString format = QString("<html><body><p>%1 %2<p>%3</body></html>");

QString sentence1 = tr("QGIS can perform conversions of GPX files, by using GPSBabel (%1) to perform the conversions.")
QString sentence1 = tr("QGIS can perform conversions of GPX files, by using GPSBabel (%1) to perform the conversions.","Description")
.arg("<a href=\"http://www.gpsbabel.org\">http://www.gpsbabel.org</a>");
QString sentence2 = tr("This requires that you have GPSBabel installed where QGIS can find it.");
QString sentence3 = tr("Select a GPX input file name, the type of conversion you want to perform, a GPX filename that you want to save the converted file as, and a name for the new layer created from the result.");
QString sentence2 = tr("This requires that you have GPSBabel installed where QGIS can find it.","Description");
QString sentence3 = tr("Select a GPX input file name, the type of conversion you want to perform, a GPX filename that you want to save the converted file as, and a name for the new layer created from the result.","Description");

QString text = format.arg(sentence1).arg(sentence2).arg(sentence3);

Expand Down

0 comments on commit 9c9b592

Please sign in to comment.