summaryrefslogtreecommitdiffstats
path: root/knotes
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
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')
-rw-r--r--knotes/knote.cpp146
-rw-r--r--knotes/knote.h18
-rw-r--r--knotes/knotealarmdlg.cpp3
-rw-r--r--knotes/knoteedit.cpp82
-rw-r--r--knotes/knoteedit.h16
-rw-r--r--knotes/knoteprinter.cpp9
-rw-r--r--knotes/knotes.desktop1
-rw-r--r--knotes/knotes_manager.desktop4
-rw-r--r--knotes/knotesalarm.cpp5
-rw-r--r--knotes/knotesapp.cpp59
-rw-r--r--knotes/knotesapp.h3
-rw-r--r--knotes/knoteslegacy.cpp7
-rw-r--r--knotes/local.desktop1
-rw-r--r--knotes/resourcelocal.cpp12
-rw-r--r--knotes/resourcemanager.cpp48
-rw-r--r--knotes/resourcemanager.h2
16 files changed, 315 insertions, 101 deletions
diff --git a/knotes/knote.cpp b/knotes/knote.cpp
index 1e55dd14c..9e644d7a6 100644
--- a/knotes/knote.cpp
+++ b/knotes/knote.cpp
@@ -30,6 +30,7 @@
#include <tqobjectlist.h>
#include <tqfile.h>
#include <tqcheckbox.h>
+#include <tqtimer.h>
#include <kapplication.h>
#include <kdebug.h>
@@ -84,7 +85,8 @@ KNote::KNote( TQDomDocument buildDoc, Journal *j, TQWidget *parent, const char *
: TQFrame( parent, name, WStyle_Customize | WStyle_NoBorder | WDestructiveClose ),
m_label( 0 ), m_pushpin( 0 ), m_fold( 0 ), m_button( 0 ), m_tool( 0 ), m_editor( 0 ),
m_config( 0 ), m_journal( j ), m_find( 0 ),
- m_kwinConf( KSharedConfig::openConfig( "kwinrc", true ) )
+ m_kwinConf( KSharedConfig::openConfig( "kwinrc", true ) ),
+ m_busy( 0 ), m_deleteWhenIdle( false ), m_blockEmitDataChanged( false )
{
setAcceptDrops( true );
actionCollection()->setWidget( this );
@@ -105,7 +107,7 @@ KNote::KNote( TQDomDocument buildDoc, Journal *j, TQWidget *parent, const char *
// create the menu items for the note - not the editor...
// rename, mail, print, save as, insert date, alarm, close, delete, new note
new KAction( i18n("New"), "filenew", 0,
- this, TQT_SIGNAL(sigRequestNewNote()), actionCollection(), "new_note" );
+ this,TQT_SLOT(slotRequestNewNote()) , actionCollection(), "new_note" );
new KAction( i18n("Rename..."), "text", 0,
this, TQT_SLOT(slotRename()), actionCollection(), "rename_note" );
m_readOnly = new KToggleAction( i18n("Lock"), "lock" , 0,
@@ -159,6 +161,7 @@ KNote::KNote( TQDomDocument buildDoc, Journal *j, TQWidget *parent, const char *
// create the note editor
m_editor = new KNoteEdit( actionCollection(), this );
+ m_editor->setNote( this );
m_editor->installEventFilter( this ); // receive events (for modified)
m_editor->viewport()->installEventFilter( this );
connect( m_editor, TQT_SIGNAL(contentsMoving( int, int )), this, TQT_SLOT(slotUpdateViewport( int, int )));
@@ -369,11 +372,27 @@ KNote::~KNote()
delete m_config;
}
+void KNote::slotRequestNewNote()
+{
+ //Be sure to save before to request a new note
+ saveConfig();
+ saveData();
+ emit sigRequestNewNote();
+}
+
+void KNote::changeJournal(KCal::Journal *journal)
+{
+ m_journal = journal;
+ m_editor->setText( m_journal->description() );
+ m_label->setText( m_journal->summary() );
+ updateLabelAlignment();
+}
// -------------------- public slots -------------------- //
void KNote::slotKill( bool force )
{
+ m_blockEmitDataChanged = true;
if ( !force &&
KMessageBox::warningContinueCancel( this,
i18n("<qt>Do you really want to delete note <b>%1</b>?</qt>").arg( m_label->text() ),
@@ -382,9 +401,10 @@ void KNote::slotKill( bool force )
)
!= KMessageBox::Continue )
{
+ m_blockEmitDataChanged = false;
return;
}
-
+ aboutToEnterEventLoop();
// delete the configuration first, then the corresponding file
delete m_config;
m_config = 0;
@@ -396,21 +416,24 @@ void KNote::slotKill( bool force )
kdError(5500) << "Can't remove the note config: " << configFile << endl;
emit sigKillNote( m_journal );
+ eventLoopLeft();
+
}
// -------------------- public member functions -------------------- //
-void KNote::saveData()
+void KNote::saveData(bool update)
{
m_journal->setSummary( m_label->text() );
m_journal->setDescription( m_editor->text() );
m_journal->setCustomProperty( "KNotes", "FgColor", m_config->fgColor().name() );
m_journal->setCustomProperty( "KNotes", "BgColor", m_config->bgColor().name() );
m_journal->setCustomProperty( "KNotes", "RichText", m_config->richText() ? "true" : "false" );
-
- emit sigDataChanged();
+ if(update) {
+ emit sigDataChanged( noteId() );
m_editor->setModified( false );
+ }
}
void KNote::saveConfig() const
@@ -498,7 +521,7 @@ void KNote::setColor( const TQColor& fg, const TQColor& bg )
m_config->setBgColor( bg );
m_journal->updated(); // because setCustomProperty() doesn't call it!!
- emit sigDataChanged();
+ emit sigDataChanged(noteId());
m_config->writeConfig();
TQPalette newpalette = palette();
@@ -684,11 +707,16 @@ void KNote::setStyle( int style )
void KNote::slotRename()
{
+ m_blockEmitDataChanged = true;
// pop up dialog to get the new name
bool ok;
+ aboutToEnterEventLoop();
+ TQString oldName = m_label->text();
TQString newName = KInputDialog::getText( TQString::null,
i18n("Please enter the new name:"), m_label->text(), &ok, this );
- if ( !ok ) // handle cancel
+ eventLoopLeft();
+ m_blockEmitDataChanged = false;
+ if ( !ok || ( oldName == newName) ) // handle cancel
return;
setName( newName );
@@ -711,6 +739,21 @@ void KNote::slotUpdateReadOnly()
actionCollection()->action( "edit_cut" )->setEnabled( !readOnly && m_editor->hasSelectedText() );
actionCollection()->action( "edit_paste" )->setEnabled( !readOnly );
actionCollection()->action( "edit_clear" )->setEnabled( !readOnly );
+ actionCollection()->action( "rename_note" )->setEnabled( !readOnly );
+
+ actionCollection()->action( "format_bold" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_italic" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_underline" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_strikeout" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_alignleft" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_aligncenter" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_alignright" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_alignblock" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_list" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_super" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_sub" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_size" )->setEnabled( !readOnly );
+ actionCollection()->action( "format_color" )->setEnabled( !readOnly );
updateFocus();
}
@@ -724,7 +767,7 @@ void KNote::slotClose()
m_editor->clearFocus();
m_config->setHideNote( true );
m_config->setPosition( pos() );
-
+ m_config->writeConfig();
// just hide the note so it's still available from the dock window
hide();
}
@@ -736,11 +779,15 @@ void KNote::slotInsDate()
void KNote::slotSetAlarm()
{
+ m_blockEmitDataChanged = true;
KNoteAlarmDlg dlg( name(), this );
dlg.setIncidence( m_journal );
+ aboutToEnterEventLoop();
if ( dlg.exec() == TQDialog::Accepted )
- emit sigDataChanged();
+ emit sigDataChanged(noteId());
+ eventLoopLeft();
+ m_blockEmitDataChanged = false;
}
void KNote::slotPreferences()
@@ -760,11 +807,12 @@ void KNote::slotSend()
{
// pop up dialog to get the IP
KNoteHostDlg hostDlg( i18n("Send \"%1\"").arg( name() ), this );
+ aboutToEnterEventLoop();
bool ok = (hostDlg.exec() == TQDialog::Accepted);
- TQString host = hostDlg.host();
-
+ eventLoopLeft();
if ( !ok ) // handle cancel
return;
+ TQString host = hostDlg.host();
if ( host.isEmpty() )
{
@@ -782,11 +830,11 @@ void KNote::slotSend()
void KNote::slotMail()
{
// get the mail action command
- TQStringList cmd_list = TQStringList::split( TQChar(' '), KNotesGlobalConfig::mailAction() );
+ const TQStringList cmd_list = TQStringList::split( TQChar(' '), KNotesGlobalConfig::mailAction() );
KProcess mail;
- for ( TQStringList::Iterator it = cmd_list.begin();
- it != cmd_list.end(); ++it )
+ for ( TQStringList::ConstIterator it = cmd_list.constBegin();
+ it != cmd_list.constEnd(); ++it )
{
if ( *it == "%f" )
mail << plainText().local8Bit(); // convert rich text to plain text
@@ -802,8 +850,6 @@ void KNote::slotMail()
void KNote::slotPrint()
{
- saveData();
-
TQString content;
if ( m_editor->textFormat() == PlainText )
content = TQStyleSheet::convertFromPlainText( m_editor->text() );
@@ -821,6 +867,7 @@ void KNote::slotPrint()
void KNote::slotSaveAs()
{
+ m_blockEmitDataChanged = true;
TQCheckBox *convert = 0;
if ( m_editor->textFormat() == RichText )
@@ -832,12 +879,16 @@ void KNote::slotSaveAs()
KFileDialog dlg( TQString::null, TQString::null, this, "filedialog", true, convert );
dlg.setOperationMode( KFileDialog::Saving );
dlg.setCaption( i18n("Save As") );
+ aboutToEnterEventLoop();
dlg.exec();
+ eventLoopLeft();
TQString fileName = dlg.selectedFile();
if ( fileName.isEmpty() )
+ {
+ m_blockEmitDataChanged = false;
return;
-
+ }
TQFile file( fileName );
if ( file.exists() &&
@@ -845,6 +896,7 @@ void KNote::slotSaveAs()
"Are you sure you want to overwrite it?</qt>").arg( TQFileInfo(file).fileName() ) )
!= KMessageBox::Continue )
{
+ m_blockEmitDataChanged = false;
return;
}
@@ -857,6 +909,7 @@ void KNote::slotSaveAs()
else
stream << text();
}
+ m_blockEmitDataChanged = false;
}
void KNote::slotPopupActionToDesktop( int id )
@@ -993,19 +1046,20 @@ void KNote::updateFocus()
{
m_label->setBackgroundColor( palette().active().shadow() );
m_button->show();
- m_editor->cornerWidget()->show();
if ( !m_editor->isReadOnly() )
{
if ( m_tool && m_tool->isHidden() && m_editor->textFormat() == TQTextEdit::RichText )
{
m_tool->show();
+ m_editor->cornerWidget()->show();
setGeometry( x(), y(), width(), height() + m_tool->height() );
}
}
else if ( m_tool && !m_tool->isHidden() )
{
m_tool->hide();
+ m_editor->cornerWidget()->hide();
setGeometry( x(), y(), width(), height() - m_tool->height() );
updateLayout(); // to update the minimum height
}
@@ -1210,8 +1264,9 @@ void KNote::resizeEvent( TQResizeEvent *qre )
updateLayout();
}
-void KNote::closeEvent( TQCloseEvent * )
+void KNote::closeEvent( TQCloseEvent *event )
{
+ event->ignore(); //We don't want to close (and delete the widget). Just hide it
slotClose();
}
@@ -1268,8 +1323,10 @@ bool KNote::eventFilter( TQObject *o, TQEvent *ev )
TQMouseEvent *e = (TQMouseEvent *)ev;
if ( ev->type() == TQEvent::MouseButtonDblClick )
- slotRename();
-
+ {
+ if( !m_editor->isReadOnly())
+ slotRename();
+ }
if ( ev->type() == TQEvent::MouseButtonPress &&
(e->button() == LeftButton || e->button() == MidButton))
{
@@ -1301,21 +1358,21 @@ bool KNote::eventFilter( TQObject *o, TQEvent *ev )
return false;
}
- if ( o == m_editor )
- {
- if ( ev->type() == TQEvent::FocusOut )
- {
+ if ( o == m_editor ) {
+ if ( ev->type() == TQEvent::FocusOut ) {
TQFocusEvent *fe = static_cast<TQFocusEvent *>(ev);
if ( fe->reason() != TQFocusEvent::Popup &&
- fe->reason() != TQFocusEvent::Mouse )
- {
+ fe->reason() != TQFocusEvent::Mouse ) {
updateFocus();
- if ( m_editor->isModified() )
- saveData();
+ if ( isModified() ) {
+ saveConfig();
+ if ( !m_blockEmitDataChanged )
+ saveData();
+ }
}
- }
- else if ( ev->type() == TQEvent::FocusIn )
+ } else if ( ev->type() == TQEvent::FocusIn ) {
updateFocus();
+ }
return false;
}
@@ -1334,6 +1391,31 @@ bool KNote::eventFilter( TQObject *o, TQEvent *ev )
return false;
}
+void KNote::slotSaveData()
+{
+ saveData();
+}
+
+void KNote::deleteWhenIdle()
+{
+ if ( m_busy <= 0 )
+ deleteLater();
+ else
+ m_deleteWhenIdle = true;
+}
+
+void KNote::aboutToEnterEventLoop()
+{
+ ++m_busy;
+}
+
+void KNote::eventLoopLeft()
+{
+ --m_busy;
+ if ( m_busy <= 0 && m_deleteWhenIdle )
+ deleteLater();
+}
+
#include "knote.moc"
#include "knotebutton.moc"
diff --git a/knotes/knote.h b/knotes/knote.h
index a3bfd7b3e..6bb2ffe84 100644
--- a/knotes/knote.h
+++ b/knotes/knote.h
@@ -56,7 +56,8 @@ public:
const char *name = 0 );
~KNote();
- void saveData();
+ void changeJournal(KCal::Journal *);
+ void saveData( bool update = true);
void saveConfig() const;
TQString noteId() const;
@@ -82,6 +83,8 @@ public:
static void setStyle( int style );
+ void deleteWhenIdle();
+ void blockEmitDataChanged( bool _b ) { m_blockEmitDataChanged = _b;}
public slots:
void slotKill( bool force = false );
@@ -89,7 +92,7 @@ signals:
void sigRequestNewNote();
void sigShowNextNote();
void sigNameChanged();
- void sigDataChanged();
+ void sigDataChanged(const TQString &);
void sigColorChanged();
void sigKillNote( KCal::Journal* );
@@ -108,6 +111,10 @@ protected:
virtual bool focusNextPrevChild( bool );
+ /// Protect against deletion while we are running a sub-eventloop
+ void aboutToEnterEventLoop();
+ void eventLoopLeft();
+
private slots:
void slotRename();
void slotUpdateReadOnly();
@@ -133,7 +140,8 @@ private slots:
void slotUpdateDesktopActions();
void slotUpdateViewport( int, int );
-
+ void slotRequestNewNote();
+ void slotSaveData();
private:
void updateFocus();
void updateMask();
@@ -170,6 +178,10 @@ private:
KSharedConfig::Ptr m_kwinConf;
static int s_ppOffset;
+
+ int m_busy;
+ bool m_deleteWhenIdle;
+ bool m_blockEmitDataChanged;
};
#endif
diff --git a/knotes/knotealarmdlg.cpp b/knotes/knotealarmdlg.cpp
index ef71c0f51..2652af633 100644
--- a/knotes/knotealarmdlg.cpp
+++ b/knotes/knotealarmdlg.cpp
@@ -70,7 +70,8 @@ KNoteAlarmDlg::KNoteAlarmDlg( const TQString& caption, TQWidget *parent, const c
TQLabel *in_min = new TQLabel( i18n("hours/minutes"), in );
label_in->setEnabled( false ); // TODO
-
+ in->hide(); //show it and enable it when feature will implement
+
connect( m_buttons, TQT_SIGNAL(clicked( int )), TQT_SLOT(slotButtonChanged( int )) );
}
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"
diff --git a/knotes/knoteedit.h b/knotes/knoteedit.h
index 862aa38ba..0e6a6e4b4 100644
--- a/knotes/knoteedit.h
+++ b/knotes/knoteedit.h
@@ -24,7 +24,7 @@
#include <tqwidget.h>
#include <ktextedit.h>
-
+class KNote;
class TQFont;
class TQColor;
class TQPushButton;
@@ -41,7 +41,9 @@ class KNoteEdit : public KTextEdit
public:
KNoteEdit( KActionCollection *actions, TQWidget *parent=0, const char *name=0 );
~KNoteEdit();
-
+ void setNote( KNote *_note ) {
+ m_note = _note;
+ }
void setText( const TQString& text );
void setTextFont( const TQFont& font );
void setTextColor( const TQColor& color );
@@ -67,10 +69,12 @@ public slots:
//void textIncreaseIndent();
//void textDecreaseIndent();
+ void slotCutEnabled( bool );
protected:
virtual void contentsDragEnterEvent( TQDragEnterEvent *e );
virtual void contentsDropEvent( TQDropEvent *e );
+ virtual TQPopupMenu *createPopupMenu( const TQPoint &pos );
private slots:
void slotReturnPressed();
@@ -79,6 +83,10 @@ private slots:
void colorChanged( const TQColor &c );
void alignmentChanged( int a );
void verticalAlignmentChanged( VerticalAlignment a );
+ void slotAllowTab();
+
+ void setEnabledRedo( bool b );
+ void setEnabledUndo( bool b );
private:
void autoIndent();
@@ -114,8 +122,10 @@ private:
KAction *m_textColor;
KFontAction *m_textFont;
KFontSizeAction *m_textSize;
-
+ KAction* undo;
+ KAction* redo;
bool m_autoIndentMode;
+ KNote *m_note;
};
#endif
diff --git a/knotes/knoteprinter.cpp b/knotes/knoteprinter.cpp
index 0bd6ef8a7..c58031671 100644
--- a/knotes/knoteprinter.cpp
+++ b/knotes/knoteprinter.cpp
@@ -4,7 +4,7 @@
#include <klocale.h>
#include <kprinter.h>
-
+#include <kdebug.h>
#include <tqfont.h>
#include <tqpaintdevicemetrics.h>
#include <tqpainter.h>
@@ -79,6 +79,9 @@ void KNotePrinter::doPrint( KPrinter& printer, TQPainter& painter,
metrics.width() - marginX * 2,
metrics.height() - marginY * 2 );
+ kdDebug()<<" content :"<<content<<endl;
+ kdDebug()<<" m_styleSheet :"<<m_styleSheet<<endl;
+ //kdDebug()<<" m_font :"<<m_font;
TQSimpleRichText text( content, m_font, m_context,
m_styleSheet, m_mimeSourceFactory,
body.height() /*, linkColor, linkUnderline? */ );
@@ -136,8 +139,8 @@ void KNotePrinter::printNotes( const TQValueList<KCal::Journal*>& journals ) con
TQPainter painter;
painter.begin( &printer );
TQString content;
- TQValueListConstIterator<KCal::Journal*> it( journals.begin() );
- TQValueListConstIterator<KCal::Journal*> end( journals.end() );
+ TQValueListConstIterator<KCal::Journal*> it( journals.constBegin() );
+ TQValueListConstIterator<KCal::Journal*> end( journals.constEnd() );
while ( it != end ) {
KCal::Journal *j = *it;
it++;
diff --git a/knotes/knotes.desktop b/knotes/knotes.desktop
index a455e07da..6a099e585 100644
--- a/knotes/knotes.desktop
+++ b/knotes/knotes.desktop
@@ -32,7 +32,6 @@ GenericName[hu]=Jegyzettömb
GenericName[is]=Litlir gulir miðar
GenericName[it]=Note a comparsa
GenericName[ja]=ポップアップメモ
-GenericName[ka]=მოტივტივე შენიშვნები
GenericName[kk]=Қалқымалы жазбалар
GenericName[km]=ចំណាំ​លេចឡើង
GenericName[lt]=Pastabos lapeliuose
diff --git a/knotes/knotes_manager.desktop b/knotes/knotes_manager.desktop
index adce2afb5..d193bcbbe 100644
--- a/knotes/knotes_manager.desktop
+++ b/knotes/knotes_manager.desktop
@@ -27,7 +27,6 @@ Name[hu]=Feljegyzések
Name[is]=Minnismiðar
Name[it]=Note
Name[ja]=メモ
-Name[ka]=ჩანიშვნები
Name[kk]=Жазбалар
Name[km]=ចំណាំ
Name[lt]=Užrašai
@@ -53,8 +52,7 @@ Name[tg]=Ахборот
Name[th]=บันทึกช่วยจำ
Name[tr]=Notlar
Name[uk]=Примітки
-Name[uz]=Yozma xotira
-Name[uz@cyrillic]=Ёзма хотира
+Name[uz]=Ёзма хотира
Name[zh_CN]=便笺
Name[zh_TW]=備忘錄
Type=Service
diff --git a/knotes/knotesalarm.cpp b/knotes/knotesalarm.cpp
index c653d80ca..616c83b7c 100644
--- a/knotes/knotesalarm.cpp
+++ b/knotes/knotesalarm.cpp
@@ -61,10 +61,11 @@ void KNotesAlarm::checkAlarms()
KNotesGlobalConfig::self()->setAlarmsLastChecked( TQDateTime::currentDateTime() );
TQValueList<KCal::Alarm *> alarms = m_manager->alarms( from, KNotesGlobalConfig::self()->alarmsLastChecked() );
-
+ if( alarms.isEmpty())
+ return;
TQStringList notes;
TQValueList<KCal::Alarm *>::ConstIterator it;
- for ( it = alarms.begin(); it != alarms.end(); ++it )
+ for ( it = alarms.constBegin(); it != alarms.constEnd(); ++it )
{
KCal::Incidence *incidence = (*it)->parent();
notes += incidence->summary();
diff --git a/knotes/knotesapp.cpp b/knotes/knotesapp.cpp
index 858cbb795..72b1ecce1 100644
--- a/knotes/knotesapp.cpp
+++ b/knotes/knotesapp.cpp
@@ -121,7 +121,7 @@ KNotesApp::KNotesApp()
this, TQT_SLOT(hideAllNotes()), actionCollection(), "hide_all_notes" );
new KHelpMenu( this, kapp->aboutData(), false, actionCollection() );
- KStdAction::find( this, TQT_SLOT(slotOpenFindDialog()), actionCollection() );
+ m_findAction = KStdAction::find( this, TQT_SLOT(slotOpenFindDialog()), actionCollection() );
KStdAction::preferences( this, TQT_SLOT(slotPreferences()), actionCollection() );
KStdAction::keyBindings( this, TQT_SLOT(slotConfigureAccels()), actionCollection() );
//FIXME: no shortcut removing!?
@@ -188,7 +188,7 @@ KNotesApp::KNotesApp()
{
KCal::Journal::List notes = calendar.journals();
KCal::Journal::List::ConstIterator it;
- for ( it = notes.begin(); it != notes.end(); ++it )
+ for ( it = notes.constBegin(); it != notes.constEnd(); ++it )
m_manager->addNewNote( *it );
m_manager->save();
@@ -258,10 +258,9 @@ TQString KNotesApp::newNote( const TQString& name, const TQString& text )
// the body of the note
journal->setDescription( text );
- m_manager->addNewNote( journal );
-
- showNote( journal->uid() );
-
+ if ( m_manager->addNewNote( journal ) ) {
+ showNote( journal->uid() );
+ }
return journal->uid();
}
@@ -284,7 +283,6 @@ void KNotesApp::showAllNotes() const
for ( ; *it; ++it )
{
(*it)->show();
- (*it)->setFocus();
}
}
@@ -516,7 +514,7 @@ void KNotesApp::slotOpenFindDialog()
findDia.setHasCursor( false );
findDia.setSupportsBackwardsFind( false );
- if ( findDia.exec() != TQDialog::Accepted )
+ if ( (findDia.exec() != TQDialog::Accepted) || findDia.pattern().isEmpty() )
return;
delete m_findPos;
@@ -596,6 +594,7 @@ void KNotesApp::slotConfigureAccels()
void KNotesApp::slotNoteKilled( KCal::Journal *journal )
{
+ m_noteUidModify="";
m_manager->deleteNote( journal );
saveNotes();
}
@@ -606,7 +605,7 @@ void KNotesApp::slotQuit()
for ( ; *it; ++it )
if ( (*it)->isModified() )
- (*it)->saveData();
+ (*it)->saveData(false);
saveConfigs();
kapp->quit();
@@ -625,6 +624,15 @@ void KNotesApp::showNote( KNote* note ) const
void KNotesApp::createNote( KCal::Journal *journal )
{
+ if( journal->uid() == m_noteUidModify)
+ {
+ KNote *note = m_noteList[m_noteUidModify];
+ if ( note )
+ note->changeJournal(journal);
+
+ return;
+ }
+ m_noteUidModify = journal->uid();
KNote *newNote = new KNote( m_noteGUI, journal, 0, journal->uid().utf8() );
m_noteList.insert( newNote->noteId(), newNote );
@@ -633,7 +641,7 @@ void KNotesApp::createNote( KCal::Journal *journal )
connect( newNote, TQT_SIGNAL(sigKillNote( KCal::Journal* )),
TQT_SLOT(slotNoteKilled( KCal::Journal* )) );
connect( newNote, TQT_SIGNAL(sigNameChanged()), TQT_SLOT(updateNoteActions()) );
- connect( newNote, TQT_SIGNAL(sigDataChanged()), TQT_SLOT(saveNotes()) );
+ connect( newNote, TQT_SIGNAL(sigDataChanged(const TQString &)), TQT_SLOT(saveNotes(const TQString &)) );
connect( newNote, TQT_SIGNAL(sigColorChanged()), TQT_SLOT(updateNoteActions()) );
connect( newNote, TQT_SIGNAL(sigFindFinished()), TQT_SLOT(slotFindNext()) );
@@ -644,9 +652,17 @@ void KNotesApp::createNote( KCal::Journal *journal )
void KNotesApp::killNote( KCal::Journal *journal )
{
+ if(m_noteUidModify == journal->uid())
+ {
+ return;
+ }
// this kills the KNote object
- m_noteList.remove( journal->uid() );
- updateNoteActions();
+ KNote *note = m_noteList.take( journal->uid() );
+ if ( note )
+ {
+ note->deleteWhenIdle();
+ updateNoteActions();
+ }
}
void KNotesApp::acceptConnection()
@@ -661,6 +677,12 @@ void KNotesApp::acceptConnection()
}
}
+void KNotesApp::saveNotes( const TQString & uid )
+{
+ m_noteUidModify = uid;
+ saveNotes();
+}
+
void KNotesApp::saveNotes()
{
KNotesGlobalConfig::writeConfig();
@@ -692,14 +714,21 @@ void KNotesApp::updateNoteActions()
m_noteActions.append( action );
}
- m_noteActions.sort();
-
if ( m_noteActions.isEmpty() )
{
+ actionCollection()->action( "hide_all_notes" )->setEnabled( false );
+ actionCollection()->action( "show_all_notes" )->setEnabled( false );
+ m_findAction->setEnabled( false );
KAction *action = new KAction( i18n("No Notes") );
m_noteActions.append( action );
}
-
+ else
+ {
+ actionCollection()->action( "hide_all_notes" )->setEnabled( true );
+ actionCollection()->action( "show_all_notes" )->setEnabled( true );
+ m_findAction->setEnabled( true );
+ m_noteActions.sort();
+ }
plugActionList( "notes", m_noteActions );
}
diff --git a/knotes/knotesapp.h b/knotes/knotesapp.h
index ba156cca4..3048958dd 100644
--- a/knotes/knotesapp.h
+++ b/knotes/knotesapp.h
@@ -125,6 +125,7 @@ private:
private slots:
void acceptConnection();
void saveNotes();
+ void saveNotes( const TQString & uid );
void updateNoteActions();
void updateGlobalAccels();
void updateNetworkListener();
@@ -159,6 +160,8 @@ private:
KXMLGUIBuilder *m_guiBuilder;
TQDomDocument m_noteGUI;
+ KAction *m_findAction;
+ TQString m_noteUidModify;
};
#endif
diff --git a/knotes/knoteslegacy.cpp b/knotes/knoteslegacy.cpp
index 8cb57d4ce..6dd80368f 100644
--- a/knotes/knoteslegacy.cpp
+++ b/knotes/knoteslegacy.cpp
@@ -72,8 +72,8 @@ bool KNotesLegacy::convert( CalendarLocal *calendar )
bool converted = false;
TQDir noteDir( KGlobal::dirs()->saveLocation( "appdata", "notes/" ) );
- TQStringList notes = noteDir.entryList( TQDir::Files, TQDir::Name );
- for ( TQStringList::Iterator note = notes.begin(); note != notes.end(); note++ )
+ const TQStringList notes = noteDir.entryList( TQDir::Files, TQDir::Name );
+ for ( TQStringList::ConstIterator note = notes.constBegin(); note != notes.constEnd(); ++note )
{
TQString file = noteDir.absFilePath( *note );
KSimpleConfig* test = new KSimpleConfig( file );
@@ -82,7 +82,6 @@ bool KNotesLegacy::convert( CalendarLocal *calendar )
if ( version < 3.0 )
{
- delete test;
// create the new note
Journal *journal = new Journal();
@@ -109,8 +108,8 @@ bool KNotesLegacy::convert( CalendarLocal *calendar )
test->writeEntry( "ShowInTaskbar", (state & NET::SkipTaskbar) ? false : true );
test->writeEntry( "KeepAbove", (state & NET::KeepAbove) ? true : false );
test->deleteEntry( "state" );
- delete test;
}
+ delete test;
}
return converted;
diff --git a/knotes/local.desktop b/knotes/local.desktop
index 514145a81..c0748995b 100644
--- a/knotes/local.desktop
+++ b/knotes/local.desktop
@@ -26,7 +26,6 @@ Name[hu]=Helyi fájlban tárolt feljegyzések
Name[is]=Minnismiðar í staðbundinni skrá
Name[it]=Note in file locale
Name[ja]=ローカルファイルのメモ
-Name[ka]=ჩანიშვნები ლოკალურ ფაილში
Name[kk]=Жергілікті файлдағы жазбалар
Name[km]=ចំណាំ​ក្នុង​ឯកសារ​មូលដ្ឋាន
Name[lt]=Užrašai vietinėje byloje
diff --git a/knotes/resourcelocal.cpp b/knotes/resourcelocal.cpp
index a6e4b9a3f..91e6d2d9f 100644
--- a/knotes/resourcelocal.cpp
+++ b/knotes/resourcelocal.cpp
@@ -75,7 +75,7 @@ bool ResourceLocal::load()
KCal::Journal::List notes = mCalendar.journals();
KCal::Journal::List::ConstIterator it;
- for ( it = notes.begin(); it != notes.end(); ++it )
+ for ( it = notes.constBegin(); it != notes.constEnd(); ++it )
manager()->registerNote( this, *it );
return true;
@@ -98,14 +98,12 @@ bool ResourceLocal::save()
bool ResourceLocal::addNote( KCal::Journal *journal )
{
- mCalendar.addJournal( journal );
- return true;
+ return mCalendar.addJournal( journal );
}
bool ResourceLocal::deleteNote( KCal::Journal *journal )
{
- mCalendar.deleteJournal( journal );
- return true;
+ return mCalendar.deleteJournal( journal );
}
KCal::Alarm::List ResourceLocal::alarms( const TQDateTime& from, const TQDateTime& to )
@@ -113,11 +111,11 @@ KCal::Alarm::List ResourceLocal::alarms( const TQDateTime& from, const TQDateTim
KCal::Alarm::List alarms;
KCal::Journal::List notes = mCalendar.journals();
KCal::Journal::List::ConstIterator note;
- for ( note = notes.begin(); note != notes.end(); ++note )
+ for ( note = notes.constBegin(); note != notes.constEnd(); ++note )
{
TQDateTime preTime = from.addSecs( -1 );
KCal::Alarm::List::ConstIterator it;
- for( it = (*note)->alarms().begin(); it != (*note)->alarms().end(); ++it )
+ for( it = (*note)->alarms().constBegin(); it != (*note)->alarms().constEnd(); ++it )
{
if ( (*it)->enabled() )
{
diff --git a/knotes/resourcemanager.cpp b/knotes/resourcemanager.cpp
index 112ec03f8..226d90005 100644
--- a/knotes/resourcemanager.cpp
+++ b/knotes/resourcemanager.cpp
@@ -64,6 +64,11 @@ void KNotesResourceManager::load()
KRES::Manager<ResourceNotes>::ActiveIterator it;
for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
{
+ if ( (*it)->isOpen() ) {
+ kdDebug(5500) << (*it)->resourceName() << " is already open" << endl;
+ continue;
+ }
+
kdDebug(5500) << "Opening resource " + (*it)->resourceName() << endl;
(*it)->setManager( this );
if ( (*it)->open() )
@@ -80,17 +85,19 @@ void KNotesResourceManager::save()
// when adding a new note, make sure a config file exists!!
-void KNotesResourceManager::addNewNote( KCal::Journal *journal )
+bool KNotesResourceManager::addNewNote( KCal::Journal *journal )
{
// TODO: Make this configurable
ResourceNotes *resource = m_manager->standardResource();
- if ( resource )
- {
- resource->addNote( journal );
- registerNote( resource, journal );
- }
- else
+ if ( resource ) {
+ if ( resource->addNote( journal ) ) {
+ registerNote( resource, journal );
+ return true;
+ }
+ } else {
kdWarning(5500) << k_funcinfo << "no resource!" << endl;
+ }
+ return false;
}
void KNotesResourceManager::registerNote( ResourceNotes *resource,
@@ -103,15 +110,21 @@ void KNotesResourceManager::registerNote( ResourceNotes *resource,
void KNotesResourceManager::deleteNote( KCal::Journal *journal )
{
+ if ( !journal )
+ return;
+
TQString uid = journal->uid();
// Remove the journal from the resource it came from
- m_resourceMap[ uid ]->deleteNote( journal );
- m_resourceMap.remove( uid );
-
- // libkcal does not delete the journal immediately, therefore it is ok to
- // emit the journal here
- emit sigDeregisteredNote( journal );
+ ResourceNotes *res = m_resourceMap[ uid ];
+ if ( res ) {
+ res->deleteNote( journal );
+ m_resourceMap.remove( uid );
+
+ // libkcal does not delete the journal immediately, therefore it is ok to
+ // emit the journal here
+ emit sigDeregisteredNote( journal );
+ }
}
KCal::Alarm::List KNotesResourceManager::alarms( const TQDateTime& from, const TQDateTime& to )
@@ -122,8 +135,8 @@ KCal::Alarm::List KNotesResourceManager::alarms( const TQDateTime& from, const T
for ( it = m_manager->activeBegin(); it != m_manager->activeEnd(); ++it )
{
KCal::Alarm::List list = (*it)->alarms( from, to );
- KCal::Alarm::List::Iterator it;
- for ( it = list.begin(); it != list.end(); ++it )
+ KCal::Alarm::List::ConstIterator it;
+ for ( it = list.constBegin(); it != list.constEnd(); ++it )
result.append( *it );
}
@@ -137,6 +150,11 @@ void KNotesResourceManager::resourceAdded( ResourceNotes *resource )
if ( !resource->isActive() )
return;
+ if ( resource->isOpen() ) {
+ kdDebug(5500) << resource->resourceName() << " is already open" << endl;
+ return;
+ }
+
resource->setManager( this );
if ( resource->open() )
resource->load();
diff --git a/knotes/resourcemanager.h b/knotes/resourcemanager.h
index 0ba70b4b5..a864fc380 100644
--- a/knotes/resourcemanager.h
+++ b/knotes/resourcemanager.h
@@ -57,7 +57,7 @@ public:
void load();
void save();
- void addNewNote( KCal::Journal *journal );
+ bool addNewNote( KCal::Journal *journal );
void registerNote( ResourceNotes *resource, KCal::Journal *journal );
void deleteNote( KCal::Journal *journal );