• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
subscriptionlistjobs.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright (C) 2008 Frank Osterfeld <osterfeld@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "subscriptionlistjobs.h"
26 #include "feedlist.h"
27 #include "folder.h"
28 #include "kernel.h"
29 #include "treenode.h"
30 
31 #include <KLocalizedString>
32 
33 #include <QTimer>
34 
35 using namespace boost;
36 using namespace Akregator;
37 
38 MoveSubscriptionJob::MoveSubscriptionJob( QObject* parent ) : KJob( parent ), m_id( 0 ), m_destFolderId( 0 ), m_afterId( -1 ), m_feedList( Kernel::self()->feedList() )
39 {
40 }
41 
42 void MoveSubscriptionJob::setSubscriptionId( int id )
43 {
44  m_id = id;
45 }
46 
47 void MoveSubscriptionJob::setDestination( int folder, int afterChild )
48 {
49  m_destFolderId = folder;
50  m_afterId = afterChild;
51 }
52 
53 
54 void MoveSubscriptionJob::start()
55 {
56  QTimer::singleShot( 20, this, SLOT(doMove()) );
57 }
58 
59 void MoveSubscriptionJob::doMove()
60 {
61  const shared_ptr<FeedList> feedList = m_feedList.lock();
62 
63  if ( !feedList ) {
64  setErrorText( i18n( "Feed list was deleted" ) );
65  emitResult();
66  return;
67  }
68 
69  TreeNode* const node = feedList->findByID( m_id );
70  Folder* const destFolder = qobject_cast<Folder*>( feedList->findByID( m_destFolderId ) );
71  TreeNode* const after = feedList->findByID( m_afterId );
72 
73  if ( !node || !destFolder )
74  {
75  setErrorText( i18n( "Node or destination folder not found" ) );
76  emitResult();
77  return;
78  }
79  const Folder* const asFolder = qobject_cast<Folder*>( node );
80 
81  if ( asFolder && asFolder->subtreeContains( destFolder ) )
82  {
83  setErrorText( i18n( "Cannot move folder %1 to its own subfolder %2", asFolder->title(), destFolder->title() ) );
84  emitResult();
85  return;
86  }
87 
88  node->parent()->removeChild( node );
89  if ( after )
90  destFolder->insertChild( node, after );
91  else
92  destFolder->appendChild( node );
93  emitResult();
94 }
95 
96 RenameSubscriptionJob::RenameSubscriptionJob( QObject* parent ) : KJob( parent ), m_id( 0 ), m_feedList( Kernel::self()->feedList() )
97 {
98 }
99 
100 void RenameSubscriptionJob::setSubscriptionId( int id )
101 {
102  m_id = id;
103 }
104 
105 void RenameSubscriptionJob::setName( const QString& name )
106 {
107  m_name = name;
108 }
109 
110 void RenameSubscriptionJob::start()
111 {
112  QTimer::singleShot( 20, this, SLOT(doRename()) );
113 }
114 
115 void RenameSubscriptionJob::doRename()
116 {
117  if ( m_id > 0 )
118  {
119  TreeNode* const node = m_feedList->findByID( m_id );
120  if ( node )
121  node->setTitle( m_name );
122  }
123  emitResult();
124 }
125 
126 DeleteSubscriptionJob::DeleteSubscriptionJob( QObject* parent ) : KJob( parent ), m_id( 0 ), m_feedList( Kernel::self()->feedList() )
127 {
128 }
129 
130 void DeleteSubscriptionJob::setSubscriptionId( int id )
131 {
132  m_id = id;
133 }
134 
135 void DeleteSubscriptionJob::start()
136 {
137  QTimer::singleShot( 20, this, SLOT(doDelete()) );
138 }
139 
140 void DeleteSubscriptionJob::doDelete()
141 {
142  const shared_ptr<FeedList> feedList = m_feedList.lock();
143  if ( m_id > 0 && feedList )
144  delete feedList->findByID( m_id );
145  emitResult();
146 }
147 
treenode.h
feedlist.h
kernel.h
Akregator::TreeNode::title
QString title() const
Get title of node.
Definition: treenode.cpp:87
Akregator::DeleteSubscriptionJob::DeleteSubscriptionJob
DeleteSubscriptionJob(QObject *parent=0)
Definition: subscriptionlistjobs.cpp:126
Akregator::Folder::removeChild
void removeChild(TreeNode *node)
remove node from children.
Definition: folder.cpp:249
Akregator::TreeNode::parent
virtual const Folder * parent() const
Returns the parent node.
Definition: treenode.cpp:141
Akregator::RenameSubscriptionJob::setName
void setName(const QString &name)
Definition: subscriptionlistjobs.cpp:105
Akregator::RenameSubscriptionJob::RenameSubscriptionJob
RenameSubscriptionJob(QObject *parent=0)
Definition: subscriptionlistjobs.cpp:96
QObject
Akregator::DeleteSubscriptionJob::start
void start()
Definition: subscriptionlistjobs.cpp:135
Akregator::MoveSubscriptionJob::setDestination
void setDestination(int folder, int afterChild)
Definition: subscriptionlistjobs.cpp:47
Akregator::TreeNode::setTitle
void setTitle(const QString &title)
Sets the title of the node.
Definition: treenode.cpp:92
Akregator::DeleteSubscriptionJob::setSubscriptionId
void setSubscriptionId(int id)
Definition: subscriptionlistjobs.cpp:130
Akregator::Folder::appendChild
void appendChild(TreeNode *node)
inserts node as last child
Definition: folder.cpp:215
Akregator::MoveSubscriptionJob::start
void start()
Definition: subscriptionlistjobs.cpp:54
QString
folder.h
Akregator::Folder
Represents a folder (containing feeds and/or other folders)
Definition: folder.h:44
Akregator::RenameSubscriptionJob::start
void start()
Definition: subscriptionlistjobs.cpp:110
subscriptionlistjobs.h
Akregator::MoveSubscriptionJob::setSubscriptionId
void setSubscriptionId(int id)
Definition: subscriptionlistjobs.cpp:42
Akregator::Kernel
Definition: kernel.h:45
Akregator::TreeNode
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:58
Akregator::Folder::insertChild
void insertChild(TreeNode *node, TreeNode *after)
inserts node as child after child node after.
Definition: folder.cpp:180
KJob
Akregator::RenameSubscriptionJob::setSubscriptionId
void setSubscriptionId(int id)
Definition: subscriptionlistjobs.cpp:100
QTimer::singleShot
singleShot
Akregator::Folder::subtreeContains
bool subtreeContains(const Akregator::TreeNode *node) const
Definition: folder.cpp:338
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal