summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-05-07 16:43:12 (GMT)
committerThiago Macieira <thiago.macieira@nokia.com>2009-05-07 16:43:12 (GMT)
commit6c067866db65f113237a4c28374317c948da8ba9 (patch)
treec8920e1ecbd4c6875691f52d5579e7264fb4af0d /tools
parent61bec93c12bdc2912b38264386af07f80c3c0272 (diff)
parent90a65aa6611eb33229cdc00ffe6c22012944ba1a (diff)
downloadQt-6c067866db65f113237a4c28374317c948da8ba9.zip
Qt-6c067866db65f113237a4c28374317c948da8ba9.tar.gz
Qt-6c067866db65f113237a4c28374317c948da8ba9.tar.bz2
Merge branch '4.5'
Conflicts: src/gui/painting/qbackingstore.cpp src/gui/painting/qwindowsurface_raster.cpp
Diffstat (limited to 'tools')
-rw-r--r--tools/assistant/tools/assistant/centralwidget.cpp2
-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
-rw-r--r--tools/assistant/tools/assistant/preferencesdialog.cpp175
5 files changed, 163 insertions, 60 deletions
diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp
index ec54d0c..b78f346 100644
--- a/tools/assistant/tools/assistant/centralwidget.cpp
+++ b/tools/assistant/tools/assistant/centralwidget.cpp
@@ -810,7 +810,7 @@ bool CentralWidget::eventFilter(QObject *object, QEvent *e)
}
}
- if (QTabBar *tabBar = qobject_cast<QTabBar*>(object)) {
+ if (qobject_cast<QTabBar*>(object)) {
const bool dblClick = e->type() == QEvent::MouseButtonDblClick;
if ((e->type() == QEvent::MouseButtonRelease) || dblClick) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(e);
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());
diff --git a/tools/assistant/tools/assistant/preferencesdialog.cpp b/tools/assistant/tools/assistant/preferencesdialog.cpp
index 094bd9c..74f7ba8 100644
--- a/tools/assistant/tools/assistant/preferencesdialog.cpp
+++ b/tools/assistant/tools/assistant/preferencesdialog.cpp
@@ -44,6 +44,7 @@
#include "installdialog.h"
#include "fontpanel.h"
#include "centralwidget.h"
+#include "aboutdialog.h"
#include <QtAlgorithms>
@@ -52,6 +53,8 @@
#include <QtGui/QMessageBox>
#include <QtGui/QMenu>
#include <QtGui/QFontDatabase>
+#include <QtGui/QApplication>
+#include <QtGui/QDesktopWidget>
#include <QtHelp/QHelpEngineCore>
@@ -59,36 +62,38 @@ QT_BEGIN_NAMESPACE
PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *parent)
: QDialog(parent)
+ , m_helpEngine(helpEngine)
, m_appFontChanged(false)
, m_browserFontChanged(false)
{
- m_helpEngine = helpEngine;
m_ui.setupUi(this);
- connect(m_ui.buttonBox->button(QDialogButtonBox::Ok),
- SIGNAL(clicked()), this, SLOT(applyChanges()));
- connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel),
- SIGNAL(clicked()), this, SLOT(reject()));
+ connect(m_ui.buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()),
+ this, SLOT(applyChanges()));
+ connect(m_ui.buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()),
+ this, SLOT(reject()));
- m_hideFiltersTab = !m_helpEngine->customValue(QLatin1String("EnableFilterFunctionality"),
- true).toBool();
- m_hideDocsTab = !m_helpEngine->customValue(QLatin1String("EnableDocumentationManager"),
- true).toBool();
+ QLatin1String key("EnableFilterFunctionality");
+ m_hideFiltersTab = !m_helpEngine->customValue(key, true).toBool();
+
+ key = QLatin1String("EnableDocumentationManager");
+ m_hideDocsTab = !m_helpEngine->customValue(key, true).toBool();
if (!m_hideFiltersTab) {
m_ui.attributeWidget->header()->hide();
m_ui.attributeWidget->setRootIsDecorated(false);
+
connect(m_ui.attributeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
this, SLOT(updateFilterMap()));
connect(m_ui.filterWidget,
- SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
- this, SLOT(updateAttributes(QListWidgetItem*)));
+ SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this,
+ SLOT(updateAttributes(QListWidgetItem*)));
- connect(m_ui.filterAddButton, SIGNAL(clicked()),
- this, SLOT(addFilter()));
- connect(m_ui.filterRemoveButton, SIGNAL(clicked()),
- this, SLOT(removeFilter()));
+ connect(m_ui.filterAddButton, SIGNAL(clicked()), this,
+ SLOT(addFilter()));
+ connect(m_ui.filterRemoveButton, SIGNAL(clicked()), this,
+ SLOT(removeFilter()));
updateFilterPage();
} else {
@@ -106,22 +111,34 @@ PreferencesDialog::PreferencesDialog(QHelpEngineCore *helpEngine, QWidget *paren
} else {
m_ui.tabWidget->removeTab(m_ui.tabWidget->indexOf(m_ui.docsTab));
}
+
updateFontSettingsPage();
updateOptionsPage();
}
PreferencesDialog::~PreferencesDialog()
{
+ QLatin1String key("");
if (m_appFontChanged) {
- m_helpEngine->setCustomValue(QLatin1String("appFont"), m_appFontPanel->selectedFont());
- m_helpEngine->setCustomValue(QLatin1String("useAppFont"), m_appFontPanel->isChecked());
- m_helpEngine->setCustomValue(QLatin1String("appWritingSystem"), m_appFontPanel->writingSystem());
+ key = QLatin1String("appFont");
+ m_helpEngine->setCustomValue(key, m_appFontPanel->selectedFont());
+
+ key = QLatin1String("useAppFont");
+ m_helpEngine->setCustomValue(key, m_appFontPanel->isChecked());
+
+ key = QLatin1String("appWritingSystem");
+ m_helpEngine->setCustomValue(key, m_appFontPanel->writingSystem());
}
if (m_browserFontChanged) {
- m_helpEngine->setCustomValue(QLatin1String("browserFont"), m_browserFontPanel->selectedFont());
- m_helpEngine->setCustomValue(QLatin1String("useBrowserFont"), m_browserFontPanel->isChecked());
- m_helpEngine->setCustomValue(QLatin1String("browserWritingSystem"), m_browserFontPanel->writingSystem());
+ key = QLatin1String("browserFont");
+ m_helpEngine->setCustomValue(key, m_browserFontPanel->selectedFont());
+
+ key = QLatin1String("useBrowserFont");
+ m_helpEngine->setCustomValue(key, m_browserFontPanel->isChecked());
+
+ key = QLatin1String("browserWritingSystem");
+ m_helpEngine->setCustomValue(key, m_browserFontPanel->writingSystem());
}
if (m_appFontChanged || m_browserFontChanged) {
@@ -129,8 +146,10 @@ PreferencesDialog::~PreferencesDialog()
emit updateBrowserFont();
}
- if (!m_ui.homePageLineEdit->text().isEmpty())
- m_helpEngine->setCustomValue(QLatin1String("homepage"), m_ui.homePageLineEdit->text());
+ if (!m_ui.homePageLineEdit->text().isEmpty()) {
+ key = QLatin1String("homepage");
+ m_helpEngine->setCustomValue(key, m_ui.homePageLineEdit->text());
+ }
}
void PreferencesDialog::showDialog()
@@ -173,7 +192,7 @@ void PreferencesDialog::updateAttributes(QListWidgetItem *item)
if (item)
checkedList = m_filterMap.value(item->text());
QTreeWidgetItem *itm;
- for (int i=0; i<m_ui.attributeWidget->topLevelItemCount(); ++i) {
+ for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) {
itm = m_ui.attributeWidget->topLevelItem(i);
if (checkedList.contains(itm->text(0)))
itm->setCheckState(0, Qt::Checked);
@@ -192,7 +211,7 @@ void PreferencesDialog::updateFilterMap()
QStringList newAtts;
QTreeWidgetItem *itm = 0;
- for (int i=0; i<m_ui.attributeWidget->topLevelItemCount(); ++i) {
+ for (int i = 0; i < m_ui.attributeWidget->topLevelItemCount(); ++i) {
itm = m_ui.attributeWidget->topLevelItem(i);
if (itm->checkState(0) == Qt::Checked)
newAtts.append(itm->text(0));
@@ -219,8 +238,8 @@ void PreferencesDialog::addFilter()
void PreferencesDialog::removeFilter()
{
- QListWidgetItem *item = m_ui.filterWidget
- ->takeItem(m_ui.filterWidget->currentRow());
+ QListWidgetItem *item =
+ m_ui.filterWidget ->takeItem(m_ui.filterWidget->currentRow());
if (!item)
return;
@@ -238,25 +257,48 @@ void PreferencesDialog::addDocumentationLocal()
if (fileNames.isEmpty())
return;
+ QStringList invalidFiles;
+ QStringList alreadyRegistered;
foreach (const QString &fileName, fileNames) {
- const QString ns = QHelpEngineCore::namespaceName(fileName);
- if (ns.isEmpty()) {
- QMessageBox::warning(this, tr("Add Documentation"),
- tr("The specified file is not a valid Qt Help File!"));
+ const QString nameSpace = QHelpEngineCore::namespaceName(fileName);
+ if (nameSpace.isEmpty()) {
+ invalidFiles.append(fileName);
continue;
}
- if (m_ui.registeredDocsListWidget->findItems(ns, Qt::MatchFixedString).count()) {
- QMessageBox::warning(this, tr("Add Documentation"),
- tr("The namespace %1 is already registered!").arg(ns));
- continue;
+ if (m_ui.registeredDocsListWidget->findItems(nameSpace,
+ Qt::MatchFixedString).count()) {
+ alreadyRegistered.append(nameSpace);
+ continue;
}
m_helpEngine->registerDocumentation(fileName);
- m_ui.registeredDocsListWidget->addItem(ns);
- m_regDocs.append(ns);
- m_unregDocs.removeAll(ns);
+ m_ui.registeredDocsListWidget->addItem(nameSpace);
+ m_regDocs.append(nameSpace);
+ m_unregDocs.removeAll(nameSpace);
+ }
+
+ if (!invalidFiles.isEmpty() || !alreadyRegistered.isEmpty()) {
+ QString message;
+ if (!alreadyRegistered.isEmpty()) {
+ foreach (const QString &ns, alreadyRegistered) {
+ message += tr("The namespace %1 is already registered!")
+ .arg(QString("<b>%1</b>").arg(ns)) + QLatin1String("<br>");
+ }
+ if (!invalidFiles.isEmpty())
+ message.append(QLatin1String("<br>"));
+ }
+
+ if (!invalidFiles.isEmpty()) {
+ message += tr("The specified file is not a valid Qt Help File!");
+ message.append(QLatin1String("<ul>"));
+ foreach (const QString &file, invalidFiles)
+ message += QLatin1String("<li>") + file + QLatin1String("</li>");
+ message.append(QLatin1String("</ul>"));
+ }
+ QMessageBox::warning(this, tr("Add Documentation"), message);
}
+
updateFilterPage();
}
@@ -362,35 +404,50 @@ void PreferencesDialog::updateFontSettingsPage()
m_ui.stackedWidget_2->setCurrentIndex(0);
const QString customSettings(tr("Use custom settings"));
- QFont font = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("appFont")));
- QFontDatabase::WritingSystem writingSystem = static_cast<QFontDatabase::WritingSystem>
- (m_helpEngine->customValue(QLatin1String("appWritingSystem")).toInt());
-
m_appFontPanel->setTitle(customSettings);
+
+ QLatin1String key = QLatin1String("appFont");
+ QFont font = qVariantValue<QFont>(m_helpEngine->customValue(key));
m_appFontPanel->setSelectedFont(font);
- m_appFontPanel->setWritingSystem(writingSystem);
- m_appFontPanel->setChecked(m_helpEngine->customValue(QLatin1String("useAppFont")).toBool());
- QFont font2 = qVariantValue<QFont>(m_helpEngine->customValue(QLatin1String("browserFont")));
- writingSystem = static_cast<QFontDatabase::WritingSystem>
- (m_helpEngine->customValue(QLatin1String("browserWritingSystem")).toInt());
+ key = QLatin1String("appWritingSystem");
+ QFontDatabase::WritingSystem system = static_cast<QFontDatabase::WritingSystem>
+ (m_helpEngine->customValue(key).toInt());
+ m_appFontPanel->setWritingSystem(system);
+
+ key = QLatin1String("useAppFont");
+ m_appFontPanel->setChecked(m_helpEngine->customValue(key).toBool());
m_browserFontPanel->setTitle(customSettings);
- m_browserFontPanel->setSelectedFont(font2);
- m_browserFontPanel->setWritingSystem(writingSystem);
- m_browserFontPanel->setChecked(m_helpEngine->customValue(QLatin1String("useBrowserFont")).toBool());
- connect(m_appFontPanel, SIGNAL(toggled(bool)), this, SLOT(appFontSettingToggled(bool)));
- connect(m_browserFontPanel, SIGNAL(toggled(bool)), this, SLOT(browserFontSettingToggled(bool)));
+ key = QLatin1String("browserFont");
+ font = qVariantValue<QFont>(m_helpEngine->customValue(key));
+ m_browserFontPanel->setSelectedFont(font);
+
+ key = QLatin1String("browserWritingSystem");
+ system = static_cast<QFontDatabase::WritingSystem>
+ (m_helpEngine->customValue(key).toInt());
+ m_browserFontPanel->setWritingSystem(system);
+
+ key = QLatin1String("useBrowserFont");
+ m_browserFontPanel->setChecked(m_helpEngine->customValue(key).toBool());
+
+ connect(m_appFontPanel, SIGNAL(toggled(bool)), this,
+ SLOT(appFontSettingToggled(bool)));
+ connect(m_browserFontPanel, SIGNAL(toggled(bool)), this,
+ SLOT(browserFontSettingToggled(bool)));
QList<QComboBox*> allCombos = qFindChildren<QComboBox*>(m_appFontPanel);
- foreach (QComboBox* box, allCombos)
- connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(appFontSettingChanged(int)));
+ foreach (QComboBox* box, allCombos) {
+ connect(box, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(appFontSettingChanged(int)));
+ }
- allCombos.clear();
allCombos = qFindChildren<QComboBox*>(m_browserFontPanel);
- foreach (QComboBox* box, allCombos)
- connect(box, SIGNAL(currentIndexChanged(int)), this, SLOT(browserFontSettingChanged(int)));
+ foreach (QComboBox* box, allCombos) {
+ connect(box, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(browserFontSettingChanged(int)));
+ }
}
void PreferencesDialog::appFontSettingToggled(bool on)
@@ -436,8 +493,8 @@ void PreferencesDialog::updateOptionsPage()
void PreferencesDialog::restoreDefaultHomepage()
{
- QString homepage = m_helpEngine->customValue(
- QLatin1String("defaultHomepage"), QLatin1String("help")).toString();
+ QString homepage = m_helpEngine->customValue(QLatin1String("defaultHomepage"),
+ QLatin1String("help")).toString();
m_ui.homePageLineEdit->setText(homepage);
}