• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kio/kfile
 

kio/kfile

  • kio
  • kfile
krecentdirs.cpp
1 /* -*- c++ -*-
2  * Copyright (C)2000 Waldo Bastian <bastian@kde.org>
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 #include <krecentdirs.h>
29 #include <ksimpleconfig.h>
30 #include <kstandarddirs.h>
31 #include <kglobalsettings.h>
32 
33 #define MAX_DIR_HISTORY 3
34 
35 static void recentdirs_done(KConfig *config)
36 {
37  if (config == KGlobal::config())
38  {
39  config->sync();
40  }
41  else
42  {
43  delete config;
44  }
45 }
46 
47 static KConfig *recentdirs_readList(TQString &key, TQStringList &result, bool readOnly)
48 {
49  KConfig *config;
50  if ((key.length() < 2) || (key[0] != ':'))
51  key = ":default";
52  if (key[1] == ':')
53  {
54  key = key.mid(2);
55  config = new KSimpleConfig(TQString::fromLatin1("krecentdirsrc"), readOnly);
56  }
57  else
58  {
59  key = key.mid(1);
60  config = KGlobal::config();
61  config->setGroup(TQString::fromLatin1("Recent Dirs"));
62  }
63 
64  result=config->readPathListEntry(key);
65  if (result.isEmpty())
66  {
67  result.append(KGlobalSettings::documentPath());
68  }
69  return config;
70 }
71 
72 TQStringList KRecentDirs::list(const TQString &fileClass)
73 {
74  TQString key = fileClass;
75  TQStringList result;
76  recentdirs_done(recentdirs_readList(key, result, true));
77  return result;
78 }
79 
80 TQString KRecentDirs::dir(const TQString &fileClass)
81 {
82  TQStringList result = list(fileClass);
83  return result[0];
84 }
85 
86 void KRecentDirs::add(const TQString &fileClass, const TQString &directory)
87 {
88  TQString key = fileClass;
89  TQStringList result;
90  KConfig *config = recentdirs_readList(key, result, false);
91  // make sure the dir is first in history
92  result.remove(directory);
93  result.prepend(directory);
94  while(result.count() > MAX_DIR_HISTORY)
95  result.remove(result.fromLast());
96  config->writePathEntry(key, result);
97  recentdirs_done(config);
98 }
99 

kio/kfile

Skip menu "kio/kfile"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

kio/kfile

Skip menu "kio/kfile"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kio/kfile by doxygen 1.8.3.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |