]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiSelectionManager.h
Remove the magic boolean in getChildren() from the public interface.
[lyx.git] / src / frontends / qt4 / GuiSelectionManager.h
index 43ceea7b50f703c8c449e245e87472f5f18c62c3..1a9d1ce9bde751c375f7ab10bbf90f71c6c7fb5e 100644 (file)
 #ifndef GUISELECTIONMANAGER_H
 #define GUISELECTIONMANAGER_H
 
-#include "Dialog.h"
-
 #include <QObject>
-#include <QKeyEvent>
-#include <QStringList>
-#include <QAbstractListModel>
-#include <QListView>
-#include <QPushButton>
-
-#include "support/qstring_helpers.h"
 
-#include <vector>
+class QAbstractListModel;
+class QModelIndex;
+class QListView;
+class QPushButton;
+class QVariant;
+class QAbstractItemView;
+class QItemSelection;
+template <class T, class U> class QMap;
 
 namespace lyx {
 namespace frontend {
@@ -38,12 +36,12 @@ namespace frontend {
  */
 class GuiSelectionManager : public QObject
 {
-Q_OBJECT
+       Q_OBJECT
 
 public:
        ///
        GuiSelectionManager(
-               QListView * availableLV, 
+               QAbstractItemView * availableLV,
                QListView * selectedLV,
                QPushButton * addPB, 
                QPushButton * delPB, 
@@ -63,32 +61,35 @@ public:
        /// to be used, for example, in displaying information about a
        /// highlighted item: should it be the highlighted available item
        /// or the highlighted selected item that is displayed?
-       bool selectedFocused() { return selectedHasFocus_; };
+       bool selectedFocused() const { return selectedHasFocus_; };
+       /// Returns the selected index. Note that this will depend upon
+       /// selectedFocused().
+       QModelIndex getSelectedIndex() const;
 
 Q_SIGNALS:
-       ///Emitted when the list of selected items has changed. 
+       /// Emitted when the list of selected items has changed. 
        void selectionChanged();
-       ///Emitted when something has changed that might lead the containing 
-       ///dialog to want to update---the focused subwidget or selected item.
-       ///(Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
-       ///NOTE: No automatic update of the button state is done here. If you
-       ///just want to do that, connect updateHook() to updateView(). Much of the
-       ///time, though, you will want to do a bit more processing first, so
-       ///you can connect to some other function that itself calls updateView().
+       /// Emitted when something has changed that might lead the containing 
+       /// dialog to want to update---the focused subwidget or selected item.
+       /// (Specifically, it is emitted by *_PB_clicked() and *_LV_clicked.)
+       /// NOTE: No automatic update of the button state is done here. If you
+       /// just want to do that, connect updateHook() to updateView(). Much of the
+       /// time, though, you will want to do a bit more processing first, so
+       /// you can connect to some other function that itself calls updateView().
        void updateHook();
-       ///Emitted on Ctrl-Enter in the availableLV. Intended to be connected 
-       ///to an "OK" event in the parent dialog.
+       /// Emitted on Ctrl-Enter in the availableLV. Intended to be connected 
+       /// to an "OK" event in the parent dialog.
        void okHook();
 
 
 protected:
-       ///Given a QModelIndex from availableLV, determines whether it has
-       ///been selected (i.e., is also in selectedLV).
+       /// Given a QModelIndex from availableLV, determines whether it has
+       /// been selected (i.e., is also in selectedLV).
        bool isSelected(const QModelIndex & idx);
        ///
        bool insertRowToSelected(int i, QMap<int, QVariant> const & itemData);
        ///
-       QListView * availableLV;
+       QAbstractItemView * availableLV;
        ///
        QListView * selectedLV;
        ///
@@ -106,9 +107,13 @@ protected:
 
 protected Q_SLOTS:
        ///
-       void availableChanged(const QModelIndex & idx, const QModelIndex &);
+       void availableChanged(QModelIndex const & idx, QModelIndex const &);
+       ///
+       void selectedChanged(QModelIndex const & idx, QModelIndex const &);
        ///
-       void selectedChanged(const QModelIndex & idx, const QModelIndex &);
+       void availableChanged(QItemSelection const & qis, QItemSelection const &);
+       ///
+       void selectedChanged(QItemSelection const & qis, QItemSelection const &);
        ///
        virtual void addPB_clicked();
        ///
@@ -118,12 +123,8 @@ protected Q_SLOTS:
        ///
        virtual void downPB_clicked();
        ///
-       void availableLV_clicked(const QModelIndex &);
-       ///
        void availableLV_doubleClicked(const QModelIndex &);
        ///
-       void selectedLV_clicked(const QModelIndex &);
-       ///
        bool eventFilter(QObject *, QEvent *);
 
 private: