* Fixed search history: chicken and egg problem - it couldn't save the history
if it couldn't load it. * Shortened license text. * Automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33693 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,24 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1998-2007 Matthijs Hollemans
|
* Copyright (c) 1998-2007 Matthijs Hollemans
|
||||||
*
|
* Distributed under the terms of the MIT License.
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
||||||
* copy of this software and associated documentation files (the "Software"),
|
|
||||||
* to deal in the Software without restriction, including without limitation
|
|
||||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
||||||
* and/or sell copies of the Software, and to permit persons to whom the
|
|
||||||
* Software is furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
||||||
* DEALINGS IN THE SOFTWARE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "Model.h"
|
#include "Model.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
@@ -42,25 +27,26 @@ using std::nothrow;
|
|||||||
|
|
||||||
|
|
||||||
Model::Model()
|
Model::Model()
|
||||||
: fDirectory(),
|
:
|
||||||
fSelectedFiles(0UL),
|
fDirectory(),
|
||||||
|
fSelectedFiles(0UL),
|
||||||
|
|
||||||
fRecurseDirs(true),
|
fRecurseDirs(true),
|
||||||
fRecurseLinks(false),
|
fRecurseLinks(false),
|
||||||
fSkipDotDirs(true),
|
fSkipDotDirs(true),
|
||||||
fCaseSensitive(false),
|
fCaseSensitive(false),
|
||||||
fEscapeText(true),
|
fEscapeText(true),
|
||||||
fTextOnly(true),
|
fTextOnly(true),
|
||||||
fInvokePe(false),
|
fInvokePe(false),
|
||||||
fShowContents(false),
|
fShowContents(false),
|
||||||
|
|
||||||
fFrame(100, 100, 500, 400),
|
fFrame(100, 100, 500, 400),
|
||||||
|
|
||||||
fState(STATE_IDLE),
|
fState(STATE_IDLE),
|
||||||
|
|
||||||
fFilePanelPath(""),
|
fFilePanelPath(""),
|
||||||
|
|
||||||
fEncoding(0)
|
fEncoding(0)
|
||||||
{
|
{
|
||||||
BPath path;
|
BPath path;
|
||||||
if (find_directory(B_USER_DIRECTORY, &path) == B_OK)
|
if (find_directory(B_USER_DIRECTORY, &path) == B_OK)
|
||||||
@@ -106,16 +92,13 @@ Model::LoadPrefs()
|
|||||||
sizeof(int32)) > 0)
|
sizeof(int32)) > 0)
|
||||||
fCaseSensitive = (value != 0);
|
fCaseSensitive = (value != 0);
|
||||||
|
|
||||||
if (file.ReadAttr("EscapeText", B_INT32_TYPE, 0, &value,
|
if (file.ReadAttr("EscapeText", B_INT32_TYPE, 0, &value, sizeof(int32)) > 0)
|
||||||
sizeof(int32)) > 0)
|
|
||||||
fEscapeText = (value != 0);
|
fEscapeText = (value != 0);
|
||||||
|
|
||||||
if (file.ReadAttr("TextOnly", B_INT32_TYPE, 0, &value,
|
if (file.ReadAttr("TextOnly", B_INT32_TYPE, 0, &value, sizeof(int32)) > 0)
|
||||||
sizeof(int32)) > 0)
|
|
||||||
fTextOnly = (value != 0);
|
fTextOnly = (value != 0);
|
||||||
|
|
||||||
if (file.ReadAttr("InvokePe", B_INT32_TYPE, 0, &value,
|
if (file.ReadAttr("InvokePe", B_INT32_TYPE, 0, &value, sizeof(int32)) > 0)
|
||||||
sizeof(int32)) > 0)
|
|
||||||
fInvokePe = (value != 0);
|
fInvokePe = (value != 0);
|
||||||
|
|
||||||
if (file.ReadAttr("ShowContents", B_INT32_TYPE, 0, &value,
|
if (file.ReadAttr("ShowContents", B_INT32_TYPE, 0, &value,
|
||||||
@@ -199,8 +182,7 @@ void
|
|||||||
Model::AddToHistory(const char* text)
|
Model::AddToHistory(const char* text)
|
||||||
{
|
{
|
||||||
BList items;
|
BList items;
|
||||||
if (!_LoadHistory(items))
|
_LoadHistory(items);
|
||||||
return;
|
|
||||||
|
|
||||||
BString* string = new (nothrow) BString(text);
|
BString* string = new (nothrow) BString(text);
|
||||||
if (string == NULL || !items.AddItem(string)) {
|
if (string == NULL || !items.AddItem(string)) {
|
||||||
@@ -287,9 +269,8 @@ Model::_SaveHistory(const BList& items) const
|
|||||||
{
|
{
|
||||||
BFile file;
|
BFile file;
|
||||||
status_t status = _OpenFile(&file, PREFS_FILE,
|
status_t status = _OpenFile(&file, PREFS_FILE,
|
||||||
B_CREATE_FILE | B_WRITE_ONLY,
|
B_CREATE_FILE | B_WRITE_ONLY | B_ERASE_FILE,
|
||||||
B_USER_SETTINGS_DIRECTORY, NULL);
|
B_USER_SETTINGS_DIRECTORY, NULL);
|
||||||
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user