[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/parley/src
From:       Frederik Gladhorn <frederik.gladhorn () gmx ! de>
Date:       2008-01-31 20:40:11
Message-ID: 1201812011.325700.24502.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 769199 by gladhorn:

Make it possible to use different online dicts. So far still hard coded,
but the combobox works.


 M  +37 -2     entry-dialogs/browserwidget.cpp  
 M  +14 -0     entry-dialogs/browserwidget.h  
 M  +1 -1      entry-dialogs/browserwidget.ui  
 M  +2 -6      parley.cpp  
 M  +0 -2      parleydocument.cpp  
 M  +14 -12    vocabulary/vocabularydelegate.cpp  
 M  +3 -0      vocabulary/vocabularymodel.cpp  
 M  +2 -1      vocabulary/vocabularymodel.h  
 M  +0 -3      vocabulary/vocabularyview.h  


--- trunk/KDE/kdeedu/parley/src/entry-dialogs/browserwidget.cpp #769198:769199
@@ -21,10 +21,13 @@
 
 #include <QDragEnterEvent>
 
+
 BrowserWidget::BrowserWidget(QWidget *parent) : QWidget(parent)
 {
     setupUi(this);
     m_currentTranslation = -1;
+    m_entry = 0;
+    m_currentProvider = 0; ///@todo kconfig?
 
     m_htmlPart = new KHTMLPart(widget);
     QHBoxLayout *layout = new QHBoxLayout(widget);
@@ -37,6 +40,9 @@
 
     connect(showCurrentButton, SIGNAL(clicked()), SLOT(showCurrentTranslation()));
 
+    setupProviders();
+    connect(providerComboBox, SIGNAL(currentIndexChanged(int)), \
SLOT(providerChanged(int))); +
     m_htmlPart->setJavaEnabled(false);
     m_htmlPart->setPluginsEnabled(false);
     m_htmlPart->setJScriptEnabled(true);
@@ -44,7 +50,30 @@
     m_htmlPart->setDNDEnabled(true);
 }
 
+void BrowserWidget::setupProviders()
+{
+    providerComboBox->clear();
 
+    DictionaryProvider provider;
+    provider.name="De-En Beolingus";
+    provider.url="http://beolingus.org/dings.cgi?query=\{@}";
+    provider.languages << "de" << "en";
+    m_providers.append(provider);
+    providerComboBox->addItem(provider.name);
+
+    provider.name="De-En Leo";
+    provider.url="http://dict.leo.org/?search=\{@}";
+    provider.languages << "de" << "en";
+    m_providers.append(provider);
+    providerComboBox->addItem(provider.name);
+
+    provider.name="De-Fr Leo";
+    provider.url="http://dict.leo.org/?lp=frde&search=\{@}";
+    provider.languages << "de" << "fr";
+    m_providers.append(provider);
+    providerComboBox->addItem(provider.name);
+}
+
 void BrowserWidget::setTranslation(KEduVocExpression* entry, int translation)
 {
     m_currentTranslation = translation;
@@ -60,10 +89,9 @@
     if (m_entry) {
         if (m_entry->translation(m_currentTranslation)) {
             QString text = m_entry->translation(m_currentTranslation)->text();
-            m_htmlPart->openUrl(KUrl(QString("http://beolingus.org/dings.cgi?query=%1").arg(text)));
 +            m_htmlPart->openUrl(KUrl(QString(m_providers.value(m_currentProvider).url.replace("\{@}", \
text))));  }
     }
-
 }
 
 void BrowserWidget::openUrl(const KUrl & targetUrl)
@@ -71,5 +99,12 @@
     m_htmlPart->openUrl(targetUrl);
 }
 
+void BrowserWidget::providerChanged(int provider)
+{
+    m_currentProvider = provider;
+    showCurrentTranslation();
+}
 
+
 #include "browserwidget.moc"
+
--- trunk/KDE/kdeedu/parley/src/entry-dialogs/browserwidget.h #769198:769199
@@ -22,6 +22,12 @@
 class KEduVocExpression;
 class KHTMLPart;
 
+struct DictionaryProvider {
+    QString name;
+    QString url;
+    QStringList languages;
+};
+
 class BrowserWidget : public QWidget, public Ui::BrowserWidget
 {
     Q_OBJECT
@@ -40,12 +46,20 @@
 private slots:
     void showCurrentTranslation();
     void openUrl(const KUrl& targetUrl);
+    void providerChanged(int);
 private:
+    /**
+     * Load a list of providers of online dictionaries
+     */
+    void setupProviders();
+
     /// Column in the document - corresponds to the language (-KV_COL_TRANS)
     int               m_currentTranslation;
     /// Selection in the doc - if more than one row is selected behavior is \
different  KEduVocExpression* m_entry;
 
     KHTMLPart *m_htmlPart;
+    QList<DictionaryProvider> m_providers;
+    int m_currentProvider;
 };
 #endif
