• 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
  • viewlistmenu
viewlistmenucontroller.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 2006-2007 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 "viewlistmenucontroller.h"
24 
25 // lib
26 #include <abstractgroupedviews.h>
27 #include <viewmanager.h>
28 // Kasten core
29 #include <abstractdocument.h>
30 // KDE
31 #include <KXMLGUIClient>
32 #include <KXMLGUIFactory>
33 #include <KActionCollection>
34 #include <KLocale>
35 #include <KStringHandler>
36 // Qt
37 #include <QtGui/QActionGroup>
38 
39 
40 
41 Q_DECLARE_METATYPE(Kasten2::AbstractView*)
42 
43 namespace Kasten2
44 {
45 
46 static const int MaxEntryLength = 150;
47 static const char WindowsListActionListId[] = "windows_list";
48 
49 
50 ViewListMenuController::ViewListMenuController( ViewManager* viewManager, AbstractGroupedViews* groupedViews,
51  KXMLGUIClient* guiClient )
52  : mViewManager( viewManager ),
53  mGroupedViews( groupedViews ),
54  mGuiClient( guiClient )
55 {
56  mWindowsActionGroup = new QActionGroup( this ); // TODO: do we use this only for the signal mapping?
57 // mWindowsActionGroup->setExclusive( true );
58  connect( mWindowsActionGroup, SIGNAL(triggered(QAction*)), SLOT(onActionTriggered(QAction*)) );
59 
60  connect( mViewManager, SIGNAL(opened(QList<Kasten2::AbstractView*>)), SLOT(updateActions()) );
61  connect( mViewManager, SIGNAL(closing(QList<Kasten2::AbstractView*>)), SLOT(updateActions()) );
62 
63  updateActions();
64 }
65 
66 void ViewListMenuController::setTargetModel( AbstractModel* model )
67 {
68 Q_UNUSED(model)
69 }
70 
71 
72 void ViewListMenuController::updateActions()
73 {
74  mGuiClient->unplugActionList( QLatin1String(WindowsListActionListId) );
75 
76  qDeleteAll( mWindowsActionGroup->actions() );
77 
78  const QList<AbstractView*> views = mViewManager->views();
79  const bool hasViews = ( views.size() > 0 );
80 
81  if( hasViews )
82  {
83  //TODO: sortieren nach namen und erste 10 mit Zahl, siehe unten
84  for( int v = 0; v < views.size(); ++v )
85  {
86  AbstractView *view = views.at( v );
87  const QString title = KStringHandler::rsqueeze( view->title(), MaxEntryLength );
88  QAction *action = new QAction( v<9 ? QString::fromLatin1("&%1 %2").arg(v+1).arg(title) : title, mWindowsActionGroup );
89  // action->setCheckable( true );
90 
91  // if(m_viewManager->activeView() && doc == m_viewManager->activeView()->document())
92  // action->setChecked(true);
93  action->setData( QVariant::fromValue(view) );
94  mWindowsActionGroup->addAction( action );
95  }
96  }
97  else
98  {
99  QAction *noneAction = new QAction( i18nc("@item There are no windows.","None."), mWindowsActionGroup );
100  mWindowsActionGroup->addAction( noneAction );
101  }
102  mWindowsActionGroup->setEnabled( hasViews );
103 
104  mGuiClient->plugActionList( QLatin1String(WindowsListActionListId), mWindowsActionGroup->actions() );
105 }
106 
107 
108 void ViewListMenuController::onActionTriggered( QAction *action )
109 {
110  AbstractView *view = action->data().value<AbstractView *>();
111  mGroupedViews->setViewFocus( view );
112 }
113 
114 }
viewlistmenucontroller.h
Kasten2::AbstractView
Definition: abstractview.h:38
abstractdocument.h
abstractgroupedviews.h
Kasten2::AbstractModel::title
virtual QString title() const =0
Kasten2::AbstractGroupedViews
Definition: abstractgroupedviews.h:37
Kasten2::ViewManager
Definition: viewmanager.h:40
Kasten2::MaxEntryLength
static const int MaxEntryLength
Definition: viewlistmenucontroller.cpp:46
Kasten2::ViewManager::views
QList< AbstractView * > views() const
Definition: viewmanager.cpp:50
Kasten2::WindowsListActionListId
static const char WindowsListActionListId[]
Definition: viewlistmenucontroller.cpp:47
Kasten2::ViewListMenuController::setTargetModel
virtual void setTargetModel(AbstractModel *model)
Definition: viewlistmenucontroller.cpp:66
Kasten2::AbstractGroupedViews::setViewFocus
virtual void setViewFocus(AbstractView *view)=0
Kasten2::AbstractModel
Definition: abstractmodel.h:40
viewmanager.h
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