Changeset View
Changeset View
Standalone View
Standalone View
src/core/KexiRecentProjects.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 76 | #endif | |||
---|---|---|---|---|---|
80 | if (!dir.mkpath(path)) { | 80 | if (!dir.mkpath(path)) { | ||
81 | q->m_result.setMessage(xi18n("Could not create folder <filename>%1</filename> for " | 81 | q->m_result.setMessage(xi18n("Could not create folder <filename>%1</filename> for " | ||
82 | "storing recent projects information.", path)); | 82 | "storing recent projects information.", path)); | ||
83 | return; | 83 | return; | ||
84 | } | 84 | } | ||
85 | if (!dir.exists() || !dir.isReadable()) { | 85 | if (!dir.exists() || !dir.isReadable()) { | ||
86 | return; | 86 | return; | ||
87 | } | 87 | } | ||
88 | QStringList shortcuts = dir.entryList( | 88 | const QStringList shortcuts | ||
89 | QStringList() << QLatin1String("*.kexis"), | 89 | = dir.entryList(QStringList() << QLatin1String("*.kexis"), | ||
90 | QDir::Files | QDir::NoSymLinks | QDir::Readable | QDir::CaseSensitive); | 90 | QDir::Files | QDir::NoSymLinks | QDir::Readable | QDir::CaseSensitive | ||
91 | | QDir::Hidden // Hidden too because there can be names starting with | ||||
92 | // dot or hidden for without a clear reason | ||||
93 | ); | ||||
91 | #ifdef KexiRecentProjects_DEBUG | 94 | #ifdef KexiRecentProjects_DEBUG | ||
92 | qDebug() << shortcuts; | 95 | qDebug() << shortcuts; | ||
93 | #endif | 96 | #endif | ||
94 | foreach (const QString& shortcutPath, shortcuts) { | 97 | foreach (const QString& shortcutPath, shortcuts) { | ||
95 | #ifdef KexiRecentProjects_DEBUG | 98 | #ifdef KexiRecentProjects_DEBUG | ||
96 | qDebug() << shortcutPath; | 99 | qDebug() << shortcutPath; | ||
97 | #endif | 100 | #endif | ||
98 | KexiProjectData *data = new KexiProjectData; | 101 | KexiProjectData *data = new KexiProjectData; | ||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Line(s) | 199 | if (shortcutPath.isEmpty()) { | |||
197 | KDbConnectionData conn = *newData->connectionData(); | 200 | KDbConnectionData conn = *newData->connectionData(); | ||
198 | KDbDriverManager manager; | 201 | KDbDriverManager manager; | ||
199 | const KDbDriverMetaData *metaData = manager.driverMetaData(conn.driverId()); | 202 | const KDbDriverMetaData *metaData = manager.driverMetaData(conn.driverId()); | ||
200 | if (!metaData) { | 203 | if (!metaData) { | ||
201 | q->m_result = manager.result(); | 204 | q->m_result = manager.result(); | ||
202 | return false; | 205 | return false; | ||
203 | } | 206 | } | ||
204 | if (metaData->isFileBased()) { | 207 | if (metaData->isFileBased()) { | ||
205 | shortcutPath = path + QFileInfo(newData->databaseName()).fileName(); | 208 | shortcutPath = QFileInfo(newData->databaseName()).fileName(); | ||
206 | QFileInfo fi(shortcutPath); | 209 | QFileInfo fi(shortcutPath); | ||
207 | if (!fi.suffix().isEmpty()) { | 210 | if (!fi.suffix().isEmpty()) { | ||
208 | shortcutPath.chop(fi.suffix().length() + 1); | 211 | shortcutPath.chop(fi.suffix().length() + 1); | ||
209 | } | 212 | } | ||
210 | } else { | 213 | } else { | ||
211 | shortcutPath = path + newData->databaseName(); | 214 | shortcutPath = newData->databaseName(); | ||
212 | if (!conn.hostName().isEmpty()) { | 215 | if (!conn.hostName().isEmpty()) { | ||
213 | shortcutPath += '_' + conn.hostName(); | 216 | shortcutPath += '_' + conn.hostName(); | ||
214 | } | 217 | } | ||
215 | } | 218 | } | ||
219 | if (shortcutPath.startsWith('.')) { | ||||
220 | shortcutPath.prepend('_'); | ||||
221 | } | ||||
222 | shortcutPath = path + shortcutPath; | ||||
216 | int suffixNumber = 0; | 223 | int suffixNumber = 0; | ||
217 | QString suffixNumberString; | 224 | QString suffixNumberString; | ||
218 | forever { // add "_{number}" to ensure uniqueness | 225 | forever { // add "_{number}" to ensure uniqueness | ||
219 | if (!QFile::exists(shortcutPath + suffixNumberString + QLatin1String(".kexis"))) | 226 | if (!QFile::exists(shortcutPath + suffixNumberString + QLatin1String(".kexis"))) | ||
220 | break; | 227 | break; | ||
221 | suffixNumber++; | 228 | suffixNumber++; | ||
222 | suffixNumberString = QString("_%1").arg(suffixNumber); | 229 | suffixNumberString = QString("_%1").arg(suffixNumber); | ||
223 | } | 230 | } | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |