KParts::ReadWritePart::closeURL ()

David Faure david at mandrakesoft.com
Fri May 24 21:27:23 BST 2002


On Friday 24 May 2002 21:44, Christoph Cullmann wrote:
> Hi,
> just noticed that the closeURL methode in kparts wasn't used right in kate, 
> will change that, but have a question:
> Should the default implementation in kdelibs not check if a file may be 
> overwritten ? That would make the default implementation a lot more useful 
> than atm.

In saveAs() you mean?
Good idea.

KOffice does it before hand, in KoMainWindow, with code like:

        bool bOk;
        do {
            bOk = true;
            ... create KFileDialog ...            
            if(dialog->exec()==QDialog::Accepted)
                newURL=dialog->selectedURL();
            else
            {
                bOk = false;
                break;
            }

            if ( newURL.isEmpty() )
            {
                bOk = false;
                break;
            }          

            if ( KIO::NetAccess::exists( newURL ) ) { // this file exists => ask for confirmation
                bOk = KMessageBox::questionYesNo( this,
                                                  i18n("A document with this name already exists.\n"\
                                                       "Do you want to overwrite it?"),
                                                  i18n("Warning") ) == KMessageBox::Yes;
            }
        } while ( !bOk );

(and then saving if bOk)

The point is to keep asking, if the user selects a file that already exists,
so that he can choose another file.

-- 
David FAURE, david at mandrakesoft.com, faure at kde.org
http://people.mandrakesoft.com/~david/
Contributing to: http://www.konqueror.org/, http://www.koffice.org/
KDE, Making The Future of Computing Available Today






More information about the kde-core-devel mailing list