diff options
author | Bibiko <bibiko@eva.mpg.de> | 2009-09-04 17:40:56 +0000 |
---|---|---|
committer | Bibiko <bibiko@eva.mpg.de> | 2009-09-04 17:40:56 +0000 |
commit | 9683c9df3cb0b1128429f42f108d4e03ca4550f1 (patch) | |
tree | e1ed970699a4d71e7dce31247ef45cc7c17e0810 | |
parent | e00013ffbf5fb252a11fc6e2c68a1af0b9886317 (diff) | |
download | sequelpro-9683c9df3cb0b1128429f42f108d4e03ca4550f1.tar.gz sequelpro-9683c9df3cb0b1128429f42f108d4e03ca4550f1.tar.bz2 sequelpro-9683c9df3cb0b1128429f42f108d4e03ca4550f1.zip |
• improved behavior while closing a document window
- if not connected close it without any checks
- if an Untitled document contains stored query favorites - What should be done? - up to now it saves them to the global prefs
• header in query favorites list keep visible while filtering
• code cleaning
-rw-r--r-- | Interfaces/English.lproj/DBView.xib | 74 | ||||
-rw-r--r-- | Source/CustomQuery.h | 26 | ||||
-rw-r--r-- | Source/CustomQuery.m | 55 | ||||
-rw-r--r-- | Source/TableDocument.m | 27 |
4 files changed, 85 insertions, 97 deletions
diff --git a/Interfaces/English.lproj/DBView.xib b/Interfaces/English.lproj/DBView.xib index 4e1298ea..6ac089b9 100644 --- a/Interfaces/English.lproj/DBView.xib +++ b/Interfaces/English.lproj/DBView.xib @@ -46,7 +46,7 @@ <string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string> <string key="NSWindowContentMinSize">{780, 480}</string> <object class="NSView" key="NSWindowView" id="579726586"> - <reference key="NSNextResponder"/> + <nil key="NSNextResponder"/> <int key="NSvFlags">256</int> <object class="NSMutableArray" key="NSSubviews"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -100,7 +100,6 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{5, 2}, {202, 19}}</string> <reference key="NSSuperview" ref="643201879"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSSearchFieldCell" key="NSCell" id="134854992"> <int key="NSCellFlags">343014976</int> @@ -181,13 +180,11 @@ </object> <string key="NSFrameSize">{212, 26}</string> <reference key="NSSuperview" ref="588922296"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> </object> <string key="NSFrameSize">{212, 26}</string> <reference key="NSSuperview" ref="199860064"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="643201879"/> <reference key="NSDocView" ref="643201879"/> <object class="NSColor" key="NSBGColor" id="529261656"> @@ -206,7 +203,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{-100, -100}, {15, 94}}</string> <reference key="NSSuperview" ref="199860064"/> - <reference key="NSWindow"/> <reference key="NSTarget" ref="199860064"/> <string key="NSAction">_doScroller:</string> <double key="NSCurValue">1.000000e+00</double> @@ -217,7 +213,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{-100, -100}, {166, 15}}</string> <reference key="NSSuperview" ref="199860064"/> - <reference key="NSWindow"/> <int key="NSsFlags">1</int> <reference key="NSTarget" ref="199860064"/> <string key="NSAction">_doScroller:</string> @@ -226,7 +221,6 @@ </object> <string key="NSFrameSize">{212, 26}</string> <reference key="NSSuperview" ref="801427893"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="588922296"/> <int key="NSsFlags">0</int> <reference key="NSVScroller" ref="540853896"/> @@ -236,7 +230,6 @@ </object> <string key="NSFrameSize">{212, 26}</string> <reference key="NSSuperview" ref="213762440"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="BWCustomView" id="1017775084"> @@ -259,7 +252,6 @@ <int key="NSvFlags">4352</int> <string key="NSFrameSize">{212, 354}</string> <reference key="NSSuperview" ref="73685676"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="_NSCornerView" key="NSCornerView"> <nil key="NSNextResponder"/> @@ -344,7 +336,6 @@ </object> <string key="NSFrameSize">{212, 354}</string> <reference key="NSSuperview" ref="233472824"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="251040077"/> <reference key="NSDocView" ref="251040077"/> <object class="NSColor" key="NSBGColor" id="1024678221"> @@ -360,7 +351,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{197, 0}, {15, 292}}</string> <reference key="NSSuperview" ref="233472824"/> - <reference key="NSWindow"/> <reference key="NSTarget" ref="233472824"/> <string key="NSAction">_doScroller:</string> <double key="NSPercent">9.965870e-01</double> @@ -370,7 +360,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{-100, -100}, {141, 11}}</string> <reference key="NSSuperview" ref="233472824"/> - <reference key="NSWindow"/> <int key="NSsFlags">257</int> <reference key="NSTarget" ref="233472824"/> <string key="NSAction">_doScroller:</string> @@ -379,7 +368,6 @@ </object> <string key="NSFrameSize">{212, 354}</string> <reference key="NSSuperview" ref="1017775084"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="73685676"/> <int key="NSsFlags">528</int> <reference key="NSVScroller" ref="693168867"/> @@ -390,13 +378,11 @@ </object> <string key="NSFrame">{{0, 27}, {212, 354}}</string> <reference key="NSSuperview" ref="213762440"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> </object> <string key="NSFrameSize">{212, 381}</string> <reference key="NSSuperview" ref="131633443"/> - <reference key="NSWindow"/> <int key="NSDividerStyle">2</int> <reference key="BWSVColor" ref="529261656"/> <bool key="BWSVColorIsEnabled">YES</bool> @@ -422,7 +408,6 @@ </object> <string key="NSFrameSize">{212, 381}</string> <reference key="NSSuperview" ref="298095498"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="BWCustomView" id="192579410"> @@ -445,7 +430,6 @@ <int key="NSvFlags">4352</int> <string key="NSFrameSize">{212, 145}</string> <reference key="NSSuperview" ref="685057119"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="_NSCornerView" key="NSCornerView"> <nil key="NSNextResponder"/> @@ -509,7 +493,6 @@ </object> <string key="NSFrameSize">{212, 145}</string> <reference key="NSSuperview" ref="298226231"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="347093764"/> <reference key="NSDocView" ref="347093764"/> <reference key="NSBGColor" ref="1024678221"/> @@ -520,7 +503,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{-100, -100}, {15, 20}}</string> <reference key="NSSuperview" ref="298226231"/> - <reference key="NSWindow"/> <reference key="NSTarget" ref="298226231"/> <string key="NSAction">_doScroller:</string> <double key="NSPercent">9.473684e-01</double> @@ -530,7 +512,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{-100, -100}, {141, 11}}</string> <reference key="NSSuperview" ref="298226231"/> - <reference key="NSWindow"/> <int key="NSsFlags">257</int> <reference key="NSTarget" ref="298226231"/> <string key="NSAction">_doScroller:</string> @@ -539,7 +520,6 @@ </object> <string key="NSFrameSize">{212, 145}</string> <reference key="NSSuperview" ref="192579410"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="685057119"/> <int key="NSsFlags">512</int> <reference key="NSVScroller" ref="245346414"/> @@ -550,13 +530,11 @@ </object> <string key="NSFrame">{{0, 382}, {212, 145}}</string> <reference key="NSSuperview" ref="298095498"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> </object> <string key="NSFrame">{{0, 23}, {212, 527}}</string> <reference key="NSSuperview" ref="372294785"/> - <reference key="NSWindow"/> <int key="NSDividerStyle">2</int> <reference key="BWSVColor" ref="304829493"/> <bool key="BWSVColorIsEnabled">NO</bool> @@ -607,7 +585,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{-1, -1}, {32, 24}}</string> <reference key="NSSuperview" ref="28219887"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="BWAnchoredButtonCell" key="NSCell" id="283448047"> <int key="NSCellFlags">67239424</int> @@ -632,7 +609,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{30, -1}, {32, 24}}</string> <reference key="NSSuperview" ref="28219887"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="BWAnchoredPopUpButtonCell" key="NSCell" id="321871356"> <int key="NSCellFlags">71433792</int> @@ -742,7 +718,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{61, -1}, {32, 24}}</string> <reference key="NSSuperview" ref="28219887"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="BWAnchoredButtonCell" key="NSCell" id="227511715"> <int key="NSCellFlags">67239424</int> @@ -767,7 +742,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{92, -1}, {32, 24}}</string> <reference key="NSSuperview" ref="28219887"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="BWAnchoredButtonCell" key="NSCell" id="708016222"> <int key="NSCellFlags">-2080244224</int> @@ -794,7 +768,6 @@ </object> <string key="NSFrameSize">{212, 23}</string> <reference key="NSSuperview" ref="372294785"/> - <reference key="NSWindow"/> <bool key="BWABBIsResizable">YES</bool> <bool key="BWABBIsAtBottom">YES</bool> <bool key="BWABBHandleIsRightAligned">NO</bool> @@ -803,7 +776,6 @@ </object> <string key="NSFrameSize">{212, 550}</string> <reference key="NSSuperview" ref="937377983"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="NSCustomView" id="604818293"> @@ -816,7 +788,6 @@ <int key="NSvFlags">274</int> <string key="NSFrame">{{-7, -10}, {735, 564}}</string> <reference key="NSSuperview" ref="604818293"/> - <reference key="NSWindow"/> <object class="NSMutableArray" key="NSTabViewItems"> <bool key="EncodedWithXMLCoder">YES</bool> <object class="NSTabViewItem" id="831053945"> @@ -2915,7 +2886,6 @@ </object> <string key="NSFrameSize">{688, 14}</string> <reference key="NSSuperview" ref="1072692119"/> - <reference key="NSWindow"/> <object class="NSTextContainer" key="NSTextContainer" id="326170846"> <object class="NSLayoutManager" key="NSLayoutManager"> <object class="NSTextStorage" key="NSTextStorage"> @@ -2974,7 +2944,6 @@ </object> <string key="NSFrame">{{1, 1}, {688, 155}}</string> <reference key="NSSuperview" ref="71560786"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="1055190999"/> <reference key="NSDocView" ref="1055190999"/> <reference key="NSBGColor" ref="449903125"/> @@ -2989,7 +2958,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{598, 1}, {15, 68}}</string> <reference key="NSSuperview" ref="71560786"/> - <reference key="NSWindow"/> <reference key="NSTarget" ref="71560786"/> <string key="NSAction">_doScroller:</string> <double key="NSCurValue">1.000000e+00</double> @@ -2999,7 +2967,6 @@ <int key="NSvFlags">256</int> <string key="NSFrame">{{-100, -100}, {601, 11}}</string> <reference key="NSSuperview" ref="71560786"/> - <reference key="NSWindow"/> <int key="NSsFlags">257</int> <reference key="NSTarget" ref="71560786"/> <string key="NSAction">_doScroller:</string> @@ -3009,7 +2976,6 @@ </object> <string key="NSFrameSize">{690, 157}</string> <reference key="NSSuperview" ref="873437769"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="1072692119"/> <int key="NSsFlags">530</int> <reference key="NSVScroller" ref="413233170"/> @@ -3019,7 +2985,6 @@ </object> <string key="NSFrameSize">{690, 156}</string> <reference key="NSSuperview" ref="894339536"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="NSCustomView" id="345834048"> @@ -3042,14 +3007,12 @@ <int key="NSvFlags">4352</int> <string key="NSFrameSize">{688, 228}</string> <reference key="NSSuperview" ref="90844306"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTableHeaderView" key="NSHeaderView" id="1038415606"> <reference key="NSNextResponder" ref="533922066"/> <int key="NSvFlags">256</int> <string key="NSFrameSize">{688, 17}</string> <reference key="NSSuperview" ref="533922066"/> - <reference key="NSWindow"/> <reference key="NSTableView" ref="581095761"/> </object> <object class="_NSCornerView" key="NSCornerView" id="151074124"> @@ -3057,7 +3020,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{-26, 0}, {16, 17}}</string> <reference key="NSSuperview" ref="678281118"/> - <reference key="NSWindow"/> </object> <object class="NSMutableArray" key="NSTableColumns"> <bool key="EncodedWithXMLCoder">YES</bool> @@ -3101,7 +3063,6 @@ </object> <string key="NSFrame">{{1, 17}, {688, 228}}</string> <reference key="NSSuperview" ref="678281118"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="581095761"/> <reference key="NSDocView" ref="581095761"/> <reference key="NSBGColor" ref="1024678221"/> @@ -3112,7 +3073,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{611, 17}, {15, 30}}</string> <reference key="NSSuperview" ref="678281118"/> - <reference key="NSWindow"/> <reference key="NSTarget" ref="678281118"/> <string key="NSAction">_doScroller:</string> <double key="NSPercent">9.375000e-01</double> @@ -3122,7 +3082,6 @@ <int key="NSvFlags">-2147483392</int> <string key="NSFrame">{{1, 47}, {610, 15}}</string> <reference key="NSSuperview" ref="678281118"/> - <reference key="NSWindow"/> <int key="NSsFlags">1</int> <reference key="NSTarget" ref="678281118"/> <string key="NSAction">_doScroller:</string> @@ -3137,7 +3096,6 @@ </object> <string key="NSFrame">{{1, 0}, {688, 17}}</string> <reference key="NSSuperview" ref="678281118"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="1038415606"/> <reference key="NSDocView" ref="1038415606"/> <reference key="NSBGColor" ref="1024678221"/> @@ -3147,7 +3105,6 @@ </object> <string key="NSFrameSize">{690, 246}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <reference key="NSNextKeyView" ref="90844306"/> <int key="NSsFlags">562</int> <reference key="NSVScroller" ref="472831765"/> @@ -3162,7 +3119,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{156, 246}, {98, 22}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="830957297"> <int key="NSCellFlags">-2076049856</int> @@ -3222,7 +3178,6 @@ <int key="NSvFlags">264</int> <string key="NSFrame">{{38, 246}, {108, 22}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="416049103"> <int key="NSCellFlags">-2076049856</int> @@ -3325,7 +3280,6 @@ <int key="NSvFlags">268</int> <string key="NSFrame">{{-10, 245}, {46, 25}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSPopUpButtonCell" key="NSCell" id="984501775"> <int key="NSCellFlags">-2076049856</int> @@ -3619,7 +3573,6 @@ <int key="NSvFlags">265</int> <string key="NSFrame">{{591, 248}, {90, 17}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="177866566"> <int key="NSCellFlags">-2080244224</int> @@ -3641,7 +3594,6 @@ <int key="NSvFlags">265</int> <string key="NSFrame">{{473, 248}, {110, 17}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSButtonCell" key="NSCell" id="588489390"> <int key="NSCellFlags">604110336</int> @@ -3674,7 +3626,6 @@ </object> <string key="NSFrame">{{32, 246}, {658, 23}}</string> <reference key="NSSuperview" ref="345834048"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSImageCell" key="NSCell" id="76236597"> <int key="NSCellFlags">130560</int> @@ -3690,7 +3641,6 @@ </object> <string key="NSFrame">{{0, 165}, {690, 269}}</string> <reference key="NSSuperview" ref="894339536"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> <object class="NSCustomView" id="875002707"> @@ -3703,7 +3653,6 @@ <int key="NSvFlags">266</int> <string key="NSFrame">{{242, 64}, {431, 17}}</string> <reference key="NSSuperview" ref="875002707"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="401235649"> <int key="NSCellFlags">67239424</int> @@ -3720,7 +3669,6 @@ <int key="NSvFlags">264</int> <string key="NSFrame">{{17, 67}, {143, 14}}</string> <reference key="NSSuperview" ref="875002707"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="194978207"> <int key="NSCellFlags">67239424</int> @@ -3737,7 +3685,6 @@ <int key="NSvFlags">274</int> <string key="NSFrame">{{17, 20}, {656, 43}}</string> <reference key="NSSuperview" ref="875002707"/> - <reference key="NSWindow"/> <bool key="NSEnabled">YES</bool> <object class="NSTextFieldCell" key="NSCell" id="948571736"> <int key="NSCellFlags">67239424</int> @@ -3752,18 +3699,15 @@ </object> <string key="NSFrame">{{0, 443}, {690, 87}}</string> <reference key="NSSuperview" ref="894339536"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> </object> <string key="NSFrame">{{6, 10}, {690, 530}}</string> <reference key="NSSuperview" ref="746504912"/> - <reference key="NSWindow"/> </object> </object> <string key="NSFrame">{{10, 7}, {700, 544}}</string> <reference key="NSSuperview" ref="714795046"/> - <reference key="NSWindow"/> </object> <string key="NSLabel">Custom Query</string> <reference key="NSColor" ref="62854682"/> @@ -4816,20 +4760,16 @@ </object> <string key="NSFrame">{{221, 0}, {723, 550}}</string> <reference key="NSSuperview" ref="937377983"/> - <reference key="NSWindow"/> <string key="NSClassName">NSView</string> </object> </object> <string key="NSFrameSize">{944, 550}</string> <reference key="NSSuperview" ref="579726586"/> - <reference key="NSWindow"/> <bool key="NSIsVertical">YES</bool> <string key="NSAutosaveName">DBViewSplitter</string> </object> </object> <string key="NSFrameSize">{944, 550}</string> - <reference key="NSSuperview"/> - <reference key="NSWindow"/> </object> <string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string> <string key="NSMinSize">{780, 502}</string> @@ -15565,6 +15505,14 @@ IGRvIHlvdSB3YW50IHRvIGFkZCBmb3IgdGhpcyBmaWVsZD8</string> </object> <int key="connectionID">6518</int> </object> + <object class="IBConnectionRecord"> + <object class="IBOutletConnection" key="connection"> + <string key="label">queryFavoritesSaveAllMenuItem</string> + <reference key="source" ref="601471102"/> + <reference key="destination" ref="336702336"/> + </object> + <int key="connectionID">6519</int> + </object> </object> <object class="IBMutableOrderedSet" key="objectRecords"> <object class="NSArray" key="orderedObjects"> @@ -25221,7 +25169,7 @@ dXJyZW50IHF1ZXJ5IG9yIHNlbGVjdGlvbi4</string> </object> </object> <nil key="sourceID"/> - <int key="maxID">6518</int> + <int key="maxID">6519</int> </object> <object class="IBClassDescriber" key="IBDocument.Classes"> <object class="NSMutableArray" key="referencedPartialClassDescriptions"> @@ -26624,6 +26572,7 @@ dXJyZW50IHF1ZXJ5IG9yIHNlbGVjdGlvbi4</string> <string>multipleLineEditingButton</string> <string>queryFavoriteNameTextField</string> <string>queryFavoritesButton</string> + <string>queryFavoritesSaveAllMenuItem</string> <string>queryFavoritesSaveAsMenuItem</string> <string>queryFavoritesSearchField</string> <string>queryFavoritesSearchFieldView</string> @@ -26670,6 +26619,7 @@ dXJyZW50IHF1ZXJ5IG9yIHNlbGVjdGlvbi4</string> <string>NSTextField</string> <string>id</string> <string>NSMenuItem</string> + <string>NSMenuItem</string> <string>NSSearchField</string> <string>id</string> <string>NSMenuItem</string> diff --git a/Source/CustomQuery.h b/Source/CustomQuery.h index 9d1559e6..a9d4f670 100644 --- a/Source/CustomQuery.h +++ b/Source/CustomQuery.h @@ -32,6 +32,20 @@ #import "RegexKitLite.h" #define SP_HELP_TOC_SEARCH_STRING @"contents" +#define SP_HELP_SEARCH_IN_MYSQL 0 +#define SP_HELP_SEARCH_IN_PAGE 1 +#define SP_HELP_SEARCH_IN_WEB 2 +#define SP_HELP_GOBACK_BUTTON 0 +#define SP_HELP_SHOW_TOC_BUTTON 1 +#define SP_HELP_GOFORWARD_BUTTON 2 +#define SP_HELP_NOT_AVAILABLE @"__no_help_available" + +#define SP_MYSQL_DEV_SEARCH_URL @"http://search.mysql.com/search?q=%@&site=refman-%@" + +#define SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG 100001 +#define SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG 100000 +#define SP_FAVORITE_HEADER_MENUITEM_TAG 200000 + @class SPQueryFavoriteManager; @@ -43,8 +57,15 @@ IBOutlet id queryFavoritesButton; IBOutlet NSMenuItem *queryFavoritesSearchMenuItem; IBOutlet NSMenuItem *queryFavoritesSaveAsMenuItem; + IBOutlet NSMenuItem *queryFavoritesSaveAllMenuItem; IBOutlet id queryFavoritesSearchFieldView; IBOutlet NSSearchField *queryFavoritesSearchField; + + IBOutlet NSWindow *queryFavoritesSheet; + IBOutlet NSButton *saveQueryFavoriteButton; + IBOutlet NSTextField *queryFavoriteNameTextField; + IBOutlet id saveQueryFavoriteGlobal; + IBOutlet id queryHistoryButton; IBOutlet NSMenuItem *queryHistorySearchMenuItem; IBOutlet id queryHistorySearchFieldView; @@ -73,11 +94,6 @@ IBOutlet NSMenuItem *commentCurrentQueryMenuItem; IBOutlet NSMenuItem *commentLineOrSelectionMenuItem; - IBOutlet NSWindow *queryFavoritesSheet; - IBOutlet NSButton *saveQueryFavoriteButton; - IBOutlet NSTextField *queryFavoriteNameTextField; - IBOutlet id saveQueryFavoriteGlobal; - IBOutlet NSWindow *helpWebViewWindow; IBOutlet WebView *helpWebView; IBOutlet NSSearchField *helpSearchField; diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 67741669..155113d9 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -40,15 +40,6 @@ #import "SPQueryFavoriteManager.h" #import "SPQueryController.h" -#define SP_MYSQL_DEV_SEARCH_URL @"http://search.mysql.com/search?q=%@&site=refman-%@" -#define SP_HELP_SEARCH_IN_MYSQL 0 -#define SP_HELP_SEARCH_IN_PAGE 1 -#define SP_HELP_SEARCH_IN_WEB 2 -#define SP_HELP_GOBACK_BUTTON 0 -#define SP_HELP_SHOW_TOC_BUTTON 1 -#define SP_HELP_GOFORWARD_BUTTON 2 -#define SP_HELP_NOT_AVAILABLE @"__no_help_available" - @implementation CustomQuery #pragma mark IBAction methods @@ -2426,34 +2417,32 @@ // Insert new favorites and allow menu items with the same name NSMenu *menu = [queryFavoritesButton menu]; - int i = 6; - NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Global" action:NULL keyEquivalent:@""]; - [item setTag:200000]; - [item setToolTip:@"All global favorites"]; + NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:@"Document" action:NULL keyEquivalent:@""]; + [item setTag:SP_FAVORITE_HEADER_MENUITEM_TAG]; + [item setToolTip:[NSString stringWithFormat:@"‘%@’ based favorites", + [[[[tableDocumentInstance fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding] lastPathComponent]]]; [item setIndentationLevel:0]; [menu addItem:item]; [item release]; - for (NSDictionary *favorite in globalFavorites) { + for (NSDictionary *favorite in [[SPQueryController sharedQueryController] favoritesForFileURL:[tableDocumentInstance fileURL]]) { NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[favorite objectForKey:@"name"]] action:NULL keyEquivalent:@""]; - [item setTag:i++]; [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]]; [item setIndentationLevel:1]; [menu addItem:item]; [item release]; } - item = [[NSMenuItem alloc] initWithTitle:@"Document" action:NULL keyEquivalent:@""]; - [item setTag:200000]; - [item setToolTip:@"All document-based favorites"]; + item = [[NSMenuItem alloc] initWithTitle:@"Global" action:NULL keyEquivalent:@""]; + [item setTag:SP_FAVORITE_HEADER_MENUITEM_TAG]; + [item setToolTip:@"Globally stored favorites"]; [item setIndentationLevel:0]; [menu addItem:item]; [item release]; - for (NSDictionary *favorite in [[SPQueryController sharedQueryController] favoritesForFileURL:[tableDocumentInstance fileURL]]) { + for (NSDictionary *favorite in globalFavorites) { NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithString:[favorite objectForKey:@"name"]] action:NULL keyEquivalent:@""]; - [item setTag:i++]; [item setToolTip:[NSString stringWithString:[favorite objectForKey:@"query"]]]; [item setIndentationLevel:1]; [menu addItem:item]; @@ -2545,8 +2534,9 @@ */ - (BOOL)validateMenuItem:(NSMenuItem *)menuItem { - // Control "Save ... to Favorites" = tag is set to 1000 - if ( [menuItem tag] == 100000 ) { + + // Control "Save ... to Favorites" + if ( [menuItem tag] == SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG ) { if ([[textView string] length] < 1) return NO; if([textView selectedRange].length) [menuItem setTitle:NSLocalizedString(@"Save Selection to Favorites",@"Save Selection to Favorites")]; @@ -2555,14 +2545,19 @@ else [menuItem setTitle:NSLocalizedString(@"Save All to Favorites",@"Save All to Favorites")]; } - // Control "Save All to Favorites" = tag is set to 1001 - if ( [menuItem tag] == 100001 ) { + + // Control "Save All to Favorites" + if ( [menuItem tag] == SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG ) { if ([[textView string] length] < 1) return NO; } - if ( [menuItem tag] == 200000 ) { + + // Avoid selecting button list headers + if ( [menuItem tag] == SP_FAVORITE_HEADER_MENUITEM_TAG ) { return NO; } + return YES; + } @@ -2609,8 +2604,10 @@ { int i; NSMenu *menu = [queryFavoritesButton menu]; + NSString *searchPattern = [queryFavoritesSearchField stringValue]; for (i=6; i< [menu numberOfItems]; i++) - [[menu itemAtIndex:i] setHidden:(![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", [queryFavoritesSearchField stringValue]]])]; + [[menu itemAtIndex:i] setHidden:([[menu itemAtIndex:i] tag] != SP_FAVORITE_HEADER_MENUITEM_TAG + && ![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", searchPattern]])]; } @@ -2618,6 +2615,7 @@ { int i; NSMenu *menu = [queryHistoryButton menu]; + NSString *searchPattern = [queryHistorySearchField stringValue]; for (i=2; i< [menu numberOfItems]; i++) [[menu itemAtIndex:i] setHidden:(![[[menu itemAtIndex:i] title] isMatchedByRegex:[NSString stringWithFormat:@"(?i).*%@.*", [queryHistorySearchField stringValue]]])]; @@ -2625,6 +2623,11 @@ - (void)awakeFromNib { + + // Set pre-defined menu tags + [queryFavoritesSaveAsMenuItem setTag:SP_SAVE_SELECTION_FAVORTITE_MENUITEM_TAG]; + [queryFavoritesSaveAllMenuItem setTag:SP_SAVE_ALL_FAVORTITE_MENUITEM_TAG]; + // Set the structure and index view's vertical gridlines if required [customQueryView setGridStyleMask:([prefs boolForKey:@"DisplayTableViewVerticalGridlines"]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 9c56ff04..a546333a 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -1925,7 +1925,7 @@ { // Auto-save preferences to spf file based connection if([self fileURL] && [[[self fileURL] absoluteString] length] && [[[self fileURL] absoluteString] hasPrefix:@"/"]) - if(![self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]) { + if(_isConnected && ![self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]) { NSLog(@"Preference data for file ‘%@’ could not be saved.", [[[self fileURL] absoluteString] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]); NSBeep(); } @@ -2128,9 +2128,12 @@ // Update only query favourites, history, etc. by reading the file again if(saveOnlyPreferences) { - // Check for save file URL - // TODO maybe alert ? - if(![[[self fileURL] absoluteString] length] && ![[[self fileURL] absoluteString] hasPrefix:@"/"]) return NO; + // Check URL for safety reasons + if(![[[self fileURL] absoluteString] length] || ![[[self fileURL] absoluteString] hasPrefix:@"/"]) { + NSLog(@"Couldn't save data. No file URL found!"); + NSBeep(); + return NO; + } NSError *readError = nil; NSString *convError = nil; @@ -2976,13 +2979,29 @@ if ( ![tablesListInstance selectionShouldChangeInTableView:nil] ) { return NO; } else { + + if(!_isConnected) return YES; + // Auto-save spf file based connection if([self fileURL] && [[[self fileURL] absoluteString] length] && [[[self fileURL] absoluteString] hasPrefix:@"/"]) { BOOL isSaved = [self saveDocumentWithFilePath:nil inBackground:YES onlyPreferences:YES]; if(isSaved) [[SPQueryController sharedQueryController] removeRegisteredDocumentWithFileURL:[self fileURL]]; return isSaved; + + // Before removing an Untitled doc check if it contains any defined query favorites. + // If so save them globally. TODO: How to do it better ? } else if([self fileURL] && [[[self fileURL] absoluteString] length] && ![[[self fileURL] absoluteString] hasPrefix:@"/"]) { + if([[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]] count]) { + + NSMutableArray *favs = [[[NSMutableArray alloc] init] autorelease]; + [favs addObjectsFromArray:[prefs objectForKey:@"queryFavorites"]]; + [favs addObjectsFromArray:[[SPQueryController sharedQueryController] favoritesForFileURL:[self fileURL]]]; + [prefs setObject:favs forKey:@"queryFavorites"]; + + if(![prefs synchronize]) + NSLog(@"Sorry, couldn't backup query favorites from Untitled document."); + } [[SPQueryController sharedQueryController] removeRegisteredDocumentWithFileURL:[self fileURL]]; return YES; } |