diff options
Diffstat (limited to 'src/notefactory.cpp')
-rw-r--r-- | src/notefactory.cpp | 240 |
1 files changed, 120 insertions, 120 deletions
diff --git a/src/notefactory.cpp b/src/notefactory.cpp index 6e57377..1b8e83e 100644 --- a/src/notefactory.cpp +++ b/src/notefactory.cpp @@ -63,15 +63,15 @@ /** Create notes from scratch (just a content) */ -Note* NoteFactory::createNoteText(const TQString &text, Basket *tqparent, bool reallyPlainText/* = false*/) +Note* NoteFactory::createNoteText(const TQString &text, Basket *parent, bool reallyPlainText/* = false*/) { - Note *note = new Note(tqparent); + Note *note = new Note(parent); if (reallyPlainText) { - TextContent *content = new TextContent(note, createFileForNewNote(tqparent, "txt")); + TextContent *content = new TextContent(note, createFileForNewNote(parent, "txt")); content->setText(text); content->saveToFile(); } else { - HtmlContent *content = new HtmlContent(note, createFileForNewNote(tqparent, "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>"; content->setHtml(html); content->saveToFile(); @@ -79,41 +79,41 @@ Note* NoteFactory::createNoteText(const TQString &text, Basket *tqparent, bool r return note; } -Note* NoteFactory::createNoteHtml(const TQString &html, Basket *tqparent) +Note* NoteFactory::createNoteHtml(const TQString &html, Basket *parent) { - Note *note = new Note(tqparent); - HtmlContent *content = new HtmlContent(note, createFileForNewNote(tqparent, "html")); + Note *note = new Note(parent); + HtmlContent *content = new HtmlContent(note, createFileForNewNote(parent, "html")); content->setHtml(html); content->saveToFile(); return note; } -Note* NoteFactory::createNoteLink(const KURL &url, Basket *tqparent) +Note* NoteFactory::createNoteLink(const KURL &url, Basket *parent) { - Note *note = new Note(tqparent); + Note *note = new Note(parent); new LinkContent(note, url, titleForURL(url), iconForURL(url), /*autoTitle=*/true, /*autoIcon=*/true); return note; } -Note* NoteFactory::createNoteLink(const KURL &url, const TQString &title, Basket *tqparent) +Note* NoteFactory::createNoteLink(const KURL &url, const TQString &title, Basket *parent) { - Note *note = new Note(tqparent); + Note *note = new Note(parent); new LinkContent(note, url, title, iconForURL(url), /*autoTitle=*/false, /*autoIcon=*/true); return note; } -Note* NoteFactory::createNoteImage(const TQPixmap &image, Basket *tqparent) +Note* NoteFactory::createNoteImage(const TQPixmap &image, Basket *parent) { - Note *note = new Note(tqparent); - ImageContent *content = new ImageContent(note, createFileForNewNote(tqparent, "png")); + Note *note = new Note(parent); + ImageContent *content = new ImageContent(note, createFileForNewNote(parent, "png")); content->setPixmap(image); content->saveToFile(); return note; } -Note* NoteFactory::createNoteColor(const TQColor &color, Basket *tqparent) +Note* NoteFactory::createNoteColor(const TQColor &color, Basket *parent) { - Note *note = new Note(tqparent); + Note *note = new Note(parent); new ColorContent(note, color); return note; } @@ -191,12 +191,12 @@ TQStringList NoteFactory::textToURLList(const TQString &text) return list; } -Note* NoteFactory::createNoteFromText(const TQString &text, Basket *tqparent) +Note* NoteFactory::createNoteFromText(const TQString &text, Basket *parent) { /* Search for a color (#RGB , #RRGGBB , #RRRGGGBBB , #RRRRGGGGBBBB) and create a color note */ TQRegExp exp("^#(?:[a-fA-F\\d]{3}){1,4}$"); if ( exp.search(text) != -1 ) - return createNoteColor(TQColor(text), tqparent); + return createNoteColor(TQColor(text), parent); /* Try to convert the text as a URL or a list of URLs */ TQStringList uriList = textToURLList(text); @@ -211,9 +211,9 @@ Note* NoteFactory::createNoteFromText(const TQString &text, Basket *tqparent) ++it; TQString title = (*it); if (title.isEmpty()) - note = createNoteLinkOrLauncher(KURL(url), tqparent); + note = createNoteLinkOrLauncher(KURL(url), parent); else - note = createNoteLink(KURL(url), title, tqparent); + 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 (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 /* Else, it's a text or an HTML note, so, create it */ if (TQStyleSheet::mightBeRichText(/*newT*/text)) - return createNoteHtml(/*newT*/text, tqparent); + return createNoteHtml(/*newT*/text, parent); else - return createNoteText(/*newT*/text, tqparent); + return createNoteText(/*newT*/text, parent); } -Note* NoteFactory::createNoteLauncher(const KURL &url, Basket *tqparent) +Note* NoteFactory::createNoteLauncher(const KURL &url, Basket *parent) { if (url.isEmpty()) - return createNoteLauncher("", "", "", tqparent); + return createNoteLauncher("", "", "", parent); else - return copyFileAndLoad(url, tqparent); + return copyFileAndLoad(url, parent); } -Note* NoteFactory::createNoteLauncher(const TQString &command, const TQString &name, const TQString &icon, Basket *tqparent) +Note* NoteFactory::createNoteLauncher(const TQString &command, const TQString &name, const TQString &icon, Basket *parent) { - TQString fileName = createNoteLauncherFile(command, name, icon, tqparent); + TQString fileName = createNoteLauncherFile(command, name, icon, parent); if (fileName.isEmpty()) return 0L; else - return loadFile(fileName, tqparent); + return loadFile(fileName, parent); } -TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQString &name, const TQString &icon, Basket *tqparent) +TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQString &name, const TQString &icon, Basket *parent) { TQString content = TQString( "[Desktop Entry]\n" @@ -265,9 +265,9 @@ TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQSt "Icon=%3\n" "Encoding=UTF-8\n" "Type=Application\n").tqarg(command, name, icon.isEmpty() ? TQString("exec") : icon); - TQString fileName = fileNameForNewNote(tqparent, "launcher.desktop"); - TQString fullPath = tqparent->fullPathForFileName(fileName); -// tqparent->dontCareOfCreation(fullPath); + TQString fileName = fileNameForNewNote(parent, "launcher.desktop"); + TQString fullPath = parent->fullPathForFileName(fileName); +// parent->dontCareOfCreation(fullPath); TQFile file(fullPath); if ( file.open(IO_WriteOnly) ) { TQTextStream stream(&file); @@ -279,7 +279,7 @@ TQString NoteFactory::createNoteLauncherFile(const TQString &command, const TQSt return TQString(); } -Note* NoteFactory::createNoteLinkOrLauncher(const KURL &url, Basket *tqparent) +Note* NoteFactory::createNoteLinkOrLauncher(const KURL &url, Basket *parent) { // IMPORTANT: we create the service ONLY if the extension is ".desktop". // 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 (service && service->isValid()) - return createNoteLauncher(url, tqparent); + return createNoteLauncher(url, parent); else - return createNoteLink(url, tqparent); + return createNoteLink(url, parent); } #include <tqstrlist.h> #include <tqimage.h> -bool NoteFactory::movingNotesInTheSameBasket(TQMimeSource *source, Basket *tqparent, TQDropEvent::Action action) +bool NoteFactory::movingNotesInTheSameBasket(TQMimeSource *source, Basket *parent, TQDropEvent::Action action) { if (NoteDrag::canDecode(source)) - return action == TQDropEvent::Move && NoteDrag::basketOf(source) == tqparent; + return action == TQDropEvent::Move && NoteDrag::basketOf(source) == parent; else return false; } -Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDrop, TQDropEvent::Action action, Note */*noteSource*/) +Note* NoteFactory::dropNote(TQMimeSource *source, Basket *parent, bool fromDrop, TQDropEvent::Action action, Note */*noteSource*/) { Note *note = 0L; @@ -316,7 +316,7 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro if (source->format(0) == 0L) { // 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". -// KMessageBox::error(tqparent, 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; } @@ -340,20 +340,20 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro if (NoteDrag::canDecode(source)) { bool moveFiles = fromDrop && action == TQDropEvent::Move; bool moveNotes = moveFiles; - return NoteDrag::decode(source, tqparent, moveFiles, moveNotes); // Filename will be kept + return NoteDrag::decode(source, parent, moveFiles, moveNotes); // Filename will be kept } /* Else : Drop object to note */ TQPixmap pixmap; if ( TQImageDrag::decode(source, pixmap) ) - return createNoteImage(pixmap, tqparent); + return createNoteImage(pixmap, parent); // KColorDrag::decode() is buggy and can trheat strings like "#include <foo.h>" as a black color // The correct "ideal" code: /*TQColor color; if ( KColorDrag::decode(source, color) ) { - createNoteColor(color, tqparent); + createNoteColor(color, parent); return; }*/ // 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)) ) { TQColor color; if (KColorDrag::decode(source, color)) - return createNoteColor(color, tqparent); -// if ( (note = createNoteColor(color, tqparent)) ) + return createNoteColor(color, parent); +// if ( (note = createNoteColor(color, parent)) ) // return note; // // 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 (!fromDrop && Tools::isAFileCut(source)) action = TQDropEvent::Move; - return dropURLs(urls, tqparent, action, fromDrop); + return dropURLs(urls, parent, action, fromDrop); } // 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 if (name == 0L) { // We haven't found name (FIXME: Is it possible ?) TQString normalHtml(&(chars[0]), chars.size()); - return createNoteLink(normalHtml, tqparent); + return createNoteLink(normalHtml, parent); } else { TQString normalHtml( &(chars[0]), size ); TQString normalTitle( name, chars.size()-size-1); - return createNoteLink(normalHtml, normalTitle, tqparent); + return createNoteLink(normalHtml, normalTitle, parent); } } @@ -432,30 +432,30 @@ Note* NoteFactory::dropNote(TQMimeSource *source, Basket *tqparent, bool fromDro TQCString subtype("html"); // 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); - return createNoteHtml(html, tqparent); + return createNoteHtml(html, parent); } TQString text; // 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) ) - return createNoteFromText(text, tqparent); + return createNoteFromText(text, parent); /* Unsucceful drop */ - note = createNoteUnknown(source, tqparent); + note = createNoteUnknown(source, parent); 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>" "<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()); - KMessageBox::information(tqparent, message, i18n("Unsupported MIME Type(s)"), + KMessageBox::information(parent, message, i18n("Unsupported MIME Type(s)"), "unsupportedDropInfo", KMessageBox::AllowLink); return note; } -Note* NoteFactory::createNoteUnknown(TQMimeSource *source, Basket *tqparent/*, const TQString &annotations*/) +Note* NoteFactory::createNoteUnknown(TQMimeSource *source, Basket *parent/*, const TQString &annotations*/) { // Save the MimeSource in a file: create and open the file: - TQString fileName = createFileForNewNote(tqparent, "unknown"); - TQFile file(tqparent->fullPath() + fileName); + TQString fileName = createFileForNewNote(parent, "unknown"); + TQFile file(parent->fullPath() + fileName); if ( ! file.open(IO_WriteOnly) ) return 0L; TQDataStream stream(&file); @@ -477,12 +477,12 @@ Note* NoteFactory::createNoteUnknown(TQMimeSource *source, Basket *tqparent/*, c } file.close(); - Note *note = new Note(tqparent); + Note *note = new Note(parent); new UnknownContent(note, fileName); return note; } -Note* NoteFactory::dropURLs(KURL::List urls, Basket *tqparent, 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" bool shiftPressed = Keyboard::shiftPressed(); @@ -499,7 +499,7 @@ Note* NoteFactory::dropURLs(KURL::List urls, Basket *tqparent, TQDropEvent::Acti break; } if (shouldAsk) { - KPopupMenu menu(tqparent); + KPopupMenu menu(parent); menu.insertItem( SmallIconSet("goto"), i18n("&Move Here\tShift"), 0 ); menu.insertItem( SmallIconSet("editcopy"), i18n("&Copy Here\tCtrl"), 1 ); menu.insertItem( SmallIconSet("www"), i18n("&Link Here\tCtrl+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) { if ( ((*it).protocol() == "mailto") || (action == TQDropEvent::Link) ) - note = createNoteLinkOrLauncher(*it, tqparent); + note = createNoteLinkOrLauncher(*it, parent); else if (!(*it).isLocalFile()) { if ( action != TQDropEvent::Link && (maybeImageOrAnimation(*it)/* || maybeSound(*it)*/) ) - note = copyFileAndLoad(*it, tqparent); + note = copyFileAndLoad(*it, parent); else - note = createNoteLinkOrLauncher(*it, tqparent); + note = createNoteLinkOrLauncher(*it, parent); } else { if (action == TQDropEvent::Copy) - note = copyFileAndLoad(*it, tqparent); + note = copyFileAndLoad(*it, parent); else if (action == TQDropEvent::Move) - note = moveFileAndLoad(*it, tqparent); + note = moveFileAndLoad(*it, parent); else - note = createNoteLinkOrLauncher(*it, tqparent); + 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): @@ -586,20 +586,20 @@ void NoteFactory::consumeContent(TQDataStream &stream, NoteType::Id type) } } -Note* NoteFactory::decodeContent(TQDataStream &stream, NoteType::Id type, Basket *tqparent) +Note* NoteFactory::decodeContent(TQDataStream &stream, NoteType::Id type, Basket *parent) { /* if (type == NoteType::Text) { TQString text; stream >> text; - return NoteFactory::createNoteText(text, tqparent); + return NoteFactory::createNoteText(text, parent); } else if (type == NoteType::Html) { TQString html; stream >> html; - return NoteFactory::createNoteHtml(html, tqparent); + return NoteFactory::createNoteHtml(html, parent); } else if (type == NoteType::Image) { TQPixmap pixmap; stream >> pixmap; - return NoteFactory::createNoteImage(pixmap, tqparent); + return NoteFactory::createNoteImage(pixmap, parent); } else */ if (type == NoteType::Link) { KURL url; @@ -609,13 +609,13 @@ Note* NoteFactory::decodeContent(TQDataStream &stream, NoteType::Id type, Basket stream >> url >> title >> icon >> autoTitle64 >> autoIcon64; autoTitle = (bool)autoTitle64; autoIcon = (bool)autoIcon64; - Note *note = NoteFactory::createNoteLink(url, tqparent); + Note *note = NoteFactory::createNoteLink(url, parent); ((LinkContent*)(note->content()))->setLink(url, title, icon, autoTitle, autoIcon); return note; } else if (type == NoteType::Color) { TQColor color; stream >> color; - return NoteFactory::createNoteColor(color, tqparent); + return NoteFactory::createNoteColor(color, parent); } else return 0; // NoteFactory::loadFile() is sufficient } @@ -674,76 +674,76 @@ bool NoteFactory::maybeLauncher(const KURL &url) ////////////// NEW: -Note* NoteFactory::copyFileAndLoad(const KURL &url, Basket *tqparent) +Note* NoteFactory::copyFileAndLoad(const KURL &url, Basket *parent) { - TQString fileName = fileNameForNewNote(tqparent, url.fileName()); - TQString fullPath = tqparent->fullPathForFileName(fileName); + TQString fileName = fileNameForNewNote(parent, url.fileName()); + TQString fullPath = parent->fullPathForFileName(fileName); if (Global::debugWindow) *Global::debugWindow << "copyFileAndLoad: " + url.prettyURL() + " to " + fullPath; // TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL()); -// tqparent->dontCareOfCreation(fullPath); +// parent->dontCareOfCreation(fullPath); // KIO::CopyJob *copyJob = KIO::copy(url, KURL(fullPath)); -// tqparent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)), -// tqparent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) ); +// parent->connect( copyJob, TQT_SIGNAL(copyingDone(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( url, KURL(fullPath), 0666, /*move=*/false, /*overwrite=*/true, /*resume=*/true, /*showProgress=*/true ); - tqparent->connect( copyJob, TQT_SIGNAL(result(KIO::Job *)), - tqparent, TQT_SLOT(slotCopyingDone2(KIO::Job *)) ); + parent->connect( copyJob, TQT_SIGNAL(result(KIO::Job *)), + parent, TQT_SLOT(slotCopyingDone2(KIO::Job *)) ); - NoteType::Id type = typeForURL(url, tqparent); // Use the type of the original file because the target doesn't exist yet - return loadFile(fileName, type, tqparent); + NoteType::Id type = typeForURL(url, parent); // Use the type of the original file because the target doesn't exist yet + return loadFile(fileName, type, parent); } -Note* NoteFactory::moveFileAndLoad(const KURL &url, Basket *tqparent) +Note* NoteFactory::moveFileAndLoad(const KURL &url, Basket *parent) { // Globally the same as copyFileAndLoad() but move instead of copy (KIO::move()) - TQString fileName = fileNameForNewNote(tqparent, url.fileName()); - TQString fullPath = tqparent->fullPathForFileName(fileName); + TQString fileName = fileNameForNewNote(parent, url.fileName()); + TQString fullPath = parent->fullPathForFileName(fileName); if (Global::debugWindow) *Global::debugWindow << "moveFileAndLoad: " + url.prettyURL() + " to " + fullPath; // TQString annotations = i18n("Original file: %1").tqarg(url.prettyURL()); -// tqparent->dontCareOfCreation(fullPath); +// parent->dontCareOfCreation(fullPath); // KIO::CopyJob *copyJob = KIO::move(url, KURL(fullPath)); -// tqparent->connect( copyJob, TQT_SIGNAL(copyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)), -// tqparent, TQT_SLOT(slotCopyingDone(KIO::Job *, const KURL &, const KURL &, bool, bool)) ); +// parent->connect( copyJob, TQT_SIGNAL(copyingDone(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( url, KURL(fullPath), 0666, /*move=*/true, /*overwrite=*/true, /*resume=*/true, /*showProgress=*/true ); - tqparent->connect( copyJob, TQT_SIGNAL(result(KIO::Job *)), - tqparent, TQT_SLOT(slotCopyingDone2(KIO::Job *)) ); + parent->connect( copyJob, TQT_SIGNAL(result(KIO::Job *)), + parent, TQT_SLOT(slotCopyingDone2(KIO::Job *)) ); - NoteType::Id type = typeForURL(url, tqparent); // Use the type of the original file because the target doesn't exist yet - return loadFile(fileName, type, tqparent); + NoteType::Id type = typeForURL(url, parent); // Use the type of the original file because the target doesn't exist yet + return loadFile(fileName, type, parent); } -Note* NoteFactory::loadFile(const TQString &fileName, Basket *tqparent) +Note* NoteFactory::loadFile(const TQString &fileName, Basket *parent) { // The file MUST exists - TQFileInfo file( KURL(tqparent->fullPathForFileName(fileName)).path() ); + TQFileInfo file( KURL(parent->fullPathForFileName(fileName)).path() ); if ( ! file.exists() ) return 0L; - NoteType::Id type = typeForURL(tqparent->fullPathForFileName(fileName), tqparent); - Note *note = loadFile(fileName, type, tqparent); + NoteType::Id type = typeForURL(parent->fullPathForFileName(fileName), parent); + Note *note = loadFile(fileName, type, parent); return note; } -Note* NoteFactory::loadFile(const TQString &fileName, NoteType::Id type, Basket *tqparent) +Note* NoteFactory::loadFile(const TQString &fileName, NoteType::Id type, Basket *parent) { - Note *note = new Note(tqparent); + Note *note = new Note(parent); switch (type) { case NoteType::Text: new TextContent( 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; } -NoteType::Id NoteFactory::typeForURL(const KURL &url, Basket */*tqparent*/) +NoteType::Id NoteFactory::typeForURL(const KURL &url, Basket */*parent*/) { /* KMimeType::Ptr kMimeType = KMimeType::findByURL(url); if (Global::debugWindow) @@ -800,37 +800,37 @@ NoteType::Id NoteFactory::typeForURL(const KURL &url, Basket */*tqparent*/) else return NoteType::File; } -TQString NoteFactory::fileNameForNewNote(Basket *tqparent, const TQString &wantedName) +TQString NoteFactory::fileNameForNewNote(Basket *parent, const TQString &wantedName) { - return Tools::fileNameForNewFile(wantedName, tqparent->fullPath()); + return Tools::fileNameForNewFile(wantedName, parent->fullPath()); } -// Create a file to store a new note in Basket tqparent 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 // (extension willn't be used for that case) -TQString NoteFactory::createFileForNewNote(Basket *tqparent, const TQString &extension, const TQString &wantedName) +TQString NoteFactory::createFileForNewNote(Basket *parent, const TQString &extension, const TQString &wantedName) { static int nb = 1; TQString fileName; TQString fullName; - if (wantedName.isEmpty()) { // TODO: fileNameForNewNote(tqparent, "note1."+extension); + if (wantedName.isEmpty()) { // TODO: fileNameForNewNote(parent, "note1."+extension); TQDir dir; for (/*int nb = 1*/; ; ++nb) { // TODO: FIXME: If overflow ??? fileName = "note" + TQString::number(nb)/*.rightJustify(5, '0')*/ + "." + extension; - fullName = tqparent->fullPath() + fileName; + fullName = parent->fullPath() + fileName; dir = TQDir(fullName); if ( ! dir.exists(fullName) ) break; } } else { - fileName = fileNameForNewNote(tqparent, wantedName); - fullName = tqparent->fullPath() + fileName; + fileName = fileNameForNewNote(parent, wantedName); + fullName = parent->fullPath() + fileName; } // Create the file -// tqparent->dontCareOfCreation(fullName); +// parent->dontCareOfCreation(fullName); TQFile file(fullName); file.open(IO_WriteOnly); 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(); } -Note* NoteFactory::createEmptyNote(NoteType::Id type, Basket *tqparent) +Note* NoteFactory::createEmptyNote(NoteType::Id type, Basket *parent) { TQPixmap *pixmap; switch (type) { case NoteType::Text: - return NoteFactory::createNoteText("", tqparent, /*reallyPlainText=*/true); + return NoteFactory::createNoteText("", parent, /*reallyPlainText=*/true); case NoteType::Html: - return NoteFactory::createNoteHtml("", tqparent); + return NoteFactory::createNoteHtml("", parent); case NoteType::Image: pixmap = new TQPixmap( TQSize(Settings::defImageX(), Settings::defImageY()) ); pixmap->fill(); pixmap->setMask(pixmap->createHeuristicMask()); - return NoteFactory::createNoteImage(*pixmap, tqparent); + return NoteFactory::createNoteImage(*pixmap, parent); case NoteType::Link: - return NoteFactory::createNoteLink(KURL(), tqparent); + return NoteFactory::createNoteLink(KURL(), parent); case NoteType::Launcher: - return NoteFactory::createNoteLauncher(KURL(), tqparent); + return NoteFactory::createNoteLauncher(KURL(), parent); case NoteType::Color: - return NoteFactory::createNoteColor(TQt::black, tqparent); + return NoteFactory::createNoteColor(TQt::black, parent); default: case NoteType::Animation: case NoteType::Sound: @@ -968,9 +968,9 @@ Note* NoteFactory::createEmptyNote(NoteType::Id type, Basket *tqparent) } } -Note* NoteFactory::importKMenuLauncher(Basket *tqparent) +Note* NoteFactory::importKMenuLauncher(Basket *parent) { - KOpenWithDlg dialog(tqparent); + KOpenWithDlg dialog(parent); dialog.setSaveNewApplications(true); // To create temp file, needed by createNoteLauncher() dialog.exec(); if (dialog.service()) { @@ -979,12 +979,12 @@ Note* NoteFactory::importKMenuLauncher(Basket *tqparent) TQString serviceUrl = dialog.service()->desktopEntryPath(); if ( ! serviceUrl.startsWith("/") ) serviceUrl = dialog.service()->locateLocal(); //locateLocal("xdgdata-apps", serviceUrl); - return createNoteLauncher(serviceUrl, tqparent); + return createNoteLauncher(serviceUrl, parent); } return 0; } -Note* NoteFactory::importIcon(Basket *tqparent) +Note* NoteFactory::importIcon(Basket *parent) { TQString iconName = KIconDialog::getIcon( KIcon::Desktop, KIcon::Application, false, Settings::defIconSize() ); if ( ! iconName.isEmpty() ) { @@ -993,16 +993,16 @@ Note* NoteFactory::importIcon(Basket *tqparent) if (dialog.iconSize() > 0) { Settings::setDefIconSize(dialog.iconSize()); Settings::saveConfig(); - return createNoteImage( DesktopIcon(iconName, dialog.iconSize()), tqparent ); // TODO: wantedName = iconName ! + return createNoteImage( DesktopIcon(iconName, dialog.iconSize()), parent ); // TODO: wantedName = iconName ! } } return 0; } -Note* NoteFactory::importFileContent(Basket *tqparent) +Note* NoteFactory::importFileContent(Basket *parent) { - KURL url = KFileDialog::getOpenURL( TQString(), TQString(), tqparent, i18n("Load File Content into a Note") ); + KURL url = KFileDialog::getOpenURL( TQString(), TQString(), parent, i18n("Load File Content into a Note") ); if ( ! url.isEmpty() ) - return copyFileAndLoad(url, tqparent); + return copyFileAndLoad(url, parent); return 0; } |