2 * \file GuiSelectionManager.h
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
12 #ifndef GUISELECTIONMANAGER_H
13 #define GUISELECTIONMANAGER_H
17 class QAbstractListModel;
22 template <class T, class U> class QMap;
27 /** Class to manage a collection of widgets that allows selection
28 * of items from a list of available items. Adapted from code originally
29 * written for GuiCitationDialog.
30 * Note that this is a not a QWidget, though it could be converted to
31 * one. Rather, the managed widgets---see constructor for descripton
32 * of them---should be created independently, and then passed to the
35 class GuiSelectionManager : public QObject
42 QListView * availableLV,
43 QListView * selectedLV,
48 QAbstractListModel * availableModel,
49 QAbstractListModel * selectedModel);
50 /// Sets the state of the various push buttons, depending upon the
51 /// state of the widgets. (E.g., "delete" is enabled only if the
52 /// selection is non-empty.)
53 /// Note: this is separated out into updateAddPB(), etc, below,
54 /// for easy over-riding of these functions.
57 /// Not strictly a matter of focus, which may be elsewhere, but
58 /// whether selectedLV is `more focused' than availableLV. Intended
59 /// to be used, for example, in displaying information about a
60 /// highlighted item: should it be the highlighted available item
61 /// or the highlighted selected item that is displayed?
62 bool selectedFocused() { return selectedHasFocus_; };
65 /// Emitted when the list of selected items has changed.
66 void selectionChanged();
67 /// Emitted when something has changed that might lead the containing
68 /// dialog to want to update---the focused subwidget or selected item.
69 /// (Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
70 /// NOTE: No automatic update of the button state is done here. If you
71 /// just want to do that, connect updateHook() to updateView(). Much of the
72 /// time, though, you will want to do a bit more processing first, so
73 /// you can connect to some other function that itself calls updateView().
75 /// Emitted on Ctrl-Enter in the availableLV. Intended to be connected
76 /// to an "OK" event in the parent dialog.
81 /// Given a QModelIndex from availableLV, determines whether it has
82 /// been selected (i.e., is also in selectedLV).
83 bool isSelected(const QModelIndex & idx);
85 bool insertRowToSelected(int i, QMap<int, QVariant> const & itemData);
87 QListView * availableLV;
89 QListView * selectedLV;
93 QPushButton * deletePB;
99 QAbstractListModel * availableModel;
101 QAbstractListModel * selectedModel;
105 void availableChanged(const QModelIndex & idx, const QModelIndex &);
107 void selectedChanged(const QModelIndex & idx, const QModelIndex &);
109 virtual void addPB_clicked();
111 virtual void deletePB_clicked();
113 virtual void upPB_clicked();
115 virtual void downPB_clicked();
117 void availableLV_clicked(const QModelIndex &);
119 void availableLV_doubleClicked(const QModelIndex &);
121 void selectedLV_clicked(const QModelIndex &);
123 bool eventFilter(QObject *, QEvent *);
127 virtual void updateAddPB();
129 virtual void updateDelPB();
131 virtual void updateDownPB();
133 virtual void updateUpPB();
135 bool selectedHasFocus_;
138 } // namespace frontend
141 #endif // GUISELECTIONMANAGER