Exemple #1
0
bool DocumentEditor::save() {
	if (!isModified() && QFile::exists(getFullPath()))
		return true;
	if (_fullPath.isEmpty()) {
		return saveAs();
	} else {
		return saveFile(_fullPath);
	}
}
void RKCommandEditorWindow::updateCaption () {
	RK_TRACE (COMMANDEDITOR);
	QString name = m_doc->url ().fileName ();
	if (name.isEmpty ()) name = m_doc->url ().prettyURL ();
	if (name.isEmpty ()) name = i18n ("Unnamed");
	if (isModified ()) name.append (i18n (" [modified]"));

	setCaption (name);
}
Exemple #3
0
void OSPRayMaterial::commit(const std::string& renderer)
{
    if (!isModified())
        return;
    ospRelease(_ospMaterial);
    _ospMaterial = ospNewMaterial2(renderer.c_str(), "default_material");
    markModified(false); // Ensure commit recreates the ISPC object
    commit();
}
Exemple #4
0
void ReportWindow::setCaption() {
    QString cap = QString();
    if(_title.isEmpty()) cap = tr("Untitled Document");
    else cap = _title;
    if(isModified()) {
        cap += tr(" *");
    }
    Q3MainWindow::setCaption(cap);
}
Exemple #5
0
 void MetaDataStore::reset() {
     for (int i = 0; i < _data.count(); i++) {
         const MetaData meta = _data[i];
         if (isModified(meta)) {
             _data.replace(i, _backup[meta.id()]);
         }
     }
     _backup.clear();
     _only_path_changed.clear();
 }
Exemple #6
0
 QList<MetaData> MetaDataStore::modifiedExcludingOnlyRenamed() const {
     QList<MetaData> modified;
     modified.reserve(_backup.count() - _only_path_changed.count());
     foreach (const MetaData meta, _data) {
         if (isModified(meta) && !_only_path_changed.contains(meta.id())) {
             modified << meta;
         }
     }
     return modified;
 }
