diff --git a/src/project/projectmanagerui.rc b/src/project/projectmanagerui.rc --- a/src/project/projectmanagerui.rc +++ b/src/project/projectmanagerui.rc @@ -1,5 +1,5 @@ - + &Go @@ -14,6 +14,10 @@ + + + + &Edit @@ -23,5 +27,7 @@ + + diff --git a/src/project/projectmodel.h b/src/project/projectmodel.h --- a/src/project/projectmodel.h +++ b/src/project/projectmodel.h @@ -155,6 +155,7 @@ enum AdditionalRoles { FuzzyUntrCountRole = Qt::UserRole, + FuzzyUntrCountAllRole, FuzzyCountRole, UntransCountRole, TemplateOnlyRole, diff --git a/src/project/projectmodel.cpp b/src/project/projectmodel.cpp --- a/src/project/projectmodel.cpp +++ b/src/project/projectmodel.cpp @@ -716,6 +716,8 @@ default: return QVariant(); } + case FuzzyUntrCountAllRole: + return hasStats?(fuzzy + untranslated):0; case FuzzyUntrCountRole: return item.isFile()?(fuzzy + untranslated):0; case FuzzyCountRole: diff --git a/src/project/projecttab.h b/src/project/projecttab.h --- a/src/project/projecttab.h +++ b/src/project/projecttab.h @@ -99,6 +99,7 @@ void gotoNextTemplateOnly(); void gotoPrevTransOnly(); void gotoNextTransOnly(); + void toggleTranslatedFiles(); void updateStatusBar(int fuzzy = 0, int translated = 0, int untranslated = 0, bool done = false); void initStatusBarProgress(); diff --git a/src/project/projecttab.cpp b/src/project/projecttab.cpp --- a/src/project/projecttab.cpp +++ b/src/project/projecttab.cpp @@ -179,6 +179,14 @@ ADD_ACTION_SHORTCUT_ICON("go_next_transOnly",i18nc("@action:inmenu","Next translation only"),Qt::ALT+Qt::Key_Down,"nextpo") connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoNextTransOnly())); + action=nav->addAction(QStringLiteral("toggle_translated_files")); + action->setText(i18nc("@action:inmenu","Hide completed items")); + action->setToolTip(i18nc("@action:inmenu","Hide fully translated files and folders")); + action->setIcon(QIcon::fromTheme("hide_table_row")); + action->setCheckable(true); + ac->setDefaultShortcut(action, QKeySequence(Qt::CTRL+Qt::Key_T)); + connect(action, &QAction::triggered, this, &ProjectTab::toggleTranslatedFiles); + // ADD_ACTION_SHORTCUT_ICON("edit_find",i18nc("@action:inmenu","Find in files"),Qt::ALT+Qt::Key_Down,"nextpo") //connect( action, SIGNAL(triggered(bool)), this, SLOT(gotoNextTransOnly())); action=nav->addAction(KStandardAction::Find,this,SLOT(searchInFiles())); @@ -205,6 +213,11 @@ m_stackedLayout->setCurrentIndex(1); } +void ProjectTab::toggleTranslatedFiles() +{ + m_browser->toggleTranslatedFiles(); +} + QString ProjectTab::currentFilePath() { return Project::instance()->path(); diff --git a/src/project/projectwidget.h b/src/project/projectwidget.h --- a/src/project/projectwidget.h +++ b/src/project/projectwidget.h @@ -61,6 +61,7 @@ void gotoNextTemplateOnly(); void gotoPrevTransOnly(); void gotoNextTransOnly(); + void toggleTranslatedFiles(); signals: void fileOpenRequested(const QString&); diff --git a/src/project/projectwidget.cpp b/src/project/projectwidget.cpp --- a/src/project/projectwidget.cpp +++ b/src/project/projectwidget.cpp @@ -143,12 +143,20 @@ connect(Project::instance()->model(),SIGNAL(totalsChanged(int,int,int,bool)),this,SLOT(invalidate())); } ~SortFilterProxyModel(){} + void toggleTranslatedFiles(); protected: bool lessThan(const QModelIndex& left, const QModelIndex& right) const; bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; +private: + bool m_hideTranslatedFiles = false; }; +void SortFilterProxyModel::toggleTranslatedFiles() +{ + m_hideTranslatedFiles = !m_hideTranslatedFiles; + invalidateFilter(); +} bool SortFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const { @@ -162,6 +170,9 @@ if (item.data(ProjectModel::TotalRole) == 0) return false; // Hide rows with no translations + if (item.data(ProjectModel::FuzzyUntrCountAllRole) == 0 && m_hideTranslatedFiles) + return false; // Hide rows with no untranslated items if the filter is enabled + int i=model->rowCount(item); while(--i>=0 && !result) result=filterAcceptsRow(i,item); @@ -501,6 +512,10 @@ void ProjectWidget::gotoNextTemplateOnly() {gotoIndex(currentIndex(), ProjectModel::TemplateOnlyRole, +1);} void ProjectWidget::gotoPrevTransOnly() {gotoIndex(currentIndex(), ProjectModel::TransOnlyRole, -1);} void ProjectWidget::gotoNextTransOnly() {gotoIndex(currentIndex(), ProjectModel::TransOnlyRole, +1);} +void ProjectWidget::toggleTranslatedFiles() +{ + m_proxyModel->toggleTranslatedFiles(); +} QSortFilterProxyModel* ProjectWidget::proxyModel(){return m_proxyModel;}