Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Education
KAlgebra
Commits
08fdd246
Commit
08fdd246
authored
Sep 27, 2011
by
Aleix Pol Gonzalez
🐧
Browse files
Add missing files related to the port to a full QML app.
parent
525bdfc9
Changes
4
Hide whitespace changes
Inline
Side-by-side
mobile/plugins/KAlgebraMobile.qml
0 → 100644
View file @
08fdd246
import
QtQuick
1.0
import
QtDesktop
0.1
import
org
.
kde
.
analitza
1.0
Rectangle
{
SystemPalette
{
id
:
syspal
}
color
:
syspal
.
window
height
:
400
width
:
300
ToolBar
{
id
:
toolbar
width
:
parent
.
width
height
:
40
Row
{
spacing
:
2
anchors.verticalCenter
:
parent
.
verticalCenter
ToolButton
{
// iconSource: "images/folder_new.png"
anchors.verticalCenter
:
parent
.
verticalCenter
text
:
"
Go!
"
onClicked
:
{
var
idx
=
pluginsView
.
currentIndex
var
toOpen
=
plugins
.
pluginPath
(
idx
)
try
{
var
component
=
Qt
.
createComponent
(
toOpen
)
frame
.
addTab
(
component
)
}
catch
(
e
)
{
console
.
log
(
"
error:
"
+
e
)
}
}
}
}
}
TabFrame
{
id
:
frame
width
:
parent
.
width
anchors.top
:
toolbar
.
bottom
anchors.bottom
:
parent
.
bottom
Tab
{
title
:
"
hola
"
TableView
{
id
:
pluginsView
anchors.fill
:
parent
headerVisible
:
false
TableColumn
{
property
:
"
display
"
caption
:
"
Title
"
width
:
120
}
// itemDelegate: Row { /*Image { source: 'image://desktoptheme/'+decoration-name } */Text { text: display } }
// highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
model
:
PluginsModel
{
id
:
plugins
}
}
}
}
}
mobile/plugins/widgets/KAlgebraPage.qml
0 → 100644
View file @
08fdd246
import
QtDesktop
0.1
Tab
{
title
:
"
<unnamed>
"
}
mobile/pluginsmodel.cpp
0 → 100644
View file @
08fdd246
/*************************************************************************************
* Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#include
"pluginsmodel.h"
#include
<KStandardDirs>
#include
<KIcon>
#include
<QDir>
#include
<QDebug>
PluginsModel
::
PluginsModel
(
QObject
*
parent
)
:
QStandardItemModel
(
parent
)
{
QHash
<
int
,
QByteArray
>
rolenames
=
QStandardItemModel
::
roleNames
();
rolenames
.
insert
(
PathRole
,
"path"
);
rolenames
.
insert
(
PriorityRole
,
"priority"
);
setRoleNames
(
rolenames
);
KStandardDirs
d
;
QStringList
basedirs
=
d
.
findDirs
(
"data"
,
"kalgebra/plugins"
);
QStringList
foundPlugins
;
foreach
(
const
QString
&
dir
,
basedirs
)
{
//we list <dir>/*/*.desktop
QDir
d
(
dir
);
QStringList
files
=
d
.
entryList
(
QStringList
(
"*.desktop"
));
foreach
(
const
QString
&
plugin
,
files
)
{
foundPlugins
+=
d
.
absoluteFilePath
(
plugin
);
}
}
qDebug
()
<<
"Plugins found:"
<<
foundPlugins
;
m_plugins
=
KPluginInfo
::
fromFiles
(
foundPlugins
);
setSortRole
(
PriorityRole
);
foreach
(
const
KPluginInfo
&
info
,
m_plugins
)
{
// const KPluginInfo& info;
QStandardItem
*
item
=
new
QStandardItem
(
KIcon
(
info
.
icon
()),
info
.
name
());
QString
postfix
=
"kalgebra/plugins/"
+
info
.
pluginName
();
QString
scriptPath
=
KStandardDirs
::
locate
(
"data"
,
postfix
);
Q_ASSERT
(
!
scriptPath
.
isEmpty
());
QVariant
priority
=
info
.
property
(
"X-KAlgebra-Priority"
);
if
(
!
priority
.
isValid
())
priority
=
1000
;
item
->
setData
(
scriptPath
,
PathRole
);
item
->
setData
(
priority
,
PriorityRole
);
appendRow
(
item
);
}
setSortRole
(
PriorityRole
);
sort
(
0
);
}
QString
PluginsModel
::
pluginPath
(
int
row
)
{
return
data
(
index
(
row
,
0
),
PathRole
).
toString
();
}
mobile/pluginsmodel.h
0 → 100644
View file @
08fdd246
/*************************************************************************************
* Copyright (C) 2010 by Aleix Pol <aleixpol@kde.org> *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
* as published by the Free Software Foundation; either version 2 *
* of the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
*************************************************************************************/
#ifndef PLUGINSMODEL_H
#define PLUGINSMODEL_H
#include
<QStandardItemModel>
#include
<KPluginInfo>
class
PluginsModel
:
public
QStandardItemModel
{
Q_OBJECT
public:
enum
Roles
{
PathRole
=
Qt
::
UserRole
+
1
,
PriorityRole
};
explicit
PluginsModel
(
QObject
*
parent
=
0
);
public
slots
:
///qml can't access data. Yay!
QString
pluginPath
(
int
row
);
private:
KPluginInfo
::
List
m_plugins
;
};
#endif // PLUGINSMODEL_H
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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