void NotificationsModel::refreshNotificationList()
{
    if (!m_dbusInterface) {
        return;
    }

    if (!m_notificationList.isEmpty()) {
        beginRemoveRows(QModelIndex(), 0, m_notificationList.size() - 1);
        qDeleteAll(m_notificationList);
        m_notificationList.clear();
        endRemoveRows();
    }

    if (!m_dbusInterface->isValid()) {
        kDebug(debugArea()) << "dbus interface not valid";
        return;
    }

    QDBusPendingReply<QStringList> pendingNotificationIds = m_dbusInterface->activeNotifications();
    pendingNotificationIds.waitForFinished();
    if (pendingNotificationIds.isError()) {
        kDebug(debugArea()) << pendingNotificationIds.error();
        return;
    }
    const QStringList& notificationIds = pendingNotificationIds.value();

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

    beginInsertRows(QModelIndex(), 0, notificationIds.size() - 1);
    Q_FOREACH (const QString& notificationId, notificationIds) {
        NotificationDbusInterface* dbusInterface = new NotificationDbusInterface(m_deviceId, notificationId, this);
        m_notificationList.append(dbusInterface);
    }
예제 #2
0
void KateFileTreeConfigPage::slotMyChanged()
{
  kDebug(debugArea()) << "BEGIN";
  m_changed = true;
  emit changed();
  kDebug(debugArea()) << "END";
}
예제 #3
0
void KateFileTreeConfigPage::defaults()
{
  kDebug(debugArea()) << "BEGIN";

  // m_plug->settings().revertToDefaults() ??
  // not sure the above is ever needed...

  reset();

  kDebug(debugArea()) << "END";
}
예제 #4
0
void KateFileTree::slotCurrentChanged ( const QModelIndex &current, const QModelIndex &previous )
{
  kDebug(debugArea()) << "current:" << current << "previous:" << previous;

  if(!current.isValid())
    return;
  
  KTextEditor::Document *doc = model()->data(current, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
  if(doc) {
    kDebug(debugArea()) << "got doc, setting prev:" << current;
    m_previouslySelected = current;
  }
}
예제 #5
0
void KateFileTreeConfigPage::reset()
{
  kDebug(debugArea()) << "BEGIN";

  const KateFileTreePluginSettings &settings = m_plug->settings();

  gbEnableShading->setChecked( settings.shadingEnabled() );
  kcbEditShade->setColor( settings.editShade() );
  kcbViewShade->setColor( settings.viewShade() );
  cmbSort->setCurrentIndex( cmbSort->findData( settings.sortRole() ) );
  cmbMode->setCurrentIndex( settings.listMode() );
  cbShowFullPath->setCheckState( settings.showFullPathOnRoots() ? Qt::Checked : Qt::Unchecked );

  m_changed = false;
  kDebug(debugArea()) << "END";
}
예제 #6
0
void KateFileTree::mouseClicked ( const QModelIndex &index )
{
  kDebug(debugArea()) << "got index" << index;

  KTextEditor::Document *doc = model()->data(index, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
  if(doc) {
    kDebug(debugArea()) << "got doc" << index << "setting prev:" << QModelIndex();
    emit activateDocument(doc);
    //m_previouslySelected = QModelIndex();
  }
  else {
    kDebug(debugArea()) << "selecting previous item" << m_previouslySelected;

    selectionModel()->setCurrentIndex(m_previouslySelected,QItemSelectionModel::ClearAndSelect);
  }
  
}
예제 #7
0
파일: Tutorial.cpp 프로젝트: KDE/ktutorial
void Tutorial::nextStep(const QString& id) {
    if (!d->mSteps.contains(id)) {
        kError(debugArea()) << "No step" << id << "found in tutorial"
                            << d->mTutorialInformation->id();
        return;
    }

    nextStep(d->mSteps.value(id));
}
예제 #8
0
파일: Tutorial.cpp 프로젝트: KDE/ktutorial
void Tutorial::changeToStep(Step* step) {
    if (d->mSteps.key(step).isEmpty()) {
        kError(debugArea()) << "Activate step" << step->id()
                            << "which doesn't belong to tutorial"
                            << d->mTutorialInformation->id();
        return;
    }

    if (d->mCurrentStep != 0) {
        d->mCurrentStep->setActive(false);
    }

    kDebug(debugArea()) << "Next step:" << step->id();

    d->mCurrentStep = step;
    d->mCurrentStep->setActive(true);

    emit stepActivated(step);
}
예제 #9
0
파일: Tutorial.cpp 프로젝트: KDE/ktutorial
void Tutorial::start() {
    setup();

    if (!d->mSteps.contains("start")) {
        kError(debugArea()) << "No start step found in tutorial"
                            << d->mTutorialInformation->id();
        finish();
        return;
    }

    nextStep("start");
}
예제 #10
0
void KateFileTreeConfigPage::apply()
{
  kDebug(debugArea()) << "BEGIN";
  if ( ! m_changed ) {
    kDebug(debugArea()) << "END !changed";
    return;
  }

  m_changed = false;

  // apply config to views
  m_plug->applyConfig(
    gbEnableShading->isChecked(),
    kcbViewShade->color(),
    kcbEditShade->color(),
    cmbMode->itemData(cmbMode->currentIndex()).toBool(),
    cmbSort->itemData(cmbSort->currentIndex()).toInt(),
    cbShowFullPath->checkState() == Qt::Checked
  );

  kDebug(debugArea()) << "END";
}
예제 #11
0
파일: Tutorial.cpp 프로젝트: KDE/ktutorial
void Tutorial::addStep(Step* step) {
    if (d->mSteps.contains(step->id())) {
        kWarning(debugArea()) << "Step with id" << step->id()
                              << "already added in tutorial"
                              << d->mTutorialInformation->id();
        return;
    }

    step->setParent(this);

    d->mSteps.insert(step->id(), step);

    connect(step, SIGNAL(nextStepRequested(QString)),
            this, SLOT(nextStep(QString)));
}
예제 #12
0
void KateFileTree::slotDocumentNext()
{
  kDebug(debugArea()) << "BEGIN";
  
  KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model());
  
  QModelIndex current_index = currentIndex();
  int parent_row_count = ftpm->rowCount( ftpm->parent(current_index) );
  QModelIndex next;
  
  // scan down the tree skipping any dir nodes
  while(current_index.isValid()) {
    if(current_index.row() < parent_row_count-1) {
      current_index = ftpm->sibling(current_index.row()+1, current_index.column(), current_index);
      if(!current_index.isValid()) {
        break;
      }
      
      if(ftpm->isDir(current_index)) {
        // we have a dir node
        while(ftpm->isDir(current_index)) {
          current_index = ftpm->index(0, 0, current_index);
        }
        
        parent_row_count = ftpm->rowCount( ftpm->parent(current_index) );
        
        if(!ftpm->isDir(current_index)) {
          next = current_index;
          break;
        }
      } else { // found document item
        next = current_index;
        break;
      }
    }
    else {
      // select the parent's next sibling
      QModelIndex parent_index = ftpm->parent(current_index);
      int grandparent_row_count = ftpm->rowCount( ftpm->parent(parent_index) );
      
      current_index = parent_index;
      parent_row_count = grandparent_row_count;
      
      // at least if we're not past the last node
      if(!current_index.isValid()) {
        // paste the root node here, try and wrap around
        QModelIndex last_index = ftpm->index(0, 0, QModelIndex());
        if(!last_index.isValid()) {
          break;
        }
        
        if(ftpm->isDir(last_index)) {
          // last node is a dir, select first child row
          while(ftpm->isDir(last_index)) {
            if(ftpm->rowCount(last_index)) {
              // has children, select first
              last_index = ftpm->index(0, 0, last_index);
            }
          }
          
          next = last_index;
          break;
        }
        else {
          // got first file node
          next = last_index;
          break;
        }
      }
    }
  }
  
  if(next.isValid()) {
    //kDebug(debugArea()) << "got next node:" << next;
    //kDebug(debugArea()) << "doc:" << ftpm->data(next, Qt::DisplayRole).value<QString>();

    KTextEditor::Document *doc = model()->data(next, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
    emit activateDocument(doc);
  }
  else {
    kDebug(debugArea()) << "didn't get next node :(";
  }
  
  kDebug(debugArea()) << "END";
}
예제 #13
0
void KateFileTree::slotDocumentPrev()
{
  kDebug(debugArea()) << "BEGIN";
  KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model());


  
  QModelIndex current_index = currentIndex();
  QModelIndex prev;
  
  // scan up the tree skipping any dir nodes
  
  //kDebug(debugArea()) << "cur" << ftpm->data(current_index, Qt::DisplayRole);
  while(current_index.isValid()) {
    if(current_index.row() > 0) {
      current_index = ftpm->sibling(current_index.row()-1, current_index.column(), current_index);
      //kDebug(debugArea()) << "get prev" << ftpm->data(current_index, Qt::DisplayRole);
      if(!current_index.isValid()) {
        //kDebug(debugArea()) << "somehow getting prev index from sibling didn't work :(";
        break;
      }
      
      if(ftpm->isDir(current_index)) {
        // try and select the last child in this parent
        //kDebug(debugArea()) << "is a dir";
        int children = ftpm->rowCount(current_index);
        current_index = ftpm->index(children-1, 0, current_index);
        //kDebug(debugArea()) << "child" << ftpm->data(current_index, Qt::DisplayRole);
        if(ftpm->isDir(current_index)) {
          // since we're a dir, keep going
          //kDebug(debugArea()) << "child is a dir";
          while(ftpm->isDir(current_index)) {
            children = ftpm->rowCount(current_index);
            current_index = ftpm->index(children-1, 0, current_index);
          }
          
          if(!ftpm->isDir(current_index)) {
            prev = current_index;
            break;
          }
          
          continue;
        } else {
          // we're the previous file, set prev
          //kDebug(debugArea()) << "got doc 1";
          prev = current_index;
          break;
        }
      } else { // found document item
        //kDebug(debugArea()) << "got doc 2";
        prev = current_index;
        break;
      }
    }
    else {
      //kDebug(debugArea()) << "get parent";
      // just select the parent, the logic above will handle the rest
      current_index = ftpm->parent(current_index);
      //kDebug(debugArea()) << "got parent" << ftpm->data(current_index, Qt::DisplayRole);
      if(!current_index.isValid()) {
        // paste the root node here, try and wrap around
        //kDebug(debugArea()) << "parent invalid";
        
        int children = ftpm->rowCount(current_index);
        QModelIndex last_index = ftpm->index(children-1, 0, current_index);
        //kDebug(debugArea()) << "last" << ftpm->data(last_index, Qt::DisplayRole);
        if(!last_index.isValid())
          break;
        
        if(ftpm->isDir(last_index)) {
          // last node is a dir, select last child row
          //kDebug(debugArea()) << "last root is a dir, select child";
          int last_children = ftpm->rowCount(last_index);
          prev = ftpm->index(last_children-1, 0, last_index);
          //kDebug(debugArea()) << "last child" << ftpm->data(current_index, Qt::DisplayRole);
          // bug here?
          break;
        }
        else {
          // got last file node
          //kDebug(debugArea()) << "got doc";
          prev = last_index;
          break;
        }
      }
    }
  }
  
  if(prev.isValid()) {
    //kDebug(debugArea()) << "got prev node:" << prev;
    //kDebug(debugArea()) << "doc:" << ftpm->data(prev, Qt::DisplayRole).value<QString>();

    KTextEditor::Document *doc = model()->data(prev, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
    emit activateDocument(doc);
  }
  else {
    kDebug(debugArea()) << "didn't get prev node :(";
  }
  
  kDebug(debugArea()) << "END";
}
예제 #14
0
KateFileTreeConfigPage::KateFileTreeConfigPage( QWidget* parent, KateFileTreePlugin *fl )
  :  Kate::PluginConfigPage( parent ),
    m_plug( fl ),
    m_changed( false )
{
  kDebug(debugArea()) << "BEGIN";

  QVBoxLayout *layout = new QVBoxLayout( this );
  layout->setMargin( 0 );

  gbEnableShading = new QGroupBox( i18n("Background Shading"), this );
  gbEnableShading->setCheckable(true);
  layout->addWidget( gbEnableShading );

  QGridLayout *lo = new QGridLayout( gbEnableShading);

  kcbViewShade = new KColorButton( gbEnableShading );
  lViewShade = new QLabel( i18n("&Viewed documents' shade:"), gbEnableShading );
  lViewShade->setBuddy( kcbViewShade );
  lo->addWidget( lViewShade, 2, 0 );
  lo->addWidget( kcbViewShade, 2, 1 );

  kcbEditShade = new KColorButton( gbEnableShading );
  lEditShade = new QLabel( i18n("&Modified documents' shade:"), gbEnableShading );
  lEditShade->setBuddy( kcbEditShade );
  lo->addWidget( lEditShade, 3, 0 );
  lo->addWidget( kcbEditShade, 3, 1 );

  // sorting
  QHBoxLayout *lo2 = new QHBoxLayout;
  layout->addLayout( lo2 );
  lSort = new QLabel( i18n("&Sort by:"), this );
  lo2->addWidget( lSort );
  cmbSort = new KComboBox( this );
  lo2->addWidget( cmbSort );
  lSort->setBuddy( cmbSort );
  cmbSort->addItem(i18n("Opening Order"), (int)KateFileTreeModel::OpeningOrderRole);
  cmbSort->addItem(i18n("Document Name"), (int)Qt::DisplayRole);
  cmbSort->addItem(i18n("Url"), (int)KateFileTreeModel::PathRole);


  // view mode
  QHBoxLayout *lo3 = new QHBoxLayout;
  layout->addLayout( lo3 );
  lMode = new QLabel( i18n("&View Mode:"), this );
  lo3->addWidget( lMode );
  cmbMode = new KComboBox( this );
  lo3->addWidget( cmbMode );
  lMode->setBuddy( cmbMode );
  cmbMode->addItem(i18n("Tree View"), QVariant(false));
  cmbMode->addItem(i18n("List View"), QVariant(true));

  // Show Full Path on Roots?
  QHBoxLayout *lo4 = new QHBoxLayout;
  layout->addLayout( lo4 );
  cbShowFullPath = new QCheckBox( i18n("&Show Full Path"), this );
  lo4->addWidget( cbShowFullPath );

  layout->insertStretch( -1, 10 );

  gbEnableShading->setWhatsThis( i18n(
      "When background shading is enabled, documents that have been viewed "
      "or edited within the current session will have a shaded background. "
      "The most recent documents have the strongest shade.") );
  kcbViewShade->setWhatsThis( i18n(
      "Set the color for shading viewed documents.") );
  kcbEditShade->setWhatsThis( i18n(
      "Set the color for modified documents. This color is blended into "
      "the color for viewed files. The most recently edited documents get "
      "most of this color.") );

  cbShowFullPath->setWhatsThis( i18n(
      "When enabled, in tree mode, top level folders will show up with their full path "
      "rather than just the last folder name." ) );

//   cmbSort->setWhatsThis( i18n(
//       "Set the sorting method for the documents.") );

  reset();

  connect( gbEnableShading, SIGNAL(toggled(bool)), this, SLOT(slotMyChanged()) );
  connect( kcbViewShade, SIGNAL(changed(QColor)), this, SLOT(slotMyChanged()) );
  connect( kcbEditShade, SIGNAL(changed(QColor)), this, SLOT(slotMyChanged()) );
  connect( cmbSort, SIGNAL(activated(int)), this, SLOT(slotMyChanged()) );
  connect( cmbMode, SIGNAL(activated(int)), this, SLOT(slotMyChanged()) );
  connect( cbShowFullPath, SIGNAL(stateChanged(int)), this, SLOT(slotMyChanged()) );

  kDebug(debugArea()) << "END";
}