Remove all use of Qt3 compatibiliy routines except for the GRASS provider/plugin. Automatic casts of QString to char* have also been removed for compatibility with Qt/Mac-Cocoa (64-bit).

git-svn-id: http://svn.osgeo.org/qgis/trunk@8406 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
telwertowski 2008-05-07 05:15:58 +00:00
parent 3d92641d3e
commit 21708a56fb
131 changed files with 1101 additions and 1319 deletions

View File

@ -151,6 +151,10 @@ FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
# Disable automatic conversion from QString to ASCII 8-bit strings (char *)
# (Keeps code compatible with Qt/Mac/64bit)
ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII)
FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
NAMES lrelease
PATHS ${QT_BINARY_DIR}

View File

@ -89,7 +89,7 @@ signals:
protected:
//! protected constructor
QgsMapLayerRegistry( QObject * parent = 0, const char * name = 0 );
QgsMapLayerRegistry( QObject * parent = 0 );
}; // class QgsMapLayerRegistry

View File

@ -1,5 +1,11 @@
# TODO: delete qgsvectorsymbologywidget.cpp and qgsvectorsymbologywidget.h from SVN
# TODO: delete from SVN
# qgslinestyledialog.(cpp|h)
# qgslinestylewidget.(cpp|h)
# qgsmarkerdialog.(cpp|h)
# qgspatterndialog.(cpp|h)
# qgspointstylewidget.(cpp|h)
# qgsvectorsymbologywidget.(cpp|h)
SET(QGIS_APP_SRCS
main.cpp
@ -25,8 +31,6 @@ SET(QGIS_APP_SRCS
qgshelpviewer.cpp
qgsidentifyresults.cpp
qgslabeldialog.cpp
qgslinestyledialog.cpp
qgslinestylewidget.cpp
qgsludialog.cpp
qgsmaptooladdfeature.cpp
qgsmaptooladdvertex.cpp
@ -41,19 +45,16 @@ SET(QGIS_APP_SRCS
qgsmaptoolselect.cpp
qgsmaptoolsplitfeatures.cpp
qgsmaptoolvertexedit.cpp
qgsmarkerdialog.cpp
qgsmeasuredialog.cpp
qgsmeasuretool.cpp
qgsnewhttpconnection.cpp
qgsnumericsortlistviewitem.cpp
qgsoptions.cpp
qgspastetransformations.cpp
qgspatterndialog.cpp
qgspluginitem.cpp
qgspluginmanager.cpp
qgspluginmetadata.cpp
qgspluginregistry.cpp
qgspointstylewidget.cpp
qgsprojectproperties.cpp
qgsrasterlayerproperties.cpp
qgssearchquerybuilder.cpp
@ -106,19 +107,14 @@ SET (QGIS_APP_MOC_HDRS
qgshelpviewer.h
qgsidentifyresults.h
qgslabeldialog.h
qgslinestyledialog.h
qgslinestylewidget.h
qgsludialog.h
qgsmaplayerinterface.h
qgsmaptoolidentify.h
qgsmarkerdialog.h
qgsmeasuredialog.h
qgsnewhttpconnection.h
qgsoptions.h
qgspastetransformations.h
qgspatterndialog.h
qgspluginmanager.h
qgspointstylewidget.h
qgsprojectproperties.h
qgsrasterlayerproperties.h
qgssearchquerybuilder.h
@ -232,19 +228,19 @@ TARGET_LINK_LIBRARIES(qgis
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY}
#${QT_QTSQL_LIBRARY}
${QT_QTSVG_LIBRARY}
${QT_QTNETWORK_LIBRARY}
#should only be needed for win
${QT_QTMAIN_LIBRARY}
${QT_QT3SUPPORT_LIBRARY}
qgis_core
qgis_gui
)
IF (MSVC)
#This resolves issues like cant find winmain etc
TARGET_LINK_LIBRARIES(qgis qtmain)
ENDIF (MSVC)
IF (${QTVERSION} STRLESS "4.3.0")
TARGET_LINK_LIBRARIES(qgis ${QT_QT3SUPPORT_LIBRARY} )
IF (APPLE)
TARGET_LINK_LIBRARIES(qgis ${QT_QTSQL_LIBRARY} )
ENDIF (APPLE)
ENDIF (${QTVERSION} STRLESS "4.3.0")
IF (APPLE)
TARGET_LINK_LIBRARIES(qgis ${APP_SERVICES_LIBRARY} )

View File

@ -68,11 +68,14 @@ QgsComposer::QgsComposer( QgisApp *qgis): QMainWindow()
mView = new QgsComposerView ( this, mViewFrame);
mPrinter = 0;
QGridLayout *l = new QGridLayout(mViewFrame, 1, 1 );
QGridLayout *l = new QGridLayout(mViewFrame );
l->setMargin(0);
l->addWidget( mView, 0, 0 );
mCompositionOptionsLayout = new QGridLayout( mCompositionOptionsFrame, 1, 1 );
mItemOptionsLayout = new QGridLayout( mItemOptionsFrame, 1, 1 );
mCompositionOptionsLayout = new QGridLayout( mCompositionOptionsFrame );
mCompositionOptionsLayout->setMargin(0);
mItemOptionsLayout = new QGridLayout( mItemOptionsFrame );
mItemOptionsLayout->setMargin(0);
mCompositionNameComboBox->insertItem( tr("Map 1") );
@ -322,7 +325,6 @@ void QgsComposer::on_mActionPrint_activated(void)
// There is a bug in Qt<=4.2.2 (dialog is not correct) if output is set to file
// => disable until they fix it
//mPrinter->setOutputToFile (true ) ;
//mPrinter->setOutputFileName ( QDir::convertSeparators ( QDir::home().path() + "/" + "qgis.eps") );
#endif
mPrinter->setColorMode(QPrinter::Color);
@ -331,7 +333,7 @@ void QgsComposer::on_mActionPrint_activated(void)
{
// Because of bug in Qt<=4.2.2 (dialog is not correct) we have to reset always
// to printer otherwise print to file is checked but printer combobox is in dialog
mPrinter->setOutputToFile(false);
mPrinter->setOutputFileName(NULL);
}
//set the resolution and paper orientation each time we call up the dialog, not just the first time we run it
@ -426,7 +428,7 @@ void QgsComposer::on_mActionPrint_activated(void)
std::cout << "Overwrite the bounding box" << std::endl;
if (!f.open(QIODevice::ReadWrite))
{
throw QgsIOException(tr("Couldn't open " + f.name() + tr(" for read/write")));
throw QgsIOException(tr("Couldn't open ") + f.name() + tr(" for read/write"));
}
Q_LONG offset = 0;
Q_LONG size;
@ -740,7 +742,7 @@ void QgsComposer::on_mActionExportAsImage_activated(void)
if ( result != QDialog::Accepted) return;
myOutputFileNameQString = myQFileDialog->selectedFile();
myOutputFileNameQString = myQFileDialog->selectedFiles().first();
QString myFilterString = myQFileDialog->selectedFilter();
#ifdef QGISDEBUG
std::cout << "Selected filter: " << myFilterString.toLocal8Bit().data() << std::endl;
@ -799,7 +801,7 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
"such as the legend or scale bar.</p>"
#else
"Qt4 svg code. In particular, there are problems "
"with layers not being clipped to the map"
"with layers not being clipped to the map "
"bounding box.</p>"
#endif
"If you require a vector-based output file from "
@ -821,7 +823,7 @@ void QgsComposer::on_mActionExportAsSVG_activated(void)
raise ();
if ( result != QDialog::Accepted) return;
QString myOutputFileNameQString = myQFileDialog->selectedFile();
QString myOutputFileNameQString = myQFileDialog->selectedFiles().first();
if ( myOutputFileNameQString == "" ) return;
myQSettings.writeEntry("/UI/lastSaveAsSvgFile", myOutputFileNameQString);

View File

@ -20,7 +20,6 @@
#include "qgscomposition.h"
class QWidget;
class Q3Canvas;
class QDomNode;
class QDomDocument;

View File

@ -256,7 +256,11 @@ void QgsComposerLabel::setOptions ( void )
void QgsComposerLabel::on_mTextEdit_textChanged()
{
QRectF r = boundingRect();
#if QT_VERSION < 0x040300
mText = mTextEdit->text();
#else
mText = mTextEdit->toPlainText();
#endif
QAbstractGraphicsShapeItem::prepareGeometryChange();
QAbstractGraphicsShapeItem::update();
writeSettings();

View File

@ -286,7 +286,7 @@ void QgsComposerMap::cache ( void )
mCacheExtent.setXmax ( mCacheExtent.xMin() + w * scale );
mCacheExtent.setYmax ( mCacheExtent.yMin() + h * scale );
mCachePixmap.resize( w, h );
mCachePixmap = QPixmap( w, h );
// WARNING: ymax in QgsMapToPixel is device height!!!
QgsMapToPixel transform(scale, h, mCacheExtent.yMin(), mCacheExtent.xMin() );

View File

@ -19,7 +19,6 @@
#include "ui_qgscomposerscalebarbase.h"
#include "qgscomposeritem.h"
#include <QAbstractGraphicsShapeItem>
#include <Q3PointArray>
#include <QRect>
#include <QPen>

View File

@ -26,10 +26,11 @@
#include "qgsvectorlayer.h"
#include <QFontDialog>
#include <QPainter>
#include <Q3PopupMenu>
#include <QGraphicsScene>
#include <QHeaderView>
#include <QMenu>
#include <QPainter>
#include <QTreeWidgetItem>
#include <iostream>
#include <vector>
@ -114,21 +115,11 @@ void QgsComposerVectorLegend::init ( void )
// setActive(true);
// Layers list view
mLayersListView->setColumnText(0,tr("Layers"));
mLayersListView->addColumn(tr("Group"));
mLayersListView->setSorting(-1);
mLayersListView->setResizeMode(Q3ListView::AllColumns);
mLayersListView->setSelectionMode(Q3ListView::Extended);
//x mLayersListView->setResizeMode(QTreeView::AllColumns);
mLayersListView->setColumnHidden(2, true);
mLayersPopupMenu = new Q3PopupMenu( );
mLayersPopupMenu->insertItem( tr("Combine selected layers"), this, SLOT(groupLayers()) );
connect ( mLayersListView, SIGNAL(clicked(Q3ListViewItem *)),
this, SLOT(layerChanged(Q3ListViewItem *)));
connect ( mLayersListView, SIGNAL(rightButtonClicked(Q3ListViewItem *, const QPoint &, int)),
this, SLOT( showLayersPopupMenu(Q3ListViewItem *, const QPoint &, int)) );
connect ( mLayersListView, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
this, SLOT(layerChanged(QTreeWidgetItem *)));
// Plot style
setPlotStyle ( QgsComposition::Preview );
@ -475,7 +466,7 @@ void QgsComposerVectorLegend::cache ( void )
std::cout << "QgsComposerVectorLegend::cache()" << std::endl;
//typical boundingRect size is 15 units wide,
mCachePixmap.resize ((int)QGraphicsRectItem::rect().width(), (int)QGraphicsRectItem::rect().height() );
mCachePixmap = QPixmap((int)QGraphicsRectItem::rect().width(), (int)QGraphicsRectItem::rect().height() );
QPainter p(&mCachePixmap);
@ -666,24 +657,25 @@ void QgsComposerVectorLegend::setOptions ( void )
int nlayers = mMapCanvas->layerCount();
for ( int i = 0; i < nlayers; i++ ) {
QgsMapLayer *layer = mMapCanvas->getZpos(i);
// if ( !layer->visible() ) continue;
//if ( layer->type() != QgsMapLayer::VECTOR ) continue;
Q3CheckListItem *li = new Q3CheckListItem ( mLayersListView, layer->name(), Q3CheckListItem::CheckBox );
QTreeWidgetItem *item = new QTreeWidgetItem(mLayersListView);
item->setText(0, layer->name() );
QString id = layer->getLayerID();
li->setText(2, id );
item->setText(2, id );
item->setCheckState(0, layerOn(id) ? Qt::Checked : Qt::Unchecked);
li->setOn ( layerOn(id) );
int group = layerGroup(id);
if ( group > 0 ) {
li->setText(1, QString::number(group) );
item->setText(1, QString::number(group) );
}
mLayersListView->insertItem ( li );
}
mLayersListView->header()->resizeSections(QHeaderView::Stretch);
}
}
@ -701,11 +693,13 @@ bool QgsComposerVectorLegend::selected( void )
return mSelected;
}
void QgsComposerVectorLegend::showLayersPopupMenu ( Q3ListViewItem * lvi, const QPoint & pt, int )
void QgsComposerVectorLegend::contextMenuEvent( QContextMenuEvent *event)
{
std::cout << "QgsComposerVectorLegend::showLayersPopupMenu" << std::endl;
std::cout << "QgsComposerVectorLegend::contextMenuEvent" << std::endl;
mLayersPopupMenu->exec(pt);
QMenu layersPopupMenu( this);
layersPopupMenu.addAction( tr("Combine selected layers"), this, SLOT(groupLayers()) );
layersPopupMenu.exec( event->globalPos());
}
bool QgsComposerVectorLegend::layerOn ( QString id )
@ -752,15 +746,14 @@ void QgsComposerVectorLegend::setLayerGroup ( QString id, int group )
}
}
void QgsComposerVectorLegend::layerChanged ( Q3ListViewItem *lvi )
void QgsComposerVectorLegend::layerChanged ( QTreeWidgetItem *lvi )
{
std::cout << "QgsComposerVectorLegend::layerChanged" << std::endl;
if ( lvi == 0 ) return;
QString id = lvi->text(2);
Q3CheckListItem *cli = dynamic_cast <Q3CheckListItem *>(lvi);
setLayerOn ( id, cli->isOn() );
setLayerOn(id, lvi->checkState(0) == Qt::Checked);
writeSettings();
@ -773,18 +766,18 @@ void QgsComposerVectorLegend::groupLayers ( void )
{
std::cout << "QgsComposerVectorLegend::groupLayers" << std::endl;
Q3ListViewItemIterator it( mLayersListView );
QTreeWidgetItemIterator it( mLayersListView );
int count = 0;
Q3ListViewItem *lastItem = NULL;
QTreeWidgetItem *lastItem = NULL;
QString id;
while ( it.current() ) {
if ( it.current()->isSelected() ) {
std::cout << "selected: " << it.current()->text(0).toLocal8Bit().data() << " " << it.current()->text(2).toLocal8Bit().data() << std::endl;
while ( *it ) {
if ( (*it)->isSelected() ) {
std::cout << "selected: " << (*it)->text(0).toLocal8Bit().data() << " " << (*it)->text(2).toLocal8Bit().data() << std::endl;
id = it.current()->text(2);
id = (*it)->text(2);
setLayerGroup ( id, mNextLayerGroup );
it.current()->setText(1,QString::number(mNextLayerGroup) );
lastItem = it.current();
(*it)->setText(1,QString::number(mNextLayerGroup) );
lastItem = *it;
count++;
}
++it;

View File

@ -44,20 +44,14 @@
#include "ui_qgscomposervectorlegendbase.h"
#include "qgscomposeritem.h"
#include <QAbstractGraphicsShapeItem>
#include <QGraphicsRectItem>
#include <QPen>
#include <QPixmap>
#include <map>
class QgsComposition;
class QgsMapCanvas;
class QDomNode;
class QDomDocument;
class QFont;
class QPainter;
class QPen;
class Q3PopupMenu;
class QRect;
class QTreeWidgetItem;
/** \class QgsComposerVectorLegend
* \brief Object representing map window.
@ -149,11 +143,8 @@ public slots:
// Called when map was changed
void mapChanged ( int id );
// Show popup menu
void showLayersPopupMenu ( Q3ListViewItem * lvi, const QPoint & pt, int );
// Layer status changed
void layerChanged ( Q3ListViewItem *lvi );
void layerChanged ( QTreeWidgetItem *lvi );
// Combine selected layers
void groupLayers( void );
@ -161,6 +152,10 @@ public slots:
// Frame settings changed
void on_mFrameCheckBox_stateChanged ( int i );
protected:
// Show popup menu
void contextMenuEvent ( QContextMenuEvent * event );
private:
// Pointer to composition
QgsComposition *mComposition;
@ -214,9 +209,6 @@ private:
/** \brief new layer group id */
int mNextLayerGroup;
/** \brief Layers list popup menu */
Q3PopupMenu *mLayersPopupMenu;
/** \brief Draw frame */
bool mFrame;
};

View File

@ -1028,8 +1028,8 @@ bool QgsLegend::readXML(QDomNode& legendnode)
QgsLegendLayerFile* theLegendLayerFile = new QgsLegendLayerFile(lastLayerFileGroup, QgsLegendLayerFile::nameFromLayer(theMapLayer), theMapLayer);
// load layer's visibility and 'show in overview' flag
theLegendLayerFile->setVisible(atoi(childelem.attribute("visible", "1"))); //Default is visible
theLegendLayerFile->setInOverview(atoi(childelem.attribute("inOverview")));
theLegendLayerFile->setVisible(atoi(childelem.attribute("visible", "1").toUtf8())); //Default is visible
theLegendLayerFile->setInOverview(atoi(childelem.attribute("inOverview").toUtf8()));
// set the check state
blockSignals(true);
@ -1432,7 +1432,7 @@ std::deque<QString> QgsLegend::layerIDs()
qWarning("QgsLegend::layerIDs()");
for(std::deque<QString>::iterator it = layers.begin(); it != layers.end(); ++it)
{
qWarning(*it);
qWarning((*it).toUtf8());
}
#endif

View File

@ -270,7 +270,6 @@ void QgsLegendLayerFile::table()
UNUSED(ba);
QMessageBox::critical(0, tr("bad_alloc exception"), tr("Filling the attribute table has been stopped because there was no more virtual memory left"));
}
mTableDisplay->table()->setSorting(true);
connect(mTableDisplay, SIGNAL(deleted()), this, SLOT(invalidateTableDisplay()));
@ -358,7 +357,7 @@ void QgsLegendLayerFile::saveAsShapefileGeneral(bool saveOnlySelection)
QString encoding = openFileDialog->encoding();
QString shapefileName = openFileDialog->selectedFile();
QString shapefileName = openFileDialog->selectedFiles().first();
settings.writeEntry("/UI/lastShapefileDir", QFileInfo(shapefileName).absolutePath());

View File

@ -31,7 +31,6 @@
#include <QStringList>
#include <QStyle>
#include <QPlastiqueStyle>
#include <QTextCodec>
#include <QTranslator>
#include <iostream>
@ -59,6 +58,9 @@
#ifdef Q_OS_MACX
#include <ApplicationServices/ApplicationServices.h>
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050
typedef SInt32 SRefCon;
#endif
#endif
#include "qgisapp.h"
@ -117,7 +119,7 @@ static QStringList myFileList;
* May be called at startup before application is initialized as well as
* at any time while the application is running.
*/
short openDocumentsAEHandler(const AppleEvent *event, AppleEvent *reply, long refCon)
OSErr openDocumentsAEHandler(const AppleEvent *event, AppleEvent *reply, SRefCon refCon)
{
AEDescList docs;
if (AEGetParamDesc(event, keyDirectObject, typeAEList, &docs) == noErr)
@ -154,18 +156,23 @@ short openDocumentsAEHandler(const AppleEvent *event, AppleEvent *reply, long re
}
// Open files now if application has been initialized
QgisApp *qgis = dynamic_cast<QgisApp *>(qApp->mainWidget());
if (qgis)
QWidgetList wl = QApplication::topLevelWidgets();
for (QWidgetList::iterator it = wl.begin(); it != wl.end(); ++it)
{
if (!myProjectFileName.isEmpty())
QgisApp *qgis = dynamic_cast<QgisApp *>(*it);
if (qgis && qgis->objectName() == "QgisApp")
{
qgis->openProject(myProjectFileName);
}
for (QStringList::Iterator myIterator = myFileList.begin();
myIterator != myFileList.end(); ++myIterator )
{
QString fileName = *myIterator;
qgis->openLayer(fileName);
if (!myProjectFileName.isEmpty())
{
qgis->openProject(myProjectFileName);
}
for (QStringList::Iterator myIterator = myFileList.begin();
myIterator != myFileList.end(); ++myIterator )
{
QString fileName = *myIterator;
qgis->openLayer(fileName);
}
break;
}
}
}
@ -390,7 +397,7 @@ int main(int argc, char *argv[])
QString gdalPlugins(QCoreApplication::applicationDirPath().append("/lib/gdalplugins"));
if (QFile::exists(gdalPlugins) && !getenv("GDAL_DRIVER_PATH"))
{
setenv("GDAL_DRIVER_PATH", gdalPlugins, 1);
setenv("GDAL_DRIVER_PATH", gdalPlugins.toUtf8(), 1);
}
#endif
@ -444,7 +451,7 @@ int main(int argc, char *argv[])
{
if (!myLocaleOverrideFlag || myUserLocale.isEmpty())
{
myTranslationCode = QTextCodec::locale();
myTranslationCode = QLocale::system().name();
}
else
{
@ -498,7 +505,7 @@ int main(int argc, char *argv[])
QgisApp *qgis = new QgisApp(mypSplash); // "QgisApp" used to find canonical instance
qgis->setName( "QgisApp" );
qgis->setObjectName( "QgisApp" );
/////////////////////////////////////////////////////////////////////

View File

@ -22,8 +22,6 @@
//
// QT4 includes make sure to use the new <CamelCase> style!
//
#include <Q3ListViewItem>
#include <Q3PopupMenu>
#include <QAction>
#include <QApplication>
#include <QBitmap>
@ -60,7 +58,6 @@
#include <QTcpSocket>
#include <QTextStream>
#include <QToolButton>
#include <QToolTip>
#include <QVBoxLayout>
#include <QWhatsThis>
#include <QtGlobal>
@ -339,7 +336,7 @@ static void customSrsValidation_(QgsSpatialRefSys* srs)
mQgisInterface = new QgisAppInterface(this); // create the interfce
// set application's icon
setIcon(QPixmap(qgis_xpm));
setWindowIcon(QPixmap(qgis_xpm));
// set application's caption
QString caption = tr("Quantum GIS - ");
@ -1130,7 +1127,7 @@ void QgisApp::createStatusBar()
mProgressBar = new QProgressBar(statusBar());
mProgressBar->setMaximumWidth(100);
mProgressBar->hide();
QWhatsThis::add(mProgressBar, tr("Progress bar that displays the status of rendering layers and other time-intensive operations"));
mProgressBar->setWhatsThis(tr("Progress bar that displays the status of rendering layers and other time-intensive operations"));
statusBar()->addWidget(mProgressBar, 1,true);
// Bumped the font up one point size since 8 was too
// small on some platforms. A point size of 9 still provides
@ -1144,7 +1141,7 @@ void QgisApp::createStatusBar()
mScaleLabel->setAlignment(Qt::AlignCenter);
mScaleLabel->setFrameStyle(QFrame::NoFrame);
mScaleLabel->setText(tr("Scale "));
QToolTip::add (mScaleLabel, tr("Current map scale"));
mScaleLabel->setToolTip(tr("Current map scale"));
statusBar()->addWidget(mScaleLabel, 0,true);
mScaleEdit = new QLineEdit(QString(),statusBar());
@ -1156,8 +1153,8 @@ void QgisApp::createStatusBar()
QRegExp validator("\\d+\\.?\\d*:\\d+\\.?\\d*");
mScaleEditValidator = new QRegExpValidator(validator, mScaleEdit);
mScaleEdit->setValidator(mScaleEditValidator);
QWhatsThis::add(mScaleEdit, tr("Displays the current map scale"));
QToolTip::add (mScaleEdit, tr("Current map scale (formatted as x:y)"));
mScaleEdit->setWhatsThis(tr("Displays the current map scale"));
mScaleEdit->setToolTip(tr("Current map scale (formatted as x:y)"));
statusBar()->addWidget(mScaleEdit, 0,true);
connect(mScaleEdit, SIGNAL(editingFinished()), this, SLOT(userScale()));
@ -1167,15 +1164,15 @@ void QgisApp::createStatusBar()
mCoordsLabel->setFont(myFont);
mCoordsLabel->setMargin(3);
mCoordsLabel->setAlignment(Qt::AlignCenter);
QWhatsThis::add(mCoordsLabel, tr("Shows the map coordinates at the current cursor position. The display is continuously updated as the mouse is moved."));
QToolTip::add (mCoordsLabel, tr("Map coordinates at mouse cursor position"));
mCoordsLabel->setWhatsThis(tr("Shows the map coordinates at the current cursor position. The display is continuously updated as the mouse is moved."));
mCoordsLabel->setToolTip(tr("Map coordinates at mouse cursor position"));
statusBar()->addWidget(mCoordsLabel, 0, true);
// render suppression status bar widget
mRenderSuppressionCBox = new QCheckBox(tr("Render"),statusBar());
mRenderSuppressionCBox->setChecked(true);
mRenderSuppressionCBox->setFont(myFont);
QWhatsThis::add(mRenderSuppressionCBox, tr("When checked, the map layers are rendered in response to map navigation commands and other events. When not checked, no rendering is done. This allows you to add a large number of layers and symbolize them before rendering."));
QToolTip::add( mRenderSuppressionCBox, tr("Toggle map rendering") );
mRenderSuppressionCBox->setWhatsThis(tr("When checked, the map layers are rendered in response to map navigation commands and other events. When not checked, no rendering is done. This allows you to add a large number of layers and symbolize them before rendering."));
mRenderSuppressionCBox->setToolTip(tr("Toggle map rendering") );
statusBar()->addWidget(mRenderSuppressionCBox,0,true);
// On the fly projection status bar icon
// Changed this to a tool button since a QPushButton is
@ -1190,8 +1187,8 @@ void QgisApp::createStatusBar()
myProjPixmap.load(myIconPath+"/mIconProjectionDisabled.png");
mOnTheFlyProjectionStatusButton->setPixmap(myProjPixmap);
assert(!myProjPixmap.isNull());
QWhatsThis::add(mOnTheFlyProjectionStatusButton, tr("This icon shows whether on the fly projection is enabled or not. Click the icon to bring up the project properties dialog to alter this behaviour."));
QToolTip::add( mOnTheFlyProjectionStatusButton, tr("Projection status - Click to open projection dialog"));
mOnTheFlyProjectionStatusButton->setWhatsThis(tr("This icon shows whether on the fly projection is enabled or not. Click the icon to bring up the project properties dialog to alter this behaviour."));
mOnTheFlyProjectionStatusButton->setToolTip(tr("Projection status - Click to open projection dialog"));
connect(mOnTheFlyProjectionStatusButton, SIGNAL(clicked()),
this, SLOT(projectPropertiesProjections()));//bring up the project props dialog when clicked
statusBar()->addWidget(mOnTheFlyProjectionStatusButton,0,true);
@ -1315,7 +1312,7 @@ void QgisApp::createCanvas()
{
// "theMapCanvas" used to find this canonical instance later
mMapCanvas = new QgsMapCanvas(this, "theMapCanvas" );
QWhatsThis::add(mMapCanvas, tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
mMapCanvas->setWhatsThis(tr("Map canvas. This is where raster and vector layers are displayed when added to the map"));
mMapCanvas->setMinimumWidth(10);
QVBoxLayout *myCanvasLayout = new QVBoxLayout;
@ -1364,10 +1361,10 @@ void QgisApp::createOverview()
{
// overview canvas
QgsMapOverviewCanvas* overviewCanvas = new QgsMapOverviewCanvas(NULL, mMapCanvas);
QWhatsThis::add(overviewCanvas, tr("Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas."));
overviewCanvas->setWhatsThis(tr("Map overview canvas. This canvas can be used to display a locator map that shows the current extent of the map canvas. The current extent is shown as a red rectangle. Any layer on the map can be added to the overview canvas."));
QBitmap overviewPanBmp(16, 16, pan_bits, true);
QBitmap overviewPanBmpMask(16, 16, pan_mask_bits, true);
QBitmap overviewPanBmp = QBitmap::fromData(QSize(16, 16), pan_bits);
QBitmap overviewPanBmpMask = QBitmap::fromData(QSize(16, 16), pan_mask_bits);
mOverviewMapCursor = new QCursor(overviewPanBmp, overviewPanBmpMask, 5, 5);
overviewCanvas->setCursor(*mOverviewMapCursor);
QVBoxLayout *myOverviewLayout = new QVBoxLayout;
@ -1397,7 +1394,7 @@ void QgisApp::createLegend()
//add the toggle editing action also to legend such that right click menu and button show the same state
mMapLegend->setToggleEditingAction(mActionToggleEditing);
QWhatsThis::add(mMapLegend, tr("Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties."));
mMapLegend->setWhatsThis(tr("Map legend that displays all the layers currently on the map canvas. Click on the check box to turn a layer on or off. Double click on a layer in the legend to customize its appearance and set other properties."));
QVBoxLayout *myLegendLayout = new QVBoxLayout;
myLegendLayout->addWidget(mMapLegend);
toolBox->widget(0)->setLayout(myLegendLayout);
@ -2600,7 +2597,7 @@ void QgisApp::newVectorLayer()
return;
}
filename = openFileDialog->selectedFile();
filename = openFileDialog->selectedFiles().first();
enc = openFileDialog->encoding();
// If the file exists, delete it otherwise we'll end up loading that
@ -2620,7 +2617,7 @@ void QgisApp::newVectorLayer()
QgsProviderRegistry * pReg = QgsProviderRegistry::instance();
QString ogrlib = pReg->library("ogr");
// load the data provider
QLibrary* myLib = new QLibrary((const char *) ogrlib);
QLibrary* myLib = new QLibrary(ogrlib);
bool loaded = myLib->load();
if (loaded)
{
@ -2693,7 +2690,7 @@ void QgisApp::fileOpen()
// Fix by Tim - getting the dirPath from the dialog
// directly truncates the last node in the dir path.
// This is a workaround for that
fullPath = openFileDialog->selectedFile();
fullPath = openFileDialog->selectedFiles().first();
QFileInfo myFI(fullPath);
QString myPath = myFI.dirPath();
// Persist last used project dir
@ -2863,7 +2860,7 @@ bool QgisApp::fileSave()
if (saveFileDialog->exec() == QDialog::Accepted)
{
fullPath.setFile( saveFileDialog->selectedFile() );
fullPath.setFile( saveFileDialog->selectedFiles().first() );
}
else
{
@ -2945,7 +2942,7 @@ void QgisApp::fileSaveAs()
// Fix by Tim - getting the dirPath from the dialog
// directly truncates the last node in the dir path.
// This is a workaround for that
fullPath.setFile(saveFileDialog->selectedFile());
fullPath.setFile(saveFileDialog->selectedFiles().first());
QString myPath = fullPath.dirPath();
// Persist last used project dir
settings.writeEntry("/UI/lastProjectDir", myPath);
@ -3188,7 +3185,7 @@ void QgisApp::saveMapAsImage()
QString myOutputFileNameQString; // = myQFileDialog->getSaveFileName(); //delete this
if (myQFileDialog->exec() == QDialog::Accepted)
{
myOutputFileNameQString = myQFileDialog->selectedFile();
myOutputFileNameQString = myQFileDialog->selectedFiles().first();
}
QString myFilterString = myQFileDialog->selectedFilter()+";;";
@ -4478,42 +4475,6 @@ void QgisApp::whatsThis()
QWhatsThis::enterWhatsThisMode();
} // QgisApp::whatsThis()
std::map<QString, int> QgisApp::menuMapByName()
{
// Must populate the maps with each call since menus might have been
// added or deleted
populateMenuMaps();
// Return the menu items mapped by name (key is name, value is menu id)
return mMenuMapByName;
}
std::map<int, QString> QgisApp::menuMapById()
{
// Must populate the maps with each call since menus might have been
// added or deleted
populateMenuMaps();
// Return the menu items mapped by menu id (key is menu id, value is name)
return mMenuMapById;
}
void QgisApp::populateMenuMaps()
{
// Populate the two menu maps by iterating through the menu bar
mMenuMapByName.clear();
mMenuMapById.clear();
int idx = 0;
int menuId;
// Loop until we get an id of -1, which indicates there are no more
// items.
do
{
menuId = menuBar()->idAt(idx++);
std::cout << "Menu id " << menuId << " is " << menuBar()->text(menuId).toLocal8Bit().data() << std::endl;
mMenuMapByName[menuBar()->text(menuId)] = menuId;
mMenuMapById[menuId] = menuBar()->text(menuId);
}
while(menuId != -1);
}
QMenu* QgisApp::getPluginMenu(QString menuName)
{
// This is going to record the menu item that the potentially new

View File

@ -52,8 +52,6 @@ class QgsRasterLayer;
class QgsRect;
class QgsVectorLayer;
#include <map>
#include <ui_qgisappbase.h>
#include <QMainWindow>
#include <QAbstractSocket>
@ -254,12 +252,6 @@ public slots:
void options();
//! Whats-this help slot
void whatsThis();
//! Get the Menu map (key is name, value is menu id)
std::map<QString, int> menuMapByName();
//! Get the Menu map (key is menu id, value is name)
std::map<int, QString> menuMapById();
//! Populate the menu maps
void populateMenuMaps();
void socketConnected();
void socketConnectionClosed();
void socketReadyRead();
@ -618,10 +610,6 @@ private:
QSplashScreen *mSplash;
//! help viewer
QgsHelpViewer *mHelpViewer;
//! menu map (key is name, value is menu id)
std::map<QString, int>mMenuMapByName;
//! menu map (key is menu id, value is name)
std::map<int, QString>mMenuMapById;
//! list of recently opened/saved project files
QStringList mRecentProjectPaths;
//! Map composer

View File

@ -165,8 +165,8 @@ void QgsAbout::init()
txtSponsors->setAcceptRichText(true);
txtSponsors->setHtml(sponsorHTML);
#ifdef QGISDEBUG
std::cout << "sponsorHTML:" << sponsorHTML.ascii() << std::endl;
std::cout << "txtSponsors:" << txtSponsors->toHtml().ascii() << std::endl;
std::cout << "sponsorHTML:" << sponsorHTML.toAscii().constData() << std::endl;
std::cout << "txtSponsors:" << txtSponsors->toHtml().toAscii().constData() << std::endl;
#endif
}
}

View File

@ -25,6 +25,7 @@ back to QgsVectorLayer.
#include "qgsattributeaction.h"
#include <QFileDialog>
#include <QHeaderView>
QgsAttributeActionDialog::QgsAttributeActionDialog(QgsAttributeAction* actions,
@ -33,8 +34,17 @@ QgsAttributeActionDialog::QgsAttributeActionDialog(QgsAttributeAction* actions,
QWidget(parent), mActions(actions)
{
setupUi(this);
connect(attributeActionTable, SIGNAL(clicked(int,int,int,const QPoint&)),
this, SLOT(rowSelected(int,int,int,const QPoint&)));
QHeaderView *header = attributeActionTable->horizontalHeader();
header->setHighlightSections(false);
header->setStretchLastSection(true);
attributeActionTable->setColumnWidth(0, 100);
attributeActionTable->setColumnWidth(1, 230);
#if QT_VERSION >= 0x040300
attributeActionTable->setCornerButtonEnabled(false);
#endif
connect(attributeActionTable, SIGNAL(itemSelectionChanged()),
this, SLOT(itemSelectionChanged()));
connect(moveUpButton, SIGNAL(clicked()), this, SLOT(moveUp()));
connect(moveDownButton, SIGNAL(clicked()), this, SLOT(moveDown()));
connect(removeButton, SIGNAL(clicked()), this, SLOT(remove()));
@ -53,18 +63,8 @@ QgsAttributeActionDialog::QgsAttributeActionDialog(QgsAttributeAction* actions,
void QgsAttributeActionDialog::init()
{
Q3Header* header = attributeActionTable->horizontalHeader();
header->setLabel(0, tr("Name") );
header->setLabel(1, tr("Action") );
header->setLabel(2, tr("Capture") );
attributeActionTable->setColumnStretchable(0, true);
attributeActionTable->setColumnStretchable(1, true);
attributeActionTable->setColumnStretchable(2, true);
// Start from a fresh slate.
for (int i = attributeActionTable->numRows()-1; i >= 0; --i)
attributeActionTable->removeRow(i);
attributeActionTable->setRowCount(0);
// Populate with our actions.
QgsAttributeAction::AttributeActions::const_iterator
@ -72,39 +72,38 @@ void QgsAttributeActionDialog::init()
int i = 0;
for (; iter != mActions->end(); ++iter, ++i)
{
attributeActionTable->insertRows(i);
attributeActionTable->setText(i, 0, iter->name());
attributeActionTable->setText(i, 1, iter->action());
Q3CheckTableItem* cp = new Q3CheckTableItem(attributeActionTable, "");
cp->setEnabled(false);
if (iter->capture())
cp->setChecked(true);
else
cp->setChecked(false);
attributeActionTable->setItem(i, 2, cp);
insertRow(i, iter->name(), iter->action(), iter->capture());
}
}
void QgsAttributeActionDialog::insertRow(int row, const QString &name, const QString &action, bool capture)
{
attributeActionTable->insertRow(row);
attributeActionTable->setItem(row, 0, new QTableWidgetItem(name));
attributeActionTable->setItem(row, 1, new QTableWidgetItem(action));
QTableWidgetItem* item = new QTableWidgetItem();
item->setFlags(item->flags() & ~Qt::ItemIsEditable | Qt::ItemIsUserCheckable);
item->setCheckState(capture ? Qt::Checked : Qt::Unchecked);
attributeActionTable->setItem(row, 2, item);
}
void QgsAttributeActionDialog::moveUp()
{
// Swap the selected row with the one above
int row1 = -1, row2 = -1;
for (int i = 0; i < attributeActionTable->numRows(); ++i)
if (attributeActionTable->isRowSelected(i))
row1 = i;
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
if (!selection.isEmpty())
{
row1 = attributeActionTable->row(selection.first());
}
if (row1 > 0)
row2 = row1 - 1;
if (row1 != -1 && row2 != -1)
{
for (int i = 0; i < attributeActionTable->numSelections(); ++i)
attributeActionTable->removeSelection(i);
attributeActionTable->swapRows(row1, row2);
attributeActionTable->updateContents();
swapRows(row1, row2);
// Move the selection to follow
attributeActionTable->selectRow(row2);
}
@ -114,25 +113,34 @@ void QgsAttributeActionDialog::moveDown()
{
// Swap the selected row with the one below
int row1 = -1, row2 = -1;
for (int i = 0; i < attributeActionTable->numRows(); ++i)
if (attributeActionTable->isRowSelected(i))
row1 = i;
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
if (!selection.isEmpty())
{
row1 = attributeActionTable->row(selection.first());
}
if (row1 < attributeActionTable->numRows()-1)
if (row1 < attributeActionTable->rowCount()-1)
row2 = row1 + 1;
if (row1 != -1 && row2 != -1)
{
for (int i = 0; i < attributeActionTable->numSelections(); ++i)
attributeActionTable->removeSelection(i);
attributeActionTable->swapRows(row1, row2);
attributeActionTable->updateContents();
swapRows(row1, row2);
// Move the selection to follow
attributeActionTable->selectRow(row2);
}
}
void QgsAttributeActionDialog::swapRows(int row1, int row2)
{
int colCount = attributeActionTable->columnCount();
for (int col = 0; col < colCount; col++)
{
QTableWidgetItem *item = attributeActionTable->takeItem(row1, col);
attributeActionTable->setItem(row1, col, attributeActionTable->takeItem(row2, col));
attributeActionTable->setItem(row2, col, item);
}
}
void QgsAttributeActionDialog::browse()
{
// Popup a file browser and place the results into the actionName
@ -147,29 +155,16 @@ void QgsAttributeActionDialog::browse()
void QgsAttributeActionDialog::remove()
{
// Remove the selected row. Remember which row was selected.
int row = -1;
for (int i = 0; i < attributeActionTable->numRows(); ++i)
if (attributeActionTable->isRowSelected(i))
{
row = i;
break;
}
if (row != -1)
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
if (!selection.isEmpty())
{
// Remove the selected row.
int row = attributeActionTable->row(selection.first());
attributeActionTable->removeRow(row);
attributeActionTable->clearSelection();
// And select the row below the one that was selected or the last
// one, or none.
// Note something is not quite right here. The highlight in the
// QTable isn't turning on when a row is selected. Don't
// understand why. Needs a bit more investigation.
if (row < attributeActionTable->numRows())
attributeActionTable->selectRow(row);
else if (attributeActionTable->numRows() > 0)
attributeActionTable->selectRow(attributeActionTable->numRows()-1);
// And select the row below the one that was selected or the last one.
if (row >= attributeActionTable->rowCount()) row = attributeActionTable->rowCount() - 1;
attributeActionTable->selectRow(row);
}
}
@ -177,7 +172,7 @@ void QgsAttributeActionDialog::insert()
{
// Add the action details as a new row in the table.
int pos = attributeActionTable->numRows();
int pos = attributeActionTable->rowCount();
insert(pos);
}
@ -190,39 +185,38 @@ void QgsAttributeActionDialog::insert(int pos)
// given pos, don't make the new name unique (because we're
// replacing it).
int numRows = attributeActionTable->rowCount();
QString name;
if (actionName->text() == attributeActionTable->text(pos, 0))
if (pos < numRows && actionName->text() == attributeActionTable->item(pos, 0)->text())
name = actionName->text();
else
name = uniqueName(actionName->text());
// Expand the table to have a row with index pos
int numRows = attributeActionTable->numRows();
if (pos >= numRows)
attributeActionTable->insertRows(numRows, pos-numRows+1);
attributeActionTable->setText(pos, 0, name);
attributeActionTable->setText(pos, 1, actionAction->text());
Q3CheckTableItem* cp = new Q3CheckTableItem(attributeActionTable, "");
cp->setEnabled(false);
if (captureCB->isChecked())
cp->setChecked(true);
{
// Expand the table to have a row with index pos
insertRow(pos, name, actionAction->text(), captureCB->isChecked());
}
else
cp->setChecked(false);
attributeActionTable->setItem(pos, 2, cp);
{
// Update existing row
attributeActionTable->item(pos, 0)->setText(name);
attributeActionTable->item(pos, 1)->setText(actionAction->text());
attributeActionTable->item(pos, 2)->setCheckState(
captureCB->isChecked() ? Qt::Checked : Qt::Unchecked);
}
}
void QgsAttributeActionDialog::update()
{
// Updates the action that is selected with the
// action details.
for (int i = 0; i < attributeActionTable->numRows(); ++i)
if (attributeActionTable->isRowSelected(i))
{
insert(i);
break;
}
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
if (!selection.isEmpty())
{
int i = attributeActionTable->row(selection.first());
insert(i);
}
}
void QgsAttributeActionDialog::insertField()
@ -243,33 +237,50 @@ void QgsAttributeActionDialog::apply()
// Update the contents of mActions from the UI.
mActions->clearActions();
for (int i = 0; i < attributeActionTable->numRows(); ++i)
for (int i = 0; i < attributeActionTable->rowCount(); ++i)
{
if (!attributeActionTable->text(i, 0).isEmpty() &&
!attributeActionTable->text(i, 1).isEmpty())
const QString &name = attributeActionTable->item(i, 0)->text();
const QString &action = attributeActionTable->item(i, 1)->text();
if (!name.isEmpty() && !action.isEmpty())
{
Q3CheckTableItem* cp = (Q3CheckTableItem*) (attributeActionTable->item(i, 2));
mActions->addAction(attributeActionTable->text(i, 0),
attributeActionTable->text(i, 1),
cp->isChecked());
QTableWidgetItem *item = attributeActionTable->item(i, 2);
mActions->addAction(name, action, item->checkState() == Qt::Checked);
}
}
}
void QgsAttributeActionDialog::rowSelected(int row, int col, int button,
const QPoint& pos)
void QgsAttributeActionDialog::itemSelectionChanged()
{
QList<QTableWidgetItem *> selection = attributeActionTable->selectedItems();
if (!selection.isEmpty())
{
#if QT_VERSION < 0x040400
// Supress multiple selection and select row where mouse release occurs.
// Workaround for Qt 4.3 bug which allows multiple rows to be selected if
// the user presses the mouse in one row header and releases in another.
if (attributeActionTable->row(selection.first()) != attributeActionTable->row(selection.last()))
{
attributeActionTable->selectRow(attributeActionTable->currentRow());
selection = attributeActionTable->selectedItems();
}
#endif
rowSelected(attributeActionTable->row(selection.first()));
}
}
void QgsAttributeActionDialog::rowSelected(int row)
{
// The user has selected a row. We take the contents of that row and
// populate the edit section of the dialog so that they can change
// the row if desired.
Q3CheckTableItem* cp = (Q3CheckTableItem*) (attributeActionTable->item(row, 2));
if ( cp )
QTableWidgetItem *item = attributeActionTable->item(row, 2);
if ( item )
{
// Only if a populated row was selected
actionName->setText(attributeActionTable->text(row, 0));
actionAction->setText(attributeActionTable->text(row, 1));
captureCB->setChecked(cp->isChecked());
actionName->setText(attributeActionTable->item(row, 0)->text());
actionAction->setText(attributeActionTable->item(row, 1)->text());
captureCB->setChecked(item->checkState() == Qt::Checked);
}
}
@ -278,12 +289,12 @@ QString QgsAttributeActionDialog::uniqueName(QString name)
// Make sure that the given name is unique, adding a numerical
// suffix if necessary.
int pos = attributeActionTable->numRows();
int pos = attributeActionTable->rowCount();
bool unique = true;
for (int i = 0; i < pos; ++i)
{
if (attributeActionTable->text(i, 0) == name)
if (attributeActionTable->item(i, 0)->text() == name)
unique = false;
}
@ -297,7 +308,7 @@ QString QgsAttributeActionDialog::uniqueName(QString name)
new_name = name + "_" + suffix;
unique = true;
for (int i = 0; i < pos; ++i)
if (attributeActionTable->text(i, 0) == new_name)
if (attributeActionTable->item(i, 0)->text() == new_name)
unique = false;
++suffix_num;
}
@ -305,4 +316,3 @@ QString QgsAttributeActionDialog::uniqueName(QString name)
}
return name;
}

View File

@ -54,12 +54,17 @@ class QgsAttributeActionDialog: public QWidget, private Ui::QgsAttributeActionDi
void insertField();
void apply();
void update();
void rowSelected(int, int, int, const QPoint&);
void itemSelectionChanged();
private:
void insertRow(int row, const QString &name, const QString &action, bool capture);
void swapRows(int row1, int row2);
void insert(int pos);
void rowSelected(int row);
QString uniqueName(QString name);
// Pointer to the QgsAttributeAction in the class that created us.

View File

@ -16,14 +16,6 @@
* *
***************************************************************************/
/* $Id$ */
#include <QApplication>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QLabel>
#include <QFont>
#include <QClipboard>
#include <QAction>
#include <QMenu>
#include <QLineEdit>
#include <QValidator>
@ -34,47 +26,78 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#include <stdlib.h>
#include <QApplication>
#include <QClipboard>
#include <QHeaderView>
#include <QMenu>
QgsAttributeTable::QgsAttributeTable(QWidget * parent, const char *name):
Q3Table(parent, name),
QgsAttributeTableItemDelegate::QgsAttributeTableItemDelegate(const QgsFieldMap & fields, QObject *parent)
: QItemDelegate(parent), mFields(fields)
{}
QWidget * QgsAttributeTableItemDelegate::createEditor( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
QWidget *editor = QItemDelegate::createEditor(parent, option, index);
QLineEdit *le = dynamic_cast<QLineEdit*>(editor);
if (le)
{
int col = index.column();
if( mFields[col-1].type()==QVariant::Int )
{
le->setValidator( new QIntValidator(le) );
}
else if( mFields[col-1].type()==QVariant::Double )
{
le->setValidator( new QDoubleValidator(le) );
}
}
return editor;
}
QgsAttributeTable::QgsAttributeTable(QWidget * parent):
QTableWidget(parent),
lockKeyPressed(false),
sort_ascending(true),
mEditable(false),
mEdited(false),
mActionPopup(0)
mActionPopup(0),
mPreviousSortIndicatorColumn(-1)
{
QFont f(font());
f.setFamily("Helvetica");
f.setPointSize(11);
setFont(f);
setSelectionMode(Q3Table::MultiRow);
QObject::connect(this, SIGNAL(selectionChanged()), this, SLOT(handleChangedSelections()));
connect(this, SIGNAL(contextMenuRequested(int, int, const QPoint&)), this, SLOT(popupMenu(int, int, const QPoint&)));
connect(this, SIGNAL(valueChanged(int, int)), this, SLOT(storeChangedValue(int,int)));
connect(verticalHeader(), SIGNAL(released(int)), this, SLOT(rowClicked(int)));
mDelegate = new QgsAttributeTableItemDelegate(mFields, this);
setItemDelegate(mDelegate);
setSelectionBehavior(QAbstractItemView::SelectRows);
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(handleChangedSelections()));
connect(this, SIGNAL(cellChanged(int, int)), this, SLOT(storeChangedValue(int,int)));
connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(columnClicked(int)));
connect(verticalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(rowClicked(int)));
setReadOnly(true);
setFocus();
}
QgsAttributeTable::~QgsAttributeTable()
{
delete mActionPopup;
delete mDelegate;
}
QWidget *QgsAttributeTable::createEditor(int row, int col, bool initFromCell ) const
void QgsAttributeTable::setReadOnly(bool b)
{
QLineEdit *le = static_cast<QLineEdit*>(Q3Table::createEditor(row, col, initFromCell));
setEditTriggers(b ? QAbstractItemView::NoEditTriggers :
QAbstractItemView::DoubleClicked | QAbstractItemView::EditKeyPressed);
}
if( mFields[col-1].type()==QVariant::Int )
void QgsAttributeTable::setColumnReadOnly(int col, bool ro)
{
for (int i = 0; i < rowCount(); ++i)
{
le->setValidator( new QIntValidator(le) );
QTableWidgetItem *item = this->item(i, col);
item->setFlags(ro ? item->flags() | Qt::ItemIsEditable : item->flags() & ~Qt::ItemIsEditable);
}
else if( mFields[col-1].type()==QVariant::Double )
{
le->setValidator( new QDoubleValidator(le) );
}
return le;
}
void QgsAttributeTable::columnClicked(int col)
@ -82,28 +105,42 @@ void QgsAttributeTable::columnClicked(int col)
QApplication::setOverrideCursor(Qt::waitCursor);
//store the ids of the selected rows in a list
QList < int >idsOfSelected;
for (int i = 0; i < numSelections(); i++)
QList<int> idsOfSelected;
QList<QTableWidgetSelectionRange> selection = selectedRanges();
for (int i = 0; i < selection.count(); i++)
{
for (int j = selection(i).topRow(); j <= selection(i).bottomRow(); j++)
for (int j = selection.at(i).topRow(); j <= selection.at(i).bottomRow(); j++)
{
idsOfSelected.append(text(j, 0).toInt());
idsOfSelected.append(item(j, 0)->text().toInt());
}
}
sortColumn(col, sort_ascending, true);
QHeaderView *header = horizontalHeader();
if (!header->isSortIndicatorShown())
{
header->setSortIndicatorShown(true);
header->setSortIndicator(col, Qt::AscendingOrder);
}
if (col != mPreviousSortIndicatorColumn)
{
// Workaround for QTableView sortIndicator displayed in wrong direction
header->setSortIndicator(col, header->sortIndicatorOrder() == Qt::AscendingOrder ?
Qt::DescendingOrder : Qt::AscendingOrder);
}
mPreviousSortIndicatorColumn = col;
sortColumn(col, header->sortIndicatorOrder() == Qt::DescendingOrder);
//clear and rebuild rowIdMap. Overwrite sortColumn later and sort rowIdMap there
rowIdMap.clear();
int id;
for (int i = 0; i < numRows(); i++)
for (int i = 0; i < rowCount(); i++)
{
id = text(i, 0).toInt();
id = item(i, 0)->text().toInt();
rowIdMap.insert(id, i);
}
QObject::disconnect(this, SIGNAL(selectionChanged()), this, SLOT(handleChangedSelections()));
clearSelection(true);
disconnect(this, SIGNAL(itemSelectionChanged()), this, SLOT(handleChangedSelections()));
clearSelection();
//select the rows again after sorting
@ -112,10 +149,7 @@ void QgsAttributeTable::columnClicked(int col)
{
selectRowWithId((*it));
}
QObject::connect(this, SIGNAL(selectionChanged()), this, SLOT(handleChangedSelections()));
//change the sorting order after each sort
(sort_ascending == true) ? sort_ascending = false : sort_ascending = true;
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(handleChangedSelections()));
QApplication::restoreOverrideCursor();
}
@ -138,27 +172,24 @@ void QgsAttributeTable::keyReleaseEvent(QKeyEvent * ev)
void QgsAttributeTable::handleChangedSelections()
{
Q3TableSelection cselection;
if (lockKeyPressed == false)
{
//clear the list and evaluate the last selection
emit selectionRemoved(false);
}
//if there is no current selection, there is nothing to do
if (currentSelection() == -1)
{
return;
}
cselection = selection(currentSelection());
for (int index = cselection.topRow(); index <= cselection.bottomRow(); index++)
{
emit selected(text(index, 0).toInt(), false);
QList<QTableWidgetSelectionRange> selectedItemRanges = selectedRanges();
QList<QTableWidgetSelectionRange>::const_iterator range_it = selectedItemRanges.constBegin();
for (; range_it != selectedItemRanges.constEnd(); ++range_it)
{
for (int index = range_it->topRow(); index <= range_it->bottomRow(); index++)
{
emit selected(item(index, 0)->text().toInt(), false);
}
}
//don't send the signal repaintRequested() from here
//but in contentsMouseReleaseEvent() and rowClicked(int)
//but in mouseReleaseEvent() and rowClicked(int)
//todo: don't repaint in case of double clicks
}
@ -170,32 +201,24 @@ void QgsAttributeTable::insertFeatureId(int id, int row)
void QgsAttributeTable::selectRowWithId(int id)
{
QMap < int, int >::iterator it = rowIdMap.find(id);
selectRow(it.data());
setRangeSelected(QTableWidgetSelectionRange(it.data(), 0, it.data(), columnCount()-1), true);
}
void QgsAttributeTable::sortColumn(int col, bool ascending, bool wholeRows)
void QgsAttributeTable::sortColumn(int col, bool ascending)
{
//if the first entry contains a letter, sort alphanumerically, otherwise numerically
QString firstentry = text(0, col);
QString firstentry = item(0, col)->text();
bool containsletter = false;
for (int i = 0; i < firstentry.length(); i++)
{
if (firstentry.ref(i).isLetter())
{
containsletter = true;
break;
}
}
if (containsletter)
{
qsort(0, numRows() - 1, col, ascending, true);
}
else
{
qsort(0, numRows() - 1, col, ascending, false);
}
repaintContents();
qsort(0, rowCount() - 1, col, ascending, containsletter);
}
@ -277,13 +300,13 @@ void QgsAttributeTable::qsort(int lower, int upper, int col, bool ascending, boo
//chose a random element (this avoids n^2 worst case)
int element = int ( (double)rand() / (double)RAND_MAX * (upper - lower) + lower);
swapRows(element, upper);
v = text(upper, col);
v = item(upper, col)->text();
i = lower - 1;
j = upper;
for (;;)
{
while (compareItems(text(++i, col), v, ascending, alphanumeric) == -1);
while (compareItems(text(--j, col), v, ascending, alphanumeric) == 1 && j > 0); //make sure that j does not get negative
while (compareItems(item(++i, col)->text(), v, ascending, alphanumeric) == -1);
while (compareItems(item(--j, col)->text(), v, ascending, alphanumeric) == 1 && j > 0); //make sure that j does not get negative
if (i >= j)
{
break;
@ -296,8 +319,22 @@ void QgsAttributeTable::qsort(int lower, int upper, int col, bool ascending, boo
}
}
void QgsAttributeTable::popupMenu(int row, int col, const QPoint& pos)
void QgsAttributeTable::swapRows(int row1, int row2)
{
for (int col = 0; col < columnCount(); col++)
{
QTableWidgetItem *item = takeItem(row1, col);
setItem(row1, col, takeItem(row2, col));
setItem(row2, col, item);
}
}
void QgsAttributeTable::contextMenuEvent(QContextMenuEvent *event)
{
const QPoint& pos = event->globalPos();
int row = rowAt(pos.x());
int col = columnAt(pos.y());
// Duplication of code in qgsidentufyresults.cpp. Consider placing
// in a seperate class
if (mActionPopup == 0)
@ -322,17 +359,9 @@ void QgsAttributeTable::popupMenu(int row, int col, const QPoint& pos)
// these are needed for substituting into the actions if the user
// chooses one.
mActionValues.clear();
Q3Header* header = horizontalHeader();
#ifdef QGISDEBUG
if (header->count() != numCols())
std::cerr << "Something wrong with the table (file "
<< __FILE__<< ", line " << __LINE__
<< ")." << std::endl;
#endif
for (int i = 0; i < numCols(); ++i)
mActionValues.push_back(std::make_pair(header->label(i), text(row, i)));
for (int i = 0; i < columnCount(); ++i)
mActionValues.push_back(std::make_pair(horizontalHeaderItem(i)->text(), item(row, i)->text()));
// The item that was clicked on, stored as an index into the
// mActionValues vector.
@ -351,9 +380,9 @@ void QgsAttributeTable::popupItemSelected(QAction* menuAction)
bool QgsAttributeTable::addAttribute(const QString& name, const QString& type)
{
//first test if an attribute with the same name is already in the table
for(int i=0;i<horizontalHeader()->count();++i)
for(int i=0;i<columnCount();++i)
{
if(horizontalHeader()->label(i)==name)
if(horizontalHeaderItem(i)->text()==name)
{
//name conflict
return false;
@ -361,12 +390,12 @@ bool QgsAttributeTable::addAttribute(const QString& name, const QString& type)
}
mAddedAttributes.insert(name,type);
QgsDebugMsg("inserting attribute " + name + " of type " + type + ", numCols: " + QString::number(numCols()) );
QgsDebugMsg("inserting attribute " + name + " of type " + type + ", numCols: " + QString::number(columnCount()) );
//add a new column at the end of the table
insertColumns(numCols());
horizontalHeader()->setLabel(numCols()-1,name);
insertColumn(columnCount());
horizontalHeaderItem(columnCount()-1)->setText(name);
mEdited=true;
return true;
}
@ -398,19 +427,19 @@ void QgsAttributeTable::copySelectedRows()
const char fieldSep = '\t';
// Pick up the headers first
Q3Header* header = horizontalHeader();
for (int i = 0; i < header->count(); ++i)
toClipboard += header->label(i) + fieldSep;
for (int i = 0; i < columnCount(); ++i)
toClipboard += horizontalHeaderItem(i)->text() + fieldSep;
toClipboard += '\n';
QList<QTableWidgetSelectionRange> selection = selectedRanges();
// Then populate with the cell contents
for (int i = 0; i < numSelections(); ++i)
for (int i = 0; i < selection.count(); ++i)
{
Q3TableSelection sel = selection(i);
for (int row = sel.topRow(); row < sel.topRow()+sel.numRows(); ++row)
QTableWidgetSelectionRange sel = selection.at(i);
for (int row = sel.topRow(); row < sel.topRow()+sel.rowCount(); ++row)
{
for (int column = 0; column < numCols(); ++column)
toClipboard += text(row, column) + fieldSep;
for (int column = 0; column < columnCount(); ++column)
toClipboard += item(row, column)->text() + fieldSep;
toClipboard += '\n';
}
}
@ -535,13 +564,12 @@ void QgsAttributeTable::fillTable(QgsVectorLayer* layer)
QgsFeatureIds& deletedFeatures = layer->deletedFeatureIds();
// set up the column headers
Q3Header *colHeader = horizontalHeader();
mFields = provider->fields();
int fieldcount=provider->fieldCount();
setNumRows(provider->featureCount() + addedFeatures.size() - deletedFeatures.size());
setNumCols(fieldcount+1);
colHeader->setLabel(0, "id"); //label for the id-column
setRowCount(provider->featureCount() + addedFeatures.size() - deletedFeatures.size());
setColumnCount(fieldcount+1);
setHorizontalHeaderItem(0, new QTableWidgetItem("id")); //label for the id-column
int h = 1;
QgsFieldMap::const_iterator fldIt;
@ -549,8 +577,8 @@ void QgsAttributeTable::fillTable(QgsVectorLayer* layer)
{
QgsDebugMsg("field " + QString::number(fldIt.key()) + ": " + fldIt->name() +
" | " + QString(QVariant::typeToName(fldIt->type())) );
colHeader->setLabel(h++, fldIt->name());
setHorizontalHeaderItem(h++, new QTableWidgetItem(fldIt->name()));
}
//go through the features and fill the values into the table
@ -573,22 +601,29 @@ void QgsAttributeTable::fillTable(QgsVectorLayer* layer)
row++;
}
// Default row height is too tall
resizeRowsToContents();
// Make each column wide enough to show all the contents
for (int i = 0; i < numCols(); ++i)
adjustColumn(i);
for (int i = 0; i < columnCount(); ++i)
{
resizeColumnToContents(i);
}
}
}
void QgsAttributeTable::putFeatureInTable(int row, QgsFeature& fet)
{
if(row >= numRows())//prevent a crash if a provider doesn't update the feature count properly
// Prevent a crash if a provider doesn't update the feature count properly
if(row >= rowCount())
{
setNumRows(row+1);
setRowCount(row+1);
}
//id-field
int id = fet.featureId();
setText(row, 0, QString::number(id));
QTableWidgetItem *item = new QTableWidgetItem(QString::number(id));
item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(row, 0, item);
insertFeatureId(id, row); //insert the id into the search tree of qgsattributetable
const QgsAttributeMap& attr = fet.attributeMap();
QgsAttributeMap::const_iterator it;
@ -608,8 +643,11 @@ void QgsAttributeTable::putFeatureInTable(int row, QgsFeature& fet)
value = it->toString();
}
clearCellWidget(row, h);
setText(row, h++, value);
bool isNum;
value.toFloat(&isNum);
item = new QTableWidgetItem(value);
if (isNum) item->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
setItem(row, h++, item);
}
}
@ -619,8 +657,8 @@ void QgsAttributeTable::storeChangedValue(int row, int column)
if(column>0)
{
//find feature id
int id=text(row,0).toInt();
QString field = horizontalHeader()->label(column);
int id=item(row,0)->text().toInt();
QString field = horizontalHeaderItem(column)->text();
if(id>=0)
{
@ -630,7 +668,7 @@ void QgsAttributeTable::storeChangedValue(int row, int column)
mChangedValues.insert(id, QMap<QString, QString>());
}
mChangedValues[id].insert(field, text(row,column));
mChangedValues[id].insert(field, item(row,column)->text());
mEdited=true;
}
else
@ -650,10 +688,9 @@ void QgsAttributeTable::clearEditingStructures()
void QgsAttributeTable::removeAttrColumn(const QString& name)
{
Q3Header* header=horizontalHeader();
for(int i=0;i<header->count();++i)
for(int i=0;i<columnCount();++i)
{
if(header->label(i)==name)
if(horizontalHeaderItem(i)->text()==name)
{
removeColumn(i);
break;
@ -664,21 +701,16 @@ void QgsAttributeTable::removeAttrColumn(const QString& name)
void QgsAttributeTable::bringSelectedToTop()
{
blockSignals(true);
horizontalHeader()->setSortIndicatorShown(false);
mPreviousSortIndicatorColumn = -1;
int swaptorow=0;
std::list<Q3TableSelection> selections;
QList<QTableWidgetSelectionRange> selections = selectedRanges();
bool removeselection;
for(int i=0;i<numSelections();++i)
{
selections.push_back(selection(i));
}
Q3TableSelection sel;
for(std::list<Q3TableSelection>::iterator iter=selections.begin();iter!=selections.end();++iter)
for(QList<QTableWidgetSelectionRange>::iterator iter=selections.begin();iter!=selections.end();++iter)
{
removeselection=true;
while(isRowSelected(swaptorow, true))//selections are not necessary stored in ascending order
while(item(swaptorow, 0)->isSelected())//selections are not necessary stored in ascending order
{
++swaptorow;
}
@ -688,7 +720,7 @@ void QgsAttributeTable::bringSelectedToTop()
if(j>swaptorow)//selections are not necessary stored in ascending order
{
swapRows(j,swaptorow);
selectRow(swaptorow);
setRangeSelected(QTableWidgetSelectionRange(swaptorow, 0, swaptorow, columnCount()-1), true);
++swaptorow;
}
@ -699,16 +731,16 @@ void QgsAttributeTable::bringSelectedToTop()
}
if(removeselection)
{
removeSelection(*iter);
setRangeSelected(*iter, false);
}
}
//clear and rebuild rowIdMap.
rowIdMap.clear();
int id;
for (int i = 0; i < numRows(); i++)
for (int i = 0; i < rowCount(); i++)
{
id = text(i, 0).toInt();
id = item(i, 0)->text().toInt();
rowIdMap.insert(id, i);
}
@ -723,16 +755,16 @@ void QgsAttributeTable::selectRowsWithId(const QgsFeatureIds& ids)
int i=0;
for(std::set<int>::iterator iter=mSelected.begin();iter!=mSelected.end();++iter)
{
++i;
progress.setValue(i);
qApp->processEvents();
if(progress.wasCanceled())
{
//deselect the remaining features if action was canceled
mSelected.erase(iter,--mSelected.end());
break;
}
selectRowWithId(*iter);//todo: avoid that the table gets repainted during each selection
++i;
progress.setValue(i);
qApp->processEvents();
if(progress.wasCanceled())
{
//deselect the remaining features if action was canceled
mSelected.erase(iter,--mSelected.end());
break;
}
selectRowWithId(*iter);//todo: avoid that the table gets repainted during each selection
}
*/
@ -740,16 +772,16 @@ void QgsAttributeTable::selectRowsWithId(const QgsFeatureIds& ids)
// to select more rows at once effectively, we stop sending signals to handleChangedSelections()
// otherwise it will repaint map everytime row is selected
QObject::disconnect(this, SIGNAL(selectionChanged()), this, SLOT(handleChangedSelections()));
disconnect(this, SIGNAL(itemSelectionChanged()), this, SLOT(handleChangedSelections()));
clearSelection(true);
clearSelection();
QgsFeatureIds::const_iterator it;
for (it = ids.begin(); it != ids.end(); it++)
{
selectRowWithId(*it);
}
QObject::connect(this, SIGNAL(selectionChanged()), this, SLOT(handleChangedSelections()));
connect(this, SIGNAL(itemSelectionChanged()), this, SLOT(handleChangedSelections()));
emit repaintRequested();
}
@ -758,7 +790,7 @@ void QgsAttributeTable::showRowsWithId(const QgsFeatureIds& ids)
setUpdatesEnabled(false);
// hide all rows first
for (int i = 0; i < numRows(); i++)
for (int i = 0; i < rowCount(); i++)
hideRow(i);
// show only matching rows
@ -770,12 +802,11 @@ void QgsAttributeTable::showRowsWithId(const QgsFeatureIds& ids)
clearSelection(); // deselect all
setUpdatesEnabled(true);
repaintContents();
}
void QgsAttributeTable::showAllRows()
{
for (int i = 0; i < numRows(); i++)
for (int i = 0; i < rowCount(); i++)
showRow(i);
}
@ -787,9 +818,9 @@ void QgsAttributeTable::rowClicked(int row)
}
}
void QgsAttributeTable::contentsMouseReleaseEvent(QMouseEvent* e)
void QgsAttributeTable::mouseReleaseEvent(QMouseEvent* e)
{
Q3Table::contentsMouseReleaseEvent(e);
QTableWidget::mouseReleaseEvent(e);
if(checkSelectionChanges())//only repaint the canvas if the selection has changed
{
emit repaintRequested();
@ -799,11 +830,14 @@ void QgsAttributeTable::contentsMouseReleaseEvent(QMouseEvent* e)
bool QgsAttributeTable::checkSelectionChanges()
{
std::set<int> theCurrentSelection;
Q3TableSelection cselection;
cselection = selection(currentSelection());
for (int index = cselection.topRow(); index <= cselection.bottomRow(); index++)
QList<QTableWidgetSelectionRange> selectedItemRanges = selectedRanges();
QList<QTableWidgetSelectionRange>::const_iterator range_it = selectedItemRanges.constBegin();
for (; range_it != selectedItemRanges.constEnd(); ++range_it)
{
theCurrentSelection.insert(index);
for (int index = range_it->topRow(); index <= range_it->bottomRow(); index++)
{
theCurrentSelection.insert(index);
}
}
if(theCurrentSelection == mLastSelectedRows)

View File

@ -19,42 +19,45 @@
#ifndef QGSATTRIBUTETABLE_H
#define QGSATTRIBUTETABLE_H
#include <Q3Table>
#include <QMap>
#include <map>
#include <set>
class QgsVectorLayer;
class QgsFeature;
class QMouseEvent;
class QKeyEvent;
class QAction;
class QMenu;
#include "qgsattributeaction.h"
#include "qgsvectorlayer.h"
#include <vector>
#include <utility>
#include <QItemDelegate>
#include <QTableWidget>
#include <set>
/**
*@author Gary E.Sherman
*/
class QgsAttributeTable:public Q3Table
class QgsAttributeTableItemDelegate: public QItemDelegate
{
Q_OBJECT
Q_OBJECT
public:
QgsAttributeTable(QWidget * parent = 0, const char *name = 0);
QgsAttributeTableItemDelegate(const QgsFieldMap & fields, QObject * parent = 0);
QWidget * createEditor(QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const;
private:
const QgsFieldMap & mFields;
};
class QgsAttributeTable:public QTableWidget
{
Q_OBJECT
public:
QgsAttributeTable(QWidget * parent = 0);
~QgsAttributeTable();
void setReadOnly(bool b);
void setColumnReadOnly(int col, bool ro);
/**Inserts the feature with the specified id into rowIdMap. This function has to be called (e.g. from QgsShapeFileLayer) when a row is inserted into the table*/
void insertFeatureId(int id, int row);
/**Selects the row which belongs to the feature with the specified id*/
void selectRowWithId(int id);
/**Sorts a column. This method replaces the one from QTable to allow numeric sorting*/
virtual void sortColumn(int col, bool ascending=true, bool wholeRows=false);
/**Sorts a column. If the first entry contains a letter, sort alphanumerically, otherwise numerically.*/
void sortColumn(int col, bool ascending);
/* Use this to give this class the current attribute actions,
which are used when the user requests a popup menu */
void setAttributeActions(const QgsAttributeAction& actions)
@ -107,8 +110,6 @@ class QgsAttributeTable:public Q3Table
public slots:
void columnClicked(int col);
void rowClicked(int row);
// Called when the user requests a popup menu
void popupMenu(int row, int col, const QPoint& pos);
// Called when the user chooses an item on the popup menu
void popupItemSelected(QAction * menuAction);
@ -122,8 +123,6 @@ class QgsAttributeTable:public Q3Table
bool lockKeyPressed;
/**Search tree to find a row corresponding to a feature id*/
QMap<int,int> rowIdMap;
/**Flag indicating, which sorting order should be used*/
bool sort_ascending;
bool mEditable;
/**True if table has been edited and contains uncommited changes*/
bool mEdited;
@ -145,6 +144,8 @@ class QgsAttributeTable:public Q3Table
void keyReleaseEvent(QKeyEvent* ev);
/**Method used by sortColumn (implementation of a quicksort)*/
void qsort(int lower, int upper, int col, bool ascending, bool alphanumeric);
/**Called when the user requests a popup menu*/
void contextMenuEvent(QContextMenuEvent* event);
/**Clears mAddedAttributes, mDeletedAttributes and mChangedValues*/
void clearEditingStructures();
/**Removes the column belonging to an attribute from the table
@ -152,13 +153,11 @@ class QgsAttributeTable:public Q3Table
void removeAttrColumn(const QString& name);
/** puts attributes of feature to the chosen table row */
void putFeatureInTable(int row, QgsFeature& fet);
void contentsMouseReleaseEvent(QMouseEvent* e);
void mouseReleaseEvent(QMouseEvent* e);
/**This function compares the current selection and the selection of the last repaint. Returns true if there are differences in the selection.
Also, mLastSelectedRows is updated*/
bool checkSelectionChanges();
virtual QWidget *createEditor(int row, int col, bool initFromCell ) const;
signals:
/**Is emitted when a row was selected*/
void selected(int, bool);
@ -170,13 +169,20 @@ class QgsAttributeTable:public Q3Table
void featureAttributeChanged(int row, int column);
private:
void swapRows(int row1, int row2);
// Data to do with providing a popup menu of actions that
std::vector<std::pair<QString, QString> > mActionValues;
int mClickedOnValue;
QMenu* mActionPopup;
QgsAttributeAction mActions;
QgsAttributeTableItemDelegate *mDelegate;
QgsFieldMap mFields;
// Track previous columm for QTableView sortIndicator wrong direction workaround
int mPreviousSortIndicatorColumn;
};
#endif

View File

@ -373,7 +373,7 @@ void QgsAttributeTableDisplay::doSearch(const QString& searchString)
QString str;
if (mSearchIds.size())
str.sprintf(tr("Found %d matching features.","", mSearchIds.size()), mSearchIds.size());
str.sprintf(tr("Found %d matching features.","", mSearchIds.size()).toUtf8(), mSearchIds.size());
else
str = tr("No matching features found.");
QMessageBox::information(this, tr("Search results"), str);
@ -413,7 +413,7 @@ void QgsAttributeTableDisplay::changeFeatureAttribute(int row, int column)
{
QgsFeatureList &flist = mLayer->addedFeatures();
int id = table()->text(row,0).toInt();
int id = table()->item(row,0)->text().toInt();
int i;
for(i=0; i<flist.size() && flist[i].featureId()!=id; i++)
@ -422,5 +422,5 @@ void QgsAttributeTableDisplay::changeFeatureAttribute(int row, int column)
if(i==flist.size())
return;
flist[i].changeAttribute(column-1, table()->text(row,column));
flist[i].changeAttribute(column-1, table()->item(row,column)->text());
}

View File

@ -87,22 +87,28 @@ void QgsBookmarks::initialise()
// get the first row of the result set
while(sqlite3_step(ppStmt) == SQLITE_ROW)
{
QTreeWidgetItem *item = new QTreeWidgetItem(lstBookmarks);
QString name = QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 1));
// sqlite3_bind_parameter_index(ppStmt, "name"));
//QgsDebugMsg("Bookmark name: " + name.toLocal8Bit().data());
Q3ListViewItem *lvi = new Q3ListViewItem(lstBookmarks, name);
item->setText(0, name);
// set the project name
lvi->setText(1, QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 2)));
item->setText(1, QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 2)));
// get the extents
QString xMin = QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 3));
QString yMin = QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 4));
QString xMax = QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 5));
QString yMax = QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 6));
// set the extents
lvi->setText(2, xMin + ", " + yMin + ", " + xMax + ", " + yMax);
item->setText(2, xMin + ", " + yMin + ", " + xMax + ", " + yMax);
// set the id
lvi->setText(3, QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 0)));
item->setText(3, QString::fromUtf8((const char *)sqlite3_column_text(ppStmt, 0)));
}
for (int col = 0; col < 4; col++)
{
lstBookmarks->resizeColumnToContents(col);
}
lstBookmarks->sortByColumn(0, Qt::AscendingOrder);
}
else
{
@ -133,30 +139,30 @@ void QgsBookmarks::saveWindowLocation()
void QgsBookmarks::on_btnDelete_clicked()
{
// get the current item
Q3ListViewItem *lvi = lstBookmarks->currentItem();
if(lvi)
QTreeWidgetItem *item = lstBookmarks->currentItem();
if(item)
{
// make sure the user really wants to delete this bookmark
if(QMessageBox::Ok == QMessageBox::information(this,tr("Really Delete?"),
tr("Are you sure you want to delete the ") + lvi->text(0) + tr(" bookmark?"),
tr("Are you sure you want to delete the ") + item->text(0) + tr(" bookmark?"),
QMessageBox::Ok | QMessageBox::Cancel))
{
// remove it from the listview
lstBookmarks->takeItem(lvi);
item = lstBookmarks->takeTopLevelItem(lstBookmarks->indexOfTopLevelItem(item));
// delete it from the database
int rc = connectDb();
if(rc == SQLITE_OK)
{
char *errmsg;
// build the sql statement
QString sql = "delete from tbl_bookmarks where bookmark_id = " + lvi->text(3);
QString sql = "delete from tbl_bookmarks where bookmark_id = " + item->text(3);
rc = sqlite3_exec(db, sql.utf8(), NULL, NULL, &errmsg);
if(rc != SQLITE_OK)
{
// XXX Provide popup message on failure?
QMessageBox::warning(this, tr("Error deleting bookmark"),
tr("Failed to delete the ") +
lvi->text(0) +
item->text(0) +
tr(" bookmark from the database. The "
"database said:\n") + QString(errmsg));
sqlite3_free(errmsg);
@ -164,6 +170,7 @@ void QgsBookmarks::on_btnDelete_clicked()
// close the database
sqlite3_close(db);
}
delete item;
}
}
}
@ -173,7 +180,7 @@ void QgsBookmarks::on_btnZoomTo_clicked()
zoomToBookmark();
}
void QgsBookmarks::on_lstBookmarks_doubleClicked(Q3ListViewItem *lvi)
void QgsBookmarks::on_lstBookmarks_doubleClicked(QTreeWidgetItem *lvi)
{
zoomToBookmark();
}
@ -183,8 +190,8 @@ void QgsBookmarks::zoomToBookmark()
// Need to fetch the extent for the selected bookmark and then redraw
// the map
// get the current item
Q3ListViewItem *lvi = lstBookmarks->currentItem();
if(!lvi)
QTreeWidgetItem *item = lstBookmarks->currentItem();
if(!item)
{
return;
}
@ -195,7 +202,7 @@ void QgsBookmarks::zoomToBookmark()
sqlite3_stmt *ppStmt;
const char *pzTail;
// build the sql statement
QString sql = "select xmin, ymin, xmax, ymax from tbl_bookmarks where bookmark_id = " + lvi->text(3);
QString sql = "select xmin, ymin, xmax, ymax from tbl_bookmarks where bookmark_id = " + item->text(3);
rc = sqlite3_prepare(db, sql.utf8(), sql.length(), &ppStmt, &pzTail);
if(rc == SQLITE_OK)
{

View File

@ -22,7 +22,7 @@
class QString;
class QWidget;
class Q3ListViewItem;
class QTreeWidgetItem;
struct sqlite3;
class QgsBookmarks : public QDialog, private Ui::QgsBookmarksBase
{
@ -35,7 +35,7 @@ private slots:
void saveWindowLocation();
void on_btnDelete_clicked();
void on_btnZoomTo_clicked();
void on_lstBookmarks_doubleClicked(Q3ListViewItem *);
void on_lstBookmarks_doubleClicked(QTreeWidgetItem *);
void on_btnHelp_clicked();
void refreshBookmarks();
private:

View File

@ -486,7 +486,7 @@ void QgsDbSourceSelect::setSql(const QModelIndex& index)
QString schemaName = mTableModel.itemFromIndex(mProxyModel.mapToSource(schemaSibling))->text();
QString tableName = mTableModel.itemFromIndex(mProxyModel.mapToSource(tableSibling))->text();
QString tableString = "\"" + schemaName + "\".\"" + tableName + "\"";
qWarning(tableString);
qWarning(tableString.toUtf8());
QString currentSql;
QModelIndex sqlSibling = index.sibling(index.row(), 4);

View File

@ -17,9 +17,9 @@
#include "qgsdelattrdialog.h"
#include "qgsfield.h"
#include <Q3Header>
#include <QHeaderView>
QgsDelAttrDialog::QgsDelAttrDialog(Q3Header* header): QDialog()
QgsDelAttrDialog::QgsDelAttrDialog(QHeaderView* header): QDialog()
{
setupUi(this);
QObject::connect(mOkButton, SIGNAL(clicked(bool)), this, SLOT(accept()));
@ -29,22 +29,21 @@ QgsDelAttrDialog::QgsDelAttrDialog(Q3Header* header): QDialog()
if(header)
{
listBox2->clear();
QAbstractItemModel *model = header->model();
for(int i=1;i<header->count();++i)
{
listBox2->insertItem(header->label(i));
}
{
listBox2->addItem(model->headerData(i, Qt::Horizontal).toString());
}
}
}
const std::list<QString>* QgsDelAttrDialog::selectedAttributes()
{
mSelectedItems.clear();
for(int i=0;i<listBox2->numRows();++i)
QListIterator<QListWidgetItem *> selection(listBox2->selectedItems());
while (selection.hasNext())
{
if(listBox2->isSelected(i))
{
mSelectedItems.push_back(listBox2->text(i));
}
mSelectedItems.push_back(selection.next()->text());
}
return &mSelectedItems;
}

View File

@ -22,13 +22,13 @@
#include <QDialog>
#include <list>
class Q3Header;
class QHeaderView;
class QgsDelAttrDialog: public QDialog, private Ui::QgsDelAttrDialogBase
{
Q_OBJECT
public:
QgsDelAttrDialog(Q3Header* header);
QgsDelAttrDialog(QHeaderView* header);
const std::list<QString>* selectedAttributes();
protected:
std::list<QString> mSelectedItems;

View File

@ -22,25 +22,21 @@
QgsGeomTypeDialog::QgsGeomTypeDialog(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
{
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
setupUi(this);
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
mPointRadioButton->setChecked(true);
mAttributeView->removeColumn(0);
mAttributeView->addColumn(tr("Name"));
mAttributeView->addColumn(tr("Type"));
mFileFormatComboBox->insertItem("ESRI Shapefile");
/*mFileFormatComboBox->insertItem("Comma Separated Value");
mFileFormatComboBox->insertItem("GML");
mFileFormatComboBox->insertItem("Mapinfo File");*/
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setEnabled(false);
mPointRadioButton->setChecked(true);
mFileFormatComboBox->insertItem("ESRI Shapefile");
/*mFileFormatComboBox->insertItem("Comma Separated Value");
mFileFormatComboBox->insertItem("GML");
mFileFormatComboBox->insertItem("Mapinfo File");*/
mOkButton = buttonBox->button(QDialogButtonBox::Ok);
mOkButton->setEnabled(false);
}
QgsGeomTypeDialog::~QgsGeomTypeDialog()
{
}
QGis::WKBTYPE QgsGeomTypeDialog::selectedType() const
@ -62,29 +58,28 @@ QGis::WKBTYPE QgsGeomTypeDialog::selectedType() const
void QgsGeomTypeDialog::on_mAddAttributeButton_clicked()
{
std::list<QString> types;
types.push_back("Real");
types.push_back("Integer");
types.push_back("String");
QgsAddAttrDialog d(types, this);
if(d.exec()==QDialog::Accepted)
{
new Q3ListViewItem(mAttributeView, d.name(), d.type());
}
if(mAttributeView->childCount()>0)
{
mOkButton->setEnabled(true);
}
std::list<QString> types;
types.push_back("Real");
types.push_back("Integer");
types.push_back("String");
QgsAddAttrDialog d(types, this);
if(d.exec()==QDialog::Accepted)
{
mAttributeView->addTopLevelItem(new QTreeWidgetItem(QStringList() << d.name() << d.type()));
}
if(mAttributeView->topLevelItemCount()>0)
{
mOkButton->setEnabled(true);
}
}
void QgsGeomTypeDialog::on_mRemoveAttributeButton_clicked()
{
delete(mAttributeView->currentItem());
if(mAttributeView->childCount()==0)
{
mOkButton->setEnabled(false);
}
delete(mAttributeView->currentItem());
if(mAttributeView->topLevelItemCount()==0)
{
mOkButton->setEnabled(false);
}
}
void QgsGeomTypeDialog::on_buttonBox_helpRequested()
@ -94,19 +89,19 @@ void QgsGeomTypeDialog::on_buttonBox_helpRequested()
void QgsGeomTypeDialog::attributes(std::list<std::pair<QString, QString> >& at) const
{
Q3ListViewItemIterator it(mAttributeView);
while ( it.current() )
{
Q3ListViewItem *item = it.current();
at.push_back(std::make_pair(item->text(0), item->text(1)));
QTreeWidgetItemIterator it(mAttributeView);
while ( *it )
{
QTreeWidgetItem *item = *it;
at.push_back(std::make_pair(item->text(0), item->text(1)));
#ifdef QGISDEBUG
qWarning(("appending "+item->text(0)+"//"+item->text(1)).toLocal8Bit().data());
qWarning(("appending "+item->text(0)+"//"+item->text(1)).toLocal8Bit().data());
#endif
++it;
}
++it;
}
}
QString QgsGeomTypeDialog::selectedFileFormat() const
{
return mFileFormatComboBox->currentText();
return mFileFormatComboBox->currentText();
}

View File

@ -439,7 +439,7 @@ void QgsGraduatedSymbolDialog::deleteCurrentClass()
mEntries.erase(classValue);
delete (mClassListWidget->takeItem(currentIndex));
qWarning("numRows: ");
qWarning(QString::number(mClassListWidget->count()));
qWarning(QString::number(mClassListWidget->count()).toUtf8());
//
if(mClassListWidget->count() < (currentIndex + 1))
{

View File

@ -32,30 +32,19 @@ QgsMeasureDialog::QgsMeasureDialog(QgsMeasureTool* tool, Qt::WFlags f)
: QDialog(tool->canvas()->topLevelWidget(), f), mTool(tool)
{
setupUi(this);
#ifdef Q_WS_MAC
// Mac buttons are larger than X11 and require a larger minimum width to be drawn correctly
frame4->setMinimumSize(QSize(224, 0));
#endif
connect(mRestartButton, SIGNAL(clicked()), this, SLOT(restart()));
connect(mCloseButton, SIGNAL(clicked()), this, SLOT(close()));
mMeasureArea = tool->measureArea();
mTotal = 0.;
mTable->setLeftMargin(0); // hide row labels
// Set one cell row where to update current distance
// If measuring area, the table doesn't get shown
mTable->setNumRows(1);
mTable->setText(0, 0, QString::number(0, 'f',1));
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(QString::number(0, 'f', 1)));
item->setTextAlignment(0, Qt::AlignRight);
mTable->addTopLevelItem(item);
//mTable->horizontalHeader()->setLabel( 0, tr("Segments (in meters)") );
//mTable->horizontalHeader()->setLabel( 1, tr("Total") );
//mTable->horizontalHeader()->setLabel( 2, tr("Azimuth") );
mTable->setColumnStretchable ( 0, true );
//mTable->setColumnStretchable ( 1, true );
//mTable->setColumnStretchable ( 2, true );
//mTable->setHeaderLabels(QStringList() << tr("Segments (in meters)") << tr("Total") << tr("Azimuth") );
updateUi();
}
@ -67,8 +56,10 @@ void QgsMeasureDialog::restart()
// Set one cell row where to update current distance
// If measuring area, the table doesn't get shown
mTable->setNumRows(1);
mTable->setText(0, 0, QString::number(0, 'f',1));
mTable->clear();
QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(QString::number(0, 'f', 1)));
item->setTextAlignment(0, Qt::AlignRight);
mTable->addTopLevelItem(item);
mTotal = 0.;
updateUi();
@ -105,8 +96,8 @@ void QgsMeasureDialog::mouseMove(QgsPoint &point)
QgsPoint p1 = tmpPoints[last], p2 = tmpPoints[last+1];
double d = mTool->canvas()->mapRender()->distArea()->measureLine(p1,p2);
//mTable->setText(last, 0, QString::number(d, 'f',1));
mTable->setText(last, 0, QLocale::system().toString(d, 'f', 2));
QTreeWidgetItem *item = mTable->topLevelItem(mTable->topLevelItemCount()-1);
item->setText(0, QLocale::system().toString(d, 'f', 2));
editTotal->setText(formatDistance(mTotal + d));
}
}
@ -129,14 +120,14 @@ void QgsMeasureDialog::addPoint(QgsPoint &point)
mTotal += d;
editTotal->setText(formatDistance(mTotal));
int row = numPoints-2;
mTable->setText(row, 0, QLocale::system().toString(d, 'f', 2));
mTable->setNumRows ( numPoints );
mTable->setText(row + 1, 0, QLocale::system().toString(0.0, 'f', 2));
mTable->ensureCellVisible(row + 1,0);
QTreeWidgetItem *item = mTable->topLevelItem(mTable->topLevelItemCount()-1);
item->setText(0, QLocale::system().toString(d, 'f', 2));
item = new QTreeWidgetItem(QStringList(QLocale::system().toString(0.0, 'f', 2)));
item->setTextAlignment(0, Qt::AlignRight);
mTable->addTopLevelItem(item);
mTable->scrollToItem(item);
}
}
@ -203,16 +194,16 @@ void QgsMeasureDialog::updateUi()
switch (myMapUnits)
{
case QGis::METERS:
mTable->horizontalHeader()->setLabel( 0, tr("Segments (in meters)") );
mTable->setHeaderLabels( QStringList( tr("Segments (in meters)") ) );
break;
case QGis::FEET:
mTable->horizontalHeader()->setLabel( 0, tr("Segments (in feet)") );
mTable->setHeaderLabels( QStringList( tr("Segments (in feet)") ) );
break;
case QGis::DEGREES:
mTable->horizontalHeader()->setLabel( 0, tr("Segments (in degrees)") );
mTable->setHeaderLabels( QStringList( tr("Segments (in degrees)") ) );
break;
case QGis::UNKNOWN:
mTable->horizontalHeader()->setLabel( 0, tr("Segments") );
mTable->setHeaderLabels( QStringList( tr("Segments") ) );
};
if (mMeasureArea)

