summaryrefslogtreecommitdiffstats
path: root/kbabel/commonui
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
commitbd9e6617827818fd043452c08c606f07b78014a0 (patch)
tree425bb4c3168f9c02f10150f235d2cb998dcc6108 /kbabel/commonui
downloadtdesdk-bd9e6617827818fd043452c08c606f07b78014a0.tar.gz
tdesdk-bd9e6617827818fd043452c08c606f07b78014a0.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/kdesdk@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kbabel/commonui')
-rw-r--r--kbabel/commonui/Makefile.am40
-rw-r--r--kbabel/commonui/cmdedit.cpp298
-rw-r--r--kbabel/commonui/cmdedit.h94
-rw-r--r--kbabel/commonui/context.cpp305
-rw-r--r--kbabel/commonui/context.h123
-rw-r--r--kbabel/commonui/diffpreferences.ui141
-rw-r--r--kbabel/commonui/diffpreferences.ui.h13
-rw-r--r--kbabel/commonui/finddialog.cpp553
-rw-r--r--kbabel/commonui/finddialog.h136
-rw-r--r--kbabel/commonui/kactionselector.cpp562
-rw-r--r--kbabel/commonui/kactionselector.h410
-rw-r--r--kbabel/commonui/kbabel_tool.desktop9
-rw-r--r--kbabel/commonui/kbabel_validator.desktop56
-rw-r--r--kbabel/commonui/klisteditor.ui261
-rw-r--r--kbabel/commonui/klisteditor.ui.h122
-rw-r--r--kbabel/commonui/projectpref.cpp278
-rw-r--r--kbabel/commonui/projectpref.h93
-rw-r--r--kbabel/commonui/projectprefwidgets.cpp1209
-rw-r--r--kbabel/commonui/projectprefwidgets.h285
-rw-r--r--kbabel/commonui/projectwizard.cpp172
-rw-r--r--kbabel/commonui/projectwizard.h74
-rw-r--r--kbabel/commonui/projectwizardwidget.ui266
-rw-r--r--kbabel/commonui/projectwizardwidget.ui.h40
-rw-r--r--kbabel/commonui/projectwizardwidget2.ui157
-rw-r--r--kbabel/commonui/roughtransdlg.cpp762
-rw-r--r--kbabel/commonui/roughtransdlg.h110
-rw-r--r--kbabel/commonui/toolaction.cpp108
-rw-r--r--kbabel/commonui/toolaction.h72
-rw-r--r--kbabel/commonui/toolselectionwidget.cpp105
-rw-r--r--kbabel/commonui/toolselectionwidget.h57
30 files changed, 6911 insertions, 0 deletions
diff --git a/kbabel/commonui/Makefile.am b/kbabel/commonui/Makefile.am
new file mode 100644
index 00000000..e0ca94ce
--- /dev/null
+++ b/kbabel/commonui/Makefile.am
@@ -0,0 +1,40 @@
+## Makefile.am for libkbabelcommon
+
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+noinst_LTLIBRARIES = libkbabelcommonui.la
+
+# set the include path for X, qt and KDE. Put local paths before all_includes.
+INCLUDES = -I$(srcdir)/../common -I../common -I$(srcdir)/../kbabeldict -I../kbabeldict $(all_includes)
+
+# which sources should be compiled
+libkbabelcommonui_la_SOURCES = klisteditor.ui context.cpp kactionselector.cpp \
+ toolselectionwidget.cpp toolaction.cpp \
+ finddialog.cpp roughtransdlg.cpp \
+ projectprefwidgets.cpp \
+ projectpref.cpp \
+ projectwizard.cpp \
+ projectwizardwidget.ui \
+ projectwizardwidget2.ui \
+ cmdedit.cpp \
+ diffpreferences.ui
+
+libkbabelcommonui_la_LIBADD = $(LIB_KIO) -lktexteditor ../common/libkbabelcommon.la ../kbabeldict/libkbabeldict.la
+
+libkbabelcommonui_la_LDFLAGS = $(all_libraries)
+
+# these are the headers for your project
+noinst_HEADERS = context.h kactionselector.h finddialog.h \
+ roughtransdlg.h projectprefwidgets.h projectpref.h \
+ cmdedit.h projectwizard.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+# we need to define our own service type for our plugins. It's data tool with a shortcut :-((
+kde_servicetypes_DATA = kbabel_validator.desktop kbabel_tool.desktop
+EXTRA_DIST = $(kde_servicetypes_DATA)
+
+context.lo: ../common/kbprojectsettings.h
+projectpref.lo: ../common/kbprojectsettings.h
+projectprefwidgets.lo: ../common/kbprojectsettings.h
diff --git a/kbabel/commonui/cmdedit.cpp b/kbabel/commonui/cmdedit.cpp
new file mode 100644
index 00000000..bfe95293
--- /dev/null
+++ b/kbabel/commonui/cmdedit.cpp
@@ -0,0 +1,298 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "cmdedit.h"
+
+#include <qlistbox.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qtoolbutton.h>
+#include <klocale.h>
+#include <kdialog.h>
+
+
+CmdEdit::CmdEdit(QWidget* parent, const char* name)
+ : QWidget(parent,name)
+{
+ QGridLayout* layout = new QGridLayout( this , 1 , 1 );
+ layout->setSpacing( KDialog::spacingHint() );
+
+ QLabel* nameLabel = new QLabel( i18n("Command &Label:"), this);
+ QLabel* cmdLabel = new QLabel( i18n("Co&mmand:"), this);
+ layout->addWidget( nameLabel, 0 , 0 );
+ layout->addWidget( cmdLabel, 0 , 1 );
+
+ _cmdNameEdit = new QLineEdit( this , "cmdNameEdit" );
+ _cmdNameEdit->setMaxLength(20);
+ nameLabel->setBuddy(_cmdNameEdit);
+ layout->addWidget( _cmdNameEdit , 1 , 0 );
+
+ _cmdEdit = new QLineEdit( this , "cmdEdit" );
+ cmdLabel->setBuddy(_cmdEdit);
+ layout->addWidget( _cmdEdit , 1 , 1 );
+
+
+ _addButton = new QPushButton( i18n("&Add"), this );
+ _addButton->setEnabled(false);
+ layout->addWidget( _addButton , 1 , 2 );
+
+ _editButton = new QPushButton( i18n("&Edit"), this );
+ _editButton->setEnabled(false);
+ layout->addWidget( _editButton , 3 , 2 );
+
+ _removeButton = new QPushButton( i18n("&Remove"), this );
+ _removeButton->setEnabled(false);
+ layout->addWidget( _removeButton , 4 , 2 );
+
+ QHBoxLayout* hbox = new QHBoxLayout();
+ layout->addLayout(hbox,5,2);
+
+ _upButton = new QToolButton(UpArrow,this);
+ _upButton->setFixedSize(20,20);
+ _upButton->setEnabled(false);
+ hbox->addWidget( _upButton );
+
+ _downButton = new QToolButton(DownArrow,this);
+ _downButton->setFixedSize(20,20);
+ _downButton->setEnabled(false);
+ hbox->addWidget( _downButton);
+
+ _commandNames = new QListBox( this , "commandNamesBox" );
+ _commandNames->setMinimumSize(100, 100);
+ layout->addMultiCellWidget( _commandNames , 3 , 6 , 0 , 0);
+
+ _commands = new QListBox( this , "commandsBox" );
+ _commands->setMinimumSize(160, 100);
+ layout->addMultiCellWidget( _commands , 3 , 6 , 1 ,1 );
+
+
+ layout->setColStretch(0,1);
+ layout->setColStretch(1,2);
+ layout->setColStretch(2,0);
+
+ layout->addRowSpacing(2, KDialog::spacingHint());
+ layout->addRowSpacing(6, KDialog::spacingHint());
+
+ setMinimumSize(layout->sizeHint());
+
+
+ connect(_addButton , SIGNAL(clicked()) , this , SLOT(addCmd()) ) ;
+ connect(_editButton , SIGNAL(clicked()) , this , SLOT(editCmd()) );
+ connect(_removeButton , SIGNAL(clicked()) , this , SLOT(removeCmd()) );
+ connect(_upButton , SIGNAL(clicked()) , this , SLOT(upCmd()) ) ;
+ connect(_downButton , SIGNAL(clicked()) , this , SLOT(downCmd()) );
+
+ connect(_commands , SIGNAL(highlighted(int)) , this, SLOT(cmdHighlighted(int)) );
+ connect(_commandNames , SIGNAL(highlighted(int)) , this, SLOT(cmdNameHighlighted(int)) );
+ connect(_commands , SIGNAL(selected(int)) , this, SLOT(editCmd()) );
+ connect(_commandNames , SIGNAL(selected(int)) , this, SLOT(editCmd()) );
+
+ connect(_cmdEdit, SIGNAL(textChanged(const QString&)) , this , SLOT(checkAdd()) );
+ connect(_cmdNameEdit, SIGNAL(textChanged(const QString&)) , this , SLOT(checkAdd()) );
+}
+
+void CmdEdit::setCommands(const QStringList& commands,const QStringList& commandNames)
+{
+ _commands->clear();
+ _commands->insertStringList(commands);
+
+ _commandNames->clear();
+ _commandNames->insertStringList(commandNames);
+}
+
+void CmdEdit::commands(QStringList& commands, QStringList& commandNames)
+{
+ commands.clear();
+ commandNames.clear();
+
+ int items=_commands->count();
+
+ int i=0;
+ for( i=0 ; i< items ; i++)
+ {
+ commands.append( _commands->text(i) );
+ commandNames.append( _commandNames->text(i) );
+ }
+}
+
+void CmdEdit::addCmd()
+{
+ QString cmd = _cmdEdit->text();
+ QString cmdName = _cmdNameEdit->text();
+ _cmdEdit->clear();
+ _cmdNameEdit->clear();
+
+ if(_commands->currentText() == cmd || _commandNames->currentText() == cmdName)
+ {
+ int current = _commands->currentItem();
+ _commands->changeItem(cmd,current);
+ _commandNames->changeItem(cmdName,current);
+ }
+ else
+ {
+ _commands->insertItem(cmd);
+ _commandNames->insertItem(cmdName);
+ }
+
+ emit widgetChanged();
+}
+
+void CmdEdit::removeCmd()
+{
+ int current=_commands->currentItem();
+
+ _commands->removeItem(current);
+ _commandNames->removeItem(current);
+
+ if(_commands->count() == 0)
+ {
+ _removeButton->setEnabled(false);
+ _editButton->setEnabled(false);
+ _upButton->setEnabled(false);
+ _downButton->setEnabled(false);
+ }
+ else
+ {
+ if(current > (int)_commands->count()-1)
+ current=_commands->count()-1;
+
+ _commands->setSelected(current,true);
+ _commandNames->setSelected(current,true);
+ cmdHighlighted(current);
+ }
+
+ emit widgetChanged();
+}
+
+void CmdEdit::upCmd()
+{
+ QString cmd = _commands->currentText();
+ QString cmdName = _commandNames->currentText();
+ int index=_commands->currentItem();
+
+ _commands->removeItem(index);
+ _commandNames->removeItem(index);
+
+ _commands->insertItem(cmd , index-1);
+ _commandNames->insertItem(cmdName , index-1);
+
+ _commands->clearSelection();
+ _commandNames->clearSelection();
+
+ _commands->setSelected(index-1,true);
+ _commandNames->setSelected(index-1,true);
+
+ cmdHighlighted(index-1);
+
+ emit widgetChanged();
+}
+
+void CmdEdit::downCmd()
+{
+ QString cmd = _commands->currentText();
+ QString cmdName = _commandNames->currentText();
+ int index=_commands->currentItem();
+
+ _commands->removeItem(index);
+ _commandNames->removeItem(index);
+
+ _commands->insertItem(cmd , index+1);
+ _commandNames->insertItem(cmdName , index+1);
+
+ _commands->clearSelection();
+ _commandNames->clearSelection();
+
+ _commands->setSelected(index+1,true);
+ _commandNames->setSelected(index+1,true);
+
+ cmdHighlighted(index+1);
+
+ emit widgetChanged();
+}
+
+void CmdEdit::cmdHighlighted(int index)
+{
+ _commandNames->blockSignals(true);
+ _commandNames->setCurrentItem(index);
+ _commandNames->blockSignals(false);
+
+ _removeButton->setEnabled(true);
+ _editButton->setEnabled(true);
+
+ if(index == (int)(_commands->count()-1))
+ _downButton->setEnabled(false);
+ else
+ _downButton->setEnabled(true);
+
+ if(index==0)
+ _upButton->setEnabled(false);
+ else
+ _upButton->setEnabled(true);
+
+}
+
+void CmdEdit::cmdNameHighlighted(int index)
+{
+ _commands->blockSignals(true);
+ _commands->setCurrentItem(index);
+ _commands->blockSignals(false);
+
+ _removeButton->setEnabled(true);
+ _editButton->setEnabled(true);
+
+ if(index == (int)(_commands->count()-1))
+ _downButton->setEnabled(false);
+ else
+ _downButton->setEnabled(true);
+
+ if(index==0)
+ _upButton->setEnabled(false);
+ else
+ _upButton->setEnabled(true);
+}
+
+void CmdEdit::editCmd()
+{
+ _cmdEdit->setText(_commands->currentText());
+ _cmdNameEdit->setText(_commandNames->currentText());
+
+ emit widgetChanged();
+}
+
+void CmdEdit::checkAdd()
+{
+ _addButton->setEnabled( !(_cmdEdit->text().isEmpty() || _cmdNameEdit->text().isEmpty()) );
+}
+
+#include "cmdedit.moc"
diff --git a/kbabel/commonui/cmdedit.h b/kbabel/commonui/cmdedit.h
new file mode 100644
index 00000000..dc61679b
--- /dev/null
+++ b/kbabel/commonui/cmdedit.h
@@ -0,0 +1,94 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef CMDEDIT_H
+#define CMDEDIT_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <qwidget.h>
+#include <qstringlist.h>
+
+class QListBox;
+class QLineEdit;
+class QPushButton;
+class QToolButton;
+
+class CmdEdit : public QWidget
+{
+ Q_OBJECT
+public:
+ CmdEdit(QWidget* parent=0,const char* name=0);
+
+ void setCommands(const QStringList& commands,const QStringList& commandNames);
+ void commands(QStringList& commands, QStringList& commandNames);
+
+signals:
+ void widgetChanged();
+
+private slots:
+ /**
+ * reads command and commandName from the line edits and
+ * inserts them at the end of the listbox
+ */
+ void addCmd();
+ /**
+ * removes the currently selected command and commandName from the listbox
+ */
+ void removeCmd();
+
+ void upCmd();
+ void downCmd();
+
+ void editCmd();
+ void cmdHighlighted(int index);
+ void cmdNameHighlighted(int index);
+
+ void checkAdd();
+
+private:
+ QListBox* _commands;
+ QListBox* _commandNames;
+
+ QLineEdit* _cmdEdit;
+ QLineEdit* _cmdNameEdit;
+
+ QPushButton* _addButton;
+ QPushButton* _editButton;
+ QPushButton* _removeButton;
+ QToolButton* _upButton;
+ QToolButton* _downButton;
+};
+
+#endif // CMDEDIT_H
diff --git a/kbabel/commonui/context.cpp b/kbabel/commonui/context.cpp
new file mode 100644
index 00000000..db468795
--- /dev/null
+++ b/kbabel/commonui/context.cpp
@@ -0,0 +1,305 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2002-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "context.h"
+#include "klisteditor.h"
+#include "kbprojectsettings.h"
+
+#include <qcombobox.h>
+#include <qfileinfo.h>
+#include <qframe.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistbox.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+#include <qvgroupbox.h>
+
+#include <kconfig.h>
+#include <kdebug.h>
+#include <kdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kurl.h>
+#include <kdeversion.h>
+#include <kio/netaccess.h>
+
+#include <klibloader.h>
+#include <ktrader.h>
+#include <ktexteditor/document.h>
+#include <ktexteditor/editinterface.h>
+#include <ktexteditor/selectioninterface.h>
+#include <ktexteditor/viewcursorinterface.h>
+
+SourceContext::SourceContext(QWidget *parent, KBabel::Project::Ptr project): QWidget(parent)
+ , m_parent( parent )
+ , _part(0)
+ , _view(0)
+ , _referenceCombo(0)
+ , _layout(0)
+ , _project(project)
+{
+ _referenceList.clear();
+ _referenceCombo = new QComboBox( this );
+ connect( _referenceCombo, SIGNAL(activated(int)), this, SLOT(updateToSelected(int)));
+
+ _layout= new QVBoxLayout(this);
+ _layout->addWidget(_referenceCombo);
+}
+
+void SourceContext::setContext( const QString& packageDir, const QString& packageName, const QString& gettextComment, const KURL& urlPoFile )
+{
+ if( !_part && !loadPart() ) return;
+ _referenceCombo->clear();
+ _referenceList = resolvePath( packageDir, packageName, gettextComment, urlPoFile );
+
+ for( QValueList<ContextInfo>::const_iterator it = _referenceList.constBegin(); it != _referenceList.constEnd(); ++it )
+ _referenceCombo->insertItem((*it).path);
+
+ _referenceCombo->setEnabled( !_referenceList.isEmpty() );
+ if( _referenceList.isEmpty() )
+ {
+ _part->setReadWrite( true );
+ // We have to simulate a new document (like with File/New) by using openStream and closeStream
+ _part->openStream("text/plain","kbabel:error"); // KBabel does not show the URL kbabel:error
+ _part->closeStream();
+ (dynamic_cast<KTextEditor::EditInterface *>(_part))->setText(i18n("Corresponding source file not found"));
+ _part->setReadWrite(false);
+ _part->setModified(false);
+ }
+ else
+ {
+ _referenceCombo->setCurrentItem(0);
+ updateToSelected(0);
+ }
+}
+
+void SourceContext::updateToSelected(int index)
+{
+ if( !_part ) return;
+ ContextInfo ci = *(_referenceList.at(index));
+ KURL newUrl( KURL::fromPathOrURL( ci.path ) );
+ if( _part->url() != newUrl )
+ {
+ _part->setReadWrite( true );
+ _part->openURL( newUrl );
+ }
+ _part->setReadWrite( false );
+ (dynamic_cast<KTextEditor::ViewCursorInterface *>(_view))->setCursorPosition(ci.line,0);
+ (dynamic_cast<KTextEditor::SelectionInterface *>(_part))->setSelection(ci.line-1,0,ci.line,0);
+}
+
+QValueList<ContextInfo> SourceContext::resolvePath( const QString& packageDir, const QString& packageName, const QString& gettextComment, const KURL& urlPoFile )
+{
+ //kdDebug() << "GETTEXTCOMMENT:" << gettextComment << endl;
+
+ // Find the directory name of the PO file, if the PO file is local
+ // ### TODO: find a way to allow remote files too
+ QString poDir;
+#if KDE_IS_VERSION( 3, 5, 0 )
+ const KURL localUrl( KIO::NetAccess::mostLocalURL( urlPoFile, m_parent ) );
+ if ( localUrl.isLocalFile() )
+ {
+ const QFileInfo fi( localUrl.path() );
+ poDir = fi.dirPath( true );
+ }
+#else
+ if ( urlPoFile.isLocalFile() )
+ {
+ const QFileInfo fi( urlPoFile.path() );
+ poDir = fi.dirPath( true );
+ }
+#endif
+
+#if 0
+ kdDebug() << "CONTEXT VARIABLE START" << endl;
+ kdDebug() << "@CODEROOT@: " << _project->settings()->codeRoot() << endl;
+ kdDebug() << "@PACKAGEDIR@: " << packageDir << endl;
+ kdDebug() << "@PACKAGE@: " << packageName << endl;
+ kdDebug() << "@POFILEDIR@: " << poDir << endl;
+ kdDebug() << "CONTEXT VARIABLE END" << endl;
+#endif
+
+ QStringList prefixes;
+ const QStringList paths = _project->settings()->paths();
+
+ for( QStringList::const_iterator it = paths.constBegin(); it!=paths.constEnd() ; ++it )
+ {
+ QString pref = (*it);
+
+ if ( !poDir.isEmpty() )
+ {
+ pref.replace( "@POFILEDIR@", poDir );
+ }
+ else if ( pref.find( "@POFILEDIR@ " ) != -1 )
+ continue; // No need to keep this path pattern, as we have no PO file dir
+
+ pref.replace( "@PACKAGEDIR@", packageDir);
+ pref.replace( "@PACKAGE@", packageName);
+ pref.replace( "@CODEROOT@", _project->settings()->codeRoot());
+ prefixes.append(pref);
+ }
+
+ QValueList<ContextInfo> rawRefList; // raw references
+ QRegExp re("^\\s*(.+):(\\d+)\\s*$"); // Reg. exp. for Gettext references
+ QRegExp rex( "^#. i18n: file (.+) line (\\d+)\\s*$" ); //Reg. exp. for KDE extractrc/extractattr references
+ QRegExp res( "^# [Ff]ile: (.+), line(?: number)?: (\\d+)\\s*$"); // Reg. exp. for "strict" PO format
+ const QStringList lines = QStringList::split( "\n", gettextComment );
+ for ( QStringList::const_iterator it = lines.constBegin() ; it != lines.constEnd() ; ++it)
+ {
+ const QString curLine = (*it).stripWhiteSpace();
+ if( curLine.startsWith( "#:" ) )
+ {
+ // We have a Gettext line with references
+ const QStringList references( QStringList::split( " ", curLine.mid( 2 ), false ) );
+ for ( QStringList::const_iterator it = references.constBegin(); it != references.constEnd(); ++it )
+ {
+ if ( re.exactMatch( (*it) ) )
+ {
+ ContextInfo ref;
+ ref.line = re.cap(2).toInt();
+ ref.path = re.cap(1);
+ // ### TODO KDE4: perhaps we should not do the replace if compiled for Windows
+ ref.path.replace( QChar( '\\' ), QChar( '/' ) );
+ rawRefList.append( ref );
+ }
+ }
+
+ }
+ else if ( curLine.startsWith( "#," ) )
+ {
+ // We have a Gettext option line. There is no source reference here.
+ continue;
+ }
+ else if ( curLine.startsWith( "#. i18n:") )
+ {
+ // We might have a KDE reference from extractrc/extractattr
+ if ( rex.exactMatch( (*it) ) )
+ {
+ ContextInfo ref;
+ ref.line = rex.cap(2).toInt();
+ ref.path = rex.cap(1);
+ // KDE is not extracted on Windows, so no backslash conversion is needed.
+ rawRefList.append( ref );
+ }
+ }
+ else if ( curLine.startsWith( "# F" ) || curLine.startsWith( "# f" ) )
+ {
+ // We might have a "strict PO" reference
+ if ( res.exactMatch( (*it) ) )
+ {
+ ContextInfo ref;
+ ref.line = res.cap(2).toInt();
+ ref.path = res.cap(1);
+ // ### TODO KDE4: perhaps we should not do the replace if compiled for Windows
+ ref.path.replace( QChar( '\\' ), QChar( '/' ) );
+ rawRefList.append( ref );
+ }
+ }
+ else
+ continue;
+ }
+
+ // Now that we have gathered the references, we need to convert them to absolute paths
+ QValueList<ContextInfo> results;
+ for ( QValueList<ContextInfo>::const_iterator it = rawRefList.constBegin(); it != rawRefList.constEnd(); ++it )
+ {
+ const int lineNum = (*it).line;
+ const QString fileName = (*it).path;
+ for ( QStringList::const_iterator it1 = prefixes.constBegin(); it1 != prefixes.constEnd(); ++it1 )
+ {
+ QString path = (*it1);
+ path.replace( "@COMMENTPATH@", fileName);
+
+ //kdDebug() << "CONTEXT PATH: " << path << endl; // DEBUG
+ QFileInfo pathInfo( path );
+ if( pathInfo.exists() )
+ {
+ ContextInfo ref;
+ ref.path = pathInfo.absFilePath();
+ ref.line = lineNum;
+ results.append(ref);
+ }
+ }
+ }
+
+ return results;
+}
+
+bool SourceContext::loadPart()
+{
+ KTrader::OfferList offers = KTrader::self()->query( "KTextEditor/Document" );
+ if( offers.count() < 1 )
+ {
+ KMessageBox::error(this,i18n("KBabel cannot start a text editor component.\n"
+ "Please check your KDE installation."));
+ _part=0;
+ _view=0;
+ return false;
+ }
+ KService::Ptr service = *offers.begin();
+ KLibFactory *factory = KLibLoader::self()->factory( service->library().latin1() );
+ if( !factory )
+ {
+ KMessageBox::error(this,i18n("KBabel cannot start a text editor component.\n"
+ "Please check your KDE installation."));
+ _part=0;
+ _view=0;
+ return false;
+ }
+ _part = static_cast<KTextEditor::Document *>( factory->create( this, 0, "KTextEditor::Document" ) );
+
+ if( !_part )
+ {
+ KMessageBox::error(this,i18n("KBabel cannot start a text editor component.\n"
+ "Please check your KDE installation."));
+ _part=0;
+ _view=0;
+ return false;
+ }
+ _view = _part->createView( this, 0 );
+ _layout->addWidget(static_cast<QWidget *>(_view), 1);
+ static_cast<QWidget *>(_view)->show();
+
+ return true;
+}
+
+void SourceContext::setProject( KBabel::Project::Ptr project )
+{
+ _project = project;
+}
+
+#include "context.moc"
+
+// kate: space-indent on; indent-width 4; replace-tabs on;
diff --git a/kbabel/commonui/context.h b/kbabel/commonui/context.h
new file mode 100644
index 00000000..2ccceecd
--- /dev/null
+++ b/kbabel/commonui/context.h
@@ -0,0 +1,123 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2002-2005 Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+#include <qvaluelist.h>
+#include <qwidget.h>
+
+#include <ktexteditor/document.h>
+#include <ktexteditor/view.h>
+
+#include <kbproject.h>
+
+class QComboBox;
+class QVBoxLayout;
+class QLineEdit;
+class KListEditor;
+class KConfig;
+class KURL;
+
+struct ContextInfo
+{
+ QString path;
+ uint line;
+};
+
+/**
+ * @short Class for displaying source code context
+ *
+ * Widget for displaying source code context of for the given GNU gettext comment.
+ * The searched paths can be configured using variables.
+ *
+ * The possible variables are:
+ * - \@POFILEDIR\@ absolute directory of the PO file (to create paths relatives to the PO file)
+ * - \@PACKAGE\@ name of the PO file
+ * - \@PACKAGEDIR\@ relative directory of the PO file (relative to \@CODEROOT\@)
+ * - \@CODEROOT\@ base directory (especially of the catalog manager)
+ * - \@COMMENTPATH\@ (relative) path given as source code reference in a comment of the PO file
+ *
+ * @note The difference between \@POFILEDIR\@ and a path constructed by
+ * \@CODEROOT\@\@PACKAGEDIR\@/ is that \@POFILEDIR\@ will also work if the file is external
+ * to the catalog manager's root
+ *
+ * @note It requires a KPart implementing KTextEditor interface with selections.
+ * @author Stanislav Visnovsky <visnovsky@kde.org>
+ */
+class KDE_EXPORT SourceContext : public QWidget
+{
+ Q_OBJECT
+public:
+ SourceContext(QWidget* parent, KBabel::Project::Ptr project);
+
+ void setProject(KBabel::Project::Ptr project);
+
+public slots:
+ /**
+ * Try to find the corresponding file and load it to this widget.
+ * @param packageDir path of the package, where to find the source file
+ * @param packageName name of the package, where to find the source file
+ * @param gettextComment comment string with context as generated by xgettext (can start with #:)
+ * @param urlPoFile URL of the PO file
+ * @todo even if @p urlPoFile is an URL SourceContext::resolvePath is not remote-aware yet
+ */
+ void setContext( const QString& packageDir, const QString& packageName, const QString& gettextComment, const KURL& urlPoFile );
+
+private:
+ /**
+ * Get a list of paths from the source references in the comment @p gettextComment
+ * @param packageDir path of the package, where to find the source file
+ * @param packageName name of the package, where to find the source file
+ * @param gettextComment comment string with context as generated by xgettext (can start with #:)
+ * @param urlPoFile URL of the PO file
+ * @todo even if @p urlPoFile is an URL SourceContext::resolvePath is not remote-aware yet
+ * @private
+ */
+ QValueList<ContextInfo> resolvePath( const QString& packageDir, const QString& packageName, const QString& gettextComment, const KURL& urlPoFile );
+ bool loadPart();
+
+ /// Parent widget (for KIO::NetAccess member functions)
+ QWidget* m_parent;
+ KTextEditor::Document* _part;
+ KTextEditor::View* _view;
+ QComboBox *_referenceCombo;
+ QVBoxLayout *_layout;
+
+ QValueList<ContextInfo> _referenceList;
+
+ KBabel::Project::Ptr _project;
+private slots:
+ void updateToSelected(int index);
+};
+
+#endif // CONTEXT_H
diff --git a/kbabel/commonui/diffpreferences.ui b/kbabel/commonui/diffpreferences.ui
new file mode 100644
index 00000000..a3ea5a4e
--- /dev/null
+++ b/kbabel/commonui/diffpreferences.ui
@@ -0,0 +1,141 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>DiffPreferences</class>
+<author>Stanislav Visnovsky</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>DiffPreferences</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>538</width>
+ <height>462</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>kcfg_UseDBForDiff</cstring>
+ </property>
+ <property name="title">
+ <string>Diff Source</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;&lt;p&gt;&lt;b&gt;Source for difference lookup&lt;/b&gt;&lt;/p&gt;
+&lt;p&gt;Here you can select a source, which should be used
+for finding a difference.&lt;/p&gt;
+&lt;p&gt;You can select file, translation database or
+corresponding msgstr.&lt;/p&gt;
+&lt;p&gt;If you choose the translation database, the messages to diff with are
+taken from the Translation Database; to be useful, you have
+to enable &lt;i&gt;Auto add entry to database&lt;/i&gt; in its
+preferences dialog.&lt;/p&gt;
+&lt;p&gt;The last option is useful for those using PO-files
+for proofreading.&lt;/p&gt;
+&lt;p&gt;You can temporarily diff with messages from a file
+by choosing &lt;i&gt;Tools-&gt;Diff-&gt;Open file for diff&lt;/i&gt;
+in KBabel's main window.&lt;/p&gt;&lt;/qt&gt;</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;file</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton2</cstring>
+ </property>
+ <property name="text">
+ <string>Use messages from &amp;translation database</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton3</cstring>
+ </property>
+ <property name="text">
+ <string>Use &amp;msgstr from the same file</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Base folder for diff files:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>kcfg_DiffBaseDir</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>kcfg_DiffBaseDir</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;&lt;q&gt;&lt;b&gt;Base folder for diff files&lt;/b&gt;&lt;/q&gt;
+&lt;p&gt;Here you can define a folder in which the files to
+diff with are stored. If the files are stored at the same
+place beneath this folder as the original files beneath
+their base folder, KBabel can automatically open the correct
+file to diff with.&lt;/p&gt;
+&lt;p&gt;Note that this option has no effect if messages from
+the database are used for diffing.&lt;/p&gt;&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<includes>
+ <include location="local" impldecl="in implementation">diffpreferences.ui.h</include>
+</includes>
+<functions>
+ <function>init()</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kbabel/commonui/diffpreferences.ui.h b/kbabel/commonui/diffpreferences.ui.h
new file mode 100644
index 00000000..5b02d278
--- /dev/null
+++ b/kbabel/commonui/diffpreferences.ui.h
@@ -0,0 +1,13 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+void DiffPreferences::init()
+{
+ kcfg_DiffBaseDir->setMode(KFile::Directory);
+}
diff --git a/kbabel/commonui/finddialog.cpp b/kbabel/commonui/finddialog.cpp
new file mode 100644
index 00000000..7335f30a
--- /dev/null
+++ b/kbabel/commonui/finddialog.cpp
@@ -0,0 +1,553 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2002 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "finddialog.h"
+
+#include <qbuttongroup.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qwhatsthis.h>
+
+#include <kcombobox.h>
+#include <kconfig.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kparts/componentfactory.h>
+#include <kregexpeditorinterface.h>
+
+using namespace KBabel;
+
+FindDialog::FindDialog(bool forReplace, QWidget* parent)
+ :KDialogBase(parent, "finddialog",true, "", Ok|Cancel, Ok)
+ , _regExpEditDialog(0), _replaceDlg(forReplace)
+{
+ QWidget* page = new QWidget(this);
+ QVBoxLayout *layout = new QVBoxLayout(page, 0, spacingHint());
+
+ QLabel *label = new QLabel(i18n("&Find:"),page);
+ layout->addWidget(label);
+
+ _findCombo = new KComboBox(true, page, "findCombo");
+ _findCombo->setMaxCount(10);
+ _findCombo->setInsertionPolicy(KComboBox::AtTop);
+ layout->addWidget(_findCombo);
+ label->setBuddy(_findCombo);
+
+ QString msg=i18n("<qt><p><b>Find text</b></p>"
+ "<p>Here you can enter the text you want to search for. "
+ "If you want to search for a regular expression, "
+ "enable <b>Use regular expression</b> below.</p></qt>");
+
+
+ QWhatsThis::add(label,msg);
+ QWhatsThis::add(_findCombo,msg);
+
+ if(forReplace) {
+ setCaption(i18n("Replace"));
+ setButtonOK(i18n("&Replace"));
+
+ _replaceLabel = new QLabel(i18n("&Replace with:"),page);
+ layout->addWidget(_replaceLabel);
+ _replaceCombo = new KComboBox(true, page, "replaceCombo");
+ _replaceCombo->setMaxCount(10);
+ _replaceCombo->setInsertionPolicy(KComboBox::AtTop);
+ layout->addWidget(_replaceCombo);
+ _replaceLabel->setBuddy(_replaceCombo);
+
+ msg=i18n("<qt><p><b>Replace text</b></p>"
+ "<p>Here you can enter the text you want the found text to get "
+ "replaced with. The text is used as is. It is not possible to make a back "
+ "reference, if you have searched for a regular expression.</p></qt>");
+
+ QWhatsThis::add(_replaceLabel,msg);
+ QWhatsThis::add(_replaceCombo,msg);
+ }
+ else {
+ setCaption(i18n("Find"));
+ setButtonOK(KGuiItem(i18n("&Find"),"find"));
+
+ _replaceLabel=0;
+ _replaceCombo=0;
+ }
+
+ _buttonGrp = new QButtonGroup(3, Qt::Horizontal, i18n("Where to Search"), page);
+ connect(_buttonGrp,SIGNAL(clicked(int)), this, SLOT(inButtonsClicked(int)));
+ layout->addWidget(_buttonGrp);
+
+ _inMsgid = new QCheckBox(i18n("&Msgid"),_buttonGrp);
+ _inMsgstr = new QCheckBox(i18n("M&sgstr"),_buttonGrp);
+ _inComment = new QCheckBox(i18n("Comm&ent"),_buttonGrp);
+
+ QWhatsThis::add(_buttonGrp,i18n("<qt><p><b>Where to search</b></p>"
+ "<p>Select here in which parts of a catalog entry you want "
+ "to search.</p></qt>"));
+
+
+ QGroupBox* box = new QGroupBox(2, Qt::Horizontal, i18n("Options"), page);
+ layout->addWidget(box);
+
+ _caseSensitive = new QCheckBox(i18n("C&ase sensitive"),box);
+ _wholeWords = new QCheckBox(i18n("O&nly whole words"),box);
+ _ignoreAccelMarker = new QCheckBox(i18n("I&gnore marker for keyboard accelerator"),box);
+ _ignoreContextInfo = new QCheckBox(i18n("Ignore con&text information"),box);
+ _fromCursor = new QCheckBox(i18n("From c&ursor position"),box);
+ _backwards = new QCheckBox(i18n("F&ind backwards"),box);
+
+ QHBox *regexp = new QHBox(box);
+
+ _isRegExp = new QCheckBox(i18n("Use regu&lar expression"),regexp);
+ _regExpButton = 0;
+
+ if( !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() )
+ {
+ _regExpButton = new QPushButton( i18n("&Edit..."), regexp );
+ connect( _regExpButton, SIGNAL( clicked() ), this, SLOT( regExpButtonClicked()));
+ connect( _isRegExp, SIGNAL( toggled(bool) ), _regExpButton, SLOT(setEnabled(bool)));
+ }
+
+ if(forReplace)
+ {
+ _inMsgid->setEnabled(false);
+ _askForReplace = new QCheckBox(i18n("As&k before replacing"),box);
+ _ignoreContextInfo->setEnabled(false);
+
+ QWhatsThis::add(box,i18n("<qt><p><b>Options</b></p>"
+ "<p>Here you can finetune replacing:"
+ "<ul><li><b>Case sensitive</b>: does case of entered text have to be respected?</li>"
+ "<li><b>Only whole words</b>: text found must not be part of a longer word</li>"
+ "<li><b>From cursor position</b>: start replacing at the part of the document where "
+ "the cursor is. Otherwise replacing is started at the beginning or the end.</li>"
+ "<li><b>Find backwards</b>: Should be self-explanatory.</li>"
+ "<li><b>Use regular expression</b>: use text entered in field <b>Find</b> "
+ "as a regular expression. This option has no effect with the replace text, especially "
+ "no back references are possible.</li>"
+ "<li><b>Ask before replacing</b>: Enable, if you want to have control about "
+ "what is replaced. Otherwise all found text is replaced without asking.</li>"
+ "</ul></p></qt>"));
+ }
+ else {
+ _askForReplace=0;
+
+ QWhatsThis::add(box,i18n("<qt><p><b>Options</b></p>"
+ "<p>Here you can finetune the search:"
+ "<ul><li><b>Case sensitive</b>: does case of entered text have to be respected?</li>"
+ "<li><b>Only whole words</b>: text found must not be part of a longer word</li>"
+ "<li><b>From cursor position</b>: start search at the part of the document, where "
+ "the cursor is. Otherwise search is started at the beginning or the end.</li>"
+ "<li><b>Find backwards</b>: Should be self-explanatory.</li>"
+ "<li><b>Use regular expression</b>: use entered text as a regular expression.</li>"
+ "</ul></p></qt>"));
+ }
+
+
+ readSettings();
+
+
+ setMainWidget(page);
+}
+
+FindDialog::~FindDialog()
+{
+ saveSettings();
+}
+
+int FindDialog::show(QString initialStr)
+{
+ if( !initialStr.isEmpty() ) {
+ _findCombo->setEditText( initialStr );
+ }
+ _findCombo->lineEdit()->selectAll();
+ _findCombo->setFocus();
+
+
+ KDialogBase::show();
+
+ int r = result();
+
+ if( r == QDialog::Accepted ) {
+ if(_replaceDlg) {
+ _replaceList.remove(_replaceCombo->currentText());
+ _replaceList.prepend(_replaceCombo->currentText());
+ if(_replaceList.count() > 10 )
+ _replaceList.remove(_replaceList.fromLast());
+
+ _replaceCombo->clear();
+ _replaceCombo->insertStringList(_replaceList);
+
+ _replaceFindList.remove(_findCombo->currentText());
+ _replaceFindList.prepend(_findCombo->currentText());
+ if(_replaceFindList.count() > 10 )
+ _replaceFindList.remove(_replaceFindList.fromLast());
+
+ _findCombo->clear();
+ _findCombo->insertStringList(_replaceFindList);
+
+ _replaceOptions.findStr = _findCombo->currentText();
+ _replaceOptions.replaceStr = _replaceCombo->currentText();
+
+ _replaceOptions.inMsgstr = _inMsgstr->isChecked();
+ _replaceOptions.inComment = _inComment->isChecked();
+ _replaceOptions.inMsgid = false;
+
+ _replaceOptions.caseSensitive = _caseSensitive->isChecked();
+ _replaceOptions.wholeWords = _wholeWords->isChecked();
+ _replaceOptions.ignoreAccelMarker = _ignoreAccelMarker->isChecked();
+ _replaceOptions.ignoreContextInfo = false;
+ _replaceOptions.backwards = _backwards->isChecked();
+ _replaceOptions.fromCursor = _fromCursor->isChecked();
+ _replaceOptions.isRegExp = _isRegExp->isChecked();
+ _replaceOptions.ask = _askForReplace->isChecked();
+ }
+ else {
+ _findList.remove(_findCombo->currentText());
+ _findList.prepend(_findCombo->currentText());
+ if(_findList.count() > 10 )
+ _findList.remove(_findList.fromLast());
+
+ _findCombo->clear();
+ _findCombo->insertStringList(_findList);
+
+ _findOptions.findStr = _findCombo->currentText();
+ _findOptions.inMsgid = _inMsgid->isChecked();
+ _findOptions.inMsgstr = _inMsgstr->isChecked();
+ _findOptions.inComment = _inComment->isChecked();
+
+ _findOptions.caseSensitive = _caseSensitive->isChecked();
+ _findOptions.wholeWords = _wholeWords->isChecked();
+ _findOptions.ignoreAccelMarker = _ignoreAccelMarker->isChecked();
+ _findOptions.ignoreContextInfo = _ignoreContextInfo->isChecked();
+ _findOptions.backwards = _backwards->isChecked();
+ _findOptions.fromCursor = _fromCursor->isChecked();
+ _findOptions.isRegExp = _isRegExp->isChecked();
+ }
+ }
+
+ return r;
+}
+
+int FindDialog::exec(QString initialStr)
+{
+ if( !initialStr.isEmpty() ) {
+ _findCombo->setEditText( initialStr );
+ }
+ _findCombo->lineEdit()->selectAll();
+ _findCombo->setFocus();
+
+
+ KDialogBase::exec();
+
+ int r = result();
+
+ if( r == QDialog::Accepted ) {
+ if(_replaceDlg) {
+ _replaceList.remove(_replaceCombo->currentText());
+ _replaceList.prepend(_replaceCombo->currentText());
+ if(_replaceList.count() > 10 )
+ _replaceList.remove(_replaceList.fromLast());
+
+ _replaceCombo->clear();
+ _replaceCombo->insertStringList(_replaceList);
+
+ _replaceFindList.remove(_findCombo->currentText());
+ _replaceFindList.prepend(_findCombo->currentText());
+ if(_replaceFindList.count() > 10 )
+ _replaceFindList.remove(_replaceFindList.fromLast());
+
+ _findCombo->clear();
+ _findCombo->insertStringList(_replaceFindList);
+
+ _replaceOptions.findStr = _findCombo->currentText();
+ _replaceOptions.replaceStr = _replaceCombo->currentText();
+
+ _replaceOptions.inMsgstr = _inMsgstr->isChecked();
+ _replaceOptions.inComment = _inComment->isChecked();
+ _replaceOptions.inMsgid = false;
+
+ _replaceOptions.caseSensitive = _caseSensitive->isChecked();
+ _replaceOptions.wholeWords = _wholeWords->isChecked();
+ _replaceOptions.ignoreAccelMarker = _ignoreAccelMarker->isChecked();
+ _replaceOptions.ignoreContextInfo = false;
+ _replaceOptions.backwards = _backwards->isChecked();
+ _replaceOptions.fromCursor = _fromCursor->isChecked();
+ _replaceOptions.isRegExp = _isRegExp->isChecked();
+ _replaceOptions.ask = _askForReplace->isChecked();
+ }
+ else {
+ _findList.remove(_findCombo->currentText());
+ _findList.prepend(_findCombo->currentText());
+ if(_findList.count() > 10 )
+ _findList.remove(_findList.fromLast());
+
+ _findCombo->clear();
+ _findCombo->insertStringList(_findList);
+
+ _findOptions.findStr = _findCombo->currentText();
+ _findOptions.inMsgid = _inMsgid->isChecked();
+ _findOptions.inMsgstr = _inMsgstr->isChecked();
+ _findOptions.inComment = _inComment->isChecked();
+
+ _findOptions.caseSensitive = _caseSensitive->isChecked();
+ _findOptions.wholeWords = _wholeWords->isChecked();
+ _findOptions.ignoreAccelMarker = _ignoreAccelMarker->isChecked();
+ _findOptions.ignoreContextInfo = _ignoreContextInfo->isChecked();
+ _findOptions.backwards = _backwards->isChecked();
+ _findOptions.fromCursor = _fromCursor->isChecked();
+ _findOptions.isRegExp = _isRegExp->isChecked();
+ }
+ }
+
+ return r;
+}
+
+FindOptions FindDialog::findOpts()
+{
+ return _findOptions;
+}
+
+void FindDialog::setFindOpts(FindOptions options)
+{
+ _findOptions = options;
+ _inMsgid->setChecked(_findOptions.inMsgid);
+ _inMsgstr->setChecked(_findOptions.inMsgstr);
+ _inComment->setChecked(_findOptions.inComment);
+
+ _caseSensitive->setChecked(_findOptions.caseSensitive);
+ _wholeWords->setChecked(_findOptions.wholeWords);
+ _ignoreAccelMarker->setChecked(_findOptions.ignoreAccelMarker);
+ _ignoreContextInfo->setChecked(_findOptions.ignoreContextInfo);
+ _backwards->setChecked(_findOptions.backwards);
+ _fromCursor->setChecked(_findOptions.fromCursor);
+ _isRegExp->setChecked(_findOptions.isRegExp);
+ if( _regExpButton ) _regExpButton->setEnabled( _findOptions.isRegExp );
+
+ _findCombo->setEditText(_findOptions.findStr);
+}
+
+ReplaceOptions FindDialog::replaceOpts()
+{
+ return _replaceOptions;
+}
+
+void FindDialog::setReplaceOpts(ReplaceOptions options)
+{
+ _replaceOptions = options;
+ _inMsgid->setChecked(_replaceOptions.inMsgid);
+ _inMsgstr->setChecked(_replaceOptions.inMsgstr);
+ _inComment->setChecked(_replaceOptions.inComment);
+
+ _caseSensitive->setChecked(_replaceOptions.caseSensitive);
+ _wholeWords->setChecked(_replaceOptions.wholeWords);
+ _ignoreAccelMarker->setChecked(_replaceOptions.ignoreAccelMarker);
+ _ignoreContextInfo->setChecked(_replaceOptions.ignoreContextInfo);
+ _backwards->setChecked(_replaceOptions.backwards);
+ _fromCursor->setChecked(_replaceOptions.fromCursor);
+ _isRegExp->setChecked(_replaceOptions.isRegExp);
+ _askForReplace->setChecked(_replaceOptions.ask);
+ if( _regExpButton ) _regExpButton->setEnabled( _replaceOptions.isRegExp );
+
+ _findCombo->setEditText(_replaceOptions.findStr);
+ _replaceCombo->setEditText(_replaceOptions.replaceStr);
+}
+
+void FindDialog::readSettings()
+{
+ KConfig* config = KGlobal::config();
+
+ if(_replaceDlg) {
+ KConfigGroupSaver cgs(config,"ReplaceDialog");
+ _replaceOptions.inMsgstr = config->readBoolEntry("InMsgstr",true);
+ _replaceOptions.inComment = config->readBoolEntry("InComment",false);
+
+ _replaceOptions.caseSensitive =
+ config->readBoolEntry("CaseSensitive",true);
+ _replaceOptions.wholeWords = config->readBoolEntry("WholeWords",false);
+ _replaceOptions.ignoreAccelMarker =
+ config->readBoolEntry("IgnoreAccelMarker",true);
+ _replaceOptions.backwards = config->readBoolEntry("Backwards",false);
+ _replaceOptions.fromCursor = config->readBoolEntry("FromCursor",true);
+ _replaceOptions.isRegExp = config->readBoolEntry("RegExp",false);
+ _replaceOptions.ask = config->readBoolEntry("AskForReplace",true);
+ _replaceFindList = config->readListEntry("FindList");
+ _replaceList = config->readListEntry("ReplaceList");
+
+ _inMsgstr->setChecked(_replaceOptions.inMsgstr);
+ _inComment->setChecked(_replaceOptions.inComment);
+
+ _caseSensitive->setChecked(_replaceOptions.caseSensitive);
+ _wholeWords->setChecked(_replaceOptions.wholeWords);
+ _ignoreAccelMarker->setChecked(_findOptions.ignoreAccelMarker);
+ _backwards->setChecked(_replaceOptions.backwards);
+ _fromCursor->setChecked(_replaceOptions.fromCursor);
+ _isRegExp->setChecked(_replaceOptions.isRegExp);
+ _askForReplace->setChecked(_replaceOptions.ask);
+ if( _regExpButton ) _regExpButton->setEnabled( _findOptions.isRegExp );
+
+ _replaceCombo->insertStringList(_replaceList);
+ _findCombo->insertStringList(_replaceFindList);
+ }
+ else {
+ KConfigGroupSaver cgs(config,"FindDialog");
+
+ _findOptions.inMsgid = config->readBoolEntry("InMsgid",true);
+ _findOptions.inMsgstr = config->readBoolEntry("InMsgstr",true);
+ _findOptions.inComment = config->readBoolEntry("InComment",false);
+
+ _findOptions.caseSensitive = config->readBoolEntry("CaseSensitive"
+ ,false);
+ _findOptions.wholeWords = config->readBoolEntry("WholeWords",false);
+ _findOptions.ignoreAccelMarker =
+ config->readBoolEntry("IgnoreAccelMarker",true);
+ _findOptions.ignoreContextInfo =
+ config->readBoolEntry("IgnoreContextInfo",true);
+ _findOptions.backwards = config->readBoolEntry("Backwards",false);
+ _findOptions.fromCursor = config->readBoolEntry("FromCursor",false);
+ _findOptions.isRegExp = config->readBoolEntry("RegExp",false);
+ _findList = config->readListEntry("List");
+ if( _regExpButton ) _regExpButton->setEnabled( _findOptions.isRegExp );
+
+ _inMsgid->setChecked(_findOptions.inMsgid);
+ _inMsgstr->setChecked(_findOptions.inMsgstr);
+ _inComment->setChecked(_findOptions.inComment);
+
+ _caseSensitive->setChecked(_findOptions.caseSensitive);
+ _wholeWords->setChecked(_findOptions.wholeWords);
+ _ignoreAccelMarker->setChecked(_findOptions.ignoreAccelMarker);
+ _ignoreContextInfo->setChecked(_findOptions.ignoreContextInfo);
+ _backwards->setChecked(_findOptions.backwards);
+ _fromCursor->setChecked(_findOptions.fromCursor);
+ _isRegExp->setChecked(_findOptions.isRegExp);
+
+ _findCombo->insertStringList(_findList);
+ }
+
+}
+
+void FindDialog::saveSettings()
+{
+ KConfig* config = KGlobal::config();
+
+ if(_replaceDlg) {
+ KConfigGroupSaver cgs(config,"ReplaceDialog");
+ config->writeEntry("InMsgstr",_replaceOptions.inMsgstr);
+ config->writeEntry("InComment",_replaceOptions.inComment);
+
+ config->writeEntry("CaseSensitive",_replaceOptions.caseSensitive);
+ config->writeEntry("WholeWords",_replaceOptions.wholeWords);
+ config->writeEntry("IgnoreAccelMarker"
+ ,_replaceOptions.ignoreAccelMarker);
+ config->writeEntry("Backwards",_replaceOptions.backwards);
+ config->writeEntry("FromCursor",_replaceOptions.fromCursor);
+ config->writeEntry("RegExp",_replaceOptions.isRegExp);
+ config->writeEntry("AskForReplace",_replaceOptions.ask);
+ config->writeEntry("FindList",_replaceFindList);
+ config->writeEntry("ReplaceList",_replaceList);
+ }
+ else {
+ KConfigGroupSaver cgs(config,"FindDialog");
+
+ config->writeEntry("InMsgid",_findOptions.inMsgid);
+ config->writeEntry("InMsgstr",_findOptions.inMsgstr);
+ config->writeEntry("InComment",_findOptions.inComment);
+
+ config->writeEntry("CaseSensitive",_findOptions.caseSensitive);
+ config->writeEntry("WholeWords",_findOptions.wholeWords);
+ config->writeEntry("IgnoreAccelMarker"
+ ,_findOptions.ignoreAccelMarker);
+ config->writeEntry("IgnoreContextInfo"
+ ,_findOptions.ignoreContextInfo);
+ config->writeEntry("Backwards",_findOptions.backwards);
+ config->writeEntry("FromCursor",_findOptions.fromCursor);
+ config->writeEntry("RegExp",_findOptions.isRegExp);
+ config->writeEntry("List",_findList);
+ }
+}
+
+
+
+void FindDialog::inButtonsClicked(int id)
+{
+ // check if at least one button is checked
+ if(! _buttonGrp->find(id)->isOn() ) {
+ if(!_inMsgstr->isOn() && !_inComment->isOn() ) {
+ if(_inMsgid->isEnabled()) {
+ if( !_inMsgid->isOn() ) {
+ _buttonGrp->setButton(id);
+ }
+ }
+ else {
+ _buttonGrp->setButton(id);
+ }
+
+ }
+ }
+}
+
+void FindDialog::regExpButtonClicked()
+{
+ if ( _regExpEditDialog == 0 )
+ _regExpEditDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>( "KRegExpEditor/KRegExpEditor", QString::null, this );
+
+ KRegExpEditorInterface *iface = dynamic_cast<KRegExpEditorInterface *>( _regExpEditDialog );
+ if( iface )
+ {
+ iface->setRegExp( _findCombo->currentText() );
+ if( _regExpEditDialog->exec() == QDialog::Accepted )
+ _findCombo->setCurrentText( iface->regExp() );
+ }
+}
+
+ReplaceDialog::ReplaceDialog(QWidget* parent)
+ :KDialogBase(Plain, "", Close|User1|User2|User3, User1, parent,"finddialog"
+ , true,false,i18n("&Replace"),i18n("&Goto Next"),i18n("R&eplace All"))
+{
+ QWidget* page = plainPage();
+ QVBoxLayout *layout = new QVBoxLayout(page, 0, spacingHint());
+
+ QLabel *label = new QLabel(i18n("Replace this string?"),page);
+ layout->addWidget(label);
+
+ connect(this,SIGNAL(user1Clicked()),this,SIGNAL(replace()));
+ connect(this,SIGNAL(user2Clicked()),this,SIGNAL(next()));
+ connect(this,SIGNAL(user3Clicked()),this,SIGNAL(replaceAll()));
+}
+
+ReplaceDialog::~ReplaceDialog()
+{
+}
+
+#include "finddialog.moc"
diff --git a/kbabel/commonui/finddialog.h b/kbabel/commonui/finddialog.h
new file mode 100644
index 00000000..7baa0675
--- /dev/null
+++ b/kbabel/commonui/finddialog.h
@@ -0,0 +1,136 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef FINDDIALOG_H
+#define FINDDIALOG_H
+
+#include <qstring.h>
+#include <qstringlist.h>
+#include <kdialogbase.h>
+
+class QButtonGroup;
+class QCheckBox;
+class QLabel;
+class KComboBox;
+
+#include "findoptions.h"
+
+class KDE_EXPORT FindDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ /**
+ * Constructor
+ * @param replaceDlg flag, if this is a replace dialog
+ */
+ FindDialog(bool replaceDlg, QWidget* parent);
+ ~FindDialog();
+
+ /**
+ * shows the dialog
+ * @param initialStr string to display in find field.
+ * If empty, the last used string is used.
+ *
+ * @return the result code of the dialog
+ */
+ int show(QString initialStr);
+
+ /**
+ * executes the dialog as modal
+ * @param initialStr string to display in find field.
+ * If empty, the last used string is used.
+ *
+ * @return the result code of the dialog
+ */
+ int exec(QString initialStr);
+ KBabel::FindOptions findOpts();
+ void setFindOpts(KBabel::FindOptions options);
+ KBabel::ReplaceOptions replaceOpts();
+ void setReplaceOpts(KBabel::ReplaceOptions options);
+
+protected:
+ void readSettings();
+ void saveSettings();
+
+ bool isReplaceDialog() { return _replaceDlg; }
+
+private slots:
+ void inButtonsClicked(int id);
+ void regExpButtonClicked();
+
+private:
+ KComboBox *_findCombo;
+ KComboBox *_replaceCombo;
+ QLabel *_replaceLabel;
+
+ QButtonGroup *_buttonGrp;
+ QCheckBox *_inMsgid;
+ QCheckBox *_inMsgstr;
+ QCheckBox *_inComment;
+
+ QCheckBox *_caseSensitive;
+ QCheckBox *_wholeWords;
+ QCheckBox *_ignoreAccelMarker;
+ QCheckBox *_ignoreContextInfo;
+ QCheckBox *_backwards;
+ QCheckBox *_fromCursor;
+ QCheckBox *_isRegExp;
+ QCheckBox *_askForReplace;
+
+ QPushButton *_regExpButton;
+ QDialog *_regExpEditDialog;
+
+ KBabel::FindOptions _findOptions;
+ KBabel::ReplaceOptions _replaceOptions;
+
+ QStringList _findList;
+ QStringList _replaceFindList;
+ QStringList _replaceList;
+
+ bool _replaceDlg;
+};
+
+class KDE_EXPORT ReplaceDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ ReplaceDialog(QWidget* parent);
+ ~ReplaceDialog();
+
+signals:
+ void replace();
+ void replaceAll();
+ void next();
+
+};
+
+#endif // FINDDIALOG_H
diff --git a/kbabel/commonui/kactionselector.cpp b/kbabel/commonui/kactionselector.cpp
new file mode 100644
index 00000000..b214a49f
--- /dev/null
+++ b/kbabel/commonui/kactionselector.cpp
@@ -0,0 +1,562 @@
+/***************************************************************************
+ KActionSelector.cpp
+ A widget for selecting and arranging actions/objects
+ -------------------
+ begin : Mon June 3 2002
+ copyright : (C) 2002 by Anders Lund
+ email : anders@alweb.dk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ * *
+ * In addition, as a special exception, the copyright holders give *
+ * permission to link the code of this program with any edition of *
+ * the Qt library by Trolltech AS, Norway (or with modified versions *
+ * of Qt that use the same license as Qt), and distribute linked *
+ * combinations including the two. You must obey the GNU General *
+ * Public License in all respects for all of the code used other than *
+ * Qt. If you modify this file, you may extend this exception to *
+ * your version of the file, but you are not obligated to do so. If *
+ * you do not wish to do so, delete this exception statement from *
+ * your version. *
+ ***************************************************************************/
+
+#include "kactionselector.h"
+#include <resources.h>
+
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kdialog.h> // for spacingHint()
+#include <kdebug.h>
+
+#include <qlistbox.h>
+#include <qtoolbutton.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qevent.h>
+#include <qwhatsthis.h>
+#include <qapplication.h>
+
+class KActionSelectorPrivate {
+ public:
+ QListBox *availableListBox, *selectedListBox;
+ QToolButton *btnAdd, *btnRemove, *btnUp, *btnDown;
+ QLabel *lAvailable, *lSelected;
+ bool moveOnDoubleClick, keyboardEnabled;
+ KActionSelector::ButtonIconSize iconSize;
+ QString addIcon, removeIcon, upIcon, downIcon;
+ KActionSelector::InsertionPolicy availableInsertionPolicy, selectedInsertionPolicy;
+ bool showUpDownButtons;
+};
+
+//BEGIN Constructor/destructor
+
+KActionSelector::KActionSelector( QWidget *parent, const char *name )
+ : QWidget( parent, name )
+{
+ d = new KActionSelectorPrivate();
+ d->moveOnDoubleClick = true;
+ d->keyboardEnabled = true;
+ d->iconSize = SmallIcon;
+ d->addIcon = QApplication::reverseLayout() ? "back" : "forward";
+ d->removeIcon = QApplication::reverseLayout() ? "forward" : "back";
+ d->upIcon = "up";
+ d->downIcon = "down";
+ d->availableInsertionPolicy = Sorted;
+ d->selectedInsertionPolicy = BelowCurrent;
+ d->showUpDownButtons = true;
+
+ //int isz = IconSize( KIcon::Small );
+
+ QHBoxLayout *lo = new QHBoxLayout( this );
+ lo->setSpacing( KDialog::spacingHint() );
+
+ QVBoxLayout *loAv = new QVBoxLayout( lo );
+ d->lAvailable = new QLabel( i18n("&Available:"), this );
+ loAv->addWidget( d->lAvailable );
+ d->availableListBox = new QListBox( this );
+ loAv->addWidget( d->availableListBox );
+ d->lAvailable->setBuddy( d->availableListBox );
+
+ QVBoxLayout *loHBtns = new QVBoxLayout( lo );
+ loHBtns->addStretch( 1 );
+ d->btnAdd = new QToolButton( this );
+ loHBtns->addWidget( d->btnAdd );
+ d->btnRemove = new QToolButton( this );
+ loHBtns->addWidget( d->btnRemove );
+ loHBtns->addStretch( 1 );
+
+ QVBoxLayout *loS = new QVBoxLayout( lo );
+ d->lSelected = new QLabel( i18n("&Selected:"), this );
+ loS->addWidget( d->lSelected );
+ d->selectedListBox = new QListBox( this );
+ loS->addWidget( d->selectedListBox );
+ d->lSelected->setBuddy( d->selectedListBox );
+
+ QVBoxLayout *loVBtns = new QVBoxLayout( lo );
+ loVBtns->addStretch( 1 );
+ d->btnUp = new QToolButton( this );
+ loVBtns->addWidget( d->btnUp );
+ d->btnDown = new QToolButton( this );
+ loVBtns->addWidget( d->btnDown );
+ loVBtns->addStretch( 1 );
+
+ loadIcons();
+
+ connect( d->btnAdd, SIGNAL(clicked()), this, SLOT(buttonAddClicked()) );
+ connect( d->btnRemove, SIGNAL(clicked()), this, SLOT(buttonRemoveClicked()) );
+ connect( d->btnUp, SIGNAL(clicked()), this, SLOT(buttonUpClicked()) );
+ connect( d->btnDown, SIGNAL(clicked()), this, SLOT(buttonDownClicked()) );
+ connect( d->availableListBox, SIGNAL(doubleClicked(QListBoxItem*)),
+ this, SLOT(itemDoubleClicked(QListBoxItem*)) );
+ connect( d->selectedListBox, SIGNAL(doubleClicked(QListBoxItem*)),
+ this, SLOT(itemDoubleClicked(QListBoxItem*)) );
+ connect( d->availableListBox, SIGNAL(currentChanged(QListBoxItem*)),
+ this, SLOT(slotCurrentChanged(QListBoxItem *)) );
+ connect( d->selectedListBox, SIGNAL(currentChanged(QListBoxItem*)),
+ this, SLOT(slotCurrentChanged(QListBoxItem *)) );
+
+ d->availableListBox->installEventFilter( this );
+ d->selectedListBox->installEventFilter( this );
+}
+
+KActionSelector::~KActionSelector()
+{
+ delete d;
+}
+
+//END Constructor/destroctor
+
+//BEGIN Public Methods
+
+QListBox *KActionSelector::availableListBox()
+{
+ return d->availableListBox;
+}
+
+QListBox *KActionSelector::selectedListBox()
+{
+ return d->selectedListBox;
+}
+
+void KActionSelector::setButtonIcon( const QString &icon, MoveButton button )
+{
+ int isz;
+ if ( d->iconSize == SmallIcon ) isz = IconSize( KIcon::Small );
+ else if ( d->iconSize == Small ) isz = 16;
+ else if ( d->iconSize == Medium ) isz = 22;
+ else if ( d->iconSize == Large ) isz = 32;
+ else if ( d->iconSize == XLarge ) isz = 48;
+
+ switch ( button )
+ {
+ case ButtonAdd:
+ d->addIcon = icon;
+ d->btnAdd->setIconSet( SmallIconSet( icon, isz ) );
+ break;
+ case ButtonRemove:
+ d->removeIcon = icon;
+ d->btnRemove->setIconSet( SmallIconSet( icon, isz ) );
+ break;
+ case ButtonUp:
+ d->upIcon = icon;
+ d->btnUp->setIconSet( SmallIconSet( icon, isz ) );
+ break;
+ case ButtonDown:
+ d->downIcon = icon;
+ d->btnDown->setIconSet( SmallIconSet( icon, isz ) );
+ break;
+ default:
+ kdDebug(KBABEL)<<"KActionSelector::setButtonIcon: DAINBREAD!"<<endl;
+ }
+}
+
+void KActionSelector::setButtonIconSet( const QIconSet &iconset, MoveButton button )
+{
+ switch ( button )
+ {
+ case ButtonAdd:
+ d->btnAdd->setIconSet( iconset );
+ break;
+ case ButtonRemove:
+ d->btnRemove->setIconSet( iconset );
+ break;
+ case ButtonUp:
+ d->btnUp->setIconSet( iconset );
+ break;
+ case ButtonDown:
+ d->btnDown->setIconSet( iconset );
+ break;
+ default:
+ kdDebug(KBABEL)<<"KActionSelector::setButtonIconSet: DAINBREAD!"<<endl;
+ }
+}
+
+void KActionSelector::setButtonTooltip( const QString &tip, MoveButton button )
+{
+ switch ( button )
+ {
+ case ButtonAdd:
+ d->btnAdd->setTextLabel( tip );
+ break;
+ case ButtonRemove:
+ d->btnRemove->setTextLabel( tip );
+ break;
+ case ButtonUp:
+ d->btnUp->setTextLabel( tip );
+ break;
+ case ButtonDown:
+ d->btnDown->setTextLabel( tip );
+ break;
+ default:
+ kdDebug(KBABEL)<<"KActionSelector::setButtonToolTip: DAINBREAD!"<<endl;
+ }
+}
+
+void KActionSelector::setButtonWhatsThis( const QString &text, MoveButton button )
+{
+ switch ( button )
+ {
+ case ButtonAdd:
+ QWhatsThis::add( d->btnAdd, text );
+ break;
+ case ButtonRemove:
+ QWhatsThis::add( d->btnRemove, text );
+ break;
+ case ButtonUp:
+ QWhatsThis::add( d->btnUp, text );
+ break;
+ case ButtonDown:
+ QWhatsThis::add( d->btnDown, text );
+ break;
+ default:
+ kdDebug(KBABEL)<<"KActionSelector::setButtonWhatsThis: DAINBREAD!"<<endl;
+ }
+}
+
+void KActionSelector::setButtonsEnabled()
+{
+ d->btnAdd->setEnabled( d->availableListBox->currentItem() > -1 );
+ d->btnRemove->setEnabled( d->selectedListBox->currentItem() > -1 );
+ d->btnUp->setEnabled( d->selectedListBox->currentItem() > 0 );
+ d->btnDown->setEnabled( d->selectedListBox->currentItem() > -1 &&
+ d->selectedListBox->currentItem() < (int)d->selectedListBox->count() - 1 );
+}
+
+//END Public Methods
+
+//BEGIN Properties
+
+bool KActionSelector::moveOnDoubleClick() const
+{
+ return d->moveOnDoubleClick;
+}
+
+void KActionSelector::setMoveOnDoubleClick( bool b )
+{
+ d->moveOnDoubleClick = b;
+}
+
+bool KActionSelector::keyboardEnabled() const
+{
+ return d->keyboardEnabled;
+}
+
+void KActionSelector::setKeyboardEnabled( bool b )
+{
+ d->keyboardEnabled = b;
+}
+
+QString KActionSelector::availableLabel() const
+{
+ return d->lAvailable->text();
+}
+
+void KActionSelector::setAvailableLabel( const QString &text )
+{
+ d->lAvailable->setText( text );
+}
+
+QString KActionSelector::selectedLabel() const
+{
+ return d->lSelected->text();
+}
+
+void KActionSelector::setSelectedLabel( const QString &text )
+{
+ d->lSelected->setText( text );
+}
+
+KActionSelector::ButtonIconSize KActionSelector::buttonIconSize() const
+{
+ return d->iconSize;
+}
+
+void KActionSelector::setButtonIconSize( ButtonIconSize size )
+{
+ d->iconSize = size;
+ // reload icons
+ loadIcons();
+}
+
+KActionSelector::InsertionPolicy KActionSelector::availableInsertionPolicy()
+{
+ return d->availableInsertionPolicy;
+}
+
+void KActionSelector::setAvailableInsertionPolicy( InsertionPolicy p )
+{
+ d->availableInsertionPolicy = p;
+}
+
+KActionSelector::InsertionPolicy KActionSelector::selectedInsertionPolicy()
+{
+ return d->selectedInsertionPolicy;
+}
+
+void KActionSelector::setSelectedInsertionPolicy( InsertionPolicy p )
+{
+ d->selectedInsertionPolicy = p;
+}
+
+bool KActionSelector::showUpDownButtons()
+{
+ return d->showUpDownButtons;
+}
+
+void KActionSelector::setShowUpDownButtons( bool show )
+{
+ d->showUpDownButtons = show;
+ if ( show )
+ {
+ d->btnUp->show();
+ d->btnDown->show();
+ }
+ else
+ {
+ d->btnUp->hide();
+ d->btnDown->hide();
+ }
+}
+
+//END Properties
+
+//BEGIN Public Slots
+
+void KActionSelector::polish()
+{
+ setButtonsEnabled();
+}
+
+//END Public Slots
+
+//BEGIN Protected
+void KActionSelector::keyPressEvent( QKeyEvent *e )
+{
+ if ( ! d->keyboardEnabled ) return;
+ if ( (e->state() & Qt::ControlButton) )
+ {
+ switch ( e->key() )
+ {
+ case Key_Right:
+ buttonAddClicked();
+ break;
+ case Key_Left:
+ buttonRemoveClicked();
+ break;
+ case Key_Up:
+ buttonUpClicked();
+ break;
+ case Key_Down:
+ buttonDownClicked();
+ break;
+ default:
+ e->ignore();
+ return;
+ }
+ }
+}
+
+bool KActionSelector::eventFilter( QObject *o, QEvent *e )
+{
+ if ( d->keyboardEnabled && e->type() == QEvent::KeyPress )
+ {
+ if ( (((QKeyEvent*)e)->state() & Qt::ControlButton) )
+ {
+ switch ( ((QKeyEvent*)e)->key() )
+ {
+ case Key_Right:
+ buttonAddClicked();
+ break;
+ case Key_Left:
+ buttonRemoveClicked();
+ break;
+ case Key_Up:
+ buttonUpClicked();
+ break;
+ case Key_Down:
+ buttonDownClicked();
+ break;
+ default:
+ return QWidget::eventFilter( o, e );
+ break;
+ }
+ return true;
+ }
+ else if ( o->inherits( "QListBox" ) )
+ {
+ switch ( ((QKeyEvent*)e)->key() )
+ {
+ case Key_Return:
+ case Key_Enter:
+ QListBox *lb = (QListBox*)o;
+ int index = lb->currentItem();
+ if ( index < 0 ) break;
+ moveItem( lb->item( index ) );
+ return true;
+ }
+ }
+ }
+ return QWidget::eventFilter( o, e );
+}
+
+//END Protected
+
+//BEGIN Private Slots
+
+void KActionSelector::buttonAddClicked()
+{
+ // move all selected items from available to selected listbox
+ QListBoxItem *item = d->availableListBox->firstItem();
+ while ( item ) {
+ if ( item->isSelected() ) {
+ d->availableListBox->takeItem( item );
+ d->selectedListBox->insertItem( item, insertionIndex( d->selectedListBox, d->selectedInsertionPolicy ) );
+ d->selectedListBox->setCurrentItem( item );
+ emit added( item );
+ }
+ item = item->next();
+ }
+ if ( d->selectedInsertionPolicy == Sorted )
+ d->selectedListBox->sort();
+ d->selectedListBox->setFocus();
+}
+
+void KActionSelector::buttonRemoveClicked()
+{
+ // move all selected items from selected to available listbox
+ QListBoxItem *item = d->selectedListBox->firstItem();
+ while ( item ) {
+ if ( item->isSelected() ) {
+ d->selectedListBox->takeItem( item );
+ d->availableListBox->insertItem( item, insertionIndex( d->availableListBox, d->availableInsertionPolicy ) );
+ d->availableListBox->setCurrentItem( item );
+ emit removed( item );
+ }
+ item = item->next();
+ }
+ if ( d->availableInsertionPolicy == Sorted )
+ d->availableListBox->sort();
+ d->availableListBox->setFocus();
+}
+
+void KActionSelector::buttonUpClicked()
+{
+ int c = d->selectedListBox->currentItem();
+ if ( c < 0 ) return;
+ QListBoxItem *item = d->selectedListBox->item( c );
+ d->selectedListBox->takeItem( item );
+ d->selectedListBox->insertItem( item, c-1 );
+ d->selectedListBox->setCurrentItem( item );
+ emit movedUp( item );
+}
+
+void KActionSelector::buttonDownClicked()
+{
+ int c = d->selectedListBox->currentItem();
+ if ( c < 0 ) return;
+ QListBoxItem *item = d->selectedListBox->item( c );
+ d->selectedListBox->takeItem( item );
+ d->selectedListBox->insertItem( item, c+1 );
+ d->selectedListBox->setCurrentItem( item );
+ emit movedDown( item );
+}
+
+void KActionSelector::itemDoubleClicked( QListBoxItem *item )
+{
+ if ( d->moveOnDoubleClick )
+ moveItem( item );
+}
+
+//END Private Slots
+
+//BEGIN Private Methods
+
+void KActionSelector::loadIcons()
+{
+ int isz;
+ if ( d->iconSize == SmallIcon ) isz = IconSize( KIcon::Small );
+ else if ( d->iconSize == Small ) isz = 16;
+ else if ( d->iconSize == Medium ) isz = 22;
+ else if ( d->iconSize == Large ) isz = 32;
+ else if ( d->iconSize == XLarge ) isz = 48;
+
+ d->btnAdd->setIconSet( SmallIconSet( d->addIcon, isz ) );
+ d->btnRemove->setIconSet( SmallIconSet( d->removeIcon, isz ) );
+ d->btnUp->setIconSet( SmallIconSet( d->upIcon, isz ) );
+ d->btnDown->setIconSet( SmallIconSet( d->downIcon, isz ) );
+}
+
+void KActionSelector::moveItem( QListBoxItem *item )
+{
+ QListBox *lbFrom = item->listBox();
+ QListBox *lbTo;
+ if ( lbFrom == d->availableListBox )
+ lbTo = d->selectedListBox;
+ else if ( lbFrom == d->selectedListBox )
+ lbTo = d->availableListBox;
+ else //?! somewhat unlikely...
+ return;
+
+ InsertionPolicy p = ( lbTo == d->availableListBox ) ?
+ d->availableInsertionPolicy : d->selectedInsertionPolicy;
+
+ lbFrom->takeItem( item );
+ lbTo->insertItem( item, insertionIndex( lbTo, p ) );
+ lbTo->setFocus();
+ lbTo->setCurrentItem( item );
+
+ if ( p == Sorted )
+ lbTo->sort();
+ if ( lbTo == d->selectedListBox )
+ emit added( item );
+ else
+ emit removed( item );
+}
+
+int KActionSelector::insertionIndex( QListBox *lb, InsertionPolicy policy )
+{
+ int index;
+ switch ( policy )
+ {
+ case BelowCurrent:
+ index = lb->currentItem();
+ if ( index > -1 ) index += 1;
+ break;
+ case AtTop:
+ index = 0;
+ break;
+ default:
+ index = -1;
+ }
+ return index;
+}
+
+//END Private Methods
+#include "kactionselector.moc"
diff --git a/kbabel/commonui/kactionselector.h b/kbabel/commonui/kactionselector.h
new file mode 100644
index 00000000..324ed54f
--- /dev/null
+++ b/kbabel/commonui/kactionselector.h
@@ -0,0 +1,410 @@
+/***************************************************************************
+ KActionSelector.h
+ A widget for selecting and arranging actions/objects
+ -------------------
+ begin : Mon June 3 2002
+ copyright : (C) 2002 by Anders Lund
+ email : anders@alweb.dk
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ * *
+ * In addition, as a special exception, the copyright holders give *
+ * permission to link the code of this program with any edition of *
+ * the Qt library by Trolltech AS, Norway (or with modified versions *
+ * of Qt that use the same license as Qt), and distribute linked *
+ * combinations including the two. You must obey the GNU General *
+ * Public License in all respects for all of the code used other than *
+ * Qt. If you modify this file, you may extend this exception to *
+ * your version of the file, but you are not obligated to do so. If *
+ * you do not wish to do so, delete this exception statement from *
+ * your version. *
+ ***************************************************************************/
+
+#ifndef _KACTION_SELECTOR_H_
+#define _KACTION_SELECTOR_H_
+
+#include <qwidget.h>
+
+class QListBox;
+class QListBoxItem;
+class QKeyEvent;
+class QEvent;
+class QIconSet;
+
+class KActionSelectorPrivate;
+
+/**
+ @short A widget for selecting and arranging actions/objects
+ This widget allows the user to select from a set of objects and arrange
+ the order of the selected ones using two list boxes labeled "Available"
+ and "Used" with horizontal arrows in between to move selected objects between
+ the two, and vertical arrows on the right to arrange the order of the selected
+ objects.
+
+ The widget moves objects to the other listbox when doubleclicked if
+ the property moveOnDoubleClick is set to true (default). See moveOnDoubleClick()
+ and setMoveOnDoubleClick().
+
+ The user control the widget using the keyboard if enabled (default),
+ see keyboardEnabled.
+
+ Note that this may conflist with keyboard selection in the selected list box,
+ if you set that to anything else than QListBox::Single (which is the default).
+
+ To use it, simply construct an instance and then add items to the two listboxes,
+ available through lbAvailable() and lbSelected(). Whenever you want, you can retrieve
+ the selected options using QListBox methods on lbSelected().
+
+ This way, you can use your own QListBoxItem class, allowing you to easily
+ store object data in those.
+
+ When an item is moved to a listbox, it is placed below the current item
+ of that listbox.
+
+ Standard arrow icons are used, but you can use icons of your own choice if desired,
+ see setButtonIcon(). It is also possible to set tooltips and whatsthis help
+ for the buttons. See setButtonTooltip() and setButtonWhatsThis().
+
+ To set whatsthis or tooltips for the listboxes, access them through
+ availableListbox() and selectedListBox().
+
+ All the moving buttons are automatically set enabled as expected.
+
+ Signals are sent each time an item is moved, allowing you to follow the
+ users actions if you need to. See addedToSelection(), removedFromSelection(),
+ movedUp() and movedDown()
+
+ @author Anders Lund <anders@alweb.dk>
+*/
+
+class KActionSelector : public QWidget {
+ Q_OBJECT
+ Q_ENUMS( ButtonIconSize InsertionPolicy )
+ Q_PROPERTY( bool moveOnDoubleClick READ moveOnDoubleClick WRITE setMoveOnDoubleClick )
+ Q_PROPERTY( bool keyboardEnabled READ keyboardEnabled WRITE setKeyboardEnabled )
+ Q_PROPERTY( QString availableLabel READ availableLabel WRITE setAvailableLabel )
+ Q_PROPERTY( QString selectedLabel READ selectedLabel WRITE setSelectedLabel )
+ Q_PROPERTY( ButtonIconSize buttonIconSize READ buttonIconSize WRITE setButtonIconSize )
+ Q_PROPERTY( InsertionPolicy availableInsertionPolicy READ availableInsertionPolicy WRITE setAvailableInsertionPolicy )
+ Q_PROPERTY( InsertionPolicy selectedInsertionPolicy READ selectedInsertionPolicy WRITE setSelectedInsertionPolicy )
+ Q_PROPERTY( bool showUpDownButtons READ showUpDownButtons WRITE setShowUpDownButtons )
+
+public:
+ KActionSelector( QWidget *parent=0, const char *name=0 );
+ ~KActionSelector();
+
+ /**
+ @return The QListBox holding the available actions
+ */
+ QListBox *availableListBox();
+
+ /**
+ @return The QListBox holding the selected actions
+ */
+ QListBox *selectedListBox();
+
+ /**
+ This enum indentifies the moving buttons
+ */
+ enum MoveButton {
+ ButtonAdd,
+ ButtonRemove,
+ ButtonUp,
+ ButtonDown
+ };
+
+ /**
+ This enum identifies the icon sizes, used for the move buttons.
+ The values correspond to the following pixel sizes:
+ @li SmallIcon - the return value of IconSize( KIcon::Small ), the user defined size
+ of a small icon in KDE. This is the default setting.
+ @li Small - 16px
+ @li Medium - 22px
+ @li Large - 32px
+ @li XLarge - 48px
+ */
+ enum ButtonIconSize {
+ SmallIcon,
+ Small,
+ Medium,
+ Large,
+ XLarge
+ };
+
+ /**
+ This enum defines policies for where to insert moved items in a listbox.
+ The following policies are currently defined:
+ @li BelowCurrent - The item is inserted below the listbox'
+ currentItem() or at the end if there is no curent item.
+ @li Sorted - The listbox is sort()ed after one or more items are inserted.
+ @li AtTop - The item is inserted at index 0 in the listbox.
+ @li AtBottom - The item is inserted at the end of the listbox.
+
+ @sa availableInsertionPolicy(), setAvailableInsertionPolicy(),
+ selectedInsertionPolicy(), setSelectedInsertionPolicy().
+ */
+ enum InsertionPolicy {
+ BelowCurrent,
+ Sorted,
+ AtTop,
+ AtBottom
+ };
+
+ /**
+ @return Wheather moveOnDoubleClcik is enabled.
+
+ If enabled, an item in any listbox will be moved to the other one whenever
+ doubleclicked.
+ @sa setMoveOnDoubleClick()
+ */
+ bool moveOnDoubleClick() const;
+
+ /**
+ Sets moveOnDoubleClick to @p enable
+ @sa moveOnDoubleClick()
+ */
+ void setMoveOnDoubleClick( bool enable );
+
+ /**
+ @return Weather keyboard control is enabled.
+
+ When Keyboard control is enabled, the widget will react to
+ the following keyboard actions:
+ @li CTRL + Right - simulate clicking the add button
+ @li CTRL + Left - simulate clicking the remove button
+ @li CTRL + Up - simulate clicking the up button
+ @li CTRL + Down - simulate clicking the down button
+
+ Additionally, pressing RETURN or ENTER on one of the list boxes
+ will cause the current item of that listbox to be moved to the other
+ listbox.
+
+ The keyboard actions are enabled by default.
+
+ @sa setKeyboardEnabled()
+ */
+ bool keyboardEnabled() const;
+
+ /**
+ Sets the keyboard enabled depending on @p enable.
+ @sa keyboardEnabled()
+ */
+ void setKeyboardEnabled( bool enable );
+
+ /**
+ @return The text of the label for the available items listbox.
+ */
+ QString availableLabel() const;
+
+ /**
+ Sets the label for the available items listbox to @p text.
+ Note that this label has the listbox as its @e buddy, so that
+ if you have a single ampersand in the text, the following character
+ will become the accellerator to focus te listbox.
+ */
+ void setAvailableLabel( const QString & text );
+
+ /**
+ @return the label of the selected items listbox.
+ */
+ QString selectedLabel() const;
+
+ /**
+ Sets the label for the selected items listbox to @p text.
+ Note that this label has the listbox as its @e buddy, so that
+ if you have a single ampersand in the text, the following character
+ will become the accellerator to focus te listbox.
+ */
+ void setSelectedLabel( const QString & text );
+
+ /**
+ @return the current ButtonIconSize.
+ */
+ ButtonIconSize buttonIconSize() const;
+
+ /**
+ Sets the button icon size.
+ See ButtonIconSize for the possible values and their pixel meaning.
+ */
+ void setButtonIconSize( ButtonIconSize size );
+
+ /**
+ @return The current insertion policy for the available listbox.
+ The default policy for the available listbox is Sorted.
+ See also InsertionPolicy, setAvailableInsertionPolicy().
+ */
+ InsertionPolicy availableInsertionPolicy();
+
+ /**
+ Sets the insertion policy for the available listbox.
+ See also InsertionPolicy, availableInsertionPolicy().
+ */
+ void setAvailableInsertionPolicy( InsertionPolicy policy );
+
+ /**
+ @return The current insertion policy for the selected listbox.
+ The default policy for the selected listbox is BelowCurrent.
+ See also InsertionPolicy, setSelectedInsertionPolicy().
+ */
+ InsertionPolicy selectedInsertionPolicy();
+
+ /**
+ Sets the insertion policy for the selected listbox.
+ See also InsertionPolicy, selectedInsertionPolicy().
+ */
+ void setSelectedInsertionPolicy( InsertionPolicy policy );
+
+ /**
+ @return wheather the Up and Down buttons should be displayed.
+ */
+ bool showUpDownButtons();
+
+ /**
+ Sets wheather the Up and Down buttons should be displayed
+ according to @p show
+ */
+ void setShowUpDownButtons( bool show );
+
+ /**
+ Sets the pixmap of the button @p button to @p icon.
+ It calls @ref SmallIconSet(pm) to generate the icon set.
+ */
+ void setButtonIcon( const QString &icon, MoveButton button );
+
+ /**
+ Sets the iconset for button @p button to @p iconset.
+ You can use this method to et a costum icon set. Either
+ created by @ref QIconSet, or use the application instance of
+ @ref KIconLoader (recommended).
+ */
+ void setButtonIconSet( const QIconSet &iconset, MoveButton button );
+
+ /**
+ Sets the tooltip for the button @p button to @p tip.
+ */
+ void setButtonTooltip( const QString &tip, MoveButton button );
+
+ /**
+ Sets the whatsthis help for button @p button to @p text.
+ */
+ void setButtonWhatsThis( const QString &text, MoveButton button );
+
+ /**
+ Sets the enabled state of all moving buttons to reflect the current
+ options.
+
+ Be sure to call this if you add or removes items to either listbox after the
+ widget is show()n
+ */
+ void setButtonsEnabled();
+
+signals:
+ /**
+ Emitted when an item is moved to the "selected" listbox.
+ */
+ void added( QListBoxItem *item );
+
+ /**
+ Emitted when an item is moved out of the "selected" listbox.
+ */
+ void removed( QListBoxItem *item );
+
+ /**
+ Emitted when an item is moved upwards in the "selected" listbox.
+ */
+ void movedUp( QListBoxItem *item );
+
+ /**
+ Emitted when an item is moved downwards in the "selected" listbox.
+ */
+ void movedDown( QListBoxItem *item );
+
+ /**
+ Emitted when an item is moved to the "selected" listbox.
+ */
+// void addedToSelection( QListBoxItem *item );
+
+public slots:
+ /**
+ Reimplemented for internal reasons.
+ (calls setButtonsEnabled())
+ */
+ void polish();
+
+protected:
+ /**
+ Reimplamented for internal reasons.
+ */
+ void keyPressEvent( QKeyEvent * );
+
+ /**
+ Reimplemented for internal reasons.
+ */
+ bool eventFilter( QObject *, QEvent * );
+
+private slots:
+ /**
+ Move selected item from available box to the selected box
+ */
+ void buttonAddClicked();
+
+ /**
+ Move selected item from selected box to available box
+ */
+ void buttonRemoveClicked();
+
+ /**
+ Move selected item in selected box upwards
+ */
+ void buttonUpClicked();
+
+ /**
+ Move seleted item in selected box downwards
+ */
+ void buttonDownClicked();
+
+ /**
+ Moves the item @p item to the other listbox if moveOnDoubleClick is enabled.
+ */
+ void itemDoubleClicked( QListBoxItem *item );
+
+ /**
+ connected to both list boxes to set the buttons enabled
+ */
+ void slotCurrentChanged( QListBoxItem * ) { setButtonsEnabled(); };
+
+private:
+
+ /**
+ Move item @p item to the other listbox
+ */
+ void moveItem( QListBoxItem *item );
+
+ /**
+ loads the icons for the move buttons.
+ */
+ void loadIcons();
+
+ /**
+ @return the index to insert an item into listbox @p lb,
+ given InsertionPolicy @p policy.
+
+ Note that if policy is Sorted, this will return -1.
+ Sort the listbox after inserting the item in that case.
+ */
+ int insertionIndex( QListBox *lb, InsertionPolicy policy );
+
+ /** @private
+ Private data storage
+ */
+ KActionSelectorPrivate *d;
+};
+
+#endif // _KACTION_SELECTOR_H_
diff --git a/kbabel/commonui/kbabel_tool.desktop b/kbabel/commonui/kbabel_tool.desktop
new file mode 100644
index 00000000..3ae5922d
--- /dev/null
+++ b/kbabel/commonui/kbabel_tool.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KBabelTool
+
+[PropertyDef::Shortcuts]
+Type=QStringList
+
+[PropertyDef::ValidationString]
+Type=QString
diff --git a/kbabel/commonui/kbabel_validator.desktop b/kbabel/commonui/kbabel_validator.desktop
new file mode 100644
index 00000000..fd8ad4ac
--- /dev/null
+++ b/kbabel/commonui/kbabel_validator.desktop
@@ -0,0 +1,56 @@
+[Desktop Entry]
+Type=ServiceType
+X-KDE-ServiceType=KBabelValidator
+Comment=KDE Data Tool for KBabel
+Comment[bg]=Инструмент за данни на KDE - KBabel
+Comment[br]=Ostilh roadoù KDE evit KBabel
+Comment[bs]=KDE podatkovni alat za KBabel
+Comment[ca]=Eina de dades KDE per a KBabel
+Comment[cs]=Datový nástroj pro KBabel
+Comment[cy]=Erfyn Data KDE i KBabel
+Comment[da]=KDE Data-værktøj for KBabel
+Comment[de]=KDE Datenbearbeitungswerkzeug für KBabel
+Comment[el]=Εργαλείο δεδομένων για το KBabel του KDE
+Comment[es]=Herramienta de datos KDE para KBabel
+Comment[et]=KBabeli KDE andmete tööriist
+Comment[eu]=KBabel-erako KDE aatu tresna
+Comment[fa]=ابزار دادۀ KDE برای KBabel
+Comment[fi]=KBabelin KDE Data Tool
+Comment[fr]=Outil de données KDE pour KBabel
+Comment[gl]=Ferramenta de Datos de KDE para KBabel
+Comment[hi]=के-बेबल के लिए केडीई डाटा औज़ार
+Comment[hu]=Adatkezelő a KBabelhez
+Comment[is]=KDE gagnatól fyrir KBabel
+Comment[it]=Strumento KDE per la gestione dati con KBabel
+Comment[ja]=KBabel のための KDE データツール
+Comment[ka]=KBabel-ის KDE მონაცემთა ხელსაწყო
+Comment[kk]=KDE-нің KBabel-дің деректер құралы
+Comment[lt]=KDE duomenų įrankis, skirtas KBabel
+Comment[ms]=Alatan Data KDE untuk KBabel
+Comment[nb]=KDE dataverktøy for KBabel
+Comment[nds]=KDE-Datenwarktüüch för KBabel
+Comment[ne]=केब्याबलका लागि केडीई डाटा उपकरण
+Comment[nl]=KDE Dataprogramma voor KBabel
+Comment[nn]=KDE-dataverktøy for KBabel
+Comment[pa]=KBabel ਲਈ ਕੇਡੀਈ ਡਾਟਾ ਸੰਦ
+Comment[pl]=Narzędzie danych KDE dla KBabel
+Comment[pt]=Ferramenta de Dados do KDE para o KBabel
+Comment[pt_BR]=Ferramenta de Dados KDE para o KBabel
+Comment[ru]=Данные для KBabel
+Comment[sk]=Dátový nástroj pre KBabel
+Comment[sl]=Podatkovno orodje KDE za KBabel
+Comment[sr]=KDE-ов алат за податке за KBabel
+Comment[sr@Latn]=KDE-ov alat za podatke za KBabel
+Comment[sv]=KDE dataverktyg för Kbabel
+Comment[ta]=KDE Kபாபேலின் தரவுக் கருவி
+Comment[tg]=Маълумоти асбоби KDE барои KBabel
+Comment[tr]=KBabel için KDE Veri Aracı
+Comment[uk]=Засіб роботи з даними KDE для KBabel
+Comment[zh_CN]=KBabel 的 KDE 数据工具
+Comment[zh_TW]=KBabel 資料工具
+
+[PropertyDef::Shortcuts]
+Type=QStringList
+
+[PropertyDef::ValidationString]
+Type=QString
diff --git a/kbabel/commonui/klisteditor.ui b/kbabel/commonui/klisteditor.ui
new file mode 100644
index 00000000..63fbfceb
--- /dev/null
+++ b/kbabel/commonui/klisteditor.ui
@@ -0,0 +1,261 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KListEditor</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KListEditor</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>334</width>
+ <height>274</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QGroupBox">
+ <property name="name">
+ <cstring>_frame</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLineEdit">
+ <property name="name">
+ <cstring>_edit</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QListBox">
+ <item>
+ <property name="text">
+ <string>New Item</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_list</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>200</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>Layout5_2</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_addButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_removeButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_upButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Up</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>_downButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Down</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </hbox>
+ </widget>
+ </hbox>
+</widget>
+<connections>
+ <connection>
+ <sender>_addButton</sender>
+ <signal>pressed()</signal>
+ <receiver>KListEditor</receiver>
+ <slot>addToList()</slot>
+ </connection>
+ <connection>
+ <sender>_removeButton</sender>
+ <signal>pressed()</signal>
+ <receiver>KListEditor</receiver>
+ <slot>removeFromList()</slot>
+ </connection>
+ <connection>
+ <sender>_upButton</sender>
+ <signal>pressed()</signal>
+ <receiver>KListEditor</receiver>
+ <slot>upInList()</slot>
+ </connection>
+ <connection>
+ <sender>_downButton</sender>
+ <signal>pressed()</signal>
+ <receiver>KListEditor</receiver>
+ <slot>downInList()</slot>
+ </connection>
+ <connection>
+ <sender>_edit</sender>
+ <signal>returnPressed()</signal>
+ <receiver>KListEditor</receiver>
+ <slot>updateList()</slot>
+ </connection>
+ <connection>
+ <sender>_edit</sender>
+ <signal>textChanged(const QString&amp;)</signal>
+ <receiver>KListEditor</receiver>
+ <slot>editChanged(const QString&amp;)</slot>
+ </connection>
+ <connection>
+ <sender>_list</sender>
+ <signal>highlighted(int)</signal>
+ <receiver>KListEditor</receiver>
+ <slot>updateButtons(int)</slot>
+ </connection>
+ <connection>
+ <sender>_list</sender>
+ <signal>highlighted(const QString&amp;)</signal>
+ <receiver>_edit</receiver>
+ <slot>setText(const QString&amp;)</slot>
+ </connection>
+</connections>
+<includes>
+ <include location="local" impldecl="in implementation">klisteditor.ui.h</include>
+</includes>
+<signals>
+ <signal>itemsChanged()</signal>
+</signals>
+<slots>
+ <slot>addToList()</slot>
+ <slot>downInList()</slot>
+ <slot>removeFromList()</slot>
+ <slot>upInList()</slot>
+ <slot>updateButtons( int newIndex )</slot>
+ <slot>updateList()</slot>
+ <slot>setList( QStringList contents )</slot>
+ <slot access="protected">editChanged( const QString &amp; s )</slot>
+ <slot>setTitle( const QString &amp; s )</slot>
+ <slot returnType="QStringList">list()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/kbabel/commonui/klisteditor.ui.h b/kbabel/commonui/klisteditor.ui.h
new file mode 100644
index 00000000..bc916e56
--- /dev/null
+++ b/kbabel/commonui/klisteditor.ui.h
@@ -0,0 +1,122 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2002-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename slots use Qt Designer which will
+** update this file, preserving your code. Create an init() slot in place of
+** a constructor, and a destroy() slot in place of a destructor.
+*****************************************************************************/
+
+
+void KListEditor::addToList()
+{
+ _list->insertItem(_edit->text());
+ _edit->clear();
+ _removeButton->setEnabled(true);
+ emit itemsChanged();
+}
+
+void KListEditor::downInList()
+{
+ int i=_list->currentItem();
+ if( i< (int)_list->count()-1 ) {
+ QString ci = _list->currentText();
+ _list->removeItem(i);
+ _list->insertItem(ci,i+1);
+ _list->setCurrentItem(i+1);
+ }
+ emit itemsChanged();
+}
+
+void KListEditor::removeFromList()
+{
+ _list->removeItem(_list->currentItem());
+ if( _list->count()==0 ) _edit->clear();
+ _removeButton->setEnabled(_list->count()>0);
+ emit itemsChanged();
+}
+
+void KListEditor::upInList()
+{
+ int i=_list->currentItem();
+ if( i>0 ) {
+ QString ci = _list->currentText();
+ _list->removeItem(i);
+ _list->insertItem(ci,i-1);
+ _list->setCurrentItem(i-1);
+ }
+ emit itemsChanged();
+}
+
+void KListEditor::updateButtons( int newIndex )
+{
+ _upButton->setEnabled(newIndex>0);
+ _downButton->setEnabled(newIndex+1 != (int)_list->count());
+ _removeButton->setEnabled(true);
+}
+
+void KListEditor::updateList()
+{
+ int i=_list->currentItem();
+ if( i==-1 ) addToList();
+ else _list->changeItem(_edit->text(), i );
+}
+
+void KListEditor::setList( QStringList contents )
+{
+ _list->clear();
+ _list->insertStringList(contents);
+ _list->setCurrentItem(0);
+ _removeButton->setEnabled(!contents.isEmpty());
+}
+
+
+void KListEditor::editChanged( const QString &s )
+{
+ _addButton->setEnabled(!s.isEmpty());
+}
+
+
+void KListEditor::setTitle( const QString &s )
+{
+ _frame->setTitle(s);
+}
+
+
+QStringList KListEditor::list()
+{
+ QStringList result;
+ for( uint i=0; i<_list->count() ; i++ )
+ result.append(_list->text(i));
+ return result;
+}
diff --git a/kbabel/commonui/projectpref.cpp b/kbabel/commonui/projectpref.cpp
new file mode 100644
index 00000000..1bffa2e6
--- /dev/null
+++ b/kbabel/commonui/projectpref.cpp
@@ -0,0 +1,278 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2004-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "projectpref.h"
+#include "projectprefwidgets.h"
+#include "diffpreferences.h"
+#include "kbprojectsettings.h"
+
+#include <qlayout.h>
+#include <qwhatsthis.h>
+#include <qvbox.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+
+
+#define PAGE_IDENTITY 0
+#define PAGE_SAVE 1
+#define PAGE_SPELL 2
+#define PAGE_SOURCE 3
+#define PAGE_MISC 4
+#define PAGE_CATMAN 5
+#define PAGE_DIRCOMMANDS 6
+#define PAGE_FILECOMMANDS 7
+#define PAGE_VIEW 8
+#define PAGE_DIFF 9
+
+using namespace KBabel;
+
+ProjectDialog::ProjectDialog(Project::Ptr project)
+ : KConfigDialog(0, "project dialog", project->settings(),
+ IconList, Help|Default|Ok|Apply|Cancel)
+ , _project( project )
+{
+
+ _identityPage = new IdentityPreferences(0, project->name());
+ addPage(_identityPage, i18n("title of page in preferences dialog","Identity")
+ , "pref_identity"
+ , i18n("Information About You and Translation Team")
+ );
+
+ _savePage = new SavePreferences(0);
+ addPage(_savePage, i18n("title of page in preferences dialog","Save")
+ , "filesave"
+ , i18n("Options for File Saving"));
+
+
+ _spellPage = new SpellPreferences(0);
+ addPage(_spellPage, i18n("title of page in preferences dialog","Spelling")
+ , "spellcheck"
+ , i18n("Options for Spell Checking"));
+ connect( _spellPage, SIGNAL( settingsChanged() )
+ , this, SLOT(updateButtons()) );
+
+ _sourcePage = new SourceContextPreferences(0);
+ addPage(_sourcePage, i18n("title of page in preferences dialog","Source")
+ , "source"
+ ,i18n("Options for Showing Source Context"));
+ connect(_sourcePage, SIGNAL (itemsChanged())
+ , this, SLOT (updateButtons()) );
+
+ _miscPage = new MiscPreferences(0);
+ addPage(_miscPage, i18n("title of page in preferences dialog","Miscellaneous")
+ , "misc"
+ ,i18n("Miscellaneous Settings"));
+
+ _catmanPage = new CatmanPreferences(0);
+ addPage(_catmanPage, i18n("title of page in preferences dialog","Folders")
+ , "catalogmanager"
+ , i18n("Paths to Message Catalogs & Catalog Templates"));
+
+ _dirCommandsPage = new DirCommandsPreferences(0);
+ addPage(_dirCommandsPage, i18n("title of page in preferences dialog","Folder Commands")
+ , "folder"
+ , i18n("User-Defined Commands for Folder Items"));
+ connect( _dirCommandsPage, SIGNAL( settingsChanged() ),
+ this, SLOT(updateButtons()) );
+
+ _fileCommandsPage = new FileCommandsPreferences(0);
+ addPage(_fileCommandsPage, i18n("title of page in preferences dialog","File Commands")
+ , "files"
+ , i18n("User-Defined Commands for File Items"));
+ connect( _fileCommandsPage, SIGNAL( settingsChanged() ),
+ this, SLOT(updateButtons()) );
+
+ _viewPage = new ViewPreferences(0);
+ addPage(_viewPage, i18n("title of page in preferences dialog","Catalog Manager")
+ , "view_tree"
+ , i18n("Catalog Manager View Settings"));
+
+ _diffPage = new DiffPreferences(0);
+ addPage(_diffPage, i18n("title of page in preferences dialog","Diff")
+ , "diff"
+ , i18n("Searching for Differences"));
+
+ setHelp( "preferences-project-settings", "kbabel" );
+
+ adjustSize();
+}
+
+void ProjectDialog::slotDefault()
+{
+ // redefine the KConfigDialog behavior to push default on the
+ // current page only
+
+ _project->settings()->useDefaults(true);
+
+ switch(activePageIndex())
+ {
+ case PAGE_IDENTITY:
+ _identityPage->defaults(_project->identitySettings());
+ break;
+ case PAGE_SAVE:
+ _savePage->defaults(_project->saveSettings());
+ break;
+ case PAGE_MISC:
+ _miscPage->defaults(_project->miscSettings());
+ break;
+ case PAGE_SPELL:
+ _spellPage->defaults(_project->spellcheckSettings());
+ break;
+ case PAGE_SOURCE:
+ _sourcePage->defaults(_project->sourceContextSettings());
+ break;
+ case PAGE_CATMAN:
+ _catmanPage->defaults(_project->catManSettings());
+ break;
+ case PAGE_DIRCOMMANDS:
+ _dirCommandsPage->defaults(_project->catManSettings());
+ break;
+ case PAGE_FILECOMMANDS:
+ _fileCommandsPage->defaults(_project->catManSettings());
+ break;
+ case PAGE_VIEW:
+ _viewPage->defaults(_project->catManSettings());
+ break;
+ }
+
+ _project->settings()->useDefaults(false);
+}
+
+void ProjectDialog::updateSettings()
+{
+ KBabel::CatManSettings _CatManSettings;
+ SourceContextSettings contextSettings;
+
+ _spellPage->mergeSettings(_spellcheckSettings);
+ _dirCommandsPage->mergeSettings(_CatManSettings);
+ _fileCommandsPage->mergeSettings(_CatManSettings);
+ _sourcePage->mergeSettings(contextSettings);
+
+ _project->settings()->setDirCommands( _CatManSettings.dirCommands );
+ _project->settings()->setDirCommandNames( _CatManSettings.dirCommandNames );
+ _project->settings()->setFileCommands( _CatManSettings.fileCommands );
+ _project->settings()->setFileCommandNames( _CatManSettings.fileCommandNames );
+
+ _project->setSettings(_spellcheckSettings);
+
+ _project->settings()->setPaths( contextSettings.sourcePaths );
+}
+
+void ProjectDialog::updateWidgets()
+{
+ _spellPage->updateWidgets(_project->spellcheckSettings());
+ _dirCommandsPage->updateWidgets(_project->catManSettings());
+ _fileCommandsPage->updateWidgets(_project->catManSettings());
+ _sourcePage->updateWidgets(_project->sourceContextSettings());
+}
+
+void ProjectDialog::updateWidgetsDefault()
+{
+ _project->settings()->useDefaults( true );
+ updateWidgets();
+ _project->settings()->useDefaults( false );
+}
+
+bool ProjectDialog::isDefault()
+{
+ SourceContextSettings contextSettings, defaultContextSettings;
+
+ // get the current values
+ _spellPage->mergeSettings(_spellcheckSettings);
+ _dirCommandsPage->mergeSettings(_CatManSettings);
+ _fileCommandsPage->mergeSettings(_CatManSettings);
+ _sourcePage->mergeSettings(defaultContextSettings);
+
+ // get default values
+ _project->settings()->useDefaults(true);
+ SpellcheckSettings defaultSpell = _project->spellcheckSettings();
+ CatManSettings defaultCatMan = _project->catManSettings();
+ defaultContextSettings = _project->sourceContextSettings();
+ _project->settings()->useDefaults(false);
+
+ bool result = true;
+
+ result &= _spellcheckSettings.noRootAffix == defaultSpell.noRootAffix;
+ result &= _spellcheckSettings.runTogether == defaultSpell.runTogether;
+ result &= _spellcheckSettings.spellClient == defaultSpell.spellClient;
+ result &= _spellcheckSettings.spellDict == defaultSpell.spellDict;
+ result &= _spellcheckSettings.spellEncoding == defaultSpell.spellEncoding;
+
+ result &= _CatManSettings.dirCommandNames == defaultCatMan.dirCommandNames;
+ result &= _CatManSettings.dirCommands == defaultCatMan.dirCommands;
+ result &= _CatManSettings.fileCommandNames == defaultCatMan.fileCommandNames;
+ result &= _CatManSettings.fileCommands == defaultCatMan.fileCommands;
+
+ result &= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
+
+ return result;
+}
+
+bool ProjectDialog::hasChanged()
+{
+ SourceContextSettings contextSettings, defaultContextSettings;
+
+ // get the current values
+ _spellPage->mergeSettings(_spellcheckSettings);
+ _dirCommandsPage->mergeSettings(_CatManSettings);
+ _fileCommandsPage->mergeSettings(_CatManSettings);
+ _sourcePage->mergeSettings(contextSettings);
+
+ // get project values
+ SpellcheckSettings defaultSpell = _project->spellcheckSettings();
+ CatManSettings defaultCatMan = _project->catManSettings();
+ defaultContextSettings = _project->sourceContextSettings();
+
+ bool result = false;
+
+ result |= _spellcheckSettings.noRootAffix != defaultSpell.noRootAffix;
+ result |= _spellcheckSettings.runTogether != defaultSpell.runTogether;
+ result |= _spellcheckSettings.spellClient != defaultSpell.spellClient;
+ result |= _spellcheckSettings.spellDict != defaultSpell.spellDict;
+ result |= _spellcheckSettings.spellEncoding != defaultSpell.spellEncoding;
+
+ result |= _CatManSettings.dirCommandNames != defaultCatMan.dirCommandNames;
+ result |= _CatManSettings.dirCommands != defaultCatMan.dirCommands;
+ result |= _CatManSettings.fileCommandNames != defaultCatMan.fileCommandNames;
+ result |= _CatManSettings.fileCommands != defaultCatMan.fileCommands;
+
+ result |= contextSettings.sourcePaths != defaultContextSettings.sourcePaths;
+
+ return result;
+}
+
+#include "projectpref.moc"
diff --git a/kbabel/commonui/projectpref.h b/kbabel/commonui/projectpref.h
new file mode 100644
index 00000000..90561c5b
--- /dev/null
+++ b/kbabel/commonui/projectpref.h
@@ -0,0 +1,93 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2004-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef PROJECTPREF_H
+#define PROJECTPREF_H
+
+#include <kconfigdialog.h>
+#include <qptrlist.h>
+
+class SavePreferences;
+class IdentityPreferences;
+class MiscPreferences;
+class SpellPreferences;
+class CatmanPreferences;
+class DirCommandsPreferences;
+class FileCommandsPreferences;
+class ViewPreferences;
+class SourceContextPreferences;
+class DiffPreferences;
+
+#include "kbproject.h"
+#include "projectsettings.h"
+#include "context.h"
+
+namespace KBabel {
+
+class KDE_EXPORT ProjectDialog : public KConfigDialog
+{
+ Q_OBJECT
+public:
+ ProjectDialog(Project::Ptr project);
+
+protected slots:
+ virtual void slotDefault();
+ virtual void updateSettings();
+ virtual void updateWidgets();
+ virtual void updateWidgetsDefault();
+
+private:
+ virtual bool hasChanged();
+ virtual bool isDefault();
+
+ SavePreferences *_savePage;
+ IdentityPreferences* _identityPage;
+ MiscPreferences* _miscPage;
+ SpellPreferences* _spellPage;
+ SourceContextPreferences* _sourcePage;
+ CatmanPreferences *_catmanPage;
+ DirCommandsPreferences *_dirCommandsPage;
+ FileCommandsPreferences *_fileCommandsPage;
+ ViewPreferences *_viewPage;
+ DiffPreferences *_diffPage;
+
+ KBabel::SpellcheckSettings _spellcheckSettings;
+ KBabel::CatManSettings _CatManSettings;
+
+ Project::Ptr _project;
+};
+
+}
+
+#endif // PROJECTPREF_H
diff --git a/kbabel/commonui/projectprefwidgets.cpp b/kbabel/commonui/projectprefwidgets.cpp
new file mode 100644
index 00000000..16bc2da4
--- /dev/null
+++ b/kbabel/commonui/projectprefwidgets.cpp
@@ -0,0 +1,1209 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2000 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2001-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "klisteditor.h"
+#include "toolselectionwidget.h"
+#include "projectprefwidgets.h"
+#include "resources.h"
+#include "kbabeldictbox.h"
+#include "toolaction.h"
+#include "cmdedit.h"
+#include "kbprojectsettings.h"
+
+#include <kcombobox.h>
+#include <kdatatool.h>
+#include <klocale.h>
+#include <kdialog.h>
+#include <kfiledialog.h>
+#include <knuminput.h>
+#include <kmessagebox.h>
+#include <klineedit.h>
+#include <kurlcompletion.h>
+#include <kfontdialog.h>
+#include <kcolorbutton.h>
+#include <kparts/componentfactory.h>
+#include <kregexpeditorinterface.h>
+#include <ksconfig.h>
+#include <kurldrag.h>
+#include <kurlrequester.h>
+
+#include <qlayout.h>
+#include <qobjectlist.h>
+#include <qlabel.h>
+#include <qvbox.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qhbuttongroup.h>
+#include <qvbuttongroup.h>
+#include <qpushbutton.h>
+#include <qcombobox.h>
+#include <qradiobutton.h>
+#include <qspinbox.h>
+#include <qtextcodec.h>
+#include <qwhatsthis.h>
+
+using namespace KBabel;
+
+static QSize sizeHintForWidget(const QWidget* widget)
+{
+ //
+ // The size is computed by adding the sizeHint().height() of all
+ // widget children and taking the width of the widest child and adding
+ // layout()->margin() and layout()->spacing()
+ //
+
+ QSize size;
+
+ int numChild = 0;
+ QObjectList *l = (QObjectList*)(widget->children());
+
+ for( uint i=0; i < l->count(); i++ )
+ {
+ QObject *o = l->at(i);
+ if( o->isWidgetType() )
+ {
+ numChild += 1;
+ QWidget *w=((QWidget*)o);
+
+ QSize s = w->sizeHint();
+ if( s.isEmpty() == true )
+ {
+ s = QSize( 50, 100 ); // Default size
+ }
+ size.setHeight( size.height() + s.height() );
+ if( s.width() > size.width() ) { size.setWidth( s.width() ); }
+ }
+ }
+
+ if( numChild > 0 )
+ {
+ size.setHeight( size.height() + widget->layout()->spacing()*(numChild-1) );
+ size += QSize( widget->layout()->margin()*2, widget->layout()->margin()*2 + 1 );
+ }
+ else
+ {
+ size = QSize( 1, 1 );
+ }
+
+ return( size );
+}
+
+
+
+
+SavePreferences::SavePreferences(QWidget *parent)
+ : KTabCtl(parent)
+{
+ QWidget* page = new QWidget(this);
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box=new QGroupBox(1,Qt::Horizontal,page);
+ layout->addWidget(box);
+
+ box->setMargin(KDialog::marginHint());
+ _updateButton = new QCheckBox(i18n("&Update header when saving"),box, "kcfg_AutoUpdate");
+ _descriptionButton = new QCheckBox(i18n("Update &description comment when saving"),box, "kcfg_UpdateDescription");
+ _autoCheckButton = new QCheckBox(i18n("Chec&k syntax of file when saving"),box, "kcfg_AutoSyntaxCheck");
+ _saveObsoleteButton = new QCheckBox(i18n("Save &obsolete entries"),box, "kcfg_SaveObsolete");
+
+ QGroupBox* descBox=new QGroupBox(1,Qt::Horizontal,i18n("De&scription"),page);
+ layout->addWidget(descBox);
+
+ descBox->setMargin(KDialog::marginHint());
+ _descriptionEdit = new QLineEdit(descBox, "kcfg_DescriptionString");
+
+ QGroupBox* encodingBox = new QGroupBox(1,Qt::Horizontal,i18n("Encoding")
+ ,page);
+ encodingBox->setMargin(KDialog::marginHint());
+ layout->addWidget(encodingBox);
+ QHBox *b = new QHBox(encodingBox);
+
+ QLabel* tempLabel=new QLabel(i18n("Default:"),b);
+ _encodingBox = new QComboBox(b, "kcfg_Encoding");
+ b->setStretchFactor(_encodingBox,2);
+ b->setSpacing(KDialog::spacingHint());
+
+ QString defaultName=charsetString(ProjectSettingsBase::Locale);
+ defaultName+=" "+i18n("(default)");
+ QString utf8Name=charsetString(ProjectSettingsBase::UTF8);
+ QString utf16Name=charsetString(ProjectSettingsBase::UTF16);
+
+ _encodingBox->insertItem(defaultName,(int)ProjectSettingsBase::Locale);
+ _encodingBox->insertItem(utf8Name,(int)ProjectSettingsBase::UTF8);
+
+ // KBabel seems to crash somehow, when saving in utf16, so
+ // it's better to disable this, since it is useless anyway
+ // at the moment
+ //_encodingBox->insertItem(utf16Name,(int)UTF16);
+
+ tempLabel->setBuddy(_encodingBox);
+
+ _oldEncodingButton = new QCheckBox(i18n("Kee&p the encoding of the file")
+ ,encodingBox, "kcfg_UseOldEncoding");
+
+ _autoSaveBox = new QGroupBox( 1, Qt::Horizontal, i18n( "Automatic Saving" ), page );
+ _autoSaveBox->setMargin( KDialog::marginHint( ) );
+ layout->addWidget( _autoSaveBox );
+ _autoSaveDelay = new KIntNumInput( _autoSaveBox, "kcfg_AutoSaveDelay" );
+ _autoSaveDelay->setRange( 0, 60 );
+ _autoSaveDelay->setSuffix( i18n( "Short for minutes", " min" ) );
+ _autoSaveDelay->setSpecialValueText( i18n( "No autosave" ) );
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+ addTab(page, i18n("&General"));
+
+ page = new QWidget(this);
+ layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* gridBox = new QGroupBox(2,Qt::Horizontal,i18n("Fields to Update"),page);
+ layout->addWidget(gridBox);
+ gridBox->setMargin(KDialog::marginHint());
+
+ _revisionButton = new QCheckBox(i18n("Re&vision-Date"),gridBox, "kcfg_UpdateRevisionDate");
+ _lastButton = new QCheckBox(i18n("Last-&Translator"),gridBox, "kcfg_UpdateLastTranslator");
+ _languageButton = new QCheckBox(i18n("&Language"),gridBox, "kcfg_UpdateLanguageTeam");
+ _charsetButton = new QCheckBox(i18n("Char&set"),gridBox, "kcfg_UpdateCharset");
+ _encodingButton = new QCheckBox(i18n("&Encoding"),gridBox, "kcfg_UpdateEncoding");
+ _projectButton = new QCheckBox(i18n("Pro&ject"),gridBox, "kcfg_UpdateProject");
+
+ QButtonGroup* dateBox = new QButtonGroup(2,Qt::Horizontal,i18n("Format of Revision-Date"),page, "kcfg_DateFormat");
+ layout->addWidget(dateBox);
+ box->setMargin(KDialog::marginHint());
+
+ // we remove/insert default date button to correctly map Qt::DateFormat to our Ids
+ _defaultDateButton = new QRadioButton( i18n("De&fault date format"),dateBox );
+ dateBox->remove (_defaultDateButton);
+ _localDateButton = new QRadioButton( i18n("Local date fo&rmat"),dateBox );
+ dateBox->remove (_localDateButton);
+ _customDateButton = new QRadioButton( i18n("Custo&m date format:"),dateBox );
+
+ dateBox->insert (_defaultDateButton);
+ dateBox->insert (_localDateButton);
+
+ _dateFormatEdit = new QLineEdit(dateBox, "kcfg_CustomDateFormat");
+ _dateFormatEdit->setEnabled(false);
+
+ connect( _customDateButton, SIGNAL(toggled(bool)), this, SLOT( customDateActivated(bool) ) );
+
+ QGroupBox* projectBox = new QGroupBox(1,Qt::Horizontal,i18n("Project String")
+ ,page);
+ projectBox->setMargin(KDialog::marginHint());
+ layout->addWidget(projectBox);
+ b = new QHBox(projectBox);
+
+ tempLabel=new QLabel(i18n("Project-Id:"),b);
+ _projectEdit = new QLineEdit(b, "kcfg_ProjectString");
+ b->setStretchFactor(_projectEdit,2);
+ b->setSpacing(KDialog::spacingHint());
+ tempLabel->setBuddy(_projectEdit);
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+ addTab(page, i18n("&Header"));
+
+ page = new QWidget(this);
+ layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* translatorCopyrightBox = new QGroupBox(1,Qt::Horizontal, page);
+ translatorCopyrightBox->setMargin(KDialog::marginHint());
+ _translatorCopyrightButton =
+ new QCheckBox(i18n("Update &translator copyright")
+ ,translatorCopyrightBox, "kcfg_UpdateTranslatorCopyright");
+ layout->addWidget(translatorCopyrightBox);
+
+ QGroupBox* fsfBox=new QButtonGroup(1,Qt::Horizontal,i18n("Free Software Foundation Copyright"),page, "kcfg_FSFCopyright");
+ layout->addWidget(fsfBox);
+
+ fsfBox->setMargin(KDialog::marginHint());
+ _removeFSFButton = new QRadioButton(i18n("&Remove copyright if empty"),fsfBox);
+ _updateFSFButton = new QRadioButton(i18n("&Update copyright"),fsfBox);
+ _nochangeFSFButton = new QRadioButton(i18n("Do &not change"),fsfBox);
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+ addTab(page, i18n("Cop&yright"));
+
+ QWhatsThis::add(_updateButton,
+ i18n("<qt><p><b>Update Header</b></p>\n"
+ "<p>Check this button to update the header "
+ "information of the file "
+ "every time it is saved.</p>\n"
+ "<p>The header normally keeps information about "
+ "the date and time the file was last\n"
+ "updated, the last translator etc.</p>\n"
+ "<p>You can choose which information you want to update from the checkboxes below.\n"
+ "Fields that do not exist are added to the header.\n"
+ "If you want to add additional fields to the header, you can edit the header manually by choosing\n"
+ "<b>Edit->Edit Header</b> in the editor window.</p></qt>"));
+
+ QWhatsThis::add(gridBox,i18n("<qt><p><b>Fields to update</b></p>\n"
+ "<p>Choose which fields in the header you want to have updated when saving.\n"
+ "If a field does not exist, it is appended to the header.</p>\n"
+ "<p>If you want to add other information to the header, you have to edit the header manually\n"
+ "by choosing <b>Edit->Edit Header</b> in the editor window.</p>\n"
+ "<p>Deactivate <b>Update Header</b> above if you do not want to have the header\n"
+ "updated when saving.</p></qt>"));
+
+ QWhatsThis::add(encodingBox,i18n("<qt><p><b>Encoding</b></p>"
+"<p>Choose how to encode characters when saving to a file. If you are unsure "
+"what encoding to use, please ask your translation coordinator.</p>"
+"<ul><li><b>%1</b>: this is the encoding that fits the character "
+"set of your system language.</li>"
+"<li><b>%2</b>: uses Unicode (UTF-8) encoding.</li>"
+"</ul></qt>").arg(defaultName).arg(utf8Name) );
+
+
+ QWhatsThis::add(_oldEncodingButton
+ ,i18n("<qt><p><b>Keep the encoding of the file</b></p>"
+ "<p>If this option is activated, files are always saved in the "
+ "same encoding as they were read in. Files without charset "
+ "information in the header (e.g. POT files) are saved in the "
+ "encoding set above.</p></qt>"));
+
+ QWhatsThis::add(_autoCheckButton,i18n("<qt><p><b>Check syntax of file when saving</b></p>\n"
+"<p>Check this to automatically check syntax of file with \"msgfmt --statistics\"\n"
+"when saving a file. You will only get a message, if an error occurred.</p></qt>"));
+
+ QWhatsThis::add(_saveObsoleteButton,i18n("<qt><p><b>Save obsolete entries</b></p>\n"
+"<p>If this option is activated, obsolete entries found when the file was open\n"
+"will be saved back to the file. Obsolete entries are marked by #~ and are\n"
+"created when the msgmerge does not need the translation anymore.\n"
+"If the text will appear again, the obsolete entries will be activated again.\n"
+"The main drawback is the size of the saved file.</p></qt>"));
+
+
+ QWhatsThis::add(dateBox, i18n("<qt><p><b>Format of Revision-Date</b></p>"
+"<p>Choose in which format the date and time of the header field\n"
+"<i>PO-Revision-Date</i> is saved: <ul>\n"
+"<li><b>Default</b> is the format normally used in PO files.</li>\n"
+"<li><b>Local</b> is the format specific to your country.\n"
+"It can be configured in KDE's Control Center.</li>\n"
+"<li><b>Custom</b> lets you define your own format.</li></ul></p> "
+"<p>It is recommended that you use the default format to avoid creating non-standard PO files.</p>"
+"<p>For more information, see section <b>The Preferences Dialog</b> "
+"in the online help.</p>"
+"</qt>") );
+
+ setMinimumSize(sizeHint());
+}
+
+
+void SavePreferences::defaults(const KBabel::SaveSettings& _settings)
+{
+ _updateButton->setChecked(_settings.autoUpdate);
+
+ _lastButton->setChecked(_settings.updateLastTranslator);
+ _revisionButton->setChecked(_settings.updateRevisionDate);
+ _languageButton->setChecked(_settings.updateLanguageTeam);
+ _charsetButton->setChecked(_settings.updateCharset);
+ _encodingButton->setChecked(_settings.updateEncoding);
+ _projectButton->setChecked(_settings.updateProject);
+
+ _encodingBox->setCurrentItem(_settings.encoding);
+ _oldEncodingButton->setChecked(_settings.useOldEncoding);
+
+ _projectEdit->setText(_settings.projectString);
+
+ _descriptionButton->setChecked(_settings.updateDescription);
+ _descriptionEdit->setText(_settings.descriptionString);
+ _translatorCopyrightButton->setChecked(_settings.updateTranslatorCopyright);
+
+ switch(_settings.FSFCopyright)
+ {
+ case ProjectSettingsBase::Update:
+ _updateFSFButton->setChecked(true);
+ break;
+ case ProjectSettingsBase::Remove:
+ _removeFSFButton->setChecked(true);
+ break;
+ case ProjectSettingsBase::NoChange:
+ _nochangeFSFButton->setChecked(true);
+ break;
+ case ProjectSettingsBase::RemoveLine:
+ break;
+ }
+
+ _autoCheckButton->setChecked(_settings.autoSyntaxCheck);
+ _saveObsoleteButton->setChecked(_settings.saveObsolete);
+
+ _dateFormatEdit->setText(_settings.customDateFormat);
+
+ switch(_settings.dateFormat)
+ {
+ case Qt::ISODate:
+ _defaultDateButton->setChecked(true);
+ break;
+ case Qt::LocalDate:
+ _localDateButton->setChecked(true);
+ break;
+ case Qt::TextDate:
+ _customDateButton->setChecked(true);
+ break;
+ }
+
+ _autoSaveDelay->setValue( _settings.autoSaveDelay );
+}
+
+
+void SavePreferences::customDateActivated(bool on)
+{
+ _dateFormatEdit->setEnabled(on);
+ _dateFormatEdit->setFocus();
+}
+
+void SavePreferences::setAutoSaveVisible( const bool on )
+{
+ if( on ) _autoSaveBox->show();
+ else _autoSaveBox->hide();
+}
+
+
+
+IdentityPreferences::IdentityPreferences(QWidget* parent, const QString& project)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ if( !project.isEmpty() )
+ {
+ // show the project name in the widget at the top
+ layout->addWidget(new QLabel(i18n("<font size=\"+1\">Project: %1</font>").arg(project),page));
+ }
+
+ QGroupBox* group = new QGroupBox(2,Qt::Horizontal,page);
+ layout->addWidget(group);
+ group->setMargin(KDialog::marginHint());
+
+ QLabel* tempLabel=new QLabel(i18n("&Name:"),group);
+ _nameEdit = new QLineEdit(group, "kcfg_AuthorName");
+ tempLabel->setBuddy(_nameEdit);
+
+ tempLabel=new QLabel(i18n("Localized na&me:"),group);
+ _localNameEdit = new QLineEdit(group, "kcfg_LocalAuthorName");
+ tempLabel->setBuddy(_localNameEdit);
+
+ tempLabel=new QLabel(i18n("E&mail:"),group);
+ _mailEdit = new QLineEdit(group, "kcfg_AuthorEmail");
+ tempLabel->setBuddy(_mailEdit);
+
+
+ tempLabel=new QLabel(i18n("&Full language name:"),group);
+
+ QHBox *hbox = new QHBox(group);
+ hbox->setSpacing(KDialog::spacingHint());
+ _langEdit = new QLineEdit(hbox, "kcfg_Language");
+ tempLabel->setBuddy(_langEdit);
+ tempLabel=new QLabel(i18n("Lan&guage code:"),hbox);
+ _langCodeEdit = new QLineEdit(hbox, "kcfg_LanguageCode");
+ tempLabel->setBuddy(_langCodeEdit);
+ connect(_langCodeEdit,SIGNAL(textChanged(const QString&)), this
+ , SLOT(checkTestPluralButton()));
+
+ tempLabel=new QLabel(i18n("&Language mailing list:"),group);
+ _listEdit = new QLineEdit(group, "kcfg_Mailinglist");
+ _listEdit->setMinimumSize(100,_listEdit->sizeHint().height());
+ tempLabel->setBuddy(_listEdit);
+
+ tempLabel=new QLabel(i18n("&Timezone:"), group);
+ _timezoneEdit = new QLineEdit(group, "kcfg_Timezone");
+ _timezoneEdit->setMinimumSize(100,_timezoneEdit->sizeHint().height());
+ tempLabel->setBuddy(_timezoneEdit);
+
+
+ QString whatsThisMsg=i18n("<qt><p><b>Identity</b></p>\n"
+"<p>Fill in information about you and your translation team.\n"
+"This information is used when updating the header of a file.</p>\n"
+"<p>You can find the options if and what fields in the header should be updated\n"
+"on page <b>Save</b> in this dialog.</p></qt>");
+
+ QWhatsThis::add(group,whatsThisMsg);
+
+
+ group = new QGroupBox(1,Qt::Horizontal,page);
+ layout->addWidget(group);
+ group->setMargin(KDialog::marginHint());
+
+ hbox = new QHBox(group);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ QLabel *label = new QLabel(i18n("&Number of singular/plural forms:"), hbox);
+ _pluralFormsBox = new QSpinBox(0,100,1,hbox, "kcfg_PluralForms");
+ _pluralFormsBox->setSpecialValueText(
+ i18n("automatic choose number of plural forms","Automatic"));
+ label->setBuddy(_pluralFormsBox);
+ connect(_pluralFormsBox,SIGNAL(valueChanged(int)), this
+ , SLOT(checkTestPluralButton()));
+
+ hbox->setStretchFactor(_pluralFormsBox,1);
+
+ _testPluralButton = new QPushButton(i18n("Te&st"),hbox);
+ _testPluralButton->setEnabled(false);
+ connect(_testPluralButton, SIGNAL(clicked()), this
+ , SLOT(testPluralForm()));
+
+ const QString msg=i18n("<qt><p><b>Number of singular/plural forms</b></p>"
+ "<p><b>Note</b>: This option is KDE specific. "
+ "If you are not translating a KDE application, you can safely "
+ "ignore this option.</p>"
+ "<p>Choose here how many singular and plural forms are used in "
+ "your language. "
+ "This number must correspond to the settings of your language "
+ "team.</p>"
+ "<p>Alternatively, you can set this option to "
+ "<i>Automatic</i> and KBabel will try to get this information "
+ "automatically from KDE. Use the <i>Test</i> button "
+ "to test if it can find it out.</p></qt>");
+ QWhatsThis::add(_pluralFormsBox,msg);
+ QWhatsThis::add(_testPluralButton,msg);
+
+ QVBox* vbox = new QVBox(group);
+ vbox->setSpacing(KDialog::spacingHint());
+
+ label = new QLabel(i18n("&GNU plural form header:"), vbox);
+
+ hbox = new QHBox(vbox);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ _gnuPluralFormHeaderEdit = new QLineEdit(hbox, "kcfg_PluralFormsHeader");
+ label->setBuddy(_gnuPluralFormHeaderEdit);
+
+ hbox->setStretchFactor(_gnuPluralFormHeaderEdit,1);
+
+ _testGnuPluralFormButton = new QPushButton(i18n("&Lookup"),hbox);
+ connect(_testGnuPluralFormButton, SIGNAL(clicked()), this
+ , SLOT(lookupGnuPluralFormHeader()));
+
+ _checkPluralArgumentBox = new QCheckBox( i18n("Re&quire plural form arguments in translation")
+ , group, "kcfg_CheckPluralArgument" );
+ QWhatsThis::add(_checkPluralArgumentBox,
+ i18n("<qt><p><b>Require plural form arguments in translation</b></p>\n"
+ "<p><b>Note</b>: This option is KDE specific at the moment. "
+ "If you are not translating a KDE application, you can safely "
+ "ignore this option.</p>\n"
+ "<p>If is this option enabled, the validation check will "
+ "require the %n argument to be present in the message.</p></qt>"));
+
+ QWhatsThis::add(_gnuPluralFormHeaderEdit,
+ i18n("<qt><p><b>GNU plural form header</b></p>\n"
+ "<p>Here you can fill a header entry for GNU plural form handling; "
+ "if you leave the entry empty, the entry in the PO file will not be "
+ "changed or added.</p>\n"
+ "<p>KBabel can automatically try to determine value suggested by the "
+ "GNU gettext tools for currently set language; just press the <b>Lookup</b> "
+ "button.</p></qt>"));
+
+ layout->addStretch(1);
+
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+
+ _mailEdit->installEventFilter(this);
+ _listEdit->installEventFilter(this);
+}
+
+void IdentityPreferences::defaults(const IdentitySettings& settings)
+{
+ _nameEdit->setText(settings.authorName);
+ _localNameEdit->setText(settings.authorLocalizedName);
+ _langEdit->setText(settings.languageName);
+ _langCodeEdit->setText(settings.languageCode);
+ _listEdit->setText(settings.mailingList);
+ _timezoneEdit->setText(settings.timeZone);
+ _pluralFormsBox->setValue(settings.numberOfPluralForms);
+ _gnuPluralFormHeaderEdit->setText(settings.gnuPluralFormHeader);
+ _checkPluralArgumentBox->setChecked(settings.checkPluralArgument);
+}
+
+bool IdentityPreferences::eventFilter(QObject *o, QEvent *e)
+{
+ if(e->type() == QEvent::Drop)
+ {
+ QDropEvent *de = static_cast<QDropEvent*>(e);
+ KURL::List urlList;
+ if(de && KURLDrag::decode(de,urlList))
+ {
+ KURL url(urlList.first());
+ if(url.protocol()== "mailto")
+ {
+ QString mail=url.path();
+
+ bool handled=false;
+ if(o == _mailEdit)
+ {
+ handled=true;
+ _mailEdit->setText(mail);
+ }
+ else if(o == _listEdit)
+ {
+ handled=true;
+ _listEdit->setText(mail);
+ }
+
+ if(handled)
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void IdentityPreferences::checkTestPluralButton()
+{
+ int val = _pluralFormsBox->value();
+ QString lang=_langCodeEdit->text();
+
+ _testPluralButton->setEnabled(val==0 && !lang.isEmpty());
+}
+
+void IdentityPreferences::testPluralForm()
+{
+ QString lang=_langCodeEdit->text();
+
+ if(lang.isEmpty())
+ {
+ KMessageBox::sorry(this,i18n("Please insert a language code first."));
+ return;
+ }
+
+ int number=Catalog::getNumberOfPluralForms(lang);
+
+ QString msg;
+
+ if(number < 0)
+ {
+ msg = i18n("It is not possible to find out the number "
+ "of singular/plural forms automatically for the "
+ "language code \"%1\".\n"
+ "Do you have kdelibs.po installed for this language?\n"
+ "Please set the correct number manually.").arg(lang);
+ }
+ else
+ {
+ msg = i18n("The number of singular/plural forms found for "
+ "the language code \"%1\" is %2.").arg(lang).arg(number);
+ }
+
+ if(!msg.isEmpty())
+ {
+ KMessageBox::information(this,msg);
+ }
+}
+
+void IdentityPreferences::lookupGnuPluralFormHeader()
+{
+ QString lang=_langCodeEdit->text();
+
+ if(lang.isEmpty())
+ {
+ KMessageBox::sorry(this,i18n("Please insert a language code first."));
+ return;
+ }
+
+ QString header=GNUPluralForms(lang);
+
+ if( header.isEmpty() )
+ {
+ KMessageBox::information(this, i18n("It was not possible to determine "
+ "GNU header for plural forms. Maybe your GNU gettext tools are too "
+ "old or they do not contain a suggested value for your language.") );
+ }
+ else
+ {
+ _gnuPluralFormHeaderEdit->setText( header );
+ }
+}
+
+
+MiscPreferences::MiscPreferences(QWidget *parent)
+ : QWidget(parent), _regExpEditDialog(0)
+{
+ QWidget* page = this;
+
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box=new QGroupBox(1,Qt::Horizontal,page);
+ box->setMargin(KDialog::marginHint());
+ layout->addWidget(box);
+
+ QHBox *hbox = new QHBox(box);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ QLabel *label = new QLabel(i18n("&Marker for keyboard accelerator:"),hbox);
+ accelMarkerEdit = new KLineEdit(hbox, "kcfg_AccelMarker");
+ accelMarkerEdit->setMaxLength(1);
+ label->setBuddy(accelMarkerEdit);
+ hbox->setStretchFactor(accelMarkerEdit,1);
+ QString msg=i18n("<qt><p><b>Marker for keyboard accelerator</b></p>"
+ "<p>Define here, what character marks the following "
+ "character as keyboard accelerator. For example in Qt it is "
+ "'&amp;' and in Gtk it is '_'.</p></qt>");
+ QWhatsThis::add(label,msg);
+ QWhatsThis::add(accelMarkerEdit,msg);
+
+
+ hbox = new QHBox(box);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ label = new QLabel(i18n("&Regular expression for context information:")
+ ,hbox);
+ contextInfoEdit = new KLineEdit(hbox, "kcfg_ContextInfo");
+ label->setBuddy(contextInfoEdit);
+ hbox->setStretchFactor(contextInfoEdit,1);
+
+ msg=i18n("<qt><p><b>Regular expression for context information</b></p>"
+ "<p>Enter a regular expression here which defines what is "
+ "context information in the message and must not get "
+ "translated.</p></qt>");
+ QWhatsThis::add(label,msg);
+ QWhatsThis::add(contextInfoEdit,msg);
+
+ if( !KTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() )
+ {
+ _regExpButton = new QPushButton( i18n("&Edit..."), hbox );
+ connect( _regExpButton, SIGNAL( clicked() ), this, SLOT( regExpButtonClicked()));
+ }
+
+
+ // preferences for mail attachments
+ QVButtonGroup* vbgroup = new QVButtonGroup(page);
+ vbgroup->setTitle(i18n("Compression Method for Mail Attachments"));
+ vbgroup->setRadioButtonExclusive(true);
+ vbgroup->setMargin(KDialog::marginHint());
+ layout->addWidget(vbgroup);
+
+ bzipButton = new QRadioButton(i18n("tar/&bzip2"), vbgroup, "kcfg_BZipCompression");
+ gzipButton = new QRadioButton(i18n("tar/&gzip"), vbgroup);
+
+ compressSingle = new QCheckBox(i18n("&Use compression when sending "
+ "a single file"), vbgroup, "kcfg_CompressSingleFile");
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+}
+
+void MiscPreferences::defaults(const MiscSettings& settings)
+{
+ accelMarkerEdit->setText(settings.accelMarker);
+ contextInfoEdit->setText(settings.contextInfo.pattern());
+ if( settings.useBzip )
+ bzipButton->setChecked (true);
+ else
+ gzipButton->setChecked (true);
+
+ compressSingle->setChecked(settings.compressSingleFile);
+}
+
+QString MiscPreferences::contextInfo() const
+{
+ QString temp=contextInfoEdit->text();
+
+ bool quoted=false;
+ QString newStr;
+
+ for(uint i=0; i<temp.length(); i++)
+ {
+ if(temp[i]=='n')
+ {
+ quoted=!quoted;
+ newStr+=temp[i];
+ }
+ else if(temp[i]=='n' && quoted)
+ {
+ newStr[newStr.length()-1]='\n';
+ quoted=false;
+ }
+ else
+ {
+ quoted=false;
+ newStr+=temp[i];
+ }
+ }
+
+ return newStr;
+}
+
+void MiscPreferences::setContextInfo(QString reg)
+{
+ reg.replace("\n","\\n");
+ contextInfoEdit->setText(reg);
+}
+
+void MiscPreferences::regExpButtonClicked()
+{
+ if ( _regExpEditDialog==0 )
+ _regExpEditDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>
+ ("KRegExpEditor/KRegExpEditor", QString::null, this );
+
+ KRegExpEditorInterface *iface = dynamic_cast<KRegExpEditorInterface *>( _regExpEditDialog );
+ if( iface )
+ {
+ iface->setRegExp( contextInfoEdit->text() );
+ if( _regExpEditDialog->exec() == QDialog::Accepted )
+ contextInfoEdit->setText( iface->regExp() );
+ }
+}
+
+
+SpellPreferences::SpellPreferences(QWidget* parent)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+
+ onFlyBtn = new QCheckBox(i18n("On the &fly spellchecking"),page, "kcfg_OnFlySpellCheck");
+ layout->addWidget(onFlyBtn);
+
+ QWhatsThis::add(onFlyBtn, i18n("<qt><p><b>On the fly spellchecking</b></p>"
+ "<p>Activate this to let KBabel spell check the text "
+ "as you type. Mispelled words will be colored by the error color.</p></qt>"));
+
+ spellConfig = new KSpellConfig(page,"spellConfigWidget",0,false);
+ layout->addWidget(spellConfig);
+ remIgnoredBtn = new QCheckBox(i18n("&Remember ignored words"),page, "kcfg_RememberIgnored");
+ layout->addWidget(remIgnoredBtn);
+
+ connect( spellConfig, SIGNAL( configChanged() )
+ , this, SIGNAL ( settingsChanged() ) );
+
+ QLabel *tempLabel = new QLabel(i18n("F&ile to store ignored words:"),page);
+ layout->addWidget(tempLabel);
+ ignoreURLEdit = new KURLRequester(page, "kcfg_IgnoreURL");
+ layout->addWidget(ignoreURLEdit);
+ tempLabel->setBuddy(ignoreURLEdit);
+
+ connect(remIgnoredBtn,SIGNAL(toggled(bool)),ignoreURLEdit
+ ,SLOT(setEnabled(bool)));
+
+
+ QString msg = i18n("<qt><p><b>Remember ignored words</b></p>"
+ "<p>Activate this, to let KBabel ignore the words, where you have "
+ "chosen <i>Ignore All</i> in the spell check dialog, "
+ "in every spell check.</p></qt>");
+
+ QWhatsThis::add(remIgnoredBtn,msg);
+ QWhatsThis::add(tempLabel,msg);
+ QWhatsThis::add(ignoreURLEdit,msg);
+
+ layout->addStretch(1);
+
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+}
+
+
+
+void SpellPreferences::updateWidgets(const SpellcheckSettings& settings)
+{
+ spellConfig->setClient(settings.spellClient);
+ spellConfig->setNoRootAffix(settings.noRootAffix);
+ spellConfig->setRunTogether(settings.runTogether);
+ spellConfig->setEncoding(settings.spellEncoding);
+ spellConfig->setDictionary(settings.spellDict);
+}
+
+
+void SpellPreferences::mergeSettings(SpellcheckSettings& settings) const
+{
+ settings.noRootAffix=spellConfig->noRootAffix();
+ settings.runTogether=spellConfig->runTogether();
+ settings.spellClient=spellConfig->client();
+ settings.spellEncoding=spellConfig->encoding();
+ settings.spellDict=spellConfig->dictionary();
+
+ settings.valid=true;
+}
+
+void SpellPreferences::defaults(const SpellcheckSettings& settings)
+{
+ remIgnoredBtn->setChecked(settings.rememberIgnored);
+ ignoreURLEdit->setURL(settings.ignoreURL);
+
+ onFlyBtn->setChecked(settings.onFlySpellcheck);
+
+ KSpellConfig spCfg;
+ *spellConfig = spCfg;
+}
+
+CatmanPreferences::CatmanPreferences(QWidget* parent)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box=new QGroupBox(1,Qt::Horizontal,page);
+ box->setMargin(KDialog::marginHint());
+ layout->addWidget(box);
+
+ QLabel* label=new QLabel(i18n("&Base folder of PO files:"),box);
+ QHBox* hbox = new QHBox(box);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ const KFile::Mode mode = static_cast<KFile::Mode>( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
+
+
+ _poDirEdit = new KURLRequester(hbox, "kcfg_PoBaseDir");
+ _poDirEdit->setMode( mode );
+ _poDirEdit->setMinimumSize(250,_poDirEdit->sizeHint().height());
+ label->setBuddy(_poDirEdit);
+
+
+ label=new QLabel(i18n("Ba&se folder of POT files:"),box);
+ hbox = new QHBox(box);
+ hbox->setSpacing(KDialog::spacingHint());
+
+ _potDirEdit = new KURLRequester(hbox, "kcfg_PotBaseDir");
+ _potDirEdit->setMode( mode );
+ _potDirEdit->setMinimumSize(250,_potDirEdit->sizeHint().height());
+ label->setBuddy(_potDirEdit);
+
+
+
+ QWhatsThis::add(box,i18n("<qt><p><b>Base folders</b></p>\n"
+ "<p>Type in the folders which contain all your PO and POT files.\n"
+ "The files and the folders in these folders will then be merged into one\n"
+ "tree.</p></qt>"));
+
+
+ box=new QGroupBox(1,Qt::Horizontal,page);
+ box->setMargin(KDialog::marginHint());
+ layout->addWidget(box);
+
+ _openWindowButton = new QCheckBox(i18n("O&pen files in new window"),box, "kcfg_OpenWindow");
+
+
+ QWhatsThis::add(_openWindowButton,i18n("<qt><p><b>Open files in new window</b></p>\n"
+"<p>If this is activated all files that are opened from the Catalog Manager are opened\n"
+"in a new window.</p></qt>"));
+
+ _killButton = new QCheckBox( i18n("&Kill processes on exit") , box, "kcfg_KillCmdOnExit" );
+
+ QWhatsThis::add( _killButton , i18n("<qt><p><b>Kill processes on exit</b></p>\n"
+"<p>If you check this, KBabel tries to kill the processes, that have not exited already when KBabel exits,\n"
+"by sending a kill signal to them.</p>\n"
+"<p>NOTE: It is not guaranteed that the processes will be killed.</p></qt>") );
+
+
+ _indexButton = new QCheckBox( i18n("Create inde&x for file contents"), box, "kcfg_IndexWords" );
+
+ QWhatsThis::add( _indexButton , i18n("<qt><p><b>Create index for file contents</b></p>\n"
+"<p>If you check this, KBabel will create an index for each PO file to speed up the find/replace functions.</p>\n"
+"<p>NOTE: This will slow down updating the file information considerably.</p></qt>") );
+
+ m_msgfmtButton = new QCheckBox( i18n("Run &msgfmt before processing a file"), box, "kcfg_msgfmt" );
+
+ QWhatsThis::add( m_msgfmtButton, i18n("<qt><p><b>Run msgfmt before processing a file</b></p>"
+ "<p>If you enable this, KBabel will run Gettext's "
+ "msgfmt tool before processing a file.</p>"
+ "<p>Enabling this setting is recommended, even if it causes processing to be slower. "
+ "This setting is enabled by default.</p>"
+ "<p>Disabling is useful for slow computers and when you want "
+ "to translate PO files that are not supported by the current version "
+ "of the Gettext tools that are on your system. "
+ "The drawback of disabling is that hardly any syntax checking is done by the processing code, "
+ "so invalid PO files could be shown as good ones, "
+ "even if Gettext tools would reject such files.</p></qt>") );
+
+ layout->addStretch(1);
+
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+}
+
+
+void CatmanPreferences::defaults(const CatManSettings& settings)
+{
+ _poDirEdit->setURL(settings.poBaseDir);
+ _potDirEdit->setURL(settings.potBaseDir);
+
+ _openWindowButton->setChecked(settings.openWindow);
+
+ _killButton->setChecked(settings.killCmdOnExit );
+ _indexButton->setChecked(settings.indexWords );
+ m_msgfmtButton->setChecked( settings.msgfmt );
+}
+
+DirCommandsPreferences::DirCommandsPreferences(QWidget* parent)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box = new QGroupBox( 1 , Qt::Horizontal , i18n("Commands for Folders") , page );
+ box->setMargin( KDialog::marginHint() );
+ layout->addWidget( box );
+
+ _dirCmdEdit = new CmdEdit( box );
+ new QLabel( i18n("Replaceables:\n@PACKAGE@, @PODIR@, @POTDIR@\n"
+ "@POFILES@, @MARKEDPOFILES@"), box);
+
+ connect (_dirCmdEdit, SIGNAL(widgetChanged()), this, SIGNAL(settingsChanged()));
+
+ QWhatsThis::add( box , i18n("<qt><p><b>Commands for folders</b></p>"
+"<p>Insert here the commands you want to execute in folders from "
+"the Catalog Manager. The commands are then shown in the submenu "
+"<b>Commands</b> in the Catalog Manager's context menu.</p>"
+"<p>The following strings will be replaced in a command:<ul>"
+"<li>@PACKAGE@: The name of the folder without path</li>"
+"<li>@PODIR@: The name of the PO-folder with path</li>"
+"<li>@POTDIR@: The name of the template folder with path</li>"
+"<li>@POFILES@: The names of the PO files with path</li>"
+"<li>@MARKEDPOFILES@: The names of the marked PO files with path</li>"
+"</ul></p>"
+"</qt>") );
+
+
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+}
+
+
+DirCommandsPreferences::~DirCommandsPreferences()
+{
+}
+
+
+void DirCommandsPreferences::updateWidgets(const CatManSettings& settings)
+{
+ _dirCmdEdit->setCommands( settings.dirCommands , settings.dirCommandNames );
+}
+
+
+void DirCommandsPreferences::mergeSettings(CatManSettings& settings) const
+{
+ _dirCmdEdit->commands( settings.dirCommands , settings.dirCommandNames );
+}
+
+void DirCommandsPreferences::defaults(const CatManSettings& settings)
+{
+ _dirCmdEdit->setCommands( settings.dirCommands, settings.dirCommandNames );
+}
+
+
+FileCommandsPreferences::FileCommandsPreferences(QWidget* parent)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box=new QGroupBox( 1 , Qt::Horizontal , i18n("Commands for Files") , page );
+ box->setMargin( KDialog::marginHint() );
+ layout->addWidget( box );
+
+ _fileCmdEdit = new CmdEdit( box );
+ new QLabel( i18n("Replaceables:\n"
+"@PACKAGE@, @POFILE@,@POTFILE@,\n@PODIR@, @POTDIR@"), box);
+
+ connect (_fileCmdEdit, SIGNAL(widgetChanged()), this, SIGNAL(settingsChanged()));
+
+ QWhatsThis::add( box , i18n("<qt><p><b>Commands for files</b></p>"
+"<p>Insert here the commands you want to execute on files from "
+"the Catalog Manager. The commands are then shown in the submenu "
+"<b>Commands</b> in the Catalog Manager's context menu.</p>"
+"<p>The following strings will be replaced in a command:<ul>"
+"<li>@PACKAGE@: The name of the file without path and extension</li>"
+"<li>@POFILE@: The name of the PO-file with path and extension</li>"
+"<li>@POTFILE@: The name of the corresponding template file with path "
+"and extension</li>"
+"<li>@POEMAIL@: The name and email address of the last translator</li>"
+"<li>@PODIR@: The name of the folder the PO-file is in, with path</li>"
+"<li>@POTDIR@: The name of the folder the template file is in, with "
+"path</li></ul></p></qt>") );
+
+
+
+ layout->addStretch(1);
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+}
+
+
+FileCommandsPreferences::~FileCommandsPreferences()
+{
+}
+
+
+void FileCommandsPreferences::updateWidgets(const CatManSettings& settings)
+{
+ _fileCmdEdit->setCommands( settings.fileCommands , settings.fileCommandNames );
+}
+
+
+void FileCommandsPreferences::mergeSettings(CatManSettings& settings) const
+{
+ _fileCmdEdit->commands( settings.fileCommands , settings.fileCommandNames );
+}
+
+void FileCommandsPreferences::defaults(const CatManSettings& settings)
+{
+ _fileCmdEdit->setCommands( settings.fileCommands, settings.fileCommandNames );
+}
+
+ViewPreferences::ViewPreferences(QWidget* parent)
+ : QWidget(parent)
+{
+ QWidget* page = this;
+
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QGroupBox* box=new QGroupBox(2, Qt::Horizontal,i18n("Shown Columns"),page);
+ box->setMargin(KDialog::marginHint());
+ layout->addWidget(box);
+
+ _flagColumnCheckbox = new QCheckBox( i18n("Fla&g"), box, "kcfg_ShowFlagColumn" );
+ _fuzzyColumnCheckbox = new QCheckBox( i18n("&Fuzzy"), box, "kcfg_ShowFuzzyColumn" );
+ _untranslatedColumnCheckbox = new QCheckBox( i18n("&Untranslated"), box, "kcfg_ShowUntranslatedColumn" );
+ _totalColumnCheckbox = new QCheckBox( i18n("&Total"), box, "kcfg_ShowTotalColumn" );
+ _cvsColumnCheckbox = new QCheckBox( i18n("SVN/&CVS status"), box, "kcfg_ShowCVSColumn" );
+ _revisionColumnCheckbox = new QCheckBox( i18n("Last &revision"), box, "kcfg_ShowRevisionColumn" );
+ _translatorColumnCheckbox = new QCheckBox( i18n("Last t&ranslator"), box, "kcfg_ShowTranslatorColumn" );
+
+ QWhatsThis::add(box,i18n("<qt><p><b>Shown columns</b></p>\n"
+ "<p></p></qt>"));
+
+ layout->addStretch(1);
+
+ page->setMinimumSize(sizeHintForWidget(page));
+
+ setMinimumSize(sizeHint());
+}
+
+
+void ViewPreferences::defaults(const CatManSettings& _settings)
+{
+ _flagColumnCheckbox->setChecked(_settings.flagColumn);
+ _fuzzyColumnCheckbox->setChecked(_settings.fuzzyColumn);
+ _untranslatedColumnCheckbox->setChecked(_settings.untranslatedColumn);
+ _totalColumnCheckbox->setChecked(_settings.totalColumn);
+ _cvsColumnCheckbox->setChecked(_settings.cvsColumn);
+ _revisionColumnCheckbox->setChecked(_settings.revisionColumn);
+ _translatorColumnCheckbox->setChecked(_settings.translatorColumn);
+}
+
+SourceContextPreferences::SourceContextPreferences(QWidget* parent): QWidget(parent)
+{
+ QWidget* page = this;
+ QVBoxLayout* layout=new QVBoxLayout(page);
+ layout->setSpacing(KDialog::spacingHint());
+ layout->setMargin(KDialog::marginHint());
+
+ QHBox* box = new QHBox(page);
+ box->setSpacing(KDialog::spacingHint());
+ QLabel* tempLabel=new QLabel(i18n("&Base folder for source code:"),box);
+
+ const KFile::Mode mode = static_cast<KFile::Mode>( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
+ _coderootEdit = new KURLRequester ( box, "kcfg_CodeRoot" );
+ _coderootEdit->setMode( mode );
+ _coderootEdit->setMinimumSize( 250, _coderootEdit->sizeHint().height() );
+ tempLabel->setBuddy( _coderootEdit );
+ layout->addWidget(box);
+
+ // FIXME: use KConfigXT
+ _pathsEditor = new KListEditor(page);
+ _pathsEditor->setTitle(i18n("Path Patterns"));
+ layout->addWidget(_pathsEditor);
+
+ connect ( _pathsEditor, SIGNAL (itemsChanged ())
+ , this, SIGNAL (itemsChanged ()));
+
+ _pathsEditor->installEventFilter(this);
+
+ setMinimumSize(sizeHint());
+}
+
+SourceContextPreferences::~SourceContextPreferences()
+{
+}
+
+void SourceContextPreferences::mergeSettings(KBabel::SourceContextSettings& settings) const
+{
+ settings.sourcePaths=_pathsEditor->list();
+}
+
+void SourceContextPreferences::updateWidgets(const KBabel::SourceContextSettings& settings)
+{
+ _pathsEditor->setList(settings.sourcePaths);
+}
+
+void SourceContextPreferences::defaults(const KBabel::SourceContextSettings& settings)
+{
+ _pathsEditor->setList(settings.sourcePaths);
+}
+
+bool SourceContextPreferences::eventFilter( QObject *, QEvent *e )
+{
+ if( e->type() == QEvent::KeyPress )
+ {
+ QKeyEvent *ke = dynamic_cast<QKeyEvent*>(e);
+ if( ke->key() == Key_Return || ke->key() == Key_Enter )
+ return true;
+ }
+ return false;
+}
+
+#include "projectprefwidgets.moc"
diff --git a/kbabel/commonui/projectprefwidgets.h b/kbabel/commonui/projectprefwidgets.h
new file mode 100644
index 00000000..81a1b3e6
--- /dev/null
+++ b/kbabel/commonui/projectprefwidgets.h
@@ -0,0 +1,285 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2001 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2001-2005 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef PROJECTPREFWIDGETS_H
+#define PROJECTPREFWIDGETS_H
+
+#include <ktabctl.h>
+#include <qptrlist.h>
+#include "projectsettings.h"
+
+
+class KLineEdit;
+class QLineEdit;
+class QCheckBox;
+class QComboBox;
+class QListBox;
+class QRadioButton;
+class QSpinBox;
+class CmdEdit;
+class KFontChooser;
+class KColorButton;
+class KComboBox;
+class KSpellConfig;
+class KURLRequester;
+class QPushButton;
+class QGroupBox;
+class KListEditor;
+class ToolSelectionWidget;
+class KIntNumInput;
+class KURLRequester;
+
+struct ModuleInfo;
+
+class KDE_EXPORT SavePreferences : public KTabCtl
+{
+ Q_OBJECT
+public:
+ SavePreferences(QWidget* parent=0);
+ void defaults(const KBabel::SaveSettings& settings);
+ void setAutoSaveVisible(const bool on);
+
+private:
+ QCheckBox* _lastButton;
+ QCheckBox* _revisionButton;
+ QCheckBox* _languageButton;
+ QCheckBox* _charsetButton;
+ QCheckBox* _encodingButton;
+ QCheckBox* _projectButton;
+
+ QCheckBox* _updateButton;
+ QCheckBox* _autoCheckButton;
+ QCheckBox* _saveObsoleteButton;
+
+ QComboBox* _encodingBox;
+ QCheckBox* _oldEncodingButton;
+
+ QRadioButton* _defaultDateButton;
+ QRadioButton* _localDateButton;
+ QRadioButton* _customDateButton;
+ QLineEdit* _dateFormatEdit;
+
+ QLineEdit* _projectEdit;
+
+ QRadioButton* _removeFSFButton;
+ QRadioButton* _updateFSFButton;
+ QRadioButton* _nochangeFSFButton;
+ QCheckBox* _translatorCopyrightButton;
+
+ QCheckBox* _descriptionButton;
+ QLineEdit* _descriptionEdit;
+
+ KIntNumInput * _autoSaveDelay;
+ QGroupBox * _autoSaveBox;
+
+private slots:
+ void customDateActivated(bool on);
+};
+
+
+class IdentityPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ IdentityPreferences(QWidget *parent = 0, const QString& project = "");
+ virtual bool eventFilter(QObject *, QEvent*);
+ void defaults(const KBabel::IdentitySettings& settings);
+
+private slots:
+ void checkTestPluralButton();
+ void testPluralForm();
+ void lookupGnuPluralFormHeader();
+
+private:
+ QLineEdit* _nameEdit;
+ QLineEdit* _localNameEdit;
+ QLineEdit* _mailEdit;
+ QLineEdit* _langEdit;
+ QLineEdit* _langCodeEdit;
+ QLineEdit* _listEdit;
+
+ QLineEdit* _timezoneEdit;
+ QSpinBox *_pluralFormsBox;
+ QPushButton *_testPluralButton;
+ QCheckBox* _checkPluralArgumentBox;
+ QLineEdit* _gnuPluralFormHeaderEdit;
+ QPushButton *_testGnuPluralFormButton;
+};
+
+
+class MiscPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ MiscPreferences(QWidget *parent=0);
+ void defaults(const KBabel::MiscSettings& settings);
+
+private slots:
+ void regExpButtonClicked();
+
+private:
+ void setContextInfo(QString reg);
+ QString contextInfo() const;
+
+ KLineEdit *contextInfoEdit;
+ KLineEdit *accelMarkerEdit;
+
+ QDialog *_regExpEditDialog;
+ QPushButton *_regExpButton;
+
+ QRadioButton* bzipButton;
+ QRadioButton* gzipButton;
+ QCheckBox* compressSingle;
+};
+
+class SpellPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ SpellPreferences(QWidget *parent=0);
+
+ void mergeSettings(KBabel::SpellcheckSettings& set) const;
+ void updateWidgets(const KBabel::SpellcheckSettings& settings);
+ void defaults(const KBabel::SpellcheckSettings& settings);
+
+signals:
+ void settingsChanged();
+
+private:
+ KSpellConfig* spellConfig;
+ QCheckBox* remIgnoredBtn;
+ QCheckBox* onFlyBtn;
+ KURLRequester* ignoreURLEdit;
+
+};
+
+class CatmanPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ CatmanPreferences(QWidget *parent = 0);
+ void defaults(const KBabel::CatManSettings& settings);
+
+private:
+ KURLRequester* _poDirEdit;
+ KURLRequester* _potDirEdit;
+
+ QCheckBox* _openWindowButton;
+
+ QCheckBox* _killButton;
+ QCheckBox* _indexButton;
+ QCheckBox* m_msgfmtButton;
+};
+
+class DirCommandsPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ DirCommandsPreferences(QWidget *parent = 0);
+ virtual ~DirCommandsPreferences();
+
+ void mergeSettings(KBabel::CatManSettings& settings) const;
+ void updateWidgets(const KBabel::CatManSettings&);
+ void defaults(const KBabel::CatManSettings& settings);
+
+signals:
+ void settingsChanged();
+
+private:
+ CmdEdit* _dirCmdEdit;
+};
+
+class FileCommandsPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ FileCommandsPreferences(QWidget *parent = 0);
+ virtual ~FileCommandsPreferences();
+
+ void mergeSettings(KBabel::CatManSettings& settings) const;
+ void updateWidgets(const KBabel::CatManSettings& settings);
+ void defaults(const KBabel::CatManSettings& settings);
+
+signals:
+ void settingsChanged();
+
+private:
+ CmdEdit* _fileCmdEdit;
+};
+
+class ViewPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ ViewPreferences(QWidget *parent = 0);
+ void defaults(const KBabel::CatManSettings& settings);
+
+private:
+ QCheckBox* _flagColumnCheckbox;
+ QCheckBox* _fuzzyColumnCheckbox;
+ QCheckBox* _untranslatedColumnCheckbox;
+ QCheckBox* _totalColumnCheckbox;
+ QCheckBox* _cvsColumnCheckbox;
+ QCheckBox* _revisionColumnCheckbox;
+ QCheckBox* _translatorColumnCheckbox;
+};
+
+/**
+* This class implements preference widget for source context
+*
+* @short Class for setting preferences for source context
+* @author Stanislav Visnovsky <visnovsky@kde.org>
+*/
+class SourceContextPreferences : public QWidget
+{
+ Q_OBJECT
+public:
+ SourceContextPreferences(QWidget* parent=0);
+ virtual ~SourceContextPreferences();
+
+ void mergeSettings(KBabel::SourceContextSettings& settings) const;
+ void updateWidgets(const KBabel::SourceContextSettings& settings);
+ void defaults(const KBabel::SourceContextSettings& settings);
+
+ virtual bool eventFilter(QObject *, QEvent*);
+
+signals:
+ void itemsChanged ();
+
+private:
+ KURLRequester* _coderootEdit;
+ KListEditor* _pathsEditor;
+};
+
+#endif // PROJECTPREFWIDGETS_H
diff --git a/kbabel/commonui/projectwizard.cpp b/kbabel/commonui/projectwizard.cpp
new file mode 100644
index 00000000..d1202f4a
--- /dev/null
+++ b/kbabel/commonui/projectwizard.cpp
@@ -0,0 +1,172 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2004 by StanislavVsinovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+
+#include "projectwizard.h"
+#include "projectwizardwidget.h"
+#include "projectwizardwidget2.h"
+
+#include "kbprojectmanager.h"
+
+#include <qcombobox.h>
+
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <kurlrequester.h>
+
+using namespace KBabel;
+
+ProjectWizard::ProjectWizard(QWidget *parent,const char *name)
+ : KWizard(parent,name,true)
+{
+ _wizard = new ProjectStep1(this,"project wizard widget");
+
+ // fill the known language codes
+ KConfig all_languages("all_languages", true, false, "locale");
+ QStringList lang_codes = KGlobal::locale()->allLanguagesTwoAlpha();
+ for (QStringList::iterator it = lang_codes.begin();
+ it != lang_codes.end(); ++it)
+ {
+ // we need untranslated entries here, because of Translation Robot!
+ QString entry = (*it);
+ const int i = entry.find('_');
+ entry.replace(0, i, entry.left(i).lower());
+ all_languages.setGroup(entry);
+ entry = all_languages.readEntryUntranslated("Name");
+ if( ! entry.isEmpty() )
+ {
+ _wizard->_projectLanguage->insertItem( entry );
+ m_language_codes[entry] = (*it);
+ }
+ }
+
+ connect( _wizard->_projectName, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+ connect( _wizard->_projectFile, SIGNAL(textChanged(const QString &)), this, SLOT(textChanged(const QString &)));
+ connect( this, SIGNAL( helpClicked( void ) ), this, SLOT( slotHelpClicked( void ) ) );
+
+ addPage(_wizard, i18n("Basic Project Information"));
+
+ _wizard2 = new ProjectStep2(this,"project wizard widget2");
+ _wizard2->_poDirEdit->setMode( KFile::Directory );
+ _wizard2->_potDirEdit->setMode( KFile::Directory );
+ addPage(_wizard2, i18n("Translation Files"));
+
+ setFinishEnabled (_wizard2, true);
+ setNextEnabled (_wizard, false);
+}
+
+QString ProjectWizard::url()
+{
+ return _wizard->_projectFile->url();
+}
+
+Project::Ptr ProjectWizard::project()
+{
+ Project::Ptr p = ProjectManager::open( _wizard->_projectFile->url() );
+ p->setName( _wizard->_projectName->text() );
+
+ enum type { KDE, GNOME, TP, Other };
+
+ type project_type = (type) _wizard->_projectType->currentItem();
+
+ KBabel::CatManSettings catman = p->catManSettings();
+ catman.poBaseDir = _wizard2->_poDirEdit->url();
+ catman.potBaseDir = _wizard2->_potDirEdit->url();
+ p->setSettings (catman);
+
+ KBabel::IdentitySettings identity = p->identitySettings();
+ // Language
+ identity.languageName = _wizard->_projectLanguage->currentText();
+ // LanguageCode
+ identity.languageCode = m_language_codes[identity.languageName];
+ p->setSettings (identity);
+
+ KBabel::SaveSettings save = p->saveSettings();
+ // autochecksyntax (not for KDE - it uses incompatible plural forms formatting)
+ if( project_type == KDE )
+ {
+ save.autoSyntaxCheck = false;
+ }
+ p->setSettings (save);
+
+ KBabel::MiscSettings misc = p->miscSettings();
+ if (project_type == GNOME)
+ {
+ misc.accelMarker = '_';
+ }
+ p->setSettings (misc);
+
+ return p;
+}
+
+void ProjectWizard::next()
+{
+ // check if the file exists
+ QFileInfo file(url());
+
+ if( file.exists() )
+ {
+ if (KMessageBox::warningContinueCancel(0, i18n("The file '%1' already exists.\n"
+ "Do you want to replace it?").arg(url()), i18n("File Exists"), i18n("Replace") ) == KMessageBox::Cancel)
+ return;
+ }
+
+ KWizard::next();
+}
+
+void ProjectWizard::textChanged(const QString &)
+{
+ setNextEnabled( _wizard, !_wizard->_projectName->text().isEmpty() && !_wizard->_projectFile->url().isEmpty() );
+}
+
+Project::Ptr ProjectWizard::newProject()
+{
+ ProjectWizard* dialog = new ProjectWizard();
+ if( dialog->exec() == QDialog::Accepted )
+ {
+ Project::Ptr res = dialog->project();
+ delete dialog;
+ res->config()->sync();
+ return res;
+ }
+
+ return 0;
+}
+
+void ProjectWizard::slotHelpClicked( void )
+{
+ kapp->invokeHelp( "preferences-project-wizard", "kbabel" );
+}
+
+#include "projectwizard.moc"
diff --git a/kbabel/commonui/projectwizard.h b/kbabel/commonui/projectwizard.h
new file mode 100644
index 00000000..5c994784
--- /dev/null
+++ b/kbabel/commonui/projectwizard.h
@@ -0,0 +1,74 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2004 by Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef PROJECTWIZARD_H
+#define PROJECTWIZARD_H
+
+#include <kwizard.h>
+
+#include "kbproject.h"
+
+#include "qmap.h"
+#include "qstring.h"
+
+class ProjectStep1;
+class ProjectStep2;
+
+namespace KBabel {
+
+class KDE_EXPORT ProjectWizard : public KWizard
+{
+ Q_OBJECT
+public:
+ ProjectWizard(QWidget* parent = 0, const char * name = 0);
+
+ Project::Ptr project();
+
+ QString url();
+
+ static Project::Ptr newProject();
+
+private slots:
+ void textChanged(const QString &);
+ void slotHelpClicked( void );
+ virtual void next();
+
+private:
+ ProjectStep1* _wizard;
+ ProjectStep2* _wizard2;
+
+ QMap<QString, QString> m_language_codes;
+};
+
+}
+
+#endif // PROJECTPREF_H
diff --git a/kbabel/commonui/projectwizardwidget.ui b/kbabel/commonui/projectwizardwidget.ui
new file mode 100644
index 00000000..3ad04de7
--- /dev/null
+++ b/kbabel/commonui/projectwizardwidget.ui
@@ -0,0 +1,266 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ProjectStep1</class>
+<author>Stanislav Visnovsky &lt;visnovsky@kde.org&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ProjectStep1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>486</width>
+ <height>432</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;font size="+1"&gt;Welcome to Project Wizard!&lt;/font&gt;
+&lt;br/&gt;
+&lt;p&gt;
+The wizard will help you to setup a new translation
+project for KBabel.
+&lt;/p&gt;
+&lt;p&gt;
+First of all, you need to choose the project name
+and the file, where the configuration should be stored.
+&lt;/p&gt;
+&lt;p&gt;
+You should also choose a language to translate into
+and also a type of the translation project.
+&lt;/p&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KURLRequester" row="1" column="1">
+ <property name="name">
+ <cstring>_projectFile</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;&lt;b&gt;Configuration File Name&lt;/b&gt;&lt;br/&gt;
+The name of a file to store the configuration of the
+project.&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Language:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_projectLanguage</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;
+&lt;b&gt;Language&lt;/b&gt;&lt;br/&gt;
+The destination language of the project, i.e., the language
+to translate into. It should follow the ISO 631 language naming
+standard.&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Project &amp;name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_projectName</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;&lt;p&gt;&lt;b&gt;Project name&lt;/b&gt;&lt;br/&gt;
+The project name is an identification of a project for
+you. It is shown in the project configuration dialog
+as well as in the title of windows opened for the project.
+&lt;br/&gt;
+&lt;br/&gt;
+&lt;b&gt;Note:&lt;/b&gt; The project name cannot be later changed.&lt;
+&lt;/p&gt;&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="2" column="1">
+ <property name="name">
+ <cstring>_projectLanguage</cstring>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;
+&lt;b&gt;Language&lt;/b&gt;&lt;br/&gt;
+The destination language of the project, i.e., the language
+to translate into. It should follow the ISO 631 language naming
+standard.&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Project &amp;type:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_projectType</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;
+&lt;b&gt;Project Type&lt;/b&gt;
+The project type allows to tune the settings for the
+particular type of the well-known translation projects.
+For example, it sets up the validation tools,
+an accelerator marker and formatting of the header.
+&lt;/p&gt;
+&lt;p&gt;Currently known types:
+&lt;ul&gt;
+&lt;li&gt;&lt;b&gt;KDE&lt;/b&gt;: K Desktop Environment Internalization project&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;GNOME&lt;/b&gt;: GNOME Translation project&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;Translation Robot&lt;/b&gt;: Translation Project Robot&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;Other&lt;/b&gt;: Other kind of project. No tuning will be
+done&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>_projectName</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;&lt;p&gt;&lt;b&gt;Project name&lt;/b&gt;&lt;br/&gt;
+The project name is an identification of a project for
+you. It is shown in the project configuration dialog
+as well as in the title of windows opened for the project.
+&lt;br/&gt;
+&lt;br/&gt;
+&lt;b&gt;Note:&lt;/b&gt; The project name cannot be later changed.&lt;
+&lt;/p&gt;&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Configuration &amp;file name:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_projectFile</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;&lt;b&gt;Configuration File Name&lt;/b&gt;&lt;br/&gt;
+The name of a file to store the configuration of the
+project.&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="3" column="1">
+ <item>
+ <property name="text">
+ <string>KDE</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>GNOME</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Translation Project Robot</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Other</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>_projectType</cstring>
+ </property>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+&lt;p&gt;
+&lt;b&gt;Project Type&lt;/b&gt;
+The project type allows to tune the settings for the
+particular type of the well-known translation projects.
+For example, it sets up the validation tools,
+an accelerator marker and formatting of the header.
+&lt;/p&gt;
+&lt;p&gt;Currently known types:
+&lt;ul&gt;
+&lt;li&gt;&lt;b&gt;KDE&lt;/b&gt;: K Desktop Environment Internalization project&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;GNOME&lt;/b&gt;: GNOME Translation project&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;Translation Robot&lt;/b&gt;: Translation Project Robot&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;Other&lt;/b&gt;: Other kind of project. No tuning will be
+done&lt;/li&gt;
+&lt;/ul&gt;
+&lt;/p&gt;
+&lt;/qt&gt;</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </vbox>
+</widget>
+<tabstops>
+ <tabstop>_projectName</tabstop>
+ <tabstop>_projectFile</tabstop>
+ <tabstop>_projectLanguage</tabstop>
+ <tabstop>_projectType</tabstop>
+</tabstops>
+<includes>
+ <include location="local" impldecl="in implementation">projectwizardwidget.ui.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/kbabel/commonui/projectwizardwidget.ui.h b/kbabel/commonui/projectwizardwidget.ui.h
new file mode 100644
index 00000000..6f16e162
--- /dev/null
+++ b/kbabel/commonui/projectwizardwidget.ui.h
@@ -0,0 +1,40 @@
+/****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 2004-2005 Stanislav Visnovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you wish to add, delete or rename functions or slots use
+** Qt Designer which will update this file, preserving your code. Create an
+** init() function in place of a constructor, and a destroy() function in
+** place of a destructor.
+*****************************************************************************/
+
+#include <kdialog.h>
diff --git a/kbabel/commonui/projectwizardwidget2.ui b/kbabel/commonui/projectwizardwidget2.ui
new file mode 100644
index 00000000..05d21a20
--- /dev/null
+++ b/kbabel/commonui/projectwizardwidget2.ui
@@ -0,0 +1,157 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ProjectStep2</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ProjectStep2</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>529</width>
+ <height>365</height>
+ </rect>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;&lt;p&gt;&lt;b&gt;Translation Files&lt;/b&gt;&lt;/p&gt;
+&lt;p&gt;Type in the folders which contain all your PO and POT files.
+The files and the folders in these folders will then be merged into one tree.&lt;/p&gt;&lt;/qt&gt;</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;font size="+1"&gt;The Translation Files&lt;/font&gt;
+&lt;br/&gt;&lt;br/&gt;
+If the project contains more than one file to translate, it
+better to organize the files.
+
+KBabel distinguishes two kind of the translation files:
+
+&lt;ul&gt;
+&lt;li&gt;&lt;b&gt;Templates&lt;/b&gt;: the files to be translated&lt;/li&gt;
+&lt;li&gt;&lt;b&gt;Translated files&lt;/b&gt;: the files already translated (at least
+partially)&lt;/li&gt;
+&lt;/ul&gt;
+
+Choose the folders to store the files. If you
+leave the entries empty, the Catalog Manager
+will not work.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Base folder of PO files:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_poDirEdit</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>_poDirEdit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout6</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Ba&amp;se folder of POT files:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>_potDirEdit</cstring>
+ </property>
+ </widget>
+ <widget class="KURLRequester">
+ <property name="name">
+ <cstring>_potDirEdit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>100</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/kbabel/commonui/roughtransdlg.cpp b/kbabel/commonui/roughtransdlg.cpp
new file mode 100644
index 00000000..de321044
--- /dev/null
+++ b/kbabel/commonui/roughtransdlg.cpp
@@ -0,0 +1,762 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2001 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+ 2002-2003 by StanislavVsinovsky
+ <visnovsky@kde.org>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#include "catalog.h"
+#include "catalogsettings.h"
+#include "editcmd.h"
+#include "dictchooser.h"
+#include "kbabeldictbox.h"
+#include "regexpextractor.h"
+#include "roughtransdlg.h"
+
+#include <qmemarray.h>
+#include <qcheckbox.h>
+#include <qhbuttongroup.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qradiobutton.h>
+#include <qtimer.h>
+#include <qvgroupbox.h>
+#include <qvbox.h>
+#include <qwhatsthis.h>
+
+#include <kapplication.h>
+#include <kconfig.h>
+#include <kglobal.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprogress.h>
+
+
+#include <kdebug.h>
+
+using namespace KBabel;
+
+RoughTransDlg::RoughTransDlg(KBabelDictBox *dict, Catalog *cat
+ , QWidget *parent,const char *name)
+ : KDialogBase(parent,name,true
+ ,i18n("Caption of dialog","Rough Translation")
+ , User1|User2|User3|Close)
+ ,catalog(cat)
+ ,active(false)
+ ,stop(false)
+ ,cancel(false)
+ ,dictBox(dict)
+ ,exactTransCounter(0)
+ ,partTransCounter(0)
+ ,totalTried(0)
+{
+ setButtonBoxOrientation(Vertical);
+ setButtonText(User1,i18n("&Start"));
+ setButtonText(User2,i18n("S&top"));
+ setButtonText(User3,i18n("C&ancel"));
+
+ enableButton(User2,false);
+ enableButton(User3,false);
+
+ QWidget *mw = new QWidget(this);
+ setMainWidget(mw);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout(mw);
+
+ configWidget = new QVBox(mw);
+ mainLayout->addWidget(configWidget);
+
+ QVGroupBox *box = new QVGroupBox(i18n("What to Translate"),configWidget);
+
+ QHButtonGroup *bBox = new QHButtonGroup(box);
+ bBox->setMargin(0);
+ bBox->setFrameStyle(QFrame::NoFrame);
+ whatBox = bBox;
+ untransButton = new QCheckBox(i18n("U&ntranslated entries"),bBox);
+ fuzzyButton = new QCheckBox(i18n("&Fuzzy entries"),bBox);
+ transButton = new QCheckBox(i18n("T&ranslated entries"),bBox);
+
+ connect(bBox,SIGNAL(clicked(int)),this,SLOT(msgButtonClicked(int)));
+
+ QWhatsThis::add(bBox,i18n("<qt><p><b>What entries to translate</b></p>"
+ "<p>Choose here, for which entries of the file KBabel "
+ "tries to find a translation. Changed entries are always "
+ "marked as fuzzy, no matter which option you choose.</p></qt>"));
+
+ box = new QVGroupBox(i18n("How to Translate"),configWidget);
+ bBox = new QHButtonGroup(box);
+ bBox->setFrameStyle(QFrame::NoFrame);
+ bBox->setMargin(0);
+
+ searchMatchButton = new QCheckBox(i18n("&Use dictionary settings")
+ ,bBox);
+
+ fuzzyMatchButton = new QCheckBox(i18n("Fu&zzy translation (slow)")
+ ,bBox);
+ singleWordButton = new QCheckBox(i18n("&Single word translation")
+ ,bBox);
+
+ QWhatsThis::add(bBox,i18n("<qt><p><b>How messages get translated</b></p>"
+ "<p>Here you can define if a message can only get translated "
+ "completely, if similar messages are acceptable or if KBabel "
+ "is supposed to try translating "
+ "the single words of a message if no translation of the "
+ "complete message or similar message was found.</p></qt>"));
+
+
+ box = new QVGroupBox(i18n("Options"),configWidget);
+
+ markFuzzyButton = new QCheckBox(i18n("&Mark changed entries as fuzzy"),box);
+ markFuzzyButton->setChecked(true);
+ QWhatsThis::add(markFuzzyButton,
+ i18n("<qt><p><b>Mark changed entries as fuzzy</b></p>"
+ "<p>When a translation for a message is found, the entry "
+ "will be marked <b>fuzzy</b> by default. This is because the "
+ "translation is just guessed by KBabel and you should always "
+ "check the results carefully. Deactivate this option only if "
+ "you know what you are doing.</p></qt>"));
+
+
+ connect(markFuzzyButton, SIGNAL(toggled(bool))
+ , this, SLOT(fuzzyButtonToggled(bool)));
+
+ kdeButton = new QCheckBox(i18n("Initialize &KDE-specific entries"),box);
+ kdeButton->setChecked(true);
+ QWhatsThis::add(kdeButton,
+ i18n("<qt><p><b>Initialize KDE-specific entries</b></p>"
+ "<p>Initialize \"Comment=\" and \"Name=\" entries "
+ "if a translation is not found. Also, \"NAME OF TRANSLATORS\" "
+ "and \"EMAIL OF TRANSLATORS\" is filled with identity settings.</p></qt>"));
+
+ QVGroupBox *dBox = new QVGroupBox(i18n("Dictionaries"),configWidget);
+ configWidget->setStretchFactor(dBox,1);
+
+ QPtrList<ModuleInfo> moduleList = dict->moduleInfos();
+
+ KConfig *config = KGlobal::config();
+ KConfigGroupSaver gs(config,"RoughTranslation");
+ QStringList selectedList=config->readListEntry("Selected");
+ if(selectedList.isEmpty())
+ {
+ int a = dict->activeModule();
+ ModuleInfo *mi = moduleList.at(a);
+ if(mi)
+ {
+ selectedList.append(mi->id);
+ }
+ }
+ dictChooser = new DictChooser(dict,selectedList,dBox,"dictChooser");
+
+ QWhatsThis::add(dictChooser,i18n("<qt><p><b>Dictionaries</b></p>"
+ "<p>Choose here, which dictionaries have to be used for "
+ "finding a translation. If you select more than one "
+ "dictionary, they are used in the same order as they "
+ "are displayed in the list.</p>"
+ "<p>The <b>Configure</b> button allows you to temporarily "
+ "configure selected dictionary. The original settings "
+ "will be restored after closing the dialog.</p></qt>"));
+
+ QLabel* label = new QLabel( i18n("Messages:"), mw );
+ progressbar = new KProgress(mw,"progressbar");
+ progressbar->setTextEnabled(true);
+ progressbar->setFormat("%v/%m (%p%)");
+ QHBoxLayout* pblayout= new QHBoxLayout(mainLayout);
+ pblayout->add(label);
+ pblayout->add(progressbar);
+
+ transButton->setChecked(config->readBoolEntry("Translated",false));
+ untransButton->setChecked(config->readBoolEntry("Untranslated",true));
+ fuzzyButton->setChecked(config->readBoolEntry("Fuzzies",false));
+
+ bool flag = config->readBoolEntry("fuzzyMatch",true);
+ fuzzyMatchButton->setChecked(flag);
+
+ flag = config->readBoolEntry("searchMatch",true);
+ searchMatchButton->setChecked(flag);
+
+ flag = config->readBoolEntry("singleWord",true);
+ singleWordButton->setChecked(flag);
+
+ flag = config->readBoolEntry("kdeSpecific",true);
+ kdeButton->setChecked(flag);
+
+ msgButtonClicked(0);
+}
+
+RoughTransDlg::~RoughTransDlg()
+{
+ KConfig *config=KGlobal::config();
+ KConfigGroupSaver gs(config,"RoughTranslation");
+ config->writeEntry("Selected",dictChooser->selectedDicts());
+
+ bool flag=transButton->isChecked();
+ config->writeEntry("Translated",flag);
+ flag=untransButton->isChecked();
+ config->writeEntry("Untranslated",flag);
+ flag=fuzzyButton->isChecked();
+ config->writeEntry("Fuzzies",flag);
+ flag=singleWordButton->isChecked();
+ config->writeEntry("singleWord",flag);
+ flag=fuzzyMatchButton->isChecked();
+ config->writeEntry("fuzzyMatch",flag);
+ flag=searchMatchButton->isChecked();
+ config->writeEntry("searchMatch",flag);
+ flag=kdeButton->isChecked();
+ config->writeEntry("kdeSpecific",flag);
+
+}
+
+void RoughTransDlg::slotUser1()
+{
+ configWidget->setEnabled(false);
+ enableButton(User1,false);
+ enableButton(Close,false);
+ enableButton(User2,true);
+ enableButton(User3,true);
+
+ active=true;
+ stop=false;
+ cancel=false;
+
+ exactTransCounter=0;
+ partTransCounter=0;
+ totalTried=0;
+
+ QTimer::singleShot(0,this, SLOT(translate()));
+}
+
+void RoughTransDlg::translate()
+{
+ bool markFuzzy = markFuzzyButton->isChecked();
+ bool translated = transButton->isChecked();
+ bool untranslated = untransButton->isChecked();
+ bool fuzzies = fuzzyButton->isChecked();
+ bool kdeSpecific=kdeButton->isChecked();
+
+ int total=catalog->numberOfEntries();
+ progressbar->setTotalSteps(total);
+
+ QStringList dictList = dictChooser->selectedDicts();
+
+ catalog->applyBeginCommand(0,Msgstr,0);
+
+ bool singleWords=singleWordButton->isChecked();
+ bool fuzzyMatch=fuzzyMatchButton->isChecked();
+ bool searchMatch=searchMatchButton->isChecked();
+ QRegExp contextReg=catalog->miscSettings().contextInfo;
+ QChar accelMarker=catalog->miscSettings().accelMarker;
+ QRegExp endPunctReg("[\\.?!: ]+$");
+
+
+ for(int i = 0; i < total; i++)
+ {
+ progressbar->setProgress(i+1);
+ kapp->processEvents(100);
+
+ if(stop || cancel) break;
+
+ // FIXME: should care about plural forms
+ QString msg=catalog->msgid(i,true).first();
+ QString translation;
+
+ // this is KDE specific:
+ if( kdeSpecific )
+ {
+ if( catalog->pluralForm(i) == NoPluralForm )
+ {
+ QString origTrans = catalog->msgstr(i).first();
+ if(msg.find("_: NAME OF TRANSLATORS\\n")==0)
+ {
+ QString authorName;
+ if( !catalog->identitySettings().authorLocalizedName.isEmpty() )
+ authorName = catalog->identitySettings().authorLocalizedName;
+ else // fallback to non-localized name
+ if( !catalog->identitySettings().authorName.isEmpty() )
+ authorName = catalog->identitySettings().authorName;
+ else continue; // there is no name to be inserted
+
+ if( !QStringList::split(',', origTrans).contains(authorName) )
+ {
+ if(origTrans.isEmpty() ) translation=authorName;
+ else translation+=origTrans+","+authorName;
+ }
+ }
+ else if(msg.find("_: EMAIL OF TRANSLATORS\\n")==0)
+ {
+ // skip, if email is not specified in settings
+ if( catalog->identitySettings().authorEmail.isEmpty() ) continue;
+
+ if( !QStringList::split(',', origTrans).contains(catalog->identitySettings().authorEmail) )
+ {
+ if(origTrans.isEmpty() ) translation=catalog->identitySettings().authorEmail;
+ else translation=origTrans+","+catalog->identitySettings().authorEmail;
+ }
+ }
+ else if (msg.find("ROLES_OF_TRANSLATORS") == 0)
+ {
+ QString temp = "<othercredit role=\\\"translator\\\">\n<firstname></firstname>"
+ "<surname></surname>\n<affiliation><address><email>" +
+ catalog->identitySettings( ).authorEmail+"</email></address>\n"
+ "</affiliation><contrib></contrib></othercredit>";
+ if (origTrans.isEmpty( ))
+ translation = temp;
+ else if (origTrans.find(catalog->identitySettings( ).authorEmail) < 0)
+ translation = origTrans + "\n" + temp;
+ }
+ else if (msg.find("CREDIT_FOR_TRANSLATORS") == 0)
+ {
+ QString authorName;
+ if (!catalog->identitySettings( ).authorLocalizedName.isEmpty( ))
+ authorName = catalog->identitySettings( ).authorLocalizedName;
+ else if (!catalog->identitySettings( ).authorName.isEmpty( ))
+ authorName = catalog->identitySettings( ).authorName;
+ QString temp = "<para>" + authorName + "\n" + "<email>" +
+ catalog->identitySettings( ).authorEmail + "</email></para>";
+ if (origTrans.isEmpty( ))
+ translation = temp;
+ else if (origTrans.find(authorName) < 0 &&
+ origTrans.find(catalog->identitySettings( ).authorEmail) < 0)
+ translation = origTrans + "\n" + temp;
+ }
+ }
+ }
+ else // not kdeSpecific
+ {
+ // skip KDE specific texts
+ if( msg.find("_: EMAIL OF TRANSLATORS\\n")==0 || msg.find("_: NAME OF TRANSLATORS\\n")==0 ||
+ msg.find("ROLES_OF_TRANSLATORS")==0 || msg.find("CREDIT_FOR_TRANSLATORS")==0)
+ continue;
+ }
+
+ if( translation.isEmpty() ) // KDE-specific translation didn't work
+ {
+ if( !untranslated && catalog->isUntranslated(i) ) continue;
+ if( !translated && !catalog->isUntranslated(i) && !catalog->isFuzzy(i) ) continue;
+ if( !fuzzies && catalog->isFuzzy(i) ) continue;
+ }
+
+ totalTried++;
+
+ if(msg.contains(contextReg))
+ {
+ msg.replace(contextReg,"");
+ }
+
+ // try exact translation
+ QStringList::Iterator dit = dictList.begin();
+ while(translation.isEmpty() && dit != dictList.end())
+ {
+ dictBox->setActiveModule(*dit);
+ translation = dictBox->translate(msg);
+
+ ++dit;
+ }
+
+ if(!translation.isEmpty())
+ {
+ exactTransCounter++;
+ }
+
+ // try search settings translation
+ else if (searchMatch) {
+ QString tr;
+ int score, best_score = 0;
+ dit = dictList.begin();
+ while(dit != dictList.end())
+ {
+ dictBox->setActiveModule(*dit);
+ tr = dictBox->searchTranslation(msg,score);
+ kdDebug() << "Found: " << tr << ", score " << score << endl;
+
+ if (score > best_score) {
+ kdDebug() << "Best score" << endl;
+ translation = tr;
+ best_score = score;
+ }
+
+ ++dit;
+ }
+
+ if(!translation.isEmpty())
+ {
+ partTransCounter++;
+ }
+ }
+
+ // try fuzzy translation
+ else if (fuzzyMatch) {
+ QString tr;
+ int score, best_score = 0;
+ dit = dictList.begin();
+ while(dit != dictList.end())
+ {
+ dictBox->setActiveModule(*dit);
+ tr = dictBox->fuzzyTranslation(msg,score);
+
+ if (score > best_score) {
+ translation = tr;
+ best_score = score;
+ }
+
+ ++dit;
+ }
+
+ if(!translation.isEmpty())
+ {
+ partTransCounter++;
+ }
+ }
+
+ kdDebug() << "Best translation so far: " << translation << endl;
+
+ // try single word translation
+ if(translation.isEmpty() && singleWords)
+ {
+ QStringList wordList;
+ QChar accel;
+ QString endingPunctuation;
+ int pos = msg.findRev(endPunctReg);
+ if(pos >= 0)
+ {
+ endingPunctuation = msg.right(msg.length()-pos);
+ }
+
+ msg=msg.simplifyWhiteSpace();
+ msg=msg.stripWhiteSpace();
+
+
+ RegExpExtractor te(catalog->tagSettings().tagExpressions);
+ te.setString(msg);
+ msg=te.matchesReplaced(" KBABELTAG ");
+
+ QString word;
+ int length = msg.length();
+ QRegExp digitReg("^[0-9]*$");
+ for(int index=0; index < length; index++)
+ {
+ QChar c=msg[index];
+
+ if(c==accelMarker)
+ {
+ index++;
+ if(index < length)
+ {
+ if(msg[index].isLetterOrNumber())
+ {
+ word+=msg[index];
+ accel=msg[index];
+ }
+ else if(!word.isEmpty() )
+ {
+ if(!word.contains(digitReg))
+ wordList.append(word);
+
+ word=QString::null;
+ }
+ }
+ else if(!word.isEmpty())
+ {
+ if(!word.contains(digitReg))
+ wordList.append(word);
+
+ word=QString::null;
+ }
+
+ }
+ else if(c.isLetterOrNumber())
+ {
+ word+=c;
+ }
+ else if(c == '\\')
+ {
+ if(index < length-2)
+ {
+ if(msg[index+1]=='n' && msg[index+2].isSpace())
+ {
+ if(!word.isEmpty() && !word.contains(digitReg))
+ wordList.append(word);
+
+ word=QString::null;
+
+ wordList.append("\\n\n");
+ index+=2;
+ }
+ else if(!word.isEmpty() )
+ {
+ if(!word.contains(digitReg))
+ wordList.append(word);
+
+ word=QString::null;
+ }
+ }
+ else if(!word.isEmpty())
+ {
+ if(!word.contains(digitReg))
+ wordList.append(word);
+
+ word=QString::null;
+ }
+ }
+ else if(!word.isEmpty())
+ {
+ if(!word.contains(digitReg)) {
+ wordList.append(word);
+ }
+
+ word=QString::null;
+ }
+ }
+
+ // handle the last word as well
+ if( !word.isEmpty() ) wordList.append(word);
+
+ dit = dictList.begin();
+ int wordCounter=0;
+ while(wordCounter==0 && dit != dictList.end())
+ {
+ dictBox->setActiveModule(*dit);
+
+ for(QStringList::Iterator it=wordList.begin();
+ it!=wordList.end(); ++it)
+ {
+ if( (*it)=="\\n\n" )
+ {
+ translation+="\\n\n";
+ }
+ else if( (*it)=="KBABELTAG" )
+ {
+ translation+=te.nextMatch();
+ }
+ else
+ {
+ QString trans = dictBox->translate(*it);
+
+ if(!trans.isEmpty())
+ {
+ wordCounter++;
+ if(!translation.isEmpty())
+ {
+ translation += ' ';
+ }
+ translation += trans;
+ }
+ }
+ }
+
+ if(wordCounter==0)
+ translation=QString::null;
+
+ ++dit;
+ }
+
+ if(!translation.isEmpty())
+ {
+ partTransCounter++;
+ // try to set the correct keyboard accelerator
+ if(!accel.isNull())
+ {
+ int index = translation.find(accel,0,false);
+ if(index >= 0)
+ {
+ translation.insert(index,accelMarker);
+ }
+ }
+
+ translation+=endingPunctuation;
+ }
+ }
+
+ // this is KDE specific:
+ if(kdeSpecific && translation.isEmpty())
+ {
+ if( msg.startsWith("Name=") ) {
+ translation="Name=";
+ partTransCounter++;
+ }
+ if( msg.startsWith("Comment=") ) {
+ translation="Comment=";
+ partTransCounter++;
+ }
+ }
+
+ if(!translation.isEmpty())
+ {
+ if(!catalog->isUntranslated(i))
+ {
+ QStringList msgs = catalog->msgstr(i);
+ uint counter = 0;
+ for( QStringList::Iterator it = msgs.begin() ; it != msgs.end() ; ++it)
+ {
+ DelTextCmd* delCmd = new DelTextCmd(0
+ ,(*it),counter++);
+ delCmd->setPart(Msgstr);
+ delCmd->setIndex(i);
+ catalog->applyEditCommand(delCmd,0);
+ }
+ }
+
+ for( int count=0; count < catalog->numberOfPluralForms(i) ; count++ )
+ {
+ InsTextCmd* insCmd = new InsTextCmd(0,translation,count);
+ insCmd->setPart(Msgstr);
+ insCmd->setIndex(i);
+ catalog->applyEditCommand(insCmd,0);
+ }
+
+ if(markFuzzy)
+ {
+ catalog->setFuzzy(i,true);
+ }
+ }
+ }
+
+ catalog->applyEndCommand(0,Msgstr,0);
+
+ if(stop || cancel)
+ {
+ if(cancel)
+ {
+ catalog->undo();
+ }
+ else
+ {
+ msgButtonClicked(0);
+ }
+ progressbar->setProgress(0);
+ configWidget->setEnabled(true);
+ active = false;
+
+ enableButton(User1,true);
+ enableButton(Close,true);
+ enableButton(User2,false);
+ enableButton(User3,false);
+
+ return;
+ }
+
+ showStatistics();
+}
+
+void RoughTransDlg::showStatistics()
+{
+ int nothing=totalTried-partTransCounter-exactTransCounter;
+ KLocale *locale = KGlobal::locale();
+ QString statMsg = i18n("Result of the translation:\n"
+ "Edited entries: %1\n"
+ "Exact translations: %2 (%3%)\n"
+ "Approximate translations: %4 (%5%)\n"
+ "Nothing found: %6 (%7%)")
+ .arg( locale->formatNumber(totalTried,0) )
+ .arg( locale->formatNumber(exactTransCounter,0) )
+ .arg( locale->formatNumber( ((double)(10000*exactTransCounter/QMAX(totalTried,1)))/100) )
+ .arg( locale->formatNumber(partTransCounter,0) )
+ .arg( locale->formatNumber(((double)(10000*partTransCounter/QMAX(totalTried,1)))/100) )
+ .arg( locale->formatNumber(nothing,0) )
+ .arg( locale->formatNumber(((double)(10000*nothing/QMAX(totalTried,1)))/100) );
+
+ KMessageBox::information(this, statMsg
+ , i18n("Rough Translation Statistics"));
+
+ dictChooser->restoreConfig();
+ accept();
+}
+
+void RoughTransDlg::slotClose()
+{
+ if(active)
+ {
+ cancel = true;
+ return;
+ }
+ else
+ {
+ dictChooser->restoreConfig();
+ accept();
+ }
+}
+
+void RoughTransDlg::slotUser2()
+{
+ stop=true;
+}
+
+void RoughTransDlg::slotUser3()
+{
+ cancel=true;
+}
+
+void RoughTransDlg::msgButtonClicked(int id)
+{
+ if(!transButton->isChecked() && !untransButton->isChecked()
+ && !fuzzyButton->isChecked())
+ {
+ QButton *button = whatBox->find(id);
+ if(button == transButton)
+ {
+ transButton->setChecked(true);
+ }
+ else if(button == untransButton)
+ {
+ untransButton->setChecked(true);
+ }
+ else if(button == fuzzyButton)
+ {
+ fuzzyButton->setChecked(true);
+ }
+ }
+
+ progressbar->setTotalSteps(catalog->numberOfEntries());
+
+ enableButton(User1,catalog->numberOfEntries());
+}
+
+void RoughTransDlg::fuzzyButtonToggled(bool on)
+{
+ if(!on)
+ {
+ QString msg=i18n("<qt><p>"
+ "When a translation for a message is found, the entry "
+ "will be marked <b>fuzzy</b> by default. This is because the "
+ "translation is just guessed by KBabel and you should always "
+ "check the results carefully. Deactivate this option only if "
+ "you know what you are doing.</p></qt>");
+
+ KMessageBox::information(this, msg, QString::null,"MarkFuzzyWarningInRoughTransDlg");
+ }
+}
+
+void RoughTransDlg::statistics(int &total, int& exact, int& part) const
+{
+ total = totalTried;
+ exact = exactTransCounter;
+ part = partTransCounter;
+}
+
+#include "roughtransdlg.moc"
diff --git a/kbabel/commonui/roughtransdlg.h b/kbabel/commonui/roughtransdlg.h
new file mode 100644
index 00000000..e51378a5
--- /dev/null
+++ b/kbabel/commonui/roughtransdlg.h
@@ -0,0 +1,110 @@
+/* ****************************************************************************
+ This file is part of KBabel
+
+ Copyright (C) 1999-2001 by Matthias Kiefer
+ <matthias.kiefer@gmx.de>
+
+ 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+**************************************************************************** */
+#ifndef ROUGHTRANSDLG_H
+#define ROUGHTRANSDLG_H
+
+#include <kdialogbase.h>
+
+
+class KBabelDictBox;
+class DictChooser;
+
+namespace KBabel
+{
+ class Catalog;
+}
+
+class KProgress;
+class QCheckBox;
+class QHButtonGroup;
+class QRadioButton;
+class QVBox;
+
+class KDE_EXPORT RoughTransDlg : public KDialogBase
+{
+ Q_OBJECT
+
+public:
+ RoughTransDlg(KBabelDictBox* dictBox, KBabel::Catalog* catalog, QWidget *parent
+ , const char *name=0);
+ ~RoughTransDlg();
+
+ void statistics(int &total, int& exactTranslated
+ , int& partlyTranslated) const;
+
+protected slots:
+ void slotUser1();
+ void slotUser2();
+ void slotUser3();
+
+ void slotClose();
+
+ void fuzzyButtonToggled(bool);
+
+ virtual void msgButtonClicked(int);
+ virtual void translate();
+ virtual void showStatistics();
+
+protected:
+ KBabel::Catalog *catalog;
+
+ bool active;
+ bool stop;
+ bool cancel;
+
+ KProgress *progressbar;
+private:
+ KBabelDictBox *dictBox;
+
+ DictChooser *dictChooser;
+ QVBox *configWidget;
+
+
+ QHButtonGroup *whatBox;
+ QCheckBox *transButton;
+ QCheckBox *untransButton;
+ QCheckBox *fuzzyButton;
+
+ QCheckBox *singleWordButton;
+ QCheckBox *fuzzyMatchButton;
+ QCheckBox *searchMatchButton;
+
+ QCheckBox *markFuzzyButton;
+ QCheckBox *kdeButton;
+
+ int exactTransCounter;
+ int partTransCounter;
+ int totalTried;
+};
+
+#endif // ROUGHTRANSDLG_H
diff --git a/kbabel/commonui/toolaction.cpp b/kbabel/commonui/toolaction.cpp
new file mode 100644
index 00000000..14589996
--- /dev/null
+++ b/kbabel/commonui/toolaction.cpp
@@ -0,0 +1,108 @@
+/* This file is part of KBabel
+ Copyright (C) 2002 Stanislav Visnovsky <visnovsky@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#include "toolaction.h"
+
+#include <kdebug.h>
+
+ToolAction::ToolAction( const QString & text, const KShortcut& cut, const KDataToolInfo & info, const QString & command,
+ QObject * parent, const char * name )
+ : KAction( text, info.iconName() == "unknown" ? QString::null : info.iconName(), cut, parent, name ),
+ m_command( command ),
+ m_info( info )
+{
+}
+
+void ToolAction::slotActivated()
+{
+ emit toolActivated( m_info, m_command );
+}
+
+QPtrList<KAction> ToolAction::dataToolActionList( const QValueList<KDataToolInfo> & tools, const QObject *receiver, const char* slot, const QStringList& command, bool excludeCommand, KActionCollection* parent, const QString& namePrefix )
+{
+ QPtrList<KAction> actionList;
+ if ( tools.isEmpty() )
+ return actionList;
+
+ QValueList<KDataToolInfo>::ConstIterator entry = tools.begin();
+ for( ; entry != tools.end(); ++entry )
+ {
+ QStringList userCommands = (*entry).userCommands();
+ QStringList commands = (*entry).commands();
+ QStringList shortcuts = (*entry).service()->property("Shortcuts").toStringList();
+ Q_ASSERT(!commands.isEmpty());
+ if ( commands.count() != userCommands.count() )
+ kdWarning() << "KDataTool desktop file error (" << (*entry).service()
+ << "). " << commands.count() << " commands and "
+ << userCommands.count() << " descriptions." << endl;
+
+ QStringList::ConstIterator uit = userCommands.begin();
+ QStringList::ConstIterator cit = commands.begin();
+ QStringList::ConstIterator sit = shortcuts.begin();
+ for (; uit != userCommands.end() && cit != commands.end(); ++uit, ++cit)
+ {
+ if( !excludeCommand == command.contains(*cit) )
+ {
+ QString sc=*sit;
+
+ ToolAction * action = new ToolAction( *uit, (sc.isEmpty()?QString::null:sc), *entry, *cit
+ , parent
+ , QString(namePrefix+(*entry).service()->library()+"_"+(*cit)).utf8() );
+ connect( action, SIGNAL( toolActivated( const KDataToolInfo &, const QString & ) ),
+ receiver, slot );
+
+ actionList.append( action );
+ }
+ if( sit != shortcuts.end() ) sit++;
+ }
+ }
+
+ return actionList;
+}
+
+QValueList<KDataToolInfo> ToolAction::validationTools()
+{
+ QValueList<KDataToolInfo> result;
+
+ QValueList<KDataToolInfo> tools = KDataToolInfo::query("CatalogItem", "application/x-kbabel-catalogitem", KGlobal::instance());
+
+ for( QValueList<KDataToolInfo>::ConstIterator entry = tools.begin(); entry != tools.end(); ++entry )
+ {
+ if( (*entry).commands().contains("validate") )
+ {
+ result.append( *entry );
+ }
+ }
+
+ return result;
+}
+
+#include "toolaction.moc"
diff --git a/kbabel/commonui/toolaction.h b/kbabel/commonui/toolaction.h
new file mode 100644
index 00000000..11e32c89
--- /dev/null
+++ b/kbabel/commonui/toolaction.h
@@ -0,0 +1,72 @@
+/* This file is part of KBabel
+ Copyright (C) 2002 Stanislav Visnovsky <visnovsky@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#ifndef TOOLACTION_H
+#define TOOLACTION_H
+
+#include <qobject.h>
+#include <kaction.h>
+#include <kdatatool.h>
+
+class KShortcut;
+class KActionCollection;
+
+class KDE_EXPORT ToolAction : public KAction
+{
+ Q_OBJECT
+public:
+ ToolAction( const QString & text, const KShortcut& cut, const KDataToolInfo & info, const QString & command, QObject * parent = 0, const char * name = 0);
+
+ /**
+ * return the list of KActions created for a list of tools. @ref command
+ * allows to specify rescriction of commands, for which the list should
+ * or shouldn't be created according to the @ref excludeCommand flag.
+ */
+ static QPtrList<KAction> dataToolActionList( const QValueList<KDataToolInfo> & tools, const QObject *receiver, const char* slot, const QStringList& command, bool excludeCommand, KActionCollection* parent=0, const QString& namePrefix=QString::null );
+
+ /**
+ * returns information about all available validation tools (KDataTools with support for CatalogItem
+ * and the "validate" command.
+ */
+ static QValueList<KDataToolInfo> validationTools();
+
+signals:
+ void toolActivated( const KDataToolInfo & info, const QString & command );
+
+protected:
+ virtual void slotActivated();
+
+private:
+ QString m_command;
+ KDataToolInfo m_info;
+};
+
+#endif
diff --git a/kbabel/commonui/toolselectionwidget.cpp b/kbabel/commonui/toolselectionwidget.cpp
new file mode 100644
index 00000000..8657657d
--- /dev/null
+++ b/kbabel/commonui/toolselectionwidget.cpp
@@ -0,0 +1,105 @@
+/* This file is part of KBabel
+ Copyright (C) 2002 Stanislav Visnovsky <visnovsky@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#include "toolselectionwidget.h"
+
+#include <kdatatool.h>
+#include <kdebug.h>
+
+#include <qlistbox.h>
+
+ToolSelectionWidget::ToolSelectionWidget( QWidget * parent, const char * name )
+ : KActionSelector( parent, name )
+{
+}
+
+void ToolSelectionWidget::loadTools( const QStringList &commands,
+ const QValueList<KDataToolInfo>& tools)
+{
+ if ( tools.isEmpty() ) return;
+
+ _allTools = tools;
+
+ QValueList<KDataToolInfo>::ConstIterator entry = tools.begin();
+ for( ; entry != tools.end(); ++entry )
+ {
+ QStringList userCommands = (*entry).userCommands();
+ QStringList toolCommands = (*entry).commands();
+ Q_ASSERT(!toolCommands.isEmpty());
+ if ( toolCommands.count() != userCommands.count() )
+ kdWarning() << "KDataTool desktop file error (" << (*entry).service()
+ << "). " << toolCommands.count() << " commands and "
+ << userCommands.count() << " descriptions." << endl;
+
+ QStringList::ConstIterator uit = userCommands.begin();
+ QStringList::ConstIterator cit = toolCommands.begin();
+ for (; uit != userCommands.end() && cit != toolCommands.end(); ++uit, ++cit )
+ {
+ if( commands.contains(*cit) )
+ {
+ availableListBox()->insertItem( *uit );
+ }
+ }
+ }
+}
+
+void ToolSelectionWidget::setSelectedTools( const QStringList& tools )
+{
+ availableListBox()->clear();
+ selectedListBox()->clear();
+ QValueList<KDataToolInfo>::ConstIterator entry = _allTools.begin();
+ for( ; entry != _allTools.end(); ++entry )
+ {
+ QString uic=*(*entry).userCommands().at((*entry).commands().findIndex("validate"));
+ if( tools.contains((*entry).service()->library()) )
+ selectedListBox()->insertItem( uic );
+ else
+ availableListBox()->insertItem( uic );
+ }
+}
+
+QStringList ToolSelectionWidget::selectedTools()
+{
+ QStringList usedNames;
+ for( uint i=0; i<selectedListBox()->count() ; i++ )
+ usedNames += selectedListBox()->text(i);
+
+ QStringList result;
+ QValueList<KDataToolInfo>::ConstIterator entry = _allTools.begin();
+ for( ; entry != _allTools.end(); ++entry )
+ {
+ if( usedNames.contains(*((*entry).userCommands().at((*entry).commands().findIndex("validate")))) )
+ result += (*entry).service()->library();
+ }
+ return result;
+}
+
+#include "toolselectionwidget.moc"
diff --git a/kbabel/commonui/toolselectionwidget.h b/kbabel/commonui/toolselectionwidget.h
new file mode 100644
index 00000000..5bad520b
--- /dev/null
+++ b/kbabel/commonui/toolselectionwidget.h
@@ -0,0 +1,57 @@
+/* This file is part of KBabel
+ Copyright (C) 2002 Stanislav Visnovsky <visnovsky@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ In addition, as a special exception, the copyright holders give
+ permission to link the code of this program with any edition of
+ the Qt library by Trolltech AS, Norway (or with modified versions
+ of Qt that use the same license as Qt), and distribute linked
+ combinations including the two. You must obey the GNU General
+ Public License in all respects for all of the code used other than
+ Qt. If you modify this file, you may extend this exception to
+ your version of the file, but you are not obligated to do so. If
+ you do not wish to do so, delete this exception statement from
+ your version.
+
+*/
+
+#ifndef TOOLSELECTIONWIDGET_H
+#define TOOLSELECTIONWIDGET_H
+
+#include "kactionselector.h"
+#include <kdemacros.h>
+
+class KDataToolInfo;
+
+class KDE_EXPORT ToolSelectionWidget : public KActionSelector
+{
+ Q_OBJECT
+public:
+ ToolSelectionWidget(QWidget* parent=0, const char* name=0 );
+
+ QStringList selectedTools();
+
+ void loadTools (const QStringList& commands, const QValueList<KDataToolInfo> & tools);
+
+public slots:
+ void setSelectedTools( const QStringList& tools );
+
+private:
+ QValueList<KDataToolInfo> _allTools;
+};
+
+#endif