2
* Copyright (C) 2007 Ivan Cukic <ivan.cukic(at)kde.org>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2,
6
* or (at your option) any later version, as published by the Free
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details
14
* You should have received a copy of the GNU General Public
15
* License along with this program; if not, write to the
16
* Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#include "NewDocuments.h"
21
#include <KStandardDirs>
26
#define LinkOrCopy(source, destination) \
27
qDebug() << "Models::LinkOrCopy:" \
28
<< source << destination; \
29
if (!QFile::link((source), (destination))) { \
30
qDebug() << "Models::LinkOrCopy:" \
31
<< "Linking failed ... copying"; \
32
QFile::copy((source), (destination)); \
35
NewDocuments::NewDocuments()
36
: FolderModel(NewDocuments::path(), QDir::Name)
38
setSelfTitle(i18n("New:"));
39
setSelfIcon(KIcon("document-new"));
42
if (dir.entryList(QDir::Files | QDir::NoDotAndDotDot).size() == 0) {
44
QStringList applications;
46
<< "ooo-writer|writer|kword"
47
<< "ooo-impress|impress|kpresenter"
48
<< "ooo-calc|calc|kspread"
54
foreach (const QString & serviceAlternatives, applications) {
55
foreach (const QString & serviceName, serviceAlternatives.split('|')) {
56
const KService::Ptr service = KService::serviceByStorageId(serviceName);
58
QFileInfo file(service->entryPath());
61
dir.absolutePath() + '/' +
62
QString::number(index++) + '_' + file.fileName());
70
NewDocuments::~NewDocuments()
74
QString NewDocuments::path()
76
QString path = KStandardDirs::locateLocal("data", "lancelot", true);
77
if (!path.endsWith('/')) {
80
path += "/newdocuments/";