View File

@ -18,56 +18,33 @@
/* $Id$ */
#include <fstream>
#include <iostream>
#include "qgsnumericsortlistviewitem.h"
QgsNumericSortListViewItem::QgsNumericSortListViewItem(Q3ListView * parent)
: Q3ListViewItem(parent)
QgsNumericSortTreeWidgetItem::QgsNumericSortTreeWidgetItem(QTreeWidget * parent)
: QTreeWidgetItem(parent, UserType)
{
// NOOP
}
QgsNumericSortListViewItem::QgsNumericSortListViewItem(Q3ListViewItem * parent)
: Q3ListViewItem(parent)
QgsNumericSortTreeWidgetItem::QgsNumericSortTreeWidgetItem(QTreeWidgetItem * parent)
: QTreeWidgetItem(parent, UserType)
{
// NOOP
}
QgsNumericSortListViewItem::~QgsNumericSortListViewItem()
QgsNumericSortTreeWidgetItem::~QgsNumericSortTreeWidgetItem()
{
// NOOP
}
int QgsNumericSortListViewItem::compare(Q3ListViewItem * i, int col, bool ascending) const
bool QgsNumericSortTreeWidgetItem::operator<(const QTreeWidgetItem &other) const
{
if (col == 0) // The ID column
int column = treeWidget() ? treeWidget()->sortColumn() : 0;
if (column == 0) // The ID column
{
uint a = text(col).toUInt();
uint b = i->text(col).toUInt();
if (a < b)
{
return -1;
}
else if (a > b)
{
return +1;
}
else
{
return 0;
}
return text(column).toUInt() < other.text(column).toUInt();
}
else
{
// Pass-through to the QListViewItem implementation
return Q3ListViewItem::compare(i, col, ascending);
}
return text(column) < other.text(column);
}

