summaryrefslogtreecommitdiffstats
path: root/src/dialogs/dependanciesdialog.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-10-13 11:56:14 +0900
committerMichele Calgaro <[email protected]>2024-10-29 21:58:42 +0900
commit2879ff70be9271550477982a1a6371714db38562 (patch)
treec2054149dba923ab080fe7093432c7663a990111 /src/dialogs/dependanciesdialog.cpp
parent3eb38d2556f676d1027746f20bf12a1dd74451ef (diff)
downloadkrecipes-2879ff70be9271550477982a1a6371714db38562.tar.gz
krecipes-2879ff70be9271550477982a1a6371714db38562.zip
Rearrange folders structure to remove unnecessary 'krecipes' second level subfolder
Signed-off-by: Michele Calgaro <[email protected]> (cherry picked from commit 0c8ed6c9a4000af8f48581a81c4b5c2f5b9fd502)
Diffstat (limited to 'src/dialogs/dependanciesdialog.cpp')
-rw-r--r--src/dialogs/dependanciesdialog.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/src/dialogs/dependanciesdialog.cpp b/src/dialogs/dependanciesdialog.cpp
new file mode 100644
index 0000000..ac7d095
--- /dev/null
+++ b/src/dialogs/dependanciesdialog.cpp
@@ -0,0 +1,100 @@
+/***************************************************************************
+* Copyright (C) 2003 by *
+* Unai Garro ([email protected]) *
+* Cyril Bosselut ([email protected]) *
+* *
+* Copyright (C) 2003-2005 by *
+* Jason Kivlighn ([email protected]) *
+* *
+* This program is free software; you can redistribute it and/or modify *
+* it under the terms of the GNU General Public License as published by *
+* the Free Software Foundation; either version 2 of the License, or *
+* (at your option) any later version. *
+***************************************************************************/
+
+#include "dependanciesdialog.h"
+#include "datablocks/elementlist.h"
+
+#include <tqvbox.h>
+
+#include <tdelocale.h>
+#include <tdeglobal.h>
+#include <tdeconfig.h>
+#include <tdemessagebox.h>
+
+DependanciesDialog::DependanciesDialog( TQWidget *parent, const TQValueList<ListInfo> &lists, bool deps_are_deleted ) : KDialogBase( parent, "DependanciesDialog", true, TQString::null,
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Cancel ),
+ m_depsAreDeleted(deps_are_deleted)
+{
+ init( lists );
+}
+
+DependanciesDialog::DependanciesDialog( TQWidget *parent, const ListInfo &list, bool deps_are_deleted ) : KDialogBase( parent, "DependanciesDialog", true, TQString::null,
+ KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Cancel ),
+ m_depsAreDeleted(deps_are_deleted)
+{
+ TQValueList<ListInfo> lists;
+ lists << list;
+ init( lists );
+}
+
+DependanciesDialog::~DependanciesDialog()
+{}
+
+void DependanciesDialog::init( const TQValueList<ListInfo> &lists )
+{
+ TQVBox *page = makeVBoxMainWidget();
+
+ // Design the dialog
+
+ instructionsLabel = new TQLabel( page );
+ instructionsLabel->setMinimumSize( TQSize( 100, 30 ) );
+ instructionsLabel->setMaximumSize( TQSize( 10000, 10000 ) );
+ instructionsLabel->setAlignment( int( TQLabel::WordBreak | TQLabel::AlignVCenter ) );
+
+ if ( m_depsAreDeleted ) {
+ instructionsLabel->setText( i18n( "<b>WARNING:</b> The following will have to be removed also, since currently they use the element you have chosen to be removed." ) );
+ }
+ else {
+ instructionsLabel->setText( i18n( "<b>WARNING:</b> The following currently use the element you have chosen to be removed." ) );
+ }
+
+ for ( TQValueList<ListInfo>::const_iterator list_it = lists.begin(); list_it != lists.end(); ++list_it ) {
+ if ( !((*list_it).list).isEmpty() ) {
+ TQGroupBox *groupBox = new TQGroupBox( 1, TQt::Vertical, (*list_it).name, page );
+ TDEListBox *listBox = new TDEListBox( groupBox );
+ loadList( listBox, (*list_it).list );
+ }
+ }
+
+ setSizeGripEnabled( true );
+}
+
+void DependanciesDialog::loadList( TDEListBox* listBox, const ElementList &list )
+{
+ TDEConfig * config = TDEGlobal::config();
+ config->setGroup( "Advanced" );
+ bool show_id = config->readBoolEntry( "ShowID", false );
+
+ for ( ElementList::const_iterator el_it = list.begin(); el_it != list.end(); ++el_it ) {
+ TQString name = ( *el_it ).name;
+ if ( show_id )
+ name += " (" + TQString::number(( *el_it ).id) + ")";
+ listBox->insertItem( name );
+ }
+}
+
+void DependanciesDialog::accept()
+{
+ if ( !m_msg.isEmpty() ) {
+ switch ( KMessageBox::warningYesNo(this,
+ TQString("<b>%1</b><br><br>%2").arg(m_msg).arg(i18n("Are you sure you wish to proceed?")),
+ TQString::null,KStdGuiItem::yes(),KStdGuiItem::no(),"doubleCheckDelete") )
+ {
+ case KMessageBox::Yes: TQDialog::accept(); break;
+ case KMessageBox::No: TQDialog::reject(); break;
+ }
+ }
+ else
+ TQDialog::accept();
+}