Пример #1
0
void ResourceView::editResource()
{
  bool ok = false;
  ResourceItem *item = currentItem();
  if ( !item ) {
    return;
  }
  ResourceCalendar *resource = item->resource();

  if ( item->isSubresource() ) {
    if ( resource->type() == "imap" ) {
      QString identifier = item->resourceIdentifier();
      const QString newResourceName =
        KInputDialog::getText( i18n( "Rename Calendar Folder" ),
                               i18n( "Please enter a new name for the calendar folder" ),
                               item->text(0),
                               &ok, this );
      if ( !ok ) {
        return;
      }

      QDBusConnection bus = QDBusConnection::sessionBus();
      QDBusInterface *interface =
        new QDBusInterface( "org.kde.kmail",
                            "/Groupware",
                            "org.kde.kmail.groupware",
                            bus,
                            this );

      QDBusReply<int> reply =
        interface->call( "changeResourceUIName", identifier, newResourceName );
      if ( !reply.isValid() ) {
        kDebug() << "DBUS Call changeResourceUIName() failed ";
      }
    } else {
      const QString subResourceName = resource->labelForSubresource( item->resourceIdentifier() );
      KMessageBox::sorry( this,
                          i18n ( "<qt>Cannot edit the calendar folder <b>%1</b>.</qt>",
                                 subResourceName ) );
    }
  } else {
    QPointer<KRES::ConfigDialog> dlg =
      new KRES::ConfigDialog( this, QString( "calendar" ), resource );
    if ( dlg->exec() ) {
      item->setText( 0, resource->resourceName() );
      mCalendar->resourceManager()->change( resource );
    }
    delete dlg;
  }
  emitResourcesChanged();
}
Пример #2
0
void ResourceView::editResource()
{
  ResourceItem *item = currentItem();
  if (!item) return;
  ResourceCalendar *resource = item->resource();

  KRES::ConfigDialog dlg( this, QString("calendar"), resource,
                          "KRES::ConfigDialog" );

  if ( dlg.exec() ) {
    item->setText( 0, resource->resourceName() );

    mCalendar->resourceManager()->change( resource );
  }
  emitResourcesChanged();
}