Skip to content

Commit d229316

Browse files
author
telwertowski
committed
Convert dialogs to Qt 4.2 StandardButton API.
Also fix memory leaks by using the delete operator or Qt::WA_DeleteOnClose along with accept or reject rather then deprecated Qt3 routines. Also eliminate compiler warnings. git-svn-id: http://svn.osgeo.org/qgis/trunk@6475 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 99a0d05 commit d229316

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+360
-1164
lines changed

src/plugins/copyright_label/plugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void QgsCopyrightLabelPlugin::help()
122122
void QgsCopyrightLabelPlugin::run()
123123
{
124124
QgsCopyrightLabelPluginGui *myPluginGui=new QgsCopyrightLabelPluginGui(qGisInterface->getMainWindow(), QgisGui::ModalDialogFlags);
125+
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
125126
//listen for when the layer has been made so we can draw it
126127
//connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
127128
//connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
@@ -134,6 +135,7 @@ void QgsCopyrightLabelPlugin::run()
134135
myPluginGui->setText(mLabelQString);
135136
myPluginGui->setPlacementLabels(mPlacementLabels);
136137
myPluginGui->setPlacement(mPlacementIndex);
138+
myPluginGui->setEnabled(mEnable);
137139
myPluginGui->show();
138140
}
139141
//! Refresh the map display using the mapcanvas exported via the plugin interface

src/plugins/copyright_label/plugingui.cpp

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616

1717
//standard includes
1818

