Dirk, On Thu, Jan 16, 2014 at 4:22 AM, Dirk Hohndel <[email protected]> wrote:
> > I wonder if we should do the same for divemaster as well. Granted, most > of the time there will be only one (I have a few exceptions in my data), > but I mostly think that this would make things visually more > consistent... > > Thoughts, comments? > Not sure whether it will work for most of users, but anyway here it is. Sergey
From da679778f42d00698351c53802999dec0a32d928 Mon Sep 17 00:00:00 2001 From: Sergey Starosek <[email protected]> Date: Sun, 19 Jan 2014 19:27:49 +0200 Subject: [PATCH 1/3] Populate divemaster completion model using CSV To: [email protected] Split divemaster field value using comma and populate completion list. Signed-off-by: Sergey Starosek <[email protected]> --- qt-ui/completionmodels.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/qt-ui/completionmodels.cpp b/qt-ui/completionmodels.cpp index a66b8d0..8ccab3f 100644 --- a/qt-ui/completionmodels.cpp +++ b/qt-ui/completionmodels.cpp @@ -32,21 +32,23 @@ void Class::updateModel() \ setStringList(list); \ } -void BuddyCompletionModel::updateModel() -{ - QSet<QString> set; - struct dive* dive; - int i = 0; - for_each_dive(i, dive) { - QString buddy(dive->buddy); - foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { - set.insert(value.trimmed()); - } - } - setStringList(set.toList()); +#define CREATE_CSV_UPDATE_METHOD(Class, diveStructMember) \ +void Class::updateModel() \ +{ \ + QSet<QString> set; \ + struct dive* dive; \ + int i = 0; \ + for_each_dive(i, dive) { \ + QString buddy(dive->diveStructMember); \ + foreach (const QString &value, buddy.split(",", QString::SkipEmptyParts)) { \ + set.insert(value.trimmed()); \ + } \ + } \ + setStringList(set.toList()); \ } -CREATE_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); +CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy); +CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster); CREATE_UPDATE_METHOD(LocationCompletionModel, location); CREATE_UPDATE_METHOD(SuitCompletionModel, suit); -- 1.8.3.2
From 4511236aab99c72cbd0a5a9c84d68b9512be4684 Mon Sep 17 00:00:00 2001 From: Sergey Starosek <[email protected]> Date: Sun, 19 Jan 2014 19:30:47 +0200 Subject: [PATCH 2/3] Expand tags approach to divemaster field To: [email protected] Signed-off-by: Sergey Starosek <[email protected]> --- qt-ui/maintab.cpp | 3 ++- qt-ui/maintab.h | 2 +- qt-ui/maintab.ui | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index f3f85b0..15030c4 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -839,8 +839,9 @@ void MainTab::on_buddy_textChanged() markChangedWidget(ui.buddy); } -void MainTab::on_divemaster_textChanged(const QString& text) +void MainTab::on_divemaster_textChanged() { + QString text = ui.divemaster->toPlainText().split(",", QString::SkipEmptyParts).join(", "); EDIT_SELECTED_DIVES( EDIT_TEXT(mydive->divemaster, text) ); markChangedWidget(ui.divemaster); } diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 313149f..c5afd2f 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -68,7 +68,7 @@ public slots: void rejectChanges(); void on_location_textChanged(const QString& text); void on_coordinates_textChanged(const QString& text); - void on_divemaster_textChanged(const QString& text); + void on_divemaster_textChanged(); void on_buddy_textChanged(); void on_suit_textChanged(const QString& text); void on_notes_textChanged(); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index b2ab316..276c792 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -136,7 +136,7 @@ </widget> </item> <item row="8" column="0"> - <widget class="QLineEdit" name="divemaster"> + <widget class="TagWidget" name="divemaster"> <property name="readOnly"> <bool>false</bool> </property> -- 1.8.3.2
From 936c4fde96eff4339c4161f590deecae6a379b8f Mon Sep 17 00:00:00 2001 From: Sergey Starosek <[email protected]> Date: Sun, 19 Jan 2014 19:36:51 +0200 Subject: [PATCH 3/3] Enter dive edit mode on divemaster field focus To: [email protected] Signed-off-by: Sergey Starosek <[email protected]> --- qt-ui/maintab.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 15030c4..af01813 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -305,7 +305,7 @@ bool MainTab::eventFilter(QObject* object, QEvent* event) // FocusIn for the starWidgets or RequestSoftwareInputPanel for tagWidget start the editing if ((event->type() == QEvent::MouseButtonPress) || (event->type() == QEvent::KeyPress && object == ui.dateTimeEdit) || - (event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility || object == ui.buddy || object == ui.tagWidget))) { + (event->type() == QEvent::FocusIn && (object == ui.rating || object == ui.visibility || object == ui.buddy || object == ui.tagWidget || object || ui.divemaster))) { tabBar()->setTabIcon(currentIndex(), QIcon(":warning")); enableEdition(); } -- 1.8.3.2
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
