4,642 changes: 2,426 additions & 2,216 deletions i18n/qgis_ru.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions scripts/tsstat.pl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
it => 'Paolo Cavallini, Flavio Rigolon, Maurizio Napolitano, Roberto Angeletti, Alessandro Fanna, Michele Beneventi, Marco Braida, Luca Casagrande, Luca Delucchi, Anne Gishla',
ja => 'BABA Yoshihiko, Yoichi Kayama',
ka_GE => 'Shota Murtskhvaladze, George Machitidze',
ko_KR => 'BJ Jang',
lo => 'Anousak Souphavanh',
lv => 'Maris Nartiss, Pēteris Brūns',
lt => 'Kestas M',
Expand Down
40 changes: 20 additions & 20 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4385,7 +4385,7 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
QDomImplementation DomImplementation;
QDomDocumentType documentType =
DomImplementation.createDocumentType(
"qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" );
"qgis", "http://mrcc.com/qgis.dtd", "SYSTEM" );
QDomDocument doc( documentType );
QDomElement rootNode = doc.createElement( "qgis" );
rootNode.setAttribute( "version", QString( "%1" ).arg( QGis::QGIS_VERSION ) );
Expand All @@ -4394,10 +4394,10 @@ void QgisApp::copyStyle( QgsMapLayer * sourceLayer )
if ( !selectionLayer->writeSymbology( rootNode, doc, errorMsg ) )
{
QMessageBox::warning( this,
tr( "Error" ),
tr( "Cannot copy style: %1" )
.arg( errorMsg ),
QMessageBox::Ok );
tr( "Error" ),
tr( "Cannot copy style: %1" )
.arg( errorMsg ),
QMessageBox::Ok );
return;
}
// Copies data in text form as well, so the XML can be pasted into a text editor
Expand All @@ -4417,26 +4417,26 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
QDomDocument doc( "qgis" );
QString errorMsg;
int errorLine, errorColumn;
if ( !doc.setContent ( clipboard()->data( QGSCLIPBOARD_STYLE_MIME ), false, &errorMsg, &errorLine, &errorColumn ) )
if ( !doc.setContent( clipboard()->data( QGSCLIPBOARD_STYLE_MIME ), false, &errorMsg, &errorLine, &errorColumn ) )
{
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot parse style: %1:%2:%3" )
.arg( errorMsg )
.arg( errorLine )
.arg( errorColumn ),
QMessageBox::Ok );
return;
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot parse style: %1:%2:%3" )
.arg( errorMsg )
.arg( errorLine )
.arg( errorColumn ),
QMessageBox::Ok );
return;
}
QDomElement rootNode = doc.firstChildElement( "qgis" );
if ( !selectionLayer->readSymbology( rootNode, errorMsg ) )
{
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot read style: %1" )
.arg( errorMsg ),
QMessageBox::Ok );
return;
QMessageBox::information( this,
tr( "Error" ),
tr( "Cannot read style: %1" )
.arg( errorMsg ),
QMessageBox::Ok );
return;
}

mMapLegend->refreshLayerSymbology( selectionLayer->id(), false );
Expand Down
26 changes: 13 additions & 13 deletions src/app/qgsclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,35 +167,35 @@ QgsCoordinateReferenceSystem QgsClipboard::crs()

void QgsClipboard::setData( const QString& mimeType, const QByteArray& data, const QString* text )
{
QMimeData *mdata = new QMimeData();
mdata->setData( mimeType, data );
if ( text )
{
mdata->setText( *text );
}
// Transfers ownership to the clipboard object
QMimeData *mdata = new QMimeData();
mdata->setData( mimeType, data );
if ( text )
{
mdata->setText( *text );
}
// Transfers ownership to the clipboard object
#ifndef Q_OS_WIN
QApplication::clipboard()->setMimeData( mdata, QClipboard::Selection );
QApplication::clipboard()->setMimeData( mdata, QClipboard::Selection );
#endif
QApplication::clipboard()->setMimeData( mdata, QClipboard::Clipboard );
QApplication::clipboard()->setMimeData( mdata, QClipboard::Clipboard );
}

void QgsClipboard::setData( const QString& mimeType, const QByteArray& data, const QString& text )
{
setData( mimeType, data, &text );
setData( mimeType, data, &text );
}

void QgsClipboard::setData( const QString& mimeType, const QByteArray& data )
{
setData( mimeType, data, 0 );
setData( mimeType, data, 0 );
}

bool QgsClipboard::hasFormat( const QString& mimeType )
{
return QApplication::clipboard()->mimeData()->hasFormat( mimeType );
return QApplication::clipboard()->mimeData()->hasFormat( mimeType );
}

QByteArray QgsClipboard::data( const QString& mimeType )
{
return QApplication::clipboard()->mimeData()->data( mimeType );
return QApplication::clipboard()->mimeData()->data( mimeType );
}
4 changes: 2 additions & 2 deletions src/app/qgsmaptooloffsetcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ void QgsMapToolOffsetCurve::setOffsetForRubberBand( double offset, bool leftSide
}
}
#else //GEOS_VERSION>=3.3
Q_UNUSED(offset);
Q_UNUSED(leftSide);
Q_UNUSED( offset );
Q_UNUSED( leftSide );
#endif //GEOS_VERSION>=3.3
}

Expand Down
12 changes: 6 additions & 6 deletions src/core/composer/qgscomposerscalebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
#include <cmath>

QgsComposerScaleBar::QgsComposerScaleBar( QgsComposition* composition )
: QgsComposerItem( composition )
, mComposerMap( 0 )
, mNumUnitsPerSegment( 0 )
, mStyle( 0 )
, mSegmentMillimeters( 0.0 )
, mAlignment( Left )
: QgsComposerItem( composition )
, mComposerMap( 0 )
, mNumUnitsPerSegment( 0 )
, mStyle( 0 )
, mSegmentMillimeters( 0.0 )
, mAlignment( Left )
{
applyDefaultSettings();
applyDefaultSize();
Expand Down
12 changes: 6 additions & 6 deletions src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ bool QgsCoordinateReferenceSystem::createFromEpsg( long id )
bool QgsCoordinateReferenceSystem::createFromSrsId( long id )
{
return loadFromDb( id < USER_CRS_START_ID ? QgsApplication::srsDbFilePath() :
QgsApplication::qgisUserDbFilePath(),
QgsApplication::qgisUserDbFilePath(),
"srs_id", QString::number( id ) );
}

Expand Down Expand Up @@ -254,8 +254,8 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
*/

QString mySql = "select srs_id,description,projection_acronym,"
"ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
"from tbl_srs where " + expression + "=" + quotedValue( value );
"ellipsoid_acronym,parameters,srid,auth_name||':'||auth_id,is_geo "
"from tbl_srs where " + expression + "=" + quotedValue( value );
myResult = sqlite3_prepare( myDatabase, mySql.toUtf8(),
mySql.toUtf8().length(),
&myPreparedStatement, &myTail );
Expand All @@ -265,7 +265,7 @@ bool QgsCoordinateReferenceSystem::loadFromDb( QString db, QString expression, Q
mSrsId = QString::fromUtf8(( char * )sqlite3_column_text(
myPreparedStatement, 0 ) ).toLong();
mDescription = QString::fromUtf8(( char * )sqlite3_column_text(
myPreparedStatement, 1 ) );
myPreparedStatement, 1 ) );
mProjectionAcronym = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 2 ) );
mEllipsoidAcronym = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 3 ) );
QString toProj4 = QString::fromUtf8(( char * )sqlite3_column_text( myPreparedStatement, 4 ) );
Expand Down Expand Up @@ -813,8 +813,8 @@ void QgsCoordinateReferenceSystem::setProj4String( QString theProj4String )
OSRDestroySpatialReference( mCRS );
mCRS = OSRNewSpatialReference( NULL );
mIsValidFlag =
OSRImportFromProj4( mCRS, theProj4String.toLatin1().constData() )
== OGRERR_NONE;
OSRImportFromProj4( mCRS, theProj4String.toLatin1().constData() )
== OGRERR_NONE;
mWkt.clear();
setMapUnits();

