Ejemplo n.º 1
0
void KateProject::slotModifiedChanged(KTextEditor::Document* document) {
  KateProjectItem *item = itemForFile (m_documents.value (document));
  
  if (!item) return;
  
  item->slotModifiedChanged(document);
}
Ejemplo n.º 2
0
void KateProject::registerDocument (KTextEditor::Document *document)
{
  // remember the document, if not already there
  if (!m_documents.contains(document))
    m_documents[document] = document->url().toLocalFile ();
  
  // try to get item for the document
  KateProjectItem *item = itemForFile (document->url().toLocalFile ());
  
  // if we got one, we are done, else create a dummy!
  if (item) {
    disconnect(document,SIGNAL(modifiedChanged(KTextEditor::Document *)),this,SLOT(slotModifiedChanged(KTextEditor::Document *)));
    disconnect(document,SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)),this,SLOT(slotModifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)));
    item->slotModifiedChanged(document);
    
/*FIXME    item->slotModifiedOnDisk(document,document->isModified(),qobject_cast<KTextEditor::ModificationInterface*>(document)->modifiedOnDisk()); FIXME*/
    
    connect(document,SIGNAL(modifiedChanged(KTextEditor::Document *)),this,SLOT(slotModifiedChanged(KTextEditor::Document *)));
    connect(document,SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)),this,SLOT(slotModifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)));

    return;
  }
  
  // perhaps create the parent item
  if (!m_documentsParent) {
    m_documentsParent = new KateProjectItem (KateProjectItem::Directory, i18n ("<untracked>"));
    m_model.insertRow (0, m_documentsParent);
  }
  
  // create document item
  QFileInfo fileInfo (document->url().toLocalFile ());
  KateProjectItem *fileItem = new KateProjectItem (KateProjectItem::File, fileInfo.fileName());
  fileItem->setData(document->url().toLocalFile (), Qt::ToolTipRole);
  fileItem->slotModifiedChanged(document);
  connect(document,SIGNAL(modifiedChanged(KTextEditor::Document *)),this,SLOT(slotModifiedChanged(KTextEditor::Document *)));
  connect(document,SIGNAL(modifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)),this,SLOT(slotModifiedOnDisk(KTextEditor::Document*,bool,KTextEditor::ModificationInterface::ModifiedOnDiskReason)));

  
  bool inserted = false;
  for (int i = 0; i < m_documentsParent->rowCount(); ++i) {
        if (m_documentsParent->child (i)->data(Qt::UserRole).toString() > document->url().toLocalFile ()) {
          m_documentsParent->insertRow (i, fileItem);
          inserted = true;
          break;
        }
  }
  if (!inserted)
    m_documentsParent->appendRow (fileItem);
  
  fileItem->setData (document->url().toLocalFile (), Qt::UserRole);
  fileItem->setData (QVariant (true), Qt::UserRole + 3);
  
  if (!m_file2Item)
    m_file2Item = KateProjectSharedQMapStringItem (new QMap<QString, KateProjectItem *> ());
  (*m_file2Item)[document->url().toLocalFile ()] = fileItem;
}
Ejemplo n.º 3
0
void KateProject::slotModifiedOnDisk (KTextEditor::Document *document,
      bool isModified, KTextEditor::ModificationInterface::ModifiedOnDiskReason reason) {
  
  KateProjectItem *item = itemForFile (m_documents.value (document));
    
  if (!item) return;
  
  item->slotModifiedOnDisk(document,isModified, reason);
  
}
void PromptOverwriteDialog::setFileEnabled(const QString &f, bool e)
{
    if (QStandardItem *item = itemForFile(f)) {
        Qt::ItemFlags flags = item->flags();
        if (e)
            flags |= Qt::ItemIsEnabled;
        else
            flags &= ~Qt::ItemIsEnabled;
        item->setFlags(flags);
    }
}
Ejemplo n.º 5
0
void KateProject::unregisterDocument (KTextEditor::Document *document)
{
  // skip if no works
  if (!m_documents.contains (document))
    return;
  
  // perhaps kill the item we have generated
  bool empty = false;
  if (KateProjectItem *item = (KateProjectItem*)itemForFile (m_documents.value (document))) {
    disconnect(document,SIGNAL(modifiedChanged(KTextEditor::Document *)),this,SLOT(slotModifiedChanged(KTextEditor::Document *)));
    if (m_documentsParent && item->data (Qt::UserRole + 3).toBool ()) {
      for (int i = 0; i < m_documentsParent->rowCount(); ++i) {
        if (m_documentsParent->child (i) == item) {
          m_documentsParent->removeRow (i);
          break;
        }
      }
      
      empty = !m_documentsParent->rowCount();
      
      m_file2Item->remove (m_documents.value (document));
    }
  }
bool PromptOverwriteDialog::isFileChecked(const QString &f) const
{
    if (const QStandardItem *item = itemForFile(f))
        return item->checkState() == Qt::Checked;
    return false;
}
void PromptOverwriteDialog::setFileChecked(const QString &f, bool e)
{
    if (QStandardItem *item = itemForFile(f))
        item->setCheckState(e ? Qt::Checked : Qt::Unchecked);
}
bool PromptOverwriteDialog::isFileEnabled(const QString &f) const
{
    if (const QStandardItem *item = itemForFile(f))
        return (item->flags() & Qt::ItemIsEnabled);
    return false;
}