| | |
| | | #include "comboboxdelegate.h" |
| | | #include <QFileDialog> |
| | | |
| | | ComboBoxDelegate::ComboBoxDelegate(QStringList labels,QObject *parent) |
| | | ComboBoxDelegate::ComboBoxDelegate(QStringList labels,QObject *parent,bool edit) |
| | | :QItemDelegate(parent), |
| | | m_labels(labels) |
| | | m_labels(labels), |
| | | m_edit(edit) |
| | | { |
| | | |
| | | } |
| | |
| | | QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const |
| | | { |
| | | QComboBox *cbb = new QComboBox(parent); |
| | | cbb->setEditable(m_edit); |
| | | for(int i=0;i<m_labels.size();++i){ |
| | | cbb->addItem(m_labels.at(i)); |
| | | } |
| | |
| | | |
| | | void ComboBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const |
| | | { |
| | | |
| | | |
| | | if(m_edit){// 可编辑状态 |
| | | int idx = ((QComboBox*)editor)->currentIndex(); |
| | | if(idx == 1){ // 需要上传 |
| | | QString fileName = QFileDialog::getOpenFileName(); |
| | | model->setData(index,fileName); |
| | | }else if(idx == 0){ // 录入 |
| | | ; |
| | | }else{ |
| | | QString val = ((QComboBox*)editor)->currentText(); |
| | | model->setData(index,val); |
| | | } |
| | | }else{ |
| | | QString val = ((QComboBox*)editor)->currentText(); |
| | | model->setData(index,val); |
| | | } |
| | | } |
| | |
| | | class ComboBoxDelegate : public QItemDelegate |
| | | { |
| | | public: |
| | | ComboBoxDelegate(QStringList labels,QObject *parent=0); |
| | | ComboBoxDelegate(QStringList labels,QObject *parent=0,bool edit=false); |
| | | |
| | | QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; |
| | | void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; |
| | | |
| | | private: |
| | | QStringList m_labels; |
| | | bool m_edit; |
| | | }; |
| | | |
| | | #endif // COMBOBOXDELEGATE_H |
| | |
| | | #include "datedelegate.h" |
| | | |
| | | DateDelegate::DateDelegate(QObject *parent):QItemDelegate(parent) |
| | | DateDelegate::DateDelegate(QObject *parent,QString format) |
| | | :QItemDelegate(parent),m_formate(format) |
| | | { |
| | | |
| | | } |
| | |
| | | { |
| | | QDateTimeEdit *de = new QDateTimeEdit(parent); |
| | | de->setDate(QDate::currentDate()); |
| | | de->setDisplayFormat("yyyy"); |
| | | de->setDisplayFormat(m_formate); |
| | | return de; |
| | | } |
| | | |
| | |
| | | class DateDelegate : public QItemDelegate |
| | | { |
| | | public: |
| | | DateDelegate(QObject *parent=0); |
| | | DateDelegate(QObject *parent=0,QString format="yyyy"); |
| | | |
| | | QWidget* createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; |
| | | void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; |
| | | |
| | | private: |
| | | QString m_formate; // 时间格式化的格式 |
| | | }; |
| | | |
| | | #endif // DATEDELEGATE_H |
| | |
| | | ui->tableWidget->setItemDelegateForColumn(6,m_cbb_way); |
| | | |
| | | // 问题描述佐证资料(上传取证单) 录入或者上传 |
| | | ui->tableWidget->setItemDelegateForColumn(13,m_fdd); |
| | | //ui->tableWidget->setItemDelegateForColumn(13,m_fdd); |
| | | QStringList fwLabels; |
| | | fwLabels << "录入(直接输入后回车即可)"<<"上传"; |
| | | m_cbb_file_wri = new ComboBoxDelegate(fwLabels,this,true); |
| | | ui->tableWidget->setItemDelegateForColumn(13,m_cbb_file_wri); |
| | | ui->tableWidget->setItemDelegateForColumn(17,m_cbb_file_wri); |
| | | ui->tableWidget->setItemDelegateForColumn(23,m_cbb_file_wri); |
| | | |
| | | // 处理年月日时间 |
| | | m_date_ymd = new DateDelegate(this,"yyyy/MM/dd"); |
| | | ui->tableWidget->setItemDelegateForColumn(19,m_date_ymd); |
| | | ui->tableWidget->setItemDelegateForColumn(21,m_date_ymd); |
| | | ui->tableWidget->setItemDelegateForColumn(24,m_date_ymd); |
| | | ui->tableWidget->setItemDelegateForColumn(29,m_date_ymd); |
| | | ui->tableWidget->setItemDelegateForColumn(31,m_date_ymd); |
| | | ui->tableWidget->setItemDelegateForColumn(34,m_date_ymd); |
| | | |
| | | |
| | | // 加载公司名 |
| | | readCompanyFromSQL(); |
| | |
| | | ComboBoxDelegate *m_cbb_company; // 审计单位 |
| | | ComboBoxDelegate *m_cbb_way; // 审计方式 |
| | | ComboBoxDelegate *m_cbb_pro; // 审计项目 |
| | | ComboBoxDelegate *m_cbb_file_wri; // 问题描述佐证 |
| | | |
| | | DateDelegate *m_date_ymd; // 时间 年月日 |
| | | }; |
| | | |
| | | #endif // THREEMERGEPROBLEMLIST_H |
| | |
| | | </column> |
| | | <column> |
| | | <property name="text"> |
| | | <string>涉及金额</string> |
| | | <string>涉及金额(万元)</string> |
| | | </property> |
| | | </column> |
| | | <column> |