--- trunk/KDE/kdeedu/parley/src/entry-dialogs/browserwidget.ui #769198:769199
@@ -23,7 +23,7 @@
       </widget>
      </item>
      <item>
-      <widget class="QComboBox" name="comboBox" />
+      <widget class="QComboBox" name="providerComboBox" />
      </item>
     </layout>
    </item>
--- trunk/KDE/kdeedu/parley/src/parley.cpp #769198:769199
@@ -103,8 +103,6 @@
 //     m_tableView->horizontalHeader()->addAction(actionRestoreNativeOrder);
 //     connect(actionRestoreNativeOrder, SIGNAL(triggered()), m_sortFilterModel, \
SLOT(restoreNativeOrder()));  
-kDebug() << "Parley - will open doc";
-
     if ( !filename.url().isEmpty() ) {
         kDebug() << "open doc" << filename.url();
         m_document->open(filename);
@@ -269,10 +267,8 @@
         m_pronunciationStatusBarLabel->setFont(Prefs::iPAFont());
     }
 
-//     m_tableView->setFont(Prefs::tableFont());
-//     m_tableView->reset();
-// 
-//     m_tableModel->reset();
+    m_vocabularyView->setFont(Prefs::tableFont());
+    m_vocabularyView->reset();
 }
 
 
--- trunk/KDE/kdeedu/parley/src/parleydocument.cpp #769198:769199
@@ -36,9 +36,7 @@
  : QObject(parent)
 {
     m_parleyApp = parent;
-kDebug() << "will new KEduVocDocument";
     m_doc = new KEduVocDocument(this);
-kDebug() << "done new KEduVocDocument";
     m_backupTimer = 0;
     enableAutoBackup(Prefs::autoBackup());
 }
--- trunk/KDE/kdeedu/parley/src/vocabulary/vocabularydelegate.cpp #769198:769199
@@ -18,6 +18,7 @@
 #include "vocabularymodel.h"
 
 #include "prefs.h"
+#include "languagesettings.h"
 
 #include <keduvocexpression.h>
 #include <keduvocgrade.h>
@@ -31,6 +32,7 @@
 #include <KIconLoader>
 #include <KIcon>
 #include <QPainter>
+#include <QDBusInterface>
 
 VocabularyDelegate::VocabularyDelegate(QObject *parent) : QItemDelegate(parent)
 {}
@@ -50,21 +52,21 @@
         editor->setFrame(false);
         editor->setFont(index.model()->data(index, Qt::FontRole).value<QFont>());
         editor->setText(index.model()->data(index, Qt::DisplayRole).toString());
-        ///@todo activate the keyboard layout switching code
-        /*if (m_doc) {
-          QString id = (col == KV_COL_ORG) ? m_doc->originalIdentifier()
-            : m_doc->identifier(col - KV_COL_TRANS).name();
 
-          if (langs) {
-            QString kbLayout(langs->keyboardLayout(langs->indexShortId(id)));
-            if (!kbLayout.isEmpty()) {
-                // TODO use generated interface instead
+        QString locale = index.model()->data(index, \
VocabularyModel::LocaleRole).toString(); +    kDebug() << "creating editor with \
locale:" << locale; +        if(!locale.isEmpty()) {
+            LanguageSettings settings(locale);
+            settings.readConfig();
+            QString layout = settings.keyboardLayout();
+            if(!layout.isEmpty()) {
                 QDBusInterface kxkb( "org.kde.kxkb", "/kxkb", "org.kde.KXKB" );
-                if (kxkb.isValid())
-                    kxkb.call( "setLayout", kbLayout );
+                if (kxkb.isValid()) {
+                    kxkb.call( "setLayout", layout );
+                }
             }
-          }
-        }*/
+        }
+
         connect(editor, SIGNAL(returnPressed()), this, \
SLOT(commitAndCloseEditor()));  return editor;
     }
--- trunk/KDE/kdeedu/parley/src/vocabulary/vocabularymodel.cpp #769198:769199
@@ -161,6 +161,9 @@
             return QVariant(m_container->entry(index.row(), \
m_recursive)->translation(translationId)->paraphrase());  //         case Audio:
 //         case Image:
+        case LocaleRole:
+   kDebug() << "locale role: " << \
m_document->identifier(translation(translationId)).locale(); +            return \
QVariant(m_document->identifier(translation(translationId)).locale());  default:
             return QVariant();
         }
--- trunk/KDE/kdeedu/parley/src/vocabulary/vocabularymodel.h #769198:769199
@@ -46,7 +46,8 @@
 
     enum roles {
         TranslationRole = Qt::UserRole,
-        EntryRole
+        EntryRole,
+        LocaleRole
     };
 
     VocabularyModel(QObject *parent = 0);
--- trunk/KDE/kdeedu/parley/src/vocabulary/vocabularyview.h #769198:769199
@@ -19,9 +19,6 @@
 
 #include <QTableView>
 
-//#include <vocabularysortfiltermodel.h>
-//#include <vocabularydelegate.h>
-
 #include <QMap>
 
 class VocabularyFilter;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic