Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
v0.9.6

Closes #788, #786, and #785

See merge request devel/studio!193
  • Loading branch information
MrMontag committed Nov 9, 2018
2 parents 94637db + 1b0f0f6 commit 9d288fd
Show file tree
Hide file tree
Showing 26 changed files with 147 additions and 115 deletions.
6 changes: 4 additions & 2 deletions src/checkforupdatewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
namespace gams {
namespace studio {

// TODO(AF) html for checkForUpdate

/**
* Possible improvments
* o html outout for checkForUpdate
*/
CheckForUpdateWrapper::CheckForUpdateWrapper()
{
char buffer[GMS_SSSIZE];
Expand Down
13 changes: 2 additions & 11 deletions src/editors/abstractedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,9 @@ void AbstractEdit::setMarks(const LineMarks *marks)
marksChanged();
}

void AbstractEdit::afterContentsChanged(int, int, int)
const LineMarks* AbstractEdit::marks() const
{
// TODO(JM) This isn't connected anymore. What kind of workaround is this?
QTextCursor tc = textCursor();
int pos = tc.position();
tc.setPosition(pos);
setTextCursor(tc);
return mMarks;
}

void AbstractEdit::showToolTip(const QList<TextMark*> marks)
Expand Down Expand Up @@ -163,11 +159,6 @@ QList<TextMark*> AbstractEdit::cachedLineMarks(int lineNr)
return mCacheMarks;
}

const LineMarks &AbstractEdit::marks() const
{
return *mMarks;
}

const QList<TextMark *> &AbstractEdit::marksAtMouse() const
{
return mMarksAtMouse;
Expand Down
12 changes: 4 additions & 8 deletions src/editors/abstractedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ class AbstractEdit : public QPlainTextEdit

void updateGroupId();

void setMarks(const LineMarks *marks);
int markCount() { return mMarks ? mMarks->size() : 0; }

signals:
void requestLstTexts(NodeId groupId, const QList<TextMark*> &marks, QStringList &result);

public slots:
void afterContentsChanged(int, int, int);

protected:
friend class FileMeta;

Expand All @@ -69,17 +63,19 @@ public slots:
void mouseReleaseEvent(QMouseEvent *e) override;
virtual void marksChanged();
QList<TextMark *> cachedLineMarks(int lineNr);
const LineMarks &marks() const;
const QList<TextMark*> &marksAtMouse() const;
inline NodeId groupId() {
bool ok;
NodeId group = property("groupId").toInt(&ok);
return ok ? group : NodeId();
}

void setMarks(const LineMarks *marks);
const LineMarks* marks() const;

private:
NodeId mGroupId;
const LineMarks *mMarks = nullptr;
const LineMarks* mMarks = nullptr;
QList<TextMark*> mMarksAtMouse;
QPoint mClickPos;
QPoint mTipPos;
Expand Down
18 changes: 10 additions & 8 deletions src/editors/codeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ int CodeEdit::lineNumberAreaWidth()

int space = 0;

if(mSettings->showLineNr())
if (mSettings->showLineNr())
space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;

space += markCount() ? iconSize() : 0;
if (marks() && marks()->hasVisibleMarks())
space += iconSize();

return space;
}
Expand Down Expand Up @@ -423,6 +424,7 @@ void CodeEdit::keyPressEvent(QKeyEvent* e)
QSet<int> moveKeys;
moveKeys << Qt::Key_Home << Qt::Key_End << Qt::Key_Down << Qt::Key_Up
<< Qt::Key_Left << Qt::Key_Right << Qt::Key_PageUp << Qt::Key_PageDown;
// deactivate when manual cursor movement was detected
if (moveKeys.contains(e->key())) mSmartType = false;

QString opening = "([{'\"";
Expand All @@ -445,7 +447,7 @@ void CodeEdit::keyPressEvent(QKeyEvent* e)
setTextCursor(tc);
return;

// jump over closing character thats already in place
// jump over closing character thats already in place
} else if (indexClosing != -1 &&
closing.indexOf(document()->characterAt(textCursor().position())) == indexClosing) {
QTextCursor tc = textCursor();
Expand All @@ -455,8 +457,8 @@ void CodeEdit::keyPressEvent(QKeyEvent* e)
e->accept();
return;

// insert closing characters
} else if (index != -1) {
// insert closing characters
} else if (index != -1 && !document()->characterAt(textCursor().position()).isLetterOrNumber()) {
mSmartType = true;
QTextCursor tc = textCursor();
tc.insertText(e->text());
Expand Down Expand Up @@ -493,7 +495,7 @@ void CodeEdit::keyReleaseEvent(QKeyEvent* e)
e->accept();
return;
}
AbstractEdit::keyReleaseEvent(e);
AbstractEdit::keyReleaseEvent(e);
}

