aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-21 11:16:34 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-21 11:16:34 (GMT)
commit33a4e9e9e740b4c351360841c4357bd81af19b72 (patch)
treeae77d6f402b787c95ac1b382ac384b25a49a6055
parent1ae8ab54f66177226b48ad512c5f499e83e519fe (diff)
search always for .kateconfig upwards
-rw-r--r--src/dialogs/katedialogs.cpp4
-rw-r--r--src/dialogs/opensaveconfigadvwidget.ui16
-rw-r--r--src/document/katedocument.cpp53
-rw-r--r--src/utils/kateconfig.cpp31
-rw-r--r--src/utils/kateconfig.h11
5 files changed, 26 insertions, 89 deletions
diff --git a/src/dialogs/katedialogs.cpp b/src/dialogs/katedialogs.cpp
index a22f9d7..82048e4 100644
--- a/src/dialogs/katedialogs.cpp
+++ b/src/dialogs/katedialogs.cpp
@@ -915,7 +915,6 @@ KateSaveConfigTab::KateSaveConfigTab(QWidget *parent)
connect(ui->chkNewLineAtEof, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
connect(uiadv->chkBackupLocalFiles, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
connect(uiadv->chkBackupRemoteFiles, SIGNAL(toggled(bool)), this, SLOT(slotChanged()));
- connect(uiadv->sbConfigFileSearchDepth, SIGNAL(valueChanged(int)), this, SLOT(slotChanged()));
connect(uiadv->edtBackupPrefix, SIGNAL(textChanged(QString)), this, SLOT(slotChanged()));
connect(uiadv->edtBackupSuffix, SIGNAL(textChanged(QString)), this, SLOT(slotChanged()));
connect(uiadv->cmbSwapFileMode, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChanged()));
@@ -1029,8 +1028,6 @@ void KateSaveConfigTab::apply()
KateDocumentConfig::global()->setSwapDirectory(uiadv->kurlSwapDirectory->url().toLocalFile());
KateDocumentConfig::global()->setSwapSyncInterval(uiadv->spbSwapFileSync->value());
- KateDocumentConfig::global()->setSearchDirConfigDepth(uiadv->sbConfigFileSearchDepth->value());
-
KateDocumentConfig::global()->setRemoveSpaces(ui->cbRemoveTrailingSpaces->currentIndex());
KateDocumentConfig::global()->setNewLineAtEof(ui->chkNewLineAtEof->isChecked());
@@ -1105,7 +1102,6 @@ void KateSaveConfigTab::reload()
ui->cbRemoveTrailingSpaces->setCurrentIndex(KateDocumentConfig::global()->removeSpaces());
ui->chkNewLineAtEof->setChecked(KateDocumentConfig::global()->newLineAtEof());
- uiadv->sbConfigFileSearchDepth->setValue(KateDocumentConfig::global()->searchDirConfigDepth());
// other stuff
uint f(KateDocumentConfig::global()->backupFlags());
diff --git a/src/dialogs/opensaveconfigadvwidget.ui b/src/dialogs/opensaveconfigadvwidget.ui
index 145fe63..f1a8c65 100644
--- a/src/dialogs/opensaveconfigadvwidget.ui
+++ b/src/dialogs/opensaveconfigadvwidget.ui
@@ -33,22 +33,6 @@
</widget>
</item>
<item>
- <widget class="QSpinBox" name="sbConfigFileSearchDepth">
- <property name="whatsThis">
- <string>The editor will search the given number of folder levels upwards for a .kateconfig file and load the settings line from it.</string>
- </property>
- <property name="specialValueText">
- <string>Do not use config file</string>
- </property>
- <property name="minimum">
- <number>-1</number>
- </property>
- <property name="maximum">
- <number>64</number>
- </property>
- </widget>
- </item>
- <item>
<spacer>
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/src/document/katedocument.cpp b/src/document/katedocument.cpp
index 314de67..bdfa69e 100644
--- a/src/document/katedocument.cpp
+++ b/src/document/katedocument.cpp
@@ -2323,44 +2323,43 @@ bool KTextEditor::DocumentPrivate::saveFile()
void KTextEditor::DocumentPrivate::readDirConfig()
{
- int depth = config()->searchDirConfigDepth();
-
- if (this->url().isLocalFile() && (depth > -1)) {
- QString currentDir = QFileInfo(localFilePath()).absolutePath();
-
- // only search as deep as specified or not at all ;)
- while (depth > -1) {
- //qCDebug(LOG_PART) << "search for config file in path: " << currentDir;
+ if (!url().isLocalFile())
+ return;
- // try to open config file in this dir
- QFile f(currentDir + QLatin1String("/.kateconfig"));
+ /**
+ * go up to /
+ */
+ QString currentDir = QFileInfo(localFilePath()).absolutePath();
+ Q_FOREVER {
+ //qCDebug(LOG_PART) << "search for config file in path: " << currentDir;
- if (f.open(QIODevice::ReadOnly)) {
- QTextStream stream(&f);
+ // try to open config file in this dir
+ QFile f(currentDir + QLatin1String("/.kateconfig"));
- uint linesRead = 0;
- QString line = stream.readLine();
- while ((linesRead < 32) && !line.isNull()) {
- readVariableLine(line);
+ if (f.open(QIODevice::ReadOnly)) {
+ QTextStream stream(&f);
- line = stream.readLine();
+ uint linesRead = 0;
+ QString line = stream.readLine();
+ while ((linesRead < 32) && !line.isNull()) {
+ readVariableLine(line);
- linesRead++;
- }
+ line = stream.readLine();
- break;
+ linesRead++;
}
- QString newDir = QFileInfo(currentDir).absolutePath();
+ break;
+ }
- // bail out on looping (for example reached /)
- if (currentDir == newDir) {
- break;
- }
+ QString newDir = QFileInfo(currentDir).absolutePath();
- currentDir = newDir;
- --depth;
+ // bail out on looping (for example reached /)
+ if (currentDir == newDir) {
+ break;
}
+
+ currentDir = newDir;
}
}
diff --git a/src/utils/kateconfig.cpp b/src/utils/kateconfig.cpp
index 49c8bcc..65f5830 100644
--- a/src/utils/kateconfig.cpp
+++ b/src/utils/kateconfig.cpp
@@ -190,7 +190,6 @@ KateDocumentConfig::KateDocumentConfig()
m_bomSet(false),
m_allowEolDetectionSet(false),
m_backupFlagsSet(false),
- m_searchDirConfigDepthSet(false),
m_backupPrefixSet(false),
m_backupSuffixSet(false),
m_swapFileModeSet(false),
@@ -235,7 +234,6 @@ KateDocumentConfig::KateDocumentConfig(const KConfigGroup &cg)
m_bomSet(false),
m_allowEolDetectionSet(false),
m_backupFlagsSet(false),
- m_searchDirConfigDepthSet(false),
m_backupPrefixSet(false),
m_backupSuffixSet(false),
m_swapFileModeSet(false),
@@ -274,7 +272,6 @@ KateDocumentConfig::KateDocumentConfig(KTextEditor::DocumentPrivate *doc)
m_bomSet(false),
m_allowEolDetectionSet(false),
m_backupFlagsSet(false),
- m_searchDirConfigDepthSet(false),
m_backupPrefixSet(false),
m_backupSuffixSet(false),
m_swapFileModeSet(false),
@@ -315,7 +312,6 @@ const char *const KEY_EOL = "End of Line";
const char *const KEY_ALLOW_EOL_DETECTION = "Allow End of Line Detection";
const char *const KEY_BOM = "BOM";
const char *const KEY_BACKUP_FLAGS = "Backup Flags";
-const char *const KEY_SEARCH_DIR_CONFIG_DEPTH = "Search Dir Config Depth";
const char *const KEY_BACKUP_PREFIX = "Backup Prefix";
const char *const KEY_BACKUP_SUFFIX = "Backup Suffix";
const char *const KEY_SWAP_FILE_MODE = "Swap File Mode";
@@ -362,8 +358,6 @@ void KateDocumentConfig::readConfig(const KConfigGroup &config)
setBackupFlags(config.readEntry(KEY_BACKUP_FLAGS, 0));
- setSearchDirConfigDepth(config.readEntry(KEY_SEARCH_DIR_CONFIG_DEPTH, 9));
-
setBackupPrefix(config.readEntry(KEY_BACKUP_PREFIX, QString()));
setBackupSuffix(config.readEntry(KEY_BACKUP_SUFFIX, QString::fromLatin1("~")));
@@ -414,8 +408,6 @@ void KateDocumentConfig::writeConfig(KConfigGroup &config)
config.writeEntry(KEY_BACKUP_FLAGS, backupFlags());
- config.writeEntry(KEY_SEARCH_DIR_CONFIG_DEPTH, searchDirConfigDepth());
-
config.writeEntry(KEY_BACKUP_PREFIX, backupPrefix());
config.writeEntry(KEY_BACKUP_SUFFIX, backupSuffix());
@@ -1142,29 +1134,6 @@ void KateDocumentConfig::setSwapDirectory(const QString &directory)
configEnd();
}
-int KateDocumentConfig::searchDirConfigDepth() const
-{
- if (m_searchDirConfigDepthSet || isGlobal()) {
- return m_searchDirConfigDepth;
- }
-
- return s_global->searchDirConfigDepth();
-}
-
-void KateDocumentConfig::setSearchDirConfigDepth(int depth)
-{
- if (m_searchDirConfigDepthSet && m_searchDirConfigDepth == depth) {
- return;
- }
-
- configStart();
-
- m_searchDirConfigDepthSet = true;
- m_searchDirConfigDepth = depth;
-
- configEnd();
-}
-
bool KateDocumentConfig::onTheFlySpellCheck() const
{
if (isGlobal()) {
diff --git a/src/utils/kateconfig.h b/src/utils/kateconfig.h
index c4a1d19..04312e0 100644
--- a/src/utils/kateconfig.h
+++ b/src/utils/kateconfig.h
@@ -312,15 +312,6 @@ public:
uint swapSyncInterval() const;
void setSwapSyncInterval(uint interval);
- /**
- * Should Kate Part search for dir wide config file
- * and if, how depth?
- * @return search depth (< 0 no search)
- */
- int searchDirConfigDepth() const;
-
- void setSearchDirConfigDepth(int depth);
-
bool onTheFlySpellCheck() const;
void setOnTheFlySpellCheck(bool on);
@@ -340,7 +331,6 @@ private:
int m_eol;
bool m_bom;
uint m_backupFlags;
- int m_searchDirConfigDepth;
QString m_encoding;
QString m_backupPrefix;
QString m_backupSuffix;
@@ -385,7 +375,6 @@ private:
bool m_bomSet : 1;
bool m_allowEolDetectionSet : 1;
bool m_backupFlagsSet : 1;
- bool m_searchDirConfigDepthSet : 1;
bool m_backupPrefixSet : 1;
bool m_backupSuffixSet : 1;
bool m_swapFileModeSet : 1;