SVN commit 743441 by sebsauer: * added notifications for DocumentLoaded and DocumentSaved to KoDocument * improved linkhandling in KSpread * added KNotify-notifications for DocumentLoaded, DocumentSaved, LinkActivated and ValidityError to KSpread and allow to configure them M +5 -4 kspread/CMakeLists.txt M +1 -0 kspread/Doc.cpp M +1 -0 kspread/Util.cpp M +26 -14 kspread/Validity.cpp A kspread/kspread.notifyrc M +2 -1 kspread/kspread.rc M +33 -22 kspread/ui/DefaultTool.cpp M +11 -4 kspread/ui/View.cpp M +1 -0 kspread/ui/View.h M +17 -0 libs/kotext/opendocument/KoTextLoadingContext.h M +13 -0 libs/main/KoDocument.cpp --- trunk/koffice/kspread/CMakeLists.txt #743440:743441 @@ -209,6 +209,7 @@ target_link_libraries(kspreadcommon ${QT_QTSQL_LIBRARY} + ${KDE4_KNOTIFYCONFIG_LIBS} komain koguiutils kochart ${KDE4_KDE3SUPPORT_LIBS} ) @@ -244,7 +245,7 @@ ########### install files ############### -install( FILES kspread.rc kspread_readonly.rc DESTINATION ${DATA_INSTALL_DIR}/kspread) -install( FILES kspreadpart.desktop DESTINATION ${SERVICES_INSTALL_DIR}) -install( FILES kspread.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) -install( FILES kspread.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) +install( FILES kspread.rc kspread_readonly.rc kspread.notifyrc DESTINATION ${DATA_INSTALL_DIR}/kspread) +install( FILES kspreadpart.desktop DESTINATION ${SERVICES_INSTALL_DIR}) +install( FILES kspread.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) +install( FILES kspread.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) --- trunk/koffice/kspread/Doc.cpp #743440:743441 @@ -904,6 +904,7 @@ //display loading time kDebug(36001) <<"Loading took" << (float)(dt.elapsed()) / 1000.0 <<" seconds"; + return true; } --- trunk/koffice/kspread/Util.cpp #743440:743441 @@ -329,6 +329,7 @@ bool KSpread::Util::localReferenceAnchor( const QString &_ref ) { bool isLocalRef = (_ref.indexOf("http://") != 0 && + _ref.indexOf("https://") != 0 && _ref.indexOf("mailto:") != 0 && _ref.indexOf("ftp://") != 0 && _ref.indexOf("file:") != 0 ); --- trunk/koffice/kspread/Validity.cpp #743440:743441 @@ -22,8 +22,12 @@ #include +// Qt +#include + // KDE #include +#include // KOffice #include @@ -887,23 +891,31 @@ valid= true; } - if ( !valid && d->displayMessage ) + if ( !valid ) { - switch (d->action ) + if ( d->displayMessage ) { - case Stop: - KMessageBox::error((QWidget*)0, d->message, - d->title); - break; - case Warning: - KMessageBox::warningYesNo((QWidget*)0, d->message, - d->title); - break; - case Information: - KMessageBox::information((QWidget*)0, d->message, - d->title); - break; + switch (d->action) + { + case Stop: + KMessageBox::error((QWidget*)0, d->message, d->title); + break; + case Warning: + KMessageBox::warningYesNo((QWidget*)0, d->message, d->title); + break; + case Information: + KMessageBox::information((QWidget*)0, d->message, d->title); + break; + } } + + KNotification *notify = new KNotification("ValidityError"); + notify->setText( i18n("Validation for cell %1 failed", cell->fullName()) ); + notify->addContext("cell", cell->fullName()); + notify->addContext("value", cell->userInput()); + notify->addContext("title", d->title); + notify->addContext("message", d->message); + QTimer::singleShot(0, notify, SLOT(sendEvent())); } return (valid || d->action != Stop); } --- trunk/koffice/kspread/kspread.rc #743440:743441 @@ -159,7 +159,8 @@ - + + --- trunk/koffice/kspread/ui/DefaultTool.cpp #743440:743441 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -679,35 +680,45 @@ void DefaultTool::Private::processLeftClickAnchor() { - bool isRefLink = Util::localReferenceAnchor( anchor ); - if ( !isRefLink ) - { - KUrl url(anchor); - if ( ! url.isValid() ) - return; - const QString type = KMimeType::findByUrl(url, 0, url.isLocalFile())->name(); - if ( KRun::isExecutableFile( url, type ) ) - { - QString question = i18n("This link points to the program or script '%1'.\n" - "Malicious programs can harm your computer. " - "Are you sure that you want to run this program?", anchor); - // this will also start local programs, so adding a "don't warn again" - // checkbox will probably be too dangerous - int choice = KMessageBox::warningYesNo(canvas, question, i18n("Open Link?")); - if ( choice != KMessageBox::Yes ) - return; - } - new KRun(url, canvas, 0, url.isLocalFile()); - } - else - { + KNotification *notify = new KNotification("LinkActivated"); + notify->setText( i18n("Link %1 activated", anchor) ); + notify->addContext("anchor", anchor); + + KUrl url(anchor); + if ( ! url.isValid() || url.isRelative() ) { Region r(anchor, canvas->view()->doc()->map(), canvas->activeSheet()); if ( r.isValid() ) { if ( r.firstSheet() != canvas->view()->activeSheet() ) canvas->view()->setActiveSheet( r.firstSheet() ); canvas->selection()->initialize(r); + + if ( ! r.firstRange().isNull() ) { + QPoint p( r.firstRange().topLeft() ); + notify->addContext("region", Cell(r.firstSheet(), p.x(), p.y()).fullName()); + } } } + else { + const QString type = KMimeType::findByUrl(url, 0, url.isLocalFile())->name(); + notify->addContext("type", type); + if ( ! Util::localReferenceAnchor(anchor) ) { + const bool executable = KRun::isExecutableFile( url, type ); + notify->addContext("executable", QVariant(executable).toString()); + if ( executable ) { + QString question = i18n("This link points to the program or script '%1'.\n" + "Malicious programs can harm your computer. " + "Are you sure that you want to run this program?", anchor); + // this will also start local programs, so adding a "don't warn again" + // checkbox will probably be too dangerous + int choice = KMessageBox::warningYesNo(canvas, question, i18n("Open Link?")); + if ( choice != KMessageBox::Yes ) + return; + } + new KRun(url, canvas, 0, url.isLocalFile()); + } + } + + QTimer::singleShot(0, notify, SLOT(sendEvent())); } #include "DefaultTool.moc" --- trunk/koffice/kspread/ui/View.cpp #743440:743441 @@ -86,6 +86,7 @@ #include #include #include +#include // KOffice includes #include @@ -1308,11 +1309,12 @@ connect(actions->showFormulaBar, SIGNAL(toggled(bool)), view, SLOT(showFormulaBar(bool))); - actions->preference = new KAction(KIcon("configure" ), i18n("Configure KSpread..."), view); - ac->addAction("preference", actions->preference ); - connect(actions->preference, SIGNAL(triggered(bool)), view, SLOT( preference() )); - actions->preference->setToolTip(i18n("Set various KSpread options")); + actions->preference = KStandardAction::preferences(view, SLOT(preference()), view); + actions->preference->setToolTip(i18n("Set various KSpread options")); + ac->addAction("preference", actions->preference); + KAction *notifyAction = KStandardAction::configureNotifications(view, SLOT(optionsNotifications()), view); + ac->addAction("configureNotifications", notifyAction); // -- calculation actions -- // @@ -5188,6 +5190,11 @@ refreshView(); } +void View::optionsNotifications() +{ + KNotifyConfigWidget::configure( this ); +} + void View::preference() { if ( !d->activeSheet ) --- trunk/koffice/kspread/ui/View.h #743440:743441 @@ -416,6 +416,7 @@ void lower(); void equalizeColumn(); void equalizeRow(); + void optionsNotifications(); void preference(); void firstLetterUpper(); void verticalText(bool ); --- trunk/koffice/libs/kotext/opendocument/KoTextLoadingContext.h #743440:743441 @@ -34,6 +34,23 @@ * * This class extends the \a KoOasisLoadingContext class with KoText specific * functionality like for example handling of lists. + * + * The context is used within the \a KoTextLoader class to provide additional + * state informations like the \a KoDocument and the \a KoStore we operate on. + * + * In the \a KoTextShapeData::loadOdf() method the \a KoTextLoader is used + * with a KoTextLoadingContext instance like this; + * + * \code + * KoStyleManager *stylemanager = new KoStyleManager(); + * KoTextLoader *loader = new KoTextLoader(stylemanager); + * KoDocument* doc = oasisContext.koDocument(); + * KoOdfStylesReader& styles = oasisContext.stylesReader(); + * KoStore *store = oasisContext.store() + * KoTextLoadingContext *loaderContext = new KoTextLoadingContext(loader, doc, styles, store); + * QTextCursor cursor( document() ); + * loader->loadBody(*loaderContext, element, cursor); // load the body from the ODF KoXmlElement. + * \endcode */ class KOTEXT_EXPORT KoTextLoadingContext : public KoOasisLoadingContext { --- trunk/koffice/libs/main/KoDocument.cpp #743440:743441 @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -483,6 +484,13 @@ } emit clearStatusBarMessage(); + if ( ret ) { + KNotification *notify = new KNotification("DocumentSaved"); + notify->setText( i18n("Document %1 saved", url().url()) ); + notify->addContext("url", url().url()); + QTimer::singleShot(0, notify, SLOT(sendEvent())); + } + return ret; } @@ -1665,6 +1673,11 @@ if ( ok ) { setMimeTypeAfterLoading( typeName ); + + KNotification *notify = new KNotification("DocumentLoaded"); + notify->setText( i18n("Document %1 loaded", url().url()) ); + notify->addContext("url", url().url()); + QTimer::singleShot(0, notify, SLOT(sendEvent())); } d->m_bLoading = false; return ok;