Skip to content

Commit db07db8

Browse files
committed
gui: minor fix from code review feedback
Signed-off-by: LucasYuki <[email protected]>
1 parent 31bd49b commit db07db8

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

src/gui/src/qComboCheckBoxes.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
namespace gui {
99

10-
qComboCheckBoxes::qComboCheckBoxes(const char* name,
11-
const char* all_text,
10+
qComboCheckBoxes::qComboCheckBoxes(const std::string& name,
11+
const std::string& all_text,
1212
QWidget* parent)
1313
: QComboBox(parent),
14-
name_item_(new QStandardItem(name)),
15-
all_item_(new QStandardItem(all_text)),
14+
name_item_(new QStandardItem(QString::fromStdString(name))),
15+
all_item_(new QStandardItem(QString::fromStdString(all_text))),
1616
model_(new QStandardItemModel(this)),
1717
updating_check_boxes_(false)
1818
{
1919
setup();
2020
}
2121

2222
qComboCheckBoxes::qComboCheckBoxes(const QString& name,
23-
const char* all_text,
23+
const QString& all_text,
2424
QWidget* parent)
2525
: QComboBox(parent),
2626
name_item_(new QStandardItem(name)),

src/gui/src/qComboCheckBoxes.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,26 @@ class qComboCheckBoxes : public QComboBox
2020
{
2121
Q_OBJECT
2222
public:
23-
qComboCheckBoxes(const char* name,
24-
const char* all_text = "All",
23+
qComboCheckBoxes(const std::string& name,
24+
const std::string& all_text = "All",
2525
QWidget* parent = nullptr);
2626
qComboCheckBoxes(const QString& name,
27-
const char* all_text = "All",
27+
const QString& all_text = "All",
2828
QWidget* parent = nullptr);
2929
void clear();
3030

31-
void setName(const char* name) { name_item_->setText(QString(name)); };
31+
void setName(const std::string& name)
32+
{
33+
name_item_->setText(QString::fromStdString(name));
34+
};
3235
void setName(const QString& name) { name_item_->setText(name); };
3336
QString getName() { return name_item_->text(); };
3437
QStandardItem* getNameItem() { return name_item_; };
3538

36-
void setAllText(const char* text) { all_item_->setText(QString(text)); };
39+
void setAllText(const std::string& text)
40+
{
41+
all_item_->setText(QString::fromStdString(text));
42+
};
3743
void setAllText(const QString& text) { all_item_->setText(text); };
3844
QString getAllText() { return all_item_->text(); };
3945
QStandardItem* getAllItem() { return all_item_; };

src/gui/src/staGui.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "staGui.h"
55

6+
#include <qchar.h>
67
#include <qglobal.h>
78

89
#include <QAbstractItemView>
@@ -1111,7 +1112,9 @@ TimingControlsDialog::TimingControlsDialog(QWidget* parent)
11111112
layout_(new QFormLayout),
11121113
path_count_spin_box_(new QSpinBox(this)),
11131114
corner_box_(new QComboBox(this)),
1114-
clock_box_(new qComboCheckBoxes("Select Clocks", "All Clocks", this)),
1115+
clock_box_(new qComboCheckBoxes(QString("Select Clocks"),
1116+
QString("All Clocks"),
1117+
this)),
11151118
unconstrained_(new QCheckBox(this)),
11161119
one_path_per_endpoint_(new QCheckBox(this)),
11171120
expand_clk_(new QCheckBox(this)),
@@ -1250,8 +1253,8 @@ void TimingControlsDialog::populate()
12501253
for (auto clk : *sta_->getClocks()) {
12511254
QString clk_name = clk->name();
12521255

1253-
if (clks_.count(clk_name) != 1) {
1254-
clks_[clk_name] = clk;
1256+
if (qstring_to_clk_.count(clk_name) != 1) {
1257+
qstring_to_clk_[clk_name] = clk;
12551258
QStandardItem* item = new QStandardItem(clk_name);
12561259

12571260
item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
@@ -1345,8 +1348,8 @@ std::vector<std::set<const sta::Pin*>> TimingControlsDialog::getThruPins() const
13451348

13461349
void TimingControlsDialog::getClocks(sta::ClockSet* clock_set) const
13471350
{
1348-
for (const auto& clk : clock_box_->selectedItems()) {
1349-
clock_set->insert(clks_[clk]);
1351+
for (const auto& clk_name : clock_box_->selectedItems()) {
1352+
clock_set->insert(qstring_to_clk_[clk_name]);
13501353
}
13511354
}
13521355

src/gui/src/staGui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include <QDialog>
1313
#include <QFormLayout>
1414
#include <QHBoxLayout>
15+
#include <QHash>
1516
#include <QListWidget>
1617
#include <QSpinBox>
17-
#include <QHash>
1818
#include <map>
1919
#include <memory>
2020
#include <set>
@@ -437,7 +437,7 @@ class TimingControlsDialog : public QDialog
437437
PinSetWidget* from_;
438438
std::vector<PinSetWidget*> thru_;
439439
PinSetWidget* to_;
440-
QHash<QString, sta::Clock*> clks_;
440+
QHash<QString, sta::Clock*> qstring_to_clk_;
441441

442442
static constexpr int kThruStartRow = 4;
443443

src/gui/src/staGuiInterface.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,8 @@ std::unique_ptr<TimingPathNode> STAGuiInterface::getTimingNode(
10261026

10271027
TimingPathList STAGuiInterface::getTimingPaths(const sta::Pin* thru) const
10281028
{
1029-
return getTimingPaths({}, {{thru}}, {}, "" /* path group name */, nullptr);
1029+
return getTimingPaths(
1030+
{}, {{thru}}, {}, "" /* path group name */, nullptr /* clockset */);
10301031
}
10311032

10321033
TimingPathList STAGuiInterface::getTimingPaths(

0 commit comments

Comments
 (0)