Example #1
0
void BookmarksPanel::setup()
{
    UrlPanel::setup();

    connect(panelTreeView(), SIGNAL(delKeyPressed()), this, SLOT(deleteBookmark()));
    connect(panelTreeView(), SIGNAL(collapsed(QModelIndex)), this, SLOT(onCollapse(QModelIndex)));
    connect(panelTreeView(), SIGNAL(expanded(QModelIndex)), this, SLOT(onExpand(QModelIndex)));

    loadFoldedState();
}
Example #2
0
void HistoryPanel::setup()
{
    UrlPanel::setup();
    kDebug() << "History panel...";

    panelTreeView()->header()->hideSection(1);

    const UrlFilterProxyModel *proxy = static_cast<const UrlFilterProxyModel*>(panelTreeView()->model());
    panelTreeView()->expand(proxy->index(0, 0));
}
Example #3
0
void BookmarksPanel::contextMenu(const QPoint &pos)
{
    if (_loadingState)
        return;

    BookmarksContextMenu menu(bookmarkForIndex(panelTreeView()->indexAt(pos)),
                              BookmarkManager::self()->manager(),
                              BookmarkManager::self()->owner()
                             );

    menu.exec(panelTreeView()->mapToGlobal(pos));
}
Example #4
0
BookmarksPanel::BookmarksPanel(const QString &title, QWidget *parent, Qt::WindowFlags flags)
    : UrlPanel(title, parent, flags)
    , _bkTreeModel(new BookmarksTreeModel(this))
    , _loadingState(false)
{
    setObjectName("bookmarksPanel");
    setVisible(ReKonfig::showBookmarksPanel());

    panelTreeView()->setDragEnabled(true);
    panelTreeView()->setAcceptDrops(true);
    connect(_bkTreeModel, SIGNAL(bookmarksUpdated()), this, SLOT(loadFoldedState()));
}
Example #5
0
void HistoryPanel::openAll()
{
    QModelIndex index = panelTreeView()->currentIndex();
    if (!index.isValid())
        return;

    QList<KUrl> allChild;

    for (int i = 0; i < index.model()->rowCount(index); i++)
        allChild << qVariantValue<KUrl>(index.child(i, 0).data(Qt::UserRole));

    if (allChild.length() > 8)
    {
        if (!(KMessageBox::warningContinueCancel(this,
                i18ncp("%1=Number of tabs. Value is always >=8",
                       "You are about to open %1 tabs.\nAre you sure?",
                       "You are about to open %1 tabs.\nAre you sure?",
                       allChild.length())) == KMessageBox::Continue)
           )
            return;
    }

    for (int i = 0; i < allChild.length(); i++)
        emit openUrl(allChild.at(i).url(), Rekonq::NewTab);
}
Example #6
0
void BookmarksPanel::deleteBookmark()
{
    QModelIndex index = panelTreeView()->currentIndex();
    if (_loadingState || !index.isValid())
        return;

    BookmarkManager::self()->owner()->deleteBookmark(bookmarkForIndex(index));
}
Example #7
0
void HistoryPanel::contextMenuGroup(const QPoint &pos)
{
    KMenu menu;
    KAction* action;

    action = new KAction(KIcon("tab-new"), i18n("Open Folder in Tabs"), this);
    connect(action, SIGNAL(triggered()), this, SLOT(openAll()));
    menu.addAction(action);

    menu.exec(panelTreeView()->mapToGlobal(pos));
}
Example #8
0
void HistoryPanel::contextMenuItem(const QPoint &pos)
{
    KMenu menu;
    KAction* action;

    action = new KAction(KIcon("tab-new"), i18n("Open"), this);
    connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInCurrentTab()));
    menu.addAction(action);

    action = new KAction(KIcon("tab-new"), i18n("Open in New Tab"), this);
    connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInNewTab()));
    menu.addAction(action);

    action = new KAction(KIcon("window-new"), i18n("Open in New Window"), this);
    connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(openInNewWindow()));
    menu.addAction(action);

    action = new KAction(KIcon("edit-copy"), i18n("Copy Link Address"), this);
    connect(action, SIGNAL(triggered()), panelTreeView(), SLOT(copyToClipboard()));
    menu.addAction(action);

    menu.exec(panelTreeView()->mapToGlobal(pos));
}
Example #9
0
void BookmarksPanel::loadFoldedState(const QModelIndex &root)
{
    QAbstractItemModel *model = panelTreeView()->model();
    if (!model)
        return;

    int count = model->rowCount(root);
    QModelIndex index;

    for (int i = 0; i < count; ++i)
    {
        index = model->index(i, 0, root);
        if (index.isValid())
        {
            KBookmark bm = bookmarkForIndex(index);
            if (bm.isGroup())
            {
                panelTreeView()->setExpanded(index, bm.toGroup().isOpen());
                loadFoldedState(index);
            }
        }
    }
}