Qt 4.8
Classes | Functions
qfontcombobox.cpp File Reference
#include "qfontcombobox.h"
#include <qstringlistmodel.h>
#include <qitemdelegate.h>
#include <qlistview.h>
#include <qpainter.h>
#include <qevent.h>
#include <qapplication.h>
#include <private/qcombobox_p.h>
#include <qdebug.h>
#include "qfontcombobox.moc"
#include "moc_qfontcombobox.cpp"

Go to the source code of this file.

Classes

class  QFontComboBoxPrivate
 
class  QFontFamilyDelegate
 

Functions

static QFontDatabase::WritingSystem writingSystemForFont (const QFont &font, bool *hasLatin)
 

Function Documentation

◆ writingSystemForFont()

static QFontDatabase::WritingSystem writingSystemForFont ( const QFont font,
bool *  hasLatin 
)
static

Definition at line 57 of file qfontcombobox.cpp.

Referenced by QFontFamilyDelegate::paint().

58 {
59  *hasLatin = true;
60 
62 // qDebug() << font.family() << writingSystems;
63 
64  // this just confuses the algorithm below. Vietnamese is Latin with lots of special chars
65  writingSystems.removeAll(QFontDatabase::Vietnamese);
66 
68 
69  if (!writingSystems.contains(QFontDatabase::Latin)) {
70  *hasLatin = false;
71  // we need to show something
72  if (writingSystems.count())
73  system = writingSystems.last();
74  } else {
75  writingSystems.removeAll(QFontDatabase::Latin);
76  }
77 
78  if (writingSystems.isEmpty())
79  return system;
80 
81  if (writingSystems.count() == 1 && writingSystems.at(0) > QFontDatabase::Cyrillic) {
82  system = writingSystems.at(0);
83  return system;
84  }
85 
86  if (writingSystems.count() <= 2
87  && writingSystems.last() > QFontDatabase::Armenian
88  && writingSystems.last() < QFontDatabase::Vietnamese) {
89  system = writingSystems.last();
90  return system;
91  }
92 
93  if (writingSystems.count() <= 5
94  && writingSystems.last() >= QFontDatabase::SimplifiedChinese
95  && writingSystems.last() <= QFontDatabase::Korean)
96  system = writingSystems.last();
97 
98  return system;
99 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QList< WritingSystem > writingSystems() const
Returns a sorted list of the available writing systems.
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
The QFontDatabase class provides information about the fonts available in the underlying window syste...
Definition: qfontdatabase.h:66
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QString family() const
Returns the requested font family name, i.e.
Definition: qfont.cpp:906
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
int removeAll(const T &t)
Removes all occurrences of value in the list and returns the number of entries removed.
Definition: qlist.h:770