X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiSelectionManager.h;h=1a9d1ce9bde751c375f7ab10bbf90f71c6c7fb5e;hb=5a46224f7311067cda747e0cae32d22dd919f179;hp=ac4671be456db74d4224904b3b1df86b6625ab54;hpb=6f0703e707a529823fe23342fd01ae36e8b5c8aa;p=lyx.git diff --git a/src/frontends/qt4/GuiSelectionManager.h b/src/frontends/qt4/GuiSelectionManager.h index ac4671be45..1a9d1ce9bd 100644 --- a/src/frontends/qt4/GuiSelectionManager.h +++ b/src/frontends/qt4/GuiSelectionManager.h @@ -12,14 +12,16 @@ #ifndef GUISELECTIONMANAGER_H #define GUISELECTIONMANAGER_H -#include "Dialog.h" - #include -#include -#include -#include -#include -#include + +class QAbstractListModel; +class QModelIndex; +class QListView; +class QPushButton; +class QVariant; +class QAbstractItemView; +class QItemSelection; +template class QMap; namespace lyx { namespace frontend { @@ -34,22 +36,24 @@ namespace frontend { */ class GuiSelectionManager : public QObject { -Q_OBJECT + Q_OBJECT public: /// GuiSelectionManager( - QListView * availableLV, + QAbstractItemView * availableLV, QListView * selectedLV, QPushButton * addPB, QPushButton * delPB, QPushButton * upPB, QPushButton * downPB, - QStringListModel * availableModel, - QStringListModel * selectedModel); + QAbstractListModel * availableModel, + QAbstractListModel * selectedModel); /// Sets the state of the various push buttons, depending upon the /// state of the widgets. (E.g., "delete" is enabled only if the /// selection is non-empty.) + /// Note: this is separated out into updateAddPB(), etc, below, + /// for easy over-riding of these functions. void update(); /// Not strictly a matter of focus, which may be elsewhere, but @@ -57,62 +61,82 @@ public: /// to be used, for example, in displaying information about a /// highlighted item: should it be the highlighted available item /// or the highlighted selected item that is displayed? - bool selectedFocused() { return selectedHasFocus_; }; + bool selectedFocused() const { return selectedHasFocus_; }; + /// Returns the selected index. Note that this will depend upon + /// selectedFocused(). + QModelIndex getSelectedIndex() const; Q_SIGNALS: - ///Emitted when the list of selected items has changed. + /// Emitted when the list of selected items has changed. void selectionChanged(); - ///Emitted when something has changed that might lead the containing - ///dialog to want to update---the focused subwidget or selected item. - ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.) - ///NOTE: No automatic update of the button state is done here. If you - ///just want to do that, connect updateHook() to updateView(). Much of the - ///time, though, you will want to do a bit more processing first, so - ///you can connect to some other function that itself calls updateView(). + /// Emitted when something has changed that might lead the containing + /// dialog to want to update---the focused subwidget or selected item. + /// (Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.) + /// NOTE: No automatic update of the button state is done here. If you + /// just want to do that, connect updateHook() to updateView(). Much of the + /// time, though, you will want to do a bit more processing first, so + /// you can connect to some other function that itself calls updateView(). void updateHook(); - ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected - ///to an "OK" event in the parent dialog. + /// Emitted on Ctrl-Enter in the availableLV. Intended to be connected + /// to an "OK" event in the parent dialog. void okHook(); protected: - ///Given a QModelIndex from availableLV, determines whether it has - ///been selected (i.e., is also in selectedLV). + /// Given a QModelIndex from availableLV, determines whether it has + /// been selected (i.e., is also in selectedLV). bool isSelected(const QModelIndex & idx); + /// + bool insertRowToSelected(int i, QMap const & itemData); + /// + QAbstractItemView * availableLV; + /// + QListView * selectedLV; + /// + QPushButton * addPB; + /// + QPushButton * deletePB; + /// + QPushButton * upPB; + /// + QPushButton * downPB; + /// + QAbstractListModel * availableModel; + /// + QAbstractListModel * selectedModel; protected Q_SLOTS: /// - void availableChanged(const QModelIndex & idx, const QModelIndex &); + void availableChanged(QModelIndex const & idx, QModelIndex const &); /// - void selectedChanged(const QModelIndex & idx, const QModelIndex &); + void selectedChanged(QModelIndex const & idx, QModelIndex const &); /// - void addPB_clicked(); + void availableChanged(QItemSelection const & qis, QItemSelection const &); /// - void deletePB_clicked(); + void selectedChanged(QItemSelection const & qis, QItemSelection const &); /// - void upPB_clicked(); + virtual void addPB_clicked(); /// - void downPB_clicked(); + virtual void deletePB_clicked(); /// - void availableLV_clicked(const QModelIndex &); + virtual void upPB_clicked(); /// - void availableLV_doubleClicked(const QModelIndex &); + virtual void downPB_clicked(); /// - void selectedLV_clicked(const QModelIndex &); + void availableLV_doubleClicked(const QModelIndex &); /// bool eventFilter(QObject *, QEvent *); private: - QListView * availableLV; - QListView * selectedLV; - QPushButton * addPB; - QPushButton * deletePB; - QPushButton * upPB; - QPushButton * downPB; - QStringListModel * availableModel; - QStringListModel * selectedModel; - //Dialog::View * dialog; - + /// + virtual void updateAddPB(); + /// + virtual void updateDelPB(); + /// + virtual void updateDownPB(); + /// + virtual void updateUpPB(); + /// bool selectedHasFocus_; };