~ubuntu-branches/ubuntu/vivid/kdepim/vivid

« back to all changes in this revision

Viewing changes to korganizer/actionmanager.cpp

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman, Jonathan Riddell, Rohan Garg, Scott Kitterman
  • Date: 2012-11-21 13:12:36 UTC
  • mfrom: (0.2.33)
  • Revision ID: package-import@ubuntu.com-20121121131236-32ijw9a2txrar80k
Tags: 4:4.9.80-0ubuntu1
[ Jonathan Riddell ]
* New upstream beta release

[ Rohan Garg ]
* Add nepomuk-core-dev to build-deps

[ Scott Kitterman ]
* Add new package, libpimcommon4
  - Add libpimcommon4.install
  - Add to debian/control, including kdepim-dbg and kdepim-dev depends
  - Add to kdepim-dev.install
* Remove usr/bin/backupmail and related files from kmail.install as they are
  not provided by upstream anymore
* Add usr/bin/pimsettingexporter and related files to kmail.install
* Add libnepomukwidgets-dev to build-depends

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#include "history.h"
36
36
#include "htmlexportjob.h"
37
37
#include "htmlexportsettings.h"
38
 
#include "importdialog.h"
39
38
#include "kocore.h"
40
39
#include "kodialogmanager.h"
41
40
#include "koglobals.h"
1033
1032
    } else {
1034
1033
      bool success = mCalendarView->openCalendar( mFile, merge );
1035
1034
      if ( success ) {
1036
 
        showStatusMessageOpen( url, merge );
 
1035
        showStatusMessageOpen( merge );
1037
1036
      }
1038
1037
    }
1039
1038
    setTitle();
1045
1044
      if ( merge ) {
1046
1045
        KIO::NetAccess::removeTempFile( tmpFile );
1047
1046
        if ( success ) {
1048
 
          showStatusMessageOpen( url, merge );
 
1047
          showStatusMessageOpen( merge );
1049
1048
        }
1050
1049
      } else {
1051
1050
        if ( success ) {
1054
1053
          mFile = tmpFile;
1055
1054
          setTitle();
1056
1055
          kDebug() << "-- Add recent URL:" << url.prettyUrl();
1057
 
          showStatusMessageOpen( url, merge );
 
1056
          showStatusMessageOpen( merge );
1058
1057
        }
1059
1058
      }
1060
1059
      return success;
1061
 
    } else {
1062
 
      QString msg;
1063
 
      msg = i18n( "Cannot download calendar from '%1'.", url.prettyUrl() );
1064
 
      KMessageBox::error( dialogParent(), msg );
 
1060
    } else { // download failed
 
1061
      KMessageBox::error( dialogParent(), KIO::NetAccess::lastErrorString() );
1065
1062
      return false;
1066
1063
    }
1067
1064
  }
1108
1105
  instance.reconfigure();
1109
1106
}
1110
1107
 
1111
 
void ActionManager::showStatusMessageOpen( const KUrl &url, bool merge )
 
1108
void ActionManager::showStatusMessageOpen( bool merge )
1112
1109
{
1113
1110
  if ( merge ) {
1114
 
    mMainWindow->showStatusMessage( i18n( "Merged calendar '%1'.", url.prettyUrl() ) );
 
1111
    mMainWindow->showStatusMessage( i18n( "Calendar Item successfully merged" ) );
1115
1112
  } else {
1116
 
    mMainWindow->showStatusMessage( i18n( "Opened calendar '%1'.", url.prettyUrl() ) );
 
1113
    mMainWindow->showStatusMessage( i18n( "Calendar Item successfully created" ) );
1117
1114
  }
1118
1115
}
1119
1116
 
1203
1200
  }
1204
1201
 
1205
1202
  if ( settings->outputFile().isEmpty() ) {
1206
 
    return;
1207
 
    //uncomment when new strings permitted
1208
 
//     int result = KMessageBox::questionYesNo(
1209
 
//       dialogParent(),
1210
 
//       i18n( "The HTML calendar export file has not been specified yet.\n"
1211
 
//             "Do you want to set it now?\n\n"
1212
 
//             "If you answer \"no\" then this export operation will be canceled" ),
1213
 
//       QString() );
1214
 
//     if ( result == KMessageBox::No ) {
1215
 
//       mMainWindow->showStatusMessage(
1216
 
//         i18nc( "@info:status",
1217
 
//                "Calendar HTML operation canceled due to unspecified output file name" ) );
1218
 
//       return;
1219
 
//     }
 
1203
    int result = KMessageBox::questionYesNo(
 
1204
      dialogParent(),
 
1205
      i18n( "The HTML calendar export file has not been specified yet.\n"
 
1206
            "Do you want to set it now?\n\n"
 
1207
            "If you answer \"no\" then this export operation will be canceled" ),
 
1208
      QString() );
 
1209
    if ( result == KMessageBox::No ) {
 
1210
      mMainWindow->showStatusMessage(
 
1211
        i18nc( "@info:status",
 
1212
               "Calendar HTML operation canceled due to unspecified output file name" ) );
 
1213
      return;
 
1214
    }
1220
1215
 
1221
 
//     const QString fileName =
1222
 
//       KFileDialog::getSaveFileName(
1223
 
//         KGlobalSettings::documentPath(),
1224
 
//         i18n( "*.html|HTML Files" ),
1225
 
//         dialogParent(),
1226
 
//         i18n( "Select path for HTML calendar export" ) );
1227
 
//     settings->setOutputFile( fileName );
1228
 
//     settings->writeConfig();
 
1216
    const QString fileName =
 
1217
      KFileDialog::getSaveFileName(
 
1218
        KGlobalSettings::documentPath(),
 
1219
        i18n( "*.html|HTML Files" ),
 
1220
        dialogParent(),
 
1221
        i18n( "Select path for HTML calendar export" ) );
 
1222
    settings->setOutputFile( fileName );
 
1223
    settings->writeConfig();
1229
1224
  }
1230
1225
 
1231
1226
  if ( !autoMode && QFileInfo( settings->outputFile() ).exists() ) {
1235
1230
                settings->outputFile() ),
1236
1231
          QString(),
1237
1232
          KStandardGuiItem::overwrite() ) == KMessageBox::Cancel ) {
1238
 
      //uncomment when new strings allowed
1239
 
//       mMainWindow->showStatusMessage(
1240
 
//         i18nc( "@info:status",
1241
 
//                "Calendar HTML operation canceled due to output file overwrite" ) );
 
1233
      mMainWindow->showStatusMessage(
 
1234
        i18nc( "@info:status",
 
1235
               "Calendar HTML operation canceled due to output file overwrite" ) );
1242
1236
      return;
1243
1237
    }
1244
1238
  }
2052
2046
    return;
2053
2047
  }
2054
2048
 
2055
 
  ImportDialog *dialog;
2056
 
  dialog = new ImportDialog( url, mMainWindow->topLevelWidget() );
2057
 
  connect( dialog, SIGNAL(dialogFinished(ImportDialog*)),
2058
 
           SLOT(slotImportDialogFinished(ImportDialog*)) );
2059
 
  connect( dialog, SIGNAL(openURL(KUrl,bool)),
2060
 
           SLOT(openURL(KUrl,bool)) );
2061
 
  connect( dialog, SIGNAL(addResource(KUrl)),
2062
 
           SLOT(addResource(KUrl)) );
2063
 
 
2064
 
  dialog->show();
2065
 
}
2066
 
 
2067
 
void ActionManager::slotImportDialogFinished( ImportDialog *dlg )
2068
 
{
2069
 
  dlg->deleteLater();
2070
 
  mCalendarView->updateView();
 
2049
  const QString questionText =
 
2050
    i18nc( "@info",
 
2051
           "<p>Would you like to merge this calendar item into an existing calendar "
 
2052
           "or use it to create a brand new calendar?</p>"
 
2053
           "<p>If you select merge, then you will be given the opportunity to select "
 
2054
           "the destination calendar.</p>"
 
2055
           "<p>If you select add, then a new calendar will be created for you automatically.</p>" );
 
2056
 
 
2057
reTry:
 
2058
  const int answer =
 
2059
    KMessageBox::questionYesNoCancel(
 
2060
      dialogParent(),
 
2061
      questionText,
 
2062
      i18nc( "@title:window", "Import Calendar" ),
 
2063
      KGuiItem( i18n( "Merge into existing calendar" ) ),
 
2064
      KGuiItem( i18n( "Add as new calendar" ) ) );
 
2065
 
 
2066
  bool status;
 
2067
  switch( answer )  {
 
2068
  case KMessageBox::Yes: //merge
 
2069
    status = openURL( url, true );
 
2070
    break;
 
2071
  case KMessageBox::No:  //import
 
2072
    status = addResource( url );
 
2073
    break;
 
2074
  default:
 
2075
    return;
 
2076
  }
 
2077
 
 
2078
  if ( !status ) {
 
2079
    int answer =
 
2080
      KMessageBox::questionYesNo(
 
2081
        dialogParent(),
 
2082
        i18nc( "@info",
 
2083
               "<p>An error occurred importing calendar item from %1.</p>"
 
2084
               "<p>Would you like to try again?</p>", url.prettyUrl() ) );
 
2085
    if ( answer == KMessageBox::Yes ) {
 
2086
      goto reTry;
 
2087
    }
 
2088
  } else {
 
2089
    KMessageBox::information(
 
2090
      dialogParent(),
 
2091
      i18nc( "@info",
 
2092
             "The calendar item from %1 was successfully imported.",
 
2093
             url.prettyUrl() ) );
 
2094
  }
2071
2095
}
2072
2096
 
2073
2097
void ActionManager::slotAutoArchivingSettingsModified()