From f3ce5fc47c50c193f6adbd48dcfeb5c6b7185750 Mon Sep 17 00:00:00 2001 From: stefan <stefan@5a81b35b-ba03-0410-adc8-b2c5c5119f08> Date: Wed, 5 May 2010 13:27:03 +0000 Subject: [PATCH] new SequenceViewer, renamed row to baserow git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2175 5a81b35b-ba03-0410-adc8-b2c5c5119f08 --- modules/gui/src/CMakeLists.txt | 6 +-- .../gui/src/sequence/{row.cc => base_row.cc} | 38 ++++++++++++++----- .../gui/src/sequence/{row.hh => base_row.hh} | 13 +++++-- modules/gui/src/sequence/view_object.cc | 10 ++--- modules/gui/src/sequence/view_object.hh | 18 ++++----- 5 files changed, 54 insertions(+), 31 deletions(-) rename modules/gui/src/sequence/{row.cc => base_row.cc} (67%) rename modules/gui/src/sequence/{row.hh => base_row.hh} (81%) diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt index 4bba75bb2..b8443780c 100644 --- a/modules/gui/src/CMakeLists.txt +++ b/modules/gui/src/CMakeLists.txt @@ -22,7 +22,7 @@ sequence_search_bar.hh set(OST_GUI_SEQUENCE_VIEW_HEADERS painter.hh -row.hh +base_row.hh seq_secstr_painter.hh seq_selection_painter.hh seq_text_painter.hh @@ -206,7 +206,7 @@ sequence_viewer/sequence_viewer_base.cc sequence_viewer/sequence_viewer.cc sequence_viewer/sequence_scene.cc sequence_viewer/sequence_search_bar.cc -sequence/row.cc +sequence/base_row.cc sequence/seq_secstr_painter.cc sequence/seq_selection_painter.cc sequence/seq_text_painter.cc @@ -332,7 +332,7 @@ sequence_viewer/sequence_viewer.hh sequence_viewer/sequence_scene.hh sequence_viewer/sequence_search_bar.hh sequence/painter.hh -sequence/row.hh +sequence/base_row.hh sequence/seq_secstr_painter.hh sequence/seq_selection_painter.hh sequence/seq_text_painter.hh diff --git a/modules/gui/src/sequence/row.cc b/modules/gui/src/sequence/base_row.cc similarity index 67% rename from modules/gui/src/sequence/row.cc rename to modules/gui/src/sequence/base_row.cc index a109fe98c..823b4f86b 100644 --- a/modules/gui/src/sequence/row.cc +++ b/modules/gui/src/sequence/base_row.cc @@ -24,42 +24,42 @@ #include <QtGui> -#include "row.hh" +#include "base_row.hh" namespace ost { namespace gui { -Row::Row(QObject *parent) : QObject(parent) +BaseRow::BaseRow(QObject *parent) : QObject(parent) { } -void Row::InsertPainter(Painter* painter, int pos) +void BaseRow::InsertPainter(Painter* painter, int pos) { if(pos == -1 || pos == painter_.size()){ painter_.append(painter); } - else if(this->IsPosValid(pos)){ + else if(this->IsPainterPosValid(pos)){ painter_.insert(pos, painter); } } -void Row::RemovePainter(Painter* painter) +void BaseRow::RemovePainter(Painter* painter) { painter_.removeAll(painter); } -Painter* Row::GetPainter(int pos) +Painter* BaseRow::GetPainter(int pos) { - if(this->IsPosValid(pos)){ + if(this->IsPainterPosValid(pos)){ return painter_[pos]; } return NULL; } -int Row::GetPainterCount() +int BaseRow::GetPainterCount() { return painter_.size(); } -bool Row::IsPosValid(int pos) +bool BaseRow::IsPainterPosValid(int pos) { if(pos >= 0 && pos < painter_.size()){ return true; @@ -67,9 +67,27 @@ bool Row::IsPosValid(int pos) return false; } -const PainterList& Row::GetPainters() const +const PainterList& BaseRow::GetPainters() const { return painter_; } +QVariant BaseRow::GetData(int column, int role) const +{ + return QVariant(); +} + +bool BaseRow::SetData(int column, const QVariant& value, int role) +{ + return false; +} + +Qt::ItemFlags BaseRow::Flags(int column) const +{ + return Qt::NoItemFlags; +} + +void BaseRow::DoubleClicked(int column) +{ } + }} diff --git a/modules/gui/src/sequence/row.hh b/modules/gui/src/sequence/base_row.hh similarity index 81% rename from modules/gui/src/sequence/row.hh rename to modules/gui/src/sequence/base_row.hh index 794a48db9..9ed545fe0 100644 --- a/modules/gui/src/sequence/row.hh +++ b/modules/gui/src/sequence/base_row.hh @@ -31,12 +31,12 @@ namespace ost { namespace gui { -class Row : public QObject +class BaseRow : public QObject { Q_OBJECT public: - Row(QObject *parent = 0); + BaseRow(QObject *parent = 0); void InsertPainter(Painter* painter, int pos = -1); void RemovePainter(Painter* painter); @@ -46,12 +46,17 @@ public: const PainterList& GetPainters() const; + virtual QVariant GetData(int column, int role) const; + virtual bool SetData(int column, const QVariant& value, int role); + virtual Qt::ItemFlags Flags(int column) const; + virtual void DoubleClicked(int column); + private: - bool IsPosValid(int pos); + bool IsPainterPosValid(int pos); PainterList painter_; }; -typedef QList<Row*> RowList; +typedef QList<BaseRow*> BaseRowList; }} diff --git a/modules/gui/src/sequence/view_object.cc b/modules/gui/src/sequence/view_object.cc index ecbfc43f6..dba4df1dc 100644 --- a/modules/gui/src/sequence/view_object.cc +++ b/modules/gui/src/sequence/view_object.cc @@ -81,7 +81,7 @@ void ViewObject::Init() default_cell_size_ = QSize(metrics.boundingRect('W').width()+2,metrics.boundingRect('|').height()*2); } -void ViewObject::InsertRow(int pos, Row* row) +void ViewObject::InsertRow(int pos, BaseRow* row) { if(pos >= 0 && pos <= rows_.size()){ ListEntry entry(row); @@ -89,7 +89,7 @@ void ViewObject::InsertRow(int pos, Row* row) } } -void ViewObject::RemoveRow(Row* row) +void ViewObject::RemoveRow(BaseRow* row) { QList<int> rows_to_delete; for (int i = 0; i < rows_.size(); ++i){ @@ -102,7 +102,7 @@ void ViewObject::RemoveRow(Row* row) } } -Row* ViewObject::GetRow(int pos) +BaseRow* ViewObject::GetRow(int pos) { if(pos >= 0 && pos < rows_.size()){ return rows_[pos].row; @@ -117,7 +117,7 @@ int ViewObject::GetRowCount() void ViewObject::AddSequence(seq::SequenceHandle& sequence, const QString& name) { - Row* new_row = new Row(this); + BaseRow* new_row = new BaseRow(this); Painter* p = new SeqSelectionPainter(this); new_row->InsertPainter(p); p = new SeqTextPainter(this); @@ -141,7 +141,7 @@ void ViewObject::AddChain(mol::ChainView& chain, const QString& name) v_one_chain.AddChain(chain, mol::ViewAddFlag::INCLUDE_ALL); sequence.AttachView(v_one_chain); - Row* new_row = new Row(this); + BaseRow* new_row = new BaseRow(this); Painter* p = new SeqSelectionPainter(this); new_row->InsertPainter(p); p = new SeqSecStrPainter(this); diff --git a/modules/gui/src/sequence/view_object.hh b/modules/gui/src/sequence/view_object.hh index d1e959fe7..640f261ba 100644 --- a/modules/gui/src/sequence/view_object.hh +++ b/modules/gui/src/sequence/view_object.hh @@ -37,27 +37,27 @@ #include <ost/seq/sequence_list.hh> -#include "row.hh" +#include "base_row.hh" namespace ost { namespace gui { struct ListEntry { - Row* row; + BaseRow* row; QString name; seq::SequenceHandle seq; mol::ChainView chain; QVarLengthArray<mol::SecStructure> secstr; ListEntry(): row(NULL) {} - ListEntry(Row* r): row(r) + ListEntry(BaseRow* r): row(r) {} - ListEntry(Row* r, const QString& n): row(r), name(n) + ListEntry(BaseRow* r, const QString& n): row(r), name(n) {} - ListEntry(Row* r, const QString& n, + ListEntry(BaseRow* r, const QString& n, seq::SequenceHandle& sequence): row(r), name(n), seq(sequence) {} - ListEntry(Row* r, const QString& n, + ListEntry(BaseRow* r, const QString& n, const seq::SequenceHandle& sequence, const mol::ChainView& c, const QVarLengthArray<mol::SecStructure>& sec): row(r), name(n), seq(sequence), chain(c), secstr(sec) {} @@ -75,10 +75,10 @@ public: ViewObject(mol::ChainView& chain, const QString& name, QObject* parent = 0); ViewObject(gfx::EntityP& entity, QObject* parent = 0); - void InsertRow(int pos, Row* row); - void RemoveRow(Row* row); + void InsertRow(int pos, BaseRow* row); + void RemoveRow(BaseRow* row); - Row* GetRow(int pos); + BaseRow* GetRow(int pos); int GetRowCount(); int GetMaxColumnCount() const; -- GitLab