OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
sequence_table_view.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-2011 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_TABLE_VIEW
20 #define OST_SEQUENCE_VIEWER_SEQUENCE_TABLE_VIEW
21 
22 /*
23  Author: Stefan Scheuber
24  */
25 
26 
27 #include <ost/gui/module_config.hh>
28 
29 #include "sequence_delegate.hh"
30 
31 #include <QTableView>
32 #include <QWheelEvent>
33 namespace ost { namespace gui {
34 
36 class DLLEXPORT_OST_GUI SequenceTableView : public QTableView {
37  Q_OBJECT
38 public:
39  SequenceTableView(QAbstractItemModel * model);
40  QTableView* GetStaticRow();
41  QTableView* GetStaticColumn();
42  QTableView* GetStaticField();
44 
45 
46  void SetSingleAlignment(bool flag) { single_alignment_=flag; }
47 
48  bool IsSingleAlignment() const { return single_alignment_; }
49 signals:
50  void MouseWheelEvent(QWheelEvent* event);
51  void CopyEvent(QKeyEvent* event);
52  void AlignmentChanged();
53 public slots:
54  void columnCountChanged(const QModelIndex& index, int old_count, int new_count);
55  void rowCountChanged(const QModelIndex& index, int old_count, int new_count);
56  void resizeColumnsToContents();
57  void resizeRowsToContents();
58 
59 protected:
60  virtual void mouseDoubleClickEvent(QMouseEvent* event);
61  virtual void mouseReleaseEvent(QMouseEvent* event);
62  virtual void resizeEvent(QResizeEvent* event);
63  virtual void wheelEvent(QWheelEvent* event);
64  virtual void keyPressEvent(QKeyEvent* event);
65  virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
66  void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible);
67  virtual int sizeHintForColumn(int column) const;
68  virtual int sizeHintForRow(int row) const;
69 
70 private slots:
71  void InitStaticColumn();
72  void InitStaticRow();
73  void InitStaticField();
74  void ResizeWidth(int index, int, int size);
75  void ResizeHeight(int index, int, int size);
76 
77 private:
78  std::pair<int, int> GetSimpleSelection(int row);
79  QTableView* static_column_;
80  QTableView* static_row_;
81  QTableView* static_field_;
82  SequenceDelegate* delegate_;
83  QModelIndex last_double_click_;
84  bool single_alignment_;
85  void updateStaticColumn();
86  void updateStaticRow();
87  void updateStaticField();
88 };
89 
90 }}
91 
92 #endif
QTableView with first column not moving.
#define DLLEXPORT_OST_GUI