summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-02-18 14:08:55 (UTC)
committer llornkcor <llornkcor>2002-02-18 14:08:55 (UTC)
commit9741205aa0b0892b870d2b7df7c5dd7e25b0bb18 (patch) (side-by-side diff)
tree7f2f3d44ff3215984bd8b487b206d3d958a498da
parent0640b30f13beb9d6480d8042ec5397a68e6247fc (diff)
downloadopie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.zip
opie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.tar.gz
opie-9741205aa0b0892b870d2b7df7c5dd7e25b0bb18.tar.bz2
added fontDialog, fileBrowserDialog, and fileSave dialog, so we can edit anyfile, save anywhere,
using a user selected name. Changed what is seen when it opens. It now opens with the texteditor opened to a new file, instead of the file selector, unless one is specified from commandline, or setDocument message. FileSelector is still available, but from a menu item.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/Makefile.in8
-rw-r--r--core/apps/textedit/fileBrowser.cpp160
-rw-r--r--core/apps/textedit/fileBrowser.h67
-rw-r--r--core/apps/textedit/fileSaver.cpp164
-rw-r--r--core/apps/textedit/fileSaver.h71
-rw-r--r--core/apps/textedit/fontDialog.cpp236
-rw-r--r--core/apps/textedit/fontDialog.h63
-rw-r--r--core/apps/textedit/inserttable.ui103
-rw-r--r--core/apps/textedit/qtextedit.h282
-rw-r--r--core/apps/textedit/textedit.cpp291
-rw-r--r--core/apps/textedit/textedit.h7
-rw-r--r--core/apps/textedit/textedit.pro4
12 files changed, 1025 insertions, 431 deletions
diff --git a/core/apps/textedit/Makefile.in b/core/apps/textedit/Makefile.in
index 997f2a4..bef671c 100644
--- a/core/apps/textedit/Makefile.in
+++ b/core/apps/textedit/Makefile.in
@@ -103,3 +103,5 @@ main.o: main.cpp \
$(OPIEDIR)/include/qpe/filemanager.h \
- $(OPIEDIR)/include/qpe/qpeapplication.h
+ $(OPIEDIR)/include/qpe/qpeapplication.h \
+ $(OPIEDIR)/include/qpedecoration_qws.h \
+ $(OPIEDIR)/include/timestring.h
@@ -110,2 +112,4 @@ textedit.o: textedit.cpp \
$(OPIEDIR)/include/qpe/fileselector.h \
+ $(OPIEDIR)/include/filemanager.h \
+ $(OPIEDIR)/include/applnk.h \
$(OPIEDIR)/include/qpe/applnk.h \
@@ -114,2 +118,4 @@ textedit.o: textedit.cpp \
$(OPIEDIR)/include/qpe/qpeapplication.h \
+ $(OPIEDIR)/include/qpedecoration_qws.h \
+ $(OPIEDIR)/include/timestring.h \
$(OPIEDIR)/include/qpe/qpemenubar.h \
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
new file mode 100644
index 0000000..82ccf2c
--- a/dev/null
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -0,0 +1,160 @@
+/****************************************************************************
+** copyright 2001 ljp ljp@llornkcor.com
+** Created: Fri Dec 14 08:16:46 2001
+**
+** 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.
+**
+****************************************************************************/
+#include "fileBrowser.h"
+#include <qpe/config.h>
+
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qfile.h>
+#include <qmessagebox.h>
+#include <unistd.h>
+
+fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString filter )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "fileBrowser" );
+ resize( 236, 280 );
+ setCaption(tr( "Browse for file" ) );
+ filterStr=filter;
+ dirLabel = new QLabel(this, "DirLabel");
+ dirLabel->setText(currentDir.canonicalPath());
+ dirLabel->setGeometry(10,4,230,30);
+ ListView = new QListView( this, "ListView" );
+ ListView->addColumn( tr( "Name" ) );
+ ListView->setColumnWidth(0,140);
+ ListView->setSorting( 2, FALSE);
+ ListView->addColumn( tr( "Size" ) );
+ ListView->setColumnWidth(1,59);
+// ListView->addColumn( tr( "" ) );
+// ListView->setColumnWidth(1,59);
+// ListView->setMultiSelection(true);
+// ListView->setSelectionMode(QListView::Extended);
+
+ ListView->setAllColumnsShowFocus( TRUE );
+ ListView->setGeometry( QRect( 10, 35, 220, 240 ) );
+
+ // signals and slots connections
+ connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
+ connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
+ currentDir.setPath(QDir::currentDirPath());
+ populateList();
+}
+
+fileBrowser::~fileBrowser()
+{
+}
+
+
+void fileBrowser::populateList()
+{
+ ListView->clear();
+//qDebug(currentDir.canonicalPath());
+ currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
+ currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
+ currentDir.setMatchAllDirs(TRUE);
+
+ currentDir.setNameFilter(filterStr);
+// currentDir.setNameFilter("*.txt;*.etx");
+ QString fileL, fileS;
+ const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
+ QFileInfoListIterator it(*list);
+ QFileInfo *fi;
+ while ( (fi=it.current()) ) {
+
+ if (fi->isSymLink() ){
+ QString symLink=fi->readLink();
+// qDebug("Symlink detected "+symLink);
+ QFileInfo sym( symLink);
+ fileS.sprintf( "%10li", sym.size() );
+ fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
+
+ } else {
+// qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
+ fileS.sprintf( "%10li", fi->size() );
+ fileL.sprintf( "%s",fi->fileName().data() );
+ if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
+ fileL+="/";
+// qDebug(currentDir.canonicalPath()+fileL);
+ }
+ }
+ item= new QListViewItem( ListView,fileL,fileS );
+ ++it;
+ }
+ ListView->setSorting( 2, FALSE);
+ dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
+}
+
+void fileBrowser::upDir()
+{
+// qDebug(currentDir.canonicalPath());
+}
+
+void fileBrowser::listDoubleClicked(QListViewItem *selectedItem)
+{
+}
+
+// you may want to switch these 2 functions. I like single clicks
+void fileBrowser::listClicked(QListViewItem *selectedItem)
+{
+ QString strItem=selectedItem->text(0);
+ QString strSize=selectedItem->text(1);
+// qDebug("strItem is "+strItem);
+ strSize.stripWhiteSpace();
+// qDebug(strSize);
+
+ if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
+ // is symlink
+ QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
+// qDebug("strItem symlink is "+strItem2);
+ if(QDir(strItem2).exists() ) {
+ currentDir.cd(strItem2, TRUE);
+ populateList();
+ }
+ } else { // not a symlink
+ if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
+ if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
+ strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
+ currentDir.cd(strItem,FALSE);
+// qDebug("Path is "+strItem);
+ populateList();
+ } else {
+ currentDir.cdUp();
+ populateList();
+ }
+ if(QDir(strItem).exists()){
+ currentDir.cd(strItem, TRUE);
+ populateList();
+ }
+ } else
+ if( QFile::exists(strItem ) ) {
+// qDebug("We found our files!!");
+ OnOK();
+ } //end not symlink
+ chdir(strItem.latin1());
+ }
+}
+
+void fileBrowser::OnOK()
+{
+ QListViewItemIterator it1( ListView);
+ for ( ; it1.current(); ++it1 ) {
+ if ( it1.current()->isSelected() ) {
+ selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0));
+// qDebug("selected filename is "+selectedFileName);
+ fileList.append( selectedFileName );
+ }
+ }
+ accept();
+}
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h
new file mode 100644
index 0000000..17ed862
--- a/dev/null
+++ b/core/apps/textedit/fileBrowser.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Created: Fri Dec 14 08:16:02 2001
+**
+** 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.
+**
+copyright Sun 02-17-2002 22:28:23 L. J. Potter ljp@llornkcor.com
+****************************************************************************/
+#ifndef FILEBROWSER_H
+#define FILEBROWSER_H
+
+//#include <qvariant.h>
+#include <qdialog.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qstringlist.h>
+#include <qlabel.h>
+#include <qstring.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QListView;
+class QListViewItem;
+class QPushButton;
+
+class fileBrowser : public QDialog
+{
+ Q_OBJECT
+
+public:
+ void populateList();
+ fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
+ ~fileBrowser();
+
+ QPushButton* buttonOk;
+ QListView* ListView;
+ QPushButton* buttonCancel;
+ QLabel *dirLabel;
+ QString selectedFileName, filterStr;
+ QDir currentDir;
+ QFile file;
+ QStringList fileList;
+
+QListViewItem * item;
+public slots:
+
+private:
+
+private slots:
+ void upDir();
+ void listDoubleClicked(QListViewItem *);
+ void listClicked(QListViewItem *);
+ void OnOK();
+protected slots:
+
+protected:
+
+};
+
+#endif // FILEBROWSER_H
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
new file mode 100644
index 0000000..d01daee
--- a/dev/null
+++ b/core/apps/textedit/fileSaver.cpp
@@ -0,0 +1,164 @@
+/****************************************************************************
+** copyright 2001 ljp ljp@llornkcor.com
+** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp
+**
+** 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.
+**
+****************************************************************************/
+#include "fileSaver.h"
+#include <qpe/config.h>
+#include <qpe/qpeapplication.h>
+
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qfile.h>
+#include <qmessagebox.h>
+#include <unistd.h>
+#include <qlineedit.h>
+
+fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "fileSaver" );
+ resize( 236, 280 );
+ setCaption(tr( "Save file" ) );
+// filterStr=currentFileName;
+
+ dirLabel = new QLabel(this, "DirLabel");
+ dirLabel->setText(currentDir.canonicalPath());
+ dirLabel->setGeometry(10,4,230,30);
+
+ ListView = new QListView( this, "ListView" );
+ ListView->addColumn( tr( "Name" ) );
+ ListView->setColumnWidth(0,140);
+ ListView->setSorting( 2, FALSE);
+ ListView->addColumn( tr( "Size" ) );
+ ListView->setColumnWidth(1,59);
+// ListView->setMultiSelection(true);
+// ListView->setSelectionMode(QListView::Extended);
+
+ ListView->setAllColumnsShowFocus( TRUE );
+ ListView->setGeometry( QRect( 10, 35, 220, 160 ) );
+
+ fileEdit= new QLineEdit(this);
+ fileEdit->setGeometry( QRect( 10, 230, 200, 25));
+ fileEdit->setText(currentFileName);
+ // signals and slots connections
+ connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) );
+ connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) );
+ currentDir.setPath(QDir::currentDirPath() );
+ populateList();
+}
+
+fileSaver::~fileSaver()
+{
+}
+
+
+void fileSaver::populateList()
+{
+ ListView->clear();
+ currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden );
+ currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst);
+ currentDir.setMatchAllDirs(TRUE);
+
+ currentDir.setNameFilter("*");
+ QString fileL, fileS;
+ const QFileInfoList *list = currentDir.entryInfoList(QDir::All /*, QDir::SortByMask*/);
+ QFileInfoListIterator it(*list);
+ QFileInfo *fi;
+ while ( (fi=it.current()) ) {
+
+ if (fi->isSymLink() ){
+ QString symLink=fi->readLink();
+// qDebug("Symlink detected "+symLink);
+ QFileInfo sym( symLink);
+ fileS.sprintf( "%10li", sym.size() );
+ fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() );
+
+ } else {
+// // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL);
+ fileS.sprintf( "%10li", fi->size() );
+ fileL.sprintf( "%s",fi->fileName().data() );
+ if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) {
+ fileL+="/";
+// qDebug(currentDir.canonicalPath()+fileL);
+ }
+ }
+ item= new QListViewItem( ListView,fileL,fileS );
+ ++it;
+ }
+ ListView->setSorting( 2, FALSE);
+ dirLabel->setText("Current Directory:\n"+currentDir.canonicalPath());
+
+
+}
+
+void fileSaver::upDir()
+{
+// qDebug(currentDir.canonicalPath());
+}
+
+void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
+{
+}
+
+void fileSaver::listClicked(QListViewItem *selectedItem)
+{
+ QString strItem=selectedItem->text(0);
+ QString strSize=selectedItem->text(1);
+// qDebug("strItem is "+strItem);
+ strSize.stripWhiteSpace();
+// qDebug(strSize);
+
+ if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink
+ QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4);
+// qDebug("strItem symlink is "+strItem2);
+ if(QDir(strItem2).exists() ) {
+ currentDir.cd(strItem2, TRUE);
+ populateList();
+ }
+ } else { // not a symlink
+ if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) {
+ if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) {
+ strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem);
+ currentDir.cd(strItem,FALSE);
+// qDebug("Path is "+strItem);
+ populateList();
+ } else {
+ currentDir.cdUp();
+ populateList();
+ }
+ if(QDir(strItem).exists()){
+ currentDir.cd(strItem, TRUE);
+ populateList();
+ }
+ } // else
+// if( QFile::exists(strItem ) ) {
+// qDebug("We found our files!!");
+
+// OnOK();
+ } //end not symlink
+ chdir(strItem.latin1());
+
+
+}
+
+
+void fileSaver::OnOK()
+{
+// reject();
+}
+
+void fileSaver::accept() {
+ selectedFileName = fileEdit->text();
+ selectedFileName = currentDir.canonicalPath()+ selectedFileName;
+ reject();
+}
diff --git a/core/apps/textedit/fileSaver.h b/core/apps/textedit/fileSaver.h
new file mode 100644
index 0000000..f496270
--- a/dev/null
+++ b/core/apps/textedit/fileSaver.h
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Created: Fri Dec 14 08:16:02 2001 fileSaver.h
+**
+copyright Sun 02-17-2002 22:28:48 L. J. Potter ljp@llornkcor.com
+
+** 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.
+**
+****************************************************************************/
+#ifndef FILESAVER_H
+#define FILESAVER_H
+
+//#include <qvariant.h>
+#include <qdialog.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qstringlist.h>
+#include <qlabel.h>
+#include <qstring.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QListView;
+class QListViewItem;
+class QPushButton;
+class QLineEdit;
+
+class fileSaver : public QDialog
+{
+ Q_OBJECT
+
+public:
+ void populateList();
+ fileSaver( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0);
+ ~fileSaver();
+ QLineEdit *fileEdit;
+
+ QPushButton* buttonOk;
+ QListView* ListView;
+ QPushButton* buttonCancel;
+ QLabel *dirLabel;
+ QString selectedFileName, filterStr;
+ QDir currentDir;
+ QFile file;
+ QStringList fileList;
+
+QListViewItem * item;
+public slots:
+
+private:
+
+private slots:
+ void accept();
+ void upDir();
+ void listDoubleClicked(QListViewItem *);
+ void listClicked(QListViewItem *);
+ void OnOK();
+protected slots:
+
+protected:
+
+};
+
+#endif // FILESAVER_H
diff --git a/core/apps/textedit/fontDialog.cpp b/core/apps/textedit/fontDialog.cpp
new file mode 100644
index 0000000..e7bd924
--- a/dev/null
+++ b/core/apps/textedit/fontDialog.cpp
@@ -0,0 +1,236 @@
+/****************************************************************************
+** Created: Sun Jan 27 11:03:24 2002 fileDialog.cpp
+copyright 2002 by L.J. Potter ljp@llornkcor.com
+
+** 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.
+**
+****************************************************************************/
+#include "fontDialog.h"
+
+#include <qpe/fontdatabase.h>
+#include <qpe/config.h>
+
+#include <qstringlist.h>
+#include <qfontinfo.h>
+#include <qvaluelist.h>
+#include <qpe/qpeapplication.h>
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlistbox.h>
+#include <qmultilineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+FontDialog::FontDialog( QWidget * parent, const char* name , bool modal, WFlags fl )
+ :QDialog /*QWidget*/( parent, name , modal, fl )
+{
+ if ( !name )
+ setName( "FontDialog" );
+ setCaption( tr( "Font Dialog" ) );
+ FontTextLabel4 = new QLabel( this, "TextLabel4" );
+ FontTextLabel4->setGeometry( QRect( 145, 100, 30, 19 /*192, 0, 43, 19*/ ) );
+ FontTextLabel4->setText( tr( "Size" ) );
+
+ FamilyGroup = new QGroupBox( this, "FamilyGroup" );
+ FamilyGroup->setGeometry( QRect( 5, 5, 115, 135 /*0, 6, 185, 131 */) );
+ FamilyGroup->setTitle( tr( "Font" ) );
+
+ familyListBox = new QListBox( FamilyGroup, "familyListBox" );
+ familyListBox->setGeometry( QRect( 5, 20, 100, 105 /* 6, 18, 170, 105 */) );
+
+ GroupBox2 = new QGroupBox( this, "GroupBox2" );
+ GroupBox2->setGeometry( QRect( 120, 5, 100, 90/* 0, 138, 170, 90*/ ) );
+ GroupBox2->setTitle( tr( "Font Style" ) );
+
+ styleListBox = new QListBox( GroupBox2, "styleListBox" );
+ styleListBox->setGeometry( QRect( 5, 20, 90, 60 /*10, 20, 150, 61*/ ) );
+
+ sizeListBox = new QListBox( this, "sizeListBox" );
+ sizeListBox->setGeometry( QRect( 180, 100, 40, 60 /* 192, 24, 40, 108 */) );
+
+ MultiLineEdit1 = new QMultiLineEdit( this, "MultiLineEdit1" );
+ MultiLineEdit1->setGeometry( QRect( 5, 165, 215, 45 /* 6, 234, 222, 55*/ ) );
+ MultiLineEdit1->setText( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ) );
+ MultiLineEdit1->setWordWrap(QMultiLineEdit::WidgetWidth);
+
+ connect( familyListBox,SIGNAL( highlighted( const QString &)),SLOT( familyListBoxSlot(const QString &) ));
+ connect( styleListBox,SIGNAL( highlighted( const QString &)),SLOT( styleListBoxSlot(const QString &) ));
+ connect( sizeListBox,SIGNAL( highlighted( const QString &)),SLOT( sizeListBoxSlot(const QString &) ));
+
+ populateLists();
+// MultiLineEdit1
+// connect();
+
+}
+
+FontDialog::~FontDialog()
+{
+}
+
+void FontDialog::familyListBoxSlot(const QString & text)
+{
+ int styleInt=styleListBox->currentItem();
+ int sizeInt=sizeListBox->currentItem();
+
+ styleListBox->clear();
+ sizeListBox->clear();
+ family= text;
+// qDebug(family);
+ QStringList styles = fdb.styles( family ); // string list of styles of our current font family
+ styleListBox->insertStringList( styles);
+ QString dstyle;// = "\t" + style + " (";
+ QValueList<int> smoothies = fdb.smoothSizes( family, styleListBox->text(0) );
+ for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
+ dstyle = QString::number( *points );
+ sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
+ }
+ if(styleInt == -1 || styleInt > styleListBox->count() )
+ styleListBox->setCurrentItem(0);
+ else
+ styleListBox->setCurrentItem(styleInt);
+
+ if(sizeInt == -1 || sizeInt > sizeListBox->count())
+ sizeListBox->setCurrentItem(0);
+ else
+ sizeListBox->setCurrentItem(sizeInt);
+
+ changeText();
+}
+
+void FontDialog::styleListBoxSlot(const QString &text)
+{
+ changeText();
+}
+
+void FontDialog::sizeListBoxSlot(const QString & text)
+{
+ changeText();
+}
+
+void FontDialog::populateLists()
+{
+// QFont defaultFont=MultiLineEdit1->font();
+// QFont defaultFont=Lview->font();
+// QFontInfo fontInfo(defaultFont);
+ Config config("TextEdit");
+ config.setGroup("Font");
+ QString familyStr = config.readEntry("Family", "fixed");
+ QString styleStr = config.readEntry("Style", "Regular");
+ QString sizeStr = config.readEntry("Size", "10");
+ QString charSetStr = config.readEntry("CharSet", "iso10646-1" );
+ bool ok;
+ int i_size=sizeStr.toInt(&ok,10);
+ selectedFont = fdb.font(familyStr,styleStr,i_size,charSetStr);
+// defaultFont.setItalic(TRUE);
+ families = fdb.families();
+ for ( QStringList::Iterator f = families.begin(); f != families.end();++f ) {
+ QString family = *f;
+// if(family == defaultFont.family())
+// qDebug(family);
+ familyListBox->insertItem( family);
+
+ if( familyListBox->text(0) == family) {
+ QStringList styles = fdb.styles( family ); // string list of styles of our current font family
+ styleListBox->insertStringList( styles);
+ for ( QStringList::Iterator s = styles.begin(); s != styles.end();++s ) { // for each font style
+ style = *s;
+ QString dstyle;// = "\t" + style + " (";
+ if(styleListBox->text(0) == style) {
+ QValueList<int> smoothies = fdb.smoothSizes( family, style );
+ for ( QValueList<int>::Iterator points = smoothies.begin(); points != smoothies.end(); ++points ) {
+ dstyle = QString::number( *points ) + " ";
+
+ sizeListBox ->insertItem( dstyle.left( dstyle.length() - 1 ));
+ }
+ dstyle = dstyle.left( dstyle.length() - 1 ) + ")";
+ }
+ } // styles
+ }
+ }
+ for(int i=0;i < familyListBox->count();i++) {
+ if( familyListBox->text(i) == familyStr)
+ familyListBox->setSelected( i, TRUE);
+ }
+
+ for(int i=0;i < styleListBox->count();i++) {
+ if( styleListBox->text(i) == styleStr)
+ styleListBox->setSelected( i, TRUE);
+ }
+
+ for(int i=0;i < sizeListBox->count();i++) {
+ if( sizeListBox->text(i) == sizeStr)
+ sizeListBox->setSelected( i, TRUE);
+ }
+ changeText();
+}
+
+void FontDialog::clearListBoxes() {
+ familyListBox->clear();
+ sizeListBox->clear();
+ styleListBox->clear();
+}
+
+void FontDialog::changeText()
+{
+ if( familyListBox->currentItem() == -1)
+ family= familyListBox->text(0);
+ else {
+ family = familyListBox->currentText();
+ }
+// qDebug("Font family is "+family);
+ if( styleListBox->currentItem() == -1)
+ style=styleListBox->text(0);
+ else {
+ style = styleListBox->currentText();
+ }
+// qDebug("font style is "+style);
+ if( sizeListBox->currentItem() == -1 )
+ size= sizeListBox->text(0);
+ else {
+ size = sizeListBox->currentText();
+ }
+
+// qDebug("Font size is "+size);
+ bool ok;
+ int i_size= size.toInt(&ok,10);
+ QStringList charSetList= fdb.charSets(family);
+// QStringList styles = fdb.styles( family ); // string list of styles of our current font family
+ QString charSet;
+ for ( QStringList::Iterator s = charSetList.begin(); s != charSetList.end();++s ) { // for each font style
+ charSet = *s;
+// qDebug(charSet);
+ }
+ selectedFont = fdb.font(family,style,i_size,charSet);
+ QFontInfo fontInfo( selectedFont);
+// if(fontInfo.italic() ) qDebug("italic");
+ selectedFont.setWeight(fontInfo.weight() );
+// qDebug("Style are "+style+" %d ",fontInfo.weight());
+ Config cfg("TextEdit");
+ cfg.setGroup("Font");
+ cfg.writeEntry("Family",family);
+ cfg.writeEntry("Style",style);
+ cfg.writeEntry("Size",size);
+ cfg.writeEntry("CharSet",charSet);
+
+ if(style.find("Italic",0,TRUE) != -1) {
+ selectedFont = fdb.font(family,"Regular",i_size,charSet);
+ selectedFont.setItalic(TRUE); //ya right
+ cfg.writeEntry("Italic","TRUE");
+// qDebug("Style is "+styleListBox->currentText());
+ } else
+ cfg.writeEntry("Italic","FALSE");
+ changedFonts=TRUE;
+ MultiLineEdit1->setFont( selectedFont);
+ MultiLineEdit1->update();
+}
+
diff --git a/core/apps/textedit/fontDialog.h b/core/apps/textedit/fontDialog.h
new file mode 100644
index 0000000..ef930df
--- a/dev/null
+++ b/core/apps/textedit/fontDialog.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+** Created: Sun Jan 27 11:02:59 2002 fileDialog.h
+copyright 2002 by L.J. Potter ljp@llornkcor.com
+
+** 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.
+**
+****************************************************************************/
+#ifndef FONTDIALOG_H
+#define FONTDIALOG_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+#include <qpe/fontdatabase.h>
+#include <qfont.h>
+
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QLabel;
+class QListBox;
+class QListBoxItem;
+class QPushButton;
+class QGroupBox;
+class QMultiLineEdit;
+
+class FontDialog : public QDialog// QWidget
+{
+ Q_OBJECT
+
+public:
+ FontDialog( QWidget * parent = 0, const char* name = 0 , bool modal=FALSE, WFlags fl = 0 );
+ ~FontDialog();
+
+ QLabel *FontTextLabel4;
+ QGroupBox *FamilyGroup, *GroupBox2;
+ QListBox *familyListBox, *styleListBox, *sizeListBox;
+ QMultiLineEdit *MultiLineEdit1;
+ QPushButton *PushButtonOk,*PushButtonCancel;
+ QStringList families;
+
+ FontDatabase fdb;
+ QString family, style, size;
+ QFont selectedFont;
+ bool changedFonts;
+ void populateLists();
+ void clearListBoxes();
+ void changeText();
+protected slots:
+
+ void familyListBoxSlot(const QString &);
+ void styleListBoxSlot(const QString &);
+ void sizeListBoxSlot(const QString &);
+
+
+};
+
+#endif // FONTDIALOG_H
diff --git a/core/apps/textedit/inserttable.ui b/core/apps/textedit/inserttable.ui
deleted file mode 100644
index 09fe3c3..0000000
--- a/core/apps/textedit/inserttable.ui
+++ b/dev/null
@@ -1,103 +0,0 @@
-<!DOCTYPE UI><UI>
-<class>InsertTable</class><comment>*********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of 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.
-**
-*********************************************************************</comment>
-<widget>
- <class>QDialog</class>
- <property stdset="1">
- <name>name</name>
- <cstring>InsertTable</cstring>
- </property>
- <property stdset="1">
- <name>geometry</name>
- <rect>
- <x>0</x>
- <y>0</y>
- <width>165</width>
- <height>79</height>
- </rect>
- </property>
- <property stdset="1">
- <name>caption</name>
- <string>Insert Table</string>
- </property>
- <grid>
- <property stdset="1">
- <name>margin</name>
- <number>11</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget row="0" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Rows:</string>
- </property>
- </widget>
- <widget row="0" column="1" >
- <class>QSpinBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>spinRows</cstring>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>1</number>
- </property>
- </widget>
- <widget row="1" column="1" >
- <class>QSpinBox</class>
- <property stdset="1">
- <name>name</name>
- <cstring>spinColumns</cstring>
- </property>
- <property stdset="1">
- <name>minValue</name>
- <number>1</number>
- </property>
- <property stdset="1">
- <name>value</name>
- <number>1</number>
- </property>
- </widget>
- <widget row="1" column="0" >
- <class>QLabel</class>
- <property stdset="1">
- <name>name</name>
- <cstring>TextLabel1_2</cstring>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Columns:</string>
- </property>
- </widget>
- </grid>
-</widget>
-</UI>
diff --git a/core/apps/textedit/qtextedit.h b/core/apps/textedit/qtextedit.h
deleted file mode 100644
index b29a728..0000000
--- a/core/apps/textedit/qtextedit.h
+++ b/dev/null
@@ -1,282 +0,0 @@
-/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
-**
-** This file is part of 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.
-**
-**********************************************************************/
-
-#ifndef QTEXTEDIT_H
-#define QTEXTEDIT_H
-
-#include <qscrollview.h>
-#include <qstylesheet.h>
-#include <qpainter.h>
-
-class QPainter;
-class QTextDocument;
-class QTextCursor;
-class QKeyEvent;
-class QResizeEvent;
-class QMouseEvent;
-class QTimer;
-class QTextString;
-class QVBox;
-class QListBox;
-class QTextCommand;
-class QTextParag;
-class QTextFormat;
-class QFont;
-class QColor;
-
-class QTextEdit : public QScrollView
-{
- Q_OBJECT
-
-public:
- QTextEdit( QWidget *parent, const QString &fn, bool tabify = FALSE );
- QTextEdit( QWidget *parent = 0, const char *name = 0 );
- virtual ~QTextEdit();
-
-#if defined(QTEXTEDIT_OPEN_API)
- QTextDocument *document() const;
- QTextCursor *textCursor() const;
-#endif
-
- QString text() const;
- QString text( int parag, bool formatted = FALSE ) const;
- Qt::TextFormat textFormat() const;
- QString fileName() const;
-
- void cursorPosition( int &parag, int &index );
- void selection( int &parag_from, int &index_from,
- int &parag_to, int &index_to );
- virtual bool find( const QString &expr, bool cs, bool wo, bool forward = TRUE,
- int *parag = 0, int *index = 0 );
- void insert( const QString &text, bool indent = FALSE, bool checkNewLine = FALSE );
-
- int paragraphs() const;
- int lines() const;
- int linesOfParagraph( int parag ) const;
- int lineOfChar( int parag, int chr );
-
- bool isModified() const;
-
- bool italic() const;
- bool bold() const;
- bool underline() const;
- QString family() const;
- int pointSize() const;
- QColor color() const;
- QFont font() const;
- int alignment() const;
- int maxLines() const;
-
- const QStyleSheet* styleSheet() const;
- void setStyleSheet( const QStyleSheet* styleSheet );
-
- void setPaper( const QBrush& pap);
- QBrush paper() const;
-
- void setLinkColor( const QColor& );
- QColor linkColor() const;
-
- void setLinkUnderline( bool );
- bool linkUnderline() const;
-
- void setMimeSourceFactory( const QMimeSourceFactory* factory );
- const QMimeSourceFactory* mimeSourceFactory() const;
-
- int heightForWidth( int w ) const;
-
- void append( const QString& text );
-
- bool hasSelectedText() const;
- QString selectedText() const;
-
- QString context() const;
-
- QString documentTitle() const;
-
- void scrollToAnchor( const QString& name );
- QString anchorAt(const QPoint& pos);
-
-public slots:
- virtual void undo();
- virtual void redo();
-
- virtual void cut();
- virtual void copy();
- virtual void paste();
-
- virtual void indent();
-
- virtual void setItalic( bool b );
- virtual void setBold( bool b );
- virtual void setUnderline( bool b );
- virtual void setFamily( const QString &f );
- virtual void setPointSize( int s );
- virtual void setColor( const QColor &c );
- virtual void setFont( const QFont &f );
-
- virtual void setAlignment( int );
-
- virtual void setParagType( QStyleSheetItem::DisplayMode, int listStyle );
-
- virtual void setTextFormat( Qt::TextFormat f );
- virtual void setText( const QString &txt, const QString &context = QString::null ) { setText( txt, context, FALSE ); }
- virtual void setText( const QString &txt, const QString &context, bool tabify );
-
- virtual void load( const QString &fn ) { load( fn, FALSE ); }
- virtual void load( const QString &fn, bool tabify );
- virtual void save( bool untabify = FALSE ) { save( QString::null, untabify ); }
- virtual void save( const QString &fn, bool untabify = FALSE );
-
- virtual void setCursorPosition( int parag, int index );
- virtual void setSelection( int parag_from, int index_from,
- int parag_to, int index_to );
-
- virtual void setModified( bool m );
- virtual void selectAll( bool select );
-
- virtual void setMaxLines( int l );
- virtual void resetFormat();
-
-signals:
- void currentFontChanged( const QFont &f );
- void currentColorChanged( const QColor &c );
- void currentAlignmentChanged( int );
- void textChanged();
- void highlighted( const QString& );
- void linkClicked( const QString& );
-
-protected:
- void setFormat( QTextFormat *f, int flags );
- void drawContents( QPainter *p, int cx, int cy, int cw, int ch );
- void keyPressEvent( QKeyEvent *e );
- void resizeEvent( QResizeEvent *e );
- void contentsMousePressEvent( QMouseEvent *e );
- void contentsMouseMoveEvent( QMouseEvent *e );
- void contentsMouseReleaseEvent( QMouseEvent *e );
- void contentsMouseDoubleClickEvent( QMouseEvent *e );
-#ifndef QT_NO_DRAGANDDROP
- void contentsDragEnterEvent( QDragEnterEvent *e );
- void contentsDragMoveEvent( QDragMoveEvent *e );
- void contentsDragLeaveEvent( QDragLeaveEvent *e );
- void contentsDropEvent( QDropEvent *e );
-#endif
- bool eventFilter( QObject *o, QEvent *e );
- bool focusNextPrevChild( bool next );
-#if !defined(QTEXTEDIT_OPEN_API)
- QTextDocument *document() const;
- QTextCursor *textCursor() const;
-#endif
-
-private slots:
- void formatMore();
- void doResize();
- void doAutoScroll();
- void doChangeInterval();
- void blinkCursor();
- void setModified();
- void startDrag();
-
-private:
- enum MoveDirection {
- MoveLeft,
- MoveRight,
- MoveUp,
- MoveDown,
- MoveHome,
- MoveEnd,
- MovePgUp,
- MovePgDown
- };
- enum KeyboardAction {
- ActionBackspace,
- ActionDelete,
- ActionReturn
- };
-
- struct UndoRedoInfo {
- enum Type { Invalid, Insert, Delete, Backspace, Return, RemoveSelected };
- UndoRedoInfo( QTextDocument *d ) : type( Invalid ), doc( d )
- { text = QString::null; id = -1; index = -1; }
- void clear();
- inline bool valid() const { return !text.isEmpty() && id >= 0&& index >= 0; }
-
- QString text;
- int id;
- int index;
- Type type;
- QTextDocument *doc;
- };
-
-private:
- virtual bool isReadOnly() const { return FALSE; }
- virtual bool linksEnabled() const { return TRUE; }
- void init();
- void ensureCursorVisible();
- void drawCursor( bool visible );
- void placeCursor( const QPoint &pos, QTextCursor *c = 0 );
- void moveCursor( int direction, bool shift, bool control );
- void moveCursor( int direction, bool control );
- void removeSelectedText();
- void doKeyboardAction( int action );
- bool doCompletion();
- void checkUndoRedoInfo( UndoRedoInfo::Type t );
- void repaintChanged();
- void updateCurrentFormat();
- void handleReadOnlyKeyEvent( QKeyEvent *e );
- void makeParagVisible( QTextParag *p );
-
-private:
- QTextDocument *doc;
- QTextCursor *cursor;
- bool drawAll;
- bool mousePressed;
- QTimer *formatTimer, *scrollTimer, *changeIntervalTimer, *blinkTimer, *dragStartTimer, *resizeTimer;
- QTextParag *lastFormatted;
- int interval;
- QVBox *completionPopup;
- QListBox *completionListBox;
- int completionOffset;
- UndoRedoInfo undoRedoInfo;
- QTextFormat *currentFormat;
- QPainter painter;
- int currentAlignment;
- bool inDoubleClick;
- QPoint oldMousePos, mousePos;
- QPixmap *buf_pixmap;
- bool cursorVisible, blinkCursorVisible;
- bool readOnly, modified, mightStartDrag;
- QPoint dragStartPos;
- int mLines;
- bool firstResize;
- QString onLink;
-
-};
-
-inline QTextDocument *QTextEdit::document() const
-{
- return doc;
-}
-
-inline QTextCursor *QTextEdit::textCursor() const
-{
- return cursor;
-}
-
-#endif
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 867625e..14bc496 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -19,5 +19,11 @@
**********************************************************************/
+// changes added by L. J. Potter Sun 02-17-2002 21:31:31
#include "textedit.h"
+#include "fileBrowser.h"
+#include "fileSaver.h"
+#include "fontDialog.h"
+
+#include <qpe/fontdatabase.h>
#include <qpe/global.h>
@@ -32,2 +38,3 @@
+#include <qstringlist.h>
#include <qaction.h>
@@ -44,2 +51,99 @@
#include <stdlib.h> //getenv
+/* XPM */
+static char * filesave_xpm[] = {
+"16 16 78 1",
+" c None",
+". c #343434",
+"+ c #A0A0A0",
+"@ c #565656",
+"# c #9E9E9E",
+"$ c #525252",
+"% c #929292",
+"& c #676767",
+"* c #848484",
+"= c #666666",
+"- c #D8D8D8",
+"; c #FFFFFF",
+"> c #DBDBDB",
+", c #636363",
+"' c #989898",
+") c #2D2D2D",
+"! c #909090",
+"~ c #AEAEAE",
+"{ c #EAEAEA",
+"] c #575757",
+"^ c #585858",
+"/ c #8A8A8A",
+"( c #828282",
+"_ c #6F6F6F",
+": c #C9C9C9",
+"< c #050505",
+"[ c #292929",
+"} c #777777",
+"| c #616161",
+"1 c #3A3A3A",
+"2 c #BEBEBE",
+"3 c #2C2C2C",
+"4 c #7C7C7C",
+"5 c #F6F6F6",
+"6 c #FCFCFC",
+"7 c #6B6B6B",
+"8 c #959595",
+"9 c #4F4F4F",
+"0 c #808080",
+"a c #767676",
+"b c #818181",
+"c c #B8B8B8",
+"d c #FBFBFB",
+"e c #F9F9F9",
+"f c #CCCCCC",
+"g c #030303",
+"h c #737373",
+"i c #7A7A7A",
+"j c #7E7E7E",
+"k c #6A6A6A",
+"l c #FAFAFA",
+"m c #505050",
+"n c #9D9D9D",
+"o c #333333",
+"p c #7B7B7B",
+"q c #787878",
+"r c #696969",
+"s c #494949",
+"t c #555555",
+"u c #949494",
+"v c #E6E6E6",
+"w c #424242",
+"x c #515151",
+"y c #535353",
+"z c #3E3E3E",
+"A c #D4D4D4",
+"B c #0C0C0C",
+"C c #353535",
+"D c #474747",
+"E c #ECECEC",
+"F c #919191",
+"G c #7D7D7D",
+"H c #000000",
+"I c #404040",
+"J c #858585",
+"K c #323232",
+"L c #D0D0D0",
+"M c #1C1C1C",
+" ...+ ",
+" @#$%&..+ ",
+" .*=-;;>,..+ ",
+" ')!~;;;;;;{]..",
+" ^/(-;;;;;;;_:<",
+" [}|;;;;;;;{12$",
+" #34-55;;;;678$+",
+" 90ab=c;dd;e1fg ",
+" [ahij((kbl0mn$ ",
+" op^q^^7r&]s/$+ ",
+"@btu;vbwxy]zAB ",
+"CzDEvEv;;DssF$ ",
+"G.H{E{E{IxsJ$+ ",
+" +...vEKxzLM ",
+" +...z]n$ ",
+" +... "};
@@ -53,3 +157,7 @@ public:
QpeEditor( QWidget *parent, const char * name = 0 )
- : QMultiLineEdit( parent, name ) {}
+ : QMultiLineEdit( parent, name )
+ {
+ clearTableFlags();
+ setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
+ }
@@ -131,4 +239,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
- QString lang = getenv( "LANG" );
-
setToolBarsMovable( FALSE );
@@ -156,2 +262,7 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
+// a->addTo( bar );
+ a->addTo( file );
+
+ a = new QAction( tr( "Browse" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( newFileOpen() ) );
a->addTo( bar );
@@ -159,2 +270,9 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
+//
+ a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
+// a->addTo( bar );
+ file->insertSeparator();
+ a->addTo( file );
+
a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
@@ -182,3 +300,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
bool defb, defi, wrap;
- {
+
Config cfg("TextEdit");
@@ -189,3 +307,2 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
wrap = cfg.readBoolEntry("Wrap",TRUE);
- }
@@ -223,2 +340,5 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
+ font->insertSeparator();
+ font->insertItem("Font", this, SLOT(changeFont()) );
+
mb->insertItem( tr( "File" ), file );
@@ -237,2 +357,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
+
a = new QAction( tr( "Find Next" ), Resource::loadPixmap( "next" ), QString::null, 0, this, 0 );
@@ -253,5 +374,3 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
- fileSelector = new FileSelector( "text/*", editorStack, "fileselector" ,
- TRUE, FALSE );
- fileSelector->setCategoriesVisible(TRUE);
+ fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //buggy
connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
@@ -259,5 +378,6 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
- fileOpen();
+// fileOpen();
editor = new QpeEditor( editorStack );
+ editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
editorStack->addWidget( editor, get_unique_id() );
@@ -266,4 +386,28 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
- setFontSize(defsize,TRUE);
+// setFontSize(defsize,TRUE);
+ FontDatabase fdb;
+ QFont defaultFont=editor->font();
+ QFontInfo fontInfo(defaultFont);
+
+ cfg.setGroup("Font");
+ QString family = cfg.readEntry("Family", fontInfo.family());
+ QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
+ int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
+ QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
+
+ defaultFont = fdb.font(family,style,i_size,charSet);
+ editor->setFont( defaultFont);
+
wa->setOn(wrap);
+ updateCaption();
+ if( qApp->argc() > 1 ) {
+ for (int i=1;i< qApp->argc();i++) {
+ QString tmp;
+ currentFileName = tmp.sprintf("%s",qApp->argv()[i]);
+ qDebug(currentFileName);
+ setDocument( currentFileName );
+ }
+ }
+ else
+ fileNew();
}
@@ -336,3 +480,5 @@ void TextEdit::setWordWrap(bool y)
{
+ bool state = editor->edited();
editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
+ editor->setEdited( state );
}
@@ -347,17 +493,17 @@ void TextEdit::fileOpen()
{
- if ( !save() ) {
- if ( QMessageBox::critical( this, tr( "Out of space" ),
- tr( "Text Editor was unable to\n"
- "save your changes.\n"
- "Free some space and try again.\n"
- "\nContinue anyway?" ),
- QMessageBox::Yes|QMessageBox::Escape,
- QMessageBox::No|QMessageBox::Default )
- != QMessageBox::Yes )
- return;
- else {
- delete doc;
- doc = 0;
- }
- }
+// if ( !save() ) {
+// if ( QMessageBox::critical( this, tr( "Out of space" ),
+// tr( "Text Editor was unable to\n"
+// "save your changes.\n"
+// "Free some space and try again.\n"
+// "\nContinue anyway?" ),
+// QMessageBox::Yes|QMessageBox::Escape,
+// QMessageBox::No|QMessageBox::Default )
+// != QMessageBox::Yes )
+// return;
+// else {
+// delete doc;
+// doc = 0;
+// }
+// }
menu->hide();
@@ -371,2 +517,25 @@ void TextEdit::fileOpen()
+void TextEdit::newFileOpen()
+{
+ fileBrowser *browseForFiles;
+ browseForFiles=new fileBrowser(this,"fileBrowser",TRUE,0, "*");
+ browseForFiles->exec();
+ QString selFile= browseForFiles->selectedFileName;
+ QStringList fileList=browseForFiles->fileList;
+ qDebug(selFile);
+ QStringList::ConstIterator f;
+ QString fileTemp;
+ for ( f = fileList.begin(); f != fileList.end(); f++ ) {
+ fileTemp = *f;
+ fileTemp.right( fileTemp.length()-5);
+ QString fileName = fileTemp;
+ if( fileName != "Unnamed" || fileName != "Empty Text" ) {
+ currentFileName = fileName;
+ qDebug("please open "+currentFileName);
+ openFile(fileName );
+ }
+ }
+ delete browseForFiles;
+
+}
@@ -381,3 +550,2 @@ void TextEdit::slotFind()
-
connect( editor, SIGNAL(notFound()),
@@ -474,3 +642,3 @@ void TextEdit::openFile( const DocLnk &f )
{
- clear();
+// clear();
FileManager fm;
@@ -479,5 +647,7 @@ void TextEdit::openFile( const DocLnk &f )
// ####### could be a new file
- //qDebug( "Cannot open file" );
+ qDebug( "Cannot open file" );
+
//return;
}
+
fileNew();
@@ -493,4 +663,5 @@ void TextEdit::showEditTools()
{
- if ( !doc )
- close();
+// if ( !doc )
+// close();
+// clear();
fileSelector->hide();
@@ -501,2 +672,4 @@ void TextEdit::showEditTools()
updateCaption();
+ editorStack->raiseWidget( editor );
+ setWState (WState_Reserved1 );
}
@@ -506,3 +679,3 @@ bool TextEdit::save()
// case of nothing to save...
- if ( !doc )
+ if ( !doc || !bFromDocView)
return true;
@@ -516,2 +689,4 @@ bool TextEdit::save()
+ if(currentFileName.isEmpty() || currentFileName == "Unnamed") {
+
if ( doc->name().isEmpty() ) {
@@ -532,7 +707,3 @@ bool TextEdit::save()
doc->setName(docname);
-
- // append .txt to the file name
- if ( doc->file().find(".txt") == -1 ) {
- QString file = doc->file() + ".txt";
- doc->setFile( file );
+ currentFileName=docname;
}
@@ -540,2 +711,10 @@ bool TextEdit::save()
+ fileSaver *fileSaveDlg;
+ fileSaveDlg=new fileSaver(this,"SaveFile",TRUE,0, currentFileName);
+ fileSaveDlg->exec();
+ QString fileNm=fileSaveDlg->selectedFileName;
+ qDebug("save filename "+fileNm);
+ doc->setName(fileNm);
+ updateCaption();
+ delete fileSaveDlg;
@@ -566,4 +745,6 @@ void TextEdit::updateCaption( const QString &name )
s = doc->name();
- if ( s.isEmpty() )
+ if ( s.isEmpty() ) {
s = tr( "Unnamed" );
+ currentFileName=s;
+ }
setCaption( s + " - " + tr("Text Editor") );
@@ -576,3 +757,3 @@ void TextEdit::setDocument(const QString& fileref)
openFile(DocLnk(fileref));
- showEditTools();
+// showEditTools();
}
@@ -581,5 +762,7 @@ void TextEdit::closeEvent( QCloseEvent *e )
{
- if ( editorStack->visibleWidget() == editor && !bFromDocView ) {
+ if ( editorStack->visibleWidget() == fileSelector && !bFromDocView ) {
e->ignore();
- fileRevert();
+ repaint();
+// fileRevert();
+
} else {
@@ -592,3 +775,29 @@ void TextEdit::accept()
{
- fileOpen();
+ close();
+// fileOpen(); //godamn thats obnoxious! lemme out!!!
+}
+
+void TextEdit::changeFont() {
+ FontDatabase fdb;
+ QFont defaultFont=editor->font();
+ QFontInfo fontInfo(defaultFont);
+ Config cfg("TextEdit");
+ cfg.setGroup("Font");
+ QString family = cfg.readEntry("Family", fontInfo.family());
+ QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
+ int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
+ QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
+
+ defaultFont = fdb.font(family,style,i_size,charSet);
+
+ FontDialog *fontDlg;
+ fontDlg=new FontDialog(this,"FontDialog",TRUE);
+
+ fontDlg->exec();
+
+ QFont myFont=fontDlg->selectedFont;
+ editor->setFont( myFont);
+ delete fontDlg;
+
}
+
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index f7d1052..4e469cc 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -19,2 +19,3 @@
**********************************************************************/
+// additions made by L.J. Potter Sun 02-17-2002 22:27:46
@@ -56,3 +57,3 @@ private slots:
void setDocument(const QString&);
-
+ void changeFont();
void fileNew();
@@ -60,2 +61,4 @@ private slots:
void fileOpen();
+ void newFileOpen();
+ bool save();
@@ -84,3 +87,2 @@ private:
void colorChanged( const QColor &c );
- bool save();
void clear();
@@ -99,2 +101,3 @@ private:
QAction *zin, *zout;
+ QString currentFileName;
};
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index 23b8d8d..9b1a841 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -5,5 +5,5 @@ DESTDIR = $(OPIEDIR)/bin
-HEADERS = textedit.h
+HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h
-SOURCES = main.cpp textedit.cpp
+SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp