Commit 94569a64 authored by Fredrik Edemar's avatar Fredrik Edemar

compile. link and run. TODO: port all DCOP code

svn path=/trunk/KDE/kdeedu/kmplot/; revision=549779
parent 733d30f5
......@@ -8,12 +8,15 @@ set(kmplotpart_PART_SRCS
plotstylewidget.cpp
functioneditor.cpp
parser.cpp
parseradaptor.cpp
xparser.cpp
diagr.cpp
equationedit.cpp
function.cpp
View.cpp
viewadaptor.cpp
MainDlg.cpp
maindlgadaptor.cpp
kprinterdlg.cpp
kconstanteditor.cpp
kparametereditor.cpp
......@@ -40,7 +43,7 @@ kde4_add_ui_files(kmplotpart_PART_SRCS
parameterswidget.ui
)
kde4_add_dcop_skels(kmplotpart_PART_SRCS MainDlgIface.h parseriface.h Viewiface.h )
# kde4_add_dcop_skels(kmplotpart_PART_SRCS MainDlgIface.h parseriface.h Viewiface.h )
kde4_add_kcfg_files(kmplotpart_PART_SRCS settings.kcfgc )
......@@ -54,10 +57,10 @@ install_targets(${PLUGIN_INSTALL_DIR} kmplotpart )
########### next target ###############
set(kmplot_SRCS main.cpp kmplot.cpp)
set(kmplot_SRCS main.cpp kmplot.cpp kmplotadaptor.cpp )
kde4_automoc(${kmplot_SRCS})
kde4_add_dcop_skels(kmplot_SRCS kmplotIface.h )
#kde4_add_dcop_skels(kmplot_SRCS kmplotIface.h )
# FIXME: it's wrong, but otherwise it does not compile
kde4_add_kcfg_files(kmplot_SRCS settings.kcfgc )
......
......@@ -30,7 +30,7 @@
#include <QTimer>
// KDE includes
#include <dcopclient.h>
// #include <dcopclient.h>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kconfigdialog.h>
......@@ -50,24 +50,61 @@
#include "functioneditor.h"
#include "kprinterdlg.h"
#include "kconstanteditor.h"
#include "MainDlg.h"
#include "MainDlg.moc"
#include "settings.h"
#include "MainDlg.h"
#include "ui_editscaling.h"
#include "ui_settingspagecolor.h"
#include "ui_settingspagefonts.h"
#include "ui_settingspagegeneral.h"
#include "ksliderwindow.h"
#include "maindlgadaptor.h"
#include <assert.h>
class XParser;
class KmPlotIO;
class EditScaling : public QWidget, public Ui::EditScaling
{
public:
EditScaling( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageColor : public QWidget, public Ui::SettingsPageColor
{
public:
SettingsPageColor( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageFonts : public QWidget, public Ui::SettingsPageFonts
{
public:
SettingsPageFonts( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageGeneral : public QWidget, public Ui::SettingsPageGeneral
{
public:
SettingsPageGeneral( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
bool MainDlg::oldfileversion;
MainDlg * MainDlg::m_self = 0;
MainDlg::MainDlg(QWidget *parentWidget, QObject *parent, const QStringList& ) :
DCOPObject( "MainDlg" ),
// DCOPObject( "MainDlg" ),
KParts::ReadOnlyPart( parent ),
m_recentFiles( 0 ),
m_modified(false),
......@@ -80,7 +117,7 @@ MainDlg::MainDlg(QWidget *parentWidget, QObject *parent, const QStringList& ) :
setInstance( KmPlotPartFactory::instance() );
kDebug() << "parentWidget->objectName():" << parentWidget->objectName() << endl;
if ( QString(parentWidget->objectName()).startsWith("KmPlot") )
if ( QString(parentWidget->objectName()).startsWith("kmplot") )
{
setXMLFile("kmplot_part.rc");
m_readonly = false;
......@@ -141,6 +178,11 @@ MainDlg::MainDlg(QWidget *parentWidget, QObject *parent, const QStringList& ) :
// User edited the configuration - update your local copies of the
// configuration data
connect( m_settingsDialog, SIGNAL( settingsChanged( const QString &) ), this, SLOT(updateSettings() ) );
new MainDlgAdaptor(this);
QDBus::sessionBus().registerObject("/maindlg", this);
}
MainDlg::~MainDlg()
......@@ -504,28 +546,28 @@ bool MainDlg::openFile()
void MainDlg::slotOpenRecent( const KUrl &url )
{
if( isModified() || !m_url.isEmpty() ) // open the file in a new window
{
QByteArray data;
QDataStream stream( &data,QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_3_1);
stream << url;
KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","openFileInNewWindow(KUrl)", data);
return;
}
View::self()->init();
if ( !kmplotio->load( url ) ) //if the loading fails
{
m_recentFiles->removeUrl(url ); //remove the file from the recent-opened-file-list
return;
}
m_url = m_currentfile = url;
m_recentFiles->setCurrentItem(-1); //don't select the item in the open-recent menu
setWindowCaption( m_url.prettyUrl(KUrl::LeaveTrailingSlash) );
m_modified = false;
View::self()->updateSliders();
View::self()->drawPlot();
// if( isModified() || !m_url.isEmpty() ) // open the file in a new window
// {
// QByteArray data;
// QDataStream stream( &data,QIODevice::WriteOnly);
// stream.setVersion(QDataStream::Qt_3_1);
// stream << url;
// KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","openFileInNewWindow(KUrl)", data);
// return;
// }
//
// View::self()->init();
// if ( !kmplotio->load( url ) ) //if the loading fails
// {
// m_recentFiles->removeUrl(url ); //remove the file from the recent-opened-file-list
// return;
// }
// m_url = m_currentfile = url;
// m_recentFiles->setCurrentItem(-1); //don't select the item in the open-recent menu
// setWindowCaption( m_url.prettyUrl(KUrl::LeaveTrailingSlash) );
// m_modified = false;
// View::self()->updateSliders();
// View::self()->drawPlot();
}
void MainDlg::slotPrint()
......@@ -664,12 +706,12 @@ void MainDlg::setReadOnlyStatusBarText(const QString &text)
void MainDlg::optionsConfigureKeys()
{
KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureKeys()", QByteArray());
// KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureKeys()", QByteArray());
}
void MainDlg::optionsConfigureToolbars()
{
KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureToolbars()", QByteArray());
// KApplication::kApplication()->dcopClient()->send(KApplication::kApplication()->dcopClient()->appId(), "KmPlotShell","optionsConfigureToolbars()", QByteArray());
}
// It's usually safe to leave the factory code alone.. with the
......@@ -735,3 +777,4 @@ void BrowserExtension::print()
static_cast<MainDlg*>(parent())->slotPrint();
}
#include "MainDlg.moc"
......@@ -49,12 +49,8 @@
#include "View.h"
#include "kminmax.h"
#include "kmplotio.h"
#include "MainDlgIface.h"
// #include "MainDlgIface.h"
#include "ui_editscaling.h"
#include "ui_settingspagecolor.h"
#include "ui_settingspagefonts.h"
#include "ui_settingspagegeneral.h"
class BrowserExtension;
class EditScaling;
......@@ -67,6 +63,17 @@ class KAction;
class KLineEdit;
class KRecentFilesAction;
class QTimer;
namespace Ui{
class EditScaling;
class SettingsPageColor;
class SettingsPageConstants;
class SettingsPageFonts;
class SettingsPageGeneral;
}
class EditScaling;
class SettingsPageColor;
class SettingsPageConstants;
class SettingsPageFonts;
......@@ -77,7 +84,7 @@ class SettingsPageGeneral;
* Its central widget view contains the parser, accessable via its parser() function.
* @see View, View::m_parser, View::parser
*/
class MainDlg : public KParts::ReadOnlyPart, virtual public MainDlgIface
class MainDlg : public KParts::ReadOnlyPart/*, virtual public MainDlgIface*/
{
Q_OBJECT
......@@ -98,14 +105,18 @@ class MainDlg : public KParts::ReadOnlyPart, virtual public MainDlgIface
/// This class needs access to private members, too.
friend class BezWnd;
/// Asks the user and returns true if modified data shall be dicarded.
bool checkModified();
/// Is set to true if a file from an old file format was loaded
static bool oldfileversion;
/// The function editor
FunctionEditor * functionEditor() const { return m_functionEditor; }
public Q_SLOTS:
// DBus interface
/// Asks the user and returns true if modified data shall be dicarded.
Q_SCRIPTABLE bool checkModified();
public slots:
/// Implement the coordinate system edit dialog
void editAxes();
......@@ -254,37 +265,4 @@ public slots:
void print();
};
class EditScaling : public QWidget, public Ui::EditScaling
{
public:
EditScaling( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageColor : public QWidget, public Ui::SettingsPageColor
{
public:
SettingsPageColor( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageFonts : public QWidget, public Ui::SettingsPageFonts
{
public:
SettingsPageFonts( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
class SettingsPageGeneral : public QWidget, public Ui::SettingsPageGeneral
{
public:
SettingsPageGeneral( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
#endif // MainDlg_included
......@@ -58,8 +58,10 @@
#include "settings.h"
#include "ksliderwindow.h"
#include "MainDlg.h"
#include "View.h"
#include "View.moc"
#include "viewadaptor.h"
// other includes
#include <assert.h>
......@@ -70,13 +72,13 @@
View * View::m_self = 0;
View::View( bool readOnly, bool & modified, KMenu * functionPopup, QWidget* parent, KActionCollection *ac )
: DCOPObject("View"),
: /*DCOPObject("View"),*/
QWidget( parent, Qt::WStaticContents ),
buffer( width(), height() ),
m_popupmenu( functionPopup ),
m_modified( modified ),
m_readonly( readOnly ),
m_dcop_client(KApplication::kApplication()->dcopClient()),
// m_dcop_client(KApplication::kApplication()->dcopClient()),
m_ac(ac)
{
assert( !m_self ); // this class should only be constructed once
......@@ -100,6 +102,9 @@ View::View( bool readOnly, bool & modified, KMenu * functionPopup, QWidget* pare
m_mousePressTimer = new QTime();
new ViewAdaptor(this);
QDBus::sessionBus().registerObject("/view", this);
XParser::self( & modified );
init();
getSettings();
......@@ -2269,7 +2274,7 @@ void View::setStatusBar(const QString &text, const int id)
QDataStream arg( &parameters,QIODevice::WriteOnly);
arg.setVersion(QDataStream::Qt_3_1);
arg << text << id;
m_dcop_client->send(m_dcop_client->appId(), "KmPlotShell","setStatusBarText(QString,int)", parameters);
// m_dcop_client->send(m_dcop_client->appId(), "KmPlotShell","setStatusBarText(QString,int)", parameters);
}
}
......@@ -2289,3 +2294,4 @@ IntegralDrawSettings::IntegralDrawSettings()
}
//END class IntegralDrawSettings
#include "View.moc"
......@@ -36,7 +36,7 @@
#include <QEvent>
// KDE includes
#include <dcopclient.h>
// #include <dcopclient.h>
#include <kactionclasses.h>
#include <kdebug.h>
#include <kmenu.h>
......@@ -46,7 +46,7 @@
// local includes
#include "diagr.h"
#include "Viewiface.h"
// #include "Viewiface.h"
#include "xparser.h"
class KMinMax;
......@@ -76,7 +76,7 @@ class XParser;
* It is the central widget of MainDlg.
* @see MainDlg, MainDlg::view
*/
class View : public QWidget, virtual public ViewIface
class View : public QWidget
{
Q_OBJECT
public:
......@@ -418,7 +418,7 @@ public slots:
/// timer that is started when the mouse is pressed
QTime * m_mousePressTimer;
DCOPClient *m_dcop_client;
// DCOPClient *m_dcop_client;
QString m_statusbartext1;
QString m_statusbartext2;
QString m_statusbartext3;
......
......@@ -28,7 +28,18 @@
#include <qradiobutton.h>
#include "settings.h"
#include "coordsconfigdialog.h"
#include "ui_editcoords.h"
class EditCoords : public QWidget, public Ui::EditCoords
{
public:
EditCoords( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
CoordsConfigDialog::CoordsConfigDialog(XParser *p, QWidget *parent)
: KConfigDialog(parent, "coords", Settings::self()), m_parser(p)
......
......@@ -27,16 +27,13 @@
#include <kconfigdialog.h>
#include "ui_editcoords.h"
#include "xparser.h"
class EditCoords : public QWidget, public Ui::EditCoords
{
public:
EditCoords( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
namespace Ui{
class EditCoords;
}
class EditCoords;
/**
@author Fredrik Edemar
......
......@@ -38,6 +38,7 @@
#include <kmessagebox.h>
#include <QMenu>
#include <QRadioButton>
#include <QTimer>
#include <assert.h>
......
......@@ -33,8 +33,18 @@
#include <QList>
#include "kminmax.h"
#include "ui_qminmax.h"
#include "xparser.h"
class QMinMax : public QWidget, public Ui::QMinMax
{
public:
QMinMax( QWidget * parent = 0 )
{ setupUi(this); }
};
KMinMax::KMinMax(QWidget *parent )
: KDialog( parent, i18n("Find Minimum Point") )
{
......
......@@ -26,9 +26,12 @@
#ifndef KMINMAX_H
#define KMINMAX_H
#include "ui_qminmax.h"
#include "View.h"
namespace Ui{
class QMinMax;
}
class QMinMax;
/**
......@@ -74,12 +77,4 @@ public slots:
QMinMax * m_mainWidget;
};
class QMinMax : public QWidget, public Ui::QMinMax
{
public:
QMinMax( QWidget * parent = 0 )
: QWidget( parent )
{ setupUi(this); }
};
#endif
......@@ -39,8 +39,11 @@
#include "MainDlg.h"
#include <ktoolinvocation.h>
#include "kmplotadaptor.h"
#include <dbus/qdbus.h>
KmPlot::KmPlot( KCmdLineArgs* args)
: DCOPObject( "KmPlotShell" ), KParts::MainWindow( 0L, "KmPlot" )
: KParts::MainWindow( 0L, "KmPlot" )
{
// set the shell's ui resource file
setXMLFile("kmplot_shell.rc");
......@@ -105,6 +108,9 @@ KmPlot::KmPlot( KCmdLineArgs* args)
}
show();
new KmplotAdaptor(this);
QDBus::sessionBus().registerObject("/kmplot", this);
}
KmPlot::~KmPlot()
......@@ -241,26 +247,14 @@ void KmPlot::openFileInNewWindow(const KUrl url)
bool KmPlot::checkModified()
{
DCOPCString replyType;
QByteArray replyData;
kapp->dcopClient()->call(kapp->dcopClient()->appId(), "MainDlg","checkModified()", QByteArray(), replyType, replyData, false);
bool result;
QDataStream stream( &replyData,QIODevice::ReadOnly);
stream.setVersion(QDataStream::Qt_3_1);
stream >> result;
return result;
QDBusReply<bool> reply = QDBusInterfacePtr( QDBus::sessionBus().baseService(), "/maindlg", "org.kde.kmplot.MainDlg")->call( QDBusAbstractInterface::UseEventLoop, "checkModified" );
return reply.value();
}
bool KmPlot::isModified()
{
DCOPCString replyType;
QByteArray replyData;
kapp->dcopClient()->call(kapp->dcopClient()->appId(), "MainDlg","isModified()", QByteArray(), replyType, replyData, false);
bool result;
QDataStream stream( &replyData,QIODevice::ReadOnly);
stream.setVersion(QDataStream::Qt_3_1);
stream >> result;
return result;
QDBusReply<bool> reply = QDBusInterfacePtr( QDBus::sessionBus().baseService(), "/maindlg", "org.kde.kmplot.isModified")->call( QDBusAbstractInterface::UseEventLoop, "checkModified" );
return reply.value();
}
bool KmPlot::queryClose()
......@@ -270,7 +264,7 @@ bool KmPlot::queryClose()
void KmPlot::setStatusBarText(const QString &text, int id)
{
statusBar()->changeItem(text,id);
statusBar()->changeItem(text,id);
}
......
......@@ -33,7 +33,7 @@
#include <kcmdlineargs.h>
#include <kparts/mainwindow.h>
#include "kmplotIface.h"
#include "kmplotadaptor.h"
class KToggleAction;
class KToggleFullScreenAction;
......@@ -45,7 +45,7 @@ class KToggleFullScreenAction;
* @short Application Shell
* @author Fredrik Edemar <f_edemar@linux.se>
*/
class KmPlot : public KParts::MainWindow, virtual public KmPlotIface
class KmPlot : public KParts::MainWindow
{
Q_OBJECT
public:
......@@ -83,16 +83,20 @@ protected:
private slots:
void fileNew();
void fileOpen();
void fileOpen(const KUrl &url);
void optionsConfigureKeys();
void optionsConfigureToolbars();
void applyNewToolbarConfig();
public Q_SLOTS:
// DBus interface
Q_SCRIPTABLE void fileOpen();
Q_SCRIPTABLE void optionsConfigureKeys();
Q_SCRIPTABLE void optionsConfigureToolbars();
Q_SCRIPTABLE void setStatusBarText(const QString &, int id);
Q_SCRIPTABLE void openFileInNewWindow(const KUrl url);
public slots:
/// Called when fullscren is enabled/disabled
void slotUpdateFullScreen(bool);
void setStatusBarText(const QString &, int id);
private:
void setupAccel();
......@@ -100,7 +104,6 @@ private:
void setupStatusBar();
bool checkModified();
bool isModified();
void openFileInNewWindow(const KUrl url);
private:
......
......@@ -42,6 +42,8 @@
//Added by qt3to4:
#include <QList>
#include "parseradaptor.h"
double Parser::m_radiansPerAngleUnit = 0;
/// List of predefined functions.
......@@ -107,6 +109,9 @@ Parser::Parser()
m_ownEquation = new Equation( Equation::Cartesian, 0 );
m_currentEquation = m_ownEquation;
new ParserAdaptor(this);
QDBus::sessionBus().registerObject("/parser", this);
}
......@@ -1235,64 +1240,64 @@ QChar Constants::generateUniqueName()
void Constants::load()
{
KSimpleConfig conf ("kcalcrc");
conf.setGroup("UserConstants");
QString tmp;
for( int i=0; ;i++)
{
tmp.setNum(i);
QString tmp_constant = conf.readEntry("nameConstant"+tmp, QString(" "));
QString tmp_value = conf.readEntry("valueConstant"+tmp, QString(" "));
// kDebug() << "konstant: " << tmp_constant << endl;
// kDebug() << "value: " << tmp_value << endl;
// kDebug() << "**************" << endl;
if ( tmp_constant == " " )
return;
if ( tmp_constant.isEmpty() )
continue;
double value = m_parser->eval(tmp_value);
if ( m_parser->parserError(false) )
{
kWarning() << k_funcinfo << "Couldn't parse the value " << tmp_value << endl;
continue;