2 * \file QSelectionManager.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>
26 /** Class to manage a collection of widgets that allows selection
27 * of items from a list of available items. Adapted from code originally
28 * written for QCitationDialog.
29 * Note that this is a not a QWidget, though it could be converted to
30 * one. Rather, the managed widgets---see constructor for descripton
31 * of them---should be created independently, and then passed to the
34 class QSelectionManager: public QObject {
40 QListView * availableLV,
41 QListView * selectedLV,
46 QStringListModel * availableModel,
47 QStringListModel * selectedModel);
48 /// Sets the state of the various push buttons, depending upon the
49 /// state of the widgets. (E.g., "delete" is enabled only if the
50 /// selection is non-empty.)
51 virtual void update();
53 /// Not strictly a matter of focus, which may be elsewhere, but
54 /// whether selectedLV is `more focused' than availableLV. Intended
55 /// to be used, for example, in displaying information about a
56 /// highlighted item: should it be the highlighted available item
57 /// or the highlighted selected item that is displayed?
58 bool selectedFocused() { return selectedHasFocus_; };
61 ///Emitted when the list of selected items has changed.
62 void selectionChanged();
63 ///Emitted when something has changed that might lead the containing
64 ///dialog to want to update---the focused subwidget or selected item.
65 ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
66 ///NOTE: No automatic update of the button state is done here. If you
67 ///just want to do that, connect updateHook() to update(). Much of the
68 ///time, though, you will want to do a bit more processing first, so
69 ///you can connect to some other function that itself calls update().
71 ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
72 ///to an "OK" event in the parent dialog.
77 ///Given a QModelIndex from availableLV, determines whether it has
78 ///been selected (i.e., is also in selectedLV).
79 bool isSelected(const QModelIndex & idx);
83 void availableChanged(const QModelIndex & idx, const QModelIndex &);
85 void selectedChanged(const QModelIndex & idx, const QModelIndex &);
89 void deletePB_clicked();
93 void downPB_clicked();
95 void availableLV_clicked(const QModelIndex &);
97 void availableLV_doubleClicked(const QModelIndex &);
99 void selectedLV_clicked(const QModelIndex &);
101 bool eventFilter(QObject *, QEvent *);
104 QListView * availableLV;
105 QListView * selectedLV;
107 QPushButton * deletePB;
109 QPushButton * downPB;
110 QStringListModel * availableModel;
111 QStringListModel * selectedModel;
112 Dialog::View * dialog;
114 bool selectedHasFocus_;
116 }//namespace frontend