Skip to content
Snippets Groups Projects
Commit c067b6ba authored by stefan's avatar stefan
Browse files

New SequenceViewer, fixed copy behavior

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2241 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent 79e8a354
No related branches found
No related tags found
No related merge requests found
...@@ -349,6 +349,16 @@ void SequenceTableView::wheelEvent(QWheelEvent* event) ...@@ -349,6 +349,16 @@ void SequenceTableView::wheelEvent(QWheelEvent* event)
} }
} }
void SequenceTableView::keyPressEvent(QKeyEvent* event)
{
if(event->matches(QKeySequence::Copy)){
emit CopyEvent(event);
}
else{
QTableView::keyPressEvent(event);
}
}
SequenceTableView::~SequenceTableView(){} SequenceTableView::~SequenceTableView(){}
}} }}
...@@ -44,6 +44,7 @@ public: ...@@ -44,6 +44,7 @@ public:
signals: signals:
void MouseWheelEvent(QWheelEvent* event); void MouseWheelEvent(QWheelEvent* event);
void CopyEvent(QKeyEvent* event);
public slots: public slots:
void columnCountChanged(const QModelIndex& index, int old_count, int new_count); void columnCountChanged(const QModelIndex& index, int old_count, int new_count);
...@@ -55,7 +56,8 @@ protected: ...@@ -55,7 +56,8 @@ protected:
virtual void mouseDoubleClickEvent(QMouseEvent* event); virtual void mouseDoubleClickEvent(QMouseEvent* event);
virtual void mouseReleaseEvent(QMouseEvent* event); virtual void mouseReleaseEvent(QMouseEvent* event);
virtual void resizeEvent(QResizeEvent* event); virtual void resizeEvent(QResizeEvent* event);
virtual void wheelEvent (QWheelEvent* event); virtual void wheelEvent(QWheelEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers); virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible); void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible);
......
...@@ -23,10 +23,13 @@ ...@@ -23,10 +23,13 @@
#include <boost/pointer_cast.hpp> #include <boost/pointer_cast.hpp>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QApplication>
#include <QClipboard>
#include <QHeaderView> #include <QHeaderView>
#include <QPushButton> #include <QPushButton>
#include <QShortcut> #include <QShortcut>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QVarLengthArray>
#include <ost/mol/chain_view.hh> #include <ost/mol/chain_view.hh>
#include <ost/mol/entity_view.hh> #include <ost/mol/entity_view.hh>
...@@ -96,6 +99,7 @@ SequenceViewerV2::SequenceViewerV2(QWidget* parent): Widget(NULL,parent) ...@@ -96,6 +99,7 @@ SequenceViewerV2::SequenceViewerV2(QWidget* parent): Widget(NULL,parent)
connect(seq_table_view_,SIGNAL(doubleClicked(const QModelIndex&)),model_,SLOT(DoubleClicked(const QModelIndex&))); connect(seq_table_view_,SIGNAL(doubleClicked(const QModelIndex&)),model_,SLOT(DoubleClicked(const QModelIndex&)));
connect(seq_table_view_->GetStaticColumn(),SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(DoubleClicked(const QModelIndex&))); connect(seq_table_view_->GetStaticColumn(),SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(DoubleClicked(const QModelIndex&)));
connect(seq_table_view_->GetStaticRow(),SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(DoubleClicked(const QModelIndex&))); connect(seq_table_view_->GetStaticRow(),SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(DoubleClicked(const QModelIndex&)));
connect(seq_table_view_,SIGNAL(CopyEvent(QKeyEvent*)),this,SLOT(CopyEvent(QKeyEvent*)));
connect(seq_table_view_,SIGNAL(MouseWheelEvent(QWheelEvent*)),this,SLOT(MouseWheelEvent(QWheelEvent*))); connect(seq_table_view_,SIGNAL(MouseWheelEvent(QWheelEvent*)),this,SLOT(MouseWheelEvent(QWheelEvent*)));
gfx::GfxNodeP root_node = gfx::Scene::Instance().GetRootNode(); gfx::GfxNodeP root_node = gfx::Scene::Instance().GetRootNode();
...@@ -128,8 +132,8 @@ void SequenceViewerV2::UpdateSearchBar() ...@@ -128,8 +132,8 @@ void SequenceViewerV2::UpdateSearchBar()
{ {
QStringList sequence_names_; QStringList sequence_names_;
for(int i = 1; i< model_->rowCount(); i++){ for(int i = 1; i< model_->rowCount(); i++){
QString name = model_->data(model_->index(i,0),Qt::DisplayRole).toString(); QString name = model_->data(model_->index(i,0),Qt::DisplayRole).toString();
sequence_names_.append(name); sequence_names_.append(name);
} }
seq_search_bar_->UpdateItems(sequence_names_); seq_search_bar_->UpdateItems(sequence_names_);
} }
...@@ -180,6 +184,27 @@ void SequenceViewerV2::MouseWheelEvent(QWheelEvent* event) ...@@ -180,6 +184,27 @@ void SequenceViewerV2::MouseWheelEvent(QWheelEvent* event)
event->accept(); event->accept();
} }
void SequenceViewerV2::CopyEvent(QKeyEvent* event)
{
const QModelIndexList& list = seq_table_view_->selectionModel()->selectedIndexes();
if(list.size()>0){
QString clipboard_string;
QVarLengthArray<QString> clipboard_array(model_->rowCount());
for(int i = 0; i < list.size(); i++){
const QModelIndex& index = list[i];
clipboard_array[index.row()].append(model_->data(index,Qt::DisplayRole).toString());
}
for(int i = 0; i < clipboard_array.size(); i++){
if(clipboard_array[i].size()>0){
clipboard_string.append(clipboard_array[i]+"\n");
}
}
QApplication::clipboard()->setText(clipboard_string);
}
event->accept();
}
void SequenceViewerV2::FindInSequence() void SequenceViewerV2::FindInSequence()
{ {
if(seq_search_bar_->isHidden()){ if(seq_search_bar_->isHidden()){
......
...@@ -56,10 +56,6 @@ public slots: ...@@ -56,10 +56,6 @@ public slots:
/// \internal /// \internal
void OnSearchBarUpdate(const QString&, bool, const QString&); void OnSearchBarUpdate(const QString&, bool, const QString&);
private slots:
/// \brief show sequence search bar
void FindInSequence();
private: private:
void UpdateSearchBar(); void UpdateSearchBar();
void SelectList(const QModelIndexList& list); void SelectList(const QModelIndexList& list);
...@@ -68,10 +64,12 @@ private: ...@@ -68,10 +64,12 @@ private:
SequenceTableView* seq_table_view_; SequenceTableView* seq_table_view_;
private slots: private slots:
/// \brief show sequence search bar
void FindInSequence();
void SelectionModelChanged(const QItemSelection&, const QItemSelection&); void SelectionModelChanged(const QItemSelection&, const QItemSelection&);
void DoubleClicked(const QModelIndex& index); void DoubleClicked(const QModelIndex& index);
void MouseWheelEvent(QWheelEvent* event); void MouseWheelEvent(QWheelEvent* event);
void CopyEvent(QKeyEvent* event);
}; };
}} }}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment