summaryrefslogtreecommitdiffstats
path: root/kwordquiz/src/kwqnewstuff.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce599e4f9f94b4eb00c1b5edb85bce5431ab3df2 (patch)
treed3bb9f5d25a2dc09ca81adecf39621d871534297 /kwordquiz/src/kwqnewstuff.cpp
downloadtdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.tar.gz
tdeedu-ce599e4f9f94b4eb00c1b5edb85bce5431ab3df2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeedu@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kwordquiz/src/kwqnewstuff.cpp')
-rw-r--r--kwordquiz/src/kwqnewstuff.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/kwordquiz/src/kwqnewstuff.cpp b/kwordquiz/src/kwqnewstuff.cpp
new file mode 100644
index 00000000..cc8310a7
--- /dev/null
+++ b/kwordquiz/src/kwqnewstuff.cpp
@@ -0,0 +1,96 @@
+/***************************************************************************
+ Implementation of KNewStuff
+ -------------------
+ begin : Thu Jun 02 13:12:30 PDT 2002
+ copyright : (C) 2005 by Peter Hedlund
+ email : peter.hedlund@kdemail.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include <qdir.h>
+
+#include <kprocess.h>
+#include <klocale.h>
+#include <kstandarddirs.h>
+#include <kmessagebox.h>
+#include <knewstuff/entry.h>
+
+#include "kwordquiz.h"
+#include "kwqnewstuff.h"
+#include "prefs.h"
+
+KWQNewStuff::KWQNewStuff(QWidget *parent, const char *name) : QObject(), KNewStuff("kdeedu/vocabulary", parent)
+{
+ m_app = (KWordQuizApp *) parent;
+}
+
+
+bool KWQNewStuff::install(const QString & fileName)
+{
+ m_app->slotFileOpenRecent(KURL(fileName));
+ return true;
+}
+
+
+bool KWQNewStuff::createUploadFile(const QString & fileName)
+{
+ return true;
+}
+
+
+QString KWQNewStuff::destinationPath(KNS::Entry * entry)
+{
+ if (entry)
+ {
+ KURL url = entry->payload();
+ QString fileName = url.fileName();
+
+ QString path = Prefs::installPath(); //default is Vocabularies which will be created in the user's home directory
+ QString file;
+
+ if (path.isEmpty())
+ file = KNewStuff::downloadDestination(entry); //fall back on a temp file, should never happen
+ else
+ {
+ file = QDir::home().path() + "/" + path + "/";
+ KStandardDirs::makeDir(file); //ensure the directory exists
+ file += fileName;
+ }
+ return file;
+ }
+ else
+ return QString::null;
+}
+
+
+QString KWQNewStuff::downloadDestination(KNS::Entry * entry)
+{
+ QString file = destinationPath(entry);
+
+ if (KStandardDirs::exists(file))
+ {
+ int result = KMessageBox::questionYesNo(parentWidget(),
+ i18n("The file '%1' already exists. Do you want to overwrite it?")
+ .arg(file),
+ QString::null,
+ i18n("Overwrite"),i18n("Do Not Overwrite"));
+ if (result == KMessageBox::No)
+ return QString::null;
+ }
+ KMessageBox::information(parentWidget(),
+ i18n("<qt>The selected file will now be downloaded and saved as\n<b>'%1'</b>.</qt>")
+ .arg(file),
+ QString::null,
+ "NewStuffDownloadLocation");
+ return file;
+}
+
+#include "kwqnewstuff.moc"