KnowIt – tool for managing notes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

knowitchooser.cpp 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /***************************************************************************
  2. knowitchooser.cpp - description
  3. -------------------
  4. begin : pi? lut 14 2003
  5. copyright : (C) 2003 by Micha? Rudolf
  6. email : mrudolf@kdewebdev.org
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************/
  16. #include "knowitchooser.h"
  17. #include <tqcheckbox.h>
  18. #include <tqlabel.h>
  19. #include <tqlayout.h>
  20. #include <tqvbox.h>
  21. #include <kcombobox.h>
  22. #include <tdelocale.h>
  23. KnowitChooser::KnowitChooser(int flags)
  24. : KDialogBase(Plain, i18n("Export"), Ok|Cancel, Ok)
  25. {
  26. TQLabel* l1;
  27. TQLabel* l2;
  28. TQVBoxLayout* layout = new TQVBoxLayout(plainPage());
  29. layout->addWidget(l1 = new TQLabel(i18n("&Exported notes:"), plainPage()));
  30. layout->addWidget(notes = new KComboBox(plainPage(), "Notes"));
  31. l1->setBuddy(notes);
  32. notes->insertItem(i18n("All"));
  33. notes->insertItem(i18n("Current with children"));
  34. notes->insertItem(i18n("Current only"));
  35. layout->addWidget(l2 = new TQLabel(i18n("&Encoding:"), plainPage()));
  36. layout->addWidget(charset = new KComboBox(plainPage(), "Encoding"));
  37. l2->setBuddy(charset);
  38. charset->insertItem(i18n("Local (8-bit)"));
  39. charset->insertItem(i18n("UTF-8"));
  40. layout->addItem(new TQSpacerItem(0, 10));
  41. layout->addWidget(enumerate = new TQCheckBox(i18n("Numbered titles"),
  42. plainPage(), "Numbered"));
  43. layout->addWidget(toc = new TQCheckBox(i18n("Table of contents"),
  44. plainPage(), "TOC"));
  45. layout->addWidget(rule = new TQCheckBox(i18n("Rule betweeen notes"),
  46. plainPage(), "Rule"));
  47. layout->addWidget(style = new TQCheckBox(i18n("Use editor font and colors"),
  48. plainPage(), "Style"));
  49. setChoice(flags);
  50. }
  51. KnowitChooser::~KnowitChooser()
  52. {
  53. }
  54. int KnowitChooser::getChoice() const
  55. {
  56. int flags = 2 - notes->currentItem();
  57. if (charset->currentItem() == 1) flags = flags | UseUTF8;
  58. if (enumerate->isChecked()) flags = flags | Enumerate;
  59. if (toc->isChecked()) flags = flags | TOC;
  60. if (rule->isChecked()) flags = flags | AddRule;
  61. if (style->isChecked()) flags = flags | Style;
  62. return flags;
  63. }
  64. void KnowitChooser::setChoice(int flags)
  65. {
  66. if (flags & SaveAll) notes->setCurrentItem(0);
  67. else if (flags & SaveSubnotes) notes->setCurrentItem(1);
  68. else notes->setCurrentItem(2);
  69. charset->setCurrentItem((flags & UseUTF8) != 0);
  70. enumerate->setChecked(flags & Enumerate);
  71. toc->setChecked(flags & TOC);
  72. rule->setChecked(flags & AddRule);
  73. style->setChecked(flags & Style);
  74. }