Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
Cantor
Commits
450871ca
Commit
450871ca
authored
Nov 02, 2014
by
Filipe Saraiva
Browse files
Null backend ported to Qt5/KF5
parent
eec961dc
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/backends/CMakeLists.txt
View file @
450871ca
#
add_subdirectory(null)
add_subdirectory
(
null
)
# add_subdirectory(maxima)
add_subdirectory
(
octave
)
# add_subdirectory(scilab)
...
...
src/backends/null/CMakeLists.txt
View file @
450871ca
set
(
NullBackend_SRCS
nullbackend.cpp
set
(
NullBackend_SRCS
nullbackend.cpp
nullsession.cpp
nullexpression.cpp
nullcompletionobject.cpp
)
kde4_add_plugin
(
cantor_nullbackend
${
NullBackend_SRCS
}
)
target_link_libraries
(
cantor_nullbackend
${
KDE4_KDEUI_LIBS
}
cantorlibs
)
add_library
(
cantor_nullbackend
MODULE
${
NullBackend_SRCS
}
)
target_link_libraries
(
cantor_nullbackend cantorlibs
)
install
(
FILES nullbackend.desktop DESTINATION
${
SERVICES_INSTALL_DIR
}
/cantor
)
install
(
TARGETS cantor_nullbackend DESTINATION
${
PLUGIN_INSTALL_DIR
}
)
src/backends/null/nullbackend.cpp
View file @
450871ca
...
...
@@ -22,38 +22,38 @@
#include "nullsession.h"
#include
"kd
ebug
.h"
#include
<QD
ebug
>
#include "cantor_macros.h"
NullBackend
::
NullBackend
(
QObject
*
parent
,
const
QList
<
QVariant
>
args
)
:
Cantor
::
Backend
(
parent
,
args
)
{
setObjectName
(
"nullbackend"
);
k
Debug
()
<<
"Creating NullBackend"
;
setObjectName
(
QLatin1String
(
"nullbackend"
)
)
;
q
Debug
()
<<
"Creating NullBackend"
;
setEnabled
(
false
);
}
NullBackend
::~
NullBackend
()
{
k
Debug
()
<<
"Destroying NullBackend"
;
q
Debug
()
<<
"Destroying NullBackend"
;
}
QString
NullBackend
::
id
()
const
{
return
"null"
;
return
QLatin1String
(
"null"
)
;
}
Cantor
::
Session
*
NullBackend
::
createSession
()
{
k
Debug
()
<<
"Spawning a new Null session"
;
q
Debug
()
<<
"Spawning a new Null session"
;
return
new
NullSession
(
this
);
}
Cantor
::
Backend
::
Capabilities
NullBackend
::
capabilities
()
const
{
k
Debug
()
<<
"Requesting capabilities of NullSession"
;
q
Debug
()
<<
"Requesting capabilities of NullSession"
;
return
Cantor
::
Backend
::
Nothing
;
}
...
...
src/backends/null/nullcompletionobject.cpp
View file @
450871ca
...
...
@@ -21,7 +21,7 @@
#include "nullcompletionobject.h"
#include <QStringList>
#include <
kd
ebug
.h
>
#include <
QD
ebug>
#include "nullsession.h"
...
...
@@ -37,10 +37,10 @@ NullCompletionObject::~NullCompletionObject()
void
NullCompletionObject
::
fetchCompletions
()
{
k
Debug
()
<<
"fetching..."
;
q
Debug
()
<<
"fetching..."
;
QStringList
comp
;
for
(
int
i
=
0
;
i
<
5
;
i
++
)
comp
<<
QString
(
"%1 %2"
).
arg
(
command
()).
arg
(
i
);
comp
<<
QString
::
fromLatin1
(
"%1 %2"
).
arg
(
command
()).
arg
(
i
);
setCompletions
(
comp
);
emit
fetchingDone
();
}
src/backends/null/nullcompletionobject.h
View file @
450871ca
...
...
@@ -31,7 +31,7 @@ class NullCompletionObject : public Cantor::CompletionObject
NullCompletionObject
(
const
QString
&
command
,
int
index
,
NullSession
*
session
);
~
NullCompletionObject
();
protected
slots
:
protected
Q_SLOTS
:
void
fetchCompletions
();
};
...
...
src/backends/null/nullexpression.cpp
View file @
450871ca
...
...
@@ -23,13 +23,13 @@
#include "textresult.h"
#include "imageresult.h"
#include "helpresult.h"
#include <
kd
ebug
.h
>
#include <
ki
con
l
oader
.h
>
#include <
QD
ebug>
#include <
KI
con
L
oader>
#include <QTimer>
NullExpression
::
NullExpression
(
Cantor
::
Session
*
session
)
:
Cantor
::
Expression
(
session
)
{
k
Debug
();
q
Debug
();
m_timer
=
new
QTimer
(
this
);
m_timer
->
setSingleShot
(
true
);
connect
(
m_timer
,
SIGNAL
(
timeout
()),
this
,
SLOT
(
evalFinished
()));
...
...
@@ -43,7 +43,7 @@ NullExpression::~NullExpression()
void
NullExpression
::
evaluate
()
{
k
Debug
()
<<
"evaluating "
<<
command
();
q
Debug
()
<<
"evaluating "
<<
command
();
setStatus
(
Cantor
::
Expression
::
Computing
);
m_timer
->
start
(
1000
);
...
...
@@ -51,18 +51,18 @@ void NullExpression::evaluate()
void
NullExpression
::
interrupt
()
{
k
Debug
()
<<
"interruptinging command"
;
q
Debug
()
<<
"interruptinging command"
;
m_timer
->
stop
();
setStatus
(
Cantor
::
Expression
::
Interrupted
);
}
void
NullExpression
::
evalFinished
()
{
k
Debug
()
<<
"evaluation finished"
;
if
(
command
()
==
"img"
)
setResult
(
new
Cantor
::
ImageResult
(
KUrl
(
KIconLoader
::
global
()
->
iconPath
(
"kde"
,
KIconLoader
::
Desktop
)),
"alternative"
)
);
q
Debug
()
<<
"evaluation finished"
;
if
(
command
()
==
QLatin1String
(
"img"
)
)
setResult
(
new
Cantor
::
ImageResult
(
KUrl
(
KIconLoader
::
global
()
->
iconPath
(
QLatin1String
(
"kde"
)
,
KIconLoader
::
Desktop
)),
QLatin1String
(
"alternative"
)
)
);
else
setResult
(
new
Cantor
::
TextResult
(
"result: "
+
command
()));
setResult
(
new
Cantor
::
TextResult
(
QLatin1String
(
"result: "
)
+
command
()));
setStatus
(
Cantor
::
Expression
::
Done
);
}
...
...
src/backends/null/nullexpression.h
View file @
450871ca
...
...
@@ -35,7 +35,7 @@ class NullExpression : public Cantor::Expression
void
evaluate
();
void
interrupt
();
public
slots
:
public
Q_SLOTS
:
void
evalFinished
();
private:
...
...
src/backends/null/nullsession.cpp
View file @
450871ca
...
...
@@ -22,33 +22,33 @@
#include "nullexpression.h"
#include "nullcompletionobject.h"
#include <
kd
ebug
.h
>
#include <
QD
ebug>
NullSession
::
NullSession
(
Cantor
::
Backend
*
backend
)
:
Session
(
backend
)
{
k
Debug
();
q
Debug
();
}
NullSession
::~
NullSession
()
{
k
Debug
();
q
Debug
();
}
void
NullSession
::
login
()
{
k
Debug
()
<<
"login"
;
q
Debug
()
<<
"login"
;
changeStatus
(
Cantor
::
Session
::
Done
);
emit
ready
();
}
void
NullSession
::
logout
()
{
k
Debug
()
<<
"logout"
;
q
Debug
()
<<
"logout"
;
}
void
NullSession
::
interrupt
()
{
k
Debug
()
<<
"interrupt"
;
q
Debug
()
<<
"interrupt"
;
foreach
(
Cantor
::
Expression
*
e
,
m_runningExpressions
)
e
->
interrupt
();
m_runningExpressions
.
clear
();
...
...
@@ -57,7 +57,7 @@ void NullSession::interrupt()
Cantor
::
Expression
*
NullSession
::
evaluateExpression
(
const
QString
&
cmd
,
Cantor
::
Expression
::
FinishingBehavior
behave
)
{
k
Debug
()
<<
"evaluating: "
<<
cmd
;
q
Debug
()
<<
"evaluating: "
<<
cmd
;
NullExpression
*
expr
=
new
NullExpression
(
this
);
expr
->
setFinishingBehavior
(
behave
);
connect
(
expr
,
SIGNAL
(
statusChanged
(
Cantor
::
Expression
::
Status
)),
this
,
SLOT
(
expressionFinished
()));
...
...
@@ -74,16 +74,16 @@ Cantor::Expression* NullSession::evaluateExpression(const QString& cmd, Cantor::
Cantor
::
CompletionObject
*
NullSession
::
completionFor
(
const
QString
&
command
,
int
index
)
{
k
Debug
()
<<
"tab completion for "
<<
command
;
q
Debug
()
<<
"tab completion for "
<<
command
;
return
new
NullCompletionObject
(
command
,
index
,
this
);
}
void
NullSession
::
expressionFinished
()
{
k
Debug
()
<<
"finished"
;
q
Debug
()
<<
"finished"
;
NullExpression
*
expression
=
qobject_cast
<
NullExpression
*>
(
sender
());
m_runningExpressions
.
removeAll
(
expression
);
k
Debug
()
<<
"size: "
<<
m_runningExpressions
.
size
();
q
Debug
()
<<
"size: "
<<
m_runningExpressions
.
size
();
if
(
m_runningExpressions
.
isEmpty
())
changeStatus
(
Cantor
::
Session
::
Done
);
...
...
src/backends/null/nullsession.h
View file @
450871ca
...
...
@@ -41,7 +41,7 @@ class NullSession : public Cantor::Session
Cantor
::
Expression
*
evaluateExpression
(
const
QString
&
command
,
Cantor
::
Expression
::
FinishingBehavior
behave
);
Cantor
::
CompletionObject
*
completionFor
(
const
QString
&
cmd
,
int
index
=-
1
);
private
slots
:
private
Q_SLOTS
:
void
expressionFinished
();
private:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment