summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorkh <qtc-committer@nokia.com>2009-05-07 09:53:30 (GMT)
committerkh <qtc-committer@nokia.com>2009-05-07 09:53:30 (GMT)
commit4f00772e4e02433d6231f2c6c64cf7d97dccf4f9 (patch)
treead57e34450207f05a13d6a22b45188c21fa10b6f /tools
parentacd6ac49150a126a08afd864210d0627487c6d3d (diff)
downloadQt-4f00772e4e02433d6231f2c6c64cf7d97dccf4f9.zip
Qt-4f00772e4e02433d6231f2c6c64cf7d97dccf4f9.tar.gz
Qt-4f00772e4e02433d6231f2c6c64cf7d97dccf4f9.tar.bz2
Implement new cmd option to remove the full text search index.
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.cpp9
-rw-r--r--tools/assistant/tools/assistant/cmdlineparser.h2
-rw-r--r--tools/assistant/tools/assistant/main.cpp35
3 files changed, 46 insertions, 0 deletions
diff --git a/tools/assistant/tools/assistant/cmdlineparser.cpp b/tools/assistant/tools/assistant/cmdlineparser.cpp
index 0dae785..67eaa44 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.cpp
+++ b/tools/assistant/tools/assistant/cmdlineparser.cpp
@@ -56,6 +56,7 @@ CmdLineParser::CmdLineParser()
m_bookmarks(Untouched),
m_search(Untouched),
m_register(None),
+ m_removeSearchIndex(false),
m_copy(false),
m_quiet(false)
{
@@ -83,6 +84,7 @@ CmdLineParser::CmdLineParser()
" (.qch) from the give collection\n"
" file.\n"
"-setCurrentFilter filter Set the filter as the active filter.\n"
+ "-remove-search-index Removes the full text search index.\n"
"-quiet Does not display any error or\n"
" status message.\n"
"-help Displays this help.\n"
@@ -217,6 +219,8 @@ CmdLineParser::Result CmdLineParser::parse(const QStringList &arguments)
error = QObject::tr("Missing filter argument!");
break;
}
+ } else if (arg == QLatin1String("-remove-search-index")) {
+ m_removeSearchIndex = true;
} else if (arg == QLatin1String("-quiet")) {
continue;
} else if (arg == QLatin1String("-help")) {
@@ -307,6 +311,11 @@ QString CmdLineParser::currentFilter() const
return m_currentFilter;
}
+bool CmdLineParser::removeSearchIndex() const
+{
+ return m_removeSearchIndex;
+}
+
CmdLineParser::RegisterState CmdLineParser::registerRequest() const
{
return m_register;
diff --git a/tools/assistant/tools/assistant/cmdlineparser.h b/tools/assistant/tools/assistant/cmdlineparser.h
index 332d464..263138b 100644
--- a/tools/assistant/tools/assistant/cmdlineparser.h
+++ b/tools/assistant/tools/assistant/cmdlineparser.h
@@ -67,6 +67,7 @@ public:
ShowState bookmarks() const;
ShowState search() const;
QString currentFilter() const;
+ bool removeSearchIndex() const;
RegisterState registerRequest() const;
QString helpFile() const;
@@ -90,6 +91,7 @@ private:
ShowState m_search;
RegisterState m_register;
QString m_currentFilter;
+ bool m_removeSearchIndex;
bool m_copy;
bool m_quiet;
};
diff --git a/tools/assistant/tools/assistant/main.cpp b/tools/assistant/tools/assistant/main.cpp
index 794be02..75955ec 100644
--- a/tools/assistant/tools/assistant/main.cpp
+++ b/tools/assistant/tools/assistant/main.cpp
@@ -52,6 +52,8 @@
#include <QtHelp/QHelpEngineCore>
+#include <QtNetwork/QLocalSocket>
+
#include <QtSql/QSqlDatabase>
#include "mainwindow.h"
@@ -166,6 +168,17 @@ referencedHelpFilesExistAll(QHelpEngineCore& user, QStringList& nameSpaces)
return (counter != nameSpaces.count()) ? false : true;
}
+QString indexFilesFolder(const QString &collectionFile)
+{
+ QString indexFilesFolder = QLatin1String(".fulltextsearch");
+ if (!collectionFile.isEmpty()) {
+ QFileInfo fi(collectionFile);
+ indexFilesFolder = QLatin1Char('.') +
+ fi.fileName().left(fi.fileName().lastIndexOf(QLatin1String(".qhc")));
+ }
+ return indexFilesFolder;
+}
+
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
@@ -212,6 +225,28 @@ int main(int argc, char *argv[])
return 0;
}
+ if (cmd.removeSearchIndex()) {
+ QString file = cmdCollectionFile;
+ if (file.isEmpty())
+ file = MainWindow::defaultHelpCollectionFileName();
+ QString path = QFileInfo(file).path();
+ path += QLatin1String("/") + indexFilesFolder(file);
+
+ QLocalSocket localSocket;
+ localSocket.connectToServer(QString(QLatin1String("QtAssistant%1"))
+ .arg(QLatin1String(QT_VERSION_STR)));
+
+ QDir dir(path); // check if there is no other instance ruinning
+ if (!localSocket.waitForConnected() && dir.exists()) {
+ QStringList lst = dir.entryList(QDir::Files | QDir::Hidden);
+ foreach (const QString &item, lst)
+ dir.remove(item);
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
{
QSqlDatabase db;
QStringList sqlDrivers(db.drivers());