void BookmarksWidget::init() { // The locationbar's direction is direction of its text, // it dynamically changes and so, it's not good choice for this widget. setLayoutDirection(QApplication::layoutDirection()); // Init SpeedDial button const SpeedDial::Page page = m_speedDial->pageForUrl(m_view->url()); if (page.url.isEmpty()) { ui->speeddialButton->setFlat(true); ui->speeddialButton->setText(tr("Add to Speed Dial")); } else { ui->speeddialButton->setFlat(false); ui->speeddialButton->setText(tr("Remove from Speed Dial")); } // Init Bookmarks button if (m_bookmark) { ui->bookmarksButton->setText(tr("Remove from Bookmarks")); ui->bookmarksButton->setFlat(false); Q_ASSERT(m_bookmark->parent()); ui->folderButton->setSelectedFolder(m_bookmark->parent()); connect(ui->folderButton, SIGNAL(selectedFolderChanged(BookmarkItem*)), SLOT(bookmarkEdited())); } connect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial())); connect(ui->bookmarksButton, SIGNAL(clicked()), this, SLOT(toggleBookmark())); }
void Buffer::onMarginClicked(int position, int, int margin) { if (margin == Fold) { toggleFold(lineFromPosition(position)); } else if (margin == Icon) { toggleBookmark(lineFromPosition(position)); } }
void DocumentEditor::setBookmarks(const QStringList& lines_) { removeAllBookmarks(); for (int i = 0; i < lines_.size(); i++) { int line = lines_.at(i).toInt(); toggleBookmark(1, line, Qt::NoModifier); } }
void BookmarksWidget::closePopup() { // Prevent clicking again on buttons while popup is being closed disconnect(ui->speeddialButton, SIGNAL(clicked()), this, SLOT(toggleSpeedDial())); disconnect(ui->bookmarksButton, SIGNAL(clicked()), this, SLOT(toggleBookmark())); QTimer::singleShot(HIDE_DELAY, this, SLOT(close())); }
void Editor::clearAllBookmarks() { int line = 1; for ( QTextBlock block = m_textEdit->document()->begin(); block.isValid(); block = block.next(), line++ ) { BlockUserData *blockUserData = ( BlockUserData* ) block.userData(); if ( blockUserData && blockUserData->bookmark ) toggleBookmark ( line ); } }
FileSelector::FileSelector(QWidget *parent) : QWidget(parent), m_view(new QListView(this)), m_model(new QFileSystemModel(this)), m_title(new QLabel(this)), m_path(new QLabel(this)), m_bookmarkButton(new QPushButton(this)), m_bookmarkMenu(new QMenu(this)), m_bookmarks(), m_signalMapper(new QSignalMapper(this)) { QGridLayout *layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setRowStretch(5, 1); layout->setSpacing(0); m_title->setAlignment(Qt::AlignCenter); layout->addWidget(m_title, 0, 0, 1, 2); layout->addWidget(m_path, 1, 0, 1, 2); m_view->setModel(m_model); connect(m_view, SIGNAL(activated(QModelIndex)), this, SLOT(enter(QModelIndex))); layout->addWidget(m_view, 2, 0, 6, 1); m_view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_view->setSelectionMode(QListView::ExtendedSelection); QFont font = m_view->font(); font.setPointSize(8); m_view->setFont(font); m_model->setNameFilterDisables(false); m_model->setRootPath("/"); connect(m_signalMapper, SIGNAL(mapped(QString)), this, SLOT(setCurrentDirectory(QString))); m_bookmarkButton->setIcon(QIcon(":nobookmark.png")); m_bookmarkButton->setShortcut(QKeySequence(Qt::ALT+Qt::Key_B)); connect(m_bookmarkButton, SIGNAL(clicked()), this, SLOT(toggleBookmark())); layout->addWidget(m_bookmarkButton, 2, 1); QPushButton *button = new QPushButton(); button->setIcon(QIcon(":up.png")); button->setShortcut(QKeySequence(Qt::ALT+Qt::Key_Up)); connect(button, SIGNAL(clicked()), this, SLOT(goUp())); layout->addWidget(button, 3, 1); button = new QPushButton(); button->setIcon(QIcon(":ok.png")); connect(button, SIGNAL(clicked()), this, SLOT(accept())); layout->addWidget(button, 6, 1); button = new QPushButton(); button->setIcon(QIcon(":cancel.png")); button->setShortcut(QKeySequence(Qt::Key_Escape)); connect(button, SIGNAL(clicked()), this, SIGNAL(cancel())); layout->addWidget(button, 7, 1); QSettings conf(QDir::homePath()+"Maps/nanomap.conf", QSettings::NativeFormat); conf.beginGroup("fileselector"); m_bookmarks = conf.value("bookmarks").toStringList(); conf.endGroup(); setCurrentDirectory(m_model->index(QDir::homePath())); updateBookmarkMenu(); m_view->setFocus(Qt::OtherFocusReason); resize(320, 240); }
void DocumentEditor::toggleBookmark() { int line, index; getCursorPosition(&line, &index); toggleBookmark(1, line, Qt::NoModifier); }