diff options
author | Felix Geyer <debfx@fobos.de> | 2010-10-07 00:54:07 +0400 |
---|---|---|
committer | Felix Geyer <debfx@fobos.de> | 2010-10-07 00:54:07 +0400 |
commit | 8fc2b9328e29520a16a43650aa25cccb283c9940 (patch) | |
tree | 1f1670b3e5b5744da55a05e1afb114e7d1113c64 /src | |
parent | 0c91be8eacd49a570cb2304228a66a61f0d31bdd (diff) |
Improve EditEntryWidget.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/Entry.cpp | 5 | ||||
-rw-r--r-- | src/core/Entry.h | 1 | ||||
-rw-r--r-- | src/gui/EditEntryWidget.cpp | 8 | ||||
-rw-r--r-- | src/gui/EditEntryWidget.ui | 43 | ||||
-rw-r--r-- | src/gui/EditEntryWidget_p.h | 62 |
5 files changed, 109 insertions, 10 deletions
diff --git a/src/core/Entry.cpp b/src/core/Entry.cpp index 9416262da..9512a7f3d 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 b14a3fdf3..40497e058 100644 --- a/src/core/Entry.h +++ b/src/core/Entry.h @@ -87,6 +87,7 @@ public: const QList<Entry*>& 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 ff2a4e524..b3c2b8a97 100644 --- a/src/gui/EditEntryWidget.cpp +++ b/src/gui/EditEntryWidget.cpp @@ -24,6 +24,7 @@ #include <QtGui/QStackedLayout> #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 047bfa490..0d485b7c9 100644 --- a/src/gui/EditEntryWidget.ui +++ b/src/gui/EditEntryWidget.ui @@ -12,22 +12,38 @@ </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> + <widget class="QLabel" name="headerLabel"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>1</width> + <height>3</height> + </size> + </property> + </spacer> + </item> + <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QListWidget" name="categoryList"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>20</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> + <widget class="CategoryListWidget" name="categoryList"/> </item> <item> <widget class="QStackedWidget" name="stackedWidget"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>80</horstretch> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding"> + <horstretch>4</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> @@ -47,6 +63,13 @@ </item> </layout> </widget> + <customwidgets> + <customwidget> + <class>CategoryListWidget</class> + <extends>QListWidget</extends> + <header>gui/EditEntryWidget_p.h</header> + </customwidget> + </customwidgets> <resources/> <connections/> </ui> diff --git a/src/gui/EditEntryWidget_p.h b/src/gui/EditEntryWidget_p.h new file mode 100644 index 000000000..3c3b3b2d3 --- /dev/null +++ b/src/gui/EditEntryWidget_p.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2010 Felix Geyer <debfx@fobos.de> + * + * 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 <http://www.gnu.org/licenses/>. + */ + +#ifndef KEEPASSX_EDITENTRYWIDGET_P_H +#define KEEPASSX_EDITENTRYWIDGET_P_H + +#include <QtCore/QSize> +#include <QtGui/QListWidget> +#include <QtGui/QScrollBar> +#include <QtGui/QStyledItemDelegate> + +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 |