#include <batchtranslationdialog.h>
Inheritance diagram for BatchTranslationDialog:


Definition at line 42 of file batchtranslationdialog.h.
Signals | |
| void | finished () |
Public Member Functions | |
| BatchTranslationDialog (MessageModel *model, QWidget *w=0) | |
| void | setPhraseBooks (const QList< PhraseBook > &phrasebooks) |
| PhraseBook * | GetNamedPhraseBook (const QString &name) |
Private Slots | |
| void | startTranslation () |
| void | movePhraseBookUp () |
| void | movePhraseBookDown () |
Private Attributes | |
| Ui::databaseTranslationDialog | m_ui |
| CheckableListModel | m_model |
| MessageModel * | m_messagemodel |
| QList< PhraseBook > | m_phrasebooks |
| BatchTranslationDialog::BatchTranslationDialog | ( | MessageModel * | model, | |
| QWidget * | w = 0 | |||
| ) |
Definition at line 41 of file batchtranslationdialog.cpp.
References QObject::connect(), m_model, m_ui, movePhraseBookDown(), movePhraseBookUp(), QDialog::reject(), QAbstractItemView::SelectItems, SIGNAL, QAbstractItemView::SingleSelection, SLOT, and startTranslation().
00042 : QDialog(w), m_model(this), m_messagemodel(model) 00043 { 00044 m_ui.setupUi(this); 00045 connect(m_ui.runButton, SIGNAL(clicked()), this, SLOT(startTranslation())); 00046 connect(m_ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject())); 00047 connect(m_ui.moveUpButton, SIGNAL(clicked()), this, SLOT(movePhraseBookUp())); 00048 connect(m_ui.moveDownButton, SIGNAL(clicked()), this, SLOT(movePhraseBookDown())); 00049 00050 m_ui.phrasebookList->setModel(&m_model); 00051 m_ui.phrasebookList->setSelectionBehavior(QAbstractItemView::SelectItems); 00052 m_ui.phrasebookList->setSelectionMode(QAbstractItemView::SingleSelection); 00053 }
Here is the call graph for this function:

| void BatchTranslationDialog::setPhraseBooks | ( | const QList< PhraseBook > & | phrasebooks | ) |
Definition at line 56 of file batchtranslationdialog.cpp.
References Qt::Checked, Qt::CheckStateRole, QStandardItemModel::clear(), QList< T >::count(), i, QStandardItemModel::index(), QStandardItemModel::insertColumn(), QStandardItemModel::insertRows(), m_model, m_phrasebooks, name, and QStandardItemModel::setData().
Referenced by TrWindow::showBatchTranslateDialog().
00057 { 00058 m_model.clear(); 00059 m_model.insertColumn(0); 00060 m_phrasebooks = phrasebooks; 00061 int count = phrasebooks.count(); 00062 m_model.insertRows(0, count); 00063 for (int i = 0; i < count; ++i) { 00064 QString name = phrasebooks[i].friendlyPhraseBookName(); 00065 //QString name = QLatin1String("language %1"); 00066 name = name.arg(i); 00067 m_model.setData(m_model.index(i,0), name); 00068 m_model.setData(m_model.index(i,0), Qt::Checked, Qt::CheckStateRole); 00069 } 00070 }
Here is the call graph for this function:

| PhraseBook * BatchTranslationDialog::GetNamedPhraseBook | ( | const QString & | name | ) |
Definition at line 72 of file batchtranslationdialog.cpp.
References QList< T >::count(), i, m_phrasebooks, and name.
Referenced by startTranslation().
00073 { 00074 for (int i = 0; i < m_phrasebooks.count(); ++i) { 00075 if (m_phrasebooks[i].friendlyPhraseBookName() == name) return &m_phrasebooks[i]; 00076 } 00077 return 0; 00078 }
Here is the call graph for this function:

| void BatchTranslationDialog::finished | ( | ) | [signal] |
Referenced by startTranslation().
| void BatchTranslationDialog::startTranslation | ( | ) | [private, slot] |
Definition at line 80 of file batchtranslationdialog.cpp.
References QList< T >::at(), b, MessageModel::begin(), Qt::BusyCursor, Qt::Checked, Qt::CheckStateRole, QList< T >::count(), MessageModel::iterator::current(), QWidget::cursor(), QStandardItemModel::data(), emit, finished(), MessageModel::getMessageCount(), GetNamedPhraseBook(), QStandardItemModel::index(), QMessageBox::information(), m, m_messagemodel, m_model, m_ui, QMessageBox::Ok, p, qApp, QStandardItemModel::rowCount(), QWidget::setCursor(), QProgressDialog::setValue(), QWidget::show(), QVariant::toString(), MessageModel::updateAll(), and QProgressDialog::wasCanceled().
Referenced by BatchTranslationDialog().
00081 { 00082 int translatedcount = 0; 00083 QCursor oldCursor = cursor(); 00084 setCursor(Qt::BusyCursor); 00085 int messageCount = m_messagemodel->getMessageCount(); 00086 00087 QProgressDialog *dlgProgress; 00088 dlgProgress = new QProgressDialog(tr("Searching, please wait..."), tr("&Cancel"), 0, messageCount, this); 00089 dlgProgress->show(); 00090 00091 MessageModel::iterator it = m_messagemodel->begin(); 00092 int msgidx = 0; 00093 bool doProcess = true; 00094 for ( ;it.current() && doProcess; ++it) { 00095 MessageItem *m = it.current(); 00096 if ( m_ui.ckOnlyUntranslated->isChecked() ) { 00097 if (!m->translation().isEmpty()) continue; 00098 } 00099 // Go through them in the order the user specified in the phrasebookList 00100 for (int b = 0; b < m_model.rowCount() && doProcess; ++b) { 00101 QVariant checkState = m_model.data(m_model.index(b, 0), Qt::CheckStateRole); 00102 if (checkState == Qt::Checked) { 00103 QVariant pbname = m_model.data(m_model.index(b, 0)); 00104 PhraseBook *pb = GetNamedPhraseBook(pbname.toString()); 00105 for (int p = 0; p < pb->count(); ++p) { 00106 Phrase ph = pb->at(p); 00107 if (ph.source() == m->sourceText() && !m->finished()) { 00108 m->setTranslation(ph.target()); 00109 m->setFinished(m_ui.ckMarkFinished->isChecked()); 00110 ++translatedcount; 00111 } 00112 } 00113 if (dlgProgress->wasCanceled()) { 00114 doProcess = false; 00115 break; 00116 } 00117 } 00118 qApp->processEvents(); 00119 } 00120 ++msgidx; 00121 dlgProgress->setValue(msgidx); 00122 } 00123 dlgProgress->setValue(messageCount); 00124 00125 setCursor(oldCursor); 00126 m_messagemodel->updateAll(); 00127 emit finished(); 00128 QMessageBox::information(this, tr("Linguist batch translator"), 00129 tr("Batch translated %1 entries").arg(translatedcount), QMessageBox::Ok); 00130 00131 //### update stats 00132 //### update translationcount etc. 00133 }
| void BatchTranslationDialog::movePhraseBookUp | ( | ) | [private, slot] |
Definition at line 135 of file batchtranslationdialog.cpp.
References QItemSelectionModel::ClearAndSelect, QList< T >::count(), QStandardItemModel::index(), QStandardItemModel::itemData(), m_model, m_ui, QModelIndex::row(), row, and QStandardItemModel::setItemData().
Referenced by BatchTranslationDialog().
00136 { 00137 QModelIndexList indexes = m_ui.phrasebookList->selectionModel()->selectedIndexes(); 00138 if (indexes.count() <= 0) return; 00139 00140 QModelIndex sel = indexes[0]; 00141 int row = sel.row(); 00142 if (row > 0) { 00143 QModelIndex other = m_model.index(row - 1, 0); 00144 QMap<int, QVariant> seldata = m_model.itemData(sel); 00145 m_model.setItemData(sel, m_model.itemData(other)); 00146 m_model.setItemData(other, seldata); 00147 m_ui.phrasebookList->selectionModel()->setCurrentIndex(other, QItemSelectionModel::ClearAndSelect); 00148 } 00149 }
| void BatchTranslationDialog::movePhraseBookDown | ( | ) | [private, slot] |
Definition at line 151 of file batchtranslationdialog.cpp.
References QItemSelectionModel::ClearAndSelect, QList< T >::count(), QStandardItemModel::index(), QStandardItemModel::itemData(), m_model, m_ui, QModelIndex::row(), row, QStandardItemModel::rowCount(), and QStandardItemModel::setItemData().
Referenced by BatchTranslationDialog().
00152 { 00153 QModelIndexList indexes = m_ui.phrasebookList->selectionModel()->selectedIndexes(); 00154 if (indexes.count() <= 0) return; 00155 00156 QModelIndex sel = indexes[0]; 00157 int row = sel.row(); 00158 if (row < m_model.rowCount() - 1) { 00159 QModelIndex other = m_model.index(row + 1, 0); 00160 QMap<int, QVariant> seldata = m_model.itemData(sel); 00161 m_model.setItemData(sel, m_model.itemData(other)); 00162 m_model.setItemData(other, seldata); 00163 m_ui.phrasebookList->selectionModel()->setCurrentIndex(other, QItemSelectionModel::ClearAndSelect); 00164 } 00165 }
Ui::databaseTranslationDialog BatchTranslationDialog::m_ui [private] |
Definition at line 59 of file batchtranslationdialog.h.
Referenced by BatchTranslationDialog(), movePhraseBookDown(), movePhraseBookUp(), and startTranslation().
Definition at line 60 of file batchtranslationdialog.h.
Referenced by BatchTranslationDialog(), movePhraseBookDown(), movePhraseBookUp(), setPhraseBooks(), and startTranslation().
QList<PhraseBook> BatchTranslationDialog::m_phrasebooks [private] |
Definition at line 62 of file batchtranslationdialog.h.
Referenced by GetNamedPhraseBook(), and setPhraseBooks().
1.5.1