View File

@ -21,21 +21,20 @@
#ifndef QGSNUMERICSORTLISTVIEWITEM_H
#define QGSNUMERICSORTLISTVIEWITEM_H
#include <Q3ListView>
#include <Q3ListViewItem>
#include <QTreeWidgetItem>
/**
\brief QListViewItem that can sort numerically (as opposed to just lexigraphically)
\brief QTreeWidgetItem that can sort numerically (as opposed to just lexigraphically)
This class extends the Qt QListViewItem concept by
reimplementing QListViewItem::compare to allow numeric comparisons
This class extends the Qt QTreeWidgetItem concept by
reimplementing QTreeWidgetItem::operator< to allow numeric comparisons
TODO: Make it work
*/
class QgsNumericSortListViewItem : public Q3ListViewItem
class QgsNumericSortTreeWidgetItem : public QTreeWidgetItem
{
// Q_OBJECT
@ -44,13 +43,13 @@ public:
/**
* Constructor.
*/
QgsNumericSortListViewItem ( Q3ListView * parent );
QgsNumericSortListViewItem ( Q3ListViewItem * parent );
QgsNumericSortTreeWidgetItem ( QTreeWidget * parent );
QgsNumericSortTreeWidgetItem ( QTreeWidgetItem * parent );
//! Destructor
virtual ~QgsNumericSortListViewItem ();
virtual ~QgsNumericSortTreeWidgetItem ();
virtual int compare ( Q3ListViewItem * i, int col, bool ascending ) const;
virtual bool operator<(const QTreeWidgetItem &other) const;
};