Expand Down
25 changes: 13 additions & 12 deletions src/core/qgsmaplayerregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,21 @@ QgsMapLayer * QgsMapLayerRegistry::mapLayer( QString theLayerId )

//introduced in 1.8
QList<QgsMapLayer *> QgsMapLayerRegistry::addMapLayers(
QList<QgsMapLayer *> theMapLayers,
bool theEmitSignal )
QList<QgsMapLayer *> theMapLayers,
bool theEmitSignal )
{
QList<QgsMapLayer *> myResultList;
for (int i = 0; i < theMapLayers.size(); ++i)
for ( int i = 0; i < theMapLayers.size(); ++i )
{
QgsMapLayer * myLayer = theMapLayers.at(i);
QgsMapLayer * myLayer = theMapLayers.at( i );
if ( !myLayer || !myLayer->isValid() )
{
QgsDebugMsg( "cannot add invalid layers" );
continue;
}
//check the layer is not already registered!
QMap<QString, QgsMapLayer*>::iterator myIterator =
mMapLayers.find( myLayer->id() );
mMapLayers.find( myLayer->id() );
//if myIterator returns mMapLayers.end() then it
//does not exist in registry and its safe to add it
if ( myIterator == mMapLayers.end() )
Expand All @@ -97,30 +97,31 @@ QgsMapLayerRegistry::addMapLayer( QgsMapLayer * theMapLayer,
bool theEmitSignal )
{
QList<QgsMapLayer *> myList;
myList.append(theMapLayer);
addMapLayers(myList, theEmitSignal);
myList.append( theMapLayer );
addMapLayers( myList, theEmitSignal );
return theMapLayer;
} // QgsMapLayerRegistry::addMapLayer

//introduced in 1.8
void QgsMapLayerRegistry::removeMapLayers( QStringList theLayerIds,
bool theEmitSignal )
bool theEmitSignal )
{
if ( theEmitSignal )
emit layersWillBeRemoved( theLayerIds );

foreach (const QString &myId, theLayerIds) {
foreach( const QString &myId, theLayerIds )
{
if ( theEmitSignal )
emit layerWillBeRemoved( myId );
delete mMapLayers[myId];
mMapLayers.remove( myId );
}
emit layersWillBeRemoved(theLayerIds);
emit layersWillBeRemoved( theLayerIds );
}

//deprecated 1.8 use removeMapLayers rather
void QgsMapLayerRegistry::removeMapLayer( QString theLayerId,
bool theEmitSignal )
bool theEmitSignal )
{
QStringList myList;
myList << theLayerId;
Expand All @@ -141,7 +142,7 @@ void QgsMapLayerRegistry::removeAllMapLayers()
QString id = it.key();
myList << id;
}
removeMapLayers(myList, false);
removeMapLayers( myList, false );
mMapLayers.clear();
} // QgsMapLayerRegistry::removeAllMapLayers()

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ QgsVectorLayer::QgsVectorLayer( QString vectorLayerPath,
#else
bool use_symbology_ng_default = true;
#endif
if ( settings.value( "/qgis/use_symbology_ng", use_symbology_ng_default ).toBool() && hasGeometryType() )
if ( settings.value( "/qgis/use_symbology_ng", use_symbology_ng_default ).toBool() && hasGeometryType() )
{
// using symbology-ng!
setUsingRendererV2( true );
Expand Down
653 changes: 349 additions & 304 deletions src/core/quazip/JlCompress.cpp

Large diffs are not rendered by default.

31 changes: 16 additions & 15 deletions src/core/quazip/JlCompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
This class contains a number of useful static functions to perform
simple operations, such as mass ZIP packing or extraction.
*/
class QUAZIP_EXPORT JlCompress {
private:
class QUAZIP_EXPORT JlCompress
{
private:
/// Compress a single file.
/**
\param zip Opened zip to compress the file to.
\param fileName The full path to the source file.
\param fileDest The full name of the file inside the archive.
\return true if success, false otherwise.
*/
static bool compressFile(QuaZip* zip, QString fileName, QString fileDest);
static bool compressFile( QuaZip* zip, QString fileName, QString fileDest );
/// Compress a subdirectory.
/**
\param parentZip Opened zip containing the parent directory.
Expand All @@ -34,37 +35,37 @@ class QUAZIP_EXPORT JlCompress {
files.
\return true if success, false otherwise.
*/
static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive = true);
static bool compressSubDir( QuaZip* parentZip, QString dir, QString parentDir, bool recursive = true );
/// Extract a single file.
/**
\param zip The opened zip archive to extract from.
\param fileName The full name of the file to extract.
\param fileDest The full path to the destination file.
\return true if success, false otherwise.
*/
static bool extractFile(QuaZip* zip, QString fileName, QString fileDest);
static bool extractFile( QuaZip* zip, QString fileName, QString fileDest );
/// Remove some files.
/**
\param listFile The list of files to remove.
\return true if success, false otherwise.
*/
static bool removeFile(QStringList listFile);
static bool removeFile( QStringList listFile );

public:
public:
/// Compress a single file.
/**
\param fileCompressed The name of the archive.
\param file The file to compress.
\return true if success, false otherwise.
*/
static bool compressFile(QString fileCompressed, QString file);
static bool compressFile( QString fileCompressed, QString file );
/// Compress a list of files.
/**
\param fileCompressed The name of the archive.
\param files The file list to compress.
\return true if success, false otherwise.
*/
static bool compressFiles(QString fileCompressed, QStringList files);
static bool compressFiles( QString fileCompressed, QStringList files );
/// Compress a whole directory.
/**
\param fileCompressed The name of the archive.
Expand All @@ -73,9 +74,9 @@ class QUAZIP_EXPORT JlCompress {
just regular files.
\return true if success, false otherwise.
*/
static bool compressDir(QString fileCompressed, QString dir = QString(), bool recursive = true);
static bool compressDir( QString fileCompressed, QString dir = QString(), bool recursive = true );

public:
public:
/// Extract a single file.
/**
\param fileCompressed The name of the archive.
Expand All @@ -84,7 +85,7 @@ class QUAZIP_EXPORT JlCompress {
\a file if left empty.
\return The list of the full paths of the files extracted, empty on failure.
*/
static QString extractFile(QString fileCompressed, QString fileName, QString fileDest = QString());
static QString extractFile( QString fileCompressed, QString fileName, QString fileDest = QString() );
/// Extract a list of files.
/**
\param fileCompressed The name of the archive.
Expand All @@ -93,22 +94,22 @@ class QUAZIP_EXPORT JlCompress {
directory if left empty.
\return The list of the full paths of the files extracted, empty on failure.
*/
static QStringList extractFiles(QString fileCompressed, QStringList files, QString dir = QString());
static QStringList extractFiles( QString fileCompressed, QStringList files, QString dir = QString() );
/// Extract a whole archive.
/**
\param fileCompressed The name of the archive.
\param dir The directory to extract to, the current directory if
left empty.
\return The list of the full paths of the files extracted, empty on failure.
*/
static QStringList extractDir(QString fileCompressed, QString dir = QString());
static QStringList extractDir( QString fileCompressed, QString dir = QString() );
/// Get the file list.
/**
\return The list of the files in the archive, or, more precisely, the
list of the entries, including both files and directories if they
are present separately.
*/
static QStringList getFileList(QString fileCompressed);
static QStringList getFileList( QString fileCompressed );
};

#endif /* JLCOMPRESSFOLDER_H_ */
132 changes: 66 additions & 66 deletions src/core/quazip/README.txt
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
QuaZIP is the C++ wrapper for the Gilles Vollant's ZIP/UNZIP package
using Trolltech's Qt library.
It contains original ZIP/UNZIP package C code and therefore depends on
zlib library.
Also, it depends on Qt 4.
To comile it on UNIX dialect:
$ cd quazip
$ qmake
$ make
You must make sure that:
* You have Qt 4 properly and fully installed (including tools and
headers, not just library)
* "qmake" command runs Qt 4's qmake, not some other version (you'll have
to type full path to qmake otherwise).
To install compiled shared library, just type:
$ make install
By default, it installs in /usr/local, but you may change it using
$ qmake PREFIX=/wherever/you/whant/to/install
You do not have to compile and install QuaZIP to use it. You can just
(and sometimes it may be the best way) add QuaZIP's source files to your
project and use them.
See doc/html or, if you do not have a browser, quazip/*.h and
quazip/doc/* files for the more detailed documentation.
For Windows, it's essentially the same, but you may have to adjust
settings for different environments.
If you want to include QuaZIP sources directly into your project or if
you want to use QuaZIP compiled as a static library using
"qmake CONFIG+=statliclib", you have to define the QUAZIP_STATIC macro,
otherwise you're likely to run into problems as QuaZIP symbols will be
marked as dllimported.
Copyright notice:
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
QuaZIP is the C++ wrapper for the Gilles Vollant's ZIP/UNZIP package
using Trolltech's Qt library.

It contains original ZIP/UNZIP package C code and therefore depends on
zlib library.

Also, it depends on Qt 4.

To comile it on UNIX dialect:

$ cd quazip
$ qmake
$ make

You must make sure that:
* You have Qt 4 properly and fully installed (including tools and
headers, not just library)
* "qmake" command runs Qt 4's qmake, not some other version (you'll have
to type full path to qmake otherwise).

To install compiled shared library, just type:

$ make install

By default, it installs in /usr/local, but you may change it using

$ qmake PREFIX=/wherever/you/whant/to/install

You do not have to compile and install QuaZIP to use it. You can just
(and sometimes it may be the best way) add QuaZIP's source files to your
project and use them.

See doc/html or, if you do not have a browser, quazip/*.h and
quazip/doc/* files for the more detailed documentation.

For Windows, it's essentially the same, but you may have to adjust
settings for different environments.

If you want to include QuaZIP sources directly into your project or if
you want to use QuaZIP compiled as a static library using
"qmake CONFIG+=statliclib", you have to define the QUAZIP_STATIC macro,
otherwise you're likely to run into problems as QuaZIP symbols will be
marked as dllimported.

Copyright notice:

Copyright (C) 2005-2011 Sergey A. Tachenov

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser 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

See COPYING file for the full LGPL text.

Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
271 changes: 136 additions & 135 deletions src/core/quazip/crypt.h
Original file line number Diff line number Diff line change
@@ -1,135 +1,136 @@
/* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/

#include "quazip_global.h"

#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))

/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab UNUSED)
{
//(void) pcrc_32_tab; /* avoid "unused parameter" warning */
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */

temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}

