📄 entrydialog.cpp
字号:
connect( entry->repeatSelect, SIGNAL(activated(int)), this, SLOT(setRepeatType(int))); connect( entry->endDateSelect, SIGNAL(valueChanged(const QDate&)), this, SLOT(setEndDate(const QDate&))); connect( entry->spinAlarm, SIGNAL(valueChanged(int)), this, SLOT(turnOnAlarm()) ); connect( entry->comboSound, SIGNAL(activated(int)), this, SLOT(checkAlarmSpin(int)) ); connect( entry->endButton, SIGNAL(valueChanged(const QDateTime&)), this, SLOT(endDateTimeChanged(const QDateTime&)) ); connect( entry->startButton, SIGNAL(valueChanged(const QDateTime&)), this, SLOT(startDateTimeChanged(const QDateTime&)) );#ifdef QTOPIA_DESKTOP connect( buttonOk, SIGNAL(clicked()), this, SLOT(accept()) ); connect( buttonCancel, SIGNAL(clicked()), this, SLOT(reject()) );#endif#ifdef QTOPIA_DESKTOP setMaximumSize( sizeHint()*2 );#endif}/* * Destroys the object and frees any allocated resources */EntryDialog::~EntryDialog(){ // no need to delete child widgets, Qt does it all for us}/* * public slot */void EntryDialog::endDateTimeChanged( const QDateTime &e ){ entry->startButton->blockSignals(TRUE); entry->endButton->blockSignals(TRUE); QDateTime target = e; // since setting the start can change the end, do this first. if (target.addSecs(-300) < mEvent.start()) { mEvent.setStart(target.addSecs(-300)); } mEvent.setEnd(target); entry->startButton->setDateTime(mEvent.start()); entry->startButton->blockSignals(FALSE); entry->endButton->blockSignals(FALSE);}/* * public slot */void EntryDialog::startDateTimeChanged( const QDateTime &s ){ entry->startButton->blockSignals(TRUE); entry->endButton->blockSignals(TRUE); // start always works. mEvent.setStart(s); // modifying start modifies end, so no need check or modify anything. // just ensure we update the widget. entry->endButton->setDateTime(mEvent.end()); entry->startButton->blockSignals(FALSE); entry->endButton->blockSignals(FALSE);}void EntryDialog::slotRepeat(){ // Work around for compiler Bug.. RepeatEntry *e; event(); // update of the shown values; e = new RepeatEntry( startWeekOnMonday, mEvent, this ); if ( QPEApplication::execDialog(e) ) { mEvent = e->event(); entry->endDateSelect->setEnabled(TRUE); } setRepeatLabel();}void EntryDialog::setWeekStartsMonday( bool onMonday ){ startWeekOnMonday = onMonday;}PimEvent EntryDialog::event(){ mEvent.setDescription( entry->comboDescription->currentText() ); mEvent.setLocation( entry->comboLocation->currentText() ); mEvent.setCategories( entry->comboCategory->currentCategories() ); mEvent.setAllDay( entry->checkAllDay->isChecked() ); if (entry->endDateSelect->date().isValid()) { mEvent.setRepeatForever(FALSE); mEvent.setRepeatTill(entry->endDateSelect->date()); } else { mEvent.setRepeatForever(TRUE); } // don't set the time if theres no need too if (entry->timezone->currentZone() == "None") mEvent.setTimeZone(TimeZone()); else mEvent.setTimeZone(TimeZone(entry->timezone->currentZone())); // all day events don't have an alarm if ( entry->checkAllDay->isChecked() ) entry->comboSound->setCurrentItem(0); // we only have one type of sound at the moment... LOUD!!! switch (entry->comboSound->currentItem()) { case 0: mEvent.clearAlarm(); break; case 1: mEvent.setAlarm( entry->spinAlarm->value(), PimEvent::Silent); break; case 2: mEvent.setAlarm( entry->spinAlarm->value(), PimEvent::Loud); break; } // don't need to do repeat, repeat dialog handles that. mEvent.setNotes( editNote->text() );#ifdef QTOPIA_DATA_LINKING QString links; QDL::saveLinks( links, QDL::clients( this ) ); mEvent.setCustomField( QDL::DATA_KEY, links );#endif return mEvent;}void EntryDialog::setRepeatLabel(){ if (!mEvent.isException()) { if ( mEvent.hasRepeat() ) { //cmdRepeat->setText( tr("Repeat...") ); if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Daily) entry->repeatSelect->setCurrentItem(1); else if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Weekly && onceAWeek(mEvent)) entry->repeatSelect->setCurrentItem(2); else if (mEvent.frequency() == 1 && mEvent.repeatType() == PimEvent::Yearly) entry->repeatSelect->setCurrentItem(3); else entry->repeatSelect->setCurrentItem(4); } else { entry->repeatSelect->setCurrentItem(0); } }}void EntryDialog::allDayToggled(bool b){ entry->startButton->setTimeEnabled(!b); entry->endButton->setTimeEnabled(!b); entry->comboSound->setEnabled(!b); entry->timezone->setEnabled(!b);}void EntryDialog::configureTimeZones(){#ifdef QTOPIA_DESKTOP // Show the WorldTime as a dialog WorldTimeDialog dlg(0, entry->timezone); dlg.exec();#endif}void EntryDialog::turnOnAlarm(){ // if alarm spin spun, then user probably wants an alarm. Make it loud :) if (entry->comboSound->currentItem() == 0 && entry->spinAlarm->value() != 0) entry->comboSound->setCurrentItem(2);}void EntryDialog::checkAlarmSpin(int aType){ entry->spinAlarm->setEnabled( aType != 0 );}void EntryDialog::setRepeatType(int i){ switch (i) { case 0: mEvent.setRepeatType(PimEvent::NoRepeat); entry->endDateSelect->setEnabled(FALSE); break; case 1: mEvent.setRepeatType(PimEvent::Daily); mEvent.setFrequency(1); entry->endDateSelect->setEnabled(TRUE); break; case 2: mEvent.setRepeatType(PimEvent::Weekly); mEvent.setFrequency(1); setOnceAWeek(mEvent); entry->endDateSelect->setEnabled(TRUE); break; case 3: mEvent.setRepeatType(PimEvent::Yearly); mEvent.setFrequency(1); entry->endDateSelect->setEnabled(TRUE); break; case 4: default: slotRepeat(); break; }}void EntryDialog::setEndDate(const QDate &date){ // chekc the date... if (date.isValid() && date < entry->startButton->date()) { entry->endDateSelect->blockSignals(TRUE); entry->endDateSelect->setDate(entry->startButton->date()); entry->endDateSelect->blockSignals(FALSE); }}void EntryDialog::updateCategories(){#ifdef QTOPIA_DESKTOP connect( this, SIGNAL( categoriesChanged() ), entry->comboCategory, SLOT( categoriesChanged() ) ); emit categoriesChanged(); disconnect( this, SIGNAL( categoriesChanged() ), entry->comboCategory, SLOT( categoriesChanged() ) );#endif}//#define ACCEPT_DEBUGvoid EntryDialog::accept(){ hide(); event(); PrEvent &oe = (PrEvent&)mOrigEvent; PrEvent &ne = (PrEvent&)mEvent; QValueList<int> fields; fields += PimEvent::Description; fields += PimEvent::Location; fields += PimEvent::StartTimeZone; fields += PimEvent::Notes; fields += PimEvent::StartDateTime; fields += PimEvent::EndDateTime; fields += PimEvent::DatebookType; fields += PimEvent::HasAlarm; fields += PimEvent::AlarmDelay; fields += PimEvent::SoundType; fields += PimEvent::RepeatPattern; fields += PimEvent::RepeatFrequency; fields += PimEvent::RepeatWeekdays; fields += PimEvent::RepeatHasEndDate; fields += PimEvent::RepeatEndDate; fields += PimEvent::RecordParent; fields += PimEvent::RecordChildren; fields += PimEvent::Exceptions; fields += PimRecord::Categories;#ifdef ACCEPT_DEBUG QMap<int, QString> fieldNames; fieldNames.insert( PimEvent::Description, "Description" ); fieldNames.insert( PimEvent::Location, "Location" ); fieldNames.insert( PimEvent::StartTimeZone, "StartTimeZone" ); fieldNames.insert( PimEvent::Notes, "Notes" ); fieldNames.insert( PimEvent::StartDateTime, "StartDateTime" ); fieldNames.insert( PimEvent::EndDateTime, "EndDateTime" ); fieldNames.insert( PimEvent::DatebookType, "DatebookType" ); fieldNames.insert( PimEvent::HasAlarm, "HasAlarm" ); fieldNames.insert( PimEvent::AlarmDelay, "AlarmDelay" ); fieldNames.insert( PimEvent::SoundType, "SoundType" ); fieldNames.insert( PimEvent::RepeatPattern, "RepeatPattern" ); fieldNames.insert( PimEvent::RepeatFrequency, "RepeatFrequency" ); fieldNames.insert( PimEvent::RepeatWeekdays, "RepeatWeekdays" ); fieldNames.insert( PimEvent::RepeatHasEndDate, "RepeatHasEndDate" ); fieldNames.insert( PimEvent::RepeatEndDate, "RepeatEndDate" ); fieldNames.insert( PimEvent::RecordParent, "RecordParent" ); fieldNames.insert( PimEvent::RecordChildren, "RecordChildren" ); fieldNames.insert( PimEvent::Exceptions, "Exceptions" ); fieldNames.insert( PimRecord::Categories, "Categories" );#endif bool modified = FALSE; for( QValueList<int>::ConstIterator it = fields.begin(); it != fields.end(); ++it ) { QString of = oe.field( *it ); QString nf = ne.field( *it );#ifdef ACCEPT_DEBUG qDebug( "%s %s %s", fieldNames[*it].latin1(), of.latin1(), nf.latin1() );#endif // if both are empty, we don't care that one is QString::null while the other is QString("") if ( !(of.isEmpty() && nf.isEmpty()) && of != nf ) { modified = TRUE; break; } } // Accepting the dialog is pointless if the contents haven't changed if ( modified ) { QDialog::accept(); } else { qDebug( "Event not modified" ); QDialog::reject(); }}void EntryDialog::tabChanged( QWidget *tab ){ if ( eventView && tab == eventView ) { eventView->init( event() ); }}void EntryDialog::showSummary(){ tw->showPage( eventView );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -