summaryrefslogtreecommitdiffstats
path: root/knode/utilities.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /knode/utilities.h
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'knode/utilities.h')
-rw-r--r--knode/utilities.h166
1 files changed, 166 insertions, 0 deletions
diff --git a/knode/utilities.h b/knode/utilities.h
new file mode 100644
index 000000000..31f83d989
--- /dev/null
+++ b/knode/utilities.h
@@ -0,0 +1,166 @@
+/*
+ KNode, the KDE newsreader
+ Copyright (c) 1999-2005 the KNode authors.
+ See file AUTHORS for details
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, US
+*/
+
+#ifndef UTILITIES_H
+#define UTILITIES_H
+
+#include <kurl.h>
+
+#include <qfile.h>
+
+#include <qglobal.h>
+#include <qptrvector.h>
+#include <qptrlist.h>
+
+class QWidget;
+class QString;
+class QChar;
+class QStringList;
+class QSize;
+
+class KTempFile;
+
+
+//*****************************************************************************
+// utility classes
+//*****************************************************************************
+
+/** clone of QSortedList... */
+template<class type> class Q_EXPORT QSortedVector : public QPtrVector<type>
+{
+public:
+ QSortedVector() {}
+ QSortedVector ( uint size ) : QPtrVector<type>(size) {}
+ QSortedVector( const QSortedVector<type> &l ) : QPtrVector<type>(l) {}
+ ~QSortedVector() { QPtrVector<type>::clear(); }
+ QSortedVector<type> &operator=(const QSortedVector<type> &l)
+ { return (QSortedVector<type>&)QPtrList<type>::operator=(l); }
+
+ virtual int compareItems( QPtrCollection::Item s1, QPtrCollection::Item s2 )
+ { if ( *((type*)s1) == *((type*)s2) ) return 0; return ( *((type*)s1) < *((type*)s2) ? -1 : 1 ); }
+};
+
+
+//==============================================================================
+
+
+class KNFile : public QFile {
+
+ public:
+ KNFile(const QString& fname=QString::null);
+ ~KNFile();
+ const QCString& readLine();
+ const QCString& readLineWnewLine();
+ /** searches for the string from the current file position
+ returns -1 when the string wasn't found. */
+ int findString(const char *s);
+
+ protected:
+ bool increaseBuffer();
+
+ QCString buffer;
+ char *dataPtr;
+ int filePos, readBytes;
+};
+
+
+//========================================================================================
+
+
+class KNSaveHelper {
+
+public:
+
+ KNSaveHelper(QString saveName, QWidget *parent);
+ ~KNSaveHelper();
+
+ /** returns a file open for writing */
+ QFile* getFile(const QString &dialogTitle);
+
+private:
+
+ QWidget *p_arent;
+ QString s_aveName;
+ KURL url;
+ QFile* file;
+ KTempFile* tmpFile;
+ static QString lastPath;
+
+};
+
+
+//========================================================================================
+
+
+class KNLoadHelper {
+
+public:
+
+ KNLoadHelper(QWidget *parent);
+ ~KNLoadHelper();
+
+ /** opens a file dialog and returns a file open for reading */
+ KNFile* getFile( const QString &dialogTitle );
+ /** tries to access the file specified by the url and returns
+ a file open for reading */
+ KNFile* setURL(KURL url);
+ /** returns the file after getFile(QString) of setURL(url) was called */
+ KNFile* getFile()const { return f_ile; };
+ KURL getURL() const { return u_rl; };
+
+private:
+
+ QWidget *p_arent;
+ KURL u_rl;
+ KNFile *f_ile;
+ QString t_empName;
+ static QString l_astPath;
+
+};
+
+
+//========================================================================================
+
+
+class KNHelper {
+
+public:
+
+ /** list selection dialog, used instead of a popup menu
+ when a select action is called via the keyboard.
+ returns -1 when the user canceled the dialog. */
+ static int selectDialog(QWidget *parent, const QString &caption, const QStringList &options, int initialValue);
+
+ static void saveWindowSize(const QString &name, const QSize &s);
+ static void restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize);
+
+ static const QString encryptStr(const QString& aStr);
+ static const QString decryptStr(const QString& aStr);
+ static QString rot13(const QString &s);
+
+ /** used for rewarping a text when replying to a message or inserting a file into a box */
+ static QString rewrapStringList(QStringList text, int wrapAt, QChar quoteChar, bool stopAtSig, bool alwaysSpace);
+
+ /** use this for all internal files */
+ static void displayInternalFileError(QWidget *w=0);
+ /** use this for all external files */
+ static void displayExternalFileError(QWidget *w=0);
+ /** use this for remote files */
+ static void displayRemoteFileError(QWidget *w=0);
+ /** use this for error on temporary files */
+ static void displayTempFileError(QWidget *w=0);
+
+};
+
+#endif