"Fossies" - the Fresh Open Source Software Archive

Member "MP3Diags-unstable-1.5.01/src/ConfigDlgImpl.cpp" (16 Feb 2019, 71353 Bytes) of package /linux/privat/MP3Diags-unstable-1.5.01.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "ConfigDlgImpl.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.3.04_vs_1.5.01.

    1 /***************************************************************************
    2  *   MP3 Diags - diagnosis, repairs and tag editing for MP3 files          *
    3  *                                                                         *
    4  *   Copyright (C) 2009 by Marian Ciobanu                                  *
    5  *   ciobi@inbox.com                                                       *
    6  *                                                                         *
    7  *   This program is free software; you can redistribute it and/or modify  *
    8  *   it under the terms of the GNU General Public License version 2 as     *
    9  *   published by the Free Software Foundation.                            *
   10  *                                                                         *
   11  *   This program is distributed in the hope that it will be useful,       *
   12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   14  *   GNU General Public License for more details.                          *
   15  *                                                                         *
   16  *   You should have received a copy of the GNU General Public License     *
   17  *   along with this program; if not, write to the                         *
   18  *   Free Software Foundation, Inc.,                                       *
   19  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
   20  ***************************************************************************/
   21 
   22 
   23 #include  <QMessageBox>
   24 #include  <QFileDialog>
   25 #include  <QTextCodec>
   26 #include  <QSettings>
   27 #include  <QFontDialog>
   28 #include  <QColorDialog>
   29 #include  <QPainter>
   30 #include  <QStackedLayout>
   31 #include  <QCloseEvent>
   32 
   33 #include  "ConfigDlgImpl.h"
   34 
   35 #include  "StructuralTransformation.h"
   36 #include  "Transformation.h"
   37 #include  "OsFile.h"
   38 #include  "Helpers.h"
   39 #include  "Id3Transf.h"
   40 #include  "Id3V230Stream.h"
   41 #include  "MpegStream.h"
   42 #include  "CommonData.h"
   43 #include  "StoredSettings.h"
   44 #include  "ColumnResizer.h"
   45 #include  "Widgets.h"
   46 #include  "Translation.h"
   47 
   48 ////#include  <iostream> //ttt remove
   49 
   50 
   51 using namespace std;
   52 using namespace pearl;
   53 
   54 //ttt2 simple / detailed files tab, with "simple" only allowing to "create backups in ..."
   55 //=====================================================================================================================
   56 //=====================================================================================================================
   57 //=====================================================================================================================
   58 
   59 
   60 class TransfListElem : public ListElem
   61 {
   62     /*override*/ std::string getText(int nCol) const;
   63     const Transformation* m_pTransformation; // doesn't own the pointer
   64     //CommonData* m_pCommonData;
   65 public:
   66     TransfListElem(const Transformation* pTransformation/*, CommonData* pCommonData*/) : m_pTransformation(pTransformation)/*, m_pCommonData(pCommonData)*/ {}
   67     const Transformation* getTransformation() const { return m_pTransformation; }
   68 };
   69 
   70 /*override*/ std::string TransfListElem::getText(int nCol) const
   71 {
   72     if (0 == nCol) { return convStr(Transformation::tr(m_pTransformation->getActionName())); }
   73     return convStr(Transformation::tr(m_pTransformation->getDescription()));
   74 }
   75 
   76 
   77 class CustomTransfListPainter : public ListPainter
   78 {
   79     Q_DECLARE_TR_FUNCTIONS(CustomTransfListPainter)
   80     /*override*/ int getColCount() const { return 2; }
   81     /*override*/ std::string getColTitle(int nCol) const { return 0 == nCol ? convStr(tr("Action")) : convStr(tr("Description")); }
   82     /*override*/ void getColor(int /*nIndex*/, int /*nColumn*/, bool /*bSubList*/, QColor& /*bckgColor*/, QColor& /*penColor*/, double& /*dGradStart*/, double& /*dGradEnd*/) const { }
   83     /*override*/ int getColWidth(int /*nCol*/) const { return -1; } // positive values are used for fixed widths, while negative ones are for "stretched"
   84     /*override*/ int getHdrHeight() const { return CELL_HEIGHT; }
   85     /*override*/ Qt::Alignment getAlignment(int /*nCol*/) const { return Qt::AlignTop | Qt::AlignLeft; }
   86     /*override*/ std::string getTooltip(TooltipKey eTooltipKey) const;
   87     /*override*/ void reset();
   88 
   89     const SubList& m_vDefaultSel; // to be used by reset()
   90 public:
   91     CustomTransfListPainter(const CommonData* pCommonData, const SubList& vOrigSel, const SubList& vSel, const SubList& vDefaultSel);
   92     ~CustomTransfListPainter();
   93 };
   94 
   95 
   96 
   97 CustomTransfListPainter::CustomTransfListPainter(const CommonData* pCommonData, const SubList& vOrigSel, const SubList& vSel, const SubList& vDefaultSel) : ListPainter(""), m_vDefaultSel(vDefaultSel)
   98 {
   99 //qDebug("init CustomTransfListPainter with origsel %d and sel %d", cSize(vOrigSel), cSize(vSel));
  100     for (int i = 0, n = cSize(pCommonData->getAllTransf()); i < n; ++i)
  101     {
  102         m_vpOrigAll.push_back(new TransfListElem(pCommonData->getAllTransf()[i]));
  103     }
  104     m_vpResetAll = m_vpOrigAll; // !!! no new pointers
  105     m_vOrigSel = vOrigSel;
  106     m_vSel = vSel;
  107 }
  108 
  109 
  110 CustomTransfListPainter::~CustomTransfListPainter()
  111 {
  112     clearPtrContainer(m_vpOrigAll);
  113 }
  114 
  115 
  116 /*override*/ string CustomTransfListPainter::getTooltip(TooltipKey eTooltipKey) const
  117 {
  118     switch (eTooltipKey)
  119     {
  120     case SELECTED_G: return "";//"Notes to be included";
  121     case AVAILABLE_G: return "";//"Available notes";
  122     case ADD_B: return convStr(tr("Add selected transformation(s)"));
  123     case DELETE_B: return convStr(tr("Remove selected transformation(s)"));
  124     case ADD_ALL_B: return "";//"Add all transformations";
  125     case DELETE_ALL_B: return "";//"Remove all transformations";
  126     case RESTORE_DEFAULT_B: return convStr(tr("Restore current list to its default value"));
  127     case RESTORE_OPEN_B: return convStr(tr("Restore current list to the configuration it had when the window was open"));
  128     default: CB_ASSERT(false);
  129     }
  130 }
  131 
  132 
  133 /*override*/ void CustomTransfListPainter::reset()
  134 {
  135     m_vSel = m_vDefaultSel;
  136 }
  137 
  138 //=====================================================================================================================
  139 //=====================================================================================================================
  140 //=====================================================================================================================
  141 
  142 
  143 class VisibleTransfPainter : public ListPainter
  144 {
  145     Q_DECLARE_TR_FUNCTIONS(VisibleTransfPainter)
  146     /*override*/ int getColCount() const { return 2; }
  147     /*override*/ std::string getColTitle(int nCol) const { return 0 == nCol ? convStr(tr("Action")) : convStr(tr("Description")); }
  148     /*override*/ void getColor(int /*nIndex*/, int /*nColumn*/, bool /*bSubList*/, QColor& /*bckgColor*/, QColor& /*penColor*/, double& /*dGradStart*/, double& /*dGradEnd*/) const { }
  149     /*override*/ int getColWidth(int /*nCol*/) const { return -1; } // positive values are used for fixed widths, while negative ones are for "stretched"
  150     /*override*/ int getHdrHeight() const { return CELL_HEIGHT; }
  151     /*override*/ Qt::Alignment getAlignment(int /*nCol*/) const { return Qt::AlignTop | Qt::AlignLeft; }
  152     /*override*/ std::string getTooltip(TooltipKey eTooltipKey) const;
  153     /*override*/ void reset();
  154 
  155     const SubList& m_vDefaultSel; // to be used by reset()
  156 
  157 public:
  158     VisibleTransfPainter(const CommonData* pCommonData, const SubList& vOrigSel, const SubList& vSel, const SubList& vDefaultSel);
  159     ~VisibleTransfPainter();
  160 };
  161 
  162 
  163 
  164 VisibleTransfPainter::VisibleTransfPainter(const CommonData* pCommonData, const SubList& vOrigSel, const SubList& vSel, const SubList& vDefaultSel) : ListPainter(""), m_vDefaultSel(vDefaultSel)
  165 {
  166     const vector<Transformation*>& v (pCommonData->getAllTransf());
  167     for (int i = 0, n = cSize(v); i < n; ++i)
  168     {
  169         const Transformation* p (v[i]);
  170         m_vpOrigAll.push_back(new TransfListElem(p));
  171     }
  172 
  173     m_vpResetAll = m_vpOrigAll; // !!! no new pointers
  174     m_vOrigSel = vOrigSel;
  175     m_vSel = vSel;
  176 }
  177 
  178 
  179 VisibleTransfPainter::~VisibleTransfPainter()
  180 {
  181     clearPtrContainer(m_vpOrigAll);
  182 }
  183 
  184 
  185 /*override*/ string VisibleTransfPainter::getTooltip(TooltipKey eTooltipKey) const
  186 {
  187     switch (eTooltipKey)
  188     {
  189     case SELECTED_G: return "";//"Notes to be included";
  190     case AVAILABLE_G: return "";//"Available notes";
  191     case ADD_B: return convStr(tr("Add selected transformation(s)"));
  192     case DELETE_B: return convStr(tr("Remove selected transformation(s)"));
  193     case ADD_ALL_B: return "";//"Add all transformations";
  194     case DELETE_ALL_B: return "";//"Remove all transformations";
  195     case RESTORE_DEFAULT_B: return convStr(tr("Restore current list to its default value"));
  196     case RESTORE_OPEN_B: return convStr(tr("Restore current list to the configuration it had when the window was open"));
  197     default: CB_ASSERT(false);
  198     }
  199 }
  200 
  201 
  202 /*override*/ void VisibleTransfPainter::reset()
  203 {
  204     m_vSel = m_vDefaultSel;
  205 }
  206 
  207 
  208 //=====================================================================================================================
  209 //=====================================================================================================================
  210 //=====================================================================================================================
  211 
  212 
  213 namespace BpsInfo
  214 {
  215     int s_aValidBps[] = { 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 288, 320, 10000 };
  216     //int s_aValidBps[] = { 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 10000 };
  217     int getIndex(int nVal)
  218     {
  219         if (nVal >= 10000) { return 0; }
  220         int i (0);
  221         for (; s_aValidBps[i] < nVal; ++i) {}
  222         if (10000 == s_aValidBps[i]) { return i - 1; }
  223         return i;
  224     }
  225 
  226     const QStringList& getValueList()
  227     {
  228         static QStringList lst;
  229         if (lst.isEmpty())
  230         {
  231             for (int i = 0; ; ++i)
  232             {
  233                 if (10000 == s_aValidBps[i]) { break; }
  234                 lst << QString::number(s_aValidBps[i]);
  235             }
  236         }
  237 
  238         return lst;
  239     }
  240 } // namespace BpsInfo
  241 
  242 
  243 //=====================================================================================================================
  244 
  245 /*
  246 class EventFilter : public QObject
  247 {
  248     bool eventFilter(QObject* pObj, QEvent* pEvent)
  249     {
  250         if (QEvent::Paint != pEvent->type())
  251         {
  252             qDebug("%s %d", pObj->objectName().toUtf8().constData(), (int)pEvent->type());
  253         }
  254 
  255         static bool b (true);
  256         if (QEvent::Hide == pEvent->type())
  257         {
  258             b = !b;
  259             if (b)
  260             {
  261                 qDebug("not allowed");
  262                 pEvent->ignore();
  263                 return true;
  264             }
  265         }
  266         return QObject::eventFilter(pObj, pEvent);
  267     }
  268 public:
  269     EventFilter(QObject* pParent) : QObject(pParent) {}
  270 };
  271 */
  272 
  273 
  274 
  275 
  276 ConfigDlgImpl::ConfigDlgImpl(TransfConfig& transfCfg, CommonData* pCommonData, QWidget* pParent, bool bFull) :
  277         QDialog(pParent, getDialogWndFlags()),
  278         Ui::ConfigDlg(),
  279         NoteListPainterBase(pCommonData, convStr(tr("<all notes>"))),
  280         m_transfCfg(transfCfg),
  281 
  282         m_pCommonData(pCommonData),
  283         m_bFull(bFull),
  284         m_pCustomTransfListPainter(0),
  285         m_pCustomTransfDoubleList(0),
  286         m_vvnCustomTransf(pCommonData->getCustomTransf()),
  287         m_nCurrentTransf(-1),
  288         m_vvnDefaultCustomTransf(CUSTOM_TRANSF_CNT),
  289         m_pVisibleTransfPainter(0),
  290         m_vnVisibleTransf(pCommonData->getVisibleTransf()),
  291         m_bExtToolChanged(false),
  292         m_vExternalToolInfos(pCommonData->m_vExternalToolInfos)
  293 {
  294     setupUi(this);
  295 
  296 #ifdef DISABLE_CHECK_FOR_UPDATES
  297     m_pCheckForUpdatesCkB->hide();
  298 #endif
  299 
  300     if (!bFull)
  301     {
  302         m_pMainTabWidget->removeTab(8);
  303         m_pMainTabWidget->removeTab(7);
  304         m_pMainTabWidget->removeTab(6);
  305         m_pMainTabWidget->removeTab(5);
  306         m_pMainTabWidget->removeTab(4);
  307         m_pMainTabWidget->removeTab(2);
  308         m_pMainTabWidget->removeTab(1);
  309         m_pLocaleGrp->hide();
  310         m_pCaseGrp->hide();
  311         //m_pRenameW->hide();
  312         m_pOthersMiscGrp->hide();
  313         //m_pScanAtStartupCkB->hide();
  314         //m_pShowDebugCkB->hide();
  315         //m_pShowSessCkB->hide();
  316         //m_pIconConfW->hide();
  317         //m_pFontsW->hide();
  318         m_pNormalizeGrp->hide();
  319         m_pRenamerGrp->hide();
  320     }
  321 
  322     m_pSourceDirF->hide();
  323 
  324     {
  325         m_pExternalToolsModel = new ExternalToolsModel(this);
  326         m_pExternalToolsG->setModel(m_pExternalToolsModel);
  327         m_pExternalToolsG->verticalHeader()->setMinimumSectionSize(CELL_HEIGHT);
  328         m_pExternalToolsG->verticalHeader()->setDefaultSectionSize(CELL_HEIGHT);
  329         decreaseRowHeaderFont(*m_pExternalToolsG);
  330 
  331         connect(m_pExternalToolsG->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(onExternalToolsGCurrentChanged()));
  332         connect(m_pExternalToolsG->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex &)), this, SLOT(onExternalToolsGCurrentChanged()));
  333     }
  334 
  335     int nWidth, nHeight;
  336     m_pCommonData->m_settings.loadConfigSize(nWidth, nHeight);
  337     if (nWidth > 400 && nHeight > 400)
  338     {
  339         resize(nWidth, nHeight);
  340     }
  341     else
  342     {
  343         defaultResize(*this);
  344     }
  345 
  346 
  347     { // set text for ID3V2 codepage test
  348         QString qstr;
  349         const Mp3Handler* p (m_pCommonData->getCrtMp3Handler());
  350         if (0 != p)
  351         {
  352             const vector<DataStream*>& vpStreams (p->getStreams());
  353             for (int i = 0, n = cSize(vpStreams); i < n; ++i)
  354             {
  355                 DataStream* p (vpStreams[i]);
  356                 Id3V2StreamBase* pId3V2 (dynamic_cast<Id3V2StreamBase*>(p));
  357 
  358                 if (0 != pId3V2)
  359                 {
  360                     QString q;
  361                     const vector<Id3V2Frame*>& vpFrames (pId3V2->getFrames());
  362                     for (int i = 0, n = cSize(vpFrames); i < n; ++i)
  363                     {
  364                         const Id3V2Frame* pFrm (vpFrames[i]);
  365                         if ('T' == pFrm->m_szName[0] && pFrm->m_bHasLatin1NonAscii)
  366                         {
  367                             q += convStr(pFrm->getUtf8String()) + "\n";
  368                         }
  369                     }
  370                     if (!q.isEmpty())
  371                     {
  372                         qstr += "*************************************************************************\nID3V2\n" + q + "\n\n";
  373                     }
  374                 }
  375 
  376                 Id3V1Stream* pId3V1 (dynamic_cast<Id3V1Stream*>(p));
  377 
  378                 if (0 != pId3V1)
  379                 {
  380                     vector<string> v;
  381                     QString q;
  382                     v.push_back(pId3V1->getTitle());
  383                     v.push_back(pId3V1->getArtist());
  384                     v.push_back(pId3V1->getAlbumName());
  385                     v.push_back(pId3V1->getOtherInfo());
  386                     for (int i = 0; i < cSize(v); ++i)
  387                     {
  388                         for (int j = 0; j < cSize(v[i]); ++j)
  389                         {
  390                             unsigned char c (v[i][j]);
  391                             if (c >= 128)
  392                             {
  393                                 q += convStr(v[i]) + "\n";
  394                                 break;
  395                             }
  396                         }
  397                     }
  398                     if (!q.isEmpty())
  399                     {
  400                         qstr += "*************************************************************************\nID3V1\n" + q + "\n\n";
  401                     }
  402                 }
  403             }
  404         }
  405 
  406         if (qstr.isEmpty())
  407         {
  408             qstr = tr("If you don't know exactly what codepage you want, it's better to make current a file having an ID3V2 tag that contains text frames using the Latin-1 encoding and having non-ASCII characters. Then the content of those frames will replace this text, allowing you to decide which codepage is a match for your file. ID3V1 tags are supported as well, if you want to copy data from them to ID3V2.");
  409         }
  410 
  411         m_codepageTestText = qstr.toLatin1();
  412     }
  413 
  414 
  415 
  416     /*EventFilter* pEventFilter (new EventFilter(this));
  417     tab->installEventFilter(pEventFilter);
  418     //tab_3->installEventFilter(pEventFilter);
  419     */
  420 
  421     {
  422 
  423         {
  424             delete m_pRemovableL;
  425 
  426             delete m_pFileSettingsW->layout();
  427             m_pFileSettingsLayout = new QStackedLayout(m_pFileSettingsW);
  428             //m_pFileSettingsLayout->setContentsMargins(0, 50, 50, 0);
  429             //m_pFileSettingsW->setLayout(m_pFileSettingsLayout);
  430             m_pFileSettingsLayout->addWidget(m_pSimpleViewTab);
  431             m_pFileSettingsLayout->addWidget(m_pFullViewTab);
  432 
  433             delete m_pDetailsTabWidget;
  434         }
  435 
  436         m_pPODestE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getProcOrigDir()))));
  437         m_pPODest2E->setText(m_pPODestE->text());
  438         m_pUODestE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getUnprocOrigDir()))));
  439         m_pProcDestE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getProcessedDir()))));
  440         m_pTempDestE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getTempDir()))));
  441         m_pCompDestE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getCompDir()))));
  442 
  443         m_pSrcDirE->setText(toNativeSeparators(convStr(getSepTerminatedDir(transfCfg.getSrcDir()))));
  444 
  445         //setSimpleViewOpt(transfCfg.m_options); //!!! pointless; doesn't work if keepTime is true; anyway, the on_m_pSimpleViewB_clicked() call below will select the right radiobutton
  446         setFullViewOpt(transfCfg.m_options); // !!! the buttons should be set for both views
  447         setSimpleViewOpt(transfCfg.m_options);
  448 
  449         TransfConfig::Options opt (transfCfg.m_options);
  450 
  451         if (opt.asBackup() == opt || opt.asNonBackup() == opt)
  452         {
  453             m_pSimpleViewB->setChecked(true);
  454             on_m_pSimpleViewB_clicked();
  455         }
  456         else
  457         {
  458             m_pFullViewB->setChecked(true);
  459             on_m_pFullViewB_clicked();
  460         }
  461 
  462 
  463         m_pKeepOrigTimeCkB->setChecked(transfCfg.m_options.m_bKeepOrigTime);
  464     }
  465 
  466 
  467 
  468     // -------------------------------------------- ignored ------------------------------------------------------
  469 
  470     m_pIgnoredNotesListHldr->setLayout(new QHBoxLayout());
  471 
  472     const vector<const Note*>& vpAllNotes (Notes::getAllNotes());
  473     for (int i = 0, n = cSize(vpAllNotes); i < n; ++i)
  474     {
  475         m_vpOrigAll.push_back(new NoteListElem(vpAllNotes[i], m_pCommonData));
  476     }
  477 
  478     m_vOrigSel = pCommonData->getIgnoredNotes();
  479     //cout << "constr:\n"; printContainer(pCommonData->m_vnIgnoredNotes, cout);
  480 
  481     m_vSel = m_vOrigSel;
  482 
  483     m_pDoubleList = new DoubleList(
  484             *this,
  485             DoubleList::ADD_ALL | DoubleList::DEL_ALL | DoubleList::RESTORE_OPEN | DoubleList::RESTORE_DEFAULT,
  486             DoubleList::SINGLE_UNSORTABLE,
  487             convStr(tr("Other notes")),
  488             convStr(tr("Ignore notes")),
  489             this);
  490 
  491     m_pIgnoredNotesListHldr->layout()->addWidget(m_pDoubleList);
  492     m_pIgnoredNotesListHldr->layout()->setContentsMargins(0, 0, 0, 0);
  493 
  494 
  495     // -------------------------------------------- custom transformations ------------------------------------------------------
  496 
  497     m_pTransfListHldr->setLayout(new QHBoxLayout());
  498     m_pTransfListHldr->layout()->setContentsMargins(0, 0, 0, 0);
  499 
  500     m_vpTransfButtons.push_back(m_pCustomTransform1B);
  501     m_vpTransfButtons.push_back(m_pCustomTransform2B);
  502     m_vpTransfButtons.push_back(m_pCustomTransform3B);
  503     m_vpTransfButtons.push_back(m_pCustomTransform4B); // CUSTOM_TRANSF_CNT
  504 
  505     m_defaultPalette = m_pCustomTransform1T->palette();
  506     m_wndPalette = m_pCustomTransform1T->palette();
  507 
  508     m_wndPalette.setColor(QPalette::Base, m_wndPalette.color(QPalette::Disabled, QPalette::Window));
  509     m_vpTransfLabels.push_back(m_pCustomTransform1T);
  510     m_vpTransfLabels.push_back(m_pCustomTransform2T);
  511     m_vpTransfLabels.push_back(m_pCustomTransform3T);
  512     m_vpTransfLabels.push_back(m_pCustomTransform4T); // CUSTOM_TRANSF_CNT
  513 
  514     for (int i = 0; i < CUSTOM_TRANSF_CNT; ++i)
  515     {
  516         m_vpTransfLabels[i]->setPalette(m_wndPalette);
  517         refreshTransfText(i);
  518         initDefaultCustomTransf(i, m_vvnDefaultCustomTransf, m_pCommonData);
  519     }
  520 
  521     selectCustomTransf(0);
  522 
  523     const QStringList& freqLst (BpsInfo::getValueList());
  524 
  525     { m_pQualStCbrCbB->insertItems(0, freqLst); m_pQualStCbrCbB->setCurrentIndex(BpsInfo::getIndex(m_pCommonData->getQualThresholds().m_nStereoCbr/1000)); }
  526     { m_pQualJtStCbrCbB->insertItems(0, freqLst); m_pQualJtStCbrCbB->setCurrentIndex(BpsInfo::getIndex(m_pCommonData->getQualThresholds().m_nJointStereoCbr/1000)); }
  527     { m_pQualDlChCbrCbB->insertItems(0, freqLst); m_pQualDlChCbrCbB->setCurrentIndex(BpsInfo::getIndex(m_pCommonData->getQualThresholds().m_nDoubleChannelCbr/1000)); }
  528 
  529     // ttt2 try and create some custom widget based on QSpinBox for CBR, so only valid frequencies can be chosen;
  530 
  531     m_pQualStVbrSB->setValue(m_pCommonData->getQualThresholds().m_nStereoVbr/1000);
  532     m_pQualJtStVbrSB->setValue(m_pCommonData->getQualThresholds().m_nJointStereoVbr/1000);
  533     m_pQualDlChVbrSB->setValue(m_pCommonData->getQualThresholds().m_nDoubleChannelVbr/1000);
  534 
  535     { // locale
  536         QStringList lNames;
  537         set<QString> s;
  538 //set<QString> s1;
  539         QList<QByteArray> l (QTextCodec::availableCodecs());
  540         for (int i = 0, n = l.size(); i < n; ++i)
  541         {
  542             //lNames << QString::fromLatin1(l[i]);
  543             //lNames << QTextCodec::codecForName(l[i])->name();
  544             s.insert(QTextCodec::codecForName(l[i])->name()); // a codec is known by several names; by doing this we eliminate redundant names and make the list a lot smaller
  545             //s.insert(QTextCodec::codecForName(l[i])->name() + QString::fromLatin1(l[i]));
  546 //qDebug("%s", (QString::fromLatin1(l[i]) + "  /  " + QTextCodec::codecForName(l[i])->name()).toUtf8().data());
  547 //s1.insert(QTextCodec::codecForName(l[i])->name() + "  /  " + QString::fromLatin1(l[i]));
  548         }
  549 
  550         for (set<QString>::const_iterator it = s.begin(); it != s.end(); ++it)
  551         {
  552             lNames << *it;
  553         }
  554 //for (set<QString>::const_iterator it = s1.begin(); it != s1.end(); ++it) { qDebug("%s", it->toUtf8().data()); }
  555 
  556 //lNames.sort();
  557 
  558         m_pId3LocaleCbB->addItems(lNames);
  559         int n (m_pId3LocaleCbB->findText(m_pCommonData->m_locale));
  560         if (-1 == n) { n = 0; }
  561         m_pId3LocaleCbB->setCurrentIndex(n);
  562     }
  563 
  564     { // case
  565         QStringList lNames;
  566         /*lNames << "Lower case: first part. second part.";
  567         lNames << "Upper case: FIRST PART. SECOND PART.";
  568         lNames << "Title case: First Part. Second Part.";
  569         lNames << "Sentence case: First part. Second part.";*/ // ttt2 perhaps put this back; as of 2009.10.15, "." is no longer supported as a sentence ending
  570         lNames << tr("lower case");
  571         lNames << tr("UPPER CASE");
  572         lNames << tr("Title Case");
  573         lNames << tr("Sentence case");
  574 
  575         m_pArtistsCaseCbB->addItems(lNames);
  576         m_pOthersCaseCbB->addItems(lNames);
  577         m_pArtistsCaseCbB->setCurrentIndex((int)m_pCommonData->m_eCaseForArtists);
  578         m_pOthersCaseCbB->setCurrentIndex((int)m_pCommonData->m_eCaseForOthers);
  579     }
  580 
  581     { // colors
  582         m_vpColButtons.push_back(m_pCol0B);
  583         m_vpColButtons.push_back(m_pCol1B);
  584         m_vpColButtons.push_back(m_pCol2B);
  585         m_vpColButtons.push_back(m_pCol3B);
  586         m_vpColButtons.push_back(m_pCol4B);
  587         m_vpColButtons.push_back(m_pCol5B);
  588         m_vpColButtons.push_back(m_pCol6B);
  589         m_vpColButtons.push_back(m_pCol7B);
  590         m_vpColButtons.push_back(m_pCol8B);
  591         m_vpColButtons.push_back(m_pCol9B);
  592         m_vpColButtons.push_back(m_pCol10B);
  593         m_vpColButtons.push_back(m_pCol11B);
  594         m_vpColButtons.push_back(m_pCol12B);
  595         m_vpColButtons.push_back(m_pCol13B);
  596 
  597         m_vNoteCategColors = m_pCommonData->m_vNoteCategColors;
  598 
  599         for (int i = 0; i < cSize(m_vpColButtons); ++i)
  600         {
  601             setBtnColor(i);
  602         }
  603     }
  604 
  605     { // tag editor
  606         m_pWarnOnNonSeqTracksCkB->setChecked(m_pCommonData->m_bWarnOnNonSeqTracks);
  607         m_pWarnOnPasteToNonSeqTracksCkB->setChecked(m_pCommonData->m_bWarnPastingToNonSeqTracks);
  608     }
  609 
  610     {  //misc
  611         {
  612             GlobalSettings st;
  613             if (st.getSessionCount() > 1)
  614             {
  615                 m_pShowSessCkB->setEnabled(false);
  616             }
  617         }
  618         m_pScanAtStartupCkB->setChecked(m_pCommonData->m_bScanAtStartup);
  619         m_pFastSaveCkB->setChecked(m_pCommonData->useFastSave());
  620         m_pShowExportCkB->setChecked(m_pCommonData->m_bShowExport);
  621         m_pShowDebugCkB->setChecked(m_pCommonData->m_bShowDebug);
  622         m_pShowSessCkB->setChecked(m_pCommonData->m_bShowSessions);
  623         m_pShowCustomCloseButtonsCkB->setChecked(m_pCommonData->m_bShowCustomCloseButtons);
  624         m_pNormalizerE->setText(convStr(m_pCommonData->m_strNormalizeCmd));
  625         m_pKeepNormOpenCkB->setChecked(m_pCommonData->m_bKeepNormWndOpen);
  626 
  627         switch (m_pCommonData->m_eAssignSave)
  628         {
  629         case CommonData::SAVE: m_pAssgnSaveRB->setChecked(true); break;
  630         case CommonData::DISCARD: m_pAssgnDiscardRB->setChecked(true); break;
  631         case CommonData::ASK: m_pAssgnAskRB->setChecked(true); break;
  632         default: CB_ASSERT (false);
  633         }
  634 
  635         switch (m_pCommonData->m_eNonId3v2Save)
  636         {
  637         case CommonData::SAVE: m_pNonId3v2SaveRB->setChecked(true); break;
  638         case CommonData::DISCARD: m_pNonId3v2DiscardRB->setChecked(true); break;
  639         case CommonData::ASK: m_pNonId3v2AskRB->setChecked(true); break;
  640         default: CB_ASSERT (false);
  641         }
  642 
  643         m_pIconSizeSB->setValue(m_pCommonData->m_nMainWndIconSize);
  644         m_pAutoSizeIconsCkB->setChecked(m_pCommonData->m_bAutoSizeIcons);
  645         m_pKeepOneValidImgCkB->setChecked(m_pCommonData->m_bKeepOneValidImg);
  646         m_pWmpCkB->setChecked(m_pCommonData->m_bWmpVarArtists);
  647         m_pItunesCkB->setChecked(m_pCommonData->m_bItunesVarArtists);
  648         m_pMaxImgSizeSB->setValue(ImageInfo::MAX_IMAGE_SIZE/1024);
  649         m_pTraceToFileCkB->setChecked(m_pCommonData->isTraceToFileEnabled());
  650 
  651         m_pInvalidCharsE->setText(convStr(m_pCommonData->m_strRenamerInvalidChars));
  652         m_pInvalidReplacementE->setText(convStr(m_pCommonData->m_strRenamerReplacementString));
  653 
  654         m_pCheckForUpdatesCkB->setChecked("yes" == m_pCommonData->m_strCheckForNewVersions);
  655 
  656         m_generalFont = m_pCommonData->getNewGeneralFont();
  657         m_pDecrLabelFontSB->setValue(m_pCommonData->getLabelFontSizeDecr());
  658         m_fixedFont = m_pCommonData->getNewFixedFont();
  659         setFontLabels();
  660 
  661         { // language
  662             m_pFlagIconL->setMaximumSize(CELL_HEIGHT*5, CELL_HEIGHT*3);
  663             int nCrt (0);
  664             const vector<string>& vstrTranslations (TranslatorHandler::getGlobalTranslator().getTranslations());
  665             string m_strTranslation (m_pCommonData->m_strTranslation); //ttt0 make member; ttt0 retranslate dynamically on on_m_pTranslationCbB_currentIndexChanged()
  666             string strTmpTranslation (m_strTranslation); // !!! needed because on_m_pTranslationCbB_currentIndexChanged() will get triggered and change m_strTranslation
  667             for (int i = 0; i < cSize(vstrTranslations); ++i)
  668             {
  669                 m_pTranslationCbB->addItem(convStr(TranslatorHandler::getLanguageInfo(vstrTranslations[i])));
  670                 if (strTmpTranslation == vstrTranslations[i])
  671                 {
  672                     nCrt = i;
  673                 }
  674             }
  675             m_strTranslation = strTmpTranslation;
  676             m_pTranslationCbB->setCurrentIndex(nCrt);
  677         }
  678     }
  679 
  680     {
  681         initDefaultVisibleTransf(m_vnDefaultVisibleTransf, m_pCommonData);
  682 
  683         m_pVisibleTransfPainter = new VisibleTransfPainter(m_pCommonData, m_pCommonData->getVisibleTransf(), m_vnVisibleTransf, m_vnDefaultVisibleTransf);
  684         m_pVisibleTransfDoubleList = new DoubleList(
  685                 *m_pVisibleTransfPainter,
  686                 DoubleList::RESTORE_OPEN | DoubleList::RESTORE_DEFAULT,
  687                 DoubleList::SINGLE_SORTABLE,
  688                 convStr(tr("Invisible transformations")),
  689                 convStr(tr("Visible transformations")),
  690                 this);
  691 
  692         m_pVisibleTransformsHndlr->setLayout(new QHBoxLayout());
  693         m_pVisibleTransformsHndlr->layout()->setContentsMargins(0, 0, 0, 0);
  694 
  695         m_pVisibleTransformsHndlr->layout()->addWidget(m_pVisibleTransfDoubleList);
  696     }
  697 
  698     m_pSrcDirE->setFocus();
  699 
  700     { QAction* p (new QAction(this)); p->setShortcut(QKeySequence("F1")); connect(p, SIGNAL(triggered()), this, SLOT(onHelp())); addAction(p); }
  701 
  702     m_pInvalidCharsE->setToolTip(tr("Characters in this list get replaced with the string below, in \"Replace with\"\n\n"
  703         "An underlined font is used to allow spaces to be seen"));
  704     m_pInvalidReplacementE->setToolTip(tr("This string replaces invalid characters in the file renamer\"\n\n"
  705         "An underlined font is used to allow spaces to be seen"));
  706 
  707     if (m_bFull)
  708     {
  709         m_pShellTempSessCkB->setChecked(ShellIntegration::isTempSessionEnabled());
  710         m_pShellVisibleSessCkB->setChecked(ShellIntegration::isVisibleSessionEnabled());
  711         m_pShellHiddenSessCkB->setChecked(ShellIntegration::isHiddenSessionEnabled());
  712 
  713         bool b (ShellIntegration::isShellIntegrationEditable());
  714         m_pShellTempSessCkB->setEnabled(b);
  715         m_pShellVisibleSessCkB->setEnabled(b);
  716         m_pShellHiddenSessCkB->setEnabled(b);
  717 
  718         string strShellErr (ShellIntegration::getShellIntegrationError());
  719 
  720         m_pShellErrorL->setText(convStr(strShellErr));
  721 
  722         QTimer::singleShot(1, this, SLOT(onResizeDelayed()));
  723     }
  724 
  725 #if 0
  726     installEventFilter(this);
  727     //tab_8->installEventFilter(this);
  728     //m_pExtToolNameE->installEventFilter(this);
  729 #endif
  730 }
  731 
  732 
  733 void ConfigDlgImpl::setBtnColor(int n)
  734 {
  735 //    QPalette pal (m_vpColButtons[n]->palette());
  736     //QPalette pal (m_pCol0B->palette());
  737 /*    pal.setBrush(QPalette::Button, m_vNoteCategColors[n]);
  738     pal.setBrush(QPalette::Window, m_vNoteCategColors[n]);
  739     pal.setBrush(QPalette::Midlight, QColor(255, 0, 0));
  740     pal.setBrush(QPalette::Dark, QColor(255, 0, 0));
  741     pal.setBrush(QPalette::Mid, QColor(255, 0, 0));
  742     pal.setBrush(QPalette::Shadow, QColor(255, 0, 0));*/
  743     //m_vpColButtons[n]->setPalette(pal);
  744 
  745     int f (QApplication::style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, m_vpColButtons.at(n)) + 2); //ttt2 hard-coded "2"
  746     int w (m_vpColButtons[n]->width() - f), h (m_vpColButtons[n]->height() - f);
  747     QPixmap pic (w, h);
  748     QPainter pntr (&pic);
  749     pntr.fillRect(0, 0, w, h, m_vNoteCategColors.at(n));
  750 
  751     m_vpColButtons[n]->setIcon(pic);
  752     m_vpColButtons[n]->setIconSize(QSize(w, h));
  753 }
  754 
  755 void ConfigDlgImpl::onButtonClicked(int n)
  756 {
  757     QColor c (QColorDialog::getColor(m_vNoteCategColors.at(n), this));
  758     if (!c.isValid()) { return; }
  759     m_vNoteCategColors[n] = c;
  760     setBtnColor(n);
  761 }
  762 
  763 
  764 void ConfigDlgImpl::on_m_pResetColorsB_clicked()
  765 {
  766     QColor c (getDefaultBkgCol());
  767     for (int i = 0; i < cSize(m_vNoteCategColors) - 1; ++i) // !!! "-1" because there is no configuration for CUSTOM colors
  768     {
  769         m_vNoteCategColors[i] = c;
  770         setBtnColor(i);
  771     }
  772 }
  773 
  774 void SessionSettings::saveTransfConfig(const TransfConfig& transfConfig)
  775 {
  776     m_pSettings->remove("transformation");
  777     m_pSettings->setValue("transformation/srcDir",          convStr(transfConfig.getSrcDir()));
  778     m_pSettings->setValue("transformation/procOrigDir",     convStr(transfConfig.getProcOrigDir()));
  779     m_pSettings->setValue("transformation/unprocOrigDir",   convStr(transfConfig.getUnprocOrigDir()));
  780     m_pSettings->setValue("transformation/processedDir",    convStr(transfConfig.getProcessedDir()));
  781     m_pSettings->setValue("transformation/tempDir",         convStr(transfConfig.getTempDir()));
  782     m_pSettings->setValue("transformation/compDir",         convStr(transfConfig.getCompDir()));
  783 
  784     m_pSettings->setValue("transformation/options",     transfConfig.getOptions());
  785 
  786     /*if (transfConfig.getOptions() != 14349) //ttt remove
  787     {
  788         qDebug("cfg changed: %x", transfConfig.getOptions());
  789     }*/
  790 }
  791 
  792 // returns false if there was some error while loading (so the user can be told about defaults being used and those defaults could get saved)
  793 bool SessionSettings::loadTransfConfig(TransfConfig& transfConfig) const
  794 {
  795     try
  796     {
  797         //TransfConfig tc ("/r/temp/1", "/r/temp/1", "/r/temp/1/proc", "/r/temp/1/temp_mp3");
  798         TransfConfig tc (
  799                 convStr(m_pSettings->value("transformation/srcDir", "*").toString()),
  800                 convStr(m_pSettings->value("transformation/procOrigDir", "*").toString()),
  801                 convStr(m_pSettings->value("transformation/unprocOrigDir", "*").toString()),
  802                 convStr(m_pSettings->value("transformation/processedDir", "*").toString()),
  803                 convStr(m_pSettings->value("transformation/tempDir", "*").toString()),
  804                 convStr(m_pSettings->value("transformation/compDir", "*").toString()),
  805                 m_pSettings->value("transformation/options", -1).toInt()
  806             );
  807         transfConfig = tc;
  808         return !tc.hadInitError();
  809     }
  810     catch (const IncorrectDirName&)
  811     {
  812         TransfConfig tc ("*", "*", "*", "*", "*", "*", -1);
  813         transfConfig = tc;
  814         return false;
  815     }
  816 }
  817 
  818 
  819 
  820 bool ConfigDlgImpl::run()
  821 {
  822     TRACER("ConfigDlgImpl::run()");
  823     if (QDialog::Accepted != exec()) { return false; }
  824     m_pCommonData->m_settings.saveConfigSize(width(), height());
  825     return true;
  826 }
  827 
  828 
  829 void ConfigDlgImpl::on_m_pId3LocaleCbB_currentIndexChanged(int)
  830 {
  831     QTextCodec* pCodec (QTextCodec::codecForName(m_pId3LocaleCbB->currentText().toLatin1()));
  832     CB_ASSERT (0 != pCodec);
  833     QString qstrTxt (pCodec->toUnicode(m_codepageTestText));
  834     m_pCodepageTestM->setText(qstrTxt);
  835 }
  836 
  837 
  838 //ttt2 treat "orig" and "proc" files as "orig" when processing them
  839 
  840 
  841 void initDefaultCustomTransf(int k, vector<vector<int> >& vv, CommonData* pCommonData)
  842 {
  843     vector<int>& v (vv[k]);
  844     switch (k)
  845     {
  846     case 0:
  847         v.push_back(pCommonData->getTransfPos(SingleBitRepairer::getClassName()));
  848         v.push_back(pCommonData->getTransfPos(InnerNonAudioRemover::getClassName()));
  849         v.push_back(pCommonData->getTransfPos(TruncatedMpegDataStreamRemover::getClassName()));
  850         v.push_back(pCommonData->getTransfPos(VbrRepairer::getClassName()));
  851         v.push_back(pCommonData->getTransfPos(MismatchedXingRemover::getClassName())); // !!! takes care of broken Xing headers for CBR files (VbrRepairer only deals with VBR files)
  852         break;
  853 
  854     case 1:
  855         v.push_back(pCommonData->getTransfPos(Id3V2Rescuer::getClassName()));
  856         v.push_back(pCommonData->getTransfPos(UnsupportedId3V2Remover::getClassName()));
  857         //v.push_back(pCommonData->getTransfPos(MultipleId3StreamRemover::getClassName()));
  858         //v.push_back(pCommonData->getTransfPos(Id3V1ToId3V2Copier::getClassName()));
  859         break;
  860 
  861     case 2:
  862         v.push_back(pCommonData->getTransfPos(InnerNonAudioRemover::getClassName()));
  863         v.push_back(pCommonData->getTransfPos(UnknownDataStreamRemover::getClassName()));
  864         v.push_back(pCommonData->getTransfPos(BrokenDataStreamRemover::getClassName()));
  865         v.push_back(pCommonData->getTransfPos(UnsupportedDataStreamRemover::getClassName()));
  866         v.push_back(pCommonData->getTransfPos(TruncatedMpegDataStreamRemover::getClassName()));
  867         v.push_back(pCommonData->getTransfPos(NullStreamRemover::getClassName()));
  868         //v.push_back(pCommonData->getTransfPos(MultipleId3StreamRemover::getClassName()));
  869         v.push_back(pCommonData->getTransfPos(MismatchedXingRemover::getClassName()));
  870         break;
  871 
  872     case 3: // CUSTOM_TRANSF_CNT
  873         v.push_back(pCommonData->getTransfPos(SingleBitRepairer::getClassName()));
  874         v.push_back(pCommonData->getTransfPos(InnerNonAudioRemover::getClassName()));
  875         v.push_back(pCommonData->getTransfPos(TruncatedMpegDataStreamRemover::getClassName()));
  876         v.push_back(pCommonData->getTransfPos(VbrRepairer::getClassName()));
  877         v.push_back(pCommonData->getTransfPos(MismatchedXingRemover::getClassName())); // !!! takes care of broken Xing headers for CBR files (VbrRepairer only deals with VBR files)
  878 
  879         v.push_back(pCommonData->getTransfPos(Id3V2Rescuer::getClassName()));
  880         v.push_back(pCommonData->getTransfPos(UnsupportedId3V2Remover::getClassName()));
  881         v.push_back(pCommonData->getTransfPos(MultipleId3StreamRemover::getClassName()));
  882         //v.push_back(pCommonData->getTransfPos(Id3V1ToId3V2Copier::getClassName()));
  883 
  884         //v.push_back(pCommonData->getTransfPos(InnerNonAudioRemover::getClassName()));
  885         v.push_back(pCommonData->getTransfPos(UnknownDataStreamRemover::getClassName()));
  886         v.push_back(pCommonData->getTransfPos(BrokenDataStreamRemover::getClassName()));
  887         v.push_back(pCommonData->getTransfPos(UnsupportedDataStreamRemover::getClassName()));
  888         v.push_back(pCommonData->getTransfPos(TruncatedMpegDataStreamRemover::getClassName()));
  889         v.push_back(pCommonData->getTransfPos(NullStreamRemover::getClassName()));
  890         //v.push_back(pCommonData->getTransfPos(MultipleId3StreamRemover::getClassName()));
  891         //v.push_back(pCommonData->getTransfPos(MismatchedXingRemover::getClassName()));
  892         break;
  893 
  894     default:
  895         CB_ASSERT (false);
  896     }
  897 }
  898 
  899 
  900 void initDefaultVisibleTransf(vector<int>& v, CommonData* pCommonData)
  901 {
  902     v.push_back(pCommonData->getTransfPos(SingleBitRepairer::getClassName()));
  903     v.push_back(pCommonData->getTransfPos(InnerNonAudioRemover::getClassName()));
  904 
  905     v.push_back(pCommonData->getTransfPos(UnknownDataStreamRemover::getClassName()));
  906     v.push_back(pCommonData->getTransfPos(BrokenDataStreamRemover::getClassName()));
  907     v.push_back(pCommonData->getTransfPos(UnsupportedDataStreamRemover::getClassName()));
  908     v.push_back(pCommonData->getTransfPos(TruncatedMpegDataStreamRemover::getClassName()));
  909     v.push_back(pCommonData->getTransfPos(NullStreamRemover::getClassName()));
  910 
  911     v.push_back(pCommonData->getTransfPos(BrokenId3V2Remover::getClassName()));
  912     v.push_back(pCommonData->getTransfPos(UnsupportedId3V2Remover::getClassName()));
  913 
  914     //v.push_back(pCommonData->getTransfPos(IdentityTransformation::getClassName()));
  915 
  916     v.push_back(pCommonData->getTransfPos(MultipleId3StreamRemover::getClassName()));
  917     v.push_back(pCommonData->getTransfPos(MismatchedXingRemover::getClassName()));
  918 
  919     v.push_back(pCommonData->getTransfPos(TruncatedAudioPadder::getClassName()));
  920 
  921     v.push_back(pCommonData->getTransfPos(VbrRepairer::getClassName()));
  922     v.push_back(pCommonData->getTransfPos(VbrRebuilder::getClassName()));
  923 
  924     v.push_back(pCommonData->getTransfPos(Id3V2Cleaner::getClassName()));
  925     v.push_back(pCommonData->getTransfPos(Id3V2Rescuer::getClassName()));
  926     v.push_back(pCommonData->getTransfPos(Id3V2UnicodeTransformer::getClassName()));
  927     //v.push_back(pCommonData->getTransfPos(Id3V2CaseTransformer::getClassName()));
  928 
  929 
  930     //v.push_back(pCommonData->getTransfPos(Id3V2ComposerAdder::getClassName()));
  931     //v.push_back(pCommonData->getTransfPos(Id3V2ComposerRemover::getClassName()));
  932     //v.push_back(pCommonData->getTransfPos(Id3V2ComposerCopier::getClassName()));
  933 
  934     //v.push_back(pCommonData->getTransfPos(SmallerImageRemover::getClassName()));
  935     //v.push_back(pCommonData->getTransfPos(Id3V1ToId3V2Copier::getClassName()));
  936     //v.push_back(pCommonData->getTransfPos(Id3V1Remover::getClassName()));
  937 
  938     //v.push_back(pCommonData->getTransfPos(ApeRemover::getClassName()));
  939     //v.push_back(pCommonData->getTransfPos(NonAudioRemover::getClassName()));
  940     //v.push_back(pCommonData->getTransfPos(XingRemover::getClassName()));
  941     //v.push_back(pCommonData->getTransfPos(LameRemover::getClassName()));
  942 
  943     //v.push_back(pCommonData->getTransfPos(Id3V2Compactor::getClassName()));
  944     //v.push_back(pCommonData->getTransfPos(Id3V2Expander::getClassName()));
  945 }
  946 
  947 
  948 ConfigDlgImpl::~ConfigDlgImpl()
  949 {
  950     clearPtrContainer(m_vpOrigAll);
  951     clearPtrContainer(m_vpResetAll); // doesn't matter if it was used or not, or if m_bResultInReset is true or false
  952     delete m_pVisibleTransfPainter;
  953     delete m_pCustomTransfListPainter;
  954     delete m_pExternalToolsModel;
  955 }
  956 
  957 
  958 void ConfigDlgImpl::refreshTransfText(int k)
  959 {
  960     QString s;
  961     for (int i = 0, n = cSize(m_vvnCustomTransf[k]); i < n; ++i)
  962     {
  963         s += m_pCommonData->getAllTransf()[m_vvnCustomTransf[k][i]]->getVisibleActionName();
  964         if (i < n - 1) { s += "\n"; }
  965     }
  966     m_vpTransfLabels[k]->setText(s);
  967 }
  968 
  969 
  970 void ConfigDlgImpl::selectCustomTransf(int k) // 0 <= k <= 2
  971 {
  972     getTransfData();
  973     delete m_pCustomTransfDoubleList;
  974     delete m_pCustomTransfListPainter;
  975     m_pCustomTransfListPainter = new CustomTransfListPainter(m_pCommonData, m_pCommonData->getCustomTransf()[k], m_vvnCustomTransf[k], m_vvnDefaultCustomTransf[k]);
  976 
  977     m_pCustomTransfDoubleList = new DoubleList(
  978             *m_pCustomTransfListPainter,
  979             DoubleList::RESTORE_OPEN | DoubleList::RESTORE_DEFAULT,
  980             DoubleList::MULTIPLE,
  981             convStr(tr("All transformations")),
  982             convStr(tr("Used transformations")),
  983             this);
  984 
  985     m_pTransfListHldr->layout()->addWidget(m_pCustomTransfDoubleList);
  986     //m_pTransfListHldr->layout()->activate();
  987     //?->300x358//m_pCustomTransfDoubleList->layout()->activate();
  988     //m_pCustomTransfDoubleList->resizeOnShow();
  989     //m_pDetailsTabWidget->setCurrentIndex(0);
  990     //m_pDetailsTabWidget->setCurrentIndex(2);
  991 
  992     for (int i = 0; i < CUSTOM_TRANSF_CNT; ++i)
  993     {
  994         m_vpTransfButtons[i]->setChecked(false); m_vpTransfLabels[i]->setPalette(m_wndPalette);
  995     }
  996 
  997     m_vpTransfButtons[k]->setChecked(true); m_vpTransfLabels[k]->setPalette(m_defaultPalette);
  998     m_nCurrentTransf = k;
  999 
 1000     connect(m_pCustomTransfDoubleList, SIGNAL(dataChanged()), this, SLOT(onTransfDataChanged()));
 1001 }
 1002 
 1003 
 1004 
 1005 
 1006 
 1007 void ConfigDlgImpl::onTransfDataChanged()
 1008 {
 1009     getTransfData();
 1010 }
 1011 
 1012 
 1013 void ConfigDlgImpl::getTransfData()
 1014 {
 1015     if (-1 == m_nCurrentTransf) { return; }
 1016     m_vvnCustomTransf[m_nCurrentTransf] = m_pCustomTransfListPainter->getSel();
 1017 //qDebug("transf %d at %d", cSize(m_vvnCustomTransf[m_nCurrentTransf]), m_nCurrentTransf);
 1018     refreshTransfText(m_nCurrentTransf);
 1019 }
 1020 
 1021 
 1022 void ConfigDlgImpl::on_m_pOkB_clicked()
 1023 {
 1024     if (m_bExtToolChanged)
 1025     {
 1026         int nOpt (showMessage(this, QMessageBox::Question, 1, 1, tr("Confirm"), tr("You modified the external tool information but you didn't save your changes. Discard the changes or cancel closing of the options window?"), tr("&Discard"), tr("&Cancel")));
 1027         if (nOpt == 1)
 1028         {
 1029             return;
 1030         }
 1031     }
 1032 
 1033     {
 1034         string strInv (convStr(m_pInvalidCharsE->text()));
 1035         string strRepl (convStr(m_pInvalidReplacementE->text()));
 1036         if (!strInv.empty())
 1037         {
 1038             string::size_type n (strRepl.find_first_of(strInv));
 1039             if (string::npos != n)
 1040             {
 1041                 showCritical(this, tr("Error"), tr("You can't have '%1' in both the list of invalid characters and the string that invalid characters are replaced with.").arg(strRepl[n]));
 1042                 return;
 1043             }
 1044         }
 1045     }
 1046 
 1047     //logState("on_m_pOkB_clicked 1");
 1048     try
 1049     {
 1050         TransfConfig::Options opt (getOpt());
 1051 
 1052         TransfConfig cfg (
 1053                 getNonSepTerminatedDir(convStr(fromNativeSeparators(m_pSrcDirE->text()))),
 1054                 getNonSepTerminatedDir(convStr(fromNativeSeparators((m_pSimpleViewB->isChecked() ? m_pPODest2E : m_pPODestE)->text()))),
 1055                 getNonSepTerminatedDir(convStr(fromNativeSeparators(m_pUODestE->text()))),
 1056                 getNonSepTerminatedDir(convStr(fromNativeSeparators(m_pProcDestE->text()))),
 1057                 getNonSepTerminatedDir(convStr(fromNativeSeparators(m_pTempDestE->text()))),
 1058                 getNonSepTerminatedDir(convStr(fromNativeSeparators(m_pCompDestE->text()))),
 1059                 opt.getVal()
 1060             );
 1061         m_transfCfg = cfg;
 1062 
 1063         { // ignored
 1064             m_pCommonData->setIgnoredNotes(m_vSel);
 1065             //cout << "OK:\n"; printContainer(m_pCommonData->m_vnIgnoredNotes, cout);
 1066         }
 1067 
 1068         { // custom transformations
 1069             getTransfData();
 1070             m_pCommonData->setCustomTransf(m_vvnCustomTransf);
 1071         }
 1072 
 1073         {
 1074             //m_pCommonData->setVisibleTransf(m_vnVisibleTransf);
 1075             m_pCommonData->setVisibleTransf(m_pVisibleTransfPainter->getSel());
 1076         }
 1077 
 1078         {
 1079             QualThresholds q;
 1080 
 1081             q.m_nStereoCbr = BpsInfo::s_aValidBps[m_pQualStCbrCbB->currentIndex()]*1000;
 1082             q.m_nJointStereoCbr = BpsInfo::s_aValidBps[m_pQualJtStCbrCbB->currentIndex()]*1000;
 1083             q.m_nDoubleChannelCbr = BpsInfo::s_aValidBps[m_pQualDlChCbrCbB->currentIndex()]*1000;
 1084 
 1085             q.m_nStereoVbr = m_pQualStVbrSB->value()*1000;
 1086             q.m_nJointStereoVbr = m_pQualJtStVbrSB->value()*1000;
 1087             q.m_nDoubleChannelVbr = m_pQualDlChVbrSB->value()*1000;
 1088 
 1089             m_pCommonData->setQualThresholds(q);
 1090         }
 1091 
 1092         {
 1093             m_pCommonData->m_locale = m_pId3LocaleCbB->currentText().toLatin1();
 1094             m_pCommonData->m_pCodec = QTextCodec::codecForName(m_pCommonData->m_locale);
 1095             CB_ASSERT (0 != m_pCommonData->m_pCodec);
 1096         }
 1097 
 1098         { // case
 1099             m_pCommonData->m_eCaseForArtists = (TextCaseOptions)m_pArtistsCaseCbB->currentIndex(); //ttt2 perhaps allow NONE
 1100             m_pCommonData->m_eCaseForOthers = (TextCaseOptions)m_pOthersCaseCbB->currentIndex();
 1101         }
 1102 
 1103         { // colors
 1104             m_pCommonData->m_vNoteCategColors = m_vNoteCategColors;
 1105         }
 1106 
 1107         { // tag editor
 1108             m_pCommonData->m_bWarnOnNonSeqTracks = m_pWarnOnNonSeqTracksCkB->isChecked();
 1109             m_pCommonData->m_bWarnPastingToNonSeqTracks = m_pWarnOnPasteToNonSeqTracksCkB->isChecked();
 1110         }
 1111 
 1112         { // misc
 1113             m_pCommonData->m_bScanAtStartup = m_pScanAtStartupCkB->isChecked();
 1114             m_pCommonData->setFastSave(m_pFastSaveCkB->isChecked(), CommonData::UPDATE_TRANSFORMS);
 1115             m_pCommonData->m_bShowExport = m_pShowExportCkB->isChecked();
 1116             m_pCommonData->m_bShowDebug = m_pShowDebugCkB->isChecked();
 1117             m_pCommonData->m_bShowSessions = m_pShowSessCkB->isChecked();
 1118             m_pCommonData->m_bShowCustomCloseButtons = m_pShowCustomCloseButtonsCkB->isChecked();
 1119             m_pCommonData->m_strNormalizeCmd = convStr(m_pNormalizerE->text());
 1120             m_pCommonData->m_bKeepNormWndOpen = m_pKeepNormOpenCkB->isChecked();
 1121 
 1122             m_pCommonData->m_eAssignSave = m_pAssgnSaveRB->isChecked() ? CommonData::SAVE : m_pAssgnDiscardRB->isChecked() ? CommonData::DISCARD : CommonData::ASK;
 1123             m_pCommonData->m_eNonId3v2Save = m_pNonId3v2SaveRB->isChecked() ? CommonData::SAVE : m_pNonId3v2DiscardRB->isChecked() ? CommonData::DISCARD : CommonData::ASK;
 1124 
 1125             m_pCommonData->m_nMainWndIconSize = m_pIconSizeSB->value();
 1126             m_pCommonData->m_bAutoSizeIcons = m_pAutoSizeIconsCkB->isChecked();
 1127             m_pCommonData->m_bKeepOneValidImg = m_pKeepOneValidImgCkB->isChecked();
 1128             m_pCommonData->m_bWmpVarArtists = m_pWmpCkB->isChecked();
 1129             m_pCommonData->m_bItunesVarArtists = m_pItunesCkB->isChecked();
 1130             ImageInfo::MAX_IMAGE_SIZE = m_pMaxImgSizeSB->value()*1024; //ttt2 inconsistent to keep this in static var and the others in CommonData; perhaps switch to a global CommonData that anybody can access, without passing it in params
 1131             m_pCommonData->setTraceToFile(m_pTraceToFileCkB->isChecked());
 1132 
 1133             m_pCommonData->setFontInfo(convStr(m_generalFont.family()), m_generalFont.pointSize(), m_pDecrLabelFontSB->value(), convStr(m_fixedFont.family()), m_fixedFont.pointSize());
 1134 
 1135             m_pCommonData->m_strRenamerInvalidChars = convStr(m_pInvalidCharsE->text());
 1136             m_pCommonData->m_strRenamerReplacementString = convStr(m_pInvalidReplacementE->text());
 1137 
 1138             m_pCommonData->m_strCheckForNewVersions = m_pCheckForUpdatesCkB->isChecked() ? "yes" : "no";
 1139 
 1140             string strTranslation (TranslatorHandler::getGlobalTranslator().getTranslations()[m_pTranslationCbB->currentIndex()]);
 1141             if (m_pCommonData->m_strTranslation != strTranslation) {
 1142                 showWarning(this, tr("Info"), tr("You need to restart the program to use the new language."));
 1143                 m_pCommonData->m_strTranslation = strTranslation;
 1144             }
 1145         }
 1146 
 1147         if (m_bFull)
 1148         { // shell integration
 1149             ShellIntegration::enableHiddenSession(m_pShellHiddenSessCkB->isChecked());
 1150             ShellIntegration::enableVisibleSession(m_pShellVisibleSessCkB->isChecked());
 1151             ShellIntegration::enableTempSession(m_pShellTempSessCkB->isChecked());
 1152         }
 1153 
 1154         m_pCommonData->m_vExternalToolInfos = m_vExternalToolInfos;
 1155 
 1156         accept();
 1157     }
 1158     catch (const IncorrectDirName&)
 1159     {
 1160         showCritical(this, tr("Invalid folder name"), tr("A folder name is incorrect.")); //ttt2 say which name
 1161     }
 1162 }
 1163 
 1164 void ConfigDlgImpl::on_m_pCancelB_clicked()
 1165 {
 1166     reject();
 1167 }
 1168 
 1169 
 1170 
 1171 void ConfigDlgImpl::on_m_pChangeGenFontB_clicked()
 1172 {
 1173     bool bOk;
 1174     QFont font = QFontDialog::getFont(&bOk, m_generalFont, this); //ttt2 see if possible to remove "What's this" button
 1175     if (!bOk) { return; }
 1176 
 1177     m_generalFont = font;
 1178     setFontLabels();
 1179 }
 1180 
 1181 
 1182 void ConfigDlgImpl::on_m_pChangeFixedFontB_clicked()
 1183 {
 1184     bool bOk;
 1185     QFont font = QFontDialog::getFont(&bOk, m_fixedFont, this);
 1186     if (!bOk) { return; }
 1187 
 1188     m_fixedFont = font;
 1189     setFontLabels();
 1190 }
 1191 
 1192 
 1193 void ConfigDlgImpl::setFontLabels()
 1194 {
 1195     m_pGeneralFontL->setText(QString("%1, %2pt").arg(m_generalFont.family()).arg(m_generalFont.pointSize()));
 1196     m_pGeneralFontL->setFont(m_generalFont);
 1197     m_pFixedFontL->setText(QString("%1, %2pt").arg(m_fixedFont.family()).arg(m_fixedFont.pointSize()));
 1198     m_pFixedFontL->setFont(m_fixedFont);
 1199 
 1200     QFont f (m_fixedFont);
 1201     f.setUnderline(true);
 1202     m_pInvalidReplacementE->setFont(f);
 1203     m_pInvalidCharsE->setFont(f);
 1204 }
 1205 
 1206 
 1207 
 1208 
 1209 void ConfigDlgImpl::logState(const char* /*szPlace*/) const
 1210 {
 1211     /*cout << szPlace << ": m_filter.m_vSelDirs=" << m_pCommonData->m_filter.m_vSelDirs.size() << " m_availableDirs.m_vstrDirs=" << m_availableDirs.m_vstrDirs.size() << " m_selectedDirs.m_vSelDirs=" << m_selectedDirs.m_vstrDirs.size() << endl;*/
 1212 }
 1213 
 1214 
 1215 
 1216 //---------------------------------------------------------------------------------------------------------------------
 1217 //---------------------------------------------------------------------------------------------------------------------
 1218 
 1219 
 1220 /*override*/ string ConfigDlgImpl::getTooltip(TooltipKey eTooltipKey) const
 1221 {
 1222     switch (eTooltipKey)
 1223     {
 1224     case SELECTED_G: return "";//"Notes to be included";
 1225     case AVAILABLE_G: return "";//"Available notes";
 1226     case ADD_B: return convStr(tr("Add selected note(s)"));
 1227     case DELETE_B: return convStr(tr("Remove selected note(s)"));
 1228     case ADD_ALL_B: return convStr(tr("Add all notes"));
 1229     case DELETE_ALL_B: return convStr(tr("Remove all notes"));
 1230     case RESTORE_DEFAULT_B: return convStr(tr("Restore lists to their default value"));
 1231     case RESTORE_OPEN_B: return convStr(tr("Restore lists to the configuration they had when the window was open"));
 1232     default: CB_ASSERT(false);
 1233     }
 1234 }
 1235 
 1236 
 1237 /*override*/ void ConfigDlgImpl::reset()
 1238 {
 1239     if (m_vpResetAll.empty())
 1240     {
 1241         const vector<const Note*>& v (Notes::getAllNotes());
 1242         for (int i = 0, n = cSize(v); i < n; ++i)
 1243         {
 1244             const Note* p (v[i]);
 1245             m_vpResetAll.push_back(new NoteListElem(p, m_pCommonData));
 1246         }
 1247     }
 1248 
 1249     m_vSel = Notes::getDefaultIgnoredNoteIds();
 1250 }
 1251 
 1252 
 1253 void ConfigDlgImpl::selectDir(QLineEdit* pEdt)
 1254 {
 1255     QString qstrStart (fromNativeSeparators(pEdt->text()));
 1256     qstrStart = convStr(getExistingDir(convStr(qstrStart)));
 1257     if (qstrStart.isEmpty()) { qstrStart = getTempDir(); }
 1258     QFileDialog dlg (this, tr("Select folder"), qstrStart, tr("All files") + " (*)"/*, 0, QFileDialog::DontUseNativeDialog*/);
 1259     //ttt0 test on Qt 4.8, for implications of "native" standard dialogs (file, color, ...) probably best is to force non-native on Qt 4.8. The thing is the native dialogs, which seem to be introduced in 4.8, are not translatable; OTOH from http://stackoverflow.com/questions/6405234/qfiledialogdontusenativedialog-is-not-working and http://stackoverflow.com/questions/4259994/qfiledialog-alternative-that-uses-default-file-dialog-defined-by-os it seems that only the static methods of QFileDialog create native dialogs; see also TranslatorHandler::TranslatorHandler() for translations and perhaps do an ifdef for 4.8 & later
 1260 
 1261     dlg.setFileMode(QFileDialog::Directory);
 1262     if (QDialog::Accepted != dlg.exec()) { return; }
 1263 
 1264     QStringList fileNames (dlg.selectedFiles());
 1265     if (1 != fileNames.size()) { return; }
 1266 
 1267     QString s (fileNames.first());
 1268 
 1269     QString s1 (getPathSep());
 1270 
 1271     if ("//" == s)
 1272     {
 1273         s = "/";
 1274     }
 1275     if (!s.endsWith(s1))
 1276     {
 1277         s += s1;
 1278     }
 1279     pEdt->setText(toNativeSeparators(s));
 1280 }
 1281 
 1282 
 1283 
 1284 void ConfigDlgImpl::onHelp()
 1285 {
 1286     switch(m_pMainTabWidget->currentIndex())
 1287     {
 1288     case 0: openHelp("250_config_files.html"); break;
 1289     case 1: openHelp("260_config_ignored_notes.html"); break;
 1290     case 2: openHelp("270_config_custom_transf.html"); break;
 1291     case 3: openHelp("290_config_transf_params.html"); break;
 1292     case 4: openHelp("292_config_visible_transf.html"); break;
 1293     case 5: openHelp("295_config_quality.html"); break;
 1294     case 6: openHelp("297_config_colors.html"); break;
 1295     case 7: openHelp("298_config_shell.html"); break;
 1296     case 8: openHelp("299_ext_tools.html"); break;
 1297     case 9: openHelp("300_config_others.html"); break;
 1298     //tttr revise as needed
 1299 
 1300     default: /*openHelp("index.html");*/ break;
 1301     }
 1302 }
 1303 
 1304 
 1305 void ConfigDlgImpl::on_m_pFastSaveCkB_stateChanged()
 1306 {
 1307     if (0 == m_pVisibleTransfPainter) { return; }
 1308 
 1309     if (m_pFastSaveCkB->isChecked())
 1310     {
 1311         const vector<int>& vnAvail (m_pVisibleTransfPainter->getAvailable());
 1312         const vector<const ListElem*>& vpAll (m_pVisibleTransfPainter->getAll());
 1313         set<int> s;
 1314         for (int i = 0; i < cSize(vnAvail); ++i)
 1315         {
 1316             const TransfListElem* p (dynamic_cast<const TransfListElem*>(vpAll.at(vnAvail.at(i))));
 1317             CB_ASSERT (0 != p);
 1318             if (p->getTransformation()->getActionName() == string(Id3V2Compactor::getClassName()) || p->getTransformation()->getActionName() == string(Id3V2Expander::getClassName()))
 1319             {
 1320                 s.insert(i);
 1321             }
 1322         }
 1323 
 1324         m_pVisibleTransfDoubleList->add(s);
 1325     }
 1326     else
 1327     {
 1328         const vector<int>& vnSel (m_pVisibleTransfPainter->getSel());
 1329         const vector<const ListElem*>& vpAll (m_pVisibleTransfPainter->getAll());
 1330         set<int> s;
 1331         for (int i = 0; i < cSize(vnSel); ++i)
 1332         {
 1333             const TransfListElem* p (dynamic_cast<const TransfListElem*>(vpAll.at(vnSel.at(i))));
 1334             CB_ASSERT (0 != p);
 1335             if (p->getTransformation()->getActionName() == string(Id3V2Compactor::getClassName()) || p->getTransformation()->getActionName() == string(Id3V2Expander::getClassName()))
 1336             {
 1337                 s.insert(i);
 1338             }
 1339         }
 1340 
 1341         m_pVisibleTransfDoubleList->remove(s);
 1342     }
 1343 }
 1344 
 1345 
 1346 
 1347 TransfConfig::Options ConfigDlgImpl::getSimpleViewOpt() // doesn't set m_bKeepOrigTime
 1348 {
 1349     TransfConfig::Options opt (getFullViewOpt());
 1350     if (m_pBackupCustomRB->isChecked()) { return opt; }
 1351 
 1352     if (m_pDontCreateBackupRB->isChecked()) { return opt.asNonBackup(); }
 1353 
 1354     return opt.asBackup();
 1355 }
 1356 
 1357 
 1358 TransfConfig::Options ConfigDlgImpl::getFullViewOpt() // doesn't set m_bKeepOrigTime
 1359 {
 1360     TransfConfig::Options opt;
 1361 
 1362     opt.m_eProcOrigChange = m_pPODontChangeRB->isChecked() ? TransfConfig::Options::PO_DONT_CHG : m_pPOEraseRB->isChecked() ? TransfConfig::Options::PO_ERASE : m_pPOMoveAlwaysChangeRB->isChecked() ? TransfConfig::Options::PO_MOVE_ALWAYS_RENAME : m_pPOMoveChangeIfNeededRB->isChecked() ? TransfConfig::Options::PO_MOVE_RENAME_IF_USED : m_pPOChangeNameRB->isChecked() ? TransfConfig::Options::PO_RENAME_SAME_DIR : m_pPOMoveOrEraseRB->isChecked() ? TransfConfig::Options::PO_MOVE_OR_ERASE : TransfConfig::Options::ProcOrig(7);
 1363     CB_ASSERT (7 != opt.m_eProcOrigChange);
 1364     opt.m_bProcOrigUseLabel = m_pPOUseLabelRB->isChecked();
 1365     opt.m_bProcOrigAlwayUseCounter = m_pPOAlwaysUseCounterRB->isChecked();
 1366 
 1367     opt.m_eUnprocOrigChange = m_pUODontChangeRB->isChecked() ? TransfConfig::Options::UPO_DONT_CHG : m_pUOEraseRB->isChecked() ? TransfConfig::Options::UPO_ERASE : m_pUOMoveAlwaysChangeRB->isChecked() ? TransfConfig::Options::UPO_MOVE_ALWAYS_RENAME : m_pUOMoveChangeIfNeededRB->isChecked() ? TransfConfig::Options::UPO_MOVE_RENAME_IF_USED : m_pUOChangeNameRB->isChecked() ? TransfConfig::Options::UPO_RENAME_SAME_DIR : TransfConfig::Options::UnprocOrig(7);
 1368     CB_ASSERT (7 != opt.m_eUnprocOrigChange);
 1369     opt.m_bUnprocOrigUseLabel = m_pUOUseLabelRB->isChecked();
 1370     opt.m_bUnprocOrigAlwayUseCounter = m_pUOAlwaysUseCounterRB->isChecked();
 1371 
 1372     opt.m_eProcessedCreate = m_pProcDontCreateRB->isChecked() ? TransfConfig::Options::PR_DONT_CREATE : m_pProcCreateAlwaysChangeRB->isChecked() ? TransfConfig::Options::PR_CREATE_ALWAYS_RENAME : m_pProcCreateChangeIfNeededRB->isChecked() ? TransfConfig::Options::PR_CREATE_RENAME_IF_USED : TransfConfig::Options::Processed(3);
 1373     CB_ASSERT (3 != opt.m_eProcessedCreate);
 1374     opt.m_bProcessedUseLabel = m_pProcUseLabelRB->isChecked();
 1375     opt.m_bProcessedAlwayUseCounter = m_pProcAlwaysUseCounterRB->isChecked();
 1376     opt.m_bProcessedUseSeparateDir = m_pProcUseSeparateDirRB->isChecked();
 1377 
 1378     opt.m_bTempCreate = m_pTempCreateRB->isChecked();
 1379 
 1380     opt.m_bCompCreate = m_pCompCreateRB->isChecked();
 1381 
 1382     return opt;
 1383 }
 1384 
 1385 
 1386 TransfConfig::Options ConfigDlgImpl::getOpt() // has the correct m_bKeepOrigTime
 1387 {
 1388     TransfConfig::Options opt (m_pSimpleViewB->isChecked() ? getSimpleViewOpt() : getFullViewOpt());
 1389     opt.m_bKeepOrigTime = m_pKeepOrigTimeCkB->isChecked();
 1390     return opt;
 1391 }
 1392 
 1393 
 1394 void ConfigDlgImpl::setSimpleViewOpt(const TransfConfig::Options& opt) // m_bKeepOrigTime shouldn't be set
 1395 {
 1396     if (opt == opt.asNonBackup())
 1397     {
 1398         m_pDontCreateBackupRB->setChecked(true);
 1399     }
 1400     else if (opt == opt.asBackup())
 1401     {
 1402         m_pCreateBackupRB->setChecked(true);
 1403     }
 1404     else
 1405     {
 1406         m_pBackupCustomRB->setChecked(true);
 1407     }
 1408 }
 1409 
 1410 
 1411 void ConfigDlgImpl::setFullViewOpt(const TransfConfig::Options& opt) // m_bKeepOrigTime is ignored
 1412 {
 1413     { // ProcOrig
 1414         switch (opt.m_eProcOrigChange)
 1415         {
 1416         case TransfConfig::Options::PO_DONT_CHG: m_pPODontChangeRB->setChecked(true); break;
 1417         case TransfConfig::Options::PO_ERASE: m_pPOEraseRB->setChecked(true); break;
 1418         case TransfConfig::Options::PO_MOVE_ALWAYS_RENAME: m_pPOMoveAlwaysChangeRB->setChecked(true); break;
 1419         case TransfConfig::Options::PO_MOVE_RENAME_IF_USED: m_pPOMoveChangeIfNeededRB->setChecked(true); break;
 1420         case TransfConfig::Options::PO_RENAME_SAME_DIR: m_pPOChangeNameRB->setChecked(true); break;
 1421         case TransfConfig::Options::PO_MOVE_OR_ERASE: m_pPOMoveOrEraseRB->setChecked(true); break;
 1422         default:
 1423             CB_ASSERT(false); // the constructor of TransfConfig should have detected it
 1424         }
 1425 
 1426         if (opt.m_bProcOrigUseLabel) { m_pPOUseLabelRB->setChecked(true); } else { m_pPODontUseLabelRB->setChecked(true); }
 1427         if (opt.m_bProcOrigAlwayUseCounter) { m_pPOAlwaysUseCounterRB->setChecked(true); } else { m_pPOUseCounterIfNeededRB->setChecked(true); }
 1428     }
 1429 
 1430     { // UnprocOrig
 1431         switch (opt.m_eUnprocOrigChange)
 1432         {
 1433         case TransfConfig::Options::UPO_DONT_CHG: m_pUODontChangeRB->setChecked(true); break;
 1434         case TransfConfig::Options::UPO_ERASE: m_pUOEraseRB->setChecked(true); break;
 1435         case TransfConfig::Options::UPO_MOVE_ALWAYS_RENAME: m_pUOMoveAlwaysChangeRB->setChecked(true); break;
 1436         case TransfConfig::Options::UPO_MOVE_RENAME_IF_USED: m_pUOMoveChangeIfNeededRB->setChecked(true); break;
 1437         case TransfConfig::Options::UPO_RENAME_SAME_DIR: m_pUOChangeNameRB->setChecked(true); break;
 1438         default:
 1439             CB_ASSERT(false); // the constructor of TransfConfig should have detected it
 1440         }
 1441 
 1442         if (opt.m_bUnprocOrigUseLabel) { m_pUOUseLabelRB->setChecked(true); } else { m_pUODontUseLabelRB->setChecked(true); }
 1443         if (opt.m_bUnprocOrigAlwayUseCounter) { m_pUOAlwaysUseCounterRB->setChecked(true); } else { m_pUOUseCounterIfNeededRB->setChecked(true); }
 1444 
 1445     }
 1446 
 1447     { // Processed
 1448         switch (opt.m_eProcessedCreate)
 1449         {
 1450         case TransfConfig::Options::PR_DONT_CREATE: m_pProcDontCreateRB->setChecked(true); break;
 1451         case TransfConfig::Options::PR_CREATE_ALWAYS_RENAME: m_pProcCreateAlwaysChangeRB->setChecked(true); break;
 1452         case TransfConfig::Options::PR_CREATE_RENAME_IF_USED: m_pProcCreateChangeIfNeededRB->setChecked(true); break;
 1453         default:
 1454             CB_ASSERT(false); // the constructor of TransfConfig should have detected it
 1455         }
 1456 
 1457         if (opt.m_bProcessedUseLabel) { m_pProcUseLabelRB->setChecked(true); } else { m_pProcDontUseLabelRB->setChecked(true); }
 1458         if (opt.m_bProcessedAlwayUseCounter) { m_pProcAlwaysUseCounterRB->setChecked(true); } else { m_pProcUseCounterIfNeededRB->setChecked(true); }
 1459         if (opt.m_bProcessedUseSeparateDir) { m_pProcUseSeparateDirRB->setChecked(true); } else { m_pProcUseSrcRB->setChecked(true); }
 1460     }
 1461 
 1462     { // Temp
 1463         if (opt.m_bTempCreate) { m_pTempCreateRB->setChecked(true); } else { m_pTempDontCreateRB->setChecked(true); }
 1464     }
 1465 
 1466     { // Comp
 1467         if (opt.m_bCompCreate) { m_pCompCreateRB->setChecked(true); } else { m_pCompDontCreateRB->setChecked(true); }
 1468     }
 1469 }
 1470 
 1471 
 1472 void ConfigDlgImpl::on_m_pSimpleViewB_clicked()
 1473 {
 1474     m_pFileSettingsLayout->setCurrentWidget(m_pSimpleViewTab);
 1475     m_pFullViewB->setChecked(false);
 1476     m_pPODest2E->setText(m_pPODestE->text());
 1477     setSimpleViewOpt(getFullViewOpt());
 1478 }
 1479 
 1480 void ConfigDlgImpl::on_m_pFullViewB_clicked()
 1481 {
 1482     m_pFileSettingsLayout->setCurrentWidget(m_pFullViewTab);
 1483     m_pSimpleViewB->setChecked(false);
 1484     m_pPODestE->setText(m_pPODest2E->text());
 1485     setFullViewOpt(getSimpleViewOpt());
 1486 }
 1487 
 1488 
 1489 
 1490 //=====================================================================================================================
 1491 //=====================================================================================================================
 1492 //=====================================================================================================================
 1493 
 1494 
 1495 void ConfigDlgImpl::resizeWidgets()
 1496 {
 1497     SimpleQTableViewWidthInterface intf1 (*m_pExternalToolsG);
 1498     ColumnResizer rsz1 (intf1, 100, ColumnResizer::FILL, ColumnResizer::CONSISTENT_RESULTS);
 1499     for (int i = 0; i < cSize(m_vExternalToolInfos); ++i) // needed on Qt 4.3.1, not needed on 4.7.1
 1500     {
 1501         m_pExternalToolsG->verticalHeader()->resizeSection(i, CELL_HEIGHT);
 1502     }
 1503 }
 1504 
 1505 /*override*/ void ConfigDlgImpl::resizeEvent(QResizeEvent* pEvent)
 1506 {
 1507     resizeWidgets();
 1508     QDialog::resizeEvent(pEvent);
 1509 }
 1510 
 1511 #if 0
 1512 
 1513 /*override*/ void ConfigDlgImpl::closeEvent(QCloseEvent* pEvent)
 1514 {
 1515     pEvent->ignore();
 1516     QCoreApplication::postEvent(this, new QKeyEvent(QEvent::KeyPress, Qt::Key_Escape, Qt::NoModifier)); // ttt2 not sure if a KeyRelease pair is expected
 1517 }
 1518 
 1519 
 1520 /*override*/ bool ConfigDlgImpl::eventFilter(QObject* pObj, QEvent* pEvent)
 1521 {
 1522     //throw 1;
 1523     //qDebug("pppp");
 1524     QKeyEvent* pKeyEvent (dynamic_cast<QKeyEvent*>(pEvent));
 1525     int nKey (0 == pKeyEvent ? 0 : pKeyEvent->key());
 1526 
 1527 /*static int s_nCnt (0);
 1528     if (0 != pKeyEvent
 1529         //&& Qt::Key_Escape == nKey
 1530         )
 1531     {
 1532         qDebug("%d. %s %d", s_nCnt++, pObj->objectName().toUtf8().constData(), (int)pEvent->type()); //return QDialog::eventFilter(pObj, pEvent);
 1533     }//*/
 1534 
 1535     if (0 != pKeyEvent && Qt::Key_Escape == nKey && this == pObj && QEvent::KeyPress == pEvent->type())
 1536     {
 1537         bool bMayClose (true);
 1538         if (m_bExtToolChanged)
 1539         {
 1540             int nOpt (showMessage(this, QMessageBox::Question, 1, 1, "Confirm", "You modified the external tool information but you didn't save your changes. Discard the changes or cancel the closing?", "&Discard", "&Cancel"));
 1541             if (nOpt == 1)
 1542             {
 1543                 bMayClose = false;
 1544             }
 1545         }
 1546         if (!bMayClose)
 1547         {
 1548             return true;
 1549         }
 1550     }
 1551 
 1552     return QDialog::eventFilter(pObj, pEvent);
 1553 }
 1554 
 1555 #endif
 1556 
 1557 void ConfigDlgImpl::tableToEdit()
 1558 {
 1559     QModelIndex ndx (m_pExternalToolsG->currentIndex()); //ttt2 perhaps don't allow the current element to be changed as long as m_bExtToolChanged==true; or better: get rid of the other controls and just use edits and combo boxes in the table, then allow dragging of the cells in the vertical header to rearrange the tools
 1560     int i (ndx.row());
 1561     if (ndx.isValid() && i < cSize(m_vExternalToolInfos))
 1562     {
 1563         m_pExtToolNameE->setText(convStr(m_vExternalToolInfos[i].m_strName));
 1564         m_pExtToolCmdE->setText(convStr(m_vExternalToolInfos[i].m_strCommand));
 1565         switch (m_vExternalToolInfos[i].m_eLaunchOption)
 1566         {
 1567         case ExternalToolInfo::DONT_WAIT: m_pExtToolDontWaitRB->click(); break;
 1568         case ExternalToolInfo::WAIT_AND_KEEP_WINDOW_OPEN: m_pExtToolWaitKeepOpenRB->click(); break;
 1569         case ExternalToolInfo::WAIT_THEN_CLOSE_WINDOW: m_pExtToolWaitCloseRB->click(); break;
 1570         default: CB_ASSERT (false);
 1571         }
 1572         m_pExtToolConfirmLaunchCkB->setChecked(m_vExternalToolInfos[i].m_bConfirmLaunch);
 1573     }
 1574     else
 1575     {
 1576         m_pExtToolNameE->setText("");
 1577         m_pExtToolCmdE->setText("");
 1578         m_pExtToolConfirmLaunchCkB->setChecked(true);
 1579         m_pExtToolDontWaitRB->setChecked(true);
 1580     }
 1581     m_bExtToolChanged = false;
 1582 }
 1583 
 1584 
 1585 
 1586 void ConfigDlgImpl::editToTable()
 1587 {
 1588     QModelIndex ndx (m_pExternalToolsG->currentIndex());
 1589     if (!ndx.isValid()) { return; }
 1590 
 1591     int i (ndx.row());
 1592     if (i >= cSize(m_vExternalToolInfos)) { return; }
 1593     m_vExternalToolInfos[i] = externalToolInfoFromEdit();
 1594 
 1595     m_bExtToolChanged = false;
 1596     m_pExternalToolsModel->emitLayoutChanged();
 1597     resizeWidgets();
 1598 }
 1599 
 1600 ExternalToolInfo ConfigDlgImpl::externalToolInfoFromEdit()
 1601 {
 1602     return ExternalToolInfo(
 1603             convStr(m_pExtToolNameE->text()),
 1604             convStr(m_pExtToolCmdE->text()),
 1605             m_pExtToolDontWaitRB->isChecked() ? ExternalToolInfo::DONT_WAIT : m_pExtToolWaitKeepOpenRB->isChecked() ? ExternalToolInfo::WAIT_AND_KEEP_WINDOW_OPEN : ExternalToolInfo::WAIT_THEN_CLOSE_WINDOW,
 1606             m_pExtToolConfirmLaunchCkB->isChecked());
 1607 }
 1608 
 1609 
 1610 void ConfigDlgImpl::on_m_pExtToolAddB_clicked()
 1611 {
 1612     m_vExternalToolInfos.push_back(externalToolInfoFromEdit());
 1613     m_pExternalToolsModel->emitLayoutChanged();
 1614     m_pExternalToolsG->setCurrentIndex(m_pExternalToolsModel->index(cSize(m_vExternalToolInfos) - 1, 0));
 1615     resizeWidgets();
 1616     //editToTable();
 1617     //m_pExternalToolsG->re
 1618 }
 1619 
 1620 void ConfigDlgImpl::on_m_pExtToolUpdateB_clicked()
 1621 {
 1622     editToTable();
 1623 }
 1624 
 1625 void ConfigDlgImpl::on_m_pExtToolDeleteB_clicked()
 1626 {
 1627     QModelIndex ndx (m_pExternalToolsG->currentIndex());
 1628     int i (ndx.row());
 1629     if (!ndx.isValid() || i >= cSize(m_vExternalToolInfos)) { return; }
 1630 
 1631     m_vExternalToolInfos.erase(m_vExternalToolInfos.begin() + i);
 1632     m_pExternalToolsModel->emitLayoutChanged();
 1633     if (!m_vExternalToolInfos.empty())
 1634     {
 1635         m_pExternalToolsG->setCurrentIndex(m_pExternalToolsModel->index(i < cSize(m_vExternalToolInfos) ? i : i - 1, 0));
 1636     }
 1637     tableToEdit();
 1638 }
 1639 
 1640 void ConfigDlgImpl::on_m_pExtToolDiscardB_clicked()
 1641 {
 1642     tableToEdit();
 1643 }
 1644 
 1645 void ConfigDlgImpl::on_m_pMainTabWidget_currentChanged(int /*nIndex*/)
 1646 {
 1647     resizeWidgets(); // !!! really needed only the first time the external tools tab is shown
 1648     QModelIndex ndx (m_pExternalToolsG->currentIndex());
 1649     int i (ndx.row());
 1650     if (!ndx.isValid() || i >= cSize(m_vExternalToolInfos))
 1651     {
 1652         if (!m_vExternalToolInfos.empty())
 1653         {
 1654             m_pExternalToolsG->setCurrentIndex(m_pExternalToolsModel->index(0, 0)); // this will trigger tableToEdit();
 1655         }
 1656         else
 1657         {
 1658             tableToEdit();
 1659         }
 1660     }
 1661 }
 1662 
 1663 //=====================================================================================================================
 1664 //=====================================================================================================================
 1665 
 1666 ExternalToolsModel::ExternalToolsModel(const ConfigDlgImpl* pConfigDlgImpl) : m_pConfigDlgImpl(pConfigDlgImpl)//, m_pCommonData(pConfigDlgImpl->getCommonData())
 1667 {
 1668 }
 1669 
 1670 
 1671 /*override*/ int ExternalToolsModel::rowCount(const QModelIndex&) const
 1672 {
 1673     return cSize(m_pConfigDlgImpl->m_vExternalToolInfos);
 1674 }
 1675 
 1676 
 1677 /*override*/ int ExternalToolsModel::columnCount(const QModelIndex&) const
 1678 {
 1679     return 4;
 1680 }
 1681 
 1682 
 1683 /*override*/ QVariant ExternalToolsModel::data(const QModelIndex& index, int nRole) const
 1684 {
 1685 //LAST_STEP("ExternalToolsModel::data()");
 1686     if (!index.isValid()) { return QVariant(); }
 1687     int i (index.row());
 1688     int j (index.column());
 1689 //qDebug("ndx %d %d", i, j);
 1690 
 1691     if (Qt::DisplayRole != nRole && Qt::ToolTipRole != nRole && Qt::EditRole != nRole) { return QVariant(); }
 1692     QString s;
 1693 
 1694     const ExternalToolInfo& info (m_pConfigDlgImpl->m_vExternalToolInfos[i]);
 1695     switch (j)
 1696     {
 1697     case 0: return convStr(info.m_strName);
 1698     case 1: return convStr(info.m_strCommand);
 1699     case 2: return ExternalToolInfo::launchOptionAsTranslatedString(info.m_eLaunchOption);
 1700     case 3: return GlobalTranslHlp::tr(boolAsYesNo(info.m_bConfirmLaunch));
 1701     default: CB_ASSERT (false);
 1702     }
 1703 }
 1704 
 1705 
 1706 /*override*/ QVariant ExternalToolsModel::headerData(int nSection, Qt::Orientation eOrientation, int nRole /* = Qt::DisplayRole*/) const
 1707 {
 1708 //LAST_STEP("ExternalToolsModel::headerData");
 1709     if (nRole != Qt::DisplayRole) { return QVariant(); }
 1710 
 1711     if (Qt::Horizontal == eOrientation)
 1712     {
 1713         switch (nSection)
 1714         {
 1715         case 0: return tr("Name");
 1716         case 1: return tr("Command");
 1717         case 2: return tr("Wait");
 1718         case 3: return tr("Confirm launch");
 1719         default: CB_ASSERT (false);
 1720         }
 1721     }
 1722 
 1723     return nSection + 1;
 1724 }
 1725 
 1726 
 1727 //=====================================================================================================================
 1728 //=====================================================================================================================
 1729 //=====================================================================================================================
 1730 
 1731 //ttt2 dir config: perhaps something simpler, with a "more options" button
 1732 
 1733 //ttt2 Font style is ignored (see DejaVu Sans / Light on machines with antialiased fonts)
 1734 
 1735 //ttt2 proxy: QNetworkProxyFactory::systemProxyForQuery; QNetworkProxy; http://www.dbits.be/index.php/pc-problems/65-vistaproxycfg  https://sourceforge.net/projects/mp3diags/forums/forum/947207/topic/3415940
 1736 
 1737