Skip to content

Commit

Permalink
- misc. Qt3 to Qt4 changes
Browse files Browse the repository at this point in the history
- add tr() to user visible text
- make the image chooser show all the valid file formats in the filter


git-svn-id: http://svn.osgeo.org/qgis/trunk@5322 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Apr 20, 2006
1 parent 38806c4 commit 4b7612c
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 41 deletions.
41 changes: 20 additions & 21 deletions src/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,29 +365,29 @@ void QgsComposer::on_mActionPrint_activated(void)
s.sprintf( "%%%%BoundingBox: 0 0 %d %d", w, h );

if ( s.length() > size ) {
QMessageBox::warning(this,"Error in Print", "Cannot format BoundingBox");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot format BoundingBox"));
} else {
if ( ! f.at(offset) ) {
QMessageBox::warning(this,"Error in Print", "Cannot seek");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot seek"));
} else {
/* Write spaces (for case the size > s.length() ) */
QString es;
es.fill(' ', size-1 );
f.flush();
if ( f.writeBlock ( es.toLocal8Bit().data(), size-1 ) < size-1 ) {
QMessageBox::warning(this,"Error in Print", "Cannot overwrite BoundingBox");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot overwrite BoundingBox"));
}
f.flush();
f.at(offset);
f.flush();
if ( f.writeBlock ( s.toLocal8Bit().data(), s.length() ) < s.length()-1 ) {
QMessageBox::warning(this,"Error in Print", "Cannot overwrite BoundingBox");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot overwrite BoundingBox"));
}
f.flush();
}
}
} else {
QMessageBox::warning(this,"Error in Print", "Cannot find BoundingBox");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot find BoundingBox"));
}
f.close();

Expand Down Expand Up @@ -420,35 +420,35 @@ void QgsComposer::on_mActionPrint_activated(void)
s.sprintf( "0 %d translate %s scale/defM matrix CM d } d", trans, (const char *)rx.cap(1).toLocal8Bit().data() );

