Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

This commit is contained in:
Kavindra Palaraja
2009-01-16 16:57:07 +01:00
22 changed files with 582 additions and 597 deletions
+2 -2
View File
@@ -222,8 +222,8 @@
\table
\row
\i Block navigation
\i To navigate between blocks, e.g., from one \c{\{} to another
\c{\c}}, use \key{Ctrl+[} and \key{Ctrl+]}.
\i To navigate between blocks, e.g., from one \bold{\{} to another
\bold{\}} , use \key{Ctrl+[} and \key{Ctrl+]}.
\row
\i Block selection
\i To select a current block, use \key{Ctrl+U}. Pressing
+1 -1
View File
@@ -563,7 +563,7 @@ TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const
}
/* Returns the current session. */
SessionManager* BookmarkManager::sessionManager() const
SessionManager *BookmarkManager::sessionManager() const
{
ExtensionSystem::PluginManager *pm = m_core->pluginManager();
ProjectExplorerPlugin *pe = pm->getObject<ProjectExplorerPlugin>();
@@ -215,11 +215,6 @@ ProjectExplorer::IProjectManager *CMakeProject::projectManager() const
return m_manager;
}
QList<Core::IFile *> CMakeProject::dependencies()
{
return QList<Core::IFile *>();
}
QList<ProjectExplorer::Project *> CMakeProject::dependsOn()
{
return QList<Project *>();
@@ -73,7 +73,6 @@ public:
virtual Core::IFile *file() const;
virtual ProjectExplorer::IProjectManager *projectManager() const;
virtual QList<Core::IFile *> dependencies(); //NBS TODO remove
virtual QList<ProjectExplorer::Project *> dependsOn(); //NBS TODO implement dependsOn
virtual bool isApplication() const;
+204 -135
View File
@@ -128,6 +128,12 @@ enum VisualMode
VisualBlockMode,
};
enum MoveType
{
MoveExclusive,
MoveInclusive,
};
struct EditOperation
{
EditOperation() : m_position(-1), m_itemCount(0) {}
@@ -137,17 +143,23 @@ struct EditOperation
QString m_to;
};
QDebug &operator<<(QDebug &ts, const EditOperation &op)
static QDebug &operator<<(QDebug &ts, const EditOperation &op)
{
if (op.m_itemCount > 0) {
ts << "EDIT BLOCK WITH" << op.m_itemCount << "ITEMS";
ts << "\n EDIT BLOCK WITH " << op.m_itemCount << " ITEMS";
} else {
ts << "EDIT AT " << op.m_position
<< " FROM " << op.m_from << " TO " << op.m_to;
ts << "\n EDIT AT " << op.m_position
<< "\n FROM " << op.m_from << "\n TO " << op.m_to;
}
return ts;
}
int lineCount(const QString &text)
{
//return text.count(QChar(ParagraphSeparator));
return text.count(QChar('\n'));
}
class FakeVimHandler::Private
{
public:
@@ -206,26 +218,29 @@ private:
// to reduce line noise
typedef QTextCursor::MoveOperation MoveOperation;
typedef QTextCursor::MoveMode MoveMode;
void moveToEndOfDocument(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::End, m, n); }
void moveToStartOfLine(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::StartOfLine, m, n); }
void moveToEndOfLine(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::EndOfLine, m, n); }
void moveUp(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::Up, m, n); }
void moveDown(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::Down, m, n); }
void moveRight(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::Right, m, n); }
void moveLeft(MoveMode m, int n = 1)
{ m_tc.movePosition(QTextCursor::Left, m, n); }
void moveToEndOfDocument()
{ m_tc.movePosition(QTextCursor::End, MoveAnchor); }
void moveToStartOfLine()
{ m_tc.movePosition(QTextCursor::StartOfLine, MoveAnchor); }
void moveToEndOfLine()
{ m_tc.movePosition(QTextCursor::EndOfLine, MoveAnchor); }
void moveUp(int n = 1)
{ m_tc.movePosition(QTextCursor::Up, MoveAnchor, n); }
void moveDown(int n = 1)
{ m_tc.movePosition(QTextCursor::Down, MoveAnchor, n); }
void moveRight(int n = 1)
{ m_tc.movePosition(QTextCursor::Right, MoveAnchor, n); }
void moveLeft(int n = 1)
{ m_tc.movePosition(QTextCursor::Left, MoveAnchor, n); }
void setAnchor() { m_anchor = m_tc.position(); }
QString selectedText() const;
void handleFfTt(int key);
// helper function for handleCommand. return 1 based line index.
int readLineCode(QString &cmd);
QTextCursor selectRange(int beginLine, int endLine);
void selectRange(int beginLine, int endLine);
void setWidget(QWidget *ob);
void enterInsertMode();
@@ -250,10 +265,12 @@ public:
int m_subsubdata;
QString m_input;
QTextCursor m_tc;
int m_anchor;
QHash<int, QString> m_registers;
int m_register;
QString m_mvcount;
QString m_opcount;
MoveType m_moveType;
bool m_fakeEnd;
@@ -277,9 +294,11 @@ public:
void recordRemoveNextChar();
void recordInsertText(const QString &data);
void recordRemoveSelectedText();
QString recordRemoveSelectedText();
void recordBeginGroup();
void recordEndGroup();
int anchor() const { return m_anchor; }
int position() const { return m_tc.position(); }
void undo();
void redo();
@@ -331,6 +350,7 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
m_plaintextedit = 0;
m_visualMode = NoVisualMode;
m_desiredColumn = 0;
m_moveType = MoveInclusive;
m_config[ConfigStartOfLine] = ConfigOn;
m_config[ConfigTabStop] = "8";
@@ -403,9 +423,9 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
{
if (m_submode == FilterSubMode) {
int beginLine = lineForPosition(m_tc.anchor());
int endLine = lineForPosition(m_tc.position());
m_tc.setPosition(qMin(m_tc.anchor(), m_tc.position()));
int beginLine = lineForPosition(anchor());
int endLine = lineForPosition(position());
m_tc.setPosition(qMin(anchor(), position()));
m_mode = ExMode;
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
m_commandHistory.append(QString());
@@ -420,16 +440,16 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (m_submode == ChangeSubMode) {
if (!dotCommand.isEmpty())
m_dotCommand = "c" + dotCommand;
m_registers[m_register] = m_tc.selectedText();
recordRemoveSelectedText();
QString text = recordRemoveSelectedText();
qDebug() << "CHANGING TO INSERT MODE" << text;
m_registers[m_register] = text;
m_mode = InsertMode;
m_submode = NoSubMode;
} else if (m_submode == DeleteSubMode) {
if (!dotCommand.isEmpty())
m_dotCommand = "d" + dotCommand;
recordRemove(qMin(m_tc.position(), m_tc.anchor()), m_tc.selectedText());
m_registers[m_register] = m_tc.selectedText();
recordRemoveSelectedText();
m_registers[m_register] = recordRemoveSelectedText();
recordEndGroup();
m_submode = NoSubMode;
if (atEol())
moveLeft(MoveAnchor);
@@ -450,6 +470,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
m_tc.setPosition(startBlock.position());
moveToFirstNonBlankOnLine();
m_submode = NoSubMode;
} else if (m_moveType == MoveExclusive) {
moveLeft(); // correct
}
m_mvcount.clear();
m_opcount.clear();
@@ -594,26 +616,31 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
m_register = key;
m_submode = NoSubMode;
} else if (m_submode == ChangeSubMode && key == 'c') {
moveToStartOfLine(MoveAnchor);
moveDown(KeepAnchor, count());
m_registers[m_register] = m_tc.selectedText();
moveToStartOfLine();
setAnchor();
moveDown(count());
moveLeft();
m_registers[m_register] = recordRemoveSelectedText();
m_submode = NoSubMode;
m_mode = InsertMode;
finishMovement("c");
} else if (m_submode == DeleteSubMode && key == 'd') {
moveToStartOfLine(MoveAnchor);
moveDown(KeepAnchor, count());
m_registers[m_register] = m_tc.selectedText();
moveToStartOfLine();
setAnchor();
moveDown(count());
m_registers[m_register] = recordRemoveSelectedText();
finishMovement("d");
} else if (m_submode == YankSubMode && key == 'y') {
moveToStartOfLine(MoveAnchor);
moveDown(KeepAnchor, count());
m_registers[m_register] = m_tc.selectedText();
moveToStartOfLine();
moveDown(count());
m_registers[m_register] = selectedText();
finishMovement();
} else if (m_submode == ReplaceSubMode) {
if (atEol())
moveLeft(KeepAnchor);
else
m_tc.deleteChar();
m_tc.insertText(text);
recordInsertText(text);
} else if (m_submode == IndentSubMode && key == '=') {
indentRegion(m_tc.block(), m_tc.block().next());
finishMovement();
@@ -679,8 +706,9 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == '\'') {
m_subsubmode = TickSubSubMode;
} else if (key == '|') {
moveToStartOfLine(KeepAnchor);
moveRight(KeepAnchor, qMin(count(), rightDist()) - 1);
setAnchor();
moveToStartOfLine();
moveRight(qMin(count(), rightDist()) - 1);
finishMovement();
} else if (key == '!' && m_visualMode == NoVisualMode) {
m_submode = FilterSubMode;
@@ -693,16 +721,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == '"') {
m_submode = RegisterSubMode;
} else if (unmodified == Key_Return) {
moveToStartOfLine(MoveAnchor);
moveDown(MoveAnchor);
moveToStartOfLine();
moveDown();
moveToFirstNonBlankOnLine();
finishMovement();
} else if (key == Key_Home) {
m_tc.movePosition(StartOfLine, KeepAnchor);
moveToStartOfLine();
finishMovement();
} else if (key == '$' || key == Key_End) {
int submode = m_submode;
moveToEndOfLine(KeepAnchor);
moveToEndOfLine();
finishMovement();
if (submode == NoSubMode)
m_desiredColumn = -1;
@@ -722,12 +750,14 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
finishMovement();
} else if (key == 'a') {
m_mode = InsertMode;
recordBeginGroup();
m_lastInsertion.clear();
m_tc.movePosition(Right, MoveAnchor, 1);
moveRight();
updateMiniBuffer();
} else if (key == 'A') {
m_mode = InsertMode;
moveToEndOfLine(MoveAnchor);
moveToEndOfLine();
recordBeginGroup();
m_lastInsertion.clear();
} else if (key == 'b') {
moveToWordBoundary(false, false);
@@ -736,30 +766,41 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
moveToWordBoundary(true, false);
finishMovement();
} else if (key == 'c') {
setAnchor();
recordBeginGroup();
m_submode = ChangeSubMode;
} else if (key == 'C') {
m_submode = ChangeSubMode;
moveToEndOfLine(KeepAnchor);
setAnchor();
recordBeginGroup();
moveToEndOfLine();
m_registers[m_register] = recordRemoveSelectedText();
m_mode = InsertMode;
finishMovement();
} else if (key == 'd' && m_visualMode == NoVisualMode) {
if (atEol())
moveLeft(MoveAnchor);
moveLeft();
setAnchor();
recordBeginGroup();
m_opcount = m_mvcount;
m_mvcount.clear();
m_submode = DeleteSubMode;
} else if (key == 'd') {
setAnchor();
leaveVisualMode();
int beginLine = lineForPosition(m_marks['<']);
int endLine = lineForPosition(m_marks['>']);
m_tc = selectRange(beginLine, endLine);
selectRange(beginLine, endLine);
recordRemoveSelectedText();
} else if (key == 'D') {
setAnchor();
recordBeginGroup();
m_submode = DeleteSubMode;
moveDown(KeepAnchor, qMax(count() - 1, 0));
moveRight(KeepAnchor, rightDist());
moveDown(qMax(count() - 1, 0));
moveRight(rightDist());
finishMovement();
} else if (key == 'e') {
moveToWordBoundary(false, true);
m_moveType = MoveExclusive;
finishMovement();
} else if (key == 'E') {
moveToWordBoundary(true, true);
@@ -775,15 +816,16 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
if (m_config[ConfigStartOfLine] == ConfigOn)
moveToFirstNonBlankOnLine();
finishMovement();
} else if (key == 'h' || key == Key_Left) {
} else if (key == 'h' || key == Key_Left
|| key == Key_Backspace || key == control('h')) {
int n = qMin(count(), leftDist());
if (m_fakeEnd && m_tc.block().length() > 1)
++n;
moveLeft(KeepAnchor, n);
moveLeft(n);
finishMovement();
} else if (key == 'H') {
m_tc = EDITOR(cursorForPosition(QPoint(0, 0)));
moveDown(KeepAnchor, qMax(count() - 1, 0));
moveDown(qMax(count() - 1, 0));
moveToFirstNonBlankOnLine();
finishMovement();
} else if (key == 'i') {
@@ -792,20 +834,21 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
if (atEol())
moveLeft(MoveAnchor);
} else if (key == 'I') {
setAnchor();
enterInsertMode();
if (m_gflag)
moveToStartOfLine(KeepAnchor);
moveToStartOfLine();
else
moveToFirstNonBlankOnLine();
} else if (key == 'j' || key == Key_Down) {
int savedColumn = m_desiredColumn;
if (m_submode == NoSubMode || m_submode == ZSubMode
|| m_submode == RegisterSubMode) {
moveDown(KeepAnchor, count());
moveDown(count());
moveToDesiredColumn();
} else {
moveToStartOfLine(MoveAnchor);
moveDown(KeepAnchor, count() + 1);
moveToStartOfLine();
moveDown(count() + 1);
}
finishMovement();
m_desiredColumn = savedColumn;
@@ -813,33 +856,34 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
recordBeginGroup();
if (m_submode == NoSubMode) {
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
moveToEndOfLine(MoveAnchor);
moveToEndOfLine();
recordRemoveNextChar();
if (!m_gflag)
recordInsertText(" ");
}
if (!m_gflag)
moveLeft(MoveAnchor, 1);
moveLeft();
}
recordEndGroup();
} else if (key == 'k' || key == Key_Up) {
int savedColumn = m_desiredColumn;
if (m_submode == NoSubMode || m_submode == ZSubMode || m_submode == RegisterSubMode) {
moveUp(KeepAnchor, count());
if (m_submode == NoSubMode || m_submode == ZSubMode
|| m_submode == RegisterSubMode) {
moveUp(count());
moveToDesiredColumn();
} else {
moveToStartOfLine(MoveAnchor);
moveDown(MoveAnchor);
moveUp(KeepAnchor, count() + 1);
moveToStartOfLine();
moveDown();
moveUp(count() + 1);
}
finishMovement();
m_desiredColumn = savedColumn;
} else if (key == 'l' || key == Key_Right) {
moveRight(KeepAnchor, qMin(count(), rightDist()));
moveRight(qMin(count(), rightDist()));
finishMovement();
} else if (key == 'L') {
m_tc = EDITOR(cursorForPosition(QPoint(0, EDITOR(height()))));
moveUp(KeepAnchor, qMax(count(), 1));
moveUp(qMax(count(), 1));
moveToFirstNonBlankOnLine();
finishMovement();
} else if (key == 'm') {
@@ -855,45 +899,52 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'o' || key == 'O') {
enterInsertMode();
moveToFirstNonBlankOnLine();
recordBeginGroup();
int numSpaces = leftDist();
moveUp(MoveAnchor, 1);
moveUp();
if (key == 'o')
m_tc.movePosition(Down, MoveAnchor, 1);
moveToEndOfLine(MoveAnchor);
m_tc.insertText("\n");
moveToStartOfLine(MoveAnchor);
moveDown();
moveToEndOfLine();
recordInsertText("\n");
moveToStartOfLine();
if (m_config[ConfigAutoIndent] == ConfigOn)
m_tc.insertText(QString(indentDist(), ' '));
recordInsertText(QString(indentDist(), ' '));
else
m_tc.insertText(QString(numSpaces, ' '));
recordInsertText(QString(numSpaces, ' '));
recordEndGroup();
} else if (key == 'p' || key == 'P') {
recordBeginGroup();
QString text = m_registers[m_register];
int n = text.count(QChar(ParagraphSeparator));
if (n > 0) {
m_tc.movePosition(StartOfLine);
moveToStartOfLine();
if (key == 'p')
m_tc.movePosition(Down);
m_tc.insertText(text);
m_tc.movePosition(Up, MoveAnchor, n);
moveDown(MoveAnchor);
recordInsertText(text);
moveUp(n);
} else {
if (key == 'p')
m_tc.movePosition(Right);
m_tc.insertText(text);
m_tc.movePosition(Left);
moveRight();
recordInsertText(text);
moveLeft();
}
recordEndGroup();
m_dotCommand = "p";
} else if (key == 'r') {
recordBeginGroup();
m_submode = ReplaceSubMode;
m_dotCommand = "r";
} else if (key == 'R') {
recordBeginGroup();
m_mode = InsertMode;
m_submode = ReplaceSubMode;
m_dotCommand = "R";
} else if (key == control('r')) {
redo();
} else if (key == 's') {
recordBeginGroup();
m_submode = ChangeSubMode;
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
moveRight(qMin(count(), rightDist()));
} else if (key == 't' || key == 'T') {
m_subsubmode = FtSubSubMode;
m_subsubdata = key;
@@ -910,7 +961,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == control('v')) {
enterVisualMode(VisualBlockMode);
} else if (key == 'w') {
moveToNextWord(false);
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the
// cursor is on a non-blank.
if (m_submode == ChangeSubMode)
moveToWordBoundary(false, true);
else
moveToNextWord(false);
m_moveType = MoveExclusive;
finishMovement("w");
} else if (key == 'W') {
moveToNextWord(true);
@@ -918,38 +975,42 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
} else if (key == 'x') { // = "dl"
if (atEol())
moveLeft(MoveAnchor);
recordBeginGroup();
m_submode = DeleteSubMode;
moveRight(KeepAnchor, qMin(count(), rightDist()));
moveRight(qMin(count(), rightDist()));
finishMovement("l");
} else if (key == 'X') {
if (leftDist() > 0) {
moveLeft(KeepAnchor, qMin(count(), leftDist()));
m_tc.deleteChar();
setAnchor();
moveLeft(qMin(count(), leftDist()));
recordRemoveSelectedText();
}
finishMovement();
} else if (key == 'y') {
if (atEol())
moveLeft(MoveAnchor);
moveLeft();
recordBeginGroup();
m_submode = YankSubMode;
} else if (key == 'z') {
recordBeginGroup();
m_submode = ZSubMode;
} else if (key == '~' && !atEol()) {
moveRight(KeepAnchor, qMin(count(), rightDist()));
QString str = m_tc.selectedText();
recordBeginGroup();
setAnchor();
moveRight(qMin(count(), rightDist()));
QString str = recordRemoveSelectedText();
for (int i = str.size(); --i >= 0; ) {
QChar c = str.at(i);
str[i] = c.isUpper() ? c.toLower() : c.toUpper();
}
m_tc.deleteChar();
m_tc.insertText(str);
recordInsertText(str);
recordEndGroup();
} else if (key == Key_PageDown || key == control('f')) {
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
moveDown(count() * (linesOnScreen() - 2));
finishMovement();
} else if (key == Key_PageUp || key == control('b')) {
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
moveUp(count() * (linesOnScreen() - 2));
finishMovement();
} else if (key == Key_Backspace || key == control('h')) {
m_tc.deletePreviousChar();
} else if (key == Key_Delete) {
m_tc.deleteChar();
} else if (key == Key_Escape) {
@@ -975,21 +1036,23 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
data += m_lastInsertion;
}
recordInsert(m_tc.position() - m_lastInsertion.size(), data);
moveLeft(MoveAnchor, qMin(1, leftDist()));
recordEndGroup();
//qDebug() << "UNDO: " << m_undoStack;
moveLeft(qMin(1, leftDist()));
enterCommandMode();
} else if (key == Key_Left) {
moveLeft(MoveAnchor, count());
moveLeft(count());
m_lastInsertion.clear();
} else if (key == Key_Down) {
m_submode = NoSubMode;
moveDown(MoveAnchor, count());
moveDown(count());
m_lastInsertion.clear();
} else if (key == Key_Up) {
m_submode = NoSubMode;
moveUp(MoveAnchor, count());
moveUp(count());
m_lastInsertion.clear();
} else if (key == Key_Right) {
moveRight(MoveAnchor, count());
moveRight(count());
m_lastInsertion.clear();
} else if (key == Key_Return) {
m_submode = NoSubMode;
@@ -1003,10 +1066,10 @@ bool FakeVimHandler::Private::handleInsertMode(int key, int, const QString &text
m_tc.deleteChar();
m_lastInsertion.clear();
} else if (key == Key_PageDown || key == control('f')) {
moveDown(KeepAnchor, count() * (linesOnScreen() - 2));
moveDown(count() * (linesOnScreen() - 2));
m_lastInsertion.clear();
} else if (key == Key_PageUp || key == control('b')) {
moveUp(KeepAnchor, count() * (linesOnScreen() - 2));
moveUp(count() * (linesOnScreen() - 2));
m_lastInsertion.clear();
} else if (key == Key_Tab && m_config[ConfigExpandTab] == ConfigOn) {
QString str = QString(m_config[ConfigTabStop].toInt(), ' ');
@@ -1173,17 +1236,15 @@ int FakeVimHandler::Private::readLineCode(QString &cmd)
return -1;
}
QTextCursor FakeVimHandler::Private::selectRange(int beginLine, int endLine)
void FakeVimHandler::Private::selectRange(int beginLine, int endLine)
{
QTextCursor tc = m_tc;
tc.setPosition(positionForLine(beginLine), MoveAnchor);
m_tc.setPosition(positionForLine(beginLine), MoveAnchor);
if (endLine == linesInDocument()) {
tc.setPosition(positionForLine(endLine), KeepAnchor);
tc.movePosition(EndOfLine, KeepAnchor);
m_tc.setPosition(positionForLine(endLine), KeepAnchor);
m_tc.movePosition(EndOfLine, KeepAnchor);
} else {
tc.setPosition(positionForLine(endLine + 1), KeepAnchor);
m_tc.setPosition(positionForLine(endLine + 1), KeepAnchor);
}
return tc;
}
void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
@@ -1223,11 +1284,11 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
beginLine = cursorLineInDocument();
if (endLine == -1)
endLine = cursorLineInDocument();
QTextCursor tc = selectRange(beginLine, endLine);
selectRange(beginLine, endLine);
QString reg = reDelete.cap(2);
QString text = recordRemoveSelectedText();
if (!reg.isEmpty())
m_registers[reg.at(0).unicode()] = tc.selection().toPlainText();
tc.removeSelectedText();
m_registers[reg.at(0).unicode()] = text;
} else if (reWrite.indexIn(cmd) != -1) { // :w
enterCommandMode();
bool noArgs = (beginLine == -1);
@@ -1245,9 +1306,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
if (exists && !forced && !noArgs) {
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
} else if (file.open(QIODevice::ReadWrite)) {
QTextCursor tc = selectRange(beginLine, endLine);
QString contents = tc.selection().toPlainText();
emit q->writeFile(fileName, contents);
selectRange(beginLine, endLine);
emit q->writeFile(fileName, selectedText());
// check by reading back
file.open(QIODevice::ReadOnly);
QByteArray ba = file.readAll();
@@ -1272,10 +1332,10 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
beginLine = cursorLineInDocument();
if (endLine == -1)
endLine = cursorLineInDocument();
QTextCursor tc = selectRange(beginLine, endLine);
QString text = tc.selection().toPlainText();
tc.removeSelectedText();
selectRange(beginLine, endLine);
QString command = cmd.mid(1).trimmed();
recordBeginGroup();
QString text = recordRemoveSelectedText();
QProcess proc;
proc.start(cmd.mid(1));
proc.waitForStarted();
@@ -1283,7 +1343,8 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
proc.closeWriteChannel();
proc.waitForFinished();
QString result = QString::fromUtf8(proc.readAllStandardOutput());
m_tc.insertText(result);
recordInsertText(result);
recordEndGroup();
leaveVisualMode();
m_tc.setPosition(positionForLine(beginLine));
@@ -1357,8 +1418,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
EDITOR(setTextCursor(m_tc));
if (EDITOR(find(needle, flags))) {
m_tc = EDITOR(textCursor());
// the qMax seems to be needed for QPlainTextEdit only
//m_tc.movePosition(Left, MoveAnchor, qMax(1, needle.size() - 1));
m_tc.setPosition(m_tc.anchor());
return;
}
@@ -1367,8 +1426,6 @@ void FakeVimHandler::Private::search(const QString &needle0, bool forward)
EDITOR(setTextCursor(m_tc));
if (EDITOR(find(needle, flags))) {
m_tc = EDITOR(textCursor());
// the qMax seems to be needed for QPlainTextEdit only
//m_tc.movePosition(Left, MoveAnchor, qMax(1, needle.size() - 1));
m_tc.setPosition(m_tc.anchor());
if (forward)
showRedMessage("search hit BOTTOM, continuing at TOP");
@@ -1474,17 +1531,15 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
int repeat = count();
QTextDocument *doc = m_tc.document();
int n = forward ? lastPositionInDocument() - 1 : 0;
int lastClass = 0;
int lastClass = -1;
while (true) {
m_tc.movePosition(forward ? Right : Left, KeepAnchor, 1);
forward ? moveRight() : moveLeft();
QChar c = doc->characterAt(m_tc.position());
int thisClass = charClass(c, simple);
if (thisClass != lastClass && lastClass != 0)
--repeat;
if (repeat == -1) {
m_tc.movePosition(forward ? Left : Right, KeepAnchor, 1);
if (repeat == -1)
break;
}
lastClass = thisClass;
if (m_tc.position() == n)
break;
@@ -1547,7 +1602,7 @@ void FakeVimHandler::Private::moveToNextWord(bool simple)
if (repeat == 0)
break;
lastClass = thisClass;
m_tc.movePosition(Right, KeepAnchor, 1);
moveRight();
if (m_tc.position() == n)
break;
}
@@ -1643,6 +1698,13 @@ QString FakeVimHandler::Private::lastSearchString() const
return m_searchHistory.empty() ? QString() : m_searchHistory.back();
}
QString FakeVimHandler::Private::selectedText() const
{
QTextCursor tc = m_tc;
tc.setPosition(m_anchor, KeepAnchor);
return tc.selection().toPlainText();
}
int FakeVimHandler::Private::positionForLine(int line) const
{
return m_tc.block().document()->findBlockByNumber(line - 1).position();
@@ -1738,6 +1800,7 @@ void FakeVimHandler::Private::redo()
void FakeVimHandler::Private::recordBeginGroup()
{
//qDebug() << "PUSH";
m_undoGroupStack.push(m_undoStack.size());
}
@@ -1745,22 +1808,27 @@ void FakeVimHandler::Private::recordEndGroup()
{
EditOperation op;
op.m_itemCount = m_undoStack.size() - m_undoGroupStack.pop();
//qDebug() << "POP " << op.m_itemCount;
recordOperation(op);
}
void FakeVimHandler::Private::recordRemoveSelectedText()
QString FakeVimHandler::Private::recordRemoveSelectedText()
{
EditOperation op;
op.m_position = qMin(m_tc.position(), m_tc.anchor());
//qDebug() << "1 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor();
m_tc.setPosition(anchor(), KeepAnchor);
op.m_position = qMin(position(), anchor());
//qDebug() << "2 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor();
op.m_from = m_tc.selection().toPlainText();
recordOperation(op);
m_tc.removeSelectedText();
m_tc.deleteChar();
return op.m_from;
}
void FakeVimHandler::Private::recordRemoveNextChar()
{
m_tc.setPosition(m_tc.position(), MoveAnchor);
m_tc.movePosition(Right, KeepAnchor);
m_anchor = position();
moveRight();
recordRemoveSelectedText();
}
@@ -1775,6 +1843,7 @@ void FakeVimHandler::Private::recordInsertText(const QString &data)
void FakeVimHandler::Private::recordOperation(const EditOperation &op)
{
//qDebug() << "OP: " << op;
m_undoStack.push(op);
m_redoStack.clear();
}
@@ -66,7 +66,7 @@ class PROJECTEXPLORER_EXPORT IBuildParserFactory
Q_OBJECT
public:
IBuildParserFactory() {};
IBuildParserFactory() {}
virtual ~IBuildParserFactory();
virtual bool canCreate(const QString & name) const = 0;
virtual BuildParserInterface * create(const QString & name) const = 0;
@@ -1,245 +0,0 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "dependenciesdialog.h"
#include "project.h"
#include "session.h"
#include <QtCore/QVector>
#include <QtCore/QDebug>
#include <QtCore/QAbstractTableModel>
#include <QtGui/QPushButton>
#include <QtGui/QHeaderView>
namespace ProjectExplorer {
namespace Internal {
// ------ DependencyModel
class DependencyModel : public QAbstractTableModel {
public:
typedef ProjectExplorer::Project Project;
typedef DependenciesDialog::ProjectList ProjectList;
DependencyModel(SessionManager *sln, const ProjectList &projectList, QObject * parent = 0);
virtual int rowCount(const QModelIndex&) const { return m_projects.size(); }
virtual int columnCount(const QModelIndex&) const { return m_projects.size(); }
virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const;
bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
virtual Qt::ItemFlags flags ( const QModelIndex & index ) const;
QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
// Apply changed items
unsigned apply(SessionManager *sln) const;
void resetDependencies();
private:
struct Entry {
Entry(SessionManager *sln, Project *rootProject, Project *dependentProject);
Entry() : m_dependentProject(0), m_dependent(false), m_defaultValue(false), m_canAddDependency(false) {}
Project* m_dependentProject;
bool m_dependent;
bool m_defaultValue;
bool m_canAddDependency;
};
// column
typedef QVector<Entry> ProjectDependencies;
typedef QList<ProjectDependencies> Projects;
Projects m_projects;
ProjectList m_projectList;
};
DependencyModel::Entry::Entry(SessionManager *sln,
Project *rootProject,
Project *dependentProject) :
m_dependentProject(dependentProject),
m_dependent(sln->hasDependency(rootProject, dependentProject)),
m_defaultValue(m_dependent),
m_canAddDependency(sln->canAddDependency(rootProject, dependentProject))
{
}
DependencyModel::DependencyModel(SessionManager *sln,
const ProjectList &projectList,
QObject * parent) :
QAbstractTableModel(parent),
m_projectList(projectList)
{
const int count = projectList.size();
for (int p = 0; p < count; p++) {
Project *rootProject = projectList.at(p);
ProjectDependencies dependencies;
dependencies.reserve(count);
for (int d = 0; d < count ; d++)
dependencies.push_back(p == d ? Entry() : Entry(sln, rootProject, projectList.at(d)));
m_projects += dependencies;
}
}
QVariant DependencyModel::data ( const QModelIndex & index, int role ) const
{
static const QVariant empty = QVariant(QString());
// TO DO: find a checked icon
static const QVariant checked = QVariant(QString(QLatin1Char('x')));
const int p = index.column();
const int d = index.row();
switch (role) {
case Qt::EditRole:
return QVariant(m_projects[p][d].m_dependent);
case Qt::DisplayRole:
return m_projects[p][d].m_dependent ? checked : empty;
default:
break;
}
return QVariant();
}
bool DependencyModel::setData ( const QModelIndex & index, const QVariant & value, int role)
{
switch (role) {
case Qt::EditRole: {
const int p = index.column();
const int d = index.row();
if (d == p)
return false;
Entry &e(m_projects[p][d]);
e.m_dependent = value.toBool();
emit dataChanged(index, index);
}
return true;
default:
break;
}
return false;
}
Qt::ItemFlags DependencyModel::flags ( const QModelIndex & index ) const
{
const int p = index.column();
const int d = index.row();
if (d == p)
return 0;
const Entry &e(m_projects[p][d]);
Qt::ItemFlags rc = Qt::ItemIsEnabled|Qt::ItemIsUserCheckable | Qt::ItemIsSelectable;
if (e.m_canAddDependency)
rc |= Qt::ItemIsEditable;
return rc;
}
QVariant DependencyModel::headerData ( int section, Qt::Orientation , int role ) const
{
switch (role) {
case Qt::DisplayRole:
return QVariant(m_projectList.at(section)->name());
default:
break;
}
return QVariant();
}
void DependencyModel::resetDependencies()
{
if (const int count = m_projectList.size()) {
for (int p = 0; p < count; p++)
for (int d = 0; d < count; d++)
m_projects[p][d].m_dependent = false;
reset();
}
}
unsigned DependencyModel::apply(SessionManager *sln) const
{
unsigned rc = 0;
const int count = m_projectList.size();
for (int p = 0; p < count; p++) {
Project *rootProject = m_projectList.at(p);
for (int d = 0; d < count; d++) {
if (d != p) {
const Entry &e(m_projects[p][d]);
if (e.m_dependent != e. m_defaultValue) {
rc++;
if (e.m_dependent) {
sln->addDependency(rootProject, e.m_dependentProject);
} else {
sln->removeDependency(rootProject, e.m_dependentProject);
}
}
}
}
}
return rc;
}
// ------ DependenciesDialog
DependenciesDialog::DependenciesDialog(QWidget *parent, SessionManager *sln) :
QDialog(parent),
m_sln(sln),
m_projectList(m_sln->projects()),
m_model(new DependencyModel(sln, m_projectList))
{
m_ui.setupUi(this);
m_ui.buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
QPushButton *resetButton = m_ui.buttonBox->addButton (QDialogButtonBox::Reset);
connect(resetButton, SIGNAL(clicked()), this, SLOT(reset()));
m_ui.dependencyTable->setModel(m_model);
}
void DependenciesDialog::accept()
{
m_model->apply(m_sln);
QDialog::accept();
}
void DependenciesDialog::reset()
{
m_model->resetDependencies();
}
DependenciesDialog::~DependenciesDialog()
{
}
}
}
@@ -1,84 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectExplorer::Internal::DependenciesDialog</class>
<widget class="QDialog" name="ProjectExplorer::Internal::DependenciesDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>492</width>
<height>435</height>
</rect>
</property>
<property name="windowTitle">
<string>Project Dependencies</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<number>9</number>
</property>
<item>
<widget class="QTableView" name="dependencyTable">
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>ProjectExplorer::Internal::DependenciesDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>142</x>
<y>285</y>
</hint>
<hint type="destinationlabel">
<x>142</x>
<y>155</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>ProjectExplorer::Internal::DependenciesDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>142</x>
<y>285</y>
</hint>
<hint type="destinationlabel">
<x>142</x>
<y>155</y>
</hint>
</hints>
</connection>
</connections>
</ui>
@@ -0,0 +1,217 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "dependenciespanel.h"
#include "project.h"
#include "session.h"
#include <coreplugin/fileiconprovider.h>
#include <QtCore/QVector>
#include <QtCore/QDebug>
#include <QtCore/QAbstractListModel>
#include <QtGui/QHeaderView>
#include <QtGui/QMessageBox>
#include <QtGui/QPushButton>
namespace ProjectExplorer {
namespace Internal {
///
/// DependenciesModel
///
class DependenciesModel : public QAbstractListModel
{
public:
DependenciesModel(SessionManager *session, Project *project, QObject *parent = 0);
int rowCount(const QModelIndex &index) const;
int columnCount(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
Qt::ItemFlags flags(const QModelIndex &index) const;
private:
SessionManager *m_session;
Project *m_project;
QList<Project *> m_projects;
};
DependenciesModel::DependenciesModel(SessionManager *session,
Project *project,
QObject *parent)
: QAbstractListModel(parent)
, m_session(session)
, m_project(project)
, m_projects(session->projects())
{
// We can't select ourselves as a dependency
m_projects.removeAll(m_project);
}
int DependenciesModel::rowCount(const QModelIndex &index) const
{
return index.isValid() ? 0 : m_projects.size();
}
int DependenciesModel::columnCount(const QModelIndex &index) const
{
return index.isValid() ? 0 : 1;
}
QVariant DependenciesModel::data(const QModelIndex &index, int role) const
{
const Project *p = m_projects.at(index.row());
switch (role) {
case Qt::DisplayRole:
return p->name();
case Qt::CheckStateRole:
return m_session->hasDependency(m_project, p) ? Qt::Checked : Qt::Unchecked;
case Qt::DecorationRole:
return Core::FileIconProvider::instance()->icon(QFileInfo(p->file()->fileName()));
default:
return QVariant();
}
}
bool DependenciesModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
qDebug() << index << value << role << value.toBool();
if (role == Qt::CheckStateRole) {
const Project *p = m_projects.at(index.row());
const Qt::CheckState c = static_cast<Qt::CheckState>(value.toInt());
if (c == Qt::Checked) {
if (m_session->addDependency(m_project, p)) {
emit dataChanged(index, index);
return true;
} else {
QMessageBox::warning(0, tr("Unable to add dependency"),
tr("This would create a circular dependency."));
}
} else if (c == Qt::Unchecked) {
if (m_session->hasDependency(m_project, p)) {
m_session->removeDependency(m_project, p);
emit dataChanged(index, index);
return true;
}
}
}
return false;
}
Qt::ItemFlags DependenciesModel::flags(const QModelIndex &index) const
{
Qt::ItemFlags rc = QAbstractListModel::flags(index);
if (index.column() == 0)
rc |= Qt::ItemIsUserCheckable | Qt::ItemIsEditable;
return rc;
}
///
/// DependenciesWidget
///
class DependenciesWidget : public QWidget
{
public:
DependenciesWidget(SessionManager *session, Project *project,
QWidget *parent = 0);
private:
Ui::DependenciesWidget m_ui;
SessionManager *m_session;
DependenciesModel *m_model;
};
DependenciesWidget::DependenciesWidget(SessionManager *session,
Project *project,
QWidget *parent)
: QWidget(parent)
, m_session(session)
, m_model(new DependenciesModel(session, project, this))
{
m_ui.setupUi(this);
m_ui.dependenciesView->setModel(m_model);
m_ui.dependenciesView->setHeaderHidden(true);
}
///
/// DependenciesPanel
///
DependenciesPanel::DependenciesPanel(SessionManager *session, Project *project)
: PropertiesPanel()
, m_widget(new DependenciesWidget(session, project))
{
}
DependenciesPanel::~DependenciesPanel()
{
delete m_widget;
}
QString DependenciesPanel::name() const
{
return tr("Dependencies");
}
QWidget *DependenciesPanel::widget()
{
return m_widget;
}
///
/// DependenciesPanelFactory
///
DependenciesPanelFactory::DependenciesPanelFactory(SessionManager *session)
: m_session(session)
{
}
bool DependenciesPanelFactory::supports(Project * /* project */)
{
return true;
}
PropertiesPanel *DependenciesPanelFactory::createPanel(Project *project)
{
return new DependenciesPanel(m_session, project);
}
} // namespace Internal
} // namespace ProjectExplorer
@@ -34,9 +34,10 @@
#ifndef DEPENDENCIESDIALOG_H
#define DEPENDENCIESDIALOG_H
#include "ui_dependenciesdialog.h"
#include "iprojectproperties.h"
#include "ui_dependenciespanel.h"
#include <QtGui/QDialog>
#include <QtGui/QWidget>
namespace ProjectExplorer {
@@ -45,27 +46,32 @@ class SessionManager;
namespace Internal {
class DependencyModel;
class DependenciesWidget;
// NBS kill DependenciesDialog?
class DependenciesDialog : public QDialog
class DependenciesPanelFactory : public IPanelFactory
{
public:
DependenciesPanelFactory(SessionManager *session);
bool supports(Project *project);
PropertiesPanel *createPanel(Project *project);
private:
SessionManager *m_session;
};
class DependenciesPanel : public PropertiesPanel
{
Q_OBJECT
public:
typedef QList<ProjectExplorer::Project *> ProjectList;
DependenciesDialog(QWidget *parent, SessionManager *sln);
virtual ~DependenciesDialog();
public slots:
virtual void accept();
void reset();
DependenciesPanel(SessionManager *session, Project *project);
~DependenciesPanel();
QString name() const;
QWidget *widget();
private:
Ui::DependenciesDialog m_ui;
SessionManager *m_sln;
ProjectList m_projectList;
DependencyModel *m_model;
DependenciesWidget *m_widget;
};
} // namespace Internal
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectExplorer::Internal::DependenciesWidget</class>
<widget class="QWidget" name="ProjectExplorer::Internal::DependenciesWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>502</width>
<height>375</height>
</rect>
</property>
<property name="windowTitle">
<string>Project Dependencies</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QTreeView" name="dependenciesView"/>
</item>
<item row="1" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>Project Dependencies:</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
@@ -73,7 +73,6 @@ private slots:
void currentEncodingChanged(int index);
private:
Ui::EditorSettingsPropertiesPage m_ui;
Project *m_project;
QList<QTextCodec *> m_codecs;
@@ -39,8 +39,6 @@
#include <coreplugin/icontext.h>
#include <QtGui/QWidget>
namespace ProjectExplorer {
class PropertiesPanel;
@@ -57,7 +55,7 @@ class PROJECTEXPLORER_EXPORT PropertiesPanel : public Core::IContext
{
Q_OBJECT
public:
virtual void finish() {};
virtual void finish() {}
virtual QString name() const = 0;
// IContext
+8 -12
View File
@@ -46,7 +46,6 @@
#include <QtCore/QTextCodec>
using namespace ProjectExplorer;
using ExtensionSystem::PluginManager;
Project::Project()
: m_activeRunConfiguration(0),
@@ -54,6 +53,14 @@ Project::Project()
{
}
Project::~Project()
{
qDeleteAll(m_buildSteps);
qDeleteAll(m_cleanSteps);
qDeleteAll(m_buildConfigurationValues);
delete m_editorConfiguration;
}
void Project::insertBuildStep(int position, BuildStep *step)
{
m_buildSteps.insert(position, step);
@@ -508,14 +515,3 @@ void Project::setDisplayNameFor(const QString &buildConfiguration, const QString
}
emit buildConfigurationDisplayNameChanged(buildConfiguration);
}
Project::~Project()
{
qDeleteAll(m_buildSteps);
qDeleteAll(m_cleanSteps);
qDeleteAll(m_buildConfigurationValues);
delete m_editorConfiguration;
}
+22 -21
View File
@@ -31,7 +31,6 @@
**
***************************************************************************/
#ifndef PROJECT_H
#define PROJECT_H
@@ -50,7 +49,7 @@
#include <QtGui/QIcon>
namespace Core {
class IFile;
class IFile;
}
namespace ProjectExplorer {
@@ -68,8 +67,7 @@ class PROJECTEXPLORER_EXPORT Project
Q_OBJECT
public:
// Roles to be implemented by all models that are exported
// via model()
// Roles to be implemented by all models that are exported via model()
enum ModelRoles {
// Absolute file path
FilePathRole = QFileSystemModel::FilePathRole
@@ -82,12 +80,11 @@ public:
virtual Core::IFile *file() const = 0;
virtual IProjectManager *projectManager() const = 0;
virtual QList<Core::IFile *> dependencies() = 0; //NBS TODO remove
virtual QList<Project *> dependsOn() = 0; //NBS TODO implement dependsOn
virtual bool isApplication() const = 0;
//Build/Clean Step functions
// Build/Clean Step functions
QList<BuildStep *> buildSteps() const;
void insertBuildStep(int position, BuildStep *step);
void removeBuildStep(int position);
@@ -97,7 +94,7 @@ public:
void insertCleanStep(int position, BuildStep *step);
void removeCleanStep(int position);
//Build configuration
// Build configuration
void addBuildConfiguration(const QString &name);
void removeBuildConfiguration(const QString &name);
void copyBuildConfiguration(const QString &source, const QString &dest);
@@ -133,8 +130,9 @@ public:
virtual BuildStepConfigWidget *createConfigWidget() = 0;
virtual QList<BuildStepConfigWidget*> subConfigWidgets();
// This method is called for new build configurations
// You should probably set some default values in this method
/* This method is called for new build configurations. You should probably
* set some default values in this method.
*/
virtual void newBuildConfiguration(const QString &buildConfiguration) = 0;
virtual ProjectNode *rootProjectNode() const = 0;
@@ -150,19 +148,22 @@ signals:
void buildConfigurationDisplayNameChanged(const QString &buildConfiguraiton);
protected:
// This method is called when the project .user file is saved.
// Simply call writer.saveValue() for each value you want to save
// Make sure to always call your base class implementation
// Note: All the values from the project/buildsteps and buildconfigurations
// are automatically stored.
/* This method is called when the project .user file is saved. Simply call
* writer.saveValue() for each value you want to save. Make sure to always
* call your base class implementation.
*
* Note: All the values from the project/buildsteps and buildconfigurations
* are automatically stored.
*/
virtual void saveSettingsImpl(PersistentSettingsWriter &writer);
// This method is called when the project is opened
// You can retrieve all the values you saved in saveSettingsImpl()
// in this method.
// Note: This function is also called if there is no .user file
// You should probably add some default build and run settings to the project
// so that it can be build and run
/* This method is called when the project is opened. You can retrieve all
* the values you saved in saveSettingsImpl() in this method.
*
* Note: This function is also called if there is no .user file. You should
* probably add some default build and run settings to the project so that
* it can be build and run.
*/
virtual void restoreSettingsImpl(PersistentSettingsReader &reader);
private:
@@ -181,4 +182,4 @@ private:
} // namespace ProjectExplorer
#endif // PROJECTINTERFACE_H
#endif // PROJECT_H
@@ -34,12 +34,13 @@
#include "applicationrunconfiguration.h"
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
#include "currentprojectfind.h"
#include "buildmanager.h"
#include "buildsettingspropertiespage.h"
#include "editorsettingspropertiespage.h"
#include "currentprojectfind.h"
#include "currentprojectfilter.h"
#include "customexecutablerunconfiguration.h"
#include "editorsettingspropertiespage.h"
#include "dependenciespanel.h"
#include "foldernavigationwidget.h"
#include "iprojectmanager.h"
#include "metatypedeclarations.h"
@@ -215,6 +216,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin
addAutoReleasedObject(new BuildSettingsPanelFactory);
addAutoReleasedObject(new RunSettingsPanelFactory);
addAutoReleasedObject(new EditorSettingsPanelFactory);
addAutoReleasedObject(new DependenciesPanelFactory(m_session));
ProcessStepFactory *processStepFactory = new ProcessStepFactory;
addAutoReleasedObject(processStepFactory);
@@ -485,11 +487,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin
mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);
// dependencies action
m_dependenciesAction = new QAction(tr("Edit Dependencies..."), this);
cmd = am->registerAction(m_dependenciesAction, Constants::DEPENDENCIES, globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
// build action
m_buildAction = new QAction(tr("Build Project"), this);
cmd = am->registerAction(m_buildAction, Constants::BUILD, globalcontext);
@@ -622,7 +619,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList & /*arguments*/, QStrin
connect(m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu()));
connect(m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild()));
connect(m_debugAction, SIGNAL(triggered()), this, SLOT(debugProject()));
connect(m_dependenciesAction, SIGNAL(triggered()), this, SLOT(editDependencies()));
connect(m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject()));
connect(m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession()));
connect(m_taskAction, SIGNAL(triggered()), this, SLOT(goToTaskWindow()));
@@ -701,7 +697,7 @@ void ProjectExplorerPlugin::unloadProject()
QList<Core::IFile*> filesToSave;
filesToSave << fi;
filesToSave << m_currentProject->dependencies();
// FIXME: What we want here is to check whether we need to safe any of the pro/pri files in this project
// check the number of modified files
int readonlycount = 0;
@@ -1203,13 +1199,13 @@ void ProjectExplorerPlugin::updateActions()
m_rebuildSessionAction->setEnabled(hasProjects && !building);
m_cleanSessionAction->setEnabled(hasProjects && !building);
m_cancelBuildAction->setEnabled(building);
m_dependenciesAction->setEnabled(hasProjects && !building);
updateRunAction();
updateTaskActions();
}
// NBS TODO check projectOrder()
// what we want here is all the projects pro depends on
QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro)
@@ -1467,14 +1463,6 @@ void ProjectExplorerPlugin::cancelBuild()
m_buildManager->cancel();
}
void ProjectExplorerPlugin::editDependencies()
{
if (debug)
qDebug() << "ProjectExplorerPlugin::editDependencies";
m_session->editDependencies();
}
void ProjectExplorerPlugin::addToRecentProjects(const QString &fileName)
{
if (debug)
@@ -138,7 +138,6 @@ private slots:
void cleanSession();
void cancelBuild();
void debugProject();
void editDependencies();
void loadAction();
void unloadProject();
void clearSession();
@@ -228,7 +227,6 @@ private:
QAction *m_runActionContextMenu;
QAction *m_cancelBuildAction;
QAction *m_debugAction;
QAction *m_dependenciesAction;
QAction *m_taskAction;
QAction *m_addNewFileAction;
QAction *m_addExistingFilesAction;
@@ -15,7 +15,7 @@ HEADERS += projectexplorer.h \
persistentsettings.h \
projectfilewizardextension.h \
session.h \
dependenciesdialog.h \
dependenciespanel.h \
allprojectsfilter.h \
buildparserinterface.h \
projectexplorerconstants.h \
@@ -62,7 +62,7 @@ SOURCES += projectexplorer.cpp \
persistentsettings.cpp \
projectfilewizardextension.cpp \
session.cpp \
dependenciesdialog.cpp \
dependenciespanel.cpp \
allprojectsfilter.cpp \
currentprojectfilter.cpp \
scriptwrappers.cpp \
@@ -94,7 +94,7 @@ SOURCES += projectexplorer.cpp \
nodesvisitor.cpp \
projectmodels.cpp \
currentprojectfind.cpp
FORMS += dependenciesdialog.ui \
FORMS += dependenciespanel.ui \
buildsettingspropertiespage.ui \
processstep.ui \
editorsettingspropertiespage.ui \
+39 -26
View File
@@ -33,7 +33,6 @@
#include "session.h"
#include "dependenciesdialog.h"
#include "project.h"
#include "projectexplorer.h"
#include "projectexplorerconstants.h"
@@ -59,6 +58,7 @@
#include <QtCore/QFuture>
#include <QtCore/QSettings>
#include <QtGui/QApplication>
#include <QtGui/QMainWindow>
#include <QtGui/QMessageBox>
@@ -118,7 +118,6 @@ private:
using namespace ProjectExplorer;
using Internal::SessionFile;
using Internal::DependenciesDialog;
void SessionFile::sessionLoadingProgress()
@@ -452,7 +451,28 @@ bool SessionManager::recursiveDependencyCheck(const QString &newDep, const QStri
return true;
}
bool SessionManager::hasDependency(Project *project, Project *depProject) const
/*
* TODO: The dependency management exposes an interface based on projects, but
* is internally purely string based. This is suboptimal. Probably it would be
* nicer to map the filenames to projects on load and only map it back to
* filenames when saving.
*/
QList<Project *> SessionManager::dependencies(const Project *project) const
{
const QString &proName = project->file()->fileName();
const QStringList &proDeps = m_file->m_depMap.value(proName);
QList<Project *> projects;
foreach (const QString &dep, proDeps) {
if (Project *pro = projectForFile(dep))
projects += pro;
}
return projects;
}
bool SessionManager::hasDependency(const Project *project, const Project *depProject) const
{
const QString &proName = project->file()->fileName();
const QString &depName = depProject->file()->fileName();
@@ -461,7 +481,7 @@ bool SessionManager::hasDependency(Project *project, Project *depProject) const
return proDeps.contains(depName);
}
bool SessionManager::canAddDependency(Project *project, Project *depProject) const
bool SessionManager::canAddDependency(const Project *project, const Project *depProject) const
{
const QString &newDep = project->file()->fileName();
const QString &checkDep = depProject->file()->fileName();
@@ -469,7 +489,7 @@ bool SessionManager::canAddDependency(Project *project, Project *depProject) con
return recursiveDependencyCheck(newDep, checkDep);
}
bool SessionManager::addDependency(Project *project, Project *depProject)
bool SessionManager::addDependency(const Project *project, const Project *depProject)
{
const QString &proName = project->file()->fileName();
const QString &depName = depProject->file()->fileName();
@@ -487,6 +507,20 @@ bool SessionManager::addDependency(Project *project, Project *depProject)
return true;
}
void SessionManager::removeDependency(const Project *project, const Project *depProject)
{
const QString &proName = project->file()->fileName();
const QString &depName = depProject->file()->fileName();
QStringList proDeps = m_file->m_depMap.value(proName);
proDeps.removeAll(depName);
if (proDeps.isEmpty()) {
m_file->m_depMap.remove(proName);
} else {
m_file->m_depMap[proName] = proDeps;
}
}
void SessionManager::setStartupProject(Project *startupProject)
{
if (debug)
@@ -505,21 +539,6 @@ Project *SessionManager::startupProject() const
return m_file->m_startupProject;
}
void SessionManager::removeDependency(Project *project,
Project *depProject)
{
const QString &proName = project->file()->fileName();
const QString &depName = depProject->file()->fileName();
QStringList proDeps = m_file->m_depMap.value(proName);
proDeps.removeAll(depName);
if (proDeps.isEmpty()) {
m_file->m_depMap.remove(proName);
} else {
m_file->m_depMap[proName] = proDeps;
}
}
void SessionManager::addProject(Project *project)
{
addProjects(QList<Project*>() << project);
@@ -702,12 +721,6 @@ bool SessionManager::clear()
return success;
}
void SessionManager::editDependencies()
{
DependenciesDialog dlg(0, this);
dlg.exec();
}
const QList<Project *> &SessionManager::projects() const
{
return m_file->m_projects;
+5 -8
View File
@@ -123,16 +123,13 @@ public:
void removeProject(Project *project);
void removeProjects(QList<Project *> remove);
void editDependencies();
void setStartupProject(Project *startupProject);
// NBS think about dependency management again.
// Probably kill these here
bool canAddDependency(Project *project, Project *depProject) const;
bool hasDependency(Project *project, Project *depProject) const;
// adds the 'requiredProject' as a dependency to 'project'
bool addDependency(Project *project, Project *depProject);
void removeDependency(Project *project, Project *depProject);
QList<Project *> dependencies(const Project *project) const;
bool hasDependency(const Project *project, const Project *depProject) const;
bool canAddDependency(const Project *project, const Project *depProject) const;
bool addDependency(const Project *project, const Project *depProject);
void removeDependency(const Project *project, const Project *depProject);
Core::IFile *file() const;
Project *startupProject() const;
@@ -569,17 +569,6 @@ QStringList Qt4Project::files(FilesMode fileMode) const
return files;
}
QList<Core::IFile *> Qt4Project::dependencies()
{
QList<Core::IFile *> result;
// TODO profile cache is no longer
// ProFileCache *cache = m_manager->proFileCache();
// foreach (const QString &file, cache->dependencies(m_rootProjectNode)) {
// result << cache->fileInterface(file);
// }
return result;
}
QList<ProjectExplorer::Project*> Qt4Project::dependsOn()
{
// NBS implement dependsOn
@@ -74,7 +74,12 @@ using ProjectExplorer::ResourceType;
using ProjectExplorer::UnknownFileType;
// Known file types of a Qt 4 project
static const char* qt4FileTypes[] = {"CppHeaderFiles", "CppSourceFiles", "Qt4FormFiles", "Qt4ResourceFiles" };
static const char* qt4FileTypes[] = {
"CppHeaderFiles",
"CppSourceFiles",
"Qt4FormFiles",
"Qt4ResourceFiles"
};
Qt4Manager::Qt4Manager(Qt4ProjectManagerPlugin *plugin, Core::ICore *core) :
m_mimeType(QLatin1String(Qt4ProjectManager::Constants::PROFILE_MIMETYPE)),