labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Spreadsheet Class Reference

Aspect providing a spreadsheet table with column logic. More...

#include <Spreadsheet.h>

Inheritance diagram for Spreadsheet:
[legend]
Collaboration diagram for Spreadsheet:
[legend]

Public Slots

void appendRows (int)
 
void appendRow ()
 
void appendColumns (int)
 
void appendColumn ()
 
void prependColumns (int)
 
void setColumnCount (int)
 
void setRowCount (int)
 
void clear ()
 
void clearMasks ()
 
void moveColumn (int from, int to)
 
void sortColumns (Column *leading, const QVector< Column * > &, bool ascending)
 
- Public Slots inherited from AbstractAspect
bool setName (const QString &, bool autoUnique=true)
 AbstractAspect::setName sets the name of the abstract aspect. More...
 
void setComment (const QString &)
 
void remove ()
 Remove me from my parent's list of children. More...
 

Signals

void requestProjectContextMenu (QMenu *)
 
void columnSelected (int)
 
void columnDeselected (int)
 
void rowCountChanged (int)
 
void columnCountChanged (int)
 
- Signals inherited from AbstractPart
void showRequested ()
 
void importFromFileRequested ()
 
void importFromSQLDatabaseRequested ()
 
void exportRequested ()
 
void printRequested ()
 
void printPreviewRequested ()
 
- Signals inherited from AbstractAspect
void aspectDescriptionAboutToChange (const AbstractAspect *)
 Emitted before the name, comment or caption spec is changed. More...
 
void aspectDescriptionChanged (const AbstractAspect *)
 Emitted after the name, comment or caption spec have changed. More...
 
