summaryrefslogtreecommitdiff
path: root/src/urlbar
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:09:41 +0100
committerAndrea Diamantini <adjam7@gmail.com>2012-12-10 02:09:41 +0100
commit288ace1df39dbea40cae66d0b04bfdefcd6cec70 (patch)
tree87c03b9dbfb330b7e743a45276d73de0cea0e950 /src/urlbar
parentLindsay's credits (diff)
downloadrekonq-288ace1df39dbea40cae66d0b04bfdefcd6cec70.tar.xz
WARNING COMMIT --> FIRST REKONQ 2 IMPORT
Preparing repo to merge rekonq2 code...
Diffstat (limited to 'src/urlbar')
-rw-r--r--src/urlbar/bookmarkwidget.cpp383
-rw-r--r--src/urlbar/bookmarkwidget.h104
-rw-r--r--src/urlbar/completionwidget.cpp402
-rw-r--r--src/urlbar/completionwidget.h93
-rw-r--r--src/urlbar/favoritewidget.cpp115
-rw-r--r--src/urlbar/favoritewidget.h58
-rw-r--r--src/urlbar/listitem.cpp661
-rw-r--r--src/urlbar/listitem.h291
-rw-r--r--src/urlbar/newresourcedialog.cpp121
-rw-r--r--src/urlbar/newresourcedialog.h57
-rw-r--r--src/urlbar/resourcelinkdialog.cpp385
-rw-r--r--src/urlbar/resourcelinkdialog.h73
-rw-r--r--src/urlbar/rsswidget.cpp166
-rw-r--r--src/urlbar/rsswidget.h61
-rw-r--r--src/urlbar/sslwidget.cpp252
-rw-r--r--src/urlbar/sslwidget.h58
-rw-r--r--src/urlbar/stackedurlbar.cpp68
-rw-r--r--src/urlbar/stackedurlbar.h55
-rw-r--r--src/urlbar/urlbar.cpp773
-rw-r--r--src/urlbar/urlbar.h156
-rw-r--r--src/urlbar/urlresolver.cpp403
-rw-r--r--src/urlbar/urlresolver.h179
-rw-r--r--src/urlbar/webshortcutwidget.cpp163
-rw-r--r--src/urlbar/webshortcutwidget.h76
24 files changed, 0 insertions, 5153 deletions
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp
deleted file mode 100644
index c1963ff0..00000000
--- a/src/urlbar/bookmarkwidget.cpp
+++ /dev/null
@@ -1,383 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Yoann Laissus <yoann dot laissus at gmail dot com>
-* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Auto Includes
-#include "bookmarkwidget.h"
-#include "bookmarkwidget.moc"
-
-// Local includes
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "bookmarkowner.h"
-
-// KDE Includes
-#include <KComboBox>
-#include <KLocalizedString>
-#include <KIcon>
-#include <KLineEdit>
-#include <KRatingWidget>
-#include <KBookmarkDialog>
-
-// Qt Includes
-#include <QDialogButtonBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QCompleter>
-#include <QTextCursor>
-#include <QDBusConnection>
-#include <QDBusConnectionInterface>
-
-// Nepomuk config include
-#include "config-nepomuk.h"
-
-#ifdef HAVE_NEPOMUK
-// Local Nepomuk Includes
-#include "resourcelinkdialog.h"
-
-//Nepomuk Includes
-#include <Soprano/Vocabulary/NAO>
-#endif
-
-
-
-BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent)
- : QMenu(parent)
- , m_bookmark(bookmark)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setFixedWidth(320);
-
-#ifdef HAVE_NEPOMUK
- m_nfoResource = (QUrl)m_bookmark.url();
- m_isNepomukEnabled = QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.NepomukServer");
- kDebug() << "IS NEPOMUK ACTUALLY RUNNING? " << m_isNepomukEnabled;
-#endif
-
- QFormLayout *layout = new QFormLayout(this);
- layout->setHorizontalSpacing(20);
-
- // Title
- QHBoxLayout *hLayout = new QHBoxLayout;
- QLabel *bookmarkInfo = new QLabel(this);
- bookmarkInfo->setText(i18n(" Bookmark"));
- QFont f = bookmarkInfo->font();
- f.setBold(true);
- bookmarkInfo->setFont(f);
-
- // Remove button
- QLabel *removeLabel = new QLabel(this);
- removeLabel->setText(i18n("<a href='Remove'>Remove</a>"));
- removeLabel->setAlignment(Qt::AlignRight);
- hLayout->addWidget(bookmarkInfo);
- hLayout->addWidget(removeLabel);
- layout->addRow(hLayout);
-
- connect(removeLabel, SIGNAL(linkActivated(QString)), this, SLOT(removeBookmark()));
-
- //Bookmark Folder
- QLabel *folderLabel = new QLabel(this);
- folderLabel->setText(i18n("Folder:"));
-
- m_folder = new KComboBox(this);
- layout->addRow(folderLabel, m_folder);
- setupFolderComboBox();
- connect(m_folder, SIGNAL(currentIndexChanged(int)), this, SLOT(onFolderIndexChanged(int)));
-
- // Bookmark name
- QLabel *nameLabel = new QLabel(this);
- nameLabel->setText(i18n("Name:"));
- m_name = new KLineEdit(this);
- if (m_bookmark.isNull())
- {
- m_name->setEnabled(false);
- }
- else
- {
- m_name->setText(m_bookmark.text());
- m_name->setFocus();
- }
- layout->addRow(nameLabel, m_name);
-
-#ifdef HAVE_NEPOMUK
-
- if (m_isNepomukEnabled)
- {
- QLabel* rateLabel = new QLabel(this);
- rateLabel->setText(i18n("Rate:"));
- KRatingWidget *ratingWidget = new KRatingWidget(this);
- if (m_nfoResource.rating() != 0)
- {
- ratingWidget->setRating(m_nfoResource.rating());
- }
- connect(ratingWidget, SIGNAL(ratingChanged(int)), this, SLOT(setRatingSlot(int)));
- ratingWidget->setToolTip(i18n("Rate this page"));
- layout->addRow(rateLabel, ratingWidget);
-
- //Add comments
- QLabel *commentLabel = new QLabel(this);
- commentLabel->setText(i18n("Describe:"));
- commentLabel->setAlignment(Qt::AlignCenter);
- m_commentEdit = new QPlainTextEdit(this);
- if (!m_nfoResource.description().isEmpty())
- {
- m_commentEdit->setPlainText(m_nfoResource.description());
- }
- connect(m_commentEdit, SIGNAL(textChanged()), this, SLOT(addCommentSlot()));
- layout->addRow(commentLabel, m_commentEdit);
-
- // Create tags
- QLabel *tagLabel = new QLabel(this);
- tagLabel->setText(i18n("Tags:"));
- tagLabel->setAlignment(Qt::AlignLeft);
- m_tagLine = new KLineEdit(this);
- m_tagLine->setPlaceholderText(i18n("add tags(comma separated)"));
-
-
- QList<Nepomuk::Tag> tagList = Nepomuk::Tag::allTags();
- Q_FOREACH(Nepomuk::Tag t, tagList)
- {
- m_tList.append(t.label());
- }
- QCompleter *completeTag = new QCompleter(m_tList);
- completeTag->setCompletionMode(QCompleter::PopupCompletion);
- m_tagLine->setCompleter(completeTag);
- loadTags();
-
- layout->addRow(tagLabel, m_tagLine);
-
- QPushButton *linkToResource = new QPushButton(this);
- linkToResource->setText(i18n("Link Resources"));
- connect(linkToResource, SIGNAL(clicked()), this, SLOT(linkToResourceSlot()));
- layout->addWidget(linkToResource);
- }
- else
- {
- QLabel *nepomukLabel = new QLabel(this);
- QPalette p = nepomukLabel->palette();
- p.setColor(QPalette::WindowText, Qt::red);
- nepomukLabel->setPalette(p);
- nepomukLabel->setText(i18n("Nepomuk is actually disabled."));
- layout->addWidget(nepomukLabel);
- }
-#endif
-
- // Ok & Cancel buttons
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
- layout->addWidget(buttonBox);
-}
-
-
-void BookmarkWidget::showAt(const QPoint &pos)
-{
- adjustSize();
-
- QPoint p(pos.x() - width(), pos.y() + 10);
- move(p);
- show();
-}
-
-
-void BookmarkWidget::accept()
-{
- if (!m_bookmark.isNull() && m_name->text() != m_bookmark.fullText())
- {
- m_bookmark.setFullText(m_name->text());
- rApp->bookmarkManager()->emitChanged();
- }
- QString folderAddress = m_folder->itemData(m_folder->currentIndex()).toString();
- KBookmarkGroup a = rApp->bookmarkManager()->manager()->findByAddress(folderAddress).toGroup();
-
- KBookmarkGroup parent = m_bookmark.parentGroup();
- parent.deleteBookmark(m_bookmark);
- a.addBookmark(m_bookmark);
- rApp->bookmarkManager()->manager()->emitChanged(a);
-
-#ifdef HAVE_NEPOMUK
- if (m_isNepomukEnabled)
- {
- parseTags();
- }
-#endif
-
- close();
-}
-
-
-void BookmarkWidget::setupFolderComboBox()
-{
- KBookmarkGroup toolBarRoot = rApp->bookmarkManager()->manager()->toolbar();
- KBookmarkGroup root = rApp->bookmarkManager()->rootGroup();
-
- if (toolBarRoot.address() == root.address())
- {
- m_folder->addItem(KIcon("bookmark-toolbar"),
- i18n("Bookmark Toolbar"),
- toolBarRoot.address());
- }
- else
- {
- m_folder->addItem(KIcon("bookmark-toolbar"),
- toolBarRoot.text(),
- toolBarRoot.address());
- }
- m_folder->insertSeparator(1);
-
- if (m_bookmark.parentGroup().address() != toolBarRoot.address())
- {
- QString parentText = m_bookmark.parentGroup().text();
-
- if (m_bookmark.parentGroup().address() == root.address())
- {
- parentText = i18n("Root folder");
- }
-
- m_folder->addItem(parentText,
- m_bookmark.parentGroup().address());
- m_folder->insertSeparator(3);
- }
-
- for (KBookmark bookmark = toolBarRoot.first(); !bookmark.isNull(); bookmark = toolBarRoot.next(bookmark))
- {
- if (bookmark.isGroup() && bookmark.address() != m_bookmark.parentGroup().address())
- {
- m_folder->addItem(bookmark.text(), bookmark.address());
- }
- }
-
- m_folder->insertSeparator(m_folder->count());
- m_folder->addItem(KIcon("folder"), i18n("Choose..."));
-
- int index = m_folder->findData(m_bookmark.parentGroup().address());
- m_folder->setCurrentIndex(index);
-}
-
-
-void BookmarkWidget::onFolderIndexChanged(int index)
-{
- if (index == m_folder->count() - 1)
- {
- KBookmarkDialog dialog(rApp->bookmarkManager()->manager());
- KBookmarkGroup selectedGroup = dialog.selectFolder(m_bookmark.parentGroup());
-
- if (selectedGroup.address() != m_bookmark.parentGroup().address() && !selectedGroup.isNull())
- {
- m_bookmark.parentGroup().deleteBookmark(m_bookmark);
- selectedGroup.addBookmark(m_bookmark);
- rApp->bookmarkManager()->manager()->emitChanged();
- }
- }
-}
-
-
-void BookmarkWidget::removeBookmark()
-{
- rApp->bookmarkManager()->owner()->deleteBookmark(m_bookmark);
- close();
-
- emit updateIcon();
-}
-
-
-#ifdef HAVE_NEPOMUK
-void BookmarkWidget::addTags(QList<Nepomuk::Tag> tagList)
-{
- Q_FOREACH(const Nepomuk::Tag & tag, tagList)
- {
- if (!m_nfoResource.tags().contains(tag))
- {
- m_nfoResource.addTag(tag);
- }
- }
- Q_FOREACH(Nepomuk::Tag tag, m_nfoResource.tags())
- {
- if (!tagList.contains(tag))
- {
- tag.remove();
- }
- }
-}
-
-void BookmarkWidget::parseTags()
-{
- QList<Nepomuk::Tag> tagList;
- if (m_tagLine->text().contains(','))
- {
- QString text = m_tagLine->text();
- QStringList tagStringList = text.split(QChar::fromAscii(','));
-
- Q_FOREACH(const QString & tag, tagStringList)
- {
- QString trimmedTag = tag.trimmed();
- if (!trimmedTag.isEmpty())
- tagList << trimmedTag;
- }
- }
- else
- {
- tagList << m_tagLine->text().trimmed();
- }
- addTags(tagList);
-}
-
-
-void BookmarkWidget::loadTags()
-{
- QString list;
- if (!m_nfoResource.tags().isEmpty())
- {
- Q_FOREACH(const Nepomuk::Tag & tag, m_nfoResource.tags())
- {
- list.append(tag.genericLabel());
- list.append(",");
- }
- m_tagLine->setText(list);
- }
-}
-
-
-void BookmarkWidget::setRatingSlot(int rate)
-{
- m_nfoResource.setRating(rate);
-}
-
-
-void BookmarkWidget::addCommentSlot()
-{
- m_nfoResource.setDescription(m_commentEdit->toPlainText());
-}
-
-
-void BookmarkWidget::linkToResourceSlot()
-{
- Nepomuk::ResourceLinkDialog r(m_nfoResource);
- r.exec();
-}
-#endif
diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h
deleted file mode 100644
index a57b2774..00000000
--- a/src/urlbar/bookmarkwidget.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Yoann Laissus <yoann dot laissus at gmail dot com>
-* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef BOOKMARKWIDGET_H
-#define BOOKMARKWIDGET_H
-
-// Qt Includes
-#include <QMenu>
-#include <QGridLayout>
-#include <QPlainTextEdit>
-
-// KDE Includes
-#include <KBookmark>
-
-// Nepomuk config include
-#include "config-nepomuk.h"
-
-#ifdef HAVE_NEPOMUK
-
-// Nepomuk Includes
-#include <Nepomuk/Resource>
-#include <Nepomuk/Tag>
-#include <Nepomuk/Vocabulary/NFO>
-
-#endif
-
-// Forward Declarations
-class KBookmark;
-class KLineEdit;
-class KComboBox;
-
-
-class BookmarkWidget : public QMenu
-{
- Q_OBJECT
-
-public:
- explicit BookmarkWidget(const KBookmark &bookmark, QWidget *parent = 0);
-
- void showAt(const QPoint &pos);
-
-#ifdef HAVE_NEPOMUK
- void addTags(QList<Nepomuk::Tag>);
- void parseTags();
- void loadTags();
-#endif
-
-Q_SIGNALS:
- void updateIcon();
-
-private:
- void setupFolderComboBox();
-
-private Q_SLOTS:
- void accept();
- void removeBookmark();
- void onFolderIndexChanged(int index);
-
-#ifdef HAVE_NEPOMUK
- void setRatingSlot(int rate);
- void addCommentSlot();
- void linkToResourceSlot();
-#endif
-
-private:
- KBookmark m_bookmark;
- KLineEdit *m_name;
- KComboBox *m_folder;
- KLineEdit *m_tagLine;
- QPlainTextEdit *m_commentEdit;
- QStringList m_tList;
-
-#ifdef HAVE_NEPOMUK
- Nepomuk::Resource m_nfoResource;
- bool m_isNepomukEnabled;
-#endif
-};
-
-#endif
diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp
deleted file mode 100644
index 04f7bad0..00000000
--- a/src/urlbar/completionwidget.cpp
+++ /dev/null
@@ -1,402 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "completionwidget.h"
-#include "completionwidget.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local Includes
-#include "application.h"
-#include "listitem.h"
-#include "searchengine.h"
-#include "urlbar.h"
-
-// KDE Includes
-#include <KGlobalSettings>
-#include <KUrl>
-
-// Qt Includes
-#include <QPoint>
-#include <QSize>
-#include <QEvent>
-
-#include <QVBoxLayout>
-#include <QKeyEvent>
-
-
-
-CompletionWidget::CompletionWidget(QWidget *parent)
- : QFrame(parent, Qt::ToolTip)
- , _parent(parent)
- , _currentIndex(0)
- , _hasSuggestions(false)
-{
- setFrameStyle(QFrame::Panel);
- setLayoutDirection(Qt::LeftToRight);
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
- layout->setSpacing(0);
- setLayout(layout);
-}
-
-
-void CompletionWidget::insertItems(const UrlSearchList &list, const QString& text, int offset)
-{
- Q_FOREACH(const UrlSearchItem & item, list)
- {
- ListItem *suggestion = ListItemFactory::create(item, text, this);
- suggestion->setBackgroundRole(offset % 2 ? QPalette::AlternateBase : QPalette::Base);
- connect(suggestion,
- SIGNAL(itemClicked(ListItem*, Qt::MouseButton, Qt::KeyboardModifiers)),
- this,
- SLOT(itemChosen(ListItem*, Qt::MouseButton, Qt::KeyboardModifiers)));
- connect(suggestion, SIGNAL(updateList()), this, SLOT(updateList()));
- connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice()));
-
- suggestion->setObjectName(QString::number(offset++));
- layout()->addWidget(suggestion);
- }
-}
-
-
-void CompletionWidget::updateSearchList(const UrlSearchList &list, const QString& text)
-{
- if (_hasSuggestions || _typedString != text)
- return;
- _hasSuggestions = true;
-
- if (_resList.count() > 0)
- {
- clear();
-
- insertItems(_resList, text);
- _list = _resList;
-
- UrlSearchList sugList = list.mid(0, 4);
- insertItems(sugList, text, _list.count());
- _list.append(sugList);
- popup();
- }
-}
-
-
-void CompletionWidget::sizeAndPosition()
-{
- setFixedWidth(_parent->width());
-
- int h = 0;
- for (int i = 0; i < layout()->count(); i++)
- {
- QWidget *widget = layout()->itemAt(i)->widget();
- h += widget->sizeHint().height();
- }
- setFixedSize(_parent->width(), h + 5);
-
- // position
- QPoint p = _parent->mapToGlobal(QPoint(0, 0));
- move(p.x(), p.y() + _parent->height());
-}
-
-
-void CompletionWidget::popup()
-{
- findChild<ListItem *>(QString::number(0))->activate(); //activate first listitem
- sizeAndPosition();
- if (!isVisible())
- show();
-}
-
-
-void CompletionWidget::up()
-{
- if (_currentIndex >= 0)
- findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
-
- --_currentIndex;
- if (_currentIndex < -1)
- {
- _currentIndex = _list.count() - 1;
- }
-
- activateCurrentListItem();
-}
-
-
-void CompletionWidget::down()
-{
- if (_currentIndex >= 0)
- findChild<ListItem *>(QString::number(_currentIndex))->deactivate(); // deactivate previous
-
- ++_currentIndex;
- if (_currentIndex == _list.count())
- _currentIndex = -1;
-
- activateCurrentListItem();
-}
-
-
-void CompletionWidget::activateCurrentListItem()
-{
- UrlBar *bar = qobject_cast<UrlBar *>(_parent);
-
- // activate "new" current
- ListItem *widget = findChild<ListItem *>(QString::number(_currentIndex));
-
- // update text of the url bar
- bar->blockSignals(true); // without compute suggestions
- if (widget)
- {
- widget->activate();
- bar->setQUrl(widget->text());
- }
- else
- {
- bar->setText(_typedString);
- }
- bar->blockSignals(false);
- bar->setFocus();
- bar->setCursorPosition(bar->text().length());
-}
-
-
-void CompletionWidget::clear()
-{
- QLayoutItem *child;
- while ((child = layout()->takeAt(0)) != 0)
- {
- delete child->widget();
- delete child;
- }
- _currentIndex = 0;
- _hasSuggestions = false;
-}
-
-
-bool CompletionWidget::eventFilter(QObject *obj, QEvent *ev)
-{
- int type = ev->type();
- QWidget *wid = qobject_cast<QWidget*>(obj);
-
- if (obj == this)
- {
- return false;
- }
-
- // hide conditions of the CompletionWidget
- if (wid
- && ((wid == _parent
- && (type == QEvent::Move || type == QEvent::Resize)) || ((wid->windowFlags() & Qt::Window)
- && (type == QEvent::Move || type == QEvent::Hide || type == QEvent::WindowDeactivate)
- && wid == _parent->window()) || (type == QEvent::MouseButtonPress && !isAncestorOf(wid)))
- )
- {
- hide();
- return false;
- }
-
- //actions on the CompletionWidget
- if (wid && wid->isAncestorOf(_parent) && isVisible())
- {
- ListItem *child;
- UrlBar *w;
-
- if (type == QEvent::KeyPress)
- {
- QKeyEvent *kev = static_cast<QKeyEvent *>(ev);
- switch (kev->key())
- {
- case Qt::Key_Up:
- case Qt::Key_Backtab:
- if (kev->modifiers() == Qt::NoButton || (kev->modifiers() & Qt::ShiftModifier))
- {
- up();
- kev->accept();
- return true;
- }
- break;
-
- case Qt::Key_Down:
- case Qt::Key_Tab:
- if (kev->modifiers() == Qt::NoButton)
- {
- down();
- kev->accept();
- return true;
- }
- if (kev->modifiers() & Qt::ControlModifier)
- {
- emit nextItemSubChoice();
- kev->accept();
- return true;
- }
- break;
-
- case Qt::Key_Enter:
- case Qt::Key_Return:
- w = qobject_cast<UrlBar *>(parent());
- if (kev->modifiers() == Qt::AltModifier)
- {
- if (kev->key() == Qt::Key_Return || kev->key() == Qt::Key_Enter)
- {
- emit chosenUrl(w->text(), Rekonq::NewFocusedTab);
- }
- }
-
- if (!w->text().startsWith(QL1S("http://"), Qt::CaseInsensitive))
- {
- QString append;
- if (kev->modifiers() == Qt::ControlModifier)
- {
- append = QL1S(".com");
- }
- else if (kev->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier))
- {
- append = QL1S(".org");
- }
- else if (kev->modifiers() == Qt::ShiftModifier)
- {
- append = QL1S(".net");
- }
-
- if (!append.isEmpty())
- {
- QUrl url(QL1S("http://") + w->text());
- QString host = url.host();
- if (!host.endsWith(append, Qt::CaseInsensitive))
- {
- host += append;
- url.setHost(host);
- }
-
- emit chosenUrl(url, Rekonq::CurrentTab);
- }
- }
-
- kDebug() << "Suggestion INDEX chosen: " << _currentIndex;
- if (_currentIndex == -1)
- _currentIndex = 0;
- child = findChild<ListItem *>(QString::number(_currentIndex));
-
- if (child) //the completionwidget is visible and the user had press down
- {
- //we can use the url of the listitem
- emit chosenUrl(child->url(), Rekonq::CurrentTab);
- }
- else //the user type too fast (completionwidget not visible or suggestion not downloaded)
- {
- UrlResolver res(w->text());
- UrlSearchList list = res.orderedSearchItems();
- if (list.isEmpty())
- {
- emit chosenUrl(KUrl(_typedString), Rekonq::CurrentTab);
- }
- else
- {
- emit chosenUrl(list.first().url, Rekonq::CurrentTab);
- }
- }
- kev->accept();
- hide();
- return true;
-
- case Qt::Key_Escape:
- hide();
- return true;
- }
- }
- }
-
- return QFrame::eventFilter(obj, ev);
-}
-
-
-void CompletionWidget::setVisible(bool visible)
-{
- if (visible)
- {
- rApp->installEventFilter(this);
- }
- else
- {
- rApp->removeEventFilter(this);
- }
-
-
- QFrame::setVisible(visible);
-}
-
-
-void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::KeyboardModifiers modifier)
-{
- if (button == Qt::MidButton
- || modifier == Qt::ControlModifier)
- {
- emit chosenUrl(item->url(), Rekonq::NewFocusedTab);
- }
- else
- {
- emit chosenUrl(item->url(), Rekonq::CurrentTab);
- }
- hide();
-}
-
-
-void CompletionWidget::updateList()
-{
- suggestUrls(_typedString);
-}
-
-
-void CompletionWidget::suggestUrls(const QString &text)
-{
- _typedString = text;
-
- QWidget *w = qobject_cast<QWidget *>(parent());
- if (!w->hasFocus())
- return;
-
- if (text.isEmpty())
- {
- hide();
- return;
- }
-
- if (!isVisible())
- {
- UrlResolver::setSearchEngine(SearchEngine::defaultEngine());
- }
-
- UrlResolver *res = new UrlResolver(text);
- connect(res, SIGNAL(suggestionsReady(UrlSearchList, QString)),
- this, SLOT(updateSearchList(UrlSearchList, QString)));
- _resList = res->orderedSearchItems();
-
- // NOTE: It's important to call this AFTER orderedSearchItems() to let everything work
- res->computeSuggestions();
-}
diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h
deleted file mode 100644
index 92d1bd39..00000000
--- a/src/urlbar/completionwidget.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef COMPLETION_WIDGET_H
-#define COMPLETION_WIDGET_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Local Includes
-#include "urlresolver.h"
-
-// KDE Includes
-#include <KService>
-
-// Qt Includes
-#include <QFrame>
-
-// Forward Declarations
-class ListItem;
-
-
-class CompletionWidget : public QFrame
-{
- Q_OBJECT
-
-public:
- CompletionWidget(QWidget *parent);
-
- virtual bool eventFilter(QObject *obj, QEvent *ev);
- void setVisible(bool visible);
-
- void suggestUrls(const QString &text);
-
-private Q_SLOTS:
- void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton, Qt::KeyboardModifiers = Qt::NoModifier);
- void updateSearchList(const UrlSearchList &list, const QString& text);
- void updateList();
-
-Q_SIGNALS:
- void chosenUrl(const KUrl &, Rekonq::OpenType);
- void nextItemSubChoice();
-
-private:
- void insertItems(const UrlSearchList &list, const QString& text, int offset = 0);
-
- void popup();
- void clear();
-
- void sizeAndPosition();
- void up();
- void down();
- void activateCurrentListItem();
-
- QWidget *_parent;
-
- UrlSearchList _list;
-
- int _currentIndex;
-
- KService::Ptr _searchEngine;
-
- QString _typedString;
- bool _hasSuggestions;
-
- UrlSearchList _resList;
-};
-
-#endif // COMPLETION_WIDGET_H
diff --git a/src/urlbar/favoritewidget.cpp b/src/urlbar/favoritewidget.cpp
deleted file mode 100644
index 6a4ffaba..00000000
--- a/src/urlbar/favoritewidget.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "favoritewidget.h"
-#include "favoritewidget.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local includes
-#include "application.h"
-#include "bookmarkmanager.h"
-#include "bookmarkowner.h"
-#include "webtab.h"
-
-// KDE Includes
-#include <KLocalizedString>
-#include <KIcon>
-#include <KLineEdit>
-
-// Qt Includes
-#include <QDialogButtonBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QPushButton>
-
-
-FavoriteWidget::FavoriteWidget(WebTab *tab, QWidget *parent)
- : QMenu(parent)
- , m_tab(tab)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setFixedWidth(350);
-
- QFormLayout *layout = new QFormLayout(this);
- QVBoxLayout *vLay = new QVBoxLayout;
-
- // Favorite icon
- QLabel *bookmarkIcon = new QLabel(this);
- bookmarkIcon->setPixmap(KIcon("emblem-favorite").pixmap(32, 32));
-
- // Title
- QLabel *favoriteInfo = new QLabel(this);
- favoriteInfo->setText(i18n("<h4>Remove this favorite?</h4>"));
- vLay->addWidget(favoriteInfo);
-
- // Favorite name
- QLabel *nameLabel = new QLabel(this);
- nameLabel->setText(i18n("Name: %1", m_tab->view()->title()));
- vLay->addWidget(nameLabel);
-
- // Favorite url
- QLabel *urlLabel = new QLabel(this);
- urlLabel->setText(i18n("URL: %1", m_tab->url().url()));
- vLay->addWidget(urlLabel);
-
- layout->addRow(bookmarkIcon, vLay);
-
- // Ok & Cancel buttons
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
- layout->addWidget(buttonBox);
-}
-
-
-void FavoriteWidget::showAt(const QPoint &pos)
-{
- adjustSize();
-
- QPoint p(pos.x() - width(), pos.y() + 10);
- move(p);
- show();
-}
-
-
-void FavoriteWidget::accept()
-{
- QStringList urls = ReKonfig::previewUrls();
- if (urls.removeOne(m_tab->url().url()))
- {
- ReKonfig::setPreviewUrls(urls);
- QStringList titles = ReKonfig::previewNames();
- titles.removeOne(m_tab->view()->title());
- ReKonfig::setPreviewNames(titles);
-
- emit updateIcon();
- }
-
- close();
-}
diff --git a/src/urlbar/favoritewidget.h b/src/urlbar/favoritewidget.h
deleted file mode 100644
index d0b05f14..00000000
--- a/src/urlbar/favoritewidget.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2011 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef FAVORITE_WIDGET_H
-#define FAVORITE_WIDGET_H
-
-
-// Qt Includes
-#include <QMenu>
-#include <QCheckBox>
-
-// Forward Declarations
-class WebTab;
-
-
-class FavoriteWidget : public QMenu
-{
- Q_OBJECT
-
-public:
- explicit FavoriteWidget(WebTab *tab, QWidget *parent = 0);
-
- void showAt(const QPoint &pos);
-
-Q_SIGNALS:
- void updateIcon();
-
-private Q_SLOTS:
- void accept();
-
-private:
- WebTab *m_tab;
-};
-
-#endif // FAVORITE_WIDGET_H
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
deleted file mode 100644
index 8b753569..00000000
--- a/src/urlbar/listitem.cpp
+++ /dev/null
@@ -1,661 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "listitem.h"
-#include "listitem.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local Includes
-#include "urlresolver.h"
-#include "application.h"
-#include "websnap.h"
-#include "completionwidget.h"
-#include "searchengine.h"
-#include "iconmanager.h"
-
-// KDE Includes
-#include <KIcon>
-#include <KAction>
-#include <kio/jobclasses.h>
-#include <kio/scheduler.h>
-
-// Qt Includes
-#include <QActionGroup>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QSizePolicy>
-#include <QPixmap>
-#include <QStylePainter>
-#include <QMouseEvent>
-#include <QWebSettings>
-#include <QFile>
-#include <QTextDocument>
-#include <QBitArray>
-
-
-ListItem::ListItem(const UrlSearchItem &item, QWidget *parent)
- : QWidget(parent)
- , m_option()
- , m_url(item.url)
-{
- m_option.initFrom(this);
- m_option.direction = Qt::LeftToRight;
-
- // use the same application palette (hence, the same colors)
- // Qt docs says that using this cctor is possible & fast (qt:qpalette)
- QPalette p(rApp->palette());
- setPalette(p);
-
- deactivate();
-}
-
-
-ListItem::~ListItem()
-{
- disconnect();
-}
-
-
-void ListItem::activate()
-{
- m_option.state |= QStyle::State_Selected;
- update();
-}
-
-
-void ListItem::deactivate()
-{
- m_option.state &= ~QStyle::State_Selected;
- update();
-}
-
-
-void ListItem::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
-
- QWidget::paintEvent(event);
- QPainter painter(this);
- m_option.rect = QRect(QPoint(), size());
- painter.fillRect(m_option.rect, palette().brush(backgroundRole()));
-
- if (m_option.state.testFlag(QStyle::State_Selected) || m_option.state.testFlag(QStyle::State_MouseOver))
- {
- style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &m_option, &painter, this);
- }
-
-}
-
-
-void ListItem::enterEvent(QEvent *e)
-{
- m_option.state |= QStyle::State_MouseOver;
- update();
- QWidget::enterEvent(e);
-}
-
-
-void ListItem::leaveEvent(QEvent *e)
-{
- m_option.state &= ~QStyle::State_MouseOver;
- update();
- QWidget::enterEvent(e);
-}
-
-
-void ListItem::mousePressEvent(QMouseEvent *e)
-{
- emit itemClicked(this, e->button(), e->modifiers());
- QWidget::mousePressEvent(e);
-}
-
-
-KUrl ListItem::url()
-{
- return m_url;
-}
-
-
-QString ListItem::text()
-{
- return m_url.url();
-}
-
-
-void ListItem::nextItemSubChoice()
-{
- // will be override
-}
-
-
-// ---------------------------------------------------------------
-
-
-TypeIconLabel::TypeIconLabel(int type, QWidget *parent)
- : QLabel(parent)
-{
- setMinimumWidth(16);
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setMargin(0);
- hLayout->setAlignment(Qt::AlignRight);
- setLayout(hLayout);
-
- if (type & UrlSearchItem::Search)
- hLayout->addWidget(getIcon("edit-find"));
- if (type & UrlSearchItem::Browse)
- hLayout->addWidget(getIcon("applications-internet"));
- if (type & UrlSearchItem::Bookmark)
- hLayout->addWidget(getIcon("rating"));
- if (type & UrlSearchItem::History)
- hLayout->addWidget(getIcon("view-history"));
- if (type & UrlSearchItem::Suggestion)
- hLayout->addWidget(getIcon("help-hint"));
-}
-
-
-QLabel *TypeIconLabel::getIcon(QString icon)
-{
- QLabel *iconLabel = new QLabel(this);
- iconLabel->setFixedSize(16, 16);
- QPixmap pixmap = KIcon(icon).pixmap(16);
- iconLabel->setPixmap(pixmap);
- return iconLabel;
-}
-
-
-// ---------------------------------------------------------------
-
-
-IconLabel::IconLabel(const QString &icon, QWidget *parent)
- : QLabel(parent)
-{
- QPixmap pixmapIcon = rApp->iconManager()->iconForUrl(KUrl(icon)).pixmap(16);
- setFixedSize(16, 16);
- setPixmap(pixmapIcon);
-}
-
-
-IconLabel::IconLabel(const KIcon &icon, QWidget *parent)
- : QLabel(parent)
-{
- QPixmap pixmapIcon = icon.pixmap(16);
- setFixedSize(16, 16);
- setPixmap(pixmapIcon);
-}
-
-
-// ---------------------------------------------------------------
-
-
-static QString highlightWordsInText(const QString &text, const QStringList &words)
-{
- QString ret = text;
- QBitArray boldSections(ret.size());
- Q_FOREACH(const QString & wordToPointOut, words)
- {
- int index = ret.indexOf(wordToPointOut, 0, Qt::CaseInsensitive);
- while (index > -1)
- {
- boldSections.fill(true, index, index + wordToPointOut.size());
- index = ret.indexOf(wordToPointOut, index + wordToPointOut.size(), Qt::CaseInsensitive);
- }
- }
-
-
- if (boldSections.isEmpty())
- return ret;
-
- int numSections = 0;
- for (int i = 0; i < boldSections.size() - 1; ++i)
- {
- if (boldSections.testBit(i) && !boldSections.testBit(i + 1))
- ++numSections;
- }
- if (boldSections.testBit(boldSections.size() - 1)) //last char was still part of a bold section
- ++numSections;
- const int tagLength = 7; // length of "<b>" and "</b>" we're going to add for each bold section.
- ret.reserve(ret.size() + numSections * tagLength);
- bool bold = false;
- for (int i = boldSections.size() - 1; i >= 0; --i)
- {
- if (!bold && boldSections.testBit(i))
- {
- ret.insert(i + 1, QL1S("</b>"));
- bold = true;
- }
- else if (bold && !boldSections.testBit(i))
- {
- ret.insert(i + 1, QL1S("<b>"));
- bold = false;
- }
- }
- if (bold)
- ret.insert(0, QL1S("<b>"));
- return ret;
-}
-
-
-TextLabel::TextLabel(const QString &text, const QString &textToPointOut, QWidget *parent)
- : QLabel(parent)
-{
- setTextFormat(Qt::RichText);
- setMouseTracking(false);
- QString t = text;
- const bool wasItalic = t.startsWith(QL1S("<i>"));
- if (wasItalic)
- t.remove(QRegExp(QL1S("<[/ib]*>")));
- t = Qt::escape(t);
- QStringList words = Qt::escape(textToPointOut.simplified()).split(QL1C(' '));
- t = highlightWordsInText(t, words);
- if (wasItalic)
- t = QL1S("<i>") + t + QL1S("</i>");
- setText(t);
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
-}
-
-
-TextLabel::TextLabel(QWidget *parent)
- : QLabel(parent)
-{
- setTextFormat(Qt::RichText);
- setMouseTracking(false);
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
-}
-
-
-void TextLabel::setEngineText(const QString &engine, const QString &text)
-{
- setText(i18nc("%1=search engine, e.g. Google, Wikipedia %2=text to search for", "Search %1 for <b>%2</b>", engine, Qt::escape(text)));
-}
-
-
-// ---------------------------------------------------------------
-
-
-DescriptionLabel::DescriptionLabel(const QString &text, QWidget *parent)
- : QLabel(parent)
-{
- QString t = text;
- const bool wasItalic = t.startsWith(QL1S("<i>"));
- if (wasItalic)
- t.remove(QRegExp("<[/ib]*>"));
-
- if (wasItalic)
- t = QL1S("<i>") + t + QL1S("</i>");
-
- setWordWrap(false); //NOTE: why setWordWrap(true) make items have a strange behavior ?
- setText(t);
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
-}
-
-
-//--------------------------------------------------------------------------------------------
-
-
-PreviewListItem::PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
-{
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
-
- // icon
- hLayout->addWidget(new TypeIconLabel(item.type, this));
-
- // url + text
- QVBoxLayout *vLayout = new QVBoxLayout;
- vLayout->setMargin(0);
-
- QString title = item.title;
- if (title.isEmpty())
- {
- title = item.url;
- title = title.remove("http://");
- title.truncate(title.indexOf("/"));
- }
-
- vLayout->addWidget(new TextLabel(title, text, this));
- vLayout->addWidget(new TextLabel("<i>" + item.url + "</i>", text, this));
- hLayout->addLayout(vLayout);
-
- // preview label icon
- QLabel *previewLabelIcon = new QLabel(this);
- previewLabelIcon->setFixedSize(45, 33);
- new PreviewLabel(item.url, 38, 29, previewLabelIcon);
- IconLabel* icon = new IconLabel(item.url, previewLabelIcon);
- icon->move(27, 16);
- hLayout->addWidget(previewLabelIcon);
-
- setLayout(hLayout);
-}
-
-
-// ---------------------------------------------------------------
-
-
-PreviewLabel::PreviewLabel(const QString &url, int width, int height, QWidget *parent)
- : QLabel(parent)
-{
- setFixedSize(width, height);
- setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
-
- KUrl u = KUrl(url);
- if (WebSnap::existsImage(KUrl(u)))
- {
- QPixmap preview;
- preview.load(WebSnap::imagePathFromUrl(u));
- setPixmap(preview.scaled(width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
- }
-}
-
-
-// ---------------------------------------------------------------
-
-
-ImageLabel::ImageLabel(const QString &url, int width, int height, QWidget *parent)
- : QLabel(parent),
- m_url(url)
-{
- setFixedSize(width, height);
- if (WebSnap::existsImage(KUrl(url)))
- {
- QPixmap pix;
- pix.load(WebSnap::imagePathFromUrl(url));
- setPixmap(pix);
- }
- else
- {
- KIO::TransferJob *job = KIO::get(KUrl(url), KIO::NoReload, KIO::HideProgressInfo);
- connect(job, SIGNAL(data(KIO::Job*, QByteArray)),
- this, SLOT(slotData(KJob*, QByteArray)));
- connect(job, SIGNAL(result(KJob*)),
- this, SLOT(slotResult(KJob*)));
- }
-}
-
-
-void ImageLabel::slotData(KJob *job, const QByteArray &data)
-{
- Q_UNUSED(job);
- m_data.append(data);
-}
-
-
-void ImageLabel::slotResult(KJob *)
-{
- QPixmap pix;
- if (!pix.loadFromData(m_data))
- kDebug() << "error while loading image: ";
- setPixmap(pix);
- pix.save(WebSnap::imagePathFromUrl(m_url), "PNG");
-}
-
-
-// ---------------------------------------------------------------
-
-
-SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
- , m_text(text)
-{
- m_iconLabel = new IconLabel(SearchEngine::buildQuery(UrlResolver::searchEngine(), ""), this);
- m_titleLabel = new TextLabel(this);
- m_titleLabel->setEngineText(UrlResolver::searchEngine()->name(), item.title);
- m_engineBar = new EngineBar(UrlResolver::searchEngine(), parent);
-
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
-
- hLayout->addWidget(m_iconLabel);
- hLayout->addWidget(m_titleLabel);
- hLayout->addWidget(new QLabel(i18n("Engines: "), this));
- hLayout->addWidget(m_engineBar);
- hLayout->addWidget(new TypeIconLabel(item.type, this));
-
- setLayout(hLayout);
-
- connect(m_engineBar, SIGNAL(searchEngineChanged(KService::Ptr)), this, SLOT(changeSearchEngine(KService::Ptr)));
-}
-
-
-QString SearchListItem::text()
-{
- return m_text;
-}
-
-
-void SearchListItem::changeSearchEngine(KService::Ptr engine)
-{
- // NOTE: This to let rekonq loading text typed in the requested engine on click.
- // There probably is a better way to do it. I just cannot see it now...
- UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(engine, m_text), m_text);
- SearchListItem sItem(item, m_text, this);
- emit itemClicked(&sItem, Qt::LeftButton, Qt::NoModifier);
-}
-
-
-void SearchListItem::nextItemSubChoice()
-{
- m_engineBar->selectNextEngine();
-}
-
-
-// -----------------------------------------------------------------------------------------------
-
-
-EngineBar::EngineBar(KService::Ptr selectedEngine, QWidget *parent)
- : KToolBar(parent)
-{
- setIconSize(QSize(16, 16));
- setToolButtonStyle(Qt::ToolButtonIconOnly);
-
- m_engineGroup = new QActionGroup(this);
- m_engineGroup->setExclusive(true);
-
- if (SearchEngine::defaultEngine().isNull())
- return;
- m_engineGroup->addAction(newEngineAction(SearchEngine::defaultEngine(), selectedEngine));
- Q_FOREACH(const KService::Ptr & engine, SearchEngine::favorites())
- {
- if (engine->desktopEntryName() != SearchEngine::defaultEngine()->desktopEntryName())
- {
- m_engineGroup->addAction(newEngineAction(engine, selectedEngine));
- }
- }
-
- addActions(m_engineGroup->actions());
-}
-
-
-KAction *EngineBar::newEngineAction(KService::Ptr engine, KService::Ptr selectedEngine)
-{
- QUrl u = engine->property("Query").toUrl();
- KUrl url = KUrl(u.toString(QUrl::RemovePath | QUrl::RemoveQuery));
-
- KAction *a = new KAction(rApp->iconManager()->iconForUrl(url), engine->name(), this);
- a->setCheckable(true);
- if (engine->desktopEntryName() == selectedEngine->desktopEntryName()) a->setChecked(true);
- a->setData(engine->entryPath());
- connect(a, SIGNAL(triggered(bool)), this, SLOT(changeSearchEngine()));
- return a;
-}
-
-
-void EngineBar::changeSearchEngine()
-{
- KAction *a = qobject_cast<KAction*>(sender());
- emit searchEngineChanged(KService::serviceByDesktopPath(a->data().toString()));
-}
-
-
-void EngineBar::selectNextEngine()
-{
- QList<QAction *> e = m_engineGroup->actions();
- int i = 0;
- while (i < e.count() && !e.at(i)->isChecked())
- {
- i++;
- }
-
- if (i + 1 == e.count())
- {
- e.at(0)->setChecked(true);
- e.at(0)->trigger();
- }
- else
- {
- e.at(i + 1)->setChecked(true);
- e.at(i + 1)->trigger();
- }
-}
-
-
-// ---------------------------------------------------------------
-
-
-SuggestionListItem::SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
- , m_text(item.title)
-{
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
-
- hLayout->addWidget(new IconLabel(item.url, this));
- hLayout->addWidget(new TextLabel(item.title, text, this));
- hLayout->addWidget(new TypeIconLabel(item.type, this));
-
- setLayout(hLayout);
-}
-
-
-QString SuggestionListItem::text()
-{
- return m_text;
-}
-
-
-// ---------------------------------------------------------------
-
-
-VisualSuggestionListItem::VisualSuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
- , m_text(item.title)
-{
-
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
- QLabel *previewLabelIcon = new QLabel(this);
-
- if (!item.image.isEmpty())
- {
- previewLabelIcon->setFixedSize(item.image_width + 10, item.image_height + 10);
- new ImageLabel(item.image, item.image_width, item.image_height, previewLabelIcon);
- IconLabel* icon = new IconLabel(item.url, previewLabelIcon);
- icon->move(item.image_width - 10, item.image_height - 10);
- }
- else
- {
- previewLabelIcon->setFixedSize(18, 18);
- new IconLabel(item.url, previewLabelIcon);
- }
-
- hLayout->addWidget(previewLabelIcon);
- QVBoxLayout *vLayout = new QVBoxLayout;
- vLayout->setMargin(0);
- vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
- vLayout->addWidget(new TextLabel(item.title, text, this));
- DescriptionLabel *d = new DescriptionLabel("", this);
- vLayout->addWidget(d);
- vLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
- hLayout->addLayout(vLayout);
- hLayout->addWidget(new TypeIconLabel(item.type, this));
- setLayout(hLayout);
- d->setText("<i>" + item.description + "</i>");
-}
-
-
-QString VisualSuggestionListItem::text()
-{
- return m_text;
-}
-
-
-// ---------------------------------------------------------------
-
-
-BrowseListItem::BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent)
- : ListItem(item, parent)
-{
- QHBoxLayout *hLayout = new QHBoxLayout;
- hLayout->setSpacing(4);
-
- hLayout->addWidget(new IconLabel(item.url, this));
- hLayout->addWidget(new TextLabel(item.url, text, this));
- hLayout->addWidget(new TypeIconLabel(item.type, this));
-
- setLayout(hLayout);
-}
-
-
-// ---------------------------------------------------------------
-
-
-ListItem *ListItemFactory::create(const UrlSearchItem &item, const QString &text, QWidget *parent)
-{
- if (item.type & UrlSearchItem::Search)
- {
- return new SearchListItem(item, text, parent);
- }
-
- if (item.type & UrlSearchItem::Browse)
- {
- return new BrowseListItem(item, text, parent);
- }
-
- if (item.type & UrlSearchItem::History)
- {
- return new PreviewListItem(item, text, parent);
- }
-
- if (item.type & UrlSearchItem::Bookmark)
- {
- return new PreviewListItem(item, text, parent);
- }
-
- if (item.type & UrlSearchItem::Suggestion)
- {
- if (item.description.isEmpty())
- {
- return new SuggestionListItem(item, text, parent);
- }
-
- return new VisualSuggestionListItem(item, text, parent);
- }
-
- return new PreviewListItem(item, text, parent);
-}
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
deleted file mode 100644
index 84e3501b..00000000
--- a/src/urlbar/listitem.h
+++ /dev/null
@@ -1,291 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef LISTITEM_H
-#define LISTITEM_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE Includes
-#include <KToolBar>
-#include <KService>
-#include <KUrl>
-
-// Qt Includes
-#include <QWidget>
-#include <QLabel>
-#include <QStyleOptionViewItemV4>
-#include <QString>
-#include <QByteArray>
-
-// Forward Declarations
-class UrlSearchItem;
-
-class KAction;
-class KIcon;
-class KJob;
-
-class QActionGroup;
-
-
-class ListItem : public QWidget
-{
- Q_OBJECT
-
-public:
- explicit ListItem(const UrlSearchItem &item, QWidget *parent = 0);
- virtual ~ListItem();
-
- void activate();
- void deactivate();
-
- KUrl url();
- virtual QString text();
-
-public Q_SLOTS:
- virtual void nextItemSubChoice();
-
-Q_SIGNALS:
- void itemClicked(ListItem *item, Qt::MouseButton, Qt::KeyboardModifiers);
- void updateList();
-
-protected:
- virtual void paintEvent(QPaintEvent *event);
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
- virtual void mousePressEvent(QMouseEvent *e);
-
-private:
- QStyleOptionViewItemV4 m_option;
-
-protected:
- KUrl m_url;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class TypeIconLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- explicit TypeIconLabel(int type, QWidget *parent = 0);
-
-private:
- QLabel *getIcon(QString icon);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class IconLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- explicit IconLabel(const QString &icon, QWidget *parent = 0);
- explicit IconLabel(const KIcon &icon, QWidget *parent = 0);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class REKONQ_TESTS_EXPORT TextLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- explicit TextLabel(const QString &text, const QString &textToPointOut = QString(), QWidget *parent = 0);
- explicit TextLabel(QWidget *parent = 0);
-
- void setEngineText(const QString &engine, const QString &text);
-};
-
-// -------------------------------------------------------------------------
-
-
-class DescriptionLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- explicit DescriptionLabel(const QString &text, QWidget *parent = 0);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class EngineBar : public KToolBar
-{
- Q_OBJECT
-
-public:
- explicit EngineBar(KService::Ptr selectedEngine, QWidget *parent = 0);
- void selectNextEngine();
-
-Q_SIGNALS:
- void searchEngineChanged(KService::Ptr engine);
-
-private Q_SLOTS:
- void changeSearchEngine();
-
-private:
- KAction *newEngineAction(KService::Ptr engine, KService::Ptr selectedEngine);
- QActionGroup *m_engineGroup;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class SearchListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- explicit SearchListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0);
- QString text();
-
-public Q_SLOTS:
- virtual void nextItemSubChoice();
-
-private Q_SLOTS:
- void changeSearchEngine(KService::Ptr engine);
-
-private:
- TextLabel* m_titleLabel;
- IconLabel* m_iconLabel;
- EngineBar* m_engineBar;
- QString m_text;
- KService::Ptr m_currentEngine;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class SuggestionListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- SuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0);
- QString text();
-
-private:
- QString m_text;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class VisualSuggestionListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- VisualSuggestionListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0);
- QString text();
-
-private:
- QString m_text;
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class PreviewListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- PreviewListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class PreviewLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- PreviewLabel(const QString &url, int width, int height, QWidget *parent = 0);
-};
-
-
-// -------------------------------------------------------------------------
-
-class ImageLabel : public QLabel
-{
- Q_OBJECT
-
-public:
- ImageLabel(const QString &url, int width, int height, QWidget *parent);
-
-private:
- QString m_url;
- QByteArray m_data;
-
-private Q_SLOTS:
- void slotData(KJob* job, const QByteArray& data);
- void slotResult(KJob* job);
-};
-
-
-// -------------------------------------------------------------------------
-
-
-class BrowseListItem : public ListItem
-{
- Q_OBJECT
-
-public:
- BrowseListItem(const UrlSearchItem &item, const QString &text, QWidget *parent = 0);
-};
-
-
-//-------------------------------------------------------------------------------------------------
-
-
-class ListItemFactory
-{
-public:
- static ListItem *create(const UrlSearchItem &item, const QString &text, QWidget *parent);
-};
-
-
-#endif
diff --git a/src/urlbar/newresourcedialog.cpp b/src/urlbar/newresourcedialog.cpp
deleted file mode 100644
index 39cffc36..00000000
--- a/src/urlbar/newresourcedialog.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ============================================================
-*
-* This is a part of the GSoC project 2011 - Fancy Bookmarking
-*
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "newresourcedialog.h"
-#include "newresourcedialog.moc"
-
-// Nepomuk Includes
-#include <Nepomuk/Vocabulary/NCO>
-#include <Nepomuk/Vocabulary/PIMO>
-#include <Nepomuk/Resource>
-#include <Nepomuk/Tag>
-
-// Qt Includes
-#include <QPlainTextEdit>
-#include <QVBoxLayout>
-#include <QLabel>
-
-
-class Nepomuk::NewResourceDialog::Private
-{
-public:
- KLineEdit *m_resourceName;
- QPlainTextEdit *m_description;
- QLabel *m_titleResource;
- QLabel *m_desResource;
- Nepomuk::NewResourceDialog *q;
- Nepomuk::Resource m_nofResource;
- int m_index;
-};
-
-
-Nepomuk::NewResourceDialog::NewResourceDialog(int index, Nepomuk::Resource& nfoResource, QWidget* parent):
- KDialog(parent),
- d(new Private())
-{
- d->q = this;
- d->m_index = index;
- d->m_nofResource = nfoResource;
- setWindowTitle(i18n("Link to new Resource"));
- setButtonText(Ok, i18n("Link"));
- setMinimumSize(200, 150);
-
- QVBoxLayout *layout = new QVBoxLayout(mainWidget());
- d->m_resourceName = new KLineEdit(mainWidget());
- d->m_titleResource = new QLabel(mainWidget());
- d->m_titleResource->setText(i18n("* Resource Name:"));
- layout->addWidget(d->m_titleResource);
- layout->addWidget(d->m_resourceName);
- d->m_description = new QPlainTextEdit(mainWidget());
- d->m_desResource = new QLabel(mainWidget());
- d->m_desResource->setText(i18n("Description (Optional)"));
- layout->addWidget(d->m_desResource);
- layout->addWidget(d->m_description);
-
- connect(this, SIGNAL(okClicked()), this, SLOT(newResourceSlot()));
-}
-
-
-Nepomuk::NewResourceDialog::~NewResourceDialog()
-{
- delete d;
-}
-
-
-void Nepomuk::NewResourceDialog::newResourceSlot()
-{
- if (d->m_index == 1)
- {
- Nepomuk::Resource newResource(d->m_resourceName->text(), Nepomuk::Vocabulary::PIMO::Person());
- newResource.addSymbol("user-identity");
- d->m_nofResource.addIsRelated(newResource);
- }
- else if (d->m_index == 2)
- {
- Nepomuk::Resource newResource(d->m_resourceName->text(), Nepomuk::Vocabulary::PIMO::Project());
- newResource.addSymbol("project-development");
- d->m_nofResource.addIsRelated(newResource);
- }
- else if (d->m_index == 3)
- {
- Nepomuk::Resource newResource(d->m_resourceName->text(), Nepomuk::Vocabulary::PIMO::Task());
- newResource.addSymbol("view-pim-tasks");
- d->m_nofResource.addIsRelated(newResource);
- }
- else if (d->m_index == 4)
- {
- Nepomuk::Resource newResource(d->m_resourceName->text(), Nepomuk::Vocabulary::PIMO::Location());
- newResource.addSymbol("user-location");
- d->m_nofResource.addIsRelated(newResource);
- }
- else if (d->m_index == 5)
- {
- Nepomuk::Resource newResource(d->m_resourceName->text(), Nepomuk::Vocabulary::PIMO::Note());
- newResource.addSymbol("knotes");
- d->m_nofResource.addIsRelated(newResource);
- }
-}
diff --git a/src/urlbar/newresourcedialog.h b/src/urlbar/newresourcedialog.h
deleted file mode 100644
index 651c631c..00000000
--- a/src/urlbar/newresourcedialog.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* ============================================================
-*
-* This is a part of the GSoC project 2011 - Fancy Bookmarking
-*
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef NEWRESOURCEDIALOG_H
-#define NEWRESOURCEDIALOG_H
-
-
-// KDE Includes
-#include <KDialog>
-#include <KLineEdit>
-
-#include <Nepomuk/Resource>
-
-
-namespace Nepomuk
-{
-class NewResourceDialog : public KDialog
-{
- Q_OBJECT
-
-public:
- explicit NewResourceDialog(int index, Nepomuk::Resource& nfoResource, QWidget* parent = 0);
- virtual ~NewResourceDialog();
-
-private Q_SLOTS:
- void newResourceSlot();
-
-private:
- class Private;
- Private* const d;
-};
-}
-
-#endif // NEWRESOURCEDIALOG_H
diff --git a/src/urlbar/resourcelinkdialog.cpp b/src/urlbar/resourcelinkdialog.cpp
deleted file mode 100644
index 8a4b5685..00000000
--- a/src/urlbar/resourcelinkdialog.cpp
+++ /dev/null
@@ -1,385 +0,0 @@
-/* ============================================================
-*
-* This is a part of the GSoC project 2011 - Fancy Bookmarking
-*
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "resourcelinkdialog.h"
-#include "resourcelinkdialog.moc"
-
-// Local Includes
-#include "newresourcedialog.h"
-
-// Qt Includes
-#include <QGridLayout>
-#include <QHBoxLayout>
-#include <QComboBox>
-#include <QAbstractItemView>
-#include <QLabel>
-#include <QListView>
-#include <QPushButton>
-#include <QColumnView>
-#include <QStringListModel>
-#include <QStandardItem>
-#include <QModelIndexList>
-#include <QItemSelectionModel>
-#include <QMenu>
-#include <QListWidget>
-
-// KDE Includes
-#include <KLocale>
-#include <KDebug>
-#include <KAction>
-#include <KIcon>
-
-// Nepomuk Includes
-#include <Nepomuk/Utils/SimpleResourceModel>
-#include <Nepomuk/Query/Term>
-#include <Nepomuk/Query/Result>
-#include <Nepomuk/Query/ResourceTypeTerm>
-#include <Nepomuk/Query/QueryServiceClient>
-#include <Nepomuk/Vocabulary/PIMO>
-#include <Nepomuk/Vocabulary/NCO>
-#include <Nepomuk/Query/QueryParser>
-#include <Nepomuk/Variant>
-
-
-class Nepomuk::ResourceLinkDialog::Private
-{
-public:
- void _k_selectionChanged();
-
- KLineEdit *m_searchBox;
- QListView *m_resourceView;
- QListView *m_linkedResources;
- KAction *m_removeResourceAction;
- QComboBox *m_resourceSelect;
- QLabel *m_resourceLabel;
- QLabel *m_linkedResourceLabel;
- QColumnView *m_leftPanel;
- QStringListModel *m_model;
- QPushButton *m_newResourceButton;
- Utils::SimpleResourceModel *m_resourceModel;
- Utils::SimpleResourceModel *m_linkedResourceModel;
- Nepomuk::ResourceLinkDialog *q;
-
- Nepomuk::Resource m_nfoResource;
-
-};
-
-
-void Nepomuk::ResourceLinkDialog::Private::_k_selectionChanged()
-{
- q->enableButton(KDialog::User1, !m_resourceView->selectionModel()->selectedRows().isEmpty());
-}
-
-
-Nepomuk::ResourceLinkDialog::ResourceLinkDialog(Nepomuk::Resource &nfoResource, QWidget* parent):
- KDialog(parent),
- d(new Private())
-{
- d->m_nfoResource = nfoResource;
- setWindowTitle(i18n("Resource Linker"));
- setButtons(Ok | User1 | User2 | Cancel);
- enableButtonCancel(true);
- enableButtonOk(true);
- enableButton(User1, false);
- setButtonText(Ok, i18n("Done"));
- setButtonText(User1, i18n("Link"));
- setButtonText(User2, "Unlink");
- setMinimumSize(400, 350);
-// d->m_resourceView->setSelectionMode(QAbstractItemView::ExtendedSelection);
- QGridLayout *mainLayout = new QGridLayout(mainWidget());
-
- d->q = this;
-
- d->m_linkedResources = new QListView(mainWidget());
- d->m_linkedResourceModel = new Utils::SimpleResourceModel(this);
- d->m_linkedResources->setModel(d->m_linkedResourceModel);
- setRelatedResources();
-
- d->m_searchBox = new KLineEdit(mainWidget());
- d->m_searchBox->setPlaceholderText(i18n("Search resources"));
- connect(d->m_searchBox, SIGNAL(textChanged(QString)), this, SLOT(dynamicSearchingSlot()));
-
- d->m_resourceView = new QListView(mainWidget());
- d->m_resourceView->setToolTip(i18n(" Double click to link resource "));
- d->m_resourceModel = new Utils::SimpleResourceModel(this);
- d->m_resourceView->setModel(d->m_resourceModel);
-
- d->m_resourceSelect = new QComboBox(mainWidget());
- QStringList rlist;
- rlist << i18n("Any resource") << i18n("Persons") << i18n("Projects") << i18n("Tasks") << i18n("Places") << i18n("Notes");
- d->m_resourceSelect->addItems(rlist);
- d->m_resourceSelect->setItemIcon(1, KIcon("user-identity"));
- d->m_resourceSelect->setItemIcon(2, KIcon("project-development"));
- d->m_resourceSelect->setItemIcon(3, KIcon("view-pim-tasks"));
- d->m_resourceSelect->setItemIcon(4, KIcon("user-location"));
- d->m_resourceSelect->setItemIcon(5, KIcon("knotes"));
- connect(d->m_resourceSelect, SIGNAL(currentIndexChanged(int)), this, SLOT(resourceSelectedSlot(int)));
-
- d->m_resourceLabel = new QLabel(i18n("Matching resources:"), mainWidget());
- d->m_linkedResourceLabel = new QLabel(i18n("Linked Resources:"), mainWidget());
-
-
- d->m_newResourceButton = new QPushButton(mainWidget());
- d->m_newResourceButton->setText(i18n("Create New Resource"));
- if (d->m_resourceSelect->currentIndex() == 0)
- {
- d->m_newResourceButton->setEnabled(false);
- }
- connect(d->m_newResourceButton, SIGNAL(clicked()), this, SLOT(createNewResourceSlot()));
-
- QVBoxLayout *vlayoutR = new QVBoxLayout;
- QVBoxLayout *vlayoutL = new QVBoxLayout;
- vlayoutL->addWidget(d->m_searchBox);
- vlayoutL->addWidget(d->m_resourceLabel);
- vlayoutL->addWidget(d->m_resourceView);
- vlayoutR->addWidget(d->m_resourceSelect);
- vlayoutR->addWidget(d->m_linkedResourceLabel);
- vlayoutR->addWidget(d->m_linkedResources);
- vlayoutR->addWidget(d->m_newResourceButton);
- mainLayout->addLayout(vlayoutL, 1 , 1);
- mainLayout->addLayout(vlayoutR, 1, 2);
- mainLayout->setColumnMinimumWidth(1, 100);
-
- d->m_linkedResources->setContextMenuPolicy(Qt::CustomContextMenu);
-
- connect(d->m_resourceView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(_k_selectionChanged()));
- connect(d->m_linkedResources->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
- this, SLOT(_k_selectionChanged()));
- connect(this, SIGNAL(user1Clicked()), this, SLOT(linkResourceSlot()));
- connect(this, SIGNAL(user2Clicked()), this, SLOT(unlinkResourceSlot()));
- connect(d->m_resourceView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(linkResourceSlot()));
- connect(d->m_linkedResources, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint)));
-
- if (!d->m_linkedResources->selectionModel()->selectedRows().isEmpty())
- {
- enableButton(User2, true);
- }
-}
-
-
-Nepomuk::ResourceLinkDialog::~ResourceLinkDialog()
-{
- delete d;
-}
-
-
-void Nepomuk::ResourceLinkDialog::setRelatedResources()
-{
- QList<Nepomuk::Resource> relatedResourceList = d->m_nfoResource.isRelateds();
- d->m_linkedResourceModel->setResources(relatedResourceList);
-
-}
-
-
-void Nepomuk::ResourceLinkDialog::linkResourceSlot()
-{
- QModelIndexList selectedResourceList;
- selectedResourceList << d->m_resourceView->selectionModel()->selectedIndexes();
- Q_FOREACH(const QModelIndex & i, selectedResourceList)
- {
- d->m_resourceView->selectionModel()->setCurrentIndex(i, QItemSelectionModel::NoUpdate);
- d->m_nfoResource.addIsRelated(d->m_resourceModel->resourceForIndex(d->m_resourceView->selectionModel()->currentIndex()));
- }
- setRelatedResources();
-}
-
-
-void Nepomuk::ResourceLinkDialog::unlinkResourceSlot()
-{
- d->m_nfoResource.removeProperty(Nepomuk::Resource::isRelatedUri(),
- d->m_linkedResourceModel->resourceForIndex(
- d->m_linkedResources->selectionModel()->currentIndex()));
- setRelatedResources();
-}
-
-
-void Nepomuk::ResourceLinkDialog::showContextMenu(const QPoint &pos)
-{
- d->m_removeResourceAction = new KAction(this);
- d->m_removeResourceAction->setText(i18n("&Unlink "));
- d->m_removeResourceAction->setIcon(KIcon("edit-delete"));
- connect(d->m_removeResourceAction, SIGNAL(triggered(bool)), this, SLOT(unlinkResourceSlot()));
-
- QMenu myMenu;
- QPoint globalPos = d->m_linkedResources->mapToGlobal(pos);
- myMenu.addAction(d->m_removeResourceAction);
- myMenu.exec(globalPos);
-}
-
-
-void Nepomuk::ResourceLinkDialog::createNewResourceSlot()
-{
- Nepomuk::NewResourceDialog newResource(d->m_resourceSelect->currentIndex(), d->m_nfoResource);
- //close();
- newResource.exec();
- setRelatedResources();
-}
-
-
-void Nepomuk::ResourceLinkDialog::dynamicSearchingSlot()
-{
- Nepomuk::Query::Query query;
- Nepomuk::Query::QueryServiceClient *test;
- switch (d->m_resourceSelect->currentIndex())
- {
- case 1:
- query = Nepomuk::Query::QueryParser::parseQuery(d->m_searchBox->text());
- query = query && Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Person());
- test = new Nepomuk::Query::QueryServiceClient(this);
- test->query(query);
- d->m_resourceModel->clear();
- connect(test, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
- d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)));
- break;
-
- case 2:
- query = Nepomuk::Query::QueryParser::parseQuery(d->m_searchBox->text());
- query = query && Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Project());
- test = new Nepomuk::Query::QueryServiceClient(this);
- test->query(query);
- d->m_resourceModel->clear();
- connect(test, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
- d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)));
- break;
-
- case 3:
- query = Nepomuk::Query::QueryParser::parseQuery(d->m_searchBox->text());
- query = query && Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Task());
- test = new Nepomuk::Query::QueryServiceClient(this);
- test->query(query);
- d->m_resourceModel->clear();
- connect(test, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
- d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)));
- break;
-
- case 4:
- query = Nepomuk::Query::QueryParser::parseQuery(d->m_searchBox->text());
- query = query && Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Location());
- test = new Nepomuk::Query::QueryServiceClient(this);
- test->query(query);
- d->m_resourceModel->clear();
- connect(test, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
- d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)));
- break;
-
- case 5:
- query = Nepomuk::Query::QueryParser::parseQuery(d->m_searchBox->text());
- query = query && Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Note());
- test = new Nepomuk::Query::QueryServiceClient(this);
- test->query(query);
- d->m_resourceModel->clear();
- connect(test, SIGNAL(newEntries(QList<Nepomuk::Query::Result>)),
- d->m_resourceModel, SLOT(addResults(QList<Nepomuk::Query::Result>)));
- break;
-
- default:
- break;
- }
-}
-
-
-void Nepomuk::ResourceLinkDialog::resourceSelectedSlot(int index)
-{
- enableButton(User1, true);
- d->m_newResourceButton->setEnabled(true);
- if (index == 0)
- {
- d->m_resourceModel->clear();
- d->m_newResourceButton->setEnabled(false);
- }
- //List Personal Contacts
- if (index == 1)
- {
- Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Person());
- Nepomuk::Query::Query query(term);
- query.setLimit(20);
- QList<Nepomuk::Query::Result>results = Nepomuk::Query::QueryServiceClient::syncQuery(query);
- QList <Nepomuk::Resource> resource;
- Q_FOREACH(const Nepomuk::Query::Result & result, results)
- {
- resource.append(result.resource());
- }
- d->m_resourceModel->setResources(resource);
- }
- //List Projects
- else if (index == 2)
- {
- Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Project());
- Nepomuk::Query::Query query(term);
- query.setLimit(20);
- QList<Nepomuk::Query::Result>results = Nepomuk::Query::QueryServiceClient::syncQuery(query);
- QList <Nepomuk::Resource> resource;
- Q_FOREACH(const Nepomuk::Query::Result & result, results)
- {
- resource.append(result.resource());
- }
- d->m_resourceModel->setResources(resource);
- }
- //List Tasks
- else if (index == 3)
- {
- Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Task());
- Nepomuk::Query::Query query(term);
- query.setLimit(20);
- QList<Nepomuk::Query::Result>results = Nepomuk::Query::QueryServiceClient::syncQuery(query);
- QList <Nepomuk::Resource> resource;
- Q_FOREACH(const Nepomuk::Query::Result & result, results)
- {
- resource.append(result.resource());
- }
- d->m_resourceModel->setResources(resource);
- }
- //List Places
- else if (index == 4)
- {
- Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Location());
- Nepomuk::Query::Query query(term);
- query.setLimit(20);
- QList<Nepomuk::Query::Result>results = Nepomuk::Query::QueryServiceClient::syncQuery(query);
- QList <Nepomuk::Resource> resource;
- Q_FOREACH(const Nepomuk::Query::Result & result, results)
- {
- resource.append(result.resource());
- }
- d->m_resourceModel->setResources(resource);
- }
- //List Notes
- else if (index == 5)
- {
- Nepomuk::Query::Term term = Nepomuk::Query::ResourceTypeTerm(Nepomuk::Vocabulary::PIMO::Note());
- Nepomuk::Query::Query query(term);
- query.setLimit(20);
- QList<Nepomuk::Query::Result>results = Nepomuk::Query::QueryServiceClient::syncQuery(query);
- QList <Nepomuk::Resource> resource;
- Q_FOREACH(const Nepomuk::Query::Result & result, results)
- {
- resource.append(result.resource());
- }
- d->m_resourceModel->setResources(resource);
- }
-}
diff --git a/src/urlbar/resourcelinkdialog.h b/src/urlbar/resourcelinkdialog.h
deleted file mode 100644
index e628aa10..00000000
--- a/src/urlbar/resourcelinkdialog.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ============================================================
-*
-* This is a part of the GSoC project 2011 - Fancy Bookmarking
-*
-* Copyright (c) 2011-2012 by Phaneendra Hegde <pnh.pes@gmail.com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef RESOURCELINKDIALOG_H
-#define RESOURCELINKDIALOG_H
-
-//Qt includes
-#include <QListView>
-
-//kde includes
-#include <KDialog>
-#include <KLineEdit>
-#include <KConfigDialog>
-
-
-namespace Nepomuk
-{
-class Resource;
-
-namespace Query
-{
-class Query;
-}
-
-class ResourceLinkDialog : public KDialog
-{
- Q_OBJECT
-
-public:
- explicit ResourceLinkDialog(Nepomuk::Resource& nfoResource, QWidget* parent = 0);
- virtual ~ResourceLinkDialog();
- void setRelatedResources();
-
-private Q_SLOTS:
- void dynamicSearchingSlot();
- void resourceSelectedSlot(int);
- void linkResourceSlot();
- void unlinkResourceSlot();
- void createNewResourceSlot();
- void showContextMenu(const QPoint&);
-
-
-private:
- class Private;
- Private* const d;
-
-};
-}
-
-#endif // RESOURCELINKDIALOG_H
diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp
deleted file mode 100644
index 2e452fbb..00000000
--- a/src/urlbar/rsswidget.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Matthieu Gicquel <matgic78 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Auto Includes
-#include "rsswidget.h"
-#include "rsswidget.moc"
-
-// Local includes
-#include "application.h"
-#include "iconmanager.h"
-#include "mainwindow.h"
-#include "webtab.h"
-
-// KDE Includes
-#include <KComboBox>
-#include <KLocalizedString>
-#include <KMessageBox>
-#include <KProcess>
-#include <KUrl>
-
-// Qt Includes
-#include <QDBusConnectionInterface>
-#include <QDBusInterface>
-
-#include <QDialogButtonBox>
-#include <QFormLayout>
-#include <QLabel>
-#include <QPushButton>
-
-
-RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent)
- : QMenu(parent)
- , m_map(map)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setFixedWidth(350);
-
- QFormLayout *layout = new QFormLayout(this);
-
- // Title
- QLabel *title = new QLabel(this);
- title->setText(i18n("Subscribe to RSS Feeds"));
- QFont f = title->font();
- f.setBold(true);
- title->setFont(f);
- layout->addRow(title);
-
- // Agregators
- QLabel *agregator = new QLabel(this);
- agregator->setText(i18n("Aggregator:"));
-
- m_agregators = new KComboBox(this);
- m_agregators->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
- m_agregators->addItem(KIcon("akregator"), QString("Akregator"));
- m_agregators->addItem(rApp->iconManager()->iconForUrl(KUrl("http://google.com/reader")), i18n("Google Reader"));
-
- layout->addRow(agregator, m_agregators);
-
- // Feeds List
- QLabel *feed = new QLabel(this);
- feed->setText(i18n("Feed:"));
-
- m_feeds = new KComboBox(this);
- m_feeds->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
-
- Q_FOREACH(const QString & title, m_map)
- {
- m_feeds->addItem(title);
- }
-
- layout->addRow(feed, m_feeds);
-
- // Buttons
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Cancel, Qt::Horizontal, this);
-
- QPushButton *addFeed = new QPushButton(KIcon("list-add"), i18n("Add Feed"), buttonBox);
- buttonBox->addButton(addFeed, QDialogButtonBox::AcceptRole);
-
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
-
- layout->addRow(buttonBox);
-}
-
-
-void RSSWidget::showAt(const QPoint &pos)
-{
- adjustSize();
-
- QPoint p(pos.x() - width(), pos.y() + 10);
- move(p);
- show();
-}
-
-
-void RSSWidget::accept()
-{
- QString url = m_map.key(m_feeds->currentText()).toMimeDataString();
-
- if (m_agregators->currentIndex() == 0)
- addWithAkregator(url);
- else
- addWithGoogleReader(url);
-
- close();
-}
-
-
-void RSSWidget::addWithGoogleReader(const QString &url)
-{
- KUrl toLoad = KUrl("http://www.google.com/ig/add?feedurl=" + url);
- rApp->mainWindow()->currentTab()->view()->load(toLoad);
-}
-
-
-void RSSWidget::addWithAkregator(const QString &url)
-{
- // Akregator is running
- if (QDBusConnection::sessionBus().interface()->isServiceRegistered("org.kde.akregator"))
- {
- QDBusInterface akregator("org.kde.akregator", "/Akregator", "org.kde.akregator.part");
- QDBusReply<void> reply = akregator.call("addFeedsToGroup", QStringList(url) , i18n("Imported Feeds"));
-
- if (!reply.isValid())
- {
- KMessageBox::error(0, QString(i18n("Could not add feed to Akregator. Please add it manually:")
- + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>"));
- }
- }
- // Akregator is not running
- else
- {
- KProcess proc;
- proc << "akregator" << "-g" << i18n("Imported Feeds");
- proc << "-a" << url;
- if (proc.startDetached() == 0)
- {
- KMessageBox::error(0, QString(i18n("There was an error. Please verify Akregator is installed on your system.")
- + "<br /><br /> <a href=\"" + url + "\">" + url + "</a>"));
- }
- }
-}
diff --git a/src/urlbar/rsswidget.h b/src/urlbar/rsswidget.h
deleted file mode 100644
index eaa3de7d..00000000
--- a/src/urlbar/rsswidget.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Matthieu Gicquel <matgic78 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef RSSWIDGET_H
-#define RSSWIDGET_H
-
-// Qt Includes
-#include <QMenu>
-
-// Forward Declarations
-class KComboBox;
-class KUrl;
-
-
-class RSSWidget : public QMenu
-{
- Q_OBJECT
-
-public:
- // QMap< feedUrl, feedTitle>
- RSSWidget(const QMap<KUrl, QString> &map, QWidget *parent = 0);
-
- void showAt(const QPoint &pos);
-
-private Q_SLOTS:
- void accept();
-
-private:
- void addWithAkregator(const QString &url);
- void addWithGoogleReader(const QString &url);
-
- QMap<KUrl, QString> m_map;
-
- KComboBox *m_agregators;
- KComboBox *m_feeds;
-};
-
-#endif // RSSWIDGET_H
diff --git a/src/urlbar/sslwidget.cpp b/src/urlbar/sslwidget.cpp
deleted file mode 100644
index 52724733..00000000
--- a/src/urlbar/sslwidget.cpp
+++ /dev/null
@@ -1,252 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2011-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Auto Includes
-#include "sslwidget.h"
-#include "sslwidget.moc"
-
-// Local includes
-#include "application.h"
-#include "historymanager.h"
-#include "sslinfodialog.h"
-
-// Qt Includes
-#include <QPointer>
-
-#include <QDialogButtonBox>
-#include <QGridLayout>
-#include <QLabel>
-#include <QPushButton>
-#include <QTextDocument>
-
-
-SSLWidget::SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent)
- : QMenu(parent)
- , m_url(url)
- , m_info(info)
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setMinimumWidth(400);
-
- QList<QSslCertificate> certList = m_info.certificateChain();
- QSslCertificate cert;
- if (!certList.isEmpty())
- cert = certList.first();
-
- QList<QStringList> certErrorList = SslInfoDialog::errorsFromString(m_info.certificateErrors());
- QStringList firstCertErrorList;
- if (!certErrorList.isEmpty())
- firstCertErrorList = certErrorList.first();
-
- QGridLayout *layout = new QGridLayout(this);
-
- QLabel *label;
- QLabel *imageLabel;
-
- int rows = 0;
- // ------------------------------------------------------------------------------------------------------
- imageLabel = new QLabel(this);
- layout->addWidget(imageLabel, rows , 0, Qt::AlignCenter);
-
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("Identity"));
- QFont f1 = label->font();
- f1.setBold(true);
- label->setFont(f1);
- layout->addWidget(label, rows++, 1);
-
- label = new QLabel(this);
- label->setWordWrap(true);
- if (cert.isNull())
- {
- label->setText(i18n("Warning: this site is NOT carrying a certificate."));
- imageLabel->setPixmap(KIcon("security-low").pixmap(32));
- layout->addWidget(label, rows++, 1);
- }
- else
- {
- if (cert.isValid() && firstCertErrorList.isEmpty())
- {
- label->setText(i18n("The certificate for this site is valid and has been verified by:\n%1.",
- Qt::escape(cert.issuerInfo(QSslCertificate::CommonName))));
-
- imageLabel->setPixmap(KIcon("security-high").pixmap(32));
- }
- else
- {
- QString c = QL1S("<ul>");
- Q_FOREACH(const QString & s, firstCertErrorList)
- {
- c += QL1S("<li>") + s + QL1S("</li>");
- }
- c += QL1S("</ul>");
-
- label->setText(i18n("The certificate for this site is NOT valid, for the following reasons:\n%1.", c));
- label->setTextFormat(Qt::RichText);
- imageLabel->setPixmap(KIcon("security-low").pixmap(32));
- }
-
- layout->addWidget(label, rows++, 1);
-
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(QL1S("<a href=\"moresslinfos\">") + i18n("Certificate Information") + QL1S("</a>"));
- connect(label, SIGNAL(linkActivated(QString)), this, SLOT(showMoreSslInfos(QString)));
- layout->addWidget(label, rows++, 1);
- }
-
- // -------------------------------------------------------------------------------------------------------------
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("Encryption"));
- QFont f2 = label->font();
- f2.setBold(true);
- label->setFont(f2);
- layout->addWidget(label, rows, 1);
-
- imageLabel = new QLabel(this);
- layout->addWidget(imageLabel, rows++ , 0, Qt::AlignCenter);
-
- QString ciph = m_info.ciphers();
- if (ciph.isEmpty()) // NOTE: Can I verify encryption in another (better?) way?
- {
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("Your connection to %1 is NOT encrypted.\n", m_url.host()));
- layout->addWidget(label, rows++ , 1);
-
- imageLabel->setPixmap(KIcon("security-low").pixmap(32));
- }
- else
- {
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("Your connection to \"%1\" is encrypted.\n", m_url.host()));
- layout->addWidget(label, rows++, 1);
-
- QString vers = m_info.protocol();
- QString sslVersion;
- if (vers == QL1S("SSLv3"))
- {
- sslVersion = QL1S("SSL 3.0");
- imageLabel->setPixmap(KIcon("security-high").pixmap(32));
- }
- else if (vers == QL1S("SSLv2"))
- {
- sslVersion = QL1S("SSL 2.0");
- imageLabel->setPixmap(KIcon("security-low").pixmap(32));
- }
- else if (vers == QL1S("TLSv1"))
- {
- sslVersion = QL1S("TLS 1.0");
- imageLabel->setPixmap(KIcon("security-high").pixmap(32));
- }
- else
- {
- sslVersion = i18n("Unknown");
- imageLabel->setPixmap(KIcon("security-low").pixmap(32));
- }
-
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("It uses protocol: %1.\n", sslVersion));
- layout->addWidget(label, rows++, 1);
-
- const QStringList cipherInfo = m_info.ciphers().split('\n', QString::SkipEmptyParts);
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(
- i18n("It is encrypted using %1 at %2 bits, with %3 for message authentication and %4 with Auth %5 as key exchange mechanism.\n\n",
- cipherInfo[0],
- m_info.usedChiperBits(),
- cipherInfo[3],
- cipherInfo[2],
- cipherInfo[1])
- );
- layout->addWidget(label, rows++, 1);
-
- }
-
- // ------------------------------------------------------------------------------------------------------------------
- imageLabel = new QLabel(this);
- layout->addWidget(imageLabel, rows , 0, Qt::AlignCenter);
-
- label = new QLabel(this);
- label->setWordWrap(true);
- label->setText(i18n("Site Information"));
- QFont f3 = label->font();
- f3.setBold(true);
- label->setFont(f3);
- layout->addWidget(label, rows++, 1);
-
- label = new QLabel(this);
- label->setWordWrap(true);
-
- QList<HistoryItem> hList = rApp->historyManager()->find(url.toString());
- HistoryItem firstVisit = hList.isEmpty() ?
- HistoryItem() :
- hList.first() ;
-
- if (firstVisit.visitCount == 1)
- {
- label->setText(i18n("It is your first time visiting this site."));
- imageLabel->setPixmap(KIcon("security-medium").pixmap(32));
- }
- else
- {
- label->setText(i18n("You just visited this site.\nYour first visit was on %1.\n", firstVisit.firstDateTimeVisit.toString()));
- imageLabel->setPixmap(KIcon("security-high").pixmap(32));
- }
- layout->addWidget(label, rows++, 1);
-
-}
-
-
-void SSLWidget::showAt(const QPoint &pos)
-{
- adjustSize();
-
- QPoint p(pos.x() - width(), pos.y() + 10);
- move(p);
- show();
-}
-
-
-void SSLWidget::accept()
-{
- close();
-}
-
-
-void SSLWidget::showMoreSslInfos(const QString &)
-{
- QPointer<SslInfoDialog> dlg = new SslInfoDialog(m_url.host(), m_info, this);
- dlg->exec();
- delete dlg;
-
- return;
-}
diff --git a/src/urlbar/sslwidget.h b/src/urlbar/sslwidget.h
deleted file mode 100644
index dd6f020d..00000000
--- a/src/urlbar/sslwidget.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2011-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef SSL_WIDGET_H
-#define SSL_WIDGET_H
-
-
-// Local Includes
-#include "websslinfo.h"
-
-// Qt Includes
-#include <QMenu>
-
-#include <QUrl>
-
-
-class SSLWidget : public QMenu
-{
- Q_OBJECT
-
-public:
- SSLWidget(const QUrl &url, const WebSslInfo &info, QWidget *parent = 0);
-
- void showAt(const QPoint &pos);
-
-private Q_SLOTS:
- void showMoreSslInfos(const QString &);
- void accept();
-
-private:
- QUrl m_url;
- WebSslInfo m_info;
-};
-
-#endif // SSL_WIDGET_H
diff --git a/src/urlbar/stackedurlbar.cpp b/src/urlbar/stackedurlbar.cpp
deleted file mode 100644
index 728a9c1b..00000000
--- a/src/urlbar/stackedurlbar.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "stackedurlbar.h"
-#include "stackedurlbar.moc"
-
-// Local Includes
-#include "urlbar.h"
-
-
-StackedUrlBar::StackedUrlBar(QWidget *parent)
- : QStackedWidget(parent)
-{
- // cosmetic
- setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
- setMinimumWidth(200);
- setMinimumHeight(20);
-}
-
-
-UrlBar *StackedUrlBar::currentUrlBar()
-{
- return urlBar(currentIndex());
-}
-
-
-UrlBar *StackedUrlBar::urlBar(int index)
-{
- UrlBar *urlBar = qobject_cast<UrlBar*>(QStackedWidget::widget(index));
- if (!urlBar)
- {
- kWarning() << "URL bar with index" << index << "not found. Returning NULL. line:" << __LINE__;
- }
-
- return urlBar;
-}
-
-
-void StackedUrlBar::moveBar(int from, int to)
-{
- QWidget *fromBar = widget(from);
- removeWidget(fromBar);
- insertWidget(to, fromBar);
-}
diff --git a/src/urlbar/stackedurlbar.h b/src/urlbar/stackedurlbar.h
deleted file mode 100644
index 7296a2f8..00000000
--- a/src/urlbar/stackedurlbar.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2010-2011 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef STACKED_URLBAR_H
-#define STACKED_URLBAR_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Qt Includes
-#include <QStackedWidget>
-
-// Forward Declarations
-class UrlBar;
-
-
-class REKONQ_TESTS_EXPORT StackedUrlBar : public QStackedWidget
-{
- Q_OBJECT
-
-public:
- StackedUrlBar(QWidget *parent = 0);
-
- UrlBar *currentUrlBar();
- UrlBar *urlBar(int index);
-
-private Q_SLOTS:
- void moveBar(int, int);
-};
-
-#endif // STACKED_URLBAR_H
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
deleted file mode 100644
index 21debceb..00000000
--- a/src/urlbar/urlbar.cpp
+++ /dev/null
@@ -1,773 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "urlbar.h"
-#include "urlbar.moc"
-
-// Auto Includes
-#include "rekonq.h"
-
-// Local Includes
-#include "application.h"
-#include "mainwindow.h"
-#include "webtab.h"
-#include "webpage.h"
-#include "webview.h"
-#include "completionwidget.h"
-#include "bookmarkmanager.h"
-#include "bookmarkowner.h"
-#include "bookmarkwidget.h"
-#include "iconmanager.h"
-#include "favoritewidget.h"
-#include "searchengine.h"
-#include "websnap.h"
-
-// KDE Includes
-#include <KCompletionBox>
-#include <KStandardDirs>
-#include <KColorScheme>
-#include <KMenu>
-#include <KIconLoader>
-
-// Qt Includes
-#include <QPainter>
-#include <QPaintEvent>
-#include <QPalette>
-#include <QVBoxLayout>
-#include <QClipboard>
-#include <QTimer>
-
-// const values
-const int c_iconMargin = 4;
-
-
-IconButton::IconButton(QWidget *parent)
- : QToolButton(parent)
-{
- setToolButtonStyle(Qt::ToolButtonIconOnly);
- setStyleSheet("IconButton { background-color:transparent; border: none; padding: 0px}");
- setCursor(Qt::ArrowCursor);
-
- setContextMenuPolicy(Qt::PreventContextMenu);
-}
-
-
-void IconButton::mouseReleaseEvent(QMouseEvent* event)
-{
- emit clicked(event->globalPos());
-}
-
-
-// -----------------------------------------------------------------------------------------------------------
-
-
-QString guessUrlWithCustomFirstLevel(const QString &str1, const QString &str2)
-{
- QUrl url(QL1S("http://www.") + str1);
- QString host = url.host().toLower();
- if (!host.endsWith(str2, Qt::CaseInsensitive))
- {
- host += str2;
- url.setHost(host);
- }
- return url.toString();
-}
-
-// -----------------------------------------------------------------------------------------------------------
-
-
-UrlBar::UrlBar(QWidget *parent)
- : KLineEdit(parent)
- , _tab(0)
- , _icon(new IconButton(this))
- , _suggestionTimer(new QTimer(this))
-{
- setLayoutDirection(Qt::LeftToRight);
-
- // set initial icon
- _icon->setIcon(KIcon("arrow-right"));
-
- // initial style
- setStyleSheet(QString("UrlBar { padding: 2px 0 2px %1px; height: %1px } ").arg(_icon->sizeHint().width()));
-
- // doesn't show the clear button
- setClearButtonShown(false);
-
- // enable dragging
- setDragEnabled(true);
-
- // insert decoded URLs
- setUrlDropsEnabled(true);
-
- // tooltip
- setToolTip(i18n("Type here to search your bookmarks, history and the web..."));
-
- // accept focus, via tabbing, clicking & wheeling
- setFocusPolicy(Qt::WheelFocus);
-
- // disable completion object (we have our own :) )
- setCompletionObject(0);
-
- _tab = qobject_cast<WebTab *>(parent);
-
- connect(_tab, SIGNAL(loadProgressing()), this, SLOT(update()));
-
- connect(_tab->view(), SIGNAL(urlChanged(QUrl)), this, SLOT(setQUrl(QUrl)));
- connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
- connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons()));
- connect(_tab->view(), SIGNAL(iconChanged()), this, SLOT(refreshFavicon()));
-
- // search icon
- connect(rApp->opensearchManager(), SIGNAL(openSearchEngineAdded(QString)), this, SLOT(updateRightIcons()));
-
- // bookmark icon
- connect(rApp->bookmarkManager(), SIGNAL(bookmarksUpdated()), this, SLOT(updateRightIcons()));
-
- _suggestionTimer->setSingleShot(true);
- connect(_suggestionTimer, SIGNAL(timeout()), this, SLOT(suggest()));
-
- activateSuggestions(true);
-}
-
-
-UrlBar::~UrlBar()
-{
- _suggestionTimer->stop();
- activateSuggestions(false);
- _box.clear();
-
- disconnect();
-}
-
-
-void UrlBar::setQUrl(const QUrl& url)
-{
- if (url.scheme() == QL1S("about"))
- {
- clear();
- setFocus();
- }
- else
- {
- clearFocus();
- KLineEdit::setUrl(url);
- setCursorPosition(0);
- refreshFavicon();
- }
-}
-
-
-void UrlBar::loadRequestedUrl(const KUrl& url, Rekonq::OpenType type)
-{
- activateSuggestions(false);
- clearFocus();
- setUrl(url);
- rApp->loadUrl(url, type);
-}
-
-
-void UrlBar::loadDigitedUrl()
-{
- UrlResolver res(text());
- UrlSearchList list = res.orderedSearchItems();
- if (list.isEmpty())
- {
- loadRequestedUrl(KUrl(text()));
- }
- else
- {
- loadRequestedUrl(list.first().url);
- }
-}
-
-
-void UrlBar::paintEvent(QPaintEvent *event)
-{
- KColorScheme colorScheme(palette().currentColorGroup());
- QColor backgroundColor;
- QColor foregroundColor;
-
- if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- backgroundColor = QColor(220, 220, 220); // light gray
- foregroundColor = Qt::black;
- }
- else
- {
- backgroundColor = rApp->palette().color(QPalette::Base);
- foregroundColor = rApp->palette().color(QPalette::Text);
- }
-
- // set background color of UrlBar
- QPalette p = palette();
-
- int progr = _tab->progress();
- if (progr == 0 || progr == 100)
- {
- if (_tab->url().scheme() == QL1S("https"))
- {
- backgroundColor = _tab->page()->hasSslValid()
- ? colorScheme.background(KColorScheme::PositiveBackground).color()
- : colorScheme.background(KColorScheme::NegativeBackground).color();
-
- foregroundColor = colorScheme.foreground(KColorScheme::NormalText).color();
- }
- p.setBrush(QPalette::Base, backgroundColor);
- p.setBrush(QPalette::Text, foregroundColor);
- }
- else
- {
- QColor highlight = rApp->palette().color(QPalette::Highlight);
-
- int r = (highlight.red() + 2 * backgroundColor.red()) / 3;
- int g = (highlight.green() + 2 * backgroundColor.green()) / 3;
- int b = (highlight.blue() + 2 * backgroundColor.blue()) / 3;
-
- QColor loadingColor(r, g, b);
-
- if (abs(loadingColor.lightness() - backgroundColor.lightness()) < 20) //eg. Gaia color scheme
- {
- r = (2 * highlight.red() + backgroundColor.red()) / 3;
- g = (2 * highlight.green() + backgroundColor.green()) / 3;
- b = (2 * highlight.blue() + backgroundColor.blue()) / 3;
- loadingColor = QColor(r, g, b);
- }
-
- QLinearGradient gradient(QPoint(0, 0), QPoint(width(), 0));
- gradient.setColorAt(0, loadingColor);
- gradient.setColorAt(((double)progr) / 100 - .000001, loadingColor);
- gradient.setColorAt(((double)progr) / 100, backgroundColor);
- p.setBrush(QPalette::Base, gradient);
- }
- setPalette(p);
-
- // you need this before our code to draw inside the line edit..
- KLineEdit::paintEvent(event);
-
- if (text().isEmpty() && (progr == 0 || progr == 100))
- {
- QStyleOptionFrame option;
- initStyleOption(&option);
- QRect textRect = style()->subElementRect(QStyle::SE_LineEditContents, &option, this);
- QPainter painter(this);
- painter.setPen(Qt::gray);
- painter.drawText(textRect,
- Qt::AlignVCenter | Qt::AlignCenter,
- i18n("Type here to search your bookmarks, history and the web...")
- );
- }
-}
-
-
-void UrlBar::keyPressEvent(QKeyEvent *event)
-{
- QString currentText = text().trimmed();
-
- if (currentText.isEmpty())
- return KLineEdit::keyPressEvent(event);
-
- // this handles the Modifiers + Return key combinations
- if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)
- {
- switch (event->modifiers())
- {
- case Qt::AltModifier:
- loadRequestedUrl(currentText, Rekonq::NewFocusedTab);
- break;
-
- case Qt::ControlModifier:
- loadRequestedUrl(guessUrlWithCustomFirstLevel(currentText, QL1S(".com")));
- break;
-
- case 0x06000000: // Qt::ControlModifier | Qt::ShiftModifier:
- loadRequestedUrl(guessUrlWithCustomFirstLevel(currentText, QL1S(".org")));
- break;
-
- case Qt::ShiftModifier:
- loadRequestedUrl(guessUrlWithCustomFirstLevel(currentText, QL1S(".net")));
- break;
-
- default:
- loadRequestedUrl(currentText);
- break;
- }
- }
-
- if (event->key() == Qt::Key_Escape)
- {
- clearFocus();
- if (!(_tab->url().protocol() == QL1S("about")))
- setText(_tab->url().url());
- event->accept();
- }
-
- KLineEdit::keyPressEvent(event);
-}
-
-
-void UrlBar::focusInEvent(QFocusEvent *event)
-{
- activateSuggestions(true);
- rApp->mainWindow()->updateTabActions();
-
- KLineEdit::focusInEvent(event);
-}
-
-
-void UrlBar::dropEvent(QDropEvent *event)
-{
- // handles only plain-text with url format
- if (event->mimeData()->hasFormat("text/plain") && event->source() != this)
- {
- QUrl url = QUrl::fromUserInput(event->mimeData()->data("text/plain"));
-
- if (url.isValid())
- {
- setQUrl(url);
- loadRequestedUrl(text());
- return;
- }
- }
-
- // handles everything else
- KLineEdit::dropEvent(event);
- loadRequestedUrl(text());
-}
-
-
-void UrlBar::loadFinished()
-{
- if (_tab->url().scheme() == QL1S("about"))
- {
- update();
- return;
- }
-
- // show bookmark info
- IconButton *bt = addRightIcon(UrlBar::BK);
- connect(bt, SIGNAL(clicked(QPoint)), this, SLOT(manageBookmarks()));
-
- // show favorite icon
- IconButton *fbt = addRightIcon(UrlBar::Favorite);
- connect(fbt, SIGNAL(clicked(QPoint)), this, SLOT(manageFavorites(QPoint)));
-
- // show KGet downloads??
- if (!KStandardDirs::findExe("kget").isNull() && ReKonfig::kgetList())
- {
- IconButton *bt = addRightIcon(UrlBar::KGet);
- connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(downloadAllContentsWithKGet()));
- }
-
- // show RSS
- if (_tab->hasRSSInfo())
- {
- IconButton *bt = addRightIcon(UrlBar::RSS);
- connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showRSSInfo(QPoint)));
- }
-
- // show SSL
- if (_tab->url().scheme() == QL1S("https"))
- {
- // NOTE: the choice for the right SSL icon is done in the addRightIcon method
- IconButton *bt = addRightIcon(UrlBar::SSL);
- connect(bt, SIGNAL(clicked(QPoint)), _tab->page(), SLOT(showSSLInfo(QPoint)));
- }
-
- // show add search engine
- if (_tab->hasNewSearchEngine())
- {
- IconButton *bt = addRightIcon(UrlBar::SearchEngine);
- connect(bt, SIGNAL(clicked(QPoint)), _tab, SLOT(showSearchEngine(QPoint)));
- }
-
- if (_tab->hasAdBlockedElements())
- {
- IconButton *bt = addRightIcon(UrlBar::AdBlock);
-
- connect(bt, SIGNAL(clicked(QPoint)), (QObject *) rApp->adblockManager(), SLOT(showBlockedItemDialog()));
- }
-
- // we need to update urlbar after the right icon settings
- // removing this code (where setStyleSheet automatically calls update) needs adding again
- // an update call
- int oneIconWidth = _icon->sizeHint().width();
- int rightIconWidth = (oneIconWidth + c_iconMargin) * (_rightIconsList.count());
- setStyleSheet(QString("UrlBar { padding: 2px %2px 2px %1px; height: %1px } ").arg(oneIconWidth).arg(rightIconWidth));
-}
-
-
-void UrlBar::updateRightIcons()
-{
- if (!_tab->isPageLoading())
- {
- clearRightIcons();
- loadFinished();
- }
-}
-
-
-void UrlBar::activateSuggestions(bool b)
-{
- if (b)
- {
- if (_box.isNull())
- {
- _box = new CompletionWidget(this);
- installEventFilter(_box.data());
- connect(_box.data(), SIGNAL(chosenUrl(KUrl, Rekonq::OpenType)), this, SLOT(loadRequestedUrl(KUrl, Rekonq::OpenType)));
-
- // activate suggestions on edit text
- connect(this, SIGNAL(textChanged(QString)), this, SLOT(detectTypedString(QString)));
- }
- }
- else
- {
- disconnect(this, SIGNAL(textChanged(QString)), this, SLOT(detectTypedString(QString)));
- removeEventFilter(_box.data());
- if (!_box.isNull())
- _box.data()->deleteLater();
- }
-}
-
-
-void UrlBar::mouseDoubleClickEvent(QMouseEvent *event)
-{
- Q_UNUSED(event);
-
- selectAll();
-}
-
-
-void UrlBar::contextMenuEvent(QContextMenuEvent* event)
-{
- KMenu menu;
- const bool clipboardFilled = !rApp->clipboard()->text().isEmpty();
-
- // Cut
- KAction *a = KStandardAction::cut(this, SLOT(cut()), this);
- a->setEnabled(hasSelectedText());
- menu.addAction(a);
-
- // Copy
- a = KStandardAction::copy(this, SLOT(copy()), this);
- a->setEnabled(hasSelectedText());
- menu.addAction(a);
-
- // Paste
- a = KStandardAction::paste(this, SLOT(paste()), this);
- a->setEnabled(clipboardFilled);
- menu.addAction(a);
-
- // Paste & Go
- const QString clipboardText = rApp->clipboard()->text();
- if (isValidURL(clipboardText) || clipboardText.isEmpty())
- {
- a = new KAction(i18n("Paste && Go"), this);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(pasteAndGo()));
- }
- else
- {
- a = new KAction(i18n("Paste && Search"), this);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(pasteAndSearch()));
- }
- a->setEnabled(clipboardFilled);
- menu.addAction(a);
-
- // Delete
- a = new KAction(KIcon("edit-delete"), i18n("Delete"), this);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(delSlot()));
- a->setEnabled(hasSelectedText());
- menu.addAction(a);
-
- menu.addSeparator();
-
- // Select All
- a = KStandardAction::selectAll(this, SLOT(selectAll()), this);
- a->setEnabled(!text().isEmpty());
- menu.addAction(a);
-
- menu.exec(event->globalPos());
-}
-
-
-bool UrlBar::isValidURL(QString url)
-{
- bool isValid = false;
- if (url.startsWith(QL1S("http://"))
- || url.startsWith(QL1S("https://"))
- || url.startsWith(QL1S("ftp://"))
- )
- url = url.remove(QRegExp("(http|https|ftp)://"));
-
- if (url.contains(QL1C('.'))
- && url.indexOf(QL1C('.')) > 0
- && url.indexOf(QL1C('.')) < url.length()
- && !url.trimmed().contains(QL1C(' '))
- && QUrl::fromUserInput(url).isValid()
- )
- isValid = true;
-
- return isValid;
-}
-
-
-IconButton *UrlBar::addRightIcon(UrlBar::icon ic)
-{
- IconButton *rightIcon = new IconButton(this);
-
- switch (ic)
- {
- case UrlBar::KGet:
- rightIcon->setIcon(KIcon("download"));
- rightIcon->setToolTip(i18n("List all links with KGet"));
- break;
- case UrlBar::RSS:
- rightIcon->setIcon(KIcon("application-rss+xml"));
- rightIcon->setToolTip(i18n("List all available RSS feeds"));
- break;
- case UrlBar::SSL:
- _tab->page()->hasSslValid()
- ? rightIcon->setIcon(KIcon("object-locked"))
- : rightIcon->setIcon(KIcon("object-unlocked"));
- rightIcon->setToolTip(i18n("Show SSL Info"));
- break;
- case UrlBar::BK:
- if (rApp->bookmarkManager()->bookmarkForUrl(_tab->url()).isNull())
- {
- rightIcon->setIcon(KIcon("bookmarks").pixmap(32, 32, QIcon::Disabled));
- rightIcon->setToolTip(i18n("Bookmark this page"));
- }
- else
- {
- rightIcon->setIcon(KIcon("bookmarks"));
- rightIcon->setToolTip(i18n("Edit this bookmark"));
- }
- break;
- case UrlBar::SearchEngine:
- {
- KIcon wsIcon("edit-web-search");
- if (wsIcon.isNull())
- {
- wsIcon = KIcon("preferences-web-browser-shortcuts");
- }
- rightIcon->setIcon(wsIcon);
- rightIcon->setToolTip(i18n("Add search engine"));
- break;
- }
- case UrlBar::Favorite:
- if (ReKonfig::previewUrls().contains(_tab->url().url()))
- {
- rightIcon->setIcon(KIcon("emblem-favorite"));
- rightIcon->setToolTip(i18n("Remove from favorite"));
- }
- else
- {
- rightIcon->setIcon(KIcon("emblem-favorite").pixmap(32, 32, QIcon::Disabled));
- rightIcon->setToolTip(i18n("Add to favorites"));
- }
- break;
- case UrlBar::AdBlock:
- rightIcon->setIcon(KIcon("preferences-web-browser-adblock"));
- rightIcon->setToolTip(i18n("There are elements blocked by AdBlock"));
- break;
- default:
- ASSERT_NOT_REACHED("ERROR.. default non extant case!!");
- break;
- }
-
- _rightIconsList << rightIcon;
-
- int iconsCount = _rightIconsList.count();
- updateRightIconPosition(rightIcon, iconsCount);
-
- rightIcon->show();
-
- return rightIcon;
-}
-
-
-void UrlBar::clearRightIcons()
-{
- qDeleteAll(_rightIconsList);
- _rightIconsList.clear();
-}
-
-
-void UrlBar::resizeEvent(QResizeEvent *event)
-{
- int ih = _icon->sizeHint().height();
- int iconsCount = _rightIconsList.count();
- int iconHeight = (height() - ih) / 2;
-
- _icon->move(c_iconMargin, iconHeight);
-
- for (int i = 0; i < iconsCount; ++i)
- {
- IconButton *bt = _rightIconsList.at(i);
- updateRightIconPosition(bt, i + 1);
- }
-
- KLineEdit::resizeEvent(event);
-}
-
-
-void UrlBar::detectTypedString(const QString &typed)
-{
- if (typed.count() == 1)
- {
- QTimer::singleShot(0, this, SLOT(suggest()));
- return;
- }
-
- if (_suggestionTimer->isActive())
- _suggestionTimer->stop();
- _suggestionTimer->start(50);
-}
-
-
-void UrlBar::suggest()
-{
- if (!_box.isNull())
- _box.data()->suggestUrls(text());
-}
-
-
-void UrlBar::refreshFavicon()
-{
- if (QWebSettings::globalSettings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- _icon->setIcon(KIcon("view-media-artist"));
- return;
- }
-
- KUrl u = _tab->url();
- if (u.scheme() == QL1S("about"))
- {
- _icon->setIcon(KIcon("arrow-right"));
- return;
- }
- _icon->setIcon(rApp->iconManager()->iconForUrl(u));
-}
-
-
-void UrlBar::pasteAndGo()
-{
- loadRequestedUrl(rApp->clipboard()->text());
-}
-
-
-void UrlBar::pasteAndSearch()
-{
- KService::Ptr defaultEngine = SearchEngine::defaultEngine();
- if (defaultEngine)
- loadRequestedUrl(KUrl(SearchEngine::buildQuery(defaultEngine, rApp->clipboard()->text())));
-}
-
-
-void UrlBar::delSlot()
-{
- del();
-}
-
-
-void UrlBar::manageBookmarks()
-{
- if (_tab->url().scheme() == QL1S("about"))
- return;
-
- KBookmark bookmark = rApp->bookmarkManager()->bookmarkForUrl(_tab->url());
-
- if (bookmark.isNull())
- {
- bookmark = rApp->bookmarkManager()->owner()->bookmarkCurrentPage();
- }
-
- // calculate position
- int iconSize = IconSize(KIconLoader::Small) + c_iconMargin;
-
- // Add a generic 10 to move it a bit below and right.
- // No need to be precise...
- int iconWidth = 10 + width() - ((iconSize + c_iconMargin));
- int iconHeight = 10 + (height() - iconSize) / 2;
-
- QPoint p = mapToGlobal(QPoint(iconWidth, iconHeight));
-
- // show bookmark widget
- BookmarkWidget *widget = new BookmarkWidget(bookmark, window());
- widget->showAt(p);
-}
-
-
-void UrlBar::manageFavorites(QPoint pos)
-{
- IconButton *bt = qobject_cast<IconButton *>(this->sender());
- if (!bt)
- return;
-
- if (_tab->url().scheme() == QL1S("about"))
- return;
-
- if (ReKonfig::previewUrls().contains(_tab->url().url()))
- {
- // remove site from favorites
- FavoriteWidget *widget = new FavoriteWidget(_tab, window());
- connect(widget, SIGNAL(updateIcon()), this, SLOT(updateRightIcons()));
- widget->showAt(pos);
- return;
- }
-
- // else, add as favorite
- QStringList urls = ReKonfig::previewUrls();
- urls << _tab->url().url();
- ReKonfig::setPreviewUrls(urls);
-
- QStringList titles = ReKonfig::previewNames();
- titles << _tab->view()->title();
- ReKonfig::setPreviewNames(titles);
-
- // also, save a site snapshot
- WebSnap *snap = new WebSnap(_tab->url(), this);
-
- updateRightIcons();
-}
-
-
-void UrlBar::updateRightIconPosition(IconButton *icon, int iconsCount)
-{
- // NOTE: cannot show a (let's say) 16x16 icon in a 16x16 square.
- // It needs some margin. It usually is 3, but using 4 (default rekonq icon margin)
- // seems NOT a big problem and let's us using just one const ;)
- int iconSize = IconSize(KIconLoader::Small) + c_iconMargin;
-
- int iconWidth = width() - ((iconSize + c_iconMargin) * iconsCount);
- int iconHeight = (height() - iconSize) / 2;
-
- icon->move(iconWidth, iconHeight);
-}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
deleted file mode 100644
index b2cf44ac..00000000
--- a/src/urlbar/urlbar.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2008-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-* Copyright (C) 2009 by Domrachev Alexandr <alexandr.domrachev@gmail.com>
-* Copyright (C) 2009 by Paweł Prażak <pawelprazak at gmail dot com>
-* Copyright (C) 2009-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef URLBAR_H
-#define URLBAR_H
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE Includes
-#include <KUrl>
-#include <KLineEdit>
-
-// Qt Includes
-#include <QWeakPointer>
-#include <QToolButton>
-
-// Forward Declarations
-class QWidget;
-class CompletionWidget;
-class WebTab;
-class QTimer;
-
-
-class IconButton : public QToolButton
-{
- Q_OBJECT
-
-public:
- IconButton(QWidget *parent = 0);
-
-Q_SIGNALS:
- void clicked(QPoint);
-
-protected:
- void mouseReleaseEvent(QMouseEvent *event);
-};
-
-
-// Definitions
-typedef QList<IconButton *> IconButtonPointerList;
-
-
-// ------------------------------------------------------------------------------------
-
-
-class REKONQ_TESTS_EXPORT UrlBar : public KLineEdit
-{
- Q_OBJECT
-
-public:
-
- enum icon
- {
- KGet = 0x00000001,
- RSS = 0x00000010,
- SSL = 0x00000100,
- BK = 0x00001000,
- SearchEngine = 0x00010000,
- Favorite = 0x00100000,
- AdBlock = 0x01000000
- };
-
- explicit UrlBar(QWidget *parent = 0);
- ~UrlBar();
-
- void activateSuggestions(bool);
-
-public Q_SLOTS:
- void setQUrl(const QUrl &url);
-
- /**
- * Let us add bookmarks as the major browsers do
- *
- */
- void manageBookmarks();
-
-private Q_SLOTS:
- void loadRequestedUrl(const KUrl& url, Rekonq::OpenType = Rekonq::CurrentTab);
-
- void loadFinished();
-
- void clearRightIcons();
- void updateRightIcons();
-
- void detectTypedString(const QString &);
- void suggest();
-
- void manageFavorites(QPoint);
-
- void refreshFavicon();
-
- void pasteAndGo();
- void pasteAndSearch();
- void delSlot();
- bool isValidURL(QString url);
-
- /**
- * Load digited url
- */
- void loadDigitedUrl();
-
-protected:
- void paintEvent(QPaintEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void focusInEvent(QFocusEvent *event);
- void dropEvent(QDropEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *);
- void contextMenuEvent(QContextMenuEvent *event);
- void resizeEvent(QResizeEvent *);
-
-private:
- /**
- * Updates right icon position, given its number in the right icons list
- * and considering rekonq window position/dimension
- */
- void updateRightIconPosition(IconButton *, int);
- IconButton *addRightIcon(UrlBar::icon);
-
- QWeakPointer<CompletionWidget> _box;
- WebTab *_tab;
-
- IconButton *_icon;
- IconButtonPointerList _rightIconsList;
-
- QTimer *_suggestionTimer;
-};
-
-
-#endif
diff --git a/src/urlbar/urlresolver.cpp b/src/urlbar/urlresolver.cpp
deleted file mode 100644
index c6d0f7a4..00000000
--- a/src/urlbar/urlresolver.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "urlresolver.h"
-#include "urlresolver.moc"
-
-// Local Includes
-#include "historymanager.h"
-#include "bookmarkmanager.h"
-#include "searchengine.h"
-
-// KDE Includes
-#include <KBookmark>
-#include <KService>
-#include <KProtocolInfo>
-
-// Qt Includes
-#include <QByteArray>
-
-
-// NOTE
-// default kurifilter plugin list (at least in my box):
-// 1. "kshorturifilter"
-// 2. "kurisearchfilter"
-// 3. "localdomainurifilter"
-// 4 ."kuriikwsfilter"
-// 5. "fixhosturifilter"
-
-
-// ------------------------------------------------------------------------
-
-KService::Ptr UrlResolver::_searchEngine;
-
-QRegExp UrlResolver::_browseRegexp;
-QRegExp UrlResolver::_searchEnginesRegexp;
-
-
-UrlResolver::UrlResolver(const QString &typedUrl)
- : QObject()
- , _typedString(typedUrl.trimmed())
- , _typedQuery()
- , _isKDEUrl(false)
-{
- if (!_searchEngine)
- setSearchEngine(SearchEngine::defaultEngine());
-
- if (_browseRegexp.isEmpty())
- {
- QString protocol = QString("^(%1)").arg(KProtocolInfo::protocols().join("|"));
-
- QString localhost = QL1S("^localhost");
-
- QString local = QL1S("^/");
-
- QString ipv4 = QL1S("^0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])"\
- "\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.0*([1-9]?\\d|1\\d\\d|2[0-4]\\d|25[0-5])");
-
- QString ipv6 = QL1S("^([0-9a-fA-F]{4}|0)(\\:([0-9a-fA-F]{4}|0)){7}");
-
- QString address = QL1S("[\\d\\w-.]+\\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|"\
- "c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrstu]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|"\
- "h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|"\
- "m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|"\
- "s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|"\
- "y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|local|mil|museum|name|net|org|"\
- "pro)");
-
- QString joiner = QL1S(")|(");
- _browseRegexp = QRegExp(QL1C('(') +
- protocol + joiner +
- localhost + joiner +
- local + joiner +
- address + joiner +
- ipv6 + joiner +
- ipv4 + QL1C(')')
- );
- }
-
- if (_searchEnginesRegexp.isEmpty())
- {
- QString reg;
- QString engineUrl;
- Q_FOREACH(KService::Ptr s, SearchEngine::favorites())
- {
- engineUrl = QRegExp::escape(s->property("Query").toString()).replace(QL1S("\\\\\\{@\\}"), QL1S("[\\d\\w-.]+"));
- if (reg.isEmpty())
- reg = QL1C('(') + engineUrl + QL1C(')');
- else
- reg = reg + QL1S("|(") + engineUrl + QL1C(')');
- }
- _searchEnginesRegexp = QRegExp(reg);
- }
-}
-
-
-UrlSearchList UrlResolver::orderedSearchItems()
-{
- if (_typedString.startsWith(QL1S("about:")))
- {
- QStringList aboutUrlList;
- aboutUrlList
- << QL1S("about:home")
- << QL1S("about:favorites")
- << QL1S("about:closedTabs")
- << QL1S("about:bookmarks")
- << QL1S("about:history")
- << QL1S("about:downloads")
- << QL1S("about:tabs")
- << QL1S("about:info");
-
- QStringList aboutUrlResults = aboutUrlList.filter(_typedString, Qt::CaseInsensitive);
-
- UrlSearchList list;
-
- if (aboutUrlResults.isEmpty())
- {
- UrlSearchItem info(UrlSearchItem::Browse, QL1S("about:info"), QL1S("info"));
- list << info;
-
- return list;
- }
-
- Q_FOREACH(const QString & urlResult, aboutUrlResults)
- {
- QString name = urlResult;
- name.remove(0, 6);
- UrlSearchItem item(UrlSearchItem::Browse, urlResult, name);
- list << item;
- }
-
- return list;
- }
-
- //compute lists
- computeHistory();
- computeQurlFromUserInput();
- computeWebSearches();
- computeBookmarks();
-
- return orderLists();
-}
-
-
-UrlSearchList UrlResolver::orderLists()
-{
- // NOTE
- // The const int here decides the number of proper suggestions, taken from history & bookmarks
- // You have to add here the "browse & search" options, always available.
- const int availableEntries = 8;
-
- bool webSearchFirst = false;
- // Browse & Search results
- UrlSearchList browseSearch;
- QString lowerTypedString = _typedString.toLower();
- if (!_isKDEUrl
- && (_browseRegexp.indexIn(lowerTypedString) != -1))
- {
- webSearchFirst = true;
- browseSearch << _webSearches;
- }
- else
- {
- browseSearch << _webSearches;
- browseSearch << _qurlFromUserInput;
- }
-
-
- // find relevant items (the one you are more probably searching...)
- UrlSearchList relevant;
-
- // history
- Q_FOREACH(const UrlSearchItem & item, _history)
- {
- QString hst = KUrl(item.url).host();
- if (item.url.startsWith(_typedString)
- || hst.startsWith(_typedString)
- || hst.remove("www.").startsWith(_typedString))
- {
- relevant << item;
- _history.removeOne(item);
- break;
- }
- }
-
- // bookmarks
- Q_FOREACH(const UrlSearchItem & item, _bookmarks)
- {
- QString hst = KUrl(item.url).host();
- if (item.url.startsWith(_typedString)
- || hst.startsWith(_typedString)
- || hst.remove("www.").startsWith(_typedString))
- {
- relevant << item;
- _bookmarks.removeOne(item);
- break;
- }
- }
-
- // decide history & bookmarks number
- int historyCount = _history.count();
- int bookmarksCount = _bookmarks.count();
- int relevantCount = relevant.count();
-
- const int historyEntries = (availableEntries - relevantCount) / 2;
- const int bookmarksEntries = availableEntries - relevantCount - historyEntries;
-
- if (historyCount >= historyEntries && bookmarksCount >= bookmarksEntries)
- {
- _history = _history.mid(0, historyEntries);
- _bookmarks = _bookmarks.mid(0, bookmarksEntries);
- }
- else if (historyCount < historyEntries && bookmarksCount >= bookmarksEntries)
- {
- if (historyCount + bookmarksCount > availableEntries)
- {
- _bookmarks = _bookmarks.mid(0, availableEntries - historyCount);
- }
- }
- else if (historyCount >= historyEntries && bookmarksCount < bookmarksEntries)
- {
- if (historyCount + bookmarksCount > availableEntries)
- {
- _history = _history.mid(0, availableEntries - bookmarksCount);
- }
- }
-
- // and finally, results
- UrlSearchList list;
-
- if (webSearchFirst)
- list << _qurlFromUserInput;
- list += relevant + browseSearch + _history + _bookmarks;
- return list;
-}
-
-
-//////////////////////////////////////////////////////////////////////////
-// PRIVATE ENGINES
-
-
-// QUrl from User Input (easily the best solution... )
-void UrlResolver::computeQurlFromUserInput()
-{
- QString url = _typedString;
- QUrl urlFromUserInput = QUrl::fromUserInput(url);
- if (urlFromUserInput.isValid())
- {
- // ensure http(s) hosts are lower cases
- if (urlFromUserInput.scheme().startsWith(QL1S("http")))
- {
- QString hst = urlFromUserInput.host();
- urlFromUserInput.setHost(hst.toLower());
- }
-
- QString urlString = urlFromUserInput.toString();
- QString gTitle = i18nc("Browse a website", "Browse");
- UrlSearchItem gItem(UrlSearchItem::Browse, urlString, gTitle);
- _qurlFromUserInput << gItem;
- }
-}
-
-
-// webSearches
-void UrlResolver::computeWebSearches()
-{
- QString query = _typedString;
- KService::Ptr engine = SearchEngine::fromString(_typedString);
- if (engine)
- {
- query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1);
- setSearchEngine(engine);
- _isKDEUrl = true;
- }
-
- if (_searchEngine)
- {
- UrlSearchItem item = UrlSearchItem(UrlSearchItem::Search, SearchEngine::buildQuery(_searchEngine, query), query);
- UrlSearchList list;
- list << item;
- _webSearches = list;
- }
-}
-
-
-// history
-void UrlResolver::computeHistory()
-{
- QList<HistoryItem> found = rApp->historyManager()->find(_typedString);
- qSort(found.begin(), found.end(), isHistoryItemRelevant);
-
- Q_FOREACH(const HistoryItem & i, found)
- {
- if (_searchEnginesRegexp.isEmpty() || _searchEnginesRegexp.indexIn(i.url) == -1) //filter all urls that are search engine results
- {
- UrlSearchItem gItem(UrlSearchItem::History, i.url, i.title);
- _history << gItem;
- }
- }
-}
-
-
-// bookmarks
-void UrlResolver::computeBookmarks()
-{
- QList<KBookmark> found = rApp->bookmarkManager()->find(_typedString);
- Q_FOREACH(const KBookmark & b, found)
- {
- UrlSearchItem gItem(UrlSearchItem::Bookmark, b.url().url(), b.fullText());
- _bookmarks << gItem;
- }
-}
-
-
-// opensearch suggestion
-void UrlResolver::computeSuggestions()
-{
- // NOTE
- // This attempt basically cuts out open search suggestions.
- UrlSearchList list;
- emit suggestionsReady(list, _typedString);
- return;
-
-// // if a string startsWith /, it is probably a local path
-// // so, no need for suggestions...
-// if (_typedString.startsWith('/') || !rApp->opensearchManager()->isSuggestionAvailable())
-// {
-// UrlSearchList list;
-// emit suggestionsReady(list, _typedString);
-// return;
-// }
-//
-// QString query = _typedString;
-// KService::Ptr engine = SearchEngine::fromString(_typedString);
-// if (engine)
-// {
-// query = query.remove(0, _typedString.indexOf(SearchEngine::delimiter()) + 1);
-// setSearchEngine(engine);
-// }
-//
-// connect(rApp->opensearchManager(),
-// SIGNAL(suggestionsReceived(QString,ResponseList)),
-// this,
-// SLOT(suggestionsReceived(QString,ResponseList)));
-//
-// _typedQuery = query;
-// rApp->opensearchManager()->requestSuggestion(query);
-}
-
-
-bool UrlResolver::isHistoryItemRelevant(const HistoryItem &a, const HistoryItem &b)
-{
- return a.relevance() > b.relevance();
-}
-
-
-void UrlResolver::suggestionsReceived(const QString &text, const ResponseList &suggestions)
-{
- if (text != _typedQuery)
- return;
-
- UrlSearchList sugList;
- QString urlString;
- Q_FOREACH(const Response & i, suggestions)
- {
- if (text == i.title)
- continue;
-
- urlString = i.url;
- if (urlString.isEmpty())
- {
- urlString = SearchEngine::buildQuery(UrlResolver::searchEngine(), i.title);
- }
-
- UrlSearchItem gItem(UrlSearchItem::Suggestion, urlString, i.title, i.description, i.image, i.image_width, i.image_height);
- sugList << gItem;
- }
- emit suggestionsReady(sugList, _typedString);
- this->deleteLater();
-}
diff --git a/src/urlbar/urlresolver.h b/src/urlbar/urlresolver.h
deleted file mode 100644
index d799231f..00000000
--- a/src/urlbar/urlresolver.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009-2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef URL_RESOLVER_H
-#define URL_RESOLVER_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// Locale Includes
-#include "application.h"
-#include "opensearchmanager.h"
-#include "suggestionparser.h"
-
-// KDE Includes
-#include <KUrl>
-#include <KService>
-
-// Qt Includes
-#include <QString>
-#include <QList>
-
-
-class UrlSearchItem
-{
-public:
-
- enum types
- {
- Undefined = 0x00000000,
- Search = 0x00000001,
- Browse = 0x00000010,
- History = 0x00000100,
- Bookmark = 0x00001000,
- Suggestion = 0x00010000
- };
-
- int type;
- QString url;
- QString title;
- QString description;
- QString image;
- int image_width;
- int image_height;
- QString bookmarkPath;
-
- UrlSearchItem(const UrlSearchItem &item)
- : type(item.type)
- , url(item.url)
- , title(item.title)
- , description(item.description)
- , image(item.image)
- , image_width(item.image_width)
- , image_height(item.image_height)
- {};
-
- UrlSearchItem()
- : type(UrlSearchItem::Undefined)
- , url(QString())
- , title(QString())
- , description(QString())
- , image(QString())
- , image_width(0)
- , image_height(0)
- {};
-
- UrlSearchItem(const int &_type,
- const QString &_url,
- const QString &_title = QString(),
- const QString &_description = QString(),
- const QString &_image = QString(),
- const int &_image_width = 0,
- const int &_image_height = 0
- )
- : type(_type)
- , url(_url)
- , title(_title)
- , description(_description)
- , image(_image)
- , image_width(_image_width)
- , image_height(_image_height)
- {};
-
- inline bool operator==(const UrlSearchItem &i) const
- {
- return i.url == url;//TODO && i.title == title;
- }
-};
-
-typedef QList <UrlSearchItem> UrlSearchList;
-
-
-// ----------------------------------------------------------------------
-
-class HistoryItem;
-
-class UrlResolver : public QObject
-{
- Q_OBJECT
-
-public:
- UrlResolver(const QString &typedUrl);
-
- UrlSearchList orderedSearchItems();
-
- static KService::Ptr searchEngine()
- {
- return _searchEngine;
- };
-
- static void setSearchEngine(KService::Ptr engine)
- {
- _searchEngine = engine;
- if (engine)
- rApp->opensearchManager()->setSearchProvider(engine->desktopEntryName());
- };
-
- void computeSuggestions();
-
- static bool isHistoryItemRelevant(const HistoryItem &a, const HistoryItem &b);
-
-private Q_SLOTS:
- void suggestionsReceived(const QString &text, const ResponseList &suggestions);
-
-Q_SIGNALS:
- void suggestionsReady(const UrlSearchList &, const QString &);
-
-private:
- void computeWebSearches();
- void computeHistory();
- void computeQurlFromUserInput();
- void computeBookmarks();
-
- UrlSearchList orderLists();
-
- QString _typedString;
- QString _typedQuery;
-
- UrlSearchList _webSearches;
- UrlSearchList _qurlFromUserInput;
- UrlSearchList _history;
- UrlSearchList _bookmarks;
- UrlSearchList _suggestions;
-
- static QRegExp _browseRegexp;
- static QRegExp _searchEnginesRegexp;
-
- static KService::Ptr _searchEngine;
-
- bool _isKDEUrl;
-};
-
-// ------------------------------------------------------------------------------
-
-#endif // URL_RESOLVER_H
diff --git a/src/urlbar/webshortcutwidget.cpp b/src/urlbar/webshortcutwidget.cpp
deleted file mode 100644
index c6dc3b79..00000000
--- a/src/urlbar/webshortcutwidget.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com>
-* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "webshortcutwidget.h"
-#include "webshortcutwidget.moc"
-
-// KDE Includes
-#include <KGlobalSettings>
-#include <KIcon>
-#include <KLocale>
-#include <KServiceTypeTrader>
-
-// Qt Includes
-#include <QSet>
-#include <QLabel>
-#include <QLineEdit>
-#include <QDialogButtonBox>
-#include <QFormLayout>
-
-
-WebShortcutWidget::WebShortcutWidget(QWidget *parent)
- : QMenu(parent)
- , m_wsLineEdit(new QLineEdit(this))
- , m_nameLineEdit(new QLineEdit(this))
- , m_noteLabel(new QLabel(this))
-{
- setAttribute(Qt::WA_DeleteOnClose);
- setFixedWidth(350);
-
- QFormLayout *layout = new QFormLayout(this);
- QVBoxLayout *vLay = new QVBoxLayout;
-
- // Web Search Icon
- QLabel *webSearchIcon = new QLabel(this);
- webSearchIcon->setPixmap(KIcon("edit-web-search").pixmap(32, 32));
-
- // Title
- QLabel *titleLabel = new QLabel(this);
- titleLabel->setText("<h4>" + i18n("Add Search Engine") + "</h4>");
- vLay->addWidget(titleLabel);
-
- // Name
- vLay->addWidget(m_nameLineEdit);
-
- layout->addRow(webSearchIcon, vLay);
-
- // Shortcuts
- QLabel *shortcutsLabel = new QLabel(i18n("Shortcuts:"), this);
- layout->addRow(shortcutsLabel, m_wsLineEdit);
- connect(m_wsLineEdit, SIGNAL(textChanged(QString)), SLOT(shortcutsChanged(QString)));
-
- // Note
- m_noteLabel->setWordWrap(true);
- layout->addRow(m_noteLabel);
- m_noteLabel->hide();
-
- // Ok & Cancel buttons
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
- connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
- layout->addWidget(buttonBox);
-
- m_providers = KServiceTypeTrader::self()->query("SearchProvider");
-
- m_wsLineEdit->setFocus();
-}
-
-
-void WebShortcutWidget::showAt(const QPoint &pos)
-{
- adjustSize();
-
- QPoint p(pos.x() - width(), pos.y() + 10);
- move(p);
- exec();
-}
-
-
-void WebShortcutWidget::show(const KUrl &url, const QString &openSearchName, const QPoint &pos)
-{
- m_wsLineEdit->clear();
- m_nameLineEdit->setText(openSearchName);
- m_url = url;
- showAt(pos);
-}
-
-
-void WebShortcutWidget::accept()
-{
- emit webShortcutSet(m_url, m_nameLineEdit->text(), m_wsLineEdit->text());
-
- // close widget (and destroy it)
- close();
-}
-
-
-void WebShortcutWidget::shortcutsChanged(const QString& newShorthands)
-{
- int savedCursorPosition = m_wsLineEdit->cursorPosition();
- QString normalizedShorthands = QString(newShorthands).replace(QL1C(' '), QL1C(','));
- m_wsLineEdit->setText(normalizedShorthands);
- m_wsLineEdit->setCursorPosition(savedCursorPosition);
-
- QSet<QString> shorthands = normalizedShorthands.split(QL1C(',')).toSet();
- QString contenderName = "";
- QString contenderWS = "";
-
- Q_FOREACH(const QString & shorthand, shorthands)
- {
- Q_FOREACH(KService::Ptr provider, m_providers)
- {
- if (provider->property("Keys").toStringList().contains(shorthand))
- {
- contenderName = provider->property("Name").toString();
- contenderWS = shorthand;
- break;
- }
- }
- }
-
- if (!contenderName.isEmpty())
- {
- m_noteLabel->setText(i18n("The shortcut \"%1\" is already assigned to \"%2\".", contenderWS, contenderName));
- m_noteLabel->setVisible(true);
- resize(minimumSize().width(), minimumSizeHint().height() + 15);
- }
- else
- {
- m_noteLabel->clear();
- bool noteIsVisible = m_noteLabel->isVisible();
- m_noteLabel->setVisible(false);
- if (noteIsVisible)
- {
- resize(minimumSize());
- }
- }
-}
diff --git a/src/urlbar/webshortcutwidget.h b/src/urlbar/webshortcutwidget.h
deleted file mode 100644
index d1291714..00000000
--- a/src/urlbar/webshortcutwidget.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Fredy Yanardi <fyanardi@gmail.com>
-* Copyright (C) 2010-2011 by Lionel Chauvin <megabigbug@yahoo.fr>
-* Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef WEBSHORTCUTWIDGET_H
-#define WEBSHORTCUTWIDGET_H
-
-
-// Rekonq Includes
-#include "rekonq_defines.h"
-
-// KDE Includes
-#include <KUrl>
-#include <KService>
-
-// Qt Includes
-#include <QMenu>
-
-// Forward Declarations
-class QLabel;
-class QLineEdit;
-class QPushButton;
-
-
-class REKONQ_TESTS_EXPORT WebShortcutWidget : public QMenu
-{
- Q_OBJECT
-public:
- WebShortcutWidget(QWidget *parent = 0);
-
- void show(const KUrl &url, const QString &openSearchName, const QPoint &pos);
-
-private Q_SLOTS:
- void accept();
- void shortcutsChanged(const QString& newShorthands);
-
-Q_SIGNALS:
- void webShortcutSet(const KUrl &url, const QString &openSearchName, const QString &webShortcut);
-
-private:
- QLineEdit *m_wsLineEdit;
- QLineEdit *m_nameLineEdit;
- QLabel *m_noteLabel;
-
- KService::List m_providers;
- KUrl m_url;
-
- void showAt(const QPoint &pos);
-};
-
-#endif // WEBSHORTCUTWIDGET_H
-