瀏覽代碼

SaltTable enhancements

Neal Wilson 5 年之前
父節點
當前提交
227e629931
簽署人: Neal Wilson <neal@typica.us> GPG Key ID: 2A0BDDE701E66EB9
共有 1 個文件被更改,包括 15 次插入3 次删除
  1. 15
    3
      src/typica.w

+ 15
- 3
src/typica.w 查看文件

@@ -6153,6 +6153,13 @@ if(currentElement.hasAttribute("display"))
6153 6153
 {
6154 6154
     widget->setDisplayColumn(currentElement.attribute("display").toInt());
6155 6155
 }
6156
+if(currentElement.hasAttribute("editable"))
6157
+{
6158
+    if(currentElement.attribute("editable") == "true")
6159
+    {
6160
+        widget->setEditable(true);
6161
+    }
6162
+}
6156 6163
 widget->addSqlOptions(currentElement.text());
6157 6164
 delegate->setWidget(widget);
6158 6165
 view->setItemDelegateForColumn(currentColumn, delegate);
@@ -13372,7 +13379,7 @@ class SaltModel : public QAbstractItemModel@/
13372 13379
     public:@/
13373 13380
         SaltModel(int columns);
13374 13381
         ~SaltModel();
13375
-        int rowCount(const QModelIndex &parent = QModelIndex()) const;
13382
+        Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const;
13376 13383
         int columnCount(const QModelIndex &parent = QModelIndex()) const;
13377 13384
         bool setHeaderData(int section, Qt::Orientation@, orientation,
13378 13385
                            const QVariant &value, int role = Qt::DisplayRole);
@@ -13932,7 +13939,12 @@ QWidget* SqlComboBoxDelegate::createEditor(QWidget *parent,@|
13932 13939
                                            const QStyleOptionViewItem &,
13933 13940
                                            const QModelIndex &) const
13934 13941
 {
13935
-    return delegate->clone(parent);
13942
+    SqlComboBox *retval = delegate->clone(parent);
13943
+    if(delegate->isEditable())
13944
+    {
13945
+        retval->setEditable(true);
13946
+    }
13947
+    return retval;
13936 13948
 }
13937 13949
 
13938 13950
 @ To set the appropriate editor data, we check the value in the model and
@@ -13957,9 +13969,9 @@ void SqlComboBoxDelegate::setModelData(QWidget *editor,@|
13957 13969
                                        const QModelIndex &index) const
13958 13970
 {
13959 13971
     SqlComboBox *self = qobject_cast<SqlComboBox *>(editor);
13972
+    model->setData(index, self->currentText(), Qt::DisplayRole);
13960 13973
     model->setData(index, self->itemData(self->currentIndex(), Qt::UserRole),
13961 13974
                    Qt::UserRole);
13962
-    model->setData(index, self->currentText(), Qt::DisplayRole);
13963 13975
 }
13964 13976
 
13965 13977
 @ This is needed to play nicely with the model view architecture.

Loading…
取消
儲存