Logo Search packages:      
Sourcecode: basket version File versions  Download package

ItemHtmlEditor::ItemHtmlEditor ( Item item,
QWidget *  toolbarParent,
QWidget *  widgetsParent,
QKeyEvent *  ke = 0L 
)

ItemHtmlEditor

Definition at line 364 of file itemedit.cpp.

References Item::html().

 : ItemEditorBase(item)
{
      m_editorWidget = m_text = new FocusedTextEdit(Settings::enterValidateInline(),
                                                    widgetsParent != toolbarParent, widgetsParent);
      m_text->setTextFormat( /*item->showSource() ? Qt::PlainText :*/ Qt::RichText );
      m_text->setText(item->html());

      m_toolbar = new KToolBar(toolbarParent);
      m_toolbar->setFlat(true);

      if (toolbarParent != widgetsParent) {
            m_toolbar->insertButton("button_ok", 11, SIGNAL(clicked()), this, SLOT(slotEscapePressed()), true, i18n("OK"));
            m_toolbar->insertLineSeparator();
      }

      m_font = new FocusedFontCombo(m_toolbar);
      m_toolbar->insertWidget(101, 0, m_font);
      connect( m_font, SIGNAL(textChanged(const QString&)), m_text, SLOT(setFamily(const QString&)) );

      m_color = new FocusedColorCombo(m_toolbar);
//    m_color->hide();
      m_toolbar->insertWidget(102, 0, m_color);
      connect( m_color, SIGNAL(activated(const QColor&)), m_text, SLOT(setColor(const QColor&)) );

/*    ColorAction *colorAct = new ColorAction(item->textColor(), i18n("Color"), "", 0L, "");
      connect( colorAct, SIGNAL(colorChanged(const QColor&)), m_text, SLOT(setColor(const QColor&)) );
      colorAct->plug(m_toolbar);
*/
      m_toolbar->insertLineSeparator();

      m_toolbar->insertButton("text_bold",   103, true, i18n("Bold")       );
      m_toolbar->insertButton("text_italic", 104, true, i18n("Italic")     );
      m_toolbar->insertButton("text_under",  105, true, i18n("Underline")  );
      m_toolbar->getButton(103)->setAccel( QKeySequence(/*i18n("Bold",      */"Ctrl+B"/*)*/) );
      m_toolbar->getButton(104)->setAccel( QKeySequence(/*i18n("Italic",    */"Ctrl+I"/*)*/) );
      m_toolbar->getButton(105)->setAccel( QKeySequence(/*i18n("Underline", */"Ctrl+U"/*)*/) );
      m_toolbar->setToggle(103, true);
      m_toolbar->setToggle(104, true);
      m_toolbar->setToggle(105, true);
      m_toolbar->insertLineSeparator();

      m_toolbar->insertButton("text_super",  106, true, i18n("Superscript"));
      m_toolbar->insertButton("text_sub",    107, true, i18n("Subscript")  );
      m_toolbar->setToggle(106, true);
      m_toolbar->setToggle(107, true);
      m_toolbar->insertLineSeparator();

      KToolBarRadioGroup *group = new KToolBarRadioGroup(m_toolbar);
      m_toolbar->insertButton("text_left",   201, true, i18n("Left Align") );
      m_toolbar->insertButton("text_center", 202, true, i18n("Centered")   );
      m_toolbar->insertButton("text_right",  203, true, i18n("Right Align"));
      m_toolbar->insertButton("text_block",  204, true, i18n("Justified")  );
      m_toolbar->setToggle(201, true);
      m_toolbar->setToggle(202, true);
      m_toolbar->setToggle(203, true);
      m_toolbar->setToggle(204, true);
      group->addButton(201);
      group->addButton(202);
      group->addButton(203);
      group->addButton(204);

/*
      "text_strike"
      "indent"
      "unindent"
*/

      m_extraWidget = 0L;
//    m_extraWidget = m_showHtmlSource = new QCheckBox(i18n("&Show HTML source"), widgetsParent);
//    connect( m_showHtmlSource, SIGNAL(toggled(bool)), this, SLOT(slotShowSource(bool)) );
//    m_showHtmlSource->setChecked(m_text->textFormat() == Qt::PlainText); // After connection, to apply it

      connect( m_text,  SIGNAL(cursorPositionChanged(int, int)), this, SLOT(cursorPositionChanged(int, int)) );
      connect( m_text,  SIGNAL(clicked(int, int)),               this, SLOT(cursorPositionChanged(int, int)) );
      connect( m_text,  SIGNAL(currentVerticalAlignmentChanged(QTextEdit::VerticalAlignment)),
               this,    SLOT(slotVerticalAlignmentChanged(QTextEdit::VerticalAlignment))                     );

      connect( m_text,  SIGNAL(escapePressed()),                 this, SLOT(slotEscapePressed())             );
      connect( m_text,  SIGNAL(focusOut()),                      this, SLOT(slotFocusOut())                  );
      connect( m_font,  SIGNAL(focusOut()),                      this, SLOT(slotFocusOut())                  );
      connect( m_color, SIGNAL(focusOut()),                      this, SLOT(slotFocusOut())                  );

      connect(m_toolbar, SIGNAL(toggled(int)), this, SLOT(buttonToggled(int)));

      m_text->moveCursor(KTextEdit::MoveEnd, false);
      cursorPositionChanged(0, 0);

      if (ke)
            kapp->postEvent(m_editorWidget, ke);
}


Generated by  Doxygen 1.6.0   Back to index