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 QSELECTIONMANAGER_H
13 #define QSELECTIONMANAGER_H
18 #include <QStringList>
19 #include <QStringListModel>
21 #include <QPushButton>
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 {
41 QListView * availableLV,
42 QListView * selectedLV,
47 QStringListModel * availableModel,
48 QStringListModel * selectedModel);
49 /// Sets the state of the various push buttons, depending upon the
50 /// state of the widgets. (E.g., "delete" is enabled only if the
51 /// selection is non-empty.)
52 virtual void update();
54 /// Not strictly a matter of focus, which may be elsewhere, but
55 /// whether selectedLV is `more focused' than availableLV. Intended
56 /// to be used, for example, in displaying information about a
57 /// highlighted item: should it be the highlighted available item
58 /// or the highlighted selected item that is displayed?
59 bool selectedFocused() { return selectedHasFocus_; };
62 ///Emitted when the list of selected items has changed.
63 void selectionChanged();
64 ///Emitted when something has changed that might lead the containing
65 ///dialog to want to update---the focused subwidget or selected item.
66 ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
67 ///NOTE: No automatic update of the button state is done here. If you
68 ///just want to do that, connect updateHook() to update(). Much of the
69 ///time, though, you will want to do a bit more processing first, so
70 ///you can connect to some other function that itself calls update().
72 ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
73 ///to an "OK" event in the parent dialog.
78 ///Given a QModelIndex from availableLV, determines whether it has
79 ///been selected (i.e., is also in selectedLV).
80 bool isSelected(const QModelIndex & idx);
84 void availableChanged(const QModelIndex & idx, const QModelIndex &);
86 void selectedChanged(const QModelIndex & idx, const QModelIndex &);
90 void deletePB_clicked();
94 void downPB_clicked();
96 void availableLV_clicked(const QModelIndex &);
98 void availableLV_doubleClicked(const QModelIndex &);
100 void selectedLV_clicked(const QModelIndex &);
102 bool eventFilter(QObject *, QEvent *);
105 QListView * availableLV;
106 QListView * selectedLV;
108 QPushButton * deletePB;
110 QPushButton * downPB;
111 QStringListModel * availableModel;
112 QStringListModel * selectedModel;
113 Dialog::View * dialog;
115 bool selectedHasFocus_;
118 } // namespace frontend