Changeset View
Changeset View
Standalone View
Standalone View
importer/importer.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 51 | { | |||
---|---|---|---|---|---|
93 | void importNext() | 93 | void importNext() | ||
94 | { | 94 | { | ||
95 | if (mUrlList.empty()) { | 95 | if (mUrlList.empty()) { | ||
96 | q->finalizeImport(); | 96 | q->finalizeImport(); | ||
97 | return; | 97 | return; | ||
98 | } | 98 | } | ||
99 | mCurrentUrl = mUrlList.takeFirst(); | 99 | mCurrentUrl = mUrlList.takeFirst(); | ||
100 | QUrl dst = mTempImportDirUrl; | 100 | QUrl dst = mTempImportDirUrl; | ||
101 | dst.setPath(dst.path() + '/' + mCurrentUrl.fileName()); | 101 | dst.setPath(dst.path() + mCurrentUrl.fileName()); | ||
102 | KIO::Job* job = KIO::copy(mCurrentUrl, dst, KIO::HideProgressInfo); | 102 | KIO::Job* job = KIO::copy(mCurrentUrl, dst, KIO::HideProgressInfo); | ||
103 | KJobWidgets::setWindow(job, mAuthWindow); | 103 | KJobWidgets::setWindow(job, mAuthWindow); | ||
104 | QObject::connect(job, SIGNAL(result(KJob*)), | 104 | QObject::connect(job, SIGNAL(result(KJob*)), | ||
105 | q, SLOT(slotCopyDone(KJob*))); | 105 | q, SLOT(slotCopyDone(KJob*))); | ||
106 | QObject::connect(job, SIGNAL(percent(KJob*,ulong)), | 106 | QObject::connect(job, SIGNAL(percent(KJob*,ulong)), | ||
107 | q, SLOT(slotPercent(KJob*,ulong))); | 107 | q, SLOT(slotPercent(KJob*,ulong))); | ||
108 | } | 108 | } | ||
109 | 109 | | |||
110 | void renameImportedUrl(const QUrl& src) | 110 | void renameImportedUrl(const QUrl& src) | ||
111 | { | 111 | { | ||
112 | QUrl dst = src.resolved(QUrl("..")); | 112 | QUrl dst = src.resolved(QUrl("..")); | ||
113 | QString fileName; | 113 | QString fileName; | ||
114 | if (mFileNameFormater.get()) { | 114 | if (mFileNameFormater.get()) { | ||
115 | KFileItem item(KFileItem::Unknown, KFileItem::Unknown, src, true /* delayedMimeTypes */); | 115 | KFileItem item(KFileItem::Unknown, KFileItem::Unknown, src, true /* delayedMimeTypes */); | ||
116 | // Get the document time, but do not cache the result because the | 116 | // Get the document time, but do not cache the result because the | ||
117 | // 'src' url is temporary: if we import "foo/image.jpg" and | 117 | // 'src' url is temporary: if we import "foo/image.jpg" and | ||
118 | // "bar/image.jpg", both images will be temporarily saved in the | 118 | // "bar/image.jpg", both images will be temporarily saved in the | ||
119 | // 'src' url. | 119 | // 'src' url. | ||
120 | QDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache); | 120 | QDateTime dateTime = TimeUtils::dateTimeForFileItem(item, TimeUtils::SkipCache); | ||
121 | fileName = mFileNameFormater->format(src, dateTime); | 121 | fileName = mFileNameFormater->format(src, dateTime); | ||
122 | } else { | 122 | } else { | ||
123 | fileName = src.fileName(); | 123 | fileName = src.fileName(); | ||
124 | } | 124 | } | ||
125 | dst.setPath(dst.path() + '/' + fileName); | 125 | dst.setPath(dst.path() + fileName); | ||
126 | 126 | | |||
127 | FileUtils::RenameResult result = FileUtils::rename(src, dst, mAuthWindow); | 127 | FileUtils::RenameResult result = FileUtils::rename(src, dst, mAuthWindow); | ||
128 | switch (result) { | 128 | switch (result) { | ||
129 | case FileUtils::RenamedOK: | 129 | case FileUtils::RenamedOK: | ||
130 | mImportedUrlList << mCurrentUrl; | 130 | mImportedUrlList << mCurrentUrl; | ||
131 | break; | 131 | break; | ||
132 | case FileUtils::RenamedUnderNewName: | 132 | case FileUtils::RenamedUnderNewName: | ||
133 | mRenamedCount++; | 133 | mRenamedCount++; | ||
▲ Show 20 Lines • Show All 109 Lines • Show Last 20 Lines |