]> git.lyx.org Git - features.git/commitdiff
cosmetics. remoe strange dependency of GuiDocument.h
authorAndré Pönitz <poenitz@gmx.net>
Sat, 20 Sep 2008 13:44:51 +0000 (13:44 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 20 Sep 2008 13:44:51 +0000 (13:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26467 a592a061-630c-0410-9148-cb99ea01b6c8

src/frontends/qt4/FloatPlacement.cpp
src/frontends/qt4/FloatPlacement.h
src/frontends/qt4/GuiDocument.cpp
src/frontends/qt4/GuiDocument.h
src/frontends/qt4/GuiSelectionManager.cpp
src/frontends/qt4/GuiSelectionManager.h
src/frontends/qt4/ui/FloatUi.ui

index f689ab24e84839bc822696b3914613da5d0cd428..f49bc5c8d1529bf168aa0988281162d23af0227c 100644 (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"
index 557f48ab5267ea98841aecc98f77f78ec2ff1b4a..f59eb39e55544725a4391a5043c235e6101d7874 100644 (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
index 947f929aa5961051b0a75eddd914557af714f615..5d5ff1d5bf11efd4af50884ef07f426493007156 100644 (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();
index 9a37ad5cfe1927402a57afd042a47d84f907f263..af66737fe988980454ac3f806b0f997b7075f38b 100644 (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"
 #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
index 4156765cc43e679aea506c5887fc7649dba2ad67..b2c846052baa67ab8d4ec0e889b79928cb3e9da1 100644 (file)
  */
 
 #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
index 43ceea7b50f703c8c449e245e87472f5f18c62c3..2e9c747363a4ab16dcf6b0d485e258a3dc621d8a 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;
+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);
index 1178bd3208fb63a9c5ae27442b4f3256703e06e6..7560cd3df41b6b7a1fb920a0a7c325f108d853f7 100644 (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" >