~ubuntu-branches/ubuntu/karmic/kdepim/karmic-backports

« back to all changes in this revision

Viewing changes to kalarm/resources/resourcelocaldir.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christian Mangold
  • Date: 2009-07-10 06:34:50 UTC
  • mfrom: (1.1.40 upstream)
  • Revision ID: james.westby@ubuntu.com-20090710063450-neojgew2fh0n3y0u
Tags: 4:4.2.96-0ubuntu1
* New upstream release
* Bump kde build-deps to 4.2.96

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
        connect(&mDirWatch, SIGNAL(dirty(const QString&)), SLOT(slotUpdated(const QString&)));
72
72
        connect(&mDirWatch, SIGNAL(created(const QString&)), SLOT(slotUpdated(const QString&)));
73
73
        connect(&mDirWatch, SIGNAL(deleted(const QString&)), SLOT(slotUpdated(const QString&)));
74
 
        mDirWatch.addDir(mURL.path(), KDirWatch::WatchFiles);
 
74
        mDirWatch.addDir(mURL.toLocalFile(), KDirWatch::WatchFiles);
75
75
 
76
76
        enableResource(isActive());
77
77
 
118
118
{
119
119
        // Re-evaluate the directory's read-only status (since KDirWatch
120
120
        // doesn't pick up permissions changes on the directory itself).
121
 
        QFileInfo dirInfo(mURL.path());
 
121
        QFileInfo dirInfo(mURL.toLocalFile());
122
122
        mDirReadOnly = !dirInfo.isWritable();
123
123
        AlarmResource::setReadOnly(ro);
124
124
}
125
125
 
126
126
void KAResourceLocalDir::enableResource(bool enable)
127
127
{
128
 
        kDebug(KARES_DEBUG) << enable << ":" << mURL.path();
 
128
        kDebug(KARES_DEBUG) << enable << ":" << mURL.toLocalFile();
129
129
        if (enable)
130
130
        {
131
 
                lock(mURL.path());
 
131
                lock(mURL.toLocalFile());
132
132
                mDirWatch.startScan();
133
133
        }
134
134
        else
140
140
 
141
141
bool KAResourceLocalDir::doOpen()
142
142
{
143
 
        QFileInfo dirInfo(mURL.path());
 
143
        QFileInfo dirInfo(mURL.toLocalFile());
144
144
        return dirInfo.isDir()  &&  dirInfo.isReadable();
145
145
}
146
146
 
150
150
#warning Only reload the individual file which has changed
151
151
#endif
152
152
        if (filepath.contains(QRegExp("(~|\\.new|\\.tmp)$"))
153
 
        ||  filepath.startsWith(mURL.path() + "/qt_temp."))
 
153
        ||  filepath.startsWith(mURL.toLocalFile() + "/qt_temp."))
154
154
                return;   // ignore backup or temporary file
155
155
        doLoad(false);
156
156
}
163
163
*/
164
164
bool KAResourceLocalDir::doLoad(bool syncCache)
165
165
{
166
 
        kDebug(KARES_DEBUG) << mURL.path() << (syncCache ?": load all" :": load changes only");
 
166
        kDebug(KARES_DEBUG) << mURL.toLocalFile() << (syncCache ?": load all" :": load changes only");
167
167
        if (!isActive()  ||  !isOpen())
168
168
                return false;
169
169
        ModifiedMap      oldLastModified;
188
188
        }
189
189
        mLastModified.clear();
190
190
        mCompatibilityMap.clear();
191
 
        QString dirName = mURL.path();
 
191
        QString dirName = mURL.toLocalFile();
192
192
        bool success = false;
193
193
        bool foundFile = false;
194
194
        if (KStandardDirs::exists(dirName)  ||  KStandardDirs::exists(dirName + '/'))
349
349
 
350
350
bool KAResourceLocalDir::doSave(bool)
351
351
{
352
 
        kDebug(KARES_DEBUG) << mURL.path();
 
352
        kDebug(KARES_DEBUG) << mURL.toLocalFile();
353
353
        bool success = true;
354
354
        Incidence::List list = addedIncidences();
355
355
        list += changedIncidences();
377
377
        }
378
378
 
379
379
        QString id = incidence->uid();
380
 
        QString fileName = mURL.path() + '/' + id;
 
380
        QString fileName = mURL.toLocalFile() + '/' + id;
381
381
        kDebug(KARES_DEBUG) << fileName;
382
382
 
383
383
        CalendarLocal cal(calendar()->timeSpec());
421
421
 
422
422
bool KAResourceLocalDir::deleteIncidenceFile(Incidence* incidence)
423
423
{
424
 
        QFile file(mURL.path() + '/' + incidence->uid());
 
424
        QFile file(mURL.toLocalFile() + '/' + incidence->uid());
425
425
        if (!file.exists())
426
426
                return true;
427
427
        mDirWatch.stopScan();
432
432
 
433
433
QString KAResourceLocalDir::dirName() const
434
434
{
435
 
        return mURL.path();
 
435
        return mURL.toLocalFile();
436
436
}
437
437
 
438
438
bool KAResourceLocalDir::setDirName(const KUrl& newURL)
442
442
                mNewURL = newURL;
443
443
                return true;
444
444
        }
445
 
        if (newURL.path() == mURL.path()  ||  !newURL.isLocalFile())
 
445
        if (!newURL.isLocalFile() || newURL.toLocalFile() == mURL.toLocalFile())
446
446
                return false;
447
 
        kDebug(KARES_DEBUG) << newURL.path();
 
447
        kDebug(KARES_DEBUG) << newURL.toLocalFile();
448
448
        if (isOpen())
449
449
                close();
450
450
        bool active = isActive();
451
451
        if (active)
452
452
                enableResource(false);
453
 
        mDirWatch.removeDir(mURL.path());
 
453
        mDirWatch.removeDir(mURL.toLocalFile());
454
454
        mURL = newURL;
455
 
        mDirWatch.addDir(mURL.path(), KDirWatch::WatchFiles);
 
455
        mDirWatch.addDir(mURL.toLocalFile(), KDirWatch::WatchFiles);
456
456
        if (active)
457
457
                enableResource(true);
458
458
        // Trigger loading the new resource, and ensure that the new configuration is saved
468
468
 
469
469
QString KAResourceLocalDir::displayLocation() const
470
470
{
471
 
        return mURL.path();
 
471
        return mURL.toLocalFile();
472
472
}
473
473
 
474
474
QString KAResourceLocalDir::displayType() const