Esempio n. 1
0
void TaskLMBMenu::mouseMoveEvent(QMouseEvent* e)
{
    if (m_dragStartPos.isNull())
    {
        QPopupMenu::mouseMoveEvent(e);
        return;
    }

    int delay = KGlobalSettings::dndEventDelay();
    QPoint newPos(e->pos());

    if ((m_dragStartPos - newPos).manhattanLength() > delay)
    {
        int index = indexOf(idAt(m_dragStartPos));
        if (index != -1)
        {
            bool ok = false;
            Task::Ptr task = m_tasks.at(index, &ok);
            if (ok)
            {
                Task::List tasks;
                tasks.append(task);
                TaskDrag* drag = new TaskDrag(tasks, this);
                drag->setPixmap(task->pixmap());
                drag->dragMove();
            }
        }
    }

    QPopupMenu::mouseMoveEvent(e);
}
Esempio n. 2
0
Task::Ptr Task::createTask(Kernel *kernel, const QString &summary, const QString &uid)
{
    Task::Ptr task = Task::Ptr(new Task(kernel, summary));
    task->setWeakPointer(task);
    if (!uid.isEmpty())
        task->setUuid(uid);
    return task;
}
Esempio n. 3
0
void TaskLMBMenu::fillMenu()
{
    setCheckable(true);

    Task::List::iterator itEnd = m_tasks.end();
    for (Task::List::iterator it = m_tasks.begin(); it != itEnd; ++it)
    {
        Task::Ptr t = (*it);

        QString text = t->visibleName().replace("&", "&&");

        TaskMenuItem *menuItem = new TaskMenuItem(text,
                                                  t->isActive(),
                                                  t->isIconified(),
                                                  t->demandsAttention());
        int id = insertItem(QIconSet(t->pixmap()), menuItem);
        connectItem(id, t, SLOT(activateRaiseOrIconify()));
        setItemChecked(id, t->isActive());

        if (t->demandsAttention())
        {
            m_attentionState = true;
            m_attentionMap.append(menuItem);
        }
    }

    if (m_attentionState)
    {
        m_attentionTimer = new QTimer(this, "AttentionTimer");
        connect(m_attentionTimer, SIGNAL(timeout()), SLOT(attentionTimeout()));
        m_attentionTimer->start(500, true);
    }
}
Esempio n. 4
0
void TaskLMBMenu::dragSwitch()
{
    bool ok = false;
    Task::Ptr t = m_tasks.at(indexOf(m_lastDragId), &ok);
    if (ok)
    {
        t->activate();

        for (unsigned int i = 0; i < count(); ++i)
        {
            setItemChecked(idAt(i), false );
        }

        setItemChecked( m_lastDragId, true );
    }
}
Esempio n. 5
0
void KasGroupItem::updateIcon()
{
    QPixmap p;
    bool usedIconLoader = false;
    Task::Ptr t = items.first();
    if(!t)
        p = KGlobal::iconLoader()->loadIcon("kicker", KIcon::NoGroup, KIcon::SizeSmall);

    int sizes[] = {KIcon::SizeEnormous, KIcon::SizeHuge, KIcon::SizeLarge, KIcon::SizeMedium, KIcon::SizeSmall};

    p = t->bestIcon(sizes[kasbar()->itemSize()], usedIconLoader);

    if(p.isNull())
        p = KGlobal::iconLoader()->loadIcon("error", KIcon::NoGroup, KIcon::SizeSmall);

    setIcon(p);
}
bool TaskFilterProxyModel::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const
{
    if (!sourceModel())
        return false;

    if (source_parent.isValid() || source_row < 0 || source_row >= sourceModel()->rowCount()) {
        qWarning() << source_parent.isValid() << source_row << sourceModel()->rowCount();
        Q_ASSERT(false);
        return false;
    }

    QModelIndex index = sourceModel()->index(source_row, 0);
    if (!index.isValid())
        return false;

    QVariant v = index.data(Storage::TaskPtrRole);
    if (!v.isValid())
        return false;

    Task::Ptr task = v.value<Task::Ptr>();
    if (!task)
        return false;

    if (task->status() == TaskStarted)
        return false;

    if (m_filterUntagged)
        return task->tags().isEmpty();

    if (m_tagText.isEmpty())
        return true;

    TagRef::List tags = task->tags();
    for (int i = 0; i < tags.count(); ++i) {
        const TagRef &tagref = tags.at(i);
        if (tagref.tagName() == m_tagText)
            return true;
    }

    return false;
}
Esempio n. 7
0
void KasGroupItem::addTask(Task::Ptr t)
{
    if(!t)
        return;

    items.append(t);
    if(items.count() == 1)
    {
        setText(t->visibleName());
        updateIcon();
    }

    connect(t, SIGNAL(changed(bool)), this, SLOT(update()));
    update();
}
Esempio n. 8
0
KasTaskItem::KasTaskItem( KasTasker *parent, Task::Ptr task )
    : KasItem( parent ),
      task_(task),
      thumbTimer(0),
      attentionTimer(0)
{
    setIcon( icon() );
    setAttention( task->demandsAttention() );
    updateTask(false);

    connect( task, SIGNAL( changed(bool) ), this, SLOT( updateTask(bool) ) );
    connect( task, SIGNAL( activated() ), this, SLOT( startAutoThumbnail() ) );
    connect( task, SIGNAL( deactivated() ), this, SLOT( stopAutoThumbnail() ) );
    connect( task, SIGNAL( iconChanged() ), this, SLOT( iconChanged() ) );
    connect( task, SIGNAL( thumbnailChanged() ), this, SLOT( iconChanged() ) );

    connect( this, SIGNAL(leftButtonClicked(QMouseEvent *)), SLOT(toggleActivateAction()) );
    connect( this, SIGNAL(rightButtonClicked(QMouseEvent *)), SLOT(showWindowMenuAt(QMouseEvent *) ) );

    attentionTimer = new QTimer( this, "attentionTimer" );
    connect( attentionTimer, SIGNAL( timeout() ), SLOT( checkAttention() ) );
    attentionTimer->start( CHECK_ATTENTION_DELAY );
}
Esempio n. 9
0
TaskInfo TaskInfo::fromTaskPtr(Task::Ptr task)
{
    TaskInfo info;
    info.comments = task->comments();

    info.commentsType = "";
    switch (task->commentsType())
    {
    case Task::PLAIN_TEXT:
        info.commentsType = "PLAIN_TEXT";
    default:
        break;
    }

    info.cost = task->cost();
    info.calcCost = task->calcCost();
    info.creationDate = toOleTime(task->creationDate());
    info.doneDate = toOleTime(task->doneDate());
    info.iconIndex = task->iconIndex();
    info.id = task->id();
    info.lastMod = toOleTime(task->lastModDate());
    info.percentDone = task->percentDone();
    info.pos = task->calcPosAttr();
    info.priority = task->priority();
    info.priorityColor = toRawColor(task->priorityColor());
    info.risk = task->risk();
    info.startDate = toOleTime(task->startDate());
    info.textColor = toRawColor(task->textColor());
    info.title = task->title();

    return info;
}
Esempio n. 10
0
void KasGroupItem::paint(QPainter *p)
{
    KasItem::paint(p);

    //
    // Item summary info
    //
    int modCount = 0;
    for(Task::List::iterator it = items.begin(); it != items.end(); ++it)
    {
        if((*it)->isModified())
            modCount++;
    }

    KasResources *res = resources();

    p->setPen(isShowingPopup() ? res->activePenColor() : res->inactivePenColor());

    if(modCount)
    {
        QString modCountStr;
        modCountStr.setNum(modCount);
        p->drawText(extent() - fontMetrics().width(modCountStr) - 3, 15 + fontMetrics().ascent(), modCountStr);

        p->drawPixmap(extent() - 12, 29, res->modifiedIcon());
    }

    int microsPerCol;
    switch(kasbar()->itemSize())
    {
        default:
        case KasBar::Small:
            microsPerCol = 2;
            break;
        case KasBar::Medium:
            microsPerCol = 4;
            break;
        case KasBar::Large:
            microsPerCol = 7;
            break;
        case KasBar::Huge:
            microsPerCol = 9;
            break;
        case KasBar::Enormous:
            microsPerCol = 16;
            break;
    }

    int xpos = 3;
    int ypos = 16;

    for(int i = 0; (i < (int)items.count()) && (i < microsPerCol); i++)
    {
        Task::Ptr t = items.at(i);

        if(t->isIconified())
            p->drawPixmap(xpos, ypos, res->microMinIcon());
        else if(t->isShaded())
            p->drawPixmap(xpos, ypos, res->microShadeIcon());
        else
            p->drawPixmap(xpos, ypos, res->microMaxIcon());

        ypos += 7;
    }

    if(((int)items.count() > microsPerCol) && (kasbar()->itemSize() != KasBar::Small))
    {
        QString countStr;
        countStr.setNum(items.count());
        p->drawText(extent() - fontMetrics().width(countStr) - 3, extent() + fontMetrics().ascent() - 16, countStr);
    }
}