5 bugs in 4 patches. \o/
From f8f434f508200bb6f88073ed6791161c7eea4270 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 16 Jul 2014 18:16:22 -0300
Subject: [PATCH 1/4] Fix saving and storing the dive plan notes when there's
 html on it

We save an HTML table-based plan, so we need to get the text as html,
not plaintext.

Signed-off-by: Tomaz Canabrava <[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 4ec3941..0fa81a4 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -1001,7 +1001,7 @@ void MainTab::on_notes_textChanged()
 	if (editMode == IGNORE)
 		return;
 	free(displayed_dive.notes);
-	displayed_dive.notes = strdup(ui.notes->toPlainText().toUtf8().data());
+	displayed_dive.notes = strdup(ui.notes->toHtml().toUtf8().data());
 	markChangedWidget(ui.notes);
 }
 
-- 
2.0.1

From c07376c4eb356d7f51e3b106b8f2871b882e6f91 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 16 Jul 2014 18:40:49 -0300
Subject: [PATCH 2/4] Added a 'use default file' button on preferences.

Added a 'Use default file' button on preferences in a way
that doesn't clutters the interface.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 pref.h                |  1 +
 qt-ui/preferences.cpp | 13 ++++++++++
 qt-ui/preferences.h   |  2 ++
 qt-ui/preferences.ui  | 70 +++++++++++++++++++++++++++++++++++----------------
 4 files changed, 64 insertions(+), 22 deletions(-)

diff --git a/pref.h b/pref.h
index ca96965..3efe0a5 100644
--- a/pref.h
+++ b/pref.h
@@ -64,6 +64,7 @@ struct preferences {
 	bool doo2breaks;
 	bool drop_stone_mode;
 	bool show_pictures_in_profile;
+	bool use_default_file;
 };
 enum unit_system_values {
 	METRIC,
diff --git a/qt-ui/preferences.cpp b/qt-ui/preferences.cpp
index a356756..cc5cfef 100644
--- a/qt-ui/preferences.cpp
+++ b/qt-ui/preferences.cpp
@@ -132,6 +132,7 @@ void PreferencesDialog::setUiFromPrefs()
 	ui.proxyUsername->setText(prefs.proxy_user);
 	ui.proxyPassword->setText(prefs.proxy_pass);
 	ui.proxyType->setCurrentIndex(ui.proxyType->findData(prefs.proxy_type));
+	ui.btnUseDefaultFile->setChecked(prefs.use_default_file);
 }
 
 void PreferencesDialog::restorePrefs()
@@ -227,6 +228,7 @@ void PreferencesDialog::syncSettings()
 	s.beginGroup("GeneralSettings");
 	s.setValue("default_filename", ui.defaultfilename->text());
 	s.setValue("default_cylinder", ui.default_cylinder->currentText());
+	s.setValue("use_default_file", ui.btnUseDefaultFile->isChecked());
 	s.endGroup();
 
 	s.beginGroup("Display");
@@ -326,6 +328,7 @@ void PreferencesDialog::loadSettings()
 	s.beginGroup("GeneralSettings");
 	GET_TXT("default_filename", default_filename);
 	GET_TXT("default_cylinder", default_cylinder);
+	GET_BOOL("use_default_file", use_default_file);
 	s.endGroup();
 
 	s.beginGroup("Display");
@@ -427,3 +430,13 @@ void PreferencesDialog::proxyType_changed(int idx)
 	ui.proxyPassword->setEnabled(hpEnabled & ui.proxyAuthRequired->isChecked());
 	ui.proxyAuthRequired->setChecked(ui.proxyAuthRequired->isChecked());
 }
+
+void PreferencesDialog::on_btnUseDefaultFile_toggled(bool toggle)
+{
+	if (toggle) {
+		ui.defaultfilename->setText(system_default_filename());
+		ui.defaultfilename->setEnabled(false);
+	} else {
+		ui.defaultfilename->setEnabled(true);
+	}
+}
diff --git a/qt-ui/preferences.h b/qt-ui/preferences.h
index ac54cc0..2a909db 100644
--- a/qt-ui/preferences.h
+++ b/qt-ui/preferences.h
@@ -14,6 +14,7 @@ public:
 	static PreferencesDialog *instance();
 	void showEvent(QShowEvent *);
 	void emitSettingsChanged();
+
 signals:
 	void settingsChanged();
 public
@@ -28,6 +29,7 @@ slots:
 	void gflowChanged(int gf);
 	void gfhighChanged(int gf);
 	void proxyType_changed(int idx);
+	void on_btnUseDefaultFile_toggled(bool toggle);
 
 private:
 	explicit PreferencesDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
diff --git a/qt-ui/preferences.ui b/qt-ui/preferences.ui
index 1b54098..78979d0 100644
--- a/qt-ui/preferences.ui
+++ b/qt-ui/preferences.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>872</width>
-    <height>648</height>
+    <height>830</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -193,6 +193,16 @@
                <widget class="QLineEdit" name="defaultfilename"/>
               </item>
               <item>
+               <widget class="QToolButton" name="btnUseDefaultFile">
+                <property name="text">
+                 <string>Use default</string>
+                </property>
+                <property name="checkable">
+                 <bool>true</bool>
+                </property>
+               </widget>
+              </item>
+              <item>
                <widget class="QToolButton" name="chooseFile">
                 <property name="text">
                  <string>...</string>
