本文整理汇总了C++中ConnectionListWidgetItem类的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionListWidgetItem类的具体用法?C++ ConnectionListWidgetItem怎么用?C++ ConnectionListWidgetItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionListWidgetItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: edit
/**
* @brief Initiate 'edit' action, usually when user clicked on Edit button
*/
void ConnectionsDialog::edit()
{
ConnectionListWidgetItem *currentItem =
(ConnectionListWidgetItem *) _listWidget->currentItem();
// Do nothing if no item selected
if (currentItem == 0)
return;
ConnectionSettings *connection = currentItem->connection();
boost::scoped_ptr<ConnectionSettings> clonedConnection(connection->clone());
ConnectionDialog editDialog(clonedConnection.get());
// Do nothing if not accepted
if (editDialog.exec() != QDialog::Accepted) {
// on linux focus is lost - we need to activate connections dialog
activateWindow();
return;
}
connection->apply(editDialog.connection());
_settingsManager->updateConnection(connection);
// on linux focus is lost - we need to activate connections dialog
activateWindow();
}
示例2: clonedConnection
/**
* @brief Initiate 'edit' action, usually when user clicked on Edit button
*/
void ConnectionsDialog::edit()
{
ConnectionListWidgetItem *currentItem =
(ConnectionListWidgetItem *) _listWidget->currentItem();
// Do nothing if no item selected
if (currentItem == 0)
return;
ConnectionSettings *connection = currentItem->connection();
boost::scoped_ptr<ConnectionSettings> clonedConnection(connection->clone());
ConnectionDialog editDialog(clonedConnection.get());
// Do nothing if not accepted
if (editDialog.exec() != QDialog::Accepted) {
// on linux focus is lost - we need to activate connections dialog
activateWindow();
return;
}
connection->apply(editDialog.connection());
// on linux focus is lost - we need to activate connections dialog
activateWindow();
int size = _connectionItems.size();
for (int i=0; i<size; ++i)
{
ConnectionListWidgetItem *item = _connectionItems[i];
if (_connectionItems[i]->connection() == connection) {
item->setConnection(connection);
break;
}
}
}
示例3: path
bool ClusterDialog::validateAndApply() {
QVariant var = typeConnection_->currentData();
core::connectionTypes currentType =
static_cast<core::connectionTypes>(qvariant_cast<unsigned char>(var));
std::string conName = common::ConvertToString(connectionName_->text());
std::string conFolder = common::ConvertToString(connectionFolder_->text());
if (conFolder.empty()) {
conFolder = defaultNameConnectionFolder;
}
core::connection_path_t path(common::file_system::stable_dir_path(conFolder) + conName);
core::IClusterSettingsBase* newConnection =
core::ClusterConnectionSettingsFactory::instance().CreateFromType(currentType, path);
if (newConnection) {
cluster_connection_.reset(newConnection);
if (logging_->isChecked()) {
cluster_connection_->SetLoggingMsTimeInterval(loggingMsec_->value());
}
for (int i = 0; i < listWidget_->topLevelItemCount(); ++i) {
ConnectionListWidgetItem* item =
dynamic_cast<ConnectionListWidgetItem*>(listWidget_->topLevelItem(i)); // +
if (item) {
core::IConnectionSettingsBaseSPtr con = item->connection();
cluster_connection_->AddNode(con);
}
}
}
return true;
}
示例4: clone
void ConnectionsDialog::clone()
{
ConnectionListWidgetItem *currentItem =
(ConnectionListWidgetItem *) _listWidget->currentItem();
// Do nothing if no item selected
if (currentItem == 0)
return;
// Clone connection
ConnectionSettings *connection = currentItem->connection()->clone();
std::string newConnectionName="Copy of "+connection->connectionName();
connection->setConnectionName(newConnectionName);
ConnectionDialog editDialog(connection);
// Cleanup newly created connection and return, if not accepted.
if (editDialog.exec() != QDialog::Accepted) {
delete connection;
return;
}
// Now connection will be owned by SettingsManager
_settingsManager->addConnection(connection);
add(connection);
}
示例5: update
/**
* @brief Update specified connection (if it exists for this dialog)
*/
void ConnectionsDialog::update(ConnectionSettings *connection)
{
ConnectionListWidgetItem *item = _hash.value(connection);
if (!item)
return;
item->setConnection(connection);
}
示例6: ConnectionListWidgetItem
/**
* @brief Add connection to the list widget
*/
void ConnectionsDialog::add(ConnectionSettings *connection)
{
ConnectionListWidgetItem *item = new ConnectionListWidgetItem(connection);
item->setIcon(0, GuiRegistry::instance().serverIcon());
_listWidget->addTopLevelItem(item);
_hash.insert(connection, item);
}
示例7: selectedConnection
IConnectionSettingsBaseSPtr ConnectionsDialog::selectedConnection() const
{
ConnectionListWidgetItem *currentItem = dynamic_cast<ConnectionListWidgetItem *>(listWidget_->currentItem());
if (currentItem){
return currentItem->connection();
}
return IConnectionSettingsBaseSPtr();
}
示例8: testConnection
void ClusterDialog::testConnection() {
ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem()); // +
// Do nothing if no item selected
if (!currentItem) {
return;
}
ConnectionDiagnosticDialog diag(this, currentItem->connection());
diag.exec();
}
示例9: QTreeWidgetItem
ClusterConnectionListWidgetItemContainer::ClusterConnectionListWidgetItemContainer(core::IClusterSettingsBaseSPtr connection,
QTreeWidgetItem* parent)
: QTreeWidgetItem(parent), connection_() {
setConnection(connection);
auto nodes = connection_->nodes();
for (size_t i = 0; i < nodes.size(); ++i) {
core::IConnectionSettingsBaseSPtr con = nodes[i];
ConnectionListWidgetItem* item = new ConnectionListWidgetItem(this);
item->setConnection(con);
addChild(item);
}
}
示例10: accept
/**
* @brief This function is called when user clicks on "Connect" button.
*/
void ConnectionsDialog::accept()
{
ConnectionListWidgetItem *currentItem = (ConnectionListWidgetItem *) _listWidget->currentItem();
// Do nothing if no item selected
if (currentItem == 0)
return;
_selectedConnection = currentItem->connection();
close();
QDialog::accept();
}
示例11: QString
void ConnectionsDialog::remove()
{
QTreeWidgetItem* qitem = listWidget_->currentItem();
if(!qitem){
return;
}
ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem *>(qitem);
if(currentItem){
QTreeWidgetItem* qpitem = qitem->parent();
if(!qpitem){
// Ask user
int answer = QMessageBox::question(this, "Connections", QString("Really delete \"%1\" connection?").arg(currentItem->text(0)),
QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
if (answer != QMessageBox::Yes)
return;
IConnectionSettingsBaseSPtr connection = currentItem->connection();
delete currentItem;
SettingsManager::instance().removeConnection(connection);
return;
}
else{
qitem = qpitem;
}
}
ClusterConnectionListWidgetItem* clCurrentItem = dynamic_cast<ClusterConnectionListWidgetItem *>(qitem);
if(clCurrentItem){
// Ask user
int answer = QMessageBox::question(this, "Connections", QString("Really delete \"%1\" cluster?").arg(clCurrentItem->text(0)),
QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
if (answer != QMessageBox::Yes)
return;
IClusterSettingsBaseSPtr connection = clCurrentItem->connection();
delete clCurrentItem;
SettingsManager::instance().removeCluster(connection);
}
}
示例12: edit
void ClusterDialog::edit() {
ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem()); // +
// Do nothing if no item selected
if (!currentItem) {
return;
}
#ifdef BUILD_WITH_REDIS
proxy::IConnectionSettingsBaseSPtr oldConnection = currentItem->connection();
ConnectionDialog dlg(oldConnection->Clone(), this);
dlg.setFolderEnabled(false);
int result = dlg.exec();
proxy::IConnectionSettingsBaseSPtr newConnection = dlg.connection();
if (result == QDialog::Accepted && newConnection) {
currentItem->setConnection(newConnection);
}
#endif
}
示例13: remove
void ClusterDialog::remove() {
ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem*>(list_widget_->currentItem()); // +
// Do nothing if no item selected
if (!currentItem) {
return;
}
// Ask user
int answer = QMessageBox::question(this, translations::trConnections,
translations::trDeleteConnectionTemplate_1S.arg(currentItem->text(0)),
QMessageBox::Yes, QMessageBox::No, QMessageBox::NoButton);
if (answer != QMessageBox::Yes) {
return;
}
delete currentItem;
}
示例14: dlg
void ConnectionsDialog::edit()
{
QTreeWidgetItem* qitem = listWidget_->currentItem();
if(!qitem){
return;
}
ConnectionListWidgetItem* currentItem = dynamic_cast<ConnectionListWidgetItem *>(qitem);
if(currentItem){
QTreeWidgetItem* qpitem = qitem->parent();
if(!qpitem){
IConnectionSettingsBaseSPtr con = currentItem->connection();
ConnectionDialog dlg(this, dynamic_cast<IConnectionSettingsBase*>(con->clone()));
int result = dlg.exec();
IConnectionSettingsBaseSPtr newConnection = dlg.connection();
if(result == QDialog::Accepted && newConnection){
currentItem->setConnection(newConnection);
SettingsManager::instance().removeConnection(con);
SettingsManager::instance().addConnection(newConnection);
}
return;
}
else{
qitem = qpitem;
}
}
ClusterConnectionListWidgetItem* clCurrentItem = dynamic_cast<ClusterConnectionListWidgetItem *>(qitem);
if(clCurrentItem){
IClusterSettingsBaseSPtr con = clCurrentItem->connection();
ClusterDialog dlg(this, dynamic_cast<IClusterSettingsBase*>(con->clone()));
int result = dlg.exec();
IClusterSettingsBaseSPtr newConnection = dlg.connection();
if(result == QDialog::Accepted && newConnection){
clCurrentItem->setConnection(newConnection);
SettingsManager::instance().removeCluster(con);
SettingsManager::instance().addCluster(newConnection);
}
}
}
示例15: listWidget_layoutChanged
/**
* @brief Handles ListWidget layoutChanged() signal
*/
void ConnectionsDialog::listWidget_layoutChanged()
{
int count = _listWidget->topLevelItemCount();
// Make childrens toplevel again. This is a bad, but quickiest item reordering
// implementation.
for(int i = 0; i < count; i++)
{
ConnectionListWidgetItem * item = (ConnectionListWidgetItem *) _listWidget->topLevelItem(i);
if (item->childCount() > 0) {
ConnectionListWidgetItem *childItem = (ConnectionListWidgetItem *) item->child(0);
item->removeChild(childItem);
_listWidget->insertTopLevelItem(++i, childItem);
_listWidget->setCurrentItem(childItem);
break;
}
}
count = _listWidget->topLevelItemCount();
SettingsManager::ConnectionSettingsContainerType items;
for(int i = 0; i < count; i++)
{
ConnectionListWidgetItem * item = (ConnectionListWidgetItem *) _listWidget->topLevelItem(i);
items.push_back(item->connection());
}
_settingsManager->reorderConnections(items);
}