97
102
m_framesV2SelectionModel(new QItemSelectionModel(m_framesV2Model, this)),
98
103
m_framelist(new FrameList(m_framesV2Model, m_framesV2SelectionModel)),
99
104
m_configStore(new ConfigStore),
100
m_downloadClient(new DownloadClient(this)),
105
m_netMgr(new QNetworkAccessManager(this)),
106
m_downloadClient(new DownloadClient(m_netMgr)),
101
107
m_textExporter(new TextExporter(this)),
102
108
m_dirRenamer(new DirRenamer(this)),
103
109
#ifdef HAVE_PHONON
106
m_downloadImageDest(ImageForSelectedFiles)
112
m_downloadImageDest(ImageForSelectedFiles),
113
m_musicBrainzClient(0)
108
115
setObjectName("Kid3Application");
109
116
m_fileProxyModel->setSourceModel(m_fileSystemModel);
119
126
ConfigStore::s_fnFormatCfg.setAsFilenameFormatter();
122
<< new FreedbImporter(this, m_trackDataModel)
123
<< new TrackTypeImporter(this, m_trackDataModel)
124
<< new DiscogsImporter(this, m_trackDataModel)
125
<< new AmazonImporter(this, m_trackDataModel)
126
<< new MusicBrainzReleaseImporter(this, m_trackDataModel);
129
<< new FreedbImporter(m_netMgr, m_trackDataModel)
130
<< new TrackTypeImporter(m_netMgr, m_trackDataModel)
131
<< new DiscogsImporter(m_netMgr, m_trackDataModel)
132
<< new AmazonImporter(m_netMgr, m_trackDataModel)
133
<< new MusicBrainzReleaseImporter(m_netMgr, m_trackDataModel);
134
#ifdef HAVE_CHROMAPRINT
135
m_musicBrainzClient = new MusicBrainzClient(m_netMgr, m_trackDataModel);
128
138
#ifdef HAVE_QTDBUS
129
139
if (QDBusConnection::sessionBus().isConnected()) {
215
225
m_configStore->readFromConfig();
216
226
if (ConfigStore::s_miscCfg.m_nameFilter.isEmpty()) {
217
createFilterString(&ConfigStore::s_miscCfg.m_nameFilter);
227
ConfigStore::s_miscCfg.m_nameFilter = createFilterString();
219
229
setTextEncodings();
220
230
if (ConfigStore::s_freedbCfg.m_server == "freedb2.org:80") {
251
261
dir = QDir(dir).absolutePath();
254
QStringList nameFilters(ConfigStore::s_miscCfg.m_nameFilter.split(' '));
264
QStringList nameFilters(ConfigStore::s_miscCfg.getNameFilterPatterns().
255
266
m_fileProxyModel->setNameFilters(nameFilters);
256
267
m_fileSystemModel->setFilter(QDir::AllEntries | QDir::AllDirs);
257
268
QModelIndex rootIndex = m_fileSystemModel->setRootPath(dir);
1742
* Get all combinations with lower- and uppercase characters.
1744
* @param str original string
1746
* @return string with all combinations, separated by spaces.
1748
static QString lowerUpperCaseCombinations(const QString& str)
1751
QString lc(str.toLower());
1752
QString uc(str.toUpper());
1754
// get a mask of all alphabetic characters in the string
1755
unsigned char numChars = 0, charMask = 0, posMask = 1;
1756
int numPos = lc.length();
1757
if (numPos > 8) numPos = 8;
1758
for (int pos = 0; pos < numPos; ++pos, posMask <<= 1) {
1759
if (lc[pos] >= 'a' && lc[pos] <= 'z') {
1760
charMask |= posMask;
1765
int numCombinations = 1 << numChars;
1766
for (int comb = 0; comb < numCombinations; ++comb) {
1769
if (!result.isEmpty()) {
1772
for (int pos = 0; pos < numPos; ++pos, posMask <<= 1) {
1773
if (charMask & posMask) {
1774
if (comb & combMask) {
1791
1752
* Create a filter string for the file dialog.
1792
1753
* The filter string contains entries for all supported types.
1794
* @param defaultNameFilter if not 0, return default name filter here
1796
1755
* @return filter string.
1798
QString Kid3Application::createFilterString(QString* defaultNameFilter) const
1757
QString Kid3Application::createFilterString() const
1800
1759
QStringList extensions = TaggedFile::getSupportedFileExtensions();
1801
QString result, allCombinations;
1760
QString result, allPatterns;
1802
1761
for (QStringList::const_iterator it = extensions.begin();
1803
1762
it != extensions.end();
1805
1764
QString text = (*it).mid(1).toUpper();
1806
QString lowerExt = '*' + *it;
1808
const QString& combinations = lowerExt;
1810
QString combinations = lowerUpperCaseCombinations(lowerExt);
1812
if (!allCombinations.isEmpty()) {
1813
allCombinations += ' ';
1765
QString pattern = '*' + *it;
1766
if (!allPatterns.isEmpty()) {
1815
allCombinations += combinations;
1769
allPatterns += pattern;
1816
1770
#ifdef CONFIG_USE_KDE
1817
result += combinations;
1819
1773
result += text;
1820
1774
result += " (";
1822
1776
result += ")\n";
1824
1778
result += text;
1825
1779
result += " (";
1826
result += combinations;
1827
1781
result += ");;";
1831
1785
#ifdef CONFIG_USE_KDE
1832
QString allExt = allCombinations;
1786
QString allExt = allPatterns;
1834
1788
allExt += i18n("All Supported Files");
1835
1789
allExt += '\n';