/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
{
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
(*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1;
{
register int keyshift = (int)((*(pkeys+1)) >> 24);
(*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift);
}
return c;
}


/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
{
*(pkeys+0) = 305419896L;
*(pkeys+1) = 591751049L;
*(pkeys+2) = 878082192L;
while (*passwd != '\0') {
update_keys(pkeys,pcrc_32_tab,(int)*passwd);
passwd++;
}
}

#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))

#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))

#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED

#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif

static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */

if (bufSize<RAND_HEAD_LEN)
return 0;

/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if (++calls == 1)
{
srand((unsigned)(time(NULL) ^ ZCR_SEED2));
}
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
c = (rand() >> 7) & 0xff;
header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t);
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys(passwd, pkeys, pcrc_32_tab);
for (n = 0; n < RAND_HEAD_LEN-2; n++)
{
buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t);
}
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t);
buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t);
return n;
}

#endif
/* crypt.h -- base code for crypt/uncrypt ZIPfile
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
This code is a modified version of crypting code in Infozip distribution
The encryption/decryption parts of this source code (as opposed to the
non-echoing password parts) were originally written in Europe. The
whole source package can be freely distributed, including from the USA.
(Prior to January 2000, re-export from the US was a violation of US law.)
This encryption code is a direct transcription of the algorithm from
Roger Schlafly, described by Phil Katz in the file appnote.txt. This
file (appnote.txt) is distributed with the PKZIP program (even in the
version without encryption capabilities).
If you don't need crypting in your application, just define symbols
NOCRYPT and NOUNCRYPT.
This code support the "Traditional PKWARE Encryption".
The new AES encryption added on Zip format by Winzip (see the page
http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong
Encryption is not supported.
*/

#include "quazip_global.h"

#define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))

/***********************************************************************
* Return the next byte in the pseudo-random sequence
*/
static int decrypt_byte( unsigned long* pkeys, const unsigned long* pcrc_32_tab UNUSED )
{
//(void) pcrc_32_tab; /* avoid "unused parameter" warning */
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */

temp = (( unsigned )( *( pkeys + 2 ) ) & 0xffff ) | 2;
return ( int )((( temp * ( temp ^ 1 ) ) >> 8 ) & 0xff );
}

/***********************************************************************
* Update the encryption keys with the next byte of plain text
*/
static int update_keys( unsigned long* pkeys, const unsigned long* pcrc_32_tab, int c )
{
( *( pkeys + 0 ) ) = CRC32(( *( pkeys + 0 ) ), c );
( *( pkeys + 1 ) ) += ( *( pkeys + 0 ) ) & 0xff;
( *( pkeys + 1 ) ) = ( *( pkeys + 1 ) ) * 134775813L + 1;
{
register int keyshift = ( int )(( *( pkeys + 1 ) ) >> 24 );
( *( pkeys + 2 ) ) = CRC32(( *( pkeys + 2 ) ), keyshift );
}
return c;
}


/***********************************************************************
* Initialize the encryption keys and the random header according to
* the given password.
*/
static void init_keys( const char* passwd, unsigned long* pkeys, const unsigned long* pcrc_32_tab )
{
*( pkeys + 0 ) = 305419896L;
*( pkeys + 1 ) = 591751049L;
*( pkeys + 2 ) = 878082192L;
while ( *passwd != '\0' )
{
update_keys( pkeys, pcrc_32_tab, ( int )*passwd );
passwd++;
}
}

