[Bug 260795] cannot edit a mail from the local folder/templates
Tobias Koenig
tokoe at kde.org
Tue Dec 28 13:21:13 GMT 2010
https://bugs.kde.org/show_bug.cgi?id=260795
Tobias Koenig <tokoe at kde.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #1 from Tobias Koenig <tokoe kde org> 2010-12-28 14:21:12 ---
commit 4c987eae234e75fc92a49ea08c67e573e72d5d2a
branch master
Author: Tobias Koenig <tokoe at kde.org>
Date: Tue Dec 28 14:24:15 2010 +0100
Open composer when clicking on template mail
BUG: 260795
diff --git a/mobile/mail/kmail-mobile.qml b/mobile/mail/kmail-mobile.qml
index 74aca88..0a7b0c0 100644
--- a/mobile/mail/kmail-mobile.qml
+++ b/mobile/mail/kmail-mobile.qml
@@ -308,6 +308,9 @@ KPIM.MainView {
{
application.restoreDraft(_itemNavigationModel.currentItemIdHack);
updateContextActionStates()
+ } else if (
application.isTemplateThreadRoot(_threadSelector.currentRow ) ) {
+
application.restoreTemplate(_itemNavigationModel.currentItemIdHack);
+ updateContextActionStates()
} else {
guiStateManager.pushUniqueState(
KPIM.GuiStateManager.ViewSingleItemState );
}
@@ -349,6 +352,9 @@ KPIM.MainView {
{
application.restoreDraft(threadContentsView.currentItemId);
updateContextActionStates()
+ } else if ( application.isTemplateThreadContent(
_threadMailSelector.currentRow ) ) {
+ application.restoreTemplate(threadContentsView.currentItemId);
+ updateContextActionStates()
} else {
guiStateManager.pushUniqueState(
KPIM.GuiStateManager.ViewSingleItemState );
}
diff --git a/mobile/mail/mainview.cpp b/mobile/mail/mainview.cpp
index 3ea1cba..4ce8970 100644
--- a/mobile/mail/mainview.cpp
+++ b/mobile/mail/mainview.cpp
@@ -1044,6 +1044,30 @@ bool MainView::isSingleMessage(int row)
return threadSize == 1;
}
+bool MainView::isTemplateThreadContent( int row )
+{
+ static const int column = 0;
+ const QModelIndex index = m_threadContentsModel->index( row, column );
+
+ const Item item = index.data( EntityTreeModel::ItemRole ).value<Item>();
+
+ return folderIsTemplates( item.parentCollection() );
+}
+
+bool MainView::isTemplateThreadRoot( int row )
+{
+ static const int column = 0;
+ const QModelIndex index = m_threadsModel->index( row, column );
+
+ const int threadSize = index.data( ThreadModel::ThreadSizeRole ).toInt();
+ if ( threadSize != 1 )
+ return false;
+
+ const Item item = index.data( EntityTreeModel::ItemRole ).value<Item>();
+
+ return folderIsTemplates( item.parentCollection() );
+}
+
// #############################################################
// ### Share the code between these marks with KMail Desktop?
@@ -1127,6 +1151,29 @@ bool MainView::folderIsDrafts( const Collection
&collection )
return false;
}
+bool MainView::folderIsTemplates( const Collection &collection )
+{
+ const Collection defaultTemplatesCollection =
SpecialMailCollections::self()->defaultCollection(
SpecialMailCollections::Templates );
+
+ // check if this is the default templates folder
+ if ( collection == defaultTemplatesCollection )
+ return true;
+
+ // check for invalid collection
+ const QString idString = QString::number( collection.id() );
+ if ( idString.isEmpty() )
+ return false;
+
+ // search the identities if the folder matches the drafts-folder
+ const KPIMIdentities::IdentityManager *im =
MobileKernel::self()->identityManager();
+ for ( KPIMIdentities::IdentityManager::ConstIterator it = im->begin(); it !=
im->end(); ++it ) {
+ if ( (*it).templates() == idString )
+ return true;
+ }
+
+ return false;
+}
+
void MainView::deleteItemResult( KJob *job )
{
if ( job->error() ) {
@@ -1523,6 +1570,14 @@ int MainView::emailTemplateCount()
return mEmailTemplateModel ? mEmailTemplateModel->rowCount() : 0;
}
+void MainView::restoreTemplate( quint64 id )
+{
+ ItemFetchJob *job = new ItemFetchJob( Item( id ), this );
+ job->fetchScope().fetchFullPayload();
+ job->fetchScope().setAncestorRetrieval( ItemFetchScope::Parent );
+ connect( job, SIGNAL( result( KJob* ) ), SLOT( templateFetchResult( KJob* )
) );
+}
+
void MainView::newMessageFromTemplate( int index )
{
Akonadi::Item item = mEmailTemplateModel->index( index, 0 ).data(
Akonadi::EntityTreeModel::ItemRole ).value<Akonadi::Item>();
diff --git a/mobile/mail/mainview.h b/mobile/mail/mainview.h
index ab66104..0f40c30 100644
--- a/mobile/mail/mainview.h
+++ b/mobile/mail/mainview.h
@@ -93,6 +93,7 @@ class MainView : public KDeclarativeMainView
public Q_SLOTS:
void startComposer();
void restoreDraft( quint64 id );
+ void restoreTemplate( quint64 id );
void markImportant( bool checked );
void markMailTask( bool checked );
@@ -103,6 +104,9 @@ class MainView : public KDeclarativeMainView
bool isDraftThreadRoot( int row );
bool isSingleMessage( int row );
bool folderIsDrafts( const Akonadi::Collection &collection );
+ bool isTemplateThreadContent( int row );
+ bool isTemplateThreadRoot( int row );
+ bool folderIsTemplates( const Akonadi::Collection &collection );
void configureIdentity();
--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the Kdepim-bugs
mailing list