Skip to content

Commit

Permalink
- Show multiline error messages in a single line and when user mouse …
Browse files Browse the repository at this point in the history
…hover then show full message in toolTip.

- selectAll with context menu.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10229 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Oct 26, 2011
1 parent a70ee4c commit 0034ef8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 28 deletions.
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/LibraryWidget.cpp
Expand Up @@ -1017,7 +1017,7 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QChar nl = QLatin1Char('\n');
for (int i = 0; i < text.count(); ++i)
if (text.at(i) == nl)
text[i] = QChar::LineSeparator;
text[i] = QChar::Nbsp;
}
displayRect = textRectangle(painter, option.rect, opt.font, text);
}
Expand Down Expand Up @@ -1048,7 +1048,7 @@ QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd
{
QSize size = QItemDelegate::sizeHint(option, index);
//Set very small height. A minimum apperantly stops at resonable size.
size.rheight() = qMax(22, size.rheight()); //pixels
size.rheight() = 22; //pixels
return size;
}

Expand Down
35 changes: 11 additions & 24 deletions OMEdit/OMEditGUI/ProblemsWidget.cpp
Expand Up @@ -233,12 +233,12 @@ Problem::Problem(ProblemsWidget *pParent)
setHeaderLabels(labels);
setContextMenuPolicy(Qt::CustomContextMenu);
// create actions
mpSelectAllAction = new QAction(tr("Select All"), this);
mpSelectAllAction->setStatusTip(tr("Selects all the Problems"));
connect(mpSelectAllAction, SIGNAL(triggered()), SLOT(selectAllProblems()));
mpCopyAction = new QAction(QIcon(":/Resources/icons/copy.png"), tr("Copy"), this);
mpCopyAction->setStatusTip(tr("Copy the Problem"));
connect(mpCopyAction, SIGNAL(triggered()), SLOT(copyProblems()));
mpCopyAllAction = new QAction(tr("Copy All"), this);
mpCopyAllAction->setStatusTip(tr("Copy All the Problems"));
connect(mpCopyAllAction, SIGNAL(triggered()), SLOT(copyAllProblems()));
mpRemoveAction = new QAction(QIcon(":/Resources/icons/delete.png"), tr("Remove"), this);
mpRemoveAction->setStatusTip(tr("Remove the Problem"));
connect(mpRemoveAction, SIGNAL(triggered()), SLOT(removeProblems()));
Expand All @@ -258,15 +258,21 @@ void Problem::showContextMenu(QPoint point)
{
item->setSelected(true);
QMenu menu(this);
menu.addAction(mpSelectAllAction);
menu.addAction(mpCopyAction);
menu.addAction(mpCopyAllAction);
menu.addSeparator();
menu.addAction(mpRemoveAction);
point.setY(point.y() + adjust);
menu.exec(mapToGlobal(point));
}
}

//! Selects all the problems.
//! Slot activated when mpSelectAllAction triggered signal is raised.
void Problem::selectAllProblems()
{
selectAll();
}

//! Copy the selected problems to the clipboard.
//! Slot activated when mpCopyAction triggered signal is raised.
void Problem::copyProblems()
Expand All @@ -283,25 +289,6 @@ void Problem::copyProblems()
QApplication::clipboard()->setText(textToCopy);
}

//! Copy all the problems to the clipboard.
//! Slot activated when mpCopyAllAction triggered signal is raised.
void Problem::copyAllProblems()
{
QString textToCopy;
QTreeWidgetItemIterator it(this);
while (*it)
{
ProblemItem *pProblemItem = dynamic_cast<ProblemItem*>(*it);
textToCopy.append(pProblemItem->text(0)).append("\t");
textToCopy.append(pProblemItem->text(1)).append("\t");
textToCopy.append(pProblemItem->text(2)).append("\t");
textToCopy.append(pProblemItem->text(3)).append("\t");
textToCopy.append(pProblemItem->text(4)).append("\n");
++it;
}
QApplication::clipboard()->setText(textToCopy);
}

//! Removes the selected problems.
//! Slot activated when mpRemoveAction triggered signal is raised.
void Problem::removeProblems()
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/ProblemsWidget.h
Expand Up @@ -79,17 +79,17 @@ class Problem : public QTreeWidget
{
Q_OBJECT
private:
QAction *mpSelectAllAction;
QAction *mpCopyAction;
QAction *mpCopyAllAction;
QAction *mpRemoveAction;
public:
Problem(ProblemsWidget *pParent);

ProblemsWidget *mpMessageWidget;
private slots:
void showContextMenu(QPoint point);
void selectAllProblems();
void copyProblems();
void copyAllProblems();
void removeProblems();
protected:
virtual void keyPressEvent(QKeyEvent *event);
Expand Down

0 comments on commit 0034ef8

Please sign in to comment.