예제 #1
0
bool WidgetScrollBox::getNext() {
	if (children.empty()) {
		scrollDown();
		return true;
	}

	if (currentChild != -1)
		children[currentChild]->in_focus = false;
	currentChild+=1;
	currentChild = (static_cast<unsigned>(currentChild) == children.size()) ? 0 : currentChild;

	if (children[currentChild]->pos.y > (cursor + pos.h) ||
			(children[currentChild]->pos.y + children[currentChild]->pos.h) > (cursor + pos.h)) {
		scrollTo(children[currentChild]->pos.y+children[currentChild]->pos.h-pos.h);
	}
	if (children[currentChild]->pos.y < cursor ||
			(children[currentChild]->pos.y + children[currentChild]->pos.h) < cursor) {
		scrollTo(children[currentChild]->pos.y);
	}
	children[currentChild]->in_focus = true;
	return true;
}
예제 #2
0
bool WidgetScrollBox::getPrev() {
	if (children.empty()) {
		scrollUp();
		return true;
	}

	if (currentChild != -1)
		children[currentChild]->in_focus = false;
	currentChild-=1;
	currentChild = (currentChild < 0) ? static_cast<int>(children.size()) - 1 : currentChild;

	if (children[currentChild]->pos.y > (cursor + pos.h) ||
			(children[currentChild]->pos.y + children[currentChild]->pos.h) > (cursor + pos.h)) {
		scrollTo(children[currentChild]->pos.y+children[currentChild]->pos.h-pos.h);
	}
	if (children[currentChild]->pos.y < cursor ||
			(children[currentChild]->pos.y + children[currentChild]->pos.h) < cursor) {
		scrollTo(children[currentChild]->pos.y);
	}
	children[currentChild]->in_focus = true;
	return true;
}
예제 #3
0
void ImageThumbnailBar::slotDockLocationChanged(Qt::DockWidgetArea area)
{
    if (area == Qt::LeftDockWidgetArea || area == Qt::RightDockWidgetArea)
    {
        setFlow(TopToBottom);
    }
    else
    {
        setFlow(LeftToRight);
    }

    scrollTo(currentIndex());
}
예제 #4
0
void EntityView::rowsInserted(const QModelIndex &parent, int start, int end)
{
    QTreeView::rowsInserted(parent, start, end);
    static bool loadedCurrentContact = false;

    if (loadedCurrentContact) {
        return;
    }

    QModelIndex selectedIndex;
    QCommandLineParser parser;

    if (QCoreApplication::arguments().count() == 1 && KTp::kpeopleEnabled()) {
        const QString selectedPersonaId = QCoreApplication::arguments().at(0);
        for (int i = start; i <= end; i++) {
            const QModelIndex index = model()->index(i, 0, parent);
            if (index.data(KTp::PersonIdRole).toUrl().toString() == selectedPersonaId) {
                selectedIndex = index;
                break;
            }
        }
    } else if (QCoreApplication::arguments().count() == 2) {
        QString selectAccountId = QCoreApplication::arguments().at(0);
        QString selectContactId = QCoreApplication::arguments().at(1);

        for (int i = start; i <= end; i++) {
            QModelIndex index = model()->index(i, 0, parent);
            Tp::AccountPtr account = index.data(PersonEntityMergeModel::AccountRole).value<Tp::AccountPtr>();
            KTp::LogEntity entity = index.data(PersonEntityMergeModel::EntityRole).value<KTp::LogEntity>();
            if (account.isNull() || !entity.isValid()) {
                continue;
            }

            if (selectAccountId == account->uniqueIdentifier() && selectContactId == entity.id()) {
                selectedIndex = index;
                break;
            }
        }
    }

    if (selectedIndex.isValid()) {
        loadedCurrentContact = true;
        setCurrentIndex(selectedIndex);
        scrollTo(selectedIndex);
    } else {
        Q_EMIT noSuchContact();
    }

    expandAll();

}
예제 #5
0
void QCustomTableWidget::addProperty(int index)
{
    if (index < 0)
    {
        // if no column is selected, we insert it at the end
        index += columnCount();
    }
    if(pChangePropertyDial->exec()==QDialog::Accepted)
    {
        // modifying the property/character Lists
        if (pProperties)
        {
            std::string property = pChangePropertyDial->text().toStdString();
            pProperties->add(property, index+1);
            emit modificationDone(new CharacterModification(pProperties, property, pCharacters, index+1));
        }
        if (pCharacters)
        {
            for (CharacterList::iterator it=pCharacters->begin(); it != pCharacters->end(); it++)
            {
                if ((unsigned int)index+1 < it->propertyNumber())
                {
                    // adding a property
                    it->addProperty("0",index+1);
                }
            } 
        }

        // updating the display
        int row_nb = rowCount();
        // created cells
        iCreatedCells = row_nb;
        insertColumn(index+1);
        for (int i = 0; i < row_nb; i++)
        {
            QTableWidgetItem *col1 = new QTableWidgetItem("0");
            setItem(i,index+1,col1);
        }
        QTableWidgetItem *columnHeaderItem = horizontalHeaderItem(index+1);
        if (columnHeaderItem)
        {
            columnHeaderItem->setText(pChangePropertyDial->text());
        }
        else
        {
            columnHeaderItem = new QTableWidgetItem(pChangePropertyDial->text());
            setHorizontalHeaderItem(index+1, columnHeaderItem);
        }
        scrollTo(-1, index+1);
    }
}
예제 #6
0
RubberbandmanMainWidget::RubberbandmanMainWidget( QWidget *parent, Qt::WindowFlags flags )
: QWidget( parent, flags )
, mpBrowseWidget( new BrowseWidget( this ) )
, mpSatelliteWidget( new SatelliteWidget( this ) )
, mpDatabaseWidget( new DatabaseWidget( this ) )
, mpTabs( new QTabWidget( this ) )
, mpSettingsButton( new QPushButton( tr("Settings"), this ) )
, mpDatabaseActivity( new QLabel( this ) )
, mpConfigDialog( new RubberbandmanConfigDialog( this ) )
, mActiveLED( LEDIcon::pixmap( QColor("#ff0000"), 25 ) )
, mIdleLED( LEDIcon::pixmap( QColor("#5f0000"), 25 ) )
{
   mpBrowseWidget->setObjectName( "BrowseWidget" );
   mpSatelliteWidget->setObjectName( "SatelliteWidget" );
   mpDatabaseWidget->setObjectName( "DatabaseWidget" );
   QVBoxLayout *mainLayout = new QVBoxLayout( this );
   mainLayout->setContentsMargins( 3, 3, 3, 3 );
   parent->setWindowIcon( QIcon( ":/Rubberbandman/Icon.png" ) );

   mpTabs->addTab( mpBrowseWidget,    tr("Filesystem") );
   mpTabs->addTab( mpSatelliteWidget, tr("Satellite") );
   mpTabs->addTab( mpDatabaseWidget,  tr("Database") );
   mpTabs->setCurrentIndex( Settings::value( Settings::RubberbandmanCurrentTab ) );

   mainLayout->addWidget( mpTabs );
   QHBoxLayout *bottomLayout( new QHBoxLayout() );
   bottomLayout->addWidget( mpSettingsButton, 1 );
   bottomLayout->addWidget( mpDatabaseActivity, 0 );
   mainLayout->addLayout( bottomLayout );

   connect( mpSatelliteWidget, SIGNAL(showInFilesystem(QString)),
            mpBrowseWidget, SLOT(scrollTo(QString)) );
   connect( mpSatelliteWidget, SIGNAL(showInFilesystem(QString)),
            this, SLOT(goToFilesystem()) );
   connect( mpTabs, SIGNAL(currentChanged(int)),
            this, SLOT(handleTabChange(int)) );
   connect( mpSettingsButton, SIGNAL(clicked()),
            mpConfigDialog, SLOT(exec()) );
   connect( mpSatelliteWidget, SIGNAL(partymanConfigUpdate()),
            mpDatabaseWidget, SLOT(readPartymanConfig()) );
   DatabaseInterface::get()->connectActivityIndicator( this, SLOT(databaseActive(bool)) );
   WindowIconChanger *wic = new WindowIconChanger( parent, QIcon(":/Common/DatabaseUp.png"), this );
   DatabaseInterface::get()->connectActivityIndicator( wic, SLOT(changed(bool)) );

   setLayout( mainLayout );

   mpSettingsButton->setObjectName( QString("SettingsButton") );

   WidgetShot::addWidget( "MainWidget", this );
}
예제 #7
0
파일: event_list.cpp 프로젝트: cojuer/vis4
void EventList::setCurrentEvent(EventModel* eventPtr)
{
    for(int i = 0; i < events.size(); ++i)
    {
        if ((*events[i]) == *eventPtr)
        {
            QModelIndex index = model()->index(i, 0, QModelIndex());
            setCurrentIndex(index);
            scrollTo(index);
            return;
        }
    }
    qFatal("Can't find given event in the list");
}
예제 #8
0
void QCustomTableWidget::editCharacter(int index)
{
    if (index != -1)
    {
        scrollTo(index, -1);
        if (pCharacters)
        {
            Character &character = (*pCharacters)[index];
            if(pChangeCharacterDial->exec(&character)==QDialog::Accepted)
            {
                // updating the CharacterList
                std::string name = character.name();
                std::string shortDescription = character.shortDescription();
                character.setName(pChangeCharacterDial->name().toStdString());
                character.setShortDescription(pChangeCharacterDial->shortDescription().toStdString());
                emit modificationDone(new CharacterModification(pCharacters, name, shortDescription, character.name(), character.shortDescription(), index));
                QTableWidgetItem *rowHeaderItem = verticalHeaderItem(logicalRow(index));
                rowHeaderItem->setText(headerText(pChangeCharacterDial->name(), pChangeCharacterDial->shortDescription()));
            }
            scrollTo(index, -1);
        }
    }
}
예제 #9
0
FreezeInfo::FreezeInfo(QObject *parent,
		       QMultiScope *backend0, QScrollBar *frontend0,
		       QLabel *timereport0, int width_ms0,
		       RawSFCli *rawsrc, SpikeSFCli *spikesrc,
		       QWidget *hideme0) throw(Error):
  QObject(parent) {
  origrawsf = rawsrc;
  origspikesf = spikesrc;
  backend = backend0;
  frontend = frontend0;
  timereport = timereport0;
  hideme = hideme0;
  width_ms = width_ms0;
  dead = false;
  
  dbx("Freezeinfo constructor - building sources");
  if (rawsrc) 
    rawsf = new SFFreeze<Sample, RawAux>(*rawsrc);
  else
    rawsf = 0;
  if (spikesrc)
    spikesf = new SFFreeze<Spikeinfo, SpikeAux>(*spikesrc);
  else
    spikesf = 0;
  dbx("Freezeinfo constructor - done building sources");

  QSSource qss = backend->source();
  qss.sf = rawsf;
  backend->setSource(qss);
  backend->setSpikeSource(spikesf);

  if (rawsf) {
    int dt_ms = (rawsf->safelatest() - rawsf->safefirst()) / FREQKHZ;
    t0 = rawsf->safelatest() - dt_ms*FREQKHZ;
    sdbx("Freezeinfo: dt_ms=%i t0=%Li first=%Li latest=%Li",
	 dt_ms,t0,rawsf->safefirst(),rawsf->safelatest());
  } else {
    t0 = 0;
  }
  frontend->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
				      QSizePolicy::Fixed));
  frontend->show();
  if (hideme)
    hideme->hide();
  resetslider();
  connect(frontend,SIGNAL(valueChanged(int)),this,SLOT(scrollTo(int)));
  frontend->setValue(frontend->maxValue());
  scrollTo(frontend->maxValue());
}
예제 #10
0
// Preserves item's selection state
void CFileListView::moveCursorToItem(const QModelIndex& index, bool invertSelection)
{
	if (index.isValid() && selectionModel()->model()->hasIndex(index.row(), index.column()))
	{
		const QModelIndex fixedIndex = model()->index(index.row(), index.column());
		const QModelIndex currentIdx = currentIndex();
		if (invertSelection && currentIdx.isValid())
		{
			for (int row = currentIdx.row(); row < fixedIndex.row(); ++row)
				selectionModel()->setCurrentIndex(fixedIndex, (!_shiftPressedItemSelected ? QItemSelectionModel::Select : QItemSelectionModel::Deselect) | QItemSelectionModel::Rows);
		}
		selectionModel()->setCurrentIndex(fixedIndex, QItemSelectionModel::Current | QItemSelectionModel::Rows);
		scrollTo(fixedIndex);
	}
}
예제 #11
0
void RKObjectListView::setObjectCurrent (RObject *object, bool only_if_none_current) {
	RK_TRACE (APP);

	if (!object) return;
	if (only_if_none_current && currentIndex ().isValid ()) return;

	QModelIndex index = settings->mapFromSource (RKGlobals::tracker ()->indexFor (object));
	if (index.isValid ()) {
		scrollTo (index);
		setCurrentIndex (index);
		resizeColumnToContents (0);
	} else {
		RK_ASSERT (false);
	}
}
예제 #12
0
파일: Viewport.cpp 프로젝트: ourgames/nbg
void Viewport::changeSceneZoom(){
    Vec2 orgPt = m_TargetNode->getPosition();
    float orgS = m_TargetNode->getScale();
    float finalS = orgS - 0.2;
    float time = 0.2;
    Vec2 setPt = orgPt * (finalS / orgS);
    scrollTo(setPt, NULL);
    applyZoom(finalS);
    Vec2 finalPt = m_TargetNode->getPosition();
    finalS = m_TargetNode->getScale();
    m_TargetNode->setPosition(orgPt);
    m_TargetNode->setScale(orgS);
    Spawn *spawn =Spawn::createWithTwoActions(MoveTo::create(time, finalPt), ScaleTo::create(time, finalS));
    m_TargetNode->runAction(spawn);
}
예제 #13
0
void MusicListView::onLocate(const MetaPtr meta)
{
    QModelIndex index = findIndex(meta);
    if (!index.isValid()) {
        return;
    }

    clearSelection();

    auto viewRect = QRect(QPoint(0, 0), size());
    if (!viewRect.intersects(visualRect(index))) {
        scrollTo(index, MusicListView::PositionAtCenter);
    }
    setCurrentIndex(index);
}
예제 #14
0
파일: api.c 프로젝트: wosigh/terminal
void scrollTop(NPP instance, NPObject *scroller)
	{
#if 1
	scrollTo(instance, scroller, 0, false);
#else
	//scroller.mojo.revealTop(0)
	//	TODO:	test again with NULL_TO_NPVARIANT(args) and/or VOID_TO_NPVARIANT(args)
	//		as when OBJECT_TO_NPVARIANT(0, args) was used it crashed
	NPVariant args;
	NULL_TO_NPVARIANT(args);
	//debug(DBG_MAIN, "scrollTop()");
	NPVariant var;
	scrollCommon(instance, scroller, "revealTop", args, 1, &var);
#endif
	}
