cosmetics. remoe strange dependency of GuiDocument.h

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26467 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2008-09-20 13:44:51 +00:00
parent 0f6b4e902f
commit fc86915b0c
7 changed files with 89 additions and 113 deletions

View File

@ -21,7 +21,7 @@ using namespace std;
using namespace lyx::support;
//namespace lyx {
namespace lyx {
FloatPlacement::FloatPlacement(QWidget *)
{
@ -239,6 +239,6 @@ void FloatPlacement::checkAllowed()
}
}
//} // namespace lyx
} // namespace lyx
#include "FloatPlacement_moc.cpp"

View File

@ -1,6 +1,6 @@
// -*- C++ -*-
/**
* \file floatplacement.h
* \file FloatPlacement.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
@ -10,8 +10,8 @@
* Full author contact details are available in file CREDITS.
*/
#ifndef QT_FLOATPLACEMENT_H
#define QT_FLOATPLACEMENT_H
#ifndef FLOATPLACEMENT_H
#define FLOATPLACEMENT_H
#include "ui_FloatPlacementUi.h"
#include <QWidget>
@ -19,7 +19,9 @@
#include <string>
namespace lyx { class InsetFloatParams; }
namespace lyx {
class InsetFloatParams;
class FloatPlacement : public QWidget, public Ui::FloatPlacementUi {
Q_OBJECT
@ -52,7 +54,6 @@ private:
};
} // namespace lyx
//} // namespace lyx
#endif
#endif // FLOATPLACEMENT_H

View File

@ -15,6 +15,7 @@
#include "GuiApplication.h"
#include "GuiBranches.h"
#include "GuiSelectionManager.h"
#include "LaTeXHighlighter.h"
#include "LengthCombo.h"
#include "PanelStack.h"
@ -140,7 +141,7 @@ class less_textclass_avail_desc
: public binary_function<string, string, int>
{
public:
int operator()(string const & lhs, string const & rhs) const
bool operator()(string const & lhs, string const & rhs) const
{
// Ordering criteria:
// 1. Availability of text class
@ -156,20 +157,6 @@ public:
}
namespace frontend {
///
QModelIndex getSelectedIndex(QListView * lv)
{
QModelIndex retval = QModelIndex();
QModelIndexList selIdx =
lv->selectionModel()->selectedIndexes();
if (!selIdx.empty())
retval = selIdx.first();
return retval;
}
namespace {
vector<string> getRequiredList(string const & modName)
@ -225,20 +212,45 @@ bool isModuleAvailable(string const & modName)
//
/////////////////////////////////////////////////////////////////////
ModuleSelectionManager::ModuleSelectionManager(
QListView * availableLV,
QListView * selectedLV,
QPushButton * addPB,
QPushButton * delPB,
QPushButton * upPB,
QPushButton * downPB,
GuiIdListModel * availableModel,
GuiIdListModel * selectedModel) :
GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
/// SelectionManager for use with modules
class ModuleSelectionManager : public GuiSelectionManager
{
public:
ModuleSelectionManager(
QListView * availableLV,
QListView * selectedLV,
QPushButton * addPB,
QPushButton * delPB,
QPushButton * upPB,
QPushButton * downPB,
GuiIdListModel * availableModel,
GuiIdListModel * selectedModel)
: GuiSelectionManager(availableLV, selectedLV, addPB, delPB,
upPB, downPB, availableModel, selectedModel)
{}
{}
private:
///
virtual void updateAddPB();
///
virtual void updateUpPB();
///
virtual void updateDownPB();
///
virtual void updateDelPB();
/// returns availableModel as a GuiIdListModel
GuiIdListModel * getAvailableModel()
{
return dynamic_cast<GuiIdListModel *>(availableModel);
}
/// returns selectedModel as a GuiIdListModel
GuiIdListModel * getSelectedModel()
{
return dynamic_cast<GuiIdListModel *>(selectedModel);
}
};
void ModuleSelectionManager::updateAddPB()
{
int const arows = availableModel->rowCount();

View File

@ -19,7 +19,6 @@
#include "BulletsModule.h"
#include "GuiDialog.h"
#include "GuiIdListModel.h"
#include "GuiSelectionManager.h"
#include "ui_DocumentUi.h"
#include "ui_FontUi.h"
@ -37,21 +36,18 @@
#include <map>
#include <vector>
class FloatPlacement;
namespace lyx {
class BufferParams;
class FloatPlacement;
class TextClass;
namespace frontend {
class GuiBranches;
class GuiSelectionManager;
class PreambleModule;
///
QModelIndex getSelectedIndex(QListView * lv);
///
typedef void const * BufferId;
@ -63,41 +59,6 @@ public:
};
/// SelectionManager for use with modules
class ModuleSelectionManager : public GuiSelectionManager
{
public:
ModuleSelectionManager(
QListView * availableLV,
QListView * selectedLV,
QPushButton * addPB,
QPushButton * delPB,
QPushButton * upPB,
QPushButton * downPB,
GuiIdListModel * availableModel,
GuiIdListModel * selectedModel);
private:
///
virtual void updateAddPB();
///
virtual void updateUpPB();
///
virtual void updateDownPB();
///
virtual void updateDelPB();
/// returns availableModel as a GuiIdListModel
GuiIdListModel * getAvailableModel()
{
return dynamic_cast<GuiIdListModel *>(availableModel);
}
/// returns selectedModel as a GuiIdListModel
GuiIdListModel * getSelectedModel()
{
return dynamic_cast<GuiIdListModel *>(selectedModel);
}
};
class GuiDocument : public GuiDialog, public Ui::DocumentUi
{
Q_OBJECT

View File

@ -13,17 +13,20 @@
*/
#include <config.h>
#include "GuiSelectionManager.h"
#include "GuiDocument.h"
#include "support/debug.h"
using std::vector;
#include <QKeyEvent>
#include <QListView>
#include <QPushButton>
#include <QAbstractListModel>
namespace lyx {
namespace frontend {
GuiSelectionManager::GuiSelectionManager(
QListView * avail,
QListView * sel,
@ -180,9 +183,12 @@ bool GuiSelectionManager::insertRowToSelected(int i,
void GuiSelectionManager::addPB_clicked()
{
QModelIndex const idxToAdd = getSelectedIndex(availableLV);
if (!idxToAdd.isValid())
QModelIndexList selIdx =
availableLV->selectionModel()->selectedIndexes();
if (selIdx.isEmpty())
return;
QModelIndex const idxToAdd = selectedLV->currentIndex();
QModelIndex const idx = selectedLV->currentIndex();
int const srows = selectedModel->rowCount();
@ -190,7 +196,7 @@ void GuiSelectionManager::addPB_clicked()
insertRowToSelected(srows, qm);
selectionChanged(); //signal
if (idx.isValid())
selectedLV->setCurrentIndex(idx);
@ -200,10 +206,11 @@ void GuiSelectionManager::addPB_clicked()
void GuiSelectionManager::deletePB_clicked()
{
QModelIndex idx = getSelectedIndex(selectedLV);
if (!idx.isValid())
QModelIndexList selIdx =
selectedLV->selectionModel()->selectedIndexes();
if (selIdx.isEmpty())
return;
QModelIndex idx = selIdx.first();
selectedModel->removeRow(idx.row());
selectionChanged(); //signal
@ -307,10 +314,9 @@ bool GuiSelectionManager::eventFilter(QObject * obj, QEvent * event)
if (keyPressed == Qt::Key_Enter || keyPressed == Qt::Key_Return) {
if (!keyModifiers)
addPB_clicked();
else if ((keyModifiers == Qt::ControlModifier) ||
(keyModifiers == Qt::KeypadModifier) ||
(keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier))
) {
else if (keyModifiers == Qt::ControlModifier ||
keyModifiers == Qt::KeypadModifier ||
keyModifiers == (Qt::ControlModifier | Qt::KeypadModifier)) {
if (addPB->isEnabled()) {
addPB_clicked();
okHook(); //signal

View File

@ -12,18 +12,14 @@
#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;
template <class T, class U> class QMap;
namespace lyx {
namespace frontend {
@ -38,7 +34,7 @@ namespace frontend {
*/
class GuiSelectionManager : public QObject
{
Q_OBJECT
Q_OBJECT
public:
///
@ -66,24 +62,24 @@ public:
bool selectedFocused() { return selectedHasFocus_; };
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);

View File

@ -26,7 +26,7 @@
<number>6</number>
</property>
<item>
<widget class="FloatPlacement" name="floatFP" />
<widget class="lyx::FloatPlacement" name="floatFP" />
</item>
<item>
<layout class="QHBoxLayout" >