QWidget *MySqlRelationDelegate::createEditor(QWidget *aParent, const QStyleOptionViewItem &option, const QModelIndex &index) const { const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model()); QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; if (!childModel) { if (HandbookDialog::m_record.fieldName(index.column()).contains("IS_", Qt::CaseSensitive)) { QCheckBox * checkBox = new QCheckBox(aParent); checkBox->setChecked(index.data().toInt() > 0); return checkBox; } else if (HandbookDialog::m_record.fieldName(index.column()).contains("DATE_", Qt::CaseSensitive)) { QDateEdit * dateEdit = new QDateEdit(aParent); dateEdit->setDate(QDate::fromString(index.data().toString(), "yyyy-MM-dd")); return dateEdit; } else { return QItemDelegate::createEditor(aParent, option, index); } } QComboBox *combo = new QComboBox(aParent); combo->setModel(childModel); combo->setModelColumn(childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn())); combo->installEventFilter(const_cast<MySqlRelationDelegate *>(this)); return combo; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void UKvyt_Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const { if (index.column() == durationColumn_2) { double value = index.model()->data(index, Qt::DisplayRole).toDouble(); QDoubleSpinBox *double_spinbox = qobject_cast<QDoubleSpinBox *>(editor); double_spinbox->setValue(value); double_spinbox->selectAll(); } else if ( (index.column() == durationColumn_3) || (index.column() == durationColumn_4) ){ QDateEdit * dateEdit = qobject_cast<QDateEdit *>(editor); dateEdit->setDate( index.model()->data(index, Qt::DisplayRole).toDate() ); dateEdit->setCurrentSection( QDateTimeEdit::DaySection ); dateEdit->stepBy( 0 ); } else if ((index.column() == durationColumn_5) || (index.column() == durationColumn_1)){ int value = index.model()->data(index, Qt::DisplayRole).toInt(); QSpinBox *spinbox = qobject_cast<QSpinBox *>(editor); spinbox->setValue(value); spinbox->selectAll(); } else { QSqlRelationalDelegate::setEditorData(editor, index); } }
QWidget *PupilSingularActivityDelegate::createEditor ( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { switch ( index.column() ) { case 2: { QDateEdit *cal = new QDateEdit ( parent ); cal->setCalendarPopup ( true ); connect ( cal, SIGNAL ( dateChanged ( const QDate ) ), this, SLOT ( emitCommitData() ) ); return cal; } break; case 3: { QComboBox *combo = new QComboBox ( parent ); QStringList myTypeList; myTypeList << "Solo-Vortrag" << "Ensemble-Mitwirkung" << "sonstiges"; combo->insertItems ( 0, myTypeList ); connect ( combo, SIGNAL ( activated ( int ) ), this, SLOT ( emitCommitData() ) ); return combo; } break; default: return QItemDelegate::createEditor ( parent, option, index ); break; } }
QDate QtopiaInputDialog::getDate(QWidget *parent, const QString &title, const QString &label, const QDate &date, const QDate &minDate, const QDate &maxDate, bool *ok) { #ifdef CALENDAR_FOR_DATE QCalendarWidget *cal = new QCalendarWidget(); cal->setSelectedDate(date); cal->setMinimumDate(minDate); cal->setMaximumDate(maxDate); cal->setVerticalHeaderFormat(QCalendarWidget::NoVerticalHeader); QTextCharFormat headerFormat = cal->headerTextFormat(); headerFormat.setBackground(QApplication::palette().window()); headerFormat.setForeground(QApplication::palette().windowText()); cal->setHeaderTextFormat(headerFormat); QWidget *navBar = cal->findChild<QWidget*>("qt_calendar_navigationbar"); if (navBar) navBar->setBackgroundRole(QPalette::Window); QtopiaInputDialog dlg(parent, title, label, cal); bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted); if (ok) *ok = accepted; return cal->selectedDate(); #else QDateEdit *de = new QDateEdit(date); de->setMinimumDate(minDate); de->setMaximumDate(maxDate); QtopiaInputDialog dlg(parent, title, label, de); bool accepted = (QtopiaApplication::execDialog(&dlg) == QDialog::Accepted); if (ok) *ok = accepted; return de->date(); #endif }
QWidget *DBFRedactorDelegate::createEditor ( QWidget * parent, const QStyleOptionViewItem & option, const QModelIndex & index ) const { const DBFRedactor::Field& field = m_redactor->field(index.column()); switch (field.type) { case DBFRedactor::TYPE_DATE: { QDateEdit *edit = new QDateEdit(parent); edit->setCalendarPopup(true); return edit; break; } case DBFRedactor::TYPE_FLOAT: case DBFRedactor::TYPE_NUMERIC: { QDoubleSpinBox *edit = new QDoubleSpinBox(parent); edit->setDecimals(field.secondLenght); QString tempString; tempString.fill('9', field.firstLenght - 1); edit->setMinimum(tempString.toDouble() * (-1)); tempString.fill('9', field.firstLenght); edit->setMaximum(tempString.toDouble()); return edit; break; } default: { QLineEdit *edit = new QLineEdit(parent); edit->setMaxLength(field.firstLenght); return edit; } } return 0; }
void DateDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QDateEdit * dateEdit = static_cast<QDateEdit*>(editor); QDate date; date = index.model()->data(index,Qt::DisplayRole).toDate(); dateEdit->setDate(date); }
void PupilSingularActivityDelegate::setModelData ( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const { switch ( index.column() ) { case 2: { QDateEdit *cal = qobject_cast<QDateEdit *> ( editor ); if ( !cal ) { QItemDelegate::setModelData ( editor, model, index ); return; } model -> setData ( index, cal->date().toString("yyyy-MM-dd") ); } break; case 3: { QComboBox *combo = qobject_cast<QComboBox *> ( editor ); if ( !combo ) { QItemDelegate::setModelData ( editor, model, index ); return; } model -> setData ( index, combo->currentIndex() ); } break; default: { QItemDelegate::setModelData ( editor, model, index ); return; } break; } }
void PupilSingularActivityDelegate::setEditorData ( QWidget *editor, const QModelIndex &index ) const { switch ( index.column() ) { case 2: { QDateEdit *cal = qobject_cast<QDateEdit *> ( editor ); if ( !cal ) { QItemDelegate::setEditorData ( editor, index ); return; } cal->setDate ( QDate::fromString ( index.model()->data(index).toString(),"dd.MM.yyyy" ) ); } break; case 3: { QComboBox *combo = qobject_cast<QComboBox *> ( editor ); if ( !combo ) { QItemDelegate::setEditorData ( editor, index ); return; } combo->setCurrentIndex(index.model()->data(index).toInt()); } break; default: { QItemDelegate::setEditorData ( editor, index ); return; } break; } }
//------------------------------------------------------------------------------ void ConditionValueDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { switch (field(index)) { case AssignmentRule::Date: { QDateEdit* dateEditor = static_cast<QDateEdit*>(editor); QDate date = dateEditor->date(); model->setData(index, date.toString(Qt::ISODate), Qt::EditRole); } break; case AssignmentRule::Amount: { MoneyEdit* moneyEditor = static_cast<MoneyEdit*>(editor); Money amount = moneyEditor->value(); QString newVal = QString("%1,%2") .arg(amount.amount()).arg(amount.currency().code()); model->setData(index, newVal, Qt::EditRole); } break; default: { LineEdit* stringEditor = static_cast<LineEdit*>(editor); model->setData(index, stringEditor->text(), Qt::EditRole); } } }
void TransactionWidget::dateChanged( const QDate &date ) { if( !sender() ) return; QDateEdit *edit = qobject_cast<QDateEdit *>( sender() ); if( !edit ) return; QString name = edit->objectName(); QDate date1 = startDateEdit->date(); QDate date2 = endDateEdit->date(); if( date1 >= date2 ) { if( name == "endDateEdit" ) { date1 = date1.addDays(-1); startDateEdit->setDate( date1 ); } else if( name == "startDateEdit" ) { date2 = date2.addDays(1); endDateEdit->setDate( date2 ); } } }
QWidget* Date::createEditor(QWidget * parent, const QModelIndex & index) { Q_UNUSED(index); QDateEdit *de = new QDateEdit(parent); de->setDate(value().toDate()); connect(de, SIGNAL(dateChanged(const QDate&)), this, SLOT(setValue(const QDate&))); return de; }
void DateDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QDateEdit * dateEdit = static_cast<QDateEdit*>(editor); QString value = dateEdit->date().toString("yyyy-MM-dd"); model->setData(index, value, Qt::EditRole); }
QWidget *CalendarDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem& /* option */, const QModelIndex& /* index */) const { QDateEdit *editor = new QDateEdit(parent); editor->setCalendarPopup(m_calpopup); editor->installEventFilter(const_cast<CalendarDelegate*>(this)); connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor())); return editor; }
QWidget *DateDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const { Q_UNUSED(option); Q_UNUSED(index); QDateEdit * dateEdit = new QDateEdit(parent); dateEdit->setDisplayFormat("yyyy-MM-dd"); return dateEdit; }
uint64_t ExprParamElement::getIntValueFromField(QString fieldName, bool isToField,bool *ok) { uint64_t val = 0; if(ok!=NULL) *ok=true ; QString suffix = (isToField) ? "2": "1" ; // NOTE qFindChild necessary for MSVC 6 compatibility!! switch (searchType) { case DateSearch: { QDateEdit * dateEdit = qFindChild<QDateEdit *> (internalframe, (fieldName + suffix)); QDateTime * time = new QDateTime(dateEdit->date()); val = (uint64_t)time->toTime_t(); break; } case SizeSearch: { QLineEdit * lineEditSize = qFindChild<QLineEdit*>(internalframe, (fieldName + suffix)); bool ok2 = false; val = (lineEditSize->displayText()).toULongLong(&ok2); if (ok2) { QComboBox * cb = qFindChild<QComboBox*> (internalframe, (QString("unitsCb") + suffix)); QVariant data = cb->itemData(cb->currentIndex()); val *= data.toULongLong(); } else if(ok!=NULL) *ok=false ; break; } case PopSearch: // not implemented /* { QLineEdit * lineEditPop = qFindChild<QLineEdit*>(elem, (fieldName + suffix)); bool ok = false; val = (lineEditPop->displayText()).toInt(&ok); if (!ok) { val = -1; } break; }*/ case NameSearch: case PathSearch: case ExtSearch: case HashSearch: default: // shouldn't be here...val stays at -1 if(ok!=NULL) *ok=false ; } return val; }
//! [6] void Window::createDateTimeEdits() { editsGroup = new QGroupBox(tr("Date and time spin boxes")); QLabel *dateLabel = new QLabel; QDateEdit *dateEdit = new QDateEdit(QDate::currentDate()); dateEdit->setDateRange(QDate(2005, 1, 1), QDate(2010, 12, 31)); dateLabel->setText(tr("Appointment date (between %0 and %1):") .arg(dateEdit->minimumDate().toString(Qt::ISODate)) .arg(dateEdit->maximumDate().toString(Qt::ISODate))); //! [6] //! [7] QLabel *timeLabel = new QLabel; QTimeEdit *timeEdit = new QTimeEdit(QTime::currentTime()); timeEdit->setTimeRange(QTime(9, 0, 0, 0), QTime(16, 30, 0, 0)); timeLabel->setText(tr("Appointment time (between %0 and %1):") .arg(timeEdit->minimumTime().toString(Qt::ISODate)) .arg(timeEdit->maximumTime().toString(Qt::ISODate))); //! [7] //! [8] meetingLabel = new QLabel; meetingEdit = new QDateTimeEdit(QDateTime::currentDateTime()); //! [8] //! [9] QLabel *formatLabel = new QLabel(tr("Format string for the meeting date " "and time:")); QComboBox *formatComboBox = new QComboBox; formatComboBox->addItem("yyyy-MM-dd hh:mm:ss (zzz 'ms')"); formatComboBox->addItem("hh:mm:ss MM/dd/yyyy"); formatComboBox->addItem("hh:mm:ss dd/MM/yyyy"); formatComboBox->addItem("hh:mm:ss"); formatComboBox->addItem("hh:mm ap"); //! [9] //! [10] connect(formatComboBox, SIGNAL(activated(const QString &)), this, SLOT(setFormatString(const QString &))); //! [10] setFormatString(formatComboBox->currentText()); //! [11] QVBoxLayout *editsLayout = new QVBoxLayout; editsLayout->addWidget(dateLabel); editsLayout->addWidget(dateEdit); editsLayout->addWidget(timeLabel); editsLayout->addWidget(timeEdit); editsLayout->addWidget(meetingLabel); editsLayout->addWidget(meetingEdit); editsLayout->addWidget(formatLabel); editsLayout->addWidget(formatComboBox); editsGroup->setLayout(editsLayout); }
void BudgetEntityDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { BudgetEntity entity = qvariant_cast<BudgetEntity>(index.data()); QDateEdit *dateEdit = qobject_cast<QDateEdit *>( editor->layout()->itemAt(0)->widget() ); QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>( editor->layout()->itemAt(1)->widget() ); QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox *>( editor->layout()->itemAt(2)->widget() ); dateEdit->setDate(entity.date()); textEdit->setPlainText(entity.description()); spinBox->setValue(entity.amount()); }
void tst_QItemDelegate::dateTimeEditor() { QFETCH(QTime, time); QFETCH(QDate, date); QTableWidgetItem *item1 = new QTableWidgetItem; item1->setData(Qt::DisplayRole, time); QTableWidgetItem *item2 = new QTableWidgetItem; item2->setData(Qt::DisplayRole, date); QTableWidgetItem *item3 = new QTableWidgetItem; item3->setData(Qt::DisplayRole, QDateTime(date, time)); QTableWidget widget(1, 3); widget.setItem(0, 0, item1); widget.setItem(0, 1, item2); widget.setItem(0, 2, item3); widget.show(); widget.editItem(item1); QTestEventLoop::instance().enterLoop(1); QTimeEdit *timeEditor = qFindChild<QTimeEdit *>(widget.viewport()); QVERIFY(timeEditor); QCOMPARE(timeEditor->time(), time); widget.clearFocus(); qApp->setActiveWindow(&widget); widget.setFocus(); widget.editItem(item2); QTestEventLoop::instance().enterLoop(1); QDateEdit *dateEditor = qFindChild<QDateEdit *>(widget.viewport()); QVERIFY(dateEditor); QCOMPARE(dateEditor->date(), date); widget.clearFocus(); widget.setFocus(); widget.editItem(item3); QTestEventLoop::instance().enterLoop(1); QList<QDateTimeEdit *> dateTimeEditors = widget.findChildren<QDateTimeEdit *>(); QDateTimeEdit *dateTimeEditor = 0; foreach(dateTimeEditor, dateTimeEditors) if (dateTimeEditor->metaObject()->className() == QLatin1String("QDateTimeEdit")) break; QVERIFY(dateTimeEditor); QCOMPARE(dateTimeEditor->date(), date); QCOMPARE(dateTimeEditor->time(), time); }
void MultiDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QVariant value; QString className = editor->metaObject()->className(); if (className == "QTimeEdit") { QTimeEdit* ed = qobject_cast<QTimeEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->time()); } else if (className == "QDateEdit") { QDateEdit* ed = qobject_cast<QDateEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->date()); } else if (className == "QDateTimeEdit") { QDateTimeEdit* ed = qobject_cast<QDateTimeEdit*>(editor); Q_ASSERT( ed); value = QVariant( ed->dateTime()); } else if (className == "IconViewer") { return; } else if (className == "QComboBox") { QComboBox* ed = qobject_cast<QComboBox*>(editor); Q_ASSERT( ed); value = QVariant( ed->currentText()); } else if (className == "QListWidget") { QListWidget* ed = qobject_cast<QListWidget*>(editor); Q_ASSERT( ed); QStringList valList; int itemCount = ed->count(); for (int i = 0; i < itemCount; ++i) { QListWidgetItem* bitItem = ed->item(i); bool isChecked = (bitItem->checkState() == Qt::Checked); if (isChecked) valList += bitItem->text(); } value = QVariant( valList); } else if (className == "QCheckBox") { QCheckBox* ed = qobject_cast<QCheckBox*>(editor); Q_ASSERT( ed); value = QVariant( ed->isChecked()); } else { QItemDelegate::setModelData( editor, model, index); return; } model->setData(index, value, Qt::EditRole); }
void DateTimeDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { QDateEdit *dateEdit = qobject_cast<QDateEdit*>(editor); if (dateEdit) { model->setData(index, dateEdit->date(), Qt::EditRole); } else { QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor); if (dateTimeEdit) { model->setData(index, dateTimeEdit->dateTime(), Qt::EditRole); } } }
void DateTimeDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QDateEdit *dateEdit = qobject_cast<QDateEdit*>(editor); if (dateEdit) { dateEdit->setDate(index.data(Qt::EditRole).toDate()); } else { QDateTimeEdit *dateTimeEdit = qobject_cast<QDateTimeEdit*>(editor); if (dateTimeEdit) { dateTimeEdit->setDateTime(index.data(Qt::EditRole).toDateTime()); } } }
// We don't set anything because the data is saved within the view not the model! void RideDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { // stored as text field if (index.column() == dateColumn) { QDateEdit *dateEdit = qobject_cast<QDateEdit *>(editor); QDate date = QDate().fromString(index.model()->data(index, Qt::DisplayRole).toString(), "dd MMM yyyy");; dateEdit->setDate(date); } else if (index.column() == dateColumn+1) { QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor); QTime time = QTime().fromString(index.model()->data(index, Qt::DisplayRole).toString(), "hh:mm:ss a");; timeEdit->setTime(time); } }
// We don't set anything because the data is saved within the view not the model! void RideDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { // stored as text field if (index.column() == dateColumn) { QDateEdit *dateEdit = qobject_cast<QDateEdit *>(editor); QString value = dateEdit->date().toString("dd MMM yyyy"); // Place in the view model->setData(index, value, Qt::DisplayRole); } else if (index.column() == dateColumn+1) { QTimeEdit *timeEdit = qobject_cast<QTimeEdit *>(editor); QString value = timeEdit->time().toString("hh:mm:ss a"); model->setData(index, value, Qt::DisplayRole); } }
void AlbumDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { if( index.column() == 1 ) { QDateEdit *dateEdit = qobject_cast<QDateEdit*>(editor); QDate editedDate = dateEdit->date(); model->setData( index, editedDate, Qt::EditRole ); } else { QItemDelegate::setModelData(editor, model, index); } }
void BudgetEntityDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const { BudgetEntity entity = qvariant_cast<BudgetEntity>(index.data()); QDateEdit *dateEdit = qobject_cast<QDateEdit *>( editor->layout()->itemAt(0)->widget() ); QPlainTextEdit *textEdit = qobject_cast<QPlainTextEdit *>( editor->layout()->itemAt(1)->widget() ); QDoubleSpinBox *spinBox = qobject_cast<QDoubleSpinBox *>( editor->layout()->itemAt(2)->widget() ); entity.setDate(dateEdit->date()); entity.setDescription(textEdit->toPlainText()); entity.setAmount(spinBox->value()); QVariant val; val.setValue<BudgetEntity>(entity); model->setData(index, val, Qt::EditRole); }
void QWidgetBusinessTrip::doToolBar() { toolBar_ = new QToolBar(this); QList<QAction*> listActions; QAction *act; act = new QAction(this); act->setIcon(QIcon(":/CTRL/refresh")); act->setToolTip("Обновить"); listActions.push_back(act); connect(act, SIGNAL(triggered(bool)), SLOT(slotRefresh())); toolBar_->addActions(listActions); QWidget *widget; QDateEdit *dateEdit; widget = new QWidget(toolBar_); widget->setLayout(new QVBoxLayout()); widget->layout()->addWidget(new QLabel("Дата с")); dateEdit = new QDateEdit(this); dateEdit->setCalendarPopup(true); dateEdit->setDate(dateStart_); connect(dateEdit, SIGNAL(dateChanged(QDate)), SLOT(slotChangeDateStart(QDate))); widget->layout()->addWidget(dateEdit); toolBar_->addWidget(widget); widget = new QWidget(toolBar_); widget->setLayout(new QVBoxLayout()); widget->layout()->addWidget(new QLabel("Дата по")); dateEdit = new QDateEdit(this); dateEdit->setCalendarPopup(true); dateEdit->setDate(dateEnd_); connect(dateEdit, SIGNAL(dateChanged(QDate)), SLOT(slotChangeDateEnd(QDate))); widget->layout()->addWidget(dateEdit); toolBar_->addWidget(widget); widget = new QWidget(toolBar_); widget->setLayout(new QVBoxLayout()); widget->layout()->addWidget(new QLabel("Сотрудник")); editEmployee_ = new QLineEdit(toolBar_); connect(editEmployee_, SIGNAL(editingFinished()), SLOT(slotRefresh())); widget->layout()->addWidget(editEmployee_); toolBar_->addWidget(widget); toolBar_->setIconSize(QSize(40,40)); layout_->addWidget(toolBar_); }
QWidget *PupilContActivityDelegate::createEditor ( QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index ) const { switch ( index.column() ) { case 2: { QStringList typeList; typeList << tr("Ensemble") << tr("Theorieunterricht") << tr("Korrepetition") << tr("Sonstiges"); QComboBox *combo = new QComboBox ( parent ); combo->insertItems ( 0, typeList ); connect ( combo, SIGNAL ( activated ( int ) ), this, SLOT ( emitCommitData() ) ); return combo; } break; case 3: { QStringList dayList; dayList << tr("Montag") << tr("Dienstag") << tr("Mittwoch") << tr("Donnerstag") << tr("Freitag") << tr("Samstag") << tr("Sonntag") << QString::fromUtf8(tr("unregelmäßig").toStdString().c_str()); QComboBox *combo = new QComboBox ( parent ); combo->insertItems ( 0, dayList ); connect ( combo, SIGNAL ( activated ( int ) ), this, SLOT ( emitCommitData() ) ); return combo; } break; case 4: { QTimeEdit *time = new QTimeEdit ( parent ); connect ( time, SIGNAL ( dateChanged ( const QDate ) ), this, SLOT ( emitCommitData() ) ); return time; } break; case 5: { QDateEdit *cal = new QDateEdit ( parent ); cal->setCalendarPopup ( true ); connect ( cal, SIGNAL ( dateChanged ( const QDate ) ), this, SLOT ( emitCommitData() ) ); return cal; } break; case 6: { QDateEdit *cal1 = new QDateEdit ( parent ); cal1->setCalendarPopup ( true ); connect ( cal1, SIGNAL ( dateChanged ( const QDate ) ), this, SLOT ( emitCommitData() ) ); return cal1; } break; default: return QItemDelegate::createEditor ( parent, option, index ); break; } }
void MainWindow::saveData() { QFile file(data_file_name_); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << password_ << endl; stream << ui_->EventsTable->rowCount() << endl; for (int i = 0; i < ui_->EventsTable->rowCount(); ++i) { QTableWidgetItem* name = ui_->EventsTable->item(i, 0); QTableWidgetItem* descr = ui_->EventsTable->item(i, 1); QDateEdit* date = dynamic_cast<QDateEdit*>(ui_->EventsTable->cellWidget(i, 2)); QComboBox* level = dynamic_cast<QComboBox*>(ui_->EventsTable->cellWidget(i, 3)); stream << name->text() << '\n' << descr->text() << '\n' << date->text() << '\n' << level->currentIndex() << endl; } stream << ui_->FriendsTable->rowCount() << endl; for (int i = 0; i < ui_->FriendsTable->rowCount(); ++i) { QTableWidgetItem* name = ui_->FriendsTable->item(i, 0); QComboBox* level = dynamic_cast<QComboBox*>(ui_->FriendsTable->cellWidget(i, 1)); QTableWidgetItem* descr = ui_->FriendsTable->item(i, 2); QDateEdit* date = dynamic_cast<QDateEdit*>(ui_->FriendsTable->cellWidget(i, 3)); stream << name->text() << '\n' << level->currentIndex() << '\n' << descr->text() << '\n' << date->text() << endl; } stream << money_.getCurRubNalValue() << ' ' << money_.getCurEurNalValue() << ' ' << money_.getCurUsdNalValue() << ' ' << money_.getCurRubElecValue() << ' ' << money_.getCurEurElecValue() << ' ' << money_.getCurUsdElecValue() << ' ' << money_.getOldRubNalValue() << ' ' << money_.getOldEurNalValue() << ' ' << money_.getOldUsdNalValue() << ' ' << money_.getOldRubElecValue() << ' ' << money_.getOldEurElecValue() << ' ' << money_.getOldUsdElecValue() << endl; stream << ui_->NotesTextField->toPlainText(); } file.close(); }
void DBFRedactorDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { switch (m_redactor->field(index.column()).type) { case DBFRedactor::TYPE_DATE: { QDateEdit *edit = qobject_cast<QDateEdit*> (editor); edit->setDate(index.data(Qt::EditRole).toDate()); break; } case DBFRedactor::TYPE_FLOAT: case DBFRedactor::TYPE_NUMERIC: { QDoubleSpinBox *edit = qobject_cast<QDoubleSpinBox*> (editor); edit->setValue(index.data(Qt::EditRole).toDouble()); break; } default: { QLineEdit *edit = qobject_cast<QLineEdit*> (editor); edit->setText(index.data(Qt::EditRole).toString()); } } }
QString ExprParamElement::toString() { QString str = ""; if (isStringSearchExpression()) { str = QString("\"") + getStrSearchValue() + QString("\""); // we don't bother with case if hash search if (searchType != HashSearch) { str += (ignoreCase() ? QString(" (ignore case)") : QString(" (case sensitive)")); } } else { if (searchType == DateSearch) { QDateEdit * dateEdit = qFindChild<QDateEdit *> (internalframe, "param1"); str = dateEdit->text(); if (inRangedConfig) { str += QString(" ") + tr("to") + QString(" "); dateEdit = qFindChild<QDateEdit *> (internalframe, "param2"); str += dateEdit->text(); } } else if (searchType == SizeSearch) { QLineEdit * lineEditSize = qFindChild<QLineEdit*>(internalframe, "param1"); str = ("" == lineEditSize->text()) ? "0" : lineEditSize->text(); QComboBox * cb = qFindChild<QComboBox*> (internalframe, "unitsCb1"); str += QString(" ") + cb->itemText(cb->currentIndex()); if (inRangedConfig) { str += QString(" ") + tr("to") + QString(" "); lineEditSize = qFindChild<QLineEdit*>(internalframe, "param2"); str += ("" == lineEditSize->text()) ? "0" : lineEditSize->text(); cb = qFindChild<QComboBox*> (internalframe, "unitsCb2"); str += QString(" ") + cb->itemText(cb->currentIndex()); } } } return str; }