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

kalgebra

  • sources
  • kde-4.14
  • kdeedu
  • kalgebra
  • src
variablesdelegate.cpp
Go to the documentation of this file.
1 /*************************************************************************************
2  * Copyright (C) 2009 by Aleix Pol <aleixpol@kde.org> *
3  * *
4  * This program is free software; you can redistribute it and/or *
5  * modify it under the terms of the GNU General Public License *
6  * as published by the Free Software Foundation; either version 2 *
7  * of the License, or (at your option) any later version. *
8  * *
9  * This program 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 General Public License for more details. *
13  * *
14  * You should have received a copy of the GNU 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 "variablesdelegate.h"
20 
21 #include <QDoubleSpinBox>
22 
23 QWidget* VariablesDelegate::createEditor(QWidget* p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const
24 {
25  QVariant val=idx.model()->data(idx);
26  if(val.type()==QVariant::Double) {
27  QDoubleSpinBox* spin=new QDoubleSpinBox(p);
28  spin->setDecimals(10);
29  return spin;
30  } else
31  return QItemDelegate::createEditor(p, opt, idx);
32 }
33 
34 void VariablesDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const
35 {
36  QDoubleSpinBox* spin=qobject_cast<QDoubleSpinBox*>(editor);
37  if(spin)
38  spin->setValue(index.model()->data(index).value<double>());
39  else
40  QItemDelegate::setEditorData(editor, index);
41 }
QModelIndex
VariablesDelegate::createEditor
virtual QWidget * createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const
Definition: variablesdelegate.cpp:23
QWidget
VariablesDelegate::setEditorData
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
Definition: variablesdelegate.cpp:34
QVariant::value
T value() const
QDoubleSpinBox
QItemDelegate::setEditorData
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const
QStyleOptionViewItem
QDoubleSpinBox::setDecimals
void setDecimals(int prec)
QDoubleSpinBox::setValue
void setValue(double val)
QAbstractItemModel::data
virtual QVariant data(const QModelIndex &index, int role) const =0
QItemDelegate::createEditor
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
variablesdelegate.h
QModelIndex::model
const QAbstractItemModel * model() const
QVariant::type
Type type() const
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:49 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalgebra

Skip menu "kalgebra"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • 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