QVariant vogleditor_stateTreeItem::columnData(int column, int role) const { if (column >= m_columnData.size()) { return QVariant(); } if (role == Qt::ForegroundRole && parent() != NULL && hasChanged()) { return QVariant(QColor(Qt::red)); } if (role == Qt::ToolTipRole) { if (hasChanged()) { QString prevValue = getDiffedValue(); if (prevValue.isEmpty()) return ""; else return "Previous value was: " + prevValue; } } // catch any other roles that we don't specifically handle if (role != Qt::DisplayRole) { return QVariant(); } // return the data since the only role left is the DisplayRole return m_columnData[column]; }
bool ShortcutsModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role != ActiveShortcutRole) return false; if (!index.parent().isValid()) return false; Item *item = static_cast<Item *>(index.internalPointer()); Q_ASSERT(item); QKeySequence newSeq = value.value<QKeySequence>(); QKeySequence oldSeq = item->shortcut; QKeySequence storedSeq = item->action->shortcut(Action::ActiveShortcut); item->shortcut = newSeq; emit dataChanged(index, index.sibling(index.row(), 1)); if (oldSeq == storedSeq && newSeq != storedSeq) { if (++_changedCount == 1) emit hasChanged(true); } else if (oldSeq != storedSeq && newSeq == storedSeq) { if (--_changedCount == 0) emit hasChanged(false); } return true; }
void SettingsPage::setChangedState(bool hasChanged_) { if (hasChanged_ != _changed) { bool old = hasChanged(); _changed = hasChanged_; if (hasChanged() != old) emit changed(hasChanged()); } }
/** * @brief Load data using a MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use * @return Loading was successful */ bool TvShowEpisode::loadData(MediaCenterInterface *mediaCenterInterface, bool reloadFromNfo) { if ((m_infoLoaded || hasChanged()) && m_infoFromNfoLoaded) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadTvShowEpisode(this); else infoLoaded = mediaCenterInterface->loadTvShowEpisode(this, nfoContent()); if (!infoLoaded) { if (files().count() > 0) { QStringList filenameParts = files().at(0).split(QDir::separator()); QString filename = filenameParts.last(); if (filename.endsWith("VIDEO_TS.IFO", Qt::CaseInsensitive)) { if (filenameParts.count() > 1 && Helper::isDvd(files().at(0))) filename = filenameParts.at(filenameParts.count()-3); else if (filenameParts.count() > 2 && Helper::isDvd(files().at(0), true)) filename = filenameParts.at(filenameParts.count()-2); } else if (filename.endsWith("index.bdmv", Qt::CaseInsensitive)) { if (filenameParts.count() > 2) filename = filenameParts.at(filenameParts.count()-3); } setName(filename.replace(".", " ").replace("_", " ")); } } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); return infoLoaded; }
void KonviConfigDialog::updateButtons() { static bool only_once = false; if (only_once) return; only_once = true; QMap<QWidget *, KConfigDialogManager *>::iterator it; bool has_changed = d->manager->hasChanged() || hasChanged(); for (it = d->managerForPage.begin(); it != d->managerForPage.end() && !has_changed; ++it) { has_changed |= (*it)->hasChanged(); } enableButton(Apply, has_changed); bool is_default = d->manager->isDefault() && isDefault(); for (it = d->managerForPage.begin(); it != d->managerForPage.end() && is_default; ++it) { is_default &= (*it)->isDefault(); } enableButton(Default, !is_default); emit widgetModified(); only_once = false; }
void KonviConfigDialog::show() { QMap<QWidget *, KConfigDialogManager *>::iterator it; updateWidgets(); d->manager->updateWidgets(); for (it = d->managerForPage.begin(); it != d->managerForPage.end(); ++it) (*it)->updateWidgets(); bool has_changed = d->manager->hasChanged() || hasChanged(); for (it = d->managerForPage.begin(); it != d->managerForPage.end() && !has_changed; ++it) { has_changed |= (*it)->hasChanged(); } enableButton(Apply, has_changed); bool is_default = d->manager->isDefault() && isDefault(); for (it = d->managerForPage.begin(); it != d->managerForPage.end() && is_default; ++it) { is_default &= (*it)->isDefault(); } enableButton(Default, !is_default); d->shown = true; KDialogBase::show(); }
QString HashLineEdit::textIfSetted() { if(m_isDefaultValue && !hasChanged()) { return ""; } else { return text(); } }
/** * @brief Load data using the given MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use * @return Loading was successful or not */ bool TvShow::loadData(MediaCenterInterface *mediaCenterInterface, bool reloadFromNfo) { if (hasChanged() || (m_infoLoaded && m_infoFromNfoLoaded && !reloadFromNfo)) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadTvShow(this); else infoLoaded = mediaCenterInterface->loadTvShow(this, nfoContent()); if (!infoLoaded) { QStringList dirParts = this->dir().split(QDir::separator()); if (dirParts.count() > 0) setName(NameFormatter::instance()->formatName(dirParts.last())); } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); m_hasImage.clear(); foreach (const int &imageType, TvShow::imageTypes()) m_hasImage.insert(imageType, !mediaCenterInterface->imageFileName(this, imageType).isEmpty()); m_hasImage.insert(ImageType::TvShowExtraFanart, !mediaCenterInterface->extraFanartNames(this).isEmpty()); return infoLoaded; }
void CoreHighlightSettingsPage::save() { if (!hasChanged()) return; if (!_initialized) return; auto ruleManager = Client::highlightRuleManager(); if (ruleManager == nullptr) return; auto clonedManager = HighlightRuleManager(); clonedManager.fromVariantMap(ruleManager->toVariantMap()); clonedManager.clear(); for (auto &rule : highlightList) { clonedManager.addHighlightRule(rule.id, rule.name, rule.isRegEx, rule.isCaseSensitive, rule.isEnabled, false, rule.sender, rule.chanName); } for (auto &rule : ignoredList) { clonedManager.addHighlightRule(rule.id, rule.name, rule.isRegEx, rule.isCaseSensitive, rule.isEnabled, true, rule.sender, rule.chanName); } auto highlightNickType = ui.highlightNicksComboBox->itemData(ui.highlightNicksComboBox->currentIndex()).value<int>(); clonedManager.setHighlightNick(HighlightRuleManager::HighlightNickType(highlightNickType)); clonedManager.setNicksCaseSensitive(ui.nicksCaseSensitive->isChecked()); ruleManager->requestUpdate(clonedManager.toVariantMap()); setChangedState(false); load(); }
void DockManagerNotificationBackend::ConfigWidget::widgetChanged() { bool changed = enabled != enabledBox->isChecked(); if (changed != hasChanged()) setChangedState(changed); }
LibraryFile::~LibraryFile() { if (hasChanged()) { writeFile(); } qDeleteAll(m_libraryPatterns); }
void CoreHighlightSettingsPage::revert() { if (!hasChanged()) return; setChangedState(false); load(); }
//! Constructor ModelicaEditor::ModelicaEditor(ProjectTab *pParent) : QPlainTextEdit(pParent) { mpParentProjectTab = pParent; setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); setTabStopWidth(Helper::tabWidth); setObjectName("ModelicaEditor"); document()->setDocumentMargin(2); setLineWrapMode(QPlainTextEdit::NoWrap); // depending on the project tab readonly state set the text view readonly state setReadOnly(mpParentProjectTab->isReadOnly()); connect(this, SIGNAL(focusOut()), mpParentProjectTab, SLOT(modelicaEditorTextChanged())); connect(this, SIGNAL(textChanged()), SLOT(hasChanged())); mpFindWidget = new QWidget; mpFindWidget->setContentsMargins(0, 0, 0, 0); mpFindWidget->hide(); mpSearchLabelImage = new QLabel; mpSearchLabelImage->setPixmap(QPixmap(":/Resources/icons/search.png")); mpSearchLabel = new QLabel(Helper::search); mpSearchTextBox = new QLineEdit; connect(mpSearchTextBox, SIGNAL(textChanged(QString)), SLOT(updateButtons())); connect(mpSearchTextBox, SIGNAL(returnPressed()), SLOT(findNextText())); mpPreviuosButton = new QToolButton; mpPreviuosButton->setAutoRaise(true); mpPreviuosButton->setText(tr("Previous")); mpPreviuosButton->setIcon(QIcon(":/Resources/icons/previous.png")); mpPreviuosButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(mpPreviuosButton, SIGNAL(clicked()), SLOT(findPreviuosText())); mpNextButton = new QToolButton; mpNextButton->setAutoRaise(true); mpNextButton->setText(tr("Next")); mpNextButton->setIcon(QIcon(":/Resources/icons/next.png")); mpNextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); connect(mpNextButton, SIGNAL(clicked()), SLOT(findNextText())); mpMatchCaseCheckBox = new QCheckBox(tr("Match case")); mpMatchWholeWordCheckBox = new QCheckBox(tr("Match whole word")); mpCloseButton = new QToolButton; mpCloseButton->setAutoRaise(true); mpCloseButton->setIcon(QIcon(":/Resources/icons/exit.png")); connect(mpCloseButton, SIGNAL(clicked()), SLOT(hideFindWidget())); mpLineNumberArea = new LineNumberArea(this); connect(this, SIGNAL(blockCountChanged(int)), this, SLOT(updateLineNumberAreaWidth(int))); connect(this, SIGNAL(updateRequest(QRect,int)), this, SLOT(updateLineNumberArea(QRect,int))); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(highlightCurrentLine())); updateLineNumberAreaWidth(0); highlightCurrentLine(); // make previous and next buttons disabled for first time updateButtons(); }
void HashLineEdit::updateObjectName() { if(m_isDefaultValue) { if(!isModified() && !hasChanged()) { setStyleSheet("font-style: italic;"); } else { setStyleSheet("font-style: normal;"); } } }
void FileLists::run() { if (hasChanged()) { Logger::info("reload %s", m_pathname.c_str()); pthread_mutex_lock(&m_mutexLock); clear(); load(); pthread_mutex_unlock(&m_mutexLock); } }
toBrowserAccessWidget::toBrowserAccessWidget(QWidget * parent) : toBrowserBaseWidget(parent) { setObjectName("toBrowserAccessWidget"); #ifdef TOEXTENDED_MYSQL // This is propably never compiled... // I'm leaving this code as is UserPanel = new toMySQLUser(curr, TAB_ACCESS_USER); curr->addTab(UserPanel, tr("&User")); SecondMap[TAB_ACCESS] = UserPanel; SecondMap[TAB_ACCESS_USER] = UserPanel; AccessPanel = new toMySQLUserAccess(curr, TAB_ACCESS_OBJECTS); curr->addTab(AccessPanel, tr("&Objects")); SecondMap[TAB_ACCESS_OBJECTS] = UserPanel; // Yes, it should be // this one, it will // signal the // TAB_ACCESS_OBJECTS // to update. connect(AccessPanel, SIGNAL(hasChanged()), UserPanel, SLOT(hasChanged())); connect(UserPanel, SIGNAL(saveChanges(const QString &, const QString &)), AccessPanel, SLOT(saveChanges(const QString &, const QString &))); connect(UserPanel, SIGNAL(changeUser(const QString &)), AccessPanel, SLOT(changeUser(const QString &))); accessContent = new toResultData(curr, TAB_ACCESS_CONTENT); accessContent->setObjectName("accessContent"); #else accessContent = new toResultData(this); accessContent->setObjectName("accessContent"); connect(accessContent, SIGNAL(changesSaved()), this, SLOT(flushPrivs())); #endif changeConnection(); }
void ConfigSubscription::flip() { bool change = hasChanged(); if (change) { _current = std::move(_next); _lastGenerationChanged = _current->getGeneration(); } else { _current.reset(new ConfigUpdate(_current->getValue(), false, _next->getGeneration())); } _isChanged = change; }
/** * @brief Loads the concert infos with the given MediaCenterInterface * @param mediaCenterInterface MediaCenterInterface to use for loading * @param force Force the loading. If set to false and infos were already loeaded this function just returns * @return Loading was successful or not */ bool Concert::loadData(MediaCenterInterface *mediaCenterInterface, bool force, bool reloadFromNfo) { if ((m_infoLoaded || hasChanged()) && !force && m_infoFromNfoLoaded) return m_infoLoaded; bool infoLoaded; if (reloadFromNfo) infoLoaded = mediaCenterInterface->loadConcert(this); else infoLoaded = mediaCenterInterface->loadConcert(this, nfoContent()); if (!infoLoaded) { NameFormatter *nameFormat = NameFormatter::instance(); if (this->files().size() > 0) { QFileInfo fi(this->files().at(0)); if (QString::compare(fi.fileName(), "VIDEO_TS.IFO", Qt::CaseInsensitive) == 0) { QStringList pathElements = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (pathElements.size() > 0 && QString::compare(pathElements.last(), "VIDEO_TS", Qt::CaseInsensitive) == 0) pathElements.removeLast(); if (pathElements.size() > 0) setName(nameFormat->formatName(pathElements.last())); } else if (QString::compare(fi.fileName(), "index.bdmv", Qt::CaseInsensitive) == 0) { QStringList pathElements = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (pathElements.size() > 0 && QString::compare(pathElements.last(), "BDMV", Qt::CaseInsensitive) == 0) pathElements.removeLast(); if (pathElements.size() > 0) setName(nameFormat->formatName(pathElements.last())); } else if (inSeparateFolder()) { QStringList splitted = QDir::toNativeSeparators(fi.path()).split(QDir::separator()); if (!splitted.isEmpty()) { setName(nameFormat->formatName(splitted.last())); } else { if (files().size() > 1) setName(nameFormat->formatName(nameFormat->formatParts(fi.completeBaseName()))); else setName(nameFormat->formatName(fi.completeBaseName())); } } else { if (files().size() > 1) setName(nameFormat->formatName(nameFormat->formatParts(fi.completeBaseName()))); else setName(nameFormat->formatName(fi.completeBaseName())); } } } m_infoLoaded = infoLoaded; m_infoFromNfoLoaded = infoLoaded && reloadFromNfo; setChanged(false); return infoLoaded; }
std::string * LiveItem::valueIfChanged() { if (source) { if (hasChanged()) { std::string * response = new std::string(); std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> cv; *response = cv.to_bytes(source->json()); return response; } } return nullptr; }
void gui_mode::load(){ lastActiveModeAction = NULL; modeActionGroup = new QActionGroup(mainWindow()->modeMenu); /// Managed manually modeActionGroup->setExclusive(false); /// Default mode (Trackball) defaultModeAction = new QAction (QIcon(":/images/no_edit.png"),"Default", this); defaultModeAction->setCheckable(true); defaultModeAction->setShortcut(Qt::Key_Escape); /// Reacts to changes in mode connect(modeActionGroup,SIGNAL(triggered(QAction*)),this,SLOT(actionClicked(QAction*))); /// Reacts to changes made on the selection connect(document(),SIGNAL(hasChanged()),this,SLOT(documentChanged())); /// When document changes, we make sure render menu/toolbars are up to date connect(document(), SIGNAL(hasChanged()), this, SLOT(update())); /// Start state machine in default mode enterState(DEFAULT,defaultModeAction); }
void Transform::update() { bool changed = hasChanged(); if (changed) { updateModelTransform(); m_oldPosition = m_position; m_oldRotation = m_rotation; m_oldScale = m_scale; } if (m_needChildrenUpdate = changed || (getParent() != nullptr && getParent()->isChildrenUpdateNeeded())) updateRealValues(); }
void QtMultimediaNotificationBackend::ConfigWidget::widgetChanged() { if (!_audioAvailable) { ui.play->setEnabled(ui.enabled->isChecked()); ui.open->setEnabled(false); ui.filename->setEnabled(false); ui.filename->setText({}); } else { ui.play->setEnabled(ui.enabled->isChecked() && !ui.filename->text().isEmpty()); bool changed = (_enabled != ui.enabled->isChecked() || _filename != ui.filename->text()); if (changed != hasChanged()) setChangedState(changed); } }
void ConfigDlg::updateSettings() { kdDebug() << "updateSettings" << endl; KConfigDialog::updateSettings(); if (!hasChanged()) { return; } m_oldIconDimText = m_ui->iconDim->currentText(); if (m_ui->iconDim->currentText() == i18n("Automatic")) { m_settings->setIconDim(m_autoSize); } else { m_settings->setIconDim(m_ui->iconDim->currentText().toInt()); } settingsChangedSlot(); }
void executeCGOL(int x, int y, int seed) { Serial.println("executeCGOL\n"); b1 = (char*)malloc(sizeof(char)*x*y); b2 = (char*)malloc(sizeof(char)*x*y); fillBoard((char*)b1, x, y, seed); long itercount =0; while (itercount<MAX_GEN && aliveCount(b1, x,y)>3) { char *artemp = b1; b1=generate(b1,b2, x, y); b2 = artemp; // display board displayBoard(b1); delay(1000); if(!hasChanged(b1, b2, x, y)) { delay(60000); break; } } }
void BufferViewOverlayFilter::setOverlay(BufferViewOverlay *overlay) { if (_overlay == overlay) return; if (_overlay) { disconnect(_overlay, 0, this, 0); } _overlay = overlay; if (!overlay) { invalidate(); return; } connect(overlay, SIGNAL(destroyed()), this, SLOT(overlayDestroyed())); connect(overlay, SIGNAL(hasChanged()), this, SLOT(invalidate())); invalidate(); }
// we need this function to SAVE settings in rc file.. void SettingsDialog::saveSettings() { if (!hasChanged()) return; ReKonfig::self()->writeConfig(); d->generalWidg->save(); d->tabsWidg->save(); d->appearanceWidg->save(); d->webkitWidg->save(); d->networkWidg->save(); d->adBlockWidg->save(); d->shortcutsEditor->save(); d->ebrowsingModule->save(); SearchEngine::reload(); Application::opensearchManager()->removeDeletedEngines(); updateButtons(); emit settingsChanged("ReKonfig"); }
void ConfigureDialog::updateSettings() { bool changed = hasChanged(); configDic->updateSettings(); if (changed) KConfigDialog::settingsChangedSlot(); }
void HashLineEdit::mousePressEvent(QMouseEvent * event) { if(m_isDefaultValue && !isModified() && !hasChanged()) { setText(""); } QLineEdit::mousePressEvent(event); }
inline void TagDialog::checkModified() //SLOT { pushButton_ok->setEnabled( hasChanged() || storedTags.count() > 0 || storedScores.count() > 0|| storedLyrics.count() > 0 ); }
int main(int argc, char* argv[]) { unsigned char ret; char c; char len; char i; char* annoyname = "Annoy_Light"; char* stairname = "Stair_Light"; DDRC = 0; PORTC = 0x7; unsigned char did = 1; // define direction of inputs and outputs // 1 for output, 0 for input // | for output, & for input DDRD = (1<<RELAY_STAIRS); DDRD |= (1<<RELAY_ANNOY); did = PINC & 0x7; serial_init(); buf_index = 0; transmit_flag = 0; // FILE s=FDEV_SETUP_STREAM(send_char_serial,NULL,_FDEV_SETUP_WRITE); // stdout=&s; // sei(); Device* annoydevice = createDevice(annoyname, 1, buffered_send_char); Device* stairdevice = createDevice(stairname, 1, buffered_send_char); setDeviceCName("Annoying Light", annoydevice); setDeviceCName("Stairs Light", stairdevice); setDeviceLocation(0, 0, 0, 0, annoydevice); setDeviceLocation(0, 0, 0, 0, stairdevice); addField(BOOL, "Light Status", 0, 1, 0, annoydevice); addField(BOOL, "Light Status", 0, 1, 0, stairdevice); while (1) { c = receive_char_serial(); if (c == '\0') { if (receive_char_serial() == did) { serial_tx_enable(); if (transmit_flag) { len = buf[0] + 1; // printf("sending packet %d\n", buf[3]); for (i = 0; i < len; i++) { send_char_serial(buf[i]); } // printf("bi:%d %d %d\n", buf_index, len, buf[3]); for (i = len; i < buf_index; i++) { buf[i-len] = buf[i]; } buf_index -= len; if (buf_index == 0) { transmit_flag = 0; } } else { send_char_serial('\0'); } serial_tx_disable(); } } else { len = c; recvChar(len, annoydevice); recvChar(len, stairdevice); for (i = 0; i < len; i++) { c = receive_char_serial(); recvChar(c, annoydevice); recvChar(c, stairdevice); if (shouldBreak(annoydevice)) break; if (shouldBreak(stairdevice)) break; } } /* if (((r_front + 1) % MAX_LEN) != r_back) { r_front++; if (r_front == MAX_LEN) { r_front = 0; } recvChar(r_buf[r_front], device); } */ if (hasChanged(0, annoydevice)) { ret = getBoolVal(0, annoydevice); if (ret) { RELAY_ANNOY_ON(); } else { RELAY_ANNOY_OFF(); } } if (hasChanged(0, stairdevice)) { ret = getBoolVal(0, stairdevice); if (ret) { RELAY_STAIRS_ON(); } else { RELAY_STAIRS_OFF(); } } } return 0; }