Diffstat (limited to 'noncore/tools/opie-sh/fviewer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/tools/opie-sh/fviewer.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/noncore/tools/opie-sh/fviewer.cpp b/noncore/tools/opie-sh/fviewer.cpp new file mode 100644 index 0000000..1a0acc6 --- a/dev/null +++ b/noncore/tools/opie-sh/fviewer.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | Opie-sh. convinience app to allow you to use qdialogs in scripts (mainly shell scripts) | ||
3 | Copyright (C) 2002 Thomas Stephens | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public | ||
6 | License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later | ||
7 | version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
10 | implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
11 | Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License along with this program; if not, write to the Free | ||
14 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
15 | */ | ||
16 | #include "fviewer.h" | ||
17 | |||
18 | FViewer::FViewer(QString filename, QString title, QWidget *parent=0, const char*name=0):QWidget(parent, name) | ||
19 | { | ||
20 | QVBoxLayout *layout = new QVBoxLayout(this); | ||
21 | |||
22 | textView = new QTextBrowser(this, "textview"); | ||
23 | layout->addWidget(textView); | ||
24 | |||
25 | QString string; | ||
26 | |||
27 | if(title.isNull()) | ||
28 | { | ||
29 | setCaption(filename); | ||
30 | } | ||
31 | else | ||
32 | { | ||
33 | setCaption(title); | ||
34 | } | ||
35 | |||
36 | file = new QFile(); | ||
37 | |||
38 | if(!filename.isNull()) | ||
39 | { | ||
40 | file->setName(filename); | ||
41 | file->open(IO_ReadOnly); | ||
42 | } | ||
43 | else | ||
44 | { | ||
45 | file->open(IO_ReadOnly, 0); | ||
46 | } | ||
47 | |||
48 | stream = new QTextStream(file); | ||
49 | |||
50 | string = stream->read(); | ||
51 | textView->setText(string); | ||
52 | textView->mimeSourceFactory()->setFilePath(QDir::currentDirPath()); | ||
53 | file->close(); | ||
54 | |||
55 | } | ||
56 | |||