mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add EntryView and DatabaseWidget.
This commit is contained in:
parent
e96c3bb011
commit
621b367f45
@ -27,7 +27,9 @@ set(keepassx_SOURCES
|
||||
core/TimeInfo.cpp
|
||||
core/Uuid.cpp
|
||||
core/Writer.cpp
|
||||
gui/DatabaseWidget.cpp
|
||||
gui/EntryModel.cpp
|
||||
gui/EntryView.cpp
|
||||
gui/GroupModel.cpp
|
||||
gui/GroupView.cpp
|
||||
)
|
||||
|
37
src/gui/DatabaseWidget.cpp
Normal file
37
src/gui/DatabaseWidget.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "DatabaseWidget.h"
|
||||
|
||||
#include <QtGui/QHBoxLayout>
|
||||
|
||||
#include "EntryView.h"
|
||||
#include "GroupView.h"
|
||||
|
||||
DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_groupView = new GroupView(db);
|
||||
m_entryView = new EntryView();
|
||||
|
||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout();
|
||||
layout->addWidget(m_groupView);
|
||||
layout->addWidget(m_entryView);
|
||||
setLayout(layout);
|
||||
}
|
39
src/gui/DatabaseWidget.h
Normal file
39
src/gui/DatabaseWidget.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 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_DATABASEWIDGET_H
|
||||
#define KEEPASSX_DATABASEWIDGET_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
class Database;
|
||||
class EntryView;
|
||||
class GroupView;
|
||||
|
||||
class DatabaseWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DatabaseWidget(Database* db, QWidget* parent = 0);
|
||||
|
||||
private:
|
||||
GroupView* m_groupView;
|
||||
EntryView* m_entryView;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_DATABASEWIDGET_H
|
38
src/gui/EntryView.cpp
Normal file
38
src/gui/EntryView.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "EntryView.h"
|
||||
|
||||
#include "EntryModel.h"
|
||||
|
||||
EntryView::EntryView(QWidget* parent)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
m_model = new EntryModel(this);
|
||||
QTreeView::setModel(m_model);
|
||||
}
|
||||
|
||||
void EntryView::setGroup(Group* group)
|
||||
{
|
||||
m_model->setGroup(group);
|
||||
}
|
||||
|
||||
void EntryView::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
Q_ASSERT(false);
|
||||
}
|
41
src/gui/EntryView.h
Normal file
41
src/gui/EntryView.h
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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_ENTRYVIEW_H
|
||||
#define KEEPASSX_ENTRYVIEW_H
|
||||
|
||||
#include <QtGui/QTreeView>
|
||||
|
||||
class EntryModel;
|
||||
class Group;
|
||||
|
||||
class EntryView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit EntryView(QWidget* parent = 0);
|
||||
void setModel(QAbstractItemModel* model);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setGroup(Group* group);
|
||||
|
||||
private:
|
||||
EntryModel* m_model;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_ENTRYVIEW_H
|
@ -27,6 +27,8 @@ GroupView::GroupView(Database* db, QWidget* parent) : QTreeView(parent)
|
||||
QTreeView::setModel(m_model);
|
||||
recInitExpanded(db->rootGroup());
|
||||
setHeaderHidden(true);
|
||||
|
||||
connect(this, SIGNAL(clicked(const QModelIndex&)), SLOT(emitGroupChanged(const QModelIndex&)));
|
||||
}
|
||||
|
||||
void GroupView::expandedChanged(const QModelIndex& index)
|
||||
@ -45,6 +47,11 @@ void GroupView::recInitExpanded(Group* group)
|
||||
}
|
||||
}
|
||||
|
||||
void GroupView::emitGroupChanged(const QModelIndex& index)
|
||||
{
|
||||
Q_EMIT groupChanged(m_model->groupFromIndex(index));
|
||||
}
|
||||
|
||||
void GroupView::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
Q_UNUSED(model);
|
||||
|
@ -32,6 +32,9 @@ public:
|
||||
GroupView(Database* db, QWidget* parent = 0);
|
||||
void setModel(QAbstractItemModel* model);
|
||||
|
||||
Q_SIGNALS:
|
||||
void groupChanged(Group* group);
|
||||
|
||||
private Q_SLOTS:
|
||||
void expandedChanged(const QModelIndex& index);
|
||||
void emitGroupChanged(const QModelIndex& index);
|
||||
|
10
src/main.cpp
10
src/main.cpp
@ -20,7 +20,7 @@
|
||||
|
||||
#include "core/Database.h"
|
||||
#include "core/Parser.h"
|
||||
#include "gui/GroupModel.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
|
||||
#include "../tests/config-keepassx-tests.h"
|
||||
|
||||
@ -32,12 +32,8 @@ int main(int argc, char **argv)
|
||||
Parser* parser = new Parser(db);
|
||||
parser->parse(QString(KEEPASSX_TEST_DIR).append("/NewDatabase.xml"));
|
||||
|
||||
GroupModel groupModel(db);
|
||||
DatabaseWidget dbWidget(db);
|
||||
dbWidget.show();
|
||||
|
||||
QTreeView view;
|
||||
view.setModel(&groupModel);
|
||||
view.setHeaderHidden(true);
|
||||
view.expandAll();
|
||||
view.show();
|
||||
return app.exec();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user