[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haiku-commits
Subject:    [Haiku-commits] r29824 - haiku/trunk/src/preferences/keymap
From:       axeld () mail ! berlios ! de
Date:       2009-03-31 14:39:17
Message-ID: 200903311439.n2VEdH0n000328 () sheep ! berlios ! de
[Download RAW message or body]

Author: axeld
Date: 2009-03-31 16:39:15 +0200 (Tue, 31 Mar 2009)
New Revision: 29824
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=29824&view=rev

Modified:
   haiku/trunk/src/preferences/keymap/Keymap.cpp
   haiku/trunk/src/preferences/keymap/Keymap.h
   haiku/trunk/src/preferences/keymap/KeymapWindow.cpp
Log:
* Added Keymap::operator=().


Modified: haiku/trunk/src/preferences/keymap/Keymap.cpp
===================================================================
--- haiku/trunk/src/preferences/keymap/Keymap.cpp	2009-03-31 14:38:44 UTC (rev 29823)
+++ haiku/trunk/src/preferences/keymap/Keymap.cpp	2009-03-31 14:39:15 UTC (rev 29824)
@@ -609,6 +609,29 @@
 }
 
 
+Keymap&
+Keymap::operator=(const Keymap& other)
+{
+	delete[] fChars;
+	delete fModificationMessage;
+
+	fChars = new(std::nothrow) char[other.fCharsSize];
+	if (fChars != NULL) {
+		memcpy(fChars, other.fChars, other.fCharsSize);
+		fCharsSize = other.fCharsSize;
+	} else
+		fCharsSize = 0;
+
+	memcpy(&fKeys, &other.fKeys, sizeof(key_map));
+	strlcpy(fName, other.fName, sizeof(fName));
+
+	fTarget = other.fTarget;
+
+	if (other.fModificationMessage != NULL)
+		fModificationMessage = new BMessage(*other.fModificationMessage);
+}
+
+
 int32
 Keymap::_Offset(uint32 keyCode, uint32 modifiers, uint32* _table)
 {

Modified: haiku/trunk/src/preferences/keymap/Keymap.h
===================================================================
--- haiku/trunk/src/preferences/keymap/Keymap.h	2009-03-31 14:38:44 UTC (rev 29823)
+++ haiku/trunk/src/preferences/keymap/Keymap.h	2009-03-31 14:39:15 UTC (rev 29824)
@@ -49,6 +49,8 @@
 			const key_map&	Map() const { return fKeys; }
 			key_map&		Map() { return fKeys; }
 
+			Keymap&			operator=(const Keymap& other);
+
 private:
 			int32			_Offset(uint32 keyCode, uint32 modifiers,
 								uint32* _table = NULL);
@@ -63,4 +65,4 @@
 };
 
 
-#endif //KEYMAP_H
+#endif	// KEYMAP_H

Modified: haiku/trunk/src/preferences/keymap/KeymapWindow.cpp
===================================================================
--- haiku/trunk/src/preferences/keymap/KeymapWindow.cpp	2009-03-31 14:38:44 UTC (rev 29823)
+++ haiku/trunk/src/preferences/keymap/KeymapWindow.cpp	2009-03-31 14:39:15 UTC (rev 29824)
@@ -95,8 +95,6 @@
 
 	_UpdateButtons();
 
-	fCurrentMap.SetTarget(this, new BMessage(kMsgKeymapUpdated));
-
 	// Make sure the user keymap directory exists
 	BPath path;
 	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
@@ -150,8 +148,9 @@
 		= static_cast<KeymapListItem*>(fUserListView->FirstItem());
 
 	fCurrentMap.Load(current->EntryRef());
-	fPreviousMap.Load(current->EntryRef());
-	fAppliedMap.Load(current->EntryRef());
+	fPreviousMap = fCurrentMap;
+	fAppliedMap = fCurrentMap;
+	fCurrentMap.SetTarget(this, new BMessage(kMsgKeymapUpdated));
 
 	_UpdateShortcutButton();
 
@@ -506,10 +505,9 @@
 	}
 
 	fPreviousMap.Use();
-	fAppliedMap.Load(ref);
-
-	// TODO: add = operator
 	fCurrentMap.Load(ref);
+	fAppliedMap = fCurrentMap;
+
 	fKeyboardLayoutView->SetKeymap(&fCurrentMap);
 
 	fCurrentMapName = _GetActiveKeymapName();

_______________________________________________
Haiku-commits mailing list
Haiku-commits@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/haiku-commits
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic