reload implemented

This commit is contained in:
nemu
2009-05-07 06:41:55 +00:00
parent 161079ff0c
commit 97c8d379ac
2 changed files with 17 additions and 7 deletions

View File

@ -367,7 +367,7 @@ void PTextEdit::setupHelpActions()
/** /**
* <p> * <p>
*/ */
void PTextEdit::load( const QString &f ) void PTextEdit::load( const QString &f, const int index )
{ {
if ( !QFile::exists( f ) ) if ( !QFile::exists( f ) )
return; return;
@ -378,7 +378,10 @@ void PTextEdit::load( const QString &f )
edit->setPointSize(11); // 11pt edit->setPointSize(11); // 11pt
edit->setFont(QFont("Courier", 11)); edit->setFont(QFont("Courier", 11));
fTabWidget->addTab( edit, QFileInfo( f ).fileName() ); if (index == -1)
fTabWidget->addTab( edit, QFileInfo( f ).fileName() );
else
fTabWidget->insertTab( edit, QFileInfo( f ).fileName(), index );
QFile file( f ); QFile file( f );
if ( !file.open( IO_ReadOnly ) ) if ( !file.open( IO_ReadOnly ) )
return; return;
@ -491,7 +494,14 @@ void PTextEdit::fileOpen()
*/ */
void PTextEdit::fileReload() void PTextEdit::fileReload()
{ {
QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok); if ( fFilenames.find( currentEditor() ) == fFilenames.end() ) {
QMessageBox::critical(this, "**ERROR**", "Cannot reload a file not previously saved ;-)");
} else {
int index = fTabWidget->currentPageIndex();
QString fln = *fFilenames.find( currentEditor() );
fileClose(false);
load(fln, index);
}
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -584,11 +594,11 @@ void PTextEdit::filePrint()
/** /**
* <p> * <p>
*/ */
void PTextEdit::fileClose() void PTextEdit::fileClose(const bool check)
{ {
// check if the has modification // check if the has modification
int idx = fTabWidget->currentPageIndex(); int idx = fTabWidget->currentPageIndex();
if (fTabWidget->label(idx).find("*")>0) { if ((fTabWidget->label(idx).find("*")>0) && check) {
int result = QMessageBox::warning(this, "**WARNING**", int result = QMessageBox::warning(this, "**WARNING**",
"Do you really want to close this file.\nChanges will be lost", "Do you really want to close this file.\nChanges will be lost",
"Close", "Cancel"); "Close", "Cancel");

View File

@ -59,7 +59,7 @@ private:
void setupTextActions(); void setupTextActions();
void setupMusrActions(); void setupMusrActions();
void setupHelpActions(); void setupHelpActions();
void load( const QString &f ); void load( const QString &f, const int index=-1 );
PSubTextEdit *currentEditor() const; PSubTextEdit *currentEditor() const;
void doConnections( PSubTextEdit *e ); void doConnections( PSubTextEdit *e );
bool validRunList(const QString runList); bool validRunList(const QString runList);
@ -71,7 +71,7 @@ private slots:
void fileSave(); void fileSave();
void fileSaveAs(); void fileSaveAs();
void filePrint(); void filePrint();
void fileClose(); void fileClose( const bool check = true );
void fileExit(); void fileExit();
void editUndo(); void editUndo();