]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/QPrint.C
Some string(widget->text()) fixes. Weirdness
[lyx.git] / src / frontends / qt2 / QPrint.C
index 602127426bbafc79b423f3beb1a811d9c970d19d..07f721d0f39b3bbca1c2d5f9a35229d579831d47 100644 (file)
@@ -1,10 +1,12 @@
 /**
  * \file QPrint.C
- * Copyright 2001 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 John Levon <moz@compsoc.man.ac.uk>
- * \author Edwin Leuven, leuven@fee.uva.nl
+ * \author John Levon
+ * \author Edwin Leuven
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 #pragma implementation
 #endif
 
+#include "LyXView.h"
+#include "PrinterParams.h"
+#include "ControlPrint.h"
+#include "support/lstrings.h"
+#include "gettext.h"
+
+#include "QPrint.h"
+#include "QLPrintDialog.h"
+#include "Qt2BC.h"
+
 #include <qlineedit.h>
 #include <qcheckbox.h>
 #include <qradiobutton.h>
 #include <qspinbox.h>
 #include <qpushbutton.h>
 
-#include "QPrintDialog.h"
-#include "QPrint.h"
-#include "Qt2BC.h"
-#include "gettext.h"
-
-#include "QtLyXView.h"
-#include "ControlPrint.h"
 
-#include "support/lstrings.h"
+typedef Qt2CB<ControlPrint, Qt2DB<QLPrintDialog> > base_class;
 
-typedef Qt2CB<ControlPrint, Qt2DB<QPrintDialog> > base_class;
 
-QPrint::QPrint(ControlPrint & c)
-       : base_class(c, _("Print"))
+QPrint::QPrint()
+       : base_class(_("Print"))
 {
 }
 
 
 void QPrint::build_dialog()
 {
-       dialog_.reset(new QPrintDialog(this));
+       dialog_.reset(new QLPrintDialog(this));
 
        bc().setOK(dialog_->printPB);
        bc().setCancel(dialog_->closePB);
@@ -50,6 +54,10 @@ void QPrint::update_contents()
 {
        PrinterParams & pp = controller().params();
 
+       // only reset params if a different buffer
+       if (!pp.file_name.empty() && pp.file_name == dialog_->fileED->text().latin1())
+               return;
+
        dialog_->printerED->setText(pp.printer_name.c_str());
        dialog_->fileED->setText(pp.file_name.c_str());
 
@@ -59,52 +67,30 @@ void QPrint::update_contents()
 
        dialog_->reverseCB->setChecked(pp.reverse_order);
 
-       QRadioButton * button;
-       switch (pp.which_pages) {
-               case PrinterParams::ALL: button = dialog_->allRB; break;
-               case PrinterParams::ODD: button = dialog_->oddRB; break;
-               case PrinterParams::EVEN: button = dialog_->evenRB; break;
-       }
-       button->setChecked(true);
-
-       // hmmm... maybe a bit weird but maybe not
-       // we might just be remembering the last
-       // time this was printed.
-       if (!pp.from_page.empty()) {
-               dialog_->fromED->setText(pp.from_page.c_str());
-
-               dialog_->toED->setText("");
-               if (pp.to_page)
-                       dialog_->toED->setText(tostr(pp.to_page).c_str());
-       } else {
-               dialog_->fromED->setText("");
-               dialog_->toED->setText("");
+       dialog_->copiesSB->setValue(pp.count_copies);
+
+       dialog_->oddCB->setChecked(pp.odd_pages);
+       dialog_->evenCB->setChecked(pp.even_pages);
+
+       dialog_->collateCB->setChecked(pp.sorted_copies);
+
+       if (pp.all_pages) {
+               dialog_->allRB->setChecked(true);
+               return;
        }
 
-       dialog_->copiesSB->setValue(pp.count_copies);
+       dialog_->rangeRB->setChecked(true);
+
+       QString s;
+       s.setNum(pp.from_page);
+       dialog_->fromED->setText(s);
+       s.setNum(pp.to_page);
+       dialog_->toED->setText(s);
 }
 
 
 void QPrint::apply()
 {
-       PrinterParams::WhichPages wp;
-
-       if (dialog_->allRB->isChecked())
-               wp = PrinterParams::ALL;
-       else if (dialog_->oddRB->isChecked())
-               wp = PrinterParams::ODD;
-       else
-               wp = PrinterParams::EVEN;
-
-       string from;
-       int to(0);
-       if (!dialog_->fromED->text().isEmpty()) {
-               // we have at least one page requested
-               from = dialog_->fromED->text().latin1();
-               if (!dialog_->toED->text().isEmpty())
-                       to = strToInt(dialog_->toED->text().latin1());
-       }
-
        PrinterParams::Target t = PrinterParams::PRINTER;
        if (dialog_->fileRB->isChecked())
                t = PrinterParams::FILE;
@@ -112,10 +98,14 @@ void QPrint::apply()
        PrinterParams const pp(t,
                dialog_->printerED->text().latin1(),
                dialog_->fileED->text().latin1(),
-               wp, from, to,
-               dialog_->reverseCB->isChecked(),
-               !dialog_->collateCB->isChecked(),
-               strToInt(dialog_->copiesSB->text().latin1()));
+               dialog_->allRB->isChecked(),
+               dialog_->fromED->text().toUInt(),
+               dialog_->toED->text().toUInt(),
+               dialog_->oddCB->isChecked(),
+               dialog_->evenCB->isChecked(),
+               dialog_->copiesSB->text().toUInt(),
+               dialog_->collateCB->isChecked(),
+               dialog_->reverseCB->isChecked());
 
        controller().params() = pp;
 }