Bo, this is for you.

Abdel.


-------- Original Message --------
Subject: r25144 - in /lyx-devel/trunk: development/scons/scons_man...
Date: Thu, 05 Jun 2008 15:08:48 -0000
From: [EMAIL PROTECTED]
Reply-To: lyx-devel@lists.lyx.org
To: [EMAIL PROTECTED]
Newsgroups: gmane.editors.lyx.cvs
Followup-To: gmane.editors.lyx.devel

Author: younes
Date: Thu Jun  5 17:08:46 2008
New Revision: 25144

URL: http://www.lyx.org/trac/changeset/25144
Log:
Preliminar InsetInfo dialog. This was done as an exercise to show Bo (an others) how easy it is to create a new dialog. This dialog needs to be filled in, right now, there is just an OK button.

Added:
    lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp   (with props)
    lyx-devel/trunk/src/frontends/qt4/GuiInfo.h   (with props)
    lyx-devel/trunk/src/frontends/qt4/ui/InfoUi.ui
Modified:
    lyx-devel/trunk/development/scons/scons_manifest.py
    lyx-devel/trunk/lib/ui/stdcontext.inc
    lyx-devel/trunk/src/BufferView.cpp
    lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
    lyx-devel/trunk/src/frontends/qt4/Makefile.am
    lyx-devel/trunk/src/insets/InsetInfo.cpp
    lyx-devel/trunk/src/insets/InsetInfo.h

Modified: lyx-devel/trunk/development/scons/scons_manifest.py
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/development/scons/scons_manifest.py?rev=25144
==============================================================================
--- lyx-devel/trunk/development/scons/scons_manifest.py (original)
+++ lyx-devel/trunk/development/scons/scons_manifest.py Thu Jun 5 17:08:46 2008
@@ -718,6 +718,7 @@
     GuiIdListModel.h
     GuiImage.h
     GuiInclude.h
+    GuiInfo.h
     GuiKeySymbol.h
     GuiLabel.h
     GuiListings.h
@@ -807,6 +808,7 @@
     GuiIdListModel.cpp
     GuiImage.cpp
     GuiInclude.cpp
+    GuiInfo.cpp
     GuiKeySymbol.cpp
     GuiLabel.cpp
     GuiListings.cpp
@@ -887,6 +889,7 @@
     HSpaceUi.ui
     HyperlinkUi.ui
     IncludeUi.ui
+    InfoUi.ui
     LabelUi.ui
     LaTeXUi.ui
     LanguageUi.ui

Modified: lyx-devel/trunk/lib/ui/stdcontext.inc
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/lib/ui/stdcontext.inc?rev=25144
==============================================================================
--- lyx-devel/trunk/lib/ui/stdcontext.inc (original)
+++ lyx-devel/trunk/lib/ui/stdcontext.inc Thu Jun  5 17:08:46 2008
@@ -347,4 +347,13 @@
                Item "Settings...|S" "inset-settings tabular"
        End

+
+#
+# InsetInfo context menu
+#
+
+       Menu "context-info"
+               Item "Settings...|S" "inset-settings"
+       End
+
 End

Modified: lyx-devel/trunk/src/BufferView.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/BufferView.cpp?rev=25144
==============================================================================
--- lyx-devel/trunk/src/BufferView.cpp (original)
+++ lyx-devel/trunk/src/BufferView.cpp Thu Jun  5 17:08:46 2008
@@ -943,6 +943,7 @@
                bool enable = false;
                InsetCode next_code = cur.nextInset()
                        ? cur.nextInset()->lyxCode() : NO_CODE;
