bool BookmarksModel::createFolder(const QString &name) { if (isFolder(name)) { return false; } QSqlQuery query; query.prepare("INSERT INTO folders (name, subfolder) VALUES (?, 'no')"); query.bindValue(0, name); if (!query.exec()) { return false; } emit folderAdded(name); mApp->sendMessages(Qz::AM_BookmarksChanged, true); return true; }
BookmarksSideBar::BookmarksSideBar(QupZilla* mainClass, QWidget* parent) : QWidget(parent) , m_isRefreshing(false) , ui(new Ui::BookmarksSideBar) , p_QupZilla(mainClass) , m_bookmarksModel(mApp->bookmarksModel()) { ui->setupUi(this); ui->bookmarksTree->setViewType(BookmarksTree::SideBarView); ui->bookmarksTree->setSelectionBehavior(QAbstractItemView::SelectRows); ui->bookmarksTree->setDragDropReceiver(true, m_bookmarksModel); ui->bookmarksTree->setMimeType(QLatin1String("application/qupzilla.treewidgetitem.bookmarks")); ui->expandAll->setIcon(QIcon::fromTheme("view-sort-ascending", QIcon(":/icons/faenza/expand.png"))); ui->collapseAll->setIcon(QIcon::fromTheme("view-sort-descending", QIcon(":/icons/faenza/collapse.png"))); ui->bookmarksTree->setDefaultItemShowMode(TreeWidget::ItemsExpanded); connect(ui->bookmarksTree, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(ui->bookmarksTree, SIGNAL(itemControlClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*))); connect(ui->bookmarksTree, SIGNAL(itemMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(itemControlClicked(QTreeWidgetItem*))); connect(ui->bookmarksTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*))); connect(ui->search, SIGNAL(textChanged(QString)), ui->bookmarksTree, SLOT(filterString(QString))); connect(ui->collapseAll, SIGNAL(clicked()), ui->bookmarksTree, SLOT(collapseAll())); connect(ui->expandAll, SIGNAL(clicked()), ui->bookmarksTree, SLOT(expandAll())); connect(m_bookmarksModel, SIGNAL(bookmarkAdded(BookmarksModel::Bookmark)), this, SLOT(addBookmark(BookmarksModel::Bookmark))); connect(m_bookmarksModel, SIGNAL(bookmarkDeleted(BookmarksModel::Bookmark)), this, SLOT(removeBookmark(BookmarksModel::Bookmark))); connect(m_bookmarksModel, SIGNAL(bookmarkEdited(BookmarksModel::Bookmark,BookmarksModel::Bookmark)), this, SLOT(bookmarkEdited(BookmarksModel::Bookmark,BookmarksModel::Bookmark))); connect(m_bookmarksModel, SIGNAL(folderAdded(QString)), this, SLOT(addFolder(QString))); connect(m_bookmarksModel, SIGNAL(folderDeleted(QString)), this, SLOT(removeFolder(QString))); connect(m_bookmarksModel, SIGNAL(folderRenamed(QString,QString)), this, SLOT(renameFolder(QString,QString))); connect(m_bookmarksModel, SIGNAL(folderParentChanged(QString,bool)), this, SLOT(changeFolderParent(QString,bool))); connect(m_bookmarksModel, SIGNAL(bookmarkParentChanged(QString,QByteArray,int,QUrl,QString,QString)), this, SLOT(changeBookmarkParent(QString,QByteArray,int,QUrl,QString,QString))); QTimer::singleShot(0, this, SLOT(refreshTable())); }