Changeset 99351b7 in subsurface


Ignore:
Timestamp:
Mar 26, 2017, 9:53:57 PM (4 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
0b59954
Parents:
cdcbeea5
git-author:
Robert C. Helling <helling@…> (03/26/17 14:47:21)
git-committer:
Dirk Hohndel <dirk@…> (03/26/17 21:53:57)
Message:

Allow cylinder names to be edited

The same ComboBoxDelegate? is used for picking a cylinder model
and picking a gas in the planner waypoint table. In the former
case we want to allow the user to edit the string in the second
we don't.

The difference is not if we are in the planner but which use of
the class. So add a bool allowEdit to the constructor.

Fixes #272

Signed-off-by: Robert C. Helling <helling@…>

Location:
desktop-widgets
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/modeldelegates.cpp

    r597539c r99351b7  
    8181}
    8282
    83 ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent) : QStyledItemDelegate(parent), model(model)
    84 {
     83ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent, bool allowEdit) : QStyledItemDelegate(parent), model(model)
     84{
     85        editable = allowEdit;
    8586        connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)),
    8687                this, SLOT(revertModelData(QWidget *, QAbstractItemDelegate::EndEditHint)));
     
    121122        comboDelegate->view()->setEditTriggers(QAbstractItemView::AllEditTriggers);
    122123        comboDelegate->lineEdit()->installEventFilter(const_cast<QObject *>(qobject_cast<const QObject *>(this)));
    123         if ((m->graphics()->currentState != ProfileWidget2::PROFILE))
    124                 comboDelegate->lineEdit()->setEnabled(false);
     124        comboDelegate->lineEdit()->setEnabled(editable);
    125125        comboDelegate->view()->installEventFilter(const_cast<QObject *>(qobject_cast<const QObject *>(this)));
    126126        QAbstractItemView *comboPopup = comboDelegate->lineEdit()->completer()->popup();
     
    268268}
    269269
    270 TankInfoDelegate::TankInfoDelegate(QObject *parent) : ComboBoxDelegate(TankInfoModel::instance(), parent)
     270TankInfoDelegate::TankInfoDelegate(QObject *parent) : ComboBoxDelegate(TankInfoModel::instance(), parent, true)
    271271{
    272272        connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)),
     
    378378}
    379379
    380 WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::instance(), parent)
     380WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::instance(), parent, false)
    381381{
    382382}
     
    407407}
    408408
    409 AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelectionModel::instance(), parent)
     409AirTypesDelegate::AirTypesDelegate(QObject *parent) : ComboBoxDelegate(GasSelectionModel::instance(), parent, false)
    410410{
    411411}
  • desktop-widgets/modeldelegates.h

    rf0bd39c r99351b7  
    3131        Q_OBJECT
    3232public:
    33         explicit ComboBoxDelegate(QAbstractItemModel *model, QObject *parent = 0);
     33        explicit ComboBoxDelegate(QAbstractItemModel *model, QObject *parent = 0, bool allowEdit = true);
    3434        virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    3535        virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
     
    4444        void fixTabBehavior();
    4545        virtual void revertModelData(QWidget *widget, QAbstractItemDelegate::EndEditHint hint) = 0;
    46 
     46private:
     47        bool editable;
    4748protected:
    4849        QAbstractItemModel *model;
Note: See TracChangeset for help on using the changeset viewer.