From e731f07fb018b898292cd185c7519f7ca9eadbea Mon Sep 17 00:00:00 2001
From: ejno <none>
Date: Wed, 26 Jun 2013 08:48:24 +0000
Subject: [PATCH] choose lowest unused number for Untitled documents
---
src/apps/stylededit/StyledEditApp.cpp | 25 +++++++++++++++++++++++--
src/apps/stylededit/StyledEditApp.h | 1 -
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/apps/stylededit/StyledEditApp.cpp b/src/apps/stylededit/StyledEditApp.cpp
index 0460af8..4a923bb 100644
a
|
b
|
StyledEditApp::StyledEditApp()
|
128 | 128 | fOpenPanelEncodingMenu = NULL; |
129 | 129 | |
130 | 130 | fWindowCount = 0; |
131 | | fNextUntitledWindow = 1; |
132 | 131 | fBadArguments = false; |
133 | 132 | } |
134 | 133 | |
… |
… |
StyledEditApp::MessageReceived(BMessage* message)
|
168 | 167 | } |
169 | 168 | |
170 | 169 | |
| 170 | static int32 |
| 171 | GetNextUntitled() |
| 172 | { |
| 173 | int nextUntitled = 1; |
| 174 | |
| 175 | BString untitled(B_TRANSLATE("Untitled ")); |
| 176 | BString title = untitled; |
| 177 | title << nextUntitled; |
| 178 | |
| 179 | int32 numWindows = be_app->CountWindows(); |
| 180 | for (int32 i = 0; i < numWindows; i++) { |
| 181 | if (be_app->WindowAt(i)->Title() == title) |
| 182 | { |
| 183 | title = untitled; |
| 184 | title << ++nextUntitled; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | return nextUntitled; |
| 189 | } |
| 190 | |
| 191 | |
171 | 192 | void |
172 | 193 | StyledEditApp::OpenDocument() |
173 | 194 | { |
174 | 195 | cascade(); |
175 | | new StyledEditWindow(gWindowRect, fNextUntitledWindow++, fOpenAsEncoding); |
| 196 | new StyledEditWindow(gWindowRect, GetNextUntitled(), fOpenAsEncoding); |
176 | 197 | fWindowCount++; |
177 | 198 | } |
178 | 199 | |
diff --git a/src/apps/stylededit/StyledEditApp.h b/src/apps/stylededit/StyledEditApp.h
index 71f1f74..0de971f 100644
a
|
b
|
private:
|
49 | 49 | BMenu* fOpenPanelEncodingMenu; |
50 | 50 | uint32 fOpenAsEncoding; |
51 | 51 | int32 fWindowCount; |
52 | | int32 fNextUntitledWindow; |
53 | 52 | bool fBadArguments; |
54 | 53 | }; |
55 | 54 | |