diff options
Diffstat (limited to 'lib/bookmarks/forms')
-rw-r--r-- | lib/bookmarks/forms/editbookmarkdialog.cpp | 45 | ||||
-rw-r--r-- | lib/bookmarks/forms/editbookmarkdialog.h | 32 | ||||
-rw-r--r-- | lib/bookmarks/forms/editbookmarkdialog.ui | 108 |
3 files changed, 185 insertions, 0 deletions
diff --git a/lib/bookmarks/forms/editbookmarkdialog.cpp b/lib/bookmarks/forms/editbookmarkdialog.cpp new file mode 100644 index 0000000..47aa0b7 --- /dev/null +++ b/lib/bookmarks/forms/editbookmarkdialog.cpp @@ -0,0 +1,45 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#include "editbookmarkdialog.h" +#include "../bookmarkitem.h" +#include "../bookmarkmodel.h" +#include "ui_editbookmarkdialog.h" + +EditBookmarkDialog::EditBookmarkDialog(BookmarkModel *model, const QModelIndex &index, QWidget *parent) + : QDialog(parent) + , ui(new Ui::EditBookmarkDialog) +{ + ui->setupUi(this); + setAttribute(Qt::WA_DeleteOnClose, true); + + ui->title->setText(model->data(index, BookmarkItem::Title, Qt::DisplayRole).toString()); + connect(ui->title, &QLineEdit::editingFinished, this, [this, model, index]() { + model->setData(index, ui->title->text(), BookmarkItem::Title, Qt::DisplayRole); + }); + + ui->address->setText(model->data(index, BookmarkItem::Href, Qt::DisplayRole).toString()); + connect(ui->address, &QLineEdit::editingFinished, this, [this, model, index]() { + model->setData(index, ui->address->text(), BookmarkItem::Href, Qt::DisplayRole); + }); + + ui->tags->setText(model->data(index, BookmarkItem::Tags, Qt::DisplayRole).toStringList().join(", ")); + connect(ui->tags, &QLineEdit::editingFinished, this, [this, model, index]() { + model->setData(index, ui->tags->text().split(", "), BookmarkItem::Tags, Qt::DisplayRole); + }); + + ui->description->setPlainText(model->data(index, BookmarkItem::Description, Qt::DisplayRole).toString()); + connect(ui->description, &QPlainTextEdit::textChanged, this, [this, model, index]() { + model->setData(index, ui->description->toPlainText(), BookmarkItem::Description, Qt::DisplayRole); + }); +} + +EditBookmarkDialog::~EditBookmarkDialog() +{ + delete ui; +} diff --git a/lib/bookmarks/forms/editbookmarkdialog.h b/lib/bookmarks/forms/editbookmarkdialog.h new file mode 100644 index 0000000..968b6af --- /dev/null +++ b/lib/bookmarks/forms/editbookmarkdialog.h @@ -0,0 +1,32 @@ +/* + * This file is part of smolbote. It's copyrighted by the contributors recorded + * in the version control history of the file, available from its original + * location: https://neueland.iserlohn-fortress.net/smolbote.hg + * + * SPDX-License-Identifier: GPL-3.0 + */ + +#ifndef SMOLBOTE_EDITBOOKMARKDIALOG_H +#define SMOLBOTE_EDITBOOKMARKDIALOG_H + +#include <QDialog> + +namespace Ui +{ +class EditBookmarkDialog; +} + +class BookmarkModel; +class EditBookmarkDialog : public QDialog +{ + Q_OBJECT + +public: + explicit EditBookmarkDialog(BookmarkModel *model, const QModelIndex &index, QWidget *parent = nullptr); + ~EditBookmarkDialog() override; + +private: + Ui::EditBookmarkDialog *ui; +}; + +#endif // SMOLBOTE_EDITBOOKMARKDIALOG_H diff --git a/lib/bookmarks/forms/editbookmarkdialog.ui b/lib/bookmarks/forms/editbookmarkdialog.ui new file mode 100644 index 0000000..1861fcc --- /dev/null +++ b/lib/bookmarks/forms/editbookmarkdialog.ui @@ -0,0 +1,108 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>EditBookmarkDialog</class> + <widget class="QDialog" name="EditBookmarkDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>262</width> + <height>320</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="title_label"> + <property name="text"> + <string>Title</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="title"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="address_label"> + <property name="text"> + <string>Address</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="address"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="tags_label"> + <property name="text"> + <string>Tags</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="tags"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="description_label"> + <property name="text"> + <string>Description</string> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QPlainTextEdit" name="description"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Close|QDialogButtonBox::Save</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>EditBookmarkDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>EditBookmarkDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> |