Changed: #1307 Added documentation and minor fixes

This commit is contained in:
cemycc 2011-08-22 14:42:51 +03:00
parent fed0a7e4e1
commit 59727ccacd
4 changed files with 75 additions and 59 deletions

View file

@ -59,7 +59,7 @@ void CEditorWorksheet::open(QString filename)
} else {
QTableWidgetItem *col = new QTableWidgetItem();
ucstring col_name = wk_file.getData(0, i);
col->setText(tr(col_name.toString().c_str()));
col->setText(QString(col_name.toString().c_str()));
if(hasHashValue)
{
table_editor->setHorizontalHeaderItem(i - 1, col);
@ -241,9 +241,9 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
if(search_results.size() == 0)
{
QList<QString> records;
records.push_back(tr(it->first.c_str()));
records.push_back(tr(it->first.c_str()));
records.push_back(tr(it->second.SheetName.c_str()));
records.push_back(QString(it->first.c_str()));
records.push_back(QString(it->first.c_str()));
records.push_back(QString(it->second.SheetName.c_str()));
insertTableRecords(records, new_items);
if(!modified) modified = true;
}
@ -261,8 +261,8 @@ void CEditorWorksheet::extractBotNames(list<string> filters, string level_design
if(search_results.size() == 0)
{
QList<QString> records;
records.push_back(tr((*it).c_str()));
records.push_back(tr(gnName.c_str()));
records.push_back(QString((*it).c_str()));
records.push_back(QString(gnName.c_str()));
records.push_back(" ");
insertTableRecords(records, new_items);
if(!modified) modified = true;
@ -318,7 +318,7 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
for(i = 0; i < allWords.size(); i++)
{
string keyName = allWords[i];
QList<QTableWidgetItem*> search_results = table_editor->findItems(tr(keyName.c_str()), Qt::MatchExactly);
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(keyName.c_str()), Qt::MatchExactly);
if(search_results.size() == 0)
{
int knPos = 0, nPos = 0;
@ -332,8 +332,8 @@ void CEditorWorksheet::extractWords(QString filename, QString columnId, IWordLis
}
QList<QString> records;
records.push_back(tr(keyName.c_str()));
records.push_back(QString("<GEN>") + tr(keyName.c_str()));
records.push_back(QString(keyName.c_str()));
records.push_back(QString("<GEN>") + QString(keyName.c_str()));
insertTableRecords(records, new_items);
if(!modified) modified = true;
}
@ -412,7 +412,7 @@ void CEditorWorksheet::mergeWorksheetFile(QString filename)
{
// search with the first column
ucstring rowId = wk_file.getData(i,colIndex);
QList<QTableWidgetItem*> search_results = table_editor->findItems(tr(rowId.toString().c_str()), Qt::MatchExactly);
QList<QTableWidgetItem*> search_results = table_editor->findItems(QString(rowId.toString().c_str()), Qt::MatchExactly);
if(search_results.size() == 0)
{
const int lastRow = table_editor->rowCount();

View file

@ -27,6 +27,7 @@ namespace TranslationManager
status = false;
}
// Connection with the FTP Server. We retrieve the file list.
void CFtpSelection::ConnectButtonClicked()
{
conn = new QFtp(this);
@ -51,6 +52,7 @@ namespace TranslationManager
}
}
// Get the user action.
void CFtpSelection::FtpCommandFinished(int, bool error)
{
#ifndef QT_NO_CURSOR
@ -98,7 +100,7 @@ namespace TranslationManager
}
}
}
// Make the file list with directories and files
void CFtpSelection::AddToList(const QUrlInfo &urlInfo)
{
QTreeWidgetItem *item = new QTreeWidgetItem;
@ -138,6 +140,7 @@ namespace TranslationManager
_ui.doneButton->setEnabled(true);
}
// Exit from a directory
void CFtpSelection::cdToParent()
{
#ifndef QT_NO_CURSOR
@ -155,6 +158,7 @@ namespace TranslationManager
conn->list();
}
// Done action
void CFtpSelection::DoneButtonClicked()
{
QString fileName = _ui.fileList->currentItem()->text(0);

View file

@ -17,6 +17,7 @@ CSourceDialog::CSourceDialog(QWidget *parent): QDialog(parent)
_ui.listWidget->setSortingEnabled(false);
}
// Insert options in the source dialog. Options like: from FTP Server, from Local directory etc.
void CSourceDialog::setSourceOptions(map<QListWidgetItem*,int> options)
{
map<QListWidgetItem*,int>::iterator it;

View file

@ -51,8 +51,7 @@ CMainWindow::CMainWindow(QWidget *parent)
{
_ui.setupUi(this);
_ui.mdiArea->closeAllSubWindows();
connect(_ui.mdiArea, SIGNAL(subWindowActivated(QMdiSubWindow*)),this, SLOT(activeSubWindowChanged()));
_ui.mdiArea->closeAllSubWindows();
windowMapper = new QSignalMapper(this);
connect(windowMapper, SIGNAL(mapped(QWidget*)), this, SLOT(setActiveSubWindow(QWidget*)));
@ -66,6 +65,7 @@ CMainWindow::CMainWindow(QWidget *parent)
}
// Functions that will insert the plugin buttons
void CMainWindow::createToolbar()
{
// File menu
@ -96,27 +96,27 @@ void CMainWindow::createToolbar()
QAction *extractItemWordsAct = wordsExtractionMenu->addAction("&Extract item words...");
extractItemWordsAct->setStatusTip(tr("Extract item words"));
connect(extractItemWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
wordsExtractionMapper->setMapping(extractItemWordsAct, tr(Constants::WK_ITEM));
wordsExtractionMapper->setMapping(extractItemWordsAct, QString(Constants::WK_ITEM));
// extract creature words
QAction *extractCreatureWordsAct = wordsExtractionMenu->addAction("&Extract creature words...");
extractCreatureWordsAct->setStatusTip(tr("Extract creature words"));
connect(extractCreatureWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
wordsExtractionMapper->setMapping(extractCreatureWordsAct, tr(Constants::WK_CREATURE));
wordsExtractionMapper->setMapping(extractCreatureWordsAct, QString(Constants::WK_CREATURE));
// extract sbrick words
QAction *extractSbrickWordsAct = wordsExtractionMenu->addAction("&Extract sbrick words...");
extractSbrickWordsAct->setStatusTip(tr("Extract sbrick words"));
connect(extractSbrickWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
wordsExtractionMapper->setMapping(extractSbrickWordsAct, tr(Constants::WK_SBRICK));
wordsExtractionMapper->setMapping(extractSbrickWordsAct, QString(Constants::WK_SBRICK));
// extract sphrase words
QAction *extractSphraseWordsAct = wordsExtractionMenu->addAction("&Extract sphrase words...");
extractSphraseWordsAct->setStatusTip(tr("Extract sphrase words"));
connect(extractSphraseWordsAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
wordsExtractionMapper->setMapping(extractSphraseWordsAct, tr(Constants::WK_SPHRASE));
wordsExtractionMapper->setMapping(extractSphraseWordsAct, QString(Constants::WK_SPHRASE));
// extract place and region names
QAction *extractPlaceNamesAct = wordsExtractionMenu->addAction("&Extract place names...");
extractPlaceNamesAct->setStatusTip(tr("Extract place names from primitives"));
connect(extractPlaceNamesAct, SIGNAL(triggered()), wordsExtractionMapper, SLOT(map()));
wordsExtractionMapper->setMapping(extractPlaceNamesAct, tr(Constants::WK_PLACE));
wordsExtractionMapper->setMapping(extractPlaceNamesAct, QString(Constants::WK_PLACE));
// Merge options
// -----------------------------
QAction *mergeSingleFileAct = wordsExtractionMenu->addAction("&Merge worksheet file...");
@ -140,24 +140,23 @@ void CMainWindow::createToolbar()
_ui.toolBar->addAction(redoAction);
}
// Update the toolbar if the editor is worksheet
void CMainWindow::updateToolbar(QMdiSubWindow *window)
{
if(_ui.mdiArea->subWindowList().size() > 0)
if(QString(window->widget()->metaObject()->className()) == "QTableWidget") // Sheet Editor
{
//setContextMenuPolicy(Qt::ActionsContextMenu);
QAction *insertRowAct = new QAction(tr("Insert new row"), this);
connect(insertRowAct, SIGNAL(triggered()), window, SLOT(insertRow()));
//addAction(insertRowAct);
windowMenu->addAction(insertRowAct);
QAction *deleteRowAct = new QAction(tr("Delete row"), this);
connect(deleteRowAct, SIGNAL(triggered()), window, SLOT(deleteRow()));
//addAction(deleteRowAct);
windowMenu->addAction(deleteRowAct);
}
}
// Set the active subwindow
void CMainWindow::setActiveSubWindow(QWidget* window)
{
if (!window)
@ -168,13 +167,11 @@ void CMainWindow::setActiveSubWindow(QWidget* window)
_ui.mdiArea->setActiveSubWindow(cwindow);
}
void CMainWindow::activeSubWindowChanged()
{
}
// Functions for updating the windows list
void CMainWindow::updateWindowsList()
{
if(_ui.mdiArea->activeSubWindow())
{
windowMenu->clear();
QMdiSubWindow *current_window = _ui.mdiArea->activeSubWindow();
QList<QMdiSubWindow*> subWindows = _ui.mdiArea->subWindowList();
@ -186,9 +183,9 @@ void CMainWindow::updateWindowsList()
QString window_file = QFileInfo(subWindows.at(i)->windowFilePath()).fileName();
QString action_text;
if (i < 9) {
action_text = tr("&%1 %2").arg(i + 1).arg(window_file);
action_text = QString("&%1 %2").arg(i + 1).arg(window_file);
} else {
action_text = tr("%1 %2").arg(i + 1).arg(window_file);
action_text = QString("%1 %2").arg(i + 1).arg(window_file);
}
QAction *action = new QAction(action_text, this);
action->setCheckable(true);
@ -196,9 +193,12 @@ void CMainWindow::updateWindowsList()
connect(action, SIGNAL(triggered()), windowMapper, SLOT(map()));
windowMenu->addAction(action);
windowMapper->setMapping(action, subWindows.at(i));
}
}
}
}
// Open signal
void CMainWindow::open()
{
QSettings *settings = Core::ICore::instance()->settings();
@ -243,6 +243,7 @@ void CMainWindow::open()
}
// Open a work file. You can set the directory for work file in the settings dialog
void CMainWindow::openWorkFile(QString file)
{
QFileInfo* file_path = new QFileInfo(QString("%1/%2").arg(work_path).arg(file));
@ -262,6 +263,7 @@ void CMainWindow::openWorkFile(QString file)
}
// Save signal
void CMainWindow::save()
{
if(_ui.mdiArea->subWindowList().size() > 0)
@ -277,6 +279,7 @@ void CMainWindow::save()
}
}
// Save as signal
void CMainWindow::saveAs()
{
QString file_name;
@ -298,6 +301,7 @@ void CMainWindow::saveAs()
}
}
// This function is needed by extraction.
void CMainWindow::initializeSettings(bool georges = false)
{
if(georges == true && initialize_settings["georges"] == false)
@ -327,6 +331,7 @@ void CMainWindow::initializeSettings(bool georges = false)
}
// Extracting words
void CMainWindow::extractWords(QString typeq)
{
if(verifySettings() == true)
@ -396,6 +401,7 @@ void CMainWindow::extractWords(QString typeq)
}
// Extract bot names from primitives
void CMainWindow::extractBotNames()
{
if(verifySettings() == true)
@ -425,6 +431,7 @@ void CMainWindow::extractBotNames()
}
}
// Merge the content for 2 worksheet files
void CMainWindow::mergeSingleFile()
{
CEditor* editor_window = qobject_cast<CEditor*>(_ui.mdiArea->currentSubWindow());
@ -485,7 +492,7 @@ void CMainWindow::mergeSingleFile()
current_window->mergeWorksheetFile(file_name);
} else {
QErrorMessage error;
error.showMessage(QString("The file: %1 has different columns from the current file in editor.").arg(file_name));
error.showMessage(tr("The file: %1 has different columns from the current file in editor.").arg(file_name));
error.exec();
}
if(dialog->selected_item == ftp_item)
@ -493,13 +500,14 @@ void CMainWindow::mergeSingleFile()
if(!ftp_dialog->file->remove())
{
QErrorMessage error;
error.showMessage(QString("Please remove the file from ftp server manually. The file is located on the same directory with OVQT application."));
error.showMessage(tr("Please remove the file from ftp server manually. The file is located on the same directory with OVQT application."));
error.exec();
}
}
}
// Read the settings from QSettings
void CMainWindow::readSettings()
{
QSettings *settings = Core::ICore::instance()->settings();
@ -517,6 +525,7 @@ void CMainWindow::readSettings()
settings->endGroup();
}
// Verify the settings
bool CMainWindow::verifySettings()
{
bool count_errors = false;
@ -533,6 +542,36 @@ bool CMainWindow::verifySettings()
}
bool CCoreListener::closeMainWindow() const
{
bool okToClose = true;
Q_FOREACH(QMdiSubWindow *subWindow, m_MainWindow->_ui.mdiArea->subWindowList())
{
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
if(subWindow->isWindowModified())
{
QMessageBox msgBox;
msgBox.setText(tr("The document has been modified ( %1 ).").arg(currentEditor->windowFilePath()));
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
if(ret == QMessageBox::Save)
{
currentEditor->save();
}
else if(ret == QMessageBox::Cancel)
{
okToClose = false;
break;
}
}
}
return okToClose;
}
// Helper functions
CEditor *CMainWindow::getEditorByWindowFilePath(const QString &fileName)
{
Q_FOREACH(QMdiSubWindow *subWindow, _ui.mdiArea->subWindowList())
@ -604,34 +643,6 @@ bool CMainWindow::isPhraseEditor(QString filename)
}
}
bool CCoreListener::closeMainWindow() const
{
bool okToClose = true;
Q_FOREACH(QMdiSubWindow *subWindow, m_MainWindow->_ui.mdiArea->subWindowList())
{
CEditor *currentEditor = qobject_cast<CEditor*>(subWindow);
if(subWindow->isWindowModified())
{
QMessageBox msgBox;
msgBox.setText(tr("The document has been modified ( %1 ).").arg(currentEditor->windowFilePath()));
msgBox.setInformativeText("Do you want to save your changes?");
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Save);
int ret = msgBox.exec();
if(ret == QMessageBox::Save)
{
currentEditor->save();
}
else if(ret == QMessageBox::Cancel)
{
okToClose = false;
break;
}
}
}
return okToClose;
}
} /* namespace Plugin */