19-
QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui() : QDialog()
20-
{
21-
setupUi(this);
22-
//programmatically hide orientation selection for now
23-
cboOrientation->hide();
24-
textLabel15->hide();
25-
}
26-
2719
QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui(QWidget* parent, Qt::WFlags fl)
2820
: QDialog(parent, fl)
2921
{
@@ -32,11 +24,12 @@ QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui(QWidget* parent, Qt::WFla
3224
cboOrientation->hide();
3325
textLabel15->hide();
3426
}
27+
3528
QgsCopyrightLabelPluginGui::~QgsCopyrightLabelPluginGui()
3629
{
3730
}
3831

39-
void QgsCopyrightLabelPluginGui::on_pbnOK_clicked()
32+
void QgsCopyrightLabelPluginGui::on_buttonBox_accepted()
4033
{
4134
//hide the dialog before we send all our signals
4235
hide();
@@ -46,18 +39,20 @@ void QgsCopyrightLabelPluginGui::on_pbnOK_clicked()
4639
emit changeColor(txtCopyrightText->color());
4740
emit changePlacement(cboPlacement->currentIndex());
4841
emit enableCopyrightLabel(cboxEnabled->isChecked());
49-
50-
done(1);
42+
43+
accept();
5144
}
52-
void QgsCopyrightLabelPluginGui::on_pbnCancel_clicked()
45+
46+
void QgsCopyrightLabelPluginGui::on_buttonBox_rejected()
5347
{
54-
close(1);
48+
reject();
5549
}
5650

57-
void QgsCopyrightLabelPluginGui::on_pbnHelp_clicked()
51+
void QgsCopyrightLabelPluginGui::on_buttonBox_helpRequested()
5852
{
5953
QgsContextHelp::run(context_id);
6054
}
55+
6156
void QgsCopyrightLabelPluginGui::setEnabled(bool theBool)
6257
{
6358
cboxEnabled->setChecked(theBool);

src/plugins/copyright_label/plugingui.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#define QGSCOPYRIGHTLABELPLUGINGUI_H
1414

1515
#include <ui_pluginguibase.h>
16-
#include <qfont.h>
17-
#include <qcolor.h>
16+
#include <QColor>
17+
#include <QFont>
1818

1919
/**
2020
@author Tim Sutton
@@ -23,18 +23,17 @@ class QgsCopyrightLabelPluginGui : public QDialog, private Ui::QgsCopyrightLabel
2323
{
2424
Q_OBJECT;
2525
public:
26-
QgsCopyrightLabelPluginGui();
2726
QgsCopyrightLabelPluginGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
2827
~QgsCopyrightLabelPluginGui();
2928
void setText(QString);
3029
void setPlacementLabels(QStringList&);
3130
void setPlacement(int);
32-
33-
public slots:
34-
void on_pbnOK_clicked();
35-
void on_pbnCancel_clicked();
36-
void on_pbnHelp_clicked();
3731
void setEnabled(bool);
32+
33+
private slots:
34+
void on_buttonBox_accepted();
35+
void on_buttonBox_rejected();
36+
void on_buttonBox_helpRequested();
3837

3938
private:
4039
static const int context_id = 32338213;

src/plugins/copyright_label/pluginguibase.ui

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<x>0</x>
77
<y>0</y>
88
<width>578</width>
9-
<height>490</height>
9+
<height>489</height>
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
@@ -184,60 +184,14 @@ p, li { white-space: pre-wrap; }
184184
</layout>
185185
</item>
186186
<item row="4" column="0" colspan="3" >
187-
<layout class="QHBoxLayout" >
188-
<property name="margin" >
189-
<number>0</number>
187+
<widget class="QDialogButtonBox" name="buttonBox" >
188+
<property name="orientation" >
189+
<enum>Qt::Horizontal</enum>
190190
</property>
191-
<property name="spacing" >
192-
<number>6</number>
191+
<property name="standardButtons" >
192+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
193193
</property>
194-
<item>
195-
<widget class="QPushButton" name="pbnHelp" >
196-
<property name="text" >
197-
<string>Help</string>
198-
</property>
199-
<property name="shortcut" >
200-
<string>Alt+O</string>
201-
</property>
202-
</widget>
203-
</item>
204-
<item>
205-
<spacer>
206-
<property name="orientation" >
207-
<enum>Qt::Horizontal</enum>
208-
</property>
209-
<property name="sizeType" >
210-
<enum>QSizePolicy::Expanding</enum>
211-
</property>
212-
<property name="sizeHint" >
213-
<size>
214-
<width>281</width>
215-
<height>26</height>
216-
</size>
217-
</property>
218-
</spacer>
219-
</item>
220-
<item>
221-
<widget class="QPushButton" name="pbnOK" >
222-
<property name="text" >
223-
<string>&amp;OK</string>
224-
</property>
225-
<property name="shortcut" >
226-
<string>Alt+O</string>
227-
</property>
228-
</widget>
229-
</item>
230-
<item>
231-
<widget class="QPushButton" name="pbnCancel" >
232-
<property name="text" >
233-
<string>&amp;Cancel</string>
234-
</property>
235-
<property name="shortcut" >
236-
<string>Alt+C</string>
237-
</property>
238-
</widget>
239-
</item>
240-
</layout>
194+
</widget>
241195
</item>
242196
</layout>
243197
</widget>

src/plugins/delimited_text/qgsdelimitedtextplugin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ void QgsDelimitedTextPlugin::run()
122122
QgsDelimitedTextPluginGui *myQgsDelimitedTextPluginGui=
123123
new QgsDelimitedTextPluginGui(qGisInterface,
124124
qGisInterface->getMainWindow(), QgisGui::ModalDialogFlags);
125+
myQgsDelimitedTextPluginGui->setAttribute(Qt::WA_DeleteOnClose);
125126
//listen for when the layer has been made so we can draw it
126127
connect(myQgsDelimitedTextPluginGui,
127128
SIGNAL(drawVectorLayer(QString,QString,QString)),

src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,14 @@
2727
#include <QMessageBox>
2828
#include <QTextStream>
2929

30-
QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui() : QDialog()
31-
{
32-
setupUi(this);
33-
34-
}
35-
3630
QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui(QgisInterface * _qI, QWidget * parent, Qt::WFlags fl)
3731
: QDialog(parent, fl), qI(_qI)
3832
{
3933
setupUi(this);
34+
pbnOK = buttonBox->button(QDialogButtonBox::Ok);
35+
pbnParse = buttonBox->addButton(tr("Parse"), QDialogButtonBox::ActionRole);
36+
connect(pbnParse, SIGNAL(clicked()), this, SLOT(on_pbnParse_clicked()));
37+
enableButtons();
4038
// at startup, fetch the last used delimiter and directory from
4139
// settings
4240
QSettings settings;
@@ -48,7 +46,7 @@ QgsDelimitedTextPluginGui::~QgsDelimitedTextPluginGui()
4846
{
4947
}
5048
/** Autoconnected slots **/
51-
void QgsDelimitedTextPluginGui::on_pbnHelp_clicked()
49+
void QgsDelimitedTextPluginGui::on_buttonBox_helpRequested()
5250
{
5351
QgsContextHelp::run(context_id);
5452
}
@@ -60,7 +58,7 @@ void QgsDelimitedTextPluginGui::on_pbnParse_clicked()
6058
{
6159
updateFieldLists();
6260
}
63-
void QgsDelimitedTextPluginGui::on_pbnOK_clicked()
61+
void QgsDelimitedTextPluginGui::on_buttonBox_accepted()
6462
{
6563
if(txtLayerName->text().length() > 0)
6664
{
@@ -80,13 +78,20 @@ void QgsDelimitedTextPluginGui::on_pbnOK_clicked()
8078
settings.writeEntry(key + "/delimiter", txtDelimiter->text());
8179
QFileInfo fi(txtFilePath->text());
8280
settings.writeEntry(key + "/text_path", fi.dirPath());
81+
82+
accept();
8383
}
8484
else
8585
{
8686
QMessageBox::warning(this, tr("No layer name"), tr("Please enter a layer name before adding the layer to the map"));
8787
}
8888
}
8989

90+
void QgsDelimitedTextPluginGui::on_buttonBox_rejected()
91+
{
92+
reject();
93+
}
94+
9095
void QgsDelimitedTextPluginGui::updateFieldLists()
9196
{
9297
// Update the x and y field dropdown boxes

src/plugins/delimited_text/qgsdelimitedtextplugingui.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,30 @@ class QgsDelimitedTextPluginGui : public QDialog, private Ui::QgsDelimitedTextPl
2424
{
2525
Q_OBJECT
2626
public:
27-
QgsDelimitedTextPluginGui();
2827
QgsDelimitedTextPluginGui( QgisInterface * _qI, QWidget* parent = 0, Qt::WFlags fl = 0 );
2928
~QgsDelimitedTextPluginGui();
30-
public slots:
31-
void on_pbnOK_clicked();
32-
void on_pbnHelp_clicked();
33-
void on_btnBrowseForFile_clicked();
34-
void on_pbnParse_clicked();
29+
30+
public slots:
31+
void help();
32+
33+
private:
3534
void updateFieldLists();
3635
void getOpenFileName();
3736
void enableButtons();
38-
void help();
3937

40-
private:
4138
QgisInterface * qI;
39+
QAbstractButton *pbnOK;
40+
QAbstractButton *pbnParse;
4241
static const int context_id = 1033030847;
43-
signals:
42+
43+
private slots:
44+
void on_buttonBox_accepted();
45+
void on_buttonBox_rejected();
46+
void on_buttonBox_helpRequested();
47+
void on_btnBrowseForFile_clicked();
48+
void on_pbnParse_clicked();
49+
50+
signals:
4451
void drawRasterLayer(QString);
4552
void drawVectorLayer(QString,QString,QString);
4653
};

0 commit comments

Comments
 (0)