示例#1
0
void Table::keyPressEvent(QKeyEvent *event)
{
    // Delete's all the selected rows for use with polygons only
    if (event->key() == Qt::Key_Delete && mType == PolyEdit::Polygon)
    {
        QList<QTableWidgetItem *> selected = selectedItems();

        int lastRow = -1;

        for(auto i : selected)
        {
            int r = i->row();

            if(lastRow == -1)
            {
                lastRow = r;
                removeRow(r);
            }
            else if(lastRow != r)
                removeRow(r);
        }

        // Ensure we have atleast one row
        if (rowCount() == 0)
            insertRow(rowCount());
    }
}
void MessageListModel::append(QString message, MessageStatus messageStatus, bool newLine) {
  QStandardItem* item = new QStandardItem;

  switch(messageStatus) {
  case MessageStatus::Information:
    item->setData(message, MessageItemDelegate::InformationRole);
    break;
  case MessageStatus::Success:
    item->setData(message, MessageItemDelegate::SuccessRole);
    break;
  case MessageStatus::Warning:
    item->setData(message, MessageItemDelegate::WarningRole);
    break;
  case MessageStatus::Error:
    item->setData(message, MessageItemDelegate::ErrorRole);
    break;
  case MessageStatus::Download:
    item->setData(message, MessageItemDelegate::DownloadRole);
    break;
  default:
    item->setData(message, MessageItemDelegate::DownloadRole);
    break;
  }

  while (rowCount() > _maxLines)
    removeRow(0);

  if (!newLine)
    removeRow(rowCount()-1);

  appendRow(item);

  emit scrollToBottomRequested();
}
示例#3
0
MetaEditor::MetaEditor(QWidget *parent)
  : QDialog(parent),
    m_mainWindow(qobject_cast<MainWindow *>(parent)),
    m_Relator(MarcRelators::instance()),
    m_RemoveRow(new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_Delete),this, 0, 0, Qt::WidgetWithChildrenShortcut))
{
    setupUi(this);

    m_book = m_mainWindow->GetCurrentBook();
    m_version = m_book->GetConstOPF()->GetEpubVersion();
    m_opfdata = m_book->GetOPF()->GetText();

    QStringList headers;
    headers << tr("Name") << tr("Value");

    QString data = GetOPFMetadata();

    TreeModel *model = new TreeModel(headers, data);
    view->setModel(model);
    for (int column = 0; column < model->columnCount(); ++column)
        view->resizeColumnToContents(column);

    if (!isVisible()) {
        ReadSettings();
    }

    if (m_version.startsWith('3')) { 
        loadMetadataElements();
        loadMetadataProperties();
    } else {
        loadE2MetadataElements();
        loadE2MetadataProperties();
    }

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

    connect(delButton, SIGNAL(clicked()), this, SLOT(removeRow()));
    connect(tbMoveUp, SIGNAL(clicked()), this, SLOT(moveRowUp()));
    connect(tbMoveDown, SIGNAL(clicked()), this, SLOT(moveRowDown()));
    connect(m_RemoveRow, SIGNAL(activated()), this, SLOT(removeRow()));

    if (m_version.startsWith('3')) {
        connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectElement()));
        connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectProperty()));
    } else {
        connect(addMetaButton, SIGNAL(clicked()), this, SLOT(selectE2Element()));
        connect(addPropButton, SIGNAL(clicked()), this, SLOT(selectE2Property()));
    }

    connect(buttonBox, SIGNAL(accepted()), this, SLOT(saveData()));
    connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    updateActions();
}
示例#4
0
/**----------------------------------------------------------------
 * Create the output from a single ChebfunWorkspace.
 */
