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
19 #include <QStringList>
20 #include <QStringListModel>
22 #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
42 QListView * availableLV,
43 QListView * selectedLV,
48 QStringListModel * availableModel,
49 QStringListModel * 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.)
55 /// Not strictly a matter of focus, which may be elsewhere, but
56 /// whether selectedLV is `more focused' than availableLV. Intended
57 /// to be used, for example, in displaying information about a
58 /// highlighted item: should it be the highlighted available item
59 /// or the highlighted selected item that is displayed?
60 bool selectedFocused() { return selectedHasFocus_; };
63 ///Emitted when the list of selected items has changed.
64 void selectionChanged();
65 ///Emitted when something has changed that might lead the containing
66 ///dialog to want to update---the focused subwidget or selected item.
67 ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
68 ///NOTE: No automatic update of the button state is done here. If you
69 ///just want to do that, connect updateHook() to updateView(). Much of the
70 ///time, though, you will want to do a bit more processing first, so
71 ///you can connect to some other function that itself calls updateView().
73 ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected
74 ///to an "OK" event in the parent dialog.
79 ///Given a QModelIndex from availableLV, determines whether it has
80 ///been selected (i.e., is also in selectedLV).
81 bool isSelected(const QModelIndex & idx);
85 void availableChanged(const QModelIndex & idx, const QModelIndex &);
87 void selectedChanged(const QModelIndex & idx, const QModelIndex &);
91 void deletePB_clicked();
95 void downPB_clicked();
97 void availableLV_clicked(const QModelIndex &);
99 void availableLV_doubleClicked(const QModelIndex &);
101 void selectedLV_clicked(const QModelIndex &);
103 bool eventFilter(QObject *, QEvent *);
106 QListView * availableLV;
107 QListView * selectedLV;
109 QPushButton * deletePB;
111 QPushButton * downPB;
112 QStringListModel * availableModel;
113 QStringListModel * selectedModel;
114 //Dialog::View * dialog;
116 bool selectedHasFocus_;
119 } // namespace frontend
122 #endif // GUISELECTIONMANAGER