[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/krss/krssreader
From: Dmitry Ivanov <vonami () gmail ! com>
Date: 2008-06-29 8:28:46
Message-ID: 1214728126.438636.15198.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 825723 by divanov:
Implement MarkNew, MarkImportant, and DeleteArticle actions
M +3 -0 krssreaderui.rc
M +69 -2 standardactionmanager.cpp
M +7 -0 standardactionmanager.h
--- trunk/playground/pim/krss/krssreader/krssreaderui.rc #825722:825723
@@ -18,7 +18,10 @@
</Menu>
<Menu name="article" >
<Text> Article </Text>
+ <Action name="krssreader_article_mark_new" />
<Action name="krssreader_article_mark_read" />
+ <Action name="krssreader_article_mark_important" />
+ <Action name="krssreader_article_delete" />
</Menu>
</MenuBar>
</kpartgui>
--- trunk/playground/pim/krss/krssreader/standardactionmanager.cpp #825722:825723
@@ -32,6 +32,7 @@
#include <akonadi/collectionmodifyjob.h>
#include <akonadi/collectiondeletejob.h>
#include <akonadi/itemmodifyjob.h>
+#include <akonadi/itemdeletejob.h>
#include <akonadi/agentmanager.h>
#include <KAction>
#include <KActionCollection>
@@ -62,7 +63,10 @@
{ "krssreader_manage_subscriptions", I18N_NOOP( "&Manage subscriptions" ), \
"", 0, SLOT( slotManageSubscriptions() ) },
{ "krssreader_import_opml", I18N_NOOP( "&Import feeds..." ), "", 0, SLOT( \
slotImportOpml() ) },
{ "krssreader_export_opml", I18N_NOOP( "&Export feeds..." ), "", 0, SLOT( \
slotExportOpml() ) },
- { "krssreader_article_mark_read", I18N_NOOP( "&Mark as read" ), "", 0, SLOT( \
slotMarkArticleRead() ) } + { "krssreader_article_mark_new", I18N_NOOP( "&Mark \
as new" ), "", 0, SLOT( slotMarkArticleNew() ) }, + { \
"krssreader_article_mark_read", I18N_NOOP( "&Mark as read" ), "", 0, SLOT( \
slotMarkArticleRead() ) }, + { "krssreader_article_mark_important", I18N_NOOP( \
"&Mark as important" ), "", 0, SLOT( slotMarkArticleImportant() ) }, + { \
"krssreader_article_delete", I18N_NOOP( "&Delete article" ), "", 0, SLOT( \
slotDeleteArticle() ) } };
static const int numActionData = sizeof (actionData) / sizeof (*actionData);
@@ -169,7 +173,10 @@
if ( !selectedIndex.isValid() )
return;
+ enableAction( StandardActionManager::MarkArticleNew, true );
enableAction( StandardActionManager::MarkArticleRead, true );
+ enableAction( StandardActionManager::MarkArticleImportant, true );
+ enableAction( StandardActionManager::DeleteArticle, true );
}
void StandardActionManager::slotCreateFeed()
@@ -386,9 +393,27 @@
}
}
+void StandardActionManager::slotMarkArticleNew()
+{
+ QModelIndex selectedIndex;
+ if ( m_articleSelectionModel && m_articleSelectionModel->hasSelection() )
+ selectedIndex = m_articleSelectionModel->selectedRows().first();
+
+ if ( !selectedIndex.isValid() )
+ return;
+
+ Akonadi::Item item = selectedIndex.data( ArticleModel::ItemRole \
).value<Akonadi::Item>(); + item.clearFlag( "\\Seen" );
+ item.setFlag( "\\Recent" );
+
+ Akonadi::ItemModifyJob *job = new Akonadi::ItemModifyJob( item, this );
+ job->setIgnorePayload( true );
+ connect( job, SIGNAL( result( KJob* ) ),
+ this, SLOT( itemModifyResult( KJob* ) ) );
+}
+
void StandardActionManager::slotMarkArticleRead()
{
- kDebug();
QModelIndex selectedIndex;
if ( m_articleSelectionModel && m_articleSelectionModel->hasSelection() )
selectedIndex = m_articleSelectionModel->selectedRows().first();
@@ -406,6 +431,40 @@
this, SLOT( itemModifyResult( KJob* ) ) );
}
+void StandardActionManager::slotMarkArticleImportant()
+{
+ QModelIndex selectedIndex;
+ if ( m_articleSelectionModel && m_articleSelectionModel->hasSelection() )
+ selectedIndex = m_articleSelectionModel->selectedRows().first();
+
+ if ( !selectedIndex.isValid() )
+ return;
+
+ Akonadi::Item item = selectedIndex.data( ArticleModel::ItemRole \
).value<Akonadi::Item>(); + item.setFlag( "\\Important" );
+
+ Akonadi::ItemModifyJob *job = new Akonadi::ItemModifyJob( item, this );
+ job->setIgnorePayload( true );
+ connect( job, SIGNAL( result( KJob* ) ),
+ this, SLOT( itemModifyResult( KJob* ) ) );
+}
+
+void StandardActionManager::slotDeleteArticle()
+{
+ QModelIndex selectedIndex;
+ if ( m_articleSelectionModel && m_articleSelectionModel->hasSelection() )
+ selectedIndex = m_articleSelectionModel->selectedRows().first();
+
+ if ( !selectedIndex.isValid() )
+ return;
+
+ Akonadi::Item::Id id = selectedIndex.data( ArticleModel::IdRole \
).value<Akonadi::Item::Id>(); +
+ Akonadi::ItemDeleteJob *job = new Akonadi::ItemDeleteJob( Akonadi::Item( id \
), this ); + connect( job, SIGNAL( result( KJob* ) ),
+ this, SLOT( itemDeleteResult( KJob* ) ) );
+}
+
void StandardActionManager::collectionCreationResult( KJob* job )
{
if ( job->error() ) {
@@ -438,4 +497,12 @@
}
}
+void StandardActionManager::itemDeletionResult( KJob* job )
+{
+ if ( job->error() ) {
+ KMessageBox::error( m_parentWidget, i18n("Could not delete the \
article: %1", job->errorString() ), + i18n( \
"Article deletion failed" ) ); + }
+}
+
#include "standardactionmanager.moc"
--- trunk/playground/pim/krss/krssreader/standardactionmanager.h #825722:825723
@@ -44,7 +44,10 @@
ManageSubscriptions,
ImportOpml,
ExportOpml,
+ MarkArticleNew,
MarkArticleRead,
+ MarkArticleImportant,
+ DeleteArticle,
LastType
};
@@ -73,13 +76,17 @@
void slotManageSubscriptions();
void slotImportOpml();
void slotExportOpml();
+ void slotMarkArticleNew();
void slotMarkArticleRead();
+ void slotMarkArticleImportant();
+ void slotDeleteArticle();
void updateActions();
void collectionCreationResult( KJob* job );
void collectionDeletionResult( KJob* job );
void collectionModifyResult( KJob* job );
void itemModifyResult( KJob* job );
+ void itemDeletionResult( KJob* job );
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic