info.append(QString((*currInfo)[i]->c_str()));
info.append("<br/>");
}
- fInspectorWidget.setDetailText(info);
+ fInspectorWidget.setText(info, SkInspectorWidget::kDetail_TabType);
fInspectorWidget.setDisabled(false);
}
}
overview.append("SkPicture Height: ");
overview.append(QString::number(fDebugger.pictureHeight()));
overview.append("px");
- fInspectorWidget.setOverviewText(overview);
+ fInspectorWidget.setText(overview, SkInspectorWidget::kOverview_TabType);
// NOTE(chudy): Makes first item unselectable.
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(
SkInspectorWidget::SkInspectorWidget() : QWidget()
, fHorizontalLayout(this)
- , fOverviewTab()
- , fOverviewLayout(&fOverviewTab)
- , fDetailTab()
- , fDetailLayout(&fDetailTab)
, fMatrixAndClipWidget(this)
, fVerticalLayout(&fMatrixAndClipWidget)
, fMatrixLabel(this)
fHorizontalLayout.setSpacing(6);
fHorizontalLayout.setContentsMargins(11, 11, 11, 11);
- fOverviewLayout.setSpacing(6);
- fOverviewLayout.setContentsMargins(11, 11, 11, 11);
-
- fOverviewText.setReadOnly(true);
- fOverviewLayout.addWidget(&fOverviewText);
-
- fDetailLayout.setSpacing(6);
- fDetailLayout.setContentsMargins(11,11,11,11);
-
- fDetailText.setReadOnly(true);
- fDetailLayout.addWidget(&fDetailText);
-
- fTabWidget.addTab(&fOverviewTab, QString("Overview"));
- fTabWidget.addTab(&fDetailTab, QString("Details"));
+ QString tabNames[kTotalTabCount];
+ tabNames[kOverview_TabType] = "Overview";
+ tabNames[kDetail_TabType] = "Details";
+
+ for (int i = 0; i < kTotalTabCount; i++) {
+ fTabTexts[i].setReadOnly(true);
+ fTabLayouts[i].setSpacing(6);
+ fTabLayouts[i].setContentsMargins(11, 11, 11, 11);
+ fTabLayouts[i].addWidget(&fTabTexts[i]);
+ fTabs[i].setLayout(&fTabLayouts[i]);
+ fTabWidget.addTab(&fTabs[i], tabNames[i]);
+ }
fHorizontalLayout.setAlignment(Qt::AlignTop);
fHorizontalLayout.addWidget(&fTabWidget);
* by adding them to horizontal layouts.
*
* We will have 1 big vertical layout, 3 horizontal layouts and then 3
- * line edits in each horizontal layout.
- */
-
+ * line edits in each horizontal layout. */
fMatrixAndClipWidget.setFixedSize(260,300);
fMatrixAndClipWidget.setDisabled(true);
fHorizontalLayout.addWidget(&fMatrixAndClipWidget);
}
-void SkInspectorWidget::setDetailText(QString text) {
- fDetailText.setHtml(text);
-}
-
-void SkInspectorWidget::setOverviewText(QString text) {
- fOverviewText.setHtml(text);
+void SkInspectorWidget::setText(QString text, TabType type) {
+ fTabTexts[type].setHtml(text);
}
void SkInspectorWidget::setMatrix(const SkMatrix& matrix) {
Q_OBJECT
public:
+ enum TabType {
+ kOverview_TabType,
+ kDetail_TabType,
+ kTotalTabCount,
+ };
+
/**
Constructs a widget with the specified parent for layout purposes.
@param parent The parent container of this widget
void setDisabled(bool isDisabled) {
fMatrixAndClipWidget.setDisabled(isDisabled);
}
- /**
- Sets the text in the detail tab.
- @param text
- */
- void setDetailText(QString text);
/**
- Sets the text in the overview tab.
+ Sets the text in tab at the specified index.
@param text
*/
- void setOverviewText(QString text);
+ void setText(QString text, TabType type);
/**
Sets the text in the current matrix.
*/
void setClip(const SkIRect& clip);
+ class Tab : public QWidget {
+ QWidget fTab;
+ QHBoxLayout fTabLayout;
+ QTextEdit fTabText;
+ QString fName;
+
+ Tab(const char* name) {
+ fTabText.setReadOnly(true);
+ fTabLayout.setSpacing(6);
+ fTabLayout.setContentsMargins(11, 11, 11, 11);
+ fTabLayout.addWidget(&fTabText);
+ fTab.setLayout(&fTabLayout);
+ fName = QString(name);
+ }
+ };
+
private:
QHBoxLayout fHorizontalLayout;
QTabWidget fTabWidget;
- QWidget fOverviewTab;
- QHBoxLayout fOverviewLayout;
- QTextEdit fOverviewText;
-
- QWidget fDetailTab;
- QHBoxLayout fDetailLayout;
- QTextEdit fDetailText;
+ QWidget fTabs[kTotalTabCount];
+ QHBoxLayout fTabLayouts[kTotalTabCount];
+ QTextEdit fTabTexts[kTotalTabCount];
QWidget fMatrixAndClipWidget;
QVBoxLayout fVerticalLayout;