Changeset View
Changeset View
Standalone View
Standalone View
src/incidencedialog.cpp
Show First 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 94 | public: | |||
---|---|---|---|---|---|
103 | void saveTemplate(const QString &templateName); | 103 | void saveTemplate(const QString &templateName); | ||
104 | void storeTemplatesInConfig(const QStringList &newTemplates); | 104 | void storeTemplatesInConfig(const QStringList &newTemplates); | ||
105 | void updateAttachmentCount(int newCount); | 105 | void updateAttachmentCount(int newCount); | ||
106 | void updateAttendeeCount(int newCount); | 106 | void updateAttendeeCount(int newCount); | ||
107 | void updateResourceCount(int newCount); | 107 | void updateResourceCount(int newCount); | ||
108 | void updateButtonStatus(bool isDirty); | 108 | void updateButtonStatus(bool isDirty); | ||
109 | void showMessage(const QString &text, KMessageWidget::MessageType type); | 109 | void showMessage(const QString &text, KMessageWidget::MessageType type); | ||
110 | void slotInvalidCollection(); | 110 | void slotInvalidCollection(); | ||
111 | void setCalendarCollection(const Akonadi::Collection &collection); | ||||
111 | 112 | | |||
112 | /// ItemEditorUi methods | 113 | /// ItemEditorUi methods | ||
113 | bool containsPayloadIdentifiers(const QSet<QByteArray> &partIdentifiers) const override; | 114 | bool containsPayloadIdentifiers(const QSet<QByteArray> &partIdentifiers) const override; | ||
114 | void handleItemSaveFinish(EditorItemManager::SaveAction); | 115 | void handleItemSaveFinish(EditorItemManager::SaveAction); | ||
115 | void handleItemSaveFail(EditorItemManager::SaveAction, const QString &errorMessage); | 116 | void handleItemSaveFail(EditorItemManager::SaveAction, const QString &errorMessage); | ||
116 | bool hasSupportedPayload(const Akonadi::Item &item) const override; | 117 | bool hasSupportedPayload(const Akonadi::Item &item) const override; | ||
117 | bool isDirty() const override; | 118 | bool isDirty() const override; | ||
118 | bool isValid() const override; | 119 | bool isValid() const override; | ||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 136 | { | |||
176 | 177 | | |||
177 | mIeAttendee = new IncidenceAttendee(qq, mIeDateTime, mUi); | 178 | mIeAttendee = new IncidenceAttendee(qq, mIeDateTime, mUi); | ||
178 | mIeAttendee->setParent(qq); | 179 | mIeAttendee->setParent(qq); | ||
179 | mEditor->combine(mIeAttendee); | 180 | mEditor->combine(mIeAttendee); | ||
180 | 181 | | |||
181 | mIeResource = new IncidenceResource(mIeAttendee, mIeDateTime, mUi); | 182 | mIeResource = new IncidenceResource(mIeAttendee, mIeDateTime, mUi); | ||
182 | mEditor->combine(mIeResource); | 183 | mEditor->combine(mIeResource); | ||
183 | 184 | | |||
185 | // Select calendar to last collection used, if valid; else select the default collection | ||||
184 | const qint64 colId = IncidenceEditorNG::IncidenceEditorSettings::self()->lastSelectedFolder(); | 186 | const qint64 colId = IncidenceEditorNG::IncidenceEditorSettings::self()->lastSelectedFolder(); | ||
185 | const Akonadi::Collection col(colId); | 187 | const Akonadi::Collection col(colId); | ||
186 | if (col.isValid()) { | 188 | setCalendarCollection(col); | ||
187 | mCalSelector->setDefaultCollection(col); | | |||
188 | } | | |||
189 | 189 | | |||
190 | q->connect(mEditor, SIGNAL(showMessage(QString,KMessageWidget::MessageType)), | 190 | q->connect(mEditor, SIGNAL(showMessage(QString,KMessageWidget::MessageType)), | ||
191 | SLOT(showMessage(QString,KMessageWidget::MessageType))); | 191 | SLOT(showMessage(QString,KMessageWidget::MessageType))); | ||
192 | q->connect(mEditor, SIGNAL(dirtyStatusChanged(bool)), | 192 | q->connect(mEditor, SIGNAL(dirtyStatusChanged(bool)), | ||
193 | SLOT(updateButtonStatus(bool))); | 193 | SLOT(updateButtonStatus(bool))); | ||
194 | q->connect(mItemManager, | 194 | q->connect(mItemManager, | ||
195 | SIGNAL(itemSaveFinished(IncidenceEditorNG::EditorItemManager::SaveAction)), | 195 | SIGNAL(itemSaveFinished(IncidenceEditorNG::EditorItemManager::SaveAction)), | ||
196 | SLOT(handleItemSaveFinish(IncidenceEditorNG::EditorItemManager::SaveAction))); | 196 | SLOT(handleItemSaveFinish(IncidenceEditorNG::EditorItemManager::SaveAction))); | ||
Show All 19 Lines | 213 | { | |||
216 | delete mUi; | 216 | delete mUi; | ||
217 | } | 217 | } | ||
218 | 218 | | |||
219 | void IncidenceDialogPrivate::slotInvalidCollection() | 219 | void IncidenceDialogPrivate::slotInvalidCollection() | ||
220 | { | 220 | { | ||
221 | showMessage(i18n("Select a valid collection first."), KMessageWidget::Warning); | 221 | showMessage(i18n("Select a valid collection first."), KMessageWidget::Warning); | ||
222 | } | 222 | } | ||
223 | 223 | | |||
224 | void IncidenceDialogPrivate::setCalendarCollection(const Akonadi::Collection &collection) | ||||
225 | { | ||||
226 | if (collection.isValid()) { | ||||
227 | mCalSelector->setDefaultCollection(collection); | ||||
228 | } else { | ||||
229 | // fallback to default collection | ||||
230 | const qint64 defColId = CalendarSupport::KCalPrefs::instance()->defaultCalendarId(); | ||||
231 | const Akonadi::Collection defCol(defColId); | ||||
232 | if (defCol.isValid()) { | ||||
233 | mCalSelector->setDefaultCollection(defCol); | ||||
234 | } else { | ||||
235 | // Give up and use the first item in the selector | ||||
236 | mCalSelector->setCurrentIndex(0); | ||||
237 | } | ||||
238 | } | ||||
239 | } | ||||
240 | | ||||
224 | void IncidenceDialogPrivate::showMessage(const QString &text, KMessageWidget::MessageType type) | 241 | void IncidenceDialogPrivate::showMessage(const QString &text, KMessageWidget::MessageType type) | ||
225 | { | 242 | { | ||
226 | mUi->mMessageWidget->setText(text); | 243 | mUi->mMessageWidget->setText(text); | ||
227 | mUi->mMessageWidget->setMessageType(type); | 244 | mUi->mMessageWidget->setMessageType(type); | ||
228 | mUi->mMessageWidget->show(); | 245 | mUi->mMessageWidget->show(); | ||
229 | } | 246 | } | ||
230 | 247 | | |||
231 | void IncidenceDialogPrivate::handleAlarmCountChange(int newCount) | 248 | void IncidenceDialogPrivate::handleAlarmCountChange(int newCount) | ||
▲ Show 20 Lines • Show All 533 Lines • ▼ Show 20 Line(s) | 779 | { | |||
765 | if (item.isValid()) { // We're editing | 782 | if (item.isValid()) { // We're editing | ||
766 | d->mItemManager->load(item); | 783 | d->mItemManager->load(item); | ||
767 | } else { // We're creating | 784 | } else { // We're creating | ||
768 | Q_ASSERT(d->hasSupportedPayload(item)); | 785 | Q_ASSERT(d->hasSupportedPayload(item)); | ||
769 | d->load(item); | 786 | d->load(item); | ||
770 | show(); | 787 | show(); | ||
771 | } | 788 | } | ||
772 | } | 789 | } | ||
773 | 790 | | |||
mlaurent: it seems to be 2 same code.
Please create a methods for removing this duplicate code.
Thanjks | |||||
774 | void IncidenceDialog::selectCollection(const Akonadi::Collection &collection) | 791 | void IncidenceDialog::selectCollection(const Akonadi::Collection &collection) | ||
775 | { | 792 | { | ||
776 | Q_D(IncidenceDialog); | 793 | Q_D(IncidenceDialog); | ||
777 | if (collection.isValid()) { | 794 | d->setCalendarCollection(collection); | ||
778 | d->mCalSelector->setDefaultCollection(collection); | | |||
779 | } else { | | |||
780 | d->mCalSelector->setCurrentIndex(0); | | |||
781 | } | | |||
782 | } | 795 | } | ||
783 | 796 | | |||
784 | void IncidenceDialog::setIsCounterProposal(bool isCounterProposal) | 797 | void IncidenceDialog::setIsCounterProposal(bool isCounterProposal) | ||
785 | { | 798 | { | ||
786 | Q_D(IncidenceDialog); | 799 | Q_D(IncidenceDialog); | ||
787 | d->mItemManager->setIsCounterProposal(isCounterProposal); | 800 | d->mItemManager->setIsCounterProposal(isCounterProposal); | ||
788 | } | 801 | } | ||
789 | 802 | | |||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |
it seems to be 2 same code.
Please create a methods for removing this duplicate code.
Thanjks