void CodeEdit::adjustIndent(QTextCursor cursor)
Expand Down Expand Up @@ -1339,9 +1341,9 @@ void CodeEdit::lineNumberAreaPaintEvent(QPaintEvent *event)
if(mSettings->showLineNr())
painter.drawText(0, realtop, mLineNumberArea->width(), fontMetrics().height(), Qt::AlignRight, number);

if (markCount() && marks().contains(blockNumber)) {
if (marks()->hasVisibleMarks() && marks()->contains(blockNumber)) {
int iTop = (2+top+bottom-iconSize())/2;
painter.drawPixmap(1, iTop, marks().value(blockNumber)->icon().pixmap(QSize(iconSize(),iconSize())));
painter.drawPixmap(1, iTop, marks()->value(blockNumber)->icon().pixmap(QSize(iconSize(),iconSize())));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/editors/processlogedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ void ProcessLogEdit::mouseReleaseEvent(QMouseEvent *event)
void ProcessLogEdit::jumpToLst(QPoint pos, bool fuzzy)
{
QTextCursor cursor = cursorForPosition(pos);
if (marks().values(cursor.blockNumber()).isEmpty() || fuzzy) {
if (marks()->values(cursor.blockNumber()).isEmpty() || fuzzy) {

// TODO(JM) only check for TextMark::error

int line = cursor.blockNumber();
TextMark* linkMark = nullptr;
for (TextMark *mark: marks()) {
for (TextMark *mark: *marks()) {
if (mark->type() == TextMark::link && mark->refFileKind() == FileKind::Lst) {
if (mark->line() < line)
linkMark = mark;
Expand Down
2 changes: 1 addition & 1 deletion src/editors/viewhelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class ViewHelper
EditorType t = editorType(w);
if (t == EditorType::lxiLst)
return toLxiViewer(w)->codeEdit();
return (t == EditorType::source) ? static_cast<CodeEdit*>(w) : nullptr;
return (t == EditorType::source || t == EditorType::txt) ? static_cast<CodeEdit*>(w) : nullptr;
}
inline static ProcessLogEdit* toLogEdit(QWidget* w) {
return (editorType(w) == EditorType::log) ? static_cast<ProcessLogEdit*>(w) : nullptr;
Expand Down
6 changes: 5 additions & 1 deletion src/file/filemetarepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,17 @@ QWidgetList FileMetaRepo::editors() const

void FileMetaRepo::unwatch(const FileMeta *fileMeta)
{
if (fileMeta->location().isEmpty()) return;

mWatcher.removePath(fileMeta->location());
mMissList.removeAll(fileMeta->location());
if (mMissList.isEmpty()) mMissCheckTimer.stop();
}

void FileMetaRepo::unwatch(const QString &filePath)
{
if (filePath.isEmpty()) return;

mWatcher.removePath(filePath);
mMissList.removeAll(filePath);
if (mMissList.isEmpty()) mMissCheckTimer.stop();
Expand Down Expand Up @@ -176,7 +180,7 @@ void FileMetaRepo::setDebugMode(bool debug)
for (int key: edits.keys()) {
FileMeta* fm = fileMeta(FileId(key));
QString nam = (fm ? fm->name() : "???");
DEB() << key << ": " << edits.value(key)->markCount() << " " << nam;
// DEB() << key << ": " << edits.value(key)->size() << " " << nam;
}

}
Expand Down
6 changes: 0 additions & 6 deletions src/file/projectcontextmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ void ProjectContextMenu::onCloseGroup()
}
}

//void ProjectContextMenu::onRunFile()
//{
// ProjectFileNode *file = mNode->toFile();
// if (file) emit runFile(file);
//}

void ProjectContextMenu::onSetMainFile()
{
ProjectFileNode *file = mNodes.first()->toFile();
Expand Down
1 change: 0 additions & 1 deletion src/file/projectcontextmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class ProjectContextMenu : public QMenu

private slots:
void onCloseGroup();
// void onRunFile();
void onCloseFile();
void onAddExisitingFile();
void onAddNewFile();
Expand Down
1 change: 0 additions & 1 deletion src/file/projectgroupnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ QStringList ProjectRunGroupNode::analyzeParameters(const QString &gmsLocation, Q
}

// prepare return value
// TODO(JM) Check if this works, taken from ProjectGroupNode::setRunnableGms()
#if defined(__unix__) || defined(__APPLE__)
QStringList output { QDir::toNativeSeparators(gmsLocation) };
#else
Expand Down
10 changes: 5 additions & 5 deletions src/file/projectlognode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ QString ProjectLogNode::extractLinks(const QString &line, ProjectFileNode::Extra
result += capture(line, posA, posB, 0, '[');

if (posB+5 < line.length()) {
TextMark::Type tmType = errFound ? TextMark::link : TextMark::none;
TextMark::Type tmType = errFound ? TextMark::link : TextMark::target;
if (isGamsLine && line.midRef(posB+1,4) == "LST:") {
int lineNr = capture(line, posA, posB, 5, ']').toInt()-1;
mCurrentErrorHint.lstLine = lineNr;
Expand All @@ -332,10 +332,10 @@ QString ProjectLogNode::extractLinks(const QString &line, ProjectFileNode::Extra
QFileInfo fi(mRunGroup->specialFile(FileKind::Lst));
mLstNode = projectRepo()->findOrCreateFileNode(mRunGroup->specialFile(FileKind::Lst), mRunGroup);
if (!mLstNode) {
errFound = false;
SysLogLocator::systemLog()->appendLog("Could not find lst-file to generate TextMark for."
"Did you overwrite default GAMS parameters?", LogMsgType::Error);
continue;
errFound = false;
SysLogLocator::systemLog()->appendLog("Could not find lst-file to generate TextMark for."
"Did you overwrite default GAMS parameters?", LogMsgType::Error);
continue;
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/file/projectrepo.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
namespace gams {
namespace studio {

// TODO(AF)
// - a file which is in different groups
// - naming and documentation of functions
// - function to find a group for a GAMSProcess
// - review class dependencies of FileRepository
// - review function argument, i.e. const strings

///
/// The ProjectRepo handles all open and assigned nodes of projects or simple gms-runables. It is based on an
/// QAbstractItemModel to provide a model for a QTreeView.
Expand Down
1 change: 0 additions & 1 deletion src/gdxviewer/gdxsymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ void GdxSymbol::calcDefaultColumns()
else if (mType == GMS_DT_EQU)
defVal = gmsDefRecEqu[mSubType][valColIdx];
for(int i=0; i<mRecordCount; i++) {
// TODO(AF) fix uninizalized defVal
if(defVal != mValues[i*GMS_VAL_MAX + valColIdx]) {
mDefaultColumn[valColIdx] = false;
break;
Expand Down
3 changes: 2 additions & 1 deletion src/locators/searchlocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ void SearchLocator::provide(SearchDialog *sd)
{
mSd = sd;
}

SearchResultList* SearchLocator::searchResults()
{
if (mSd)
return mSd->getCachedResults();
return mSd->cachedResults();
else
return nullptr;
}
Expand Down
29 changes: 16 additions & 13 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ int MainWindow::fileDeletedExtern(FileId fileId, bool ask, int count)
FileMeta *file = mFileMetaRepo.fileMeta(fileId);
if (!file) return 0;
if (file->exists(true)) return 0;
mTextMarkRepo.removeMarks(fileId, QSet<TextMark::Type>() << TextMark::all);
if (!file->isOpen()) {
QVector<ProjectFileNode*> nodes = mProjectRepo.fileNodes(file->id());
for (ProjectFileNode* node: nodes) {
Expand Down Expand Up @@ -1113,7 +1114,8 @@ void MainWindow::processFileEvents()
FileEventData fileEvent = mFileEvents.takeFirst();
FileMeta *fm = mFileMetaRepo.fileMeta(fileEvent.fileId);
int remainKind = 0;
if (!fm) continue;
if (!fm || fm->kind() == FileKind::Log)
continue;
switch (fileEvent.kind) {
case FileEventKind::changedExtern:
remainKind = fileChangedExtern(fm->id(), false);
Expand Down Expand Up @@ -1198,7 +1200,6 @@ void MainWindow::postGamsRun(NodeId origin)

void MainWindow::postGamsLibRun()
{
// TODO(AF) Are there models without a GMS file? How to handle them?"
ProjectFileNode *node = mProjectRepo.findFile(mLibProcess->targetDir() + "/" + mLibProcess->inputFile());
if (!node)
node = addNode(mLibProcess->targetDir(), mLibProcess->inputFile());
Expand Down Expand Up @@ -1723,12 +1724,13 @@ void MainWindow::execute(QString commandLineStr, ProjectFileNode* gmsFileNode)

// clear the TextMarks for this group
QSet<TextMark::Type> markTypes;
markTypes << TextMark::error << TextMark::link;
markTypes << TextMark::error << TextMark::link << TextMark::target;
for (ProjectFileNode *node: runGroup->listFiles(true))
mTextMarkRepo.removeMarks(node->file()->id(), node->assignedRunGroup()->id(), markTypes);

// prepare the log
ProjectLogNode* logNode = mProjectRepo.logNode(runGroup);
mTextMarkRepo.removeMarks(logNode->file()->id(), logNode->assignedRunGroup()->id(), markTypes);
logNode->resetLst();
if (!logNode->file()->isOpen()) {
QWidget *wid = logNode->file()->createEdit(ui->logTabs, logNode->assignedRunGroup(), QList<int>() << logNode->file()->codecMib());
Expand Down Expand Up @@ -1893,7 +1895,7 @@ void MainWindow::changeToLog(ProjectAbstractNode *node, bool createMissing)
ProcessLogEdit* logEdit = ViewHelper::toLogEdit(logNode->file()->editors().first());
if (logEdit) {
if (ui->logTabs->currentWidget() != logEdit) {
if (ui->logTabs->currentWidget() != mResultsView)
if (ui->logTabs->currentWidget() != searchDialog()->resultsView())
ui->logTabs->setCurrentWidget(logEdit);
}
if (moveToEnd) {
Expand Down Expand Up @@ -2212,23 +2214,24 @@ void MainWindow::on_actionSearch_triggered()

void MainWindow::showResults(SearchResultList &results)
{
int index = ui->logTabs->indexOf(mResultsView); // did widget exist before?
ResultsView* resultsView = searchDialog()->resultsView();
int index = ui->logTabs->indexOf(resultsView); // did widget exist before?

mResultsView = new ResultsView(results, this);
searchDialog()->setResultsView(new ResultsView(results, this));
QString title("Results: " + mSearchDialog->searchTerm() + " (" + QString::number(results.size()) + ")");

ui->dockLogView->show();
mResultsView->resizeColumnsToContent();
searchDialog()->resultsView()->resizeColumnsToContent();

if (index != -1) ui->logTabs->removeTab(index); // remove old result page

ui->logTabs->addTab(mResultsView, title); // add new result page
ui->logTabs->setCurrentWidget(mResultsView);
ui->logTabs->addTab(searchDialog()->resultsView(), title); // add new result page
ui->logTabs->setCurrentWidget(searchDialog()->resultsView());
}

void MainWindow::closeResults()
void MainWindow::closeResultsPage()
{
int index = ui->logTabs->indexOf(mResultsView);
int index = ui->logTabs->indexOf(searchDialog()->resultsView());
if (index != -1) ui->logTabs->removeTab(index);
}

Expand All @@ -2246,7 +2249,7 @@ void MainWindow::updateFixedFonts(const QString &fontFamily, int fontSize)
}

void MainWindow::updateEditorLineWrapping()
{// TODO(AF) split logs and editors
{
QPlainTextEdit::LineWrapMode wrapModeEditor = mSettings->lineWrapEditor() ? QPlainTextEdit::WidgetWidth
: QPlainTextEdit::NoWrap;
QPlainTextEdit::LineWrapMode wrapModeProcess = mSettings->lineWrapProcess() ? QPlainTextEdit::WidgetWidth
Expand Down Expand Up @@ -2697,7 +2700,7 @@ void MainWindow::setForegroundOSCheck()
if (mSettings->foregroundOnDemand())
setForeground();
}

void MainWindow::on_actionNextTab_triggered()
{
QWidget *wid = focusWidget();
Expand Down
3 changes: 1 addition & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class MainWindow : public QMainWindow
QList<AbstractEdit*> openLogs();
SearchDialog* searchDialog() const;
void showResults(SearchResultList &results);
void closeResults();
void closeResultsPage();
RecentData *recent();
void openModelFromLib(QString glbFile, LibraryItem *model);
bool readTabs(const QJsonObject &json);
Expand Down Expand Up @@ -310,7 +310,6 @@ private slots:
HelpWidget *mHelpWidget = nullptr;
#endif
OptionWidget *mGamsOptionWidget = nullptr;
ResultsView *mResultsView = nullptr;
SystemLogEdit *mSyslog = nullptr;
StatusWidgets* mStatusWidgets;

Expand Down
Loading

0 comments on commit 9d288fd

Please sign in to comment.