00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <tqlabel.h>
00022 #include <tqdrawutil.h>
00023 #include <tqsize.h>
00024 #include <tqsizegrip.h>
00025 #include <tqbitmap.h>
00026 #include <tqcursor.h>
00027 #include <tqpainter.h>
00028 #include <tqpaintdevicemetrics.h>
00029 #include <tqsimplerichtext.h>
00030 #include <tqobjectlist.h>
00031 #include <tqfile.h>
00032 #include <tqcheckbox.h>
00033 #include <tqtimer.h>
00034
00035 #include <kapplication.h>
00036 #include <kdebug.h>
00037 #include <kaction.h>
00038 #include <kstdaction.h>
00039 #include <kcombobox.h>
00040 #include <ktoolbar.h>
00041 #include <kpopupmenu.h>
00042 #include <kxmlguibuilder.h>
00043 #include <kxmlguifactory.h>
00044 #include <kcolordrag.h>
00045 #include <kiconeffect.h>
00046 #include <klocale.h>
00047 #include <kstandarddirs.h>
00048 #include <kmessagebox.h>
00049 #include <kfind.h>
00050 #include <kprocess.h>
00051 #include <kinputdialog.h>
00052 #include <kmdcodec.h>
00053 #include <kglobalsettings.h>
00054 #include <kfiledialog.h>
00055 #include <kio/netaccess.h>
00056
00057 #include <libkcal/journal.h>
00058
00059 #include "knote.h"
00060 #include "knotebutton.h"
00061 #include "knoteedit.h"
00062 #include "knoteconfig.h"
00063 #include "knotesglobalconfig.h"
00064 #include "knoteconfigdlg.h"
00065 #include "knotealarmdlg.h"
00066 #include "knotehostdlg.h"
00067 #include "knotesnetsend.h"
00068 #include "knoteprinter.h"
00069 #include "version.h"
00070
00071 #include "pushpin.xpm"
00072
00073 #include <kwin.h>
00074 #include <netwm.h>
00075
00076 #include <fixx11h.h>
00077
00078 using namespace KCal;
00079
00080 extern Time qt_x_time;
00081
00082 int KNote::s_ppOffset = 0;
00083
00084 KNote::KNote( TQDomDocument buildDoc, Journal *j, TQWidget *parent, const char *name )
00085 : TQFrame( parent, name, WStyle_Customize | WStyle_NoBorder | WDestructiveClose ),
00086 m_label( 0 ), m_pushpin( 0 ), m_fold( 0 ), m_button( 0 ), m_tool( 0 ), m_editor( 0 ),
00087 m_config( 0 ), m_journal( j ), m_find( 0 ),
00088 m_kwinConf( KSharedConfig::openConfig( "kwinrc", true ) ),
00089 m_busy( 0 ), m_deleteWhenIdle( false ), m_blockEmitDataChanged( false )
00090 {
00091 setAcceptDrops( true );
00092 actionCollection()->setWidget( this );
00093
00094 setDOMDocument( buildDoc );
00095
00096
00097 setXMLFile( instance()->instanceName() + "ui.rc", false, false );
00098
00099
00100
00101 if ( m_journal->summary().isNull() && m_journal->dtStart().isValid() )
00102 {
00103 TQString s = KGlobal::locale()->formatDateTime( m_journal->dtStart() );
00104 m_journal->setSummary( s );
00105 }
00106
00107
00108
00109 new KAction( i18n("New"), "filenew", 0,
00110 this,TQT_SLOT(slotRequestNewNote()) , actionCollection(), "new_note" );
00111 new KAction( i18n("Rename..."), "text", 0,
00112 this, TQT_SLOT(slotRename()), actionCollection(), "rename_note" );
00113 m_readOnly = new KToggleAction( i18n("Lock"), "lock" , 0,
00114 this, TQT_SLOT(slotUpdateReadOnly()), actionCollection(), "lock_note" );
00115 m_readOnly->setCheckedState( KGuiItem( i18n("Unlock"), "unlock" ) );
00116 new KAction( i18n("Hide"), "fileclose" , Key_Escape,
00117 this, TQT_SLOT(slotClose()), actionCollection(), "hide_note" );
00118 new KAction( i18n("Delete"), "knotes_delete", 0,
00119 this, TQT_SLOT(slotKill()), actionCollection(), "delete_note" );
00120
00121 new KAction( i18n("Insert Date"), "knotes_date", 0 ,
00122 this, TQT_SLOT(slotInsDate()), actionCollection(), "insert_date" );
00123 new KAction( i18n("Set Alarm..."), "knotes_alarm", 0 ,
00124 this, TQT_SLOT(slotSetAlarm()), actionCollection(), "set_alarm" );
00125
00126 new KAction( i18n("Send..."), "network", 0,
00127 this, TQT_SLOT(slotSend()), actionCollection(), "send_note" );
00128 new KAction( i18n("Mail..."), "mail_send", 0,
00129 this, TQT_SLOT(slotMail()), actionCollection(), "mail_note" );
00130 new KAction( i18n("Save As..."), "filesaveas", 0,
00131 this, TQT_SLOT(slotSaveAs()), actionCollection(), "save_note" );
00132 KStdAction::print( this, TQT_SLOT(slotPrint()), actionCollection(), "print_note" );
00133 new KAction( i18n("Preferences..."), "configure", 0,
00134 this, TQT_SLOT(slotPreferences()), actionCollection(), "configure_note" );
00135
00136 m_keepAbove = new KToggleAction( i18n("Keep Above Others"), "up", 0,
00137 this, TQT_SLOT(slotUpdateKeepAboveBelow()), actionCollection(), "keep_above" );
00138 m_keepAbove->setExclusiveGroup( "keepAB" );
00139
00140 m_keepBelow = new KToggleAction( i18n("Keep Below Others"), "down", 0,
00141 this, TQT_SLOT(slotUpdateKeepAboveBelow()), actionCollection(), "keep_below" );
00142 m_keepBelow->setExclusiveGroup( "keepAB" );
00143
00144 m_toDesktop = new KListAction( i18n("To Desktop"), 0,
00145 this, TQT_SLOT(slotPopupActionToDesktop(int)), actionCollection(), "to_desktop" );
00146 connect( m_toDesktop->popupMenu(), TQT_SIGNAL(aboutToShow()), this, TQT_SLOT(slotUpdateDesktopActions()) );
00147
00148
00149 new KAction( i18n("Walk Through Notes"), 0, SHIFT+Key_BackTab,
00150 this, TQT_SIGNAL(sigShowNextNote()), actionCollection(), "walk_notes" );
00151
00152
00153 m_label = new TQLabel( this );
00154 m_label->setFrameStyle( NoFrame );
00155 m_label->setLineWidth( 0 );
00156 m_label->installEventFilter( this );
00157 setName( m_journal->summary() );
00158
00159 m_button = new KNoteButton( "knotes_close", this );
00160 connect( m_button, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotClose()) );
00161
00162
00163 m_editor = new KNoteEdit( actionCollection(), this );
00164 m_editor->setNote( this );
00165 m_editor->installEventFilter( this );
00166 m_editor->viewport()->installEventFilter( this );
00167 connect( m_editor, TQT_SIGNAL(contentsMoving( int, int )), this, TQT_SLOT(slotUpdateViewport( int, int )));
00168
00169 KXMLGUIBuilder builder( this );
00170 KXMLGUIFactory factory( &builder, this );
00171 factory.addClient( this );
00172
00173 m_menu = dynamic_cast<KPopupMenu*>(factory.container( "note_context", this ));
00174 m_edit_menu = dynamic_cast<KPopupMenu*>(factory.container( "note_edit", this ));
00175 m_tool = dynamic_cast<KToolBar*>(factory.container( "note_tool", this ));
00176
00177 if ( m_tool ) {
00178 m_tool->setIconSize( 10 );
00179 m_tool->setFixedHeight( 16 );
00180 m_tool->setIconText( KToolBar::IconOnly );
00181
00182
00183 TQObjectList *list = m_tool->queryList( "KComboBox" );
00184 TQObjectListIt it( *list );
00185 while ( it.current() != 0 )
00186 {
00187 KComboBox *combo = (KComboBox *)it.current();
00188 TQFont font = combo->font();
00189 font.setPointSize( 7 );
00190 combo->setFont( font );
00191 combo->setFixedHeight( 14 );
00192 ++it;
00193 }
00194 delete list;
00195
00196 m_tool->hide();
00197 }
00198
00199 setFocusProxy( m_editor );
00200
00201
00202 m_editor->setCornerWidget( new TQSizeGrip( this ) );
00203 uint width = m_editor->cornerWidget()->width();
00204 uint height = m_editor->cornerWidget()->height();
00205 TQBitmap mask;
00206 mask.resize( width, height );
00207 mask.fill( color0 );
00208 TQPointArray array;
00209 array.setPoints( 3, 0, height, width, height, width, 0 );
00210 TQPainter p;
00211 p.begin( &mask );
00212 p.setBrush( color1 );
00213 p.drawPolygon( array );
00214 p.end();
00215 m_editor->cornerWidget()->setMask( mask );
00216 m_editor->cornerWidget()->setBackgroundMode( PaletteBase );
00217
00218
00219 TQString configFile = KGlobal::dirs()->saveLocation( "appdata", "notes/" );
00220 configFile += m_journal->uid();
00221
00222
00223
00224 bool newNote = !KIO::NetAccess::exists( KURL::fromPathOrURL( configFile ), false, 0 );
00225
00226 m_config = new KNoteConfig( KSharedConfig::openConfig( configFile, false, false ) );
00227 m_config->readConfig();
00228 m_config->setVersion( KNOTES_VERSION );
00229
00230 if ( newNote )
00231 {
00232
00233 KNotesGlobalConfig *globalConfig = KNotesGlobalConfig::self();
00234 m_config->setBgColor( globalConfig->bgColor() );
00235 m_config->setFgColor( globalConfig->fgColor() );
00236 m_config->setWidth( globalConfig->width() );
00237 m_config->setHeight( globalConfig->height() );
00238
00239 m_config->setFont( globalConfig->font() );
00240 m_config->setTitleFont( globalConfig->titleFont() );
00241 m_config->setAutoIndent( globalConfig->autoIndent() );
00242 m_config->setRichText( globalConfig->richText() );
00243 m_config->setTabSize( globalConfig->tabSize() );
00244 m_config->setReadOnly( globalConfig->readOnly() );
00245
00246 m_config->setDesktop( globalConfig->desktop() );
00247 m_config->setHideNote( globalConfig->hideNote() );
00248 m_config->setPosition( globalConfig->position() );
00249 m_config->setShowInTaskbar( globalConfig->showInTaskbar() );
00250 m_config->setKeepAbove( globalConfig->keepAbove() );
00251 m_config->setKeepBelow( globalConfig->keepBelow() );
00252
00253 m_config->writeConfig();
00254 }
00255
00256
00257 setMinimumSize( 20, 20 );
00258 setLineWidth( 1 );
00259 setMargin( 0 );
00260
00261 m_editor->setMargin( 0 );
00262 m_editor->setFrameStyle( NoFrame );
00263 m_editor->setBackgroundOrigin( WindowOrigin );
00264
00265
00266 bool closeLeft = false;
00267 m_kwinConf->setGroup( "Style" );
00268 if ( m_kwinConf->readBoolEntry( "CustomButtonPositions" ) )
00269 closeLeft = m_kwinConf->readEntry( "ButtonsOnLeft" ).find( 'X' ) > -1;
00270
00271 TQPixmap pushpin_pix;
00272 if ( closeLeft )
00273 pushpin_pix = TQPixmap( TQPixmap( pushpin_xpm ).convertToImage().mirror( true, false ) );
00274 else
00275 pushpin_pix = TQPixmap( pushpin_xpm );
00276
00277
00278 m_pushpin = new TQLabel( this );
00279 m_pushpin->setScaledContents( true );
00280 m_pushpin->setBackgroundMode( NoBackground );
00281 m_pushpin->setPixmap( pushpin_pix );
00282 m_pushpin->resize( pushpin_pix.size() );
00283
00284
00285 m_fold = new TQLabel( this );
00286 m_fold->setScaledContents( true );
00287 m_fold->setBackgroundMode( NoBackground );
00288
00289
00290 width = m_config->width();
00291 height = m_config->height();
00292 resize( width, height );
00293
00294
00295
00296 const TQPoint& position = m_config->position();
00297 TQRect desk = kapp->desktop()->rect();
00298 desk.addCoords( 10, 10, -10, -10 );
00299 if ( desk.intersects( TQRect( position, TQSize( width, height ) ) ) )
00300 move( position );
00301
00302
00303 TQString property = m_journal->customProperty( "KNotes", "FgColor" );
00304 if ( !property.isNull() )
00305 m_config->setFgColor( TQColor( property ) );
00306 else
00307 m_journal->setCustomProperty( "KNotes", "FgColor", m_config->fgColor().name() );
00308
00309 property = m_journal->customProperty( "KNotes", "BgColor" );
00310 if ( !property.isNull() )
00311 m_config->setBgColor( TQColor( property ) );
00312 else
00313 m_journal->setCustomProperty( "KNotes", "BgColor", m_config->bgColor().name() );
00314
00315 property = m_journal->customProperty( "KNotes", "RichText" );
00316 if ( !property.isNull() )
00317 m_config->setRichText( property == "true" ? true : false );
00318 else
00319 m_journal->setCustomProperty( "KNotes", "RichText", m_config->richText() ? "true" : "false" );
00320
00321
00322 slotApplyConfig();
00323
00324
00325
00326 m_fold->setMask( TQRegion( m_fold->pixmap()->createHeuristicMask() ) );
00327
00328
00329
00330 int desktop = m_config->desktop();
00331 if ( desktop < 0 && desktop != NETWinInfo::OnAllDesktops )
00332 desktop = KWin::currentDesktop();
00333
00334
00335 if ( desktop != 0 && !m_config->hideNote() )
00336 {
00337
00338 toDesktop( desktop );
00339 show();
00340
00341
00342 if ( desktop == NETWinInfo::OnAllDesktops )
00343 toDesktop( desktop );
00344 }
00345
00346 m_editor->setText( m_journal->description() );
00347 m_editor->setModified( false );
00348
00349 m_readOnly->setChecked( m_config->readOnly() );
00350 slotUpdateReadOnly();
00351
00352 if ( m_config->keepAbove() )
00353 m_keepAbove->setChecked( true );
00354 else if ( m_config->keepBelow() )
00355 m_keepBelow->setChecked( true );
00356 else
00357 {
00358 m_keepAbove->setChecked( false );
00359 m_keepBelow->setChecked( false );
00360 }
00361 slotUpdateKeepAboveBelow();
00362
00363
00364 KIconEffect effect;
00365 TQPixmap icon = effect.apply( kapp->icon(), KIconEffect::Colorize, 1, m_config->bgColor(), false );
00366 TQPixmap miniIcon = effect.apply( kapp->miniIcon(), KIconEffect::Colorize, 1, m_config->bgColor(), false );
00367 KWin::setIcons( winId(), icon, miniIcon );
00368 }
00369
00370 KNote::~KNote()
00371 {
00372 delete m_config;
00373 }
00374
00375 void KNote::slotRequestNewNote()
00376 {
00377
00378 saveConfig();
00379 saveData();
00380 emit sigRequestNewNote();
00381 }
00382
00383 void KNote::changeJournal(KCal::Journal *journal)
00384 {
00385 m_journal = journal;
00386 m_editor->setText( m_journal->description() );
00387 m_label->setText( m_journal->summary() );
00388 updateLabelAlignment();
00389 }
00390
00391
00392
00393 void KNote::slotKill( bool force )
00394 {
00395 m_blockEmitDataChanged = true;
00396 if ( !force &&
00397 KMessageBox::warningContinueCancel( this,
00398 i18n("<qt>Do you really want to delete note <b>%1</b>?</qt>").arg( m_label->text() ),
00399 i18n("Confirm Delete"), KGuiItem( i18n("&Delete"), "editdelete" ),
00400 "ConfirmDeleteNote"
00401 )
00402 != KMessageBox::Continue )
00403 {
00404 m_blockEmitDataChanged = false;
00405 return;
00406 }
00407 aboutToEnterEventLoop();
00408
00409 delete m_config;
00410 m_config = 0;
00411
00412 TQString configFile = KGlobal::dirs()->saveLocation( "appdata", "notes/" );
00413 configFile += m_journal->uid();
00414
00415 if ( !KIO::NetAccess::del( KURL::fromPathOrURL( configFile ), this ) )
00416 kdError(5500) << "Can't remove the note config: " << configFile << endl;
00417
00418 emit sigKillNote( m_journal );
00419 eventLoopLeft();
00420
00421 }
00422
00423
00424
00425
00426 void KNote::saveData(bool update)
00427 {
00428 m_journal->setSummary( m_label->text() );
00429 m_journal->setDescription( m_editor->text() );
00430 m_journal->setCustomProperty( "KNotes", "FgColor", m_config->fgColor().name() );
00431 m_journal->setCustomProperty( "KNotes", "BgColor", m_config->bgColor().name() );
00432 m_journal->setCustomProperty( "KNotes", "RichText", m_config->richText() ? "true" : "false" );
00433 if(update) {
00434 emit sigDataChanged( noteId() );
00435 m_editor->setModified( false );
00436 }
00437 }
00438
00439 void KNote::saveConfig() const
00440 {
00441 m_config->setWidth( width() );
00442 if ( m_tool )
00443 m_config->setHeight( height() - (m_tool->isHidden() ? 0 : m_tool->height()) );
00444 else
00445 m_config->setHeight( 0 );
00446 m_config->setPosition( pos() );
00447
00448 NETWinInfo wm_client( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
00449 if ( wm_client.desktop() == NETWinInfo::OnAllDesktops || wm_client.desktop() > 0 )
00450 m_config->setDesktop( wm_client.desktop() );
00451
00452
00453 m_config->writeConfig();
00454 }
00455
00456 TQString KNote::noteId() const
00457 {
00458 return m_journal->uid();
00459 }
00460
00461 TQString KNote::name() const
00462 {
00463 return m_label->text();
00464 }
00465
00466 TQString KNote::text() const
00467 {
00468 return m_editor->text();
00469 }
00470
00471 TQString KNote::plainText() const
00472 {
00473 if ( m_editor->textFormat() == RichText )
00474 {
00475 TQTextEdit conv;
00476 conv.setTextFormat( RichText );
00477 conv.setText( m_editor->text() );
00478 conv.setTextFormat( PlainText );
00479 return conv.text();
00480 }
00481 else
00482 return m_editor->text();
00483 }
00484
00485 void KNote::setName( const TQString& name )
00486 {
00487 m_label->setText( name );
00488 updateLabelAlignment();
00489
00490 if ( m_editor )
00491 saveData();
00492
00493
00494 NETWinInfo note_win( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
00495 note_win.setName( name.utf8() );
00496
00497 emit sigNameChanged();
00498 }
00499
00500 void KNote::setText( const TQString& text )
00501 {
00502 m_editor->setText( text );
00503 saveData();
00504 }
00505
00506 TQColor KNote::fgColor() const
00507 {
00508 return m_config->fgColor();
00509 }
00510
00511 TQColor KNote::bgColor() const
00512 {
00513 return m_config->bgColor();
00514 }
00515
00516 void KNote::setColor( const TQColor& fg, const TQColor& bg )
00517 {
00518 m_journal->setCustomProperty( "KNotes", "FgColor", fg.name() );
00519 m_journal->setCustomProperty( "KNotes", "BgColor", bg.name() );
00520 m_config->setFgColor( fg );
00521 m_config->setBgColor( bg );
00522
00523 m_journal->updated();
00524 emit sigDataChanged(noteId());
00525 m_config->writeConfig();
00526
00527 TQPalette newpalette = palette();
00528 newpalette.setColor( TQColorGroup::Background, bg );
00529 newpalette.setColor( TQColorGroup::Foreground, fg );
00530 newpalette.setColor( TQColorGroup::Base, bg );
00531 newpalette.setColor( TQColorGroup::Text, fg );
00532 newpalette.setColor( TQColorGroup::Button, bg );
00533 newpalette.setColor( TQColorGroup::ButtonText, fg );
00534
00535
00536
00537
00538
00539 newpalette.setColor( TQColorGroup::Midlight, bg.light(150) );
00540 newpalette.setColor( TQColorGroup::Shadow, bg.dark(116) );
00541 newpalette.setColor( TQColorGroup::Light, bg.light(180) );
00542 if ( s_ppOffset )
00543 newpalette.setColor( TQColorGroup::Dark, bg.dark(200) );
00544 else
00545 newpalette.setColor( TQColorGroup::Dark, bg.dark(108) );
00546 setPalette( newpalette );
00547
00548
00549 m_editor->setTextColor( fg );
00550
00551
00552 updateBackground();
00553
00554
00555 TQPalette darker = palette();
00556 darker.setColor( TQColorGroup::Button, bg.dark(116) );
00557 m_button->setPalette( darker );
00558
00559
00560 KIconEffect effect;
00561 TQPixmap icon = effect.apply( kapp->icon(), KIconEffect::Colorize, 1, bg, false );
00562 TQPixmap miniIcon = effect.apply( kapp->miniIcon(), KIconEffect::Colorize, 1, bg, false );
00563 KWin::setIcons( winId(), icon, miniIcon );
00564
00565
00566 TQColor sel = palette().color( TQPalette::Active, TQColorGroup::Base ).dark();
00567 if ( sel == Qt::black )
00568 sel = palette().color( TQPalette::Active, TQColorGroup::Base ).light();
00569
00570 m_editor->setSelectionAttributes( 1, sel, true );
00571
00572
00573 createFold();
00574
00575
00576 updateFocus();
00577 emit sigColorChanged();
00578 }
00579
00580 void KNote::find( const TQString& pattern, long options )
00581 {
00582 delete m_find;
00583 m_find = new KFind( pattern, options, this );
00584
00585 connect( m_find, TQT_SIGNAL(highlight( const TQString &, int, int )),
00586 this, TQT_SLOT(slotHighlight( const TQString &, int, int )) );
00587 connect( m_find, TQT_SIGNAL(findNext()), this, TQT_SLOT(slotFindNext()) );
00588
00589 m_find->setData( plainText() );
00590 slotFindNext();
00591 }
00592
00593 void KNote::slotFindNext()
00594 {
00595
00596
00597
00598
00599 KFind::Result res = m_find->find();
00600
00601 if ( res == KFind::NoMatch )
00602 {
00603 m_editor->removeSelection( 1 );
00604 emit sigFindFinished();
00605 delete m_find;
00606 m_find = 0;
00607 }
00608 else
00609 {
00610 show();
00611 KWin::setCurrentDesktop( KWin::windowInfo( winId() ).desktop() );
00612 }
00613 }
00614
00615 void KNote::slotHighlight( const TQString& str, int idx, int len )
00616 {
00617 int paraFrom = 0, idxFrom = 0, p = 0;
00618 for ( ; p < idx; ++p )
00619 if ( str[p] == '\n' )
00620 {
00621 ++paraFrom;
00622 idxFrom = 0;
00623 }
00624 else
00625 ++idxFrom;
00626
00627 int paraTo = paraFrom, idxTo = idxFrom;
00628
00629 for ( ; p < idx + len; ++p )
00630 {
00631 if ( str[p] == '\n' )
00632 {
00633 ++paraTo;
00634 idxTo = 0;
00635 }
00636 else
00637 ++idxTo;
00638 }
00639
00640 m_editor->setSelection( paraFrom, idxFrom, paraTo, idxTo, 1 );
00641 }
00642
00643 bool KNote::isModified() const
00644 {
00645 return m_editor->isModified();
00646 }
00647
00648
00649 void KNote::sync( const TQString& app )
00650 {
00651 TQByteArray sep( 1 );
00652 sep[0] = '\0';
00653
00654 KMD5 hash;
00655 TQCString result;
00656
00657 hash.update( m_label->text().utf8() );
00658 hash.update( sep );
00659 hash.update( m_editor->text().utf8() );
00660 hash.hexDigest( result );
00661
00662
00663 KConfig *config = m_config->config();
00664 config->setGroup( "Synchronisation" );
00665 config->writeEntry( app, result.data() );
00666 }
00667
00668 bool KNote::isNew( const TQString& app ) const
00669 {
00670 KConfig *config = m_config->config();
00671 config->setGroup( "Synchronisation" );
00672 TQString hash = config->readEntry( app );
00673 return hash.isEmpty();
00674 }
00675
00676 bool KNote::isModified( const TQString& app ) const
00677 {
00678 TQByteArray sep( 1 );
00679 sep[0] = '\0';
00680
00681 KMD5 hash;
00682 hash.update( m_label->text().utf8() );
00683 hash.update( sep );
00684 hash.update( m_editor->text().utf8() );
00685 hash.hexDigest();
00686
00687 KConfig *config = m_config->config();
00688 config->setGroup( "Synchronisation" );
00689 TQString orig = config->readEntry( app );
00690
00691 if ( hash.verify( orig.utf8() ) )
00692 return false;
00693 else
00694 return true;
00695 }
00696
00697 void KNote::setStyle( int style )
00698 {
00699 if ( style == KNotesGlobalConfig::EnumStyle::Plain )
00700 s_ppOffset = 0;
00701 else
00702 s_ppOffset = 12;
00703 }
00704
00705
00706
00707
00708 void KNote::slotRename()
00709 {
00710 m_blockEmitDataChanged = true;
00711
00712 bool ok;
00713 aboutToEnterEventLoop();
00714 TQString oldName = m_label->text();
00715 TQString newName = KInputDialog::getText( TQString::null,
00716 i18n("Please enter the new name:"), m_label->text(), &ok, this );
00717 eventLoopLeft();
00718 m_blockEmitDataChanged = false;
00719 if ( !ok || ( oldName == newName) )
00720 return;
00721
00722 setName( newName );
00723 }
00724
00725 void KNote::slotUpdateReadOnly()
00726 {
00727 const bool readOnly = m_readOnly->isChecked();
00728
00729 m_editor->setReadOnly( readOnly );
00730 m_config->setReadOnly( readOnly );
00731
00732
00733 actionCollection()->action( "configure_note" )->setEnabled( !readOnly );
00734 actionCollection()->action( "insert_date" )->setEnabled( !readOnly );
00735 actionCollection()->action( "delete_note" )->setEnabled( !readOnly );
00736
00737 actionCollection()->action( "edit_undo" )->setEnabled( !readOnly && m_editor->isUndoAvailable() );
00738 actionCollection()->action( "edit_redo" )->setEnabled( !readOnly && m_editor->isRedoAvailable() );
00739 actionCollection()->action( "edit_cut" )->setEnabled( !readOnly && m_editor->hasSelectedText() );
00740 actionCollection()->action( "edit_paste" )->setEnabled( !readOnly );
00741 actionCollection()->action( "edit_clear" )->setEnabled( !readOnly );
00742 actionCollection()->action( "rename_note" )->setEnabled( !readOnly );
00743
00744 actionCollection()->action( "format_bold" )->setEnabled( !readOnly );
00745 actionCollection()->action( "format_italic" )->setEnabled( !readOnly );
00746 actionCollection()->action( "format_underline" )->setEnabled( !readOnly );
00747 actionCollection()->action( "format_strikeout" )->setEnabled( !readOnly );
00748 actionCollection()->action( "format_alignleft" )->setEnabled( !readOnly );
00749 actionCollection()->action( "format_aligncenter" )->setEnabled( !readOnly );
00750 actionCollection()->action( "format_alignright" )->setEnabled( !readOnly );
00751 actionCollection()->action( "format_alignblock" )->setEnabled( !readOnly );
00752 actionCollection()->action( "format_list" )->setEnabled( !readOnly );
00753 actionCollection()->action( "format_super" )->setEnabled( !readOnly );
00754 actionCollection()->action( "format_sub" )->setEnabled( !readOnly );
00755 actionCollection()->action( "format_size" )->setEnabled( !readOnly );
00756 actionCollection()->action( "format_color" )->setEnabled( !readOnly );
00757
00758 updateFocus();
00759 }
00760
00761 void KNote::slotClose()
00762 {
00763 NETWinInfo wm_client( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
00764 if ( wm_client.desktop() == NETWinInfo::OnAllDesktops || wm_client.desktop() > 0 )
00765 m_config->setDesktop( wm_client.desktop() );
00766
00767 m_editor->clearFocus();
00768 m_config->setHideNote( true );
00769 m_config->setPosition( pos() );
00770 m_config->writeConfig();
00771
00772 hide();
00773 }
00774
00775 void KNote::slotInsDate()
00776 {
00777 m_editor->insert( KGlobal::locale()->formatDateTime(TQDateTime::currentDateTime()) );
00778 }
00779
00780 void KNote::slotSetAlarm()
00781 {
00782 m_blockEmitDataChanged = true;
00783 KNoteAlarmDlg dlg( name(), this );
00784 dlg.setIncidence( m_journal );
00785
00786 aboutToEnterEventLoop();
00787 if ( dlg.exec() == TQDialog::Accepted )
00788 emit sigDataChanged(noteId());
00789 eventLoopLeft();
00790 m_blockEmitDataChanged = false;
00791 }
00792
00793 void KNote::slotPreferences()
00794 {
00795
00796 if ( KNoteConfigDlg::showDialog( noteId().utf8() ) )
00797 return;
00798
00799
00800 KNoteConfigDlg *dialog = new KNoteConfigDlg( m_config, name(), this, noteId().utf8() );
00801 connect( dialog, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(slotApplyConfig()) );
00802 connect( this, TQT_SIGNAL(sigNameChanged()), dialog, TQT_SLOT(slotUpdateCaption()) );
00803 dialog->show();
00804 }
00805
00806 void KNote::slotSend()
00807 {
00808
00809 KNoteHostDlg hostDlg( i18n("Send \"%1\"").arg( name() ), this );
00810 aboutToEnterEventLoop();
00811 bool ok = (hostDlg.exec() == TQDialog::Accepted);
00812 eventLoopLeft();
00813 if ( !ok )
00814 return;
00815 TQString host = hostDlg.host();
00816
00817 if ( host.isEmpty() )
00818 {
00819 KMessageBox::sorry( this, i18n("The host cannot be empty.") );
00820 return;
00821 }
00822
00823
00824 KNotesNetworkSender *sender = new KNotesNetworkSender( host, KNotesGlobalConfig::port() );
00825 sender->setSenderId( KNotesGlobalConfig::senderID() );
00826 sender->setNote( name(), text() );
00827 sender->connect();
00828 }
00829
00830 void KNote::slotMail()
00831 {
00832
00833 const TQStringList cmd_list = TQStringList::split( TQChar(' '), KNotesGlobalConfig::mailAction() );
00834
00835 KProcess mail;
00836 for ( TQStringList::ConstIterator it = cmd_list.constBegin();
00837 it != cmd_list.constEnd(); ++it )
00838 {
00839 if ( *it == "%f" )
00840 mail << plainText().local8Bit();
00841 else if ( *it == "%t" )
00842 mail << m_label->text().local8Bit();
00843 else
00844 mail << (*it).local8Bit();
00845 }
00846
00847 if ( !mail.start( KProcess::DontCare ) )
00848 KMessageBox::sorry( this, i18n("Unable to start the mail process.") );
00849 }
00850
00851 void KNote::slotPrint()
00852 {
00853 TQString content;
00854 if ( m_editor->textFormat() == PlainText )
00855 content = TQStyleSheet::convertFromPlainText( m_editor->text() );
00856 else
00857 content = m_editor->text();
00858
00859 KNotePrinter printer;
00860 printer.setMimeSourceFactory( m_editor->mimeSourceFactory() );
00861 printer.setFont( m_config->font() );
00862 printer.setContext( m_editor->context() );
00863 printer.setStyleSheet( m_editor->styleSheet() );
00864 printer.setColorGroup( colorGroup() );
00865 printer.printNote( TQString(), content );
00866 }
00867
00868 void KNote::slotSaveAs()
00869 {
00870 m_blockEmitDataChanged = true;
00871 TQCheckBox *convert = 0;
00872
00873 if ( m_editor->textFormat() == RichText )
00874 {
00875 convert = new TQCheckBox( 0 );
00876 convert->setText( i18n("Save note as plain text") );
00877 }
00878
00879 KFileDialog dlg( TQString::null, TQString::null, this, "filedialog", true, convert );
00880 dlg.setOperationMode( KFileDialog::Saving );
00881 dlg.setCaption( i18n("Save As") );
00882 aboutToEnterEventLoop();
00883 dlg.exec();
00884 eventLoopLeft();
00885
00886 TQString fileName = dlg.selectedFile();
00887 if ( fileName.isEmpty() )
00888 {
00889 m_blockEmitDataChanged = false;
00890 return;
00891 }
00892 TQFile file( fileName );
00893
00894 if ( file.exists() &&
00895 KMessageBox::warningContinueCancel( this, i18n("<qt>A file named <b>%1</b> already exists.<br>"
00896 "Are you sure you want to overwrite it?</qt>").arg( TQFileInfo(file).fileName() ) )
00897 != KMessageBox::Continue )
00898 {
00899 m_blockEmitDataChanged = false;
00900 return;
00901 }
00902
00903 if ( file.open( IO_WriteOnly ) )
00904 {
00905 TQTextStream stream( &file );
00906
00907 if ( convert && convert->isChecked() )
00908 stream << plainText();
00909 else
00910 stream << text();
00911 }
00912 m_blockEmitDataChanged = false;
00913 }
00914
00915 void KNote::slotPopupActionToDesktop( int id )
00916 {
00917 toDesktop( id - 1 );
00918 }
00919
00920
00921
00922
00923 void KNote::slotApplyConfig()
00924 {
00925 if ( m_config->richText() )
00926 m_editor->setTextFormat( RichText );
00927 else
00928 m_editor->setTextFormat( PlainText );
00929
00930 m_label->setFont( m_config->titleFont() );
00931 m_editor->setTextFont( m_config->font() );
00932 m_editor->setTabStop( m_config->tabSize() );
00933 m_editor->setAutoIndentMode( m_config->autoIndent() );
00934
00935
00936
00937 if ( sender() )
00938 saveData();
00939
00940 setColor( m_config->fgColor(), m_config->bgColor() );
00941
00942 updateLabelAlignment();
00943 slotUpdateShowInTaskbar();
00944 }
00945
00946 void KNote::slotUpdateKeepAboveBelow()
00947 {
00948 KWin::WindowInfo info( KWin::windowInfo( winId() ) );
00949
00950 if ( m_keepAbove->isChecked() )
00951 {
00952 m_config->setKeepAbove( true );
00953 m_config->setKeepBelow( false );
00954 KWin::setState( winId(), info.state() | NET::KeepAbove );
00955 }
00956 else if ( m_keepBelow->isChecked() )
00957 {
00958 m_config->setKeepAbove( false );
00959 m_config->setKeepBelow( true );
00960 KWin::setState( winId(), info.state() | NET::KeepBelow );
00961 }
00962 else
00963 {
00964 m_config->setKeepAbove( false );
00965 KWin::clearState( winId(), NET::KeepAbove );
00966
00967 m_config->setKeepBelow( false );
00968 KWin::clearState( winId(), NET::KeepBelow );
00969 }
00970 }
00971
00972 void KNote::slotUpdateShowInTaskbar()
00973 {
00974 if ( !m_config->showInTaskbar() )
00975 KWin::setState( winId(), KWin::windowInfo(winId()).state() | NET::SkipTaskbar );
00976 else
00977 KWin::clearState( winId(), NET::SkipTaskbar );
00978 }
00979
00980 void KNote::slotUpdateDesktopActions()
00981 {
00982 NETRootInfo wm_root( qt_xdisplay(), NET::NumberOfDesktops | NET::DesktopNames );
00983 NETWinInfo wm_client( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMDesktop );
00984
00985 TQStringList desktops;
00986 desktops.append( i18n("&All Desktops") );
00987 desktops.append( TQString::null );
00988
00989 int count = wm_root.numberOfDesktops();
00990 for ( int n = 1; n <= count; n++ )
00991 desktops.append( TQString("&%1 %2").arg( n ).arg( TQString::fromUtf8(wm_root.desktopName( n )) ) );
00992
00993 m_toDesktop->setItems( desktops );
00994
00995 if ( wm_client.desktop() == NETWinInfo::OnAllDesktops )
00996 m_toDesktop->setCurrentItem( 0 );
00997 else
00998 m_toDesktop->setCurrentItem( wm_client.desktop() + 1 );
00999 }
01000
01001 void KNote::slotUpdateViewport( int , int y )
01002 {
01003 if ( s_ppOffset )
01004 updateBackground( y );
01005 }
01006
01007
01008
01009 void KNote::toDesktop( int desktop )
01010 {
01011 if ( desktop == 0 )
01012 return;
01013
01014 if ( desktop == NETWinInfo::OnAllDesktops )
01015 KWin::setOnAllDesktops( winId(), true );
01016 else
01017 KWin::setOnDesktop( winId(), desktop );
01018 }
01019
01020 void KNote::createFold()
01021 {
01022 TQPixmap fold( 15, 15 );
01023 TQPainter foldp( &fold );
01024 foldp.setPen( Qt::NoPen );
01025 foldp.setBrush( palette().active().dark() );
01026 TQPointArray foldpoints( 3 );
01027 foldpoints.putPoints( 0, 3, 0, 0, 14, 0, 0, 14 );
01028 foldp.drawPolygon( foldpoints );
01029 foldp.end();
01030 m_fold->setPixmap( fold );
01031 }
01032
01033 void KNote::updateLabelAlignment()
01034 {
01035
01036 TQString labelText = m_label->text();
01037 if ( m_label->fontMetrics().boundingRect( labelText ).width() > m_label->width() )
01038 m_label->setAlignment( AlignLeft );
01039 else
01040 m_label->setAlignment( AlignHCenter );
01041 }
01042
01043 void KNote::updateFocus()
01044 {
01045 if ( hasFocus() )
01046 {
01047 m_label->setBackgroundColor( palette().active().shadow() );
01048 m_button->show();
01049
01050 if ( !m_editor->isReadOnly() )
01051 {
01052 if ( m_tool && m_tool->isHidden() && m_editor->textFormat() == TQTextEdit::RichText )
01053 {
01054 m_tool->show();
01055 m_editor->cornerWidget()->show();
01056 setGeometry( x(), y(), width(), height() + m_tool->height() );
01057 }
01058 }
01059 else if ( m_tool && !m_tool->isHidden() )
01060 {
01061 m_tool->hide();
01062 m_editor->cornerWidget()->hide();
01063 setGeometry( x(), y(), width(), height() - m_tool->height() );
01064 updateLayout();
01065 }
01066
01067 m_fold->hide();
01068 }
01069 else
01070 {
01071 m_button->hide();
01072 m_editor->cornerWidget()->hide();
01073
01074 if ( m_tool && !m_tool->isHidden() )
01075 {
01076 m_tool->hide();
01077 setGeometry( x(), y(), width(), height() - m_tool->height() );
01078 updateLayout();
01079 }
01080
01081 if ( s_ppOffset )
01082 {
01083 m_label->setBackgroundColor( palette().active().midlight() );
01084 m_fold->show();
01085 }
01086 else
01087 m_label->setBackgroundColor( palette().active().background() );
01088 }
01089 }
01090
01091 void KNote::updateMask()
01092 {
01093 if ( !s_ppOffset )
01094 {
01095 clearMask();
01096 return;
01097 }
01098
01099 int w = width();
01100 int h = height();
01101 TQRegion reg( 0, s_ppOffset, w, h - s_ppOffset );
01102
01103 const TQBitmap *pushpin_bitmap = m_pushpin->pixmap()->mask();
01104 TQRegion pushpin_reg( *pushpin_bitmap );
01105 m_pushpin->setMask( pushpin_reg );
01106 pushpin_reg.translate( m_pushpin->x(), m_pushpin->y() );
01107
01108 if ( !hasFocus() )
01109 {
01110 TQPointArray foldpoints( 3 );
01111 foldpoints.putPoints( 0, 3, w-15, h, w, h-15, w, h );
01112 TQRegion fold( foldpoints, false );
01113 setMask( reg.unite( pushpin_reg ).subtract( fold ) );
01114 }
01115 else
01116 setMask( reg.unite( pushpin_reg ) );
01117 }
01118
01119 void KNote::updateBackground( int y_offset )
01120 {
01121 if ( !s_ppOffset )
01122 {
01123 m_editor->setPaper( TQBrush( colorGroup().background() ) );
01124 return;
01125 }
01126
01127 int w = m_editor->visibleWidth();
01128 int h = m_editor->visibleHeight();
01129
01130
01131
01132
01133 if ( y_offset == -1 )
01134 y_offset = m_editor->contentsY();
01135
01136 y_offset = y_offset % h;
01137
01138 TQImage grad_img( w, h, 32 );
01139 QRgb rgbcol;
01140 TQColor bg = palette().active().background();
01141
01142 for ( int i = 0; i < h; ++i )
01143 {
01144
01145
01146
01147
01148
01149
01150
01151 int i_1 = 150 - 75 * ((i - y_offset + h) % h) / h;
01152 rgbcol = bg.light( i_1 ).rgb();
01153 for ( int j = 0; j < w; ++j )
01154 grad_img.setPixel( j, i, rgbcol );
01155 }
01156
01157
01158 m_editor->setPaper( TQBrush( Qt::black, TQPixmap( grad_img ) ) );
01159 }
01160
01161 void KNote::updateLayout()
01162 {
01163 const int headerHeight = m_label->sizeHint().height();
01164 const int margin = m_editor->margin();
01165 bool closeLeft = false;
01166
01167 m_kwinConf->setGroup( "Style" );
01168 if ( m_kwinConf->readBoolEntry( "CustomButtonPositions" ) )
01169 closeLeft = m_kwinConf->readEntry( "ButtonsOnLeft" ).find( 'X' ) > -1;
01170
01171 if ( s_ppOffset )
01172 {
01173 if ( !m_editor->paper().pixmap() )
01174 setColor( palette().active().foreground(), palette().active().background() );
01175
01176 m_pushpin->show();
01177 setFrameStyle( Panel | Raised );
01178
01179 if ( closeLeft )
01180 m_pushpin->move( width() - m_pushpin->width(), 0 );
01181 else
01182 m_pushpin->move( 0, 0 );
01183 }
01184 else
01185 {
01186 if ( m_editor->paper().pixmap() )
01187 setColor( palette().active().foreground(), palette().active().background() );
01188
01189 setFrameStyle( WinPanel | Raised );
01190 m_pushpin->hide();
01191 m_fold->hide();
01192 }
01193
01194 m_button->setGeometry(
01195 closeLeft ? contentsRect().x() : contentsRect().width() - headerHeight,
01196 contentsRect().y() + s_ppOffset,
01197 headerHeight,
01198 headerHeight
01199 );
01200
01201 m_label->setGeometry(
01202 contentsRect().x(), contentsRect().y() + s_ppOffset,
01203 contentsRect().width(), headerHeight
01204 );
01205
01206 m_editor->setGeometry( TQRect(
01207 TQPoint( contentsRect().x(),
01208 contentsRect().y() + headerHeight + s_ppOffset ),
01209 TQPoint( contentsRect().right(),
01210 contentsRect().bottom() - ( m_tool ? (m_tool->isHidden() ? 0 : m_tool->height()) : 0 ) )
01211 ) );
01212
01213 if( m_tool ) {
01214 m_tool->setGeometry(
01215 contentsRect().x(),
01216 contentsRect().bottom() - m_tool->height() + 1,
01217 contentsRect().width(),
01218 m_tool->height()
01219 );
01220 }
01221
01222 if ( s_ppOffset )
01223 m_fold->move( width() - 15, height() - 15 );
01224
01225 setMinimumSize(
01226 m_editor->cornerWidget()->width() + margin*2,
01227 headerHeight + s_ppOffset + ( m_tool ? (m_tool->isHidden() ? 0 : m_tool->height() ) : 0 ) +
01228 m_editor->cornerWidget()->height() + margin*2
01229 );
01230
01231 updateLabelAlignment();
01232 updateMask();
01233 updateBackground();
01234 }
01235
01236
01237
01238 void KNote::drawFrame( TQPainter *p )
01239 {
01240 TQRect r = frameRect();
01241 r.setTop( s_ppOffset );
01242 if ( s_ppOffset )
01243 qDrawShadePanel( p, r, colorGroup(), false, lineWidth() );
01244 else
01245 qDrawWinPanel( p, r, colorGroup(), false );
01246 }
01247
01248 void KNote::showEvent( TQShowEvent * )
01249 {
01250 if ( m_config->hideNote() )
01251 {
01252
01253 slotUpdateKeepAboveBelow();
01254 slotUpdateShowInTaskbar();
01255 toDesktop( m_config->desktop() );
01256 move( m_config->position() );
01257 m_config->setHideNote( false );
01258 }
01259 }
01260
01261 void KNote::resizeEvent( TQResizeEvent *qre )
01262 {
01263 TQFrame::resizeEvent( qre );
01264 updateLayout();
01265 }
01266
01267 void KNote::closeEvent( TQCloseEvent *event )
01268 {
01269 event->ignore();
01270 slotClose();
01271 }
01272
01273 void KNote::dragEnterEvent( TQDragEnterEvent *e )
01274 {
01275 if ( !m_config->readOnly() )
01276 e->accept( KColorDrag::canDecode( e ) );
01277 }
01278
01279 void KNote::dropEvent( TQDropEvent *e )
01280 {
01281 if ( m_config->readOnly() )
01282 return;
01283
01284 TQColor bg;
01285 if ( KColorDrag::decode( e, bg ) )
01286 setColor( paletteForegroundColor(), bg );
01287 }
01288
01289 bool KNote::focusNextPrevChild( bool )
01290 {
01291 return true;
01292 }
01293
01294 bool KNote::event( TQEvent *ev )
01295 {
01296 if ( ev->type() == TQEvent::LayoutHint )
01297 {
01298 updateLayout();
01299 return true;
01300 }
01301 else
01302 return TQFrame::event( ev );
01303 }
01304
01305 bool KNote::eventFilter( TQObject *o, TQEvent *ev )
01306 {
01307 if ( ev->type() == TQEvent::DragEnter &&
01308 KColorDrag::canDecode( static_cast<TQDragEnterEvent *>(ev) ) )
01309 {
01310 dragEnterEvent( static_cast<TQDragEnterEvent *>(ev) );
01311 return true;
01312 }
01313
01314 if ( ev->type() == TQEvent::Drop &&
01315 KColorDrag::canDecode( static_cast<TQDropEvent *>(ev) ) )
01316 {
01317 dropEvent( static_cast<TQDropEvent *>(ev) );
01318 return true;
01319 }
01320
01321 if ( o == m_label )
01322 {
01323 TQMouseEvent *e = (TQMouseEvent *)ev;
01324
01325 if ( ev->type() == TQEvent::MouseButtonDblClick )
01326 {
01327 if( !m_editor->isReadOnly())
01328 slotRename();
01329 }
01330 if ( ev->type() == TQEvent::MouseButtonPress &&
01331 (e->button() == LeftButton || e->button() == MidButton))
01332 {
01333 e->button() == LeftButton ? KWin::raiseWindow( winId() )
01334 : KWin::lowerWindow( winId() );
01335
01336 XUngrabPointer( qt_xdisplay(), qt_x_time );
01337 NETRootInfo wm_root( qt_xdisplay(), NET::WMMoveResize );
01338 wm_root.moveResizeRequest( winId(), e->globalX(), e->globalY(), NET::Move );
01339 return true;
01340 }
01341
01342 #if KDE_IS_VERSION( 3, 5, 1 )
01343 if ( ev->type() == TQEvent::MouseButtonRelease )
01344 {
01345 NETRootInfo wm_root( qt_xdisplay(), NET::WMMoveResize );
01346 wm_root.moveResizeRequest( winId(), e->globalX(), e->globalY(), NET::MoveResizeCancel );
01347 return false;
01348 }
01349 #endif
01350
01351 if ( m_menu && ( ev->type() == TQEvent::MouseButtonPress )
01352 && ( e->button() == RightButton ) )
01353 {
01354 m_menu->popup( TQCursor::pos() );
01355 return true;
01356 }
01357
01358 return false;
01359 }
01360
01361 if ( o == m_editor ) {
01362 if ( ev->type() == TQEvent::FocusOut ) {
01363 TQFocusEvent *fe = static_cast<TQFocusEvent *>(ev);
01364 if ( fe->reason() != TQFocusEvent::Popup &&
01365 fe->reason() != TQFocusEvent::Mouse ) {
01366 updateFocus();
01367 if ( isModified() ) {
01368 saveConfig();
01369 if ( !m_blockEmitDataChanged )
01370 saveData();
01371 }
01372 }
01373 } else if ( ev->type() == TQEvent::FocusIn ) {
01374 updateFocus();
01375 }
01376
01377 return false;
01378 }
01379
01380 if ( o == m_editor->viewport() )
01381 {
01382 if ( m_edit_menu &&
01383 ev->type() == TQEvent::MouseButtonPress &&
01384 ((TQMouseEvent *)ev)->button() == RightButton )
01385 {
01386 m_edit_menu->popup( TQCursor::pos() );
01387 return true;
01388 }
01389 }
01390
01391 return false;
01392 }
01393
01394 void KNote::slotSaveData()
01395 {
01396 saveData();
01397 }
01398
01399 void KNote::deleteWhenIdle()
01400 {
01401 if ( m_busy <= 0 )
01402 deleteLater();
01403 else
01404 m_deleteWhenIdle = true;
01405 }
01406
01407 void KNote::aboutToEnterEventLoop()
01408 {
01409 ++m_busy;
01410 }
01411
01412 void KNote::eventLoopLeft()
01413 {
01414 --m_busy;
01415 if ( m_busy <= 0 && m_deleteWhenIdle )
01416 deleteLater();
01417 }
01418
01419
01420 #include "knote.moc"
01421 #include "knotebutton.moc"