Skip to content

Commit

Permalink
Convert dialogs to Qt 4.2 StandardButton API.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
telwertowski committed Feb 1, 2007
1 parent 99a0d05 commit d229316
Show file tree
Hide file tree
Showing 49 changed files with 360 additions and 1,164 deletions.
2 changes: 2 additions & 0 deletions src/plugins/copyright_label/plugin.cpp
Expand Up @@ -122,6 +122,7 @@ void QgsCopyrightLabelPlugin::help()
void QgsCopyrightLabelPlugin::run()
{
QgsCopyrightLabelPluginGui *myPluginGui=new QgsCopyrightLabelPluginGui(qGisInterface->getMainWindow(), QgisGui::ModalDialogFlags);
myPluginGui->setAttribute(Qt::WA_DeleteOnClose);
//listen for when the layer has been made so we can draw it
//connect(myPluginGui, SIGNAL(drawRasterLayer(QString)), this, SLOT(drawRasterLayer(QString)));
//connect(myPluginGui, SIGNAL(drawVectorLayer(QString,QString,QString)), this, SLOT(drawVectorLayer(QString,QString,QString)));
Expand All @@ -134,6 +135,7 @@ void QgsCopyrightLabelPlugin::run()
myPluginGui->setText(mLabelQString);
myPluginGui->setPlacementLabels(mPlacementLabels);
myPluginGui->setPlacement(mPlacementIndex);
myPluginGui->setEnabled(mEnable);
myPluginGui->show();
}
//! Refresh the map display using the mapcanvas exported via the plugin interface
Expand Down
23 changes: 9 additions & 14 deletions src/plugins/copyright_label/plugingui.cpp
Expand Up @@ -16,14 +16,6 @@

//standard includes

QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui() : QDialog()
{
setupUi(this);
//programmatically hide orientation selection for now
cboOrientation->hide();
textLabel15->hide();
}

QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui(QWidget* parent, Qt::WFlags fl)
: QDialog(parent, fl)
{
Expand All @@ -32,11 +24,12 @@ QgsCopyrightLabelPluginGui::QgsCopyrightLabelPluginGui(QWidget* parent, Qt::WFla
cboOrientation->hide();
textLabel15->hide();
}

QgsCopyrightLabelPluginGui::~QgsCopyrightLabelPluginGui()
{
}

void QgsCopyrightLabelPluginGui::on_pbnOK_clicked()
void QgsCopyrightLabelPluginGui::on_buttonBox_accepted()
{
//hide the dialog before we send all our signals
hide();
Expand All @@ -46,18 +39,20 @@ void QgsCopyrightLabelPluginGui::on_pbnOK_clicked()
emit changeColor(txtCopyrightText->color());
emit changePlacement(cboPlacement->currentIndex());
emit enableCopyrightLabel(cboxEnabled->isChecked());
done(1);

accept();
}
void QgsCopyrightLabelPluginGui::on_pbnCancel_clicked()

void QgsCopyrightLabelPluginGui::on_buttonBox_rejected()
{
close(1);
reject();
}

void QgsCopyrightLabelPluginGui::on_pbnHelp_clicked()
void QgsCopyrightLabelPluginGui::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}

