french -> French
[kdepim.git] / knode / utilities.h
blobd5017fa57411cbbc2a770ec4f209d2611b7b695a
1 /*
2 KNode, the KDE newsreader
3 Copyright (c) 1999-2005 the KNode authors.
4 See file AUTHORS for details
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 You should have received a copy of the GNU General Public License
11 along with this program; if not, write to the Free Software Foundation,
12 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
15 #ifndef UTILITIES_H
16 #define UTILITIES_H
18 #include <kurl.h>
20 class KTemporaryFile;
21 class QFile;
23 //*****************************************************************************
24 // utility classes
25 //*****************************************************************************
28 /** File save helper (includes file save dialog and network upload). */
29 class KNSaveHelper {
31 public:
33 KNSaveHelper(QString saveName, QWidget *parent);
34 ~KNSaveHelper();
36 /** returns a file open for writing */
37 QFile* getFile(const QString &dialogTitle);
39 private:
41 QWidget *p_arent;
42 QString s_aveName;
43 KUrl url;
44 QFile* file;
45 KTemporaryFile* tmpFile;
46 static QString lastPath;
51 //========================================================================================
54 /** File open helper (includes file open dialog and network download). */
55 class KNLoadHelper {
57 public:
59 explicit KNLoadHelper(QWidget *parent);
60 ~KNLoadHelper();
62 /** opens a file dialog and returns a file open for reading */
63 QFile* getFile( const QString &dialogTitle );
64 /** tries to access the file specified by the url and returns
65 a file open for reading */
66 QFile* setURL(const KUrl& url);
67 /** returns the file after getFile(QString) of setURL(url) was called */
68 QFile* getFile()const { return f_ile; }
69 KUrl getURL() const { return u_rl; }
71 private:
73 QWidget *p_arent;
74 KUrl u_rl;
75 QFile *f_ile;
76 QString t_empName;
77 static KUrl l_astPath;
82 //========================================================================================
85 /** Some static helper methods. */
86 class KNHelper {
88 public:
90 /** list selection dialog, used instead of a popup menu
91 when a select action is called via the keyboard.
92 returns -1 when the user canceled the dialog. */
93 static int selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue);
95 static void saveWindowSize(const QString &name, const QSize &s);
96 static void restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize);
98 static const QString encryptStr(const QString& aStr);
99 static const QString decryptStr(const QString& aStr);
101 /** used for rewarping a text when replying to a message or inserting a file into a box */
102 static QString rewrapStringList(const QStringList &text, int wrapAt, QChar quoteChar, bool stopAtSig, bool alwaysSpace);
104 /** use this for all internal files */
105 static void displayInternalFileError(QWidget *w=0);
106 /** use this for all external files */
107 static void displayExternalFileError(QWidget *w=0);
108 /** use this for remote files */
109 static void displayRemoteFileError(QWidget *w=0);
110 /** use this for error on temporary files */
111 static void displayTempFileError(QWidget *w=0);
113 /** Searches for the string from the current file position. Returns -1 if
114 * the string wasn't found.
116 static int findStringInFile( QFile *file, const char *str );
120 #endif