Skip to content

Commit

Permalink
Merge pull request #47 from jorge-barroso/work/customer_on_project_dr…
Browse files Browse the repository at this point in the history
…opdown

Added company name to projects dropdown
  • Loading branch information
jorge-barroso authored Feb 16, 2023
2 parents a2991f7 + 8782afc commit 28ec092
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ find_package(Qt6 ${QT6_MIN_VERSION} REQUIRED
Widgets
Network
LinguistTools
# Multimedia
Svg
)

Expand Down
2 changes: 1 addition & 1 deletion customtaskdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void CustomTaskDialog::add_projects(const std::vector<HarvestProject>& new_proje
projects = new_projects;
for (const HarvestProject& project: projects)
{
project_dropdown->addItem(project.project_name);
project_dropdown->addItem(project.get_project_label());
}

new_project_chosen(0, task_dropdown);
Expand Down
8 changes: 4 additions & 4 deletions harvesthandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ HarvestHandler::get_projects_data(const QJsonDocument &json_payload, std::vector
}

const HarvestProject project{
project_assignment["client"]["name"].toString(),
project_assignment["project"]["name"].toString(),
project_assignment["project"]["id"].toInteger(),
project_tasks_vector
.client_name=project_assignment["client"]["name"].toString(),
.project_name=project_assignment["project"]["name"].toString(),
.project_id=project_assignment["project"]["id"].toInteger(),
.task=project_tasks_vector
};
projects_vector.emplace_back(project);
}
Expand Down
10 changes: 9 additions & 1 deletion harvestproject.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@

struct HarvestProject
{
QString company_name;
QString client_name;
QString project_name;
qint64 project_id;
std::vector<HarvestTask> task;

[[nodiscard]] QString get_project_label() const {
if(client_name.isNull() || client_name.isEmpty()) {
return project_name;
}

return QString("%1 (%2)").arg(project_name, client_name);
}
};


Expand Down
2 changes: 1 addition & 1 deletion task.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct Task {
return project_name;
}

return project_name + " (" + client_name + ")";
return QString("%1 (%2)").arg(project_name, client_name);
}
};

Expand Down

0 comments on commit 28ec092

Please sign in to comment.