⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trwindow.cpp

📁 qt-x11-opensource-src-4.1.4.tar.gz源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    about.versionLabel->setText(tr(                    "Version %1"#if QT_EDITION == QT_EDITION_OPENSOURCE                    " Open Source Edition"#endif                    ).arg(QT_VERSION_STR));    about.infoText->setTextFormat(Qt::RichText);    about.infoText->setText(tr(                    "<br/>Qt Linguist is a tool for adding translations to Qt "                    "applications.<br/><br/>"#if QT_EDITION == QT_EDITION_OPENSOURCE                    "This version of Qt Linguist is part of the Qt Open Source Edition, for use "                    "in the development of Open Source applications. "                    "Qt is a comprehensive C++ framework for cross-platform application "                    "development.<br/><br/>"                    "You need a commercial Qt license for development of proprietary (closed "                    "source) applications. Please see <tt>http://www.trolltech.com/company/model"                    ".html</tt> for an overview of Qt licensing.<br/>"#else                    "This program is licensed to you under the terms of the "                    "Qt Commercial License Agreement. For details, see the file LICENSE "                    "that came with this software distribution.<br/>"#endif                    "<br/>Copyright (C) 2000-2006 Trolltech ASA. All rights reserved."                    "<br/><br/>The program is provided AS IS with NO WARRANTY OF ANY KIND,"                    " INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A"                    " PARTICULAR PURPOSE.<br/> "));    about.exec();}void TrWindow::aboutQt(){    QMessageBox::aboutQt(this, tr("Qt Linguist"));}void TrWindow::setupPhrase(){    bool enabled = !phraseBooks[PhraseCloseMenu].isEmpty();    closePhraseBookId->setEnabled(enabled);    editPhraseBookId->setEnabled(enabled);    printPhraseBookId->setEnabled(enabled);}void TrWindow::closeEvent(QCloseEvent *e){    if (maybeSave())        e->accept();    else        e->ignore();}bool TrWindow::maybeSave(){    if (dirty) {        switch (QMessageBox::information(this, tr("Qt Linguist"),            tr("Do you want to save '%1'?").arg(filename),            QMessageBox::Yes | QMessageBox::Default,            QMessageBox::No,            QMessageBox::Cancel | QMessageBox::Escape))        {            case QMessageBox::Cancel:                return false;            case QMessageBox::Yes:                save();                return !dirty;            case QMessageBox::No:                break;        }    }    return true;}void TrWindow::updateCaption(){    QString cap;    bool enable = !filename.isEmpty();    saveAct->setEnabled(enable);    saveAsAct->setEnabled(enable);    releaseAct->setEnabled(enable);    printAct->setEnabled(enable);    acceleratorsAct->setEnabled(enable);    endingPunctuationAct->setEnabled(enable);    phraseMatchesAct->setEnabled(enable);    revertSortingAct->setEnabled(enable);    if (filename.isEmpty())        cap = tr("Qt Linguist by Trolltech");    else        cap = tr("%1 - %2").arg( tr("Qt Linguist by Trolltech"))        .arg(filename);    setWindowTitle(cap);    modified->setEnabled(dirty);}//// New scope selected - select a new list of source text items// for that scope.//void TrWindow::showNewScope(const QModelIndex &current, const QModelIndex &old){    stv->clearSelection();    statusBar()->clearMessage();    if (current.isValid()) {        ContextItem *c = cmdl->contextItem(current);        mmdl->setContextItem(c);        Qt::SortOrder sortOrder;        int sortColumn;        if (c->sortParameters(sortOrder, sortColumn)) {            stv->header()->setSortIndicator(sortColumn, sortOrder);            stv->header()->setSortIndicatorShown(true);        }        else {            stv->header()->setSortIndicatorShown(false);        }    }    Q_UNUSED(old);}void TrWindow::showNewCurrent(const QModelIndex &current, const QModelIndex &old){    ContextItem *c = mmdl->contextItem();    if (current.isValid()) {        MessageItem *m = c->messageItem(current.row());        me->showMessage(m->sourceText(), m->comment(), c->fullContext(),            m->translation(), m->message().type(), getPhrases(m->sourceText()));        if (m->danger())            printDanger(m);        else            statusBar()->clearMessage();        doneAndNextAct->setEnabled(m->message().type() !=            MetaTranslatorMessage::Obsolete);    }    else {        me->showNothing();        doneAndNextAct->setEnabled(false);    }    doneAndNextAlt->setEnabled(doneAndNextAct->isEnabled());    //selectAllAct->setEnabled(doneAndNextAct->isEnabled());    Q_UNUSED(old);}void TrWindow::insertMessage(MessageItem *m){    if (!dirty) {        dirty = true;        updateCaption();    }    tor.insert(m->message());}void TrWindow::updateTranslation(const QString &translation){    QModelIndex item = stv->currentIndex();    if (!item.isValid())        return;    ContextItem *c = mmdl->contextItem();    MessageItem *m = c->messageItem(item.row());    if (translation != m->translation()) {        m->setTranslation(translation);        updateDanger(m, true);        mmdl->updateItem(item);        if (m->finished())            updateFinished(false);        else            insertMessage(m);    }}void TrWindow::updateFinished(bool finished){    QModelIndex item = stv->currentIndex();    if (!item.isValid())        return;    ContextItem *c = mmdl->contextItem();    MessageItem *m = c->messageItem(item.row());    if (finished != m->finished()) {        numFinished += finished ? +1 : -1;        updateProgress();        m->setFinished(finished);        mmdl->updateItem(item);        insertMessage(m);        cmdl->updateItem(tv->currentIndex());        updateStatistics();    }}void TrWindow::doneAndNext(){    if (!stv->currentIndex().isValid())        return;    ContextItem *c = mmdl->contextItem();    MessageItem *m = c->messageItem(stv->currentIndex().row());    if (!m->danger()) {        updateFinished(true);        nextUnfinished();        me->setEditorFocus();    }    else {        qApp->beep();    }}void TrWindow::toggleFinished(const QModelIndex &index){    if (!index.isValid() || (index.column() != 0))        return;    ContextItem *c = mmdl->contextItem();    MessageItem *m = c->messageItem(index.row());    if (m->message().type() == MetaTranslatorMessage::Obsolete)        return;    if (m->danger())        printDanger(m);    if (!m->danger() && !m->finished())        updateFinished(true);    else if (m->finished())        updateFinished(false);}int TrWindow::findCurrentContextRow(){    QModelIndex index = tv->selectionModel()->currentIndex();    if (index.isValid())        return index.row();    //if no context is selected    setCurrentContextRow(0);    return 0;}int TrWindow::findCurrentMessageRow(){    ContextItem *cntxt = mmdl->contextItem();    if (cntxt == 0)        return -2;    QModelIndex index = stv->selectionModel()->currentIndex();    if (index.isValid())        return index.row();    //if no message is selected, select the first one.. if it exists    if (cntxt->messageItemsInList() <= 0)        return -2; //no messages in this context    setCurrentMessageRow(0);    return -1; // so that the next message will be 0}bool TrWindow::setNextContext(int *currentrow, bool checkUnfinished){    QModelIndex mindx;    ++(*currentrow);    for (; *currentrow < cmdl->contextsInList(); ++(*currentrow)) {        if (!checkUnfinished) {            setCurrentContextRow(*currentrow);            return true; //it is one more item        }        mindx = cmdl->index(*currentrow, 0);        if (cmdl->contextItem(mindx)->unfinished() > 0) {            setCurrentContext(mindx);            return true; // found a unfinished context        }    }    return false; // done}bool TrWindow::setPrevContext(int *currentrow, bool checkUnfinished){    QModelIndex mindx;    --(*currentrow);    for (; *currentrow >= 0; --(*currentrow)) {        if (!checkUnfinished) {            setCurrentContextRow(*currentrow);            return true; //it is one more item        }        mindx = cmdl->index(*currentrow, 0);        if (cmdl->contextItem(mindx)->unfinished() > 0) {            setCurrentContext(mindx);            return true; // found a unfinished context        }    }    return false; // done}bool TrWindow::setNextMessage(int *currentrow, bool checkUnfinished){    ContextItem *cntxt = mmdl->contextItem();    ++(*currentrow);    for (; *currentrow < cntxt->messageItemsInList(); ++(*currentrow)) {        if (!checkUnfinished) {            setCurrentMessageRow(*currentrow);            return true; //it is one more item        }        if (!cntxt->messageItem(*currentrow)->finished())        {            setCurrentMessageRow(*currentrow);            return true; // found a unfinished message        }    }    return false; // done in this context}bool TrWindow::setPrevMessage(int *currentrow, bool checkUnfinished){    ContextItem *cntxt = mmdl->contextItem();    --(*currentrow);    for (; *currentrow >= 0; --(*currentrow)) {        if (!checkUnfinished) {            setCurrentMessageRow(*currentrow);            return true; //it is one more item        }        if (!cntxt->messageItem(*currentrow)->finished())        {            setCurrentMessageRow(*currentrow);            return true; // found a unfinished message        }    }    return false; // done in this context}void TrWindow::nextUnfinished(){    if (nextUnfinishedAct->isEnabled()) {        if (!next(true)) {            // If no Unfinished message is left, the user has finished the job.  We            // congratulate on a job well done with this ringing bell.            statusBar()->showMessage(tr("No untranslated phrases left."), MessageMS);            qApp->beep();        }    }}void TrWindow::prevUnfinished(){    if (nextUnfinishedAct->isEnabled()) {        if (!prev(true)) {            // If no Unfinished message is left, the user has finished the job.  We            // congratulate on a job well done with this ringing bell.            statusBar()->showMessage(tr("No untranslated phrases left."), MessageMS);            qApp->beep();        }    }}void TrWindow::prev(){    if(prev(false))        stv->scrollTo(stv->currentIndex());}bool TrWindow::prev(bool checkUnfinished){    int curContext = findCurrentContextRow();    int curMessage = findCurrentMessageRow();    if ((curMessage != -2) && setPrevMessage(&curMessage, checkUnfinished))        return true; // found it!    // search the other contexts    while (setPrevContext(&curContext, checkUnfinished)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -