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.)
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 QListView * availableLV;
87 QListView * selectedLV;
91 QPushButton * deletePB;
97 QStringListModel * availableModel;
99 QStringListModel * selectedModel;
103 void availableChanged(const QModelIndex & idx, const QModelIndex &);
105 void selectedChanged(const QModelIndex & idx, const QModelIndex &);
107 void addPB_clicked();
109 void deletePB_clicked();
113 void downPB_clicked();
115 void availableLV_clicked(const QModelIndex &);
117 void availableLV_doubleClicked(const QModelIndex &);
119 void selectedLV_clicked(const QModelIndex &);
121 bool eventFilter(QObject *, QEvent *);
125 virtual void updateAddPB();
127 virtual void updateDelPB();
129 virtual void updateDownPB();
131 virtual void updateUpPB();
133 bool selectedHasFocus_;
136 } // namespace frontend
139 #endif // GUISELECTIONMANAGER