Changeset View
Changeset View
Standalone View
Standalone View
src/commandentry.cpp
Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Line(s) | 83 | { | |||
---|---|---|---|---|---|
93 | m_promptItemAnimation->setStartValue(1); | 93 | m_promptItemAnimation->setStartValue(1); | ||
94 | m_promptItemAnimation->setKeyValueAt(0.5, 0); | 94 | m_promptItemAnimation->setKeyValueAt(0.5, 0); | ||
95 | m_promptItemAnimation->setEndValue(1); | 95 | m_promptItemAnimation->setEndValue(1); | ||
96 | connect(m_promptItemAnimation, &QPropertyAnimation::finished, this, &CommandEntry::animatePromptItem); | 96 | connect(m_promptItemAnimation, &QPropertyAnimation::finished, this, &CommandEntry::animatePromptItem); | ||
97 | 97 | | |||
98 | m_promptItem->setDoubleClickBehaviour(WorksheetTextItem::DoubleClickEventBehaviour::Simple); | 98 | m_promptItem->setDoubleClickBehaviour(WorksheetTextItem::DoubleClickEventBehaviour::Simple); | ||
99 | connect(m_promptItem, &WorksheetTextItem::doubleClick, this, &CommandEntry::changeResultCollapsingAction); | 99 | connect(m_promptItem, &WorksheetTextItem::doubleClick, this, &CommandEntry::changeResultCollapsingAction); | ||
100 | 100 | | |||
101 | connect(&m_controlElement, &WorksheetControlItem::doubleClick, this, &CommandEntry::changeResultCollapsingAction); | ||||
102 | | ||||
101 | connect(m_commandItem, &WorksheetTextItem::tabPressed, this, &CommandEntry::showCompletion); | 103 | connect(m_commandItem, &WorksheetTextItem::tabPressed, this, &CommandEntry::showCompletion); | ||
102 | connect(m_commandItem, &WorksheetTextItem::backtabPressed, this, &CommandEntry::selectPreviousCompletion); | 104 | connect(m_commandItem, &WorksheetTextItem::backtabPressed, this, &CommandEntry::selectPreviousCompletion); | ||
103 | connect(m_commandItem, &WorksheetTextItem::applyCompletion, this, &CommandEntry::applySelectedCompletion); | 105 | connect(m_commandItem, &WorksheetTextItem::applyCompletion, this, &CommandEntry::applySelectedCompletion); | ||
104 | connect(m_commandItem, &WorksheetTextItem::execute, this, [=]() { evaluate();} ); | 106 | connect(m_commandItem, &WorksheetTextItem::execute, this, [=]() { evaluate();} ); | ||
105 | connect(m_commandItem, &WorksheetTextItem::moveToPrevious, this, &CommandEntry::moveToPreviousItem); | 107 | connect(m_commandItem, &WorksheetTextItem::moveToPrevious, this, &CommandEntry::moveToPreviousItem); | ||
106 | connect(m_commandItem, &WorksheetTextItem::moveToNext, this, &CommandEntry::moveToNextItem); | 108 | connect(m_commandItem, &WorksheetTextItem::moveToNext, this, &CommandEntry::moveToNextItem); | ||
107 | connect(m_commandItem, &WorksheetTextItem::receivedFocus, worksheet, &Worksheet::highlightItem); | 109 | connect(m_commandItem, &WorksheetTextItem::receivedFocus, worksheet, &Worksheet::highlightItem); | ||
108 | connect(m_promptItem, &WorksheetTextItem::drag, this, &CommandEntry::startDrag); | 110 | connect(m_promptItem, &WorksheetTextItem::drag, this, &CommandEntry::startDrag); | ||
▲ Show 20 Lines • Show All 637 Lines • ▼ Show 20 Line(s) | 744 | { | |||
746 | for (int i = m_resultItems.size(); i < expr->results().size(); i++) | 748 | for (int i = m_resultItems.size(); i < expr->results().size(); i++) | ||
747 | m_resultItems << ResultItem::create(this, expr->results()[i]); | 749 | m_resultItems << ResultItem::create(this, expr->results()[i]); | ||
748 | } | 750 | } | ||
749 | else | 751 | else | ||
750 | { | 752 | { | ||
751 | for (ResultItem* item: m_resultItems) | 753 | for (ResultItem* item: m_resultItems) | ||
752 | item->update(); | 754 | item->update(); | ||
753 | } | 755 | } | ||
756 | | ||||
757 | m_controlElement.isCollapsable = m_resultItems.size() > 0; | ||||
758 | | ||||
754 | animateSizeChange(); | 759 | animateSizeChange(); | ||
755 | } | 760 | } | ||
756 | 761 | | |||
757 | void CommandEntry::expressionChangedStatus(Cantor::Expression::Status status) | 762 | void CommandEntry::expressionChangedStatus(Cantor::Expression::Status status) | ||
758 | { | 763 | { | ||
759 | switch (status) | 764 | switch (status) | ||
760 | { | 765 | { | ||
761 | case Cantor::Expression::Computing: | 766 | case Cantor::Expression::Computing: | ||
▲ Show 20 Lines • Show All 467 Lines • ▼ Show 20 Line(s) | 1199 | { | |||
1229 | return WorksheetCursor(); | 1234 | return WorksheetCursor(); | ||
1230 | } | 1235 | } | ||
1231 | 1236 | | |||
1232 | void CommandEntry::layOutForWidth(qreal w, bool force) | 1237 | void CommandEntry::layOutForWidth(qreal w, bool force) | ||
1233 | { | 1238 | { | ||
1234 | if (w == size().width() && !force) | 1239 | if (w == size().width() && !force) | ||
1235 | return; | 1240 | return; | ||
1236 | 1241 | | |||
1237 | m_promptItem->setPos(0,0); | 1242 | m_promptItem->setPos(0, 0); | ||
1238 | double x = 0 + m_promptItem->width() + HorizontalSpacing; | 1243 | double x = 0 + m_promptItem->width() + HorizontalSpacing; | ||
1239 | double y = 0; | 1244 | double y = 0; | ||
1240 | double width = 0; | 1245 | double width = 0; | ||
1241 | 1246 | | |||
1242 | m_commandItem->setGeometry(x,y, w-x); | 1247 | const qreal margin = worksheet()->isPrinting() ? 0 : RightMargin; | ||
1243 | width = qMax(width, m_commandItem->width()); | 1248 | | ||
1249 | m_commandItem->setGeometry(x, y, w - x - margin); | ||||
1250 | width = qMax(width, m_commandItem->width()+margin); | ||||
1244 | 1251 | | |||
1245 | y += qMax(m_commandItem->height(), m_promptItem->height()); | 1252 | y += qMax(m_commandItem->height(), m_promptItem->height()); | ||
1246 | foreach(WorksheetTextItem* information, m_informationItems) { | 1253 | foreach(WorksheetTextItem* information, m_informationItems) { | ||
1247 | y += VerticalSpacing; | 1254 | y += VerticalSpacing; | ||
1248 | y += information->setGeometry(x,y,w-x); | 1255 | y += information->setGeometry(x, y, w - x - margin); | ||
1249 | width = qMax(width, information->width()); | 1256 | width = qMax(width, information->width() + margin); | ||
1250 | } | 1257 | } | ||
1251 | 1258 | | |||
1252 | if (m_errorItem) { | 1259 | if (m_errorItem) { | ||
1253 | y += VerticalSpacing; | 1260 | y += VerticalSpacing; | ||
1254 | y += m_errorItem->setGeometry(x,y,w-x); | 1261 | y += m_errorItem->setGeometry(x,y,w - x - margin); | ||
1255 | width = qMax(width, m_errorItem->width()); | 1262 | width = qMax(width, m_errorItem->width() + margin); | ||
1256 | } | 1263 | } | ||
1257 | 1264 | | |||
1258 | for (auto* resultItem : m_resultItems) | 1265 | for (auto* resultItem : m_resultItems) | ||
1259 | { | 1266 | { | ||
1260 | if (!resultItem || !resultItem->graphicsObject()->isVisible()) | 1267 | if (!resultItem || !resultItem->graphicsObject()->isVisible()) | ||
1261 | continue; | 1268 | continue; | ||
1262 | y += VerticalSpacing; | 1269 | y += VerticalSpacing; | ||
1263 | y += resultItem->setGeometry(x, y, w-x); | 1270 | y += resultItem->setGeometry(x, y, w - x - margin); | ||
1264 | width = qMax(width, resultItem->width()); | 1271 | width = qMax(width, resultItem->width() + margin); | ||
1265 | } | 1272 | } | ||
1266 | y += VerticalMargin; | 1273 | y += VerticalMargin; | ||
1267 | 1274 | | |||
1268 | QSizeF s(x+ width, y); | 1275 | QSizeF s(x+ width, y); | ||
1269 | if (animationActive()) { | 1276 | if (animationActive()) { | ||
1270 | updateSizeAnimation(s); | 1277 | updateSizeAnimation(s); | ||
1271 | } else { | 1278 | } else { | ||
1272 | setSize(s); | 1279 | setSize(s); | ||
Show All 23 Lines | 1295 | { | |||
1296 | if (worksheet()->animationsEnabled()) | 1303 | if (worksheet()->animationsEnabled()) | ||
1297 | { | 1304 | { | ||
1298 | QTimer::singleShot(100, this, &CommandEntry::setMidPrompt); | 1305 | QTimer::singleShot(100, this, &CommandEntry::setMidPrompt); | ||
1299 | QTimer::singleShot(200, this, &CommandEntry::setHidePrompt); | 1306 | QTimer::singleShot(200, this, &CommandEntry::setHidePrompt); | ||
1300 | } | 1307 | } | ||
1301 | else | 1308 | else | ||
1302 | setHidePrompt(); | 1309 | setHidePrompt(); | ||
1303 | 1310 | | |||
1311 | m_controlElement.isCollapsed = true; | ||||
1304 | animateSizeChange(); | 1312 | animateSizeChange(); | ||
1305 | } | 1313 | } | ||
1306 | 1314 | | |||
1307 | void CommandEntry::expandResults() | 1315 | void CommandEntry::expandResults() | ||
1308 | { | 1316 | { | ||
1309 | for(auto* item : m_resultItems) { | 1317 | for(auto* item : m_resultItems) { | ||
1310 | fadeInItem(item->graphicsObject(), nullptr); | 1318 | fadeInItem(item->graphicsObject(), nullptr); | ||
1311 | item->graphicsObject()->show(); | 1319 | item->graphicsObject()->show(); | ||
1312 | } | 1320 | } | ||
1313 | 1321 | | |||
1314 | m_resultsCollapsed = false; | 1322 | m_resultsCollapsed = false; | ||
1315 | 1323 | | |||
1316 | if (worksheet()->animationsEnabled()) | 1324 | if (worksheet()->animationsEnabled()) | ||
1317 | { | 1325 | { | ||
1318 | QTimer::singleShot(100, this, &CommandEntry::setMidPrompt); | 1326 | QTimer::singleShot(100, this, &CommandEntry::setMidPrompt); | ||
1319 | QTimer::singleShot(200, this, SLOT(updatePrompt())); | 1327 | QTimer::singleShot(200, this, SLOT(updatePrompt())); | ||
1320 | } | 1328 | } | ||
1321 | else | 1329 | else | ||
1322 | this->updatePrompt(); | 1330 | this->updatePrompt(); | ||
1323 | 1331 | | |||
1332 | m_controlElement.isCollapsed = false; | ||||
1324 | animateSizeChange(); | 1333 | animateSizeChange(); | ||
1325 | } | 1334 | } | ||
1326 | 1335 | | |||
1327 | void CommandEntry::setHidePrompt() | 1336 | void CommandEntry::setHidePrompt() | ||
1328 | { | 1337 | { | ||
1329 | updatePrompt(HidePrompt); | 1338 | updatePrompt(HidePrompt); | ||
1330 | } | 1339 | } | ||
1331 | 1340 | | |||
Show All 15 Lines |