summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/fileSaver.cpp3
-rw-r--r--core/apps/textedit/textedit.cpp16
2 files changed, 13 insertions, 6 deletions
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp
index b1ddc0b..209a258 100644
--- a/core/apps/textedit/fileSaver.cpp
+++ b/core/apps/textedit/fileSaver.cpp
@@ -135,133 +135,134 @@ void fileSaver::populateList()
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();
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" );
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( 2, FALSE);
dirLabel->setText(currentDir.canonicalPath());
}
void fileSaver::upDir()
{
// qDebug(currentDir.canonicalPath());
}
void fileSaver::listDoubleClicked(QListViewItem *selectedItem)
{
}
void fileSaver::listClicked(QListViewItem *selectedItem)
{
+ if(selectedItem != NULL) {
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::closeEvent( QCloseEvent *e )
{
if(e->isAccepted()) {
e->accept();
} else {
qDebug("not accepted");
done(-1);
}
}
void fileSaver::accept() {
selectedFileName = fileEdit->text();
QString path = currentDir.canonicalPath()+"/" + selectedFileName;
if( path.find("//",0,TRUE) ==-1 ) {
selectedFileName = path;
} else {
selectedFileName = currentDir.canonicalPath()+selectedFileName;
}
qDebug("going to save "+selectedFileName);
done(1);
}
void fileSaver::homeButtonPushed() {
chdir( QDir::homeDirPath().latin1() );
currentDir.cd( QDir::homeDirPath(), TRUE);
populateList();
update();
}
void fileSaver::docButtonPushed() {
chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
populateList();
update();
}
void fileSaver::hideButtonPushed(bool b) {
if (b)
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
else
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
// chdir( QString(QPEApplication::documentDir()+"/text").latin1() );
// currentDir.cd( QPEApplication::documentDir()+"/text", TRUE);
populateList();
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index f89ed6d..f99f259 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -465,97 +465,97 @@ void TextEdit::setFontSize(int sz, bool round_down_not_up)
}
}
QFont f = editor->font();
f.setPointSize(s);
editor->setFont(f);
zin->setEnabled(s != fontsize[nfontsizes-1]);
zout->setEnabled(s != fontsize[0]);
}
void TextEdit::setBold(bool y)
{
QFont f = editor->font();
f.setBold(y);
editor->setFont(f);
}
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()
{
Config cfg("TextEdit");
cfg.setGroup("View");
bool b=FALSE;
// if(cfg.readEntry("useOldFileDialog") == "TRUE")
// b=TRUE;
// if(!b) {
- QString str = OFileDialog::getOpenFileName( 1,"/");//,"", "*", this );
+ QString str = OFileDialog::getOpenFileName( 2,"/");//,"", "*", this );
if(!str.isEmpty() )
openFile( str );
// } else {
// QString str;
// browseForFiles = new fileBrowser(this,tr("Open File"),TRUE,0, "*"); //
// 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(currentFileName );
// }
// }
// 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()
@@ -703,175 +703,181 @@ void TextEdit::openFile( const DocLnk &f )
qDebug( "Cannot open file" );
}
// fileNew();
if ( doc )
delete doc;
doc = new DocLnk(f);
editor->setText(txt);
editor->setEdited( FALSE);
edited1=FALSE;
edited=FALSE;
doc->setName(currentFileName);
updateCaption();
}
void TextEdit::showEditTools()
{
// if ( !doc )
// close();
// clear();
menu->show();
editBar->show();
if ( searchVisible )
searchBar->show();
// updateCaption();
setWState (WState_Reserved1 );
}
/*!
unprompted save */
bool TextEdit::save()
{
QString file = doc->file();
qDebug("saver file "+file);
QString name= doc->name();
qDebug("File named "+name);
QString rt = editor->text();
if( !rt.isEmpty() ) {
if(name.isEmpty()) {
saveAs();
} else {
currentFileName= name ;
qDebug("saveFile "+currentFileName);
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 ) ) {
return false;
}
} else {
qDebug("regular save file");
QFile f(file);
if( f.open(IO_WriteOnly)) {
f.writeBlock(rt,rt.length());
} else {
QMessageBox::message("Text Edit","Write Failed");
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()
{
// qDebug("saveAsFile "+currentFileName);
// case of nothing to save...
if ( !doc )//|| !bFromDocView)
{
qDebug("no doc");
return true;
}
if ( !editor->edited() ) {
delete doc;
doc = 0;
return true;
}
QString rt = editor->text();
qDebug(currentFileName);
if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
qDebug("do silly TT filename thing");
if ( 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");
doc->setName(docname);
currentFileName=docname;
}
}
- fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName);
- qDebug("wanna save filename "+currentFileName);
- fileSaveDlg->exec();
- if( fileSaveDlg->result() == 1 ) {
+// QString str = OFileDialog::getSaveFileName( 2,"/");//,"", "*", this );
+// if(!str.isEmpty() ) {
+// openFile( str );
+
+ fileSaveDlg=new fileSaver(this,tr("Save File As?"),TRUE, 0, currentFileName);
+ qDebug("wanna save filename "+currentFileName);
+ fileSaveDlg->exec();
+ if( fileSaveDlg->result() == 1 ) {
QString fileNm=fileSaveDlg->selectedFileName;
+// QString fileNm=srt;
qDebug("saving filename "+fileNm);
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("openFile doclnk "+currentFileName);
doc->setName( currentFileName);
updateCaption( currentFileName);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
return false;
}
if( fileSaveDlg->filePermCheck->isChecked() ) {
filePermissions *filePerm;
filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
filePerm->exec();
if( filePerm)
delete filePerm;
}
}
}
editor->setEdited(TRUE);
edited1=FALSE;
edited=TRUE;
if(caption().left(1)=="*")
setCaption(caption().right(caption().length()-1));
if(fileSaveDlg)
delete fileSaveDlg;
return true;
} //end saveAs
void TextEdit::clear()
{
delete doc;
doc = 0;
editor->clear();
}