Scribus
Open source desktop publishing at your fingertips
unicodesearch.h
1 /*
2 For general Scribus (>=1.3.2) copyright and licensing information please refer
3 to the COPYING file provided with the program. Following this notice may exist
4 a copyright and/or license notice that predates the release of Scribus 1.3.2
5 for which a new license (GPL+exception) is in place.
6 */
7 #ifndef UNICODESEARCH_H
8 #define UNICODESEARCH_H
9 
10 #include <QPushButton>
11 // #include <QTimer>
12 
13 #include "ui_unicodesearch.h"
14 #include "scribusapi.h"
15 
16 class UnicodeSearchModel;
17 class QSortFilterProxyModel;
18 
19 
26 class SCRIBUS_API UnicodeSearch : public QDialog, public Ui::UnicodeSearch
27 {
28  Q_OBJECT
29 
30 public:
34  UnicodeSearch(QWidget* parent = 0);
35  ~UnicodeSearch();
36 
37 signals:
39  void setVisibleState(bool);
43  void glyphSelected(const QString & hex);
44 
45 private:
47  QSortFilterProxyModel * m_proxyModel;
49  UnicodeSearchModel * m_model;
50 
52  void hideEvent(QHideEvent * e);
53 
54  private slots:
56  void searchEdit_returnPressed();
58  void itemChosen(const QModelIndex & index);
59 };
60 
61 
69 class UnicodeSearchModel : public QAbstractTableModel
70 {
71  Q_OBJECT
72 
73  public:
74  UnicodeSearchModel(QObject * parent = 0);
76 
77  int rowCount(const QModelIndex & parent = QModelIndex()) const;
78  int columnCount(const QModelIndex & parent = QModelIndex()) const;
79 
80  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
81 
83  QString hexData(const QModelIndex & index);
84 
86  QString descriptionFromHex(const QString& hex);
87 
88  private:
89 
91  struct UnicodeStruct
92  {
93  QString hex;
94  QString description;
95  };
100  QList<UnicodeStruct> m_unicode;
101 
102 /* QVariant headerData(int section,
103  Qt::Orientation orientation,
104  int role = Qt::DisplayRole) const;*/
105 };
106 
113 class SCRIBUS_API UnicodeChooseButton : public QPushButton
114 {
115  Q_OBJECT
116 
117 public:
121  UnicodeChooseButton(QWidget * parent);
122  ~UnicodeChooseButton(){};
123 
124  virtual void changeEvent(QEvent *e);
125 
126 signals:
128  void chosenUnicode(const QString &);
129 
130 public slots:
132  void languageChange();
133 
134 private:
138  UnicodeSearch* m_searchDialog;
139 
140  /* \brief Hold cache timer.
141  It triggers the m_searchDialog deletion when it's no longer used
142  by user.
143  */
144 // QTimer * m_cacheTimer;
145 
146 private slots:
148  void self_toggled(bool);
150  void glyphSelected(const QString & hex);
151  // \brief Flush the cached m_searchDialog (destroy it).
152 // void deleteSearchDialog();
153 };
154 
155 #endif
QString descriptionFromHex(const QString &hex)
Return character unicode description from hex code.
Definition: unicodesearch.cpp:120
Qt4 model for QTableView used in UnicodeSearch dialog. It contains only 2 columns with hex-descriptio...
Definition: unicodesearch.h:69
Special "search for unicode character" dialog. The search string entered by user is searched in chara...
Definition: unicodesearch.h:26
A special widget to cooperate with UnicodeSearch. Construct a toggle push button. When it's toggled...
Definition: unicodesearch.h:113
QString hexData(const QModelIndex &index)
Return hex-key for the row of given index. See m_keys.
Definition: unicodesearch.cpp:154