1 /************************************************************************** 2 * Otter Browser: Web browser controlled by the user, not vice-versa. 3 * Copyright (C) 2014 Piotr Wójcik <chocimier@tlen.pl> 4 * Copyright (C) 2014 - 2018 Michal Dutkiewicz aka Emdek <michal@emdek.pl> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 * 19 **************************************************************************/ 20 21 #include "BookmarksImporter.h" 22 #include "BookmarksManager.h" 23 24 namespace Otter 25 { 26 BookmarksImporter(QObject * parent)27BookmarksImporter::BookmarksImporter(QObject *parent) : Importer(parent), 28 m_currentFolder(nullptr), 29 m_importFolder(nullptr), 30 m_areDuplicatesAllowed(true) 31 { 32 setImportFolder(BookmarksManager::getModel()->getRootItem()); 33 } 34 goToParent()35void BookmarksImporter::goToParent() 36 { 37 if (m_currentFolder == m_importFolder) 38 { 39 return; 40 } 41 42 if (m_currentFolder) 43 { 44 m_currentFolder = static_cast<BookmarksModel::Bookmark*>(m_currentFolder->parent()); 45 } 46 47 if (!m_currentFolder) 48 { 49 m_currentFolder = (m_importFolder ? m_importFolder : BookmarksManager::getModel()->getRootItem()); 50 } 51 } 52 removeAllBookmarks()53void BookmarksImporter::removeAllBookmarks() 54 { 55 BookmarksManager::getModel()->getRootItem()->removeRows(0, BookmarksManager::getModel()->getRootItem()->rowCount()); 56 } 57 setAllowDuplicates(bool allow)58void BookmarksImporter::setAllowDuplicates(bool allow) 59 { 60 m_areDuplicatesAllowed = allow; 61 } 62 setCurrentFolder(BookmarksModel::Bookmark * folder)63void BookmarksImporter::setCurrentFolder(BookmarksModel::Bookmark *folder) 64 { 65 m_currentFolder = folder; 66 } 67 setImportFolder(BookmarksModel::Bookmark * folder)68void BookmarksImporter::setImportFolder(BookmarksModel::Bookmark *folder) 69 { 70 m_importFolder = folder; 71 m_currentFolder = folder; 72 } 73 getCurrentFolder() const74BookmarksModel::Bookmark* BookmarksImporter::getCurrentFolder() const 75 { 76 return m_currentFolder; 77 } 78 getImportFolder() const79BookmarksModel::Bookmark* BookmarksImporter::getImportFolder() const 80 { 81 return m_importFolder; 82 } 83 getImportType() const84Importer::ImportType BookmarksImporter::getImportType() const 85 { 86 return BookmarksImport; 87 } 88 areDuplicatesAllowed() const89bool BookmarksImporter::areDuplicatesAllowed() const 90 { 91 return m_areDuplicatesAllowed; 92 } 93 94 } 95