diff --git a/doc_manager.py b/doc_manager.py index 8e53025..edd4e05 100644 --- a/doc_manager.py +++ b/doc_manager.py @@ -5,7 +5,7 @@ from datetime import datetime from typing import List import org_rw -from org_rw import OrgTime, OrgDoc +from org_rw import OrgDoc, OrgTime EXTENSIONS = ( ".org", ".org.txt" ) @@ -49,6 +49,15 @@ class DocumentManager: docs = [] for root, dirs, files in os.walk(top): + # Prune dirs + i = 0 + while i < len(dirs): + if dirs[i].startswith('.git'): + del dirs[i] + else: + i += 1 + + # Process files for name in files: if all(map(lambda ext: not name.endswith(ext), EXTENSIONS)): continue diff --git a/main.py b/main.py index 7128930..12eaf34 100755 --- a/main.py +++ b/main.py @@ -7,7 +7,7 @@ import time from PySide2.QtCore import QObject, QThread, Signal, Slot from PySide2.QtWidgets import (QApplication, QDialog, QLabel, QLineEdit, QProgressBar, QScrollArea, QTabBar, - QVBoxLayout, QFrame, QScroller) + QVBoxLayout, QFrame, QScroller, QHBoxLayout, QPushButton, QGroupBox) import doc_manager @@ -47,6 +47,7 @@ class Dialog(QDialog): layout.addWidget(self.progressBar) self.edit = QLineEdit("", placeholderText='Search for notes') + self.edit.textEdited.connect(self.on_text_edited) layout.addWidget(self.edit) layout.setSpacing(0) @@ -70,6 +71,10 @@ class Dialog(QDialog): self.setLayout(layout) self.startLoad() + @Slot() + def on_text_edited(self): + self.tabBar.setCurrentIndex(1) + @Slot() def update_tab(self): tabIndex = self.tabBar.currentIndex() @@ -114,30 +119,46 @@ class Dialog(QDialog): layout = QVBoxLayout() for item in agenda.with_hour: - text = "{} {} {}".format( - item.scheduled.time, - item.state, - item.title, - ) - label = QLabel(text=text) - layout.addWidget(label) + layout.addWidget(self.build_agenda_task_widget(item)) # if len(agenda.with_hour) > 0 and len(agenda.no_hour) > 0: # layout.addWidget(QSplitter()) for item in agenda.no_hour: - text = "{} {} {}".format( - item.scheduled.time, - item.state, - item.title, - ) - label = QLabel(text=text) - layout.addWidget(label) + layout.addWidget(self.build_agenda_task_widget(item)) frame = QFrame(self.results) frame.setLayout(layout) self.results.setWidget(frame) + def build_agenda_task_widget(self, item): + box = QHBoxLayout() + frame = QGroupBox() + frame.setLayout(box) + + state_button = QPushButton(text=f"{item.state or '-'}", maximumWidth=60) + if item.is_done: + state_button.setFlat(True) + box.addWidget(state_button) + + box.addWidget( + QLabel(text=f"{item.scheduled.time}", maximumWidth=200) + ) + box.addWidget( + QLabel(text=f"{item.title}") + ) + + def on_clicked(): + state_button.setText('DONE') + # state_button.setFlat(True) + # item.state = 'DONE' + + if not item.is_done: + state_button.clicked.connect(on_clicked) + + + return frame + def loadNotes(self): logging.warning("loadNotes not yet implemented") diff --git a/org-mode.svg b/org-mode.svg new file mode 100644 index 0000000..917cf3a --- /dev/null +++ b/org-mode.svg @@ -0,0 +1,149 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + +