Commit 3323523b authored by David Saxton's avatar David Saxton

More porting to Qt4 (dialogs and code).

svn path=/trunk/KDE/kdeedu/kmplot/; revision=522295
parent 7a9704ed
......@@ -33,7 +33,6 @@
#include <klocale.h>
#include <kmessagebox.h>
#include <kpushbutton.h>
#include <q3cstring.h>
#include <qcursor.h>
#include <qtimer.h>
//Added by qt3to4:
......
......@@ -63,7 +63,7 @@ class KmPlotIO;
bool MainDlg::oldfileversion;
MainDlg::MainDlg(QWidget *parentWidget, const char *, QObject *parent, const char *name) : DCOPObject( "MainDlg" ), KParts::ReadOnlyPart( parent ), m_recentFiles( 0 ), m_modified(false), m_parent(parentWidget)
MainDlg::MainDlg(QWidget *parentWidget, const char *, QObject *parent ) : DCOPObject( "MainDlg" ), KParts::ReadOnlyPart( parent ), m_recentFiles( 0 ), m_modified(false), m_parent(parentWidget)
{
// we need an instance
setInstance( KmPlotPartFactory::instance() );
......@@ -379,7 +379,7 @@ void MainDlg::slotExport()
if( url.fileName().right(4).lower()==".svg")
{
Q3Picture pic;
QPicture pic;
view->draw(&pic, 2);
if (url.isLocalFile() )
pic.save( url.prettyURL(0), "SVG");
......@@ -816,11 +816,10 @@ KmPlotPartFactory::~KmPlotPartFactory()
}
KParts::Part* KmPlotPartFactory::createPartObject( QWidget *parentWidget, const char *widgetName,
QObject *parent, const char *name,
const char *, const QStringList & )
QObject *parent, const char *, const char *, const QStringList & )
{
// Create an instance of our Part
MainDlg* obj = new MainDlg( parentWidget, widgetName, parent, name );
MainDlg* obj = new MainDlg( parentWidget, widgetName, parent );
emit objectCreated( obj );
return obj;
}
......
......@@ -30,7 +30,7 @@
#define MainDlg_included
// Qt includes
#include <q3picture.h>
#include <QPicture>
// KDE includes
#include <kaction.h>
......@@ -85,7 +85,7 @@ public:
* @param parent parent object
* @param name name of this dialog
*/
MainDlg(QWidget *parentWidget, const char *, QObject *parent, const char *name);
MainDlg(QWidget *parentWidget, const char *, QObject *parent );
/// Cleaning up a bit.
virtual ~MainDlg();
/// This class needs access to private members, too.
......
......@@ -28,14 +28,12 @@
#include <qbitmap.h>
#include <qcursor.h>
#include <qdatastream.h>
#include <q3picture.h>
#include <QPicture>
#include <qslider.h>
#include <qtimer.h>
#include <qtooltip.h>
#include <q3whatsthis.h>
//Added by qt3to4:
#include <QPixmap>
#include <Q3CString>
#include <QPaintEvent>
#include <QKeyEvent>
#include <QEvent>
......
......@@ -27,7 +27,6 @@
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qdialog.h>
#include <q3frame.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qradiobutton.h>
......
......@@ -32,19 +32,23 @@
#include "keditconstant.h"
KEditConstant::KEditConstant(XParser *p, char &c, QString &v, QWidget *parent, const char *name)
: QEditConstant(parent, name,Qt::WDestructiveClose), constant(c), value(v), m_parser(p)
KEditConstant::KEditConstant(XParser *p, char &c, QString &v, QWidget *parent)
: KDialog( parent, i18n("Edit Constant"), Ok|Cancel ),
constant(c), value(v), m_parser(p)
{
m_mainWidget = new QEditConstant( this );
setMainWidget( m_mainWidget );
if ( constant != '0' )
{
txtConstant->setEnabled(false);
txtConstant->setText(QString(constant));
txtValue->setText(value);
txtValue->setFocus();
txtValue->selectAll();
m_mainWidget->txtConstant->setEnabled(false);
m_mainWidget->txtConstant->setText(QString(constant));
m_mainWidget->txtValue->setText(value);
m_mainWidget->txtValue->setFocus();
m_mainWidget->txtValue->selectAll();
}
connect( cmdCancel, SIGNAL( clicked() ), this, SLOT( deleteLater() ));
connect( cmdOK, SIGNAL( clicked() ), this, SLOT( cmdOK_clicked() ));
connect( m_mainWidget->txtConstant, SIGNAL( textChanged( const QString & ) ), this, SLOT( nameChanged( const QString & ) ) );
}
......@@ -52,19 +56,19 @@ KEditConstant::~KEditConstant()
{
}
void KEditConstant::cmdOK_clicked()
void KEditConstant::accept()
{
constant = txtConstant->text().at(0).latin1();
value = txtValue->text();
constant = m_mainWidget->txtConstant->text().at(0).latin1();
value = m_mainWidget->txtValue->text();
if ( constant<'A' || constant>'Z')
{
KMessageBox::error(this, i18n("Please insert a valid constant name between A and Z."));
txtConstant->setFocus();
txtConstant->selectAll();
KMessageBox::sorry(this, i18n("Please insert a valid constant name between A and Z."));
m_mainWidget->txtConstant->setFocus();
m_mainWidget->txtConstant->selectAll();
return;
}
if ( txtConstant->isEnabled() ) //creating, not edit a constant
if ( m_mainWidget->txtConstant->isEnabled() ) //creating, not edit a constant
{
bool found= false;
QVector<Constant>::iterator it;
......@@ -75,15 +79,15 @@ void KEditConstant::cmdOK_clicked()
}
if (found)
{
KMessageBox::error(this, i18n("The constant already exists."));
KMessageBox::sorry(this, i18n("The constant already exists."));
return;
}
}
(double) m_parser->eval(value);
if ( m_parser->parserError() )
{
txtValue->setFocus();
txtValue->selectAll();
m_mainWidget->txtValue->setFocus();
m_mainWidget->txtValue->selectAll();
return;
}
......@@ -91,9 +95,10 @@ void KEditConstant::cmdOK_clicked()
QDialog::accept();
}
void KEditConstant::txtVariable_lostFocus()
void KEditConstant::nameChanged( const QString & newName )
{
txtConstant->setText( txtConstant->text().upper() );
m_mainWidget->txtConstant->setText( newName.upper() );
}
#include "keditconstant.moc"
......
......@@ -26,23 +26,27 @@
#ifndef KEDITCONSTANT_H
#define KEDITCONSTANT_H
#include <kdialog.h>
#include "qeditconstant.h"
#include "xparser.h"
class QEditConstant;
/**
@author Fredrik Edemar
*/
/// A small dialog for creating an editing constants
class KEditConstant : public QEditConstant
class KEditConstant : public KDialog
{
Q_OBJECT
public:
KEditConstant(XParser *p, char &, QString &,QWidget *parent = 0, const char *name = 0);
KEditConstant( XParser *p, char &, QString &,QWidget *parent = 0 );
~KEditConstant();
public slots:
void cmdOK_clicked();
void txtVariable_lostFocus();
virtual void accept();
void nameChanged( const QString & newName );
signals:
/// called when we are finished
......@@ -52,8 +56,15 @@ private:
char &constant;
QString &value;
XParser *m_parser;
QEditConstant * m_mainWidget;
};
class QEditConstant : public QWidget, public Ui::QEditConstant
{
public:
QEditConstant( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
#endif
......
......@@ -38,7 +38,7 @@
#include "kminmax.h"
#include "xparser.h"
KMinMax::KMinMax(View *v, QWidget *parent, const char *name)
KMinMax::KMinMax(View *v, QWidget *parent )
: KDialog( parent, i18n("Find Minimum Point") ),
m_view(v)
{
......
......@@ -39,7 +39,7 @@ class KMinMax : public KDialog
{
Q_OBJECT
public:
KMinMax(View *, QWidget *parent = 0, const char *name = 0);
KMinMax(View *, QWidget *parent = 0 );
/// called every time the dialog is opened
void init(char);
/// update the list with functions
......
......@@ -40,7 +40,6 @@
#include "MainDlg.h"
#include "kmplotprogress.h"
//Added by qt3to4:
#include <Q3CString>
#include <ktoolinvocation.h>
KmPlot::KmPlot( KCmdLineArgs* args)
......
......@@ -43,7 +43,7 @@
class ParameterValueList;
KParameterEditor::KParameterEditor(XParser *m, QList<ParameterValueItem> *l, QWidget *parent, const char *name)
KParameterEditor::KParameterEditor(XParser *m, QList<ParameterValueItem> *l, QWidget *parent )
: KDialog( parent, i18n("Parameter Editor"), Ok ),
m_parameter(l),
m_parser(m)
......
......@@ -42,7 +42,7 @@ class KParameterEditor : public KDialog
{
Q_OBJECT
public:
KParameterEditor(XParser *, QList<ParameterValueItem> *, QWidget *parent = 0, const char *name = 0);
KParameterEditor(XParser *, QList<ParameterValueItem> *, QWidget *parent = 0 );
~KParameterEditor();
public slots:
......
......@@ -80,11 +80,17 @@ KSliderWindow::KSliderWindow( QWidget * parent, KActionCollection * ac ) :
connect( m_sliders[i], SIGNAL( valueChanged( int ) ), this, SIGNAL( valueChanged() ) );
}
//BEGIN create popup-menu
m_popupmenu = new KMenu(this);
KAction *mnuMinValue = new KAction(i18n("&Change Minimum Value") ,0,this, SLOT( mnuMinValue_clicked() ),ac, "");
KAction * mnuMinValue = new KAction( i18n("&Change Minimum Value"), ac, "" );
connect( mnuMinValue, SIGNAL( triggered(bool) ), this, SLOT( mnuMinValue_clicked() ) );
mnuMinValue->plug(m_popupmenu);
KAction *mnuMaxValue = new KAction(i18n("&Change Maximum Value") ,0,this, SLOT( mnuMaxValue_clicked() ),ac, "" );
KAction * mnuMaxValue = new KAction( i18n("&Change Maximum Value"), ac, "" );
connect( mnuMaxValue, SIGNAL( triggered(bool) ), this, SLOT( mnuMaxValue_clicked() ) );
mnuMaxValue->plug(m_popupmenu);
//END create popup-menu
}
KSliderWindow::~KSliderWindow()
......
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>QEditConstant</class>
<widget class="QDialog">
<property name="name">
<cstring>QEditConstant</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>252</width>
<height>115</height>
</rect>
</property>
<property name="windowTitle">
<string>Edit Constant</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QLabel" row="0" column="0">
<property name="name">
<cstring>textLabel1</cstring>
</property>
<property name="text">
<string>Variable:</string>
</property>
</widget>
<widget class="QLabel" row="1" column="0">
<property name="name">
<cstring>textLabel2</cstring>
</property>
<property name="text">
<string>Value:</string>
</property>
</widget>
<widget class="QLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
<property name="name">
<cstring>layout1</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>cmdOK</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>spacer1</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>71</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>cmdCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</hbox>
</widget>
<widget class="KLineEdit" row="0" column="1">
<property name="name">
<cstring>txtConstant</cstring>
</property>
<property name="maxLength">
<number>1</number>
</property>
<property name="toolTip" stdset="0">
<string>Name of the constant (only 1 character but "E")</string>
</property>
<property name="whatsThis" stdset="0">
<string>Enter the name of the constant here. User-defined constant names only have 1 character; the constant "E" (Euler number) is reserved.</string>
</property>
</widget>
<widget class="KLineEdit" row="1" column="1">
<property name="name">
<cstring>txtValue</cstring>
</property>
<property name="toolTip" stdset="0">
<string>Enter the constant's value here.</string>
</property>
<property name="whatsThis" stdset="0">
<string>The value of a constant can be an expression, for instance PI/2 or sqrt(2).</string>
</property>
</widget>
</grid>
</widget>
<connections>
<connection>
<sender>txtConstant</sender>
<signal>lostFocus()</signal>
<receiver>QEditConstant</receiver>
<slot>txtVariable_lostFocus()</slot>
</connection>
</connections>
<tabstops>
<tabstop>txtConstant</tabstop>
<tabstop>txtValue</tabstop>
<tabstop>cmdCancel</tabstop>
<tabstop>cmdOK</tabstop>
</tabstops>
<includes>
<include location="local" impldecl="in implementation">qeditconstant.ui.h</include>
</includes>
<slots>
<slot>txtVariable_lostFocus()</slot>
</slots>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>klineedit.h</includehint>
<includehint>klineedit.h</includehint>
</includehints>
</UI>
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>QEditConstant</class>
<widget class="QWidget" name="QEditConstant" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>321</width>
<height>131</height>
</rect>
</property>
<property name="windowTitle" >
<string>Edit Constant</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="KLineEdit" name="txtConstant" >
<property name="toolTip" >
<string>Name of the constant (only 1 character but "E")</string>
</property>
<property name="whatsThis" >
<string>Enter the name of the constant here. User-defined constant names only have 1 character; the constant "E" (Euler number) is reserved.</string>
</property>
<property name="maxLength" >
<number>1</number>
</property>
</widget>
</item>
<item row="2" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>38</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Variable:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="txtValue" >
<property name="toolTip" >
<string>Enter the constant's value here.</string>
</property>
<property name="whatsThis" >
<string>The value of a constant can be an expression, for instance PI/2 or sqrt(2).</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Value:</string>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<customwidgets>
<customwidget>
<class>KLineEdit</class>
<extends></extends>
<header>klineedit.h</header>
<container>0</container>
<pixmap></pixmap>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -35,7 +35,6 @@
#include "xparser.h"
//Added by qt3to4:
#include <QList>
#include <Q3CString>
XParser::XParser(bool &mo) : DCOPObject("Parser"), Parser(), m_modified(mo)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment