Skip to content

Commit

Permalink
Refactor DetailsWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
frostasm committed Jan 7, 2018
1 parent 6476b6b commit 6d9bd7d
Show file tree
Hide file tree
Showing 9 changed files with 846 additions and 729 deletions.
2 changes: 1 addition & 1 deletion src/core/EntryAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool EntryAttributes::hasKey(const QString& key) const
return m_attributes.contains(key);
}

QList<QString> EntryAttributes::customKeys()
QList<QString> EntryAttributes::customKeys() const
{
QList<QString> customKeys;
const QList<QString> keyList = keys();
Expand Down
2 changes: 1 addition & 1 deletion src/core/EntryAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EntryAttributes : public QObject
explicit EntryAttributes(QObject* parent = nullptr);
QList<QString> keys() const;
bool hasKey(const QString& key) const;
QList<QString> customKeys();
QList<QString> customKeys() const;
QString value(const QString& key) const;
bool contains(const QString& key) const;
bool containsValue(const QString& value) const;
Expand Down
6 changes: 3 additions & 3 deletions src/core/Group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,11 @@ void Group::setParent(Database* db)
QObject::setParent(db);
}

QStringList Group::hierarchy()
QStringList Group::hierarchy() const
{
QStringList hierarchy;
Group* group = this;
Group* parent = m_parent;
const Group* group = this;
const Group* parent = m_parent;
hierarchy.prepend(group->name());

while (parent) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class Group : public QObject
Group* parentGroup();
const Group* parentGroup() const;
void setParent(Group* parent, int index = -1);
QStringList hierarchy();
QStringList hierarchy() const;

Database* database();
const Database* database() const;
Expand Down
15 changes: 12 additions & 3 deletions src/gui/DatabaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
"border-radius: 5px;");

m_detailsView = new DetailsWidget(this);
connect(m_detailsView, &DetailsWidget::errorOccurred, this, [this](const QString& error) {
showMessage(error, MessageWidget::MessageType::Error);
});
m_detailsView->hide();
connect(this, SIGNAL(pressedEntry(Entry*)), m_detailsView, SLOT(setEntry(Entry*)));
connect(this, SIGNAL(pressedGroup(Group*)), m_detailsView, SLOT(setGroup(Group*)));
connect(this, SIGNAL(currentModeChanged(DatabaseWidget::Mode)),
m_detailsView, SLOT(setDatabaseMode(DatabaseWidget::Mode)));
connect(m_detailsView, SIGNAL(errorOccurred(QString)), this, SLOT(showErrorMessage(QString)));


QVBoxLayout* vLayout = new QVBoxLayout(rightHandSideWidget);
vLayout->setMargin(0);
Expand Down Expand Up @@ -1439,6 +1443,11 @@ void DatabaseWidget::showMessage(const QString& text, MessageWidget::MessageType
m_messageWidget->showMessage(text, type, autoHideTimeout);
}

void DatabaseWidget::showErrorMessage(const QString& errorMessage)
{
showMessage(errorMessage, MessageWidget::MessageType::Error);
}

void DatabaseWidget::hideMessage()
{
if (m_messageWidget->isVisible()) {
Expand Down
1 change: 1 addition & 0 deletions src/gui/DatabaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public slots:

void showMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true,
int autoHideTimeout = MessageWidget::DefaultAutoHideTimeout);
void showErrorMessage(const QString& errorMessage);
void hideMessage();

private slots:
Expand Down
Loading

0 comments on commit 6d9bd7d

Please sign in to comment.