[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kdepim/work/akonadi-ports] akregator: clean up commands
From: Frank Osterfeld <frank.osterfeld () kdab ! com>
Date: 2011-09-20 22:36:09
Message-ID: 20110920223609.D8A6EA607A () git ! kde ! org
[Download RAW message or body]
Git commit 5de630ea1b063610126c3d0b603235db6a120dd1 by Frank Osterfeld.
Committed on 20/09/2011 at 23:20.
Pushed by osterfeld into branch 'work/akonadi-ports'.
clean up commands
M +11 -1 akregator/interfaces/command.cpp
M +8 -0 akregator/interfaces/command.h
M +4 -0 akregator/src/abstractselectioncontroller.h
M +15 -0 akregator/src/command_p.cpp
M +2 -1 akregator/src/command_p.h
M +9 -11 akregator/src/createfeedcommand.cpp
M +2 -2 akregator/src/createtagcommand.cpp
M +6 -12 akregator/src/editfeedcommand.cpp
M +65 -33 akregator/src/exportfeedlistcommand.cpp
M +8 -3 akregator/src/exportfeedlistcommand.h
M +2 -3 akregator/src/mainwidget.cpp
M +22 -8 akregator/src/selectioncontroller.cpp
M +6 -1 akregator/src/selectioncontroller.h
M +14 -17 akregator/src/setupakonadicommand.cpp
M +1 -2 akregator/src/setupakonadicommand.h
http://commits.kde.org/kdepim/5de630ea1b063610126c3d0b603235db6a120dd1
diff --git a/akregator/interfaces/command.cpp b/akregator/interfaces/command.cpp
index c1d2882..36f8662 100644
--- a/akregator/interfaces/command.cpp
+++ b/akregator/interfaces/command.cpp
@@ -113,11 +113,21 @@ void Command::setShowErrorDialog( bool s ) {
}
void Command::jobFinished() {
- if ( error() && d->showErrorDialog )
+ if ( error() && error() != UserCanceled && d->showErrorDialog )
//don't show error dialog synchronously, to not disturb the
//finished signals with a local event loop
(new ShowErrorJob( errorText(), d->parentWidget ))->start();
}
+void Command::setErrorAndEmitResult( const QString& errorText, int error ) {
+ setErrorText( errorText );
+ setError( error );
+ emitResult();
+}
+
+void Command::emitCanceled() {
+ setErrorAndEmitResult( i18n("User canceled"), Command::UserCanceled );
+}
+
#include "command.moc"
#include "command_p.moc"
diff --git a/akregator/interfaces/command.h b/akregator/interfaces/command.h
index 44d7336..118fdef 100644
--- a/akregator/interfaces/command.h
+++ b/akregator/interfaces/command.h
@@ -44,6 +44,12 @@ class AKREGATORINTERFACES_EXPORT Command : public KJob
friend class ::Akregator::EmitResultGuard;
public:
+
+ enum Error {
+ UserCanceled = KJob::UserDefinedError,
+ SomeError,
+ UserDefinedCommandError
+ };
explicit Command( QObject* parent = 0 );
virtual ~Command();
@@ -65,6 +71,8 @@ Q_SIGNALS:
protected:
void setShowErrorDialog( bool );
virtual void doStart() = 0;
+ void setErrorAndEmitResult( const QString& errorText, int error=SomeError );
+ void emitCanceled();
private Q_SLOTS:
void jobFinished();
diff --git a/akregator/src/abstractselectioncontroller.h \
b/akregator/src/abstractselectioncontroller.h index b2be3a1..29a9e96 100644
--- a/akregator/src/abstractselectioncontroller.h
+++ b/akregator/src/abstractselectioncontroller.h
@@ -25,6 +25,7 @@
#define AKREGATOR_ABSTRACTSELECTIONCONTROLLER_H
#include <QObject>
+#include <Akonadi/Collection>
#include <boost/shared_ptr.hpp>
#include <vector>
@@ -106,6 +107,9 @@ public:
virtual QModelIndex selectedCollectionIndex() const = 0;
virtual Akonadi::Collection selectedCollection() const = 0;
+
+ virtual Akonadi::Collection::List resourceRootCollections() const = 0;
+
public Q_SLOTS:
virtual void setFilters( const std::vector<boost::shared_ptr<const \
Akregator::Filters::AbstractMatcher> >& ) = 0;
diff --git a/akregator/src/command_p.cpp b/akregator/src/command_p.cpp
index 0fd1b0f..a0a7bd0 100644
--- a/akregator/src/command_p.cpp
+++ b/akregator/src/command_p.cpp
@@ -25,6 +25,8 @@
#include "command_p.h"
#include "command.h"
+#include <KLocalizedString>
+
#include <QPointer>
#include <QSharedData>
@@ -39,6 +41,19 @@ public:
EmitResultGuard::EmitResultGuard( Command* cmd ) : d( new Private( cmd ) ) {}
EmitResultGuard::~EmitResultGuard() {}
+void EmitResultGuard::setErrorAndEmitResult( const QString& errorText, int error ) {
+ if ( !d->command )
+ return;
+ d->command->setErrorText( errorText );
+ d->command->setError( error );
+ d->command->emitResult();
+}
+
+void EmitResultGuard::emitCanceled() {
+ if ( d->command )
+ d->command->emitCanceled();
+}
+
bool EmitResultGuard::exists() const {
return d->command != 0;
}
diff --git a/akregator/src/command_p.h b/akregator/src/command_p.h
index e23a5fb..993f74e 100644
--- a/akregator/src/command_p.h
+++ b/akregator/src/command_p.h
@@ -38,8 +38,9 @@ namespace Akregator {
void setError( int code );
void setErrorText( const QString& text );
-
+ void setErrorAndEmitResult( const QString& errorText, int error );
void emitResult();
+ void emitCanceled();
bool exists() const;
private:
diff --git a/akregator/src/createfeedcommand.cpp \
b/akregator/src/createfeedcommand.cpp index 8cef42d..e7bf5ff 100644
--- a/akregator/src/createfeedcommand.cpp
+++ b/akregator/src/createfeedcommand.cpp
@@ -77,7 +77,8 @@ CreateFeedCommand::Private::Private( Akonadi::Session* session, \
CreateFeedComman m_session( session ),
m_autoexec( false )
{
-
+ q->setUserVisible( false );
+ q->setShowErrorDialog( true );
}
void CreateFeedCommand::Private::doCreate()
@@ -169,20 +170,18 @@ void CreateFeedCommand::Private::doCreate()
void CreateFeedCommand::Private::creationDone( KJob* job )
{
- EmitResultGuard guard( q );
if ( job->error() )
- KMessageBox::error( q->parentWidget(), i18n("Could not add feed: %1", \
job->errorString()),
- i18n("Feed Creation Failed") );
-
- guard.emitResult();
+ q->setErrorAndEmitResult( i18n("Could not add feed: %1", job->errorString()) \
); + else
+ q->emitResult();
}
void CreateFeedCommand::Private::modificationDone( KJob* j )
{
- EmitResultGuard guard( q );
if ( j->error() )
- KMessageBox::error( q->parentWidget(), i18n("Could not edit the feed: %1", \
j->errorString() ), i18n("Editing Feed Failed") );
- guard.emitResult();
+ q->setErrorAndEmitResult( i18n("Could not edit feed: %1", j->errorString()) \
); + else
+ q->emitResult();
}
CreateFeedCommand::CreateFeedCommand( Akonadi::Session* session, QObject* parent ) : \
Command( parent ), d( new Private( session, this ) ) @@ -195,7 +194,6 @@ \
CreateFeedCommand::~CreateFeedCommand() delete d;
}
-
void CreateFeedCommand::setUrl( const QString& url )
{
d->m_url = url;
@@ -213,7 +211,7 @@ void CreateFeedCommand::setParentCollection( const \
Akonadi::Collection& collecti
void CreateFeedCommand::doStart()
{
- QTimer::singleShot( 0, this, SLOT(doCreate()) );
+ d->doCreate();
}
#include "createfeedcommand.moc"
diff --git a/akregator/src/createtagcommand.cpp b/akregator/src/createtagcommand.cpp
index d1e1f72..ffed233 100644
--- a/akregator/src/createtagcommand.cpp
+++ b/akregator/src/createtagcommand.cpp
@@ -71,7 +71,7 @@ CreateFolderCommand::Private::Private( const Collection& parent, \
const QString& void CreateFolderCommand::Private::collectionCreated( KJob* j )
{
if ( j->error() ) {
- q->setError( KJob::UserDefinedError );
+ q->setError( Command::SomeError );
q->setErrorText( j->errorText() );
q->emitResult();
return;
@@ -107,7 +107,7 @@ void CreateFolderCommand::doStart()
d->parentCollection = FeedCollection::findFolder( d->parentCollection );
if ( !d->parentCollection.isValid() ) {
- setError( KJob::UserDefinedError );
+ setError( SomeError );
setErrorText( tr("Invalid parent collection. Cannot create folder") );
emitResult();
return;
diff --git a/akregator/src/editfeedcommand.cpp b/akregator/src/editfeedcommand.cpp
index 638b123..8688d5d 100644
--- a/akregator/src/editfeedcommand.cpp
+++ b/akregator/src/editfeedcommand.cpp
@@ -56,9 +56,7 @@ public:
EmitResultGuard guard( q );
if ( j->error() ) {
- q->setError( KJob::UserDefinedError );
- q->setErrorText( j->errorText() );
- guard.emitResult();
+ guard.setErrorAndEmitResult( j->errorText(), Command::SomeError );
return;
}
@@ -77,7 +75,7 @@ public:
if ( dlg->exec() != QDialog::Accepted ) {
delete dlg;
- guard.emitResult();
+ guard.emitCanceled();
return;
}
fc.setTitle( dlg->feedTitle() );
@@ -92,16 +90,12 @@ public:
}
void collectionModified( KJob* j ) {
- if ( j->error() ) {
- q->setError( KJob::UserDefinedError );
- q->setErrorText( j->errorText() );
- }
-
- q->emitResult();
+ if ( j->error() )
+ q->setErrorAndEmitResult( j->errorText() );
+ else
+ q->emitResult();
}
- void jobFinished();
-
Akonadi::Collection collection;
Akonadi::Session* session;
};
diff --git a/akregator/src/exportfeedlistcommand.cpp \
b/akregator/src/exportfeedlistcommand.cpp index 1e6f22e..e230bd4 100644
--- a/akregator/src/exportfeedlistcommand.cpp
+++ b/akregator/src/exportfeedlistcommand.cpp
@@ -26,20 +26,17 @@
#include "command_p.h"
#include <krss/exportopmljob.h>
-#include <krss/netresource.h>
-#include <krss/resourcemanager.h>
+#include <krss/feedcollection.h>
#include <KFileDialog>
+#include <KInputDialog>
#include <KLocalizedString>
#include <KMessageBox>
#include <KUrl>
#include <QTimer>
-#include <boost/shared_ptr.hpp>
-
-#include <cassert>
-
+using namespace Akonadi;
using namespace Akregator;
using namespace KRss;
@@ -51,33 +48,63 @@ public:
void doExport();
void exportFinished( KJob* );
- bool checkResource( const boost::shared_ptr<const NetResource>& r );
KUrl url;
- QString resourceIdentifier;
+ Akonadi::Session* session;
+ Collection::List rootCollections;
+ Collection preset;
};
ExportFeedListCommand::Private::Private( ExportFeedListCommand* qq )
: q( qq )
+ , session( 0 )
{
-
-}
-
-bool ExportFeedListCommand::Private::checkResource( const boost::shared_ptr<const \
NetResource>& r ) {
- if ( r )
- return true;
- EmitResultGuard guard( q );
- KMessageBox::error( q->parentWidget(), i18n("Could not export feed list: \
Resource %1 not found.", resourceIdentifier ), i18n("Import Error" ) \
);
- guard.emitResult();
- return false;
+ q->setUserVisible( true );
+ q->setShowErrorDialog( true );
}
void ExportFeedListCommand::Private::doExport()
{
- if ( !checkResource( ResourceManager::self()->resource( resourceIdentifier ) ) )
- return;
EmitResultGuard guard( q );
+ Collection selected = preset;
+ QHash<QString,int> occs;
+ QStringList titles;
+ titles.reserve( rootCollections.size() );
+ Q_FOREACH( const Collection& i, rootCollections ) {
+ const QString t = FeedCollection( i ).title();
+ //not efficient, but who has trillions of resources anyway? Right? Right.
+ if ( titles.contains( t ) ) {
+ occs[t] += 1;
+ titles.append( i18nc( "folder title (occurrence number, for \
duplicates)", "%1 (%2)", t, QString::number( occs[t] + 1 ) ) ); + }
+ else
+ titles.append( t );
+ }
+
+ if ( rootCollections.size() > 1 ) {
+ bool ok;
+ const QString sel =
+ KInputDialog::getItem( i18n("Feed List Export"),
+ i18n("Please select the list to export"),
+ titles,
+ rootCollections.indexOf( selected ),
+ /*editable=*/false,
+ &ok,
+ q->parentWidget() );
+ if ( !ok ) {
+ guard.emitCanceled();
+ return;
+ }
+
+ if ( !guard.exists() )
+ return;
+
+ selected = rootCollections.at( titles.indexOf( sel ) );
+ }
+
+ Q_ASSERT( selected.isValid() );
+
if ( !url.isValid() ) {
url = KFileDialog::getSaveUrl( KUrl(),
QLatin1String("*.opml *.xml|") + i18n("OPML Outlines \
(*.opml, *.xml)") @@ -87,25 +114,21 @@ void \
ExportFeedListCommand::Private::doExport() }
if ( !url.isValid() ) {
- guard.emitResult();
+ guard.emitCanceled();
return;
}
-
- const boost::shared_ptr<const NetResource> resource = \
ResourceManager::self()->resource( resourceIdentifier );
- if ( !checkResource( resource ) )
- return;
+#ifdef KRSS_PORT_DISABLED
KRss::ExportOpmlJob* job = resource->createExportOpmlJob( url );
connect( job, SIGNAL(finished(KJob*)), q, SLOT(exportFinished(KJob*)) );
job->start();
+#endif
}
void ExportFeedListCommand::Private::exportFinished( KJob* job ) {
- EmitResultGuard guard( q );
if ( job->error() )
- KMessageBox::error( q->parentWidget(), i18n("Could not export feed list: \
%1", job->errorString() ), i18n("Export Error" ) ); + \
q->setErrorAndEmitResult( i18n("Could not export feed list: %1", job->errorString() ) \
); else
- KMessageBox::information( q->parentWidget(), i18n("The feed list was \
successfully exported." ), i18n("Export Finished") );
- guard.emitResult();
+ q->emitResult();
}
ExportFeedListCommand::ExportFeedListCommand( QObject* parent ) : Command( parent ), \
d( new Private( this ) ) @@ -117,20 +140,29 @@ \
ExportFeedListCommand::~ExportFeedListCommand() delete d;
}
-
void ExportFeedListCommand::setTargetUrl( const KUrl& url )
{
d->url = url;
}
-void ExportFeedListCommand::setResourceIdentifier( const QString& identifier )
+void ExportFeedListCommand::setSession( Akonadi::Session* s )
{
- d->resourceIdentifier = identifier;
+ d->session = s;
+}
+
+void ExportFeedListCommand::setRootCollections(const Akonadi::Collection::List& \
list, const Akonadi::Collection& preset ) { + Q_ASSERT( !preset.isValid() || \
list.contains( preset ) ); + d->rootCollections = list;
+ if( !list.isEmpty() )
+ d->preset = preset.isValid() ? preset : d->rootCollections.first();
+ else
+ d->preset = Collection();
}
void ExportFeedListCommand::doStart()
{
- QTimer::singleShot( 0, this, SLOT(doExport()) );
+ Q_ASSERT( d->session );
+ d->doExport();
}
#include "exportfeedlistcommand.moc"
diff --git a/akregator/src/exportfeedlistcommand.h \
b/akregator/src/exportfeedlistcommand.h index cd1018a..ac02831 100644
--- a/akregator/src/exportfeedlistcommand.h
+++ b/akregator/src/exportfeedlistcommand.h
@@ -27,8 +27,14 @@
#include "command.h"
+#include <Akonadi/Collection>
+
class KUrl;
+namespace Akonadi {
+ class Session;
+ class Collection;
+}
namespace Akregator {
class ExportFeedListCommand : public Command
@@ -38,8 +44,8 @@ public:
explicit ExportFeedListCommand( QObject* parent = 0 );
~ExportFeedListCommand();
- void setResourceIdentifier( const QString& identifier );
-
+ void setRootCollections( const Akonadi::Collection::List& list, const \
Akonadi::Collection& preset ); + void setSession( Akonadi::Session* session );
void setTargetUrl( const KUrl& url );
private:
@@ -48,7 +54,6 @@ private:
private:
class Private;
Private* const d;
- Q_PRIVATE_SLOT( d, void doExport() )
Q_PRIVATE_SLOT( d, void exportFinished( KJob* ) )
};
diff --git a/akregator/src/mainwidget.cpp b/akregator/src/mainwidget.cpp
index 0489cc8..26912cf 100644
--- a/akregator/src/mainwidget.cpp
+++ b/akregator/src/mainwidget.cpp
@@ -407,14 +407,14 @@ void Akregator::MainWidget::sendArticle(bool attach)
void MainWidget::slotImportFeedList()
{
std::auto_ptr<ImportFeedListCommand> cmd( new ImportFeedListCommand );
- cmd->setResourceIdentifier( Settings::activeAkonadiResource() );
d->setUpAndStart( cmd.release() );
}
void MainWidget::slotExportFeedList()
{
std::auto_ptr<ExportFeedListCommand> cmd( new ExportFeedListCommand );
- cmd->setResourceIdentifier( Settings::activeAkonadiResource() );
+ cmd->setSession( m_session );
+ cmd->setRootCollections( m_selectionController->resourceRootCollections(), \
Akonadi::Collection() ); d->setUpAndStart( cmd.release() );
}
@@ -422,7 +422,6 @@ void MainWidget::slotMetakitImport()
{
std::auto_ptr<MigrateFeedsCommand> cmd( new MigrateFeedsCommand );
cmd->setOpmlFile( KGlobal::dirs()->saveLocation("data", "akregator/data") + \
"/feeds.opml" );
- cmd->setResource( Settings::activeAkonadiResource() );
d->setUpAndStart( cmd.release() );
}
diff --git a/akregator/src/selectioncontroller.cpp \
b/akregator/src/selectioncontroller.cpp index 515ac5c..e8d0fc1 100644
--- a/akregator/src/selectioncontroller.cpp
+++ b/akregator/src/selectioncontroller.cpp
@@ -73,7 +73,8 @@ Akregator::SelectionController::SelectionController( \
Akonadi::Session* session, m_folderExpansionHandler( 0 ),
m_itemModel( 0 ),
m_feedSelectionResolved( 0 ),
- m_session( session )
+ m_session( session ),
+ m_collectionFilterModel( 0 )
{
Akonadi::ItemFetchScope iscope;
iscope.fetchFullPayload( true );
@@ -91,6 +92,14 @@ Akregator::SelectionController::SelectionController( \
Akonadi::Session* session, recorder->setMimeTypeMonitored( KRss::Item::mimeType() );
m_itemModel = new FeedItemModel( recorder, this );
+
+ Akonadi::EntityMimeTypeFilterModel* filterProxy = new \
Akonadi::EntityMimeTypeFilterModel( this ); + \
filterProxy->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() ); + \
filterProxy->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders ); + \
filterProxy->setSourceModel( m_itemModel ); + filterProxy->setDynamicSortFilter( \
true ); + m_collectionFilterModel = filterProxy;
+
}
@@ -116,21 +125,16 @@ void Akregator::SelectionController::init() {
Q_ASSERT( m_articleLister->itemView() );
Q_ASSERT( !m_feedSelector->model() );
- Akonadi::EntityMimeTypeFilterModel* filterProxy = new \
Akonadi::EntityMimeTypeFilterModel( this );
- filterProxy->addMimeTypeInclusionFilter( Akonadi::Collection::mimeType() );
- filterProxy->setHeaderGroup( Akonadi::EntityTreeModel::CollectionTreeHeaders );
- filterProxy->setSourceModel( m_itemModel );
- filterProxy->setDynamicSortFilter( true );
connect( m_feedSelector, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(subscriptionContextMenuRequested(QPoint)) );
- m_feedSelector->setModel( filterProxy );
+ m_feedSelector->setModel( m_collectionFilterModel );
connect( m_feedSelector->selectionModel(), \
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this, SLOT(feedSelectionChanged(QItemSelection,QItemSelection)) );
- m_feedSelectionResolved = new QItemSelectionModel( filterProxy, this );
+ m_feedSelectionResolved = new QItemSelectionModel( m_collectionFilterModel, this \
);
Akonadi::SelectionProxyModel* selectionProxy = new Akonadi::SelectionProxyModel( \
m_feedSelectionResolved );
selectionProxy->setFilterBehavior( \
KSelectionProxyModel::ChildrenOfExactSelection ); selectionProxy->setSourceModel( \
m_itemModel ); @@ -193,6 +197,16 @@ QModelIndex \
Akregator::SelectionController::selectedCollectionIndex() const { return \
m_feedSelector->selectionModel()->currentIndex(); }
+Akonadi::Collection::List SelectionController::resourceRootCollections() const {
+ Akonadi::Collection::List l;
+ const int rows = m_collectionFilterModel->rowCount();
+ l.reserve( rows );
+ for ( int i = 0; i < rows; ++i )
+ l.push_back( m_collectionFilterModel->index( i, 0 ).data( \
Akonadi::EntityTreeModel::CollectionRole ).value<Akonadi::Collection>() ); + \
//PENDING(frank) filter out search folders etc. + return l;
+}
+
Akonadi::Collection Akregator::SelectionController::selectedCollection() const
{
return m_feedSelector->selectionModel()->currentIndex().data( \
Akonadi::EntityTreeModel::CollectionRole \
).value<Akonadi::Collection>();
diff --git a/akregator/src/selectioncontroller.h \
b/akregator/src/selectioncontroller.h index 8920375..57feccf 100644
--- a/akregator/src/selectioncontroller.h
+++ b/akregator/src/selectioncontroller.h
@@ -26,6 +26,8 @@
#include "abstractselectioncontroller.h"
+#include <Akonadi/Collection>
+
#include <QtCore/QMap>
#include <QtCore/QPointer>
#include <QtCore/QTime>
@@ -38,7 +40,6 @@ class QItemSelectionModel;
class KJob;
namespace Akonadi {
- class Collection;
class Item;
class Session;
}
@@ -77,10 +78,13 @@ public:
Akonadi::Collection selectedCollection() const;
+ Akonadi::Collection::List resourceRootCollections() const;
+
//impl
void setFolderExpansionHandler( Akregator::FolderExpansionHandler* handler );
+
public Q_SLOTS:
//impl
@@ -108,6 +112,7 @@ private:
QItemSelectionModel* m_feedSelectionResolved;
QMap<Akonadi::Collection, QPoint> m_scrollBarPositions;
Akonadi::Session* m_session;
+ QAbstractItemModel* m_collectionFilterModel;
};
} // namespace Akregator
diff --git a/akregator/src/setupakonadicommand.cpp \
b/akregator/src/setupakonadicommand.cpp index fd3d029..3585f71 100644
--- a/akregator/src/setupakonadicommand.cpp
+++ b/akregator/src/setupakonadicommand.cpp
@@ -69,7 +69,11 @@ public:
QPointer<QWidget> mainWidget;
};
-SetUpAkonadiCommand::SetUpAkonadiCommand( QObject* parent ) : d( new Private( this ) \
) {} +SetUpAkonadiCommand::SetUpAkonadiCommand( QObject* parent ) : d( new Private( \
this ) ) +{
+ setUserVisible( false );
+ setShowErrorDialog( true );
+}
void SetUpAkonadiCommand::doStart() {
Akonadi::AttributeFactory::registerAttribute<KRss::SubscriptionLabelsCollectionAttribute>();
@@ -93,23 +97,19 @@ void SetUpAkonadiCommand::Private::dialogAccepted() {
}
void SetUpAkonadiCommand::Private::dialogRejected() {
- q->setError( SetUpAkonadiCommand::SetupCanceled );
- q->emitResult();
+ q->emitCanceled();
}
void SetUpAkonadiCommand::Private::resourceCreated( KJob* j ) {
- EmitResultGuard guard( q );
const AgentInstanceCreateJob* const job = qobject_cast<const \
AgentInstanceCreateJob*>( j );
- assert( job );
+ assert( job );
if ( job->error() ) {
- KMessageBox::error( q->parentWidget(), i18n( "Could not create a news feed \
resource: %1. Please check your installation or contact your system administrator.", \
job->errorString() ) );
- guard.setError( SetUpAkonadiCommand::SetupFailed );
- guard.setErrorText( job->errorText() );
- } else {
- assert( job->instance().isValid() );
- Settings::setActiveAkonadiResource( job->instance().identifier() );
+ q->setErrorAndEmitResult( i18n( "Could not create a news feed resource: %1. \
Please check your installation or contact your system administrator.", \
job->errorString() ), SetUpAkonadiCommand::SetupFailed ); + return;
}
- guard.emitResult();
+ assert( job->instance().isValid() );
+ Settings::setActiveAkonadiResource( job->instance().identifier() );
+ q->emitResult();
}
void SetUpAkonadiCommand::Private::startSetup() {
@@ -120,8 +120,7 @@ void SetUpAkonadiCommand::Private::startSetup() {
Control::widgetNeedsAkonadi( mainWidget );
if ( !Control::start( q->parentWidget() ) || !guard.exists() ) {
- guard.setError( SetUpAkonadiCommand::SetupFailed );
- guard.emitResult();
+ guard.setErrorAndEmitResult( QString(), SetUpAkonadiCommand::SetupFailed );
return;
}
@@ -139,9 +138,7 @@ void SetUpAkonadiCommand::Private::startSetup() {
const QString typeId = QLatin1String( "akonadi_opml_rss_resource" );
const AgentType type = AgentManager::self()->type( typeId );
if ( !type.isValid() ) {
- KMessageBox::error( q->parentWidget(), i18n("Could not create a resource \
of type %1. Please check your installation or contact your system administrator.", \
typeId ) );
- guard.setError( SetUpAkonadiCommand::SetupFailed );
- guard.emitResult();
+ guard.setErrorAndEmitResult( i18n("Could not create a resource of type \
%1. Please check your installation or contact your system administrator.", typeId ), \
SetUpAkonadiCommand::SetupFailed ); return;
}
diff --git a/akregator/src/setupakonadicommand.h \
b/akregator/src/setupakonadicommand.h index a717f87..bee6dc6 100644
--- a/akregator/src/setupakonadicommand.h
+++ b/akregator/src/setupakonadicommand.h
@@ -35,8 +35,7 @@ public:
explicit SetUpAkonadiCommand( QObject* parent=0 );
enum Error {
- SetupCanceled=UserDefinedError,
- SetupFailed
+ SetupFailed=UserDefinedCommandError
};
QWidget* mainWidget() const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic