mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
editComment: Move Gui elements to widgets/XcaTreeView
Another step to separate GUI from functionality
This commit is contained in:
parent
2f70cb13d2
commit
56c6df6c90
@ -8,6 +8,8 @@
|
||||
#include "db_base.h"
|
||||
#include "func.h"
|
||||
#include "exception.h"
|
||||
#include "XcaWarningCore.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QListView>
|
||||
#include <QClipboard>
|
||||
@ -18,13 +20,9 @@
|
||||
#include <QFileInfo>
|
||||
|
||||
#warning drop UI dependencies
|
||||
#include "widgets/XcaWarning.h"
|
||||
#include "widgets/ImportMulti.h"
|
||||
#include "widgets/XcaDialog.h"
|
||||
|
||||
#include "ui_ItemProperties.h"
|
||||
#include "widgets/XcaWarning.h"
|
||||
#include "ui_ImportMulti.h"
|
||||
#include "ui_XcaDialog.h"
|
||||
|
||||
void db_base::restart_timer()
|
||||
{
|
||||
@ -630,26 +628,6 @@ void db_base::timerEvent(QTimerEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
void db_base::editComment(const QModelIndex &index)
|
||||
{
|
||||
pki_base *item = fromIndex(index);
|
||||
if (!index.isValid() || !item)
|
||||
return;
|
||||
|
||||
QWidget *w = new QWidget(NULL);
|
||||
Ui::ItemProperties *prop = new Ui::ItemProperties();
|
||||
prop->setupUi(w);
|
||||
prop->comment->setPlainText(item->getComment());
|
||||
prop->name->setText(item->getIntName());
|
||||
prop->source->setText(item->pki_source_name());
|
||||
prop->insertionDate->setText(item->getInsertionDate().toPretty());
|
||||
XcaDialog *d = new XcaDialog(nullptr, item->getType(), w,
|
||||
tr("Item properties"), QString(), "itemproperties");
|
||||
if (d->exec())
|
||||
updateItem(item, prop->name->text(), prop->comment->toPlainText());
|
||||
delete d;
|
||||
}
|
||||
|
||||
void db_base::load_default(load_base &load)
|
||||
{
|
||||
QString s;
|
||||
|
||||
@ -128,7 +128,6 @@ class db_base: public QAbstractItemModel
|
||||
|
||||
void deletePKI(QModelIndex idx);
|
||||
QMimeData *mimeData(const QModelIndexList &indexes) const;
|
||||
void editComment(const QModelIndex &index);
|
||||
void emitDataChanged(pki_base *pki);
|
||||
bool containsType(enum pki_type t) const;
|
||||
void writeVcalendar(XFile &file, QStringList vcal) const;
|
||||
|
||||
@ -18,8 +18,11 @@
|
||||
#include "XcaProxyModel.h"
|
||||
#include "MainWindow.h"
|
||||
#include "XcaWarning.h"
|
||||
#include "XcaDialog.h"
|
||||
#include "XcaApplication.h"
|
||||
|
||||
#include "ui_ItemProperties.h"
|
||||
|
||||
XcaTreeView::XcaTreeView(QWidget *parent)
|
||||
:QTreeView(parent)
|
||||
{
|
||||
@ -282,8 +285,23 @@ void XcaTreeView::doubleClick(const QModelIndex &m)
|
||||
|
||||
void XcaTreeView::editComment()
|
||||
{
|
||||
if (basemodel)
|
||||
basemodel->editComment(currentIndex());
|
||||
pki_base *item = db_base::fromIndex(currentIndex());
|
||||
if (!basemodel || !item)
|
||||
return;
|
||||
|
||||
QWidget *w = new QWidget(nullptr);
|
||||
Ui::ItemProperties *prop = new Ui::ItemProperties();
|
||||
prop->setupUi(w);
|
||||
prop->comment->setPlainText(item->getComment());
|
||||
prop->name->setText(item->getIntName());
|
||||
prop->source->setText(item->pki_source_name());
|
||||
prop->insertionDate->setText(item->getInsertionDate().toPretty());
|
||||
XcaDialog *d = new XcaDialog(this, item->getType(), w,
|
||||
tr("Item properties"), QString(), "itemproperties");
|
||||
if (d->exec())
|
||||
basemodel->updateItem(item, prop->name->text(),
|
||||
prop->comment->toPlainText());
|
||||
delete d;
|
||||
}
|
||||
|
||||
void XcaTreeView::pem2clipboard()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user