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

parley

  • sources
  • kde-4.12
  • kdeedu
  • parley
  • src
  • vocabulary
vocabularyfilter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  Copyright 2007-2008 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
4 
5  ***************************************************************************/
6 
7 /***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "vocabularyfilter.h"
17 
18 #include "vocabularymodel.h"
19 
20 using namespace Editor;
21 
22 VocabularyFilter::VocabularyFilter(QObject *parent)
23  : QSortFilterProxyModel(parent), m_model(0)
24 {
25  // do not use capitalization for searches
26  setSortCaseSensitivity(Qt::CaseInsensitive);
27  setFilterCaseSensitivity(Qt::CaseInsensitive);
28  // sort locale aware: at least puts umlauts and accents in the right position.
29  // Not sure about languages that are more different.
30  // Also depends on the current locale.
31  setSortLocaleAware(true);
32 
33  // eventually accept only one language if so desired...
34  setFilterKeyColumn(-1);
35 }
36 
37 QModelIndex VocabularyFilter::appendEntry(KEduVocExpression *expression)
38 {
39  if (!m_model) {
40  return QModelIndex();
41  }
42  return mapFromSource(m_model->appendEntry(expression));
43 }
44 
45 void VocabularyFilter::setSourceModel(VocabularyModel * model)
46 {
47  QSortFilterProxyModel::setSourceModel(model);
48  m_model=model;
49 }
50 
51 void VocabularyFilter::setSearchString(const QString & expression)
52 {
53  m_filterString = expression;
54  invalidateFilter();
55 }
56 
57 bool VocabularyFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
58 {
59  if(m_filterString.isEmpty()) {
60  return true;
61  }
62 
63  int columns = m_model->columnCount(QModelIndex());
64  for(int i=0; i < columns; i += VocabularyModel::EntryColumnsMAX) {
65  QModelIndex index = sourceModel()->index(sourceRow, i, sourceParent);
66  if(sourceModel()->data(index).toString().contains(m_filterString, Qt::CaseInsensitive)) {
67  return true;
68  }
69  }
70  return false;
71 }
72 
73 KEduVocLesson * VocabularyFilter::lesson()
74 {
75  if (m_model) {
76  return m_model->lesson();
77  }
78  return 0;
79 }
80 
81 #include "vocabularyfilter.moc"
82 
Editor::VocabularyModel::columnCount
int columnCount(const QModelIndex &) const
Definition: vocabularymodel.cpp:109
Editor::VocabularyFilter::setSourceModel
void setSourceModel(VocabularyModel *model)
Definition: vocabularyfilter.cpp:45
Editor::VocabularyModel
Definition: vocabularymodel.h:30
Editor::VocabularyFilter::VocabularyFilter
VocabularyFilter(QObject *parent=0)
Definition: vocabularyfilter.cpp:22
QObject
Editor::VocabularyFilter::lesson
KEduVocLesson * lesson()
Definition: vocabularyfilter.cpp:73
Editor::VocabularyFilter::filterAcceptsRow
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
Definition: vocabularyfilter.cpp:57
Editor::VocabularyModel::EntryColumnsMAX
Definition: vocabularymodel.h:45
Editor::VocabularyFilter::setSearchString
void setSearchString(const QString &expression)
Definition: vocabularyfilter.cpp:51
QSortFilterProxyModel
Editor::VocabularyFilter::appendEntry
QModelIndex appendEntry(KEduVocExpression *expression=0)
Definition: vocabularyfilter.cpp:37
Editor::VocabularyModel::lesson
KEduVocLesson * lesson()
Definition: vocabularymodel.cpp:91
Editor::VocabularyModel::appendEntry
QModelIndex appendEntry(KEduVocExpression *expression=0)
Definition: vocabularymodel.cpp:323
vocabularyfilter.h
vocabularymodel.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:42:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

parley

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

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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