Open url when an entry is activated via its url column.

Closes #55
This commit is contained in:
Florian Geyer 2013-04-07 21:05:52 +02:00
parent 5786e2620a
commit bf906a7867
4 changed files with 21 additions and 6 deletions

View File

@ -138,6 +138,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
connect(m_entryView, SIGNAL(entryActivated(Entry*)), SLOT(switchToEntryEdit(Entry*)));
connect(m_entryView, SIGNAL(openUrl(Entry*)), SLOT(openUrlForEntry(Entry*)));
connect(m_entryView, SIGNAL(entrySelectionChanged()), SIGNAL(entrySelectionChanged()));
connect(m_editEntryWidget, SIGNAL(editFinished(bool)), SLOT(switchToView(bool)));
connect(m_editEntryWidget, SIGNAL(historyEntryActivated(Entry*)), SLOT(switchToHistoryView(Entry*)));
@ -303,8 +304,13 @@ void DatabaseWidget::openUrl()
return;
}
if (!currentEntry->url().isEmpty()) {
QDesktopServices::openUrl(currentEntry->url());
openUrlForEntry(currentEntry);
}
void DatabaseWidget::openUrlForEntry(Entry* entry)
{
if (!entry->url().isEmpty()) {
QDesktopServices::openUrl(entry->url());
}
}

View File

@ -89,6 +89,7 @@ public Q_SLOTS:
void copyAttribute(QAction* action);
void performAutoType();
void openUrl();
void openUrlForEntry(Entry* entry);
void createGroup();
void deleteGroup();
void switchToEntryEdit();

View File

@ -43,7 +43,7 @@ EntryView::EntryView(QWidget* parent)
// QAbstractItemView::startDrag() uses this property as the default drag action
setDefaultDropAction(Qt::MoveAction);
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(this, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivationSignal(QModelIndex)));
connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SIGNAL(entrySelectionChanged()));
connect(m_model, SIGNAL(switchedToEntryListMode()), SLOT(switchToEntryListMode()));
connect(m_model, SIGNAL(switchedToGroupMode()), SLOT(switchToGroupMode()));
@ -66,9 +66,16 @@ bool EntryView::inEntryListMode()
return m_inEntryListMode;
}
void EntryView::emitEntryActivated(const QModelIndex& index)
void EntryView::emitEntryActivationSignal(const QModelIndex& index)
{
Q_EMIT entryActivated(entryFromIndex(index));
Entry* entry = entryFromIndex(index);
if (m_sortModel->mapToSource(index).column() == 3) {
Q_EMIT openUrl(entry);
}
else {
Q_EMIT entryActivated(entry);
}
}
void EntryView::setModel(QAbstractItemModel* model)

View File

@ -46,10 +46,11 @@ public Q_SLOTS:
Q_SIGNALS:
void entryActivated(Entry* entry);
void openUrl(Entry* entry);
void entrySelectionChanged();
private Q_SLOTS:
void emitEntryActivated(const QModelIndex& index);
void emitEntryActivationSignal(const QModelIndex& index);
void switchToEntryListMode();
void switchToGroupMode();