+               //FIXME: remove these special cases:
                switch (next_code) {
                        case TABULAR_CODE:
                        case ERT_CODE:
@@ -952,6 +953,7 @@
                        case BRANCH_CODE:
                        case BOX_CODE:
                        case LISTINGS_CODE:
+                       case INFO_CODE:
                                enable = (cmd.argument().empty() ||
                                          cmd.getArg(0) == 
insetName(next_code));
                                break;

Added: lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp?rev=25144
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp (added)
+++ lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp Thu Jun  5 17:08:46 2008
@@ -1,0 +1,104 @@
+/**
+ * \file GuiInfo.cpp
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "GuiInfo.h"
+
+#include "qt_helpers.h"
+
+#include "Buffer.h"
+#include "buffer_funcs.h"
+#include "BufferParams.h"
+#include "BufferView.h"
+#include "Cursor.h"
+#include "FuncRequest.h"
+
+#include "insets/InsetInfo.h"
+
+#include "support/debug.h"
+
+
+using namespace std;
+
+namespace lyx {
+namespace frontend {
+
+/////////////////////////////////////////////////////////////////
+//
+// GuiInfo
+//
+/////////////////////////////////////////////////////////////////
+
+GuiInfo::GuiInfo(GuiView & lv)
+       : DialogView(lv, "info", qt_("Info"))
+{
+       setupUi(this);
+}
+
+
+void GuiInfo::on_closePB_clicked()
+{
+       hide();
+}
+
+
+InsetInfo * GuiInfo::inset() const
+{
+       return static_cast<InsetInfo *>(bufferview()->cursor().
+               innerInsetOfType(INFO_CODE));
+}
+
+
+void GuiInfo::applyView()
+{
+       InsetInfo * ii = inset();
+       if (!ii)
+               return;
+       
+       // FIXME: update the inset contents
+
+       updateLabels(bufferview()->buffer());
+       bufferview()->updateMetrics();
+       bufferview()->buffer().changed();
+}
+
+
+void GuiInfo::updateView()
+{
+       InsetInfo * ii = inset();
+       if (!ii) {
+               // FIXME: A New button to create an InsetInfo at the cursor 
location
+               // would be nice.
+               enableView(false);
+               return;
+       }
+       //FIXME: update the controls.
+}
+
+
+void GuiInfo::enableView(bool enable)
+{
+       //FIXME: enable controls that need enabling.
+}
+
+
+void GuiInfo::dispatchParams()
+{
+}
+
+
+Dialog * createGuiInfo(GuiView & lv) { return new GuiInfo(lv); }
+
+
+} // namespace frontend
+} // namespace lyx
+
+#include "GuiInfo_moc.cpp"

Propchange: lyx-devel/trunk/src/frontends/qt4/GuiInfo.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Added: lyx-devel/trunk/src/frontends/qt4/GuiInfo.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiInfo.h?rev=25144
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiInfo.h (added)
+++ lyx-devel/trunk/src/frontends/qt4/GuiInfo.h Thu Jun  5 17:08:46 2008
@@ -1,0 +1,51 @@
+// -*- C++ -*-
+/**
+ * \file GuiInfo.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Abdelrazak Younes
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef GUI_INFO_H
+#define GUI_INFO_H
+
+#include "DialogView.h"
+#include "ui_InfoUi.h"
+
+namespace lyx {
+
+class InsetInfo;
+
+namespace frontend {
+
+class GuiInfo : public DialogView, public Ui::InfoUi
+{
+       Q_OBJECT
+
+public:
+       GuiInfo(GuiView & lv);
+
+       /// Dialog inherited methods
+       //@{
+       void applyView();
+       void updateView();
+       void dispatchParams();
+       void enableView(bool enable);
+       bool isBufferDependent() const { return true; }
+       //@}
+
+private Q_SLOTS:
+       void on_closePB_clicked();
+
+private:
+       ///
+       InsetInfo * inset() const;
+};
+
+} // namespace frontend
+} // namespace lyx
+
+#endif // GUI_INFO_H

Propchange: lyx-devel/trunk/src/frontends/qt4/GuiInfo.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: lyx-devel/trunk/src/frontends/qt4/GuiView.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/GuiView.cpp?rev=25144
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/GuiView.cpp (original)
+++ lyx-devel/trunk/src/frontends/qt4/GuiView.cpp Thu Jun  5 17:08:46 2008
@@ -2079,7 +2079,7 @@
 char const * const dialognames[] = {
 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
 "citation", "document", "errorlist", "ert", "external", "file",
-"findreplace", "float", "graphics", "include", "index", "nomenclature", "label", "log", +"findreplace", "float", "graphics", "include", "index", "info", "nomenclature", "label", "log",
 "mathdelimiter", "mathmatrix", "note", "paragraph", "prefs", "print",
"ref", "sendto", "space", "spellchecker", "symbols", "tabular", "tabularcreate",

@@ -2252,6 +2252,7 @@
 Dialog * createGuiGraphics(GuiView & lv);
 Dialog * createGuiHSpace(GuiView & lv);
 Dialog * createGuiInclude(GuiView & lv);
+Dialog * createGuiInfo(GuiView & lv);
 Dialog * createGuiLabel(GuiView & lv);
 Dialog * createGuiListings(GuiView & lv);
 Dialog * createGuiLog(GuiView & lv);
@@ -2316,6 +2317,8 @@
                return createGuiGraphics(*this);
        if (name == "include")
                return createGuiInclude(*this);
+       if (name == "info")
+               return createGuiInfo(*this);
        if (name == "nomenclature")
                return createGuiNomenclature(*this);
        if (name == "label")

Modified: lyx-devel/trunk/src/frontends/qt4/Makefile.am
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/Makefile.am?rev=25144
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/Makefile.am (original)
+++ lyx-devel/trunk/src/frontends/qt4/Makefile.am Thu Jun  5 17:08:46 2008
@@ -89,6 +89,7 @@
        GuiIdListModel.cpp \
        GuiImage.cpp \
        GuiInclude.cpp \
+       GuiInfo.cpp \
        GuiKeySymbol.cpp \
        GuiLabel.cpp \
        GuiListings.cpp \
@@ -182,6 +183,7 @@
        GuiHSpace.h \
        GuiHyperlink.h \
        GuiInclude.h \
+       GuiInfo.h \
        GuiLabel.h \
        GuiListings.h \
        GuiLog.h \
@@ -247,6 +249,7 @@
        HSpaceUi.ui \
        HyperlinkUi.ui \
        IncludeUi.ui \
+       InfoUi.ui \
        LabelUi.ui \
        LanguageUi.ui \
        LaTeXUi.ui \

Added: lyx-devel/trunk/src/frontends/qt4/ui/InfoUi.ui
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/frontends/qt4/ui/InfoUi.ui?rev=25144
==============================================================================
--- lyx-devel/trunk/src/frontends/qt4/ui/InfoUi.ui (added)
+++ lyx-devel/trunk/src/frontends/qt4/ui/InfoUi.ui Thu Jun  5 17:08:46 2008
@@ -1,0 +1,52 @@
+<ui version="4.0" >
+ <class>InfoUi</class>
+ <widget class="QDialog" name="InfoUi" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>161</width>
+    <height>121</height>
+   </rect>
+  </property>
+  <property name="windowTitle" >
+   <string/>
+  </property>
+  <property name="sizeGripEnabled" >
+   <bool>true</bool>
+  </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" >
+    <spacer name="spacer" >
+     <property name="orientation" >
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Expanding</enum>
+     </property>
+     <property name="sizeHint" stdset="0" >
+      <size>
+       <width>84</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item row="0" column="1" >
+    <widget class="QPushButton" name="closePB" >
+     <property name="text" >
+      <string>&amp;Close</string>
+     </property>
+     <property name="default" >
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <includes>
+  <include location="local" >qt_i18n.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>

Modified: lyx-devel/trunk/src/insets/InsetInfo.cpp
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetInfo.cpp?rev=25144
==============================================================================
--- lyx-devel/trunk/src/insets/InsetInfo.cpp (original)
+++ lyx-devel/trunk/src/insets/InsetInfo.cpp Thu Jun  5 17:08:46 2008
@@ -16,6 +16,7 @@
 #include "BufferParams.h"
 #include "BufferView.h"
 #include "FuncRequest.h"
+#include "FuncStatus.h"
 #include "InsetGraphics.h"
 #include "InsetSpecialChar.h"
 #include "KeyMap.h"
@@ -136,6 +137,32 @@
 {
        os << "Info\ntype  \"" << nameTranslator().find(type_)
           << "\"\narg   \"" << name_ << '\"';
+}
+
+
+bool InsetInfo::showInsetDialog(BufferView * bv) const
+{
+       bv->showDialog("info", "", const_cast<InsetInfo *>(this));
+       return true;
+}
+
+
+bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
+               FuncStatus & flag) const
+{
+       switch (cmd.action) {
+
+       case LFUN_INSET_MODIFY:
+               flag.setEnabled(true);
+               break;
+       //FIXME: do something.
+       /*
+       */
+
+       default:
+               return false;
+       }
+       return true;
 }


@@ -289,4 +316,10 @@
        return true;
 }

+
+docstring InsetInfo::contextMenu(BufferView const &, int, int) const
+{
+       return from_ascii("context-info");
+}
+
 } // namespace lyx

Modified: lyx-devel/trunk/src/insets/InsetInfo.h
URL: http://www.lyx.org/trac/file/lyx-devel/trunk/src/insets/InsetInfo.h?rev=25144
==============================================================================
--- lyx-devel/trunk/src/insets/InsetInfo.h (original)
+++ lyx-devel/trunk/src/insets/InsetInfo.h Thu Jun  5 17:08:46 2008
@@ -105,6 +105,10 @@
        ///
        void write(std::ostream & os) const;
        ///
+       bool showInsetDialog(BufferView * bv) const;
+       ///
+       bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
+       ///
        void doDispatch(Cursor & cur, FuncRequest & cmd);
        ///
        InsetCode lyxCode() const { return INFO_CODE; }
@@ -116,6 +120,8 @@
        bool setMouseHover(bool mouse_hover);
        ///
        docstring toolTip(BufferView const & bv, int x, int y) const;
+       ///
+       docstring contextMenu(BufferView const &, int, int) const;

 private:
/// The translator between the information type enum and corresponding string.



Reply via email to