diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 9416262d..9512a7f3 100644 --- a/src/core/Entry.cpp +++ b/src/core/Entry.cpp @@ -264,6 +264,11 @@ void Entry::addHistoryItem(Entry* entry) m_history.append(entry); } +Group* Entry::group() +{ + return m_group; +} + void Entry::setGroup(Group* group) { if (m_group) { diff --git a/src/core/Entry.h b/src/core/Entry.h index b14a3fdf..40497e05 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -87,6 +87,7 @@ public: const QList& historyItems() const; void addHistoryItem(Entry* entry); + Group* group(); void setGroup(Group* group); diff --git a/src/gui/EditEntryWidget.cpp b/src/gui/EditEntryWidget.cpp index ff2a4e52..b3c2b8a9 100644 --- a/src/gui/EditEntryWidget.cpp +++ b/src/gui/EditEntryWidget.cpp @@ -24,6 +24,7 @@ #include #include "core/Entry.h" +#include "core/Group.h" EditEntryWidget::EditEntryWidget(QWidget* parent) : QWidget(parent) @@ -36,6 +37,11 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) { m_ui->setupUi(this); + QFont headerLabelFont = m_ui->headerLabel->font(); + headerLabelFont.setBold(true); + headerLabelFont.setPointSize(headerLabelFont.pointSize() + 2); + m_ui->headerLabel->setFont(headerLabelFont); + m_ui->categoryList->addItem(tr("Entry")); m_ui->categoryList->addItem(tr("Description")); @@ -60,6 +66,8 @@ void EditEntryWidget::loadEntry(Entry* entry) { m_entry = entry; + m_ui->headerLabel->setText(m_entry->group()->name()+" > "+tr("Edit entry")); + m_mainUi->titleEdit->setText(entry->title()); m_mainUi->usernameEdit->setText(entry->username()); m_mainUi->urlEdit->setText(entry->url()); diff --git a/src/gui/EditEntryWidget.ui b/src/gui/EditEntryWidget.ui index 047bfa49..0d485b7c 100644 --- a/src/gui/EditEntryWidget.ui +++ b/src/gui/EditEntryWidget.ui @@ -11,23 +11,39 @@ + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 1 + 3 + + + + - - - - 20 - 0 - - - + - - 80 + + 4 0 @@ -47,6 +63,13 @@ + + + CategoryListWidget + QListWidget +
gui/EditEntryWidget_p.h
+
+
diff --git a/src/gui/EditEntryWidget_p.h b/src/gui/EditEntryWidget_p.h new file mode 100644 index 00000000..3c3b3b2d --- /dev/null +++ b/src/gui/EditEntryWidget_p.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 Felix Geyer + * + * 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 or (at your option) + * 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 . + */ + +#ifndef KEEPASSX_EDITENTRYWIDGET_P_H +#define KEEPASSX_EDITENTRYWIDGET_P_H + +#include +#include +#include +#include + +class CategoryListViewDelegate : public QStyledItemDelegate +{ +public: + CategoryListViewDelegate(QObject *parent) : QStyledItemDelegate(parent) {} + + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const + { + QSize size = QStyledItemDelegate::sizeHint(option, index); + size.setHeight(qMax(size.height(), 22)); + return size; + } +}; + +class CategoryListWidget : public QListWidget +{ +public: + CategoryListWidget(QWidget* parent = 0) : QListWidget(parent) + { + setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding); + setItemDelegate(new CategoryListViewDelegate(this)); + } + + virtual QSize sizeHint() const + { + QSize sizeHint = QListWidget::sizeHint(); + + int width = sizeHintForColumn(0) + frameWidth() * 2 + 5; + if (verticalScrollBar()->isVisible()) { + width += verticalScrollBar()->width(); + } + sizeHint.setWidth(width); + + return sizeHint; + } +}; + +#endif // KEEPASSX_EDITENTRYWIDGET_P_H