void player::use(int index){ //WEAPON,ARMOR,CONSUMABLE,ETC Item tmp = load::getItemData(getItemList()->at(index).getID()); if(tmp.getItemType() == "WEAPON"){ getStat()->addAll(0-getWeapon().getiAtk(),0-getWeapon().getiDef(),0-getWeapon().getiMaxHp()); getItemList()->at(index) = load::getItemData(getWeapon().getID()); if(getItemList()->at(index).getID() == 1)delItem(index); setWeapon(tmp.getID()); getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp()); cout << "\n\tEquipe "<<tmp.getName()<<endl; }else if(tmp.getItemType() == "ARMOR"){ getStat()->addAll(0-getArmor().getiAtk(),0-getArmor().getiDef(),0-getArmor().getiMaxHp()); getItemList()->at(index) = load::getItemData(getArmor().getID()); if(getItemList()->at(index).getID() == 2)delItem(index); setArmor(tmp.getID()); getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp()); cout << "\n\tEquipe "<<tmp.getName()<<endl; }else if(tmp.getItemType() == "CONSUMABLE"){ getStat()->addAll(tmp.getiAtk(),tmp.getiDef(),tmp.getiMaxHp()); getStat()->addHp(tmp.getiHp()); delItem(index); cout << "\tUse "<<tmp.getName()<<endl; }else{ cout << "\n\tCannot use "<<tmp.getName()<<endl; } getch(); }
QTitleWidget::QTitleWidget(QWidget *parent) : QWidget(parent) { QHBoxLayout *hl = new QHBoxLayout; hl->setMargin(0); hl->setSpacing(0); setObjectName("titleWidget"); QLabel * label = new QLabel; QImage image(":/inner/images/begin.png"); label->setPixmap(QPixmap::fromImage(image)); label->setFixedSize(16,16); QAction * ac = new QAction(QIcon(":/inner/images/delete_item.png"),tr("Remove Item"),this); m_delButton = new QToolBarButton(ac); ac = new QAction(QIcon(":/inner/images/add.png"),tr("Add Title"),this); m_addTitleButton = new QToolBarButton(ac); m_addTitleButton->setVisible(true); hl->addWidget(m_addTitleButton); hl->addWidget(label); hl->addSpacerItem(new QSpacerItem(1,1,QSizePolicy::Expanding, QSizePolicy::Expanding)); hl->addWidget(m_delButton); setLayout(hl); setStyleSheet("#titleWidget{background-color:rgb(255,220,180);}"); setFixedHeight(22); connect(m_addTitleButton,SIGNAL(clicked()),this,SIGNAL(addTitle())); connect(m_delButton,SIGNAL(clicked()),this,SIGNAL(delItem())); }
UIPlaylist::UIPlaylist(MehdiaPlayer* parent) { this->parent = parent; widgetPlaylist = new QListWidget; buttonDel = new QPushButton("Remove"); buttonDel->setFixedHeight(30); buttonClear = new QPushButton("Clear"); buttonClear->setFixedHeight(30); buttonSave = new QPushButton("Save"); buttonSave->setFixedHeight(30); // Layout layout = new QVBoxLayout(); layoutControlPL = new QHBoxLayout; layoutControlPL->addWidget(buttonDel); layoutControlPL->addWidget(buttonClear); layoutControlPL->addWidget(buttonSave); layoutControlPL->setAlignment(Qt::AlignCenter); connect(buttonDel, SIGNAL(clicked()), SLOT(delItem())); connect(buttonClear, SIGNAL(clicked()), SLOT(buttonClearPlaylist())); connect(buttonSave, SIGNAL(clicked()), SLOT(savePlaylist())); connect(widgetPlaylist, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(playlistDoubleClicked())); layout->addWidget(widgetPlaylist); layout->addLayout(layoutControlPL); setLayout(layout); }
void QKeyList::contextMenuEvent(QContextMenuEvent* evt) { QMenu menu(this); QAction* addObjItem = menu.addAction(tr("Add Object")); QAction* delObjItem = menu.addAction(tr("Remove Object")); if (currentItem() == NULL) delObjItem->setEnabled(false); QAction* sel = menu.exec(evt->globalPos()); if (sel == addObjItem) { QFindKeyDialog dlg(this); if (fKeys.size() > 0) dlg.init(PrpShopMain::ResManager(), fKeys.back()->getLocation(), fKeys.back()->getType()); else dlg.init(PrpShopMain::ResManager(), fContainer->getLocation()); if (dlg.exec() == QDialog::Accepted) { addKey(dlg.selection()); emit itemAdded(dlg.selection()); } } else if (sel == delObjItem) { int idx = indexOfTopLevelItem(currentItem()); delItem(idx); emit itemRemoved(idx); } }
ScriptCore::~ScriptCore() { runTask(new DelV8(m_pInternal)); safe_delete(m_pInternal); delItem(); }
void CschedulerDlg::OnBnClickedDel() { // TODO: Add your control notification handler code here // POSITION pos = m_list.GetFirstSelectedItemPosition(); // while (pos) // { // int nItem = m_list.GetNextSelectedItem(pos); // m_list.DeleteItem(nItem); // } int nsel=m_list.GetSelectedColumn(); int cursel; // ITEMDATA* pItemData; // int index; cursel=m_list.GetNextItem(-1,LVIS_SELECTED); while(cursel != -1) { //delete item data // pItemData=(ITEMDATA*)m_list.GetItemData(cursel); // index=pItemData->index; // while(index < KS_MAX_ITIMES) // { // if (m_pData[index+1]==0) break; // m_pData[index]=m_pData[index+1]; // m_pData[index]->index--; // index++; // } // m_pData[index]=0; // delete pItemData; // // m_list.DeleteItem(cursel); delItem(cursel); cursel=m_list.GetNextItem(-1,LVIS_SELECTED|LVIS_FOCUSED); } }
GroupWidget::GroupWidget(QList <Group*> *group, QWidget *parent) : QWidget(parent), groupList(group) { QHBoxLayout *h1 = new QHBoxLayout(); { QLabel *l = new QLabel(tr("Group: ")); addGroupEdit = new QLineEdit(this); connect(addGroupEdit, SIGNAL(editingFinished()), SLOT(createGroup())); addButton = new QPushButton(tr("Create"), this); connect(addGroupEdit, SIGNAL(textChanged(QString)), SLOT(changeAddGroup(QString))); connect(addButton, SIGNAL(clicked()), SLOT(createGroup())); addButton->setEnabled(false); h1->addWidget(l); h1->addWidget(addGroupEdit); h1->addWidget(addButton); } QHBoxLayout *h2 = new QHBoxLayout(); { h2->setMargin(0); upButton = new QPushButton(this); upButton->setIcon(QIcon(":images/uparrow.png")); downButton = new QPushButton(this); downButton->setIcon(QIcon(":images/downarrow.png")); h2->addStretch(); h2->addWidget(upButton); h2->addWidget(downButton); editButton = new QPushButton(this); editButton->setIcon(QIcon(":images/edit.png")); h2->addWidget(editButton); delButton = new QPushButton(this); delButton->setIcon(QIcon(":images/delete.png")); h2->addWidget(delButton); } groupListWidget = new QListWidget(this); QVBoxLayout *v = new QVBoxLayout; v->setMargin(0); v->setSpacing(0); v->addLayout(h1); v->addWidget(groupListWidget); v->addLayout(h2); setLayout(v); //qDebug() << "BookWidget 3"; connect(upButton, SIGNAL(clicked()), SLOT(upItem())); connect(downButton, SIGNAL(clicked()), SLOT(downItem())); connect(editButton, SIGNAL(clicked()), SLOT(editItem())); connect(delButton, SIGNAL(clicked()), SLOT(delItem())); connect(groupListWidget, SIGNAL(currentRowChanged(int)), SLOT(changeRow(int))); connect(groupListWidget, SIGNAL(itemChanged(QListWidgetItem*)), SLOT(changeName(QListWidgetItem*))); connect(groupListWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(editItem(QListWidgetItem*))); connect(groupListWidget, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem*)), SLOT(changeSelect(QListWidgetItem *, QListWidgetItem*))); initGroup(); resetButtons(); }
customActionsDialog::customActionsDialog(MainWindow *parent) { mainWindow = parent; mainLayout = new QVBoxLayout(); treeWidget = new QTreeWidget(); treeWidget->setAlternatingRowColors(true); treeWidget->setRootIsDecorated(false); treeWidget->setSelectionBehavior(QAbstractItemView::SelectRows); connect(treeWidget,SIGNAL(itemDoubleClicked(QTreeWidgetItem *,int)),this,SLOT(getIcon(QTreeWidgetItem *,int))); QTreeWidgetItem *header = treeWidget->headerItem(); header->setText(0,tr("Filetype")); header->setText(1,tr("Text")); header->setText(2,tr("Icon")); header->setText(3,tr("Command")); treeWidget->setColumnWidth(1,160); treeWidget->setColumnWidth(2,160); treeWidget->setDragDropMode(QAbstractItemView::InternalMove); mainLayout->addWidget(treeWidget); horizontalLayout = new QHBoxLayout(); addButton = new QToolButton(); delButton = new QToolButton(); infoButton= new QToolButton(); addButton->setIcon(QIcon::fromTheme("list-add")); delButton->setIcon(QIcon::fromTheme("list-remove")); infoButton->setIcon(QIcon::fromTheme("dialog-question",QIcon::fromTheme("help-browser"))); connect(addButton,SIGNAL(clicked()),this,SLOT(addItem())); connect(delButton,SIGNAL(clicked()),this,SLOT(delItem())); connect(infoButton,SIGNAL(clicked()),this,SLOT(infoItem())); buttons = new QDialogButtonBox; buttons->setStandardButtons(QDialogButtonBox::Save|QDialogButtonBox::Cancel); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); horizontalLayout->addWidget(infoButton); horizontalLayout->addWidget(addButton); horizontalLayout->addWidget(delButton); horizontalLayout->addWidget(buttons); mainLayout->addLayout(horizontalLayout); setLayout(mainLayout); readItems(); resize(600,360); setWindowTitle(tr("Custom Actions")); }
void HashTable::detach( Object& objectToDetach, DeleteType dt ) { hashValueType index = getHashValue( objectToDetach ); if( table[ index ] != 0 ) { unsigned listSize = ((List *)table[ index ])->getItemsInContainer(); ((List *)table[ index ])->detach( objectToDetach, delItem(dt) ); if( ((List *)table[ index ])->getItemsInContainer() != listSize ) itemsInContainer--; } }
UINT CschedulerDlg::showNote(LPVOID lparam) { COleDateTime curtime; COleDateTime temptime; CString tempstr; CString notemsg; int nitem=m_list.GetItemCount(); int count=0,i; TCHAR tempch; curtime = COleDateTime::GetCurrentTime(); for(i=0;i<nitem;) { tempstr = m_list.GetItemText(i,0); if(!temptime.ParseDateTime(tempstr,0)) return 0; tempstr = m_list.GetItemText(i,2); tempstr = tempstr.Left(1); tempch = tempstr[0]; if(tempch != L'0') if((m_ksSetting.alertBeforeChk == BST_CHECKED) || (tempch==L'D')) { temptime =temptime - m_ksSetting.alertBeforeTime; } // tempstr=m_ksSetting.alertBeforeTime.Format(_T("%m/%d/%Y %H:%M:%S")); // tempstr=temptime.Format(_T("%m/%d/%Y %H:%M:%S")); if (curtime>=temptime){ count++; notemsg.AppendFormat(_T("%s: %s\n"),m_list.GetItemText(i,1),m_list.GetItemText(i,2)); delItem(i); //m_list.DeleteItem(i); nitem--; } else i++; } if(count > 0) { // AfxMessageBox(notemsg); MessageBox(notemsg.GetBuffer(),0,MB_SYSTEMMODAL); } return 0; }
void ScriptCore::setItem(ScriptCoreItemI* item) { if (!item) return; ScriptCoreItemI* temp = ItemJSBinding::GetItem(m_uiItemId); if (temp == item) return; delItem(); m_uiItemId = ItemJSBinding::AddItem(item); executeString(gcString("item.SetItem({0});", (int32)m_uiItemId).c_str()); }
void SpawnShell::deleteItem(spawnItemType type, int id) { #ifdef SPAWNSHELL_DIAG seqDebug("SpawnShell::deleteItem()"); #endif ItemMap& theMap = getMap(type); Item* item = theMap.find(id); if (item != NULL) { emit delItem(item); theMap.remove(id); // send notifcation of new spawn count emit numSpawns(m_spawns.count()); } }
void SpawnShell::deleteItem(itemType type, int id) { #ifdef SPAWNSHELL_DIAG printf ("SpawnShell::deleteItem()\n"); #endif ItemMap& theMap = getMap(type); Item* item = theMap.find(id); if (item != NULL) { if (item->filterFlags() & FILTER_FLAG_ALERT) emit handleAlert(item, tDelSpawn); emit delItem(item); theMap.remove(id); // send notifcation of new spawn count emit numSpawns(m_spawns.count()); } }
FinanceMgr::FinanceMgr(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); MainButtonList* btnList = new MainButtonList(this); // set splitter window as the central widget of main window mainView = new MainView(this); mainView->openWindow(DepartmentManagerView); QSplitter* splitter = new QSplitter(this); setCentralWidget(splitter); splitter->addWidget(btnList); splitter->addWidget(mainView); // connect the manage menu connect(ui.actionDepartment, SIGNAL(triggered()), this, SLOT(handleActionDepartment())); connect(ui.actionBankAccount, SIGNAL(triggered()), this, SLOT(handleActionBank())); connect(ui.actionBudget, SIGNAL(triggered()), this, SLOT(handleBudget())); connect(ui.actionTitle, SIGNAL(triggered()), this, SLOT(handleTitle())); connect(ui.actionDetailTitle, SIGNAL(triggered()), this, SLOT(handleDetailTitle())); connect(ui.actionIncome, SIGNAL(triggered()), this, SLOT(handleIncome())); connect(ui.actionCheck, SIGNAL(triggered()), this, SLOT(handleCRCheck())); connect(ui.actionCash, SIGNAL(triggered()), this, SLOT(hanldeCashShow())); // here connect the operation of operation menu connect(ui.actionInsert, SIGNAL(triggered()), this, SLOT(addItem())); connect(ui.actionEdit, SIGNAL(triggered()), this, SLOT(editItem())); connect(ui.actionDel, SIGNAL(triggered()), this, SLOT(delItem())); // create the toolbar createToolbar(); QString strCurrentYear = QString("%1").arg(QDate::currentDate().year()); QString strCurrentMonth = QString("%1").arg(QDate::currentDate().month()); QString strTitle = windowTitle(); strTitle += QString("-%1%2").arg(strCurrentYear, strCurrentMonth); setWindowTitle(strTitle); }
/*! * Shows popup menu. * \param item (in) - current item. * \param p (in) - mouse pointer position. * \param col (in) - current column. */ void aListView::showMenu( QListViewItem* item, const QPoint& p, int col) { delete menu; menu = new QPopupMenu(); if(toSelect) { menu->insertItem(tr("Select"), this, SLOT(select())); menu->insertSeparator(); } menu->insertItem(tr("Edit"), this, SLOT(edit())); menu->insertSeparator(); menu->insertItem(tr("New element"), this, SLOT(newItem())); menu->insertItem(tr("New group"), this, SLOT(newGroup())); menu->insertSeparator(); //menu->setItemEnabled(menu->idAt(3),false); menu->insertItem(tr("Undo mark delete"), this, SLOT(undoMarkDeleted())); menu->insertItem(tr("Delete (mark deleted)"),this, SLOT(markDeleted())); menu->insertItem(tr("Delete (phisical)"), this, SLOT(delItem())); parentItem = item; if(col==-1) col = 0; columnClicked = col; menu->popup( p ); }
static void test_comboboxex(void) { HWND myHwnd = 0; LONG res = -1; COMBOBOXEXITEMA cbexItem; static const char *first_item = "First Item", *second_item = "Second Item", *third_item = "Third Item", *middle_item = "Between First and Second Items", *replacement_item = "Between First and Second Items", *out_of_range_item = "Out of Range Item"; /* Allocate space for result */ textBuffer = HeapAlloc(GetProcessHeap(), 0, MAX_CHARS); /* Basic comboboxex test */ myHwnd = createComboEx(WS_BORDER | WS_VISIBLE | WS_CHILD | CBS_DROPDOWN); /* Add items onto the end of the combobox */ res = addItem(myHwnd, -1, first_item); ok(res == 0, "Adding simple item failed (%d)\n", res); res = addItem(myHwnd, -1, second_item); ok(res == 1, "Adding simple item failed (%d)\n", res); res = addItem(myHwnd, 2, third_item); ok(res == 2, "Adding simple item failed (%d)\n", res); res = addItem(myHwnd, 1, middle_item); ok(res == 1, "Inserting simple item failed (%d)\n", res); /* Add an item completely out of range */ res = addItem(myHwnd, 99, out_of_range_item); ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res); res = addItem(myHwnd, 5, out_of_range_item); ok(res == -1, "Adding using out of range index worked unexpectedly (%d)\n", res); /* Removed: Causes traps on Windows XP res = addItem(myHwnd, -2, "Out Of Range Item"); ok(res == -1, "Adding out of range worked unexpectedly (%ld)\n", res); */ /* Get an item completely out of range */ res = getItem(myHwnd, 99, &cbexItem); ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText); res = getItem(myHwnd, 4, &cbexItem); ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText); res = getItem(myHwnd, -2, &cbexItem); ok(res == 0, "Getting item using out of range index worked unexpectedly (%d, %s)\n", res, cbexItem.pszText); /* Get an item in range */ res = getItem(myHwnd, 0, &cbexItem); ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res); ok(strcmp(first_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText); res = getItem(myHwnd, 1, &cbexItem); ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res); ok(strcmp(middle_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText); res = getItem(myHwnd, 2, &cbexItem); ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res); ok(strcmp(second_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText); res = getItem(myHwnd, 3, &cbexItem); ok(res != 0, "Getting item using valid index failed unexpectedly (%d)\n", res); ok(strcmp(third_item, cbexItem.pszText) == 0, "Getting item returned wrong string (%s)\n", cbexItem.pszText); /* Set an item completely out of range */ res = setItem(myHwnd, 99, replacement_item); ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res); res = setItem(myHwnd, 4, replacement_item); ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res); res = setItem(myHwnd, -2, replacement_item); ok(res == 0, "Setting item using out of range index worked unexpectedly (%d)\n", res); /* Set an item in range */ res = setItem(myHwnd, 0, replacement_item); ok(res != 0, "Setting first item failed (%d)\n", res); res = setItem(myHwnd, 3, replacement_item); ok(res != 0, "Setting last item failed (%d)\n", res); /* Remove items completely out of range (4 items in control at this point) */ res = delItem(myHwnd, -1); ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res); res = delItem(myHwnd, 4); ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res); /* Remove items in range (4 items in control at this point) */ res = delItem(myHwnd, 3); ok(res == 3, "Deleting using out of range index failed (%d)\n", res); res = delItem(myHwnd, 0); ok(res == 2, "Deleting using out of range index failed (%d)\n", res); res = delItem(myHwnd, 0); ok(res == 1, "Deleting using out of range index failed (%d)\n", res); res = delItem(myHwnd, 0); ok(res == 0, "Deleting using out of range index failed (%d)\n", res); /* Remove from an empty box */ res = delItem(myHwnd, 0); ok(res == CB_ERR, "Deleting using out of range index worked unexpectedly (%d)\n", res); /* Cleanup */ HeapFree(GetProcessHeap(), 0, textBuffer); DestroyWindow(myHwnd); }
/*! Key press event handler. Emit signal keyEnterPressed(). * \param e (in) - key press event. */ void aListView::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Qt::Key_Return: e->accept(); parentItem = selectedItem(); columnClicked = 0; if(toSelect) { select(); } else { edit(); } break; case Qt::Key_Insert: parentItem = selectedItem(); columnClicked = 0; switch(QMessageBox::question(this, tr("Type of new item"), tr("<p align=\"center\">Select type of new item</p>"), tr("&Elemnt"), tr("&Group"))) { case 0: newItem(); break; case 1: newGroup(); break; default: break; } break; case Qt::Key_Delete: parentItem = selectedItem(); columnClicked = 0; switch(QMessageBox::question(this, tr("Delete item"), tr("<p align=\"center\">Mark deleted or delete?</p>"), tr("&Mark deleted"), tr("&Delete"))) { case 0: markDeleted(); break; case 1: delItem(); break; default: break; } break; default: e->ignore(); break; } QListView::keyPressEvent(e); }
void SimTreeView::onCommand( int id, HWND hwndCtl, UINT codeNotify ) { hwndCtl, codeNotify; SimObject *obj; SimSet *prnt; lockManager(); switch( id ) { case IDM_EXIT: destroyWindow(); break; case IDM_CUT: if ( (obj = getSelectedObject()) != NULL ) { // persist selected object obj->fileStore( "temp\\clip.tmp" ); // remove it from parent obj->deleteObject(); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_COPY: if ( (obj = getSelectedObject()) != NULL ) obj->fileStore( "temp\\clip.tmp" ); break; case IDM_PASTE: { // unpersist object to get a duplicate Persistent::Base::Error err; obj = (SimObject*)Persistent::Base::fileLoad( "temp\\clip.tmp", &err ); if ( err != Ok ) return; // add to simTree HTREEITEM hParent = getSelection(); if ( !isItemFolder(hParent) ) hParent = getParent( hParent ); prnt = (SimSet*)getObject( hParent ); prnt->getManager()->addObject( obj ); prnt->addObject(obj); HTREEITEM hItem = addSet( obj, hParent ); selectItem( hItem ); state.set(STV_MODIFIED); } break; case IDM_DELETE: obj = getSelectedObject(); if ( obj ) { obj->deleteObject(); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_REMOVE: obj = getSelectedObject(); if ( obj ) { prnt = getSelectedParent(); prnt->removeObject(obj); delItem( getSelection() ); state.set(STV_MODIFIED); } break; case IDM_DUPLICATE: { obj = getSelectedObject(); // persist object to get a duplicate if ( obj->fileStore( "temp\\clip.tmp" ) != Ok ) { unlockManager(); return; } Persistent::Base::Error err; obj = (SimObject*)Persistent::Base::fileLoad( "temp\\clip.tmp", &err ); if ( err != Ok ) { unlockManager(); return; } // perhaps delete clip.tmp to clean up directory HTREEITEM hParent = getSelection(); if ( !isItemFolder(hParent) ) hParent = getParent( hParent ); prnt = (SimSet*)getObject( hParent ); prnt->getManager()->addObject( obj ); prnt->addObject( obj ); HTREEITEM hItem = addSet( obj, getParent(getSelection()) ); selectItem( hItem ); state.set(STV_MODIFIED); } break; case IDM_EDIT: inspectObject( getSelectedObject() ); state.set(STV_MODIFIED); break; case IDM_LOCK: lockObject( getSelectedObject(), true ); state.set( STV_MODIFIED ); break; case IDM_UNLOCK: lockObject( getSelectedObject(), false ); state.set( STV_MODIFIED ); break; default: if ( (id>=IDM_SCRIPT_START) && (id<=scriptMenu_IDM) ) { int scriptIndex = id-IDM_SCRIPT_START; CMDConsole::getLocked()->evaluate( script[scriptIndex], false ); } // let parent handle its default menu items WinParent::handleContextMenuItemSelection( id ); } checkMenu( hMainMenu ); unlockManager(); }
/* get the list of Transfers from the RsIface. **/ void TransfersDialog::insertTransfers() { QString symbol, name, sources, status, coreId; qlonglong fileSize, completed, remaining; double progress, dlspeed; /* get current selection */ std::list<std::string> selectedIds; for(int i = 0; i <= DLListModel->rowCount(); i++) { if(selection->isRowSelected(i, QModelIndex())) { std::string id = getID(i, DLListModel).toStdString(); selectedIds.push_back(id); } } //remove all Items for(int i = DLListModel->rowCount(); i >= 0; i--) { delItem(i); } for(int i = ULListModel->rowCount(); i >= 0; i--) { delUploadItem(i); } ui.downloadList->sortByColumn(_sortColDwl, _sortOrderDwl); /* disable for performance issues, enable after insert all transfers */ ui.downloadList->setSortingEnabled(false); QModelIndex firstSelIdx; /* get the download and upload lists */ std::list<std::string> downHashes; std::list<std::string> upHashes; rsFiles->FileDownloads(downHashes); rsFiles->FileUploads(upHashes); uint32_t dlCount = 0; uint32_t ulCount = 0; std::list<std::string>::iterator it; for(it = downHashes.begin(); it != downHashes.end(); it++) { FileInfo info; if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) { continue; } //if file transfer is a cache file index file, don't show it if (info.flags & CB_CODE_CACHE) { continue; } std::list<TransferInfo>::iterator pit; for(pit = info.peers.begin(); pit != info.peers.end(); pit++) { symbol = ""; coreId = QString::fromStdString(info.hash); name = QString::fromUtf8(info.fname.c_str()); sources = QString::fromStdString(rsPeers->getPeerName(pit->peerId)); switch(pit->status) { case FT_STATE_FAILED: status = tr("Failed"); break; case FT_STATE_OKAY: status = tr("Okay"); break; case FT_STATE_WAITING: status = tr("Waiting"); break; case FT_STATE_DOWNLOADING: status = tr("Downloading"); break; case FT_STATE_COMPLETE: default: status = tr("Complete"); break; } if (info.downloadStatus == FT_STATE_COMPLETE) { status = tr("Complete"); } dlspeed = (pit->status == FT_STATE_DOWNLOADING)?( pit->tfRate * 1024.0 ) :0.0; fileSize = info.size; completed = info.transfered; progress = info.transfered * 100.0 / info.size; remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining); /* if found in selectedIds -> select again */ if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) { selection->select(DLListModel->index(dlCount, 0), QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); if (!firstSelIdx.isValid()) firstSelIdx = DLListModel->index(dlCount, NAME); } dlCount++; } /* alternative ... if no peers there stick it in anyway */ if (info.peers.size() == 0) { symbol = ""; coreId = QString::fromStdString(info.hash); name = QString::fromUtf8(info.fname.c_str()); sources = tr("Unknown"); switch(info.downloadStatus) { case FT_STATE_FAILED: status = tr("Failed"); break; case FT_STATE_OKAY: status = tr("Okay"); break; case FT_STATE_WAITING: status = tr("Waiting"); break; case FT_STATE_DOWNLOADING: status = tr("Downloading"); break; case FT_STATE_COMPLETE: default: status = tr("Complete"); break; } dlspeed = (pit->status == FT_STATE_DOWNLOADING)?( pit->tfRate * 1024.0 ) :0.0; fileSize = info.size; completed = info.transfered; progress = info.transfered * 100.0 / info.size; remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); addItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining); /* if found in selectedIds -> select again */ if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash)) { selection->select(DLListModel->index(dlCount, 0), QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent); if (!firstSelIdx.isValid()) firstSelIdx = DLListModel->index(dlCount, NAME); } dlCount++; } } if (firstSelIdx.isValid()) ui.downloadList->scrollTo(firstSelIdx); ui.downloadList->setSortingEnabled(true); ui.uploadsList->sortByColumn(_sortColUpl, _sortOrderUpl); /* disable for performance issues, enable after insert all transfers */ ui.uploadsList->setSortingEnabled(false); for(it = upHashes.begin(); it != upHashes.end(); it++) { FileInfo info; if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) { continue; } std::list<TransferInfo>::iterator pit; for(pit = info.peers.begin(); pit != info.peers.end(); pit++) { symbol = ""; coreId = QString::fromStdString(info.hash); name = QString::fromUtf8(info.fname.c_str()); sources = QString::fromStdString(rsPeers->getPeerName(pit->peerId)); switch(pit->status) { case FT_STATE_FAILED: status = tr("Failed"); break; case FT_STATE_OKAY: status = tr("Okay"); break; case FT_STATE_WAITING: status = tr("Waiting"); break; case FT_STATE_DOWNLOADING: status = tr("Uploading"); break; case FT_STATE_COMPLETE: default: status = tr("Complete"); break; } // if (info.downloadStatus == FT_STATE_COMPLETE) // { // status = "Complete"; // } dlspeed = (pit->status == FT_STATE_DOWNLOADING)?( pit->tfRate * 1024.0 ) :0.0; fileSize = info.size; completed = info.transfered; progress = info.transfered * 100.0 / info.size; remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); addUploadItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining); ulCount++; } if (info.peers.size() == 0) { symbol = ""; coreId = QString::fromStdString(info.hash); name = QString::fromUtf8(info.fname.c_str()); sources = tr("Unknown"); switch(info.downloadStatus) { case FT_STATE_FAILED: status = tr("Failed"); break; case FT_STATE_OKAY: status = tr("Okay"); break; case FT_STATE_WAITING: status = tr("Waiting"); break; case FT_STATE_DOWNLOADING: status = tr("Uploading"); break; case FT_STATE_COMPLETE: default: status = tr("Complete"); break; } dlspeed = info.tfRate * 1024.0; fileSize = info.size; completed = info.transfered; progress = info.transfered * 100.0 / info.size; remaining = (info.size - info.transfered) / (info.tfRate * 1024.0); addUploadItem(symbol, name, coreId, fileSize, progress, dlspeed, sources, status, completed, remaining); ulCount++; } } }
__MSSHELL_WRAPPER_ static inline void _MS__private __lmp_prog delLog(const sel_typ argc, char ** argv) { delItem(argc ? getItemID(argv[0], &logs_manager[__pmode__], LOGS) : getItemsListNo(LOGS), LOGS); return; }
void phdFilterList::delItem(phdFilter * _item) { delItem(indexOf(_item)); }
int satipc_reply(sockets * s) { int rlen = s->rlen; adapter *ad; char *arg[50], *sess, *es, *sid; int la, i, rc; s->rlen = 0; LOG("satipc_reply (sock %d) handle %d, adapter %d:\n%s", s->id, s->sock, s->sid, s->buf); if (!(ad = get_adapter(s->sid))) return 0; sess = strstr(s->buf, "Session:"); la = split(arg, (char *) s->buf, 50, ' '); rc = map_int(arg[1], NULL); if (ad->last_cmd == RTSP_OPTIONS && !sess && ad->session[0]) rc = 454; if (rc == 454 || rc == 503 || rc == 405) { ad->sent_transport = 0; ad->want_tune = 1; ad->want_commit = 1; ad->force_commit = 1; } else if (rc != 200) ad->err = 1; sid = NULL; if (rc == 200 && !ad->want_tune) ad->ignore_packets = 0; sess = NULL; for (i = 0; i < la; i++) if (strncasecmp("Session:", arg[i], 8) == 0) sess = header_parameter(arg, i); else if (strncasecmp("com.ses.streamID:", arg[i], 17) == 0) sid = header_parameter(arg, i); else if (strncasecmp("Server:", arg[i], 7) == 0) { char *ua = header_parameter(arg, i); if (!strncmp(ua, app_name, strlen(app_name))) { ad->satip_addpids = 1; ad->satip_setup_pids = 1; } } if (!ad->err && !ad->session[0] && sess) { if ((es = strchr(sess, ';'))) *es = 0; strncpy(ad->session, sess, sizeof(ad->session)); ad->session[sizeof(ad->session) - 1] = 0; LOG("satipc: session set for adapter %d to %s", ad->id, ad->session); if (sid && ad->stream_id == -1) ad->stream_id = map_int(sid, NULL); ad->expect_reply = 0; ad->force_commit = 1; // http_request(ad, NULL, "PLAY"); satipc_commit(ad); return 0; } if (ad->wp >= ad->qp) ad->expect_reply = 0; else { char *np = (char *) getItem(MAKE_ITEM(ad->id, ad->wp)); if (np) { int len = strlen(np); if (ad->session[0] && !strstr(np, "Session:")) sprintf(np + len - 2, "Session: %s\r\n\r\n", ad->session); LOG("satipc_reply: sending next packet:\n%s", np); write(s->sock, np, strlen(np)); delItem(MAKE_ITEM(ad->id, ad->wp++)); } } if (!ad->expect_reply && (ad->wp >= ad->qp) && (ad->want_commit || ad->force_commit)) // we do not expect reply and no other events in the queue, we commit a { satipc_commit(ad); } return 0; }