#define zdecode(pkeys,pcrc_32_tab,c) \
(update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab)))

#define zencode(pkeys,pcrc_32_tab,c,t) \
(t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c))

#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED

#define RAND_HEAD_LEN 12
/* "last resort" source for second part of crypt seed pattern */
# ifndef ZCR_SEED2
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif

static int crypthead( passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting )
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
{
int n; /* index in random header */
int t; /* temporary */
int c; /* random byte */
unsigned char header[RAND_HEAD_LEN-2]; /* random header */
static unsigned calls = 0; /* ensure different random header each time */

if ( bufSize < RAND_HEAD_LEN )
return 0;

/* First generate RAND_HEAD_LEN-2 random bytes. We encrypt the
* output of rand() to get less predictability, since rand() is
* often poorly implemented.
*/
if ( ++calls == 1 )
{
srand(( unsigned )( time( NULL ) ^ ZCR_SEED2 ) );
}
init_keys( passwd, pkeys, pcrc_32_tab );
for ( n = 0; n < RAND_HEAD_LEN - 2; n++ )
{
c = ( rand() >> 7 ) & 0xff;
header[n] = ( unsigned char )zencode( pkeys, pcrc_32_tab, c, t );
}
/* Encrypt random header (last two bytes is high word of crc) */
init_keys( passwd, pkeys, pcrc_32_tab );
for ( n = 0; n < RAND_HEAD_LEN - 2; n++ )
{
buf[n] = ( unsigned char )zencode( pkeys, pcrc_32_tab, header[n], t );
}
buf[n++] = zencode( pkeys, pcrc_32_tab, ( int )( crcForCrypting >> 16 ) & 0xff, t );
buf[n++] = zencode( pkeys, pcrc_32_tab, ( int )( crcForCrypting >> 24 ) & 0xff, t );
return n;
}

#endif
155 changes: 78 additions & 77 deletions src/core/quazip/ioapi.h
Original file line number Diff line number Diff line change
@@ -1,77 +1,78 @@
/* ioapi.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
Modified by Sergey A. Tachenov to integrate with Qt.
*/

#ifndef _ZLIBIOAPI_H
#define _ZLIBIOAPI_H


#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)

#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)

#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)


#ifndef ZCALLBACK

#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK
#else
#define ZCALLBACK
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf file, int mode));
typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));

typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;



void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));

#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))


#ifdef __cplusplus
}
#endif

#endif

/* ioapi.h -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
Modified by Sergey A. Tachenov to integrate with Qt.
*/

#ifndef _ZLIBIOAPI_H
#define _ZLIBIOAPI_H


#define ZLIB_FILEFUNC_SEEK_CUR (1)
#define ZLIB_FILEFUNC_SEEK_END (2)
#define ZLIB_FILEFUNC_SEEK_SET (0)

#define ZLIB_FILEFUNC_MODE_READ (1)
#define ZLIB_FILEFUNC_MODE_WRITE (2)
#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3)

#define ZLIB_FILEFUNC_MODE_EXISTING (4)
#define ZLIB_FILEFUNC_MODE_CREATE (8)


#ifndef ZCALLBACK

#if (defined(WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK)
#define ZCALLBACK CALLBACK
#else
#define ZCALLBACK
#endif
#endif

#ifdef __cplusplus
extern "C"
{
#endif

typedef voidpf( ZCALLBACK *open_file_func ) OF(( voidpf opaque, voidpf file, int mode ) );
typedef uLong( ZCALLBACK *read_file_func ) OF(( voidpf opaque, voidpf stream, void* buf, uLong size ) );
typedef uLong( ZCALLBACK *write_file_func ) OF(( voidpf opaque, voidpf stream, const void* buf, uLong size ) );
typedef uLong( ZCALLBACK *tell_file_func ) OF(( voidpf opaque, voidpf stream ) );
typedef int ( ZCALLBACK *seek_file_func ) OF(( voidpf opaque, voidpf stream, uLong offset, int origin ) );
typedef int ( ZCALLBACK *close_file_func ) OF(( voidpf opaque, voidpf stream ) );
typedef int ( ZCALLBACK *testerror_file_func ) OF(( voidpf opaque, voidpf stream ) );

typedef struct zlib_filefunc_def_s
{
open_file_func zopen_file;
read_file_func zread_file;
write_file_func zwrite_file;
tell_file_func ztell_file;
seek_file_func zseek_file;
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
} zlib_filefunc_def;



void fill_qiodevice_filefunc OF(( zlib_filefunc_def* pzlib_filefunc_def ) );

#define ZREAD(filefunc,filestream,buf,size) ((*((filefunc).zread_file))((filefunc).opaque,filestream,buf,size))
#define ZWRITE(filefunc,filestream,buf,size) ((*((filefunc).zwrite_file))((filefunc).opaque,filestream,buf,size))
#define ZTELL(filefunc,filestream) ((*((filefunc).ztell_file))((filefunc).opaque,filestream))
#define ZSEEK(filefunc,filestream,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque,filestream,pos,mode))
#define ZCLOSE(filefunc,filestream) ((*((filefunc).zclose_file))((filefunc).opaque,filestream))
#define ZERROR(filefunc,filestream) ((*((filefunc).zerror_file))((filefunc).opaque,filestream))


#ifdef __cplusplus
}
#endif

#endif

295 changes: 150 additions & 145 deletions src/core/quazip/qioapi.cpp
Original file line number Diff line number Diff line change
@@ -1,145 +1,150 @@
/* ioapi.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
Modified by Sergey A. Tachenov to integrate with Qt.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "zlib.h"
#include "ioapi.h"
#include "quazip_global.h"
#include <QIODevice>


/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */

#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif

#ifndef SEEK_END
#define SEEK_END 2
#endif

#ifndef SEEK_SET
#define SEEK_SET 0
#endif

voidpf ZCALLBACK qiodevice_open_file_func (
voidpf opaque UNUSED,
voidpf file,
int mode)
{
QIODevice *iodevice = reinterpret_cast<QIODevice*>(file);
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
iodevice->open(QIODevice::ReadOnly);
else
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
iodevice->open(QIODevice::ReadWrite);
else
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
iodevice->open(QIODevice::WriteOnly);

if (iodevice->isOpen()) {
if (iodevice->isSequential()) {
iodevice->close();
return NULL;
} else {
return iodevice;
}
} else
return NULL;
}


uLong ZCALLBACK qiodevice_read_file_func (
voidpf opaque UNUSED,
voidpf stream,
void* buf,
uLong size)
{
uLong ret;
ret = (uLong)((QIODevice*)stream)->read((char*)buf,size);
return ret;
}


uLong ZCALLBACK qiodevice_write_file_func (
voidpf opaque UNUSED,
voidpf stream,
const void* buf,
uLong size)
{
uLong ret;
ret = (uLong)((QIODevice*)stream)->write((char*)buf,size);
return ret;
}

uLong ZCALLBACK qiodevice_tell_file_func (
voidpf opaque UNUSED,
voidpf stream)
{
uLong ret;
ret = ((QIODevice*)stream)->pos();
return ret;
}

