summaryrefslogtreecommitdiff
path: root/numberator.cpp
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2020-08-17 00:56:17 +0200
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2020-08-17 00:56:17 +0200
commitc6713d0876ce2d99f912151c9884477606909681 (patch)
tree07717d3ffb8d78095f83bee5b0779a6bd264149a /numberator.cpp
parent2deadc6cfbf71e06908963fb1bae628cfe370f9d (diff)
downloadnumberator-c6713d0876ce2d99f912151c9884477606909681.tar.gz
numberator-c6713d0876ce2d99f912151c9884477606909681.tar.bz2
numberator-c6713d0876ce2d99f912151c9884477606909681.zip
More UI work
Diffstat (limited to 'numberator.cpp')
-rw-r--r--numberator.cpp75
1 files changed, 65 insertions, 10 deletions
diff --git a/numberator.cpp b/numberator.cpp
index 29c0d6b..3161ee8 100644
--- a/numberator.cpp
+++ b/numberator.cpp
@@ -8,11 +8,13 @@ Numberator::Numberator(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::Numberator)
, tagsDockUi(new Ui::TagListDock)
+ , tagEditUi(new Ui::TagEditDialog)
, settings("jaseg.de", "Numberator")
, loadImageDialog(this)
, proj()
, tagListModel(proj)
- , tagPropTableModel(proj)
+ , tagPropTableModel(&proj)
+ , dialogTagPropTableModel(nullptr, false)
{
ui->setupUi(this);
@@ -22,16 +24,75 @@ Numberator::Numberator(QWidget *parent)
QMessageBox::critical(this, errorName, description);
});
+ QDialog *tagEditDialog = new QDialog(this);
+ tagEditUi->setupUi(tagEditDialog);
+ tagEditUi->tagPropertiesView->setModel(&dialogTagPropTableModel);
+ connect(tagEditUi->buttonBox, &QDialogButtonBox::accepted, [=]() {
+ Tag newTag(m_tagBeingEdited);
+ newTag.name = tagEditUi->tagNameEdit->text();
+ newTag.metadata = dialogTagPropTableModel.metadata();
+ proj.updateTag(newTag);
+ tagEditDialog->hide();
+ });
+
+ connect(tagEditUi->buttonBox, &QDialogButtonBox::rejected, tagEditDialog, &QDialog::hide);
+
+ connect(ui->graphicsView->scene(), &TagScene::selectionChanged, [=](){
+ auto dbg = qDebug() << "tag view selection changed";
+ auto items = ui->graphicsView->scene()->selectedItems();
+ if (items.isEmpty()) {
+ dbg << "<empty>";
+ return;
+ }
+ QGraphicsItem *first = items.first();
+ TagItem *it = qgraphicsitem_cast<TagItem *>(first);
+ dbg << first << it << first->type() << TagItem::Type;
+ if (!it) {
+ dbg << "<no tagitem>";
+ return;
+ }
+ dbg << it->tag().id << it->tag().name;
+ QSignalBlocker(tagsDockUi->tagList->selectionModel());
+ tagsDockUi->tagList->selectionModel()->select(tagListModel.indexOf(it->tag()), QItemSelectionModel::ClearAndSelect);
+ tagPropTableModel.showTag(it->tag());
+ });
+
+ /*
+ m_tagBeingEdited = it->tag();
+ tagEditUi->tagNameEdit->setText(m_tagBeingEdited.name);
+ tagEditUi->tagIdLabel->setText(QString::number(m_tagBeingEdited.id));
+ tagEditUi->tagLocationLabel->setText(m_tagBeingEdited.humanReadableAnchor());
+ dialogTagPropTableModel.showTag(m_tagBeingEdited);
+ */
+
QDockWidget *dock = new QDockWidget(this);
tagsDockUi->setupUi(dock);
addDockWidget(Qt::LeftDockWidgetArea, dock);
+ tagsDockUi->tagList->setModel(&tagListModel);
+ qDebug() << "connecting up model" << tagsDockUi->tagList->selectionModel();
+ connect(tagsDockUi->tagList->selectionModel(), &QItemSelectionModel::selectionChanged,
+ [=](const QItemSelection &selected, const QItemSelection &deselected) {
+ Q_UNUSED(deselected);
+ auto dbg = qDebug() << "tagList...selectionChanged";
+ if (selected.indexes().isEmpty()) {
+ dbg << "<empty>";
+ ui->graphicsView->scene()->clearSelection();
+ tagPropTableModel.showTag(Tag());
+
+ } else {
+ Tag tag(tagListModel.getTag(selected.indexes().first()));
+ qDebug() << tag.id << tag.name;
+ tagPropTableModel.showTag(tag);
+ QSignalBlocker(ui->graphicsView->scene());
+ ui->graphicsView->scene()->selectTag(tag);
+ }
+ });
+
ui->menuView->addAction(dock->toggleViewAction());
- connect(ui->actionReload_Image, &QAction::triggered,
- &proj, &SQLiteSaveFile::reloadImageFromDisk);
+ connect(ui->actionReload_Image, &QAction::triggered, &proj, &SQLiteSaveFile::reloadImageFromDisk);
ui->graphicsView->setProject(&proj);
- tagsDockUi->tagList->setModel(&tagListModel);
tagsDockUi->propertyTable->setModel(&tagPropTableModel);
loadImageDialog.setWindowModality(Qt::ApplicationModal);
@@ -80,12 +141,6 @@ Numberator::Numberator(QWidget *parent)
});
connect(ui->actionAbout, &QAction::triggered, &aboutDialog, &AboutDialog::open);
- connect(tagsDockUi->tagList->selectionModel(), &QItemSelectionModel::selectionChanged,
- [=](const QItemSelection &selected, const QItemSelection &deselected) {
- Q_UNUSED(deselected);
- tagPropTableModel.showTag(tagListModel.getTag(selected.indexes().first()));
- });
-
connect(ui->actionZoom_to_fit, &QAction::triggered, ui->graphicsView, &TagView::zoomToFit);
connect(ui->actionZoom_in, &QAction::triggered, ui->graphicsView, &TagView::zoomIn);
connect(ui->actionZoom_out, &QAction::triggered, ui->graphicsView, &TagView::zoomOut);