summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index f38ea53..e3b8361 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -765,13 +765,13 @@ bool TextEdit::save() {
765 return false; 765 return false;
766} 766}
767 767
768/*! 768/*!
769 prompted save */ 769 prompted save */
770bool TextEdit::saveAs() { 770bool TextEdit::saveAs() {
771 qDebug("saveAsFile "+currentFileName); 771 qDebug("saveAsFile " + currentFileName);
772 // case of nothing to save... 772 // case of nothing to save...
773 if ( !doc ) { 773 if ( !doc ) {
774//|| !bFromDocView) 774//|| !bFromDocView)
775 qDebug("no doc"); 775 qDebug("no doc");
776 return true; 776 return true;
777 } 777 }
@@ -781,25 +781,28 @@ bool TextEdit::saveAs() {
781 return true; 781 return true;
782 } 782 }
783 783
784 QString rt = editor->text(); 784 QString rt = editor->text();
785 qDebug(currentFileName); 785 qDebug(currentFileName);
786 786
787 if( currentFileName.isEmpty() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) { 787 if( currentFileName.isEmpty()
788 || currentFileName == tr("Unnamed")
789 || currentFileName == tr("Text Editor")) {
788// qDebug("do silly TT filename thing"); 790// qDebug("do silly TT filename thing");
789 if ( doc->name().isEmpty() ) { 791 if ( doc->name().isEmpty() ) {
790 QString pt = rt.simplifyWhiteSpace(); 792 QString pt = rt.simplifyWhiteSpace();
791 int i = pt.find( ' ' ); 793 int i = pt.find( ' ' );
792 QString docname = pt; 794 QString docname = pt;
793 if ( i > 0 ) 795 if ( i > 0 )
794 docname = pt.left( i ); 796 docname = pt.left( i );
795 // remove "." at the beginning 797 // remove "." at the beginning
796 while( docname.startsWith( "." ) ) 798 while( docname.startsWith( "." ) )
797 docname = docname.mid( 1 ); 799 docname = docname.mid( 1 );
798 docname.replace( QRegExp("/"), "_" ); 800 docname.replace( QRegExp("/"), "_" );
799 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 801 // cut the length. filenames longer than that
802 //don't make sense and something goes wrong when they get too long.
800 if ( docname.length() > 40 ) 803 if ( docname.length() > 40 )
801 docname = docname.left(40); 804 docname = docname.left(40);
802 if ( docname.isEmpty() ) 805 if ( docname.isEmpty() )
803 docname = tr("Unnamed"); 806 docname = tr("Unnamed");
804 doc->setName(docname); 807 doc->setName(docname);
805 currentFileName=docname; 808 currentFileName=docname;
@@ -810,14 +813,16 @@ bool TextEdit::saveAs() {
810 map.insert(tr("All"), QStringList() ); 813 map.insert(tr("All"), QStringList() );
811 QStringList text; 814 QStringList text;
812 text << "text/*"; 815 text << "text/*";
813 map.insert(tr("Text"), text ); 816 map.insert(tr("Text"), text );
814 text << "*"; 817 text << "*";
815 map.insert(tr("All"), text ); 818 map.insert(tr("All"), text );
816 819// if(currentFileName
817 QString str = OFileDialog::getSaveFileName( 2,QPEApplication::documentDir(), QString::null, map); 820 QString str = OFileDialog::getSaveFileName( 2,
821 QPEApplication::documentDir(),
822 currentFileName, map);
818 823
819 if(!str.isEmpty() ) { 824 if(!str.isEmpty() ) {
820 QString fileNm=str; 825 QString fileNm=str;
821 826
822 qDebug("saving filename "+fileNm); 827 qDebug("saving filename "+fileNm);
823 QFileInfo fi(fileNm); 828 QFileInfo fi(fileNm);
@@ -839,13 +844,15 @@ bool TextEdit::saveAs() {
839 if ( !fm.saveFile( *doc, rt ) ) { 844 if ( !fm.saveFile( *doc, rt ) ) {
840 return false; 845 return false;
841 } 846 }
842 847
843 if( filePerms ) { 848 if( filePerms ) {
844 filePermissions *filePerm; 849 filePermissions *filePerm;
845 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 850 filePerm = new filePermissions(this,
851 tr("Permissions"),true,
852 0,(const QString &)fileNm);
846 filePerm->showMaximized(); 853 filePerm->showMaximized();
847 filePerm->exec(); 854 filePerm->exec();
848 855
849 if( filePerm) 856 if( filePerm)
850 delete filePerm; 857 delete filePerm;
851 } 858 }