void ChebfunToTable::fromChebWorkspace()
{
  ChebfunWorkspace_sptr cws = getClass("InputWorkspace");

  Numeric::FunctionDomain1D_sptr domain;

  size_t n = (int)get("N");

  if (n < 2)
  {// if n has default value (0) use the x-points of the chebfuns
    domain = cws->fun().createDomainFromXPoints();
    n = domain->size();
  }
  else
  {// otherwise create a regular comb
    domain = cws->fun().createDomain( n );
  }

  Numeric::FunctionValues values( *domain );
  cws->fun().function(*domain, values);

  auto tws = API::TableWorkspace_ptr(dynamic_cast<API::TableWorkspace*>(
    API::WorkspaceFactory::instance().create("TableWorkspace"))
    );

  tws->addColumn("double","X");
  tws->addColumn("double","Y");
  tws->setRowCount(n);
  auto xColumn = static_cast<API::TableColumn<double>*>(tws->getColumn("X").get());
  xColumn->asNumeric()->setPlotRole(API::NumericColumn::X);
  auto& x = xColumn->data();
  auto yColumn = static_cast<API::TableColumn<double>*>(tws->getColumn("Y").get());
  yColumn->asNumeric()->setPlotRole(API::NumericColumn::Y);
  auto& y = yColumn->data();
  
  for(size_t i = 0; i < domain->size(); ++i)
  {
    x[i] = (*domain)[i];
    y[i] = values.getCalculated(i);
  }

  bool dropXInf = get("DropXInf");
  if ( dropXInf )
  {
    if ( fabs( x.front() ) == inf )
    {
      tws->removeRow( 0 );
    }
    if ( fabs( x.back() ) == inf )
    {
      tws->removeRow( tws->rowCount() - 1 );
    }
  }

  setProperty("OutputWorkspace",tws);
}
示例#5
0
bool PersonsTableModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
    Q_D(PersonsTableModel);
    if(!(index.row() < d->persons.size()))
        return false;
    if(index.column() == 0) {
        if(role == Qt::DisplayRole
                || role == Qt::EditRole) {
            if(value.toString().isEmpty()) {
                return removeRow(index.row());
            }

            d->persons[index.row()].setName(value.toString());
            emit dataChanged(index, index);
            return true;
        }
    }
    else {
        if(role == Qt::CheckStateRole) {
            Qt::CheckState check = (Qt::CheckState)value.toInt();
            switch (check) {
            case Qt::Unchecked:
                d->persons[index.row()].removeDate(d->columns.at(index.column()-1));
                break;
            default:
                d->persons[index.row()].addDate(d->columns.at(index.column()-1));
                break;
            }
            emit dataChanged(index, index);
            return true;
        }
    }
    return false;
}
示例#6
0
void pTableWidget::removeAll()
{
    clearContents();

    while(rowCount() > 0)
        removeRow(0);
}
示例#7
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    setupUi(this);

    QStringList headers;
    headers << tr("Title") << tr("Description");

    QFile file(":/default.txt");
    file.open(QIODevice::ReadOnly);
    TreeModel *model = new TreeModel(headers, file.readAll());
    file.close();

    view->setModel(model);
    for (int column = 0; column < model->columnCount(); ++column)
        view->resizeColumnToContents(column);

    connect(exitAction, SIGNAL(triggered()), qApp, SLOT(quit()));

    connect(view->selectionModel(),
            SIGNAL(selectionChanged(const QItemSelection &,
                                    const QItemSelection &)),
            this, SLOT(updateActions()));

    connect(actionsMenu, SIGNAL(aboutToShow()), this, SLOT(updateActions()));
    connect(insertRowAction, SIGNAL(triggered()), this, SLOT(insertRow()));
    connect(insertColumnAction, SIGNAL(triggered()), this, SLOT(insertColumn()));
    connect(removeRowAction, SIGNAL(triggered()), this, SLOT(removeRow()));
    connect(removeColumnAction, SIGNAL(triggered()), this, SLOT(removeColumn()));
    connect(insertChildAction, SIGNAL(triggered()), this, SLOT(insertChild()));

    updateActions();
}
示例#8
0
void HistoryModel::removeEntry(quint64 identifier)
{
	HistoryEntryItem *entry(getEntry(identifier));

	if (!entry)
	{
		return;
	}

	const QUrl url(Utils::normalizeUrl(entry->data(UrlRole).toUrl()));

	if (m_urls.contains(url))
	{
		m_urls[url].removeAll(entry);

		if (m_urls[url].isEmpty())
		{
			m_urls.remove(url);
		}
	}

	if (identifier > 0 && m_identifiers.contains(identifier))
	{
		m_identifiers.remove(identifier);
	}

	emit entryRemoved(entry);

	removeRow(entry->row());

	emit modelModified();
}
示例#9
0
void
mail_item_model::remove_msg(mail_msg* msg)
{
  DBG_PRINTF(8, "remove_msg(mail_id=" MAIL_ID_FMT_STRING ")", msg->get_id());
  QMap<mail_id_t, QStandardItem*>::iterator it = items_map.find(msg->get_id());
  if (it!=items_map.end()) {
    QStandardItem* item = it.value();
    QStandardItem* parent_item = item->parent();
    while (item->child(0,0)!=NULL) {
      // reparent childs of the item to remove
      QList<QStandardItem*> ql = item->takeRow(0);
      if (parent_item) {
	DBG_PRINTF(9, "reparenting child to immediate parent row=%d", item->index().row());
	parent_item->insertRow(item->index().row(), ql);
      }
      else {
	DBG_PRINTF(9, "reparenting child to root");
	insertRow(item->index().row(), ql);
      }
    }
    // 
    DBG_PRINTF(9, "removing mail_id=" MAIL_ID_FMT_STRING
	       " from model at index.row=%d index.column=%d",
	       msg->get_id(), item->index().row(),
	       item->index().column());
    QModelIndex index = item->index();
    removeRow(index.row(), index.parent());
    items_map.erase(it);
  }
  else {
    DBG_PRINTF(1, "ERR: mail_id=" MAIL_ID_FMT_STRING " not found in items_map", msg->get_id());
  }
}
示例#10
0
void GameSettings::removeScriptTag(std::string const & key)
{
    std::string key2 = key;
    boost::to_lower(key2);

    removeRow(key2);
}
示例#11
0
文件: qsidebar.cpp 项目: fluxer/katie
/*!
    Add urls \a list into the list at \a row.  If move then movie
    existing ones to row.

    \sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
    if (row == -1)
        row = rowCount();
    row = qMin(row, rowCount());
    for (int i = list.count() - 1; i >= 0; --i) {
        QUrl url = list.at(i);
        if (!url.isValid() || url.scheme() != QLatin1String("file"))
            continue;
        //this makes sure the url is clean
        const QString cleanUrl = QDir::cleanPath(url.toLocalFile());
        url = QUrl::fromLocalFile(cleanUrl);

        for (int j = 0; move && j < rowCount(); ++j) {
            const QString local = index(j, 0).data(UrlRole).toUrl().toLocalFile();
            if (local == cleanUrl) {
                removeRow(j);
                if (j <= row)
                    row--;
                break;
            }
        }
        row = qMax(row, 0);
        const QModelIndex idx = fileSystemModel->index(cleanUrl);
        if (!fileSystemModel->isDir(idx))
            continue;
        insertRows(row, 1);
        setUrl(index(row, 0), url, idx);
        watching.append(qMakePair(idx, cleanUrl));
    }
}
示例#12
0
void DirectoryNode::refresh()
{
    QFileInfoList fileList = _dirObject.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries, QDir::DirsFirst | QDir::Name);

    QMap<Id, DirectoryNode*> subfolders;
    QMap<Id, FileNode*> files;

    // FIXME
    foreach (QFileInfo fileInfo, fileList) {
        if(fileInfo.isDir()){
            QString dirName = fileInfo.fileName();
            DirectoryNode *node;
            if(_subFolderNodes.contains(dirName)){
                node = _subFolderNodes.take(dirName);
            }else{
                node = new DirectoryNode(FileName::fromString(fileInfo.filePath()));
                appendRow(node);
            }
            subfolders.insert(dirName, node);
        }else if(fileInfo.isFile()){
            QString fileName = fileInfo.fileName();
            FileNode* node;
            if(_fileNodes.contains(fileName)){
                node = _fileNodes.take(fileName);
            }else{
                node = new FileNode(FileName::fromString(fileInfo.filePath()));
                appendRow(node);
            }
            files.insert(fileName, node);
        }
    }

    foreach (DirectoryNode* item, _subFolderNodes) {
        removeRow(item->row());
    }
示例#13
0
文件: qsidebar.cpp 项目: icefox/ambit
/*!
    Add urls \a list into the list at \a row.  If move then movie
    existing ones to row.

    \sa dropMimeData()
*/
void QUrlModel::addUrls(const QList<QUrl> &list, int row, bool move)
{
    if (row == -1)
        row = rowCount();
    row = qMin(row, rowCount());
    for (int i = list.count() - 1; i >= 0; --i) {
        QUrl url = list.at(i);
        if (!url.isValid() || url.scheme() != QLatin1String("file"))
            continue;
        for (int j = 0; move && j < rowCount(); ++j) {
            if (index(j, 0).data(UrlRole) == url) {
                removeRow(j);
                if (j <= row)
                    row--;
                break;
            }
        }
        row = qMax(row, 0);
        QModelIndex idx = fileSystemModel->index(url.toLocalFile());
        if (!fileSystemModel->isDir(idx))
            continue;
        insertRows(row, 1);
        setUrl(index(row, 0), url, idx);
        watching.append(QPair<QModelIndex, QString>(idx, url.toLocalFile()));
    }
}
示例#14
0
文件: ml_model.cpp 项目: AsamQi/vlc
bool MLModel::event( QEvent *event )
{
    if ( event->type() == MLEvent::MediaAdded_Type )
    {
        event->accept();
        MLEvent *e = static_cast<MLEvent *>(event);
        vlc_array_t* p_result = vlc_array_new();
        if ( ml_FindMedia( e->p_ml, p_result, ML_ID, e->ml_media_id ) == VLC_SUCCESS )
        {
            insertResultArray( p_result );
            ml_DestroyResultArray( p_result );
        }
        vlc_array_destroy( p_result );
        return true;
    }
    else if( event->type() == MLEvent::MediaRemoved_Type )
    {
        event->accept();
        MLEvent *e = static_cast<MLEvent *>(event);
        removeRow( getIndexByMLID( e->ml_media_id ).row() );
        return true;
    }
    else if( event->type() == MLEvent::MediaUpdated_Type )
    {
        event->accept();
        /* Never implemented... */
        return true;
    }

    return VLCModel::event( event );
}
void AgentsModel::removeAgentConfig(const QString &agent_id)
{
    if (m_row2id.contains(agent_id)) {
        int removedRow = m_row2id.indexOf(agent_id);
        removeRow(removedRow);
    }
}
void TableEditor::endEdit(int row,int col,bool accept,bool replace)
{
	Q3Table::endEdit(row,col,accept,replace);
	setCellContentFromEditor(row,col);
	if(isEmptyRow(row)) if(numRows()>1) removeRow(row);
	if(!isEmptyRow(numRows()-1)) addEmptyRow();
}
示例#17
0
		void ResourceLoader::handleDirectoryChanged (const QString& path)
		{
			emit watchedDirectoriesChanged ();

			for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
				i->removeAll (path);

			QFileInfo fi (path);
			if (fi.exists () &&
					fi.isDir () &&
					fi.isReadable ())
				ScanPath (path);

			QStringList toRemove;
			for (auto i = Entry2Paths_.begin (), end = Entry2Paths_.end (); i != end; ++i)
				if (i->isEmpty ())
					toRemove << i.key ();

			Q_FOREACH (const auto& entry, toRemove)
			{
				Entry2Paths_.remove (entry);

				auto items = SubElemModel_->findItems (entry);
				Q_FOREACH (auto item, SubElemModel_->findItems (entry))
					SubElemModel_->removeRow (item->row ());
			}
示例#18
0
void gTree::clear()
{
	char *key;
	
	while ((key = firstRow()))
		removeRow(key);
}
示例#19
0
/*!
 * \brief Clear table
 */
void OptionList::clear()
{
    while (rowCount() > 0)
    {
       removeRow(0);
    }
}
示例#20
0
/**
 * Obtains the investigations that the user can publish
 * to and saves related information to a workspace.
 * @return A workspace containing investigation information the user can publish
 * to.
 */
API::ITableWorkspace_sptr ICat4Catalog::getPublishInvestigations() {
  ICATPortBindingProxy icat;
  setICATProxySettings(icat);

  auto ws = API::WorkspaceFactory::Instance().createTable("TableWorkspace");
  // Populate the workspace with all the investigations that
  // the user is an investigator off and has READ access to.
  myData(ws);

  // Remove each investigation returned from `myData`
  // were the user does not have create/write access.
  for (int row = static_cast<int>(ws->rowCount()) - 1; row >= 0; --row) {
    ns1__dataset dataset;
    ns1__datafile datafile;

    // Verify if the user can CREATE datafiles in the "mantid" specific dataset.
    int64_t datasetID =
        getMantidDatasetId(ws->getRef<std::string>("InvestigationID", row));
    std::string datafileName = "tempName.nxs";

    dataset.id = &datasetID;
    datafile.name = &datafileName;
    datafile.dataset = &dataset;

    if (!isAccessAllowed(ns1__accessType__CREATE, datafile))
      ws->removeRow(row);
  }

  return ws;
}
示例#21
0
void TableWidgetDEV::clearItem(const QString &no)
{
    QList<QTableWidgetItem*> temp = findItems(no,Qt::MatchCaseSensitive);
    foreach(const QTableWidgetItem* c ,temp)
    {
        removeRow(row(c));
    }
示例#22
0
void ColumnEditorModel::deleteRow(int nRow)
{
	DatabaseColumn *col = columnItem(nRow);
	removeRow(nRow);
	if(col)
		delete col;
}
示例#23
0
void UserItem::onUpdateHosts (const HostInfoMap & hosts) {
	bool changed = false; // host list changed (added or removed)
	for (HostInfoMap::const_iterator i = hosts.begin(); i != hosts.end(); i++) {
		sf::HostId id (i->first);
		HostItemMap::iterator j = mHosts.find (id);
		if (j == mHosts.end()) {
			// Generate a new Host
			HostItem * item = new HostItem (i->second);
			mHosts[id] = item;
			appendRow (item);
			changed = true;
		} else {
			// Update a host
			HostItem * item = j->second;
			item->set (i->second);
		}
	}
	{
		HostItemMap::iterator i = mHosts.begin();
		while (i != mHosts.end()){
			if (hosts.count(i->first) == 0) { 
				// remove host
				removeRow (i->second->row()); // will delete all descendants by Qt
				mHosts.erase(i++);
				changed = true;
			} else {
				i++;
			}
		}
	}
	if (changed)
		updatePresentation ();
}
示例#24
0
void UserTreeModel::updateBranch(const QModelIndex &rootBranchIndex)
{
    UserItem* rootBranchItem = getItem(rootBranchIndex);
    if (rootBranchItem->childCount() == 0) {
        removeRow(rootBranchIndex.row(), rootBranchIndex.parent());
        if (rootBranchIndex == operatorsBranch) {
            operatorsBranch = QModelIndex();
            if (usersBranch.isValid()) {
                usersBranch = index(usersBranch.row()-1, 0);
            }
            if (voicedBranch.isValid()) {
                voicedBranch = index(voicedBranch.row()-1, 0);
            }
        } else if (rootBranchIndex == voicedBranch) {
            voicedBranch = QModelIndex();
            if (usersBranch.isValid()) {
                usersBranch = index(usersBranch.row()-1, 0);
            }
        } else {
            usersBranch = QModelIndex();
        }
    } else {
        setData(index(rootBranchIndex.row(), 0), QVariant(QString("%1 (%2)").arg(rootBranchItem->data().split(" ").at(0)).arg(rootBranchItem->childCount())));
    }
}
void MusicMyDownloadRecordWidget::setDeleteItemAt()
{
    MusicMessageBox message;
    message.setText(tr("Are you sure to delete?"));
    if( message.exec() || rowCount() == 0 )
    {
       return;
    }
    MIntSet deletedRow; //if selected multi rows
    for(int i=0; i<selectedItems().count(); ++i)
    {
        deletedRow.insert(selectedItems()[i]->row());
    }
    MIntList deleteList = deletedRow.toList();
    qSort(deleteList);
    for(int i=deleteList.count() - 1; i>=0; --i)
    {
        int ind = deleteList[i];
        removeRow(ind); //Delete the current row
        m_musicRecord.m_names.removeAt(ind);
        m_musicRecord.m_paths.removeAt(ind);
        m_musicRecord.m_sizes.removeAt(ind);
        --m_loadRecordCount;
    }
}
示例#26
0
void MyPlaylist::clear_play_list()
{
    while(rowCount())
        removeRow(0);
    emit play_list_clean();//删除完后,发送清空成功信号

}
示例#27
0
void TutorModel::deleteTutorRecord(int nRow)
{
    int prevStep;
    int nextStep=0;
    if(nRow == 0 || nRow == rowCount(QModelIndex())-1)//表头或者表尾;
    {
       updateRecordStep(nRow+1, -1);
    }else//中间;
    {
        prevStep = m_tutorVec.at(nRow-1)->record.nStep;
        nextStep = m_tutorVec.at(nRow+1)->record.nStep;
        int curStep = m_tutorVec.at(nRow)->record.nStep;
        if(prevStep != curStep && nextStep != curStep)
            updateRecordStep(nRow+1, -1);
    }

    LPTutorRecordStr pRecord = m_tutorVec.at(nRow);
	m_tutorVec.remove(nRow);//从vecotr中取走;

	//释放内存;
	qDebug()<<pRecord->record.pData;
    delete pRecord->record.pData;
    delete pRecord;

    removeRow(nRow, QModelIndex());
}
 void removeFileNames(const QModelIndexList& indexes)
 {
     for (int i = indexes.size() - 1; i >= 0; i--)
     {
         removeRow(indexes[i].row(), indexes[i].parent());
     }
 }
示例#29
0
SubscribeServerThread::SubscribeStatus SubscribeServerThread::removeSubscription(
    const SipMessage* subscribeMessage)
{
    int subscribeCseqInt = 0;
    UtlString callId;
    UtlString to;
    UtlString from;
    UtlString method;

    subscribeMessage->getToField(&to);
    subscribeMessage->getFromField(&from);
    subscribeMessage->getCallIdField(&callId);
    subscribeMessage->getCSeqField(&subscribeCseqInt, &method);
    Url toUrl;
    subscribeMessage->getToUrl(toUrl);
    // remove subscription binding
    // remove all bindings  because one contact value is *
    OsSysLog::add(FAC_SIP, PRI_DEBUG, "SubscribeServerThread::removeSubscription -"
      " Removing subscription for url %s and callid %s", toUrl.toString().data(), callId.data());

    // note that the subscribe's csequence is used
    // as a remove filter here (all rows with CSEQ < this are removed)
    removeRow(to, from, callId, subscribeCseqInt);

    return STATUS_REMOVED;
}
示例#30
0
void BookmarkModel::remove(const QString& url)
{
    if (!contains(url))
        return;

    QSqlQuery sqlQuery(database());
    sqlQuery.prepare(QLatin1String("SELECT id FROM bookmarks WHERE url = ?"));
    sqlQuery.addBindValue(url);
    sqlQuery.exec();
    sqlQuery.first();
    int indexToDelete = -1;
    for (int row = 0; row < rowCount(); ++row) {
        if (createIndex(row, 0).data(Qt::DisplayRole).toInt() == sqlQuery.value(0).toInt()) {
            indexToDelete = row;
            break;
        }
    }

    if (indexToDelete >= 0) {
        beginRemoveRows(createIndex(indexToDelete, 0), indexToDelete, indexToDelete);
        removeRow(indexToDelete);
        submitAll();
        endRemoveRows();
    }
}