Add expiry option to group edit.

This commit is contained in:
Florian Geyer 2012-05-18 10:52:05 +02:00
parent 810a6e4b39
commit d218924b4f
4 changed files with 55 additions and 11 deletions

View File

@ -248,6 +248,24 @@ void Group::setLastTopVisibleEntry(Entry* entry)
set(m_lastTopVisibleEntry, entry);
}
void Group::setExpires(const bool& value)
{
if (m_timeInfo.expires() != value) {
m_timeInfo.setExpires(value);
updateTimeinfo();
Q_EMIT modified();
}
}
void Group::setExpiryTime(const QDateTime& dateTime)
{
if (m_timeInfo.expiryTime() != dateTime) {
m_timeInfo.setExpiryTime(dateTime);
updateTimeinfo();
Q_EMIT modified();
}
}
Group* Group::parentGroup()
{
return m_parent;

View File

@ -65,6 +65,8 @@ public:
void setAutoTypeEnabled(TriState enable);
void setSearchingEnabled(TriState enable);
void setLastTopVisibleEntry(Entry* entry);
void setExpires(const bool& value);
void setExpiryTime(const QDateTime& dateTime);
void setUpdateTimeinfo(bool value);

View File

@ -39,6 +39,8 @@ EditGroupWidget::EditGroupWidget(QWidget* parent)
labelHeaderFont.setPointSize(labelHeaderFont.pointSize() + 2);
headlineLabel()->setFont(labelHeaderFont);
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
connect(this, SIGNAL(accepted()), SLOT(save()));
connect(this, SIGNAL(rejected()), SLOT(cancel()));
}
@ -61,13 +63,16 @@ void EditGroupWidget::loadGroup(Group* group, bool create, Database* database)
m_mainUi->editName->setText(m_group->name());
m_mainUi->editNotes->setPlainText(m_group->notes());
m_mainUi->expireCheck->setChecked(group->timeInfo().expires());
m_mainUi->expireDatePicker->setDateTime(group->timeInfo().expiryTime().toLocalTime());
setCurrentRow(0);
IconStruct iconStruct;
iconStruct.uuid = group->iconUuid();
iconStruct.number = group->iconNumber();
m_editGroupWidgetIcons->load(group->uuid(), database, iconStruct);
setCurrentRow(0);
m_mainUi->editName->setFocus();
}
@ -75,6 +80,8 @@ void EditGroupWidget::save()
{
m_group->setName(m_mainUi->editName->text());
m_group->setNotes(m_mainUi->editNotes->toPlainText());
m_group->setExpires(m_mainUi->expireCheck->isChecked());
m_group->setExpiryTime(m_mainUi->expireDatePicker->dateTime().toUTC());
IconStruct iconStruct = m_editGroupWidgetIcons->save();

View File

@ -16,16 +16,6 @@
<property name="fieldGrowthPolicy">
<enum>QFormLayout::ExpandingFieldsGrow</enum>
</property>
<item row="1" column="0">
<widget class="QLabel" name="labelNotes">
<property name="text">
<string>Notes</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="editName"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="labelName">
<property name="text">
@ -33,9 +23,36 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="editName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelNotes">
<property name="text">
<string>Notes</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPlainTextEdit" name="editNotes"/>
</item>
<item row="2" column="1">
<widget class="QDateTimeEdit" name="expireDatePicker">
<property name="enabled">
<bool>false</bool>
</property>
<property name="calendarPopup">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="expireCheck">
<property name="text">
<string>Expires</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>