~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/klib/itemmodelserialization.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2015-01-07 14:51:16 UTC
  • mfrom: (4.3.5 sid)
  • Revision ID: package-import@ubuntu.com-20150107145116-yxnafinf4lrdvrmx
Tags: 1.4.1-0.1ubuntu1
* Merge with Debian, remaining changes:
 - Drop soprano, nepomuk build-dep
* Drop ubuntu patches, now upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
 *   Copyright (C) 2014 by Savoir-Faire Linux                               *
 
3
 *   Author : Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
 
4
 *                                                                          *
 
5
 *   This library is free software; you can redistribute it and/or          *
 
6
 *   modify it under the terms of the GNU Lesser General Public             *
 
7
 *   License as published by the Free Software Foundation; either           *
 
8
 *   version 2.1 of the License, or (at your option) any later version.     *
 
9
 *                                                                          *
 
10
 *   This library is distributed in the hope that it will be useful,        *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU      *
 
13
 *   Lesser General Public License for more details.                        *
 
14
 *                                                                          *
 
15
 *   You should have received a copy of the GNU General Public License      *
 
16
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 
17
 ***************************************************************************/
 
18
#include "itemmodelserialization.h"
 
19
 
 
20
#include "../lib/abstractitembackend.h"
 
21
#include "kcfg_settings.h"
 
22
 
 
23
ItemModelStateSerialization::~ItemModelStateSerialization()
 
24
{
 
25
   
 
26
}
 
27
 
 
28
bool ItemModelStateSerialization::save()
 
29
{
 
30
   //FIXME this is too tied to the contact backend, it need to support roles for
 
31
   //other collection types (aka: bookmarks)
 
32
   QStringList ret;
 
33
   for (QHash<QByteArray,bool>::iterator i = m_hChecked.begin(); i != m_hChecked.end(); ++i) {
 
34
      if (i.value())
 
35
         ret << i.key();
 
36
   }
 
37
//    digg(QModelIndex());
 
38
   ConfigurationSkeleton::setDisabledCollectionList(ret);
 
39
   return true;
 
40
}
 
41
 
 
42
bool ItemModelStateSerialization::load()
 
43
{
 
44
   m_hChecked.clear();
 
45
   const QStringList disabled = ConfigurationSkeleton::disabledCollectionList();
 
46
   foreach(const QString& str, disabled) {
 
47
      m_hChecked[str.toAscii()] = true; //Disabled == true, enabled == false
 
48
   }
 
49
   return true;
 
50
}
 
51
 
 
52
bool ItemModelStateSerialization::isChecked(AbstractItemBackendBase* backend) const
 
53
{
 
54
   return !(m_hChecked[backend->id()]);
 
55
}
 
56
 
 
57
bool ItemModelStateSerialization::setChecked(AbstractItemBackendBase* backend, bool enabled)
 
58
{
 
59
   m_hChecked[backend->id()] = ! enabled;
 
60
   return true;
 
61
}