@@ -25,18 +25,20 @@ NextcloudDeckDialog::~NextcloudDeckDialog() { delete ui; }
25
25
26
26
void NextcloudDeckDialog::setupUi () {
27
27
setupMainSplitter ();
28
+ refreshUi ();
28
29
29
30
ui->newItemEdit ->installEventFilter (this );
30
31
ui->cardItemTreeWidget ->installEventFilter (this );
31
32
ui->newItemEdit ->setFocus ();
32
33
33
34
// Adding shortcuts not working when defined in the ui file
34
- auto *shortcut = new QShortcut (QKeySequence (QStringLiteral (" Ctrl+S" )), this );
35
- QObject::connect (shortcut, SIGNAL (activated ()), this , SLOT (on_saveButton_clicked ()));
36
- shortcut = new QShortcut (QKeySequence (QStringLiteral (" Ctrl+I" )), this );
37
- QObject::connect (shortcut, SIGNAL (activated ()), this , SLOT (onSaveAndInsertButtonClicked ()));
38
- shortcut = new QShortcut (QKeySequence (QStringLiteral (" Ctrl+R" )), this );
39
- QObject::connect (shortcut, SIGNAL (activated ()), this , SLOT (on_removeButton_clicked ()));
35
+ // auto *shortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+S")), this);
36
+ // QObject::connect(shortcut, SIGNAL(activated()), this, SLOT(on_saveButton_clicked()));
37
+ // shortcut = new QShortcut(QKeySequence(QStringLiteral("Ctrl+I")), this);
38
+ // QObject::connect(shortcut, SIGNAL(activated()), this,
39
+ // SLOT(onSaveAndInsertButtonClicked())); shortcut = new
40
+ // QShortcut(QKeySequence(QStringLiteral("Ctrl+R")), this); QObject::connect(shortcut,
41
+ // SIGNAL(activated()), this, SLOT(on_removeButton_clicked()));
40
42
41
43
/*
42
44
* Set up the note button menu
@@ -49,14 +51,14 @@ void NextcloudDeckDialog::setupUi() {
49
51
insertAction->setToolTip (
50
52
tr (" Save the current todo item and insert a link"
51
53
" to it into the current note" ));
52
- connect (insertAction, SIGNAL (triggered ()), this , SLOT (onSaveAndInsertButtonClicked ()));
54
+ // connect(insertAction, SIGNAL(triggered()), this, SLOT(onSaveAndInsertButtonClicked()));
53
55
54
56
QAction *importAction = noteMenu->addAction (tr (" Import as note" ));
55
57
importAction->setIcon (
56
58
QIcon::fromTheme (QStringLiteral (" document-import" ),
57
59
QIcon (" :icons/breeze-qownnotes/16x16/document-import.svg" )));
58
60
importAction->setToolTip (tr (" Import the current todo item as new note" ));
59
- connect (importAction, SIGNAL (triggered ()), this , SLOT (onImportAsNoteButtonClicked ()));
61
+ // connect(importAction, SIGNAL(triggered()), this, SLOT(onImportAsNoteButtonClicked()));
60
62
61
63
// ui->noteButton->setMenu(noteMenu);
62
64
@@ -154,3 +156,42 @@ void NextcloudDeckDialog::setupMainSplitter() {
154
156
155
157
ui->gridLayout ->layout ()->addWidget (this ->mainSplitter );
156
158
}
159
+
160
+ void NextcloudDeckDialog::refreshUi () { reloadCardList (); }
161
+
162
+ void NextcloudDeckDialog::reloadCardList () {
163
+ NextcloudDeckService nextcloudDeckService (this );
164
+ auto cards = nextcloudDeckService.getCards ();
165
+
166
+ qDebug () << __func__ << " - 'cards': " << cards;
167
+
168
+ // Clear existing items
169
+ ui->cardItemTreeWidget ->clear ();
170
+
171
+ // Populate the tree widget with cards
172
+ for (const auto &card : cards) {
173
+ auto *item = new QTreeWidgetItem (ui->cardItemTreeWidget );
174
+
175
+ // Set the summary (title) in the first column
176
+ item->setText (0 , card.title );
177
+
178
+ // Set the due date in the second column
179
+ if (card.duedate .isValid ()) {
180
+ item->setText (1 , card.duedate .toString (" yyyy-MM-dd hh:mm" ));
181
+ } else {
182
+ item->setText (1 , tr (" No due date" ));
183
+ }
184
+
185
+ // Store the card ID as user data for later reference
186
+ item->setData (0 , Qt::UserRole, card.id );
187
+
188
+ // Set tooltip with description if available
189
+ if (!card.description .isEmpty ()) {
190
+ item->setToolTip (0 , card.description );
191
+ }
192
+ }
193
+
194
+ // Auto-resize columns to content
195
+ ui->cardItemTreeWidget ->resizeColumnToContents (0 );
196
+ ui->cardItemTreeWidget ->resizeColumnToContents (1 );
197
+ }
0 commit comments