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
Marco Bubke
flatpak-qt-creator
Commits
bb900dd8
Commit
bb900dd8
authored
Jul 06, 2009
by
Erik Verbruggen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
parents
fb48a262
d9cabeba
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
165 additions
and
16 deletions
+165
-16
doc/addressbook-sdk.qdoc
doc/addressbook-sdk.qdoc
+66
-9
doc/examples/addressbook-sdk/part6/addressbook.cpp
doc/examples/addressbook-sdk/part6/addressbook.cpp
+78
-0
doc/examples/addressbook-sdk/part6/addressbook.ui
doc/examples/addressbook-sdk/part6/addressbook.ui
+6
-0
src/plugins/coreplugin/coreconstants.h
src/plugins/coreplugin/coreconstants.h
+2
-2
src/plugins/cppeditor/cppeditorconstants.h
src/plugins/cppeditor/cppeditorconstants.h
+1
-1
src/plugins/cpptools/cppmodelmanager.cpp
src/plugins/cpptools/cppmodelmanager.cpp
+8
-0
src/plugins/find/findplugin.cpp
src/plugins/find/findplugin.cpp
+1
-1
src/plugins/projectexplorer/projectexplorer.cpp
src/plugins/projectexplorer/projectexplorer.cpp
+2
-2
src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
+1
-1
No files found.
doc/addressbook-sdk.qdoc
View file @
bb900dd8
...
...
@@ -362,7 +362,7 @@
\snippet examples/addressbook-sdk/part2/addressbook.cpp window title
\section2 The \c
{
addContact()
}
Function
\section2 The \c
addContact() Function
In this function, we begin by storing the last displayed contact details
in \c oldName and \c oldAddress. Then we clear these input fields and turn
...
...
@@ -371,7 +371,7 @@
\snippet examples/addressbook-sdk/part2/addressbook.cpp addContact
\section2 The \c
{
submitContact()
}
Function
\section2 The \c
submitContact() Function
This function can be divided into three parts:
...
...
@@ -404,7 +404,7 @@
\image addressbook-tutorial-part2-add-successful.png
\section2 The \c
{
cancel()
}
Function
\section2 The \c
cancel() Function
This function restores the last displayed contact details and enables
\c addButton, as well as hides \c submitButton and \c cancelButton.
...
...
@@ -632,7 +632,7 @@
detail.
\section2 The \c
{
editContact()
}
Function
\section2 The \c
editContact() Function
This function stores the contact's old details in \c oldName and
\c oldAddress, before switching the mode to \c EditingMode. In this mode,
...
...
@@ -680,7 +680,7 @@
# image
\section2 The \c
{
updateInterface()
}
Function
\section2 The \c
updateInterface() Function
We mentioned this function earlier as a means to enable and disable the
push buttons, depending on the current mode. The function updates the
...
...
@@ -911,13 +911,70 @@
Ideally, it would be more user-friendly to set the push buttons' labels to
"Load contacts from a file" and "Save contacts to a file". However, due to
the size of our push buttons, we set the labels to \gui{Load...} and
\gui{Save...}. Fortunately, Qt provides a simple way to set tooltips with
\l{QWidget::}{setToolTip()} and we use it in the following way for our push
buttons:
\gui{Save...}. Fortunately, Qt Creator's \QD plugin provides a simple way
to set tooltips with the \gui{Property Editor}. Simply fill in your tool
tips in the \gui{toolTip} property. To test your tooltip, use
\key{Ctrl+Alt+R} and hover your mouse cursor on the \gui{Load...} and
\gui{Save...} push buttons.
# code
# screenshot of property editor
Now lets look at the \c saveToFile() and \c loadFromFile() functions in
detail.
\section2 The \c saveToFile() Function
To save a contact, we first obtain \c fileName using
QFileDialog::getSaveFileName(). This is a convenience function provided by
QFileDialog, which pops up a modal file dialog and allows the user to enter
a file name or select any existing \c{.abk} file. The \c{.abk} file is our
Address Book extension that we create when we save contacts.
\snippet examples/addressbook-sdk/part6/addressbook.cpp saveToFile part1
The file dialog that pops up is displayed in the screenshto below:
#screenshot
If \c fileName is not empty, we create a QFile object, \c file, with
\c fileName. The QFile object works with QDataStream as QFile is a
QIODevice.
Next, we attempt to open the file in \l{QIODevice::}{WriteOnly} mode. If
this is unsuccessful, we display a QMessageBox to inform the user.
\snippet examples/addressbook-sdk/part6/addressbook.cpp saveToFile part2
Otherwise, we instantiate a QDataStream object, \c out, to write the open
file. QDataStream requires that the same version of the stream is used for
reading and writing. We ensure that this is the case by setting the version
used to the version introduced with Qt 4.5 before serializing the data into
\c file.
\snippet examples/addressbook-sdk/part6/addressbook.cpp saveToFile part3
\section2 The \c loadFromFile() Function
To load a contact, we also obtain \c fileName using
QFileDialog::getOpenFileName(). This function, the counterpart to
QFileDialog::getSaveFileName(), also pops up the modal file dialog and
allows the user to enter a file name or select any existing \c{.abk} file
to load it into the address book.
\snippet examples/addressbook-sdk/part6/addressbook.cpp loadFromFile part1
On Windows, for example, this function pops up a native file dialog, as
shown in the following screenshot.
# screenshot
If \c fileName is not empty, again, we use a QFile object, \c file, and
attempt to open it in \l{QIODevice::}{ReadOnly} mode. Similar to our
implementation
\snippet examples/addressbook-sdk/part6/addressbook.cpp loadFromFile part2
\snippet examples/addressbook-sdk/part6/addressbook.cpp loadFromFile part3
*/
...
...
doc/examples/addressbook-sdk/part6/addressbook.cpp
View file @
bb900dd8
...
...
@@ -46,6 +46,14 @@ AddressBook::AddressBook(QWidget *parent)
dialog
=
new
FindDialog
;
//! [private members]
loadButton
=
new
QPushButton
;
loadButton
=
ui
->
loadButton
;
saveButton
=
new
QPushButton
;
saveButton
=
ui
->
saveButton
;
//! [private members]
connect
(
addButton
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addContact
()));
connect
(
submitButton
,
SIGNAL
(
clicked
()),
this
,
...
...
@@ -263,3 +271,73 @@ void AddressBook::findContact()
updateInterface
(
NavigationMode
);
}
//! [saveToFile part1]
void
AddressBook
::
saveToFile
()
{
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"Save Address Book"
),
""
,
tr
(
"Address book (*.abk);; AllFiles (*)"
));
//! [saveToFile part1]
//! [saveToFile part2]
if
(
fileName
.
isEmpty
())
return
;
else
{
QFile
file
(
fileName
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
QMessageBox
::
information
(
this
,
tr
(
"Unable to open file"
),
file
.
errorString
());
return
;
}
//! [saveToFile part2]
//! [saveToFile part3]
QDataStream
out
(
&
file
);
out
.
setVersion
(
QDataStream
::
Qt_4_5
);
out
<<
contacts
;
}
}
//! [saveToFile part3]
//! [loadFromFile part1]
void
AddressBook
::
loadFromFile
()
{
QString
fileName
=
QFileDialog
::
getOpenFileName
(
this
,
tr
(
"Open Address Book"
),
""
,
tr
(
"Address Book(*.abk);; All Files(*)"
));
//! [loadFromFile part1]
//! [loadFromFile part2]
if
(
fileName
.
isEmpty
())
return
;
else
{
QFile
file
(
fileName
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
QMessageBox
::
information
(
this
,
tr
(
"Unable to open file"
),
file
.
errorString
());
return
;
}
QDataStream
in
(
&
file
);
in
.
setVersion
(
QDataStream
::
Qt_4_5
);
contacts
.
empty
();
// empty existing contacts
in
>>
contacts
;
//! [loadFromFile part2]
//! [loadFromFile part3]
if
(
contacts
.
isEmpty
())
{
QMessagebox
::
information
(
this
,
tr
(
"No contacts in file"
),
tr
(
"The file you are attempting to open contains no contacts."
));
}
else
{
QMap
<
QString
,
QString
>::
iterator
i
=
contacts
.
begin
();
nameLine
->
setText
(
i
.
key
());
addressText
->
setText
(
i
.
value
());
}
}
updateInterface
(
NavigationMode
);
}
//! [loadFromFile part3]
doc/examples/addressbook-sdk/part6/addressbook.ui
View file @
bb900dd8
...
...
@@ -85,6 +85,9 @@
</item>
<item>
<widget
class=
"QPushButton"
name=
"loadButton"
>
<property
name=
"toolTip"
>
<string>
Load contacts from a file
</string>
</property>
<property
name=
"text"
>
<string>
Load...
</string>
</property>
...
...
@@ -92,6 +95,9 @@
</item>
<item>
<widget
class=
"QPushButton"
name=
"saveButton"
>
<property
name=
"toolTip"
>
<string>
Save contacts to a file
</string>
</property>
<property
name=
"text"
>
<string>
Save...
</string>
</property>
...
...
src/plugins/coreplugin/coreconstants.h
View file @
bb900dd8
...
...
@@ -91,8 +91,8 @@ const char * const C_NAVIGATION_PANE = "Core.NavigationPane";
const
char
*
const
C_PROBLEM_PANE
=
"Core.ProblemPane"
;
//default editor kind
const
char
*
const
K_DEFAULT_TEXT_EDITOR
=
"Plain Text Editor"
;
const
char
*
const
K_DEFAULT_BINARY_EDITOR
=
"Binary Editor"
;
const
char
*
const
K_DEFAULT_TEXT_EDITOR
=
QT_TRANSLATE_NOOP
(
"OpenWith::Editors"
,
"Plain Text Editor"
)
;
const
char
*
const
K_DEFAULT_BINARY_EDITOR
=
QT_TRANSLATE_NOOP
(
"OpenWith::Editors"
,
"Binary Editor"
)
;
//actions
const
char
*
const
UNDO
=
"QtCreator.Undo"
;
...
...
src/plugins/cppeditor/cppeditorconstants.h
View file @
bb900dd8
...
...
@@ -36,7 +36,7 @@ namespace Constants {
const
char
*
const
FORMATCODE
=
"CppEditor.FormatCode"
;
const
char
*
const
M_CONTEXT
=
"CppEditor.ContextMenu"
;
const
char
*
const
C_CPPEDITOR
=
"C++ Editor"
;
const
char
*
const
CPPEDITOR_KIND
=
"C++ Editor"
;
const
char
*
const
CPPEDITOR_KIND
=
QT_TRANSLATE_NOOP
(
"OpenWith::Editors"
,
"C++ Editor"
)
;
const
char
*
const
SWITCH_DECLARATION_DEFINITION
=
"CppEditor.SwitchDeclarationDefinition"
;
const
char
*
const
JUMP_TO_DEFINITION
=
"CppEditor.JumpToDefinition"
;
...
...
src/plugins/cpptools/cppmodelmanager.cpp
View file @
bb900dd8
...
...
@@ -372,6 +372,14 @@ protected:
}
virtual
bool
visit
(
TypenameTypeParameterAST
*
ast
)
{
if
(
NameAST
*
nameAst
=
ast
->
name
)
addType
(
nameAst
->
name
);
return
true
;
}
virtual
bool
visit
(
TemplateTypeParameterAST
*
ast
)
{
if
(
ast
->
name
)
addType
(
ast
->
name
->
name
);
...
...
src/plugins/find/findplugin.cpp
View file @
bb900dd8
...
...
@@ -163,7 +163,7 @@ void FindPlugin::setupMenu()
cmd
=
am
->
registerAction
(
separator
,
QLatin1String
(
"Find.Sep.Actions"
),
globalcontext
);
mfind
->
addAction
(
cmd
,
Constants
::
G_FIND_ACTIONS
);
m_openFindDialog
=
new
QAction
(
tr
(
"Find
Dialog
"
),
this
);
m_openFindDialog
=
new
QAction
(
tr
(
"Find
...
"
),
this
);
cmd
=
am
->
registerAction
(
m_openFindDialog
,
QLatin1String
(
"Find.Dialog"
),
globalcontext
);
cmd
->
setDefaultKeySequence
(
QKeySequence
(
tr
(
"Ctrl+Shift+F"
)));
mfind
->
addAction
(
cmd
,
Constants
::
G_FIND_FILTERS
);
...
...
src/plugins/projectexplorer/projectexplorer.cpp
View file @
bb900dd8
...
...
@@ -1917,7 +1917,7 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
// Add all suitable editors
foreach
(
Core
::
IEditorFactory
*
editorFactory
,
factories
)
{
// Add action to open with this very editor factory
QString
const
actionTitle
(
editorFactory
->
kind
());
QString
const
actionTitle
=
qApp
->
translate
(
"OpenWith::Editors"
,
editorFactory
->
kind
()
.
toAscii
()
);
QAction
*
const
action
=
m_openWithMenu
->
addAction
(
actionTitle
);
action
->
setData
(
qVariantFromValue
(
editorFactory
));
// File already open in an editor -> only enable that entry since
...
...
@@ -1934,7 +1934,7 @@ void ProjectExplorerPlugin::populateOpenWithMenu()
}
// for editor factories
// Add all suitable external editors
foreach
(
Core
::
IExternalEditor
*
externalEditor
,
externalEditors
)
{
QAction
*
const
action
=
m_openWithMenu
->
addAction
(
externalEditor
->
kind
());
QAction
*
const
action
=
m_openWithMenu
->
addAction
(
qApp
->
translate
(
"OpenWith::Editors"
,
externalEditor
->
kind
()
.
toAscii
())
);
action
->
setData
(
qVariantFromValue
(
externalEditor
));
}
}
// matches
...
...
src/plugins/qt4projectmanager/qt4projectmanagerconstants.h
View file @
bb900dd8
...
...
@@ -39,7 +39,7 @@ const char * const C_PROFILEEDITOR_PANEL = ".pro File Editor (embedded)";
// kinds
const
char
*
const
PROJECT_KIND
=
"Qt4"
;
const
char
*
const
PROFILE_EDITOR
=
".pro File Editor"
;
const
char
*
const
PROFILE_EDITOR
=
QT_TRANSLATE_NOOP
(
"OpenWith::Editors"
,
".pro File Editor"
)
;
const
char
*
const
PROFILE_MIMETYPE
=
"application/vnd.nokia.qt.qmakeprofile"
;
const
char
*
const
PROINCLUDEFILE_MIMETYPE
=
"application/vnd.nokia.qt.qmakeproincludefile"
;
const
char
*
const
CPP_SOURCE_MIMETYPE
=
"text/x-c++src"
;
...
...
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