home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / unicodesearch.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-10-08  |  4.2 KB  |  153 lines

  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.  
  20. /*! \brief Special "search for unicode character" dialog.
  21. The search string entered by user is searched in character
  22. description and in the hex representation (as string) too.
  23. See directory ./unicodemap/ for more info
  24. \author Petr Vanek <petr@scribus.info>
  25. */
  26. class SCRIBUS_API UnicodeSearch : public QDialog, public Ui::UnicodeSearch
  27. {
  28.     Q_OBJECT
  29.  
  30. public:
  31.     /*! \brief QDialog like constructor
  32.     \param parent standard qt widget
  33.     */
  34.     UnicodeSearch(QWidget* parent = 0);
  35.     ~UnicodeSearch();
  36.  
  37. signals:
  38.     //! \brief Emitted when the dialog gets hidden.
  39.     void setVisibleState(bool);
  40.     /*! \brief Emitted when user choses any value.
  41.     \param hex a hex value of glyph - see m_keys.
  42.     */
  43.     void glyphSelected(const QString & hex);
  44.  
  45. private:
  46.     //! Searching wrapper
  47.     QSortFilterProxyModel * m_proxyModel;
  48.     //! Data model
  49.     UnicodeSearchModel * m_model;
  50.  
  51.     //! \brief Overriden hide event. Just emit the setVisibleState(false) here.
  52.     void hideEvent(QHideEvent * e);
  53.  
  54.     private slots:
  55.         //! Perform the search and switch the focus to the tableView
  56.         void searchEdit_returnPressed();
  57.         //! Handle items from view to promote upstream and close the widget
  58.         void itemChosen(const QModelIndex & index);
  59. };
  60.  
  61.  
  62. /*!\brief Qt4 model for QTableView used in UnicodeSearch dialog.
  63. It contains only 2 columns with hex-description pairs/rows of
  64. unicode glyphs (loaded from unicodemap/unicodenameslist.txt.
  65. Hex and descriptions are stored in QMap description+code/code
  66. for performance.
  67. \author Petr Vanek <petr@scribus.info>
  68. */
  69. class UnicodeSearchModel : public QAbstractTableModel
  70. {
  71.     Q_OBJECT
  72.  
  73.     public:
  74.         UnicodeSearchModel(QObject * parent = 0);
  75.         ~UnicodeSearchModel();
  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.  
  82.         //! \brief Return hex-key for the row of given index. See m_keys.
  83.         QString hexData(const QModelIndex & index);
  84.  
  85.     private:
  86.  
  87.         //! \brief Easier to use QPair-like replacement
  88.         struct UnicodeStruct
  89.         {
  90.             QString hex;
  91.             QString description;
  92.         };
  93.         /*! \brief Internal hex-description mapping.
  94.         It's filled in constructor only once. All searching re-fills
  95.         of the unicodeList are performed on this list (used
  96.         as model's data) */
  97.         QList<UnicodeStruct> m_unicode;
  98.  
  99. /*        QVariant headerData(int section,
  100.                             Qt::Orientation orientation,
  101.                             int role = Qt::DisplayRole) const;*/
  102. };
  103.  
  104. /*! \brief A special widget to cooperate with UnicodeSearch.
  105. Construct a toggle push button. When it's toggled, the search dialog
  106. is shown. It is an "apply" button too.
  107. Search dialog is constructed on demand only.
  108. \author Petr Vanek <petr@scribus.info>
  109. */
  110. class SCRIBUS_API UnicodeChooseButton : public QPushButton
  111. {
  112.     Q_OBJECT
  113.  
  114. public:
  115.     /*! \brief QWidget like constructor.
  116.     \param parent a QWidget parent
  117.     */
  118.     UnicodeChooseButton(QWidget * parent);
  119.     ~UnicodeChooseButton(){};
  120.  
  121.     virtual void changeEvent(QEvent *e);
  122.  
  123. signals:
  124.     //! \brief Signal transfering the chosen character as QString
  125.     void chosenUnicode(const QString &);
  126.  
  127. public slots:
  128.     //! \brief Slot for changing language of GUI
  129.     void languageChange();
  130.  
  131. private:
  132.     /*! \brief UnicodeSearch reference.
  133.     The dialog is created in "this" constructor. Showing and hiding
  134.     is handled by toggled() signal catched in self_toggled() */
  135.     UnicodeSearch* m_searchDialog;
  136.  
  137.     /* \brief Hold cache timer.
  138.     It triggers the m_searchDialog deletion when it's no longer used
  139.     by user.
  140.     */
  141. //     QTimer * m_cacheTimer;
  142.  
  143. private slots:
  144.     //! \brief Handle toggle state (show/hide) search dialog.
  145.     void self_toggled(bool);
  146.     //! \brief Handle various signals - user inputs (clicked, return pressed etc.)
  147.     void glyphSelected(const QString & hex);
  148.     // \brief Flush the cached m_searchDialog (destroy it).
  149. //     void deleteSearchDialog();
  150. };
  151.  
  152. #endif
  153.