summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/urlbar/bookmarkwidget.cpp72
-rw-r--r--src/urlbar/bookmarkwidget.h14
2 files changed, 35 insertions, 51 deletions
diff --git a/src/urlbar/bookmarkwidget.cpp b/src/urlbar/bookmarkwidget.cpp
index cb711723..6b507490 100644
--- a/src/urlbar/bookmarkwidget.cpp
+++ b/src/urlbar/bookmarkwidget.cpp
@@ -35,99 +35,96 @@
// KDE Includes
#include <KLocalizedString>
+#include <KIcon>
#include <KLineEdit>
-#include <KMessageBox>
// Qt Includes
-#include <QtGui/QFormLayout>
#include <QtGui/QDialogButtonBox>
+#include <QtGui/QFormLayout>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
-
BookmarkWidget::BookmarkWidget(const KBookmark &bookmark, QWidget *parent)
: QFrame(parent, Qt::Popup)
- , m_bookmark(bookmark)
+ , m_bookmark(new KBookmark(bookmark))
{
setAttribute(Qt::WA_DeleteOnClose);
setFixedWidth(350);
setFrameStyle(QFrame::Panel);
QFormLayout *layout = new QFormLayout(this);
- setLayout(layout);
-
- QHBoxLayout *hLayout = new QHBoxLayout();
+ // Bookmark icon
+ QHBoxLayout *hLayout = new QHBoxLayout(this);
QLabel *bookmarkIcon = new QLabel(this);
bookmarkIcon->setPixmap(KIcon("bookmarks").pixmap(32, 32));
- hLayout->addWidget(bookmarkIcon);
hLayout->setSpacing(10);
+ hLayout->addWidget(bookmarkIcon);
- QVBoxLayout *vLayout = new QVBoxLayout();
-
+ // Title
+ QVBoxLayout *vLayout = new QVBoxLayout(this);
QLabel *bookmarkInfo = new QLabel(this);
bookmarkInfo->setText(i18n("Edit this Bookmark"));
QFont font;
font.setPointSize(font.pointSize() + 2);
bookmarkInfo->setFont(font);
-
+ bookmarkInfo->setAlignment(Qt::AlignCenter);
vLayout->addWidget(bookmarkInfo);
+ // Remove button
QPushButton *removeButton = new QPushButton(this);
removeButton->setText(i18n("Remove this Bookmark"));
connect(removeButton, SIGNAL(clicked()), this, SLOT(removeBookmark()));
-
vLayout->addWidget(removeButton);
+
hLayout->addLayout(vLayout);
layout->addItem(hLayout);
-
+ // Bookmark name
QLabel *nameLabel = new QLabel(this);
nameLabel->setText(i18n("Name:"));
-
m_name = new KLineEdit(this);
- if (m_bookmark.isNull())
+ if (m_bookmark->isNull())
{
m_name->setEnabled(false);
}
else
{
- m_name->setText(m_bookmark.text());
+ m_name->setText(m_bookmark->text());
m_name->setFocus();
}
-
layout->addRow(nameLabel, m_name);
- QLabel *urlLabel = new QLabel(this);
- urlLabel->setText("URL:");
-
- KLineEdit *url = new KLineEdit(this);
- url->setText(m_bookmark.url().url());
- url->setEnabled(false);
-
- layout->addRow(urlLabel, url);
-
+ // Ok & Cancel buttons
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- buttonBox->button(QDialogButtonBox::Ok)->setText(i18n("Done"));
connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
layout->addWidget(buttonBox);
+
+ setLayout(layout);
}
BookmarkWidget::~BookmarkWidget()
{
- delete m_name;
+ delete m_bookmark;
+}
+
+
+void BookmarkWidget::showAt(const QPoint &pos)
+{
+ QPoint p(pos.x()-350, pos.y()+12);
+ move(p);
+ show();
}
void BookmarkWidget::accept()
{
- if (!m_bookmark.isNull() && m_name->text() != m_bookmark.fullText())
+ if (!m_bookmark->isNull() && m_name->text() != m_bookmark->fullText())
{
- m_bookmark.setFullText(m_name->text());
+ m_bookmark->setFullText(m_name->text());
Application::bookmarkProvider()->bookmarkManager()->emitChanged();
}
reject();
@@ -137,22 +134,11 @@ void BookmarkWidget::accept()
void BookmarkWidget::reject()
{
close();
- deleteLater();
-}
-
-
-void BookmarkWidget::showAt(const QPoint &pos)
-{
- QPoint p;
- p.setX(pos.x() - 350);
- p.setY(pos.y() + 12);
- move(p);
- show();
}
void BookmarkWidget::removeBookmark()
{
- Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(m_bookmark);
+ Application::bookmarkProvider()->bookmarkOwner()->deleteBookmark(*m_bookmark);
reject();
}
diff --git a/src/urlbar/bookmarkwidget.h b/src/urlbar/bookmarkwidget.h
index c3c15e18..b95e55db 100644
--- a/src/urlbar/bookmarkwidget.h
+++ b/src/urlbar/bookmarkwidget.h
@@ -30,14 +30,13 @@
// Rekonq Includes
#include "rekonq_defines.h"
-// KDE Includes
-#include <KUrl>
-#include <KBookmark>
-#include <KLineEdit>
-
// Qt Includes
#include <QtGui/QFrame>
+// Forward Declarations
+class KBookmark;
+class KLineEdit;
+
class BookmarkWidget : public QFrame
{
@@ -45,7 +44,7 @@ class BookmarkWidget : public QFrame
public:
explicit BookmarkWidget(const KBookmark &bookmark, QWidget *parent = 0);
- ~BookmarkWidget();
+ virtual ~BookmarkWidget();
void showAt(const QPoint &pos);
@@ -55,9 +54,8 @@ private slots:
void removeBookmark();
private:
- KBookmark m_bookmark;
+ KBookmark *m_bookmark;
KLineEdit *m_name;
-
};
#endif // BOOKMARKWIDGET_H