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

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • libs
  • kasten
  • controllers
  • shellwindow
  • switchview
switchviewcontroller.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the Kasten Framework, made within the KDE community.
3 
4  Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) version 3, or any
10  later version accepted by the membership of KDE e.V. (or its
11  successor approved by the membership of KDE e.V.), which shall
12  act as a proxy defined in Section 6 of version 3 of the license.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
23 #include "switchviewcontroller.h"
24 
25 // lib
26 #include <abstractgroupedviews.h>
27 // KDE
28 #include <KXMLGUIClient>
29 #include <KActionCollection>
30 #include <KAction>
31 // Qt
32 #include <QtGui/QActionGroup>
33 
34 
35 namespace Kasten2
36 {
37 
38 SwitchViewController::SwitchViewController( AbstractGroupedViews* groupedViews, KXMLGUIClient* guiClient )
39  : mGroupedViews( groupedViews )
40 {
41  KActionCollection* actionCollection = guiClient->actionCollection();
42 
43  mForwardAction = actionCollection->addAction( KStandardAction::Forward, QLatin1String("window_next"), this, SLOT(forward()) );
44  mBackwardAction = actionCollection->addAction( KStandardAction::Back, QLatin1String("window_previous"), this, SLOT(backward()) );
45 
46  connect( groupedViews, SIGNAL(added(QList<Kasten2::AbstractView*>)), SLOT(updateActions()) );
47  connect( groupedViews, SIGNAL(removing(QList<Kasten2::AbstractView*>)), SLOT(updateActions()) );
48 
49  connect( groupedViews, SIGNAL(viewFocusChanged(Kasten2::AbstractView*)), SLOT(updateActions()) );
50 
51  updateActions();
52 }
53 
54 void SwitchViewController::setTargetModel( AbstractModel* model )
55 {
56 Q_UNUSED(model)
57 }
58 
59 // TODO: think about moving this properties/abilities (hasNext/Previous,switchToNext/Previous) into a interface for the groupedview
60 void SwitchViewController::updateActions()
61 {
62  bool hasNext;
63  bool hasPrevious;
64  const QList<AbstractView*> viewList = mGroupedViews->viewList();
65  if( viewList.isEmpty() )
66  {
67  hasNext = false;
68  hasPrevious = false;
69  }
70  else
71  {
72  AbstractView* focussedView = mGroupedViews->viewFocus();
73  const int indexOfFocussedView = viewList.indexOf( focussedView );
74 
75  hasNext = ( indexOfFocussedView+1 < viewList.count() );
76  hasPrevious = ( indexOfFocussedView > 0 );
77  }
78 
79  mForwardAction->setEnabled( hasNext );
80  mBackwardAction->setEnabled( hasPrevious );
81 }
82 
83 
84 void SwitchViewController::forward()
85 {
86  const QList<AbstractView*> viewList = mGroupedViews->viewList();
87  AbstractView* focussedView = mGroupedViews->viewFocus();
88  const int indexOfFocussedView = viewList.indexOf( focussedView );
89  AbstractView* nextView = viewList.at( indexOfFocussedView + 1 );
90  mGroupedViews->setViewFocus( nextView );
91 }
92 
93 
94 void SwitchViewController::backward()
95 {
96  const QList<AbstractView*> viewList = mGroupedViews->viewList();
97  AbstractView* focussedView = mGroupedViews->viewFocus();
98  const int indexOfFocussedView = viewList.indexOf( focussedView );
99  AbstractView* previousView = viewList.at( indexOfFocussedView - 1 );
100  mGroupedViews->setViewFocus( previousView );
101 }
102 
103 }
Kasten2::AbstractView
Definition: abstractview.h:38
Kasten2::AbstractGroupedViews::viewList
virtual QList< AbstractView * > viewList() const =0
switchviewcontroller.h
abstractgroupedviews.h
Kasten2::AbstractGroupedViews
Definition: abstractgroupedviews.h:37
Kasten2::SwitchViewController::setTargetModel
virtual void setTargetModel(AbstractModel *model)
Definition: switchviewcontroller.cpp:54
Kasten2::AbstractGroupedViews::viewFocus
virtual AbstractView * viewFocus() const =0
Kasten2::AbstractGroupedViews::setViewFocus
virtual void setViewFocus(AbstractView *view)=0
Kasten2::SwitchViewController::SwitchViewController
SwitchViewController(AbstractGroupedViews *groupedViews, KXMLGUIClient *guiClient)
Definition: switchviewcontroller.cpp:38
Kasten2::AbstractModel
Definition: abstractmodel.h:40
QList< Kasten2::AbstractView * >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:09 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

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