void BLSURFPluginGUI_AdvWidget::onChooseGMFFile()
{
QString fileName = QFileDialog::getSaveFileName(0, tr("BLSURF_GMF_FILE_DIALOG"), myGMFFileName->text(), tr("BLSURF_GMF_FILE_FORMAT"));
- std::cout << "fileName: " << fileName.toStdString() << std::endl;
- if (!fileName.endsWith(".mesh") && !fileName.endsWith(".meshb"))
- fileName.append(".mesh");
- myGMFFileName->setText(fileName);
+ if ( !fileName.isEmpty() ) {
+ if (!fileName.endsWith(".mesh") && !fileName.endsWith(".meshb"))
+ fileName.append(".mesh");
+ myGMFFileName->setText(fileName);
+ }
}
void BLSURFPluginGUI_AdvWidget::AddOption( int iTable, const char* option )
if ( !option )
{
myOptionTable->scrollToItem( row );
+ myOptionTable->setCurrentItem( row );
myOptionTable->editItem( row, NAME_COL );
}
}
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="3">
- <widget class="QTreeWidget" name="myOptionTable">
+ <widget class="BLSURFPluginGUI_TreeWidget" name="myOptionTable">
<property name="editTriggers">
- <set>QAbstractItemView::DoubleClicked</set>
+ <set>QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed</set>
+ </property>
+ <property name="tabKeyNavigation">
+ <bool>true</bool>
</property>
<column>
<property name="text">
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>BLSURFPluginGUI_TreeWidget</class>
+ <extends>QTreeWidget</extends>
+ <header location="global">BLSURFPluginGUI_TreeWidget.h</header>
+ </customwidget>
+ </customwidgets>
<tabstops>
<tabstop>addBtn</tabstop>
<tabstop>myVerbosity</tabstop>
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "BLSURFPluginGUI_TreeWidget.h"
+#include <QKeyEvent>
+
+namespace
+{
+ bool isEditable( const QModelIndex& index )
+ {
+ return index.isValid() &&
+ index.flags() & Qt::ItemIsEditable &&
+ index.flags() & Qt::ItemIsEnabled &&
+ ( !index.data( Qt::UserRole + 1 ).isValid() || index.data( Qt::UserRole + 1 ).toInt() != 0 );
+ }
+}
+
+BLSURFPluginGUI_TreeWidget::BLSURFPluginGUI_TreeWidget( QWidget* parent )
+ : QTreeWidget( parent )
+{
+}
+
+QModelIndex BLSURFPluginGUI_TreeWidget::moveCursor( CursorAction action, Qt::KeyboardModifiers modifiers )
+{
+ QModelIndex current = currentIndex();
+ int column = current.column();
+ if ( action == MoveNext ) {
+ if ( column < columnCount()-1 ) {
+ QModelIndex next = current.sibling( current.row(), column+1 );
+ if ( isEditable( next ) )
+ return next;
+ }
+ else {
+ QModelIndex next = current.sibling( current.row()+1, 0 );
+ if ( isEditable( next ) )
+ return next;
+ }
+ }
+ else if ( action == MovePrevious ) {
+ if ( column == 0 ) {
+ QModelIndex next = current.sibling( current.row()-1, columnCount()-1 );
+ if ( isEditable( next ) )
+ return next;
+ }
+ else {
+ QModelIndex next = current.sibling( current.row(), column-1 );
+ if ( isEditable( next ) )
+ return next;
+ }
+ }
+ return QTreeWidget::moveCursor( action, modifiers );
+}
+
+void BLSURFPluginGUI_TreeWidget::keyPressEvent( QKeyEvent* e )
+{
+ switch ( e->key() ) {
+ case Qt::Key_F2:
+ {
+ QModelIndex index = currentIndex();
+ if ( !isEditable( index ) ) {
+ for ( int i = 0; i < columnCount(); i++ ) {
+ QModelIndex sibling = index.sibling( index.row(), i );
+ if ( isEditable( sibling ) ) {
+ if ( !edit( sibling, EditKeyPressed, e ) )
+ e->ignore();
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ QTreeWidget::keyPressEvent( e );
+}
--- /dev/null
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#if !defined(BLSURFPluginGUI_TreeWidget_H)
+#define BLSURFPluginGUI_TreeWidget_H
+
+#include <QTreeWidget>
+
+class BLSURFPluginGUI_TreeWidget : public QTreeWidget
+{
+ Q_OBJECT
+public:
+ BLSURFPluginGUI_TreeWidget( QWidget* );
+
+protected:
+ QModelIndex moveCursor( CursorAction, Qt::KeyboardModifiers );
+ void keyPressEvent( QKeyEvent* );
+};
+
+#endif // BLSURFPluginGUI_TreeWidget_H
${CMAKE_CURRENT_BINARY_DIR}
${PROJECT_BINARY_DIR}/idl
${PROJECT_SOURCE_DIR}/src/BLSURFPlugin
+ ${PROJECT_SOURCE_DIR}/src/GUI
)
# additional preprocessor / compiler flags
SET(BLSURFPluginGUI_HEADERS
BLSURFPluginGUI_HypothesisCreator.h
BLSURFPluginGUI_Dlg.h
+ BLSURFPluginGUI_TreeWidget.h
)
# --- sources ---
BLSURFPluginGUI_StdWidget.cxx
BLSURFPluginGUI_AdvWidget.cxx
BLSURFPluginGUI_HypothesisCreator.cxx
+ BLSURFPluginGUI_TreeWidget.cxx
)
# --- resources ---