View File

@ -27,7 +27,6 @@
#include <QSettings>
#include <QColorDialog>
#include <QLocale>
#include <QTextCodec>
#include <cassert>
#include <iostream>
@ -144,7 +143,7 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
//
// Locale settings
//
QString mySystemLocale = QTextCodec::locale();
QString mySystemLocale = QLocale::system().name();
lblSystemLocale->setText(tr("Detected active locale on your system: ") + mySystemLocale);
QString myUserLocale = settings.value("locale/userLocale", "").toString();
QStringList myI18nList = i18nList();
@ -168,8 +167,8 @@ QgsOptions::QgsOptions(QWidget *parent, Qt::WFlags fl) :
mDefaultSnapModeComboBox->insertItem(0, tr("to vertex"));
mDefaultSnapModeComboBox->insertItem(1, tr("to segment"));
mDefaultSnapModeComboBox->insertItem(2, tr("to vertex and segment"));
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", "to vertex").toString();
mDefaultSnapModeComboBox->setCurrentIndex(mDefaultSnapModeComboBox->findText(tr(defaultSnapString)));
QString defaultSnapString = settings.value("/qgis/digitizing/default_snap_mode", tr("to vertex")).toString();
mDefaultSnapModeComboBox->setCurrentIndex(mDefaultSnapModeComboBox->findText(defaultSnapString));
mDefaultSnappingToleranceSpinBox->setValue(settings.value("/qgis/digitizing/default_snapping_tolerance", 0).toDouble());
mSearchRadiusVertexEditSpinBox->setValue(settings.value("/qgis/digitizing/search_radius_vertex_edit", 10).toDouble());
@ -425,7 +424,7 @@ void QgsOptions::getEllipsoidList()
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select * from tbl_ellipsoid order by name";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
@ -457,7 +456,7 @@ QString QgsOptions::getEllipsoidAcronym(QString theEllipsoidName)
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select acronym from tbl_ellipsoid where name='" + theEllipsoidName + "'";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{
@ -489,7 +488,7 @@ QString QgsOptions::getEllipsoidName(QString theEllipsoidAcronym)
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidAcronym + "'";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{

View File

@ -132,8 +132,8 @@ void QgsPasteTransformations::addTransfer(const QString& sourceSelectedFieldName
// TODO: Do not add the transfer if neither the sourceSelectedFieldName nor the destinationSelectedFieldName could be found.
// For some reason Qt4's uic3 only outputs generic names for layout items
QComboBox* newSourceFields = new QComboBox(FALSE, gridLayout->mainWidget() );
QComboBox* newDestinationFields = new QComboBox(FALSE, gridLayout->mainWidget() );
QComboBox* newSourceFields = new QComboBox(gridLayout->mainWidget() );
QComboBox* newDestinationFields = new QComboBox(gridLayout->mainWidget() );
int count = 0;

View File

@ -13,12 +13,18 @@
* *
***************************************************************************/
/* $Id$ */
#include <iostream>
#include <QMessageBox>
#include <QListView>
#include "qgspgquerybuilder.h"
#include <qgslogger.h>
#include "qgslogger.h"
#include <iostream>
#include <QListView>
#include <QMessageBox>
#include <QRegExp>
#if QT_VERSION < 0x040300
#define toPlainText() text()
#endif
// default constructor
QgsPgQueryBuilder::QgsPgQueryBuilder(QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl)
@ -257,7 +263,7 @@ void QgsPgQueryBuilder::on_btnTest_clicked()
// returned
// if there is no sql, issue a warning
if(txtSQL->text().isEmpty())
if(txtSQL->toPlainText().isEmpty())
{
QMessageBox::information(this, tr("No Query"), tr("You must create a query before you can test it"));
}
@ -265,7 +271,7 @@ void QgsPgQueryBuilder::on_btnTest_clicked()
{
QString numRows;
QString sql = "select count(*) from " + mUri->quotedTablename()
+ " where " + txtSQL->text();
+ " where " + txtSQL->toPlainText();
PGresult *result = PQexec(mPgConnection, sql.toUtf8());
if (PQresultStatus(result) == PGRES_TUPLES_OK)
{
@ -318,10 +324,10 @@ void QgsPgQueryBuilder::setConnection(PGconn *con)
void QgsPgQueryBuilder::on_btnOk_clicked()
{
// if user hits Ok and there is no query, skip the validation
if(txtSQL->text().stripWhiteSpace().length() > 0)
if(txtSQL->toPlainText().stripWhiteSpace().length() > 0)
{
// test the query to see if it will result in a valid layer
long numRecs = countRecords(txtSQL->text());
long numRecs = countRecords(txtSQL->toPlainText());
if(numRecs == -1)
{
//error in query - show the problem
@ -382,7 +388,7 @@ void QgsPgQueryBuilder::on_btnLike_clicked()
QString QgsPgQueryBuilder::sql()
{
return txtSQL->text();
return txtSQL->toPlainText();
}
void QgsPgQueryBuilder::setSql( QString sqlStatement)

View File

@ -65,7 +65,11 @@ void QgsPythonDialog::on_edtCmdLine_returnPressed()
}
QString str = "<b><font color=\"green\">>>></font> " + escapeHtml(command) + "</b><br>" + output;
#if QT_VERSION < 0x040300
txtHistory->setText(txtHistory->text() + str);
#else
txtHistory->setPlainText(txtHistory->toPlainText() + str);
#endif
edtCmdLine->setText("");
txtHistory->moveCursor(QTextCursor::End);

View File

@ -242,7 +242,7 @@ QString QgsPythonUtils::getVariableFromMain(QString name)
QString output;
// get the result
obj = PyDict_GetItemString(mMainDict, name); // obj is borrowed reference
obj = PyDict_GetItemString(mMainDict, name.toUtf8()); // obj is borrowed reference
if (obj != NULL && obj != Py_None)
{
@ -255,7 +255,7 @@ QString QgsPythonUtils::getVariableFromMain(QString name)
}
// erase result
PyDict_SetItemString(mMainDict, name, Py_None);
PyDict_SetItemString(mMainDict, name.toUtf8(), Py_None);
return output;
}

View File

@ -49,12 +49,11 @@
const char * const ident =
"$Id$";
// Constant that signals property not used.
const QString QgsRasterLayerProperties::QSTRING_NOT_SET = QT_TR_NOOP("Not Set");
QgsRasterLayerProperties::QgsRasterLayerProperties(QgsMapLayer *lyr, QWidget *parent, Qt::WFlags fl)
: QDialog(parent, fl),
mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr)),
// Constant that signals property not used.
TRSTRING_NOT_SET( tr("Not Set"))
{
ignoreSpinBoxEvent = false; //Short circuit signal loop between min max field and stdDev spin box
@ -164,16 +163,16 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
cboGreen->addItem(tr("Blue"));
cboBlue->addItem(tr("Blue"));
cboRed->addItem(tr(QSTRING_NOT_SET));
cboGreen->addItem(tr(QSTRING_NOT_SET));
cboBlue->addItem(tr(QSTRING_NOT_SET));
cboRed->addItem(TRSTRING_NOT_SET);
cboGreen->addItem(TRSTRING_NOT_SET);
cboBlue->addItem(TRSTRING_NOT_SET);
cboGray->addItem(tr("Red"));
cboGray->addItem(tr("Green"));
cboGray->addItem(tr("Blue"));
cboGray->addItem(tr(QSTRING_NOT_SET));
cboGray->addItem(TRSTRING_NOT_SET);
lstHistogramLabels->insertItem(tr("Palette"));
lstHistogramLabels->addItem(tr("Palette"));
}
else // all other layer types use band name entries only
{
@ -238,7 +237,7 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
{
myPixmap.fill( Qt::gray );
}
lstHistogramLabels->insertItem(myPixmap,myRasterBandNameQString);
lstHistogramLabels->addItem(new QListWidgetItem( myPixmap, myRasterBandNameQString));
mGradientHeight = pixHistogram->height() / 2;
mGradientWidth = pixHistogram->width() /2;
//keep a list of band names for later use
@ -251,8 +250,8 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
myIteratorInt <= myBandCountInt;
++myIteratorInt)
{
Q3ListBoxItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
lstHistogramLabels->setSelected( myItem,true);
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
myItem->setSelected(true);
}
for (QStringList::Iterator myIterator = myBandNameList.begin();
@ -271,14 +270,14 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
cboBlue->addItem(myQString);
}
cboRed->addItem(tr(QSTRING_NOT_SET));
cboGreen->addItem(tr(QSTRING_NOT_SET));
cboBlue->addItem(tr(QSTRING_NOT_SET));
cboGray->addItem(tr(QSTRING_NOT_SET));
cboRed->addItem(TRSTRING_NOT_SET);
cboGreen->addItem(TRSTRING_NOT_SET);
cboBlue->addItem(TRSTRING_NOT_SET);
cboGray->addItem(TRSTRING_NOT_SET);
}
cboxTransparencyBand->addItem(tr(QSTRING_NOT_SET));
cboxTransparencyLayer->addItem(tr(QSTRING_NOT_SET));
cboxTransparencyBand->addItem(TRSTRING_NOT_SET);
cboxTransparencyLayer->addItem(TRSTRING_NOT_SET);
QMap<QString, QgsMapLayer *> myLayers = QgsMapLayerRegistry::instance()->mapLayers();
QMap<QString, QgsMapLayer *>::iterator it;
for(it = myLayers.begin(); it != myLayers.end(); it++)
@ -313,15 +312,15 @@ mRasterLayer( dynamic_cast<QgsRasterLayer*>(lyr) )
{
if ((*myRasterPyramidIterator).existsFlag==true)
{
lbxPyramidResolutions->insertItem(myPyramidPixmap,
lbxPyramidResolutions->addItem(new QListWidgetItem(myPyramidPixmap,
QString::number((*myRasterPyramidIterator).xDim) + QString(" x ") +
QString::number((*myRasterPyramidIterator).yDim));
QString::number((*myRasterPyramidIterator).yDim)));
}
else
{
lbxPyramidResolutions->insertItem(myNoPyramidPixmap,
lbxPyramidResolutions->addItem(new QListWidgetItem(myNoPyramidPixmap,
QString::number((*myRasterPyramidIterator).xDim) + QString(" x ") +
QString::number((*myRasterPyramidIterator).yDim));
QString::number((*myRasterPyramidIterator).yDim)));
}
}
}
@ -642,17 +641,17 @@ void QgsRasterLayerProperties::sync()
QgsRasterLayer::PALETTED_SINGLE_BAND_PSEUDO_COLOR != mRasterLayer->getDrawingStyle() &&
QgsRasterLayer::PALETTED_MULTI_BAND_COLOR != mRasterLayer->getDrawingStyle())
{
if(mRasterLayer->getRedBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getRedBandName() != TRSTRING_NOT_SET)
{
leRedMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getRedBandName())));
leRedMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getRedBandName())));
}
if(mRasterLayer->getGreenBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGreenBandName() != TRSTRING_NOT_SET)
{
leGreenMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getGreenBandName())));
leGreenMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getGreenBandName())));
}
if(mRasterLayer->getBlueBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getBlueBandName() != TRSTRING_NOT_SET)
{
leBlueMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getBlueBandName())));
leBlueMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getBlueBandName())));
@ -679,7 +678,7 @@ void QgsRasterLayerProperties::sync()
QgsRasterLayer::PALETTED_SINGLE_BAND_PSEUDO_COLOR != mRasterLayer->getDrawingStyle() &&
QgsRasterLayer::PALETTED_MULTI_BAND_COLOR != mRasterLayer->getDrawingStyle())
{
if(mRasterLayer->getGrayBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGrayBandName() != TRSTRING_NOT_SET)
{
leGrayMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getGrayBandName())));
leGrayMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getGrayBandName())));
@ -755,7 +754,7 @@ void QgsRasterLayerProperties::sync()
}
else
{
cboxTransparencyLayer->setCurrentIndex(cboxTransparencyLayer->findText(tr(QSTRING_NOT_SET)));
cboxTransparencyLayer->setCurrentIndex(cboxTransparencyLayer->findText(TRSTRING_NOT_SET));
}
myIndex = cboxTransparencyBand->findText(mRasterLayer->getTransparentBandName());
@ -765,7 +764,7 @@ void QgsRasterLayerProperties::sync()
}
else
{
cboxTransparencyBand->setCurrentIndex(cboxTransparencyBand->findText(tr(QSTRING_NOT_SET)));
cboxTransparencyBand->setCurrentIndex(cboxTransparencyBand->findText(TRSTRING_NOT_SET));
}
//add current NoDataValue to NoDataValue line edit
if(mRasterLayer->isNoDataValueValid())
@ -1134,17 +1133,17 @@ void QgsRasterLayerProperties::apply()
//Set min max based on user defined values if all are set and stdDev is 0.0
if(rbtnThreeBandMinMax->isEnabled() && rbtnThreeBandMinMax->isChecked() && validUserDefinedMinMax())
{
if(mRasterLayer->getRedBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getRedBandName() != TRSTRING_NOT_SET)
{
mRasterLayer->setMinimumValue(cboRed->currentText(), leRedMin->text().toDouble(), false);
mRasterLayer->setMaximumValue(cboRed->currentText(), leRedMax->text().toDouble());
}
if(mRasterLayer->getGreenBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGreenBandName() != TRSTRING_NOT_SET)
{
mRasterLayer->setMinimumValue(cboGreen->currentText(), leGreenMin->text().toDouble(), false);
mRasterLayer->setMaximumValue(cboGreen->currentText(), leGreenMax->text().toDouble());
}
if(mRasterLayer->getBlueBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getBlueBandName() != TRSTRING_NOT_SET)
{
mRasterLayer->setMinimumValue(cboBlue->currentText(), leBlueMin->text().toDouble(), false);
mRasterLayer->setMaximumValue(cboBlue->currentText(), leBlueMax->text().toDouble());
@ -1168,7 +1167,7 @@ void QgsRasterLayerProperties::apply()
//Set min max based on user defined values if all are set and stdDev is 0.0
if(rbtnSingleBandMinMax->isEnabled() && rbtnSingleBandMinMax->isChecked() && validUserDefinedMinMax())
{
if(mRasterLayer->getGrayBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGrayBandName() != TRSTRING_NOT_SET)
{
mRasterLayer->setMinimumValue(cboGray->currentText(), leGrayMin->text().toDouble(), false);
mRasterLayer->setMaximumValue(cboGray->currentText(), leGrayMax->text().toDouble());
@ -1486,17 +1485,17 @@ void QgsRasterLayerProperties::apply()
if(rbtnThreeBandMinMax->isEnabled())
{
if(mRasterLayer->getRedBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getRedBandName() != TRSTRING_NOT_SET)
{
leRedMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getRedBandName())));
leRedMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getRedBandName())));
}
if(mRasterLayer->getGreenBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGreenBandName() != TRSTRING_NOT_SET)
{
leGreenMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getGreenBandName())));
leGreenMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getGreenBandName())));
}
if(mRasterLayer->getBlueBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getBlueBandName() != TRSTRING_NOT_SET)
{
leBlueMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getBlueBandName())));
leBlueMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getBlueBandName())));
@ -1512,7 +1511,7 @@ void QgsRasterLayerProperties::apply()
if(rbtnSingleBandMinMax->isEnabled())
{
if(mRasterLayer->getGrayBandName() != tr(QSTRING_NOT_SET))
if(mRasterLayer->getGrayBandName() != TRSTRING_NOT_SET)
{
leGrayMin->setText(QString::number(mRasterLayer->getMinimumValue(mRasterLayer->getGrayBandName())));
leGrayMax->setText(QString::number(mRasterLayer->getMaximumValue(mRasterLayer->getGrayBandName())));
@ -1551,7 +1550,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
QgsRasterLayer::RasterPyramidList myPyramidList = mRasterLayer->buildRasterPyramidList();
for ( unsigned int myCounterInt = 0; myCounterInt < lbxPyramidResolutions->count(); myCounterInt++ )
{
Q3ListBoxItem *myItem = lbxPyramidResolutions->item( myCounterInt );
QListWidgetItem *myItem = lbxPyramidResolutions->item( myCounterInt );
if ( myItem->isSelected() )
{
//mark to be pyramided
@ -1601,15 +1600,15 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
{
if ((*myRasterPyramidIterator).existsFlag==true)
{
lbxPyramidResolutions->insertItem(myPyramidPixmap,
lbxPyramidResolutions->addItem(new QListWidgetItem(myPyramidPixmap,
QString::number((*myRasterPyramidIterator).xDim) + QString(" x ") +
QString::number((*myRasterPyramidIterator).yDim));
QString::number((*myRasterPyramidIterator).yDim)));
}
else
{
lbxPyramidResolutions->insertItem(myNoPyramidPixmap,
lbxPyramidResolutions->addItem(new QListWidgetItem(myNoPyramidPixmap,
QString::number((*myRasterPyramidIterator).xDim) + QString(" x ") +
QString::number((*myRasterPyramidIterator).yDim));
QString::number((*myRasterPyramidIterator).yDim)));
}
}
//update the legend pixmap
@ -1624,7 +1623,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged(const QString& theText)
{
if(mRasterLayerIsGdal && tr(QSTRING_NOT_SET) != theText)
if(mRasterLayerIsGdal && TRSTRING_NOT_SET != theText)
{
leBlueMin->setText(QString::number(mRasterLayer->getMinimumValue(theText)));
leBlueMax->setText(QString::number(mRasterLayer->getMaximumValue(theText)));
@ -1633,7 +1632,7 @@ void QgsRasterLayerProperties::on_cboBlue_currentIndexChanged(const QString& the
void QgsRasterLayerProperties::on_cboGray_currentIndexChanged(const QString& theText)
{
if(mRasterLayerIsGdal && tr(QSTRING_NOT_SET) != theText)
if(mRasterLayerIsGdal && TRSTRING_NOT_SET != theText)
{
leGrayMin->setText(QString::number(mRasterLayer->getMinimumValue(theText)));
leGrayMax->setText(QString::number(mRasterLayer->getMaximumValue(theText)));
@ -1642,7 +1641,7 @@ void QgsRasterLayerProperties::on_cboGray_currentIndexChanged(const QString& the
void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged(const QString& theText)
{
if(mRasterLayerIsGdal && tr(QSTRING_NOT_SET) != theText)
if(mRasterLayerIsGdal && TRSTRING_NOT_SET != theText)
{
leGreenMin->setText(QString::number(mRasterLayer->getMinimumValue(theText)));
leGreenMax->setText(QString::number(mRasterLayer->getMaximumValue(theText)));
@ -1651,7 +1650,7 @@ void QgsRasterLayerProperties::on_cboGreen_currentIndexChanged(const QString& th
void QgsRasterLayerProperties::on_cboRed_currentIndexChanged(const QString& theText)
{
if(mRasterLayerIsGdal && tr(QSTRING_NOT_SET) != theText)
if(mRasterLayerIsGdal && TRSTRING_NOT_SET != theText)
{
leRedMin->setText(QString::number(mRasterLayer->getMinimumValue(theText)));
leRedMax->setText(QString::number(mRasterLayer->getMaximumValue(theText)));
@ -1744,10 +1743,10 @@ void QgsRasterLayerProperties::on_cboxColorMap_currentIndexChanged(const QString
void QgsRasterLayerProperties::on_cboxTransparencyLayer_currentIndexChanged(const QString& theText)
{
if(theText == tr(QSTRING_NOT_SET))
if(theText == TRSTRING_NOT_SET)
{
cboxTransparencyBand->clear();
cboxTransparencyBand->addItem(tr(QSTRING_NOT_SET));
cboxTransparencyBand->addItem(TRSTRING_NOT_SET);
}
else
{
@ -1760,7 +1759,7 @@ void QgsRasterLayerProperties::on_cboxTransparencyLayer_currentIndexChanged(cons
QgsRasterLayer* myRasterLayer = (QgsRasterLayer*)it.value();
int myBandCount = myRasterLayer->getBandCount();
cboxTransparencyBand->clear();
cboxTransparencyBand->addItem(tr(QSTRING_NOT_SET));
cboxTransparencyBand->addItem(TRSTRING_NOT_SET);
for(int bandRunner = 1; bandRunner <= myBandCount; bandRunner++)
{
cboxTransparencyBand->addItem(myRasterLayer->getRasterBandName(bandRunner));
@ -1884,7 +1883,7 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
++myIteratorInt)
{
QgsRasterBandStats myRasterBandStats = mRasterLayer->getRasterBandStats(myIteratorInt);
Q3ListBoxItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
if ( myItem->isSelected() )
{
mySelectionCount++;
@ -1948,7 +1947,7 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
{
myXAxisMax=static_cast < unsigned int >(myRasterBandStats.maxVal);
}
Q3ListBoxItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
if ( myItem->isSelected() )
{
#ifdef QGISDEBUG
@ -2135,7 +2134,7 @@ void QgsRasterLayerProperties::on_pbnHistRefresh_clicked()
++myIteratorInt)
{
QgsRasterBandStats myRasterBandStats = mRasterLayer->getRasterBandStats(myIteratorInt);
Q3ListBoxItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
QListWidgetItem *myItem = lstHistogramLabels->item( myIteratorInt-1 );
if ( myItem->isSelected() )
{
@ -2460,7 +2459,7 @@ void QgsRasterLayerProperties::on_rbtnSingleBand_toggled(bool theState)
// Populate transparency table with single value transparency pixels
populateTransparencyTable();
// If no band is selected but there are multiple bands, selcet the first as the default
if(cboGray->currentText() == tr(QSTRING_NOT_SET) && 1 < cboGray->count())
if(cboGray->currentText() == TRSTRING_NOT_SET && 1 < cboGray->count())
{
cboGray->setCurrentIndex(0);
}

View File

@ -122,7 +122,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
private:
/** \brief A constant that signals property not used */
static const QString QSTRING_NOT_SET;
const QString TRSTRING_NOT_SET;
/** \brief Pointer to the raster layer that this property dilog changes the behaviour of. */
QgsRasterLayer * mRasterLayer;

View File

@ -26,6 +26,10 @@
#include "qgsvectordataprovider.h"
#include "qgsvectorlayer.h"
#if QT_VERSION < 0x040300
#define toPlainText() text()
#endif
QgsSearchQueryBuilder::QgsSearchQueryBuilder(QgsVectorLayer* layer,
QWidget *parent, Qt::WFlags fl)
@ -156,7 +160,7 @@ void QgsSearchQueryBuilder::on_btnGetAllValues_clicked()
void QgsSearchQueryBuilder::on_btnTest_clicked()
{
long count = countRecords(txtSQL->text());
long count = countRecords(txtSQL->toPlainText());
// error?
if (count == -1)
@ -164,7 +168,7 @@ void QgsSearchQueryBuilder::on_btnTest_clicked()
QString str;
if (count)
str.sprintf(tr("Found %d matching features.","",count), count);
str.sprintf(tr("Found %d matching features.","",count).toUtf8(), count);
else
str = tr("No matching features found.");
QMessageBox::information(this, tr("Search results"), str);
@ -218,14 +222,14 @@ long QgsSearchQueryBuilder::countRecords(QString searchString)
void QgsSearchQueryBuilder::on_btnOk_clicked()
{
// if user hits Ok and there is no query, skip the validation
if(txtSQL->text().stripWhiteSpace().length() > 0)
if(txtSQL->toPlainText().stripWhiteSpace().length() > 0)
{
accept();
return;
}
// test the query to see if it will result in a valid layer
long numRecs = countRecords(txtSQL->text());
long numRecs = countRecords(txtSQL->toPlainText());
if (numRecs == -1)
{
// error shown in countRecords
@ -278,7 +282,7 @@ void QgsSearchQueryBuilder::on_btnLike_clicked()
QString QgsSearchQueryBuilder::searchString()
{
return txtSQL->text();
return txtSQL->toPlainText();
}
void QgsSearchQueryBuilder::setSearchString(QString searchString)

View File

@ -209,12 +209,11 @@ bool QgsServerSourceSelect::populateLayerList(QgsWmsProvider* wmsProvider)
layerAndStyleCount++;
QgsNumericSortListViewItem *lItem = new QgsNumericSortListViewItem(lstLayers);
QgsNumericSortTreeWidgetItem *lItem = new QgsNumericSortTreeWidgetItem(lstLayers);
lItem->setText(0, QString::number(layerAndStyleCount));
lItem->setText(1, layer->name.simplifyWhiteSpace());
lItem->setText(2, layer->title.simplifyWhiteSpace());
lItem->setText(3, layer->abstract.simplifyWhiteSpace());
lstLayers->insertItem(lItem);
// Also insert the styles
// Layer Styles
@ -226,20 +225,18 @@ bool QgsServerSourceSelect::populateLayerList(QgsWmsProvider* wmsProvider)
layerAndStyleCount++;
QgsNumericSortListViewItem *lItem2 = new QgsNumericSortListViewItem(lItem);
QgsNumericSortTreeWidgetItem *lItem2 = new QgsNumericSortTreeWidgetItem(lItem);
lItem2->setText(0, QString::number(layerAndStyleCount));
lItem2->setText(1, layer->style[j].name.simplifyWhiteSpace());
lItem2->setText(2, layer->style[j].title.simplifyWhiteSpace());
lItem2->setText(3, layer->style[j].abstract.simplifyWhiteSpace());
lItem->insertItem(lItem2);
}
}
// If we got some layers, let the user add them to the map
if (lstLayers->childCount() > 0)
if (lstLayers->topLevelItemCount() > 0)
{
btnAdd->setEnabled(TRUE);
}
@ -518,7 +515,7 @@ void QgsServerSourceSelect::on_btnChangeSpatialRefSys_clicked()
* 2. Ensure that only one style is selected per layer.
* If more than one is found, the most recently selected style wins.
*/
void QgsServerSourceSelect::on_lstLayers_selectionChanged()
void QgsServerSourceSelect::on_lstLayers_itemSelectionChanged()
{
QString layerName = "";
@ -528,10 +525,10 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
std::map<QString, QString> newSelectedStyleIdForLayer;
// Iterate through the layers
Q3ListViewItemIterator it( lstLayers );
while ( it.current() )
QTreeWidgetItemIterator it( lstLayers );
while ( *it )
{
Q3ListViewItem *item = it.current();
QTreeWidgetItem *item = *it;
// save the name of the layer (in case only one of its styles was
// selected)
@ -564,7 +561,7 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
)
{
// Remove old style selection
lstLayers->findItem(m_selectedStyleIdForLayer[layerName], 0)->setSelected(FALSE);
lstLayers->findItems(m_selectedStyleIdForLayer[layerName], 0).first()->setSelected(FALSE);
}
#ifdef QGISDEBUG
@ -599,7 +596,7 @@ void QgsServerSourceSelect::on_lstLayers_selectionChanged()
if (parts.at(0) == "EPSG")
{
long epsg = atol(parts.at(1));
long epsg = atol(parts.at(1).toUtf8());
if (epsg == m_Epsg)
{
isThere = true;

View File

@ -110,7 +110,7 @@ public slots:
void on_btnHelp_clicked();
//! Signaled when a layer selection is changed. Ensures that only one style is selected per layer.
void on_lstLayers_selectionChanged();
void on_lstLayers_itemSelectionChanged();
//! Set status message to theMessage
void showStatusMessage(QString const & theMessage);

View File

@ -247,7 +247,7 @@ void QgsUniqueValueDialog::deleteCurrentClass()
mValues.erase(classValue);
delete (mClassListWidget->takeItem(currentIndex));
qWarning("numRows: ");
qWarning(QString::number(mClassListWidget->count()));
qWarning(QString::number(mClassListWidget->count()).toUtf8());
if(mClassListWidget->count() < (currentIndex + 1))
{

View File

@ -47,6 +47,11 @@
#include <QFileInfo>
#include <QSettings>
#if QT_VERSION < 0x040300
#define toPlainText() text()
#endif
QgsVectorLayerProperties::QgsVectorLayerProperties(QgsVectorLayer * lyr,
QWidget * parent,
Qt::WFlags fl)
@ -275,7 +280,7 @@ void QgsVectorLayerProperties::apply()
{
grpSubset->setEnabled(true);
// set the subset sql for the layer
layer->setSubsetString(txtSubsetSQL->text());
layer->setSubsetString(txtSubsetSQL->toPlainText());
// update the metadata with the updated sql subset
teMetadata->setText(getMetadata());
// update the extents of the layer (fetched from the provider)
@ -349,7 +354,7 @@ void QgsVectorLayerProperties::on_pbnQueryBuilder_clicked()
// Set the sql in the query builder to the same in the prop dialog
// (in case the user has already changed it)
pqb->setSql(txtSubsetSQL->text());
pqb->setSql(txtSubsetSQL->toPlainText());
// Open the query builder
if(pqb->exec())
{

View File

@ -178,22 +178,14 @@ TARGET_LINK_LIBRARIES(qgis_core
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTXML_LIBRARY}
#${QT_QTSQL_LIBRARY}
${QT_QTSVG_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTMAIN_LIBRARY}
${QT_QT3SUPPORT_LIBRARY}
${PROJ_LIBRARY}
${GEOS_LIBRARY}
${GDAL_LIBRARY}
${PLATFORM_LIBRARIES}
)
#work aroud for the fact that qt3 support on mac is linked ot qsql
IF (APPLE)
TARGET_LINK_LIBRARIES(qgis_core
${QT_QTSQL_LIBRARY}
)
ENDIF (APPLE)
IF (NOT WITH_INTERNAL_SQLITE3)
TARGET_LINK_LIBRARIES(qgis_core ${SQLITE3_LIBRARY})

View File

@ -147,8 +147,8 @@ void QgsCoordinateTransform::initialise()
}
// init the projections (destination and source)
mDestinationProjection = pj_init_plus(mDestSRS.proj4String());
mSourceProjection = pj_init_plus(mSourceSRS.proj4String());
mDestinationProjection = pj_init_plus(mDestSRS.proj4String().toUtf8());
mSourceProjection = pj_init_plus(mSourceSRS.proj4String().toUtf8());
mInitialisedFlag = true;
if ( mDestinationProjection == NULL )
@ -561,7 +561,7 @@ const char *finder( const char *name )
proj = QApplication::applicationDirPath()
+ "/share/proj/" + QString(name);
#endif
return proj.ascii();
return proj.toUtf8();
}
void QgsCoordinateTransform::setFinder()

View File

@ -97,7 +97,7 @@ bool QgsDistanceArea::setEllipsoid(const QString& ellipsoid)
}
// Set up the query to retreive the projection information needed to populate the ELLIPSOID list
QString mySql = "select radius, parameter2 from tbl_ellipsoid where acronym='" + ellipsoid + "'";
myResult = sqlite3_prepare(myDatabase, (const char *)mySql, mySql.length(), &myPreparedStatement, &myTail);
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
// XXX Need to free memory from the error msg if one is set
if(myResult == SQLITE_OK)
{

View File

@ -40,7 +40,7 @@ QgsMapLayerRegistry *QgsMapLayerRegistry::instance()
// Main class begins now...
//
QgsMapLayerRegistry::QgsMapLayerRegistry(QObject *parent, const char *name) : QObject(parent,name)
QgsMapLayerRegistry::QgsMapLayerRegistry(QObject *parent) : QObject(parent)
{
QgsDebugMsg("QgsMapLayerRegistry created!");
// constructor does nothing

View File

@ -108,7 +108,7 @@ signals:
protected:
//! protected constructor
QgsMapLayerRegistry( QObject * parent = 0, const char * name = 0 );
QgsMapLayerRegistry( QObject * parent = 0 );
private:

View File

@ -942,8 +942,8 @@ bool QgsProject::write()
// even though we got an error, let's make
// sure it's closed anyway
imp_->file.close();
throw QgsIOException(imp_->file.name() + QObject::tr(QString(" is not writeable.")
+ QString("Please adjust permissions (if possible) and try again.")));
throw QgsIOException(imp_->file.name() + QObject::tr(" is not writeable.")
+ QObject::tr("Please adjust permissions (if possible) and try again."));
// XXX raise exception? Ok now superfluous
return false;
@ -1116,7 +1116,7 @@ QgsProject::readListEntry(QString const & scope,
if (valid)
{
return value.asStringList();
return value.toStringList();
}
return QStringList();

View File

@ -17,19 +17,12 @@
#include "qgsprojectproperty.h"
#include <qdom.h>
#include <qglobal.h>
// Qt4-only includes to go here
#include <QDomDocument>
#include <QStringList>
static const char * const ident_ = "$Id$";
void QgsPropertyValue::dump( size_t tabs ) const
{
QString tabString;
@ -209,28 +202,28 @@ bool QgsPropertyValue::readXML(QDomNode & keyNode)
break;
case QVariant::Int:
value_ = QVariant(subkeyElement.text()).asInt();
value_ = QVariant(subkeyElement.text()).toInt();
break;
case QVariant::UInt:
value_ = QVariant(subkeyElement.text()).asUInt();
value_ = QVariant(subkeyElement.text()).toUInt();
break;
case QVariant::Bool:
value_ = QVariant(subkeyElement.text()).asBool();
value_ = QVariant(subkeyElement.text()).toBool();
break;
case QVariant::Double:
value_ = QVariant(subkeyElement.text()).asDouble();
value_ = QVariant(subkeyElement.text()).toDouble();
break;
// in Qt4 this is equivalent to case QVariant::ByteArray
case QVariant::CString:
value_ = QVariant(subkeyElement.text()).asCString();
value_ = QVariant(subkeyElement.text()).toCString();
break;
@ -288,11 +281,11 @@ bool QgsPropertyValue::readXML(QDomNode & keyNode)
//
/*
case QVariant::LongLong :
value_ = QVariant(subkeyElement.text()).asLongLong();
value_ = QVariant(subkeyElement.text()).toLongLong();
break;
case QVariant::ULongLong :
value_ = QVariant(subkeyElement.text()).asULongLong();
value_ = QVariant(subkeyElement.text()).toULongLong();
break;
*/
default :
@ -324,7 +317,7 @@ bool QgsPropertyValue::writeXML( QString const & nodeName,
// XXX Not the most elegant way to handle string lists?
if ( QVariant::StringList == value_.type() )
{
QStringList sl = value_.asStringList();
QStringList sl = value_.toStringList();
for ( QStringList::iterator i = sl.begin();
i != sl.end();
@ -353,17 +346,18 @@ bool QgsPropertyValue::writeXML( QString const & nodeName,
QgsPropertyKey::QgsPropertyKey( QString const name )
: mName( name )
{}
QgsPropertyKey::~QgsPropertyKey()
{
// since we own our properties, we are responsible for deleting the
// contents
mProperties.setAutoDelete(true);
clearKeys();
}
QVariant QgsPropertyKey::value() const
{
QgsProperty * foundQgsProperty;
if ( 0 == ( foundQgsProperty = mProperties.find(name()) ) )
if ( 0 == ( foundQgsProperty = mProperties.value(name()) ) )
{ // recurse down to next key
return foundQgsProperty->value();
} else
@ -388,18 +382,19 @@ void QgsPropertyKey::dump( size_t tabs ) const
if ( ! mProperties.isEmpty() )
{
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
QHashIterator < QString, QgsProperty* > i(mProperties);
while (i.hasNext())
{
if ( i.current()->isValue() )
if ( i.next().value()->isValue() )
{
QgsPropertyValue * propertyValue =
dynamic_cast<QgsPropertyValue*>( i.current() );
dynamic_cast<QgsPropertyValue*>( i.value() );
if ( QVariant::StringList == propertyValue->value().type() )
{
qDebug("%skey: <%s> value:",
tabString.toLocal8Bit().data(),
i.currentKey().toLocal8Bit().data() );
i.key().toLocal8Bit().data() );
propertyValue->dump( tabs + 1 );
}
@ -407,7 +402,7 @@ void QgsPropertyKey::dump( size_t tabs ) const
{
qDebug("%skey: <%s> value: %s",
tabString.toLocal8Bit().data(),
i.currentKey().toLocal8Bit().data(),
i.key().toLocal8Bit().data(),
propertyValue->value().toString().toLocal8Bit().data() );
}
}
@ -415,21 +410,21 @@ void QgsPropertyKey::dump( size_t tabs ) const
{
qDebug("%skey: <%s> subkey: <%s>",
tabString.toLocal8Bit().data(),
i.currentKey().toLocal8Bit().data(),
dynamic_cast<QgsPropertyKey*>(i.current())->name().toLocal8Bit().data() );
i.key().toLocal8Bit().data(),
dynamic_cast<QgsPropertyKey*>(i.value())->name().toLocal8Bit().data() );
i.current()->dump( tabs + 1 );
i.value()->dump( tabs + 1 );
}
// qDebug("<%s>", (const char *) name().utf8());
// if ( i.current()->isValue() )
// if ( i.value()->isValue() )
// {
// qDebug(" <%s>", (const char*) i.currentKey().utf8() );
// qDebug(" <%s>", (const char*) i.key().utf8() );
// }
// i.current()->dump();
// if ( i.current()->isValue() )
// i.value()->dump();
// if ( i.value()->isValue() )
// {
// qDebug(" </%s>", (const char*) i.currentKey().utf8() );
// qDebug(" </%s>", (const char*) i.key().utf8() );
// }
// qDebug("</%s>", (const char *) name().utf8());
}
@ -453,7 +448,8 @@ bool QgsPropertyKey::readXML(QDomNode & keyNode)
subkeys.item(i).isElement() && // and we're an element
subkeys.item(i).toElement().hasAttribute("type")) // and we have a "type" attribute
{ // then we're a key value
mProperties.replace(subkeys.item(i).nodeName(), new QgsPropertyValue);
delete mProperties.take(subkeys.item(i).nodeName());
mProperties.insert(subkeys.item(i).nodeName(), new QgsPropertyValue);
QDomNode subkey = subkeys.item(i);
@ -496,9 +492,11 @@ bool QgsPropertyKey::writeXML(QString const &nodeName, QDomElement & element, QD
if ( ! mProperties.isEmpty() )
{
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
QHashIterator < QString, QgsProperty* > i(mProperties);
while (i.hasNext())
{
if (!i.current()->writeXML(i.currentKey(), keyElement, document))
i.next();
if (!i.value()->writeXML(i.key(), keyElement, document))
{
return false;
}
@ -517,12 +515,13 @@ bool QgsPropertyKey::writeXML(QString const &nodeName, QDomElement & element, QD
void QgsPropertyKey::entryList( QStringList & entries ) const
{
// now add any leaf nodes to the entries list
for (Q3DictIterator<QgsProperty> i(mProperties); i.current(); ++i)
QHashIterator < QString, QgsProperty* > i(mProperties);
while (i.hasNext())
{
// add any of the nodes that have just a single value
if (i.current()->isLeaf())
if (i.next().value()->isLeaf())
{
entries.append(i.currentKey());
entries.append(i.key());
}
}
} // QgsPropertyKey::entryList
@ -532,12 +531,13 @@ void QgsPropertyKey::entryList( QStringList & entries ) const
void QgsPropertyKey::subkeyList(QStringList & entries) const
{
// now add any leaf nodes to the entries list
for (Q3DictIterator < QgsProperty > i(mProperties); i.current(); ++i)
QHashIterator < QString, QgsProperty* > i(mProperties);
while (i.hasNext())
{
// add any of the nodes that have just a single value
if (!i.current()->isLeaf())
if (!i.next().value()->isLeaf())
{
entries.append(i.currentKey());
entries.append(i.key());
}
}
} // QgsPropertyKey::subkeyList
@ -551,9 +551,9 @@ bool QgsPropertyKey::isLeaf() const
}
else if (1 == count())
{
Q3DictIterator < QgsProperty > i(mProperties);
QHashIterator < QString, QgsProperty* > i(mProperties);
if (i.current() && i.current()->isValue())
if (i.hasNext() && i.next().value()->isValue())
{
return true;
}
@ -561,6 +561,3 @@ bool QgsPropertyKey::isLeaf() const
return false;
} // QgsPropertyKey::isLeaf

View File

@ -23,9 +23,8 @@
#ifndef QGSPROJECTPROPERTY_H
#define QGSPROJECTPROPERTY_H
#include <qvariant.h>
#include <qstring.h>
#include <q3dict.h>
#include <QHash>
#include <QVariant>
class QDomNode;
class QDomElement;
@ -104,7 +103,7 @@ public:
embedded QVariant, _value. For QgsPropertyKey, this means returning
the QgsPropertyValue _value that is keyed by its name, if it exists;
i.e., QgsPropertyKey "foo" will return the property value mapped to its
name, "foo", in its QDict of QProperties.
name, "foo", in its QHash of QProperties.
*/
virtual QVariant value() const = 0;
@ -186,7 +185,7 @@ private:
Can, itself, contain QgsPropertyKeys and QgsPropertyValues.
The internal QDict, mProperties, maps key names to their respective
The internal QHash, mProperties, maps key names to their respective
QgsPropertyValue or next QgsPropertyKey in the key name sequence. The key with
the current name should contain its QgsPropertyValue.
@ -203,8 +202,7 @@ public:
QgsPropertyKey( QString const name = "" );
virtual ~ QgsPropertyKey()
{ }
virtual ~ QgsPropertyKey();
/// every key has a name
// @{
@ -225,16 +223,17 @@ public:
/// add the given property key
QgsPropertyKey * addKey( QString const & keyName )
{
mProperties.replace( keyName, new QgsPropertyKey(keyName) );
delete mProperties.take( keyName );
mProperties.insert( keyName, new QgsPropertyKey(keyName) );
return dynamic_cast<QgsPropertyKey*>(mProperties.find( keyName ));
return dynamic_cast<QgsPropertyKey*>(mProperties.value( keyName ));
}
/// remove the given key
bool removeKey( QString const & keyName )
void removeKey( QString const & keyName )
{
return mProperties.remove( keyName );
delete mProperties.take( keyName );
}
/** set the value associated with this key
@ -242,9 +241,10 @@ public:
*/
QgsPropertyValue * setValue( QString const & name, QVariant const & value )
{
mProperties.replace( name, new QgsPropertyValue( value ) );
delete mProperties.take( name );
mProperties.insert( name, new QgsPropertyValue( value ) );
return dynamic_cast<QgsPropertyValue*>(mProperties.find( name ));
return dynamic_cast<QgsPropertyValue*>(mProperties.value( name ));
}
/** set the value associated with this key
@ -298,18 +298,19 @@ public:
virtual void clear()
{
mName = "";
mProperties.clear();
clearKeys();
}
/// delete any sub-nodes
virtual void clearKeys()
{
qDeleteAll(mProperties);
mProperties.clear();
}
QgsProperty * find( QString & propertyName )
{
return mProperties.find( propertyName );
return mProperties.value( propertyName );
}
private:
@ -318,7 +319,7 @@ private:
QString mName;
/// sub-keys
Q3Dict < QgsProperty > mProperties;
QHash < QString, QgsProperty* > mProperties;
}; // class QgsPropertyKey

View File

@ -18,11 +18,10 @@
/* $Id$ */
#include "qgsprovidercountcalcevent.h"
//Added by qt3to4:
#include <QCustomEvent>
#include "qgis.h"
QgsProviderCountCalcEvent::QgsProviderCountCalcEvent( long numberFeatures )
: QCustomEvent( QGis::ProviderCountCalcEvent ),
: QEvent( static_cast<QEvent::Type>(QGis::ProviderCountCalcEvent) ),
n( numberFeatures )
{
// NO-OP

View File

@ -20,11 +20,7 @@
#ifndef QGSPROVIDERCOUNTCALCEVENT_H
#define QGSPROVIDERCOUNTCALCEVENT_H
#include <qevent.h>
#include "qgis.h"
//Added by qt3to4:
#include <QCustomEvent>
#include <QEvent>
/*!
* \brief A custom event that is designed to be fired when a layer count has been fully calculated.
@ -32,7 +28,7 @@
\date March 2005
This QCustomEvent is designed to be fired when the full item count of a layer has been calculated.
This custom QEvent is designed to be fired when the full item count of a layer has been calculated.
It was initially included in QGIS to help the QgsPostgresProvider provide the asynchronous
calculation of PostgreSQL layer counts.
@ -43,7 +39,7 @@
// TODO: Add the pg table this is a count OF.
class CORE_EXPORT QgsProviderCountCalcEvent : public QCustomEvent
class CORE_EXPORT QgsProviderCountCalcEvent : public QEvent
{
public:

View File

@ -18,11 +18,10 @@
/* $Id$ */
#include "qgsproviderextentcalcevent.h"
//Added by qt3to4:
#include <QCustomEvent>
#include "qgis.h"
QgsProviderExtentCalcEvent::QgsProviderExtentCalcEvent( QgsRect* layerExtent )
: QCustomEvent( QGis::ProviderExtentCalcEvent ),
: QEvent( static_cast<QEvent::Type>(QGis::ProviderExtentCalcEvent) ),
le( layerExtent )
{
// NO-OP

View File

@ -20,12 +20,8 @@
#ifndef QGSPROVIDEREXTENTCALCEVENT_H
#define QGSPROVIDEREXTENTCALCEVENT_H
#include <qevent.h>
#include "qgis.h"
#include "qgsrect.h"
//Added by qt3to4:
#include <QCustomEvent>
#include <QEvent>
class QgsRect;
/*!
* \brief A custom event that is designed to be fired when a layer extent has been fully calculated.
@ -33,7 +29,7 @@
\date March 2005
This QCustomEvent is designed to be fired when the full extent of a layer has been calculated.
This custom QEvent is designed to be fired when the full extent of a layer has been calculated.
It was initially included in QGIS to help the QgsPostgresProvider provide the asynchronous
calculation of PostgreSQL layer extents.
@ -44,7 +40,7 @@
// TODO: Add the pg table this is a extent OF.
class CORE_EXPORT QgsProviderExtentCalcEvent : public QCustomEvent
class CORE_EXPORT QgsProviderExtentCalcEvent : public QEvent
{
public:

View File

@ -72,9 +72,9 @@ QgsProviderRegistry::QgsProviderRegistry(QString pluginPath)
mLibraryDirectory.setFilter( QDir::Files | QDir::NoSymLinks );
#ifdef WIN32
mLibraryDirectory.setNameFilter( "*.dll" );
mLibraryDirectory.setNameFilters( QStringList("*.dll") );
#else
mLibraryDirectory.setNameFilter( "*.so" );
mLibraryDirectory.setNameFilters( QStringList("*.so") );
#endif
#ifdef QGISDEBUG
@ -316,7 +316,7 @@ QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey,
QString lib = library(providerKey);
#ifdef TESTPROVIDERLIB
const char *cLib = (const char *) lib;
const char *cLib = lib.toUtf8();
// test code to help debug provider loading problems
// void *handle = dlopen(cLib, RTLD_LAZY);
@ -334,7 +334,7 @@ QgsDataProvider* QgsProviderRegistry::getProvider( QString const & providerKey,
#endif
// load the data provider
QLibrary* myLib = new QLibrary((const char *) lib);
QLibrary* myLib = new QLibrary(lib);
#ifdef QGISDEBUG
QgsDebugMsg("QgsProviderRegistry::getRasterProvider: Library name is " + myLib->library());

View File

@ -231,7 +231,7 @@ QString QgsRect::asPolygon() const
QTextOStream foo( &rep );
foo.precision(8);
foo.setf(QTextStream::fixed);
foo.setRealNumberNotation(QTextStream::FixedNotation);
// NOTE: a polygon isn't a polygon unless its closed. In the case of
// a rectangle, that means 5 points (last == first)
foo << xmin << " " << ymin << ", "

View File

@ -228,7 +228,7 @@ bool QgsSpatialRefSys::loadFromDb(QString db, QString field, long id)
mGeoFlag = (geo == 0 ? false : true);
setMapUnits();
mIsValidFlag = true;
OSRImportFromProj4( mSRS, (const char *)proj4String.latin1() );
OSRImportFromProj4( mSRS, (const char *)proj4String.toLatin1() );
}
else
{
@ -251,7 +251,7 @@ bool QgsSpatialRefSys::createFromWkt(QString theWkt)
}
QgsDebugMsg("QgsSpatialRefSys::createFromWkt(QString theWkt) using: " + theWkt);
//this is really ugly but we need to get a QString to a char**
char *pWkt = (char *)theWkt.latin1();
char *pWkt = theWkt.toLatin1().data();
OGRErr myInputResult = OSRImportFromWkt( mSRS, &pWkt );
@ -408,7 +408,7 @@ bool QgsSpatialRefSys::createFromProj4 (const QString theProj4String)
if (!myRecord.empty())
{
// Success! We have found the proj string by swapping the lat_1 and lat_2
OSRImportFromProj4(mSRS, (const char *)theProj4StringModified.latin1() );
OSRImportFromProj4(mSRS, (const char *)theProj4StringModified.toLatin1() );
mySrsId=myRecord["srs_id"].toLong();
QgsDebugMsg("QgsSpatialRefSys::createFromProj4 proj4string match search for srsid returned srsid: " + QString::number(mySrsId));
if (mySrsId > 0)
@ -658,7 +658,7 @@ void QgsSpatialRefSys::setDescription (QString theDescription)
}
void QgsSpatialRefSys::setProj4String (QString theProj4String)
{
mIsValidFlag = OSRImportFromProj4(mSRS, (const char *)theProj4String.latin1())==OGRERR_NONE;
mIsValidFlag = OSRImportFromProj4(mSRS, (const char *)theProj4String.toLatin1())==OGRERR_NONE;
}
void QgsSpatialRefSys::setGeographicFlag (bool theGeoFlag)
{

View File

@ -57,7 +57,7 @@ QgsVectorFileWriter::QgsVectorFileWriter(const QString& shapefileName,
}
// create the data source
mDS = OGR_Dr_CreateDataSource(poDriver,shapefileName, NULL);
mDS = OGR_Dr_CreateDataSource(poDriver, shapefileName.toLocal8Bit().data(), NULL);
if (mDS == NULL)
{
mError = ErrCreateDataSource;

View File

@ -2227,7 +2227,7 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
}
else
{
QgsDebugMsg("Invalid provider plugin " + QString(mDataSource.ascii()));
QgsDebugMsg("Invalid provider plugin " + QString(mDataSource.toUtf8()));
return false;
}
}

View File

@ -105,9 +105,6 @@ static const char *const mSupportedRasterFormats[] =
};
// Constant that signals property not used.
const QString QgsRasterLayer::QSTRING_NOT_SET = QT_TR_NOOP("Not Set");
/**
Builds the list of file filter strings to later be used by
QgisApp::addRasterLayer()
@ -385,7 +382,11 @@ QgsRasterLayer::QgsRasterLayer(
mDebugOverlayFlag(false),
mInvertPixelsFlag(false),
mStandardDeviations(0),
mDataProvider(0)
mDataProvider(0),
// Constant that signals property not used.
QSTRING_NOT_SET("Not Set"),
TRSTRING_NOT_SET(tr("Not Set"))
{
mUserDefinedRGBMinMaxFlag = false; //defaults needed to bypass stretch
@ -618,8 +619,8 @@ bool QgsRasterLayer::readFile( QString const & fileName )
mRedBandName = "Red"; // sensible default
mGreenBandName = "Green"; // sensible default
mBlueBandName = "Blue";// sensible default
mTransparencyBandName = tr(QSTRING_NOT_SET); // sensible default
mGrayBandName = tr(QSTRING_NOT_SET); //sensible default
mTransparencyBandName = TRSTRING_NOT_SET; // sensible default
mGrayBandName = TRSTRING_NOT_SET; //sensible default
drawingStyle = PALETTED_MULTI_BAND_COLOR; //sensible default
setContrastEnhancementAlgorithm(QgsContrastEnhancement::NO_STRETCH);
}
@ -635,7 +636,7 @@ bool QgsRasterLayer::readFile( QString const & fileName )
}
else
{
mBlueBandName = tr(QSTRING_NOT_SET); // sensible default
mBlueBandName = TRSTRING_NOT_SET; // sensible default
}
//Beacuse the transparent band can be set from a different layer defaulting to the fourth
@ -645,19 +646,19 @@ bool QgsRasterLayer::readFile( QString const & fileName )
mTransparencyBandName = getRasterBandName(4);
else
*/
mTransparencyBandName = tr(QSTRING_NOT_SET);
mTransparencyBandName = TRSTRING_NOT_SET;
mGrayBandName = tr(QSTRING_NOT_SET); //sensible default
mGrayBandName = TRSTRING_NOT_SET; //sensible default
drawingStyle = MULTI_BAND_COLOR; //sensible default
}
else //GRAY_OR_UNDEFINED
{
//Disabled automatically generating stats to improve initial load speed.
//getRasterBandStats(1);
mRedBandName = tr(QSTRING_NOT_SET); //sensible default
mGreenBandName = tr(QSTRING_NOT_SET); //sensible default
mBlueBandName = tr(QSTRING_NOT_SET); //sensible default
mTransparencyBandName = tr(QSTRING_NOT_SET); //sensible default
mRedBandName = TRSTRING_NOT_SET; //sensible default
mGreenBandName = TRSTRING_NOT_SET; //sensible default
mBlueBandName = TRSTRING_NOT_SET; //sensible default
mTransparencyBandName = TRSTRING_NOT_SET; //sensible default
drawingStyle = SINGLE_BAND_GRAY; //sensible default
mGrayBandName = getRasterBandName(1); // usually gdal will return gray or undefined
}
@ -967,9 +968,8 @@ QPixmap QgsRasterLayer::getPaletteAsPixmap()
QPixmap myPalettePixmap( mySize, mySize);
QPainter myQPainter(&myPalettePixmap);
QImage myQImage = QImage( mySize, mySize, 32);
QImage myQImage = QImage( mySize, mySize, QImage::Format_RGB32);
myQImage.fill(0);
myQImage.setAlphaBuffer(false);
myPalettePixmap.fill();
double myStep = ( myMax - myMin ) / ( mySize * mySize);
@ -1309,7 +1309,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
// a "Gray" or "Undefined" layer drawn as a range of gray colors
case SINGLE_BAND_GRAY:
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1322,7 +1322,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
// a "Gray" or "Undefined" layer drawn using a pseudocolor algorithm
case SINGLE_BAND_PSEUDO_COLOR:
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1335,7 +1335,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
// a "Palette" layer drawn in gray scale (using only one of the color components)
case PALETTED_SINGLE_BAND_GRAY:
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1352,7 +1352,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
// a "Palette" layer having only one of its color components rendered as psuedo color
case PALETTED_SINGLE_BAND_PSEUDO_COLOR:
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1373,7 +1373,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
case MULTI_BAND_SINGLE_BAND_GRAY:
QgsDebugMsg("MULTI_BAND_SINGLE_BAND_GRAY drawing type detected...");
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
QgsDebugMsg("MULTI_BAND_SINGLE_BAND_GRAY Not Set detected..." + mGrayBandName);
break;
@ -1389,7 +1389,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
//a layer containing 2 or more bands, but using only one band to produce a pseudocolor image
case MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR:
//check the band is set!
if (mGrayBandName == tr(QSTRING_NOT_SET))
if (mGrayBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1404,9 +1404,9 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
//In the case of a multiband with only two bands,
//one band will have to be mapped to more than one color
case MULTI_BAND_COLOR:
if(mRedBandName == tr(QSTRING_NOT_SET) ||
mGreenBandName == tr(QSTRING_NOT_SET) ||
mBlueBandName == tr(QSTRING_NOT_SET))
if(mRedBandName == TRSTRING_NOT_SET ||
mGreenBandName == TRSTRING_NOT_SET ||
mBlueBandName == TRSTRING_NOT_SET)
{
break;
}
@ -1450,8 +1450,7 @@ void QgsRasterLayer::drawSingleBandGray(QPainter * theQPainter, QgsRasterViewPor
return;
}
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
QgsRasterBandStats myGrayBandStats;
@ -1554,8 +1553,7 @@ void QgsRasterLayer::drawSingleBandPseudoColor(QPainter * theQPainter,
return;
}
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
if (NULL == mRasterShader)
@ -1659,8 +1657,7 @@ void QgsRasterLayer::drawPalettedSingleBandColor(QPainter * theQPainter, QgsRast
QgsColorTable *myColorTable = colorTable ( theBandNo );
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
double myPixelValue = 0.0;
@ -1745,8 +1742,7 @@ void QgsRasterLayer::drawPalettedSingleBandGray(QPainter * theQPainter, QgsRaste
QgsColorTable *myColorTable = &(myRasterBandStats.colorTable);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
bool found = false;
@ -1842,8 +1838,7 @@ void QgsRasterLayer::drawPalettedSingleBandPseudoColor(QPainter * theQPainter, Q
return;
}
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
if (NULL == mRasterShader)
@ -1972,8 +1967,7 @@ void QgsRasterLayer::drawPalettedMultiBandColor(QPainter * theQPainter, QgsRaste
QgsColorTable *myColorTable = colorTable ( theBandNo );
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
double myPixelValue = 0.0;
@ -2119,8 +2113,7 @@ void QgsRasterLayer::drawMultiBandColor(QPainter * theQPainter, QgsRasterViewPor
return;
}
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, 32);
myQImage.setAlphaBuffer(true);
QImage myQImage = QImage(theRasterViewPort->drawableAreaXDim, theRasterViewPort->drawableAreaYDim, QImage::Format_ARGB32);
myQImage.fill(qRgba(255,255,255,0 )); // fill transparent
QgsRasterBandStats myRedBandStats;
@ -2717,10 +2710,10 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
{
QgsDebugMsg("setRedBandName : " + theBandNameQString);
//check if the band is unset
if (theBandNameQString == tr(QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
{
// Use translated name internally
mRedBandName = tr(QSTRING_NOT_SET);
mRedBandName = TRSTRING_NOT_SET;
return;
}
//check if the image is paletted
@ -2743,7 +2736,7 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
}
//if no matches were found default to not set
mRedBandName = tr(QSTRING_NOT_SET);
mRedBandName = TRSTRING_NOT_SET;
return;
}
@ -2753,10 +2746,10 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
void QgsRasterLayer::setGreenBandName(QString const & theBandNameQString)
{
//check if the band is unset
if (theBandNameQString == tr(QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
{
// Use translated name internally
mGreenBandName = tr(QSTRING_NOT_SET);
mGreenBandName = TRSTRING_NOT_SET;
return;
}
//check if the image is paletted
@ -2779,7 +2772,7 @@ void QgsRasterLayer::setGreenBandName(QString const & theBandNameQString)
}
//if no matches were found default to not set
mGreenBandName = tr(QSTRING_NOT_SET);
mGreenBandName = TRSTRING_NOT_SET;
return;
}
@ -2787,10 +2780,10 @@ void QgsRasterLayer::setGreenBandName(QString const & theBandNameQString)
void QgsRasterLayer::setBlueBandName(QString const & theBandNameQString)
{
//check if the band is unset
if (theBandNameQString == tr(QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET)
if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET)
{
// Use translated name internally
mBlueBandName = tr(QSTRING_NOT_SET);
mBlueBandName = TRSTRING_NOT_SET;
return;
}
//check if the image is paletted
@ -2813,7 +2806,7 @@ void QgsRasterLayer::setBlueBandName(QString const & theBandNameQString)
}
//if no matches were found default to not set
mBlueBandName = tr(QSTRING_NOT_SET);
mBlueBandName = TRSTRING_NOT_SET;
return;
}
@ -2821,7 +2814,7 @@ void QgsRasterLayer::setBlueBandName(QString const & theBandNameQString)
void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
{
//check if the band is unset
if (theBandNameQString == tr(QSTRING_NOT_SET))
if (theBandNameQString == TRSTRING_NOT_SET)
{
mTransparencyBandName = theBandNameQString;
return;
@ -2846,7 +2839,7 @@ void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
}
//if no matches were found default to not set
mTransparencyBandName = tr(QSTRING_NOT_SET);
mTransparencyBandName = TRSTRING_NOT_SET;
return;
}
@ -2855,10 +2848,10 @@ void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
void QgsRasterLayer::setGrayBandName(QString const & theBandNameQString)
{
//check if the band is unset
if (theBandNameQString == tr(QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
if (theBandNameQString == TRSTRING_NOT_SET || theBandNameQString == QSTRING_NOT_SET )
{
// Use translated name internally
mGrayBandName = tr(QSTRING_NOT_SET);
mGrayBandName = TRSTRING_NOT_SET;
return;
}
//check if the image is paletted
@ -2883,7 +2876,7 @@ void QgsRasterLayer::setGrayBandName(QString const & theBandNameQString)
}
//if no matches were found default to not set
mGrayBandName = tr(QSTRING_NOT_SET);
mGrayBandName = TRSTRING_NOT_SET;
return;
}
@ -4609,7 +4602,7 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
// <mRedBandName>
QDomElement mRedBandNameElement = document.createElement( "mRedBandName" );
QString writtenRedBandName = getRedBandName();
if ( writtenRedBandName == tr(QSTRING_NOT_SET) )
if ( writtenRedBandName == TRSTRING_NOT_SET )
{
// Write english "not set" only.
writtenRedBandName = QSTRING_NOT_SET;
@ -4624,7 +4617,7 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
// <mGreenBandName>
QDomElement mGreenBandNameElement = document.createElement( "mGreenBandName" );
QString writtenGreenBandName = getGreenBandName();
if ( writtenGreenBandName == tr(QSTRING_NOT_SET) )
if ( writtenGreenBandName == TRSTRING_NOT_SET )
{
// Write english "not set" only.
writtenGreenBandName = QSTRING_NOT_SET;
@ -4639,7 +4632,7 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
// <mBlueBandName>
QDomElement mBlueBandNameElement = document.createElement( "mBlueBandName" );
QString writtenBlueBandName = getBlueBandName();
if ( writtenBlueBandName == tr(QSTRING_NOT_SET) )
if ( writtenBlueBandName == TRSTRING_NOT_SET )
{
// Write english "not set" only.
writtenBlueBandName = QSTRING_NOT_SET;
@ -4654,7 +4647,7 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
// <mGrayBandName>
QDomElement mGrayBandNameElement = document.createElement( "mGrayBandName" );
QString writtenGrayBandName = getGrayBandName();
if ( writtenGrayBandName == tr(QSTRING_NOT_SET) )
if ( writtenGrayBandName == TRSTRING_NOT_SET )
{
// Write english "not set" only.
writtenGrayBandName = QSTRING_NOT_SET;
@ -5074,7 +5067,7 @@ void QgsRasterLayer::setDataProvider( QString const & provider,
#endif
// load the data provider
mLib = new QLibrary((const char *) ogrlib);
mLib = new QLibrary(ogrlib);
QgsDebugMsg("QgsRasterLayer::setDataProvider: Library name is " + mLib->library());
bool loaded = mLib->load();

View File

@ -1003,8 +1003,9 @@ private:
//
// Private member vars
//
/** \brief Static constant defining flag for XML and a constant that signals property not used */
static const QString QSTRING_NOT_SET;
/** \brief Constant defining flag for XML and a constant that signals property not used */
const QString QSTRING_NOT_SET;
const QString TRSTRING_NOT_SET;
/** \brief Raster width. */
int mRasterXDim;

View File

@ -16,7 +16,6 @@
***************************************************************************/
/* $Id$ */
#include "qgssymbologyutils.h"
//Added by qt3to4:
#include <QPixmap>
static const char *solidLineData[] = {
@ -851,7 +850,7 @@ Qt::BrushStyle QgsSymbologyUtils::qString2BrushStyle(QString brushString)
}
else //return a null string
{
qWarning("Brush style \"" + brushString + "\" not found in qString2BrushStyle");
qWarning("Brush style \"" + brushString.toUtf8() + "\" not found in qString2BrushStyle");
return Qt::NoBrush;
}
}

View File

@ -78,19 +78,10 @@ TARGET_LINK_LIBRARIES(qgis_gui
${QT_QTSVG_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTMAIN_LIBRARY}
${QT_QT3SUPPORT_LIBRARY}
${SQLITE3_LIBRARIES}
qgis_core
)
#work aroud for the fact that qt3 support on mac is linked ot qsql
IF (APPLE)
TARGET_LINK_LIBRARIES(qgis_gui
${QT_QTSQL_LIBRARY}
)
ENDIF (APPLE)
INSTALL(TARGETS qgis_gui
RUNTIME DESTINATION ${QGIS_BIN_DIR}
LIBRARY DESTINATION ${QGIS_LIB_DIR}

View File

@ -32,10 +32,11 @@ class QgsPanningWidget : public QWidget
{
public:
QgsPanningWidget(QWidget* parent)
: QWidget(parent, "panningWidget")
: QWidget(parent)
{
setObjectName("panningWidget");
setMinimumSize(5,5);
setBackgroundMode(Qt::NoBackground);
setAttribute(Qt::WA_NoSystemBackground);
}
void resizeEvent(QResizeEvent* r)

View File

@ -25,8 +25,8 @@ QgsMapToolPan::QgsMapToolPan(QgsMapCanvas* canvas)
: QgsMapTool(canvas), mDragging(FALSE)
{
// set cursor
QBitmap panBmp(16, 16, pan_bits, true);
QBitmap panBmpMask(16, 16, pan_mask_bits, true);
QBitmap panBmp = QBitmap::fromData( QSize(16, 16), pan_bits);
QBitmap panBmpMask = QBitmap::fromData( QSize(16, 16), pan_mask_bits);
mCursor = QCursor(panBmp, panBmpMask, 5, 5);
}

View File

@ -894,7 +894,7 @@ void QgsProjectionSelector::on_pbnFind_clicked()
myFileInfo.setFile(myDatabaseFileName);
if ( !myFileInfo.exists( ) ) //its not critical if this happens
{
qDebug(myDatabaseFileName);
qDebug(myDatabaseFileName.toUtf8());
qDebug("User db does not exist");
return ;
}

View File

@ -597,7 +597,7 @@ void QgsQuickPrint::printMap()
int myLogoYDim = ( myDrawableHeight / 100 ) * myLogoHeightPercent;
QPixmap myLogo1;
qDebug("Logo1:");
qDebug(mLogo1File);
qDebug(mLogo1File.toLocal8Bit());
myLogo1.fill ( Qt::white );
myLogo1.load ( mLogo1File );
myLogo1 = myLogo1.scaled ( myLogoXDim,myLogoYDim, Qt::KeepAspectRatio);

View File

@ -38,10 +38,22 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
)
TARGET_LINK_LIBRARIES(qgis_help
${QT_LIBRARIES}
${SQLITE3_LIBRARY}
qgis_core
)
IF (${QTVERSION} STRLESS "4.3.0")
TARGET_LINK_LIBRARIES(qgis_help
${QT_LIBRARIES}
)
ELSE (${QTVERSION} STRLESS "4.3.0")
TARGET_LINK_LIBRARIES(qgis_help
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTSVG_LIBRARY}
${QT_QTXML_LIBRARY}
)
ENDIF (${QTVERSION} STRLESS "4.3.0")
########################################################

View File

@ -16,10 +16,8 @@
* *
***************************************************************************/
#include <iostream>
#include <qgsapplication.h>
#include <qstring.h>
#include <QLocale>
#include <QSettings>
#include <QTextCodec>
#include <QTranslator>
#include "qgshelpserver.h"
#include "qgshelpviewer.h"
@ -49,7 +47,7 @@ int main( int argc, char ** argv )
QString i18nPath = QgsApplication::i18nPath();
if (myTranslationCode.isEmpty())
{
myTranslationCode = QTextCodec::locale();
myTranslationCode = QLocale::system().name();
}
#ifdef QGISDEBUG
std::cout << "Setting translation to "

View File

@ -22,10 +22,10 @@
#include <QString>
#include <QApplication>
#include <QLocale>
#include <QMessageBox>
#include <QFileInfo>
#include <QSettings>
#include <QTextCodec>
#include <QTextStream>
#include <QFile>
@ -104,7 +104,7 @@ void QgsHelpViewer::loadContext(const QString &contextId)
* determine the locale and create the file name from
* the context id
*/
QString lang(QTextCodec::locale());
QString lang(QLocale::system().name());
/*
* If the language isn't set on the system, assume en_US,
* otherwise we get the banner at the top of the help file
@ -175,7 +175,7 @@ void QgsHelpViewer::loadContextFromSqlite(const QString &contextId)
// build the sql statement
QString sql = "select content,title from context_helps where context_id = "
+ contextId;
rc = sqlite3_prepare(db, (const char *)sql, sql.length(), &ppStmt, &pzTail);
rc = sqlite3_prepare(db, sql.toUtf8(), sql.length(), &ppStmt, &pzTail);
if(rc == SQLITE_OK)
{
if(sqlite3_step(ppStmt) == SQLITE_ROW){

View File

@ -36,7 +36,11 @@ void QgsCopyrightLabelPluginGui::on_buttonBox_accepted()
hide();
//close the dialog
emit changeFont(txtCopyrightText->currentFont());
#if QT_VERSION < 0x040300
emit changeLabel(txtCopyrightText->text());
#else
emit changeLabel(txtCopyrightText->toPlainText());
#endif
emit changeColor(pbnColorChooser->color());
emit changePlacement(cboPlacement->currentIndex());
emit enableCopyrightLabel(cboxEnabled->isChecked());

View File

@ -248,7 +248,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections>
<connection>

View File

@ -76,8 +76,8 @@ void QgsPgGeoprocessing::initGui()
{
// Create the action for tool
bufferAction = new QAction(QIcon(icon_buffer), tr("&Buffer features"), this);
bufferAction->setWhatsThis(tr("Create a buffer for a PostgreSQL layer. " +
tr("A new layer is created in the database with the buffered features.")));
bufferAction->setWhatsThis(tr("Create a buffer for a PostgreSQL layer. ") +
tr("A new layer is created in the database with the buffered features."));
// Connect the action to the buffer slot
connect(bufferAction, SIGNAL(triggered()), this, SLOT(buffer()));
@ -103,7 +103,7 @@ void QgsPgGeoprocessing::buffer()
QgsDebugMsg("data source = " + uri.connInfo() );
// connect to the database and check the capabilities
PGconn *capTest = PQconnectdb((const char *) uri.connInfo() );
PGconn *capTest = PQconnectdb(uri.connInfo().toUtf8() );
if (PQstatus(capTest) == CONNECTION_OK) {
postgisVersion(capTest);
}
@ -131,12 +131,12 @@ void QgsPgGeoprocessing::buffer()
}
}
// connect to the database
PGconn *conn = PQconnectdb((const char *) uri.connInfo() );
PGconn *conn = PQconnectdb(uri.connInfo().toUtf8() );
if (PQstatus(conn) == CONNECTION_OK) {
// populate the schema drop-down
QString schemaSql =
QString("select nspname from pg_namespace,pg_user where nspowner = usesysid and usename = '%1'").arg( uri.username() );
PGresult *schemas = PQexec(conn, (const char *) schemaSql);
PGresult *schemas = PQexec(conn, schemaSql.toUtf8());
if (PQresultStatus(schemas) == PGRES_TUPLES_OK) {
// add the schemas to the drop-down, otherwise just public (the
// default) will show up
@ -154,7 +154,7 @@ void QgsPgGeoprocessing::buffer()
QgsDebugMsg("SRID SQL: " + sridSql);
QString geometryCol;
PGresult *sridq = PQexec(conn, (const char *) sridSql);
PGresult *sridq = PQexec(conn, sridSql.toUtf8());
if (PQresultStatus(sridq) == PGRES_TUPLES_OK) {
bb->setSrid(PQgetvalue(sridq, 0, 0));
geometryCol = PQgetvalue(sridq, 0, 1);
@ -187,7 +187,7 @@ void QgsPgGeoprocessing::buffer()
if(bb->schema() != "public")
{
sql = QString("set search_path = '%1','public'").arg(bb->schema());
result = PQexec(conn, (const char *) sql);
result = PQexec(conn, sql.toUtf8());
PQclear(result);
QgsDebugMsg("SQL: " + sql);
@ -201,7 +201,7 @@ void QgsPgGeoprocessing::buffer()
.arg(objIdType);
QgsDebugMsg("SQL: " + sql);
result = PQexec(conn, (const char *) sql);
result = PQexec(conn, sql.toUtf8());
QgsDebugMsg( QString("Status from create table is %1").arg( PQresultStatus(result) ) );
QgsDebugMsg( QString("Error message is %1").arg(PQresStatus(PQresultStatus(result))) );
@ -219,7 +219,7 @@ void QgsPgGeoprocessing::buffer()
.arg("2");
QgsDebugMsg("SQL: " + sql);
PGresult *geoCol = PQexec(conn, (const char *) sql);
PGresult *geoCol = PQexec(conn, sql.toUtf8());
if (PQresultStatus(geoCol) == PGRES_TUPLES_OK) {
PQclear(geoCol);
@ -234,7 +234,7 @@ void QgsPgGeoprocessing::buffer()
QgsDebugMsg( "SQL: " + sql);
result = PQexec(conn, (const char *) sql);
result = PQexec(conn, sql.toUtf8());
if(PQresultStatus(result) == PGRES_COMMAND_OK)
{
PQclear(result);
@ -270,7 +270,7 @@ void QgsPgGeoprocessing::buffer()
.arg(tableName);
QgsDebugMsg("SQL: " + sql);
}
result = PQexec(conn, (const char *) sql);
result = PQexec(conn, sql.toUtf8());
PQclear(result);
// }

View File

@ -200,7 +200,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<tabstops>
<tabstop>leXCoord</tabstop>
<tabstop>leYCoord</tabstop>

View File

@ -65,7 +65,7 @@ QgsGeorefPluginGui::~QgsGeorefPluginGui()
void QgsGeorefPluginGui::on_pbnClose_clicked()
{
close(1);
close();
}
void QgsGeorefPluginGui::on_pbnDescription_clicked()

View File

@ -81,7 +81,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -73,7 +73,7 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
GDALDriverH driver = GDALGetDriverByName("GTiff");
char **papszOptions = NULL;
papszOptions = CSLSetNameValue(papszOptions, "INIT_DEST", "NO_DATA");
papszOptions = CSLSetNameValue(papszOptions, "COMPRESS", compression);
papszOptions = CSLSetNameValue(papszOptions, "COMPRESS", compression.toAscii());
GDALDatasetH hDstDS =
GDALCreate(driver,
QFile::encodeName(output).constData(), newXSize, newYSize,

View File

@ -534,11 +534,11 @@ void QgsPointDialog::initialize()
// set up the canvas
QHBoxLayout* layout = new QHBoxLayout(canvasFrame);
layout->setAutoAdd(true);
mCanvas = new QgsMapCanvas(canvasFrame, "georefCanvas");
mCanvas->setBackgroundColor(Qt::white);
mCanvas->setMinimumWidth(400);
//mCanvas->freeze(true);
layout->addWidget(mCanvas);
// set up map tools
mToolZoomIn = new QgsMapToolZoom(mCanvas, FALSE /* zoomOut */);

View File

@ -25,6 +25,7 @@ QgsGPSDeviceDialog::QgsGPSDeviceDialog(std::map<QString, QgsGPSDevice*>&
{
setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
// Manually set the relative size of the two main parts of the
// device dialog box.
QList<int> split;
@ -183,5 +184,5 @@ void QgsGPSDeviceDialog::writeDeviceSettings() {
void QgsGPSDeviceDialog::on_pbnClose_clicked()
{
close(1);
close();
}

View File

@ -1,7 +1,4 @@
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QgsGPSDeviceDialogBase</class>
<widget class="QDialog" name="QgsGPSDeviceDialogBase" >
<property name="geometry" >
@ -310,7 +307,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -32,8 +32,8 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QAction>
#include <Q3Process>
#include <Q3ProgressDialog>
#include <QProcess>
#include <QProgressDialog>
#include <QSettings>
#include <QStringList>
@ -159,7 +159,7 @@ void QgsGPSPlugin::createGPX() {
tr("Save new GPX file as..."), "." , tr("GPS eXchange file (*.gpx)"));
if (!fileName.isEmpty()) {
QFileInfo fileInfo(fileName);
std::ofstream ofs((const char*)fileName);
std::ofstream ofs(fileName.toUtf8());
if (!ofs) {
QMessageBox::warning(NULL, tr("Could not create file"),
tr("Unable to create a GPX file with the given name. ")+
@ -249,28 +249,26 @@ void QgsGPSPlugin::importGPSFile(QString inputFilename, QgsBabelFormat* importer
QgsDebugMsg(QString("Import command: ") + babelArgs.join("|"));
Q3Process babelProcess(babelArgs);
if (!babelProcess.start()) {
QProcess babelProcess;
babelProcess.start(babelArgs.join(" "));
if (!babelProcess.waitForStarted()) {
QMessageBox::warning(NULL, tr("Could not start process"),
tr("Could not start GPSBabel!"));
return;
}
// wait for gpsbabel to finish (or the user to cancel)
Q3ProgressDialog progressDialog(tr("Importing data..."), tr("Cancel"), 0,
NULL, 0, true);
progressDialog.show();
for (int i = 0; babelProcess.isRunning(); ++i) {
QCoreApplication::processEvents();
progressDialog.setProgress(i/64);
QProgressDialog progressDialog(tr("Importing data..."), tr("Cancel"), 0, 0);
progressDialog.setWindowModality(Qt::WindowModal);
for (int i = 0; babelProcess.state() == QProcess::Running; ++i) {
progressDialog.setValue(i/64);
if (progressDialog.wasCanceled())
return;
}
// did we get any data?
if (babelProcess.exitStatus() != 0) {
QString babelError(babelProcess.readStderr());
QString babelError(babelProcess.readAllStandardError());
QString errorMsg(tr("Could not import data from %1!\n\n")
.arg(inputFilename));
errorMsg += babelError;
@ -319,28 +317,26 @@ void QgsGPSPlugin::convertGPSFile(QString inputFilename,
<< convertStrings <<"-o"<<"gpx"<<"-F"<< outputFilename;
QgsDebugMsg(QString("Conversion command: ") + babelArgs.join("|"));
Q3Process babelProcess(babelArgs);
if (!babelProcess.start()) {
QProcess babelProcess;
babelProcess.start(babelArgs.join(" "));
if (!babelProcess.waitForStarted()) {
QMessageBox::warning(NULL, tr("Could not start process"),
tr("Could not start GPSBabel!"));
return;
}
// wait for gpsbabel to finish (or the user to cancel)
Q3ProgressDialog progressDialog(tr("Importing data..."), tr("Cancel"), 0,
NULL, 0, true);
progressDialog.show();
for (int i = 0; babelProcess.isRunning(); ++i) {
QCoreApplication::processEvents();
progressDialog.setProgress(i/64);
QProgressDialog progressDialog(tr("Importing data..."), tr("Cancel"), 0, 0);
progressDialog.setWindowModality(Qt::WindowModal);
for (int i = 0; babelProcess.state() == QProcess::Running; ++i) {
progressDialog.setValue(i/64);
if (progressDialog.wasCanceled())
return;
}
// did we get any data?
if (babelProcess.exitStatus() != 0) {
QString babelError(babelProcess.readStderr());
QString babelError(babelProcess.readAllStandardError());
QString errorMsg(tr("Could not convert data from %1!\n\n")
.arg(inputFilename));
errorMsg += babelError;
@ -401,28 +397,26 @@ void QgsGPSPlugin::downloadFromGPS(QString device, QString port,
QgsDebugMsg(QString("Download command: ") + babelArgs.join("|"));
Q3Process babelProcess(babelArgs);
if (!babelProcess.start()) {
QProcess babelProcess;
babelProcess.start(babelArgs.join(" "));
if (!babelProcess.waitForStarted()) {
QMessageBox::warning(NULL, tr("Could not start process"),
tr("Could not start GPSBabel!"));
return;
}
// wait for gpsbabel to finish (or the user to cancel)
Q3ProgressDialog progressDialog(tr("Downloading data..."), tr("Cancel"), 0,
NULL, 0, true);
progressDialog.show();
for (int i = 0; babelProcess.isRunning(); ++i) {
QCoreApplication::processEvents();
progressDialog.setProgress(i/64);
QProgressDialog progressDialog(tr("Downloading data..."), tr("Cancel"), 0, 0);
progressDialog.setWindowModality(Qt::WindowModal);
for (int i = 0; babelProcess.state() == QProcess::Running; ++i) {
progressDialog.setValue(i/64);
if (progressDialog.wasCanceled())
return;
}
// did we get any data?
if (babelProcess.exitStatus() != 0) {
QString babelError(babelProcess.readStderr());
QString babelError(babelProcess.readAllStandardError());
QString errorMsg(tr("Could not download data from GPS!\n\n"));
errorMsg += babelError;
QMessageBox::warning(NULL, tr("Error downloading data"), errorMsg);
@ -486,28 +480,26 @@ void QgsGPSPlugin::uploadToGPS(QgsVectorLayer* gpxLayer, QString device,
QgsDebugMsg(QString("Upload command: ") + babelArgs.join("|"));
Q3Process babelProcess(babelArgs);
if (!babelProcess.start()) {
QProcess babelProcess;
babelProcess.start(babelArgs.join(" "));
if (!babelProcess.waitForStarted()) {
QMessageBox::warning(NULL, tr("Could not start process"),
tr("Could not start GPSBabel!"));
return;
}
// wait for gpsbabel to finish (or the user to cancel)
Q3ProgressDialog progressDialog(tr("Uploading data..."), tr("Cancel"), 0,
NULL, 0, true);
progressDialog.show();
for (int i = 0; babelProcess.isRunning(); ++i) {
QCoreApplication::processEvents();
progressDialog.setProgress(i/64);
QProgressDialog progressDialog(tr("Uploading data..."), tr("Cancel"), 0, 0);
progressDialog.setWindowModality(Qt::WindowModal);
for (int i = 0; babelProcess.state() == QProcess::Running; ++i) {
progressDialog.setValue(i/64);
if (progressDialog.wasCanceled())
return;
}
// did we get an error?
if (babelProcess.exitStatus() != 0) {
QString babelError(babelProcess.readStderr());
QString babelError(babelProcess.readAllStandardError());
QString errorMsg(tr("Error while uploading data to GPS!\n\n"));
errorMsg += babelError;
QMessageBox::warning(NULL, tr("Error uploading data"), errorMsg);

View File

@ -390,7 +390,7 @@ void QgsGPSPluginGui::populateIMPBabelFormats() {
QString lastULDevice = settings.readEntry("/Plugin-GPS/lastuldevice", "");
BabelMap::const_iterator iter;
for (iter = mImporters.begin(); iter != mImporters.end(); ++iter)
mBabelFilter.append((const char*)iter->first).append(" (*.*);;");
mBabelFilter.append(iter->first).append(" (*.*);;");
mBabelFilter.chop(2); // Remove the trailing ;;, which otherwise leads to an empty filetype
int u = -1, d = -1;
std::map<QString, QgsGPSDevice*>::const_iterator iter2;

View File

@ -745,7 +745,7 @@ void QgsGrassShell::printStdout()
msg.replace ( " ", "&nbsp;" );
mText->setTextFormat(Qt::RichText);
mText->append ( "<img src=\"" + img + "\">" + QString::fromLocal8Bit( msg ) );
mText->append ( "<img src=\"" + img + "\">" + msg );
mParagraph++;
mNewLine = true;
mStdoutBuffer.remove ( 0, mlen );
@ -781,7 +781,7 @@ void QgsGrassShell::printStdout()
std::cerr << "TXT: '" << out.local8Bit().data()<< "'" << std::endl;
#endif
insert ( QString::fromLocal8Bit( out ) );
insert ( out );
mStdoutBuffer.remove ( 0, length );
}

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>457</width>
<height>422</height>
<height>424</height>
</rect>
</property>
<property name="windowTitle" >
@ -200,12 +200,10 @@
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="Q3IconView" name="iconView" >
<item>
<property name="text" >
<string>New Item</string>
</property>
</item>
<widget class="QListView" name="iconView" >
<property name="viewMode" >
<enum>QListView::IconMode</enum>
</property>
</widget>
</item>
</layout>
@ -283,13 +281,6 @@
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<customwidgets>
<customwidget>
<class>Q3IconView</class>
<extends>Q3Frame</extends>
<header>q3iconview.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="northarrow_plugin.qrc" />
</resources>

View File

@ -20,6 +20,10 @@
#include <QSettings>
#include <QPrinter>
#if QT_VERSION < 0x040300
#define toPlainText() text()
#endif
//standard includes
@ -83,7 +87,7 @@ void QuickPrintGui::writeSettings()
QSettings mySettings;
mySettings.setValue("quickprint/mapTitle", leMapTitle->text());
mySettings.setValue("quickprint/mapName", leMapName->text());
mySettings.setValue("quickprint/mapCopyright", teCopyright->text());
mySettings.setValue("quickprint/mapCopyright", teCopyright->toPlainText());
mySettings.setValue("quickprint/incrementLastFile", radUseIncrementedFileName->isChecked());
mySettings.setValue("quickprint/pageSize",
cboPageSize->itemData(cboPageSize->currentIndex()));
@ -136,7 +140,7 @@ void QuickPrintGui::on_buttonBox_accepted()
myQuickPrint.setMapCanvas(mpMapCanvas);
myQuickPrint.setTitle(leMapTitle->text());
myQuickPrint.setName(leMapName->text());
myQuickPrint.setCopyright(teCopyright->text());
myQuickPrint.setCopyright(teCopyright->toPlainText());
myQuickPrint.setLogo1(QgsApplication::iconsPath() + "/qgis-icon.png");
myQuickPrint.setNorthArrow(myNorthArrowFile);
myQuickPrint.setOutputPdf(myOutputFileName);

View File

@ -70,8 +70,6 @@ QgsShapeFile::QgsShapeFile(QString name, QString encoding){
QgsShapeFile::~QgsShapeFile(){
OGR_DS_Destroy( ogrDataSource );
delete filename;
delete geom_type;
}
int QgsShapeFile::getFeatureCount(){
@ -169,7 +167,7 @@ QString QgsShapeFile::getFeatureClass(){
//geom_type = "GEOMETRY";
QgsDebugMsg("Preparing to escape " + geom_type);
char * esc_str = new char[geom_type.length()*2+1];
PQescapeString(esc_str, (const char *)geom_type, geom_type.length());
PQescapeString(esc_str, geom_type.toUtf8(), geom_type.length());
geom_type = QString(esc_str);
QgsDebugMsg("After escaping, geom_type is : " + geom_type);
delete[] esc_str;
@ -177,7 +175,7 @@ QString QgsShapeFile::getFeatureClass(){
QString file(filename);
file.replace(file.length()-3, 3, "dbf");
// open the dbf file
std::ifstream dbf((const char*)file, std::ios::in | std::ios::binary);
std::ifstream dbf(file.toUtf8(), std::ios::in | std::ios::binary);
// read header
DbaseHeader dbh;
dbf.read((char *)&dbh, sizeof(dbh));

View File

@ -62,7 +62,7 @@ QgsSpit::QgsSpit( QWidget *parent, Qt::WFlags fl ) : QDialog( parent, fl )
setupUi(this);
QPixmap icon;
icon = QPixmap( spitIcon );
setIcon( icon );
setWindowIcon( icon );
// Set up the table column headers
tblShapefiles->setColumnCount(5);
@ -418,7 +418,7 @@ void QgsSpit::dbConnect()
settings.readEntry(key + "/username"),
password );
conn = PQconnectdb( ( const char * ) uri.connInfo() );
conn = PQconnectdb( uri.connInfo().toUtf8() );
}
if( conn==NULL || PQstatus(conn)!=CONNECTION_OK )

View File

@ -37,7 +37,6 @@ INCLUDE_DIRECTORIES(
..
../../app # for QgsNewHttpConnection
${GEOS_INCLUDE_DIR}
${GEOS_INCLUDE_DIR}/geos
)
TARGET_LINK_LIBRARIES(wfsplugin

View File

@ -215,7 +215,7 @@ int QgsWFSSourceSelect::getCapabilitiesGET(QString uri, std::list<QString>& type
//print out result for a test
QString resultString(result);
qWarning(resultString);
qWarning(resultString.toUtf8());
return 0;
}
@ -270,7 +270,7 @@ void QgsWFSSourceSelect::connectToServer()
QSettings settings;
QString key = "/Qgis/connections-wfs/" + cmbConnections->currentText() + "/url";
mUri = settings.value(key).toString();
qWarning("url is: " + mUri);
qWarning("url is: " + mUri.toUtf8());
//make a GetCapabilities request
std::list<QString> typenames;
@ -340,7 +340,7 @@ void QgsWFSSourceSelect::addLayer()
{
uri.append("?");
}
qWarning(uri + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName);
qWarning(uri.toUtf8() + "SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=" + typeName.toUtf8());
//get CRS
QString crsString;
@ -376,7 +376,7 @@ void QgsWFSSourceSelect::changeCRSFilter()
if(currentTreeItem)
{
QString currentTypename = currentTreeItem->text(1);
qWarning("the current typename is: " + currentTypename);
qWarning("the current typename is: " + currentTypename.toUtf8());
std::map<QString, std::list<QString> >::const_iterator crsIterator = mAvailableCRS.find(currentTypename);
if(crsIterator != mAvailableCRS.end())

View File

@ -336,7 +336,7 @@ bool QgsDelimitedTextProvider::getNextFeature(QgsFeature& feature)
feature.setFeatureId( mFid );
QByteArray buffer;
QDataStream s( &buffer, QIODevice::WriteOnly ); // open on buffers's data
QDataStream s( &buffer, static_cast<QIODevice::OpenMode>(QIODevice::WriteOnly) ); // open on buffers's data
switch ( QgsApplication::endian() )
{

View File

@ -308,7 +308,7 @@ void GPSData::removeTracks(const QgsFeatureIds & ids) {
void GPSData::writeXML(QTextStream& stream) {
stream.setEncoding(QTextStream::UnicodeUTF8);
stream.setCodec(QTextCodec::codecForName("UTF8"));
stream<<"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
<<"<gpx version=\"1.0\" creator=\"Quantum GIS\">\n";
for (WaypointIterator wIter = waypoints.begin();

View File

@ -45,9 +45,16 @@ ENDIF (WIN32)
TARGET_LINK_LIBRARIES (qgisgrass
${QT_QTCORE_LIBRARY}
${QT_QTXML_LIBRARY}
${QT_QT3SUPPORT_LIBRARY}
${GRASS_LIBRARIES}
qgis_core
)
#work aroud for the fact that qt3support on mac is linked to qtsql
IF (APPLE)
TARGET_LINK_LIBRARIES (qgisgrass
${QT_QTSQL_LIBRARY}
)
ENDIF (APPLE)
ADD_LIBRARY (grassprovider MODULE ${GRASS_PROVIDER_SRCS})

View File

@ -94,13 +94,13 @@ void GRASS_EXPORT QgsGrass::init( void )
// This value should always take precedence.
QString gisBase = getenv("GISBASE");
#ifdef QGISDEBUG
qDebug( "%s:%d GRASS gisBase from GISBASE env var is: %s", __FILE__, __LINE__, (const char*)gisBase );
qDebug( "%s:%d GRASS gisBase from GISBASE env var is: %s", __FILE__, __LINE__, gisBase.toAscii().constData() );
#endif
if ( !isValidGrassBaseDir(gisBase) ) {
// Look for gisbase in QSettings
gisBase = settings.readEntry("/GRASS/gisbase", "");
#ifdef QGISDEBUG
qDebug( "%s:%d GRASS gisBase from QSettings is: %s", __FILE__, __LINE__, (const char*)gisBase );
qDebug( "%s:%d GRASS gisBase from QSettings is: %s", __FILE__, __LINE__, gisBase.toAscii().constData() );
#endif
}
@ -119,7 +119,7 @@ void GRASS_EXPORT QgsGrass::init( void )
// Use the location specified --with-grass during configure
gisBase = GRASS_BASE;
#ifdef QGISDEBUG
qDebug( "%s:%d GRASS gisBase from configure is: %s", __FILE__, __LINE__, (const char*)gisBase );
qDebug( "%s:%d GRASS gisBase from configure is: %s", __FILE__, __LINE__, gisBase.toAscii().constData() );
#endif
#endif
@ -172,7 +172,7 @@ void GRASS_EXPORT QgsGrass::init( void )
}
#ifdef QGISDEBUG
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, (const char*)gisBase );
qDebug( "%s:%d Valid GRASS gisBase is: %s", __FILE__, __LINE__, gisBase.toAscii().constData() );
#endif
QString gisBaseEnv = "GISBASE=" + gisBase;
/* _Correct_ putenv() implementation is not making copy! */

View File

@ -2335,7 +2335,7 @@ QString *QgsGrassProvider::isOrphan ( int field, int cat, int *orphan)
if ( db_open_select_cursor(driver, &dbstr, &cursor, DB_SCROLL) != DB_OK )
{
db_close_database_shutdown_driver ( driver );
error->setAscii("Cannot query database: " + query );
error->append("Cannot query database: ").append(query);
return error;
}
int nRecords = db_get_num_rows ( &cursor );

View File

@ -354,7 +354,7 @@ void QgsOgrProvider::select(QgsAttributeList fetchAttributes, QgsRect rect, bool
{
OGRGeometryH filter = 0;
QString wktExtent = QString("POLYGON ((%1))").arg(rect.asPolygon());
const char *wktText = (const char *)wktExtent;
const char *wktText = wktExtent.toAscii();
if(useIntersect)
{
@ -367,7 +367,7 @@ void QgsOgrProvider::select(QgsAttributeList fetchAttributes, QgsRect rect, bool
NULL, &mSelectionRectangle);
}
wktText = (const char *) wktExtent;
wktText = wktExtent.toAscii();
OGR_G_CreateFromWkt( (char **)&wktText, NULL, &filter );
QgsDebugMsg("Setting spatial filter using " + wktExtent);
OGR_L_SetSpatialFilter( ogrLayer, filter );
@ -732,7 +732,7 @@ bool QgsOgrProvider::createSpatialIndex()
QString filename=dataSourceUri().section('/',-1,-1);//find out the filename from the uri
QString layername=filename.section('.',0,0);
QString sql="CREATE SPATIAL INDEX ON "+layername;
OGR_DS_ExecuteSQL (ogrDataSource,sql.ascii(), OGR_L_GetSpatialFilter(ogrLayer),"");
OGR_DS_ExecuteSQL (ogrDataSource, sql.toAscii(), OGR_L_GetSpatialFilter(ogrLayer),"");
//find out, if the .qix file is there
QString indexname = dataSourceUri();
indexname.truncate(dataSourceUri().length()-filename.length());
@ -1127,7 +1127,7 @@ QGISEXTERN bool createEmptyDataSource(const QString& uri,
{
OGRSFDriverH driver;
OGRRegisterAll();
driver = OGRGetDriverByName(format);
driver = OGRGetDriverByName(format.toAscii());
if(driver == NULL)
{
return false;
@ -1276,7 +1276,7 @@ void QgsOgrProvider::getUniqueValues(int index, QStringList &uniqueValues)
uniqueValues.clear();
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.ascii(), NULL, "SQL");
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.toAscii(), NULL, "SQL");
if(l==0)
return;
@ -1301,7 +1301,7 @@ QVariant QgsOgrProvider::minValue(int index)
QString sql = QString("SELECT MIN(%1) FROM %2").arg( fld.name() ).arg( fi.baseName() );
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.ascii(), NULL, "SQL");
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.toAscii(), NULL, "SQL");
if(l==0)
return QVariant();
@ -1341,7 +1341,7 @@ QVariant QgsOgrProvider::maxValue(int index)
QString sql = QString("SELECT MAX(%1) FROM %2").arg( fld.name() ).arg( fi.baseName() );
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.ascii(), NULL, "SQL");
OGRLayerH l = OGR_DS_ExecuteSQL(ogrDataSource, sql.toAscii(), NULL, "SQL");
if(l==0)
return QVariant();

View File

@ -78,7 +78,7 @@ void QgsPostgresCountThread::run()
std::cout << "QgsPostgresCountThread: Started running." << std::endl;
// Open another connection to the database
PGconn *connection = PQconnectdb((const char *) connInfo);
PGconn *connection = PQconnectdb(connInfo.toUtf8());
// get the extents
@ -91,7 +91,7 @@ void QgsPostgresCountThread::run()
std::cout << "QgsPostgresCountThread: About to issue query." << std::endl;
PGresult *result = PQexec(connection, (const char *) sql);
PGresult *result = PQexec(connection, sql.toUtf8());
std::cout << "QgsPostgresCountThread: Query completed." << std::endl;

View File

@ -20,13 +20,14 @@
#include <fstream>
#include <QEvent>
#include <QApplication>
#include <QCustomEvent>
#include <QEvent>
#include "qgis.h"
#include "qgsrect.h"
#include "qgspostgresextentthread.h"
#include "qgsproviderextentcalcevent.h"
/*
@ -78,7 +79,7 @@ void QgsPostgresExtentThread::run()
std::cout << "QgsPostgresExtentThread: Started running." << std::endl;
// Open another connection to the database
PGconn *connection = PQconnectdb((const char *) connInfo);
PGconn *connection = PQconnectdb(connInfo.toUtf8());
// get the extents
@ -95,13 +96,13 @@ void QgsPostgresExtentThread::run()
#endif
#ifdef QGISDEBUG
qDebug("+++++++++QgsPostgresExtentThread::run - Getting extents using schema.table: " + sql);
qDebug("+++++++++QgsPostgresExtentThread::run - Getting extents using schema.table: " + sql.toUtf8());
#endif
std::cout << "QgsPostgresExtentThread: About to issue query." << std::endl;
PGresult *result = PQexec(connection, (const char *) sql);
PGresult *result = PQexec(connection, sql.toUtf8());
std::cout << "QgsPostgresExtentThread: Query completed." << std::endl;
@ -156,8 +157,7 @@ void QgsPostgresExtentThread::run()
std::cout << "QgsPostgresExtentThread: About to create and dispatch event " << QGis::ProviderExtentCalcEvent << " to callback" << std::endl;
QCustomEvent * e1 = new QCustomEvent ( QGis::ProviderExtentCalcEvent );
e1->setData(layerExtent);
QgsProviderExtentCalcEvent * e1 = new QgsProviderExtentCalcEvent ( layerExtent );
QApplication::postEvent( (QObject *)callbackObject, e1);
// QApplication::postEvent(qApp->mainWidget(), e1);

View File

@ -1494,7 +1494,7 @@ void QgsPostgresProvider::findColumns(tableCols& cols)
if (s.indexIn(viewDefinition) != -1)
{
attname_view = s.cap(1);
qWarning("original view column name was: " + attname_view);
qWarning("original view column name was: " + attname_view.toUtf8());
}
}
@ -2540,9 +2540,9 @@ bool QgsPostgresProvider::getGeometryDetails()
else // something went wrong...
{
log.prepend(tr("Qgis was unable to determine the type and srid of "
"column " + geometryColumn + tr(" in ") +
"column ") + geometryColumn + tr(" in ") +
mSchemaTableName +
tr(". The database communication log was:\n")));
tr(". The database communication log was:\n"));
showMessageBox(tr("Unable to get feature type and srid"), log);
}

View File

@ -409,7 +409,7 @@ QImage* QgsWmsProvider::draw(QgsRect const & viewExtent, int pixelWidth, int pi
url += "TRANSPARENT=TRUE";
}
qWarning(url);
qWarning(url.toUtf8());
// cache some details for if the user wants to do an identifyAsHtml() later
mGetFeatureInfoUrlBase = baseUrl;

Some files were not shown because too many files have changed in this diff Show More