Skip to content

Commit

Permalink
Remove all use of Qt3 compatibiliy routines except for the GRASS prov…
Browse files Browse the repository at this point in the history
…ider/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/qgis@8406 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
telwertowski committed May 7, 2008
1 parent 880ee6d commit 4b45366
Show file tree
Hide file tree
Showing 131 changed files with 1,103 additions and 1,321 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgsmaplayerregistry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ signals:
protected:

//! protected constructor
QgsMapLayerRegistry( QObject * parent = 0, const char * name = 0 );
QgsMapLayerRegistry( QObject * parent = 0 );


}; // class QgsMapLayerRegistry
Expand Down
30 changes: 13 additions & 17 deletions src/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,8 +31,6 @@ SET(QGIS_APP_SRCS
qgshelpviewer.cpp
qgsidentifyresults.cpp
qgslabeldialog.cpp
qgslinestyledialog.cpp
qgslinestylewidget.cpp
qgsludialog.cpp
qgsmaptooladdfeature.cpp
qgsmaptooladdvertex.cpp
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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} )
Expand Down
20 changes: 11 additions & 9 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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") );

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 "
Expand All @@ -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);
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgscomposeritem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "qgscomposition.h"

class QWidget;
class Q3Canvas;
class QDomNode;
class QDomDocument;

Expand Down
4 changes: 4 additions & 0 deletions src/app/composer/qgscomposerlabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgscomposerscalebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "ui_qgscomposerscalebarbase.h"
#include "qgscomposeritem.h"
#include <QAbstractGraphicsShapeItem>
#include <Q3PointArray>
#include <QRect>
#include <QPen>

Expand Down
73 changes: 33 additions & 40 deletions src/app/composer/qgscomposervectorlegend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);

mLayersPopupMenu = new Q3PopupMenu( );

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

connect ( mLayersListView, SIGNAL(clicked(Q3ListViewItem *)),
this, SLOT(layerChanged(Q3ListViewItem *)));
//x mLayersListView->setResizeMode(QTreeView::AllColumns);
mLayersListView->setColumnHidden(2, true);

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 );
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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 )
Expand Down Expand Up @@ -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();

Expand All @@ -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;
Expand Down
Loading

0 comments on commit 4b45366

Please sign in to comment.