int ZCALLBACK qiodevice_seek_file_func (
voidpf opaque UNUSED,
voidpf stream,
uLong offset,
int origin)
{
uLong qiodevice_seek_result=0;
int ret;
switch (origin)
{
case ZLIB_FILEFUNC_SEEK_CUR :
qiodevice_seek_result = ((QIODevice*)stream)->pos() + offset;
break;
case ZLIB_FILEFUNC_SEEK_END :
qiodevice_seek_result = ((QIODevice*)stream)->size() - offset;
break;
case ZLIB_FILEFUNC_SEEK_SET :
qiodevice_seek_result = offset;
break;
default: return -1;
}
ret = !((QIODevice*)stream)->seek(qiodevice_seek_result);
return ret;
}

int ZCALLBACK qiodevice_close_file_func (
voidpf opaque UNUSED,
voidpf stream)
{
((QIODevice*)stream)->close();
return 0;
}

int ZCALLBACK qiodevice_error_file_func (
voidpf opaque UNUSED,
voidpf stream)
{
return !((QIODevice*)stream)->errorString().isEmpty();
}

void fill_qiodevice_filefunc (
zlib_filefunc_def* pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen_file = qiodevice_open_file_func;
pzlib_filefunc_def->zread_file = qiodevice_read_file_func;
pzlib_filefunc_def->zwrite_file = qiodevice_write_file_func;
pzlib_filefunc_def->ztell_file = qiodevice_tell_file_func;
pzlib_filefunc_def->zseek_file = qiodevice_seek_file_func;
pzlib_filefunc_def->zclose_file = qiodevice_close_file_func;
pzlib_filefunc_def->zerror_file = qiodevice_error_file_func;
pzlib_filefunc_def->opaque = NULL;
}
/* ioapi.c -- IO base function header for compress/uncompress .zip
files using zlib + zip or unzip API
Version 1.01e, February 12th, 2005
Copyright (C) 1998-2005 Gilles Vollant
Modified by Sergey A. Tachenov to integrate with Qt.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "zlib.h"
#include "ioapi.h"
#include "quazip_global.h"
#include <QIODevice>


/* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */

#ifndef SEEK_CUR
#define SEEK_CUR 1
#endif

#ifndef SEEK_END
#define SEEK_END 2
#endif

#ifndef SEEK_SET
#define SEEK_SET 0
#endif

voidpf ZCALLBACK qiodevice_open_file_func(
voidpf opaque UNUSED,
voidpf file,
int mode )
{
QIODevice *iodevice = reinterpret_cast<QIODevice*>( file );
if (( mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER ) == ZLIB_FILEFUNC_MODE_READ )
iodevice->open( QIODevice::ReadOnly );
else
if ( mode & ZLIB_FILEFUNC_MODE_EXISTING )
iodevice->open( QIODevice::ReadWrite );
else
if ( mode & ZLIB_FILEFUNC_MODE_CREATE )
iodevice->open( QIODevice::WriteOnly );

if ( iodevice->isOpen() )
{
if ( iodevice->isSequential() )
{
iodevice->close();
return NULL;
}
else
{
return iodevice;
}
}
else
return NULL;
}


uLong ZCALLBACK qiodevice_read_file_func(
voidpf opaque UNUSED,
voidpf stream,
void* buf,
uLong size )
{
uLong ret;
ret = ( uLong )(( QIODevice* )stream )->read(( char* )buf, size );
return ret;
}


uLong ZCALLBACK qiodevice_write_file_func(
voidpf opaque UNUSED,
voidpf stream,
const void* buf,
uLong size )
{
uLong ret;
ret = ( uLong )(( QIODevice* )stream )->write(( char* )buf, size );
return ret;
}

uLong ZCALLBACK qiodevice_tell_file_func(
voidpf opaque UNUSED,
voidpf stream )
{
uLong ret;
ret = (( QIODevice* )stream )->pos();
return ret;
}

int ZCALLBACK qiodevice_seek_file_func(
voidpf opaque UNUSED,
voidpf stream,
uLong offset,
int origin )
{
uLong qiodevice_seek_result = 0;
int ret;
switch ( origin )
{
case ZLIB_FILEFUNC_SEEK_CUR :
qiodevice_seek_result = (( QIODevice* )stream )->pos() + offset;
break;
case ZLIB_FILEFUNC_SEEK_END :
qiodevice_seek_result = (( QIODevice* )stream )->size() - offset;
break;
case ZLIB_FILEFUNC_SEEK_SET :
qiodevice_seek_result = offset;
break;
default: return -1;
}
ret = !(( QIODevice* )stream )->seek( qiodevice_seek_result );
return ret;
}

int ZCALLBACK qiodevice_close_file_func(
voidpf opaque UNUSED,
voidpf stream )
{
(( QIODevice* )stream )->close();
return 0;
}

int ZCALLBACK qiodevice_error_file_func(
voidpf opaque UNUSED,
voidpf stream )
{
return !(( QIODevice* )stream )->errorString().isEmpty();
}

void fill_qiodevice_filefunc(
zlib_filefunc_def* pzlib_filefunc_def )
{
pzlib_filefunc_def->zopen_file = qiodevice_open_file_func;
pzlib_filefunc_def->zread_file = qiodevice_read_file_func;
pzlib_filefunc_def->zwrite_file = qiodevice_write_file_func;
pzlib_filefunc_def->ztell_file = qiodevice_tell_file_func;
pzlib_filefunc_def->zseek_file = qiodevice_seek_file_func;
pzlib_filefunc_def->zclose_file = qiodevice_close_file_func;
pzlib_filefunc_def->zerror_file = qiodevice_error_file_func;
pzlib_filefunc_def->opaque = NULL;
}
14 changes: 7 additions & 7 deletions src/core/quazip/quaadler32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

QuaAdler32::QuaAdler32()
{
reset();
reset();
}

