File indexing completed on 2024-05-05 08:41:24

0001 /*
0002  * Copyright (C) 2012-2015 by Stephen Allewell
0003  * steve.allewell@gmail.com
0004  *
0005  * This program is free software; you can redistribute it and/or modify
0006  * it under the terms of the GNU General Public License as published by
0007  * the Free Software Foundation; either version 2 of the License, or
0008  * (at your option) any later version.
0009  */
0010 
0011 /**
0012  * @file
0013  * Header file for the SymbolSelectorDlg class.
0014  */
0015 
0016 #ifndef SymbolSelectorDlg_H
0017 #define SymbolSelectorDlg_H
0018 
0019 #include <QDialog>
0020 
0021 #include "ui_SymbolSelector.h"
0022 
0023 class SymbolLibrary;
0024 class QHideEvent;
0025 class QShowEvent;
0026 
0027 /**
0028  * @brief Provide a dialog to allow the selection of a symbol for the floss.
0029  *
0030  * This class implements a dialog that will display the symbols belonging to
0031  * the symbol set used by the palette. The icons used are displayed reflecting
0032  * whether the symbol has already been used or not. The user can select a symbol
0033  * either by single or double clicking depending on the system settings for
0034  * selections. The new symbol selected is made available to the caller.
0035  */
0036 class SymbolSelectorDlg : public QDialog
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041     SymbolSelectorDlg(QWidget *parent, const QString &symbolLibrary);
0042 
0043     void setSelectedSymbol(qint16 symbol, const QList<qint16> &usedSymbols);
0044     qint16 selectedSymbol();
0045 
0046 protected:
0047     virtual void hideEvent(QHideEvent *) Q_DECL_OVERRIDE;
0048     virtual void showEvent(QShowEvent *) Q_DECL_OVERRIDE;
0049 
0050 protected slots:
0051     void on_SymbolTable_itemClicked(QListWidgetItem *item);
0052 
0053 private slots:
0054     void on_DialogButtonBox_rejected();
0055     void on_DialogButtonBox_helpRequested();
0056 
0057 private:
0058     Ui::SymbolSelector ui; /**< dialog interface description */
0059 
0060     QList<qint16> m_usedSymbols; /**< a list of used symbols indexes */
0061     qint16 m_currentSymbol; /**< the current symbols index */
0062 };
0063 
0064 #endif