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

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • itemviews
kviewstatemaintainer.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 Klarälvdalens Datakonsult AB,
3  a KDAB Group company, info@kdab.net,
4  author Stephen Kelly <stephen@kdab.com>
5 
6  This library is free software; you can redistribute it and/or modify it
7  under the terms of the GNU Library General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or (at your
9  option) any later version.
10 
11  This library is distributed in the hope that it will be useful, but WITHOUT
12  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
14  License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  02110-1301, USA.
20 */
21 
22 #ifndef KVIEWSTATEMAINTAINER_H
23 #define KVIEWSTATEMAINTAINER_H
24 
25 #include "kdeui_export.h"
26 
27 #include <QtGui/QItemSelectionModel>
28 #include <QtGui/QAbstractItemView>
29 
30 #include "kconfiggroup.h"
31 #include "ksharedconfig.h"
32 
33 class KViewStateMaintainerBasePrivate;
34 
35 class KDEUI_EXPORT KViewStateMaintainerBase : public QObject
36 {
37  Q_OBJECT
38 public:
39  KViewStateMaintainerBase(KConfigGroup configGroup, QObject* parent = 0);
40  ~KViewStateMaintainerBase();
41 
42  void setSelectionModel(QItemSelectionModel *selectionModel);
43  QItemSelectionModel *selectionModel() const;
44 
45  void setView(QAbstractItemView *view);
46  QAbstractItemView *view() const;
47 
48  virtual void saveState() = 0;
49  virtual void restoreState() = 0;
50 
51 protected:
52  KConfigGroup configGroup() const;
53 
54 private:
55  Q_DECLARE_PRIVATE(KViewStateMaintainerBase)
56  KViewStateMaintainerBasePrivate * const d_ptr;
57 
58  Q_PRIVATE_SLOT( d_func(), void _k_modelAboutToBeReset() )
59  Q_PRIVATE_SLOT( d_func(), void _k_modelReset() )
60 };
61 
75 template<typename StateSaver>
76 class KViewStateMaintainer : public KViewStateMaintainerBase
77 {
78  typedef StateSaver StateRestorer;
79 public:
80  KViewStateMaintainer(KConfigGroup configGroup, QObject* parent = 0)
81  : KViewStateMaintainerBase(configGroup, parent)
82  {
83 
84  }
85 
86  /* reimp */ void saveState()
87  {
88  StateSaver saver;
89  saver.setView(view());
90  saver.setSelectionModel(selectionModel());
91  KConfigGroup cfg = configGroup();
92  saver.saveState(cfg);
93  cfg.sync();
94  }
95 
96  /* reimp */ void restoreState()
97  {
98  StateRestorer *restorer = new StateRestorer;
99  restorer->setView(view());
100  restorer->setSelectionModel(selectionModel());
101  restorer->restoreState(configGroup());
102  }
103 
104 };
105 
106 #endif
KViewStateMaintainerBase::selectionModel
QItemSelectionModel * selectionModel() const
Definition: kviewstatemaintainer.cpp:75
QItemSelectionModel
KViewStateMaintainer::saveState
void saveState()
Definition: kviewstatemaintainer.h:86
QObject
KViewStateMaintainerBase::view
QAbstractItemView * view() const
Definition: kviewstatemaintainer.cpp:96
KViewStateMaintainer
Encapsulates the maintenance of state between resets of QAbstractItemModel.
Definition: kviewstatemaintainer.h:76
KViewStateMaintainerBase::configGroup
KConfigGroup configGroup() const
Definition: kviewstatemaintainer.cpp:69
ksharedconfig.h
KConfigGroup
KViewStateMaintainer::restoreState
void restoreState()
Definition: kviewstatemaintainer.h:96
kdeui_export.h
KConfigGroup::sync
void sync()
KViewStateMaintainerBase
Definition: kviewstatemaintainer.h:35
KViewStateMaintainer::KViewStateMaintainer
KViewStateMaintainer(KConfigGroup configGroup, QObject *parent=0)
Definition: kviewstatemaintainer.h:80
kconfiggroup.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:16 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

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