if ( s.length() > size ) {
QMessageBox::warning(this,"Error in Print", "Cannot format translate");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot format translate"));
} else {
if ( ! f.at(offset) ) {
QMessageBox::warning(this,"Error in Print", "Cannot seek");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot seek"));
} else {
/* Write spaces (for case the size > s.length() ) */
QString es;
es.fill(' ', size-1 );
f.flush();
if ( f.writeBlock ( es.toLocal8Bit().data(), size-1 ) < size-1 ) {
QMessageBox::warning(this,"Error in Print", "Cannot overwrite translate");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot overwrite translate"));
}
f.flush();
f.at(offset);
f.flush();
if ( f.writeBlock ( s.toLocal8Bit().data(), s.length() ) < s.length()-1 ) {
QMessageBox::warning(this,"Error in Print", "Cannot overwrite translate");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot overwrite translate"));
}
f.flush();
}
}
} else {
QMessageBox::warning(this,"Error in Print", "Cannot find translate");
QMessageBox::warning(this, tr("Error in Print"), tr("Cannot find translate"));
}
f.close();
}
#endif
} catch (QgsIOException e) {
QMessageBox::warning(this,"File IO Error", e.what());
QMessageBox::warning(this, tr("File IO Error"), e.what());
}
} else { // print to printer
bool print = true;
Expand All @@ -458,8 +458,8 @@ void QgsComposer::on_mActionPrint_activated(void)
if ( mComposition->paperWidth() != mPrinter->widthMM() ||
mComposition->paperHeight() != mPrinter->heightMM() )
{
int answer = QMessageBox::warning ( 0, "Paper does not match",
"The selected paper size does not match the composition size",
int answer = QMessageBox::warning ( 0, tr("Paper does not match"),
tr("The selected paper size does not match the composition size"),
QMessageBox::Ok, QMessageBox::Abort );

if ( answer == QMessageBox::Abort )
Expand Down Expand Up @@ -502,11 +502,11 @@ void QgsComposer::on_mActionExportAsImage_activated(void)
#endif

if ( memuse > 200 ) { // cca 4500 x 4500
int answer = QMessageBox::warning ( 0, "Big image",
"To create image " + QString::number(width) + " x "
int answer = QMessageBox::warning ( 0, tr("Big image"),
tr("To create image ") + QString::number(width) + " x "
+ QString::number(height)
+ " requires circa "
+ QString::number(memuse) + " MB of memory",
+ tr(" requires circa ")
+ QString::number(memuse) + tr(" MB of memory"),
QMessageBox::Ok, QMessageBox::Abort );

raise ();
Expand Down Expand Up @@ -616,13 +616,12 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
QSettings myQSettings;
QString myLastUsedFile = myQSettings.readEntry("/UI/lastSaveAsSvgFile","qgis.svg");

QFileDialog *myQFileDialog = new QFileDialog( this, "Save svg file dialog",
"", "SVG Format (*.svg *SVG)" );
QFileDialog *myQFileDialog = new QFileDialog( this, tr("Choose a filename to save the map as"),
".", "SVG Format (*.svg *SVG)" );

myQFileDialog->setCaption(tr("Choose a filename to save the map as"));

myQFileDialog->selectFile( myLastUsedFile );
myQFileDialog->setMode(QFileDialog::AnyFile);
myQFileDialog->setAcceptMode(QFileDialog::AcceptSave);

int result = myQFileDialog->exec();
raise ();
Expand Down
4 changes: 2 additions & 2 deletions src/composer/qgscomposeritem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <qwidget.h>
#include <qdom.h>
#include <QWidget>
#include <QDomNode>

#include "qgscomposition.h"
#include "qgscomposeritem.h"
Expand Down
6 changes: 3 additions & 3 deletions src/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ void QgsComposerMap::init ()

// Preview style
mPreviewMode = Cache;
mPreviewModeComboBox->insertItem ( "Cache", Cache );
mPreviewModeComboBox->insertItem ( "Render", Render );
mPreviewModeComboBox->insertItem ( "Rectangle", Rectangle );
mPreviewModeComboBox->insertItem ( tr("Cache"), Cache );
mPreviewModeComboBox->insertItem ( tr("Render"), Render );
mPreviewModeComboBox->insertItem ( tr("Rectangle"), Rectangle );
mPreviewModeComboBox->setCurrentItem ( Cache );

mWidthScale = 1.0 / mComposition->scale();
Expand Down
12 changes: 6 additions & 6 deletions src/composer/qgscomposerpicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QPainter>
#include <Q3StrList>
#include <QImageWriter>

#include <cmath>
#include <iostream>
Expand Down Expand Up @@ -411,8 +411,8 @@ void QgsComposerPicture::pictureChanged ( )
loadPicture();

if ( !mPictureValid ) {
QMessageBox::warning( 0, "Warning",
"Cannot load picture." );
QMessageBox::warning( 0, tr("Warning"),
tr("Cannot load picture.") );
}
else
{
Expand Down Expand Up @@ -479,19 +479,19 @@ QWidget *QgsComposerPicture::options ( void )
QString QgsComposerPicture::pictureDialog ( void )
{
QString filters = "Pictures ( *.svg *.SVG ";
Q3StrList formats = QPictureIO::outputFormats();
QList<QByteArray> formats = QImageWriter::supportedImageFormats();

for ( int i = 0; i < formats.count(); i++ )
{
QString frmt = QPictureIO::outputFormats().at( i );
QString frmt = formats.at( i );
QString fltr = " *." + frmt.lower() + " *." + frmt.upper();
filters += fltr;
}
filters += " )";

QString file = QFileDialog::getOpenFileName(
0,
"Choose a file",
tr("Choose a file"),
".",
filters );

Expand Down
8 changes: 4 additions & 4 deletions src/composer/qgscomposervectorlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void QgsComposerVectorLegend::init ( void )

mLayersPopupMenu = new Q3PopupMenu( );

mLayersPopupMenu->insertItem( "Combine selected layers", this, SLOT(groupLayers()) );
mLayersPopupMenu->insertItem( tr("Combine selected layers"), this, SLOT(groupLayers()) );

connect ( mLayersListView, SIGNAL(clicked(Q3ListViewItem *)),
this, SLOT(layerChanged(Q3ListViewItem *)));
Expand All @@ -127,9 +127,9 @@ void QgsComposerVectorLegend::init ( void )

// Preview style
mPreviewMode = Render;
mPreviewModeComboBox->insertItem ( "Cache", Cache );
mPreviewModeComboBox->insertItem ( "Render", Render );
mPreviewModeComboBox->insertItem ( "Rectangle", Rectangle );
mPreviewModeComboBox->insertItem ( tr("Cache"), Cache );
mPreviewModeComboBox->insertItem ( tr("Render"), Render );
mPreviewModeComboBox->insertItem ( tr("Rectangle"), Rectangle );
mPreviewModeComboBox->setCurrentItem ( mPreviewMode );

connect ( mComposition, SIGNAL(mapChanged(int)), this, SLOT(mapChanged(int)) );
Expand Down
4 changes: 2 additions & 2 deletions src/composer/qgscomposerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
***************************************************************************/
#include <iostream>

#include <qmatrix.h>
#include <qevent.h>
#include <QMatrix>
#include <QEvent>

#include "qgsrect.h"

Expand Down
6 changes: 3 additions & 3 deletions src/composer/qgscomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void QgsComposition::setTool ( Tool tool )

// Create new object outside the visible area
QgsComposerLabel *lab = new QgsComposerLabel ( this, mNextItemId++,
(-1000)*mScale, (-1000)*mScale, "Label", (int) (mScale*mPaperHeight/40) );
(-1000)*mScale, (-1000)*mScale, tr("Label"), (int) (mScale*mPaperHeight/40) );
mNewCanvasItem = dynamic_cast <Q3CanvasItem *> (lab);
mComposer->showItemOptions ( lab->options() );

Expand Down Expand Up @@ -759,8 +759,8 @@ void QgsComposition::setTool ( Tool tool )
}
else
{
QMessageBox::warning( 0, "Warning",
"Cannot load picture." );
QMessageBox::warning( 0, tr("Warning"),
tr("Cannot load picture.") );

delete pi;
}
Expand Down

0 comments on commit 4b7612c

Please sign in to comment.