summaryrefslogtreecommitdiffstats
path: root/knotes/knoteedit.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-01 00:37:02 +0000
commitcc29364f06178f8f6b457384f2ec37a042bd9d43 (patch)
tree7c77a3184c698bbf9d98cef09fb1ba8124daceba /knotes/knoteedit.cpp
parent4f6c584bacc8c3c694228f36ada3de77a76614a6 (diff)
downloadtdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.tar.gz
tdepim-cc29364f06178f8f6b457384f2ec37a042bd9d43.zip
* Massive set of changes to bring in all fixes and enhancements from the Enterprise PIM branch
* Ensured that the Trinity changes were applied on top of those enhancements, and any redundancy removed * Added journal read support to the CalDAV resource * Fixed CalDAV resource to use events URL for tasks and journals when separate URL checkbox unchecked git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1170461 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knotes/knoteedit.cpp')
-rw-r--r--knotes/knoteedit.cpp82
1 files changed, 72 insertions, 10 deletions
diff --git a/knotes/knoteedit.cpp b/knotes/knoteedit.cpp
index 7df68149c..7b99254b0 100644
--- a/knotes/knoteedit.cpp
+++ b/knotes/knoteedit.cpp
@@ -27,24 +27,26 @@
#include <kurldrag.h>
#include <kstdaction.h>
#include <kcolordialog.h>
-
+#include <tqpopupmenu.h>
+#include <kiconloader.h>
#include "knoteedit.h"
+#include "knote.h"
static const short SEP = 5;
static const short ICON_SIZE = 10;
KNoteEdit::KNoteEdit( KActionCollection *actions, TQWidget *parent, const char *name )
- : KTextEdit( parent, name )
+ : KTextEdit( parent, name ), m_note( 0 )
{
setAcceptDrops( true );
setWordWrap( WidgetWidth );
setWrapPolicy( AtWhiteSpace );
setLinkUnderline( true );
-
+ setCheckSpellingEnabled(false);
// create the actions for the RMB menu
- KAction* undo = KStdAction::undo( this, TQT_SLOT(undo()), actions );
- KAction* redo = KStdAction::redo( this, TQT_SLOT(redo()), actions );
+ undo = KStdAction::undo( this, TQT_SLOT(undo()), actions );
+ redo = KStdAction::redo( this, TQT_SLOT(redo()), actions );
undo->setEnabled( isUndoAvailable() );
redo->setEnabled( isRedoAvailable() );
@@ -56,10 +58,10 @@ KNoteEdit::KNoteEdit( KActionCollection *actions, TQWidget *parent, const char *
m_copy->setEnabled( false );
m_paste->setEnabled( true );
- connect( this, TQT_SIGNAL(undoAvailable(bool)), undo, TQT_SLOT(setEnabled(bool)) );
- connect( this, TQT_SIGNAL(redoAvailable(bool)), redo, TQT_SLOT(setEnabled(bool)) );
+ connect( this, TQT_SIGNAL(undoAvailable(bool)), this, TQT_SLOT(setEnabledUndo(bool)) );
+ connect( this, TQT_SIGNAL(redoAvailable(bool)), this, TQT_SLOT(setEnabledRedo(bool)) );
- connect( this, TQT_SIGNAL(copyAvailable(bool)), m_cut, TQT_SLOT(setEnabled(bool)) );
+ connect( this, TQT_SIGNAL(copyAvailable(bool)), this, TQT_SLOT( slotCutEnabled( bool ) ) );
connect( this, TQT_SIGNAL(copyAvailable(bool)), m_copy, TQT_SLOT(setEnabled(bool)) );
new KAction( KStdGuiItem::clear(), 0, this, TQT_SLOT(clear()), actions, "edit_clear" );
@@ -156,6 +158,21 @@ KNoteEdit::~KNoteEdit()
{
}
+void KNoteEdit::setEnabledRedo( bool b )
+{
+ redo->setEnabled( b && !isReadOnly() );
+}
+
+void KNoteEdit::setEnabledUndo( bool b )
+{
+ undo->setEnabled( b && !isReadOnly() );
+}
+
+void KNoteEdit::slotCutEnabled( bool b )
+{
+ m_cut->setEnabled( b && !isReadOnly() );
+}
+
void KNoteEdit::setText( const TQString& text )
{
// to update the font and font size combo box - TQTextEdit stopped
@@ -269,10 +286,14 @@ void KNoteEdit::textStrikeOut( bool s )
void KNoteEdit::textColor()
{
+ if ( m_note )
+ m_note->blockEmitDataChanged( true );
TQColor c = color();
int ret = KColorDialog::getColor( c, this );
if ( ret == TQDialog::Accepted )
setTextColor( c );
+ if ( m_note )
+ m_note->blockEmitDataChanged( false );
}
void KNoteEdit::textAlignLeft()
@@ -347,13 +368,17 @@ void KNoteEdit::contentsDropEvent( TQDropEvent *e )
KURL::List list;
if ( KURLDrag::decode( e, list ) )
- for ( KURL::List::Iterator it = list.begin(); it != list.end(); ++it )
+ {
+ KURL::List::ConstIterator begin = list.constBegin();
+ KURL::List::ConstIterator end = list.constEnd();
+ for ( KURL::List::ConstIterator it = begin; it != end; ++it )
{
- if ( it != list.begin() )
+ if ( it != begin )
insert( ", " );
insert( (*it).prettyURL() );
}
+ }
else
KTextEdit::contentsDropEvent( e );
}
@@ -492,4 +517,41 @@ void KNoteEdit::disableRichTextActions()
// m_textDecreaseIndent->setEnabled( false );
}
+void KNoteEdit::slotAllowTab()
+{
+ setTabChangesFocus(!tabChangesFocus());
+}
+
+TQPopupMenu *KNoteEdit::createPopupMenu( const TQPoint &pos )
+{
+ enum { IdUndo, IdRedo, IdSep1, IdCut, IdCopy, IdPaste, IdClear, IdSep2, IdSelectAll };
+
+ TQPopupMenu *menu = TQTextEdit::createPopupMenu( pos );
+
+ if ( isReadOnly() )
+ menu->changeItem( menu->idAt(0), SmallIconSet("editcopy"), menu->text( menu->idAt(0) ) );
+ else {
+ int id = menu->idAt(0);
+ menu->changeItem( id - IdUndo, SmallIconSet("undo"), menu->text( id - IdUndo) );
+ menu->changeItem( id - IdRedo, SmallIconSet("redo"), menu->text( id - IdRedo) );
+ menu->changeItem( id - IdCut, SmallIconSet("editcut"), menu->text( id - IdCut) );
+ menu->changeItem( id - IdCopy, SmallIconSet("editcopy"), menu->text( id - IdCopy) );
+ menu->changeItem( id - IdPaste, SmallIconSet("editpaste"), menu->text( id - IdPaste) );
+ menu->changeItem( id - IdClear, SmallIconSet("editclear"), menu->text( id - IdClear) );
+
+ menu->insertSeparator();
+ id = menu->insertItem( SmallIconSet( "spellcheck" ), i18n( "Check Spelling..." ),
+ this, TQT_SLOT( checkSpelling() ) );
+
+ if( text().isEmpty() )
+ menu->setItemEnabled( id, false );
+
+ menu->insertSeparator();
+ id=menu->insertItem(i18n("Allow Tabulations"),this,TQT_SLOT(slotAllowTab()));
+ menu->setItemChecked(id, !tabChangesFocus());
+ }
+
+ return menu;
+}
+
#include "knoteedit.moc"