summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-09-15 14:28:25 (UTC)
committer llornkcor <llornkcor>2002-09-15 14:28:25 (UTC)
commita013fbe2ba39e5ebd249766f223dbb67fe18027c (patch) (unidiff)
tree4c6b4c513f128e029a45d12ab12c59596f6657e7
parent74d0e81facb652eecd9c0684d7fa69a51471f4bc (diff)
downloadopie-a013fbe2ba39e5ebd249766f223dbb67fe18027c.zip
opie-a013fbe2ba39e5ebd249766f223dbb67fe18027c.tar.gz
opie-a013fbe2ba39e5ebd249766f223dbb67fe18027c.tar.bz2
fix filepermissions size
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index bd0014a..f6a869a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -750,192 +750,193 @@ bool TextEdit::save() {
750 return false; 750 return false;
751 } 751 }
752 752
753 } 753 }
754 editor->setEdited( FALSE); 754 editor->setEdited( FALSE);
755 edited1=FALSE; 755 edited1=FALSE;
756 edited=FALSE; 756 edited=FALSE;
757 if(caption().left(1)=="*") 757 if(caption().left(1)=="*")
758 setCaption(caption().right(caption().length()-1)); 758 setCaption(caption().right(caption().length()-1));
759 759
760 760
761 chmod( file.latin1(), mode); 761 chmod( file.latin1(), mode);
762 } 762 }
763 return true; 763 return true;
764 } 764 }
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 }
778 if ( !editor->edited() ) { 778 if ( !editor->edited() ) {
779 delete doc; 779 delete doc;
780 doc = 0; 780 doc = 0;
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() || currentFileName == tr("Unnamed") || currentFileName == tr("Text Editor")) {
788// qDebug("do silly TT filename thing"); 788// qDebug("do silly TT filename thing");
789 if ( doc->name().isEmpty() ) { 789 if ( doc->name().isEmpty() ) {
790 QString pt = rt.simplifyWhiteSpace(); 790 QString pt = rt.simplifyWhiteSpace();
791 int i = pt.find( ' ' ); 791 int i = pt.find( ' ' );
792 QString docname = pt; 792 QString docname = pt;
793 if ( i > 0 ) 793 if ( i > 0 )
794 docname = pt.left( i ); 794 docname = pt.left( i );
795 // remove "." at the beginning 795 // remove "." at the beginning
796 while( docname.startsWith( "." ) ) 796 while( docname.startsWith( "." ) )
797 docname = docname.mid( 1 ); 797 docname = docname.mid( 1 );
798 docname.replace( QRegExp("/"), "_" ); 798 docname.replace( QRegExp("/"), "_" );
799 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long. 799 // cut the length. filenames longer than that don't make sense and something goes wrong when they get too long.
800 if ( docname.length() > 40 ) 800 if ( docname.length() > 40 )
801 docname = docname.left(40); 801 docname = docname.left(40);
802 if ( docname.isEmpty() ) 802 if ( docname.isEmpty() )
803 docname = tr("Unnamed"); 803 docname = tr("Unnamed");
804 doc->setName(docname); 804 doc->setName(docname);
805 currentFileName=docname; 805 currentFileName=docname;
806 } 806 }
807 } 807 }
808 808
809 QMap<QString, QStringList> map; 809 QMap<QString, QStringList> map;
810 map.insert(tr("All"), QStringList() ); 810 map.insert(tr("All"), QStringList() );
811 QStringList text; 811 QStringList text;
812 text << "text/*"; 812 text << "text/*";
813 map.insert(tr("Text"), text ); 813 map.insert(tr("Text"), text );
814 text << "*"; 814 text << "*";
815 map.insert(tr("All"), text ); 815 map.insert(tr("All"), text );
816 816
817 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map); 817 QString str = OFileDialog::getSaveFileName( 2,"/", QString::null, map);
818 818
819 if(!str.isEmpty() ) { 819 if(!str.isEmpty() ) {
820 QString fileNm=str; 820 QString fileNm=str;
821 821
822 qDebug("saving filename "+fileNm); 822 qDebug("saving filename "+fileNm);
823 QFileInfo fi(fileNm); 823 QFileInfo fi(fileNm);
824 currentFileName=fi.fileName(); 824 currentFileName=fi.fileName();
825 if(doc) { 825 if(doc) {
826// QString file = doc->file(); 826// QString file = doc->file();
827// doc->removeFiles(); 827// doc->removeFiles();
828 delete doc; 828 delete doc;
829 DocLnk nf; 829 DocLnk nf;
830 nf.setType("text/plain"); 830 nf.setType("text/plain");
831 nf.setFile( fileNm); 831 nf.setFile( fileNm);
832 doc = new DocLnk(nf); 832 doc = new DocLnk(nf);
833// editor->setText(rt); 833// editor->setText(rt);
834// qDebug("openFile doclnk "+currentFileName); 834// qDebug("openFile doclnk "+currentFileName);
835 doc->setName( currentFileName); 835 doc->setName( currentFileName);
836 updateCaption( currentFileName); 836 updateCaption( currentFileName);
837 837
838 FileManager fm; 838 FileManager fm;
839 if ( !fm.saveFile( *doc, rt ) ) { 839 if ( !fm.saveFile( *doc, rt ) ) {
840 return false; 840 return false;
841 } 841 }
842 842
843 if( useAdvancedFeatures ) { 843 if( useAdvancedFeatures ) {
844 filePermissions *filePerm; 844 filePermissions *filePerm;
845 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); 845 filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm);
846 filePerm->showMaximized();
846 filePerm->exec(); 847 filePerm->exec();
847 848
848 if( filePerm) 849 if( filePerm)
849 delete filePerm; 850 delete filePerm;
850 } 851 }
851 } 852 }
852 editor->setEdited( false); 853 editor->setEdited( false);
853 edited1 = false; 854 edited1 = false;
854 edited = false; 855 edited = false;
855 if(caption().left(1)=="*") 856 if(caption().left(1)=="*")
856 setCaption(caption().right(caption().length()-1)); 857 setCaption(caption().right(caption().length()-1));
857 858
858 return true; 859 return true;
859 } 860 }
860 qDebug("returning false"); 861 qDebug("returning false");
861 return false; 862 return false;
862} //end saveAs 863} //end saveAs
863 864
864void TextEdit::clear() { 865void TextEdit::clear() {
865 delete doc; 866 delete doc;
866 doc = 0; 867 doc = 0;
867 editor->clear(); 868 editor->clear();
868} 869}
869 870
870void TextEdit::updateCaption( const QString &name ) { 871void TextEdit::updateCaption( const QString &name ) {
871 if ( !doc ) 872 if ( !doc )
872 setCaption( tr("Text Editor") ); 873 setCaption( tr("Text Editor") );
873 else { 874 else {
874 QString s = name; 875 QString s = name;
875 if ( s.isNull() ) 876 if ( s.isNull() )
876 s = doc->name(); 877 s = doc->name();
877 if ( s.isEmpty() ) { 878 if ( s.isEmpty() ) {
878 s = tr( "Unnamed" ); 879 s = tr( "Unnamed" );
879 currentFileName=s; 880 currentFileName=s;
880 } 881 }
881 if(s.left(1) == "/") 882 if(s.left(1) == "/")
882 s = s.right(s.length()-1); 883 s = s.right(s.length()-1);
883 setCaption( s + " - " + tr("Text Editor") ); 884 setCaption( s + " - " + tr("Text Editor") );
884 } 885 }
885} 886}
886 887
887void TextEdit::setDocument(const QString& fileref) { 888void TextEdit::setDocument(const QString& fileref) {
888 bFromDocView = TRUE; 889 bFromDocView = TRUE;
889 openFile(fileref); 890 openFile(fileref);
890 editor->setEdited(TRUE); 891 editor->setEdited(TRUE);
891 edited1=FALSE; 892 edited1=FALSE;
892 edited=TRUE; 893 edited=TRUE;
893 doSearchBar(); 894 doSearchBar();
894} 895}
895 896
896void TextEdit::closeEvent( QCloseEvent *e ) { 897void TextEdit::closeEvent( QCloseEvent *e ) {
897 bFromDocView = FALSE; 898 bFromDocView = FALSE;
898 e->accept(); 899 e->accept();
899} 900}
900 901
901void TextEdit::changeFont() { 902void TextEdit::changeFont() {
902 FontDatabase fdb; 903 FontDatabase fdb;
903 QFont defaultFont=editor->font(); 904 QFont defaultFont=editor->font();
904 QFontInfo fontInfo(defaultFont); 905 QFontInfo fontInfo(defaultFont);
905 Config cfg("TextEdit"); 906 Config cfg("TextEdit");
906 cfg.setGroup("Font"); 907 cfg.setGroup("Font");
907 QString family = cfg.readEntry("Family", fontInfo.family()); 908 QString family = cfg.readEntry("Family", fontInfo.family());
908 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont)); 909 QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
909 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10); 910 int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
910 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) ); 911 QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
911 912
912 defaultFont = fdb.font(family,style,i_size,charSet); 913 defaultFont = fdb.font(family,style,i_size,charSet);
913 914
914 FontDialog *fontDlg; 915 FontDialog *fontDlg;
915 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE); 916 fontDlg=new FontDialog(this,tr("FontDialog"),TRUE);
916 917
917 fontDlg->exec(); 918 fontDlg->exec();
918 919
919 QFont myFont=fontDlg->selectedFont; 920 QFont myFont=fontDlg->selectedFont;
920 editor->setFont( myFont); 921 editor->setFont( myFont);
921 delete fontDlg; 922 delete fontDlg;
922 923
923} 924}
924 925
925void TextEdit::editDelete() { 926void TextEdit::editDelete() {
926 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) { 927 switch ( QMessageBox::warning(this,tr("Text Editor"),tr("Do you really want<BR>to <B>delete</B> the current file\nfrom the disk?<BR>This is <B>irreversable!!</B>"),tr("Yes"),tr("No"),0,0,1) ) {
927 case 0: 928 case 0:
928 if(doc) { 929 if(doc) {
929 doc->removeFiles(); 930 doc->removeFiles();
930 clear(); 931 clear();
931 setCaption( tr("Text Editor") ); 932 setCaption( tr("Text Editor") );
932 } 933 }
933 break; 934 break;
934 case 1: 935 case 1:
935 // exit 936 // exit
936 break; 937 break;
937 }; 938 };
938} 939}
939 940
940void TextEdit::changeStartConfig( bool b ) { 941void TextEdit::changeStartConfig( bool b ) {
941 942