aboutsummaryrefslogtreecommitdiff
path: root/src/forms
diff options
context:
space:
mode:
Diffstat (limited to 'src/forms')
-rw-r--r--src/forms/bookmarksdialog.cpp53
-rw-r--r--src/forms/bookmarksdialog.h14
-rw-r--r--src/forms/bookmarksdialog.ui111
3 files changed, 161 insertions, 17 deletions
diff --git a/src/forms/bookmarksdialog.cpp b/src/forms/bookmarksdialog.cpp
index bf5a9fc..d61cf18 100644
--- a/src/forms/bookmarksdialog.cpp
+++ b/src/forms/bookmarksdialog.cpp
@@ -20,17 +20,42 @@
#include "bookmarksdialog.h"
#include "ui_bookmarksdialog.h"
-
+#include <QTreeWidget>
#include "xbel/xbel.h"
+#include "mainwindow.h"
-BookmarksDialog::BookmarksDialog(QWidget *parent) :
+BookmarksDialog::BookmarksDialog(MainWindow *parent) :
QDialog(parent),
ui(new Ui::BookmarksDialog)
{
+ parentWindow = parent;
ui->setupUi(this);
+ ui->treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
+
+ QStyle *style = ui->treeWidget->style();
+ ui->addFolder_toolButton->setIcon(style->standardPixmap(QStyle::SP_DirIcon));
+ ui->addBookmark_toolButton->setIcon(style->standardPixmap(QStyle::SP_FileIcon));
+ ui->addSeparator_toolButton->setText("---");
+ ui->deleteItem_toolButton->setIcon(style->standardPixmap(QStyle::SP_TrashIcon));
+
+ connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(showItemDetails()));
+ connect(ui->treeWidget, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(openItem(QTreeWidgetItem*,int)));
+
+ ui->deleteItem_toolButton->setShortcut(QKeySequence::Delete);
+ connect(ui->deleteItem_toolButton, SIGNAL(clicked(bool)), this, SLOT(deleteCurrentItem()));
xbel = new Xbel(ui->treeWidget);
xbel->read("bookmarks.xbel");
+
+ connect(ui->addFolder_toolButton, &QToolButton::clicked, [this]() {
+ xbel->addFolder(ui->treeWidget->currentItem());
+ });
+ connect(ui->addBookmark_toolButton, &QToolButton::clicked, [this]() {
+ xbel->addBookmark(ui->treeWidget->currentItem());
+ });
+ connect(ui->addSeparator_toolButton, &QToolButton::clicked, [this]() {
+ xbel->addSeparator(ui->treeWidget->currentItem());
+ });
}
BookmarksDialog::~BookmarksDialog()
@@ -40,3 +65,27 @@ BookmarksDialog::~BookmarksDialog()
delete xbel;
delete ui;
}
+
+void BookmarksDialog::deleteCurrentItem()
+{
+ delete ui->treeWidget->currentItem();
+}
+
+void BookmarksDialog::openItem(QTreeWidgetItem *item, int column)
+{
+ Q_UNUSED(column)
+
+ parentWindow->createNewTab(QUrl::fromUserInput(item->text(1)));
+}
+
+void BookmarksDialog::showItemDetails()
+{
+ QTreeWidgetItem *item = ui->treeWidget->currentItem();
+ if(!item) {
+ ui->title_lineEdit->setText("");
+ ui->href_label->setText("");
+ return;
+ }
+ ui->title_lineEdit->setText(item->text(0));
+ ui->href_lineEdit->setText(item->text(1));
+}
diff --git a/src/forms/bookmarksdialog.h b/src/forms/bookmarksdialog.h
index b01fc8b..e2387d7 100644
--- a/src/forms/bookmarksdialog.h
+++ b/src/forms/bookmarksdialog.h
@@ -28,15 +28,27 @@ namespace Ui {
class BookmarksDialog;
}
+class MainWindow;
class BookmarksDialog : public QDialog
{
Q_OBJECT
public:
- explicit BookmarksDialog(QWidget *parent = 0);
+ explicit BookmarksDialog(MainWindow *parent = 0);
~BookmarksDialog();
+public slots:
+ // void addFolder(const QString &title);
+ // void addBookmark(const QString &title, const QString &href);
+ // void addSeparator();
+ void deleteCurrentItem();
+
+private slots:
+ void openItem(QTreeWidgetItem *item, int column);
+ void showItemDetails();
+
private:
+ MainWindow *parentWindow;
Ui::BookmarksDialog *ui;
Xbel *xbel;
};
diff --git a/src/forms/bookmarksdialog.ui b/src/forms/bookmarksdialog.ui
index f578737..a0e4316 100644
--- a/src/forms/bookmarksdialog.ui
+++ b/src/forms/bookmarksdialog.ui
@@ -6,27 +6,110 @@
<rect>
<x>0</x>
<y>0</y>
- <width>640</width>
+ <width>820</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Bookmarks</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QTreeWidget" name="treeWidget">
- <column>
- <property name="text">
- <string notr="true">1</string>
- </property>
- </column>
- <column>
- <property name="text">
- <string>2</string>
- </property>
- </column>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QTreeWidget" name="treeWidget">
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::InternalMove</enum>
+ </property>
+ <property name="defaultDropAction">
+ <enum>Qt::MoveAction</enum>
+ </property>
+ <column>
+ <property name="text">
+ <string notr="true">Title</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>href</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QToolButton" name="addFolder_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="addBookmark_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="addSeparator_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteItem_toolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="minimumSize">
+ <size>
+ <width>250</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>250</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Details</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="1" column="0">
+ <widget class="QLabel" name="href_label">
+ <property name="text">
+ <string>href</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="href_lineEdit"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="title_lineEdit"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">