| 1 |
#ifndef XMPSOLVE_ROOTSMODEL_H |
| 2 |
#define XMPSOLVE_ROOTSMODEL_H |
| 3 |
|
| 4 |
#include <QAbstractListModel> |
| 5 |
#include "root.h" |
| 6 |
|
| 7 |
namespace xmpsolve { |
| 8 |
|
| 9 |
class RootsModel : public QAbstractListModel |
| 10 |
{ |
| 11 |
Q_OBJECT |
| 12 |
|
| 13 |
|
| 14 |
public: |
| 15 |
|
| 16 |
enum Roles { |
| 17 |
RADIUS = Qt::UserRole + 1, |
| 18 |
STATUS, |
| 19 |
SHORT_APPROXIMATION, |
| 20 |
ROOT, |
| 21 |
MARKED |
| 22 |
}; |
| 23 |
|
| 24 |
explicit RootsModel(QObject *parent = 0); |
| 25 |
|
| 26 |
Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const; |
| 27 |
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
| 28 |
|
| 29 |
QHash<int, QByteArray> roleNames() const; |
| 30 |
|
| 31 |
void setRoots(QList<Root*> roots); |
| 32 |
|
| 33 |
/** |
| 34 |
* @brief markRoot can be used to highlight an approximation. |
| 35 |
* @param i is the root to highlight, or -1 to clear any previous |
| 36 |
* highlighting. |
| 37 |
*/ |
| 38 |
Q_INVOKABLE void markRoot(int i = -1); |
| 39 |
|
| 40 |
double getPointX(int i) { return m_roots[i]->get_real_part(); } |
| 41 |
double getPointY(int i) { return m_roots[i]->get_imag_part(); } |
| 42 |
|
| 43 |
private: |
| 44 |
QList<Root*> m_roots; |
| 45 |
int m_length; |
| 46 |
int m_marked_root; |
| 47 |
|
| 48 |
signals: |
| 49 |
|
| 50 |
public slots: |
| 51 |
|
| 52 |
}; |
| 53 |
|
| 54 |
} // namespace xmpsolve |
| 55 |
|
| 56 |
#endif // XMPSOLVE_ROOTSMODEL_H |