@@ -969,8 +979,8 @@
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>247</x>
-     <y>635</y>
+     <x>259</x>
+     <y>817</y>
     </hint>
     <hint type="destinationlabel">
      <x>157</x>
@@ -985,8 +995,8 @@
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>315</x>
-     <y>635</y>
+     <x>327</x>
+     <y>817</y>
     </hint>
     <hint type="destinationlabel">
      <x>286</x>
@@ -1225,12 +1235,12 @@
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>181</x>
-     <y>319</y>
+     <x>361</x>
+     <y>439</y>
     </hint>
     <hint type="destinationlabel">
-     <x>798</x>
-     <y>314</y>
+     <x>831</x>
+     <y>447</y>
     </hint>
    </hints>
   </connection>
@@ -1241,12 +1251,12 @@
    <slot>setValue(int)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>798</x>
-     <y>314</y>
+     <x>831</x>
+     <y>447</y>
     </hint>
     <hint type="destinationlabel">
-     <x>181</x>
-     <y>319</y>
+     <x>361</x>
+     <y>439</y>
     </hint>
    </hints>
   </connection>
@@ -1257,12 +1267,12 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>211</x>
-     <y>122</y>
+     <x>200</x>
+     <y>42</y>
     </hint>
     <hint type="destinationlabel">
-     <x>257</x>
-     <y>151</y>
+     <x>200</x>
+     <y>42</y>
     </hint>
    </hints>
   </connection>
@@ -1273,23 +1283,39 @@
    <slot>setEnabled(bool)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>230</x>
-     <y>124</y>
+     <x>200</x>
+     <y>42</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>200</x>
+     <y>42</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>btnUseDefaultFile</sender>
+   <signal>toggled(bool)</signal>
+   <receiver>chooseFile</receiver>
+   <slot>setHidden(bool)</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>754</x>
+     <y>216</y>
     </hint>
     <hint type="destinationlabel">
-     <x>319</x>
-     <y>187</y>
+     <x>801</x>
+     <y>213</y>
     </hint>
    </hints>
   </connection>
  </connections>
  <buttongroups>
-  <buttongroup name="verticalSpeed"/>
   <buttongroup name="buttonGroup_2"/>
   <buttongroup name="buttonGroup_3"/>
   <buttongroup name="buttonGroup_4"/>
   <buttongroup name="buttonGroup_5"/>
   <buttongroup name="buttonGroup_6"/>
+  <buttongroup name="verticalSpeed"/>
   <buttongroup name="buttonGroup"/>
  </buttongroups>
 </ui>
-- 
2.0.1

From 8bd135e043af18762aa57e4a42e6c90b1f412e76 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 16 Jul 2014 19:05:49 -0300
Subject: [PATCH 3/4] Complete the name of the first Cylinder on edit

When you entered part of the name of a cylinder this was
being treated as a new cylinder, and not selecting the first
one.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/modeldelegates.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index add853c..3d99177 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -222,18 +222,19 @@ void TankInfoDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
 	TankInfoModel *tanks = TankInfoModel::instance();
 	QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText);
 	int row;
+	QString cylinderName = currCombo.activeText;
 	if (matches.isEmpty()) {
-		// we need to add this
 		tanks->insertRows(tanks->rowCount(), 1);
 		tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText);
 		row = tanks->rowCount() - 1;
 	} else {
 		row = matches.first().row();
+		cylinderName = matches.first().data().toString();
 	}
 	int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt();
 	int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt();
 
-	mymodel->setData(IDX(CylindersModel::TYPE), currCombo.activeText, Qt::EditRole);
+	mymodel->setData(IDX(CylindersModel::TYPE), cylinderName, Qt::EditRole);
 	mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure);
 	mymodel->passInData(IDX(CylindersModel::SIZE), tankSize);
 }
-- 
2.0.1

From 2df9415ef8d14c82e6c4bb484057f6096db328b3 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Wed, 16 Jul 2014 19:10:23 -0300
Subject: [PATCH 4/4] Fixed creating recursion on the connections

Ugh. Each time you wanted to change a cylinder, a new connection was
being created on this object, delaying the correctly setup of the item.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/modeldelegates.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qt-ui/modeldelegates.cpp b/qt-ui/modeldelegates.cpp
index 3d99177..930f055 100644
--- a/qt-ui/modeldelegates.cpp
+++ b/qt-ui/modeldelegates.cpp
@@ -66,6 +66,8 @@ ComboBoxDelegate::ComboBoxDelegate(QAbstractItemModel *model, QObject *parent) :
 {
 	connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)),
 		this, SLOT(revertModelData(QWidget *, QAbstractItemDelegate::EndEditHint)));
+	connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)),
+		this, SLOT(fixTabBehavior()));
 }
 
 void ComboBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
@@ -105,7 +107,6 @@ QWidget *ComboBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewI
 	connect(comboDelegate, SIGNAL(activated(QString)), this, SLOT(fakeActivation()));
 	connect(comboPopup, SIGNAL(entered(QModelIndex)), this, SLOT(testActivation(QModelIndex)));
 	connect(comboPopup, SIGNAL(activated(QModelIndex)), this, SLOT(fakeActivation()));
-	connect(this, SIGNAL(closeEditor(QWidget *, QAbstractItemDelegate::EndEditHint)), this, SLOT(fixTabBehavior()));
 	currCombo.comboEditor = comboDelegate;
 	currCombo.currRow = index.row();
 	currCombo.model = const_cast<QAbstractItemModel *>(index.model());
-- 
2.0.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to