bool ContactView::CheckSaving()
{
  if (isEditing() && isModified())
  {
    QMessageBox::StandardButton ret;
    ret = QMessageBox::question(this, tr("Application"),
                                tr("The contact has been modified.\nDo you want to save your changes ?"),
                                QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
    if (ret == QMessageBox::Cancel)
    {
      ui->firstname->setFocus();
      return false;
    }
    else
    {
      if (ret == QMessageBox::Yes)
      {
        if (isValid())
        {
          onSave();
        }
        else
        {
          QMessageBox::warning(this, tr("Application"),
                               tr("Please correct the Keyhotee ID."),
                               QMessageBox::Ok);
          return false;
        }
      }
      else
      {
        onCancel();
      }
      setModified(false);
    }
  }
  else if (isEditing() && !isModified())
  {
    onCancel();
  }
  return true;
}
QString RKCommandEditorWindow::fullCaption () {
	RK_TRACE (COMMANDEDITOR);

	if (m_doc->url ().isEmpty ()) {
		return (shortCaption ());
	} else {
		QString cap = m_doc->url ().url ();
		if (isModified ()) cap.append (i18n (" [modified]"));
		return (cap);
	}
}
void BtLineEdit::lineChanged(Unit::unitDisplay oldUnit, Unit::unitScale oldScale)
{
   // This is where it gets hard
   double val = -1.0;
   QString amt;
   bool force = Brewtarget::hasUnits(text());
   bool ok = false;
   bool wasChanged = sender() == this;

   // editingFinished happens on focus being lost, regardless of anything
   // being changed. I am hoping this short circuits properly and we do
   // nothing if nothing changed.
   if ( sender() == this && ! isModified() )
   {
      return;
   }

   if (text().isEmpty())
   {
      return;
   }

   // The idea here is we need to first translate the field into a known
   // amount (aka to SI) and then into the unit we want.
   switch( _type )
   {
      case Unit::Mass:
      case Unit::Volume:
      case Unit::Temp:
      case Unit::Time:
      case Unit::Density:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,3);
         break;
      case Unit::Color:
         val = toSI(oldUnit,oldScale,force);
         amt = displayAmount(val,0);
         break;
      case Unit::String:
         amt = text();
         break;
      case Unit::None:
      default:
         val = Brewtarget::toDouble(text(),&ok);
         if ( ! ok )
            Brewtarget::logW( QString("%1: failed to convert %2 (%3:%4) to double").arg(Q_FUNC_INFO).arg(text()).arg(_section).arg(_editField) );
         amt = displayAmount(val);
   }
   QLineEdit::setText(amt);

   if ( wasChanged ) {
      emit textModified();
   }
}
void SettingsWidget::save()
{
	if(!isModified())
		return;
	p->sleep = true;
	saveImpl();
	p->clearValues();
	p->sleep = false;
	emit saved();
	emit modifiedChanged(false);
}
void ProjectController::load()
{
    if (isModified())
        throw ProjectIsModifiedException();
    if (!m_project->hasFileName())
        throw NoFileNameException();
    ProjectSerializer serializer;
    serializer.load(m_project->fileName(), m_project.data());
    m_isModified = false;
    emit changed();
}
QUndoCommand * KarbonPatternEditStrategyBase::createCommand()
{
    KoPatternBackground * fill = dynamic_cast<KoPatternBackground*>( m_shape->background() );
    if( fill && isModified() )
    {
        *fill = m_oldFill;
        KoPatternBackground * newFill = new KoPatternBackground( m_imageCollection );
        *newFill = m_newFill;
        return new KoShapeBackgroundCommand( m_shape, newFill, 0 );
    }
    return 0;
}
void RKCommandEditorWindow::closeEvent (QCloseEvent *e) {
	if (isModified ()) {
		int status = KMessageBox::warningYesNo (this, i18n ("The document \"%1\" has been modified. Close it anyway?").arg (caption ()), i18n ("File not saved"));
	
		if (status != KMessageBox::Yes) {
			e->ignore ();
			return;
		}
	}

	QWidget::closeEvent (e);
}
Exemple #14
0
//-----------------------------------------------------------------------------
// Function: updateTabTitle()
//-----------------------------------------------------------------------------
void TabDocument::updateTabTitle()
{
    // Update also the title.
    if (isModified())
    {
        setTabTitle(docName_ + docType_ + "*");
    }
    else
    {
        setTabTitle(docName_ + docType_);
    }
}
Exemple #15
0
 QHash<QString, QString> MetaDataStore::renamedPaths() const {
     QHash<QString, QString> paths;
     foreach (const MetaData meta, _data) {
         if (isModified(meta)) {
             const MetaData orig = _backup[meta.id()];
             if (meta.path() != orig.path()) {
                 paths.insert(orig.path(), meta.path());
             }
         }
     }
     return paths;
 }
