summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-03-10 00:09:03 (UTC)
committer llornkcor <llornkcor>2002-03-10 00:09:03 (UTC)
commit637cea2664defb5414a3897f70b616deba926ffe (patch) (side-by-side diff)
tree369bac70a10207db8e464dc591b7015cafb0624a
parent1ad5936cfea54786379c58200d7bbf321dcd6185 (diff)
downloadopie-637cea2664defb5414a3897f70b616deba926ffe.zip
opie-637cea2664defb5414a3897f70b616deba926ffe.tar.gz
opie-637cea2664defb5414a3897f70b616deba926ffe.tar.bz2
added an asterik in the caption if the text is edited and unsaved
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp40
-rw-r--r--core/apps/textedit/textedit.h5
2 files changed, 37 insertions, 8 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index 03f3a1e..78c4d8a 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -156,28 +156,28 @@ static char * filesave_xpm[] = {
class QpeEditor : public QMultiLineEdit
{
// Q_OBJECT
public:
QpeEditor( QWidget *parent, const char * name = 0 )
: QMultiLineEdit( parent, name )
{
clearTableFlags();
setTableFlags( Tbl_vScrollBar | Tbl_autoHScrollBar );
}
- //public slots:
void find( const QString &txt, bool caseSensitive,
bool backwards );
- /*
+//public slots:
+ /*
signals:
void notFound();
void searchWrapped();
*/
private:
};
void QpeEditor::find ( const QString &txt, bool caseSensitive,
bool backwards )
@@ -231,25 +231,26 @@ static int u_id = 1;
static int get_unique_id()
{
return u_id++;
}
static const int nfontsizes = 6;
static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ), bFromDocView( FALSE )
{
doc = 0;
-
+ edited=FALSE;
+ edited1=FALSE;
setToolBarsMovable( FALSE );
setIcon( Resource::loadPixmap( "TextEditor" ) );
QPEToolBar *bar = new QPEToolBar( this );
bar->setHorizontalStretchable( TRUE );
menu = bar;
QPEMenuBar *mb = new QPEMenuBar( bar );
QPopupMenu *file = new QPopupMenu( this );
QPopupMenu *edit = new QPopupMenu( this );
font = new QPopupMenu( this );
@@ -391,24 +392,25 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
searchVisible = FALSE;
fileSelector = new FileSelector( "text/*", editorStack, "fileselector" , TRUE, TRUE); //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( openFile( const DocLnk & ) ) );
// fileOpen();
editor = new QpeEditor( editorStack );
editor->setFrameStyle( QFrame::Panel | QFrame::Sunken );
editorStack->addWidget( editor, get_unique_id() );
+ connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
resize( 200, 300 );
// 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);
@@ -547,25 +549,28 @@ void TextEdit::newFileOpen()
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;
- editor->setEdited( true );
+ editor->setEdited( FALSE);
+ edited1=FALSE;
+ edited=FALSE;
+ setCaption(caption().right(caption().length()-1));
}
#if 0
void TextEdit::slotFind()
{
FindDialog frmFind( "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()),
@@ -675,25 +680,29 @@ void TextEdit::openFile( const DocLnk &f )
if ( !fm.loadFile( f, txt ) ) {
// ####### could be a new file
qDebug( "Cannot open file" );
//return;
}
fileNew();
if ( doc )
delete doc;
doc = new DocLnk(f);
editor->setText(txt);
- editor->setEdited( false);
+ editor->setEdited( FALSE);
+ edited1=FALSE;
+ edited=FALSE;
+ setCaption(caption().right(caption().length()-1));
+
qDebug("openFile doclnk "+currentFileName);
doc->setName(currentFileName);
updateCaption();
}
void TextEdit::showEditTools()
{
// if ( !doc )
// close();
// clear();
fileSelector->hide();
menu->show();
@@ -722,25 +731,29 @@ bool TextEdit::save()
qDebug("saveFile "+currentFileName);
struct stat buf;
mode_t mode;
stat(file.latin1(), &buf);
mode = buf.st_mode;
doc->setName( name);
FileManager fm;
if ( !fm.saveFile( *doc, rt ) ) {
return false;
}
- editor->setEdited( false );
+ editor->setEdited( FALSE);
+ edited1=FALSE;
+ edited=FALSE;
+ setCaption(caption().right(caption().length()-1));
+
chmod( file.latin1(), mode);
}
return true;
}
return false;
}
/*!
prompted save */
bool TextEdit::saveAs()
{
@@ -804,30 +817,35 @@ bool TextEdit::saveAs()
// 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, "Permissions",true,0,(const QString &)fileNm);
filePerm->exec();
- editor->setEdited( false );
+
if( filePerm)
delete filePerm;
}
}
}
+ editor->setEdited( FALSE);
+ edited1=FALSE;
+ edited=FALSE;
+ if(caption().left(1)=="*")
+ setCaption(caption().right(caption().length()-1));
if(fileSaveDlg)
delete fileSaveDlg;
return true;
}
void TextEdit::clear()
{
delete doc;
doc = 0;
editor->clear();
}
@@ -929,12 +947,20 @@ void TextEdit::editDelete()
void TextEdit::changeStartConfig( bool b ) {
Config cfg("TextEdit");
cfg.setGroup("View");
if(b) {
qDebug("bool");
cfg.writeEntry("startNew","TRUE");
} else {
cfg.writeEntry("startNew","FALSE");
}
update();
}
+
+void TextEdit::editorChanged() {
+ if(editor->edited() && edited && !edited1) {
+ setCaption( "*"+caption());
+ edited1=TRUE;
+ }
+ edited=TRUE;
+}
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index fb58738..e7e20e3 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -45,26 +45,29 @@ 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;
+ bool edited, edited1;
void openFile( const QString & );
-
+public slots:
+ void editorChanged();
+
protected:
void closeEvent( QCloseEvent *e );
private slots:
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void newFileOpen();
void changeStartConfig(bool);
bool save();