Skip to content

Commit

Permalink
Allow ignoring note files by regular expression patterns (pbek#2580)
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Sep 10, 2022
1 parent 3d724f0 commit da5dfba
Show file tree
Hide file tree
Showing 7 changed files with 419 additions and 350 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# QOwnNotes Changelog

## 22.9.0
- the settings dialog opening time was improved a bit (for [#2574](https://github.com/pbek/QOwnNotes/issues/2574), thank you, @Waqar144)
- the settings dialog opening time was improved a lot (for [#2574](https://github.com/pbek/QOwnNotes/issues/2574), thank you, @Waqar144)
- you can now specify file patterns of note files to ignore as regular expressions
in the *Panels settings* (for [#2580](https://github.com/pbek/QOwnNotes/issues/2580))

## 22.8.4
- there now is a new scripting command `mainWindow.removeNoteTab(index)` to
Expand Down
7 changes: 7 additions & 0 deletions src/dialogs/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,10 @@ void SettingsDialog::storePanelSettings() {
settings.setValue(QStringLiteral("ignoreNoteSubFolders"),
ui->ignoreNoteSubFoldersLineEdit->text());

const QSignalBlocker blocker2(ui->ignoredNoteFilesLineEdit);
settings.setValue(QStringLiteral("ignoredNoteFiles"),
ui->ignoredNoteFilesLineEdit->text());

// Tags Panel Options
settings.setValue(QStringLiteral("tagsPanelHideSearch"),
ui->tagsPanelHideSearchCheckBox->isChecked());
Expand Down Expand Up @@ -1653,6 +1657,9 @@ void SettingsDialog::readPanelSettings() {
IGNORED_NOTE_SUBFOLDERS_DEFAULT)
.toString());

ui->ignoredNoteFilesLineEdit->setText(
settings.value(QStringLiteral("ignoredNoteFiles")).toString());

// Navigation Panel Options
ui->navigationPanelHideSearchCheckBox->setChecked(
settings.value(QStringLiteral("navigationPanelHideSearch")).toBool());
Expand Down
50 changes: 36 additions & 14 deletions src/dialogs/settingsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5632,13 +5632,6 @@ git config --global user.name &quot;Your name&quot;</string>
<string>Note list panel</string>
</property>
<layout class="QGridLayout" name="gridLayout_61">
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="noteListPreviewCheckBox">
<property name="text">
<string>Show notes in the note list with preview</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QCheckBox" name="noteSubfoldersPanelShowNotesRecursivelyCheckBox">
<property name="text">
Expand All @@ -5653,7 +5646,14 @@ git config --global user.name &quot;Your name&quot;</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="2" column="1" colspan="2">
<widget class="QCheckBox" name="noteListPreviewCheckBox">
<property name="text">
<string>Show notes in the note list with preview</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QGroupBox" name="notesPanelSortGroupBox">
<property name="title">
<string>Sort</string>
Expand All @@ -5676,7 +5676,14 @@ git config --global user.name &quot;Your name&quot;</string>
</layout>
</widget>
</item>
<item row="4" column="2">
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="enableNoteTreeCheckBox">
<property name="text">
<string>Instead of a note list use a note tree with all the subfolders (if they are turned on for the note folder)</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QGroupBox" name="notesPanelOrderGroupBox">
<property name="enabled">
<bool>true</bool>
Expand Down Expand Up @@ -5705,11 +5712,26 @@ git config --global user.name &quot;Your name&quot;</string>
</layout>
</widget>
</item>
<item row="3" column="1" colspan="2">
<widget class="QCheckBox" name="enableNoteTreeCheckBox">
<property name="text">
<string>Instead of a note list use a note tree with all the subfolders (if they are turned on for the note folder)</string>
<item row="4" column="1" colspan="2">
<widget class="QGroupBox" name="groupBox_39">
<property name="toolTip">
<string>Regular expressions of note subfolders to ignore, separated by &quot;;&quot;</string>
</property>
<property name="title">
<string>Ignored note files</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLineEdit" name="ignoredNoteFilesLineEdit">
<property name="placeholderText">
<string>Regular expressions of note files to ignore, separated by &quot;;&quot;</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -6904,8 +6926,8 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
<tabstop>enableSocketServerCheckBox</tabstop>
</tabstops>
<resources>
<include location="../breeze-dark-qownnotes.qrc"/>
<include location="../breeze-qownnotes.qrc"/>
<include location="../breeze-dark-qownnotes.qrc"/>
</resources>
<connections>
<connection>
Expand Down
24 changes: 24 additions & 0 deletions src/entities/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4156,6 +4156,30 @@ QStringList Note::getHeadingList() {
return headingList;
}

bool Note::applyIgnoredNotesSetting(QStringList& fileNames) {
const QSettings settings;
const QStringList ignoredFileRegExpList =
settings.value(QStringLiteral("ignoredNoteFiles")).toString()
.split(QLatin1Char(';'));

if (ignoredFileRegExpList.isEmpty()) {
return false;
}

auto newFileNames = QStringList();

for (const QString &fileName : fileNames) {
if (!Utils::Misc::regExpInListMatches(fileName,
ignoredFileRegExpList)) {
newFileNames.append(fileName);
}
}

fileNames = newFileNames;

return true;
}

/**
* Fetches all tags of the note
*/
Expand Down
2 changes: 2 additions & 0 deletions src/entities/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class Note {

QStringList getHeadingList();

static bool applyIgnoredNotesSetting(QStringList& fileNames);

protected:
int _id;
int _noteSubFolderId;
Expand Down
Loading

0 comments on commit da5dfba

Please sign in to comment.