/// Function name  : onDocumentsControl_ContextMenu
// Description     : Displays the tab context menu and implements it's commands
// 
// DOCUMENTS_DATA*  pWindowData  : [in] Documents data
// CONST POINT*     ptClick      : [in] Cursor position (in screen co-ordinates)
// 
BOOL  onDocumentsControl_ContextMenu(DOCUMENTS_DATA*  pWindowData, CONST POINT*  ptClick)
{
   TCHITTESTINFO  oHitTest;            // Document tab HitTest
   CUSTOM_MENU*   pCustomMenu;         // Custom menu
   DOCUMENT*      pDocument;           // Document that was clicked, if any
   INT            iDocumentIndex;      // Index of the document that was clicked

   // Prepare
   oHitTest.pt    = *ptClick;
   oHitTest.flags = TCHT_ONITEM;

   /// [CHECK] Has the user clicked a tab heading?
   ScreenToClient(pWindowData->hTabCtrl, &oHitTest.pt);
   iDocumentIndex = TabCtrl_HitTest(pWindowData->hTabCtrl, &oHitTest);

   // Lookup document (Will fails if user did not click a tab heading)
   if (findDocumentByIndex(pWindowData->hTabCtrl, iDocumentIndex, pDocument))
   {
      CONSOLE_ACTION();

      // Generate custom menu
      pCustomMenu = createCustomMenu(TEXT("DIALOG_MENU"), TRUE, IDM_DOCUMENT_POPUP);

      /// Enable/Disable menu items
      EnableMenuItem(pCustomMenu->hPopup, IDM_FILE_SAVE,                    isModified(pDocument) ? MF_ENABLED : MF_DISABLED);
      EnableMenuItem(pCustomMenu->hPopup, IDM_WINDOW_CLOSE_OTHER_DOCUMENTS, getDocumentCount() > 1 ? MF_ENABLED : MF_DISABLED);

      // Enable/Disable project items
      EnableMenuItem(pCustomMenu->hPopup, IDM_DOCUMENT_ADD_PROJECT,    getActiveProject() AND !isDocumentInProject(pDocument) ? MF_ENABLED : MF_DISABLED);
      EnableMenuItem(pCustomMenu->hPopup, IDM_DOCUMENT_REMOVE_PROJECT, getActiveProject() AND isDocumentInProject(pDocument)  ? MF_ENABLED : MF_DISABLED);

      /// Display context menu and return choice immediately
      switch (TrackPopupMenu(pCustomMenu->hPopup, TPM_RETURNCMD WITH TPM_TOPALIGN WITH TPM_LEFTALIGN, ptClick->x, ptClick->y, NULL, pWindowData->hTabCtrl, NULL))
      {
      // [SAVE/CLOSE/CLOSE-OTHER] Perform relevant command
      case IDM_FILE_SAVE:                     commandSaveDocument(getMainWindowData(), pDocument, FALSE, NULL);  break;
      case IDM_FILE_CLOSE:                    closeDocumentByIndex(pWindowData->hTabCtrl, iDocumentIndex);       break;
      case IDM_WINDOW_CLOSE_OTHER_DOCUMENTS:  closeAllDocuments(pWindowData->hTabCtrl, TRUE);                    break;

      // [ADD/REMOVE PROJECT] TODO
      case IDM_DOCUMENT_ADD_PROJECT:          addDocumentToProject(pDocument);         break;
      case IDM_DOCUMENT_REMOVE_PROJECT:       removeDocumentFromProject(pDocument);    break;
         break;
      }

      // Cleanup
      deleteCustomMenu(pCustomMenu);
   }
   
   // Return TRUE if handled, otherwise FALSE
   return (iDocumentIndex != -1);
}
Exemple #17
0
void
Job::saveQueueFile() {
  if (m_uuid.isNull())
    m_uuid = QUuid::createUuid();

  auto fileName = queueFileName();
  if (!isModified() && QFileInfo{ fileName }.exists())
    return;

  auto settings = Util::ConfigFile::create(fileName);
  saveJob(*settings);
  settings->save();
}
void ProjectController::load()
{
    if (isModified()) {
        throw ProjectIsModifiedException();
    }
    if (!_project->hasFileName()) {
        throw NoFileNameException();
    }
    ProjectSerializer serializer;
    serializer.load(_project->getFileName(), _project.data());
    _is_modified = false;
    emit changed();
}
Exemple #19
0
bool SourceFile::closeEvent()
{
    if ( !isModified() && fileNameTemp ) {
	pro->removeSourceFile( this );
	return TRUE;
    }

    if ( !isModified() )
	return TRUE;

    if ( ed )
	ed->save();

    switch ( QMessageBox::warning( MainWindow::self, tr( "Save Code" ),
				   tr( "Save changes to '%1'?" ).arg( filename ),
				   tr( "&Yes" ), tr( "&No" ), tr( "&Cancel" ), 0, 2 ) ) {
    case 0: // save
	if ( !save() )
	    return FALSE;
	break;
    case 1: // don't save
	load();
	if ( ed )
	    ed->editorInterface()->setText( txt );
	if ( fileNameTemp ) {
	    pro->removeSourceFile( this );
	    return TRUE;
	}
	if ( MainWindow::self )
	    MainWindow::self->workspace()->update();
	break;
    case 2: // cancel
	return FALSE;
    default:
	break;
    }
    setModified( FALSE );
    return TRUE;
}
Exemple #20
0
bool KdevDoc::canCloseFrame(KdevView* pFrame)
{
	if(!isLastView())
		return true;
		
	bool ret=false;
  if(isModified())
  {
		QString saveName;
  	switch(QMessageBox::information(pFrame, title(), tr("The current file has been modified.\n"
                          "Do you want to save it?"),QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel ))
    {
			case QMessageBox::Yes:
				if(title().contains(tr("Untitled")))
				{
					saveName=QFileDialog::getSaveFileName(0, 0, pFrame);
          if(saveName.isEmpty())
          	return false;
				}
				else
					saveName=pathName();
					
				if(!saveDocument(saveName))
				{
 					switch(QMessageBox::critical(pFrame, tr("I/O Error !"), tr("Could not save the current document !\n"
																												"Close anyway ?"),QMessageBox::Yes ,QMessageBox::No))
 	
 					{
 						case QMessageBox::Yes:
 							ret=true;
 						case QMessageBox::No:
 							ret=false;
 					}	        			
				}
				else
					ret=true;
				break;
			case QMessageBox::No:
				ret=true;
				break;
			case QMessageBox::Cancel:
			default:
				ret=false; 				
				break;
		}
	}
	else
		ret=true;
		
	return ret;
}
int OptVectorLayer::addFeatureWithDefaultValue( OptFeature& f )
{
//{zhangliye2715:api}
  if ( !isEditable() )
  {
    startEditing();
  }

  // add the fields to the QgsFeature
  QgsVectorDataProvider* provider = dataProvider();
  const QgsFieldMap fields = provider->fields();

  for ( QgsFieldMap::const_iterator it = fields.begin(); it != fields.end(); ++it )
  {
    f.addAttribute( it.key(), provider->defaultValue( it.key() ) );
  }

  int id = -1;
  id = OptVectorLayer::addFeature( f );
  if ( id != -1 )
  {
    //add points to other features to keep topology up-to-date
    int topologicalEditing = QgsProject::instance()->readNumEntry( "Digitizing", "/TopologicalEditing", 0 );

    if( topologicalEditing )
    {
      addTopologicalPoints( f.geometry() );
    }
  }
  else
  {
    return -1;
  }

  //vlayer->setModified(true);
  //commit or rollBack the change
  if ( isModified() )
  {
    commitChanges();
  }
  else
  {
    rollBack();
    return -1;
  }

  //make the layer still editable for the next adding operation
  startEditing();

  return id;
}
/// Function name  : isAnyDocumentModified
// Description     : Determines whether any document is modified
// 
// HWND  hTabCtrl : [in] Documents control
//
// Return Value   : TRUE if there is at least one modified document, otherwise FALSE
// 
BOOL   isAnyDocumentModified(HWND  hTabCtrl)
{
   DOCUMENTS_DATA*  pWindowData;     // Window data
   DOCUMENT*        pDocument;       // Current document
   BOOL             bModified;
   
   // Prepare
   pWindowData = getDocumentsControlData(hTabCtrl);
   bModified   = FALSE;
   
   /// [DOCUMENTS] Iterate through document list
   for (LIST_ITEM*  pIterator = getListHead(pWindowData->pDocumentList); !bModified AND (pDocument = extractListItemPointer(pIterator, DOCUMENT)); pIterator = pIterator->pNext)
      // [CHECK] Abort if document is modified...
      if (isModified(pDocument))
         bModified = TRUE;

   /// [PROJECT] Check project, if any
   if (!bModified)
      bModified = isModified(getActiveProject());
   
   // Return state
   return bModified;
}
void UndoGroup::checkAllCleanStates()
{
    bool clean = true;
    
    foreach(QUndoStack* stack, stacks()) {
        if(!stack->isClean()) {
            clean = false;
            break;
        }
    }

    //TODO: don't emit on every entry only when the state changes.
    emit isModified(!clean);
}
Exemple #24
0
void HCGinputline::keyPressEvent(QKeyEvent *event)
{
  if (event->key() == Qt::Key_Up || event->key() == Qt::Key_Down)
  {
    char direction = event->key() == Qt::Key_Up ? HCG_IL_BACK : HCG_IL_FORWARD;
    if (isModified()) history_insert(text(), history_cur);
    setModified(FALSE);
    QString tmp = history(direction);
    if (!tmp.isNull())
      setText(tmp);
  } else {
    QLineEdit::keyPressEvent(event);
  }
}
Exemple #25
0
bool DocumentEditor::reload() {
	if(isModified()) {
		int ret = QMessageBox::warning(this,
									   tr("Reload file"),
									   tr("File %1 has unsaved modifications.\n"
										  "Reloading will discard them.\n"
										  "Do you want to proceed?").arg(getName()),
									   QMessageBox::Yes |
									   QMessageBox::Cancel);
		if (ret == QMessageBox::Cancel)
			return false;
	}
	return load(getFullPath());
}
void BasePropertyWidget::setWidgetDirty()
{
	validate();
	if(isModified())
	{
		setState(State::modified);
		if (m_parent)
			m_parent->setState(State::modified);
		else if(m_property->saveTrigger() == Property::SaveTrigger::asap)
			updatePropertyValue();
	}
	else if(m_state == State::modified)
		setState(State::unchanged);
}
int QGraphicsWebView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGraphicsWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 17)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 17;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = title(); break;
        case 1: *reinterpret_cast< QIcon*>(_v) = icon(); break;
        case 2: *reinterpret_cast< qreal*>(_v) = zoomFactor(); break;
        case 3: *reinterpret_cast< QUrl*>(_v) = url(); break;
        case 4: *reinterpret_cast< bool*>(_v) = isModified(); break;
        case 5: *reinterpret_cast< bool*>(_v) = resizesToContents(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isTiledBackingStoreFrozen(); break;
        case 7: *reinterpret_cast<int*>(_v) = QFlag(renderHints()); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 2: setZoomFactor(*reinterpret_cast< qreal*>(_v)); break;
        case 3: setUrl(*reinterpret_cast< QUrl*>(_v)); break;
        case 5: setResizesToContents(*reinterpret_cast< bool*>(_v)); break;
        case 6: setTiledBackingStoreFrozen(*reinterpret_cast< bool*>(_v)); break;
        case 7: setRenderHints(QFlag(*reinterpret_cast<int*>(_v))); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
/*!
    \fn OptVectorLayer:: changeAttribute(QgsFeature& feature, int field, QVariant attr)
 */
bool OptVectorLayer:: changeAttribute(QgsFeature& feature, int field, QVariant attr)
{
  if ( !isEditable() )
  {
    startEditing();
  }
  if ( isModified() )
  {
    commitChanges();
  }

  QgsChangedAttributesMap attributeChanges;
  QgsAttributeMap newAttMap;
  newAttMap.insert(field, attr );
	attributeChanges.insert(feature.id(), newAttMap);
//{zhangliye2715} ;api changed
//   commitAttributeChanges(QgsAttributeIds(),
//           QgsNewAttributesMap(),
//           attributeChanges);
	dataProvider()->changeAttributeValues(attributeChanges);

  //commit or rollBack the change
  if ( isModified() )
  {
    commitChanges();
  }
  else
  {
    rollBack();
    return false;
  }

  //make the layer still editable for the next adding operation
  startEditing();

  return true;
}
Exemple #29
0
         bool CIniImpl::Close()
         {
            TRACE_FUN( Routine, "CIniImpl::Close" );

            if( !isModified() && CThread::isRun() )
            {
               synchronization().terminate();
            }
            
            WaitForDriverStop();

            bool ret( false );
            
            CMutexLocker locker( synchronization().mutex() );

            if( !( ret = !isModified() ) )
            {
               CFile theFile( file() );
               if( !hasError() && theFile.open( CFile::omWriteOnly | CFile::omTruncate ) )
               {
                  std::string buf;
   
                  buf += "/*********************************************************" + CBaseSerializer::cr() +
                         " * The file was generated by l2Registry driver" + CBaseSerializer::cr() +
                         " * Name: " + _registryDriverInfo._name + CBaseSerializer::cr() +
                         " * Description: " + _registryDriverInfo._description + CBaseSerializer::cr() +
                         " * Version: " + _registryDriverInfo._version + CBaseSerializer::cr() +
                         " *********************************************************/" + CBaseSerializer::cr();
   
                  buf += CTextIniCategorySerializer( category()->members(), 0 ).serialized();
   
                  ret = theFile.write( buf.c_str(), buf.size() ) == buf.size();
               }
            }
            
            return ret;
         }
Exemple #30
0
void Dentry::endEdit()
{
	if (isModified())
	{
		if (setSValue(text()))
		{
			setString(val);
			return;
		}
	}
	setString(val);
	clearFocus();
	if (!drawFrame)
		QLineEdit::setFrame(false);
}