quint32 QuaAdler32::calculate(const QByteArray &data)
quint32 QuaAdler32::calculate( const QByteArray &data )
{
return adler32( adler32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
return adler32( adler32( 0L, Z_NULL, 0 ), ( const Bytef* )data.data(), data.size() );
}

void QuaAdler32::reset()
{
checksum = adler32(0L, Z_NULL, 0);
checksum = adler32( 0L, Z_NULL, 0 );
}

void QuaAdler32::update(const QByteArray &buf)
void QuaAdler32::update( const QByteArray &buf )
{
checksum = adler32( checksum, (const Bytef*)buf.data(), buf.size() );
checksum = adler32( checksum, ( const Bytef* )buf.data(), buf.size() );
}

quint32 QuaAdler32::value()
{
return checksum;
return checksum;
}
16 changes: 8 additions & 8 deletions src/core/quazip/quaadler32.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
class QUAZIP_EXPORT QuaAdler32 : public QuaChecksum32
{

public:
QuaAdler32();
public:
QuaAdler32();

quint32 calculate(const QByteArray &data);
quint32 calculate( const QByteArray &data );

void reset();
void update(const QByteArray &buf);
quint32 value();
void reset();
void update( const QByteArray &buf );
quint32 value();

private:
quint32 checksum;
private:
quint32 checksum;
};

#endif //QUAADLER32_H
40 changes: 20 additions & 20 deletions src/core/quazip/quachecksum32.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
* Classes implementing this interface can calcunate a certin
* checksum in a single step:
* \code
* QChecksum32 *crc32 = new QuaCrc32();
* QChecksum32 *crc32 = new QuaCrc32();
* rasoult = crc32->calculate(data);
* \endcode
* or by streaming the data:
* \code
* QChecksum32 *crc32 = new QuaCrc32();
* QChecksum32 *crc32 = new QuaCrc32();
* while(!fileA.atEnd())
* crc32->update(fileA.read(bufSize));
* resoultA = crc32->value();
Expand All @@ -28,27 +28,27 @@
class QUAZIP_EXPORT QuaChecksum32
{

public:
///Calculates the checksum for data.
/** \a data source data
* \return data checksum
*
* This function has no efect on the value returned by value().
*/
virtual quint32 calculate(const QByteArray &data) = 0;
public:
///Calculates the checksum for data.
/** \a data source data
* \return data checksum
*
* This function has no efect on the value returned by value().
*/
virtual quint32 calculate( const QByteArray &data ) = 0;

///Resets the calculation on a checksun for a stream.
virtual void reset() = 0;
///Resets the calculation on a checksun for a stream.
virtual void reset() = 0;

///Updates the calculated checksum for the stream
/** \a buf next portion of data from the stream
*/
virtual void update(const QByteArray &buf) = 0;
///Updates the calculated checksum for the stream
/** \a buf next portion of data from the stream
*/
virtual void update( const QByteArray &buf ) = 0;

///Value of the checksum calculated for the stream passed throw update().
/** \return checksum
*/
virtual quint32 value() = 0;
///Value of the checksum calculated for the stream passed throw update().
/** \return checksum
*/
virtual quint32 value() = 0;
};

#endif //QUACHECKSUM32_H
14 changes: 7 additions & 7 deletions src/core/quazip/quacrc32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

QuaCrc32::QuaCrc32()
{
reset();
reset();
}

quint32 QuaCrc32::calculate(const QByteArray &data)
quint32 QuaCrc32::calculate( const QByteArray &data )
{
return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() );
return crc32( crc32( 0L, Z_NULL, 0 ), ( const Bytef* )data.data(), data.size() );
}

void QuaCrc32::reset()
{
checksum = crc32(0L, Z_NULL, 0);
checksum = crc32( 0L, Z_NULL, 0 );
}

void QuaCrc32::update(const QByteArray &buf)
void QuaCrc32::update( const QByteArray &buf )
{
checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() );
checksum = crc32( checksum, ( const Bytef* )buf.data(), buf.size() );
}

