]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QFloat.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QFloat.C
index 7713d512bf7f4b1b42c30319d96ce50404f8ef3e..5b760ced4e9d1ae30f6c2c27af68e147f1a52bb9 100644 (file)
@@ -1,9 +1,11 @@
 /**
  * \file QFloat.C
- * Copyright 2002 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Edwin Leuven <leuven@fee.uva.nl>
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 #include "QFloat.h"
 #include "Qt2BC.h"
 #include "gettext.h"
-#include "helper_funcs.h"
 
 #include "support/lstrings.h"
 
-#include <qradiobutton.h>
 #include <qpushbutton.h>
 #include <qcheckbox.h>
 
 typedef Qt2CB<ControlFloat, Qt2DB<QFloatDialog> > base_class;
 
+
 QFloat::QFloat()
-       : base_class(_("LaTeX Information"))
+       : base_class(_("Float Settings"))
 {
 }
 
@@ -41,22 +42,40 @@ void QFloat::build_dialog()
        bc().setApply(dialog_->applyPB);
        bc().setOK(dialog_->okPB);
        bc().setRestore(dialog_->restorePB);
+
+       bc().addReadOnly(dialog_->topCB);
+       bc().addReadOnly(dialog_->bottomCB);
+       bc().addReadOnly(dialog_->herepossiblyCB);
+       bc().addReadOnly(dialog_->heredefinitelyCB);
+       bc().addReadOnly(dialog_->pageCB);
+       bc().addReadOnly(dialog_->ignoreCB);
+       bc().addReadOnly(dialog_->defaultsCB);
+       bc().addReadOnly(dialog_->spanCB);
 }
 
 
 void QFloat::update_contents()
 {
+       bool def_placement = false;
        bool top = false;
        bool bottom = false;
        bool page = false;
        bool here = false;
-       bool forcehere = false;
+       bool force = false;
+       bool here_definitely = false;
+
+       FloatParams const & params = controller().params();
 
-       string placement(controller().params().placement);
+       string const & placement = params.placement;
 
-       if (contains(placement, "H")) {
-               forcehere = true;
+       if (placement.empty()) {
+               def_placement = true;
+       } else if (contains(placement, "H")) {
+               here_definitely = true;
        } else {
+               if (contains(placement, "!")) {
+                       force = true;
+               }
                if (contains(placement, "t")) {
                        top = true;
                }
@@ -71,32 +90,55 @@ void QFloat::update_contents()
                }
        }
 
-       dialog_->top->setChecked(top);
-       dialog_->bottom->setChecked(bottom);
-       dialog_->page->setChecked(page);
-       dialog_->here->setChecked(here);
-       dialog_->forcehere->setChecked(forcehere);
+       dialog_->defaultsCB->setChecked(def_placement);
+       dialog_->topCB->setChecked(top);
+       dialog_->bottomCB->setChecked(bottom);
+       dialog_->pageCB->setChecked(page);
+       dialog_->herepossiblyCB->setChecked(here);
+       dialog_->ignoreCB->setChecked(force);
+       dialog_->ignoreCB->setEnabled(top || bottom || page || here);
+       dialog_->heredefinitelyCB->setChecked(here_definitely);
+
+       if (params.wide) {
+               dialog_->herepossiblyCB->setChecked(false);
+               dialog_->bottomCB->setChecked(false);
+       }
+
+       dialog_->spanCB->setChecked(params.wide);
 }
 
+
 void QFloat::apply()
 {
+       FloatParams & params = controller().params();
+
+       params.wide = dialog_->spanCB->isChecked();
+
+       if (dialog_->defaultsCB->isChecked()) {
+               params.placement.erase();
+               return;
+       }
+
        string placement;
 
-       if (dialog_->forcehere->isChecked()) {
-               placement += "H";
+       if (dialog_->heredefinitelyCB->isChecked()) {
+               placement += 'H';
        } else {
-               if (dialog_->top->isChecked()) {
-                       placement += "t";
+               if (dialog_->ignoreCB->isChecked()) {
+                       placement += '!';
+               }
+               if (dialog_->topCB->isChecked()) {
+                       placement += 't';
                }
-               if (dialog_->bottom->isChecked()) {
-                       placement += "b";
+               if (dialog_->bottomCB->isChecked()) {
+                       placement += 'b';
                }
-               if (dialog_->page->isChecked()) {
-                       placement += "p";
+               if (dialog_->pageCB->isChecked()) {
+                       placement += 'p';
                }
-               if (dialog_->here->isChecked()) {
-                       placement += "h";
+               if (dialog_->herepossiblyCB->isChecked()) {
+                       placement += 'h';
                }
        }
-       controller().params().placement = placement;
+       params.placement = placement;
 }