~ubuntu-branches/ubuntu/saucy/kdepimlibs/saucy-proposed

« back to all changes in this revision

Viewing changes to kcalutils/icaldrag.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2014-01-16 14:37:08 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20140116143708-to5k8l8il6534d0f
Tags: 4:4.11.5-0ubuntu0.1
New upstream bugfix release (LP: #1266285)

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
QString ICalDrag::mimeType()
34
34
{
35
 
  return "text/calendar";
36
 
}
37
 
 
38
 
bool ICalDrag::populateMimeData( QMimeData *me, const MemoryCalendar::Ptr &cal )
39
 
{
40
 
  ICalFormat icf;
41
 
  QString scal = icf.toString( cal, QString(), false );
42
 
 
43
 
  if ( scal.length()>0 ){
44
 
    me->setData( mimeType(), scal.toUtf8() );
45
 
  }
46
 
  return canDecode( me );
47
 
}
48
 
 
49
 
bool ICalDrag::canDecode( const QMimeData *me )
50
 
{
51
 
  return me->hasFormat( mimeType() );
52
 
}
53
 
 
54
 
bool ICalDrag::fromMimeData( const QMimeData *de, const MemoryCalendar::Ptr &cal )
55
 
{
56
 
  if ( !canDecode( de ) ) {
57
 
    return false;
58
 
  }
59
 
  bool success = false;
60
 
 
61
 
  QByteArray payload = de->data( mimeType() );
62
 
  if ( payload.size() ) {
63
 
    QString txt = QString::fromUtf8( payload.data() );
64
 
 
 
35
    return "text/calendar";
 
36
}
 
37
 
 
38
bool ICalDrag::populateMimeData(QMimeData *me, const MemoryCalendar::Ptr &cal)
 
39
{
65
40
    ICalFormat icf;
66
 
    success = icf.fromString( cal, txt );
67
 
  }
68
 
 
69
 
  return success;
 
41
    QString scal = icf.toString(cal, QString(), false);
 
42
 
 
43
    if (scal.length()>0) {
 
44
        me->setData(mimeType(), scal.toUtf8());
 
45
    }
 
46
    return canDecode(me);
 
47
}
 
48
 
 
49
bool ICalDrag::canDecode(const QMimeData *me)
 
50
{
 
51
    return me->hasFormat(mimeType());
 
52
}
 
53
 
 
54
bool ICalDrag::fromMimeData(const QMimeData *de, const MemoryCalendar::Ptr &cal)
 
55
{
 
56
    if (!canDecode(de)) {
 
57
        return false;
 
58
    }
 
59
    bool success = false;
 
60
 
 
61
    QByteArray payload = de->data(mimeType());
 
62
    if (payload.size()) {
 
63
        QString txt = QString::fromUtf8(payload.data());
 
64
 
 
65
        ICalFormat icf;
 
66
        success = icf.fromString(cal, txt);
 
67
    }
 
68
 
 
69
    return success;
70
70
}
71
71