quint32 QuaCrc32::value()
{
return checksum;
return checksum;
}
19 changes: 10 additions & 9 deletions src/core/quazip/quacrc32.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
* This class wrappers the crc32 function with the QuaChecksum32 interface.
* See QuaChecksum32 for more info.
*/
class QUAZIP_EXPORT QuaCrc32 : public QuaChecksum32 {
class QUAZIP_EXPORT QuaCrc32 : public QuaChecksum32
{

public:
QuaCrc32();
public:
QuaCrc32();

quint32 calculate(const QByteArray &data);
quint32 calculate( const QByteArray &data );

void reset();
void update(const QByteArray &buf);
quint32 value();
void reset();
void update( const QByteArray &buf );
quint32 value();

private:
quint32 checksum;
private:
quint32 checksum;
};

#endif //QUACRC32_H
1,134 changes: 588 additions & 546 deletions src/core/quazip/quazip.cpp

Large diffs are not rendered by default.

816 changes: 410 additions & 406 deletions src/core/quazip/quazip.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/core/quazip/quazip_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ quazip/(un)zip.h files for details, basically it's zlib license.
* qglobal.h takes care of defining Q_DECL_* correctly for msvc/gcc.
*/
#if defined(QUAZIP_BUILD)
#define QUAZIP_EXPORT Q_DECL_EXPORT
#define QUAZIP_EXPORT Q_DECL_EXPORT
#else
#define QUAZIP_EXPORT Q_DECL_IMPORT
#define QUAZIP_EXPORT Q_DECL_IMPORT
#endif
#endif // QUAZIP_STATIC

Expand Down
998 changes: 517 additions & 481 deletions src/core/quazip/quazipfile.cpp

Large diffs are not rendered by default.

885 changes: 443 additions & 442 deletions src/core/quazip/quazipfile.h

Large diffs are not rendered by default.

133 changes: 67 additions & 66 deletions src/core/quazip/quazipfileinfo.h
Original file line number Diff line number Diff line change
@@ -1,66 +1,67 @@
#ifndef QUA_ZIPFILEINFO_H
#define QUA_ZIPFILEINFO_H

/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
**/

#include <QByteArray>
#include <QDateTime>

#include "quazip_global.h"

/// Information about a file inside archive.
/** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to
* fill this structure. */
struct QUAZIP_EXPORT QuaZipFileInfo {
/// File name.
QString name;
/// Version created by.
quint16 versionCreated;
/// Version needed to extract.
quint16 versionNeeded;
/// General purpose flags.
quint16 flags;
/// Compression method.
quint16 method;
/// Last modification date and time.
QDateTime dateTime;
/// CRC.
quint32 crc;
/// Compressed file size.
quint32 compressedSize;
/// Uncompressed file size.
quint32 uncompressedSize;
/// Disk number start.
quint16 diskNumberStart;
/// Internal file attributes.
quint16 internalAttr;
/// External file attributes.
quint32 externalAttr;
/// Comment.
QString comment;
/// Extra field.
QByteArray extra;
};

#endif
#ifndef QUA_ZIPFILEINFO_H
#define QUA_ZIPFILEINFO_H

/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
**/

#include <QByteArray>
#include <QDateTime>

#include "quazip_global.h"

/// Information about a file inside archive.
/** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to
* fill this structure. */
struct QUAZIP_EXPORT QuaZipFileInfo
{
/// File name.
QString name;
/// Version created by.
quint16 versionCreated;
/// Version needed to extract.
quint16 versionNeeded;
/// General purpose flags.
quint16 flags;
/// Compression method.
quint16 method;
/// Last modification date and time.
QDateTime dateTime;
/// CRC.
quint32 crc;
/// Compressed file size.
quint32 compressedSize;
/// Uncompressed file size.
quint32 uncompressedSize;
/// Disk number start.
quint16 diskNumberStart;
/// Internal file attributes.
quint16 internalAttr;
/// External file attributes.
quint32 externalAttr;
/// Comment.
QString comment;
/// Extra field.
QByteArray extra;
};

#endif
102 changes: 51 additions & 51 deletions src/core/quazip/quazipnewinfo.cpp
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
*/

#include <QFileInfo>

#include "quazipnewinfo.h"


QuaZipNewInfo::QuaZipNewInfo(const QString& name):
name(name), dateTime(QDateTime::currentDateTime()), internalAttr(0), externalAttr(0)
{
}

QuaZipNewInfo::QuaZipNewInfo(const QString& name, const QString& file):
name(name), internalAttr(0), externalAttr(0)
{
QFileInfo info(file);
QDateTime lm = info.lastModified();
if (!info.exists())
dateTime = QDateTime::currentDateTime();
else
dateTime = lm;
}

void QuaZipNewInfo::setFileDateTime(const QString& file)
{
QFileInfo info(file);
QDateTime lm = info.lastModified();
if (info.exists())
dateTime = lm;
}
/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
*/

#include <QFileInfo>

#include "quazipnewinfo.h"


QuaZipNewInfo::QuaZipNewInfo( const QString& name ):
name( name ), dateTime( QDateTime::currentDateTime() ), internalAttr( 0 ), externalAttr( 0 )
{
}

QuaZipNewInfo::QuaZipNewInfo( const QString& name, const QString& file ):
name( name ), internalAttr( 0 ), externalAttr( 0 )
{
QFileInfo info( file );
QDateTime lm = info.lastModified();
if ( !info.exists() )
dateTime = QDateTime::currentDateTime();
else
dateTime = lm;
}

void QuaZipNewInfo::setFileDateTime( const QString& file )
{
QFileInfo info( file );
QDateTime lm = info.lastModified();
if ( info.exists() )
dateTime = lm;
}
205 changes: 103 additions & 102 deletions src/core/quazip/quazipnewinfo.h
Original file line number Diff line number Diff line change
@@ -1,102 +1,103 @@
#ifndef QUA_ZIPNEWINFO_H
#define QUA_ZIPNEWINFO_H

/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
**/

#include <QDateTime>
#include <QString>

#include "quazip_global.h"

/// Information about a file to be created.
/** This structure holds information about a file to be created inside
* ZIP archive. At least name should be set to something correct before
* passing this structure to
* QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).
**/
struct QUAZIP_EXPORT QuaZipNewInfo {
/// File name.
/** This field holds file name inside archive, including path relative
* to archive root.
**/
QString name;
/// File timestamp.
/** This is the last file modification date and time. Will be stored
* in the archive central directory. It is a good practice to set it
* to the source file timestamp instead of archive creating time. Use
* setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
**/
QDateTime dateTime;
/// File internal attributes.
quint16 internalAttr;
/// File external attributes.
quint32 externalAttr;
/// File comment.
/** Will be encoded using QuaZip::getCommentCodec().
**/
QString comment;
/// File local extra field.
QByteArray extraLocal;
/// File global extra field.
QByteArray extraGlobal;
/// Uncompressed file size.
/** This is only needed if you are using raw file zipping mode, i. e.
* adding precompressed file in the zip archive.
**/
ulong uncompressedSize;
/// Constructs QuaZipNewInfo instance.
/** Initializes name with \a name, dateTime with current date and
* time. Attributes are initialized with zeros, comment and extra
* field with null values.
**/
QuaZipNewInfo(const QString& name);
/// Constructs QuaZipNewInfo instance.
/** Initializes name with \a name and dateTime with timestamp of the
* file named \a file. If the \a file does not exists or its timestamp
* is inaccessible (e. g. you do not have read permission for the
* directory file in), uses current date and time. Attributes are
* initialized with zeros, comment and extra field with null values.
*
* \sa setFileDateTime()
**/
QuaZipNewInfo(const QString& name, const QString& file);
/// Sets the file timestamp from the existing file.
/** Use this function to set the file timestamp from the existing
* file. Use it like this:
* \code
* QuaZipFile zipFile(&zip);
* QFile file("file-to-add");
* file.open(QIODevice::ReadOnly);
* QuaZipNewInfo info("file-name-in-archive");
* info.setFileDateTime("file-to-add"); // take the timestamp from file
* zipFile.open(QIODevice::WriteOnly, info);
* \endcode
*
* This function does not change dateTime if some error occured (e. g.
* file is inaccessible).
**/
void setFileDateTime(const QString& file);
};

#endif
#ifndef QUA_ZIPNEWINFO_H
#define QUA_ZIPNEWINFO_H

/*
Copyright (C) 2005-2011 Sergey A. Tachenov
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser 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 Lesser
General Public License for more details.
You should have received a copy of the GNU Lesser 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
See COPYING file for the full LGPL text.
Original ZIP package is copyrighted by Gilles Vollant, see
quazip/(un)zip.h files for details, basically it's zlib license.
**/

#include <QDateTime>
#include <QString>

#include "quazip_global.h"

/// Information about a file to be created.
/** This structure holds information about a file to be created inside
* ZIP archive. At least name should be set to something correct before
* passing this structure to
* QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).
**/
struct QUAZIP_EXPORT QuaZipNewInfo
{
/// File name.
/** This field holds file name inside archive, including path relative
* to archive root.
**/
QString name;
/// File timestamp.
/** This is the last file modification date and time. Will be stored
* in the archive central directory. It is a good practice to set it
* to the source file timestamp instead of archive creating time. Use
* setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
**/
QDateTime dateTime;
/// File internal attributes.
quint16 internalAttr;
/// File external attributes.
quint32 externalAttr;
/// File comment.
/** Will be encoded using QuaZip::getCommentCodec().
**/
QString comment;
/// File local extra field.
QByteArray extraLocal;
/// File global extra field.
QByteArray extraGlobal;
/// Uncompressed file size.
/** This is only needed if you are using raw file zipping mode, i. e.
* adding precompressed file in the zip archive.
**/
ulong uncompressedSize;
/// Constructs QuaZipNewInfo instance.
/** Initializes name with \a name, dateTime with current date and
* time. Attributes are initialized with zeros, comment and extra
* field with null values.
**/
QuaZipNewInfo( const QString& name );
/// Constructs QuaZipNewInfo instance.
/** Initializes name with \a name and dateTime with timestamp of the
* file named \a file. If the \a file does not exists or its timestamp
* is inaccessible (e. g. you do not have read permission for the
* directory file in), uses current date and time. Attributes are
* initialized with zeros, comment and extra field with null values.
*
* \sa setFileDateTime()
**/
QuaZipNewInfo( const QString& name, const QString& file );
/// Sets the file timestamp from the existing file.
/** Use this function to set the file timestamp from the existing
* file. Use it like this:
* \code
* QuaZipFile zipFile(&zip);
* QFile file("file-to-add");
* file.open(QIODevice::ReadOnly);
* QuaZipNewInfo info("file-name-in-archive");
* info.setFileDateTime("file-to-add"); // take the timestamp from file
* zipFile.open(QIODevice::WriteOnly, info);
* \endcode
*
* This function does not change dateTime if some error occured (e. g.
* file is inaccessible).
**/
void setFileDateTime( const QString& file );
};

#endif
3,210 changes: 1,607 additions & 1,603 deletions src/core/quazip/unzip.c

Large diffs are not rendered by default.

713 changes: 357 additions & 356 deletions src/core/quazip/unzip.h

Large diffs are not rendered by default.

2,564 changes: 1,283 additions & 1,281 deletions src/core/quazip/zip.c

Large diffs are not rendered by default.

491 changes: 246 additions & 245 deletions src/core/quazip/zip.h

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1569,12 +1569,12 @@ bool QgsMapCanvas::event( QEvent * e )
{
return done;
}
if (e->type() == QEvent::Gesture )
if ( e->type() == QEvent::Gesture )
{
// call handler of current map tool
if ( mMapTool )
{
done = mMapTool->gestureEvent( static_cast<QGestureEvent*>(e) );
done = mMapTool->gestureEvent( static_cast<QGestureEvent*>( e ) );
}
}
else
Expand Down
27 changes: 14 additions & 13 deletions src/gui/qgsmaptooltouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


QgsMapToolTouch::QgsMapToolTouch( QgsMapCanvas* canvas )
: QgsMapTool( canvas ), mDragging( false ), mPinching( false )
: QgsMapTool( canvas ), mDragging( false ), mPinching( false )
{
// set cursor
// QBitmap panBmp = QBitmap::fromData( QSize( 16, 16 ), pan_bits );
Expand All @@ -34,18 +34,18 @@ QgsMapToolTouch::QgsMapToolTouch( QgsMapCanvas* canvas )

QgsMapToolTouch::~QgsMapToolTouch()
{
mCanvas->ungrabGesture(Qt::PinchGesture);
mCanvas->ungrabGesture( Qt::PinchGesture );
}

void QgsMapToolTouch::activate()
{
mCanvas->grabGesture(Qt::PinchGesture);
mCanvas->grabGesture( Qt::PinchGesture );
QgsMapTool::activate();
}

void QgsMapToolTouch::deactivate()
{
mCanvas->ungrabGesture(Qt::PinchGesture);
mCanvas->ungrabGesture( Qt::PinchGesture );
QgsMapTool::deactivate();
}

Expand Down Expand Up @@ -88,27 +88,28 @@ void QgsMapToolTouch::canvasDoubleClickEvent( QMouseEvent *e )
{
if ( !mPinching )
{
mCanvas->zoomWithCenter(e->x(), e->y(), true);
mCanvas->zoomWithCenter( e->x(), e->y(), true );
}
}

bool QgsMapToolTouch::gestureEvent(QGestureEvent *event)
bool QgsMapToolTouch::gestureEvent( QGestureEvent *event )
{
qDebug() << "gesture " << event;
if (QGesture *gesture = event->gesture(Qt::PinchGesture))
if ( QGesture *gesture = event->gesture( Qt::PinchGesture ) )
{
mPinching = true;
pinchTriggered(static_cast<QPinchGesture *>(gesture));
pinchTriggered( static_cast<QPinchGesture *>( gesture ) );
}
return true;
}


void QgsMapToolTouch::pinchTriggered(QPinchGesture *gesture)
void QgsMapToolTouch::pinchTriggered( QPinchGesture *gesture )
{
if (gesture->state() == Qt::GestureFinished) {
if ( gesture->state() == Qt::GestureFinished )
{
//a very small totalScaleFactor indicates a two finger tap (pinch gesture without pinching)
if (0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
if ( 0.98 < gesture->totalScaleFactor() && gesture->totalScaleFactor() < 1.02 )
{
mCanvas->zoomOut();
}
Expand All @@ -118,9 +119,9 @@ void QgsMapToolTouch::pinchTriggered(QPinchGesture *gesture)
QPoint pos = gesture->centerPoint().toPoint();
pos = mCanvas->mapFromGlobal( pos );
// transform the mouse pos to map coordinates
QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( pos.x(),pos.y() );
QgsPoint center = mCanvas->getCoordinateTransform()->toMapPoint( pos.x(), pos.y() );
QgsRectangle r = mCanvas->extent();
r.scale( 1/gesture->totalScaleFactor(), &center );
r.scale( 1 / gesture->totalScaleFactor(), &center );
mCanvas->setExtent( r );
mCanvas->refresh();
}
Expand Down
4 changes: 2 additions & 2 deletions src/gui/qgsmaptooltouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class GUI_EXPORT QgsMapToolTouch : public QgsMapTool
bool mDragging;
//! Flag to indicate a pinch gesture is taking place
bool mPinching;
bool gestureEvent(QGestureEvent *event);
void pinchTriggered(QPinchGesture *gesture);
bool gestureEvent( QGestureEvent *event );
void pinchTriggered( QPinchGesture *gesture );
};

#endif
2 changes: 1 addition & 1 deletion src/providers/mssql/qgsmssqlgeometryparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void QgsMssqlGeometryParser::CopyBytes( void* src, int len )

void QgsMssqlGeometryParser::CopyCoordinates( unsigned char* src )
{
if (IsGeography)
if ( IsGeography )
{
CopyBytes( src + 8, 8 ); // longitude
CopyBytes( src, 8 ); // latitude
Expand Down
8 changes: 4 additions & 4 deletions src/providers/mssql/qgsmssqlprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void QgsMssqlProvider::loadFields()

QVariant QgsMssqlProvider::defaultValue( int fieldId )
{
if ( mDefaultValues.contains(fieldId) )
if ( mDefaultValues.contains( fieldId ) )
return mDefaultValues[fieldId];
else
return QVariant( QString::null );
Expand Down Expand Up @@ -592,7 +592,7 @@ void QgsMssqlProvider::select( QgsAttributeList fetchAttributes,
<< rect.xMinimum() << " " << rect.yMinimum();

mStatement += QString( " where [%1].STIntersects([%2]::STGeomFromText('POLYGON((%3))',%4)) = 1" ).arg(
mGeometryColName, mGeometryColType, r, QString::number( mSRId ) );
mGeometryColName, mGeometryColType, r, QString::number( mSRId ) );
}
mFetchGeom = fetchGeometry;
mAttributesToFetch = fetchAttributes;
Expand Down Expand Up @@ -783,7 +783,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
if ( fld.name().isEmpty() )
continue; // invalid

if ( mDefaultValues.contains(it2.key()) && mDefaultValues[it2.key()] == *it2 )
if ( mDefaultValues.contains( it2.key() ) && mDefaultValues[it2.key()] == *it2 )
continue; // skip fields having default values

if ( !first )
Expand Down Expand Up @@ -856,7 +856,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
if ( fld.name().isEmpty() )
continue; // invalid

if ( mDefaultValues.contains(it2.key()) && mDefaultValues[it2.key()] == *it2 )
if ( mDefaultValues.contains( it2.key() ) && mDefaultValues[it2.key()] == *it2 )
continue; // skip fields having default values

QVariant::Type type = fld.type();
Expand Down
11 changes: 8 additions & 3 deletions src/providers/postgres/qgspgtablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ void QgsPgTableModel::addTableEntry( QgsPostgresLayerProperty layerProperty )
}
else
{
pkCol = pkText = layerProperty.pkCols[0];
if ( layerProperty.pkCols.size() > 1 )
{
pkText = tr( "Select..." );
}

pkCol = layerProperty.pkCols[0];
}

QStandardItem *pkItem = new QStandardItem( pkText );
Expand Down Expand Up @@ -323,9 +328,9 @@ bool QgsPgTableModel::setData( const QModelIndex &idx, const QVariant &value, in

if ( idx.column() == dbtmType || idx.column() == dbtmSrid || idx.column() == dbtmPkCol )
{
QGis::GeometryType geomType = ( QGis::GeometryType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();
QGis::WkbType geomType = ( QGis::WkbType ) idx.sibling( idx.row(), dbtmType ).data( Qt::UserRole + 2 ).toInt();

bool ok = geomType != QGis::UnknownGeometry;
bool ok = geomType != QGis::WKBUnknown;

if ( ok && geomType != QGis::NoGeometry )
idx.sibling( idx.row(), dbtmSrid ).data().toInt( &ok );
Expand Down
2 changes: 1 addition & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3281,7 +3281,7 @@ QGISEXTERN bool deleteLayer( const QString& uri, QString& errCause )
.arg( QgsPostgresConn::quotedValue( schemaName ) )
.arg( QgsPostgresConn::quotedValue( tableName ) );
QgsPostgresResult result = conn->PQexec( sql );
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
errCause = QObject::tr( "Unable to delete layer %1: \n%2" )
.arg( schemaTableName )
Expand Down