Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
96940fa9
Commit
96940fa9
authored
Jul 27, 2009
by
Friedemann Kleint
Browse files
Gitorious wizard: Import CMake projects, look in src directory.
Remove unused code.
parent
f3a04e7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/plugins/git/gitorious/gitorioushostwidget.cpp
View file @
96940fa9
...
...
@@ -46,8 +46,6 @@
enum
{
debug
=
0
};
enum
{
NewDummyEntryRole
=
Qt
::
UserRole
+
1
};
namespace
Gitorious
{
namespace
Internal
{
...
...
@@ -164,9 +162,7 @@ void GitoriousHostWidget::selectRow(int r)
void
GitoriousHostWidget
::
appendNewDummyEntry
()
{
// Append a new entry where a host name is editable
const
QList
<
QStandardItem
*>
dummyRow
=
hostEntry
(
m_newHost
,
0
,
QString
(),
true
);
dummyRow
.
front
()
->
setData
(
QVariant
(
true
),
NewDummyEntryRole
);
m_model
->
appendRow
(
dummyRow
);
m_model
->
appendRow
(
hostEntry
(
m_newHost
,
0
,
QString
(),
true
));
}
void
GitoriousHostWidget
::
slotItemEdited
(
QStandardItem
*
item
)
...
...
@@ -180,7 +176,6 @@ void GitoriousHostWidget::slotItemEdited(QStandardItem *item)
case
HostNameColumn
:
if
(
isDummyEntry
)
{
Gitorious
::
instance
().
addHost
(
item
->
text
(),
m_model
->
item
(
row
,
DescriptionColumn
)
->
text
());
item
->
setData
(
QVariant
(
false
),
NewDummyEntryRole
);
m_isHostListDirty
=
true
;
appendNewDummyEntry
();
selectRow
(
row
);
...
...
src/plugins/git/gitorious/gitoriousprojectwizardpage.cpp
View file @
96940fa9
...
...
@@ -68,11 +68,12 @@ void GitoriousProjectWizardPage::initializePage()
{
// Try to find the page by hostindex
const
int
hostIndex
=
m_hostPage
->
selectedHostIndex
();
const
int
existingStackIndex
=
hostIndexToStackIndex
(
hostIndex
);
const
QString
hostName
=
Gitorious
::
instance
().
hostName
(
hostIndex
);
const
int
existingStackIndex
=
stackIndexOf
(
hostName
);
// Found? - pop up that page
if
(
existingStackIndex
!=
-
1
)
{
m_stackedWidget
->
setCurrentIndex
(
existingStackIndex
);
setSubTitle
(
msgChooseProject
(
selectedH
ostName
()
));
setSubTitle
(
msgChooseProject
(
h
ostName
));
return
;
}
// Add a new page
...
...
@@ -119,12 +120,12 @@ GitoriousProjectWidget *GitoriousProjectWizardPage::currentProjectWidget() const
return
projectWidgetAt
(
index
);
}
// Convert a host
index
to a stack index.
int
GitoriousProjectWizardPage
::
hostIndexToStackIndex
(
int
hostIndex
)
const
// Convert a host
name
to a stack index.
int
GitoriousProjectWizardPage
::
stackIndexOf
(
const
QString
&
hostName
)
const
{
const
int
count
=
m_stackedWidget
->
count
();
for
(
int
i
=
0
;
i
<
count
;
i
++
)
if
(
projectWidgetAt
(
i
)
->
host
Index
()
==
host
Index
)
if
(
projectWidgetAt
(
i
)
->
host
Name
()
==
host
Name
)
return
i
;
return
-
1
;
}
...
...
src/plugins/git/gitorious/gitoriousprojectwizardpage.h
View file @
96940fa9
...
...
@@ -74,7 +74,7 @@ private slots:
private:
GitoriousProjectWidget
*
projectWidgetAt
(
int
index
)
const
;
GitoriousProjectWidget
*
currentProjectWidget
()
const
;
int
hostIndexToStackIndex
(
int
hostIndex
)
const
;
int
stackIndexOf
(
const
QString
&
hostName
)
const
;
const
GitoriousHostWizardPage
*
m_hostPage
;
QStackedWidget
*
m_stackedWidget
;
...
...
src/plugins/vcsbase/basecheckoutwizard.cpp
View file @
96940fa9
...
...
@@ -109,6 +109,36 @@ QStringList BaseCheckoutWizard::runWizard(const QString &path, QWidget *parent)
return
QStringList
(
projectFile
);
}
static
inline
QString
msgNoProjectFiles
(
const
QDir
&
dir
,
const
QStringList
&
patterns
)
{
return
BaseCheckoutWizard
::
tr
(
"Could not find any project files matching (%1) in the directory '%2'."
).
arg
(
patterns
.
join
(
QLatin1String
(
", "
)),
dir
.
absolutePath
());
}
// Try to find the project files in a project directory with some smartness
static
QFileInfoList
findProjectFiles
(
const
QDir
&
projectDir
,
QString
*
errorMessage
)
{
// Hardcoded: Find *.pro/Cmakefiles
QStringList
projectFilePatterns
;
projectFilePatterns
<<
QLatin1String
(
"*.pro"
)
<<
QLatin1String
(
"CMakeLists.txt"
);
// Project directory
QFileInfoList
projectFiles
=
projectDir
.
entryInfoList
(
projectFilePatterns
,
QDir
::
Files
|
QDir
::
NoDotAndDotDot
|
QDir
::
Readable
);
if
(
!
projectFiles
.
empty
())
return
projectFiles
;
// Try a 'src' directory
QFileInfoList
srcDirs
=
projectDir
.
entryInfoList
(
QStringList
(
QLatin1String
(
"src"
)),
QDir
::
Dirs
|
QDir
::
NoDotAndDotDot
|
QDir
::
Readable
);
if
(
srcDirs
.
empty
())
{
*
errorMessage
=
msgNoProjectFiles
(
projectDir
,
projectFilePatterns
);
return
QFileInfoList
();
}
const
QDir
srcDir
=
QDir
(
srcDirs
.
front
().
absoluteFilePath
());
projectFiles
=
srcDir
.
entryInfoList
(
projectFilePatterns
,
QDir
::
Files
|
QDir
::
NoDotAndDotDot
|
QDir
::
Readable
);
if
(
projectFiles
.
empty
())
{
*
errorMessage
=
msgNoProjectFiles
(
srcDir
,
projectFilePatterns
);
return
QFileInfoList
();
}
return
projectFiles
;;
}
QString
BaseCheckoutWizard
::
openProject
(
const
QString
&
path
,
QString
*
errorMessage
)
{
ProjectExplorer
::
ProjectExplorerPlugin
*
pe
=
ProjectExplorer
::
ProjectExplorerPlugin
::
instance
();
...
...
@@ -123,15 +153,10 @@ QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessa
*
errorMessage
=
tr
(
"'%1' does not exist."
).
arg
(
path
);
// Should not happen
return
QString
();
}
// Hardcoded: Find *.pro/Cmakefiles
QStringList
patterns
;
patterns
<<
QLatin1String
(
"*.pro"
)
<<
QLatin1String
(
"CMakeList.txt"
);
QFileInfoList
projectFiles
=
dir
.
entryInfoList
(
patterns
,
QDir
::
Files
|
QDir
::
NoDotAndDotDot
|
QDir
::
Readable
);
if
(
projectFiles
.
empty
())
{
*
errorMessage
=
tr
(
"No project files could be found (%1)."
).
arg
(
patterns
.
join
(
QLatin1String
(
", "
)));
QFileInfoList
projectFiles
=
findProjectFiles
(
dir
,
errorMessage
);
if
(
projectFiles
.
empty
())
return
QString
();
}
// Open!
// Open. Do not use a busy cursor here as additional wizards might pop up
const
QString
projectFile
=
projectFiles
.
front
().
absoluteFilePath
();
if
(
!
pe
->
openProject
(
projectFile
))
{
*
errorMessage
=
tr
(
"Unable to open the project '%1'."
).
arg
(
projectFile
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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