summaryrefslogtreecommitdiffstats
path: root/knotes/knotesapp.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/knotesapp.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/knotesapp.cpp')
-rw-r--r--knotes/knotesapp.cpp59
1 files changed, 44 insertions, 15 deletions
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 );
}