Skip to content

Commit

Permalink
#1181, implemented note folder reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Apr 19, 2019
1 parent a333188 commit 2688ab3
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# QOwnNotes Changelog

## 19.4.3
- you can now reorder your note folders in the *Note folders settings* via drag and drop
(for [#1181](https://github.com/pbek/QOwnNotes/issues/1181))

## 19.4.2
- for Linux there there now is a setting in the *Interface settings* to enforce
the system icon theme in case your desktop environment doesn't report the icon
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Expand Up @@ -238,6 +238,8 @@ set(SOURCE_FILES
widgets/combobox.h
widgets/scriptlistwidget.cpp
widgets/scriptlistwidget.h
widgets/notefolderlistwidget.cpp
widgets/notefolderlistwidget.h
widgets/fontcolorwidget.ui
widgets/fontcolorwidget.cpp
widgets/fontcolorwidget.h
Expand Down
2 changes: 2 additions & 0 deletions src/QOwnNotes.pro
Expand Up @@ -137,6 +137,7 @@ SOURCES += main.cpp\
widgets/lineedit.cpp \
widgets/qtexteditsearchwidget.cpp \
widgets/scriptlistwidget.cpp \
widgets/notefolderlistwidget.cpp \
widgets/notetreewidgetitem.cpp \
widgets/layoutwidget.cpp

Expand Down Expand Up @@ -222,6 +223,7 @@ HEADERS += mainwindow.h \
widgets/lineedit.h \
widgets/qtexteditsearchwidget.h \
widgets/scriptlistwidget.h \
widgets/notefolderlistwidget.h \
widgets/notetreewidgetitem.h \
widgets/layoutwidget.h

Expand Down
2 changes: 1 addition & 1 deletion src/build_number.h
@@ -1 +1 @@
#define BUILD 530
#define BUILD 531
16 changes: 15 additions & 1 deletion src/dialogs/settingsdialog.ui
Expand Up @@ -450,13 +450,22 @@
<number>9</number>
</property>
<item row="0" column="0">
<widget class="QListWidget" name="noteFolderListWidget">
<widget class="NoteFolderListWidget" name="noteFolderListWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::InternalMove</enum>
</property>
<property name="defaultDropAction">
<enum>Qt::TargetMoveAction</enum>
</property>
</widget>
</item>
<item row="1" column="0">
Expand Down Expand Up @@ -5501,6 +5510,11 @@ Just test yourself if you get sync conflicts and set a higher value if so.</stri
<header location="global">widgets/layoutwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>NoteFolderListWidget</class>
<extends>QListWidget</extends>
<header>widgets/notefolderlistwidget.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../breeze-qownnotes.qrc"/>
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
@@ -1 +1 @@
#define VERSION "19.4.2"
#define VERSION "19.4.3"
44 changes: 44 additions & 0 deletions src/widgets/notefolderlistwidget.cpp
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2014-2019 Patrizio Bekerle -- http://www.bekerle.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#include "notefolderlistwidget.h"
#include <entities/notefolder.h>

NoteFolderListWidget::NoteFolderListWidget(QWidget *parent) {
Q_UNUSED(parent);
}

void NoteFolderListWidget::dropEvent(QDropEvent *e) {
// finish the move event
QListWidget::dropEvent(e);

int itemCount = count();

if (itemCount == 0) {
return;
}

// update all priorities of the scripts
for (int index = 0; index < itemCount; index++) {
QListWidgetItem *listItem = item(index);
int noteFolderId = listItem->data(Qt::UserRole).toInt();

NoteFolder noteFolder = NoteFolder::fetch(noteFolderId);

// store the new priority of the note folder
if (noteFolder.isFetched()) {
noteFolder.setPriority(index);
noteFolder.store();
}
}
}
26 changes: 26 additions & 0 deletions src/widgets/notefolderlistwidget.h
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2014-2019 Patrizio Bekerle -- http://www.bekerle.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#pragma once

#include <QListWidget>
#include <QDropEvent>

class NoteFolderListWidget : public QListWidget
{
public:
explicit NoteFolderListWidget(QWidget *parent = Q_NULLPTR);

protected:
void dropEvent(QDropEvent *e);
};

0 comments on commit 2688ab3

Please sign in to comment.