~cyril-jacquet/plume-creator/devel

« back to all changes in this revision

Viewing changes to src/maintextdocument.cpp

  • Committer: Cyril Jacquet
  • Date: 2014-01-01 17:19:35 UTC
  • Revision ID: git-v1:91e7c99ea1b7a6cb84153c59985c36966cbe2959
0.66.2 : trash tree : allows renaming ; add first : begins base for
minimap scrollbar in minimap.cpp, minimap.h and minimap.ui ; fix memory
leak of spellchecker when opening new sheet

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
 
14
14
    m_spellChecker = spellCheck;
15
 
    connect(m_spellChecker, SIGNAL(userDictSignal(QStringList)), this, SIGNAL(userDictSignal(QStringList)));
16
 
    connect(this, SIGNAL(attendTree_namesListChanged(QStringList)), this, SLOT(attendTree_namesListChangedSlot(QStringList)));
17
 
 
18
 
    highlighter = new TextHighlighter(this, m_spellChecker);
19
 
 
 
15
//    connect(this, SIGNAL(attendTree_namesListChanged(QStringList)), this, SLOT(attendTree_namesListChangedSlot(QStringList)));
 
16
 
 
17
    highlighter = new TextHighlighter(this);
 
18
highlighter->setSpellChecker(spellCheck);
20
19
}
21
20
 
22
21
//-------------------------------------------------------------
92
91
 
93
92
bool MainTextDocument::activateSpellChecker()
94
93
{
95
 
    if(m_dictionaryPath.isEmpty()){
 
94
    if(!m_spellChecker->activate()){
96
95
        qWarning() << "activateSpellChecker() without dictionary";
97
96
        return false;
98
97
    }
99
 
    m_spellChecker->setDict(m_dictionaryPath, m_userDictionary, m_attendTree_names);
100
 
 
101
 
 
102
 
    m_spellChecker->activate();
 
98
//    m_spellChecker->setDict(m_dictionaryPath, m_userDictionary, m_attendTree_names);
 
99
 
 
100
 
 
101
 
103
102
    highlighter->rehighlight();
104
103
 
105
104
    return true;
116
115
}
117
116
//-------------------------------------------------------------
118
117
 
119
 
void MainTextDocument::setDicts(const QString &dictionaryPath, const QStringList &userDictionary)
 
118
void MainTextDocument::setDicts()
120
119
{
121
120
 
122
 
    m_dictionaryPath = dictionaryPath;
123
 
    m_userDictionary = userDictionary ;
124
 
 
125
121
 
126
122
    if(m_spellChecker->isActive()){
127
 
        m_spellChecker->setDict(m_dictionaryPath, m_userDictionary, m_attendTree_names);
128
123
        highlighter->rehighlight();
129
124
    }
130
125
}
139
134
void MainTextDocument::setSpellChecker(SpellChecker *spellChecker)
140
135
{
141
136
    m_spellChecker = spellChecker;
142
 
 
 
137
highlighter->setSpellChecker(spellChecker);
143
138
}
144
139
 
145
140
//-------------------------------------------------------------
146
141
 
147
 
void MainTextDocument::attendTree_namesListChangedSlot(QStringList namesList)
148
 
{
149
 
    m_attendTree_names.clear();
150
 
 
151
 
QSettings settings;
152
 
 
153
 
if(namesList.isEmpty() || !settings.value("SpellChecking/includeNamesFromTheMiseEnScene", true).toBool())
154
 
        return;
155
 
 
156
 
    for(int i = 0; i < namesList.size() ; ++i){
157
 
 
158
 
        QString name = namesList.at(i);
159
 
 
160
 
//break names into parts :
161
 
        QStringList fragmentList = name.split(" ", QString::SkipEmptyParts);
162
 
        if(!fragmentList.isEmpty())
163
 
            foreach (QString fragment, fragmentList) {
164
 
                m_attendTree_names.append( fragment );
165
 
            }
166
 
 
167
 
 
168
 
 
169
 
    }
170
 
 
171
 
    if(m_spellChecker->isActive()){
172
 
        m_spellChecker->setDict(m_dictionaryPath, m_userDictionary, m_attendTree_names);
173
 
        highlighter->rehighlight();
174
 
    }
175
 
}