1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
//
// C++ Implementation: kvtnewstuff
//
// Description:
//
//
// Author: Peter Hedlund <peter.hedlund@kdemail.net>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <tqdir.h>
#include <kprocess.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include <kmessagebox.h>
#include <knewstuff/entry.h>
#include "kvoctrain.h"
#include "kvtnewstuff.h"
#include "prefs.h"
KVTNewStuff::KVTNewStuff(TQWidget *tqparent, const char * /*name*/) : TQObject(), KNewStuff("kdeedu/vocabulary", tqparent)
{
m_app = (kvoctrainApp*) tqparent;
}
bool KVTNewStuff::install(const TQString & fileName)
{
if (m_app->queryExit())
m_app->loadfileFromPath(fileName, true);
return true;
}
bool KVTNewStuff::createUploadFile(const TQString & /*fileName*/)
{
return true;
}
TQString KVTNewStuff::destinationPath(KNS::Entry * entry)
{
if (entry)
{
KURL url = entry->payload();
TQString fileName = url.fileName();
TQString path = Prefs::installPath(); //default is Vocabularies which will be created in the user's home directory
TQString file;
if (path.isEmpty())
file = KNewStuff::downloadDestination(entry); //fall back on a temp file, should never happen
else
{
file = TQDir::home().path() + "/" + path + "/";
KStandardDirs::makeDir(file); //ensure the directory exists
file += fileName;
}
return file;
}
else
return TQString();
}
TQString KVTNewStuff::downloadDestination(KNS::Entry * entry)
{
TQString file = destinationPath(entry);
if (KStandardDirs::exists(file))
{
int result = KMessageBox::warningContinueCancel(tqparentWidget(),
i18n("The file '%1' already exists. Do you want to overwrite it?")
.tqarg(file),
TQString(), i18n("Overwrite") );
if (result == KMessageBox::Cancel)
return TQString();
}
KMessageBox::information(tqparentWidget(),
i18n("<qt>The selected file will now be downloaded and saved as\n<b>'%1'</b>.</qt>")
.tqarg(file),
TQString(),
"NewStuffDownloadLocation");
return file;
}
#include "kvtnewstuff.moc"
|