From f596cc4eec938cb25a5a7f4ba7de50c029be673d Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Mon, 14 May 2012 18:18:31 +0200 Subject: [PATCH] Add base edit widget. --- src/CMakeLists.txt | 3 ++ src/gui/EditWidget.cpp | 53 ++++++++++++++++++++++++++++++++ src/gui/EditWidget.h | 53 ++++++++++++++++++++++++++++++++ src/gui/EditWidget.ui | 69 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 178 insertions(+) create mode 100644 src/gui/EditWidget.cpp create mode 100644 src/gui/EditWidget.h create mode 100644 src/gui/EditWidget.ui diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 19b75c57..cfc452ad 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,6 +60,7 @@ set(keepassx_SOURCES gui/DialogyWidget.cpp gui/EditEntryWidget.cpp gui/EditGroupWidget.cpp + gui/EditWidget.cpp gui/EntryAttachmentsModel.cpp gui/EntryAttributesModel.cpp gui/EntryModel.cpp @@ -96,6 +97,7 @@ set(keepassx_MOC gui/DialogyWidget.h gui/EditEntryWidget.h gui/EditGroupWidget.h + gui/EditWidget.h gui/EntryAttachmentsModel.h gui/EntryAttributesModel.h gui/EntryModel.h @@ -122,6 +124,7 @@ set(keepassx_FORMS gui/EditEntryWidgetMain.ui gui/EditEntryWidgetNotes.ui gui/EditGroupWidget.ui + gui/EditWidget.ui gui/MainWindow.ui ) diff --git a/src/gui/EditWidget.cpp b/src/gui/EditWidget.cpp new file mode 100644 index 00000000..a5b28f1b --- /dev/null +++ b/src/gui/EditWidget.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 . + */ + +#include "EditWidget.h" +#include "ui_EditWidget.h" + +EditWidget::EditWidget(QWidget *parent) + : DialogyWidget(parent) + , m_ui(new Ui::EditWidget()) +{ + m_ui->setupUi(this); + + connect(m_ui->categoryList, SIGNAL(currentRowChanged(int)), + m_ui->stackedWidget, SLOT(setCurrentIndex(int))); + + connect(m_ui->buttonBox, SIGNAL(accepted()), SIGNAL(accepted())); + connect(m_ui->buttonBox, SIGNAL(rejected()), SIGNAL(rejected())); +} + +EditWidget::~EditWidget() +{ +} + +void EditWidget::add(const QString& labelText, QWidget* widget) +{ + m_ui->categoryList->addItem(labelText); + m_ui->stackedWidget->addWidget(widget); +} + +void EditWidget::setCurrentRow(int index) +{ + m_ui->categoryList->setCurrentRow(index); +} + +QLabel* EditWidget::headlineLabel() +{ + return m_ui->headerLabel; +} + diff --git a/src/gui/EditWidget.h b/src/gui/EditWidget.h new file mode 100644 index 00000000..9fdd35c7 --- /dev/null +++ b/src/gui/EditWidget.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2012 Felix Geyer + * + * 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 . + */ + +#ifndef KEEPASSX_EDITWIDGET_H +#define KEEPASSX_EDITWIDGET_H + +#include +#include + +#include + + +namespace Ui { + class EditWidget; +} + +class EditWidget : public DialogyWidget +{ + Q_OBJECT + +public: + explicit EditWidget(QWidget *parent = 0); + ~EditWidget(); + + void add(const QString& labelText, QWidget* widget); + void setCurrentRow(int index); + QLabel* headlineLabel(); + +Q_SIGNALS: + void accepted(); + void rejected(); + +private: + const QScopedPointer m_ui; + + Q_DISABLE_COPY(EditWidget) +}; + +#endif // KEEPASSX_EDITWIDGET_H diff --git a/src/gui/EditWidget.ui b/src/gui/EditWidget.ui new file mode 100644 index 00000000..5231e509 --- /dev/null +++ b/src/gui/EditWidget.ui @@ -0,0 +1,69 @@ + + + EditWidget + + + + 0 + 0 + 612 + 255 + + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 1 + 3 + + + + + + + + + + + + + -1 + + + + + + + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + CategoryListWidget + QListWidget +
gui/EditEntryWidget_p.h
+
+
+ + +