void QgsCopyrightLabelPluginGui::setEnabled(bool theBool)
{
cboxEnabled->setChecked(theBool);
Expand Down
15 changes: 7 additions & 8 deletions src/plugins/copyright_label/plugingui.h
Expand Up @@ -13,8 +13,8 @@
#define QGSCOPYRIGHTLABELPLUGINGUI_H

#include <ui_pluginguibase.h>
#include <qfont.h>
#include <qcolor.h>
#include <QColor>
#include <QFont>

/**
@author Tim Sutton
Expand All @@ -23,18 +23,17 @@ class QgsCopyrightLabelPluginGui : public QDialog, private Ui::QgsCopyrightLabel
{
Q_OBJECT;
public:
QgsCopyrightLabelPluginGui();
QgsCopyrightLabelPluginGui( QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsCopyrightLabelPluginGui();
void setText(QString);
void setPlacementLabels(QStringList&);
void setPlacement(int);

public slots:
void on_pbnOK_clicked();
void on_pbnCancel_clicked();
void on_pbnHelp_clicked();
void setEnabled(bool);

private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();

private:
static const int context_id = 32338213;
Expand Down
60 changes: 7 additions & 53 deletions src/plugins/copyright_label/pluginguibase.ui
Expand Up @@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>578</width>
<height>490</height>
<height>489</height>
</rect>
</property>
<property name="windowTitle" >
Expand Down Expand Up @@ -184,60 +184,14 @@ p, li { white-space: pre-wrap; }
</layout>
</item>
<item row="4" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="spacing" >
<number>6</number>
<property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property>
<item>
<widget class="QPushButton" name="pbnHelp" >
<property name="text" >
<string>Help</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>281</width>
<height>26</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbnOK" >
<property name="text" >
<string>&amp;OK</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbnCancel" >
<property name="text" >
<string>&amp;Cancel</string>
</property>
<property name="shortcut" >
<string>Alt+C</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/delimited_text/qgsdelimitedtextplugin.cpp
Expand Up @@ -122,6 +122,7 @@ void QgsDelimitedTextPlugin::run()
QgsDelimitedTextPluginGui *myQgsDelimitedTextPluginGui=
new QgsDelimitedTextPluginGui(qGisInterface,
qGisInterface->getMainWindow(), QgisGui::ModalDialogFlags);
myQgsDelimitedTextPluginGui->setAttribute(Qt::WA_DeleteOnClose);
//listen for when the layer has been made so we can draw it
connect(myQgsDelimitedTextPluginGui,
SIGNAL(drawVectorLayer(QString,QString,QString)),
Expand Down
21 changes: 13 additions & 8 deletions src/plugins/delimited_text/qgsdelimitedtextplugingui.cpp
Expand Up @@ -27,16 +27,14 @@
#include <QMessageBox>
#include <QTextStream>

QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui() : QDialog()
{
setupUi(this);

}

QgsDelimitedTextPluginGui::QgsDelimitedTextPluginGui(QgisInterface * _qI, QWidget * parent, Qt::WFlags fl)
: QDialog(parent, fl), qI(_qI)
{
setupUi(this);
pbnOK = buttonBox->button(QDialogButtonBox::Ok);
pbnParse = buttonBox->addButton(tr("Parse"), QDialogButtonBox::ActionRole);
connect(pbnParse, SIGNAL(clicked()), this, SLOT(on_pbnParse_clicked()));
enableButtons();
// at startup, fetch the last used delimiter and directory from
// settings
QSettings settings;
Expand All @@ -48,7 +46,7 @@ QgsDelimitedTextPluginGui::~QgsDelimitedTextPluginGui()
{
}
/** Autoconnected slots **/
void QgsDelimitedTextPluginGui::on_pbnHelp_clicked()
void QgsDelimitedTextPluginGui::on_buttonBox_helpRequested()
{
QgsContextHelp::run(context_id);
}
Expand All @@ -60,7 +58,7 @@ void QgsDelimitedTextPluginGui::on_pbnParse_clicked()
{
updateFieldLists();
}
void QgsDelimitedTextPluginGui::on_pbnOK_clicked()
void QgsDelimitedTextPluginGui::on_buttonBox_accepted()
{
if(txtLayerName->text().length() > 0)
{
Expand All @@ -80,13 +78,20 @@ void QgsDelimitedTextPluginGui::on_pbnOK_clicked()
settings.writeEntry(key + "/delimiter", txtDelimiter->text());
QFileInfo fi(txtFilePath->text());
settings.writeEntry(key + "/text_path", fi.dirPath());

accept();
}
else
{
QMessageBox::warning(this, tr("No layer name"), tr("Please enter a layer name before adding the layer to the map"));
}
}

void QgsDelimitedTextPluginGui::on_buttonBox_rejected()
{
reject();
}

void QgsDelimitedTextPluginGui::updateFieldLists()
{
// Update the x and y field dropdown boxes
Expand Down
25 changes: 16 additions & 9 deletions src/plugins/delimited_text/qgsdelimitedtextplugingui.h
Expand Up @@ -24,23 +24,30 @@ class QgsDelimitedTextPluginGui : public QDialog, private Ui::QgsDelimitedTextPl
{
Q_OBJECT
public:
QgsDelimitedTextPluginGui();
QgsDelimitedTextPluginGui( QgisInterface * _qI, QWidget* parent = 0, Qt::WFlags fl = 0 );
~QgsDelimitedTextPluginGui();
public slots:
void on_pbnOK_clicked();
void on_pbnHelp_clicked();
void on_btnBrowseForFile_clicked();
void on_pbnParse_clicked();

public slots:
void help();

private:
void updateFieldLists();
void getOpenFileName();
void enableButtons();
void help();

private:
QgisInterface * qI;
QAbstractButton *pbnOK;
QAbstractButton *pbnParse;
static const int context_id = 1033030847;
signals:

private slots:
void on_buttonBox_accepted();
void on_buttonBox_rejected();
void on_buttonBox_helpRequested();
void on_btnBrowseForFile_clicked();
void on_pbnParse_clicked();

signals:
void drawRasterLayer(QString);
void drawVectorLayer(QString,QString,QString);
};
Expand Down

0 comments on commit d229316

Please sign in to comment.