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

palapeli/libpala

  • sources
  • kde-4.14
  • kdegames
  • palapeli
  • libpala
slicer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright 2009, 2010 Stefan Majewsky <majewsky@gmx.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***************************************************************************/
18 
19 #include "slicer.h"
20 #include "slicerjob.h"
21 #include "slicermode.h"
22 #include "slicerproperty.h"
23 
24 //BEGIN Pala::Slicer::Private
25 
26 class Pala::Slicer::Private
27 {
28  public:
29  QList<const Pala::SlicerMode*> m_modes;
30  QList<const Pala::SlicerProperty*> m_properties;
31  Pala::Slicer::SlicerFlags m_flags;
32 };
33 
34 //END Pala::Slicer::Private
35 
36 Pala::Slicer::Slicer(QObject* parent, const QVariantList& /*args*/)
37  : QObject(parent)
38  , p(new Private)
39 {
40  p->m_flags = NoFlags;
41 }
42 
43 Pala::Slicer::~Slicer()
44 {
45  qDeleteAll(p->m_modes);
46  qDeleteAll(p->m_properties);
47  delete p;
48 }
49 
50 QList<const Pala::SlicerMode*> Pala::Slicer::modes() const
51 {
52  return p->m_modes;
53 }
54 
55 QMap<QByteArray, const Pala::SlicerProperty*> Pala::Slicer::properties() const
56 {
57  QMap<QByteArray, const Pala::SlicerProperty*> result;
58  foreach (const Pala::SlicerProperty* property, p->m_properties)
59  result.insert(property->key(), property);
60  return result;
61 }
62 
63 QList<const Pala::SlicerProperty*> Pala::Slicer::propertyList() const
64 {
65  return p->m_properties;
66 }
67 
68 Pala::Slicer::SlicerFlags Pala::Slicer::flags() const
69 {
70  return p->m_flags;
71 }
72 
73 void Pala::Slicer::addProperty(const QByteArray& key, Pala::SlicerProperty* property)
74 {
75  //NOTE: This function is done such that it retains the insertion order in the list.
76  for (int i = 0; i < p->m_properties.size(); ++i)
77  {
78  if (p->m_properties[i] == property)
79  return;
80  if (p->m_properties[i]->key() == key)
81  {
82  delete p->m_properties.takeAt(i);
83  break;
84  }
85  }
86  p->m_properties << property;
87  property->setKey(key);
88 }
89 
90 void Pala::Slicer::addMode(Pala::SlicerMode* mode)
91 {
92  //NOTE: This one too. ;-)
93  for (int i = 0; i < p->m_modes.size(); ++i)
94  {
95  if (p->m_modes[i] == mode)
96  return;
97  if (p->m_modes[i]->key() == mode->key())
98  {
99  delete p->m_modes.takeAt(i);
100  break;
101  }
102  }
103  p->m_modes << mode;
104 }
105 
106 void Pala::Slicer::setFlags(Pala::Slicer::SlicerFlags flags)
107 {
108  p->m_flags = flags;
109 }
110 
111 bool Pala::Slicer::process(Pala::SlicerJob* job)
112 {
113  job->respectSlicerFlags(p->m_flags);
114  return run(job);
115 }
116 
117 #include "slicer.moc"
Pala::Slicer::NoFlags
Definition: slicer.h:69
slicer.h
Pala::Slicer::process
bool process(Pala::SlicerJob *job)
Definition: slicer.cpp:111
QByteArray
Pala::SlicerProperty::key
QByteArray key() const
Definition: slicerproperty.cpp:90
QMap
Pala::Slicer::properties
QMap< QByteArray, const Pala::SlicerProperty * > properties() const
Definition: slicer.cpp:55
Pala::Slicer::setFlags
void setFlags(SlicerFlags flags)
Definition: slicer.cpp:106
Pala::Slicer::~Slicer
virtual ~Slicer()
Deletes this slicer, and all properties and modes which have been added with addProperty() and addMod...
Definition: slicer.cpp:43
Pala::Slicer::Slicer
Slicer(QObject *parent=0, const QVariantList &args=QVariantList())
Constructs a new Slicer object.
Definition: slicer.cpp:36
Pala::SlicerJob::respectSlicerFlags
void respectSlicerFlags(int flags)
Definition: slicerjob.cpp:89
Pala::SlicerJob
Representation of a single run of a slicing algorithm.
Definition: slicerjob.h:46
Pala::SlicerMode
Representation of an operational mode of a slicing algorithm.
Definition: slicermode.h:46
Pala::Slicer::addMode
void addMode(Pala::SlicerMode *mode)
Add an operation mode to this slicer.
Definition: slicer.cpp:90
QObject
Pala::Slicer::flags
SlicerFlags flags() const
Definition: slicer.cpp:68
Pala::Slicer::addProperty
void addProperty(const QByteArray &key, Pala::SlicerProperty *property)
Add the given property to the property list of this slicer.
Definition: slicer.cpp:73
slicermode.h
QList
slicerproperty.h
slicerjob.h
Pala::Slicer::modes
QList< const Pala::SlicerMode * > modes() const
Definition: slicer.cpp:50
Pala::SlicerProperty::setKey
void setKey(const QByteArray &key)
Definition: slicerproperty.cpp:124
Pala::SlicerMode::key
QByteArray key() const
Definition: slicermode.cpp:57
QMap::insert
iterator insert(const Key &key, const T &value)
Pala::SlicerProperty
Representation of a single configurable parameter of a slicing algorithm.
Definition: slicerproperty.h:44
Pala::Slicer::propertyList
QList< const Pala::SlicerProperty * > propertyList() const
Definition: slicer.cpp:63
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:19:02 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

palapeli/libpala

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

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

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