From b0280e9d93104ebc35d81908066acaf81c78830f Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Mon, 29 Oct 2012 23:44:10 +0100 Subject: [PATCH] Small refactoring in EditWidget and EditEntryWidget. --- src/gui/EditWidget.cpp | 7 +++++-- src/gui/EditWidget.h | 2 +- src/gui/entry/EditEntryWidget.cpp | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/EditWidget.cpp b/src/gui/EditWidget.cpp index 69e645160..831db54b4 100644 --- a/src/gui/EditWidget.cpp +++ b/src/gui/EditWidget.cpp @@ -46,9 +46,12 @@ void EditWidget::add(const QString& labelText, QWidget* widget) m_ui->stackedWidget->addWidget(widget); } -void EditWidget::setRowHidden(int row, bool hide) +void EditWidget::setRowHidden(QWidget* widget, bool hide) { - m_ui->categoryList->item(row)->setHidden(hide); + int row = m_ui->stackedWidget->indexOf(widget); + if (row != -1) { + m_ui->categoryList->item(row)->setHidden(hide); + } } void EditWidget::setCurrentRow(int index) diff --git a/src/gui/EditWidget.h b/src/gui/EditWidget.h index 60c1b28c0..9cd79fa5f 100644 --- a/src/gui/EditWidget.h +++ b/src/gui/EditWidget.h @@ -37,7 +37,7 @@ public: ~EditWidget(); void add(const QString& labelText, QWidget* widget); - void setRowHidden(int row, bool hide); + void setRowHidden(QWidget *widget, bool hide); void setCurrentRow(int index); void setHeadline(const QString& text); QLabel* headlineLabel(); diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index 5569fdd30..2db5e9040 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -73,7 +73,6 @@ EditEntryWidget::EditEntryWidget(QWidget* parent) setupIcon(); setupAutoType(); setupProperties(); - // when adding a new row, update setRowHidden() call setupHistory(); connect(this, SIGNAL(accepted()), SLOT(saveEntry())); @@ -280,7 +279,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, bool history, const Q setForms(entry); setCurrentRow(0); - setRowHidden(6, m_history); + setRowHidden(m_historyWidget, m_history); } void EditEntryWidget::setForms(const Entry* entry, bool restore)