~bzoltan/kubuntu-packaging/decouple_cmake_plugin

« back to all changes in this revision

Viewing changes to src/plugins/bookmarks/bookmarkmanager.cpp

  • Committer: Timo Jyrinki
  • Date: 2013-11-15 12:25:23 UTC
  • mfrom: (1.1.28)
  • Revision ID: timo.jyrinki@canonical.com-20131115122523-i2kyamsu4gs2mu1m
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
using namespace Bookmarks::Internal;
62
62
using namespace ProjectExplorer;
63
63
using namespace Core;
 
64
using namespace Utils;
64
65
 
65
66
BookmarkDelegate::BookmarkDelegate(QObject *parent)
66
67
    : QStyledItemDelegate(parent), m_normalPixmap(0), m_selectedPixmap(0)
219
220
 
220
221
    connect(this, SIGNAL(clicked(QModelIndex)),
221
222
            this, SLOT(gotoBookmark(QModelIndex)));
 
223
    connect(this, SIGNAL(activated(QModelIndex)),
 
224
            this, SLOT(gotoBookmark(QModelIndex)));
222
225
 
223
226
    ICore::addContextObject(m_bookmarkContext);
224
227
 
280
283
    m_manager->removeBookmark(bm);
281
284
}
282
285
 
 
286
void BookmarkView::keyPressEvent(QKeyEvent *event)
 
287
{
 
288
    if (event->key() == Qt::Key_Delete) {
 
289
        removeBookmark(currentIndex());
 
290
        event->accept();
 
291
        return;
 
292
    }
 
293
    QListView::keyPressEvent(event);
 
294
}
 
295
 
283
296
void BookmarkView::removeAll()
284
297
{
285
298
    const QString key = QLatin1String("Bookmarks.DontAskAgain");
343
356
    connect(Core::ICore::instance(), SIGNAL(contextChanged(QList<Core::IContext*>,Core::Context)),
344
357
            this, SLOT(updateActionStatus()));
345
358
 
346
 
    connect(ProjectExplorerPlugin::instance()->session(), SIGNAL(sessionLoaded(QString)),
 
359
    connect(SessionManager::instance(), SIGNAL(sessionLoaded(QString)),
347
360
            this, SLOT(loadBookmarks()));
348
361
 
349
362
    updateActionStatus();
426
439
    if (!editor)
427
440
        return;
428
441
 
429
 
    toggleBookmark(editor->document()->fileName(), editor->currentLine());
 
442
    toggleBookmark(editor->document()->filePath(), editor->currentLine());
430
443
}
431
444
 
432
445
void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
545
558
{
546
559
    TextEditor::ITextEditor *editor = currentTextEditor();
547
560
    int editorLine = editor->currentLine();
548
 
    QFileInfo fi(editor->document()->fileName());
 
561
    QFileInfo fi(editor->document()->filePath());
549
562
    if (!m_bookmarksMap.contains(fi.path()))
550
563
        return;
551
564
 
567
580
            nextLine = markLine;
568
581
    }
569
582
 
570
 
    Core::EditorManager *em = Core::EditorManager::instance();
571
 
    em->addCurrentPositionToNavigationHistory();
 
583
    EditorManager::addCurrentPositionToNavigationHistory();
572
584
    if (next) {
573
585
        if (nextLine == -1)
574
586
            editor->gotoLine(firstLine);
634
646
    return qobject_cast<TextEditor::ITextEditor *>(currEditor);
635
647
}
636
648
 
637
 
/* Returns the current session. */
638
 
SessionManager *BookmarkManager::sessionManager() const
639
 
{
640
 
    return ProjectExplorerPlugin::instance()->session();
641
 
}
642
 
 
643
649
BookmarkManager::State BookmarkManager::state() const
644
650
{
645
651
    if (m_bookmarksMap.empty())
649
655
    if (!editor)
650
656
        return HasBookMarks;
651
657
 
652
 
    const QFileInfo fi(editor->document()->fileName());
 
658
    const QFileInfo fi(editor->document()->filePath());
653
659
 
654
660
    const DirectoryFileBookmarksMap::const_iterator dit = m_bookmarksMap.constFind(fi.path());
655
661
    if (dit == m_bookmarksMap.constEnd())
815
821
    foreach (const Bookmark *bookmark, m_bookmarksList)
816
822
            list << bookmarkToString(bookmark);
817
823
 
818
 
    sessionManager()->setValue(QLatin1String("Bookmarks"), list);
 
824
    SessionManager::setValue(QLatin1String("Bookmarks"), list);
819
825
}
820
826
 
821
827
void BookmarkManager::operateTooltip(TextEditor::ITextEditor *textEditor, const QPoint &pos, Bookmark *mark)
824
830
        return;
825
831
 
826
832
    if (mark->note().isEmpty())
827
 
        Utils::ToolTip::instance()->hide();
 
833
        ToolTip::hide();
828
834
    else
829
 
        Utils::ToolTip::instance()->show(pos, Utils::TextContent(mark->note()), textEditor->widget());
 
835
        ToolTip::show(pos, TextContent(mark->note()), textEditor->widget());
830
836
}
831
837
 
832
838
/* Loads the bookmarks from the session settings. */
833
839
void BookmarkManager::loadBookmarks()
834
840
{
835
841
    removeAllBookmarks();
836
 
    const QStringList &list = sessionManager()->value(QLatin1String("Bookmarks")).toStringList();
 
842
    const QStringList &list = SessionManager::value(QLatin1String("Bookmarks")).toStringList();
837
843
    foreach (const QString &bookmarkString, list)
838
844
        addBookmark(bookmarkString);
839
845
 
845
851
                                            TextEditor::ITextEditor::MarkRequestKind kind)
846
852
{
847
853
    if (kind == TextEditor::ITextEditor::BookmarkRequest && textEditor->document())
848
 
        toggleBookmark(textEditor->document()->fileName(), line);
 
854
        toggleBookmark(textEditor->document()->filePath(), line);
849
855
}
850
856
 
851
857
void BookmarkManager::handleBookmarkTooltipRequest(TextEditor::ITextEditor *textEditor, const QPoint &pos,
852
858
                                            int line)
853
859
{
854
860
    if (textEditor->document()) {
855
 
        const QFileInfo fi(textEditor->document()->fileName());
 
861
        const QFileInfo fi(textEditor->document()->filePath());
856
862
        Bookmark *mark = findBookmark(fi.path(), fi.fileName(), line);
857
863
        operateTooltip(textEditor, pos, mark);
858
864
    }
877
883
 
878
884
Id BookmarkViewFactory::id() const
879
885
{
880
 
    return Id("Bookmarks");
 
886
    return "Bookmarks";
881
887
}
882
888
 
883
889
QKeySequence BookmarkViewFactory::activationSequence() const