OpenStructure
Loading...
Searching...
No Matches
sequence_model.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef OST_SEQUENCE_VIEWER_SEQUENCE_MODEL
20#define OST_SEQUENCE_VIEWER_SEQUENCE_MODEL
21
22/*
23 Author: Stefan Scheuber
24 */
25
26#ifndef Q_MOC_RUN
27
28#include <ost/mol/chain_view.hh>
29
32
33#include <ost/gfx/entity.hh>
34
35#include "base_view_object.hh"
38
39#include <QAbstractTableModel>
40#include <QItemSelection>
41#endif
42
43namespace ost { namespace gui {
44
45class SequenceModel : public QAbstractTableModel
46{
47 Q_OBJECT
48
49public:
50 SequenceModel(QObject *parent = 0);
51
52 void InsertAlignment(const seq::AlignmentHandle& alignment);
53 void InsertGfxEntity(const gfx::EntityP& entity);
54 void InsertChain(QString& name, mol::ChainView& view);
55 void InsertSequence(QString& name, seq::SequenceHandle& seq);
56 void InsertSequences(const QList<QString>& names, seq::SequenceList& list);
57
58 void RemoveAlignment(const seq::AlignmentHandle& alignment);
59 void RemoveGfxEntity(const gfx::EntityP& entity);
60
61 QModelIndexList GetModelIndexes(gfx::EntityP& entity, const mol::EntityView& view);
62 QModelIndexList GetModelIndexes(const QString& subject, const QString& sequence_name=QString());
63
64 int GetGlobalRow(BaseViewObject* obj, int row) const;
65
66 const QStringList& GetDisplayModes();
67 const QStringList& GetDisplayModes(const gfx::EntityP& entity);
68 const QStringList& GetDisplayModes(const seq::AlignmentHandle& alignment);
69 const QString& GetCurrentDisplayMode();
70 const QString& GetCurrentDisplayMode(const gfx::EntityP& entity);
71 const QString& GetCurrentDisplayMode(const seq::AlignmentHandle& alignment);
72 void SetDisplayMode(const QString& mode);
73 void SetDisplayMode(const gfx::EntityP& entity, const QString& mode);
74 void SetDisplayMode(const seq::AlignmentHandle& alignment, const QString& mode);
75
76 const PainterList& GetPainters(const QModelIndex& index) const;
77
78 // abstract item model interface
79 int rowCount(const QModelIndex& parent=QModelIndex()) const;
80
81 int columnCount(const QModelIndex& parent=QModelIndex()) const;
82
83 QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const;
84
85 QVariant headerData(int section, Qt::Orientation orientation,
86 int role=Qt::DisplayRole) const;
87
88 virtual Qt::ItemFlags flags(const QModelIndex& index=QModelIndex()) const;
89 QPair<seq::AlignmentHandle, int> GetAlignmentForRow(int row);
90
91 void EmitRowChanged(int row);
92
93 void Clear();
94public slots:
95 void ZoomIn();
96 void ZoomOut();
97 void DoubleClicked(const QModelIndex& index);
98 void SelectionChanged(const QItemSelection& sel, const QItemSelection& desel);
99private:
100 int GetColumnCount() const;
101 SequenceViewObject* GetItem(const gfx::EntityP& entity);
102 AlignmentViewObject* GetItem(const seq::AlignmentHandle& alignment);
103 BaseViewObject* GetItem(const QModelIndex& index) const;
104 QPair<int, BaseViewObject*> GetRowWithItem(int row) const;
105 QPair<int, BaseViewObject*> GetRowWithItem(const QModelIndex& index) const;
106
107 QList<BaseViewObject*> objects_;
108 int max_columns;
109 PainterList empty_painter_list_;
110 QString empty_string_;
111 QStringList empty_string_list_;
112 QStringList display_modes_;
113 QString current_display_mode_;
114};
115
116
117}}
118
119#endif
void SelectionChanged(const QItemSelection &sel, const QItemSelection &desel)
void InsertChain(QString &name, mol::ChainView &view)
virtual Qt::ItemFlags flags(const QModelIndex &index=QModelIndex()) const
SequenceModel(QObject *parent=0)
const QStringList & GetDisplayModes(const seq::AlignmentHandle &alignment)
void SetDisplayMode(const seq::AlignmentHandle &alignment, const QString &mode)
void InsertAlignment(const seq::AlignmentHandle &alignment)
void RemoveGfxEntity(const gfx::EntityP &entity)
int columnCount(const QModelIndex &parent=QModelIndex()) const
void SetDisplayMode(const gfx::EntityP &entity, const QString &mode)
const PainterList & GetPainters(const QModelIndex &index) const
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
const QStringList & GetDisplayModes(const gfx::EntityP &entity)
const QString & GetCurrentDisplayMode(const gfx::EntityP &entity)
int GetGlobalRow(BaseViewObject *obj, int row) const
QModelIndexList GetModelIndexes(const QString &subject, const QString &sequence_name=QString())
void SetDisplayMode(const QString &mode)
const QStringList & GetDisplayModes()
const QString & GetCurrentDisplayMode(const seq::AlignmentHandle &alignment)
void EmitRowChanged(int row)
void DoubleClicked(const QModelIndex &index)
int rowCount(const QModelIndex &parent=QModelIndex()) const
QPair< seq::AlignmentHandle, int > GetAlignmentForRow(int row)
void InsertGfxEntity(const gfx::EntityP &entity)
const QString & GetCurrentDisplayMode()
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
void InsertSequences(const QList< QString > &names, seq::SequenceList &list)
void RemoveAlignment(const seq::AlignmentHandle &alignment)
void InsertSequence(QString &name, seq::SequenceHandle &seq)
QModelIndexList GetModelIndexes(gfx::EntityP &entity, const mol::EntityView &view)
definition of ChainView
Definition chain_view.hh:37
definition of EntityView
representation of a multiple sequence alignemnt consisting of two or more sequences
mutable sequence handle.
list of sequences.
boost::shared_ptr< Entity > EntityP
Definition entity_fw.hh:28
QList< Painter * > PainterList
Definition painter.hh:48
Definition base.dox:1