author | llornkcor <llornkcor> | 2002-07-02 12:46:18 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-02 12:46:18 (UTC) |
commit | d4a5bcbba0e6f67ef9d41e08c7d5ae598caa61a8 (patch) (unidiff) | |
tree | 36de80f384f0a6c51efef6bed184a77ece608eae | |
parent | dbcbad1d7252e877e485020966eb25e9f4a34f49 (diff) | |
download | opie-d4a5bcbba0e6f67ef9d41e08c7d5ae598caa61a8.zip opie-d4a5bcbba0e6f67ef9d41e08c7d5ae598caa61a8.tar.gz opie-d4a5bcbba0e6f67ef9d41e08c7d5ae598caa61a8.tar.bz2 |
use icon on opie-reader pics dir
-rw-r--r-- | noncore/apps/opie-reader/QTReaderApp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index 06a35f6..68c80c1 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,992 +1,992 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qwidgetstack.h> | 21 | #include <qwidgetstack.h> |
22 | #include <qpe/qpemenubar.h> | 22 | #include <qpe/qpemenubar.h> |
23 | #include <qpe/qpetoolbar.h> | 23 | #include <qpe/qpetoolbar.h> |
24 | #include <qpe/fontdatabase.h> | 24 | #include <qpe/fontdatabase.h> |
25 | #include <qcombobox.h> | 25 | #include <qcombobox.h> |
26 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
27 | #include <qaction.h> | 27 | #include <qaction.h> |
28 | #include <qapplication.h> | 28 | #include <qapplication.h> |
29 | #include <qlineedit.h> | 29 | #include <qlineedit.h> |
30 | #include <qtoolbutton.h> | 30 | #include <qtoolbutton.h> |
31 | #include <qspinbox.h> | 31 | #include <qspinbox.h> |
32 | #include <qobjectlist.h> | 32 | #include <qobjectlist.h> |
33 | #include <qpe/global.h> | 33 | #include <qpe/global.h> |
34 | #include <qpe/applnk.h> | 34 | #include <qpe/applnk.h> |
35 | #include <qfileinfo.h> | 35 | #include <qfileinfo.h> |
36 | #include <stdlib.h> //getenv | 36 | #include <stdlib.h> //getenv |
37 | #include <qprogressbar.h> | 37 | #include <qprogressbar.h> |
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | #include <qbuttongroup.h> | 39 | #include <qbuttongroup.h> |
40 | #include <qradiobutton.h> | 40 | #include <qradiobutton.h> |
41 | 41 | ||
42 | #include "cbkmkselector.h" | 42 | #include "cbkmkselector.h" |
43 | #include "infowin.h" | 43 | #include "infowin.h" |
44 | 44 | ||
45 | //#include <qpe/fontdatabase.h> | 45 | //#include <qpe/fontdatabase.h> |
46 | 46 | ||
47 | #include <qpe/resource.h> | 47 | #include <qpe/resource.h> |
48 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
49 | 49 | ||
50 | #include "QTReaderApp.h" | 50 | #include "QTReaderApp.h" |
51 | #include "fileBrowser.h" | 51 | #include "fileBrowser.h" |
52 | 52 | ||
53 | 53 | ||
54 | unsigned long QTReaderApp::m_uid = 0; | 54 | unsigned long QTReaderApp::m_uid = 0; |
55 | 55 | ||
56 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 56 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
57 | 57 | ||
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <stddef.h> | 59 | #include <stddef.h> |
60 | #include <dirent.h> | 60 | #include <dirent.h> |
61 | 61 | ||
62 | void QTReaderApp::listBkmkFiles() | 62 | void QTReaderApp::listBkmkFiles() |
63 | { | 63 | { |
64 | bkmkselector->clear(); | 64 | bkmkselector->clear(); |
65 | int cnt = 0; | 65 | int cnt = 0; |
66 | DIR *d; | 66 | DIR *d; |
67 | d = opendir((const char *)Global::applicationFileName("uqtreader","")); | 67 | d = opendir((const char *)Global::applicationFileName("uqtreader","")); |
68 | 68 | ||
69 | while(1) | 69 | while(1) |
70 | { | 70 | { |
71 | struct dirent* de; | 71 | struct dirent* de; |
72 | struct stat buf; | 72 | struct stat buf; |
73 | de = readdir(d); | 73 | de = readdir(d); |
74 | if (de == NULL) break; | 74 | if (de == NULL) break; |
75 | 75 | ||
76 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 76 | if (lstat((const char *)Global::applicationFileName("uqtreader",de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
77 | { | 77 | { |
78 | bkmkselector->insertItem(de->d_name); | 78 | bkmkselector->insertItem(de->d_name); |
79 | cnt++; | 79 | cnt++; |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | closedir(d); | 83 | closedir(d); |
84 | 84 | ||
85 | if (cnt > 0) | 85 | if (cnt > 0) |
86 | { | 86 | { |
87 | menu->hide(); | 87 | menu->hide(); |
88 | editBar->hide(); | 88 | editBar->hide(); |
89 | if (m_fontVisible) m_fontBar->hide(); | 89 | if (m_fontVisible) m_fontBar->hide(); |
90 | if (regVisible) regBar->hide(); | 90 | if (regVisible) regBar->hide(); |
91 | if (searchVisible) searchBar->hide(); | 91 | if (searchVisible) searchBar->hide(); |
92 | m_nRegAction = cRmBkmkFile; | 92 | m_nRegAction = cRmBkmkFile; |
93 | editorStack->raiseWidget( bkmkselector ); | 93 | editorStack->raiseWidget( bkmkselector ); |
94 | } | 94 | } |
95 | else | 95 | else |
96 | QMessageBox::information(this, "QTReader", "No bookmark files"); | 96 | QMessageBox::information(this, "QTReader", "No bookmark files"); |
97 | } | 97 | } |
98 | 98 | ||
99 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 99 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
100 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) | 100 | : QMainWindow( parent, name, f ), bFromDocView( FALSE ) |
101 | { | 101 | { |
102 | // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 102 | // qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
103 | // qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 103 | // qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
104 | 104 | ||
105 | pBkmklist = NULL; | 105 | pBkmklist = NULL; |
106 | doc = 0; | 106 | doc = 0; |
107 | 107 | ||
108 | m_fBkmksChanged = false; | 108 | m_fBkmksChanged = false; |
109 | 109 | ||
110 | QString lang = getenv( "LANG" ); | 110 | QString lang = getenv( "LANG" ); |
111 | 111 | ||
112 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; | 112 | m_autogenstr = "^ *[A-Z].*[a-z] *$"; |
113 | setToolBarsMovable( FALSE ); | 113 | setToolBarsMovable( FALSE ); |
114 | 114 | ||
115 | setIcon( Resource::loadPixmap( "uqtreader" ) ); | 115 | setIcon( Resource::loadPixmap( "uqtreader" ) ); |
116 | 116 | ||
117 | QPEToolBar *bar = new QPEToolBar( this ); | 117 | QPEToolBar *bar = new QPEToolBar( this ); |
118 | bar->setHorizontalStretchable( TRUE ); | 118 | bar->setHorizontalStretchable( TRUE ); |
119 | addToolBar(bar, "tool",QMainWindow::Top, true); | 119 | addToolBar(bar, "tool",QMainWindow::Top, true); |
120 | menu = bar; | 120 | menu = bar; |
121 | 121 | ||
122 | QPEMenuBar *mb = new QPEMenuBar( bar ); | 122 | QPEMenuBar *mb = new QPEMenuBar( bar ); |
123 | QPopupMenu *file = new QPopupMenu( this ); | 123 | QPopupMenu *file = new QPopupMenu( this ); |
124 | QPopupMenu *format = new QPopupMenu( this ); | 124 | QPopupMenu *format = new QPopupMenu( this ); |
125 | // QPopupMenu *edit = new QPopupMenu( this ); | 125 | // QPopupMenu *edit = new QPopupMenu( this ); |
126 | 126 | ||
127 | // bar = new QToolBar( this ); | 127 | // bar = new QToolBar( this ); |
128 | editBar = bar; | 128 | editBar = bar; |
129 | 129 | ||
130 | /* | 130 | /* |
131 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); | 131 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); |
132 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 132 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
133 | a->addTo( bar ); | 133 | a->addTo( bar ); |
134 | a->addTo( file ); | 134 | a->addTo( file ); |
135 | */ | 135 | */ |
136 | 136 | ||
137 | editorStack = new QWidgetStack( this ); | 137 | editorStack = new QWidgetStack( this ); |
138 | setCentralWidget( editorStack ); | 138 | setCentralWidget( editorStack ); |
139 | 139 | ||
140 | searchVisible = FALSE; | 140 | searchVisible = FALSE; |
141 | regVisible = FALSE; | 141 | regVisible = FALSE; |
142 | m_fontVisible = false; | 142 | m_fontVisible = false; |
143 | 143 | ||
144 | pbar = new QProgressBar(this); | 144 | pbar = new QProgressBar(this); |
145 | pbar->hide(); | 145 | pbar->hide(); |
146 | 146 | ||
147 | m_infoWin = new infowin(editorStack); | 147 | m_infoWin = new infowin(editorStack); |
148 | editorStack->addWidget(m_infoWin, get_unique_id()); | 148 | editorStack->addWidget(m_infoWin, get_unique_id()); |
149 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); | 149 | connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); |
150 | 150 | ||
151 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); | 151 | // bkmkselector = new QListBox(editorStack, "Bookmarks"); |
152 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); | 152 | bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); |
153 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); | 153 | // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); |
154 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); | 154 | connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); |
155 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); | 155 | connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); |
156 | editorStack->addWidget( bkmkselector, get_unique_id() ); | 156 | editorStack->addWidget( bkmkselector, get_unique_id() ); |
157 | 157 | ||
158 | /* | 158 | /* |
159 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); | 159 | importSelector = new FileSelector( "*", editorStack, "importselector", false ); |
160 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); | 160 | connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); |
161 | 161 | ||
162 | editorStack->addWidget( importSelector, get_unique_id() ); | 162 | editorStack->addWidget( importSelector, get_unique_id() ); |
163 | 163 | ||
164 | // don't need the close visible, it is redundant... | 164 | // don't need the close visible, it is redundant... |
165 | importSelector->setCloseVisible( FALSE ); | 165 | importSelector->setCloseVisible( FALSE ); |
166 | */ | 166 | */ |
167 | 167 | ||
168 | reader = new QTReader( editorStack ); | 168 | reader = new QTReader( editorStack ); |
169 | Config config( "uqtreader" ); | 169 | Config config( "uqtreader" ); |
170 | config.setGroup( "View" ); | 170 | config.setGroup( "View" ); |
171 | 171 | ||
172 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); | 172 | reader->bstripcr = config.readBoolEntry( "StripCr", true ); |
173 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); | 173 | reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); |
174 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); | 174 | reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); |
175 | reader->bunindent = config.readBoolEntry( "Unindent", false ); | 175 | reader->bunindent = config.readBoolEntry( "Unindent", false ); |
176 | reader->brepara = config.readBoolEntry( "Repara", false ); | 176 | reader->brepara = config.readBoolEntry( "Repara", false ); |
177 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); | 177 | reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); |
178 | reader->bindenter = config.readNumEntry( "Indent", 0 ); | 178 | reader->bindenter = config.readNumEntry( "Indent", 0 ); |
179 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); | 179 | reader->m_textsize = config.readNumEntry( "FontSize", 12 ); |
180 | reader->m_bBold = config.readBoolEntry( "Bold", false ); | 180 | reader->m_bBold = config.readBoolEntry( "Bold", false ); |
181 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); | 181 | reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); |
182 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); | 182 | reader->m_lastfile = config.readEntry( "LastFile", QString::null ); |
183 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); | 183 | reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); |
184 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); | 184 | reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); |
185 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); | 185 | reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); |
186 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); | 186 | reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); |
187 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); | 187 | reader->m_encd = config.readNumEntry( "Encoding", 0 ); |
188 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); | 188 | reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); |
189 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); | 189 | reader->m_overlap = config.readNumEntry( "Overlap", 0 ); |
190 | reader->m_targetapp = config.readEntry( "TargetApp", QString::null ); | 190 | reader->m_targetapp = config.readEntry( "TargetApp", QString::null ); |
191 | reader->m_targetmsg = config.readEntry( "TargetMsg", QString::null ); | 191 | reader->m_targetmsg = config.readEntry( "TargetMsg", QString::null ); |
192 | reader->init(); | 192 | reader->init(); |
193 | editorStack->addWidget( reader, get_unique_id() ); | 193 | editorStack->addWidget( reader, get_unique_id() ); |
194 | 194 | ||
195 | QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); | 195 | QAction *a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); |
196 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 196 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
197 | a->addTo( bar ); | 197 | a->addTo( bar ); |
198 | a->addTo( file ); | 198 | a->addTo( file ); |
199 | 199 | ||
200 | /* | 200 | /* |
201 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 201 | a = new QAction( tr( "Revert" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
202 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); | 202 | connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); |
203 | a->addTo( file ); | 203 | a->addTo( file ); |
204 | 204 | ||
205 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); | 205 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 ); |
206 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 206 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
207 | a->addTo( editBar ); | 207 | a->addTo( editBar ); |
208 | a->addTo( edit ); | 208 | a->addTo( edit ); |
209 | */ | 209 | */ |
210 | 210 | ||
211 | a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); | 211 | a = new QAction( tr( "Info" ), QString::null, 0, this, NULL); |
212 | connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); | 212 | connect( a, SIGNAL( activated() ), this, SLOT( showinfo() ) ); |
213 | a->addTo( file ); | 213 | a->addTo( file ); |
214 | 214 | ||
215 | a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); | 215 | a = new QAction( tr( "Start Block" ), QString::null, 0, this, NULL); |
216 | connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); | 216 | connect( a, SIGNAL( activated() ), this, SLOT( editMark() ) ); |
217 | file->insertSeparator(); | 217 | file->insertSeparator(); |
218 | a->addTo( file ); | 218 | a->addTo( file ); |
219 | 219 | ||
220 | a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); | 220 | a = new QAction( tr( "Copy Block" ), QString::null, 0, this, NULL); |
221 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 221 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
222 | a->addTo( file ); | 222 | a->addTo( file ); |
223 | 223 | ||
224 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "panel-arrow-down" ), QString::null, 0, this, 0, true ); | 224 | a = m_scrollButton = new QAction( tr( "Scroll" ), Resource::loadPixmap( "opie-reader/panel-arrow-down" ), QString::null, 0, this, 0, true ); |
225 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); | 225 | // connect( a, SIGNAL( activated() ), this, SLOT( autoScroll() ) ); |
226 | a->setOn(false); | 226 | a->setOn(false); |
227 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); | 227 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); |
228 | file->insertSeparator(); | 228 | file->insertSeparator(); |
229 | a->addTo( bar ); | 229 | a->addTo( bar ); |
230 | a->addTo( file ); | 230 | a->addTo( file ); |
231 | 231 | ||
232 | /* | 232 | /* |
233 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); | 233 | a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); |
234 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 234 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
235 | a->addTo( file ); | 235 | a->addTo( file ); |
236 | 236 | ||
237 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); | 237 | a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); |
238 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 238 | // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
239 | a->addTo( file ); | 239 | a->addTo( file ); |
240 | */ | 240 | */ |
241 | a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL); | 241 | a = new QAction( tr( "Jump" ), QString::null, 0, this, NULL); |
242 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); | 242 | connect( a, SIGNAL( activated() ), this, SLOT( jump() ) ); |
243 | a->addTo( file ); | 243 | a->addTo( file ); |
244 | 244 | ||
245 | a = new QAction( tr( "Page/Line scroll" ), QString::null, 0, this, NULL, true ); | 245 | a = new QAction( tr( "Page/Line scroll" ), QString::null, 0, this, NULL, true ); |
246 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); | 246 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); |
247 | a->setOn(reader->m_bpagemode); | 247 | a->setOn(reader->m_bpagemode); |
248 | a->addTo( file ); | 248 | a->addTo( file ); |
249 | 249 | ||
250 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL); | 250 | a = new QAction( tr( "Set Overlap" ), QString::null, 0, this, NULL); |
251 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); | 251 | connect( a, SIGNAL( activated() ), this, SLOT( setoverlap() ) ); |
252 | a->addTo( file ); | 252 | a->addTo( file ); |
253 | 253 | ||
254 | a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); | 254 | a = new QAction( tr( "Set Dictionary" ), QString::null, 0, this, NULL); |
255 | connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); | 255 | connect( a, SIGNAL( activated() ), this, SLOT( settarget() ) ); |
256 | a->addTo( file ); | 256 | a->addTo( file ); |
257 | 257 | ||
258 | /* | 258 | /* |
259 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); | 259 | a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); |
260 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); | 260 | connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); |
261 | a->addTo( file ); | 261 | a->addTo( file ); |
262 | */ | 262 | */ |
263 | 263 | ||
264 | a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); | 264 | a = new QAction( tr( "Up" ), Resource::loadPixmap( "up" ), QString::null, 0, this, 0 ); |
265 | connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) ); | 265 | connect( a, SIGNAL( activated() ), this, SLOT( pageup() ) ); |
266 | a->addTo( editBar ); | 266 | a->addTo( editBar ); |
267 | 267 | ||
268 | a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); | 268 | a = new QAction( tr( "Down" ), Resource::loadPixmap( "down" ), QString::null, 0, this, 0 ); |
269 | connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); | 269 | connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); |
270 | a->addTo( editBar ); | 270 | a->addTo( editBar ); |
271 | 271 | ||
272 | /* | 272 | /* |
273 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); | 273 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 ); |
274 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 274 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
275 | a->addTo( editBar ); | 275 | a->addTo( editBar ); |
276 | a->addTo( edit ); | 276 | a->addTo( edit ); |
277 | */ | 277 | */ |
278 | 278 | ||
279 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 279 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
280 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 280 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
281 | file->insertSeparator(); | 281 | file->insertSeparator(); |
282 | a->addTo( bar ); | 282 | a->addTo( bar ); |
283 | a->addTo( file ); | 283 | a->addTo( file ); |
284 | 284 | ||
285 | 285 | ||
286 | a = new QAction( tr( "Strip CR" ), QString::null, 0, this, NULL, true ); | 286 | a = new QAction( tr( "Strip CR" ), QString::null, 0, this, NULL, true ); |
287 | a->setOn(reader->bstripcr); | 287 | a->setOn(reader->bstripcr); |
288 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); | 288 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( stripcr(bool) ) ); |
289 | a->addTo( format ); | 289 | a->addTo( format ); |
290 | // a->setOn(true); | 290 | // a->setOn(true); |
291 | 291 | ||
292 | a = new QAction( tr( "Strip HTML" ), QString::null, 0, this, NULL, true ); | 292 | a = new QAction( tr( "Strip HTML" ), QString::null, 0, this, NULL, true ); |
293 | a->setOn(reader->bstriphtml); | 293 | a->setOn(reader->bstriphtml); |
294 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); | 294 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( striphtml(bool) ) ); |
295 | a->addTo( format ); | 295 | a->addTo( format ); |
296 | 296 | ||
297 | a = new QAction( tr( "Dehyphen" ), QString::null, 0, this, NULL, true ); | 297 | a = new QAction( tr( "Dehyphen" ), QString::null, 0, this, NULL, true ); |
298 | a->setOn(reader->bdehyphen); | 298 | a->setOn(reader->bdehyphen); |
299 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); | 299 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dehyphen(bool) ) ); |
300 | a->addTo( format ); | 300 | a->addTo( format ); |
301 | 301 | ||
302 | a = new QAction( tr( "Unindent" ), QString::null, 0, this, NULL, true ); | 302 | a = new QAction( tr( "Unindent" ), QString::null, 0, this, NULL, true ); |
303 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); | 303 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( unindent(bool) ) ); |
304 | a->setOn(reader->bunindent); | 304 | a->setOn(reader->bunindent); |
305 | a->addTo( format ); | 305 | a->addTo( format ); |
306 | 306 | ||
307 | a = new QAction( tr( "Re-paragraph" ), QString::null, 0, this, NULL, true ); | 307 | a = new QAction( tr( "Re-paragraph" ), QString::null, 0, this, NULL, true ); |
308 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); | 308 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( repara(bool) ) ); |
309 | a->setOn(reader->brepara); | 309 | a->setOn(reader->brepara); |
310 | a->addTo( format ); | 310 | a->addTo( format ); |
311 | 311 | ||
312 | a = new QAction( tr( "Double Space" ), QString::null, 0, this, NULL, true ); | 312 | a = new QAction( tr( "Double Space" ), QString::null, 0, this, NULL, true ); |
313 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); | 313 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( dblspce(bool) ) ); |
314 | a->setOn(reader->bdblspce); | 314 | a->setOn(reader->bdblspce); |
315 | a->addTo( format ); | 315 | a->addTo( format ); |
316 | 316 | ||
317 | a = new QAction( tr( "Indent+" ), QString::null, 0, this, NULL ); | 317 | a = new QAction( tr( "Indent+" ), QString::null, 0, this, NULL ); |
318 | connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); | 318 | connect( a, SIGNAL( activated() ), this, SLOT( indentplus() ) ); |
319 | a->addTo( format ); | 319 | a->addTo( format ); |
320 | 320 | ||
321 | a = new QAction( tr( "Indent-" ), QString::null, 0, this, NULL ); | 321 | a = new QAction( tr( "Indent-" ), QString::null, 0, this, NULL ); |
322 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); | 322 | connect( a, SIGNAL( activated() ), this, SLOT( indentminus() ) ); |
323 | a->addTo( format ); | 323 | a->addTo( format ); |
324 | 324 | ||
325 | a = new QAction( tr( "Bold" ), QString::null, 0, this, NULL, true ); | 325 | a = new QAction( tr( "Bold" ), QString::null, 0, this, NULL, true ); |
326 | a->setOn(reader->m_bBold); | 326 | a->setOn(reader->m_bBold); |
327 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setbold(bool) ) ); | 327 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( setbold(bool) ) ); |
328 | a->addTo( format ); | 328 | a->addTo( format ); |
329 | 329 | ||
330 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); | 330 | // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); |
331 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); | 331 | // a = new QAction( tr( "Zoom" ), Resource::loadPixmap( "mag" ), QString::null, 0, this, 0 ); |
332 | a = new QAction( tr( "Zoom" ), QString::null, 0, this); | 332 | a = new QAction( tr( "Zoom" ), QString::null, 0, this); |
333 | connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) ); | 333 | connect( a, SIGNAL( activated() ), this, SLOT( TBDzoom() ) ); |
334 | format->insertSeparator(); | 334 | format->insertSeparator(); |
335 | a->addTo( format ); | 335 | a->addTo( format ); |
336 | // a->addTo( editBar ); | 336 | // a->addTo( editBar ); |
337 | 337 | ||
338 | 338 | ||
339 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); | 339 | a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); |
340 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); | 340 | connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); |
341 | a->setOn(reader->m_bMonoSpaced); | 341 | a->setOn(reader->m_bMonoSpaced); |
342 | format->insertSeparator(); | 342 | format->insertSeparator(); |
343 | a->addTo( format ); | 343 | a->addTo( format ); |
344 | 344 | ||
345 | a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); | 345 | a = new QAction( tr( "Set width" ), QString::null, 0, this, NULL); |
346 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); | 346 | connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); |
347 | a->addTo( format ); | 347 | a->addTo( format ); |
348 | 348 | ||
349 | QPopupMenu *encoding = new QPopupMenu(this); | 349 | QPopupMenu *encoding = new QPopupMenu(this); |
350 | format->insertSeparator(); | 350 | format->insertSeparator(); |
351 | format->insertItem( tr( "Encoding" ), encoding ); | 351 | format->insertItem( tr( "Encoding" ), encoding ); |
352 | 352 | ||
353 | QActionGroup* ag = new QActionGroup(this); | 353 | QActionGroup* ag = new QActionGroup(this); |
354 | 354 | ||
355 | m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); | 355 | m_EncodingAction[0] = new QAction( tr( "Ascii" ), QString::null, 0, ag, NULL, true ); |
356 | 356 | ||
357 | m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true ); | 357 | m_EncodingAction[1] = new QAction( tr( "UTF-8" ), QString::null, 0, ag, NULL, true ); |
358 | 358 | ||
359 | m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true ); | 359 | m_EncodingAction[2] = new QAction( tr( "UCS-2(BE)" ), QString::null, 0, ag, NULL, true ); |
360 | 360 | ||
361 | m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true ); | 361 | m_EncodingAction[3] = new QAction( tr( "USC-2(LE)" ), QString::null, 0, ag, NULL, true ); |
362 | 362 | ||
363 | m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true ); | 363 | m_EncodingAction[4] = new QAction( tr( "Palm" ), QString::null, 0, ag, NULL, true ); |
364 | 364 | ||
365 | m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true ); | 365 | m_EncodingAction[5] = new QAction( tr( "Windows(1252)" ), QString::null, 0, ag, NULL, true ); |
366 | 366 | ||
367 | ag->addTo(encoding); | 367 | ag->addTo(encoding); |
368 | 368 | ||
369 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) ); | 369 | connect(ag, SIGNAL( selected(QAction*) ), this, SLOT( encodingSelected(QAction*) ) ); |
370 | 370 | ||
371 | a = new QAction( tr( "Set Font" ), QString::null, 0, this); | 371 | a = new QAction( tr( "Set Font" ), QString::null, 0, this); |
372 | connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) ); | 372 | connect( a, SIGNAL( activated() ), this, SLOT( setfont() ) ); |
373 | format->insertSeparator(); | 373 | format->insertSeparator(); |
374 | a->addTo( format ); | 374 | a->addTo( format ); |
375 | 375 | ||
376 | QPopupMenu *marks = new QPopupMenu( this ); | 376 | QPopupMenu *marks = new QPopupMenu( this ); |
377 | 377 | ||
378 | a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); | 378 | a = new QAction( tr( "Mark" ), QString::null, 0, this, NULL); |
379 | connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); | 379 | connect( a, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); |
380 | a->addTo( marks ); | 380 | a->addTo( marks ); |
381 | 381 | ||
382 | a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); | 382 | a = new QAction( tr( "Goto" ), QString::null, 0, this, NULL, false ); |
383 | connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); | 383 | connect( a, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); |
384 | a->addTo( marks ); | 384 | a->addTo( marks ); |
385 | 385 | ||
386 | a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); | 386 | a = new QAction( tr( "Delete" ), QString::null, 0, this, NULL); |
387 | connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); | 387 | connect( a, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); |
388 | a->addTo( marks ); | 388 | a->addTo( marks ); |
389 | 389 | ||
390 | a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); | 390 | a = new QAction( tr( "Autogen" ), QString::null, 0, this, NULL, false ); |
391 | connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); | 391 | connect( a, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); |
392 | marks->insertSeparator(); | 392 | marks->insertSeparator(); |
393 | a->addTo( marks ); | 393 | a->addTo( marks ); |
394 | 394 | ||
395 | a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); | 395 | a = new QAction( tr( "Clear" ), QString::null, 0, this, NULL); |
396 | connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); | 396 | connect( a, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); |
397 | a->addTo( marks ); | 397 | a->addTo( marks ); |
398 | 398 | ||
399 | a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); | 399 | a = new QAction( tr( "Save" ), QString::null, 0, this, NULL ); |
400 | connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); | 400 | connect( a, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); |
401 | a->addTo( marks ); | 401 | a->addTo( marks ); |
402 | 402 | ||
403 | a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); | 403 | a = new QAction( tr( "Tidy" ), QString::null, 0, this, NULL); |
404 | connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); | 404 | connect( a, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); |
405 | marks->insertSeparator(); | 405 | marks->insertSeparator(); |
406 | a->addTo( marks ); | 406 | a->addTo( marks ); |
407 | 407 | ||
408 | mb->insertItem( tr( "File" ), file ); | 408 | mb->insertItem( tr( "File" ), file ); |
409 | // mb->insertItem( tr( "Edit" ), edit ); | 409 | // mb->insertItem( tr( "Edit" ), edit ); |
410 | mb->insertItem( tr( "Format" ), format ); | 410 | mb->insertItem( tr( "Format" ), format ); |
411 | mb->insertItem( tr( "Marks" ), marks ); | 411 | mb->insertItem( tr( "Marks" ), marks ); |
412 | 412 | ||
413 | searchBar = new QToolBar( "Search", this, QMainWindow::Top, TRUE ); | 413 | searchBar = new QToolBar( "Search", this, QMainWindow::Top, TRUE ); |
414 | 414 | ||
415 | searchBar->setHorizontalStretchable( TRUE ); | 415 | searchBar->setHorizontalStretchable( TRUE ); |
416 | 416 | ||
417 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 417 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
418 | // QFont f("unifont", 16 /*, QFont::Bold*/); | 418 | // QFont f("unifont", 16 /*, QFont::Bold*/); |
419 | // searchEdit->setFont( f ); | 419 | // searchEdit->setFont( f ); |
420 | searchBar->setStretchableWidget( searchEdit ); | 420 | searchBar->setStretchableWidget( searchEdit ); |
421 | #ifdef __ISEARCH | 421 | #ifdef __ISEARCH |
422 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 422 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
423 | this, SLOT( search( const QString& ) ) ); | 423 | this, SLOT( search( const QString& ) ) ); |
424 | #else | 424 | #else |
425 | connect( searchEdit, SIGNAL( returnPressed( ) ), | 425 | connect( searchEdit, SIGNAL( returnPressed( ) ), |
426 | this, SLOT( search( ) ) ); | 426 | this, SLOT( search( ) ) ); |
427 | #endif | 427 | #endif |
428 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); | 428 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 ); |
429 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 429 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
430 | a->addTo( searchBar ); | 430 | a->addTo( searchBar ); |
431 | 431 | ||
432 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 432 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
433 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 433 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
434 | a->addTo( searchBar ); | 434 | a->addTo( searchBar ); |
435 | 435 | ||
436 | searchBar->hide(); | 436 | searchBar->hide(); |
437 | 437 | ||
438 | regBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 438 | regBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
439 | 439 | ||
440 | regBar->setHorizontalStretchable( TRUE ); | 440 | regBar->setHorizontalStretchable( TRUE ); |
441 | 441 | ||
442 | regEdit = new QLineEdit( regBar, "regEdit" ); | 442 | regEdit = new QLineEdit( regBar, "regEdit" ); |
443 | // regEdit->setFont( f ); | 443 | // regEdit->setFont( f ); |
444 | 444 | ||
445 | regBar->setStretchableWidget( regEdit ); | 445 | regBar->setStretchableWidget( regEdit ); |
446 | 446 | ||
447 | connect( regEdit, SIGNAL( returnPressed( ) ), | 447 | connect( regEdit, SIGNAL( returnPressed( ) ), |
448 | this, SLOT( do_regaction() ) ); | 448 | this, SLOT( do_regaction() ) ); |
449 | 449 | ||
450 | a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); | 450 | a = new QAction( tr( "Do Reg" ), Resource::loadPixmap( "enter" ), QString::null, 0, this, 0 ); |
451 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); | 451 | connect( a, SIGNAL( activated() ), this, SLOT( do_regaction() ) ); |
452 | a->addTo( regBar ); | 452 | a->addTo( regBar ); |
453 | 453 | ||
454 | a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 454 | a = new QAction( tr( "Close Edit" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
455 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); | 455 | connect( a, SIGNAL( activated() ), this, SLOT( regClose() ) ); |
456 | a->addTo( regBar ); | 456 | a->addTo( regBar ); |
457 | 457 | ||
458 | regBar->hide(); | 458 | regBar->hide(); |
459 | 459 | ||
460 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); | 460 | m_fontBar = new QToolBar( "Autogen", this, QMainWindow::Top, TRUE ); |
461 | 461 | ||
462 | m_fontBar->setHorizontalStretchable( TRUE ); | 462 | m_fontBar->setHorizontalStretchable( TRUE ); |
463 | 463 | ||
464 | m_fontSelector = new QComboBox(false, m_fontBar); | 464 | m_fontSelector = new QComboBox(false, m_fontBar); |
465 | m_fontBar->setStretchableWidget( m_fontSelector ); | 465 | m_fontBar->setStretchableWidget( m_fontSelector ); |
466 | { | 466 | { |
467 | FontDatabase f; | 467 | FontDatabase f; |
468 | m_fontSelector->insertStringList(f.families()); | 468 | m_fontSelector->insertStringList(f.families()); |
469 | } // delete the FontDatabase!!! | 469 | } // delete the FontDatabase!!! |
470 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), | 470 | connect( m_fontSelector, SIGNAL( activated(const QString& ) ), |
471 | this, SLOT( do_setfont(const QString&) ) ); | 471 | this, SLOT( do_setfont(const QString&) ) ); |
472 | 472 | ||
473 | m_fontBar->hide(); | 473 | m_fontBar->hide(); |
474 | m_fontVisible = false; | 474 | m_fontVisible = false; |
475 | 475 | ||
476 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), | 476 | connect(qApp, SIGNAL( appMessage(const QCString&, const QByteArray& ) ), |
477 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); | 477 | this, SLOT( msgHandler(const QCString&, const QByteArray&) ) ); |
478 | 478 | ||
479 | 479 | ||
480 | if (!reader->m_lastfile.isEmpty()) | 480 | if (!reader->m_lastfile.isEmpty()) |
481 | { | 481 | { |
482 | openFile( reader->m_lastfile ); | 482 | openFile( reader->m_lastfile ); |
483 | doc = new DocLnk(reader->m_lastfile); | 483 | doc = new DocLnk(reader->m_lastfile); |
484 | } | 484 | } |
485 | m_EncodingAction[reader->m_encd]->setOn(true); | 485 | m_EncodingAction[reader->m_encd]->setOn(true); |
486 | do_setfont(reader->m_fontname); | 486 | do_setfont(reader->m_fontname); |
487 | } | 487 | } |
488 | 488 | ||
489 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) | 489 | void QTReaderApp::msgHandler(const QCString& _msg, const QByteArray& _data) |
490 | { | 490 | { |
491 | QString msg = QString::fromUtf8(_msg); | 491 | QString msg = QString::fromUtf8(_msg); |
492 | 492 | ||
493 | // qDebug("Received:%s", (const char*)msg); | 493 | // qDebug("Received:%s", (const char*)msg); |
494 | 494 | ||
495 | QDataStream stream( _data, IO_ReadOnly ); | 495 | QDataStream stream( _data, IO_ReadOnly ); |
496 | if ( msg == "info(QString)" ) | 496 | if ( msg == "info(QString)" ) |
497 | { | 497 | { |
498 | QString info; | 498 | QString info; |
499 | stream >> info; | 499 | stream >> info; |
500 | QMessageBox::information(this, "QTReader", info); | 500 | QMessageBox::information(this, "QTReader", info); |
501 | } else if ( msg == "warn(QString)" ) | 501 | } else if ( msg == "warn(QString)" ) |
502 | { | 502 | { |
503 | QString info; | 503 | QString info; |
504 | stream >> info; | 504 | stream >> info; |
505 | QMessageBox::warning(this, "QTReader", info); | 505 | QMessageBox::warning(this, "QTReader", info); |
506 | } | 506 | } |
507 | } | 507 | } |
508 | 508 | ||
509 | int QTReaderApp::EncNameToInt(const QString& _enc) | 509 | int QTReaderApp::EncNameToInt(const QString& _enc) |
510 | { | 510 | { |
511 | for (int i = 0; i < MAX_ENCODING; i++) | 511 | for (int i = 0; i < MAX_ENCODING; i++) |
512 | { | 512 | { |
513 | if (m_EncodingAction[i]->text() == _enc) return i; | 513 | if (m_EncodingAction[i]->text() == _enc) return i; |
514 | } | 514 | } |
515 | return 0; | 515 | return 0; |
516 | /* | 516 | /* |
517 | if (_enc == "Ascii") return 0; | 517 | if (_enc == "Ascii") return 0; |
518 | if (_enc == "UTF-8") return 1; | 518 | if (_enc == "UTF-8") return 1; |
519 | if (_enc == "UCS-2(BE)") return 2; | 519 | if (_enc == "UCS-2(BE)") return 2; |
520 | if (_enc == "USC-2(LE)") return 3; | 520 | if (_enc == "USC-2(LE)") return 3; |
521 | */ | 521 | */ |
522 | } | 522 | } |
523 | 523 | ||
524 | void QTReaderApp::encodingSelected(QAction* _a) | 524 | void QTReaderApp::encodingSelected(QAction* _a) |
525 | { | 525 | { |
526 | // qDebug("es:%x : %s", _a, (const char *)(_a->text())); | 526 | // qDebug("es:%x : %s", _a, (const char *)(_a->text())); |
527 | reader->setencoding(EncNameToInt(_a->text())); | 527 | reader->setencoding(EncNameToInt(_a->text())); |
528 | } | 528 | } |
529 | 529 | ||
530 | QTReaderApp::~QTReaderApp() | 530 | QTReaderApp::~QTReaderApp() |
531 | { | 531 | { |
532 | } | 532 | } |
533 | 533 | ||
534 | void QTReaderApp::autoScroll(bool _b) | 534 | void QTReaderApp::autoScroll(bool _b) |
535 | { | 535 | { |
536 | reader->setautoscroll(_b); | 536 | reader->setautoscroll(_b); |
537 | } | 537 | } |
538 | 538 | ||
539 | void QTReaderApp::TBD() | 539 | void QTReaderApp::TBD() |
540 | { | 540 | { |
541 | QMessageBox::information(this, "QTReader", "Not yet implemented", 1); | 541 | QMessageBox::information(this, "QTReader", "Not yet implemented", 1); |
542 | } | 542 | } |
543 | 543 | ||
544 | void QTReaderApp::TBDzoom() | 544 | void QTReaderApp::TBDzoom() |
545 | { | 545 | { |
546 | QMessageBox::information(this, "QTReader", "Zooming is done interactively\nTry left/right cursor keys", 1); | 546 | QMessageBox::information(this, "QTReader", "Zooming is done interactively\nTry left/right cursor keys", 1); |
547 | } | 547 | } |
548 | 548 | ||
549 | void QTReaderApp::clearBkmkList() | 549 | void QTReaderApp::clearBkmkList() |
550 | { | 550 | { |
551 | delete pBkmklist; | 551 | delete pBkmklist; |
552 | pBkmklist = NULL; | 552 | pBkmklist = NULL; |
553 | m_fBkmksChanged = false; | 553 | m_fBkmksChanged = false; |
554 | } | 554 | } |
555 | 555 | ||
556 | void QTReaderApp::fileOpen() | 556 | void QTReaderApp::fileOpen() |
557 | { | 557 | { |
558 | /* | 558 | /* |
559 | menu->hide(); | 559 | menu->hide(); |
560 | editBar->hide(); | 560 | editBar->hide(); |
561 | if (regVisible) regBar->hide(); | 561 | if (regVisible) regBar->hide(); |
562 | if (searchVisible) searchBar->hide(); | 562 | if (searchVisible) searchBar->hide(); |
563 | */ | 563 | */ |
564 | if (pBkmklist != NULL) | 564 | if (pBkmklist != NULL) |
565 | { | 565 | { |
566 | if (m_fBkmksChanged) | 566 | if (m_fBkmksChanged) |
567 | { | 567 | { |
568 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) | 568 | if (QMessageBox::warning(this, "QTReader", "Save bookmarks?", "Save", "Don't bother") == 0) |
569 | savebkmks(); | 569 | savebkmks(); |
570 | } | 570 | } |
571 | delete pBkmklist; | 571 | delete pBkmklist; |
572 | pBkmklist = NULL; | 572 | pBkmklist = NULL; |
573 | m_fBkmksChanged = false; | 573 | m_fBkmksChanged = false; |
574 | } | 574 | } |
575 | reader->disableAutoscroll(); | 575 | reader->disableAutoscroll(); |
576 | /* | 576 | /* |
577 | editorStack->raiseWidget( fileSelector ); | 577 | editorStack->raiseWidget( fileSelector ); |
578 | fileSelector->reread(); | 578 | fileSelector->reread(); |
579 | */ | 579 | */ |
580 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, | 580 | fileBrowser* fb = new fileBrowser(this,"QTReader",TRUE, |
581 | 0, | 581 | 0, |
582 | // WStyle_Customize | WStyle_NoBorderEx, | 582 | // WStyle_Customize | WStyle_NoBorderEx, |
583 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); | 583 | "*", QFileInfo(reader->m_lastfile).dirPath(true)); |
584 | 584 | ||
585 | if (fb->exec()) | 585 | if (fb->exec()) |
586 | { | 586 | { |
587 | QString fn(fb->fileList[0]); | 587 | QString fn(fb->fileList[0]); |
588 | // fb->populateList(); | 588 | // fb->populateList(); |
589 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); | 589 | if (!fn.isEmpty() && QFileInfo(fn).isFile()) openFile(fn); |
590 | } | 590 | } |
591 | delete fb; | 591 | delete fb; |
592 | } | 592 | } |
593 | 593 | ||
594 | void QTReaderApp::showinfo() | 594 | void QTReaderApp::showinfo() |
595 | { | 595 | { |
596 | unsigned long fs, ts, pl; | 596 | unsigned long fs, ts, pl; |
597 | if (reader->empty()) | 597 | if (reader->empty()) |
598 | { | 598 | { |
599 | QMessageBox::information(this, "QTReader", "No file loaded", 1); | 599 | QMessageBox::information(this, "QTReader", "No file loaded", 1); |
600 | } | 600 | } |
601 | else | 601 | else |
602 | { | 602 | { |
603 | reader->sizes(fs,ts); | 603 | reader->sizes(fs,ts); |
604 | pl = reader->pagelocate(); | 604 | pl = reader->pagelocate(); |
605 | m_infoWin->setFileSize(fs); | 605 | m_infoWin->setFileSize(fs); |
606 | m_infoWin->setTextSize(ts); | 606 | m_infoWin->setTextSize(ts); |
607 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); | 607 | m_infoWin->setRatio(100-(100*fs + (ts >> 1))/ts); |
608 | m_infoWin->setLocation(pl); | 608 | m_infoWin->setLocation(pl); |
609 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); | 609 | m_infoWin->setRead((100*pl + (ts >> 1))/ts); |
610 | editorStack->raiseWidget( m_infoWin ); | 610 | editorStack->raiseWidget( m_infoWin ); |
611 | m_infoWin->setFocus(); | 611 | m_infoWin->setFocus(); |
612 | } | 612 | } |
613 | } | 613 | } |
614 | 614 | ||
615 | void QTReaderApp::infoClose() | 615 | void QTReaderApp::infoClose() |
616 | { | 616 | { |
617 | showEditTools(); | 617 | showEditTools(); |
618 | } | 618 | } |
619 | 619 | ||
620 | /* | 620 | /* |
621 | void QTReaderApp::fileRevert() | 621 | void QTReaderApp::fileRevert() |
622 | { | 622 | { |
623 | clear(); | 623 | clear(); |
624 | fileOpen(); | 624 | fileOpen(); |
625 | } | 625 | } |
626 | 626 | ||
627 | void QTReaderApp::editCut() | 627 | void QTReaderApp::editCut() |
628 | { | 628 | { |
629 | #ifndef QT_NO_CLIPBOARD | 629 | #ifndef QT_NO_CLIPBOARD |
630 | editor->cut(); | 630 | editor->cut(); |
631 | #endif | 631 | #endif |
632 | } | 632 | } |
633 | */ | 633 | */ |
634 | void QTReaderApp::editMark() | 634 | void QTReaderApp::editMark() |
635 | { | 635 | { |
636 | m_savedpos = reader->pagelocate(); | 636 | m_savedpos = reader->pagelocate(); |
637 | } | 637 | } |
638 | 638 | ||
639 | void QTReaderApp::editCopy() | 639 | void QTReaderApp::editCopy() |
640 | { | 640 | { |
641 | QClipboard* cb = QApplication::clipboard(); | 641 | QClipboard* cb = QApplication::clipboard(); |
642 | QString text; | 642 | QString text; |
643 | int ch; | 643 | int ch; |
644 | unsigned long currentpos = reader->pagelocate(); | 644 | unsigned long currentpos = reader->pagelocate(); |
645 | unsigned long endpos = reader->locate(); | 645 | unsigned long endpos = reader->locate(); |
646 | reader->jumpto(m_savedpos); | 646 | reader->jumpto(m_savedpos); |
647 | while (reader->locate() < endpos && (ch = reader->getch()) != UEOF) | 647 | while (reader->locate() < endpos && (ch = reader->getch()) != UEOF) |
648 | { | 648 | { |
649 | text += ch; | 649 | text += ch; |
650 | } | 650 | } |
651 | cb->setText(text); | 651 | cb->setText(text); |
652 | // text = cb->text(); | 652 | // text = cb->text(); |
653 | // if (text) | 653 | // if (text) |
654 | // qDebug("The clipboard contains: %s", (const tchar*)text); | 654 | // qDebug("The clipboard contains: %s", (const tchar*)text); |
655 | reader->locate(currentpos); | 655 | reader->locate(currentpos); |
656 | #ifndef QT_NO_CLIPBOARD | 656 | #ifndef QT_NO_CLIPBOARD |
657 | // TBD(); | 657 | // TBD(); |
658 | // reader->copy(); | 658 | // reader->copy(); |
659 | #endif | 659 | #endif |
660 | } | 660 | } |
661 | 661 | ||
662 | void QTReaderApp::pageup() | 662 | void QTReaderApp::pageup() |
663 | { | 663 | { |
664 | reader->goUp(); | 664 | reader->goUp(); |
665 | } | 665 | } |
666 | 666 | ||
667 | void QTReaderApp::pagedn() | 667 | void QTReaderApp::pagedn() |
668 | { | 668 | { |
669 | reader->goDown(); | 669 | reader->goDown(); |
670 | } | 670 | } |
671 | 671 | ||
672 | void QTReaderApp::stripcr(bool _b) | 672 | void QTReaderApp::stripcr(bool _b) |
673 | { | 673 | { |
674 | reader->setstripcr(_b); | 674 | reader->setstripcr(_b); |
675 | } | 675 | } |
676 | void QTReaderApp::striphtml(bool _b) | 676 | void QTReaderApp::striphtml(bool _b) |
677 | { | 677 | { |
678 | reader->setstriphtml(_b); | 678 | reader->setstriphtml(_b); |
679 | } | 679 | } |
680 | void QTReaderApp::dehyphen(bool _b) | 680 | void QTReaderApp::dehyphen(bool _b) |
681 | { | 681 | { |
682 | reader->setdehyphen(_b); | 682 | reader->setdehyphen(_b); |
683 | } | 683 | } |
684 | void QTReaderApp::unindent(bool _b) | 684 | void QTReaderApp::unindent(bool _b) |
685 | { | 685 | { |
686 | reader->setunindent(_b); | 686 | reader->setunindent(_b); |
687 | } | 687 | } |
688 | void QTReaderApp::repara(bool _b) | 688 | void QTReaderApp::repara(bool _b) |
689 | { | 689 | { |
690 | reader->setrepara(_b); | 690 | reader->setrepara(_b); |
691 | } | 691 | } |
692 | void QTReaderApp::setbold(bool _b) | 692 | void QTReaderApp::setbold(bool _b) |
693 | { | 693 | { |
694 | reader->m_bBold = _b; | 694 | reader->m_bBold = _b; |
695 | reader->ChangeFont(reader->fontsizes[reader->m_textsize]); | 695 | reader->ChangeFont(reader->fontsizes[reader->m_textsize]); |
696 | reader->refresh(); | 696 | reader->refresh(); |
697 | } | 697 | } |
698 | void QTReaderApp::dblspce(bool _b) | 698 | void QTReaderApp::dblspce(bool _b) |
699 | { | 699 | { |
700 | reader->setdblspce(_b); | 700 | reader->setdblspce(_b); |
701 | } | 701 | } |
702 | void QTReaderApp::pagemode(bool _b) | 702 | void QTReaderApp::pagemode(bool _b) |
703 | { | 703 | { |
704 | reader->setpagemode(_b); | 704 | reader->setpagemode(_b); |
705 | } | 705 | } |
706 | 706 | ||
707 | void QTReaderApp::monospace(bool _b) | 707 | void QTReaderApp::monospace(bool _b) |
708 | { | 708 | { |
709 | reader->setmono(_b); | 709 | reader->setmono(_b); |
710 | } | 710 | } |
711 | 711 | ||
712 | void QTReaderApp::setspacing() | 712 | void QTReaderApp::setspacing() |
713 | { | 713 | { |
714 | m_nRegAction = cMonoSpace; | 714 | m_nRegAction = cMonoSpace; |
715 | char lcn[20]; | 715 | char lcn[20]; |
716 | sprintf(lcn, "%lu", reader->m_charpc); | 716 | sprintf(lcn, "%lu", reader->m_charpc); |
717 | regEdit->setText(lcn); | 717 | regEdit->setText(lcn); |
718 | do_regedit(); | 718 | do_regedit(); |
719 | } | 719 | } |
720 | 720 | ||
721 | void QTReaderApp::setoverlap() | 721 | void QTReaderApp::setoverlap() |
722 | { | 722 | { |
723 | m_nRegAction = cOverlap; | 723 | m_nRegAction = cOverlap; |
724 | char lcn[20]; | 724 | char lcn[20]; |
725 | sprintf(lcn, "%lu", reader->m_overlap); | 725 | sprintf(lcn, "%lu", reader->m_overlap); |
726 | regEdit->setText(lcn); | 726 | regEdit->setText(lcn); |
727 | do_regedit(); | 727 | do_regedit(); |
728 | } | 728 | } |
729 | 729 | ||
730 | void QTReaderApp::settarget() | 730 | void QTReaderApp::settarget() |
731 | { | 731 | { |
732 | m_nRegAction = cSetTarget; | 732 | m_nRegAction = cSetTarget; |
733 | QString text = ((reader->m_targetapp.isEmpty()) ? QString("") : reader->m_targetapp) | 733 | QString text = ((reader->m_targetapp.isEmpty()) ? QString("") : reader->m_targetapp) |
734 | + "/" | 734 | + "/" |
735 | + ((reader->m_targetmsg.isEmpty()) ? QString("") : reader->m_targetmsg); | 735 | + ((reader->m_targetmsg.isEmpty()) ? QString("") : reader->m_targetmsg); |
736 | regEdit->setText(text); | 736 | regEdit->setText(text); |
737 | do_regedit(); | 737 | do_regedit(); |
738 | } | 738 | } |
739 | 739 | ||
740 | void QTReaderApp::do_overlap(const QString& lcn) | 740 | void QTReaderApp::do_overlap(const QString& lcn) |
741 | { | 741 | { |
742 | bool ok; | 742 | bool ok; |
743 | unsigned long ulcn = lcn.toULong(&ok); | 743 | unsigned long ulcn = lcn.toULong(&ok); |
744 | if (ok) | 744 | if (ok) |
745 | { | 745 | { |
746 | reader->m_overlap = ulcn; | 746 | reader->m_overlap = ulcn; |
747 | } | 747 | } |
748 | else | 748 | else |
749 | QMessageBox::information(this, "QTReader", "Must be a number"); | 749 | QMessageBox::information(this, "QTReader", "Must be a number"); |
750 | } | 750 | } |
751 | 751 | ||
752 | void QTReaderApp::do_mono(const QString& lcn) | 752 | void QTReaderApp::do_mono(const QString& lcn) |
753 | { | 753 | { |
754 | bool ok; | 754 | bool ok; |
755 | unsigned long ulcn = lcn.toULong(&ok); | 755 | unsigned long ulcn = lcn.toULong(&ok); |
756 | if (ok) | 756 | if (ok) |
757 | { | 757 | { |
758 | reader->m_charpc = ulcn; | 758 | reader->m_charpc = ulcn; |
759 | // reader->setmono(true); | 759 | // reader->setmono(true); |
760 | } | 760 | } |
761 | else | 761 | else |
762 | QMessageBox::information(this, "QTReader", "Must be a number"); | 762 | QMessageBox::information(this, "QTReader", "Must be a number"); |
763 | } | 763 | } |
764 | 764 | ||
765 | /* | 765 | /* |
766 | void QTReaderApp::editPaste() | 766 | void QTReaderApp::editPaste() |
767 | { | 767 | { |
768 | #ifndef QT_NO_CLIPBOARD | 768 | #ifndef QT_NO_CLIPBOARD |
769 | editor->paste(); | 769 | editor->paste(); |
770 | #endif | 770 | #endif |
771 | } | 771 | } |
772 | */ | 772 | */ |
773 | 773 | ||
774 | void QTReaderApp::editFind() | 774 | void QTReaderApp::editFind() |
775 | { | 775 | { |
776 | searchStart = reader->pagelocate(); | 776 | searchStart = reader->pagelocate(); |
777 | #ifdef __ISEARCH | 777 | #ifdef __ISEARCH |
778 | searchStack = new QStack<searchrecord>; | 778 | searchStack = new QStack<searchrecord>; |
779 | #endif | 779 | #endif |
780 | searchBar->show(); | 780 | searchBar->show(); |
781 | searchVisible = TRUE; | 781 | searchVisible = TRUE; |
782 | searchEdit->setFocus(); | 782 | searchEdit->setFocus(); |
783 | #ifdef __ISEARCH | 783 | #ifdef __ISEARCH |
784 | searchStack->push(new searchrecord("",reader->pagelocate())); | 784 | searchStack->push(new searchrecord("",reader->pagelocate())); |
785 | #endif | 785 | #endif |
786 | } | 786 | } |
787 | 787 | ||
788 | void QTReaderApp::findNext() | 788 | void QTReaderApp::findNext() |
789 | { | 789 | { |
790 | // qDebug("findNext called\n"); | 790 | // qDebug("findNext called\n"); |
791 | #ifdef __ISEARCH | 791 | #ifdef __ISEARCH |
792 | QString arg = searchEdit->text(); | 792 | QString arg = searchEdit->text(); |
793 | #else | 793 | #else |
794 | QRegExp arg = searchEdit->text(); | 794 | QRegExp arg = searchEdit->text(); |
795 | #endif | 795 | #endif |
796 | CBuffer test; | 796 | CBuffer test; |
797 | size_t start = reader->pagelocate(); | 797 | size_t start = reader->pagelocate(); |
798 | reader->jumpto(start); | 798 | reader->jumpto(start); |
799 | reader->buffdoc.getline(&test,reader->width()); | 799 | reader->buffdoc.getline(&test,reader->width()); |
800 | dosearch(start, test, arg); | 800 | dosearch(start, test, arg); |
801 | } | 801 | } |
802 | 802 | ||
803 | void QTReaderApp::findClose() | 803 | void QTReaderApp::findClose() |
804 | { | 804 | { |
805 | searchVisible = FALSE; | 805 | searchVisible = FALSE; |
806 | searchEdit->setText(""); | 806 | searchEdit->setText(""); |
807 | searchBar->hide(); | 807 | searchBar->hide(); |
808 | #ifdef __ISEARCH | 808 | #ifdef __ISEARCH |
809 | // searchStack = new QStack<searchrecord>; | 809 | // searchStack = new QStack<searchrecord>; |
810 | while (!searchStack->isEmpty()) | 810 | while (!searchStack->isEmpty()) |
811 | { | 811 | { |
812 | delete searchStack->pop(); | 812 | delete searchStack->pop(); |
813 | } | 813 | } |
814 | delete searchStack; | 814 | delete searchStack; |
815 | #endif | 815 | #endif |
816 | reader->setFocus(); | 816 | reader->setFocus(); |
817 | } | 817 | } |
818 | 818 | ||
819 | void QTReaderApp::regClose() | 819 | void QTReaderApp::regClose() |
820 | { | 820 | { |
821 | regVisible = FALSE; | 821 | regVisible = FALSE; |
822 | regEdit->setText(""); | 822 | regEdit->setText(""); |
823 | regBar->hide(); | 823 | regBar->hide(); |
824 | reader->setFocus(); | 824 | reader->setFocus(); |
825 | } | 825 | } |
826 | 826 | ||
827 | #ifdef __ISEARCH | 827 | #ifdef __ISEARCH |
828 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QString& arg) | 828 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QString& arg) |
829 | #else | 829 | #else |
830 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) | 830 | bool QTReaderApp::dosearch(size_t start, CBuffer& test, const QRegExp& arg) |
831 | #endif | 831 | #endif |
832 | { | 832 | { |
833 | bool ret = true; | 833 | bool ret = true; |
834 | size_t pos = start; | 834 | size_t pos = start; |
835 | reader->buffdoc.getline(&test,reader->width()); | 835 | reader->buffdoc.getline(&test,reader->width()); |
836 | #ifdef __ISEARCH | 836 | #ifdef __ISEARCH |
837 | while (strstr(test.data(),(const tchar*)arg) == NULL) | 837 | while (strstr(test.data(),(const tchar*)arg) == NULL) |
838 | #else | 838 | #else |
839 | #ifdef _UNICODE | 839 | #ifdef _UNICODE |
840 | while (arg.match(toQString(test.data())) == -1) | 840 | while (arg.match(toQString(test.data())) == -1) |
841 | #else | 841 | #else |
842 | while (arg.match(test.data()) == -1) | 842 | while (arg.match(test.data()) == -1) |
843 | #endif | 843 | #endif |
844 | #endif | 844 | #endif |
845 | { | 845 | { |
846 | pos = reader->locate(); | 846 | pos = reader->locate(); |
847 | if (!reader->buffdoc.getline(&test,reader->width())) | 847 | if (!reader->buffdoc.getline(&test,reader->width())) |
848 | { | 848 | { |
849 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) | 849 | if (QMessageBox::warning(this, "Can't find", searchEdit->text(), 1, 2) == 2) |
850 | pos = searchStart; | 850 | pos = searchStart; |
851 | else | 851 | else |
852 | pos = start; | 852 | pos = start; |
853 | ret = false; | 853 | ret = false; |
854 | findClose(); | 854 | findClose(); |
855 | break; | 855 | break; |
856 | } | 856 | } |
857 | } | 857 | } |
858 | reader->locate(pos); | 858 | reader->locate(pos); |
859 | return ret; | 859 | return ret; |
860 | } | 860 | } |
861 | 861 | ||
862 | #ifdef __ISEARCH | 862 | #ifdef __ISEARCH |
863 | void QTReaderApp::search(const QString & arg) | 863 | void QTReaderApp::search(const QString & arg) |
864 | { | 864 | { |
865 | searchrecord* ss = searchStack->top(); | 865 | searchrecord* ss = searchStack->top(); |
866 | CBuffer test; | 866 | CBuffer test; |
867 | size_t start = reader->pagelocate(); | 867 | size_t start = reader->pagelocate(); |
868 | bool haspopped = false; | 868 | bool haspopped = false; |
869 | while (arg.left(ss->s.length()) != ss->s) | 869 | while (arg.left(ss->s.length()) != ss->s) |
870 | { | 870 | { |
871 | haspopped = true; | 871 | haspopped = true; |
872 | start = ss->pos; | 872 | start = ss->pos; |
873 | // reader->locate(start); | 873 | // reader->locate(start); |
874 | searchStack->pop(); | 874 | searchStack->pop(); |
875 | delete ss; | 875 | delete ss; |
876 | } | 876 | } |
877 | if (haspopped) reader->locate(start); | 877 | if (haspopped) reader->locate(start); |
878 | /* | 878 | /* |
879 | if (arg.length() < ss->len) | 879 | if (arg.length() < ss->len) |
880 | { | 880 | { |
881 | start = ss->pos; | 881 | start = ss->pos; |
882 | reader->locate(start); | 882 | reader->locate(start); |
883 | searchStack->pop(); | 883 | searchStack->pop(); |
884 | delete ss; | 884 | delete ss; |
885 | } | 885 | } |
886 | */ | 886 | */ |
887 | else | 887 | else |
888 | { | 888 | { |
889 | start = reader->pagelocate(); | 889 | start = reader->pagelocate(); |
890 | reader->jumpto(start); | 890 | reader->jumpto(start); |
891 | searchStack->push(new searchrecord(arg,start)); | 891 | searchStack->push(new searchrecord(arg,start)); |
892 | } | 892 | } |
893 | dosearch(start, test, arg); | 893 | dosearch(start, test, arg); |
894 | } | 894 | } |
895 | #else | 895 | #else |
896 | void QTReaderApp::search() | 896 | void QTReaderApp::search() |
897 | { | 897 | { |
898 | QRegExp arg = searchEdit->text(); | 898 | QRegExp arg = searchEdit->text(); |
899 | CBuffer test; | 899 | CBuffer test; |
900 | size_t start = reader->pagelocate(); | 900 | size_t start = reader->pagelocate(); |
901 | // reader->jumpto(start); | 901 | // reader->jumpto(start); |
902 | dosearch(start, test, arg); | 902 | dosearch(start, test, arg); |
903 | } | 903 | } |
904 | #endif | 904 | #endif |
905 | 905 | ||
906 | void QTReaderApp::openFile( const QString &f ) | 906 | void QTReaderApp::openFile( const QString &f ) |
907 | { | 907 | { |
908 | openFile(DocLnk(f)); | 908 | openFile(DocLnk(f)); |
909 | } | 909 | } |
910 | 910 | ||
911 | void QTReaderApp::openFile( const DocLnk &f ) | 911 | void QTReaderApp::openFile( const DocLnk &f ) |
912 | { | 912 | { |
913 | clear(); | 913 | clear(); |
914 | FileManager fm; | 914 | FileManager fm; |
915 | if ( fm.exists( f ) ) | 915 | if ( fm.exists( f ) ) |
916 | { | 916 | { |
917 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); | 917 | // QMessageBox::information(0, "Progress", "Calling fileNew()"); |
918 | 918 | ||
919 | clear(); | 919 | clear(); |
920 | 920 | ||
921 | // editorStack->raiseWidget( reader ); | 921 | // editorStack->raiseWidget( reader ); |
922 | 922 | ||
923 | // reader->setFocus(); | 923 | // reader->setFocus(); |
924 | 924 | ||
925 | // QMessageBox::information(0, "DocLnk", "Begin"); | 925 | // QMessageBox::information(0, "DocLnk", "Begin"); |
926 | doc = new DocLnk(f); | 926 | doc = new DocLnk(f); |
927 | // QMessageBox::information(0, "DocLnk done", doc->file()); | 927 | // QMessageBox::information(0, "DocLnk done", doc->file()); |
928 | // QMessageBox::information(0, "Progress", "Calling setText()"); | 928 | // QMessageBox::information(0, "Progress", "Calling setText()"); |
929 | // QMessageBox::information(0, "Progress", "Textset"); | 929 | // QMessageBox::information(0, "Progress", "Textset"); |
930 | 930 | ||
931 | // updateCaption(); | 931 | // updateCaption(); |
932 | showEditTools(); | 932 | showEditTools(); |
933 | reader->setText(doc->name(), doc->file()); | 933 | reader->setText(doc->name(), doc->file()); |
934 | readbkmks(); | 934 | readbkmks(); |
935 | } | 935 | } |
936 | else | 936 | else |
937 | { | 937 | { |
938 | QMessageBox::information(this, "QTReader", "File does not exist"); | 938 | QMessageBox::information(this, "QTReader", "File does not exist"); |
939 | } | 939 | } |
940 | 940 | ||
941 | } | 941 | } |
942 | 942 | ||
943 | void QTReaderApp::showEditTools() | 943 | void QTReaderApp::showEditTools() |
944 | { | 944 | { |
945 | if ( !doc ) | 945 | if ( !doc ) |
946 | close(); | 946 | close(); |
947 | // fileSelector->hide(); | 947 | // fileSelector->hide(); |
948 | menu->show(); | 948 | menu->show(); |
949 | editBar->show(); | 949 | editBar->show(); |
950 | if ( searchVisible ) | 950 | if ( searchVisible ) |
951 | searchBar->show(); | 951 | searchBar->show(); |
952 | if ( regVisible ) | 952 | if ( regVisible ) |
953 | regBar->show(); | 953 | regBar->show(); |
954 | if (m_fontVisible) m_fontBar->show(); | 954 | if (m_fontVisible) m_fontBar->show(); |
955 | 955 | ||
956 | updateCaption(); | 956 | updateCaption(); |
957 | editorStack->raiseWidget( reader ); | 957 | editorStack->raiseWidget( reader ); |
958 | reader->setFocus(); | 958 | reader->setFocus(); |
959 | } | 959 | } |
960 | /* | 960 | /* |
961 | void QTReaderApp::save() | 961 | void QTReaderApp::save() |
962 | { | 962 | { |
963 | if ( !doc ) | 963 | if ( !doc ) |
964 | return; | 964 | return; |
965 | if ( !editor->edited() ) | 965 | if ( !editor->edited() ) |
966 | return; | 966 | return; |
967 | 967 | ||
968 | QString rt = editor->text(); | 968 | QString rt = editor->text(); |
969 | QString pt = rt; | 969 | QString pt = rt; |
970 | 970 | ||
971 | if ( doc->name().isEmpty() ) { | 971 | if ( doc->name().isEmpty() ) { |
972 | unsigned ispace = pt.find( ' ' ); | 972 | unsigned ispace = pt.find( ' ' ); |
973 | unsigned ienter = pt.find( '\n' ); | 973 | unsigned ienter = pt.find( '\n' ); |
974 | int i = (ispace < ienter) ? ispace : ienter; | 974 | int i = (ispace < ienter) ? ispace : ienter; |
975 | QString docname; | 975 | QString docname; |
976 | if ( i == -1 ) { | 976 | if ( i == -1 ) { |
977 | if ( pt.isEmpty() ) | 977 | if ( pt.isEmpty() ) |
978 | docname = "Empty Text"; | 978 | docname = "Empty Text"; |
979 | else | 979 | else |
980 | docname = pt; | 980 | docname = pt; |
981 | } else { | 981 | } else { |
982 | docname = pt.left( i ); | 982 | docname = pt.left( i ); |
983 | } | 983 | } |
984 | doc->setName(docname); | 984 | doc->setName(docname); |
985 | } | 985 | } |
986 | FileManager fm; | 986 | FileManager fm; |
987 | fm.saveFile( *doc, rt ); | 987 | fm.saveFile( *doc, rt ); |
988 | } | 988 | } |
989 | */ | 989 | */ |
990 | 990 | ||
991 | void QTReaderApp::clear() | 991 | void QTReaderApp::clear() |
992 | { | 992 | { |