• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

rocs/RocsCore

  • sources
  • kde-4.12
  • kdeedu
  • rocs
  • RocsCore
  • DataStructures
  • RootedTree
RootedTreePlugin.cpp
Go to the documentation of this file.
1 /*
2  This file is part of RootedTree (Rocs Plugin).
3  Copyright 2012 Wagner Reck <wagner.reck@gmail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License as
7  published by the Free Software Foundation; either version 2 of
8  the License, or (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "RootedTreePlugin.h"
20 
21 #include "RootedTreeStructure.h"
22 #include "RootedTreeNodeItem.h"
23 #include "RootedTreeEdgeItem.h"
24 
25 #include "Data.h"
26 
27 #include <KAboutData>
28 #include <KPluginFactory>
29 #include <knuminput.h>
30 #include <KMessageBox>
31 #include <KComboBox>
32 #include <QVBoxLayout>
33 #include <QCheckBox>
34 
35 
36 static const KAboutData aboutdata("rocs_RootedTreeStructure", 0, ki18nc("@title Displayed plugin name", "RootedTree Structure") , "0.1" );
37 using namespace Rocs;
38 
39 K_PLUGIN_FACTORY( DSPluginFactory, registerPlugin< RootedTreePlugin>(); )
40 K_EXPORT_PLUGIN( DSPluginFactory(aboutdata) )
41 
42 
43 RootedTreePlugin::RootedTreePlugin(QObject* parent, const QList< QVariant >& /*args*/ )
44  : DataStructureBackendInterface(DSPluginFactory::componentData(), parent)
45 {
46 }
47 
48 RootedTreePlugin::~RootedTreePlugin()
49 {
50 }
51 
52 DataStructurePtr RootedTreePlugin::convertToDataStructure(DataStructurePtr ds, Document * parent)
53 {
54  return RootedTreeStructure::create(ds, parent);
55 }
56 
57 DataStructurePtr RootedTreePlugin::createDataStructure ( Document* parent )
58 {
59  return RootedTreeStructure::create(parent);
60 }
61 
62 QGraphicsItem* RootedTreePlugin::dataItem(DataPtr node) const
63 {
64  return new RootedTreeNodeItem(node);
65 }
66 
67 QGraphicsItem* RootedTreePlugin::pointerItem(PointerPtr edge) const
68 {
69  return new RootedTreeEdgeItem(edge);
70 }
71 QLayout* RootedTreePlugin::dataExtraProperties(DataPtr /*node*/, QWidget* /*parentWidget*/) const
72 {
73  return 0;
74 }
75 
76 QLayout* RootedTreePlugin::pointerExtraProperties(PointerPtr arg1, QWidget* arg2) const
77 {
78  return DataStructureBackendInterface::pointerExtraProperties(arg1, arg2);
79 }
80 
81 QLayout* RootedTreePlugin::dataStructureExtraProperties(DataStructurePtr graph, QWidget* parentWidget) const
82 {
83 // if (!m_layout){
84  RootedTreeStructure * ds = qobject_cast< RootedTreeStructure* >(graph.get());
85  QVBoxLayout* layout = new QVBoxLayout(parentWidget);
86  QCheckBox * showPointer = new QCheckBox(i18nc("@option:check", "Show all pointers"),parentWidget);
87  layout->addWidget(showPointer);
88  connect(showPointer, SIGNAL(toggled(bool)), ds, SLOT(setShowAllPointers(bool)));
89  connect(ds, SIGNAL(showPointersChanged(bool)), showPointer, SLOT(setChecked(bool)));
90 // }
91 
92  showPointer->setChecked(ds->isShowingAllPointers());
93  return layout;
94 }
95 
96 
97 bool RootedTreePlugin::canConvertFrom(Document* doc) const
98 {
99  QStringList errors;
100  QSet<Data*> visited;
101  QSet<Data*> cycles;
102  QQueue<DataPtr> queue;
103  foreach (DataStructurePtr ds, doc->dataStructures()){
104  //FIXME only default data type considered
105  foreach(DataPtr p, ds->dataList(0)){
106  if (visited.contains(p.get())) {
107  continue;
108  }
109  visited.insert(p.get());
110  queue.enqueue(p);
111  while (!queue.isEmpty()){
112  DataPtr c = queue.dequeue();
113  foreach ( DataPtr n, c->adjacentDataList()){
114  if (visited.contains(n.get())){
115  if (!cycles.contains(n.get())){
116  errors << i18n("There are cycles at node %1. Data will be lost by conversion.", n->identifier());
117  cycles.insert(n.get());
118  }
119  }else{
120  queue.enqueue(n);
121  visited.insert(n.get());
122  }
123  }
124  }
125  }
126  }
127  if (!errors.isEmpty()){
128  if (KMessageBox::Continue != KMessageBox::warningContinueCancelList(0,
129  i18n("Cannot convert document \'%1\'", doc->name()),
130  errors))
131  {
132  return false;
133  }
134  }
135  return true;
136 }
RootedTreeStructure.h
RootedTreePlugin.h
DataStructurePtr
boost::shared_ptr< DataStructure > DataStructurePtr
Definition: CoreTypes.h:38
aboutdata
static const KAboutData aboutdata("rocs_RootedTreeStructure", 0, ki18nc("@title Displayed plugin name","RootedTree Structure"),"0.1")
RootedTreeStructure::isShowingAllPointers
bool isShowingAllPointers() const
return true if all the pointers need to be draw.
Definition: RootedTreeStructure.cpp:240
RootedTreeEdgeItem
the Edge drawing on screen. long explanation here...
Definition: RootedTreeEdgeItem.h:34
QObject
Data.h
Rocs::RootedTreePlugin::dataItem
virtual QGraphicsItem * dataItem(DataPtr) const
Definition: RootedTreePlugin.cpp:62
RootedTreeEdgeItem.h
RootedTreeStructure
Definition: RootedTreeStructure.h:27
PointerPtr
boost::shared_ptr< Pointer > PointerPtr
Definition: CoreTypes.h:35
Rocs::RootedTreePlugin::pointerItem
virtual QGraphicsItem * pointerItem(PointerPtr) const
Definition: RootedTreePlugin.cpp:67
Rocs::RootedTreePlugin::dataExtraProperties
virtual QLayout * dataExtraProperties(DataPtr arg1, QWidget *arg2) const
Definition: RootedTreePlugin.cpp:71
Rocs::RootedTreePlugin::createDataStructure
virtual DataStructurePtr createDataStructure(Document *parent)
Definition: RootedTreePlugin.cpp:57
RootedTreeNodeItem
Definition: RootedTreeNodeItem.h:27
Rocs::RootedTreePlugin::~RootedTreePlugin
virtual ~RootedTreePlugin()
Definition: RootedTreePlugin.cpp:48
Document
Definition: Document.h:41
Rocs::RootedTreePlugin
Definition: RootedTreePlugin.h:27
Rocs::RootedTreePlugin::dataStructureExtraProperties
virtual QLayout * dataStructureExtraProperties(DataStructurePtr graph, QWidget *parentWidget) const
Definition: RootedTreePlugin.cpp:81
Document::dataStructures
QList< DataStructurePtr > & dataStructures() const
Definition: Document.cpp:227
DataStructureBackendInterface::pointerExtraProperties
virtual QLayout * pointerExtraProperties(PointerPtr pointer, QWidget *widget) const
Definition: DataStructureBackendInterface.cpp:32
DataPtr
boost::shared_ptr< Data > DataPtr
Definition: CoreTypes.h:34
Rocs::RootedTreePlugin::convertToDataStructure
virtual DataStructurePtr convertToDataStructure(DataStructurePtr ds, Document *parent)
Definition: RootedTreePlugin.cpp:52
DataStructureBackendInterface
Definition: DataStructureBackendInterface.h:42
Rocs::RootedTreePlugin::pointerExtraProperties
virtual QLayout * pointerExtraProperties(PointerPtr arg1, QWidget *arg2) const
Definition: RootedTreePlugin.cpp:76
Document::name
QString name() const
Definition: Document.cpp:253
Rocs::RootedTreePlugin::canConvertFrom
bool canConvertFrom(Document *) const
Check if is possíble to convert from the doc document to this data structure.
Definition: RootedTreePlugin.cpp:97
RootedTreeStructure::create
static DataStructurePtr create(Document *parent)
Definition: RootedTreeStructure.cpp:45
RootedTreeNodeItem.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

rocs/RocsCore

Skip menu "rocs/RocsCore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal