[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: fairly bad KFM bug
From: David Faure <David.Faure () insa-lyon ! fr>
Date: 1999-01-27 17:29:07
[Download RAW message or body]
> > (Sorry, no numbering, I don't see how to do it - or with a static int, we
> > can do it for the current session, which is a little better than nothing.)
>
> You could iterate over the number until QFile::exists() returns false?
Here you go (I even tested it :) ) :
Index: bookmark.cpp
===================================================================
RCS file: /home/kde/kdebase/kfm/bookmark.cpp,v
retrieving revision 1.16
diff -u -p -r1.16 bookmark.cpp
--- bookmark.cpp 1998/11/14 00:14:03 1.16
+++ bookmark.cpp 1999/01/27 17:23:02
@@ -281,14 +281,25 @@ KBookmark::KBookmark( KBookmarkManager *
m_id = g_id++;
m_pManager = _bm;
m_lstChildren.setAutoDelete( true );
- m_text = _text;
m_url = _url;
m_type = URL;
-
- m_file = _parent->file();
- m_file += "/";
- m_file += encode( _text );
- m_file += ".kdelnk";
+
+ int fileNumber = 0;
+ bool empty = (_text[0]=='\0');
+
+ do {
+ if (empty)
+ m_text.sprintf("NoTitle%d",fileNumber);
+ else
+ m_text = _text;
+
+ m_file = _parent->file();
+ m_file += "/";
+ m_file += encode( m_text );
+ m_file += ".kdelnk";
+ fileNumber++;
+ }
+ while (QFile::exists(m_file) && empty); // iterate only if _text is empty
FILE *f = fopen( m_file, "w" );
if ( f == 0L )
Problem is that for a URL with a title, saving it twice will only save it
twice to the same file (as the filename is determined by the title), but a
page with no title will be saved to two different files. Not very
consistent...
Should we number also for files that set the title ? That could be useful
if lots of different pages have the same title.
Then the '&& empty' in the while() has to be removed.
--
____________________________________________________________________
| |
| David FAURE |
| E-mail : David.Faure@insa-lyon.fr, faure@kde.org |
| http://www.insa-lyon.fr/People/AEDI/dfaure/index.html |
|____________________________________________________________________|
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic