@ -63,15 +63,15 @@
/** Create notes from scratch (just a content) */
/** Create notes from scratch (just a content) */
Note * NoteFactory : : createNoteText ( const TQString & text , Basket * tq parent, bool reallyPlainText /* = false*/ )
Note * NoteFactory : : createNoteText ( const TQString & text , Basket * parent, bool reallyPlainText /* = false*/ )
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
if ( reallyPlainText ) {
if ( reallyPlainText ) {
TextContent * content = new TextContent ( note , createFileForNewNote ( tq parent, " txt " ) ) ;
TextContent * content = new TextContent ( note , createFileForNewNote ( parent, " txt " ) ) ;
content - > setText ( text ) ;
content - > setText ( text ) ;
content - > saveToFile ( ) ;
content - > saveToFile ( ) ;
} else {
} else {
HtmlContent * content = new HtmlContent ( note , createFileForNewNote ( tq parent, " html " ) ) ;
HtmlContent * content = new HtmlContent ( note , createFileForNewNote ( parent, " html " ) ) ;
TQString html = " <html><head><meta name= \" qrichtext \" content= \" 1 \" /></head><body> " + Tools : : textToHTMLWithoutP ( text ) + " </body></html> " ;
TQString html = " <html><head><meta name= \" qrichtext \" content= \" 1 \" /></head><body> " + Tools : : textToHTMLWithoutP ( text ) + " </body></html> " ;
content - > setHtml ( html ) ;
content - > setHtml ( html ) ;
content - > saveToFile ( ) ;
content - > saveToFile ( ) ;
@ -79,41 +79,41 @@ Note* NoteFactory::createNoteText(const TQString &text, Basket *tqparent, bool r
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteHtml ( const TQString & html , Basket * tq parent)
Note * NoteFactory : : createNoteHtml ( const TQString & html , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
HtmlContent * content = new HtmlContent ( note , createFileForNewNote ( tq parent, " html " ) ) ;
HtmlContent * content = new HtmlContent ( note , createFileForNewNote ( parent, " html " ) ) ;
content - > setHtml ( html ) ;
content - > setHtml ( html ) ;
content - > saveToFile ( ) ;
content - > saveToFile ( ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteLink ( const KURL & url , Basket * tq parent)
Note * NoteFactory : : createNoteLink ( const KURL & url , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
new LinkContent ( note , url , titleForURL ( url ) , iconForURL ( url ) , /*autoTitle=*/ true , /*autoIcon=*/ true ) ;
new LinkContent ( note , url , titleForURL ( url ) , iconForURL ( url ) , /*autoTitle=*/ true , /*autoIcon=*/ true ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteLink ( const KURL & url , const TQString & title , Basket * tq parent)
Note * NoteFactory : : createNoteLink ( const KURL & url , const TQString & title , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
new LinkContent ( note , url , title , iconForURL ( url ) , /*autoTitle=*/ false , /*autoIcon=*/ true ) ;
new LinkContent ( note , url , title , iconForURL ( url ) , /*autoTitle=*/ false , /*autoIcon=*/ true ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteImage ( const TQPixmap & image , Basket * tq parent)
Note * NoteFactory : : createNoteImage ( const TQPixmap & image , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
ImageContent * content = new ImageContent ( note , createFileForNewNote ( tq parent, " png " ) ) ;
ImageContent * content = new ImageContent ( note , createFileForNewNote ( parent, " png " ) ) ;
content - > setPixmap ( image ) ;
content - > setPixmap ( image ) ;
content - > saveToFile ( ) ;
content - > saveToFile ( ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteColor ( const TQColor & color , Basket * tq parent)
Note * NoteFactory : : createNoteColor ( const TQColor & color , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
new ColorContent ( note , color ) ;
new ColorContent ( note , color ) ;
return note ;
return note ;
}
}
@ -191,12 +191,12 @@ TQStringList NoteFactory::textToURLList(const TQString &text)
return list ;
return list ;
}
}
Note * NoteFactory : : createNoteFromText ( const TQString & text , Basket * tq parent)
Note * NoteFactory : : createNoteFromText ( const TQString & text , Basket * parent)
{
{
/* Search for a color (#RGB , #RRGGBB , #RRRGGGBBB , #RRRRGGGGBBBB) and create a color note */
/* Search for a color (#RGB , #RRGGBB , #RRRGGGBBB , #RRRRGGGGBBBB) and create a color note */
TQRegExp exp ( " ^#(?:[a-fA-F \\ d]{3}) { 1 , 4 } $ " );
TQRegExp exp ( " ^#(?:[a-fA-F \\ d]{3}) { 1 , 4 } $ " );
if ( exp . search ( text ) ! = - 1 )
if ( exp . search ( text ) ! = - 1 )
return createNoteColor ( TQColor ( text ) , tq parent) ;
return createNoteColor ( TQColor ( text ) , parent) ;
/* Try to convert the text as a URL or a list of URLs */
/* Try to convert the text as a URL or a list of URLs */
TQStringList uriList = textToURLList ( text ) ;
TQStringList uriList = textToURLList ( text ) ;
@ -211,9 +211,9 @@ Note* NoteFactory::createNoteFromText(const TQString &text, Basket *tqparent)
+ + it ;
+ + it ;
TQString title = ( * it ) ;
TQString title = ( * it ) ;
if ( title . isEmpty ( ) )
if ( title . isEmpty ( ) )
note = createNoteLinkOrLauncher ( KURL ( url ) , tq parent) ;
note = createNoteLinkOrLauncher ( KURL ( url ) , parent) ;
else
else
note = createNoteLink ( KURL ( url ) , title , tq parent) ;
note = createNoteLink ( KURL ( url ) , title , parent) ;
// If we got a new note, insert it in a linked list (we will return the first note of that list):
// If we got a new note, insert it in a linked list (we will return the first note of that list):
if ( note ) {
if ( note ) {
@ -234,29 +234,29 @@ Note* NoteFactory::createNoteFromText(const TQString &text, Basket *tqparent)
//TQString newText = text.stripWhiteSpace(); // The text for a new note, without useless spaces
//TQString newText = text.stripWhiteSpace(); // The text for a new note, without useless spaces
/* Else, it's a text or an HTML note, so, create it */
/* Else, it's a text or an HTML note, so, create it */
if ( TQStyleSheet : : mightBeRichText ( /*newT*/ text ) )
if ( TQStyleSheet : : mightBeRichText ( /*newT*/ text ) )
return createNoteHtml ( /*newT*/ text , tq parent) ;
return createNoteHtml ( /*newT*/ text , parent) ;
else
else
return createNoteText ( /*newT*/ text , tq parent) ;
return createNoteText ( /*newT*/ text , parent) ;
}
}
Note * NoteFactory : : createNoteLauncher ( const KURL & url , Basket * tq parent)
Note * NoteFactory : : createNoteLauncher ( const KURL & url , Basket * parent)
{
{
if ( url . isEmpty ( ) )
if ( url . isEmpty ( ) )
return createNoteLauncher ( " " , " " , " " , tq parent) ;
return createNoteLauncher ( " " , " " , " " , parent) ;
else
else
return copyFileAndLoad ( url , tq parent) ;
return copyFileAndLoad ( url , parent) ;
}
}
Note * NoteFactory : : createNoteLauncher ( const TQString & command , const TQString & name , const TQString & icon , Basket * tq parent)
Note * NoteFactory : : createNoteLauncher ( const TQString & command , const TQString & name , const TQString & icon , Basket * parent)
{
{
TQString fileName = createNoteLauncherFile ( command , name , icon , tq parent) ;
TQString fileName = createNoteLauncherFile ( command , name , icon , parent) ;
if ( fileName . isEmpty ( ) )
if ( fileName . isEmpty ( ) )
return 0L ;
return 0L ;
else
else
return loadFile ( fileName , tq parent) ;
return loadFile ( fileName , parent) ;
}
}
TQString NoteFactory : : createNoteLauncherFile ( const TQString & command , const TQString & name , const TQString & icon , Basket * tq parent)
TQString NoteFactory : : createNoteLauncherFile ( const TQString & command , const TQString & name , const TQString & icon , Basket * parent)
{
{
TQString content = TQString (
TQString content = TQString (
" [Desktop Entry] \n "
" [Desktop Entry] \n "
@ -265,9 +265,9 @@ TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQSt
" Icon=%3 \n "
" Icon=%3 \n "
" Encoding=UTF-8 \n "
" Encoding=UTF-8 \n "
" Type=Application \n " ) . tqarg ( command , name , icon . isEmpty ( ) ? TQString ( " exec " ) : icon ) ;
" Type=Application \n " ) . tqarg ( command , name , icon . isEmpty ( ) ? TQString ( " exec " ) : icon ) ;
TQString fileName = fileNameForNewNote ( tq parent, " launcher.desktop " ) ;
TQString fileName = fileNameForNewNote ( parent, " launcher.desktop " ) ;
TQString fullPath = tq parent- > fullPathForFileName ( fileName ) ;
TQString fullPath = parent- > fullPathForFileName ( fileName ) ;
// tq parent->dontCareOfCreation(fullPath);
// parent->dontCareOfCreation(fullPath);
TQFile file ( fullPath ) ;
TQFile file ( fullPath ) ;
if ( file . open ( IO_WriteOnly ) ) {
if ( file . open ( IO_WriteOnly ) ) {
TQTextStream stream ( & file ) ;
TQTextStream stream ( & file ) ;
@ -279,7 +279,7 @@ TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQSt
return TQString ( ) ;
return TQString ( ) ;
}
}
Note * NoteFactory : : createNoteLinkOrLauncher ( const KURL & url , Basket * tq parent)
Note * NoteFactory : : createNoteLinkOrLauncher ( const KURL & url , Basket * parent)
{
{
// IMPORTANT: we create the service ONLY if the extension is ".desktop".
// IMPORTANT: we create the service ONLY if the extension is ".desktop".
// Otherwise, KService take a long time to analyse all the file
// Otherwise, KService take a long time to analyse all the file
@ -292,23 +292,23 @@ Note* NoteFactory::createNoteLinkOrLauncher(const KURL &url, Basket *tqparent)
// If link point to a .desktop file then add a launcher, otherwise it's a link
// If link point to a .desktop file then add a launcher, otherwise it's a link
if ( service & & service - > isValid ( ) )
if ( service & & service - > isValid ( ) )
return createNoteLauncher ( url , tq parent) ;
return createNoteLauncher ( url , parent) ;
else
else
return createNoteLink ( url , tq parent) ;
return createNoteLink ( url , parent) ;
}
}
# include <tqstrlist.h>
# include <tqstrlist.h>
# include <tqimage.h>
# include <tqimage.h>
bool NoteFactory : : movingNotesInTheSameBasket ( TQMimeSource * source , Basket * tq parent, TQDropEvent : : Action action )
bool NoteFactory : : movingNotesInTheSameBasket ( TQMimeSource * source , Basket * parent, TQDropEvent : : Action action )
{
{
if ( NoteDrag : : canDecode ( source ) )
if ( NoteDrag : : canDecode ( source ) )
return action = = TQDropEvent : : Move & & NoteDrag : : basketOf ( source ) = = tq parent;
return action = = TQDropEvent : : Move & & NoteDrag : : basketOf ( source ) = = parent;
else
else
return false ;
return false ;
}
}
Note * NoteFactory : : dropNote ( TQMimeSource * source , Basket * tq parent, bool fromDrop , TQDropEvent : : Action action , Note */ * noteSource */ )
Note * NoteFactory : : dropNote ( TQMimeSource * source , Basket * parent, bool fromDrop , TQDropEvent : : Action action , Note */ * noteSource */ )
{
{
Note * note = 0L ;
Note * note = 0L ;
@ -316,7 +316,7 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
if ( source - > format ( 0 ) = = 0L ) {
if ( source - > format ( 0 ) = = 0L ) {
// TODO: add a parameter to say if it's from a clipboard paste, a selection paste, or a drop
// TODO: add a parameter to say if it's from a clipboard paste, a selection paste, or a drop
// To be able to say "The clipboard/selection/drop is empty".
// To be able to say "The clipboard/selection/drop is empty".
// KMessageBox::error( tq parent, i18n("There is no data to insert."), i18n("No Data"));
// KMessageBox::error( parent, i18n("There is no data to insert."), i18n("No Data"));
return 0 ;
return 0 ;
}
}
@ -340,20 +340,20 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
if ( NoteDrag : : canDecode ( source ) ) {
if ( NoteDrag : : canDecode ( source ) ) {
bool moveFiles = fromDrop & & action = = TQDropEvent : : Move ;
bool moveFiles = fromDrop & & action = = TQDropEvent : : Move ;
bool moveNotes = moveFiles ;
bool moveNotes = moveFiles ;
return NoteDrag : : decode ( source , tq parent, moveFiles , moveNotes ) ; // Filename will be kept
return NoteDrag : : decode ( source , parent, moveFiles , moveNotes ) ; // Filename will be kept
}
}
/* Else : Drop object to note */
/* Else : Drop object to note */
TQPixmap pixmap ;
TQPixmap pixmap ;
if ( TQImageDrag : : decode ( source , pixmap ) )
if ( TQImageDrag : : decode ( source , pixmap ) )
return createNoteImage ( pixmap , tq parent) ;
return createNoteImage ( pixmap , parent) ;
// KColorDrag::decode() is buggy and can trheat strings like "#include <foo.h>" as a black color
// KColorDrag::decode() is buggy and can trheat strings like "#include <foo.h>" as a black color
// The correct "ideal" code:
// The correct "ideal" code:
/*TQColor color;
/*TQColor color;
if ( KColorDrag : : decode ( source , color ) ) {
if ( KColorDrag : : decode ( source , color ) ) {
createNoteColor ( color , tq parent) ;
createNoteColor ( color , parent) ;
return ;
return ;
} */
} */
// And then the hack (if provide color MIME type or a text that contains color), using createNote Color RegExp:
// And then the hack (if provide color MIME type or a text that contains color), using createNote Color RegExp:
@ -362,8 +362,8 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
if ( source - > provides ( " application/x-color " ) | | ( TQTextDrag : : decode ( source , hack ) & & ( exp . search ( hack ) ! = - 1 ) ) ) {
if ( source - > provides ( " application/x-color " ) | | ( TQTextDrag : : decode ( source , hack ) & & ( exp . search ( hack ) ! = - 1 ) ) ) {
TQColor color ;
TQColor color ;
if ( KColorDrag : : decode ( source , color ) )
if ( KColorDrag : : decode ( source , color ) )
return createNoteColor ( color , tq parent) ;
return createNoteColor ( color , parent) ;
// if ( (note = createNoteColor(color, tq parent)) )
// if ( (note = createNoteColor(color, parent)) )
// return note;
// return note;
// // Theorically it should be returned. If not, continue by dropping other things
// // Theorically it should be returned. If not, continue by dropping other things
}
}
@ -373,7 +373,7 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
// If it's a Paste, we should know if files should be copied (copy&paste) or moved (cut&paste):
// If it's a Paste, we should know if files should be copied (copy&paste) or moved (cut&paste):
if ( ! fromDrop & & Tools : : isAFileCut ( source ) )
if ( ! fromDrop & & Tools : : isAFileCut ( source ) )
action = TQDropEvent : : Move ;
action = TQDropEvent : : Move ;
return dropURLs ( urls , tq parent, action , fromDrop ) ;
return dropURLs ( urls , parent, action , fromDrop ) ;
}
}
// FIXME: use dropURLs() also from Mozilla?
// FIXME: use dropURLs() also from Mozilla?
@ -419,11 +419,11 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
// Create a TQString that take the address of the first TQChar and a length
// Create a TQString that take the address of the first TQChar and a length
if ( name = = 0L ) { // We haven't found name (FIXME: Is it possible ?)
if ( name = = 0L ) { // We haven't found name (FIXME: Is it possible ?)
TQString normalHtml ( & ( chars [ 0 ] ) , chars . size ( ) ) ;
TQString normalHtml ( & ( chars [ 0 ] ) , chars . size ( ) ) ;
return createNoteLink ( normalHtml , tq parent) ;
return createNoteLink ( normalHtml , parent) ;
} else {
} else {
TQString normalHtml ( & ( chars [ 0 ] ) , size ) ;
TQString normalHtml ( & ( chars [ 0 ] ) , size ) ;
TQString normalTitle ( name , chars . size ( ) - size - 1 ) ;
TQString normalTitle ( name , chars . size ( ) - size - 1 ) ;
return createNoteLink ( normalHtml , normalTitle , tq parent) ;
return createNoteLink ( normalHtml , normalTitle , parent) ;
}
}
}
}
@ -432,30 +432,30 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro
TQCString subtype ( " html " ) ;
TQCString subtype ( " html " ) ;
// If the text/html comes from Mozilla or GNOME it can be UTF-16 encoded: we need ExtendedTextDrag to check that
// If the text/html comes from Mozilla or GNOME it can be UTF-16 encoded: we need ExtendedTextDrag to check that
ExtendedTextDrag : : decode ( source , html , subtype ) ;
ExtendedTextDrag : : decode ( source , html , subtype ) ;
return createNoteHtml ( html , tq parent) ;
return createNoteHtml ( html , parent) ;
}
}
TQString text ;
TQString text ;
// If the text/plain comes from GEdit or GNOME it can be empty: we need ExtendedTextDrag to check other MIME types
// If the text/plain comes from GEdit or GNOME it can be empty: we need ExtendedTextDrag to check other MIME types
if ( ExtendedTextDrag : : decode ( source , text ) )
if ( ExtendedTextDrag : : decode ( source , text ) )
return createNoteFromText ( text , tq parent) ;
return createNoteFromText ( text , parent) ;
/* Unsucceful drop */
/* Unsucceful drop */
note = createNoteUnknown ( source , tq parent) ;
note = createNoteUnknown ( source , parent) ;
TQString message = i18n ( " <p>%1 doesn't support the data you've dropped.<br> "
TQString message = i18n ( " <p>%1 doesn't support the data you've dropped.<br> "
" It however created a generic note, allowing you to drag or copy it to an application that understand it.</p> "
" It however created a generic note, allowing you to drag or copy it to an application that understand it.</p> "
" <p>If you want the support of these data, please contact developer or visit the "
" <p>If you want the support of these data, please contact developer or visit the "
" <a href= \" http://basket.kde.org/dropdb.php \" >BasKet Drop Database</a>.</p> " ) . tqarg ( kapp - > aboutData ( ) - > programName ( ) ) ;
" <a href= \" http://basket.kde.org/dropdb.php \" >BasKet Drop Database</a>.</p> " ) . tqarg ( kapp - > aboutData ( ) - > programName ( ) ) ;
KMessageBox : : information ( tq parent, message , i18n ( " Unsupported MIME Type(s) " ) ,
KMessageBox : : information ( parent, message , i18n ( " Unsupported MIME Type(s) " ) ,
" unsupportedDropInfo " , KMessageBox : : AllowLink ) ;
" unsupportedDropInfo " , KMessageBox : : AllowLink ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : createNoteUnknown ( TQMimeSource * source , Basket * tq parent/*, const TQString &annotations*/ )
Note * NoteFactory : : createNoteUnknown ( TQMimeSource * source , Basket * parent/*, const TQString &annotations*/ )
{
{
// Save the MimeSource in a file: create and open the file:
// Save the MimeSource in a file: create and open the file:
TQString fileName = createFileForNewNote ( tq parent, " unknown " ) ;
TQString fileName = createFileForNewNote ( parent, " unknown " ) ;
TQFile file ( tq parent- > fullPath ( ) + fileName ) ;
TQFile file ( parent- > fullPath ( ) + fileName ) ;
if ( ! file . open ( IO_WriteOnly ) )
if ( ! file . open ( IO_WriteOnly ) )
return 0L ;
return 0L ;
TQDataStream stream ( & file ) ;
TQDataStream stream ( & file ) ;
@ -477,12 +477,12 @@ Note* NoteFactory::createNoteUnknown(TQMimeSource *source, Basket *tqparent/*, c
}
}
file . close ( ) ;
file . close ( ) ;
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
new UnknownContent ( note , fileName ) ;
new UnknownContent ( note , fileName ) ;
return note ;
return note ;
}
}
Note * NoteFactory : : dropURLs ( KURL : : List urls , Basket * tq parent, TQDropEvent : : Action action , bool fromDrop )
Note * NoteFactory : : dropURLs ( KURL : : List urls , Basket * parent, TQDropEvent : : Action action , bool fromDrop )
{
{
int shouldAsk = 0 ; // shouldAsk==0: don't ask ; shouldAsk==1: ask for "file" ; shouldAsk>=2: ask for "files"
int shouldAsk = 0 ; // shouldAsk==0: don't ask ; shouldAsk==1: ask for "file" ; shouldAsk>=2: ask for "files"
bool shiftPressed = Keyboard : : shiftPressed ( ) ;
bool shiftPressed = Keyboard : : shiftPressed ( ) ;
@ -499,7 +499,7 @@ Note* NoteFactory::dropURLs(KURL::List urls, Basket *tqparent, TQDropEvent::Acti
break ;
break ;
}
}
if ( shouldAsk ) {
if ( shouldAsk ) {
KPopupMenu menu ( tq parent) ;
KPopupMenu menu ( parent) ;
menu . insertItem ( SmallIconSet ( " goto " ) , i18n ( " &Move Here \t Shift " ) , 0 ) ;
menu . insertItem ( SmallIconSet ( " goto " ) , i18n ( " &Move Here \t Shift " ) , 0 ) ;
menu . insertItem ( SmallIconSet ( " editcopy " ) , i18n ( " &Copy Here \t Ctrl " ) , 1 ) ;
menu . insertItem ( SmallIconSet ( " editcopy " ) , i18n ( " &Copy Here \t Ctrl " ) , 1 ) ;
menu . insertItem ( SmallIconSet ( " www " ) , i18n ( " &Link Here \t Ctrl+Shift " ) , 2 ) ;
menu . insertItem ( SmallIconSet ( " www " ) , i18n ( " &Link Here \t Ctrl+Shift " ) , 2 ) ;
@ -543,19 +543,19 @@ Note* NoteFactory::dropURLs(KURL::List urls, Basket *tqparent, TQDropEvent::Acti
for ( KURL : : List : : iterator it = urls . begin ( ) ; it ! = urls . end ( ) ; + + it ) {
for ( KURL : : List : : iterator it = urls . begin ( ) ; it ! = urls . end ( ) ; + + it ) {
if ( ( ( * it ) . protocol ( ) = = " mailto " ) | |
if ( ( ( * it ) . protocol ( ) = = " mailto " ) | |
( action = = TQDropEvent : : Link ) )
( action = = TQDropEvent : : Link ) )
note = createNoteLinkOrLauncher ( * it , tq parent) ;
note = createNoteLinkOrLauncher ( * it , parent) ;
else if ( ! ( * it ) . isLocalFile ( ) ) {
else if ( ! ( * it ) . isLocalFile ( ) ) {
if ( action ! = TQDropEvent : : Link & & ( maybeImageOrAnimation ( * it ) /* || maybeSound(*it)*/ ) )
if ( action ! = TQDropEvent : : Link & & ( maybeImageOrAnimation ( * it ) /* || maybeSound(*it)*/ ) )
note = copyFileAndLoad ( * it , tq parent) ;
note = copyFileAndLoad ( * it , parent) ;
else
else
note = createNoteLinkOrLauncher ( * it , tq parent) ;
note = createNoteLinkOrLauncher ( * it , parent) ;
} else {
} else {
if ( action = = TQDropEvent : : Copy )
if ( action = = TQDropEvent : : Copy )
note = copyFileAndLoad ( * it , tq parent) ;
note = copyFileAndLoad ( * it , parent) ;
else if ( action = = TQDropEvent : : Move )
else if ( action = = TQDropEvent : : Move )
note = moveFileAndLoad ( * it , tq parent) ;
note = moveFileAndLoad ( * it , parent) ;
else
else
note = createNoteLinkOrLauncher ( * it , tq parent) ;
note = createNoteLinkOrLauncher ( * it , parent) ;
}
}
// If we got a new note, insert it in a linked list (we will return the first note of that list):
// If we got a new note, insert it in a linked list (we will return the first note of that list):
@ -586,20 +586,20 @@ void NoteFactory::consumeContent(TQDataStream &stream, NoteType::Id type)
}
}
}
}
Note * NoteFactory : : decodeContent ( TQDataStream & stream , NoteType : : Id type , Basket * tq parent)
Note * NoteFactory : : decodeContent ( TQDataStream & stream , NoteType : : Id type , Basket * parent)
{
{
/* if (type == NoteType::Text) {
/* if (type == NoteType::Text) {
TQString text ;
TQString text ;
stream > > text ;
stream > > text ;
return NoteFactory : : createNoteText ( text , tq parent) ;
return NoteFactory : : createNoteText ( text , parent) ;
} else if ( type = = NoteType : : Html ) {
} else if ( type = = NoteType : : Html ) {
TQString html ;
TQString html ;
stream > > html ;
stream > > html ;
return NoteFactory : : createNoteHtml ( html , tq parent) ;
return NoteFactory : : createNoteHtml ( html , parent) ;
} else if ( type = = NoteType : : Image ) {
} else if ( type = = NoteType : : Image ) {
TQPixmap pixmap ;
TQPixmap pixmap ;
stream > > pixmap ;
stream > > pixmap ;
return NoteFactory : : createNoteImage ( pixmap , tq parent) ;
return NoteFactory : : createNoteImage ( pixmap , parent) ;
} else */
} else */
if ( type = = NoteType : : Link ) {
if ( type = = NoteType : : Link ) {
KURL url ;
KURL url ;
@ -609,13 +609,13 @@ Note* NoteFactory::decodeContent(TQDataStream &stream, NoteType::Id type, Basket
stream > > url > > title > > icon > > autoTitle64 > > autoIcon64 ;
stream > > url > > title > > icon > > autoTitle64 > > autoIcon64 ;
autoTitle = ( bool ) autoTitle64 ;
autoTitle = ( bool ) autoTitle64 ;
autoIcon = ( bool ) autoIcon64 ;
autoIcon = ( bool ) autoIcon64 ;
Note * note = NoteFactory : : createNoteLink ( url , tq parent) ;
Note * note = NoteFactory : : createNoteLink ( url , parent) ;
( ( LinkContent * ) ( note - > content ( ) ) ) - > setLink ( url , title , icon , autoTitle , autoIcon ) ;
( ( LinkContent * ) ( note - > content ( ) ) ) - > setLink ( url , title , icon , autoTitle , autoIcon ) ;
return note ;
return note ;
} else if ( type = = NoteType : : Color ) {
} else if ( type = = NoteType : : Color ) {
TQColor color ;
TQColor color ;
stream > > color ;
stream > > color ;
return NoteFactory : : createNoteColor ( color , tq parent) ;
return NoteFactory : : createNoteColor ( color , parent) ;
} else
} else
return 0 ; // NoteFactory::loadFile() is sufficient
return 0 ; // NoteFactory::loadFile() is sufficient
}
}
@ -674,76 +674,76 @@ bool NoteFactory::maybeLauncher(const KURL &url)
////////////// NEW:
////////////// NEW:
Note * NoteFactory : : copyFileAndLoad ( const KURL & url , Basket * tq parent)
Note * NoteFactory : : copyFileAndLoad ( const KURL & url , Basket * parent)
{
{
TQString fileName = fileNameForNewNote ( tq parent, url . fileName ( ) ) ;
TQString fileName = fileNameForNewNote ( parent, url . fileName ( ) ) ;
TQString fullPath = tq parent- > fullPathForFileName ( fileName ) ;
TQString fullPath = parent- > fullPathForFileName ( fileName ) ;
if ( Global : : debugWindow )
if ( Global : : debugWindow )
* Global : : debugWindow < < " copyFileAndLoad: " + url . prettyURL ( ) + " to " + fullPath ;
* Global : : debugWindow < < " copyFileAndLoad: " + url . prettyURL ( ) + " to " + fullPath ;
// TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL());
// TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL());
// tq parent->dontCareOfCreation(fullPath);
// parent->dontCareOfCreation(fullPath);
// KIO::CopyJob *copyJob = KIO::copy(url, KURL(fullPath));
// KIO::CopyJob *copyJob = KIO::copy(url, KURL(fullPath));
// tq parent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)),
// parent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)),
// tq parent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) );
// parent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) );
KIO : : FileCopyJob * copyJob = new KIO : : FileCopyJob (
KIO : : FileCopyJob * copyJob = new KIO : : FileCopyJob (
url , KURL ( fullPath ) , 0666 , /*move=*/ false ,
url , KURL ( fullPath ) , 0666 , /*move=*/ false ,
/*overwrite=*/ true , /*resume=*/ true , /*showProgress=*/ true ) ;
/*overwrite=*/ true , /*resume=*/ true , /*showProgress=*/ true ) ;
tq parent- > connect ( copyJob , TQT_SIGNAL ( result ( KIO : : Job * ) ) ,
parent- > connect ( copyJob , TQT_SIGNAL ( result ( KIO : : Job * ) ) ,
tq parent, TQT_SLOT ( slotCopyingDone2 ( KIO : : Job * ) ) ) ;
parent, TQT_SLOT ( slotCopyingDone2 ( KIO : : Job * ) ) ) ;
NoteType : : Id type = typeForURL ( url , tq parent) ; // Use the type of the original file because the target doesn't exist yet
NoteType : : Id type = typeForURL ( url , parent) ; // Use the type of the original file because the target doesn't exist yet
return loadFile ( fileName , type , tq parent) ;
return loadFile ( fileName , type , parent) ;
}
}
Note * NoteFactory : : moveFileAndLoad ( const KURL & url , Basket * tq parent)
Note * NoteFactory : : moveFileAndLoad ( const KURL & url , Basket * parent)
{
{
// Globally the same as copyFileAndLoad() but move instead of copy (KIO::move())
// Globally the same as copyFileAndLoad() but move instead of copy (KIO::move())
TQString fileName = fileNameForNewNote ( tq parent, url . fileName ( ) ) ;
TQString fileName = fileNameForNewNote ( parent, url . fileName ( ) ) ;
TQString fullPath = tq parent- > fullPathForFileName ( fileName ) ;
TQString fullPath = parent- > fullPathForFileName ( fileName ) ;
if ( Global : : debugWindow )
if ( Global : : debugWindow )
* Global : : debugWindow < < " moveFileAndLoad: " + url . prettyURL ( ) + " to " + fullPath ;
* Global : : debugWindow < < " moveFileAndLoad: " + url . prettyURL ( ) + " to " + fullPath ;
// TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL());
// TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL());
// tq parent->dontCareOfCreation(fullPath);
// parent->dontCareOfCreation(fullPath);
// KIO::CopyJob *copyJob = KIO::move(url, KURL(fullPath));
// KIO::CopyJob *copyJob = KIO::move(url, KURL(fullPath));
// tq parent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)),
// parent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)),
// tq parent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) );
// parent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) );
KIO : : FileCopyJob * copyJob = new KIO : : FileCopyJob (
KIO : : FileCopyJob * copyJob = new KIO : : FileCopyJob (
url , KURL ( fullPath ) , 0666 , /*move=*/ true ,
url , KURL ( fullPath ) , 0666 , /*move=*/ true ,
/*overwrite=*/ true , /*resume=*/ true , /*showProgress=*/ true ) ;
/*overwrite=*/ true , /*resume=*/ true , /*showProgress=*/ true ) ;
tq parent- > connect ( copyJob , TQT_SIGNAL ( result ( KIO : : Job * ) ) ,
parent- > connect ( copyJob , TQT_SIGNAL ( result ( KIO : : Job * ) ) ,
tq parent, TQT_SLOT ( slotCopyingDone2 ( KIO : : Job * ) ) ) ;
parent, TQT_SLOT ( slotCopyingDone2 ( KIO : : Job * ) ) ) ;
NoteType : : Id type = typeForURL ( url , tq parent) ; // Use the type of the original file because the target doesn't exist yet
NoteType : : Id type = typeForURL ( url , parent) ; // Use the type of the original file because the target doesn't exist yet
return loadFile ( fileName , type , tq parent) ;
return loadFile ( fileName , type , parent) ;
}
}
Note * NoteFactory : : loadFile ( const TQString & fileName , Basket * tq parent)
Note * NoteFactory : : loadFile ( const TQString & fileName , Basket * parent)
{
{
// The file MUST exists
// The file MUST exists
TQFileInfo file ( KURL ( tq parent- > fullPathForFileName ( fileName ) ) . path ( ) ) ;
TQFileInfo file ( KURL ( parent- > fullPathForFileName ( fileName ) ) . path ( ) ) ;
if ( ! file . exists ( ) )
if ( ! file . exists ( ) )
return 0L ;
return 0L ;
NoteType : : Id type = typeForURL ( tq parent- > fullPathForFileName ( fileName ) , tq parent) ;
NoteType : : Id type = typeForURL ( parent- > fullPathForFileName ( fileName ) , parent) ;
Note * note = loadFile ( fileName , type , tq parent) ;
Note * note = loadFile ( fileName , type , parent) ;
return note ;
return note ;
}
}
Note * NoteFactory : : loadFile ( const TQString & fileName , NoteType : : Id type , Basket * tq parent)
Note * NoteFactory : : loadFile ( const TQString & fileName , NoteType : : Id type , Basket * parent)
{
{
Note * note = new Note ( tq parent) ;
Note * note = new Note ( parent) ;
switch ( type ) {
switch ( type ) {
case NoteType : : Text : new TextContent ( note , fileName ) ; break ;
case NoteType : : Text : new TextContent ( note , fileName ) ; break ;
case NoteType : : Html : new HtmlContent ( note , fileName ) ; break ;
case NoteType : : Html : new HtmlContent ( note , fileName ) ; break ;
@ -763,7 +763,7 @@ Note* NoteFactory::loadFile(const TQString &fileName, NoteType::Id type, Basket
return note ;
return note ;
}
}
NoteType : : Id NoteFactory : : typeForURL ( const KURL & url , Basket */ * tq parent*/ )
NoteType : : Id NoteFactory : : typeForURL ( const KURL & url , Basket */ * parent*/ )
{
{
/* KMimeType::Ptr kMimeType = KMimeType::findByURL(url);
/* KMimeType::Ptr kMimeType = KMimeType::findByURL(url);
if ( Global : : debugWindow )
if ( Global : : debugWindow )
@ -800,37 +800,37 @@ NoteType::Id NoteFactory::typeForURL(const KURL &url, Basket */*tqparent*/)
else return NoteType : : File ;
else return NoteType : : File ;
}
}
TQString NoteFactory : : fileNameForNewNote ( Basket * tq parent, const TQString & wantedName )
TQString NoteFactory : : fileNameForNewNote ( Basket * parent, const TQString & wantedName )
{
{
return Tools : : fileNameForNewFile ( wantedName , tq parent- > fullPath ( ) ) ;
return Tools : : fileNameForNewFile ( wantedName , parent- > fullPath ( ) ) ;
}
}
// Create a file to store a new note in Basket tq parent and with extension extension.
// Create a file to store a new note in Basket parent and with extension extension.
// If wantedName is provided, the function will first try to use this file name, or derive it if it's impossible
// If wantedName is provided, the function will first try to use this file name, or derive it if it's impossible
// (extension willn't be used for that case)
// (extension willn't be used for that case)
TQString NoteFactory : : createFileForNewNote ( Basket * tq parent, const TQString & extension , const TQString & wantedName )
TQString NoteFactory : : createFileForNewNote ( Basket * parent, const TQString & extension , const TQString & wantedName )
{
{
static int nb = 1 ;
static int nb = 1 ;
TQString fileName ;
TQString fileName ;
TQString fullName ;
TQString fullName ;
if ( wantedName . isEmpty ( ) ) { // TODO: fileNameForNewNote( tq parent, "note1."+extension);
if ( wantedName . isEmpty ( ) ) { // TODO: fileNameForNewNote( parent, "note1."+extension);
TQDir dir ;
TQDir dir ;
for ( /*int nb = 1*/ ; ; + + nb ) { // TODO: FIXME: If overflow ???
for ( /*int nb = 1*/ ; ; + + nb ) { // TODO: FIXME: If overflow ???
fileName = " note " + TQString : : number ( nb ) /*.rightJustify(5, '0')*/ + " . " + extension ;
fileName = " note " + TQString : : number ( nb ) /*.rightJustify(5, '0')*/ + " . " + extension ;
fullName = tq parent- > fullPath ( ) + fileName ;
fullName = parent- > fullPath ( ) + fileName ;
dir = TQDir ( fullName ) ;
dir = TQDir ( fullName ) ;
if ( ! dir . exists ( fullName ) )
if ( ! dir . exists ( fullName ) )
break ;
break ;
}
}
} else {
} else {
fileName = fileNameForNewNote ( tq parent, wantedName ) ;
fileName = fileNameForNewNote ( parent, wantedName ) ;
fullName = tq parent- > fullPath ( ) + fileName ;
fullName = parent- > fullPath ( ) + fileName ;
}
}
// Create the file
// Create the file
// tq parent->dontCareOfCreation(fullName);
// parent->dontCareOfCreation(fullName);
TQFile file ( fullName ) ;
TQFile file ( fullName ) ;
file . open ( IO_WriteOnly ) ;
file . open ( IO_WriteOnly ) ;
file . close ( ) ;
file . close ( ) ;
@ -940,25 +940,25 @@ bool NoteFactory::isIconExist(const TQString &icon)
return ! kapp - > iconLoader ( ) - > loadIcon ( icon , KIcon : : NoGroup , 16 , KIcon : : DefaultState , 0L , true ) . isNull ( ) ;
return ! kapp - > iconLoader ( ) - > loadIcon ( icon , KIcon : : NoGroup , 16 , KIcon : : DefaultState , 0L , true ) . isNull ( ) ;
}
}
Note * NoteFactory : : createEmptyNote ( NoteType : : Id type , Basket * tq parent)
Note * NoteFactory : : createEmptyNote ( NoteType : : Id type , Basket * parent)
{
{
TQPixmap * pixmap ;
TQPixmap * pixmap ;
switch ( type ) {
switch ( type ) {
case NoteType : : Text :
case NoteType : : Text :
return NoteFactory : : createNoteText ( " " , tq parent, /*reallyPlainText=*/ true ) ;
return NoteFactory : : createNoteText ( " " , parent, /*reallyPlainText=*/ true ) ;
case NoteType : : Html :
case NoteType : : Html :
return NoteFactory : : createNoteHtml ( " " , tq parent) ;
return NoteFactory : : createNoteHtml ( " " , parent) ;
case NoteType : : Image :
case NoteType : : Image :
pixmap = new TQPixmap ( TQSize ( Settings : : defImageX ( ) , Settings : : defImageY ( ) ) ) ;
pixmap = new TQPixmap ( TQSize ( Settings : : defImageX ( ) , Settings : : defImageY ( ) ) ) ;
pixmap - > fill ( ) ;
pixmap - > fill ( ) ;
pixmap - > setMask ( pixmap - > createHeuristicMask ( ) ) ;
pixmap - > setMask ( pixmap - > createHeuristicMask ( ) ) ;
return NoteFactory : : createNoteImage ( * pixmap , tq parent) ;
return NoteFactory : : createNoteImage ( * pixmap , parent) ;
case NoteType : : Link :
case NoteType : : Link :
return NoteFactory : : createNoteLink ( KURL ( ) , tq parent) ;
return NoteFactory : : createNoteLink ( KURL ( ) , parent) ;
case NoteType : : Launcher :
case NoteType : : Launcher :
return NoteFactory : : createNoteLauncher ( KURL ( ) , tq parent) ;
return NoteFactory : : createNoteLauncher ( KURL ( ) , parent) ;
case NoteType : : Color :
case NoteType : : Color :
return NoteFactory : : createNoteColor ( TQt : : black , tq parent) ;
return NoteFactory : : createNoteColor ( TQt : : black , parent) ;
default :
default :
case NoteType : : Animation :
case NoteType : : Animation :
case NoteType : : Sound :
case NoteType : : Sound :
@ -968,9 +968,9 @@ Note* NoteFactory::createEmptyNote(NoteType::Id type, Basket *tqparent)
}
}
}
}
Note * NoteFactory : : importKMenuLauncher ( Basket * tq parent)
Note * NoteFactory : : importKMenuLauncher ( Basket * parent)
{
{
KOpenWithDlg dialog ( tq parent) ;
KOpenWithDlg dialog ( parent) ;
dialog . setSaveNewApplications ( true ) ; // To create temp file, needed by createNoteLauncher()
dialog . setSaveNewApplications ( true ) ; // To create temp file, needed by createNoteLauncher()
dialog . exec ( ) ;
dialog . exec ( ) ;
if ( dialog . service ( ) ) {
if ( dialog . service ( ) ) {
@ -979,12 +979,12 @@ Note* NoteFactory::importKMenuLauncher(Basket *tqparent)
TQString serviceUrl = dialog . service ( ) - > desktopEntryPath ( ) ;
TQString serviceUrl = dialog . service ( ) - > desktopEntryPath ( ) ;
if ( ! serviceUrl . startsWith ( " / " ) )
if ( ! serviceUrl . startsWith ( " / " ) )
serviceUrl = dialog . service ( ) - > locateLocal ( ) ; //locateLocal("xdgdata-apps", serviceUrl);
serviceUrl = dialog . service ( ) - > locateLocal ( ) ; //locateLocal("xdgdata-apps", serviceUrl);
return createNoteLauncher ( serviceUrl , tq parent) ;
return createNoteLauncher ( serviceUrl , parent) ;
}
}
return 0 ;
return 0 ;
}
}
Note * NoteFactory : : importIcon ( Basket * tq parent)
Note * NoteFactory : : importIcon ( Basket * parent)
{
{
TQString iconName = KIconDialog : : getIcon ( KIcon : : Desktop , KIcon : : Application , false , Settings : : defIconSize ( ) ) ;
TQString iconName = KIconDialog : : getIcon ( KIcon : : Desktop , KIcon : : Application , false , Settings : : defIconSize ( ) ) ;
if ( ! iconName . isEmpty ( ) ) {
if ( ! iconName . isEmpty ( ) ) {
@ -993,16 +993,16 @@ Note* NoteFactory::importIcon(Basket *tqparent)
if ( dialog . iconSize ( ) > 0 ) {
if ( dialog . iconSize ( ) > 0 ) {
Settings : : setDefIconSize ( dialog . iconSize ( ) ) ;
Settings : : setDefIconSize ( dialog . iconSize ( ) ) ;
Settings : : saveConfig ( ) ;
Settings : : saveConfig ( ) ;
return createNoteImage ( DesktopIcon ( iconName , dialog . iconSize ( ) ) , tq parent ) ; // TODO: wantedName = iconName !
return createNoteImage ( DesktopIcon ( iconName , dialog . iconSize ( ) ) , parent ) ; // TODO: wantedName = iconName !
}
}
}
}
return 0 ;
return 0 ;
}
}
Note * NoteFactory : : importFileContent ( Basket * tq parent)
Note * NoteFactory : : importFileContent ( Basket * parent)
{
{
KURL url = KFileDialog : : getOpenURL ( TQString ( ) , TQString ( ) , tq parent, i18n ( " Load File Content into a Note " ) ) ;
KURL url = KFileDialog : : getOpenURL ( TQString ( ) , TQString ( ) , parent, i18n ( " Load File Content into a Note " ) ) ;
if ( ! url . isEmpty ( ) )
if ( ! url . isEmpty ( ) )
return copyFileAndLoad ( url , tq parent) ;
return copyFileAndLoad ( url , parent) ;
return 0 ;
return 0 ;
}
}