void aspectAboutToBeAdded (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted before a new child is inserted. More...
 
void aspectAdded (const AbstractAspect *)
 Emitted after a new Aspect has been added to the tree. More...
 
void aspectAboutToBeRemoved (const AbstractAspect *)
 Emitted before an aspect is removed from its parent. More...
 
void aspectRemoved (const AbstractAspect *parent, const AbstractAspect *before, const AbstractAspect *child)
 Emitted from the parent after removing a child. More...
 
void aspectHiddenAboutToChange (const AbstractAspect *)
 Emitted before the hidden attribute is changed. More...
 
void aspectHiddenChanged (const AbstractAspect *)
 Emitted after the hidden attribute has changed. More...
 
void statusInfo (const QString &)
 Emitted whenever some aspect in the tree wants to give status information to the user. More...
 
void renameRequested ()
 
void selected (const AbstractAspect *)
 
void deselected (const AbstractAspect *)
 
void childAspectSelectedInView (const AbstractAspect *)
 
void childAspectDeselectedInView (const AbstractAspect *)
 

Public Member Functions

 Spreadsheet (const QString &name, bool loading=false, AspectType type=AspectType::Spreadsheet)
 
QIcon icon () const override
 
QMenu * createContextMenu () override
 
QWidget * view () const override
 
bool exportView () const override
 
bool printView () override
 
bool printPreview () const override
 
void setModel (SpreadsheetModel *)
 
SpreadsheetModelmodel ()
 
void updateHorizontalHeader ()
 
void updateLocale ()
 
int columnCount () const
 
int columnCount (AbstractColumn::PlotDesignation) const
 
Columncolumn (int index) const
 
Columncolumn (const QString &) const
 
int rowCount () const
 
void removeRows (int first, int count)
 
void insertRows (int before, int count)
 
void removeColumns (int first, int count)
 
void insertColumns (int before, int count)
 
int colX (int col)
 
int colY (int col)
 
QString text (int row, int col) const
 
void copy (Spreadsheet *other)
 
void save (QXmlStreamWriter *) const override
 
bool load (XmlStreamReader *, bool preview) override
 
void setColumnSelectedInView (int index, bool selected)
 
void emitRowCountChanged ()
 
void emitColumnCountChanged ()
 
int prepareImport (std::vector< void * > &dataContainer, AbstractFileFilter::ImportMode, int rows, int cols, QStringList colNameList, QVector< AbstractColumn::ColumnMode >) override
 
void finalizeImport (int columnOffset, int startColumn, int endColumn, const QString &dateTimeFormat, AbstractFileFilter::ImportMode) override
 
int resize (AbstractFileFilter::ImportMode, QStringList colNameList, int cols)
 
- Public Member Functions inherited from AbstractDataSource
 AbstractDataSource (const QString &name, AspectType type)
 
 ~AbstractDataSource () override=default
 
void clear ()
 
- Public Member Functions inherited from AbstractPart
 AbstractPart (const QString &name, AspectType type)
 
 ~AbstractPart () override
 
void deleteView () const
 
PartMdiViewmdiSubWindow () const
 Wrap the view() into a PartMdiView. More...
 
bool hasMdiSubWindow () const
 
bool isDraggable () const override
 
QVector< AspectTypedropableOn () const override
 
virtual void registerShortcuts ()
 
virtual void unregisterShortcuts ()
 
- Public Member Functions inherited from AbstractAspect
 AbstractAspect (const QString &name, AspectType type)
 
 ~AbstractAspect () override
 
QString name () const
 
QString comment () const
 
void setCreationTime (const QDateTime &)
 
QDateTime creationTime () const
 
virtual Projectproject ()
 Return the Project this Aspect belongs to, or 0 if it is currently not part of one. More...
 
virtual QString path () const
 Return the path that leads from the top-most Aspect (usually a Project) to me. More...
 
void setHidden (bool)
 Set "hidden" property, i.e. whether to exclude this aspect from being shown in the explorer. More...
 
bool hidden () const
 
void setIsLoading (bool)
 
bool isLoading () const
 
AspectType type () const
 
bool inherits (AspectType type) const
 
AbstractAspectparentAspect () const
 Return my parent Aspect or 0 if I currently don't have one. More...
 
AbstractAspectparent (AspectType type) const
 In the parent-child hierarchy, return the first parent of type. More...
 
void setParentAspect (AbstractAspect *)
 
Folderfolder ()
 Return the folder the Aspect is contained in or 0 if there is none. More...
 
bool isDescendantOf (AbstractAspect *other)
 Return whether the there is a path upwards to the given aspect. More...
 
void addChild (AbstractAspect *)
 Add the given Aspect to my list of children. More...
 
void addChildFast (AbstractAspect *)
 Add the given Aspect to my list of children without any checks and without putting this step onto the undo-stack. More...
 
virtual void finalizeAdd ()
 
QVector< AbstractAspect * > children (AspectType type, ChildIndexFlags flags={}) const
 
void insertChildBefore (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children. More...
 
void insertChildBeforeFast (AbstractAspect *child, AbstractAspect *before)
 Insert the given Aspect at a specific position in my list of children.without any checks and without putting this step onto the undo-stack. More...
 
void reparent (AbstractAspect *newParent, int newIndex=-1)
 Move a child to another parent aspect and transfer ownership. More...
 
void removeChild (AbstractAspect *)
 Remove the given Aspect from my list of children. More...
 
void removeAllChildren ()
 Remove all child Aspects. More...
 
virtual QVector< AbstractAspect * > dependsOn () const
 
virtual void processDropEvent (const QVector< quintptr > &)
 
template<class T >
T * ancestor () const
 Return the closest ancestor of class T (or NULL if none found). More...
 
template<class T >
QVector< T * > children (ChildIndexFlags flags={}) const
 
template<class T >
T * child (int index, ChildIndexFlags flags={}) const
 
template<class T >
T * child (const QString &name) const
 Get child by name and class. More...
 
template<class T >
int childCount (ChildIndexFlags flags={}) const
 Return the number of child Aspects inheriting from given class. More...
 
template<class T >
int indexOfChild (const AbstractAspect *child, ChildIndexFlags flags={}) const
 Return (0 based) index of child in the list of children inheriting from class T. More...
 
void setSelected (bool)
 
void setUndoAware (bool)
 
virtual QUndoStack * undoStack () const
 Return the undo stack of the Project, or 0 if this Aspect is not part of a Project. More...
 
void exec (QUndoCommand *)
 Execute the given command, pushing it on the undoStack() if available. More...
 
void exec (QUndoCommand *command, const char *preChangeSignal, const char *postChangeSignal, QGenericArgument val0=QGenericArgument(), QGenericArgument val1=QGenericArgument(), QGenericArgument val2=QGenericArgument(), QGenericArgument val3=QGenericArgument())
 Execute command and arrange for signals to be sent before/after it is redone or undone. More...
 
void beginMacro (const QString &text)
 Begin an undo stack macro (series of commands) More...
 
void endMacro ()
 End the current undo stack macro. More...
 

Protected Attributes

SpreadsheetViewm_view {nullptr}
 
- Protected Attributes inherited from AbstractPart
QWidget * m_partView {nullptr}
 
- Protected Attributes inherited from AbstractAspect
const AspectType m_type
 

Private Slots

void childSelected (const AbstractAspect *) override
 
void childDeselected (const AbstractAspect *) override
 

Private Member Functions

void init ()
 

Private Attributes

SpreadsheetModelm_model {nullptr}
 

Additional Inherited Members

- Public Types inherited from AbstractAspect
enum class  ChildIndexFlag { IncludeHidden = 0x01 , Recursive = 0x02 , Compress = 0x04 }
 Flags which control numbering scheme of children. More...
 
- Protected Slots inherited from AbstractAspect
virtual void childSelected (const AbstractAspect *)
 
virtual void childDeselected (const AbstractAspect *)
 
- Protected Member Functions inherited from AbstractAspect
void info (const QString &text)
 Implementations should call this whenever status information should be given to the user. More...
 
bool readBasicAttributes (XmlStreamReader *)
 Load name and creation time from XML. More...
 
void writeBasicAttributes (QXmlStreamWriter *) const
 Save name and creation time to XML. More...
 
void writeCommentElement (QXmlStreamWriter *) const
 Save the comment to XML. More...
 
bool readCommentElement (XmlStreamReader *)
 Load comment from an XML element. More...
 

Detailed Description

Aspect providing a spreadsheet table with column logic.

File : Spreadsheet.cpp Project : LabPlot

Description : Aspect providing a spreadsheet table with column logic

Copyright : (C) 2006-2008 Tilman Benkert (thzs@.nosp@m.gmx..nosp@m.net) Copyright : (C) 2006-2009 Knut Franke (knut..nosp@m.fran.nosp@m.ke@gm.nosp@m.x.de) Copyright : (C) 2012-2019 Alexander Semke (alexa.nosp@m.nder.nosp@m..semk.nosp@m.e@we.nosp@m.b.de) Copyright : (C) 2017-2020 Stefan Gerlach (stefa.nosp@m.n.ge.nosp@m.rlach.nosp@m.@uni.nosp@m..kn)

  • 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 *

Spreadsheet is a container object for columns with no data of its own. By definition, it's columns are all of its children inheriting from class Column. Thus, the basic API is already defined by AbstractAspect (managing the list of columns, notification of column insertion/removal) and Column (changing and monitoring state of the actual data).

Spreadsheet stores a pointer to its primary view of class SpreadsheetView. SpreadsheetView calls the Spreadsheet API but Spreadsheet only notifies SpreadsheetView by signals without calling its API directly. This ensures a maximum independence of UI and backend. SpreadsheetView can be easily replaced by a different class. User interaction is completely handled in SpreadsheetView and translated into Spreadsheet API calls (e.g., when a user edits a cell this will be handled by the delegate of SpreadsheetView and Spreadsheet will not know whether a script or a user changed the data.). All actions, menus etc. for the user interaction are handled SpreadsheetView, e.g., via a context menu. Selections are also handled by SpreadsheetView. The view itself is created by the first call to view();

Definition at line 40 of file Spreadsheet.h.

Constructor & Destructor Documentation

◆ Spreadsheet()

Spreadsheet::Spreadsheet ( const QString &  name,
bool  loading = false,
AspectType  type = AspectType::Spreadsheet 
)
explicit

Definition at line 68 of file Spreadsheet.cpp.

References init().

Member Function Documentation

◆ appendColumn

void Spreadsheet::appendColumn ( )
slot

Definition at line 180 of file Spreadsheet.cpp.

References columnCount(), and insertColumns().

◆ appendColumns

void Spreadsheet::appendColumns ( int  count)
slot

Definition at line 176 of file Spreadsheet.cpp.

References columnCount(), and insertColumns().

◆ appendRow

void Spreadsheet::appendRow ( )
slot

Definition at line 172 of file Spreadsheet.cpp.

References insertRows(), and rowCount().

◆ appendRows

void Spreadsheet::appendRows ( int  count)
slot

◆ childDeselected

void Spreadsheet::childDeselected ( const AbstractAspect aspect)
overrideprivateslot

This slot is, indirectly, called when a child of Spreadsheet (i.e. column) was deselected in ProjectExplorer. Emits the signal columnDeselected that is handled in SpreadsheetView.

Definition at line 784 of file Spreadsheet.cpp.

References column(), and columnDeselected().

◆ childSelected

void Spreadsheet::childSelected ( const AbstractAspect aspect)
overrideprivateslot

This slot is, indirectly, called when a child of Spreadsheet (i.e. column) was selected in ProjectExplorer. Emits the signal columnSelected that is handled in SpreadsheetView.

Definition at line 772 of file Spreadsheet.cpp.

References column(), and columnSelected().

◆ clear

void Spreadsheet::clear ( )
slot

◆ clearMasks

void Spreadsheet::clearMasks ( )
slot

Clears all mask in the spreadsheet.

Definition at line 285 of file Spreadsheet.cpp.

References AbstractAspect::beginMacro(), AbstractAspect::endMacro(), i18n, AbstractAspect::name(), RESET_CURSOR, and WAIT_CURSOR.

Referenced by SpreadsheetView::connectActions().

◆ column() [1/2]

Column * Spreadsheet::column ( const QString &  name) const

Returns the column with the name name.

Definition at line 210 of file Spreadsheet.cpp.

References AbstractAspect::name().

◆ column() [2/2]

◆ columnCount() [1/2]

◆ columnCount() [2/2]

int Spreadsheet::columnCount ( AbstractColumn::PlotDesignation  pd) const

Returns the number of columns matching the given designation.

Definition at line 224 of file Spreadsheet.cpp.

◆ columnCountChanged

void Spreadsheet::columnCountChanged ( int  )
signal

◆ columnDeselected

void Spreadsheet::columnDeselected ( int  )
signal

◆ columnSelected

void Spreadsheet::columnSelected ( int  )
signal

◆ colX()

int Spreadsheet::colX ( int  col)

Determines the corresponding X column.

Definition at line 341 of file Spreadsheet.cpp.

References column(), columnCount(), and AbstractColumn::X.

◆ colY()

int Spreadsheet::colY ( int  col)

Determines the corresponding Y column.

Definition at line 357 of file Spreadsheet.cpp.

References column(), columnCount(), AbstractColumn::XError, AbstractColumn::Y, and AbstractColumn::YError.

◆ copy()

◆ createContextMenu()

QMenu * Spreadsheet::createContextMenu ( )
overridevirtual

Returns a new context menu. The caller takes ownership of the menu.

Reimplemented from AbstractPart.

Definition at line 297 of file Spreadsheet.cpp.

References AbstractPart::createContextMenu(), and requestProjectContextMenu().

◆ emitColumnCountChanged()

void Spreadsheet::emitColumnCountChanged ( )
inline

◆ emitRowCountChanged()

void Spreadsheet::emitRowCountChanged ( )
inline

◆ exportView()

bool Spreadsheet::exportView ( ) const
overridevirtual

Implements AbstractPart.

Definition at line 114 of file Spreadsheet.cpp.

References SpreadsheetView::exportView(), and m_view.

Referenced by Workbook::exportView(), and Datapicker::exportView().

◆ finalizeImport()

◆ icon()

QIcon Spreadsheet::icon ( ) const
overridevirtual

Returns an icon to be used for decorating my views.

Reimplemented from AbstractAspect.

Definition at line 753 of file Spreadsheet.cpp.

◆ init()

void Spreadsheet::init ( )
private

initializes the spreadsheet with the default number of columns and rows

Definition at line 78 of file Spreadsheet.cpp.

References AbstractAspect::addChild(), Column, AbstractColumn::Numeric, Column::setPlotDesignation(), setRowCount(), AbstractColumn::X, and AbstractColumn::Y.

Referenced by Spreadsheet().

◆ insertColumns()

◆ insertRows()

◆ load()

◆ model()

SpreadsheetModel * Spreadsheet::model ( )

Definition at line 97 of file Spreadsheet.cpp.

References m_model.

Referenced by setModel().

◆ moveColumn

◆ prepareImport()

◆ prependColumns

void Spreadsheet::prependColumns ( int  count)
slot

Definition at line 184 of file Spreadsheet.cpp.

References insertColumns().

◆ printPreview()

bool Spreadsheet::printPreview ( ) const
overridevirtual

Implements AbstractPart.

Definition at line 122 of file Spreadsheet.cpp.

References m_view, and SpreadsheetView::printPreview().

Referenced by Workbook::printPreview(), and Datapicker::printPreview().

◆ printView()

bool Spreadsheet::printView ( )
overridevirtual

Implements AbstractPart.

Definition at line 118 of file Spreadsheet.cpp.

References m_view, and SpreadsheetView::printView().

Referenced by Workbook::printView(), and Datapicker::printView().

◆ removeColumns()

void Spreadsheet::removeColumns ( int  first,
int  count 
)

◆ removeRows()

void Spreadsheet::removeRows ( int  first,
int  count 
)

◆ requestProjectContextMenu

void Spreadsheet::requestProjectContextMenu ( QMenu *  )
signal

◆ resize()

int Spreadsheet::resize ( AbstractFileFilter::ImportMode  mode,
QStringList  colNameList,
int  cols 
)

◆ rowCount()

◆ rowCountChanged

void Spreadsheet::rowCountChanged ( int  )
signal

◆ save()

void Spreadsheet::save ( QXmlStreamWriter *  writer) const
overridevirtual

◆ setColumnCount

void Spreadsheet::setColumnCount ( int  new_size)
slot

Sets the number of columns to new_size

Definition at line 259 of file Spreadsheet.cpp.

References columnCount(), insertColumns(), and removeColumns().

Referenced by LiveDataSource::load(), MQTTTopic::load(), load(), and OriginProjectParser::loadSpreadsheet().

◆ setColumnSelectedInView()

void Spreadsheet::setColumnSelectedInView ( int  index,
bool  selected 
)

Emits the signal to select or to deselect the column number index in the project explorer, if selected=true or selected=false, respectively. The signal is handled in AspectTreeModel and forwarded to the tree view in ProjectExplorer. This function is called in SpreadsheetView upon selection changes.

Definition at line 798 of file Spreadsheet.cpp.

References AbstractAspect::childAspectDeselectedInView(), AbstractAspect::childAspectSelectedInView(), AbstractAspect::parent(), AbstractAspect::parentAspect(), and AbstractAspect::selected().

Referenced by SpreadsheetView::columnClicked(), and SpreadsheetView::selectionChanged().

◆ setModel()

void Spreadsheet::setModel ( SpreadsheetModel model)

Definition at line 93 of file Spreadsheet.cpp.

References m_model, and model().

Referenced by SpreadsheetModel::SpreadsheetModel().

◆ setRowCount

◆ sortColumns

◆ text()

QString Spreadsheet::text ( int  row,
int  col 
) const

Returns the text displayed in the given cell.

Definition at line 760 of file Spreadsheet.cpp.

References Column::asStringColumn(), column(), and ColumnStringIO::textAt().

Referenced by SpreadsheetView::print().

◆ updateHorizontalHeader()

void Spreadsheet::updateHorizontalHeader ( )

Definition at line 126 of file Spreadsheet.cpp.

References m_model, and SpreadsheetModel::updateHorizontalHeader().

Referenced by MainWin::handleSettingsChanges().

◆ updateLocale()

void Spreadsheet::updateLocale ( )

Definition at line 130 of file Spreadsheet.cpp.

◆ view()

QWidget * Spreadsheet::view ( ) const
overridevirtual

Constructs a primary view on me. This method may be called multiple times during the life time of an Aspect, or it might not get called at all. Aspects must not depend on the existence of a view for their operation.

Implements AbstractPart.

Definition at line 105 of file Spreadsheet.cpp.

References DatapickerCurve, AbstractPart::m_partView, m_view, AbstractAspect::parentAspect(), and AbstractAspect::type().

Referenced by SpreadsheetDock::load(), SpreadsheetDock::loadConfig(), and PlotDataDialog::processColumns().

Member Data Documentation

◆ m_model

SpreadsheetModel* Spreadsheet::m_model {nullptr}
private

Definition at line 111 of file Spreadsheet.h.

Referenced by finalizeImport(), model(), prepareImport(), setModel(), and updateHorizontalHeader().

◆ m_view

SpreadsheetView* Spreadsheet::m_view {nullptr}
mutableprotected

The documentation for this class was generated from the following files: