#include <Events_Loop.h>
#include <QLayout>
-#include <QTreeWidget>
#include <QPushButton>
#include <QToolButton>
#include <QStyledItemDelegate>
#include <QPainter>
#include <QMessageBox>
#include <QTimer>
+#include <QEvent>
+#include <QKeyEvent>
enum ColumnType {
Col_Name,
return QStyledItemDelegate::createEditor(parent, option, index);
}
+/////////////////////////////////////////////////////////////////////////////////////////////////
+void ParametersPlugin_TreeWidget::closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint)
+{
+ if (theHint == QAbstractItemDelegate::EditNextItem) {
+ QModelIndex aCurrent = currentIndex();
+ QModelIndex aParent = model()->index(0, 0);
+ int aNbRows = model()->rowCount(aParent);
+ QModelIndex aIdx;
+ switch (aCurrent.column()) {
+ case 0:
+ aIdx = model()->index(aCurrent.row(), 1, aParent);
+ break;
+ case 1:
+ if (aCurrent.row() < (aNbRows - 1))
+ aIdx = model()->index(aCurrent.row() + 1, 0, aParent);
+ else {
+ QTreeWidget::closeEditor(theEditor, QAbstractItemDelegate::NoHint);
+ return;
+ }
+ break;
+ case 3:
+ QTreeWidget::closeEditor(theEditor, theHint);
+ return;
+ }
+ if (aIdx.isValid()) {
+ QTreeWidget::closeEditor(theEditor, QAbstractItemDelegate::NoHint);
+ setCurrentIndex(aIdx);
+ edit(aIdx);
+ return;
+ }
+ }
+ QTreeWidget::closeEditor(theEditor, theHint);
+}
/////////////////////////////////////////////////////////////////////////////////////////////////
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
- myTable = new QTreeWidget(this);
+ myTable = new ParametersPlugin_TreeWidget(this);
myTable->setColumnCount(4);
QStringList aHeaders;
aHeaders << tr("Name") << tr("Equation") << tr("Result") << tr("Comment");
void ParametersPlugin_WidgetParamsMgr::onDoubleClick(const QModelIndex& theIndex)
{
if (myDelegate->isEditable(theIndex)) {
+ myTable->setCurrentIndex(theIndex);
myTable->edit(theIndex);
}
}
myParametersList.append(aFeature);
myTable->scrollToItem(aItem);
+ myTable->setCurrentItem(aItem);
+ myTable->editItem(aItem);
}
QTreeWidgetItem* ParametersPlugin_WidgetParamsMgr::selectedItem() const
myUpBtn->setEnabled(isParameter);
myDownBtn->setEnabled(isParameter);
}
+
#include <ModuleBase_ModelWidget.h>
#include <QModelIndex>
#include <QAbstractItemDelegate>
+#include <QTreeWidget>
-class QTreeWidget;
class QTreeWidgetItem;
class ParametersPlugin_ItemDelegate;
class QPushButton;
class QToolButton;
+
+class ParametersPlugin_TreeWidget: public QTreeWidget
+{
+ Q_OBJECT
+public:
+ ParametersPlugin_TreeWidget(QWidget* theParent = 0) : QTreeWidget(theParent) {}
+
+protected slots:
+ virtual void closeEditor(QWidget* theEditor, QAbstractItemDelegate::EndEditHint theHint);
+};
+
+
+
/*!
* \ingroup GUI
* Represent a content of the property panel to show/modify parameters of some feature.
void updateParametersFeatures();
- QTreeWidget* myTable;
+ ParametersPlugin_TreeWidget* myTable;
QTreeWidgetItem* myFeatures;
QTreeWidgetItem* myParameters;
ParametersPlugin_ItemDelegate* myDelegate;