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

kstars

  • sources
  • kde-4.12
  • kdeedu
  • kstars
  • kstars
  • tools
  • whatsinteresting
skyobjlistmodel.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  skyobjlistmodel.cpp - K Desktop Planetarium
3  -------------------
4  begin : 2012/26/05
5  copyright : (C) 2012 by Samikshan Bairagya
6  email : samikshan@gmail.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "skyobjlistmodel.h"
19 
20 SkyObjListModel::SkyObjListModel(SkyObjItem *soitem, QObject *parent): QAbstractListModel(parent)
21 {
22  setRoleNames(soitem->roleNames());
23 }
24 
25 void SkyObjListModel::addSkyObject(SkyObjItem *soitem)
26 {
27  beginInsertRows(QModelIndex(), rowCount(), rowCount());
28  m_SoItemList.append(soitem);
29  endInsertRows();
30 }
31 
32 int SkyObjListModel::rowCount(const QModelIndex& parent) const
33 {
34  return m_SoItemList.size();
35 }
36 
37 QVariant SkyObjListModel::data(const QModelIndex& index, int role) const
38 {
39  if (index.row() < 0 || index.row() > rowCount())
40  return QVariant();
41 
42  SkyObjItem *soitem = m_SoItemList[index.row()];
43 
44  return soitem->data(role);
45 }
46 
47 QList< SkyObjItem *> SkyObjListModel::getSkyObjItems()
48 {
49  return m_SoItemList;
50 }
51 
52 SkyObjItem* SkyObjListModel::getSkyObjItem(int index)
53 {
54  return m_SoItemList[index];
55 }
56 
57 void SkyObjListModel::resetModel()
58 {
59  m_SoItemList.clear();
60 }
SkyObjListModel::addSkyObject
void addSkyObject(SkyObjItem *sobj)
Add a sky-object to the model.
Definition: skyobjlistmodel.cpp:25
SkyObjItem
Represents an item in the list of interesting sky-objects.
Definition: skyobjitem.h:29
SkyObjListModel::resetModel
void resetModel()
Erase all data in model.
Definition: skyobjlistmodel.cpp:57
QAbstractListModel
SkyObjListModel::getSkyObjItem
SkyObjItem * getSkyObjItem(int index)
Get sky-object item referred to by index.
Definition: skyobjlistmodel.cpp:52
QObject
skyobjlistmodel.h
SkyObjListModel::getSkyObjItems
QList< SkyObjItem * > getSkyObjItems()
Get the list of sky-object items in the model.
Definition: skyobjlistmodel.cpp:47
SkyObjListModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Overriden method from QAbstractItemModel.
Definition: skyobjlistmodel.cpp:37
SkyObjItem::data
QVariant data(int role)
Get data associated with a particular role for the SkyObjItem.
Definition: skyobjitem.cpp:56
SkyObjListModel::rowCount
int rowCount(const QModelIndex &parent=QModelIndex()) const
Overridden method from QAbstractItemModel.
Definition: skyobjlistmodel.cpp:32
SkyObjItem::roleNames
QHash< int, QByteArray > roleNames() const
Create and return a QHash of rolenames for the SkyObjItem.
Definition: skyobjitem.cpp:71
SkyObjListModel::SkyObjListModel
SkyObjListModel(SkyObjItem *soitem=0, QObject *parent=0)
Constructor.
Definition: skyobjlistmodel.cpp:20
QList
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:36:21 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kstars

Skip menu "kstars"
  • 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