[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: Sugestion: KStdErrorMessages
From:       Pedro Morais <morais () kde ! org>
Date:       2001-08-26 2:31:01
[Download RAW message or body]

Em Domingo, 26 de Agosto de 2001 01:03, David Faure escreveu:
> On Sunday 26 August 2001 00:45, Pedro Morais wrote:
>
> I suggest you have a look at kio/global.cpp ... 62 error messages are
> already centralized.

But they are only used in kio.
Continuing with my domtreeviewer, take a look at line 444 of
kdeaddons/konq-plugins/domtreeviewer/domtreeviewer.cpp
It deals with QFile's, not with ioslaves.
What I'm saying is that code like

if (file.exists()) {
   const QString title = i18n( "File exists" );
   const QString text = i18n( "Do you really want to overwrite: \n%1" ).arg(url.url());
   if (KMessageBox::Yes != KMessageBox::warningYesNoCancel(this, text, title ) ) {
      return;
   }
}

could be replaced with something like

if (file.exists()) {
   const QString title = i18n(KStdErrorMessages::OVERWRITE_TITLE)
   const QString text = i18n(KStdErrorMessages::OVERWRITE).arg(url.url());
   if (KMessageBox::Yes != KMessageBox::warningYesNoCancel(this, text, title ) ) {
      return;
   }
}

Or maybe just the whole code that checks if a file satisfied a certain condition
(in this case, if exists user must have accepted that it is overwriten, must be writable)
should be refactored to someplace; and them you could use something like:

QFile file = HelperClass::open(HelperClass::PROMPT_EXIST | HelperClass::WRITABLE)
if (file != null) {
  doStuff
}

and all the apropriate user interaction (warnings, errors) would be handled by
this class.

Just try:
grep "want to overwrite" $(find kde-i18n/templates -name "*.pot")
and wonder how many times this code is replicated and why should the user
receive a slighly diferent message depending on the apps he's running.

-- 
Pedro Morais - LEIC/IST - pmmm@rnl.ist.utl.pt http://www.rnl.ist.utl.pt/~pmmm
Página Portuguesa do KDE http://kde.poli.org morais@kde.org
"Still something's missin'... cannot say..." - Pearl Jam

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic