This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiSelectionManager.h
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Richard Heck
|
|
|
|
* \author Et Alia
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef QSELECTIONMANAGER_H
|
|
|
|
#define QSELECTIONMANAGER_H
|
|
|
|
|
|
|
|
#include "Dialog.h"
|
|
|
|
#include <QObject>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QStringListModel>
|
|
|
|
#include <QListView>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
|
|
|
/** Class to manage a collection of widgets that allows selection
|
|
|
|
* of items from a list of available items. Adapted from code originally
|
2007-08-31 05:53:55 +00:00
|
|
|
* written for GuiCitationDialog.
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
* Note that this is a not a QWidget, though it could be converted to
|
|
|
|
* one. Rather, the managed widgets---see constructor for descripton
|
|
|
|
* of them---should be created independently, and then passed to the
|
|
|
|
* constructor.
|
|
|
|
*/
|
2007-08-31 05:53:55 +00:00
|
|
|
class GuiSelectionManager : public QObject {
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
///
|
2007-08-31 05:53:55 +00:00
|
|
|
GuiSelectionManager(
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
QListView * availableLV,
|
|
|
|
QListView * selectedLV,
|
|
|
|
QPushButton * addPB,
|
|
|
|
QPushButton * delPB,
|
|
|
|
QPushButton * upPB,
|
|
|
|
QPushButton * downPB,
|
|
|
|
QStringListModel * availableModel,
|
|
|
|
QStringListModel * selectedModel);
|
|
|
|
/// Sets the state of the various push buttons, depending upon the
|
|
|
|
/// state of the widgets. (E.g., "delete" is enabled only if the
|
|
|
|
/// selection is non-empty.)
|
2007-09-03 20:28:26 +00:00
|
|
|
virtual void updateView();
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
|
|
|
|
/// Not strictly a matter of focus, which may be elsewhere, but
|
|
|
|
/// whether selectedLV is `more focused' than availableLV. Intended
|
|
|
|
/// 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_; };
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
///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
|
2007-09-03 20:28:26 +00:00
|
|
|
///just want to do that, connect updateHook() to updateView(). Much of the
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
///time, though, you will want to do a bit more processing first, so
|
2007-09-03 20:28:26 +00:00
|
|
|
///you can connect to some other function that itself calls updateView().
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
void updateHook();
|
|
|
|
///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).
|
|
|
|
bool isSelected(const QModelIndex & idx);
|
|
|
|
|
|
|
|
protected Q_SLOTS:
|
|
|
|
///
|
|
|
|
void availableChanged(const QModelIndex & idx, const QModelIndex &);
|
|
|
|
///
|
|
|
|
void selectedChanged(const QModelIndex & idx, const QModelIndex &);
|
|
|
|
///
|
|
|
|
void addPB_clicked();
|
|
|
|
///
|
|
|
|
void deletePB_clicked();
|
|
|
|
///
|
|
|
|
void upPB_clicked();
|
|
|
|
///
|
|
|
|
void downPB_clicked();
|
|
|
|
///
|
|
|
|
void availableLV_clicked(const QModelIndex &);
|
|
|
|
///
|
|
|
|
void availableLV_doubleClicked(const QModelIndex &);
|
|
|
|
///
|
|
|
|
void selectedLV_clicked(const QModelIndex &);
|
|
|
|
///
|
|
|
|
bool eventFilter(QObject *, QEvent *);
|
|
|
|
|
|
|
|
private:
|
|
|
|
QListView * availableLV;
|
|
|
|
QListView * selectedLV;
|
|
|
|
QPushButton * addPB;
|
|
|
|
QPushButton * deletePB;
|
|
|
|
QPushButton * upPB;
|
|
|
|
QPushButton * downPB;
|
|
|
|
QStringListModel * availableModel;
|
|
|
|
QStringListModel * selectedModel;
|
|
|
|
Dialog::View * dialog;
|
|
|
|
|
|
|
|
bool selectedHasFocus_;
|
|
|
|
};
|
2007-08-31 05:53:55 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
|
|
|
|
This is one of a series of patches that will merge the layout modules development in personal/branches/rgheck back into the tree.
Design goal: Allow the use of layout "modules", which are to LaTeX packages as layout files are to LaTeX document classes. Thus, one could have a module that defined certain character styles, environments, commands, or what have you, and include it in various documents, each of which uses a different document class, without having to modify the layout files themselves. For example, a theorems.module could be used with article.layout to provide support for theorem-type environments, without having to modify article.layout itself, and the same module could be used with book.layout, etc.
This third patch just re-factors some code presently in QCitation*. (It also incorporates some bug fixes that have been committed separately.) We're going to use essentially the same set of widgets for choosing modules that is used for choosing citation keys, so we pull the controlling logic out into a new class, QSelectionManager. I did not make this a QWidget. That seemed to me to be overkill, and it would have made things much more complicated, I think...and I'm not all that experienced with Qt, anyway. Anyone who wants to do that is of course welcome.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19860 a592a061-630c-0410-9148-cb99ea01b6c8
2007-08-28 16:49:40 +00:00
|
|
|
#endif
|