Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Tobias Hunger
qt-creator
Commits
bcc7561d
Commit
bcc7561d
authored
Feb 09, 2010
by
Christiaan Janssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QmlDesigner.Navigator: Icons and error message on invalid id
parent
d1bdfcc3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
...s/qmldesigner/components/navigator/navigatortreemodel.cpp
+8
-1
src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp
...ns/qmldesigner/components/navigator/navigatortreeview.cpp
+20
-11
No files found.
src/plugins/qmldesigner/components/navigator/navigatortreemodel.cpp
View file @
bcc7561d
...
...
@@ -36,6 +36,7 @@
#include <invalididexception.h>
#include <QMimeData>
#include <QMessageBox>
namespace
QmlDesigner
{
...
...
@@ -272,8 +273,14 @@ void NavigatorTreeModel::handleChangedItem(QStandardItem *item)
try
{
if
(
ModelNode
::
isValidId
(
item
->
text
()))
node
.
setId
(
item
->
text
());
else
else
{
QMessageBox
errorDialog
;
errorDialog
.
setModal
(
true
);
errorDialog
.
setText
(
tr
(
"Invalid id.
\n
Only alphanumeric characters and underscore allowed.
\n
Ids must begin with a lowercase letter."
));
errorDialog
.
exec
();
item
->
setText
(
node
.
id
());
}
}
catch
(
InvalidIdException
&
)
{
item
->
setText
(
node
.
id
());
}
...
...
src/plugins/qmldesigner/components/navigator/navigatortreeview.cpp
View file @
bcc7561d
...
...
@@ -44,7 +44,7 @@ QSize IconCheckboxItemDelegate::sizeHint(const QStyleOptionViewItem &option,
{
Q_UNUSED
(
option
);
Q_UNUSED
(
index
);
return
QSize
(
15
,
1
7
);
return
QSize
(
15
,
2
1
);
}
void
IconCheckboxItemDelegate
::
paint
(
QPainter
*
painter
,
...
...
@@ -63,10 +63,6 @@ void IconCheckboxItemDelegate::paint(QPainter *painter,
else
painter
->
drawPixmap
(
option
.
rect
.
x
()
+
2
,
option
.
rect
.
y
()
+
1
,
offPix
);
painter
->
setOpacity
(
1.0
);
painter
->
setPen
(
QColor
(
_separator_line_color_
));
painter
->
drawLine
(
option
.
rect
.
topLeft
(),
option
.
rect
.
bottomLeft
());
painter
->
restore
();
}
...
...
@@ -81,19 +77,32 @@ void IdItemDelegate::paint(QPainter *painter,
ModelNode
node
=
m_TreeModel
->
nodeForIndex
(
index
);
//
QIcon icon=node.metaInfo().icon();
//
if (icon.isNull()) icon = QIcon(":/ItemLibrary/images/default-icon.png");
//
QPixmap pixmap = icon.pixmap(option.rect.width(),option.rect.height());
//
painter->drawPixmap(option.rect.x()+
1
,option.rect.y(),pixmap);
QIcon
icon
=
node
.
metaInfo
().
icon
();
if
(
icon
.
isNull
())
icon
=
QIcon
(
":/ItemLibrary/images/default-icon.png"
);
QPixmap
pixmap
=
icon
.
pixmap
(
option
.
rect
.
width
(),
option
.
rect
.
height
()
-
4
);
painter
->
drawPixmap
(
option
.
rect
.
x
()
+
5
,
option
.
rect
.
y
()
+
2
,
pixmap
);
QString
myString
=
node
.
id
();
if
(
myString
.
isEmpty
())
myString
=
node
.
simplifiedTypeName
();
// Check text length does not exceed available space
int
extraSpace
=
12
+
pixmap
.
width
();
QFontMetrics
metric
(
painter
->
fontMetrics
());
if
(
painter
->
fontMetrics
().
boundingRect
(
myString
).
width
()
>
option
.
rect
.
width
()
-
extraSpace
)
{
QString
origString
(
myString
);
int
cutpoint
=
origString
.
length
()
/
2
;
while
(
painter
->
fontMetrics
().
boundingRect
(
myString
).
width
()
>
option
.
rect
.
width
()
-
extraSpace
)
{
cutpoint
--
;
myString
=
origString
.
left
(
cutpoint
)
+
QLatin1String
(
"..."
)
+
origString
.
right
(
cutpoint
);
}
}
if
(
m_TreeModel
->
isNodeInvisible
(
index
))
painter
->
setOpacity
(
0.5
);
// painter->drawText(option.rect.bottomLeft()+QPoint(4+pixmap.width(),-4),myString);
painter
->
drawText
(
option
.
rect
.
bottomLeft
()
+
QPoint
(
4
,
-
4
),
myString
);
painter
->
drawText
(
option
.
rect
.
bottomLeft
()
+
QPoint
(
8
+
pixmap
.
width
(),
-
4
),
myString
);
painter
->
restore
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment