Hi there, Although basket has the function "transform lines start with * or - to lists", the support for list editing is not as good as kjots, which can let user choose different list type. I have done some work to make the list editing function
more effective. The attached patch is against basket-1.81, on top of kde4.6/qt4.7. Please review and consider the possibility to add such a support. Regards, Feng
<<attachment: basket_list_bullettype_support.png>>
diff -ruN basket-1.81/src/basket_part.rc basket-1.81-new/src/basket_part.rc --- basket-1.81/src/basket_part.rc 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/basket_part.rc 2011-02-28 03:36:46.000000000 +0800 @@ -161,6 +161,10 @@ <Action name="richtext_center" /> <Action name="richtext_right" /> <Action name="richtext_block" /> + <Separator lineSeparator="true" name="separator_4" /> + <Action name="richtext_indenttype" /> + <Action name="richtext_indent" /> + <Action name="richtext_dedent" /> </ToolBar> <Menu name="basket_popup" > <Action name="basket_new_menu" /> diff -ruN basket-1.81/src/basketui.rc basket-1.81-new/src/basketui.rc --- basket-1.81/src/basketui.rc 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/basketui.rc 2011-02-28 03:42:06.000000000 +0800 @@ -163,11 +163,15 @@ <Action name="richtext_super" /> <Action name="richtext_sub" /> --> - <Separator lineSeparator="true" name="separator_0" /> + <Separator lineSeparator="true" name="separator_3" /> <Action name="richtext_left" /> <Action name="richtext_center" /> <Action name="richtext_right" /> <Action name="richtext_block" /> + <Separator lineSeparator="true" name="separator_4" /> + <Action name="richtext_indenttype" /> + <Action name="richtext_indent" /> + <Action name="richtext_dedent" /> </ToolBar> <Menu name="basket_popup" > <Action name="basket_new_menu" /> diff -ruN basket-1.81/src/basketview.cpp basket-1.81-new/src/basketview.cpp --- basket-1.81/src/basketview.cpp 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/basketview.cpp 2011-02-28 02:13:49.000000000 +0800 @@ -46,7 +46,7 @@ #include <QTextDocument> #include <QAbstractTextDocumentLayout> #include <QPushButton> -#include <KDE/KTextEdit> +#include <KDE/KRichTextEdit> #include <QPoint> #include <QStringList> #include <KDE/KApplication> @@ -1303,7 +1303,7 @@ m_canDrag = true; // Saving where we were editing, because during a drag, the mouse can fly over the text edit and move the cursor position: if (m_editor && m_editor->textEdit()) { - KTextEdit *editor = m_editor->textEdit(); + KRichTextEdit *editor = m_editor->textEdit(); m_textCursor = editor->textCursor(); } } @@ -1781,7 +1781,7 @@ // This is because during a drag, the mouse can fly over the text edit and move the cursor position, and even HIDE the cursor. // So we re-show the cursor, and re-position it at the right place: if (m_editor && m_editor->textEdit()) { - KTextEdit *editor = m_editor->textEdit(); + KRichTextEdit *editor = m_editor->textEdit(); editor->setTextCursor(m_textCursor); } } @@ -3593,7 +3593,7 @@ return; QFrame *editorQFrame = dynamic_cast<QFrame*>(m_editor->widget()); - KTextEdit *textEdit = m_editor->textEdit(); + KRichTextEdit *textEdit = m_editor->textEdit(); // QLineEdit *lineEdit = m_editor->lineEdit(); Note *note = m_editor->note(); @@ -3902,7 +3902,7 @@ connect(m_editor, SIGNAL(mouseEnteredEditorWidget()), this, SLOT(mouseEnteredEditorWidget())); - KTextEdit *textEdit = m_editor->textEdit(); + KRichTextEdit *textEdit = m_editor->textEdit(); if (textEdit) { connect(textEdit, SIGNAL(textChanged()), this, SLOT(placeEditorAndEnsureVisible())); if (clickedPoint != QPoint()) { Binary files basket-1.81/src/.basketview.cpp.swp and basket-1.81-new/src/.basketview.cpp.swp differ diff -ruN basket-1.81/src/focusedwidgets.cpp basket-1.81-new/src/focusedwidgets.cpp --- basket-1.81/src/focusedwidgets.cpp 2010-06-03 11:48:13.000000000 +0800 +++ basket-1.81-new/src/focusedwidgets.cpp 2011-02-28 07:15:29.000000000 +0800 @@ -36,10 +36,11 @@ FocusedTextEdit::FocusedTextEdit(bool disableUpdatesOnKeyPress, QWidget *parent) - : KTextEdit(parent), + : KRichTextEdit(parent), m_disableUpdatesOnKeyPress(disableUpdatesOnKeyPress) { // pass +enableRichTextMode(); } FocusedTextEdit::~FocusedTextEdit() @@ -56,7 +57,7 @@ if (m_disableUpdatesOnKeyPress) setUpdatesEnabled(false); - KTextEdit::keyPressEvent(event); + KRichTextEdit::keyPressEvent(event); // Workaround (for ensuring the cursor to be visible): signal not emited when pressing those keys: if (event->key() == Qt::Key_Home @@ -80,7 +81,7 @@ QScrollBar *sb = verticalScrollBar(); if ((event->delta() > 0 && sb->value() > sb->minimum()) || (event->delta() < 0 && sb->value() < sb->maximum())) - KTextEdit::wheelEvent(event); + KRichTextEdit::wheelEvent(event); else Global::bnpView->currentBasket()->wheelEvent(event); } @@ -88,7 +89,7 @@ void FocusedTextEdit::enterEvent(QEvent *event) { emit mouseEntered(); - KTextEdit::enterEvent(event); + KRichTextEdit::enterEvent(event); } /** class FocusWidgetFilter */ diff -ruN basket-1.81/src/focusedwidgets.h basket-1.81-new/src/focusedwidgets.h --- basket-1.81/src/focusedwidgets.h 2010-06-03 11:48:13.000000000 +0800 +++ basket-1.81-new/src/focusedwidgets.h 2011-02-28 05:10:48.000000000 +0800 @@ -21,7 +21,7 @@ #ifndef FOCUSEDWIDGETS_H #define FOCUSEDWIDGETS_H -#include <KDE/KTextEdit> +#include <KDE/KRichTextEdit> #include <KDE/KColorCombo> #include <QFontComboBox> #include <KComboBox> @@ -34,7 +34,7 @@ class KMenu; -class FocusedTextEdit : public KTextEdit +class FocusedTextEdit : public KRichTextEdit { Q_OBJECT public: diff -ruN basket-1.81/src/notecontent.cpp basket-1.81-new/src/notecontent.cpp --- basket-1.81/src/notecontent.cpp 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/notecontent.cpp 2011-02-28 02:52:16.000000000 +0800 @@ -28,7 +28,7 @@ #include <QBuffer> #include <QStringList> #include <QPixmap> -#include <KDE/KTextEdit> +#include <KDE/KRichTextEdit> #include <KDE/KService> #include <KDE/KColorDialog> #include <KDE/KMessageBox> diff -ruN basket-1.81/src/noteedit.cpp basket-1.81-new/src/noteedit.cpp --- basket-1.81/src/noteedit.cpp 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/noteedit.cpp 2011-02-28 07:17:03.000000000 +0800 @@ -37,6 +37,7 @@ #include <KDE/KUriFilter> #include <KDE/KDebug> #include <KDE/KStandardAction> +#include <KDE/KRichTextEdit> #include "KDE/KIconDialog" #include "noteedit.h" @@ -122,7 +123,7 @@ m_textEdit = 0; m_lineEdit = 0; - KTextEdit *textEdit = dynamic_cast<KTextEdit*>(inlineEditor); + KRichTextEdit *textEdit = dynamic_cast<KRichTextEdit*>(inlineEditor); if (textEdit) m_textEdit = textEdit; else { @@ -259,6 +260,11 @@ connect(InlineEditors::instance()->richTextJustified, SIGNAL(activated()), this, SLOT(setBlock())); // InlineEditors::instance()->richTextToolBar()->show(); + connect(InlineEditors::instance()->richTextIndentType, SIGNAL(currentIndexChanged (int)), this, SLOT(setIndentType(int))); + + connect(InlineEditors::instance()->richTextIndent, SIGNAL(activated()), this, SLOT(setIndent())); + connect(InlineEditors::instance()->richTextDedent, SIGNAL(activated()), this, SLOT(setDedent())); + cursorPositionChanged(); fontChanged(textEdit->currentFont()); //QTimer::singleShot( 0, this, SLOT(cursorPositionChanged()) ); @@ -286,6 +292,13 @@ InlineEditors::instance()->richTextItalic->setChecked(textEdit()->fontItalic()); InlineEditors::instance()->richTextUnderline->setChecked(textEdit()->fontUnderline()); + InlineEditors::instance()->richTextIndent->setEnabled(false); + + InlineEditors::instance()->richTextIndent->setEnabled(textEdit()->canIndentList()); + + InlineEditors::instance()->richTextDedent->setEnabled(false); + InlineEditors::instance()->richTextDedent->setEnabled(textEdit()->canDedentList()); + switch (textEdit()->alignment()) { default: case 1/*Qt::AlignLeft*/: InlineEditors::instance()->richTextLeft->setChecked(true); break; @@ -314,11 +327,11 @@ { QTextEdit::VerticalAlignment align = textEdit() switch (align) { - case KTextEdit::AlignSuperScript: + case KRichTextEdit::AlignSuperScript: InlineEditors::instance()->richTextSuper->setChecked(true); InlineEditors::instance()->richTextSub->setChecked(false); break; - case KTextEdit::AlignSubScript: + case KRichTextEdit::AlignSubScript: InlineEditors::instance()->richTextSuper->setChecked(false); InlineEditors::instance()->richTextSub->setChecked(true); break; @@ -331,15 +344,65 @@ case 106: if (isChecked && m_toolbar->isButtonOn(107)) m_toolbar->setButton(107, false); - m_text->setVerticalAlignment(isChecked ? KTextEdit::AlignSuperScript : KTextEdit::AlignNormal); + m_text->setVerticalAlignment(isChecked ? KRichTextEdit::AlignSuperScript : KRichTextEdit::AlignNormal); break; case 107: if (isChecked && m_toolbar->isButtonOn(106)) m_toolbar->setButton(106, false); - m_text->setVerticalAlignment(isChecked ? KTextEdit::AlignSubScript : KTextEdit::AlignNormal); + m_text->setVerticalAlignment(isChecked ? KRichTextEdit::AlignSubScript : KRichTextEdit::AlignNormal); break; }*/ +void HtmlEditor::setIndentType(int ind/*QString curType*/) +{ + +//currentIndexChanged + //int m_iIndentType=QTextListFormat::ListDisc; + //QString curType=InlineEditors::instance()->richTextIndentType->currentText(); +/* + int m_iIndentType; + if(curType == "Disc") + m_iIndentType = QTextListFormat::ListDisc; + else if(curType == "Circle") + m_iIndentType = QTextListFormat::ListCircle; + else if(curType == "Square") + m_iIndentType = QTextListFormat::ListSquare; + else if(curType == "123") + m_iIndentType = QTextListFormat::ListDecimal; + else if(curType == "abc") + m_iIndentType = QTextListFormat::ListLowerAlpha; + else if(curType == "ABC") + m_iIndentType = QTextListFormat::ListUpperAlpha; + else if(curType == "i ii iii") + m_iIndentType = QTextListFormat::ListLowerRoman; + else if(curType == "I II III") + m_iIndentType = QTextListFormat::ListUpperRoman; + m_iIndentType=-m_iIndentType; + textEdit()->setListStyle(m_iIndentType); + //InlineEditors::instance()->m_iIndentType = m_iIndentType; +*/ + textEdit()->setListStyle(ind+1); + +} + +void HtmlEditor::setIndent() +{ + textEdit()->indentListMore(); + + textEdit()->setListStyle(InlineEditors::instance()->richTextIndentType->currentIndex()+1); + + InlineEditors::instance()->richTextIndent->setEnabled(textEdit()->canIndentList()); + InlineEditors::instance()->richTextDedent->setEnabled(textEdit()->canDedentList()); + +} +void HtmlEditor::setDedent() +{ + //textEdit()->setListStyle(0); + textEdit()->indentListLess(); + InlineEditors::instance()->richTextIndent->setEnabled(textEdit()->canIndentList()); + InlineEditors::instance()->richTextDedent->setEnabled(textEdit()->canDedentList()); + +} void HtmlEditor::setLeft() { textEdit()->setAlignment(Qt::AlignLeft); @@ -1096,6 +1159,34 @@ ta->setIcon(KIcon("format-justify-fill")); richTextJustified = ta; +/*indent*/ + richTextIndentType = new QComboBox(Global::mainWindow()); + richTextIndentType -> addItem("Disc"); + richTextIndentType -> addItem("Circle"); + richTextIndentType -> addItem("Square"); + richTextIndentType -> addItem("123"); + richTextIndentType -> addItem("abc"); + richTextIndentType -> addItem("ABC"); + richTextIndentType -> addItem("i ii iii"); + richTextIndentType -> addItem("I II III"); + action = ac->addAction("richtext_indenttype"); + action->setDefaultWidget(richTextIndentType); + action->setText(i18n("Indent type")); + + KAction * ka = new KAction(ac); + ac->addAction("richtext_indent", ka); + ka->setText(i18n("Indent")); + ka->setIcon(KIcon("format-indent-more")); + richTextIndent = ka; + ka = new KAction(ac); + ac->addAction("richtext_dedent", ka); + ka->setText(i18n("Dedent")); + ka->setIcon(KIcon("format-indent-less")); + richTextDedent = ka; + + + + QActionGroup *alignmentGroup = new QActionGroup(this); alignmentGroup->addAction(richTextLeft); alignmentGroup->addAction(richTextCenter); @@ -1140,6 +1231,9 @@ richTextJustified->setEnabled(true); richTextUndo->setEnabled(true); richTextRedo->setEnabled(true); + richTextIndentType->setEnabled(true); + //richTextIndent->setEnabled(true); + //richTextDedent->setEnabled(true); } void InlineEditors::disableRichTextToolBar() @@ -1156,6 +1250,9 @@ disconnect(richTextJustified); disconnect(richTextUndo); disconnect(richTextRedo); + disconnect(richTextIndentType); + disconnect(richTextIndent); + disconnect(richTextDedent); richTextFont->setEnabled(false); richTextFontSize->setEnabled(false); @@ -1169,6 +1266,9 @@ richTextJustified->setEnabled(false); richTextUndo->setEnabled(false); richTextRedo->setEnabled(false); +// richTextIndentType->setEnabled(false); + richTextIndent->setEnabled(false); + richTextDedent->setEnabled(false); // Return to a "proper" state: QFont defaultFont; @@ -1185,6 +1285,8 @@ richTextCenter->setChecked(false); richTextRight->setChecked(false); richTextJustified->setChecked(false); + //richTextIndentType->setCurrentIndex(0); +// richTextIndent->setChecked(fals) } QPalette InlineEditors::palette() const diff -ruN basket-1.81/src/noteedit.h basket-1.81-new/src/noteedit.h --- basket-1.81/src/noteedit.h 2010-09-26 11:57:18.000000000 +0800 +++ basket-1.81-new/src/noteedit.h 2011-02-28 07:12:28.000000000 +0800 @@ -31,7 +31,7 @@ class QPushButton; class KIconButton; class KUrlRequester; -class KTextEdit; +class KRichTextEdit; class KMainWindow; class KToolBar; class KToggleAction; @@ -81,7 +81,7 @@ QWidget* widget() { return m_widget; } - KTextEdit* textEdit() { + KRichTextEdit* textEdit() { return m_textEdit; } QLineEdit* lineEdit() { @@ -92,7 +92,7 @@ bool m_isEmpty; bool m_canceled; QWidget *m_widget; - KTextEdit *m_textEdit; + KRichTextEdit *m_textEdit; QLineEdit *m_lineEdit; NoteContent *m_noteContent; @@ -154,6 +154,11 @@ void setCentered(); void setRight(); void setBlock(); + void setIndent(); + void setDedent(); + void setIndentType(int indenttype); + + }; class ImageEditor : public NoteEditor @@ -332,6 +337,12 @@ KToggleAction *richTextCenter; KToggleAction *richTextRight; KToggleAction *richTextJustified; + + QComboBox *richTextIndentType; + KAction *richTextIndent; + KAction *richTextDedent; + + KAction *richTextUndo; KAction *richTextRedo; FocusWidgetFilter *focusWidgetFilter;
------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________ Basket-devel mailing list Basket-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basket-devel