AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager) : QDialog(parent) , m_url(url) , m_bookmarksManager(bookmarkManager) { setWindowFlags(Qt::Sheet); if (!m_bookmarksManager) m_bookmarksManager = BrowserApplication::bookmarksManager(); setupUi(this); QTreeView *view = new QTreeView(this); m_proxyModel = new AddBookmarkProxyModel(this); BookmarksModel *model = m_bookmarksManager->bookmarksModel(); m_proxyModel->setSourceModel(model); view->setModel(m_proxyModel); view->expandAll(); view->header()->setStretchLastSection(true); view->header()->hide(); view->setItemsExpandable(false); view->setRootIsDecorated(false); view->setIndentation(10); location->setModel(m_proxyModel); view->show(); location->setView(view); BookmarkNode *menu = m_bookmarksManager->menu(); QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu)); view->setCurrentIndex(idx); location->setCurrentIndex(idx.row()); name->setText(title); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksItemDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const { BookmarksModel* bModel = qobject_cast<BookmarksModel*>(model); QLineEdit* line = static_cast<QLineEdit*>(editor); QString value = line->text(); if (value.isEmpty() == false) { QModelIndex bIndex = bModel->index(index.row(), BookmarksItem::Name, index.parent()); bModel->setData(bIndex, value, Qt::DisplayRole); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void BookmarksModel::moveIndexInternally(const QModelIndex& index, QModelIndex& oldParent, QModelIndex& newParent) { BookmarksModel* tempModel = new BookmarksModel(); // Copy the sub-tree to a temporary model, to retain its data and structure copyIndexToTemp(index, oldParent, QModelIndex(), tempModel); // Now copy the sub-tree to its new position for (int i = 0; i < tempModel->rowCount(QModelIndex()); i++) { QModelIndex tempIndex = tempModel->index(i, BookmarksItem::Name, QModelIndex()); copyTempToIndex(tempIndex, newParent, QModelIndex(), tempModel); } // Remove the index from its original spot self->removeRow(index.row(), oldParent); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SIMPLView_UI::checkFirstRun() { // Launch v6.0 dialog box if this is the first run of v6.0 SIMPLViewSettings prefs; bool firstRun = prefs.value("First Run", true).toBool(); if (firstRun == true) { // This is the first run of SIMPLView v6.0, so we need to show the v6.0 wizard SIMPLViewv6Wizard* wizard = new SIMPLViewv6Wizard(this, Qt::WindowTitleHint); wizard->exec(); bool value = wizard->isBookmarkBtnChecked(); if (value == true) { BookmarksModel* model = BookmarksModel::Instance(); model->insertRow(0, QModelIndex()); QModelIndex nameIndex = model->index(0, BookmarksItem::Name, QModelIndex()); model->setData(nameIndex, "SIMPLView v4 Favorites", Qt::DisplayRole); model->setData(nameIndex, QIcon(":/folder_blue.png"), Qt::DecorationRole); QDir favoritesDir = getBookmarksToolboxWidget()->findV4FavoritesDirectory(); QString favoritesPath = favoritesDir.path(); QFileInfo fi(favoritesPath); if (fi.exists() && favoritesPath.isEmpty() == false) { QDirIterator iter(favoritesPath, QDir::AllDirs | QDir::Files | QDir::NoDotAndDotDot); while (iter.hasNext()) { QString path = iter.next(); model->addFileToTree(path, nameIndex); } } } } }