CVS commit by mteijeiro: * Open the knote edit dialog on create a "new" note, BTW, create a new note only requires one step. BUGS:99286 M +32 -4 knotes_part.cpp 1.52 M +5 -1 knotes_part.rc 1.5 M +22 -0 knotes_part_p.h 1.5 --- kdepim/kontact/plugins/knotes/knotes_part.cpp #1.51:1.52 @@ -128,5 +128,26 @@ QString KNotesPart::newNote( const QStri journal->setDescription( text ); - mManager->addNewNote( journal ); + + + // Edit the new note if text is empty + if ( text.isNull() ) + { + if ( !mNoteEditDlg ) + mNoteEditDlg = new KNoteEditDlg( widget() ); + + mNoteEditDlg->setTitle( journal->summary() ); + mNoteEditDlg->setText( journal->description() ); + + if ( mNoteEditDlg->exec() == QDialog::Accepted ) + { + journal->setSummary( mNoteEditDlg->title() ); + journal->setDescription( mNoteEditDlg->text() ); + } + else + { + delete journal; + return ""; + } + } KNotesIconViewItem *note = mNoteList[ journal->uid() ]; @@ -134,6 +155,6 @@ QString KNotesPart::newNote( const QStri mNotesView->setCurrentItem( note ); + mManager->addNewNote( journal ); mManager->save(); - return journal->uid(); } @@ -249,7 +270,12 @@ void KNotesPart::killSelectedNotes() void KNotesPart::popupRMB( QIconViewItem *item, const QPoint& pos ) { - QPopupMenu *contextMenu = static_cast( factory()->container( "note_context", this ) ); + QPopupMenu *contextMenu = NULL; - if ( !contextMenu || !item ) + if ( item ) + contextMenu = static_cast( factory()->container( "note_context", this ) ); + else + contextMenu = static_cast( factory()->container( "notepart_context", this ) ); + + if ( !contextMenu ) return; @@ -303,7 +329,9 @@ void KNotesPart::editNote( QIconViewItem KCal::Journal *journal = static_cast( item )->journal(); + mNoteEditDlg->setTitle( journal->summary() ); mNoteEditDlg->setText( journal->description() ); if ( mNoteEditDlg->exec() == QDialog::Accepted ) { + journal->setSummary( mNoteEditDlg->title() ); journal->setDescription( mNoteEditDlg->text() ); mManager->save(); --- kdepim/kontact/plugins/knotes/knotes_part.rc #1.4:1.5 @@ -1,4 +1,4 @@ - + &Edit @@ -13,3 +13,7 @@ + + + + --- kdepim/kontact/plugins/knotes/knotes_part_p.h #1.4:1.5 @@ -34,4 +34,5 @@ #include +#include #include @@ -41,4 +42,5 @@ #include #include +#include #include #include @@ -105,4 +107,13 @@ class KNoteEditDlg : public KDialogBase, QVBoxLayout *layout = new QVBoxLayout( page ); + QHBoxLayout *hbl = new QHBoxLayout( layout ); + QLabel *label = new QLabel( page); + label->setText( i18n( "Name:" ) ); + hbl->addWidget( label,0 ); + mTitleEdit= new KLineEdit( page, "name" ); + hbl->addWidget( mTitleEdit, 1,Qt::AlignVCenter ); + +// layout->addLayout( hbl); + mNoteEdit = new KNoteEdit( actionCollection(), page ); mNoteEdit->setFocus(); @@ -128,5 +139,16 @@ class KNoteEditDlg : public KDialogBase, } + QString title() const + { + return mTitleEdit->text(); + } + + void setTitle( const QString& text ) + { + mTitleEdit->setText( text ); + } + private: + KLineEdit *mTitleEdit; KNoteEdit *mNoteEdit; KToolBar *mTool;