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

lokalize

  • sources
  • kde-4.14
  • kdesdk
  • lokalize
  • src
  • tm
dbfilesmodel.h
Go to the documentation of this file.
1 /* ****************************************************************************
2  This file is part of Lokalize
3 
4  Copyright (C) 2007-2011 by Nick Shaforostoff <shafff@ukr.net>
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License as
8  published by the Free Software Foundation; either version 2 of
9  the License or (at your option) version 3 or any later version
10  accepted by the membership of KDE e.V. (or its successor approved
11  by the membership of KDE e.V.), which shall act as a proxy
12  defined in Section 14 of version 3 of the license.
13 
14  This program 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
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program. If not, see <http://www.gnu.org/licenses/>.
21 
22 **************************************************************************** */
23 
24 #ifndef DBFILESMODEL_H
25 #define DBFILESMODEL_H
26 
27 #include "jobs.h"
28 
29 #include <QSortFilterProxyModel>
30 #include <QTime>
31 class QFileSystemModel;
32 class QPersistentModelIndex;
33 
34 namespace ThreadWeaver{class Job;}
35 
36 namespace TM{
37 class OpenDBJob;
38 
39 class DBFilesModel: public QSortFilterProxyModel
40 {
41 Q_OBJECT
42 public:
43 
44  enum Columns
45  {
46  Name=0,
47  SourceLang,
48  TargetLang,
49  Pairs,
50  OriginalsCount,
51  TranslationsCount,
52  ColumnCount
53  };
54 
55  enum Rolse
56  {
57  NameRole=Qt::UserRole+50
58  };
59 
60  DBFilesModel();
61  ~DBFilesModel();
62 
63  QVariant data(const QModelIndex& index, int role=Qt::DisplayRole) const;
64  int columnCount ( const QModelIndex& parent = QModelIndex() ) const;
65  Qt::ItemFlags flags(const QModelIndex&) const {return Qt::ItemIsSelectable|Qt::ItemIsEnabled;}
66  QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const;
67 
68  QModelIndex rootIndex() const;
69  void removeTM(QModelIndex);
70 
71 
72  //can be zero!!!
73  QPersistentModelIndex* projectDBIndex()const{return projectDB;}
74 
75  void openDB(const QString& name);
76  void openDB(const QString& name, DbType type);
77  void openDB(OpenDBJob*);
78 
79  static DBFilesModel* instance();
80 private:
81  static DBFilesModel* _instance;
82  static void cleanupDBFilesModel();
83 
84 protected:
85  bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
86 
87 public slots:
88  void updateStats(const QModelIndex& topLeft, const QModelIndex& bottomRight);
89  void calcStats(const QModelIndex& parent, int start, int end);
90  void openJobDone(ThreadWeaver::Job*);
91  void closeJobDone(ThreadWeaver::Job*);
92  void updateProjectTmIndex();
93 
94 private:
95  mutable QPersistentModelIndex* projectDB;
96  QFileSystemModel* m_fileSystemModel;
97  QString m_tmRootPath;
98  QTime m_timeSinceLastUpdate;
99 
100  QMap< QString,OpenDBJob::DBStat> m_stats;
101 public:
102  QMap< QString,TMConfig> m_configurations;
103 };
104 
105 }
106 #endif
QSortFilterProxyModel::index
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
TM::DbType
DbType
Definition: jobs.h:43
TM::DBFilesModel
Definition: dbfilesmodel.h:39
QModelIndex
TM::DBFilesModel::NameRole
Definition: dbfilesmodel.h:57
TM::DBFilesModel::filterAcceptsRow
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
Definition: dbfilesmodel.cpp:86
TM::DBFilesModel::Name
Definition: dbfilesmodel.h:46
QFileSystemModel
TM::DBFilesModel::m_configurations
QMap< QString, TMConfig > m_configurations
Definition: dbfilesmodel.h:102
QMap
TM::DBFilesModel::data
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
Definition: dbfilesmodel.cpp:203
TM::DBFilesModel::SourceLang
Definition: dbfilesmodel.h:47
QTime
TM::DBFilesModel::updateStats
void updateStats(const QModelIndex &topLeft, const QModelIndex &bottomRight)
Definition: dbfilesmodel.cpp:137
QObject::name
const char * name() const
TM::DBFilesModel::DBFilesModel
DBFilesModel()
Definition: dbfilesmodel.cpp:57
TM::DBFilesModel::calcStats
void calcStats(const QModelIndex &parent, int start, int end)
Definition: dbfilesmodel.cpp:148
TM::DBFilesModel::closeJobDone
void closeJobDone(ThreadWeaver::Job *)
Definition: dbfilesmodel.cpp:183
TM::DBFilesModel::TargetLang
Definition: dbfilesmodel.h:48
TM::DBFilesModel::headerData
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: dbfilesmodel.cpp:100
TM::OpenDBJob
Definition: jobs.h:74
TM::DBFilesModel::projectDBIndex
QPersistentModelIndex * projectDBIndex() const
Definition: dbfilesmodel.h:73
QString
TM::DBFilesModel::Columns
Columns
Definition: dbfilesmodel.h:44
TM::DBFilesModel::openJobDone
void openJobDone(ThreadWeaver::Job *)
Definition: dbfilesmodel.cpp:166
TM::DBFilesModel::OriginalsCount
Definition: dbfilesmodel.h:50
TM::DBFilesModel::openDB
void openDB(const QString &name)
Definition: dbfilesmodel.cpp:117
TM::DBFilesModel::flags
Qt::ItemFlags flags(const QModelIndex &) const
Definition: dbfilesmodel.h:65
TM::DBFilesModel::Rolse
Rolse
Definition: dbfilesmodel.h:55
QSortFilterProxyModel
TM::DBFilesModel::TranslationsCount
Definition: dbfilesmodel.h:51
TM::DBFilesModel::~DBFilesModel
~DBFilesModel()
Definition: dbfilesmodel.cpp:80
jobs.h
QPersistentModelIndex
TM::DBFilesModel::rootIndex
QModelIndex rootIndex() const
Definition: dbfilesmodel.cpp:95
TM::DBFilesModel::Pairs
Definition: dbfilesmodel.h:49
TM::DBFilesModel::columnCount
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: dbfilesmodel.cpp:197
QObject::parent
QObject * parent() const
TM::DBFilesModel::updateProjectTmIndex
void updateProjectTmIndex()
Definition: dbfilesmodel.cpp:189
TM::DBFilesModel::removeTM
void removeTM(QModelIndex)
Definition: dbfilesmodel.cpp:174
TM::DBFilesModel::ColumnCount
Definition: dbfilesmodel.h:52
TM::DBFilesModel::instance
static DBFilesModel * instance()
Definition: dbfilesmodel.cpp:46
QVariant
Qt::ItemFlags
typedef ItemFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:40:06 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

lokalize

Skip menu "lokalize"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • 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