Salome HOME
97dda02daf4d7d1ffccf96e64b18c9a0b8ffba0d
[modules/yacs.git] / src / genericgui / YACSWidgets.cxx
1 // Copyright (C) 2006-2022  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "YACSWidgets.hxx"
21 #include <QApplication>
22 #include <QClipboard>
23
24 //#define _DEVDEBUG_
25 #include "YacsTrace.hxx"
26
27 using namespace YACS::HMI;
28
29 YTableView::YTableView(QWidget *parent)
30   : QTableView(parent)
31 {
32 }
33
34 bool YTableView::event(QEvent *e)
35 {
36   if (e->type() == QEvent::ShortcutOverride)
37     {
38       e->accept();
39       return true;
40     }
41   return QTableView::event(e);
42 }
43
44 QModelIndex YTableView::moveCursor(CursorAction cursorAction,Qt::KeyboardModifiers modifiers)
45 {
46   QModelIndex ix = currentIndex();
47
48   if (!ix.isValid()) 
49     return QTableView::moveCursor(cursorAction,  modifiers);
50
51   if(cursorAction==QAbstractItemView::MoveNext || cursorAction==QAbstractItemView::MovePrevious)
52     {
53       int row=ix.row();
54       QModelIndex parent=ix.parent();
55       int rowCount=model()->rowCount(parent);
56
57       while(1)
58         {
59           if(cursorAction==QAbstractItemView::MoveNext)
60             {
61               row=row+1;
62               if(row >= rowCount)
63                 row=0;
64             }
65           else
66             {
67               row=row-1;
68               if(row < 0)
69                 row=rowCount -1;
70             }
71           if(!isRowHidden(row))
72             break;
73         }
74       return model()->index(row, ix.column(), parent);
75     }
76   return QTableView::moveCursor(cursorAction,  modifiers);
77 }
78