Logo Search packages:      
Sourcecode: kcmpureftpd version File versions  Download package

void KPureftpdScript::slotScriptSave (  )  [protected, slot]

Save current selected script data back to disk. This operation generate or update the XML data file which have ".purescr" extension. The changed icon is removed the point that script item is not changed.

Definition at line 387 of file kcmpureftpdscript.cpp.

References script, and ui.

Referenced by KPureftpdScript().

  KListViewItem *item = (KListViewItem *)ui->scriptList->currentItem();
  if (item != 0L) {
    if (listMap.contains(item)) {
      // get the id of item and check if it's a script one
      QString id = listMap[item];
      if (id.left(1) == "/") {
        // it happen if I forgot to disable "Save" for templates items
        kdFatal() << "slotScriptSave: cannot save script templates" << endl;
      } else {
        Script::IOStatus ret;
        QString scriptfile;

        // calculate where to save script file, according to permissions
        // and KDE way
        int pos;
        if ((pos=scriptfile.findRev("/")) == -1) {
          scriptfile=KGlobal::dirs()->saveLocation("data","kcmpureftpdscript/") + scriptfile;
        } else {
          QFileInfo fi(scriptfile);
          if (!fi.isWritable()) {
            scriptfile=KGlobal::dirs()->saveLocation("data","kcmpureftpdscript/") + scriptfile.mid(pos+1);

        switch (ret) {
          case Script::SaveOk:
          case Script::OpenError:
                      i18n("There was an error trying to open the script file for writing."),
                      i18n("<qt>You may not have required permissions to open it. Please "
                           "check the \"<i>%1</i>\" file.</qt>").arg(scriptfile),
                      i18n("Save failed"));
          case Script::WriteError:
                      i18n("There was an error trying to write the script file."),
                      i18n("<qt>It's possible that some disk access error occured. Please "
                           "check the \"<i>%1</i>\" file</qt>").arg(scriptfile),
                      i18n("Save failed"));
            kdFatal() << "slotScriptSave: unknown IOStatus code; ret=" << ret << endl;
    } else {
      // it happen if I forgot to disable "Save" for toplevel
      // ListViewItems or bug in application (listMap not in-sync)
      kdFatal() << "slotScriptSave: the current selected item is not in listMap" << endl;

Generated by  Doxygen 1.6.0   Back to index