1 // Copyright (C) 2009-2019 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "BL_JobsTable.hxx"
21 #include "BL_Traces.hxx"
22 #include "BL_GenericGui.hxx"
24 #include <QHeaderView>
25 #include <QMainWindow>
27 BL::JobsTable::JobsTable(QWidget *parent) : QTableView(parent)
29 DEBTRACE("Creating BL::JobsTable");
36 setCornerButtonEnabled(false);
37 setEditTriggers(QAbstractItemView::NoEditTriggers);
38 setAlternatingRowColors(true);
39 setSortingEnabled(true);
41 setSelectionBehavior(QAbstractItemView::SelectRows);
42 setSelectionMode(QAbstractItemView::ExtendedSelection);
44 QHeaderView * header_view = verticalHeader();
45 #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
46 header_view->setClickable(false);
48 header_view->setSectionsClickable(false);
52 BL::JobsTable::~JobsTable()
54 DEBTRACE("Destroying BL::JobsTable");
58 BL::JobsTable::selectCurrent()
60 QModelIndex idx = currentIndex();
62 if (!isMultipleSelected())
64 DEBTRACE("SELECT CURRENT ACTIVATION !!!");
73 BL::JobsTable::set_main_gui(BL::GenericGui * main_gui)
79 BL::JobsTable::selectionChanged ( const QItemSelection & selected, const QItemSelection & deselected )
81 QTableView::selectionChanged(selected, deselected);
82 DEBTRACE("selection changed");
83 QModelIndexList selected_rows = selectionModel()->selectedRows();
84 if (selected_rows.length() == 0)
88 _main_gui->reset_job_selection();
91 else if (selected_rows.length() == 1)
93 DEBTRACE("SELECTED CHANGED ACTIVATION !!!");
94 DEBTRACE("ROW NUMBER: " << selected_rows[0].row());
95 QModelIndex current = selected_rows[0];
96 if (!selectionModel()->isSelected(current))
98 setCurrentIndex(current);
102 DEBTRACE("Number of selected rows selection: " << selected_rows.length());
106 BL::JobsTable::currentChanged(const QModelIndex & current, const QModelIndex & previous)
108 QTableView::currentChanged(current, previous);
109 DEBTRACE("current changed");
110 DEBTRACE("current row: " << current.row());
111 if (current.row() > -1)
112 if (!isMultipleSelected())
114 DEBTRACE("CURRENT CHANGED ACTIVATION !!!");
115 //setCurrentIndex(current);
116 //activated(current);
121 BL::JobsTable::isMultipleSelected()
123 QModelIndexList selected_rows = selectionModel()->selectedRows();
124 DEBTRACE("Number of selected rows: " << selected_rows.length());
125 if (selected_rows.length() > 1)
132 BL::JobsTable::getSelectedIndexes()
134 return selectedIndexes();