summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/helpbrowser/helpbrowser.cpp103
-rw-r--r--core/apps/taboapp/main.cpp48
-rw-r--r--core/apps/textedit/filePermissions.cpp2
-rw-r--r--core/apps/textedit/textedit.cpp83
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 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#define QTOPIA_INTERNAL_LANGLIST
#include "helpbrowser.h"
+#include "magictextbrowser.h"
+/* OPIE */
+#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <qpe/resource.h>
+using namespace Opie::Core;
+/* QT */
#include <qmenubar.h>
#include <qtoolbar.h>
#include <qpe/qcopenvelope_qws.h>
#include <qfileinfo.h>
#include <qaction.h>
-#include <cctype>
-
-#include "magictextbrowser.h"
-
HelpBrowser::HelpBrowser( QWidget* parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ),
selectedURL()
{
init( "index.html" );
}
void HelpBrowser::init( const QString& _home )
{
setIcon( Resource::loadPixmap( "HelpBrowser" ) );
setBackgroundMode( PaletteButton );
browser = new MagicTextBrowser( this );
browser->setFrameStyle( QFrame::Panel | QFrame::Sunken );
connect( browser, SIGNAL( textChanged() ),
- this, SLOT( textChanged() ) );
+ this, SLOT( textChanged() ) );
setCentralWidget( browser );
setToolBarsMovable( FALSE );
if ( !_home.isEmpty() )
- browser->setSource( _home );
+ browser->setSource( _home );
QToolBar* toolbar = new QToolBar( this );
toolbar->setHorizontalStretchable( TRUE );
QMenuBar *menu = new QMenuBar( toolbar );
toolbar = new QToolBar( this );
// addToolBar( toolbar, "Toolbar");
QPopupMenu* go = new QPopupMenu( this );
backAction = new QAction( tr( "Backward" ), Resource::loadIconSet( "back" ), QString::null, 0, this, 0 );
connect( backAction, SIGNAL( activated() ), browser, SLOT( backward() ) );
connect( browser, SIGNAL( backwardAvailable(bool) ),
- backAction, SLOT( setEnabled(bool) ) );
+ backAction, SLOT( setEnabled(bool) ) );
backAction->addTo( go );
backAction->addTo( toolbar );
backAction->setEnabled( FALSE );
forwardAction = new QAction( tr( "Forward" ), Resource::loadIconSet( "forward" ), QString::null, 0, this, 0 );
connect( forwardAction, SIGNAL( activated() ), browser, SLOT( forward() ) );
connect( browser, SIGNAL( forwardAvailable(bool) ),
- forwardAction, SLOT( setEnabled(bool) ) );
+ forwardAction, SLOT( setEnabled(bool) ) );
forwardAction->addTo( go );
forwardAction->addTo( toolbar );
forwardAction->setEnabled( FALSE );
QAction *a = new QAction( tr( "Home" ), Resource::loadIconSet( "home" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), browser, SLOT( home() ) );
a->addTo( go );
a->addTo( toolbar );
bookm = new QPopupMenu( this );
bookm->insertItem( tr( "Add Bookmark" ), this, SLOT( addBookmark() ) );
bookm->insertItem( tr( "Remove from Bookmarks" ), this, SLOT( removeBookmark() ) );
bookm->insertSeparator();
connect( bookm, SIGNAL( activated(int) ),
- this, SLOT( bookmChosen(int) ) );
+ this, SLOT( bookmChosen(int) ) );
readBookmarks();
menu->insertItem( tr("Go"), go );
menu->insertItem( tr( "Bookmarks" ), bookm );
resize( 240, 300 );
browser->setFocus();
browser->setFrameStyle( QFrame::NoFrame );
#if !defined(QT_NO_COP)
QCopChannel *addressChannel = new QCopChannel("QPE/HelpBrowser" , this );
connect (addressChannel, SIGNAL( received(const QCString&,const QByteArray&)),
this, SLOT ( appMessage(const QCString&,const QByteArray&) ) );
#endif
connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
- this, SLOT(appMessage(const QCString&,const QByteArray&)) );
+ this, SLOT(appMessage(const QCString&,const QByteArray&)) );
}
void HelpBrowser::appMessage(const QCString& msg, const QByteArray& data)
{
- qDebug("reached appMessage");
+ odebug << "reached appMessage" << oendl;
if ( msg == "showFile(QString)" ) {
- QDataStream ds(data,IO_ReadOnly);
- QString fn;
- ds >> fn;
- setDocument( fn );
+ QDataStream ds(data,IO_ReadOnly);
+ QString fn;
+ ds >> fn;
+ setDocument( fn );
QPEApplication::setKeepRunning();
- showMaximized();
- setActiveWindow();
- raise();
+ showMaximized();
+ setActiveWindow();
+ raise();
}
}
void HelpBrowser::setDocument( const QString &doc )
{
if ( !doc.isEmpty() )
- browser->setSource( doc );
+ browser->setSource( doc );
raise();
}
void HelpBrowser::textChanged()
{
if ( browser->documentTitle().isNull() )
- setCaption( tr("Help Browser") );
+ setCaption( tr("Help Browser") );
else
- setCaption( browser->documentTitle() ) ;
+ setCaption( browser->documentTitle() ) ;
selectedURL = caption();
}
HelpBrowser::~HelpBrowser()
{
QStringList bookmarks;
QMap<int, Bookmark>::Iterator it2 = mBookmarks.begin();
for ( ; it2 != mBookmarks.end(); ++it2 )
- bookmarks.append( (*it2).name + "=" + (*it2).file );
+ bookmarks.append( (*it2).name + "=" + (*it2).file );
QFile f2( Global::applicationFileName("helpbrowser", "bookmarks") );
if ( f2.open( IO_WriteOnly ) ) {
- QDataStream s2( &f2 );
- s2 << bookmarks;
- f2.close();
+ QDataStream s2( &f2 );
+ s2 << bookmarks;
+ f2.close();
}
}
void HelpBrowser::pathSelected( const QString &_path )
{
browser->setSource( _path );
}
void HelpBrowser::readBookmarks()
{
QString file = Global::applicationFileName("helpbrowser", "bookmarks");
if ( QFile::exists( file ) ) {
- QStringList bookmarks;
- QFile f( file );
- if ( f.open( IO_ReadOnly ) ) {
- QDataStream s( &f );
- s >> bookmarks;
- f.close();
- }
- QStringList::Iterator it = bookmarks.begin();
- for ( ; it != bookmarks.end(); ++it ) {
- Bookmark b;
- QString current = *it;
- int equal = current.find( "=" );
- if ( equal < 1 || equal == (int)current.length() - 1 )
- continue;
- b.name = current.left( equal );
- b.file = current.mid( equal + 1 );
- mBookmarks[ bookm->insertItem( b.name ) ] = b;
- }
+ QStringList bookmarks;
+ QFile f( file );
+ if ( f.open( IO_ReadOnly ) ) {
+ QDataStream s( &f );
+ s >> bookmarks;
+ f.close();
+ }
+ QStringList::Iterator it = bookmarks.begin();
+ for ( ; it != bookmarks.end(); ++it ) {
+ Bookmark b;
+ QString current = *it;
+ int equal = current.find( "=" );
+ if ( equal < 1 || equal == (int)current.length() - 1 )
+ continue;
+ b.name = current.left( equal );
+ b.file = current.mid( equal + 1 );
+ mBookmarks[ bookm->insertItem( b.name ) ] = b;
+ }
}
}
void HelpBrowser::bookmChosen( int i )
{
if ( mBookmarks.contains( i ) )
- browser->setSource( mBookmarks[ i ].file );
+ browser->setSource( mBookmarks[ i ].file );
}
void HelpBrowser::addBookmark()
{
Bookmark b;
b.name = browser->documentTitle();
b.file = browser->source();
if (b.name.isEmpty() ) {
- b.name = b.file.left( b.file.length() - 5 ); // remove .html
+ b.name = b.file.left( b.file.length() - 5 ); // remove .html
}
QMap<int, Bookmark>::Iterator it;
for( it = mBookmarks.begin(); it != mBookmarks.end(); ++it )
- if ( (*it).file == b.file ) return;
+ if ( (*it).file == b.file ) return;
mBookmarks[ bookm->insertItem( b.name ) ] = b;
}
void HelpBrowser::removeBookmark()
{
QString file = browser->source();
QMap<int, Bookmark>::Iterator it = mBookmarks.begin();
for( ; it != mBookmarks.end(); ++it )
- if ( (*it).file == file ) {
- bookm->removeItem( it.key() );
- mBookmarks.remove( it );
- break;
- }
+ if ( (*it).file == file ) {
+ bookm->removeItem( it.key() );
+ mBookmarks.remove( it );
+ break;
+ }
}
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 @@
-#include <qdir.h>
-
-#include <qpe/qpeapplication.h>
-#include <qpe/qlibrary.h>
+/* OPIE */
#include <oappinterface.h>
#include <oappplugin.h>
-
+#include <opie2/odebug.h>
#include <opie2/otabwidget.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/qlibrary.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
+/* QT */
+#include <qdir.h>
int main( int argc, char **argv )
{
QPEApplication a( argc, argv );
- Opie::Ui::OTabWidget *tabwidget = new Opie::Ui::OTabWidget(0, "tab widget");
+ OTabWidget *tabwidget = new OTabWidget(0, "tab widget");
QString path = QPEApplication::qpeDir() + "/plugins/app";
QDir dir( path, "lib*.so" );
QStringList list = dir.entryList();
QStringList::Iterator it;
QInterfacePtr<OAppInterface> iface;
for ( it = list.begin(); it != list.end(); ++it ) {
QLibrary *lib = new QLibrary( path + "/" + *it );
- qDebug( "querying: %s", QString( path + "/" + *it ).latin1() );
+ odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl;
if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
- qDebug( "accepted: %s", QString( path + "/" + *it ).latin1() );
+ odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl;
- QList<QWidget> list = iface->widgets();
+ QList<QWidget> list = iface->widgets();
QWidget *widget;
for ( widget = list.first(); widget != 0; widget = list.next() )
tabwidget->addTab(widget, QString(*it), QString(*it));
QString lang = getenv( "LANG" );
- if (lang.isNull())
- lang = "en";
- QTranslator *trans = new QTranslator(qApp);
- QString type = (*it).left( (*it).find(".") );
- if (type.left(3) == "lib")
- type = type.mid(3);
- type = type.right( type.find("lib") );
- QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
- if ( trans->load( tfn ))
- qApp->installTranslator( trans );
- else
- delete trans;
- }
+ if (lang.isNull())
+ lang = "en";
+ QTranslator *trans = new QTranslator(qApp);
+ QString type = (*it).left( (*it).find(".") );
+ if (type.left(3) == "lib")
+ type = type.mid(3);
+ type = type.right( type.find("lib") );
+ QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
+ if ( trans->load( tfn ))
+ qApp->installTranslator( trans );
+ else
+ delete trans;
+ }
}
a.showMainDocumentWidget(tabwidget);
return a.exec();
}
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
@@ -11,49 +11,49 @@
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include "filePermissions.h"
#include <qfileinfo.h>
#include <qcheckbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qmessagebox.h>
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
filePermissions::filePermissions( QWidget* parent, const char* name, bool modal, WFlags fl, const QString &fileName )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( tr("File Permissions") );
-// qDebug("FilePermissions "+fileName);
+// odebug << "FilePermissions "+fileName << oendl;
resize( 236, 210 );
setMaximumSize( QSize( 236, 210 ) );
setCaption( tr( "Set File Permissions" ) );
TextLabel1 = new QLabel( this, "TextLabel1" );
TextLabel1->setGeometry( QRect( 25, 5, 175, 20 ) );
TextLabel1->setText( tr( "Set file permissions for:" ) );
LineEdit1 = new QLineEdit( this, "LineEdit1" );
LineEdit1->setGeometry( QRect( 10, 25, 218, 22 ) );
LineEdit1->setReadOnly(true);
TextLabel4 = new QLabel( this, "TextLabel4" );
TextLabel4->setGeometry( QRect( 5, 85, 50, 15 ) );
TextLabel4->setText( tr( "owner" ) );
TextLabel4_2 = new QLabel( this, "TextLabel4_2" );
TextLabel4_2->setGeometry( QRect( 5, 105, 50, 15 ) );
TextLabel4_2->setText( tr( "group" ) );
TextLabel4_3 = new QLabel( this, "TextLabel4_3" );
TextLabel4_3->setGeometry( QRect( 5, 125, 50, 15 ) );
TextLabel4_3->setText( tr( "others" ) );
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,67 +1,70 @@
/**********************************************************************
// textedit.cpp
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Opie Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
**********************************************************************/
// changes added by L. J. Potter Sun 02-17-2002 21:31:31
+
#include "textedit.h"
#include "filePermissions.h"
-
+/* OPIE */
+#include <opie2/odebug.h>
#include <opie2/ofileselector.h>
#include <opie2/ofiledialog.h>
#include <opie2/ofontselector.h>
-
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/qpeapplication.h>
+using namespace Opie::Core;
+using namespace Opie::Ui;
+
+/* QT */
#include <qmenubar.h>
#include <qtoolbar.h>
-
#include <qtextstream.h>
#include <qclipboard.h>
#include <qaction.h>
#include <qlineedit.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <qtimer.h>
#include <qdir.h>
+
+/* STD */
#include <unistd.h>
#include <sys/stat.h>
#include <stdlib.h> //getenv
-using namespace Opie::Ui;
-
#if QT_VERSION < 300
-
class QpeEditor : public QMultiLineEdit
{
public:
QpeEditor( QWidget *parent, const char * name = 0 )
: QMultiLineEdit( parent, name ) {
clearTableFlags();
setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
}
void find( const QString &txt, bool caseSensitive,
bool backwards );
protected:
bool markIt;
int line1, line2, col1, col2;
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
//public slots:
/*
signals:
void notFound();
void searchWrapped();
*/
@@ -390,49 +393,49 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
bool wrap = cfg. readBoolEntry ( "Wrap", true );
wa-> setOn ( wrap );
setWordWrap ( wrap );
/////////////////
if( qApp->argc() > 1) {
currentFileName=qApp->argv()[1];
QFileInfo fi(currentFileName);
if(fi.baseName().left(1) == "") {
openDotFile(currentFileName);
} else {
openFile(currentFileName);
}
} else {
edited1=false;
openDotFile("");
}
viewSelection = cfg.readNumEntry( "FileView", 0 );
}
TextEdit::~TextEdit() {
- qWarning("textedit d'tor");
+ owarn << "textedit d'tor" << oendl;
delete editor;
}
void TextEdit::closeEvent(QCloseEvent *) {
if( edited1 && promptExit)
{
switch( savePrompt() )
{
case 1:
{
saveAs();
qApp->quit();
}
break;
case 2:
{
qApp->quit();
}
break;
case -1:
break;
};
@@ -625,382 +628,382 @@ void TextEdit::editFind() {
searchEdit->setFocus();
}
void TextEdit::findNext() {
editor->find( searchEdit->text(), false, false );
}
void TextEdit::findClose() {
searchBar->hide();
}
void TextEdit::search() {
editor->find( searchEdit->text(), false, false );
}
void TextEdit::newFile( const DocLnk &f ) {
DocLnk nf = f;
nf.setType("text/plain");
clear();
setWState (WState_Reserved1 );
editor->setFocus();
doc = new DocLnk(nf);
currentFileName = "Unnamed";
- qDebug("newFile "+currentFileName);
+ odebug << "newFile "+currentFileName << oendl;
updateCaption( currentFileName);
// editor->setEdited( false);
}
void TextEdit::openDotFile( const QString &f ) {
if(!currentFileName.isEmpty()) {
currentFileName=f;
- qDebug("openFile dotfile " + currentFileName);
+ odebug << "openFile dotfile " + currentFileName << oendl;
QString txt;
QFile file(f);
file.open(IO_ReadWrite);
QTextStream t(&file);
while ( !t.atEnd()) {
txt+=t.readLine()+"\n";
}
editor->setText(txt);
editor->setEdited( false);
edited1=false;
edited=false;
}
updateCaption( currentFileName);
}
void TextEdit::openFile( const QString &f ) {
- qDebug("filename is "+ f);
+ odebug << "filename is "+ f << oendl;
QString filer;
QFileInfo fi( f);
// bFromDocView = true;
if(f.find(".desktop",0,true) != -1 && !openDesktop )
{
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) )
{
case 0: //desktop
filer = f;
break;
case 1: //linked
DocLnk sf(f);
filer = sf.file();
break;
};
}
else if(fi.baseName().left(1) == "")
{
- qDebug("opening dotfile");
+ odebug << "opening dotfile" << oendl;
currentFileName=f;
openDotFile(currentFileName);
return;
}
/*
* The problem is a file where Config(f).isValid() and it does not
* end with .desktop will be treated as desktop file
*/
else if (f.find(".desktop",0,true) != -1 )
{
DocLnk sf(f);
filer = sf.file();
if(filer.right(1) == "/")
filer = f;
}
else
filer = f;
DocLnk nf;
nf.setType("text/plain");
nf.setFile(filer);
currentFileName=filer;
nf.setName(fi.baseName());
openFile(nf);
- qDebug("openFile string "+currentFileName);
+ odebug << "openFile string "+currentFileName << oendl;
showEditTools();
// Show filename in caption
QString name = filer;
int sep = name.findRev( '/' );
if ( sep > 0 )
name = name.mid( sep+1 );
updateCaption( name );
}
void TextEdit::openFile( const DocLnk &f ) {
// clear();
// bFromDocView = true;
FileManager fm;
QString txt;
currentFileName=f.file();
- qDebug("openFile doclnk " + currentFileName);
+ odebug << "openFile doclnk " + currentFileName << oendl;
if ( !fm.loadFile( f, txt ) ) {
// ####### could be a new file
- qDebug( "Cannot open file" );
+ odebug << "Cannot open file" << oendl;
}
// fileNew();
if ( doc )
delete doc;
doc = new DocLnk(f);
editor->setText(txt);
editor->setEdited( false);
edited1=false;
edited=false;
doc->setName(currentFileName);
updateCaption();
setTimer();
}
void TextEdit::showEditTools() {
menu->show();
editBar->show();
if(!useSearchBar)
searchBar->hide();
else
searchBar->show();
setWState (WState_Reserved1 );
}
/*!
unprompted save */
bool TextEdit::save() {
- qDebug("saveAsFile " + currentFileName);
+ odebug << "saveAsFile " + currentFileName << oendl;
if(currentFileName.isEmpty()) {
saveAs();
return false;
}
QString file = doc->file();
- qDebug("saver file "+file);
+ odebug << "saver file "+file << oendl;
QString name= doc->name();
- qDebug("File named "+name);
+ odebug << "File named "+name << oendl;
QString rt = editor->text();
if( !rt.isEmpty() ) {
if(name.isEmpty()) {
saveAs();
} else {
currentFileName= name ;
- qDebug("saveFile "+currentFileName);
+ odebug << "saveFile "+currentFileName << oendl;
struct stat buf;
mode_t mode;
stat(file.latin1(), &buf);
mode = buf.st_mode;
if(!fileIs) {
doc->setName( name);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
- QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
+ QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
return false;
}
} else {
- qDebug("regular save file");
+ odebug << "regular save file" << oendl;
QFile f(file);
if( f.open(IO_WriteOnly)) {
QCString crt = rt.utf8();
f.writeBlock(crt,crt.length());
} else {
QMessageBox::message(tr("Text Edit"),tr("Write Failed"));
- return false;
+ return false;
}
}
editor->setEdited( false);
edited1=false;
edited=false;
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
chmod( file.latin1(), mode);
}
return true;
}
return false;
}
/*!
prompted save */
bool TextEdit::saveAs() {
if(caption() == tr("Text Editor"))
return false;
- qDebug("saveAsFile " + currentFileName);
+ odebug << "saveAsFile " + currentFileName << oendl;
// case of nothing to save...
// if ( !doc && !currentFileName.isEmpty()) {
// //|| !bFromDocView)
-// qDebug("no doc");
+// odebug << "no doc" << oendl;
// return true;
// }
// if ( !editor->edited() ) {
// delete doc;
// doc = 0;
// return true;
// }
QString rt = editor->text();
- qDebug(currentFileName);
+ odebug << currentFileName << oendl;
if( currentFileName.isEmpty()
|| currentFileName == tr("Unnamed")
|| currentFileName == tr("Text Editor")) {
- qDebug("do silly TT filename thing");
+ odebug << "do silly TT filename thing" << oendl;
// if ( doc && doc->name().isEmpty() ) {
QString pt = rt.simplifyWhiteSpace();
int i = pt.find( ' ' );
QString docname = pt;
if ( i > 0 )
docname = pt.left( i );
// remove "." at the beginning
while( docname.startsWith( "." ) )
docname = docname.mid( 1 );
docname.replace( QRegExp("/"), "_" );
// cut the length. filenames longer than that
//don't make sense and something goes wrong when they get too long.
if ( docname.length() > 40 )
docname = docname.left(40);
if ( docname.isEmpty() )
docname = tr("Unnamed");
if(doc) doc->setName(docname);
currentFileName=docname;
// }
// else
-// qDebug("hmmmmmm");
+// odebug << "hmmmmmm" << oendl;
}
QMap<QString, QStringList> map;
map.insert(tr("All"), QStringList() );
QStringList text;
text << "text/*";
map.insert(tr("Text"), text );
text << "*";
map.insert(tr("All"), text );
QFileInfo cuFi( currentFileName);
QString filee = cuFi.fileName();
QString dire = cuFi.dirPath();
if(dire==".")
dire = QPEApplication::documentDir();
QString str;
if( !featureAutoSave) {
str = OFileDialog::getSaveFileName( 2,
dire,
filee, map);
} else
str=currentFileName;
if(!str.isEmpty()) {
QString fileNm=str;
- qDebug("saving filename "+fileNm);
+ odebug << "saving filename "+fileNm << oendl;
QFileInfo fi(fileNm);
currentFileName=fi.fileName();
if(doc)
// QString file = doc->file();
// doc->removeFiles();
delete doc;
DocLnk nf;
nf.setType("text/plain");
nf.setFile( fileNm);
doc = new DocLnk(nf);
// editor->setText(rt);
- qDebug("Saving file as "+currentFileName);
+ odebug << "Saving file as "+currentFileName << oendl;
doc->setName( currentFileName);
updateCaption( currentFileName);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
- QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
+ QMessageBox::message(tr("Text Edit"),tr("Save Failed"));
return false;
}
if( filePerms ) {
filePermissions *filePerm;
filePerm = new filePermissions(this,
tr("Permissions"),true,
0,(const QString &)fileNm);
QPEApplication::execDialog( filePerm );
if( filePerm)
delete filePerm;
}
// }
editor->setEdited( false);
edited1 = false;
edited = false;
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
return true;
}
- qDebug("returning false");
+ odebug << "returning false" << oendl;
return false;
} //end saveAs
void TextEdit::clear() {
delete doc;
doc = 0;
editor->clear();
}
void TextEdit::updateCaption( const QString &name ) {
if ( name.isEmpty() )
setCaption( tr("Text Editor") );
else {
QString s = name;
if ( s.isNull() )
s = doc->name();
if ( s.isEmpty() ) {
s = tr( "Unnamed" );
currentFileName=s;
}
// if(s.left(1) == "/")
// s = s.right(s.length()-1);
setCaption( tr("%1 - Text Editor").arg( s ) );
}
}
void TextEdit::setDocument(const QString& fileref) {
if(fileref != "Unnamed") {
currentFileName=fileref;
- qDebug("setDocument");
+ odebug << "setDocument" << oendl;
QFileInfo fi(currentFileName);
- qDebug("basename:"+fi.baseName()+": current filenmame "+currentFileName);
+ odebug << "basename:"+fi.baseName()+": current filenmame "+currentFileName << oendl;
if( (fi.baseName().left(1)).isEmpty() ) {
openDotFile(currentFileName);
} else {
- qDebug("setDoc open");
+ odebug << "setDoc open" << oendl;
bFromDocView = true;
openFile(fileref);
editor->setEdited(true);
edited1=false;
edited=true;
// fromSetDocument=false;
// doSearchBar();
}
}
updateCaption( currentFileName);
}
void TextEdit::changeFont() {
QDialog *d = new QDialog ( this, "FontDialog", true );
d-> setCaption ( tr( "Choose font" ));
QBoxLayout *lay = new QVBoxLayout ( d );
OFontSelector *ofs = new OFontSelector ( true, d );
lay-> addWidget ( ofs );
ofs-> setSelectedFont ( editor-> font ( ));
if ( QPEApplication::execDialog( d ) == QDialog::Accepted )
editor-> setFont ( ofs-> selectedFont ( ));
delete d;
@@ -1013,60 +1016,60 @@ void TextEdit::editDelete() {
"<B>irreversable!</B>"),
tr("Yes"),tr("No"),0,0,1) ) {
case 0:
if(doc) {
doc->removeFiles();
clear();
setCaption( tr("Text Editor") );
}
break;
case 1:
// exit
break;
};
}
void TextEdit::changeStartConfig( bool b ) {
startWithNew=b;
Config cfg("TextEdit");
cfg.setGroup("View");
cfg.writeEntry("startNew",b);
update();
}
void TextEdit::editorChanged() {
-// qDebug("editor changed");
+// odebug << "editor changed" << oendl;
if( /*editor->edited() &&*/ /*edited && */!edited1) {
setCaption( "*"+caption());
edited1=true;
}
edited=true;
}
void TextEdit::receive(const QCString&msg, const QByteArray &) {
- qDebug("QCop "+msg);
+ odebug << "QCop "+msg << oendl;
if ( msg == "setDocument(QString)" ) {
- qDebug("bugger all");
+ odebug << "bugger all" << oendl;
}
}
void TextEdit::doAbout() {
QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>"
"2000 Trolltech AS, and<BR>"
"2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>"
"and is licensed under the GPL"));
}
void TextEdit::doPrompt(bool b) {
promptExit=b;
Config cfg("TextEdit");
cfg.setGroup ( "View" );
cfg.writeEntry ( "PromptExit", b);
}
void TextEdit::doDesktop(bool b) {
openDesktop=b;
Config cfg("TextEdit");
cfg.setGroup ( "View" );
cfg.writeEntry ( "OpenDesktop", b);
@@ -1108,76 +1111,76 @@ int TextEdit::savePrompt()
}
break;
case 2:
{
return -1;
}
break;
};
return 0;
}
void TextEdit::timerCrank()
{
if(featureAutoSave && edited1)
{
if(currentFileName.isEmpty())
{
currentFileName = QDir::homeDirPath()+"/textedit.tmp";
saveAs();
}
else
{
-// qDebug("autosave");
+// odebug << "autosave" << oendl;
save();
}
setTimer();
}
}
void TextEdit::doTimer(bool b)
{
Config cfg("TextEdit");
cfg.setGroup ( "View" );
cfg.writeEntry ( "autosave", b);
featureAutoSave = b;
nAutoSave->setOn(b);
if(b)
{
-// qDebug("doTimer true");
+// odebug << "doTimer true" << oendl;
setTimer();
}
// else
-// qDebug("doTimer false");
+// odebug << "doTimer false" << oendl;
}
void TextEdit::setTimer()
{
if(featureAutoSave)
{
-// qDebug("setting autosave");
+// odebug << "setting autosave" << oendl;
QTimer *timer = new QTimer(this );
connect( timer, SIGNAL(timeout()), this, SLOT(timerCrank()) );
timer->start( 300000, true); //5 minutes
}
}
void TextEdit::gotoLine() {
if( editor->length() < 1)
return;
QWidget *d = QApplication::desktop();
gotoEdit = new QLineEdit( 0, "Goto line");
gotoEdit->move( (d->width()/2) - ( gotoEdit->width()/2) , (d->height()/2) - (gotoEdit->height()/2));
gotoEdit->setFrame(true);
gotoEdit->show();
connect (gotoEdit,SIGNAL(returnPressed()), this, SLOT(doGoto()));
}
void TextEdit::doGoto() {
QString number = gotoEdit->text();
gotoEdit->hide();
if(gotoEdit) {
delete gotoEdit;