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

lokalize

catalogmodel.cpp

Go to the documentation of this file.
00001 /* ****************************************************************************
00002   This file is part of Lokalize
00003 
00004   Copyright (C) 2007-2008 by Nick Shaforostoff <shafff@ukr.net>
00005 
00006   This program is free software; you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation; either version 2 of the License, or
00009   (at your option) any later version.
00010 
00011   This program is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014   GNU General Public License for more details.
00015 
00016   You should have received a copy of the GNU General Public License
00017   along with this program; if not, write to the Free Software
00018   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019 
00020   In addition, as a special exception, the copyright holders give
00021   permission to link the code of this program with any edition of
00022   the Qt library by Trolltech AS, Norway (or with modified versions
00023   of Qt that use the same license as Qt), and distribute linked
00024   combinations including the two.  You must obey the GNU General
00025   Public License in all respects for all of the code used other than
00026   Qt. If you modify this file, you may extend this exception to
00027   your version of the file, but you are not obligated to do so.  If
00028   you do not wish to do so, delete this exception statement from
00029   your version.
00030 
00031 **************************************************************************** */
00032 
00033 #include "catalogmodel.h"
00034 
00035 #include "catalog.h"
00036 
00037 #include <kdebug.h>
00038 #include <klocale.h>
00039 
00040 #include <QApplication>
00041 
00042 
00043 
00044 int CatalogTreeModel::rowCount(const QModelIndex& parent) const
00045 {
00046     if (parent.isValid())
00047         return 0;
00048     return m_catalog->numberOfEntries();
00049 }
00050 
00051 QVariant CatalogTreeModel::headerData( int section, Qt::Orientation /*orientation*/, int role) const
00052 {
00053     if (role!=Qt::DisplayRole)
00054         return QVariant();
00055 
00056     switch (section)
00057     {
00058         case Key: return i18nc("@title:column","Entry");
00059         case Source: return i18nc("@title:column Original text","Source");
00060         case Target: return i18nc("@title:column Text in target language","Target");
00061         case Approved: return i18nc("@title:column","Approved");
00062     }
00063     return QVariant();
00064 }
00065 
00066 QVariant CatalogTreeModel::data(const QModelIndex& index,int role) const
00067 {
00068     if (m_catalog->numberOfEntries()<=index.row() )
00069         return QVariant();
00070 
00071     if (role==Qt::FontRole && index.column()==Target)
00072     {
00073         bool fuzzy=!m_catalog->isApproved(index.row());
00074         bool modified=m_catalog->isModified(index.row());
00075         if (fuzzy || modified)
00076         {
00077             QFont font=QApplication::font();
00078             font.setItalic(fuzzy);
00079             font.setBold(modified);
00080             return font;
00081         }
00082     }
00083     if (role!=Qt::DisplayRole)
00084         return QVariant();
00085 
00086 
00087 
00088     switch (index.column())
00089     {
00090         case Key: return index.row()+1;
00091         case Source: return m_catalog->msgid(index.row());
00092         case Target: return m_catalog->msgstr(index.row());
00093         case Approved:
00094             static const char* yesno[]={"no","yes"};
00095             return yesno[m_catalog->isApproved(index.row())];
00096     }
00097     return QVariant();
00098 }
00099 
00100 Qt::ItemFlags CatalogTreeModel::flags ( const QModelIndex & index ) const
00101 {
00102     if (index.column()==Approved)
00103         return Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled;
00104     return QAbstractItemModel::flags(index);
00105 }
00106 

lokalize

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

kdesdk

Skip menu "kdesdk"
  • kapptemplate
  • kate
  •     kate
  • kbugbuster
  • kcachegrind
  • kompare
  • lokalize
  • umbrello
  •   umbrello
Generated for kdesdk by doxygen 1.5.7
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal