-rw-r--r-- | core/apps/helpbrowser/helpbrowser.cpp | 103 | ||||
-rw-r--r-- | core/apps/taboapp/main.cpp | 48 | ||||
-rw-r--r-- | core/apps/textedit/filePermissions.cpp | 2 | ||||
-rw-r--r-- | core/apps/textedit/textedit.cpp | 83 |
4 files changed, 122 insertions, 114 deletions
diff --git a/core/apps/helpbrowser/helpbrowser.cpp b/core/apps/helpbrowser/helpbrowser.cpp index 336d9fb..cbb4059 100644 --- a/core/apps/helpbrowser/helpbrowser.cpp +++ b/core/apps/helpbrowser/helpbrowser.cpp | |||
@@ -1,228 +1,229 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia 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 | #define QTOPIA_INTERNAL_LANGLIST | 21 | #define QTOPIA_INTERNAL_LANGLIST |
22 | 22 | ||
23 | #include "helpbrowser.h" | 23 | #include "helpbrowser.h" |
24 | #include "magictextbrowser.h" | ||
24 | 25 | ||
26 | /* OPIE */ | ||
27 | #include <opie2/odebug.h> | ||
25 | #include <qpe/qpeapplication.h> | 28 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/resource.h> | 29 | #include <qpe/resource.h> |
30 | using namespace Opie::Core; | ||
27 | 31 | ||
32 | /* QT */ | ||
28 | #include <qmenubar.h> | 33 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 34 | #include <qtoolbar.h> |
30 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
31 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
32 | #include <qaction.h> | 37 | #include <qaction.h> |
33 | 38 | ||
34 | #include <cctype> | ||
35 | |||
36 | #include "magictextbrowser.h" | ||
37 | |||
38 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) | 39 | HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f ) |
39 | : QMainWindow( parent, name, f ), | 40 | : QMainWindow( parent, name, f ), |
40 | selectedURL() | 41 | selectedURL() |
41 | { | 42 | { |
42 | init( "index.html" ); | 43 | init( "index.html" ); |
43 | } | 44 | } |
44 | 45 | ||
45 | 46 | ||
46 | 47 | ||
47 | void HelpBrowser::init( const QString& _home ) | 48 | void HelpBrowser::init( const QString& _home ) |
48 | { | 49 | { |
49 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); | 50 | setIcon( Resource::loadPixmap( "HelpBrowser" ) ); |
50 | setBackgroundMode( PaletteButton ); | 51 | setBackgroundMode( PaletteButton ); |
51 | 52 | ||
52 | browser = new MagicTextBrowser( this ); | 53 | browser = new MagicTextBrowser( this ); |
53 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 54 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
54 | connect( browser, SIGNAL( textChanged() ), | 55 | connect( browser, SIGNAL( textChanged() ), |
55 | this, SLOT( textChanged() ) ); | 56 | this, SLOT( textChanged() ) ); |
56 | 57 | ||
57 | setCentralWidget( browser ); | 58 | setCentralWidget( browser ); |
58 | setToolBarsMovable( FALSE ); | 59 | setToolBarsMovable( FALSE ); |
59 | 60 | ||
60 | if ( !_home.isEmpty() ) | 61 | if ( !_home.isEmpty() ) |
61 | browser->setSource( _home ); | 62 | browser->setSource( _home ); |
62 | 63 | ||
63 | QToolBar* toolbar = new QToolBar( this ); | 64 | QToolBar* toolbar = new QToolBar( this ); |
64 | toolbar->setHorizontalStretchable( TRUE ); | 65 | toolbar->setHorizontalStretchable( TRUE ); |
65 | QMenuBar *menu = new QMenuBar( toolbar ); | 66 | QMenuBar *menu = new QMenuBar( toolbar ); |
66 | 67 | ||
67 | toolbar = new QToolBar( this ); | 68 | toolbar = new QToolBar( this ); |
68 | // addToolBar( toolbar, "Toolbar"); | 69 | // addToolBar( toolbar, "Toolbar"); |
69 | 70 | ||
70 | QPopupMenu* go = new QPopupMenu( this ); | 71 | QPopupMenu* go = new QPopupMenu( this ); |
71 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); | 72 | backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 ); |
72 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 73 | connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
73 | connect( browser, SIGNAL( backwardAvailable(bool) ), | 74 | connect( browser, SIGNAL( backwardAvailable(bool) ), |
74 | backAction, SLOT( setEnabled(bool) ) ); | 75 | backAction, SLOT( setEnabled(bool) ) ); |
75 | backAction->addTo( go ); | 76 | backAction->addTo( go ); |
76 | backAction->addTo( toolbar ); | 77 | backAction->addTo( toolbar ); |
77 | backAction->setEnabled( FALSE ); | 78 | backAction->setEnabled( FALSE ); |
78 | 79 | ||
79 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); | 80 | forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 ); |
80 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 81 | connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
81 | connect( browser, SIGNAL( forwardAvailable(bool) ), | 82 | connect( browser, SIGNAL( forwardAvailable(bool) ), |
82 | forwardAction, SLOT( setEnabled(bool) ) ); | 83 | forwardAction, SLOT( setEnabled(bool) ) ); |
83 | forwardAction->addTo( go ); | 84 | forwardAction->addTo( go ); |
84 | forwardAction->addTo( toolbar ); | 85 | forwardAction->addTo( toolbar ); |
85 | forwardAction->setEnabled( FALSE ); | 86 | forwardAction->setEnabled( FALSE ); |
86 | 87 | ||
87 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); | 88 | QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 ); |
88 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); | 89 | connect( a, SIGNAL( activated() ), browser, SLOT( home() ) ); |
89 | a->addTo( go ); | 90 | a->addTo( go ); |
90 | a->addTo( toolbar ); | 91 | a->addTo( toolbar ); |
91 | 92 | ||
92 | bookm = new QPopupMenu( this ); | 93 | bookm = new QPopupMenu( this ); |
93 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); | 94 | bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) ); |
94 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); | 95 | bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) ); |
95 | bookm->insertSeparator(); | 96 | bookm->insertSeparator(); |
96 | connect( bookm, SIGNAL( activated(int) ), | 97 | connect( bookm, SIGNAL( activated(int) ), |
97 | this, SLOT( bookmChosen(int) ) ); | 98 | this, SLOT( bookmChosen(int) ) ); |
98 | 99 | ||
99 | readBookmarks(); | 100 | readBookmarks(); |
100 | 101 | ||
101 | menu->insertItem( tr("Go"), go ); | 102 | menu->insertItem( tr("Go"), go ); |
102 | menu->insertItem( tr( "Bookmarks" ), bookm ); | 103 | menu->insertItem( tr( "Bookmarks" ), bookm ); |
103 | 104 | ||
104 | resize( 240, 300 ); | 105 | resize( 240, 300 ); |
105 | browser->setFocus(); | 106 | browser->setFocus(); |
106 | browser->setFrameStyle( QFrame::NoFrame ); | 107 | browser->setFrameStyle( QFrame::NoFrame ); |
107 | 108 | ||
108 | #if !defined(QT_NO_COP) | 109 | #if !defined(QT_NO_COP) |
109 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); | 110 | QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this ); |
110 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), | 111 | connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)), |
111 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); | 112 | this, SLOT ( appMessage(const QCString&,const QByteArray&) ) ); |
112 | #endif | 113 | #endif |
113 | 114 | ||
114 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | 115 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
115 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | 116 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
116 | } | 117 | } |
117 | 118 | ||
118 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) | 119 | void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data) |
119 | { | 120 | { |
120 | qDebug("reached appMessage"); | 121 | odebug << "reached appMessage" << oendl; |
121 | if ( msg == "showFile(QString)" ) { | 122 | if ( msg == "showFile(QString)" ) { |
122 | QDataStream ds(data,IO_ReadOnly); | 123 | QDataStream ds(data,IO_ReadOnly); |
123 | QString fn; | 124 | QString fn; |
124 | ds >> fn; | 125 | ds >> fn; |
125 | setDocument( fn ); | 126 | setDocument( fn ); |
126 | 127 | ||
127 | QPEApplication::setKeepRunning(); | 128 | QPEApplication::setKeepRunning(); |
128 | 129 | ||
129 | showMaximized(); | 130 | showMaximized(); |
130 | setActiveWindow(); | 131 | setActiveWindow(); |
131 | raise(); | 132 | raise(); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | 135 | ||
135 | void HelpBrowser::setDocument( const QString &doc ) | 136 | void HelpBrowser::setDocument( const QString &doc ) |
136 | { | 137 | { |
137 | if ( !doc.isEmpty() ) | 138 | if ( !doc.isEmpty() ) |
138 | browser->setSource( doc ); | 139 | browser->setSource( doc ); |
139 | raise(); | 140 | raise(); |
140 | } | 141 | } |
141 | 142 | ||
142 | 143 | ||
143 | void HelpBrowser::textChanged() | 144 | void HelpBrowser::textChanged() |
144 | { | 145 | { |
145 | if ( browser->documentTitle().isNull() ) | 146 | if ( browser->documentTitle().isNull() ) |
146 | setCaption( tr("Help Browser") ); | 147 | setCaption( tr("Help Browser") ); |
147 | else | 148 | else |
148 | setCaption( browser->documentTitle() ) ; | 149 | setCaption( browser->documentTitle() ) ; |
149 | 150 | ||
150 | selectedURL = caption(); | 151 | selectedURL = caption(); |
151 | } | 152 | } |
152 | 153 | ||
153 | HelpBrowser::~HelpBrowser() | 154 | HelpBrowser::~HelpBrowser() |
154 | { | 155 | { |
155 | QStringList bookmarks; | 156 | QStringList bookmarks; |
156 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); | 157 | QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin(); |
157 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 158 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
158 | bookmarks.append( (*it2).name + "=" + (*it2).file ); | 159 | bookmarks.append( (*it2).name + "=" + (*it2).file ); |
159 | 160 | ||
160 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); | 161 | QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") ); |
161 | if ( f2.open( IO_WriteOnly ) ) { | 162 | if ( f2.open( IO_WriteOnly ) ) { |
162 | QDataStream s2( &f2 ); | 163 | QDataStream s2( &f2 ); |
163 | s2 << bookmarks; | 164 | s2 << bookmarks; |
164 | f2.close(); | 165 | f2.close(); |
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | void HelpBrowser::pathSelected( const QString &_path ) | 169 | void HelpBrowser::pathSelected( const QString &_path ) |
169 | { | 170 | { |
170 | browser->setSource( _path ); | 171 | browser->setSource( _path ); |
171 | } | 172 | } |
172 | 173 | ||
173 | void HelpBrowser::readBookmarks() | 174 | void HelpBrowser::readBookmarks() |
174 | { | 175 | { |
175 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); | 176 | QString file = Global::applicationFileName("helpbrowser", "bookmarks"); |
176 | if ( QFile::exists( file ) ) { | 177 | if ( QFile::exists( file ) ) { |
177 | QStringList bookmarks; | 178 | QStringList bookmarks; |
178 | QFile f( file ); | 179 | QFile f( file ); |
179 | if ( f.open( IO_ReadOnly ) ) { | 180 | if ( f.open( IO_ReadOnly ) ) { |
180 | QDataStream s( &f ); | 181 | QDataStream s( &f ); |
181 | s >> bookmarks; | 182 | s >> bookmarks; |
182 | f.close(); | 183 | f.close(); |
183 | } | 184 | } |
184 | QStringList::Iterator it = bookmarks.begin(); | 185 | QStringList::Iterator it = bookmarks.begin(); |
185 | for ( ; it != bookmarks.end(); ++it ) { | 186 | for ( ; it != bookmarks.end(); ++it ) { |
186 | Bookmark b; | 187 | Bookmark b; |
187 | QString current = *it; | 188 | QString current = *it; |
188 | int equal = current.find( "=" ); | 189 | int equal = current.find( "=" ); |
189 | if ( equal < 1 || equal == (int)current.length() - 1 ) | 190 | if ( equal < 1 || equal == (int)current.length() - 1 ) |
190 | continue; | 191 | continue; |
191 | b.name = current.left( equal ); | 192 | b.name = current.left( equal ); |
192 | b.file = current.mid( equal + 1 ); | 193 | b.file = current.mid( equal + 1 ); |
193 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 194 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
194 | } | 195 | } |
195 | } | 196 | } |
196 | } | 197 | } |
197 | 198 | ||
198 | void HelpBrowser::bookmChosen( int i ) | 199 | void HelpBrowser::bookmChosen( int i ) |
199 | { | 200 | { |
200 | if ( mBookmarks.contains( i ) ) | 201 | if ( mBookmarks.contains( i ) ) |
201 | browser->setSource( mBookmarks[ i ].file ); | 202 | browser->setSource( mBookmarks[ i ].file ); |
202 | } | 203 | } |
203 | 204 | ||
204 | void HelpBrowser::addBookmark() | 205 | void HelpBrowser::addBookmark() |
205 | { | 206 | { |
206 | Bookmark b; | 207 | Bookmark b; |
207 | b.name = browser->documentTitle(); | 208 | b.name = browser->documentTitle(); |
208 | b.file = browser->source(); | 209 | b.file = browser->source(); |
209 | if (b.name.isEmpty() ) { | 210 | if (b.name.isEmpty() ) { |
210 | b.name = b.file.left( b.file.length() - 5 ); // remove .html | 211 | b.name = b.file.left( b.file.length() - 5 ); // remove .html |
211 | } | 212 | } |
212 | QMap<int, Bookmark>::Iterator it; | 213 | QMap<int, Bookmark>::Iterator it; |
213 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) | 214 | for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it ) |
214 | if ( (*it).file == b.file ) return; | 215 | if ( (*it).file == b.file ) return; |
215 | mBookmarks[ bookm->insertItem( b.name ) ] = b; | 216 | mBookmarks[ bookm->insertItem( b.name ) ] = b; |
216 | } | 217 | } |
217 | 218 | ||
218 | void HelpBrowser::removeBookmark() | 219 | void HelpBrowser::removeBookmark() |
219 | { | 220 | { |
220 | QString file = browser->source(); | 221 | QString file = browser->source(); |
221 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); | 222 | QMap<int, Bookmark>::Iterator it = mBookmarks.begin(); |
222 | for( ; it != mBookmarks.end(); ++it ) | 223 | for( ; it != mBookmarks.end(); ++it ) |
223 | if ( (*it).file == file ) { | 224 | if ( (*it).file == file ) { |
224 | bookm->removeItem( it.key() ); | 225 | bookm->removeItem( it.key() ); |
225 | mBookmarks.remove( it ); | 226 | mBookmarks.remove( it ); |
226 | break; | 227 | break; |
227 | } | 228 | } |
228 | } | 229 | } |
diff --git a/core/apps/taboapp/main.cpp b/core/apps/taboapp/main.cpp index e46c71f..e43f118 100644 --- a/core/apps/taboapp/main.cpp +++ b/core/apps/taboapp/main.cpp | |||
@@ -1,53 +1,57 @@ | |||
1 | #include <qdir.h> | 1 | /* OPIE */ |
2 | |||
3 | #include <qpe/qpeapplication.h> | ||
4 | #include <qpe/qlibrary.h> | ||
5 | #include <oappinterface.h> | 2 | #include <oappinterface.h> |
6 | #include <oappplugin.h> | 3 | #include <oappplugin.h> |
7 | 4 | #include <opie2/odebug.h> | |
8 | #include <opie2/otabwidget.h> | 5 | #include <opie2/otabwidget.h> |
6 | #include <qpe/qpeapplication.h> | ||
7 | #include <qpe/qlibrary.h> | ||
8 | using namespace Opie::Core; | ||
9 | using namespace Opie::Ui; | ||
10 | |||
11 | /* QT */ | ||
12 | #include <qdir.h> | ||
9 | 13 | ||
10 | int main( int argc, char **argv ) | 14 | int main( int argc, char **argv ) |
11 | { | 15 | { |
12 | QPEApplication a( argc, argv ); | 16 | QPEApplication a( argc, argv ); |
13 | 17 | ||
14 | Opie::Ui::OTabWidget *tabwidget = new Opie::Ui::OTabWidget(0, "tab widget"); | 18 | OTabWidget *tabwidget = new OTabWidget(0, "tab widget"); |
15 | 19 | ||
16 | QString path = QPEApplication::qpeDir() + "/plugins/app"; | 20 | QString path = QPEApplication::qpeDir() + "/plugins/app"; |
17 | QDir dir( path, "lib*.so" ); | 21 | QDir dir( path, "lib*.so" ); |
18 | 22 | ||
19 | QStringList list = dir.entryList(); | 23 | QStringList list = dir.entryList(); |
20 | QStringList::Iterator it; | 24 | QStringList::Iterator it; |
21 | 25 | ||
22 | QInterfacePtr<OAppInterface> iface; | 26 | QInterfacePtr<OAppInterface> iface; |
23 | for ( it = list.begin(); it != list.end(); ++it ) { | 27 | for ( it = list.begin(); it != list.end(); ++it ) { |
24 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 28 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
25 | 29 | ||
26 | qDebug( "querying: %s", QString( path + "/" + *it ).latin1() ); | 30 | odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl; |
27 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { | 31 | if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) { |
28 | qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() ); | 32 | odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl; |
29 | 33 | ||
30 | QList<QWidget> list = iface->widgets(); | 34 | QList<QWidget> list = iface->widgets(); |
31 | QWidget *widget; | 35 | QWidget *widget; |
32 | for ( widget = list.first(); widget != 0; widget = list.next() ) | 36 | for ( widget = list.first(); widget != 0; widget = list.next() ) |
33 | tabwidget->addTab(widget, QString(*it), QString(*it)); | 37 | tabwidget->addTab(widget, QString(*it), QString(*it)); |
34 | 38 | ||
35 | QString lang = getenv( "LANG" ); | 39 | QString lang = getenv( "LANG" ); |
36 | if (lang.isNull()) | 40 | if (lang.isNull()) |
37 | lang = "en"; | 41 | lang = "en"; |
38 | QTranslator *trans = new QTranslator(qApp); | 42 | QTranslator *trans = new QTranslator(qApp); |
39 | QString type = (*it).left( (*it).find(".") ); | 43 | QString type = (*it).left( (*it).find(".") ); |
40 | if (type.left(3) == "lib") | 44 | if (type.left(3) == "lib") |
41 | type = type.mid(3); | 45 | type = type.mid(3); |
42 | type = type.right( type.find("lib") ); | 46 | type = type.right( type.find("lib") ); |
43 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 47 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
44 | if ( trans->load( tfn )) | 48 | if ( trans->load( tfn )) |
45 | qApp->installTranslator( trans ); | 49 | qApp->installTranslator( trans ); |
46 | else | 50 | else |
47 | delete trans; | 51 | delete trans; |
48 | } | 52 | } |
49 | } | 53 | } |
50 | 54 | ||
51 | a.showMainDocumentWidget(tabwidget); | 55 | a.showMainDocumentWidget(tabwidget); |
52 | return a.exec(); | 56 | return a.exec(); |
53 | } | 57 | } |
diff --git a/core/apps/textedit/filePermissions.cpp b/core/apps/textedit/filePermissions.cpp index db353a9..a059dce 100644 --- a/core/apps/textedit/filePermissions.cpp +++ b/core/apps/textedit/filePermissions.cpp | |||
@@ -1,270 +1,270 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2002 ljp ljp@llornkcor.com | 2 | ** copyright 2002 ljp ljp@llornkcor.com |
3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter | 3 | ** Created: Sat Feb 23 19:44:40 2002 L.J. Potter |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <qfileinfo.h> | 16 | #include <qfileinfo.h> |
17 | 17 | ||
18 | #include <qcheckbox.h> | 18 | #include <qcheckbox.h> |
19 | #include <qlabel.h> | 19 | #include <qlabel.h> |
20 | #include <qlineedit.h> | 20 | #include <qlineedit.h> |
21 | #include <qmessagebox.h> | 21 | #include <qmessagebox.h> |
22 | 22 | ||
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <sys/stat.h> | 24 | #include <sys/stat.h> |
25 | #include <stdlib.h> | 25 | #include <stdlib.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <pwd.h> | 27 | #include <pwd.h> |
28 | #include <grp.h> | 28 | #include <grp.h> |
29 | 29 | ||
30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) | 30 | filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName ) |
31 | : QDialog( parent, name, modal, fl ) | 31 | : QDialog( parent, name, modal, fl ) |
32 | { | 32 | { |
33 | if ( !name ) | 33 | if ( !name ) |
34 | setName( tr("File Permissions") ); | 34 | setName( tr("File Permissions") ); |
35 | // qDebug("FilePermissions "+fileName); | 35 | // odebug << "FilePermissions "+fileName << oendl; |
36 | resize( 236, 210 ); | 36 | resize( 236, 210 ); |
37 | setMaximumSize( QSize( 236, 210 ) ); | 37 | setMaximumSize( QSize( 236, 210 ) ); |
38 | setCaption( tr( "Set File Permissions" ) ); | 38 | setCaption( tr( "Set File Permissions" ) ); |
39 | 39 | ||
40 | TextLabel1 = new QLabel( this, "TextLabel1" ); | 40 | TextLabel1 = new QLabel( this, "TextLabel1" ); |
41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); | 41 | TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) ); |
42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); | 42 | TextLabel1->setText( tr( "Set file permissions for:" ) ); |
43 | 43 | ||
44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); | 44 | LineEdit1 = new QLineEdit( this, "LineEdit1" ); |
45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); | 45 | LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) ); |
46 | LineEdit1->setReadOnly(true); | 46 | LineEdit1->setReadOnly(true); |
47 | 47 | ||
48 | TextLabel4 = new QLabel( this, "TextLabel4" ); | 48 | TextLabel4 = new QLabel( this, "TextLabel4" ); |
49 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); | 49 | TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) ); |
50 | TextLabel4->setText( tr( "owner" ) ); | 50 | TextLabel4->setText( tr( "owner" ) ); |
51 | 51 | ||
52 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); | 52 | TextLabel4_2 = new QLabel( this, "TextLabel4_2" ); |
53 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); | 53 | TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) ); |
54 | TextLabel4_2->setText( tr( "group" ) ); | 54 | TextLabel4_2->setText( tr( "group" ) ); |
55 | 55 | ||
56 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); | 56 | TextLabel4_3 = new QLabel( this, "TextLabel4_3" ); |
57 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); | 57 | TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) ); |
58 | TextLabel4_3->setText( tr( "others" ) ); | 58 | TextLabel4_3->setText( tr( "others" ) ); |
59 | 59 | ||
60 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); | 60 | CheckBox1 = new QCheckBox( this, "CheckBox1" ); |
61 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); | 61 | CheckBox1->setGeometry( QRect( 75, 85, 20, 16 ) ); |
62 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); | 62 | connect(CheckBox1, SIGNAL(released()),this,SLOT(ownReadCheck())); |
63 | 63 | ||
64 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); | 64 | CheckBox1_2 = new QCheckBox( this, "CheckBox1_2" ); |
65 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); | 65 | CheckBox1_2->setGeometry( QRect( 135, 85, 20, 16 ) ); |
66 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); | 66 | connect(CheckBox1_2, SIGNAL(released()),this,SLOT(ownWriteCheck())); |
67 | 67 | ||
68 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); | 68 | CheckBox1_3 = new QCheckBox( this, "CheckBox1_3" ); |
69 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); | 69 | CheckBox1_3->setGeometry( QRect( 195, 85, 20, 16 ) ); |
70 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); | 70 | connect(CheckBox1_3, SIGNAL(released()),this,SLOT(ownExeCheck())); |
71 | 71 | ||
72 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); | 72 | CheckBox1_4 = new QCheckBox( this, "CheckBox1_4" ); |
73 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); | 73 | CheckBox1_4->setGeometry( QRect( 75, 105, 20, 16 ) ); |
74 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); | 74 | connect(CheckBox1_4, SIGNAL(released()),this,SLOT(grpReadCheck())); |
75 | 75 | ||
76 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); | 76 | CheckBox1_5 = new QCheckBox( this, "CheckBox1_5" ); |
77 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); | 77 | CheckBox1_5->setGeometry( QRect( 135, 105, 20, 16 ) ); |
78 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); | 78 | connect(CheckBox1_5, SIGNAL(released()),this,SLOT(grpWriteCheck())); |
79 | 79 | ||
80 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); | 80 | CheckBox1_6 = new QCheckBox( this, "CheckBox1_6" ); |
81 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); | 81 | CheckBox1_6->setGeometry( QRect( 195, 105, 20, 16 ) ); |
82 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); | 82 | connect(CheckBox1_6, SIGNAL(released()),this,SLOT(grpExeCheck())); |
83 | 83 | ||
84 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); | 84 | CheckBox1_7 = new QCheckBox( this, "CheckBox1_7" ); |
85 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); | 85 | CheckBox1_7->setGeometry( QRect( 75, 125, 16, 16 ) ); |
86 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); | 86 | connect(CheckBox1_7, SIGNAL(released()),this,SLOT(wrldReadCheck())); |
87 | 87 | ||
88 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); | 88 | CheckBox1_8 = new QCheckBox( this, "CheckBox1_8" ); |
89 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); | 89 | CheckBox1_8->setGeometry( QRect( 135, 125, 20, 16 ) ); |
90 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); | 90 | connect(CheckBox1_8, SIGNAL(released()),this,SLOT(wrldWriteCheck())); |
91 | 91 | ||
92 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); | 92 | CheckBox1_8_2 = new QCheckBox( this, "CheckBox1_8_2" ); |
93 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); | 93 | CheckBox1_8_2->setGeometry( QRect( 195, 125, 20, 16 ) ); |
94 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); | 94 | connect(CheckBox1_8_2, SIGNAL(released()),this,SLOT(wrldExeCheck())); |
95 | 95 | ||
96 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); | 96 | GroupLineEdit = new QLineEdit( this, "GroupLineEdit" ); |
97 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); | 97 | GroupLineEdit->setGeometry( QRect( 125, 155, 106, 22 ) ); |
98 | 98 | ||
99 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); | 99 | OwnerLineEdit = new QLineEdit( this, "OwnerLineEdit" ); |
100 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); | 100 | OwnerLineEdit->setGeometry( QRect( 10, 155, 106, 22 ) ); |
101 | 101 | ||
102 | TextLabel5 = new QLabel( this, "TextLabel5" ); | 102 | TextLabel5 = new QLabel( this, "TextLabel5" ); |
103 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); | 103 | TextLabel5->setGeometry( QRect( 45, 180, 40, 16 ) ); |
104 | TextLabel5->setText( tr( "Owner" ) ); | 104 | TextLabel5->setText( tr( "Owner" ) ); |
105 | 105 | ||
106 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); | 106 | TextLabel5_2 = new QLabel( this, "TextLabel5_2" ); |
107 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); | 107 | TextLabel5_2->setGeometry( QRect( 155, 180, 40, 16 ) ); |
108 | TextLabel5_2->setText( tr( "Group" ) ); | 108 | TextLabel5_2->setText( tr( "Group" ) ); |
109 | 109 | ||
110 | ModeLine = new QLineEdit( this, "TextLabelMode" ); | 110 | ModeLine = new QLineEdit( this, "TextLabelMode" ); |
111 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); | 111 | ModeLine->setGeometry( QRect( 10, 60, 40, 15 ) ); |
112 | 112 | ||
113 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); | 113 | TextLabel3_2 = new QLabel( this, "TextLabel3_2" ); |
114 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); | 114 | TextLabel3_2->setGeometry( QRect( 60, 55, 50, 20 ) ); |
115 | TextLabel3_2->setText( tr( "read" ) ); | 115 | TextLabel3_2->setText( tr( "read" ) ); |
116 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 116 | TextLabel3_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
117 | 117 | ||
118 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); | 118 | TextLabel3_2_2 = new QLabel( this, "TextLabel3_2_2" ); |
119 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); | 119 | TextLabel3_2_2->setGeometry( QRect( 120, 55, 50, 20 ) ); |
120 | TextLabel3_2_2->setText( tr( "write" ) ); | 120 | TextLabel3_2_2->setText( tr( "write" ) ); |
121 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 121 | TextLabel3_2_2->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
122 | 122 | ||
123 | TextLabel3 = new QLabel( this, "TextLabel3" ); | 123 | TextLabel3 = new QLabel( this, "TextLabel3" ); |
124 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); | 124 | TextLabel3->setGeometry( QRect( 180, 55, 50, 20 ) ); |
125 | TextLabel3->setText( tr( "execute" ) ); | 125 | TextLabel3->setText( tr( "execute" ) ); |
126 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); | 126 | TextLabel3->setAlignment( int( QLabel::AlignBottom | QLabel::AlignHCenter ) ); |
127 | 127 | ||
128 | struct stat buf; | 128 | struct stat buf; |
129 | mode_t mode; | 129 | mode_t mode; |
130 | file = fileName; | 130 | file = fileName; |
131 | QFileInfo fi(file); | 131 | QFileInfo fi(file); |
132 | 132 | ||
133 | LineEdit1->setText( file); | 133 | LineEdit1->setText( file); |
134 | OwnerLineEdit->setText( fi.owner()); | 134 | OwnerLineEdit->setText( fi.owner()); |
135 | GroupLineEdit->setText( fi.group()); | 135 | GroupLineEdit->setText( fi.group()); |
136 | 136 | ||
137 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } | 137 | if( fi.permission( QFileInfo::ReadUser)) { CheckBox1->setChecked(true); } |
138 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } | 138 | if( fi.permission( QFileInfo::WriteUser)) { CheckBox1_2->setChecked(true); } |
139 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } | 139 | if( fi.permission( QFileInfo::ExeUser)) { CheckBox1_3->setChecked(true); } |
140 | 140 | ||
141 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } | 141 | if( fi.permission( QFileInfo::ReadGroup)) { CheckBox1_4->setChecked(true); } |
142 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } | 142 | if( fi.permission( QFileInfo::WriteGroup)) { CheckBox1_5->setChecked(true); } |
143 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } | 143 | if( fi.permission( QFileInfo::ExeGroup)) { CheckBox1_6->setChecked(true); } |
144 | 144 | ||
145 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } | 145 | if( fi.permission( QFileInfo::ReadOther)) { CheckBox1_7->setChecked(true); } |
146 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } | 146 | if( fi.permission( QFileInfo::WriteOther)) { CheckBox1_8->setChecked(true); } |
147 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } | 147 | if( fi.permission( QFileInfo::ExeOther)) { CheckBox1_8_2->setChecked(true); } |
148 | 148 | ||
149 | stat(file.latin1(), &buf); | 149 | stat(file.latin1(), &buf); |
150 | mode = buf.st_mode; | 150 | mode = buf.st_mode; |
151 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); | 151 | modeStr.sprintf("%#o", buf.st_mode & ~(S_IFMT) ); |
152 | ModeLine->setText(modeStr); | 152 | ModeLine->setText(modeStr); |
153 | bool ok; | 153 | bool ok; |
154 | i_mode = modeStr.toInt(&ok,10); | 154 | i_mode = modeStr.toInt(&ok,10); |
155 | 155 | ||
156 | } | 156 | } |
157 | 157 | ||
158 | /* | 158 | /* |
159 | * Destroys the object and frees any allocated resources | 159 | * Destroys the object and frees any allocated resources |
160 | */ | 160 | */ |
161 | filePermissions::~filePermissions() | 161 | filePermissions::~filePermissions() |
162 | { | 162 | { |
163 | } | 163 | } |
164 | 164 | ||
165 | 165 | ||
166 | // might this be better as a callback routine??? | 166 | // might this be better as a callback routine??? |
167 | void filePermissions::ownReadCheck() { | 167 | void filePermissions::ownReadCheck() { |
168 | if(CheckBox1->isChecked()) { i_mode +=400; } | 168 | if(CheckBox1->isChecked()) { i_mode +=400; } |
169 | else i_mode -=400; | 169 | else i_mode -=400; |
170 | modeStr.sprintf("0%d",i_mode); | 170 | modeStr.sprintf("0%d",i_mode); |
171 | ModeLine->setText( modeStr); | 171 | ModeLine->setText( modeStr); |
172 | // 0400 | 172 | // 0400 |
173 | } | 173 | } |
174 | 174 | ||
175 | void filePermissions::ownWriteCheck() { | 175 | void filePermissions::ownWriteCheck() { |
176 | if(CheckBox1_2->isChecked()) { i_mode +=200; } | 176 | if(CheckBox1_2->isChecked()) { i_mode +=200; } |
177 | else i_mode -=200; | 177 | else i_mode -=200; |
178 | modeStr.sprintf("0%d",i_mode); | 178 | modeStr.sprintf("0%d",i_mode); |
179 | ModeLine->setText(modeStr); | 179 | ModeLine->setText(modeStr); |
180 | // 0200 | 180 | // 0200 |
181 | } | 181 | } |
182 | 182 | ||
183 | void filePermissions::ownExeCheck() { | 183 | void filePermissions::ownExeCheck() { |
184 | if(CheckBox1_3->isChecked()) { i_mode +=100; } | 184 | if(CheckBox1_3->isChecked()) { i_mode +=100; } |
185 | else i_mode -=100; | 185 | else i_mode -=100; |
186 | modeStr.sprintf("0%d",i_mode); | 186 | modeStr.sprintf("0%d",i_mode); |
187 | ModeLine->setText(modeStr); | 187 | ModeLine->setText(modeStr); |
188 | // 0100 | 188 | // 0100 |
189 | } | 189 | } |
190 | 190 | ||
191 | void filePermissions::grpReadCheck() { | 191 | void filePermissions::grpReadCheck() { |
192 | if(CheckBox1_4->isChecked()) { i_mode +=40; } | 192 | if(CheckBox1_4->isChecked()) { i_mode +=40; } |
193 | else i_mode -=40; | 193 | else i_mode -=40; |
194 | modeStr.sprintf("0%d",i_mode); | 194 | modeStr.sprintf("0%d",i_mode); |
195 | ModeLine->setText(modeStr); | 195 | ModeLine->setText(modeStr); |
196 | // 0040 | 196 | // 0040 |
197 | } | 197 | } |
198 | 198 | ||
199 | void filePermissions::grpWriteCheck() { | 199 | void filePermissions::grpWriteCheck() { |
200 | if(CheckBox1_5->isChecked()) { i_mode +=20; } | 200 | if(CheckBox1_5->isChecked()) { i_mode +=20; } |
201 | else i_mode -=20; | 201 | else i_mode -=20; |
202 | modeStr.sprintf("0%d",i_mode); | 202 | modeStr.sprintf("0%d",i_mode); |
203 | ModeLine->setText(modeStr); | 203 | ModeLine->setText(modeStr); |
204 | // 0020 | 204 | // 0020 |
205 | } | 205 | } |
206 | 206 | ||
207 | void filePermissions::grpExeCheck() { | 207 | void filePermissions::grpExeCheck() { |
208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } | 208 | if(CheckBox1_6->isChecked()) { i_mode +=10; } |
209 | else i_mode -=10; | 209 | else i_mode -=10; |
210 | modeStr.sprintf("0%d",i_mode); | 210 | modeStr.sprintf("0%d",i_mode); |
211 | ModeLine->setText(modeStr); | 211 | ModeLine->setText(modeStr); |
212 | // 0010 | 212 | // 0010 |
213 | } | 213 | } |
214 | 214 | ||
215 | void filePermissions::wrldReadCheck() { | 215 | void filePermissions::wrldReadCheck() { |
216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } | 216 | if(CheckBox1_7->isChecked()) { i_mode +=4; } |
217 | else i_mode -=4; | 217 | else i_mode -=4; |
218 | modeStr.sprintf("0%d",i_mode); | 218 | modeStr.sprintf("0%d",i_mode); |
219 | ModeLine->setText(modeStr); | 219 | ModeLine->setText(modeStr); |
220 | // 0004 | 220 | // 0004 |
221 | } | 221 | } |
222 | 222 | ||
223 | void filePermissions::wrldWriteCheck() { | 223 | void filePermissions::wrldWriteCheck() { |
224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } | 224 | if(CheckBox1_8->isChecked()) { i_mode +=2; } |
225 | else i_mode -=2; | 225 | else i_mode -=2; |
226 | modeStr.sprintf("0%d",i_mode); | 226 | modeStr.sprintf("0%d",i_mode); |
227 | ModeLine->setText(modeStr); | 227 | ModeLine->setText(modeStr); |
228 | // 0002 | 228 | // 0002 |
229 | } | 229 | } |
230 | 230 | ||
231 | void filePermissions::wrldExeCheck() { | 231 | void filePermissions::wrldExeCheck() { |
232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } | 232 | if(CheckBox1_8_2->isChecked()) { i_mode +=1; } |
233 | else i_mode -=1; | 233 | else i_mode -=1; |
234 | modeStr.sprintf("0%d",i_mode); | 234 | modeStr.sprintf("0%d",i_mode); |
235 | ModeLine->setText(modeStr); | 235 | ModeLine->setText(modeStr); |
236 | // 0001 | 236 | // 0001 |
237 | } | 237 | } |
238 | 238 | ||
239 | void filePermissions::accept() { | 239 | void filePermissions::accept() { |
240 | 240 | ||
241 | QFileInfo fi(file); | 241 | QFileInfo fi(file); |
242 | struct passwd *pwd=0; | 242 | struct passwd *pwd=0; |
243 | struct group *grp=0; | 243 | struct group *grp=0; |
244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); | 244 | pwd = getpwnam(OwnerLineEdit->text().latin1() ); |
245 | if(pwd == NULL) { | 245 | if(pwd == NULL) { |
246 | perror("getpwnam"); | 246 | perror("getpwnam"); |
247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); | 247 | QMessageBox::warning(this,tr("Warning"),tr("Error- no user")); |
248 | return; | 248 | return; |
249 | } else { | 249 | } else { |
250 | grp = getgrnam(GroupLineEdit->text().latin1()); | 250 | grp = getgrnam(GroupLineEdit->text().latin1()); |
251 | if(grp==NULL) { | 251 | if(grp==NULL) { |
252 | perror("getgrnam"); | 252 | perror("getgrnam"); |
253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); | 253 | QMessageBox::warning(this,tr("Warning"),tr("Error- no group")); |
254 | return; | 254 | return; |
255 | } | 255 | } |
256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { | 256 | if( chown( file.latin1(), pwd->pw_uid, grp->gr_gid) <0) { |
257 | perror("chown"); | 257 | perror("chown"); |
258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); | 258 | QMessageBox::warning(this,tr("Warning"),tr("Error setting ownership or group")); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | bool ok; | 261 | bool ok; |
262 | uint moder = modeStr.toUInt(&ok,8); | 262 | uint moder = modeStr.toUInt(&ok,8); |
263 | if( chmod( file.latin1(), moder) < 0) { | 263 | if( chmod( file.latin1(), moder) < 0) { |
264 | perror("chmod"); | 264 | perror("chmod"); |
265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); | 265 | QMessageBox::warning(this,tr("Warning"),tr("Error setting mode")); |
266 | return; | 266 | return; |
267 | } | 267 | } |
268 | } | 268 | } |
269 | close(); | 269 | close(); |
270 | } | 270 | } |
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 5bb65a9..c9178a5 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp | |||
@@ -1,1195 +1,1198 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | // textedit.cpp | 2 | // textedit.cpp |
3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 3 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
4 | ** | 4 | ** |
5 | ** This file is part of Opie Environment. | 5 | ** This file is part of Opie Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | **********************************************************************/ | 12 | **********************************************************************/ |
13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 | 13 | // changes added by L. J. Potter Sun 02-17-2002 21:31:31 |
14 | |||
14 | #include "textedit.h" | 15 | #include "textedit.h" |
15 | #include "filePermissions.h" | 16 | #include "filePermissions.h" |
16 | 17 | ||
17 | 18 | /* OPIE */ | |
19 | #include <opie2/odebug.h> | ||
18 | #include <opie2/ofileselector.h> | 20 | #include <opie2/ofileselector.h> |
19 | #include <opie2/ofiledialog.h> | 21 | #include <opie2/ofiledialog.h> |
20 | #include <opie2/ofontselector.h> | 22 | #include <opie2/ofontselector.h> |
21 | |||
22 | #include <qpe/resource.h> | 23 | #include <qpe/resource.h> |
23 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
24 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | using namespace Opie::Core; | ||
27 | using namespace Opie::Ui; | ||
28 | |||
29 | /* QT */ | ||
25 | #include <qmenubar.h> | 30 | #include <qmenubar.h> |
26 | #include <qtoolbar.h> | 31 | #include <qtoolbar.h> |
27 | |||
28 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
29 | #include <qclipboard.h> | 33 | #include <qclipboard.h> |
30 | #include <qaction.h> | 34 | #include <qaction.h> |
31 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
32 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
33 | #include <qlayout.h> | 37 | #include <qlayout.h> |
34 | #include <qtimer.h> | 38 | #include <qtimer.h> |
35 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | |||
41 | /* STD */ | ||
36 | #include <unistd.h> | 42 | #include <unistd.h> |
37 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
38 | #include <stdlib.h> //getenv | 44 | #include <stdlib.h> //getenv |
39 | 45 | ||
40 | using namespace Opie::Ui; | ||
41 | |||
42 | #if QT_VERSION < 300 | 46 | #if QT_VERSION < 300 |
43 | |||
44 | class QpeEditor : public QMultiLineEdit | 47 | class QpeEditor : public QMultiLineEdit |
45 | { | 48 | { |
46 | 49 | ||
47 | public: | 50 | public: |
48 | QpeEditor( QWidget *parent, const char * name = 0 ) | 51 | QpeEditor( QWidget *parent, const char * name = 0 ) |
49 | : QMultiLineEdit( parent, name ) { | 52 | : QMultiLineEdit( parent, name ) { |
50 | clearTableFlags(); | 53 | clearTableFlags(); |
51 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); | 54 | setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar ); |
52 | } | 55 | } |
53 | 56 | ||
54 | void find( const QString &txt, bool caseSensitive, | 57 | void find( const QString &txt, bool caseSensitive, |
55 | bool backwards ); | 58 | bool backwards ); |
56 | protected: | 59 | protected: |
57 | bool markIt; | 60 | bool markIt; |
58 | int line1, line2, col1, col2; | 61 | int line1, line2, col1, col2; |
59 | void mousePressEvent( QMouseEvent * ); | 62 | void mousePressEvent( QMouseEvent * ); |
60 | void mouseReleaseEvent( QMouseEvent * ); | 63 | void mouseReleaseEvent( QMouseEvent * ); |
61 | 64 | ||
62 | //public slots: | 65 | //public slots: |
63 | /* | 66 | /* |
64 | signals: | 67 | signals: |
65 | void notFound(); | 68 | void notFound(); |
66 | void searchWrapped(); | 69 | void searchWrapped(); |
67 | */ | 70 | */ |
68 | 71 | ||
69 | private: | 72 | private: |
70 | 73 | ||
71 | }; | 74 | }; |
72 | 75 | ||
73 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { | 76 | void QpeEditor::mousePressEvent( QMouseEvent *e ) { |
74 | switch(e->button()) { | 77 | switch(e->button()) { |
75 | case RightButton: | 78 | case RightButton: |
76 | { //rediculous workaround for qt popup menu | 79 | { //rediculous workaround for qt popup menu |
77 | //and the hold right click mechanism | 80 | //and the hold right click mechanism |
78 | this->setSelection( line1, col1, line2, col2); | 81 | this->setSelection( line1, col1, line2, col2); |
79 | QMultiLineEdit::mousePressEvent( e ); | 82 | QMultiLineEdit::mousePressEvent( e ); |
80 | markIt = false; | 83 | markIt = false; |
81 | } | 84 | } |
82 | break; | 85 | break; |
83 | default: | 86 | default: |
84 | { | 87 | { |
85 | if(!markIt) { | 88 | if(!markIt) { |
86 | int line, col; | 89 | int line, col; |
87 | this->getCursorPosition(&line, &col); | 90 | this->getCursorPosition(&line, &col); |
88 | line1=line2=line; | 91 | line1=line2=line; |
89 | col1=col2=col; | 92 | col1=col2=col; |
90 | } | 93 | } |
91 | QMultiLineEdit::mousePressEvent( e ); | 94 | QMultiLineEdit::mousePressEvent( e ); |
92 | } | 95 | } |
93 | break; | 96 | break; |
94 | }; | 97 | }; |
95 | } | 98 | } |
96 | 99 | ||
97 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { | 100 | void QpeEditor::mouseReleaseEvent( QMouseEvent * ) { |
98 | if(this->hasMarkedText()) { | 101 | if(this->hasMarkedText()) { |
99 | markIt = true; | 102 | markIt = true; |
100 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); | 103 | this->getMarkedRegion( &line1, &col1, &line2, & col2 ); |
101 | } else { | 104 | } else { |
102 | markIt = false; | 105 | markIt = false; |
103 | } | 106 | } |
104 | } | 107 | } |
105 | 108 | ||
106 | void QpeEditor::find ( const QString &txt, bool caseSensitive, | 109 | void QpeEditor::find ( const QString &txt, bool caseSensitive, |
107 | bool backwards ) | 110 | bool backwards ) |
108 | { | 111 | { |
109 | static bool wrap = false; | 112 | static bool wrap = false; |
110 | int line, col; | 113 | int line, col; |
111 | if ( wrap ) { | 114 | if ( wrap ) { |
112 | if ( !backwards ) | 115 | if ( !backwards ) |
113 | line = col = 0; | 116 | line = col = 0; |
114 | wrap = false; | 117 | wrap = false; |
115 | // emit searchWrapped(); | 118 | // emit searchWrapped(); |
116 | } else { | 119 | } else { |
117 | getCursorPosition( &line, &col ); | 120 | getCursorPosition( &line, &col ); |
118 | } | 121 | } |
119 | //ignore backwards for now.... | 122 | //ignore backwards for now.... |
120 | if ( !backwards ) { | 123 | if ( !backwards ) { |
121 | for ( ; ; ) { | 124 | for ( ; ; ) { |
122 | if ( line >= numLines() ) { | 125 | if ( line >= numLines() ) { |
123 | wrap = true; | 126 | wrap = true; |
124 | //emit notFound(); | 127 | //emit notFound(); |
125 | break; | 128 | break; |
126 | } | 129 | } |
127 | int findCol = getString( line )->find( txt, col, caseSensitive ); | 130 | int findCol = getString( line )->find( txt, col, caseSensitive ); |
128 | if ( findCol >= 0 ) { | 131 | if ( findCol >= 0 ) { |
129 | setCursorPosition( line, findCol, false ); | 132 | setCursorPosition( line, findCol, false ); |
130 | col = findCol + txt.length(); | 133 | col = findCol + txt.length(); |
131 | setCursorPosition( line, col, true ); | 134 | setCursorPosition( line, col, true ); |
132 | 135 | ||
133 | //found = true; | 136 | //found = true; |
134 | break; | 137 | break; |
135 | } | 138 | } |
136 | line++; | 139 | line++; |
137 | col = 0; | 140 | col = 0; |
138 | } | 141 | } |
139 | } | 142 | } |
140 | } | 143 | } |
141 | 144 | ||
142 | 145 | ||
143 | #else | 146 | #else |
144 | 147 | ||
145 | #error "Must make a QpeEditor that inherits QTextEdit" | 148 | #error "Must make a QpeEditor that inherits QTextEdit" |
146 | 149 | ||
147 | #endif | 150 | #endif |
148 | 151 | ||
149 | 152 | ||
150 | static const int nfontsizes = 6; | 153 | static const int nfontsizes = 6; |
151 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; | 154 | static const int fontsize[nfontsizes] = {8,10,12,14,18,24}; |
152 | 155 | ||
153 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) | 156 | TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) |
154 | : QMainWindow( parent, name, f ), bFromDocView( false ) | 157 | : QMainWindow( parent, name, f ), bFromDocView( false ) |
155 | { | 158 | { |
156 | doc = 0; | 159 | doc = 0; |
157 | edited=false; | 160 | edited=false; |
158 | fromSetDocument=false; | 161 | fromSetDocument=false; |
159 | 162 | ||
160 | setToolBarsMovable( false ); | 163 | setToolBarsMovable( false ); |
161 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); | 164 | connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) ); |
162 | 165 | ||
163 | channel = new QCopChannel( "QPE/Application/textedit", this ); | 166 | channel = new QCopChannel( "QPE/Application/textedit", this ); |
164 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 167 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
165 | this, SLOT(receive(const QCString&,const QByteArray&)) ); | 168 | this, SLOT(receive(const QCString&,const QByteArray&)) ); |
166 | 169 | ||
167 | setIcon( Resource::loadPixmap( "TextEditor" ) ); | 170 | setIcon( Resource::loadPixmap( "TextEditor" ) ); |
168 | 171 | ||
169 | QToolBar *bar = new QToolBar( this ); | 172 | QToolBar *bar = new QToolBar( this ); |
170 | bar->setHorizontalStretchable( true ); | 173 | bar->setHorizontalStretchable( true ); |
171 | menu = bar; | 174 | menu = bar; |
172 | 175 | ||
173 | QMenuBar *mb = new QMenuBar( bar ); | 176 | QMenuBar *mb = new QMenuBar( bar ); |
174 | QPopupMenu *file = new QPopupMenu( this ); | 177 | QPopupMenu *file = new QPopupMenu( this ); |
175 | QPopupMenu *edit = new QPopupMenu( this ); | 178 | QPopupMenu *edit = new QPopupMenu( this ); |
176 | QPopupMenu *advancedMenu = new QPopupMenu(this); | 179 | QPopupMenu *advancedMenu = new QPopupMenu(this); |
177 | 180 | ||
178 | font = new QPopupMenu( this ); | 181 | font = new QPopupMenu( this ); |
179 | 182 | ||
180 | bar = new QToolBar( this ); | 183 | bar = new QToolBar( this ); |
181 | editBar = bar; | 184 | editBar = bar; |
182 | 185 | ||
183 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), | 186 | QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), |
184 | QString::null, 0, this, 0 ); | 187 | QString::null, 0, this, 0 ); |
185 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); | 188 | connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); |
186 | // a->addTo( bar ); | 189 | // a->addTo( bar ); |
187 | a->addTo( file ); | 190 | a->addTo( file ); |
188 | 191 | ||
189 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), | 192 | a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), |
190 | QString::null, 0, this, 0 ); | 193 | QString::null, 0, this, 0 ); |
191 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); | 194 | connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); |
192 | a->addTo( bar ); | 195 | a->addTo( bar ); |
193 | a->addTo( file ); | 196 | a->addTo( file ); |
194 | 197 | ||
195 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , | 198 | a = new QAction( tr( "Save" ), Resource::loadPixmap("save") , |
196 | QString::null, 0, this, 0 ); | 199 | QString::null, 0, this, 0 ); |
197 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); | 200 | connect( a, SIGNAL( activated() ), this, SLOT( save() ) ); |
198 | file->insertSeparator(); | 201 | file->insertSeparator(); |
199 | a->addTo( bar ); | 202 | a->addTo( bar ); |
200 | a->addTo( file ); | 203 | a->addTo( file ); |
201 | 204 | ||
202 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , | 205 | a = new QAction( tr( "Save As" ), Resource::loadPixmap("save") , |
203 | QString::null, 0, this, 0 ); | 206 | QString::null, 0, this, 0 ); |
204 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); | 207 | connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) ); |
205 | a->addTo( file ); | 208 | a->addTo( file ); |
206 | 209 | ||
207 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), | 210 | a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), |
208 | QString::null, 0, this, 0 ); | 211 | QString::null, 0, this, 0 ); |
209 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); | 212 | connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); |
210 | a->addTo( editBar ); | 213 | a->addTo( editBar ); |
211 | a->addTo( edit ); | 214 | a->addTo( edit ); |
212 | 215 | ||
213 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), | 216 | a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), |
214 | QString::null, 0, this, 0 ); | 217 | QString::null, 0, this, 0 ); |
215 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); | 218 | connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) ); |
216 | a->addTo( editBar ); | 219 | a->addTo( editBar ); |
217 | a->addTo( edit ); | 220 | a->addTo( edit ); |
218 | 221 | ||
219 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), | 222 | a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), |
220 | QString::null, 0, this, 0 ); | 223 | QString::null, 0, this, 0 ); |
221 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); | 224 | connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); |
222 | a->addTo( editBar ); | 225 | a->addTo( editBar ); |
223 | a->addTo( edit ); | 226 | a->addTo( edit ); |
224 | 227 | ||
225 | 228 | ||
226 | #ifndef QT_NO_CLIPBOARD | 229 | #ifndef QT_NO_CLIPBOARD |
227 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), | 230 | a = new QAction( tr( "Insert Time and Date" ), Resource::loadPixmap( "paste" ), |
228 | QString::null, 0, this, 0 ); | 231 | QString::null, 0, this, 0 ); |
229 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); | 232 | connect( a, SIGNAL( activated() ), this, SLOT( editPasteTimeDate() ) ); |
230 | a->addTo( edit ); | 233 | a->addTo( edit ); |
231 | #endif | 234 | #endif |
232 | 235 | ||
233 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), | 236 | a = new QAction( tr( "Goto Line..." ), Resource::loadPixmap( "find" ), |
234 | QString::null, 0, this, 0 ); | 237 | QString::null, 0, this, 0 ); |
235 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); | 238 | connect( a, SIGNAL( activated() ), this, SLOT( gotoLine() ) ); |
236 | edit->insertSeparator(); | 239 | edit->insertSeparator(); |
237 | a->addTo( edit ); | 240 | a->addTo( edit ); |
238 | 241 | ||
239 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), | 242 | a = new QAction( tr( "Find..." ), Resource::loadPixmap( "find" ), |
240 | QString::null, 0, this, 0 ); | 243 | QString::null, 0, this, 0 ); |
241 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); | 244 | connect( a, SIGNAL( activated() ), this, SLOT( editFind() ) ); |
242 | a->addTo( bar ); | 245 | a->addTo( bar ); |
243 | a->addTo( edit ); | 246 | a->addTo( edit ); |
244 | 247 | ||
245 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); | 248 | zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); |
246 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); | 249 | connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); |
247 | zin->addTo( font ); | 250 | zin->addTo( font ); |
248 | 251 | ||
249 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); | 252 | zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); |
250 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); | 253 | connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); |
251 | zout->addTo( font ); | 254 | zout->addTo( font ); |
252 | 255 | ||
253 | font->insertSeparator(); | 256 | font->insertSeparator(); |
254 | 257 | ||
255 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); | 258 | font->insertItem(tr("Font"), this, SLOT(changeFont()) ); |
256 | 259 | ||
257 | font->insertSeparator(); | 260 | font->insertSeparator(); |
258 | font->insertItem(tr("Advanced Features"), advancedMenu); | 261 | font->insertItem(tr("Advanced Features"), advancedMenu); |
259 | 262 | ||
260 | QAction *wa = new QAction( tr("Wrap lines"), | 263 | QAction *wa = new QAction( tr("Wrap lines"), |
261 | QString::null, 0, this, 0 ); | 264 | QString::null, 0, this, 0 ); |
262 | connect( wa, SIGNAL( toggled(bool) ), | 265 | connect( wa, SIGNAL( toggled(bool) ), |
263 | this, SLOT( setWordWrap(bool) ) ); | 266 | this, SLOT( setWordWrap(bool) ) ); |
264 | wa->setToggleAction(true); | 267 | wa->setToggleAction(true); |
265 | wa->addTo( advancedMenu); | 268 | wa->addTo( advancedMenu); |
266 | 269 | ||
267 | nStart = new QAction( tr("Start with new file"), | 270 | nStart = new QAction( tr("Start with new file"), |
268 | QString::null, 0, this, 0 ); | 271 | QString::null, 0, this, 0 ); |
269 | connect( nStart, SIGNAL( toggled(bool) ), | 272 | connect( nStart, SIGNAL( toggled(bool) ), |
270 | this, SLOT( changeStartConfig(bool) ) ); | 273 | this, SLOT( changeStartConfig(bool) ) ); |
271 | nStart->setToggleAction(true); | 274 | nStart->setToggleAction(true); |
272 | nStart->addTo( advancedMenu ); | 275 | nStart->addTo( advancedMenu ); |
273 | nStart->setEnabled(false); | 276 | nStart->setEnabled(false); |
274 | 277 | ||
275 | nAdvanced = new QAction( tr("Prompt on Exit"), | 278 | nAdvanced = new QAction( tr("Prompt on Exit"), |
276 | QString::null, 0, this, 0 ); | 279 | QString::null, 0, this, 0 ); |
277 | connect( nAdvanced, SIGNAL( toggled(bool) ), | 280 | connect( nAdvanced, SIGNAL( toggled(bool) ), |
278 | this, SLOT( doPrompt(bool) ) ); | 281 | this, SLOT( doPrompt(bool) ) ); |
279 | nAdvanced->setToggleAction(true); | 282 | nAdvanced->setToggleAction(true); |
280 | nAdvanced->addTo( advancedMenu ); | 283 | nAdvanced->addTo( advancedMenu ); |
281 | 284 | ||
282 | desktopAction = new QAction( tr("Always open linked file"), | 285 | desktopAction = new QAction( tr("Always open linked file"), |
283 | QString::null, 0, this, 0 ); | 286 | QString::null, 0, this, 0 ); |
284 | connect( desktopAction, SIGNAL( toggled(bool) ), | 287 | connect( desktopAction, SIGNAL( toggled(bool) ), |
285 | this, SLOT( doDesktop(bool) ) ); | 288 | this, SLOT( doDesktop(bool) ) ); |
286 | desktopAction->setToggleAction(true); | 289 | desktopAction->setToggleAction(true); |
287 | desktopAction->addTo( advancedMenu); | 290 | desktopAction->addTo( advancedMenu); |
288 | 291 | ||
289 | filePermAction = new QAction( tr("File Permissions"), | 292 | filePermAction = new QAction( tr("File Permissions"), |
290 | QString::null, 0, this, 0 ); | 293 | QString::null, 0, this, 0 ); |
291 | connect( filePermAction, SIGNAL( toggled(bool) ), | 294 | connect( filePermAction, SIGNAL( toggled(bool) ), |
292 | this, SLOT( doFilePerms(bool) ) ); | 295 | this, SLOT( doFilePerms(bool) ) ); |
293 | filePermAction->setToggleAction(true); | 296 | filePermAction->setToggleAction(true); |
294 | filePermAction->addTo( advancedMenu); | 297 | filePermAction->addTo( advancedMenu); |
295 | 298 | ||
296 | searchBarAction = new QAction( tr("Search Bar Open"), | 299 | searchBarAction = new QAction( tr("Search Bar Open"), |
297 | QString::null, 0, this, 0 ); | 300 | QString::null, 0, this, 0 ); |
298 | connect( searchBarAction, SIGNAL( toggled(bool) ), | 301 | connect( searchBarAction, SIGNAL( toggled(bool) ), |
299 | this, SLOT( setSearchBar(bool) ) ); | 302 | this, SLOT( setSearchBar(bool) ) ); |
300 | searchBarAction->setToggleAction(true); | 303 | searchBarAction->setToggleAction(true); |
301 | searchBarAction->addTo( advancedMenu); | 304 | searchBarAction->addTo( advancedMenu); |
302 | 305 | ||
303 | nAutoSave = new QAction( tr("Auto Save 5 min."), | 306 | nAutoSave = new QAction( tr("Auto Save 5 min."), |
304 | QString::null, 0, this, 0 ); | 307 | QString::null, 0, this, 0 ); |
305 | connect( nAutoSave, SIGNAL( toggled(bool) ), | 308 | connect( nAutoSave, SIGNAL( toggled(bool) ), |
306 | this, SLOT( doTimer(bool) ) ); | 309 | this, SLOT( doTimer(bool) ) ); |
307 | nAutoSave->setToggleAction(true); | 310 | nAutoSave->setToggleAction(true); |
308 | nAutoSave->addTo( advancedMenu); | 311 | nAutoSave->addTo( advancedMenu); |
309 | 312 | ||
310 | 313 | ||
311 | //font->insertSeparator(); | 314 | //font->insertSeparator(); |
312 | 315 | ||
313 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); | 316 | //font->insertItem(tr("About"), this, SLOT( doAbout()) ); |
314 | 317 | ||
315 | mb->insertItem( tr( "File" ), file ); | 318 | mb->insertItem( tr( "File" ), file ); |
316 | mb->insertItem( tr( "Edit" ), edit ); | 319 | mb->insertItem( tr( "Edit" ), edit ); |
317 | mb->insertItem( tr( "View" ), font ); | 320 | mb->insertItem( tr( "View" ), font ); |
318 | 321 | ||
319 | searchBar = new QToolBar(this); | 322 | searchBar = new QToolBar(this); |
320 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); | 323 | addToolBar( searchBar, "Search", QMainWindow::Top, true ); |
321 | 324 | ||
322 | searchBar->setHorizontalStretchable( true ); | 325 | searchBar->setHorizontalStretchable( true ); |
323 | 326 | ||
324 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); | 327 | searchEdit = new QLineEdit( searchBar, "searchEdit" ); |
325 | searchBar->setStretchableWidget( searchEdit ); | 328 | searchBar->setStretchableWidget( searchEdit ); |
326 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), | 329 | connect( searchEdit, SIGNAL( textChanged(const QString&) ), |
327 | this, SLOT( search() ) ); | 330 | this, SLOT( search() ) ); |
328 | 331 | ||
329 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), | 332 | a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), |
330 | QString::null, 0, this, 0 ); | 333 | QString::null, 0, this, 0 ); |
331 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); | 334 | connect( a, SIGNAL( activated() ), this, SLOT( findNext() ) ); |
332 | a->addTo( searchBar ); | 335 | a->addTo( searchBar ); |
333 | a->addTo( edit ); | 336 | a->addTo( edit ); |
334 | 337 | ||
335 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), | 338 | a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), |
336 | QString::null, 0, this, 0 ); | 339 | QString::null, 0, this, 0 ); |
337 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); | 340 | connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); |
338 | a->addTo( searchBar ); | 341 | a->addTo( searchBar ); |
339 | 342 | ||
340 | edit->insertSeparator(); | 343 | edit->insertSeparator(); |
341 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), | 344 | a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), |
342 | QString::null, 0, this, 0 ); | 345 | QString::null, 0, this, 0 ); |
343 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); | 346 | connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); |
344 | a->addTo( edit ); | 347 | a->addTo( edit ); |
345 | 348 | ||
346 | searchBar->hide(); | 349 | searchBar->hide(); |
347 | 350 | ||
348 | editor = new QpeEditor( this ); | 351 | editor = new QpeEditor( this ); |
349 | setCentralWidget( editor ); | 352 | setCentralWidget( editor ); |
350 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 353 | editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
351 | connect( editor, SIGNAL( textChanged() ), | 354 | connect( editor, SIGNAL( textChanged() ), |
352 | this, SLOT( editorChanged() ) ); | 355 | this, SLOT( editorChanged() ) ); |
353 | 356 | ||
354 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); | 357 | QPEApplication::setStylusOperation( editor, QPEApplication::RightOnHold); |
355 | 358 | ||
356 | Config cfg("TextEdit"); | 359 | Config cfg("TextEdit"); |
357 | cfg. setGroup ( "Font" ); | 360 | cfg. setGroup ( "Font" ); |
358 | 361 | ||
359 | QFont defaultFont = editor-> font ( ); | 362 | QFont defaultFont = editor-> font ( ); |
360 | 363 | ||
361 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); | 364 | QString family = cfg. readEntry ( "Family", defaultFont. family ( )); |
362 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); | 365 | int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); |
363 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); | 366 | int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); |
364 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); | 367 | bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); |
365 | 368 | ||
366 | defaultFont = QFont ( family, size, weight, italic ); | 369 | defaultFont = QFont ( family, size, weight, italic ); |
367 | editor-> setFont ( defaultFont ); | 370 | editor-> setFont ( defaultFont ); |
368 | // updateCaption(); | 371 | // updateCaption(); |
369 | 372 | ||
370 | cfg.setGroup ( "View" ); | 373 | cfg.setGroup ( "View" ); |
371 | 374 | ||
372 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); | 375 | promptExit = cfg.readBoolEntry ( "PromptExit", false ); |
373 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); | 376 | openDesktop = cfg.readBoolEntry ( "OpenDesktop", true ); |
374 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); | 377 | filePerms = cfg.readBoolEntry ( "FilePermissions", false ); |
375 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); | 378 | useSearchBar = cfg.readBoolEntry ( "SearchBar", false ); |
376 | startWithNew = cfg.readBoolEntry ( "startNew", true); | 379 | startWithNew = cfg.readBoolEntry ( "startNew", true); |
377 | featureAutoSave = cfg.readBoolEntry( "autosave", false); | 380 | featureAutoSave = cfg.readBoolEntry( "autosave", false); |
378 | 381 | ||
379 | if(useSearchBar) searchBarAction->setOn(true); | 382 | if(useSearchBar) searchBarAction->setOn(true); |
380 | if(promptExit) nAdvanced->setOn( true ); | 383 | if(promptExit) nAdvanced->setOn( true ); |
381 | if(openDesktop) desktopAction->setOn( true ); | 384 | if(openDesktop) desktopAction->setOn( true ); |
382 | if(filePerms) filePermAction->setOn( true ); | 385 | if(filePerms) filePermAction->setOn( true ); |
383 | if(startWithNew) nStart->setOn( true ); | 386 | if(startWithNew) nStart->setOn( true ); |
384 | if(featureAutoSave) nAutoSave->setOn(true); | 387 | if(featureAutoSave) nAutoSave->setOn(true); |
385 | 388 | ||
386 | // { | 389 | // { |
387 | // doTimer(true); | 390 | // doTimer(true); |
388 | // } | 391 | // } |
389 | 392 | ||
390 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); | 393 | bool wrap = cfg. readBoolEntry ( "Wrap", true ); |
391 | wa-> setOn ( wrap ); | 394 | wa-> setOn ( wrap ); |
392 | setWordWrap ( wrap ); | 395 | setWordWrap ( wrap ); |
393 | 396 | ||
394 | ///////////////// | 397 | ///////////////// |
395 | if( qApp->argc() > 1) { | 398 | if( qApp->argc() > 1) { |
396 | currentFileName=qApp->argv()[1]; | 399 | currentFileName=qApp->argv()[1]; |
397 | 400 | ||
398 | QFileInfo fi(currentFileName); | 401 | QFileInfo fi(currentFileName); |
399 | 402 | ||
400 | if(fi.baseName().left(1) == "") { | 403 | if(fi.baseName().left(1) == "") { |
401 | openDotFile(currentFileName); | 404 | openDotFile(currentFileName); |
402 | } else { | 405 | } else { |
403 | openFile(currentFileName); | 406 | openFile(currentFileName); |
404 | } | 407 | } |
405 | } else { | 408 | } else { |
406 | edited1=false; | 409 | edited1=false; |
407 | openDotFile(""); | 410 | openDotFile(""); |
408 | } | 411 | } |
409 | 412 | ||
410 | viewSelection = cfg.readNumEntry( "FileView", 0 ); | 413 | viewSelection = cfg.readNumEntry( "FileView", 0 ); |
411 | } | 414 | } |
412 | 415 | ||
413 | TextEdit::~TextEdit() { | 416 | TextEdit::~TextEdit() { |
414 | qWarning("textedit d'tor"); | 417 | owarn << "textedit d'tor" << oendl; |
415 | delete editor; | 418 | delete editor; |
416 | } | 419 | } |
417 | 420 | ||
418 | void TextEdit::closeEvent(QCloseEvent *) { | 421 | void TextEdit::closeEvent(QCloseEvent *) { |
419 | if( edited1 && promptExit) | 422 | if( edited1 && promptExit) |
420 | { | 423 | { |
421 | switch( savePrompt() ) | 424 | switch( savePrompt() ) |
422 | { | 425 | { |
423 | case 1: | 426 | case 1: |
424 | { | 427 | { |
425 | saveAs(); | 428 | saveAs(); |
426 | qApp->quit(); | 429 | qApp->quit(); |
427 | } | 430 | } |
428 | break; | 431 | break; |
429 | 432 | ||
430 | case 2: | 433 | case 2: |
431 | { | 434 | { |
432 | qApp->quit(); | 435 | qApp->quit(); |
433 | } | 436 | } |
434 | break; | 437 | break; |
435 | 438 | ||
436 | case -1: | 439 | case -1: |
437 | break; | 440 | break; |
438 | }; | 441 | }; |
439 | } | 442 | } |
440 | else | 443 | else |
441 | qApp->quit(); | 444 | qApp->quit(); |
442 | 445 | ||
443 | } | 446 | } |
444 | 447 | ||
445 | void TextEdit::cleanUp() { | 448 | void TextEdit::cleanUp() { |
446 | 449 | ||
447 | Config cfg ( "TextEdit" ); | 450 | Config cfg ( "TextEdit" ); |
448 | cfg. setGroup ( "Font" ); | 451 | cfg. setGroup ( "Font" ); |
449 | QFont f = editor->font(); | 452 | QFont f = editor->font(); |
450 | cfg.writeEntry ( "Family", f. family ( )); | 453 | cfg.writeEntry ( "Family", f. family ( )); |
451 | cfg.writeEntry ( "Size", f. pointSize ( )); | 454 | cfg.writeEntry ( "Size", f. pointSize ( )); |
452 | cfg.writeEntry ( "Weight", f. weight ( )); | 455 | cfg.writeEntry ( "Weight", f. weight ( )); |
453 | cfg.writeEntry ( "Italic", f. italic ( )); | 456 | cfg.writeEntry ( "Italic", f. italic ( )); |
454 | 457 | ||
455 | cfg.setGroup ( "View" ); | 458 | cfg.setGroup ( "View" ); |
456 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); | 459 | cfg.writeEntry ( "Wrap", editor->wordWrap() == QMultiLineEdit::WidgetWidth ); |
457 | cfg.writeEntry ( "FileView", viewSelection ); | 460 | cfg.writeEntry ( "FileView", viewSelection ); |
458 | 461 | ||
459 | cfg.writeEntry ( "PromptExit", promptExit ); | 462 | cfg.writeEntry ( "PromptExit", promptExit ); |
460 | cfg.writeEntry ( "OpenDesktop", openDesktop ); | 463 | cfg.writeEntry ( "OpenDesktop", openDesktop ); |
461 | cfg.writeEntry ( "FilePermissions", filePerms ); | 464 | cfg.writeEntry ( "FilePermissions", filePerms ); |
462 | cfg.writeEntry ( "SearchBar", useSearchBar ); | 465 | cfg.writeEntry ( "SearchBar", useSearchBar ); |
463 | cfg.writeEntry ( "startNew", startWithNew ); | 466 | cfg.writeEntry ( "startNew", startWithNew ); |
464 | 467 | ||
465 | } | 468 | } |
466 | 469 | ||
467 | 470 | ||
468 | void TextEdit::accept() { | 471 | void TextEdit::accept() { |
469 | if( edited1) | 472 | if( edited1) |
470 | saveAs(); | 473 | saveAs(); |
471 | qApp->quit(); | 474 | qApp->quit(); |
472 | } | 475 | } |
473 | 476 | ||
474 | void TextEdit::zoomIn() { | 477 | void TextEdit::zoomIn() { |
475 | setFontSize(editor->font().pointSize()+1,false); | 478 | setFontSize(editor->font().pointSize()+1,false); |
476 | } | 479 | } |
477 | 480 | ||
478 | void TextEdit::zoomOut() { | 481 | void TextEdit::zoomOut() { |
479 | setFontSize(editor->font().pointSize()-1,true); | 482 | setFontSize(editor->font().pointSize()-1,true); |
480 | } | 483 | } |
481 | 484 | ||
482 | 485 | ||
483 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { | 486 | void TextEdit::setFontSize(int sz, bool round_down_not_up) { |
484 | int s=10; | 487 | int s=10; |
485 | for (int i=0; i<nfontsizes; i++) { | 488 | for (int i=0; i<nfontsizes; i++) { |
486 | if ( fontsize[i] == sz ) { | 489 | if ( fontsize[i] == sz ) { |
487 | s = sz; | 490 | s = sz; |
488 | break; | 491 | break; |
489 | } else if ( round_down_not_up ) { | 492 | } else if ( round_down_not_up ) { |
490 | if ( fontsize[i] < sz ) | 493 | if ( fontsize[i] < sz ) |
491 | s = fontsize[i]; | 494 | s = fontsize[i]; |
492 | } else { | 495 | } else { |
493 | if ( fontsize[i] > sz ) { | 496 | if ( fontsize[i] > sz ) { |
494 | s = fontsize[i]; | 497 | s = fontsize[i]; |
495 | break; | 498 | break; |
496 | } | 499 | } |
497 | } | 500 | } |
498 | } | 501 | } |
499 | 502 | ||
500 | QFont f = editor->font(); | 503 | QFont f = editor->font(); |
501 | f.setPointSize(s); | 504 | f.setPointSize(s); |
502 | editor->setFont(f); | 505 | editor->setFont(f); |
503 | 506 | ||
504 | zin->setEnabled(s != fontsize[nfontsizes-1]); | 507 | zin->setEnabled(s != fontsize[nfontsizes-1]); |
505 | zout->setEnabled(s != fontsize[0]); | 508 | zout->setEnabled(s != fontsize[0]); |
506 | } | 509 | } |
507 | 510 | ||
508 | void TextEdit::setBold(bool y) { | 511 | void TextEdit::setBold(bool y) { |
509 | QFont f = editor->font(); | 512 | QFont f = editor->font(); |
510 | f.setBold(y); | 513 | f.setBold(y); |
511 | editor->setFont(f); | 514 | editor->setFont(f); |
512 | } | 515 | } |
513 | 516 | ||
514 | void TextEdit::setItalic(bool y) { | 517 | void TextEdit::setItalic(bool y) { |
515 | QFont f = editor->font(); | 518 | QFont f = editor->font(); |
516 | f.setItalic(y); | 519 | f.setItalic(y); |
517 | editor->setFont(f); | 520 | editor->setFont(f); |
518 | } | 521 | } |
519 | 522 | ||
520 | void TextEdit::setWordWrap(bool y) { | 523 | void TextEdit::setWordWrap(bool y) { |
521 | bool state = editor->edited(); | 524 | bool state = editor->edited(); |
522 | QString captionStr = caption(); | 525 | QString captionStr = caption(); |
523 | bool b1 = edited1; | 526 | bool b1 = edited1; |
524 | bool b2 = edited; | 527 | bool b2 = edited; |
525 | 528 | ||
526 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); | 529 | editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap ); |
527 | editor->setEdited( state ); | 530 | editor->setEdited( state ); |
528 | edited1=b1; | 531 | edited1=b1; |
529 | edited=b2; | 532 | edited=b2; |
530 | setCaption(captionStr); | 533 | setCaption(captionStr); |
531 | } | 534 | } |
532 | 535 | ||
533 | void TextEdit::setSearchBar(bool b) { | 536 | void TextEdit::setSearchBar(bool b) { |
534 | useSearchBar=b; | 537 | useSearchBar=b; |
535 | Config cfg("TextEdit"); | 538 | Config cfg("TextEdit"); |
536 | cfg.setGroup("View"); | 539 | cfg.setGroup("View"); |
537 | cfg.writeEntry ( "SearchBar", b ); | 540 | cfg.writeEntry ( "SearchBar", b ); |
538 | searchBarAction->setOn(b); | 541 | searchBarAction->setOn(b); |
539 | if(b) | 542 | if(b) |
540 | searchBar->show(); | 543 | searchBar->show(); |
541 | else | 544 | else |
542 | searchBar->hide(); | 545 | searchBar->hide(); |
543 | editor->setFocus(); | 546 | editor->setFocus(); |
544 | } | 547 | } |
545 | 548 | ||
546 | void TextEdit::fileNew() { | 549 | void TextEdit::fileNew() { |
547 | // if( !bFromDocView ) { | 550 | // if( !bFromDocView ) { |
548 | // saveAs(); | 551 | // saveAs(); |
549 | // } | 552 | // } |
550 | newFile(DocLnk()); | 553 | newFile(DocLnk()); |
551 | } | 554 | } |
552 | 555 | ||
553 | void TextEdit::fileOpen() { | 556 | void TextEdit::fileOpen() { |
554 | Config cfg("TextEdit"); | 557 | Config cfg("TextEdit"); |
555 | cfg. setGroup ( "View" ); | 558 | cfg. setGroup ( "View" ); |
556 | QMap<QString, QStringList> map; | 559 | QMap<QString, QStringList> map; |
557 | map.insert(tr("All"), QStringList() ); | 560 | map.insert(tr("All"), QStringList() ); |
558 | QStringList text; | 561 | QStringList text; |
559 | text << "text/*"; | 562 | text << "text/*"; |
560 | map.insert(tr("Text"), text ); | 563 | map.insert(tr("Text"), text ); |
561 | text << "*"; | 564 | text << "*"; |
562 | map.insert(tr("All"), text ); | 565 | map.insert(tr("All"), text ); |
563 | QString str = OFileDialog::getOpenFileName( 2, | 566 | QString str = OFileDialog::getOpenFileName( 2, |
564 | QString::null , | 567 | QString::null , |
565 | QString::null, map); | 568 | QString::null, map); |
566 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) | 569 | if( !str.isEmpty() && QFile(str).exists() && !QFileInfo(str).isDir() ) |
567 | { | 570 | { |
568 | openFile( str ); | 571 | openFile( str ); |
569 | } | 572 | } |
570 | else | 573 | else |
571 | updateCaption(); | 574 | updateCaption(); |
572 | } | 575 | } |
573 | 576 | ||
574 | void TextEdit::doSearchBar() { | 577 | void TextEdit::doSearchBar() { |
575 | if(!useSearchBar) | 578 | if(!useSearchBar) |
576 | searchBar->hide(); | 579 | searchBar->hide(); |
577 | else | 580 | else |
578 | searchBar->show(); | 581 | searchBar->show(); |
579 | } | 582 | } |
580 | 583 | ||
581 | #if 0 | 584 | #if 0 |
582 | void TextEdit::slotFind() { | 585 | void TextEdit::slotFind() { |
583 | FindDialog frmFind( tr("Text Editor"), this ); | 586 | FindDialog frmFind( tr("Text Editor"), this ); |
584 | connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), | 587 | connect( &frmFind, SIGNAL(signalFindClicked(const QString&,bool,bool,int)), |
585 | editor, SLOT(slotDoFind(const QString&,bool,bool))); | 588 | editor, SLOT(slotDoFind(const QString&,bool,bool))); |
586 | 589 | ||
587 | //case sensitive, backwards, [category] | 590 | //case sensitive, backwards, [category] |
588 | 591 | ||
589 | connect( editor, SIGNAL(notFound()), | 592 | connect( editor, SIGNAL(notFound()), |
590 | &frmFind, SLOT(slotNotFound()) ); | 593 | &frmFind, SLOT(slotNotFound()) ); |
591 | connect( editor, SIGNAL(searchWrapped()), | 594 | connect( editor, SIGNAL(searchWrapped()), |
592 | &frmFind, SLOT(slotWrapAround()) ); | 595 | &frmFind, SLOT(slotWrapAround()) ); |
593 | 596 | ||
594 | frmFind.exec(); | 597 | frmFind.exec(); |
595 | 598 | ||
596 | 599 | ||
597 | } | 600 | } |
598 | #endif | 601 | #endif |
599 | 602 | ||
600 | void TextEdit::fileRevert() { | 603 | void TextEdit::fileRevert() { |
601 | clear(); | 604 | clear(); |
602 | fileOpen(); | 605 | fileOpen(); |
603 | } | 606 | } |
604 | 607 | ||
605 | void TextEdit::editCut() { | 608 | void TextEdit::editCut() { |
606 | #ifndef QT_NO_CLIPBOARD | 609 | #ifndef QT_NO_CLIPBOARD |
607 | editor->cut(); | 610 | editor->cut(); |
608 | #endif | 611 | #endif |
609 | } | 612 | } |
610 | 613 | ||
611 | void TextEdit::editCopy() { | 614 | void TextEdit::editCopy() { |
612 | #ifndef QT_NO_CLIPBOARD | 615 | #ifndef QT_NO_CLIPBOARD |
613 | editor->copy(); | 616 | editor->copy(); |
614 | #endif | 617 | #endif |
615 | } | 618 | } |
616 | 619 | ||
617 | void TextEdit::editPaste() { | 620 | void TextEdit::editPaste() { |
618 | #ifndef QT_NO_CLIPBOARD | 621 | #ifndef QT_NO_CLIPBOARD |
619 | editor->paste(); | 622 | editor->paste(); |
620 | #endif | 623 | #endif |
621 | } | 624 | } |
622 | 625 | ||
623 | void TextEdit::editFind() { | 626 | void TextEdit::editFind() { |
624 | searchBar->show(); | 627 | searchBar->show(); |
625 | searchEdit->setFocus(); | 628 | searchEdit->setFocus(); |
626 | } | 629 | } |
627 | 630 | ||
628 | void TextEdit::findNext() { | 631 | void TextEdit::findNext() { |
629 | editor->find( searchEdit->text(), false, false ); | 632 | editor->find( searchEdit->text(), false, false ); |
630 | 633 | ||
631 | } | 634 | } |
632 | 635 | ||
633 | void TextEdit::findClose() { | 636 | void TextEdit::findClose() { |
634 | searchBar->hide(); | 637 | searchBar->hide(); |
635 | } | 638 | } |
636 | 639 | ||
637 | void TextEdit::search() { | 640 | void TextEdit::search() { |
638 | editor->find( searchEdit->text(), false, false ); | 641 | editor->find( searchEdit->text(), false, false ); |
639 | } | 642 | } |
640 | 643 | ||
641 | void TextEdit::newFile( const DocLnk &f ) { | 644 | void TextEdit::newFile( const DocLnk &f ) { |
642 | DocLnk nf = f; | 645 | DocLnk nf = f; |
643 | nf.setType("text/plain"); | 646 | nf.setType("text/plain"); |
644 | clear(); | 647 | clear(); |
645 | setWState (WState_Reserved1 ); | 648 | setWState (WState_Reserved1 ); |
646 | editor->setFocus(); | 649 | editor->setFocus(); |
647 | doc = new DocLnk(nf); | 650 | doc = new DocLnk(nf); |
648 | currentFileName = "Unnamed"; | 651 | currentFileName = "Unnamed"; |
649 | qDebug("newFile "+currentFileName); | 652 | odebug << "newFile "+currentFileName << oendl; |
650 | updateCaption( currentFileName); | 653 | updateCaption( currentFileName); |
651 | // editor->setEdited( false); | 654 | // editor->setEdited( false); |
652 | } | 655 | } |
653 | 656 | ||
654 | void TextEdit::openDotFile( const QString &f ) { | 657 | void TextEdit::openDotFile( const QString &f ) { |
655 | if(!currentFileName.isEmpty()) { | 658 | if(!currentFileName.isEmpty()) { |
656 | currentFileName=f; | 659 | currentFileName=f; |
657 | 660 | ||
658 | qDebug("openFile dotfile " + currentFileName); | 661 | odebug << "openFile dotfile " + currentFileName << oendl; |
659 | QString txt; | 662 | QString txt; |
660 | QFile file(f); | 663 | QFile file(f); |
661 | file.open(IO_ReadWrite); | 664 | file.open(IO_ReadWrite); |
662 | QTextStream t(&file); | 665 | QTextStream t(&file); |
663 | while ( !t.atEnd()) { | 666 | while ( !t.atEnd()) { |
664 | txt+=t.readLine()+"\n"; | 667 | txt+=t.readLine()+"\n"; |
665 | } | 668 | } |
666 | editor->setText(txt); | 669 | editor->setText(txt); |
667 | editor->setEdited( false); | 670 | editor->setEdited( false); |
668 | edited1=false; | 671 | edited1=false; |
669 | edited=false; | 672 | edited=false; |
670 | 673 | ||
671 | 674 | ||
672 | } | 675 | } |
673 | updateCaption( currentFileName); | 676 | updateCaption( currentFileName); |
674 | } | 677 | } |
675 | 678 | ||
676 | void TextEdit::openFile( const QString &f ) { | 679 | void TextEdit::openFile( const QString &f ) { |
677 | qDebug("filename is "+ f); | 680 | odebug << "filename is "+ f << oendl; |
678 | QString filer; | 681 | QString filer; |
679 | QFileInfo fi( f); | 682 | QFileInfo fi( f); |
680 | // bFromDocView = true; | 683 | // bFromDocView = true; |
681 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) | 684 | if(f.find(".desktop",0,true) != -1 && !openDesktop ) |
682 | { | 685 | { |
683 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) | 686 | switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Text Editor has detected<BR>you selected a <B>.desktop</B>file.<BR>Open<B>.desktop</B> file or <B>linked</B> file?"),tr(".desktop File"),tr("Linked Document"),0,1,1) ) |
684 | { | 687 | { |
685 | case 0: //desktop | 688 | case 0: //desktop |
686 | filer = f; | 689 | filer = f; |
687 | break; | 690 | break; |
688 | case 1: //linked | 691 | case 1: //linked |
689 | DocLnk sf(f); | 692 | DocLnk sf(f); |
690 | filer = sf.file(); | 693 | filer = sf.file(); |
691 | break; | 694 | break; |
692 | }; | 695 | }; |
693 | } | 696 | } |
694 | else if(fi.baseName().left(1) == "") | 697 | else if(fi.baseName().left(1) == "") |
695 | { | 698 | { |
696 | qDebug("opening dotfile"); | 699 | odebug << "opening dotfile" << oendl; |
697 | currentFileName=f; | 700 | currentFileName=f; |
698 | openDotFile(currentFileName); | 701 | openDotFile(currentFileName); |
699 | return; | 702 | return; |
700 | } | 703 | } |
701 | /* | 704 | /* |
702 | * The problem is a file where Config(f).isValid() and it does not | 705 | * The problem is a file where Config(f).isValid() and it does not |
703 | * end with .desktop will be treated as desktop file | 706 | * end with .desktop will be treated as desktop file |
704 | */ | 707 | */ |
705 | else if (f.find(".desktop",0,true) != -1 ) | 708 | else if (f.find(".desktop",0,true) != -1 ) |
706 | { | 709 | { |
707 | DocLnk sf(f); | 710 | DocLnk sf(f); |
708 | filer = sf.file(); | 711 | filer = sf.file(); |
709 | if(filer.right(1) == "/") | 712 | if(filer.right(1) == "/") |
710 | filer = f; | 713 | filer = f; |
711 | 714 | ||
712 | } | 715 | } |
713 | else | 716 | else |
714 | filer = f; | 717 | filer = f; |
715 | 718 | ||
716 | DocLnk nf; | 719 | DocLnk nf; |
717 | nf.setType("text/plain"); | 720 | nf.setType("text/plain"); |
718 | nf.setFile(filer); | 721 | nf.setFile(filer); |
719 | currentFileName=filer; | 722 | currentFileName=filer; |
720 | 723 | ||
721 | nf.setName(fi.baseName()); | 724 | nf.setName(fi.baseName()); |
722 | openFile(nf); | 725 | openFile(nf); |
723 | 726 | ||
724 | qDebug("openFile string "+currentFileName); | 727 | odebug << "openFile string "+currentFileName << oendl; |
725 | 728 | ||
726 | showEditTools(); | 729 | showEditTools(); |
727 | // Show filename in caption | 730 | // Show filename in caption |
728 | QString name = filer; | 731 | QString name = filer; |
729 | int sep = name.findRev( '/' ); | 732 | int sep = name.findRev( '/' ); |
730 | if ( sep > 0 ) | 733 | if ( sep > 0 ) |
731 | name = name.mid( sep+1 ); | 734 | name = name.mid( sep+1 ); |
732 | updateCaption( name ); | 735 | updateCaption( name ); |
733 | } | 736 | } |
734 | 737 | ||
735 | void TextEdit::openFile( const DocLnk &f ) { | 738 | void TextEdit::openFile( const DocLnk &f ) { |
736 | // clear(); | 739 | // clear(); |
737 | // bFromDocView = true; | 740 | // bFromDocView = true; |
738 | FileManager fm; | 741 | FileManager fm; |
739 | QString txt; | 742 | QString txt; |
740 | currentFileName=f.file(); | 743 | currentFileName=f.file(); |
741 | qDebug("openFile doclnk " + currentFileName); | 744 | odebug << "openFile doclnk " + currentFileName << oendl; |
742 | if ( !fm.loadFile( f, txt ) ) { | 745 | if ( !fm.loadFile( f, txt ) ) { |
743 | // ####### could be a new file | 746 | // ####### could be a new file |
744 | qDebug( "Cannot open file" ); | 747 | odebug << "Cannot open file" << oendl; |
745 | } | 748 | } |
746 | // fileNew(); | 749 | // fileNew(); |
747 | if ( doc ) | 750 | if ( doc ) |
748 | delete doc; | 751 | delete doc; |
749 | doc = new DocLnk(f); | 752 | doc = new DocLnk(f); |
750 | editor->setText(txt); | 753 | editor->setText(txt); |
751 | editor->setEdited( false); | 754 | editor->setEdited( false); |
752 | edited1=false; | 755 | edited1=false; |
753 | edited=false; | 756 | edited=false; |
754 | 757 | ||
755 | doc->setName(currentFileName); | 758 | doc->setName(currentFileName); |
756 | updateCaption(); | 759 | updateCaption(); |
757 | setTimer(); | 760 | setTimer(); |
758 | } | 761 | } |
759 | 762 | ||
760 | void TextEdit::showEditTools() { | 763 | void TextEdit::showEditTools() { |
761 | menu->show(); | 764 | menu->show(); |
762 | editBar->show(); | 765 | editBar->show(); |
763 | if(!useSearchBar) | 766 | if(!useSearchBar) |
764 | searchBar->hide(); | 767 | searchBar->hide(); |
765 | else | 768 | else |
766 | searchBar->show(); | 769 | searchBar->show(); |
767 | setWState (WState_Reserved1 ); | 770 | setWState (WState_Reserved1 ); |
768 | } | 771 | } |
769 | 772 | ||
770 | /*! | 773 | /*! |
771 | unprompted save */ | 774 | unprompted save */ |
772 | bool TextEdit::save() { | 775 | bool TextEdit::save() { |
773 | qDebug("saveAsFile " + currentFileName); | 776 | odebug << "saveAsFile " + currentFileName << oendl; |
774 | if(currentFileName.isEmpty()) { | 777 | if(currentFileName.isEmpty()) { |
775 | saveAs(); | 778 | saveAs(); |
776 | return false; | 779 | return false; |
777 | } | 780 | } |
778 | 781 | ||
779 | QString file = doc->file(); | 782 | QString file = doc->file(); |
780 | qDebug("saver file "+file); | 783 | odebug << "saver file "+file << oendl; |
781 | QString name= doc->name(); | 784 | QString name= doc->name(); |
782 | qDebug("File named "+name); | 785 | odebug << "File named "+name << oendl; |
783 | QString rt = editor->text(); | 786 | QString rt = editor->text(); |
784 | if( !rt.isEmpty() ) { | 787 | if( !rt.isEmpty() ) { |
785 | if(name.isEmpty()) { | 788 | if(name.isEmpty()) { |
786 | saveAs(); | 789 | saveAs(); |
787 | } else { | 790 | } else { |
788 | currentFileName= name ; | 791 | currentFileName= name ; |
789 | qDebug("saveFile "+currentFileName); | 792 | odebug << "saveFile "+currentFileName << oendl; |
790 | 793 | ||
791 | struct stat buf; | 794 | struct stat buf; |
792 | mode_t mode; | 795 | mode_t mode; |
793 | stat(file.latin1(), &buf); | 796 | stat(file.latin1(), &buf); |
794 | mode = buf.st_mode; | 797 | mode = buf.st_mode; |
795 | 798 | ||
796 | if(!fileIs) { | 799 | if(!fileIs) { |
797 | doc->setName( name); | 800 | doc->setName( name); |
798 | FileManager fm; | 801 | FileManager fm; |
799 | if ( !fm.saveFile( *doc, rt ) ) { | 802 | if ( !fm.saveFile( *doc, rt ) ) { |
800 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 803 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
801 | return false; | 804 | return false; |
802 | } | 805 | } |
803 | } else { | 806 | } else { |
804 | qDebug("regular save file"); | 807 | odebug << "regular save file" << oendl; |
805 | QFile f(file); | 808 | QFile f(file); |
806 | if( f.open(IO_WriteOnly)) { | 809 | if( f.open(IO_WriteOnly)) { |
807 | QCString crt = rt.utf8(); | 810 | QCString crt = rt.utf8(); |
808 | f.writeBlock(crt,crt.length()); | 811 | f.writeBlock(crt,crt.length()); |
809 | } else { | 812 | } else { |
810 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); | 813 | QMessageBox::message(tr("Text Edit"),tr("Write Failed")); |
811 | return false; | 814 | return false; |
812 | } | 815 | } |
813 | 816 | ||
814 | } | 817 | } |
815 | editor->setEdited( false); | 818 | editor->setEdited( false); |
816 | edited1=false; | 819 | edited1=false; |
817 | edited=false; | 820 | edited=false; |
818 | if(caption().left(1)=="*") | 821 | if(caption().left(1)=="*") |
819 | setCaption(caption().right(caption().length()-1)); | 822 | setCaption(caption().right(caption().length()-1)); |
820 | 823 | ||
821 | 824 | ||
822 | chmod( file.latin1(), mode); | 825 | chmod( file.latin1(), mode); |
823 | } | 826 | } |
824 | return true; | 827 | return true; |
825 | } | 828 | } |
826 | return false; | 829 | return false; |
827 | } | 830 | } |
828 | 831 | ||
829 | /*! | 832 | /*! |
830 | prompted save */ | 833 | prompted save */ |
831 | bool TextEdit::saveAs() { | 834 | bool TextEdit::saveAs() { |
832 | 835 | ||
833 | if(caption() == tr("Text Editor")) | 836 | if(caption() == tr("Text Editor")) |
834 | return false; | 837 | return false; |
835 | qDebug("saveAsFile " + currentFileName); | 838 | odebug << "saveAsFile " + currentFileName << oendl; |
836 | // case of nothing to save... | 839 | // case of nothing to save... |
837 | // if ( !doc && !currentFileName.isEmpty()) { | 840 | // if ( !doc && !currentFileName.isEmpty()) { |
838 | // //|| !bFromDocView) | 841 | // //|| !bFromDocView) |
839 | // qDebug("no doc"); | 842 | // odebug << "no doc" << oendl; |
840 | // return true; | 843 | // return true; |
841 | // } | 844 | // } |
842 | // if ( !editor->edited() ) { | 845 | // if ( !editor->edited() ) { |
843 | // delete doc; | 846 | // delete doc; |
844 | // doc = 0; | 847 | // doc = 0; |
845 | // return true; | 848 | // return true; |
846 | // } | 849 | // } |
847 | 850 | ||
848 | QString rt = editor->text(); | 851 | QString rt = editor->text(); |
849 | qDebug(currentFileName); | 852 | odebug << currentFileName << oendl; |
850 | 853 | ||
851 | if( currentFileName.isEmpty() | 854 | if( currentFileName.isEmpty() |
852 | || currentFileName == tr("Unnamed") | 855 | || currentFileName == tr("Unnamed") |
853 | || currentFileName == tr("Text Editor")) { | 856 | || currentFileName == tr("Text Editor")) { |
854 | qDebug("do silly TT filename thing"); | 857 | odebug << "do silly TT filename thing" << oendl; |
855 | // if ( doc && doc->name().isEmpty() ) { | 858 | // if ( doc && doc->name().isEmpty() ) { |
856 | QString pt = rt.simplifyWhiteSpace(); | 859 | QString pt = rt.simplifyWhiteSpace(); |
857 | int i = pt.find( ' ' ); | 860 | int i = pt.find( ' ' ); |
858 | QString docname = pt; | 861 | QString docname = pt; |
859 | if ( i > 0 ) | 862 | if ( i > 0 ) |
860 | docname = pt.left( i ); | 863 | docname = pt.left( i ); |
861 | // remove "." at the beginning | 864 | // remove "." at the beginning |
862 | while( docname.startsWith( "." ) ) | 865 | while( docname.startsWith( "." ) ) |
863 | docname = docname.mid( 1 ); | 866 | docname = docname.mid( 1 ); |
864 | docname.replace( QRegExp("/"), "_" ); | 867 | docname.replace( QRegExp("/"), "_" ); |
865 | // cut the length. filenames longer than that | 868 | // cut the length. filenames longer than that |
866 | //don't make sense and something goes wrong when they get too long. | 869 | //don't make sense and something goes wrong when they get too long. |
867 | if ( docname.length() > 40 ) | 870 | if ( docname.length() > 40 ) |
868 | docname = docname.left(40); | 871 | docname = docname.left(40); |
869 | if ( docname.isEmpty() ) | 872 | if ( docname.isEmpty() ) |
870 | docname = tr("Unnamed"); | 873 | docname = tr("Unnamed"); |
871 | if(doc) doc->setName(docname); | 874 | if(doc) doc->setName(docname); |
872 | currentFileName=docname; | 875 | currentFileName=docname; |
873 | // } | 876 | // } |
874 | // else | 877 | // else |
875 | // qDebug("hmmmmmm"); | 878 | // odebug << "hmmmmmm" << oendl; |
876 | } | 879 | } |
877 | 880 | ||
878 | 881 | ||
879 | QMap<QString, QStringList> map; | 882 | QMap<QString, QStringList> map; |
880 | map.insert(tr("All"), QStringList() ); | 883 | map.insert(tr("All"), QStringList() ); |
881 | QStringList text; | 884 | QStringList text; |
882 | text << "text/*"; | 885 | text << "text/*"; |
883 | map.insert(tr("Text"), text ); | 886 | map.insert(tr("Text"), text ); |
884 | text << "*"; | 887 | text << "*"; |
885 | map.insert(tr("All"), text ); | 888 | map.insert(tr("All"), text ); |
886 | 889 | ||
887 | QFileInfo cuFi( currentFileName); | 890 | QFileInfo cuFi( currentFileName); |
888 | QString filee = cuFi.fileName(); | 891 | QString filee = cuFi.fileName(); |
889 | QString dire = cuFi.dirPath(); | 892 | QString dire = cuFi.dirPath(); |
890 | if(dire==".") | 893 | if(dire==".") |
891 | dire = QPEApplication::documentDir(); | 894 | dire = QPEApplication::documentDir(); |
892 | QString str; | 895 | QString str; |
893 | if( !featureAutoSave) { | 896 | if( !featureAutoSave) { |
894 | str = OFileDialog::getSaveFileName( 2, | 897 | str = OFileDialog::getSaveFileName( 2, |
895 | dire, | 898 | dire, |
896 | filee, map); | 899 | filee, map); |
897 | } else | 900 | } else |
898 | str=currentFileName; | 901 | str=currentFileName; |
899 | 902 | ||
900 | if(!str.isEmpty()) { | 903 | if(!str.isEmpty()) { |
901 | QString fileNm=str; | 904 | QString fileNm=str; |
902 | 905 | ||
903 | qDebug("saving filename "+fileNm); | 906 | odebug << "saving filename "+fileNm << oendl; |
904 | QFileInfo fi(fileNm); | 907 | QFileInfo fi(fileNm); |
905 | currentFileName=fi.fileName(); | 908 | currentFileName=fi.fileName(); |
906 | if(doc) | 909 | if(doc) |
907 | // QString file = doc->file(); | 910 | // QString file = doc->file(); |
908 | // doc->removeFiles(); | 911 | // doc->removeFiles(); |
909 | delete doc; | 912 | delete doc; |
910 | DocLnk nf; | 913 | DocLnk nf; |
911 | nf.setType("text/plain"); | 914 | nf.setType("text/plain"); |
912 | nf.setFile( fileNm); | 915 | nf.setFile( fileNm); |
913 | doc = new DocLnk(nf); | 916 | doc = new DocLnk(nf); |
914 | // editor->setText(rt); | 917 | // editor->setText(rt); |
915 | qDebug("Saving file as "+currentFileName); | 918 | odebug << "Saving file as "+currentFileName << oendl; |
916 | doc->setName( currentFileName); | 919 | doc->setName( currentFileName); |
917 | updateCaption( currentFileName); | 920 | updateCaption( currentFileName); |
918 | 921 | ||
919 | FileManager fm; | 922 | FileManager fm; |
920 | if ( !fm.saveFile( *doc, rt ) ) { | 923 | if ( !fm.saveFile( *doc, rt ) ) { |
921 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); | 924 | QMessageBox::message(tr("Text Edit"),tr("Save Failed")); |
922 | return false; | 925 | return false; |
923 | } | 926 | } |
924 | 927 | ||
925 | if( filePerms ) { | 928 | if( filePerms ) { |
926 | filePermissions *filePerm; | 929 | filePermissions *filePerm; |
927 | filePerm = new filePermissions(this, | 930 | filePerm = new filePermissions(this, |
928 | tr("Permissions"),true, | 931 | tr("Permissions"),true, |
929 | 0,(const QString &)fileNm); | 932 | 0,(const QString &)fileNm); |
930 | QPEApplication::execDialog( filePerm ); | 933 | QPEApplication::execDialog( filePerm ); |
931 | 934 | ||
932 | if( filePerm) | 935 | if( filePerm) |
933 | delete filePerm; | 936 | delete filePerm; |
934 | } | 937 | } |
935 | // } | 938 | // } |
936 | editor->setEdited( false); | 939 | editor->setEdited( false); |
937 | edited1 = false; | 940 | edited1 = false; |
938 | edited = false; | 941 | edited = false; |
939 | if(caption().left(1)=="*") | 942 | if(caption().left(1)=="*") |
940 | setCaption(caption().right(caption().length()-1)); | 943 | setCaption(caption().right(caption().length()-1)); |
941 | 944 | ||
942 | return true; | 945 | return true; |
943 | } | 946 | } |
944 | qDebug("returning false"); | 947 | odebug << "returning false" << oendl; |
945 | return false; | 948 | return false; |
946 | } //end saveAs | 949 | } //end saveAs |
947 | 950 | ||
948 | void TextEdit::clear() { | 951 | void TextEdit::clear() { |
949 | delete doc; | 952 | delete doc; |
950 | doc = 0; | 953 | doc = 0; |
951 | editor->clear(); | 954 | editor->clear(); |
952 | } | 955 | } |
953 | 956 | ||
954 | void TextEdit::updateCaption( const QString &name ) { | 957 | void TextEdit::updateCaption( const QString &name ) { |
955 | 958 | ||
956 | if ( name.isEmpty() ) | 959 | if ( name.isEmpty() ) |
957 | setCaption( tr("Text Editor") ); | 960 | setCaption( tr("Text Editor") ); |
958 | else { | 961 | else { |
959 | QString s = name; | 962 | QString s = name; |
960 | if ( s.isNull() ) | 963 | if ( s.isNull() ) |
961 | s = doc->name(); | 964 | s = doc->name(); |
962 | if ( s.isEmpty() ) { | 965 | if ( s.isEmpty() ) { |
963 | s = tr( "Unnamed" ); | 966 | s = tr( "Unnamed" ); |
964 | currentFileName=s; | 967 | currentFileName=s; |
965 | } | 968 | } |
966 | // if(s.left(1) == "/") | 969 | // if(s.left(1) == "/") |
967 | // s = s.right(s.length()-1); | 970 | // s = s.right(s.length()-1); |
968 | setCaption( tr("%1 - Text Editor").arg( s ) ); | 971 | setCaption( tr("%1 - Text Editor").arg( s ) ); |
969 | } | 972 | } |
970 | } | 973 | } |
971 | 974 | ||
972 | void TextEdit::setDocument(const QString& fileref) { | 975 | void TextEdit::setDocument(const QString& fileref) { |
973 | if(fileref != "Unnamed") { | 976 | if(fileref != "Unnamed") { |
974 | currentFileName=fileref; | 977 | currentFileName=fileref; |
975 | qDebug("setDocument"); | 978 | odebug << "setDocument" << oendl; |
976 | QFileInfo fi(currentFileName); | 979 | QFileInfo fi(currentFileName); |
977 | qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName); | 980 | odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl; |
978 | if( (fi.baseName().left(1)).isEmpty() ) { | 981 | if( (fi.baseName().left(1)).isEmpty() ) { |
979 | openDotFile(currentFileName); | 982 | openDotFile(currentFileName); |
980 | 983 | ||
981 | } else { | 984 | } else { |
982 | qDebug("setDoc open"); | 985 | odebug << "setDoc open" << oendl; |
983 | bFromDocView = true; | 986 | bFromDocView = true; |
984 | openFile(fileref); | 987 | openFile(fileref); |
985 | editor->setEdited(true); | 988 | editor->setEdited(true); |
986 | edited1=false; | 989 | edited1=false; |
987 | edited=true; | 990 | edited=true; |
988 | // fromSetDocument=false; | 991 | // fromSetDocument=false; |
989 | // doSearchBar(); | 992 | // doSearchBar(); |
990 | } | 993 | } |
991 | } | 994 | } |
992 | updateCaption( currentFileName); | 995 | updateCaption( currentFileName); |
993 | } | 996 | } |
994 | 997 | ||
995 | void TextEdit::changeFont() { | 998 | void TextEdit::changeFont() { |
996 | QDialog *d = new QDialog ( this, "FontDialog", true ); | 999 | QDialog *d = new QDialog ( this, "FontDialog", true ); |
997 | d-> setCaption ( tr( "Choose font" )); | 1000 | d-> setCaption ( tr( "Choose font" )); |
998 | QBoxLayout *lay = new QVBoxLayout ( d ); | 1001 | QBoxLayout *lay = new QVBoxLayout ( d ); |
999 | OFontSelector *ofs = new OFontSelector ( true, d ); | 1002 | OFontSelector *ofs = new OFontSelector ( true, d ); |
1000 | lay-> addWidget ( ofs ); | 1003 | lay-> addWidget ( ofs ); |
1001 | ofs-> setSelectedFont ( editor-> font ( )); | 1004 | ofs-> setSelectedFont ( editor-> font ( )); |
1002 | 1005 | ||
1003 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) | 1006 | if ( QPEApplication::execDialog( d ) == QDialog::Accepted ) |
1004 | editor-> setFont ( ofs-> selectedFont ( )); | 1007 | editor-> setFont ( ofs-> selectedFont ( )); |
1005 | delete d; | 1008 | delete d; |
1006 | 1009 | ||
1007 | } | 1010 | } |
1008 | 1011 | ||
1009 | void TextEdit::editDelete() { | 1012 | void TextEdit::editDelete() { |
1010 | switch ( QMessageBox::warning(this,tr("Text Editor"), | 1013 | switch ( QMessageBox::warning(this,tr("Text Editor"), |
1011 | tr("Do you really want<BR>to <B>delete</B> " | 1014 | tr("Do you really want<BR>to <B>delete</B> " |
1012 | "the current file\nfrom the disk?<BR>This is " | 1015 | "the current file\nfrom the disk?<BR>This is " |
1013 | "<B>irreversable!</B>"), | 1016 | "<B>irreversable!</B>"), |
1014 | tr("Yes"),tr("No"),0,0,1) ) { | 1017 | tr("Yes"),tr("No"),0,0,1) ) { |
1015 | case 0: | 1018 | case 0: |
1016 | if(doc) { | 1019 | if(doc) { |
1017 | doc->removeFiles(); | 1020 | doc->removeFiles(); |
1018 | clear(); | 1021 | clear(); |
1019 | setCaption( tr("Text Editor") ); | 1022 | setCaption( tr("Text Editor") ); |
1020 | } | 1023 | } |
1021 | break; | 1024 | break; |
1022 | case 1: | 1025 | case 1: |
1023 | // exit | 1026 | // exit |
1024 | break; | 1027 | break; |
1025 | }; | 1028 | }; |
1026 | } | 1029 | } |
1027 | 1030 | ||
1028 | void TextEdit::changeStartConfig( bool b ) { | 1031 | void TextEdit::changeStartConfig( bool b ) { |
1029 | startWithNew=b; | 1032 | startWithNew=b; |
1030 | Config cfg("TextEdit"); | 1033 | Config cfg("TextEdit"); |
1031 | cfg.setGroup("View"); | 1034 | cfg.setGroup("View"); |
1032 | cfg.writeEntry("startNew",b); | 1035 | cfg.writeEntry("startNew",b); |
1033 | update(); | 1036 | update(); |
1034 | } | 1037 | } |
1035 | 1038 | ||
1036 | void TextEdit::editorChanged() { | 1039 | void TextEdit::editorChanged() { |
1037 | // qDebug("editor changed"); | 1040 | // odebug << "editor changed" << oendl; |
1038 | if( /*editor->edited() &&*/ /*edited && */!edited1) { | 1041 | if( /*editor->edited() &&*/ /*edited && */!edited1) { |
1039 | setCaption( "*"+caption()); | 1042 | setCaption( "*"+caption()); |
1040 | edited1=true; | 1043 | edited1=true; |
1041 | } | 1044 | } |
1042 | edited=true; | 1045 | edited=true; |
1043 | } | 1046 | } |
1044 | 1047 | ||
1045 | void TextEdit::receive(const QCString&msg, const QByteArray &) { | 1048 | void TextEdit::receive(const QCString&msg, const QByteArray &) { |
1046 | qDebug("QCop "+msg); | 1049 | odebug << "QCop "+msg << oendl; |
1047 | if ( msg == "setDocument(QString)" ) { | 1050 | if ( msg == "setDocument(QString)" ) { |
1048 | qDebug("bugger all"); | 1051 | odebug << "bugger all" << oendl; |
1049 | 1052 | ||
1050 | } | 1053 | } |
1051 | 1054 | ||
1052 | } | 1055 | } |
1053 | 1056 | ||
1054 | void TextEdit::doAbout() { | 1057 | void TextEdit::doAbout() { |
1055 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" | 1058 | QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" |
1056 | "2000 Trolltech AS, and<BR>" | 1059 | "2000 Trolltech AS, and<BR>" |
1057 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" | 1060 | "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" |
1058 | "and is licensed under the GPL")); | 1061 | "and is licensed under the GPL")); |
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | void TextEdit::doPrompt(bool b) { | 1064 | void TextEdit::doPrompt(bool b) { |
1062 | promptExit=b; | 1065 | promptExit=b; |
1063 | Config cfg("TextEdit"); | 1066 | Config cfg("TextEdit"); |
1064 | cfg.setGroup ( "View" ); | 1067 | cfg.setGroup ( "View" ); |
1065 | cfg.writeEntry ( "PromptExit", b); | 1068 | cfg.writeEntry ( "PromptExit", b); |
1066 | } | 1069 | } |
1067 | 1070 | ||
1068 | void TextEdit::doDesktop(bool b) { | 1071 | void TextEdit::doDesktop(bool b) { |
1069 | openDesktop=b; | 1072 | openDesktop=b; |
1070 | Config cfg("TextEdit"); | 1073 | Config cfg("TextEdit"); |
1071 | cfg.setGroup ( "View" ); | 1074 | cfg.setGroup ( "View" ); |
1072 | cfg.writeEntry ( "OpenDesktop", b); | 1075 | cfg.writeEntry ( "OpenDesktop", b); |
1073 | } | 1076 | } |
1074 | 1077 | ||
1075 | void TextEdit::doFilePerms(bool b) { | 1078 | void TextEdit::doFilePerms(bool b) { |
1076 | filePerms=b; | 1079 | filePerms=b; |
1077 | Config cfg("TextEdit"); | 1080 | Config cfg("TextEdit"); |
1078 | cfg.setGroup ( "View" ); | 1081 | cfg.setGroup ( "View" ); |
1079 | cfg.writeEntry ( "FilePermissions", b); | 1082 | cfg.writeEntry ( "FilePermissions", b); |
1080 | } | 1083 | } |
1081 | 1084 | ||
1082 | void TextEdit::editPasteTimeDate() { | 1085 | void TextEdit::editPasteTimeDate() { |
1083 | #ifndef QT_NO_CLIPBOARD | 1086 | #ifndef QT_NO_CLIPBOARD |
1084 | QClipboard *cb = QApplication::clipboard(); | 1087 | QClipboard *cb = QApplication::clipboard(); |
1085 | QDateTime dt = QDateTime::currentDateTime(); | 1088 | QDateTime dt = QDateTime::currentDateTime(); |
1086 | cb->setText( dt.toString()); | 1089 | cb->setText( dt.toString()); |
1087 | editor->paste(); | 1090 | editor->paste(); |
1088 | #endif | 1091 | #endif |
1089 | } | 1092 | } |
1090 | 1093 | ||
1091 | int TextEdit::savePrompt() | 1094 | int TextEdit::savePrompt() |
1092 | { | 1095 | { |
1093 | switch( QMessageBox::information( 0, (tr("Textedit")), | 1096 | switch( QMessageBox::information( 0, (tr("Textedit")), |
1094 | (tr("Textedit detected\n" | 1097 | (tr("Textedit detected\n" |
1095 | "you have unsaved changes\n" | 1098 | "you have unsaved changes\n" |
1096 | "Go ahead and save?\n")), | 1099 | "Go ahead and save?\n")), |
1097 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) | 1100 | (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) |
1098 | { | 1101 | { |
1099 | case 0: | 1102 | case 0: |
1100 | { | 1103 | { |
1101 | return 1; | 1104 | return 1; |
1102 | } | 1105 | } |
1103 | break; | 1106 | break; |
1104 | 1107 | ||
1105 | case 1: | 1108 | case 1: |
1106 | { | 1109 | { |
1107 | return 2; | 1110 | return 2; |
1108 | } | 1111 | } |
1109 | break; | 1112 | break; |
1110 | 1113 | ||
1111 | case 2: | 1114 | case 2: |
1112 | { | 1115 | { |
1113 | return -1; | 1116 | return -1; |
1114 | } | 1117 | } |
1115 | break; | 1118 | break; |
1116 | }; | 1119 | }; |
1117 | 1120 | ||
1118 | return 0; | 1121 | return 0; |
1119 | } | 1122 | } |
1120 | 1123 | ||
1121 | void TextEdit::timerCrank() | 1124 | void TextEdit::timerCrank() |
1122 | { | 1125 | { |
1123 | if(featureAutoSave && edited1) | 1126 | if(featureAutoSave && edited1) |
1124 | { | 1127 | { |
1125 | if(currentFileName.isEmpty()) | 1128 | if(currentFileName.isEmpty()) |
1126 | { | 1129 | { |
1127 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; | 1130 | currentFileName = QDir::homeDirPath()+"/textedit.tmp"; |
1128 | saveAs(); | 1131 | saveAs(); |
1129 | } | 1132 | } |
1130 | else | 1133 | else |
1131 | { | 1134 | { |
1132 | // qDebug("autosave"); | 1135 | // odebug << "autosave" << oendl; |
1133 | save(); | 1136 | save(); |
1134 | } | 1137 | } |
1135 | setTimer(); | 1138 | setTimer(); |
1136 | } | 1139 | } |
1137 | } | 1140 | } |
1138 | 1141 | ||
1139 | void TextEdit::doTimer(bool b) | 1142 | void TextEdit::doTimer(bool b) |
1140 | { | 1143 | { |
1141 | Config cfg("TextEdit"); | 1144 | Config cfg("TextEdit"); |
1142 | cfg.setGroup ( "View" ); | 1145 | cfg.setGroup ( "View" ); |
1143 | cfg.writeEntry ( "autosave", b); | 1146 | cfg.writeEntry ( "autosave", b); |
1144 | featureAutoSave = b; | 1147 | featureAutoSave = b; |
1145 | nAutoSave->setOn(b); | 1148 | nAutoSave->setOn(b); |
1146 | if(b) | 1149 | if(b) |
1147 | { | 1150 | { |
1148 | // qDebug("doTimer true"); | 1151 | // odebug << "doTimer true" << oendl; |
1149 | setTimer(); | 1152 | setTimer(); |
1150 | } | 1153 | } |
1151 | // else | 1154 | // else |
1152 | // qDebug("doTimer false"); | 1155 | // odebug << "doTimer false" << oendl; |
1153 | } | 1156 | } |
1154 | 1157 | ||
1155 | void TextEdit::setTimer() | 1158 | void TextEdit::setTimer() |
1156 | { | 1159 | { |
1157 | if(featureAutoSave) | 1160 | if(featureAutoSave) |
1158 | { | 1161 | { |
1159 | // qDebug("setting autosave"); | 1162 | // odebug << "setting autosave" << oendl; |
1160 | QTimer *timer = new QTimer(this ); | 1163 | QTimer *timer = new QTimer(this ); |
1161 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); | 1164 | connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) ); |
1162 | timer->start( 300000, true); //5 minutes | 1165 | timer->start( 300000, true); //5 minutes |
1163 | } | 1166 | } |
1164 | } | 1167 | } |
1165 | 1168 | ||
1166 | void TextEdit::gotoLine() { | 1169 | void TextEdit::gotoLine() { |
1167 | if( editor->length() < 1) | 1170 | if( editor->length() < 1) |
1168 | return; | 1171 | return; |
1169 | QWidget *d = QApplication::desktop(); | 1172 | QWidget *d = QApplication::desktop(); |
1170 | gotoEdit = new QLineEdit( 0, "Goto line"); | 1173 | gotoEdit = new QLineEdit( 0, "Goto line"); |
1171 | 1174 | ||
1172 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); | 1175 | gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2)); |
1173 | gotoEdit->setFrame(true); | 1176 | gotoEdit->setFrame(true); |
1174 | gotoEdit->show(); | 1177 | gotoEdit->show(); |
1175 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); | 1178 | connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto())); |
1176 | } | 1179 | } |
1177 | 1180 | ||
1178 | void TextEdit::doGoto() { | 1181 | void TextEdit::doGoto() { |
1179 | QString number = gotoEdit->text(); | 1182 | QString number = gotoEdit->text(); |
1180 | gotoEdit->hide(); | 1183 | gotoEdit->hide(); |
1181 | 1184 | ||
1182 | if(gotoEdit) { | 1185 | if(gotoEdit) { |
1183 | delete gotoEdit; | 1186 | delete gotoEdit; |
1184 | gotoEdit = 0; | 1187 | gotoEdit = 0; |
1185 | } | 1188 | } |
1186 | 1189 | ||
1187 | bool ok; | 1190 | bool ok; |
1188 | int lineNumber = number.toInt(&ok, 10); | 1191 | int lineNumber = number.toInt(&ok, 10); |
1189 | if( editor->numLines() < lineNumber) | 1192 | if( editor->numLines() < lineNumber) |
1190 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); | 1193 | QMessageBox::message(tr("Text Edit"),tr("Not enough lines")); |
1191 | else | 1194 | else |
1192 | { | 1195 | { |
1193 | editor->setCursorPosition(lineNumber, 0, false); | 1196 | editor->setCursorPosition(lineNumber, 0, false); |
1194 | } | 1197 | } |
1195 | } | 1198 | } |