summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-04-19 12:09:05 (UTC)
committer llornkcor <llornkcor>2002-04-19 12:09:05 (UTC)
commit9233f285e5f3366ca5e1d44892e0797d7ef0608c (patch) (side-by-side diff)
treef4599e33492b04d7d8a9250d662e8bb814313bdf /core
parent6ffbfe7daee3b01b8dce2afa9036b70b187a8fc7 (diff)
downloadopie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.zip
opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.gz
opie-9233f285e5f3366ca5e1d44892e0797d7ef0608c.tar.bz2
fixed a slight bugy
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/fileBrowser.cpp45
-rw-r--r--core/apps/textedit/textedit.cpp71
-rw-r--r--core/apps/textedit/textedit.h2
3 files changed, 68 insertions, 50 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp
index f322513..fced326 100644
--- a/core/apps/textedit/fileBrowser.cpp
+++ b/core/apps/textedit/fileBrowser.cpp
@@ -1,94 +1,100 @@
/****************************************************************************
** 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.
**
****************************************************************************/
-//#define QTOPIA_INTERNAL_MIMEEXT
+#define QTOPIA_INTERNAL_MIMEEXT
#include "fileBrowser.h"
//#include "inputDialog.h"
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/qpeapplication.h>
#include <qpe/menubutton.h>
#include <qpe/mimetype.h>
#include <qdict.h>
#include <qwidgetstack.h>
#include <qlistview.h>
#include <qcombo.h>
#include <qpushbutton.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qlayout.h>
#include <unistd.h>
#include <qpopupmenu.h>
#include <qlineedit.h>
#include <qstringlist.h>
#include <unistd.h>
#include <stdlib.h>
static int u_id = 1;
static int get_unique_id()
{
return u_id++;
}
fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags fl , const QString mimeFilter )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "fileBrowser" );
setCaption(tr( name ) );
-// mimeType = mimeFilter;
-// MimeType mt( mimeType);
-// if( mt.extension().isEmpty())
-// QStringList filterList;
-// filterList=QStringList::split(";",mimeFilter,FALSE);
-// for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
-// printf( "%s \n", (*it).latin1() );
-// }
+
+// getMimeTypes();
+
+ mimeType = mimeFilter;
+ MimeType mt( mimeType);
+
+ if( mt.extension().isEmpty()) {
+
+ QStringList filterList;
+ filterList=QStringList::split(";",mimeFilter,FALSE);
+
+ for ( QStringList::Iterator it = filterList.begin(); it != filterList.end(); ++it ) {
+ printf( "%s \n", (*it).latin1() );
+ }
filterStr = mimeFilter.right(mimeFilter.length() - mimeFilter.find("/",0,TRUE) - 1);// "*";
qDebug(filterStr);
-// else
-// filterStr = "*."+ mt.extension();
+ } else {
+ filterStr = "*."+ mt.extension();
// qDebug("description "+mt.description());
// qDebug( "id "+mt.id());
// qDebug("extension "+mt.extension());
-
+ }
// channel = new QCopChannel( "QPE/fileDialog", this );
// connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
// this, SLOT(receive(const QCString&, const QByteArray&)) );
QGridLayout *layout = new QGridLayout( this );
layout->setSpacing( 4 );
layout->setMargin( 4 );
dirPathCombo = new QComboBox( FALSE, this, "dirPathCombo" );
dirPathCombo->setEditable(TRUE);
connect( dirPathCombo, SIGNAL( activated( const QString & ) ),
this, SLOT( dirPathComboActivated( const QString & ) ) );
connect( dirPathCombo->lineEdit(), SIGNAL( returnPressed( ) ),
this, SLOT( dirPathEditPressed( ) ) );
dirPathStringList << "/";
// we can get the storage here
layout->addMultiCellWidget( dirPathCombo, 0, 0, 0, 4 );
cdUpButton = new QPushButton(Resource::loadIconSet("up"),"",this,"cdUpButton");
cdUpButton ->setMinimumSize( QSize( 20, 20 ) );
@@ -213,49 +219,49 @@ void fileBrowser::populateList()
if(fileL !="./" && fi->exists()) {
item= new QListViewItem( ListView,fileL,fileS , fileDate);
QPixmap pm;
if(isDir || fileL.find("/",0,TRUE) != -1) {
if( !QDir( fi->filePath() ).isReadable())
pm = Resource::loadPixmap( "lockedfolder" );
else
pm= Resource::loadPixmap( "folder" );
item->setPixmap( 0,pm );
} else {
if( !fi->isReadable() )
pm = Resource::loadPixmap( "locked" );
else {
MimeType mt(fi->filePath());
pm=mt.pixmap();// sets the pixmap for the mimetype
if(pm.isNull())
pm = Resource::loadPixmap( "UnknownDocument-14" );
item->setPixmap( 0,pm);
}
}
if( fileL.find("->",0,TRUE) != -1) {
// overlay link image
pm= Resource::loadPixmap( "folder" );
- QPixmap lnk = Resource::loadPixmap( "symlink" );
+ QPixmap lnk = Resource::loadPixmap( "opie/symlink" );
QPainter painter( &pm );
painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk );
pm.setMask( pm.createHeuristicMask( FALSE ) );
item->setPixmap( 0, pm);
}
}
isDir=FALSE;
++it;
// }
}
ListView->setSorting( 3, FALSE);
QString currentPath = currentDir.canonicalPath();
fillCombo( (const QString &)currentPath);
// dirPathCombo->lineEdit()->setText(currentPath);
// if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) {
// dirPathCombo->clear();
// dirPathStringList.prepend(currentPath );
// dirPathCombo->insertStringList( dirPathStringList,-1);
// }
}
void fileBrowser::upDir()
@@ -471,106 +477,109 @@ void fileBrowser::localDelete() {
}
void fileBrowser::updateMimeTypeMenu() {
disconnect( typemb, SIGNAL(selected(const QString&)),
this, SLOT(showType(const QString&)) );
QString prev;
// Type filter
QStringList types;
types << tr("All");
types << "--";
types += getMimeTypes();
prev = typemb->currentText();
typemb->clear();
typemb->insertItems(types);
// typemb->select(prev);
connect(typemb, SIGNAL(selected(const QString&)), this, SLOT(showType(const QString&)));
}
void fileBrowser::showType(const QString &t) {
- qDebug(t);
+// qDebug("Show type "+t);
if(t.find("All",0,TRUE) != -1) {
filterStr = "*";
} else {
QStringList list = mimetypes.grep( t,TRUE);
QString ext;
for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
mimeType =(*it);
MimeType mt( mimeType);
+
// qDebug("mime "+mimeType);
// qDebug("description "+mt.description());
// qDebug( "id "+mt.id());
// qDebug("extension "+mt.extension());
-// if( mt.extension().isEmpty())
+
+ if( mt.extension().isEmpty())
filterStr = "*";
-// else
-// filterStr = "*."+ mt.extension()+" ";
+ else
+ filterStr = "*."+ mt.extension()+" ";
// printf( "%s \n", (*it).latin1() );
}
}
currentDir.setNameFilter(filterStr);
populateList();
update();
// if(fileSelector) {
// disconnect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
// delete fileSelector;
// }
// fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy
// connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) );
// connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) );
// connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) );
// fileSelector->reread();
// if ( t == tr("All") ) {
// icons->setTypeFilter("",TRUE);
// } else {
// icons->setTypeFilter(t+"/*",TRUE);
// }
}
QStringList fileBrowser::getMimeTypes() {
QStringList r;
AppLnkSet apps( QPEApplication::qpeDir() + "apps" );
QFile file( QPEApplication::qpeDir()+"etc/available.mime");
file.open( IO_WriteOnly|IO_Truncate);//)
for ( QListIterator<AppLnk> it( apps.children() ); it.current(); ++it ) {
AppLnk* l;
l = it.current();
QStringList maj = l->mimeTypes();
QStringList::ConstIterator f;
for ( f = maj.begin(); f != maj.end(); f++ ) {
QString temp = *f;
+ qDebug("type "+temp);
mimetypes << temp;
int sl = temp.find('/');
if (sl >= 0) {
- QString k = temp.left(sl);
+ QString k = temp;//.left(sl);
if( r.grep(k,TRUE).isEmpty() ) {
r << k;
k+="\n";
file.writeBlock( k.latin1(), k.length());
}
}
}
}
r.sort();
file.close();
return r;
}
void fileBrowser::receive( const QCString &msg, const QByteArray &data ) {
// QDataStream stream( data, IO_ReadOnly );
// if (msg == "keyRegister(int key, QString channel, QString message)")
// {
// int k;
// QString c, m;
// stream >> k;
// stream >> c;
// stream >> m;
}
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 18402d4..84888c1 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -480,81 +480,90 @@ void TextEdit::setBold(bool y)
void TextEdit::setItalic(bool y)
{
QFont f = editor->font();
f.setItalic(y);
editor->setFont(f);
}
void TextEdit::setWordWrap(bool y)
{
bool state = editor->edited();
editor->setWordWrap(y ? QMultiLineEdit::WidgetWidth : QMultiLineEdit::NoWrap );
editor->setEdited( state );
}
void TextEdit::fileNew()
{
// if( !bFromDocView ) {
// saveAs();
// }
newFile(DocLnk());
}
void TextEdit::fileOpen()
{
- QString str = OFileDialog::getOpenFileName(1,"/","", QStringList() , this );
+ Config cfg("TextEdit");
+ cfg.setGroup("View");
+ bool b=FALSE;
+ if(cfg.readEntry("useOldFileDialog") == "TRUE")
+ b=TRUE;
+ if(!b) {
+ QString str = OFileDialog::getOpenFileName( 1,"/","", "text/plain", this );
if(!str.isEmpty() )
openFile( str );
-// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
-// browseForFiles->setFileView( viewSelection );
-// browseForFiles->showMaximized();
-// // if( result != -1 )
-
-// if( browseForFiles->exec() != -1 ) {
-// 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(str );
-// }
-// }
-// viewSelection = browseForFiles->SelectionCombo->currentItem();
-// }
-// delete browseForFiles;
-// editor->setEdited( FALSE);
-// edited1=FALSE;
-// edited=FALSE;
-// if(caption().left(1)=="*")
-// setCaption(caption().right(caption().length()-1));
-// doSearchBar();
+ } else {
+ QString str;
+ browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "text/*"); //
+ browseForFiles->setFileView( viewSelection );
+ browseForFiles->showMaximized();
+// if( result != -1 )
+
+ if( browseForFiles->exec() != -1 ) {
+ 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(str );
+ }
+ }
+ viewSelection = browseForFiles->SelectionCombo->currentItem();
+ }
+ delete browseForFiles;
+ editor->setEdited( FALSE);
+ edited1=FALSE;
+ edited=FALSE;
+ if(caption().left(1)=="*")
+ setCaption(caption().right(caption().length()-1));
+ doSearchBar();
+ }
}
void TextEdit::doSearchBar()
{
Config cfg("TextEdit");
cfg.setGroup("View");
if(cfg.readEntry("SearchBar","Closed") != "Opened")
searchBar->hide();
}
#if 0
void TextEdit::slotFind()
{
FindDialog frmFind( tr("Text Editor"), this );
connect( &frmFind, SIGNAL(signalFindClicked(const QString &, bool, bool, int)),
editor, SLOT(slotDoFind( const QString&,bool,bool)));
//case sensitive, backwards, [category]
connect( editor, SIGNAL(notFound()),
&frmFind, SLOT(slotNotFound()) );
connect( editor, SIGNAL(searchWrapped()),
&frmFind, SLOT(slotWrapAround()) );
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index 61fa2a0..edc6fe3 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -36,49 +36,49 @@
#include <qmultilineedit.h>
#include <qlist.h>
#include <qmap.h>
class QAction;
class QWidgetStack;
class QToolButton;
class QPopupMenu;
class QToolBar;
class QLineEdit;
class QAction;
class FileSelector;
class QpeEditor;
class QPopupMenu;
class TextEdit : public QMainWindow
{
Q_OBJECT
public:
TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~TextEdit();
QPopupMenu *font;
- QAction *nStart;
+ QAction *nStart, *nFileDlgOpt;
bool edited, edited1;
void openFile( const QString & );
QCopChannel * channel;
public slots:
void editorChanged();
void receive(const QCString&, const QByteArray&);
protected:
void closeEvent( QCloseEvent *e );
void doSearchBar();
private slots:
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void changeStartConfig(bool);
bool save();
bool saveAs();
void cleanUp();
void editCut();
void editCopy();
void editPaste();