| 1 |
/****************************************************************************** |
| 2 |
This source file is part of the Avogadro project. |
| 3 |
This source code is released under the 3-Clause BSD License, (see "LICENSE"). |
| 4 |
******************************************************************************/ |
| 5 |
|
| 6 |
#ifndef MOLECULARMODEL_H |
| 7 |
#define MOLECULARMODEL_H |
| 8 |
|
| 9 |
#include <QtCore/QAbstractTableModel> |
| 10 |
#include <QtCore/QList> |
| 11 |
#include <QtCore/QObject> |
| 12 |
#include <QtCore/QString> |
| 13 |
|
| 14 |
#include <avogadro/core/variantmap.h> |
| 15 |
#include <avogadro/qtgui/rwmolecule.h> |
| 16 |
|
| 17 |
namespace Avogadro { |
| 18 |
|
| 19 |
namespace QtGui { |
| 20 |
class Molecule; |
| 21 |
} |
| 22 |
|
| 23 |
enum FixedRowType |
| 24 |
{ |
| 25 |
Name = 0, |
| 26 |
Mass, |
| 27 |
Formula, |
| 28 |
Atoms, |
| 29 |
Bonds |
| 30 |
// these are the fixed rows |
| 31 |
}; |
| 32 |
|
| 33 |
namespace QtPlugins { |
| 34 |
|
| 35 |
class MolecularModel : public QAbstractTableModel |
| 36 |
{ |
| 37 |
Q_OBJECT |
| 38 |
|
| 39 |
public slots: |
| 40 |
void updateTable(unsigned int flags); |
| 41 |
|
| 42 |
public: |
| 43 |
explicit MolecularModel(QObject* parent = nullptr); |
| 44 |
|
| 45 |
int rowCount(const QModelIndex& parent = QModelIndex()) const override; |
| 46 |
int columnCount(const QModelIndex& parent = QModelIndex()) const override; |
| 47 |
QVariant data(const QModelIndex& index, int role) const override; |
| 48 |
Qt::ItemFlags flags(const QModelIndex& index) const override; |
| 49 |
bool setData(const QModelIndex& index, const QVariant& value, |
| 50 |
int role = Qt::EditRole) override; |
| 51 |
QVariant headerData(int section, Qt::Orientation orientation, |
| 52 |
int role = Qt::DisplayRole) const override; |
| 53 |
|
| 54 |
void setMolecule(QtGui::Molecule* molecule); |
| 55 |
|
| 56 |
QString name() const; |
| 57 |
|
| 58 |
private: |
| 59 |
QtGui::Molecule* m_molecule = nullptr; |
| 60 |
Core::VariantMap m_propertiesCache; |
| 61 |
}; |
| 62 |
|
| 63 |
} // namespace QtPlugins |
| 64 |
} // end namespace Avogadro |
| 65 |
|
| 66 |
#endif |