• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • kdecore
  • io
ksavefile.h
Go to the documentation of this file.
1/* kate: tab-indents off; replace-tabs on; tab-width 4; remove-trailing-space on; encoding utf-8;*/
2/*
3 This file is part of the KDE libraries
4 Copyright 1999 Waldo Bastian <bastian@kde.org>
5 Copyright 2006 Jaison Lee <lee.jaison@gmail.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License version 2 as published by the Free Software Foundation.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef KSAVEFILE_H
23#define KSAVEFILE_H
24
25#include <kdecore_export.h>
26
27#include <QtCore/QFile>
28#include <QtCore/QString>
29#include <kglobal.h>
30
96class KDECORE_EXPORT KSaveFile : public QFile
97{
98public:
102 KSaveFile();
103
110 explicit KSaveFile(const QString &filename, const KComponentData &componentData = KGlobal::mainComponent()); // KDE5 TODO: remove KComponentData
111
118 virtual ~KSaveFile();
119
126 void setFileName(const QString &filename);
127
134 QString fileName() const;
135
141 QFile::FileError error() const;
142
149 QString errorString() const;
150
162 virtual bool open(OpenMode flags = QIODevice::ReadWrite);
163
169 void abort();
170
176 bool finalize();
177
202 void setDirectWriteFallback(bool enabled);
203
210 bool directWriteFallback() const;
211
225 static bool backupFile( const QString& filename,
226 const QString& backupDir = QString() );
227
239 static bool simpleBackupFile( const QString& filename,
240 const QString& backupDir = QString(),
241 const QString& backupExtension = QLatin1String( "~" ) );
242
270 static bool numberedBackupFile( const QString& filename,
271 const QString& backupDir = QString(),
272 const QString& backupExtension = QString::fromLatin1( "~" ),
273 const uint maxBackups = 10
274 );
275
276
299 static bool rcsBackupFile( const QString& filename,
300 const QString& backupDir = QString(),
301 const QString& backupMessage = QString()
302 );
303
304private:
305 Q_DISABLE_COPY(KSaveFile)
306
307 class Private;
308 Private *const d;
309};
310
311#endif
KComponentData
Per component data.
Definition kcomponentdata.h:47
KSaveFile::finalize
bool finalize()
Finalize changes to the file.
Definition ksavefile.cpp:219
KSaveFile::KSaveFile
KSaveFile()
Default constructor.
Definition ksavefile.cpp:62
KSaveFile::fileName
QString fileName() const
Returns the name of the target file.
Definition ksavefile.cpp:199
KSaveFile::open
virtual bool open(OpenMode flags=QIODevice::ReadWrite)
Open the save file.
Definition ksavefile.cpp:81
KSaveFile::error
QFile::FileError error() const
Returns the last error that occurred.
Definition ksavefile.cpp:181
KSaveFile::directWriteFallback
bool directWriteFallback() const
Returns true if the fallback solution for saving files in read-only directories is enabled.
Definition ksavefile.cpp:280
KSaveFile::errorString
QString errorString() const
Returns a human-readable description of the last error.
Definition ksavefile.cpp:190
KSaveFile::setDirectWriteFallback
void setDirectWriteFallback(bool enabled)
Allows writing over the existing file if necessary.
Definition ksavefile.cpp:275
KSaveFile::setFileName
void setFileName(const QString &filename)
Set the target filename for the save file.
Definition ksavefile.cpp:166
KSaveFile::rcsBackupFile
static bool rcsBackupFile(const QString &filename, const QString &backupDir=QString(), const QString &backupMessage=QString())
Static method to create an rcs backup file for a given filename.
Definition ksavefile.cpp:321
KSaveFile::backupFile
static bool backupFile(const QString &filename, const QString &backupDir=QString())
Static method to create a backup file before saving.
Definition ksavefile.cpp:285
KSaveFile::abort
void abort()
Discard changes without affecting the target file.
Definition ksavefile.cpp:204
KSaveFile::simpleBackupFile
static bool simpleBackupFile(const QString &filename, const QString &backupDir=QString(), const QString &backupExtension=QLatin1String("~"))
Static method to create a backup file for a given filename.
Definition ksavefile.cpp:305
KSaveFile::numberedBackupFile
static bool numberedBackupFile(const QString &filename, const QString &backupDir=QString(), const QString &backupExtension=QString::fromLatin1("~"), const uint maxBackups=10)
Static method to create a backup file for a given filename.
Definition ksavefile.cpp:388
QString
kdecore_export.h
kglobal.h
KGlobal::mainComponent
const KComponentData & mainComponent()
Returns the global component data.
Definition kglobal.cpp:145
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal