diff --git a/src/basket_part.rc b/src/basket_part.rc --- a/src/basket_part.rc +++ b/src/basket_part.rc @@ -1,6 +1,6 @@ - + &Basket @@ -27,16 +27,6 @@ &Import - - - - - - - - - - @@ -188,16 +178,6 @@ &Import - - - - - - - - - - @@ -209,16 +189,6 @@ &Import - - - - - - - - - - diff --git a/src/basketui.rc b/src/basketui.rc --- a/src/basketui.rc +++ b/src/basketui.rc @@ -1,6 +1,6 @@ - + &Basket @@ -27,16 +27,6 @@ &Import - - - - - - - - - - @@ -195,16 +185,6 @@ &Import - - - - - - - - - - @@ -216,16 +196,6 @@ &Import - - - - - - - - - - diff --git a/src/bnpview.h b/src/bnpview.h --- a/src/bnpview.h +++ b/src/bnpview.h @@ -108,13 +108,6 @@ void newFilterFromFilterBar(); bool isFilteringAllBaskets(); // From main window - void importKNotes(); - void importKJots(); - void importKnowIt(); - void importTuxCards(); - void importStickyNotes(); - void importTomboy(); - void importJreepadFile(); void importTextFile(); void backupRestore(); void checkCleanup(); diff --git a/src/bnpview.cpp b/src/bnpview.cpp --- a/src/bnpview.cpp +++ b/src/bnpview.cpp @@ -499,42 +499,7 @@ a->setShortcut(0); m_actExportToHtml = a; - a = ac->addAction("basket_import_knotes", this, SLOT(importKNotes())); - a->setText(i18n("K&Notes")); - a->setIcon(QIcon::fromTheme("knotes")); - a->setShortcut(0); - - a = ac->addAction("basket_import_kjots", this, SLOT(importKJots())); - a->setText(i18n("K&Jots")); - a->setIcon(QIcon::fromTheme("kjots")); - a->setShortcut(0); - - a = ac->addAction("basket_import_knowit", this, SLOT(importKnowIt())); - a->setText(i18n("&KnowIt...")); - a->setIcon(QIcon::fromTheme("knowit")); - a->setShortcut(0); - - a = ac->addAction("basket_import_tuxcards", this, SLOT(importTuxCards())); - a->setText(i18n("Tux&Cards...")); - a->setIcon(QIcon::fromTheme("tuxcards")); - a->setShortcut(0); - - a = ac->addAction("basket_import_sticky_notes", this, SLOT(importStickyNotes())); - a->setText(i18n("&Sticky Notes")); - a->setIcon(QIcon::fromTheme("gnome")); - a->setShortcut(0); - - a = ac->addAction("basket_import_tomboy", this, SLOT(importTomboy())); - a->setText(i18n("&Tomboy")); - a->setIcon(QIcon::fromTheme(IconNames::TOMBOY)); - a->setShortcut(0); - - a = ac->addAction("basket_import_jreepad_file", this, SLOT(importJreepadFile())); - a->setText(i18n("J&reepad XML File...")); - a->setIcon(QIcon::fromTheme("text-xml")); - a->setShortcut(0); - - a = ac->addAction("basket_import_text_file", this, SLOT(importTextFile())); + a = ac->addAction("basket_import_text_file", this, &BNPView::importTextFile); a->setText(i18n("Text &File...")); a->setIcon(QIcon::fromTheme("text-plain")); a->setShortcut(0); @@ -1571,34 +1536,6 @@ currentDecoratedBasket()->resetFilter(); } -void BNPView::importKJots() -{ - SoftwareImporters::importKJots(); -} -void BNPView::importKNotes() -{ - SoftwareImporters::importKNotes(); -} -void BNPView::importKnowIt() -{ - SoftwareImporters::importKnowIt(); -} -void BNPView::importTuxCards() -{ - SoftwareImporters::importTuxCards(); -} -void BNPView::importStickyNotes() -{ - SoftwareImporters::importStickyNotes(); -} -void BNPView::importTomboy() -{ - SoftwareImporters::importTomboy(); -} -void BNPView::importJreepadFile() -{ - SoftwareImporters::importJreepadFile(); -} void BNPView::importTextFile() { SoftwareImporters::importTextFile(); diff --git a/src/softwareimporters.h b/src/softwareimporters.h --- a/src/softwareimporters.h +++ b/src/softwareimporters.h @@ -68,26 +68,10 @@ */ namespace SoftwareImporters { -// Useful methods to design importers: -QString fromICS(const QString &ics); -QString fromTomboy(QString tomboy); -//! Get first of the to be used as basket name. Strip 'system:notebook:' part -QString getFirstTomboyTag(const QDomElement &docElem); -Note *insertTitledNote(BasketScene *parent, const QString &title, const QString &content, Qt::TextFormat format = Qt::PlainText, Note *parentNote = nullptr); void finishImport(BasketScene *basket); // The importers in themselves: -void importKNotes(); -void importKJots(); -void importKnowIt(); -void importTuxCards(); -void importStickyNotes(); -void importTomboy(); -void importJreepadFile(); void importTextFile(); - -// -void importTuxCardsNode(const QDomElement &element, BasketScene *parentBasket, Note *parentNote, int remainingHierarchy); } #endif // SOFTWAREIMPORTERS_H diff --git a/src/softwareimporters.cpp b/src/softwareimporters.cpp --- a/src/softwareimporters.cpp +++ b/src/softwareimporters.cpp @@ -186,118 +186,6 @@ /** namespace SoftwareImporters: */ -QString SoftwareImporters::fromICS(const QString &ics) -{ - QString result = ics; - - // Remove escaped '\' characters and append the text to the body - int pos = 0; - while ((pos = result.indexOf('\\', pos)) != -1) { - if (pos == result.length() - 1) // End of string - break; - if (result[pos + 1] == 'n') { - result.replace(pos, 2, '\n'); - } else if (result[pos + 1] == 'r') { - result.replace(pos, 2, '\r'); - } else if (result[pos + 1] == 't') { - result.replace(pos, 2, '\t'); - } else if (result[pos] == '\\') { - result.remove(pos, 1); // Take care of "\\", "\,", "\;" and other escaped characters I haven't noticed - ++pos; - } - } - - return result; -} - -QString SoftwareImporters::fromTomboy(QString tomboy) -{ - // The first line is the note title, and we already have it, so we remove it (yes, that's pretty stupid to duplicate it in the content...): - tomboy = tomboy.mid(tomboy.indexOf("\n")).trimmed(); - - // Font styles and decorations: - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - - // Highlight not supported by KTextEdit: - // TODO: implement this marker-style yellow highlight? - tomboy.replace("", ""); - tomboy.replace("", ""); - - // Font sizes: - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - tomboy.replace("", ""); - - // Internal links to other notes aren't supported yet by BasKet Note Pads: - tomboy.replace("", QString()); - tomboy.replace("", QString()); - - // Bullets - tomboy.replace("", "
    "); - tomboy.replace("", "
"); - - QRegExp tagRegex(""); - tagRegex.setMinimal(true); // non-greedy - tomboy.replace(QRegExp(tagRegex), "
  • "); - tomboy.replace("", "
  • "); - - // In the Tomboy file, new lines are "\n" and not "
    ": - tomboy.replace('\n', "
    \n"); - - // Preserve consecutive spaces: - return "" + tomboy + ""; -} - -QString SoftwareImporters::getFirstTomboyTag(const QDomElement &docElem) -{ - // Would be better to take the last tag (latest user choice), but that requires more DOM code - - QString tag = XMLWork::getElementText(docElem, "tags/tag"); - if (tag.length() > 0) { - // Carefully peel the markup - const QString SYSTEM_PREFIX = "system:"; - const QString NOTEBOOK_PREFIX = "notebook:"; - - if (tag.startsWith(SYSTEM_PREFIX)) - tag.remove(0, SYSTEM_PREFIX.length()); - - if (tag.startsWith(NOTEBOOK_PREFIX)) - tag.remove(0, NOTEBOOK_PREFIX.length()); - } - - return tag; -} - -Note *SoftwareImporters::insertTitledNote(BasketScene *parent, const QString &title, const QString &content, Qt::TextFormat format /* = Qt::PlainText*/, Note *parentNote /* = 0*/) -{ - Note *nGroup = new Note(parent); - - Note *nTitle = NoteFactory::createNoteText(title, parent); - nTitle->addState(Tag::stateForId("title")); - - Note *nContent; - if (format == Qt::PlainText) - nContent = NoteFactory::createNoteText(content, parent); - else - nContent = NoteFactory::createNoteHtml(content, parent); - - if (parentNote == nullptr) - parentNote = parent->firstNote(); // In the first column! - parent->insertNote(nGroup, parentNote, Note::BottomColumn, QPoint(), /*animate=*/false); - parent->insertNote(nTitle, nGroup, Note::BottomColumn, QPoint(), /*animate=*/false); - parent->insertNote(nContent, nTitle, Note::BottomInsert, QPoint(), /*animate=*/false); - - return nGroup; -} - void SoftwareImporters::finishImport(BasketScene *basket) { // Unselect the last inserted group: @@ -312,322 +200,6 @@ basket->save(); } -void SoftwareImporters::importKJots() -{ - // This code is out-of-date. KJots (KDE4) and KNotes (KDE4, 5) now store data in Akonadi and MIME files in .local/share/notes - QString dirPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/../kjots/"; // I think the assumption is good - QDir dir(dirPath, QString(), QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); - - QStringList list = dir.entryList(); - if (list.isEmpty()) - return; - - BasketFactory::newBasket(QStringLiteral("kjots"), i18n("From KJots")); - BasketScene *kjotsBasket = Global::bnpView->currentBasket(); - - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // For each file - QFile file(dirPath + *it); - if (file.open(QIODevice::ReadOnly)) { - QTextStream stream(&file); - QString buf = stream.readLine(); - - // IT IS A NOTEBOOK FILE, AT THE VERION 0.6.x and older: - if (!buf.isNull() && buf.left(9) == "\\NewEntry") { - // First create a basket for it: - BasketFactory::newBasket(QStringLiteral("kjots"), - QUrl::fromLocalFile(file.fileName()).fileName(), - kjotsBasket); - BasketScene *basket = Global::bnpView->currentBasket(); - basket->load(); - - QString title, body; - bool haveAnEntry = false; - while (1) { - if (buf.left(9) == "\\NewEntry") { - if (haveAnEntry) // Do not add note the first time - insertTitledNote(basket, title, Tools::stripEndWhiteSpaces(body)); - title = buf.mid(10, buf.length()); // Problem : basket will be saved - body = QString(); // New note will then be created // EACH time a note is imported - haveAnEntry = true; - } else if (buf.left(3) != "\\ID") { // Don't care of the ID - // Remove escaped '\' characters and append the text to the body - int pos = 0; - while ((pos = buf.indexOf('\\', pos)) != -1) - if (buf[++pos] == '\\') - buf.remove(pos, 1); - body.append(buf + '\n'); - } - buf = stream.readLine(); - if (buf.isNull()) // OEF - break; - } - // Add the ending note (there isn't any other "\\NewEntry" to do it): - if (haveAnEntry) - insertTitledNote(basket, title, Tools::stripEndWhiteSpaces(body)); - finishImport(basket); - - // IT IS A NOTEBOOK XML FILE, AT THE VERION 0.7.0 and later: - } else if ((*it).endsWith(QLatin1String(".book")) /*&& !buf.isNull() && (buf.left(2) == "documentElement(), "KJotsBook/Title"); - - // First create a basket for it: - BasketFactory::newBasket(QStringLiteral("kjots"), bookTitle, kjotsBasket); - BasketScene *basket = Global::bnpView->currentBasket(); - basket->load(); - - QDomElement docElem = XMLWork::getElement(doc->documentElement(), "KJotsBook"); - for (QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); - if ((!e.isNull()) && e.tagName() == "KJotsPage") - insertTitledNote(basket, XMLWork::getElementText(e, "Title"), XMLWork::getElementText(e, "Text")); - } - finishImport(basket); - } - - file.close(); - } - } -} - -void SoftwareImporters::importKNotes() -{ - QString dirPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/../knotes/"; // I think the assumption is good - QDir dir(dirPath, QString(), QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); - - QStringList list = dir.entryList(); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // For each file - if (!(*it).endsWith(QLatin1String(".ics"))) // Don't process *.ics~ and other files - continue; - QFile file(dirPath + *it); - if (file.open(QIODevice::ReadOnly)) { - QTextStream stream(&file); - stream.setCodec("UTF-8"); - - // First create a basket for it: - BasketFactory::newBasket(QStringLiteral("knotes"), i18n("From KNotes")); - BasketScene *basket = Global::bnpView->currentBasket(); - basket->load(); - - bool inVJournal = false; - bool inDescription = false; - bool isRichText = false; - QString title, body; - QString buf; - while (1) { - buf = stream.readLine(); - if (buf.isNull()) // OEF - break; - - if (!buf.isNull() && buf == "BEGIN:VJOURNAL") { - inVJournal = true; - } else if (inVJournal && buf.startsWith(QLatin1String("SUMMARY:"))) { - title = buf.mid(8, buf.length()); - } else if (inVJournal && buf.startsWith(QLatin1String("DESCRIPTION:"))) { - body = buf.mid(12, buf.length()); - inDescription = true; - } else if (inDescription && buf.startsWith(QLatin1String(" "))) { - body += buf.mid(1, buf.length()); - } else if (buf.startsWith(QLatin1String("X-KDE-KNotes-RichText:"))) { - isRichText = XMLWork::trueOrFalse(buf.mid(22, buf.length() - 22).trimmed(), "false"); - } else if (buf == "END:VJOURNAL") { - insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? Qt::RichText : Qt::PlainText)); - inVJournal = false; - inDescription = false; - isRichText = false; - title = QString(); - body = QString(); - } else - inDescription = false; - } - - // Bouh : duplicate code - // In case of invalid ICAL file! - if (!body.isEmpty()) // Add the ending note - insertTitledNote(basket, fromICS(title), fromICS(body), (isRichText ? Qt::RichText : Qt::PlainText)); - file.close(); - finishImport(basket); - } - } -} - -void SoftwareImporters::importStickyNotes() -{ - // Sticky Notes file is usually located in ~/.gnome2/stickynotes_applet - // We will search all directories in "~/" that contain "gnome" in the name, - // and will search for "stickynotes_applet" file (that should be XML file with root. - QDir dir(QDir::home().absolutePath(), QString(), QDir::Name | QDir::IgnoreCase, QDir::Dirs | QDir::NoSymLinks | QDir::Hidden); - QStringList founds; - - QStringList list = dir.entryList(); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // For each folder - if ((*it).contains("gnome", Qt::CaseInsensitive)) { - QString fullPath = QDir::home().absolutePath() + '/' + (*it) + "/stickynotes_applet"; - if (dir.exists(fullPath)) - founds += fullPath; - } - } - - for (QStringList::Iterator it = founds.begin(); it != founds.end(); ++it) { // For each file - QFile file(*it); - QDomDocument *doc = XMLWork::openFile("stickynotes", *it); - if (doc == nullptr) - continue; - - // First create a basket for it: - BasketFactory::newBasket(QStringLiteral("gnome"), i18n("From Sticky Notes")); - BasketScene *basket = Global::bnpView->currentBasket(); - basket->load(); - - QDomElement docElem = doc->documentElement(); - for (QDomNode n = docElem.firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); - if ((!e.isNull()) && e.tagName() == "note") - insertTitledNote(basket, e.attribute("title"), e.text()); - } - finishImport(basket); - } -} - -// TODO: FIXME: Code duplicated from notecontent.cpp but with UTF-8 encoding. -// TODO: FIXME: Later, merge! -QString loadUtf8FileToString(const QString &fileName) -{ - QFile file(fileName); - if (file.open(QIODevice::ReadOnly)) { - QTextStream stream(&file); - stream.setCodec("UTF-8"); - QString text; - text = stream.readAll(); - file.close(); - return text; - } else - return QString(); -} - -void SoftwareImporters::importTomboy() -{ - /* A notebook becomes a basket. - What can be improved: separate big text into notes by "\n\n"; - remove "\n" from lists - we don't need
    between two
  • s */ - - BasketScene *basketFromTomboy = nullptr; // Create the basket ONLY if we found at least one note to add! - BasketScene *subBasket; // Where are we adding current note? (can equal basketFromTomboy if the note is in generic notebook) - QMap subBuskets; // "notebook name - basket" correspondence - - QString possibleLocations[2] = {"/.tomboy/", "/.local/share/tomboy/"}; - for (int L = 0; L < 2; L++) { - QString dirPath = QDir::home().absolutePath() + possibleLocations[L]; - QDir dir(dirPath, QString(), QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::NoSymLinks); - DEBUG_WIN << "Tomboy import: Checking " + dirPath; - - QStringList list = dir.entryList(); - for (QStringList::Iterator it = list.begin(); it != list.end(); ++it) { // For each file - if (!(*it).endsWith(QLatin1String(".note"))) - continue; - QDomDocument *doc = XMLWork::openFile("note", dirPath + *it); - if (doc == nullptr) - continue; - - if (basketFromTomboy == nullptr) { - // First create a basket for it: - BasketFactory::newBasket(IconNames::TOMBOY, i18n("From Tomboy")); - basketFromTomboy = Global::bnpView->currentBasket(); - basketFromTomboy->load(); - } - - QDomElement docElem = doc->documentElement(); - QString title = XMLWork::getElementText(docElem, "title"); - QString notebook = getFirstTomboyTag(docElem); //!< Tomboy notebook name - - // Find subbasket or create a new one - if (notebook.length() > 0) { - if (subBuskets.contains(notebook)) - subBasket = subBuskets[notebook]; - else { - BasketFactory::newBasket(IconNames::TOMBOY, notebook, basketFromTomboy); - subBasket = Global::bnpView->currentBasket(); // TODO: ? change newBasket() so that it returns pointer and we don't have to load it - subBasket->load(); - - subBuskets.insert(notebook, subBasket); - } - } else - subBasket = basketFromTomboy; // will insert to the root basket - - // DOES NOT REALLY WORKS: - // QDomElement contentElement = XMLWork::getElement(docElem, "text/note-content"); - // QString content = XMLWork::innerXml(contentElement); - - // Isolate "CONTENT"! - QString xml = loadUtf8FileToString(dirPath + *it); - xml = xml.mid(xml.indexOf("") + 1); - xml = xml.mid(0, xml.indexOf("")); - - if (!title.isEmpty() && !/*content*/ xml.isEmpty()) { - insertTitledNote(subBasket, title, fromTomboy(xml /*content*/), Qt::RichText); - DEBUG_WIN << QString("Tomboy import: Inserting note '%1' into '%2'").arg(title, notebook); - } - } - } - - if (basketFromTomboy) - finishImport(basketFromTomboy); -} - -void SoftwareImporters::importJreepadFile() -{ - typedef QPair basketAndElementPair; - - QString fileName = QFileDialog::getOpenFileName(nullptr, QString(), "kfiledialog:///:ImportJreepadFile", "*.xml|XML files"); - if (fileName.isEmpty()) { - return; - } - - basketAndElementPair newElement; - basketAndElementPair currentElement; - QList elements; - QList basketList; - - QDomDocument *doc = XMLWork::openFile("node", fileName); - newElement.second = doc->documentElement(); - - BasketScene *basket = nullptr; - BasketFactory::newBasket(QStringLiteral("xml"), doc->documentElement().attribute("title")); - basket = Global::bnpView->currentBasket(); - basket->load(); - basketList << basket; - newElement.first = basket; - - elements << newElement; - - while (!elements.isEmpty()) { - currentElement = elements.takeFirst(); - for (QDomNode n = currentElement.second.firstChild(); !n.isNull(); n = n.nextSibling()) { - if (n.isText()) { - basket = currentElement.first; - Note *note = NoteFactory::createNoteFromText(n.toText().data(), basket); - basket->insertNote(note, basket->firstNote(), Note::BottomColumn, QPoint(), /*animate=*/false); - } else if (n.isElement()) { - BasketFactory::newBasket(QStringLiteral("xml"), n.toElement().attribute("title"), currentElement.first); - basket = Global::bnpView->currentBasket(); - basket->load(); - basketList << basket; - newElement.first = basket; - newElement.second = n.toElement(); - elements << newElement; - } - } - } - - foreach (basket, basketList) { - finishImport(basket); - } -} - void SoftwareImporters::importTextFile() { QString fileName = QFileDialog::getOpenFileName(nullptr, QString(), "kfiledialog:///:ImportTextFile", "*|All files"); @@ -662,156 +234,3 @@ } } -/** @author Petri Damsten - */ -void SoftwareImporters::importKnowIt() -{ - QUrl url = QFileDialog::getOpenFileUrl(nullptr, QString(), QUrl("kfiledialog:///:ImportKnowIt"), "*.kno|KnowIt files\n*|All files"); - if (!url.isEmpty()) { - QFile file(url.path()); - QFileInfo info(url.path()); - BasketScene *basket = nullptr; - QStack baskets; - QString text; - int hierarchy = 0; - - TreeImportDialog dialog; - if (dialog.exec() == QDialog::Rejected) - return; - - hierarchy = dialog.choice(); - - BasketFactory::newBasket(QStringLiteral("knowit"), info.baseName()); - basket = Global::bnpView->currentBasket(); - basket->load(); - baskets.push(basket); - - if (file.open(QIODevice::ReadOnly)) { - QTextStream stream(&file); - int level = 0; - QString name; - QString line; - QStringList links; - QStringList descriptions; - - stream.setCodec("UTF-8"); - while (1) { - line = stream.readLine(); - - if (line.startsWith(QLatin1String("\\NewEntry")) || line.startsWith(QLatin1String("\\CurrentEntry")) || stream.atEnd()) { - while (level + 1 < baskets.size() - baskets.count(0)) - baskets.pop(); - if (level + 1 > baskets.size() - baskets.count(0)) - baskets.push(basket); - - if (!name.isEmpty()) { - if ((level == 0 && hierarchy == 1) || (hierarchy == 0)) { - BasketFactory::newBasket(QStringLiteral("knowit"), name, baskets.top()); - basket = Global::bnpView->currentBasket(); - basket->load(); - } - - if (!text.trimmed().isEmpty() || hierarchy == 2 || (hierarchy == 1 && level > 0)) { - insertTitledNote(basket, name, text, Qt::RichText); - } - for (int j = 0; j < links.count(); ++j) { - Note *link; - if (descriptions.count() < j + 1 || descriptions[j].isEmpty()) - link = NoteFactory::createNoteLink(links[j], basket); - else - link = NoteFactory::createNoteLink(links[j], descriptions[j], basket); - basket->insertCreatedNote(link); - } - finishImport(basket); - } - if (stream.atEnd()) - break; - - int i = line.indexOf("Entry") + 6; - int n = line.indexOf(' ', i); - level = line.mid(i, n - i).toInt(); - name = line.mid(n + 1); - text = QString(); - links.clear(); - descriptions.clear(); - } else if (line.startsWith(QLatin1String("\\Link"))) { - links.append(line.mid(6)); - } else if (line.startsWith(QLatin1String("\\Descr"))) { - while (descriptions.count() < links.count() - 1) - descriptions.append(QString()); - descriptions.append(line.mid(7)); - } else { - text += line + '\n'; - } - } - file.close(); - } - } -} - -void SoftwareImporters::importTuxCards() -{ - QString fileName = QFileDialog::getOpenFileName(nullptr, QString(), "kfiledialog:///:ImportTuxCards", "*|All files"); - if (fileName.isEmpty()) - return; - - TreeImportDialog dialog; - if (dialog.exec() == QDialog::Rejected) - return; - - int hierarchy = dialog.choice(); - - QDomDocument *document = XMLWork::openFile("tuxcards_data_file" /*"InformationCollection"*/, fileName); - if (document == nullptr) { - KMessageBox::error(nullptr, i18n("Can not import that file. It is either corrupted or not a TuxCards file."), i18n("Bad File Format")); - return; - } - - QDomElement collection = document->documentElement(); - int remainingHierarchy = (hierarchy == 0 ? 65000 : 3 - hierarchy); - importTuxCardsNode(collection, /*parentBasket=*/nullptr, /*parentNote=*/nullptr, remainingHierarchy); -} - -// TODO: Encrypted note.
    The importer do not support encrypted notes yet. Please remove the encryption with TuxCards and re-import the file."); - } - - if (remainingHierarchy > 0) { - BasketFactory::newBasket(icon, name, parentBasket); - BasketScene *basket = Global::bnpView->currentBasket(); - basket->load(); - - if (isRichText) - nContent = NoteFactory::createNoteHtml(content, basket); - else - nContent = NoteFactory::createNoteText(content, basket); - basket->insertNote(nContent, basket->firstNote(), Note::BottomColumn, QPoint(), /*animate=*/false); - - importTuxCardsNode(e, basket, nullptr, remainingHierarchy - 1); - finishImport(basket); - } else { - Note *nGroup = insertTitledNote(parentBasket, name, content, (isRichText ? Qt::RichText : Qt::PlainText), parentNote); - importTuxCardsNode(e, parentBasket, nGroup, remainingHierarchy - 1); - } - } -}