예제 #15
0
void HFViewport::changeSceneZoom(){
    CCPoint orgPt = m_TargetNode->getPosition();
    float orgS = m_TargetNode->getScale();
    float finalS = orgS - 0.2;
    float time = 0.2;
    CCPoint setPt = orgPt * (finalS / orgS);
    scrollTo(setPt, NULL);
    applyZoom(finalS);
    CCPoint finalPt = m_TargetNode->getPosition();
    finalS = m_TargetNode->getScale();
    m_TargetNode->setPosition(orgPt);
    m_TargetNode->setScale(orgS);
    CCSpawn *spawn =CCSpawn::createWithTwoActions(CCMoveTo::create(time, finalPt), CCScaleTo::create(time, finalS));
    m_TargetNode->runAction(CCSequence::create(spawn, NULL));
}
void HierarchyTreeControl::HandleDragMoveControlMimeData(QDragMoveEvent *event, const ControlMimeData* /*mimeData*/)
{
    DropIndicatorPosition position = dropIndicatorPosition();
    Logger::Warning("POSITION TYPE^ %i", position);

	// Where we are in tree?
	QTreeWidgetItem* item = itemAt(event->pos());
	if (!item)
	{
		HierarchyTreeController::Instance()->ResetSelectedControl();
		return;
	}

	HierarchyTreeNode::HIERARCHYTREENODEID insertInto = HierarchyTreeNode::HIERARCHYTREENODEID_EMPTY;
	QVariant data = item->data(ITEM_ID);
	insertInto = data.toInt();
	
	// Handle specific types of nodes.
	HierarchyTreeNode* nodeToInsertControlTo = HierarchyTreeController::Instance()->GetTree().GetNode(insertInto);
	if (dynamic_cast<HierarchyTreePlatformNode*>(nodeToInsertControlTo) ||
		dynamic_cast<HierarchyTreeAggregatorControlNode*>(nodeToInsertControlTo))
	{
		// Don't allow to drop the controls directly to Platform or Aggregator.
		HierarchyTreeController::Instance()->ResetSelectedControl();
		return;
	}
	
	// Expand the items while dragging control on them.
	if (!item->isExpanded())
	{
		item->setExpanded(true);
	}

	scrollTo(indexAt(event->pos()));

	HierarchyTreeControlNode* controlNode = dynamic_cast<HierarchyTreeControlNode*>(nodeToInsertControlTo);
	if (controlNode)
	{
		// Don't reselect the same control, if it is already selected.
		if (!HierarchyTreeController::Instance()->IsControlSelected(controlNode))
		{
			HierarchyTreeController::Instance()->ResetSelectedControl();
			HierarchyTreeController::Instance()->SelectControl(controlNode);
		}
	}

	event->accept();
}
예제 #17
0
void PoitemTableView::currentChanged(const QModelIndex &current, const QModelIndex &previous )
{
  if (DEBUG) qDebug("PoitemTableView::currentChanged(current %d,%d prev %d,%d)",
                    current.row(),  current.column(),
                    previous.row(), previous.column());
  if (current != QModelIndex() && current != previous)
  {
    if (DEBUG) qDebug("PoitemTableView::currentChanged setting current");
    setCurrentIndex(current);
    if (DEBUG) qDebug("PoitemTableView::currentChanged scrolling to current");
    scrollTo(current);
    if (DEBUG) qDebug("PoitemTableView::currentChanged editing current");
    edit(current);
  }
  if (DEBUG) qDebug("PoitemTableView::currentChanged returning");
}
예제 #18
0
void DActionsListView::makeSelection(QModelIndexList indexes, QModelIndex ScrolledTo)
{
    //selectionModel()->clear();
    bool CurrentIndexHasBeenSet = false;
    for(auto& index : indexes)
    {
        if(not CurrentIndexHasBeenSet)
        {
            selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
            CurrentIndexHasBeenSet = false;
        }
        selectionModel()->select(index, QItemSelectionModel::Select);
    }
    if(ScrolledTo.isValid())
        scrollTo(ScrolledTo);
}
예제 #19
0
void FlickCharm::timerEvent(QTimerEvent *event) {
  //  qDebug() << __FUNCTION__ << "timer" << m_count <<  m_speed << m_count * m_speed;
  m_count++;

  // 0..100 -> 0..1
  scrollTo(m_releasePos + m_speed / MULT);

  // create unit vector
  QPoint unit = MULT * m_speed / m_speed.manhattanLength();
  if(m_count >= 1000 || unit.manhattanLength() > m_speed.manhattanLength()) 
    m_timer.stop();
  else
    m_speed -= unit;
  
  QObject::timerEvent(event);
} 
예제 #20
0
void Pageview::scrollToEnd (bool ifAtEnd)
   {
//    QScrollBar *vs = verticalScrollBar ();

//    qDebug () << "scrollToEnd" << _autoscroll;
   if (!ifAtEnd || _autoscroll)
      {
      _ignore_scroll = true;
      // doesn't seem to work, perhaps because the window extent hasn't been updated yet
//       vs->setValue (vs->maximum ());

      // so use this instead
      scrollTo (model ()->index (model ()->rowCount (QModelIndex ()) - 1, 0, QModelIndex ()));
      _ignore_scroll = false;
      }
   }
예제 #21
0
void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle)
{
	QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model());
	QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
	QItemSelectionModel::SelectionFlags flags;
	QModelIndex idx = match.first();

	QModelIndex parent = idx.parent();
	if (parent.isValid())
		expand(parent);
	flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select;
	flags |= QItemSelectionModel::Rows;
	selectionModel()->select( idx, flags);
	if (scrollto)
		scrollTo(idx, PositionAtCenter);
}
예제 #22
0
void ExtendedTableWidget::selectTableLine(int lineToSelect)
{
    SqliteTableModel* m = qobject_cast<SqliteTableModel*>(model());

    // Are there even that many lines?
    if(lineToSelect >= m->rowCount())
        return;

    QApplication::setOverrideCursor( Qt::WaitCursor );
    m->triggerCacheLoad(lineToSelect);

    // Select it
    clearSelection();
    selectRow(lineToSelect);
    scrollTo(currentIndex(), QAbstractItemView::PositionAtTop);
    QApplication::restoreOverrideCursor();
}
예제 #23
0
파일: imdelegate.cpp 프로젝트: KDE/ring-kde
///Constructor
IMTab::IMTab(QAbstractItemModel* model,QWidget* parent) : QListView(parent)
{
   setModel(model);
   setAlternatingRowColors(true);
//    setWrapping(true);
   setUniformItemSizes(false);
   setItemDelegate(new ImDelegates(this));
   setVerticalScrollMode(ScrollPerPixel);

   scrollTo(model->index(model->rowCount()-1,0));

   if (verticalScrollBar())
      verticalScrollBar()->setValue(verticalScrollBar()->maximum());

   connect(model,&QAbstractItemModel::dataChanged,this,&IMTab::scrollBottom);
   connect(model, &QAbstractItemModel::rowsInserted, this, &IMTab::updateScrollBar);
}
예제 #24
0
void KNMusicTreeViewBase::searchText(QString text)
{
    //Backup the search text.
    m_seachText=text;
    //Set to proxy model's filter.
    if(m_proxyModel!=nullptr)
    {
        //Do search.
        m_proxyModel->setFilterFixedString(m_seachText);
        if(currentIndex().isValid())
        {
            scrollTo(model()->index(currentIndex().row(),
                                    0),
                     QAbstractItemView::PositionAtCenter);
        }
        //Emit search signal.
        emit searchComplete();
    }
}
예제 #25
0
void DropDownList::onScroll(wxScrollWinEvent& ev) {
    wxEventType type = ev.GetEventType();
    if (type == wxEVT_SCROLLWIN_TOP) {
        scrollTo(0);
    } else if (type == wxEVT_SCROLLWIN_BOTTOM) {
        scrollTo(INT_MAX);
    } else if (type == wxEVT_SCROLLWIN_LINEUP) {
        scrollTo(visible_start - item_size.height);
    } else if (type == wxEVT_SCROLLWIN_LINEDOWN) {
        scrollTo(visible_start + item_size.height);
    } else if (type == wxEVT_SCROLLWIN_PAGEUP) {
        scrollTo(visible_start - (GetClientSize().y - item_size.height));
    } else if (type == wxEVT_SCROLLWIN_PAGEDOWN) {
        scrollTo(visible_start + (GetClientSize().y - item_size.height));
    } else {
        scrollTo(ev.GetPosition());
    }
}
예제 #26
0
void XournalView::zoomChanged()
{
	XOJ_CHECK_TYPE(XournalView);

	Layout* layout = gtk_xournal_get_layout(this->widget);
	int currentPage = this->getCurrentPage();
	XojPageView* view = getViewFor(currentPage);
	ZoomControl* zoom = control->getZoomControl();

	if (!view)
	{
		return;
	}

	// move this somewhere else maybe
	layout->layoutPages();

	if(zoom->isZoomPresentationMode() || zoom->isZoomFitMode())
	{
		scrollTo(currentPage);
	}
	else
	{
		std::tuple<double, double> pos = zoom->getScrollPositionAfterZoom();
		if(std::get<0>(pos) != -1 && std::get<1>(pos) != -1)
		{
			layout->scrollAbs(std::get<0>(pos), std::get<1>(pos));
		}
	}

	Document* doc = control->getDocument();
	doc->lock();
	Path file = doc->getEvMetadataFilename();
	doc->unlock();

	control->getMetadataManager()->storeMetadata(file.str(), getCurrentPage(), zoom->getZoomReal());

	// Updates the Eraser's cursor icon in order to make it as big as the erasing area
	control->getCursor()->updateCursor();

	this->control->getScheduler()->blockRerenderZoom();
}
예제 #27
0
void
ReportEdit::refresh( const QDateTime & key )
{
	m_model->setQuery( QString("SELECT "
			"%1, "			// datetime is a unique attribute
			"c.who, "
			"l.num_text, "
			"l.num, "
			"CASE WHEN l.zakaz = 0 THEN '' ELSE 'заказное' END, "
			"%2 "
		"FROM "
			"%3 l "
		"INNER JOIN "
			"%4 c ON l.contact_id = c.id "
		"WHERE "
			"%5 "
		"ORDER BY "
			"6 "	// by time
			)
		.arg( _dbPg ? "date_trunc( 'second', l.drec )" : "l.timestamp" )
		.arg( _dbPg ? "\"time\"( l.drec )" : "substr( l.timestamp, 12 )" )
		.arg( _tableName( "log" ) )
		.arg( _tableName( "contact" ) )
		.arg( _dbPg ? QString("date( l.drec ) = '%1'").arg( m_date.toString("yyyy-MM-dd") ) :
				QString("substr( l.timestamp, 1, 10 ) = '%1'").arg( m_date.toString("yyyy-MM-dd") ) ) );

	hideColumn( 0 );	// datetime
	hideColumn( 5 );	// time

	resizeColumnsToContents();

	if ( key.isValid() ) {
		for ( int i = 0; i < m_model->rowCount(); ++i ) {
			if ( m_model->index( i, 0 ).data().toDateTime() == key ) {
				const QModelIndex index = m_model->index( i, 1 );
				setCurrentIndex( index );
				scrollTo( index );
				break;
			}
		}
	}
}
예제 #28
0
void PlaylistView::JumpToCurrentlyPlayingTrack() {
  Q_ASSERT(playlist_);

  // Usage of the "Jump to the currently playing track" action shall enable
  // autoscroll
  inhibit_autoscroll_ = false;

  if (playlist_->current_row() == -1) return;

  QModelIndex current = playlist_->proxy()->mapFromSource(
      playlist_->index(playlist_->current_row(), 0));
  if (!current.isValid()) return;

  currently_autoscrolling_ = true;

  // Scroll to the item
  scrollTo(current, QAbstractItemView::PositionAtCenter);

  currently_autoscrolling_ = false;
}
예제 #29
0
void PlaylistView::JumpToLastPlayedTrack() {
  Q_ASSERT(playlist_);

  if (playlist_->last_played_row() == -1) return;

  QModelIndex last_played = playlist_->proxy()->mapFromSource(
      playlist_->index(playlist_->last_played_row(), 0));
  if (!last_played.isValid()) return;

  // Select last played song
  last_current_item_ = last_played;
  setCurrentIndex(last_current_item_);

  currently_autoscrolling_ = true;

  // Scroll to the item
  scrollTo(last_played, QAbstractItemView::PositionAtCenter);

  currently_autoscrolling_ = false;
}
void cMaterialItemView::rowsInserted(const QModelIndex &parent, int start, int end)
{
	for (int r = start; r <= end; r++)
	{
		cMaterialWidget *widget = new cMaterialWidget(this);
		widget->setAutoFillBackground(true);
		setIndexWidget(model()->index(r, 0, parent), widget);
	}
	QAbstractItemView::rowsInserted(parent, start, end);
	// updateGeometries();

	updateScrollBar();
	updateGeometries();

	setCurrentIndex(model()->index(start, 0));
	scrollTo(model()->index(start, 0));

	model()->fetchMore(QModelIndex());
	viewport()->update();
}