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

akregator

  • sources
  • kde-4.12
  • kdepim
  • akregator
  • src
createfoldercommand.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 "createfoldercommand.h"
26 
27 #include "folder.h"
28 #include "subscriptionlistview.h"
29 
30 #include <KInputDialog>
31 #include <KLocalizedString>
32 
33 #include <QTimer>
34 
35 #include <cassert>
36 
37 using namespace Akregator;
38 
39 class CreateFolderCommand::Private
40 {
41  CreateFolderCommand* const q;
42 public:
43  explicit Private( CreateFolderCommand* qq );
44 
45  void doCreate();
46 
47  TreeNode* m_selectedSubscription;
48  Folder* m_rootFolder;
49  SubscriptionListView* m_subscriptionListView;
50 };
51 
52 CreateFolderCommand::Private::Private( CreateFolderCommand* qq )
53  : q( qq ),
54  m_selectedSubscription( 0 ),
55  m_rootFolder( 0 ),
56  m_subscriptionListView( 0 )
57 {
58 
59 }
60 
61 void CreateFolderCommand::Private::doCreate()
62 {
63  assert( m_rootFolder );
64  assert( m_subscriptionListView );
65  bool ok;
66  const QString name = KInputDialog::getText( i18n( "Add Folder" ),
67  i18n( "Folder name:" ),
68  QString(),
69  &ok,
70  q->parentWidget() );
71  if ( !ok )
72  {
73  q->done();
74  return;
75  }
76 
77  Folder* parentFolder = qobject_cast<Folder*>( m_selectedSubscription );
78  if ( !parentFolder )
79  parentFolder = m_selectedSubscription ? m_selectedSubscription->parent() : 0;
80  if ( !parentFolder )
81  parentFolder = m_rootFolder;
82 
83  TreeNode* const after = ( m_selectedSubscription && m_selectedSubscription->isGroup() ) ? m_selectedSubscription : 0;
84 
85  Folder* const newFolder = new Folder( name );
86  parentFolder->insertChild( newFolder, after );
87  m_subscriptionListView->ensureNodeVisible( newFolder );
88  q->done();
89 }
90 
91 CreateFolderCommand::CreateFolderCommand( QObject* parent ) : Command( parent ), d( new Private( this ) )
92 {
93 
94 }
95 
96 CreateFolderCommand::~CreateFolderCommand()
97 {
98  delete d;
99 }
100 
101 void CreateFolderCommand::setSubscriptionListView( SubscriptionListView* view )
102 {
103  d->m_subscriptionListView = view;
104 }
105 
106 void CreateFolderCommand::setSelectedSubscription( TreeNode* selected )
107 {
108  d->m_selectedSubscription = selected;
109 }
110 
111 void CreateFolderCommand::setRootFolder( Folder* rootFolder )
112 {
113  d->m_rootFolder = rootFolder;
114 }
115 
116 void CreateFolderCommand::doStart()
117 {
118  QTimer::singleShot( 0, this, SLOT(doCreate()) );
119 }
120 
121 void CreateFolderCommand::doAbort()
122 {
123 
124 }
125 #include "createfoldercommand.moc"
Akregator::CreateFolderCommand::setRootFolder
void setRootFolder(Folder *rootFolder)
Definition: createfoldercommand.cpp:111
Akregator::Command
Definition: command.h:36
Akregator::CreateFolderCommand::setSubscriptionListView
void setSubscriptionListView(SubscriptionListView *view)
Definition: createfoldercommand.cpp:101
Akregator::CreateFolderCommand::~CreateFolderCommand
~CreateFolderCommand()
Definition: createfoldercommand.cpp:96
Akregator::CreateFolderCommand
Definition: createfoldercommand.h:36
QObject
Akregator::CreateFolderCommand::setSelectedSubscription
void setSelectedSubscription(TreeNode *selected)
Definition: createfoldercommand.cpp:106
Akregator::SubscriptionListView
Definition: subscriptionlistview.h:39
Akregator::TreeNode::parent
virtual const Folder * parent() const
Returns the parent node.
Definition: treenode.cpp:141
subscriptionlistview.h
folder.h
Akregator::Folder
Represents a folder (containing feeds and/or other folders)
Definition: folder.h:44
Akregator::CreateFolderCommand::CreateFolderCommand
CreateFolderCommand(QObject *parent=0)
Definition: createfoldercommand.cpp:91
createfoldercommand.h
Akregator::TreeNode
Abstract base class for all kind of elements in the feed tree, like feeds and feed groups (and search...
Definition: treenode.h:59
Akregator::Folder::insertChild
void insertChild(TreeNode *node, TreeNode *after)
inserts node as child after child node after.
Definition: folder.cpp:180
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:58:14 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

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