Improve EditEntryWidget.
This commit is contained in:
@@ -264,6 +264,11 @@ void Entry::addHistoryItem(Entry* entry)
|
|||||||
m_history.append(entry);
|
m_history.append(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group* Entry::group()
|
||||||
|
{
|
||||||
|
return m_group;
|
||||||
|
}
|
||||||
|
|
||||||
void Entry::setGroup(Group* group)
|
void Entry::setGroup(Group* group)
|
||||||
{
|
{
|
||||||
if (m_group) {
|
if (m_group) {
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ public:
|
|||||||
const QList<Entry*>& historyItems() const;
|
const QList<Entry*>& historyItems() const;
|
||||||
void addHistoryItem(Entry* entry);
|
void addHistoryItem(Entry* entry);
|
||||||
|
|
||||||
|
Group* group();
|
||||||
void setGroup(Group* group);
|
void setGroup(Group* group);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <QtGui/QStackedLayout>
|
#include <QtGui/QStackedLayout>
|
||||||
|
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
|
#include "core/Group.h"
|
||||||
|
|
||||||
EditEntryWidget::EditEntryWidget(QWidget* parent)
|
EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@@ -36,6 +37,11 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
|||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
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("Entry"));
|
||||||
m_ui->categoryList->addItem(tr("Description"));
|
m_ui->categoryList->addItem(tr("Description"));
|
||||||
|
|
||||||
@@ -60,6 +66,8 @@ void EditEntryWidget::loadEntry(Entry* entry)
|
|||||||
{
|
{
|
||||||
m_entry = entry;
|
m_entry = entry;
|
||||||
|
|
||||||
|
m_ui->headerLabel->setText(m_entry->group()->name()+" > "+tr("Edit entry"));
|
||||||
|
|
||||||
m_mainUi->titleEdit->setText(entry->title());
|
m_mainUi->titleEdit->setText(entry->title());
|
||||||
m_mainUi->usernameEdit->setText(entry->username());
|
m_mainUi->usernameEdit->setText(entry->username());
|
||||||
m_mainUi->urlEdit->setText(entry->url());
|
m_mainUi->urlEdit->setText(entry->url());
|
||||||
|
|||||||
@@ -11,23 +11,39 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<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>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListWidget" name="categoryList">
|
<widget class="CategoryListWidget" name="categoryList"/>
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>20</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
<horstretch>80</horstretch>
|
<horstretch>4</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
@@ -47,6 +63,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>CategoryListWidget</class>
|
||||||
|
<extends>QListWidget</extends>
|
||||||
|
<header>gui/EditEntryWidget_p.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
62
src/gui/EditEntryWidget_p.h
Normal file
62
src/gui/EditEntryWidget_p.h
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user