summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2024-03-01 18:22:59 -0500
committerLouie S <louie@example.com>2024-03-01 18:22:59 -0500
commit74c9ba962ffe142b04f77fd831438a75eec7b46b (patch)
tree3e59b5cd84d452a6580dec125fcb441d2d251945
parent4b99428a0e73c9e573624b2784464ce8ae632e33 (diff)
Add right-click skeletons to groups
-rw-r--r--src/add_group_form.cpp1
-rw-r--r--src/assignmentList.cpp5
-rw-r--r--src/assignmentList.h4
-rw-r--r--src/group.cpp41
-rw-r--r--src/group.h8
5 files changed, 48 insertions, 11 deletions
diff --git a/src/add_group_form.cpp b/src/add_group_form.cpp
index b20713d..4a84934 100644
--- a/src/add_group_form.cpp
+++ b/src/add_group_form.cpp
@@ -28,7 +28,6 @@ void AddGroupForm::accept() {
}
new_id = database.insertGroup(Group(0, name_text, column_text, link_text));
- // TODO redraw the main window
QDialog::accept();
}
diff --git a/src/assignmentList.cpp b/src/assignmentList.cpp
index 26af7ce..cf53fc3 100644
--- a/src/assignmentList.cpp
+++ b/src/assignmentList.cpp
@@ -94,11 +94,6 @@ void AssignmentList::addGroup() {
this->displayWidgets();
}
-// Open the 'editGroup; form
-void AssignmentList::editGroup(int id) {
- qDebug() << "WIP";
-}
-
void AssignmentList::preferences() {
qDebug() << "WIP";
}
diff --git a/src/assignmentList.h b/src/assignmentList.h
index c21ca15..9997ab5 100644
--- a/src/assignmentList.h
+++ b/src/assignmentList.h
@@ -21,10 +21,6 @@ class AssignmentList : public QMainWindow {
void initializeUI();
void displayDate();
void displayWidgets();
- void editGroup(int id);
- void removeGroup(int id);
- void groupContextMenu(int group_id);
- void addEntry(int parent); // TODO figure out type for parameter
void editEntry(int id);
void toggleDoneEntry(int id);
void removeEntry(int id);
diff --git a/src/group.cpp b/src/group.cpp
index 781fb98..5bc6b7c 100644
--- a/src/group.cpp
+++ b/src/group.cpp
@@ -1,6 +1,9 @@
#include <QLabel>
+#include <QMenu>
#include <QString>
+#include <QDebug>
+
#include "group.h"
Group::Group(int id, QString name, QString column, QString link, bool hidden) :
@@ -14,10 +17,46 @@ Group::Group(int id, QString name, QString column, QString link, bool hidden) :
QLabel *name_label = new QLabel(this->name);
name_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
+ name_label->setToolTip("Right-Click for actions");
+ name_label->setContextMenuPolicy(Qt::CustomContextMenu);
+ //name_label->customContextMenuRequested(const QPoint &pos)
+ QObject::connect(name_label,
+ SIGNAL(customContextMenuRequested(const QPoint &)),
+ SLOT(showContextMenu()));
QFont name_font = QFont("Arial", 13);
name_font.setUnderline(true);
-
name_label->setFont(name_font);
+
this->addWidget(name_label);
}
+
+void Group::showContextMenu() {
+ QMenu menu;
+
+ QAction *add_entry_act = new QAction("Add Entry");
+ QObject::connect(add_entry_act, &QAction::triggered, this, &Group::addEntry);
+ menu.addAction(add_entry_act);
+
+ QAction *edit_group_act = new QAction("Edit Group");
+ QObject::connect(edit_group_act, &QAction::triggered, this, &Group::editGroup);
+ menu.addAction(edit_group_act);
+
+ QAction *del_group_act = new QAction("Remove Group");
+ QObject::connect(del_group_act, &QAction::triggered, this, &Group::removeGroup);
+ menu.addAction(del_group_act);
+
+ menu.exec(QCursor::pos());
+}
+
+void Group::addEntry() {
+ qDebug() << "WIP";
+}
+
+void Group::editGroup() {
+ qDebug() << "WIP";
+}
+
+void Group::removeGroup() {
+ qDebug() << "WIP";
+}
diff --git a/src/group.h b/src/group.h
index 5513f7c..370cbb2 100644
--- a/src/group.h
+++ b/src/group.h
@@ -5,6 +5,8 @@
#include <QVBoxLayout>
class Group : public QVBoxLayout {
+ Q_OBJECT
+
public:
int id;
QString name;
@@ -19,6 +21,12 @@ class Group : public QVBoxLayout {
QString link = "",
bool hidden = false
);
+
+ private slots:
+ void showContextMenu();
+ void addEntry();
+ void editGroup();
+ void removeGroup();
};
#endif