[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/utils/gwenrename
From:       Spiros Georgaras <sngeorgaras () otenet ! gr>
Date:       2007-12-29 14:38:55
Message-ID: 1198939135.574507.21074.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 754307 by sngeorgaras:

implementing history for the folder selection dialog

 M  +51 -2     inputdir.ui  
 M  +48 -2     inputdir.ui.h  


--- trunk/playground/utils/gwenrename/inputdir.ui #754306:754307
@@ -82,16 +82,41 @@
         </widget>
         <widget class="QLayoutWidget">
             <property name="name">
-                <cstring>layout5</cstring>
+                <cstring>layout6</cstring>
             </property>
             <hbox>
                 <property name="name">
                     <cstring>unnamed</cstring>
                 </property>
+                <widget class="QLabel">
+                    <property name="name">
+                        <cstring>textLabel1</cstring>
+                    </property>
+                    <property name="sizePolicy">
+                        <sizepolicy>
+                            <hsizetype>4</hsizetype>
+                            <vsizetype>5</vsizetype>
+                            <horstretch>0</horstretch>
+                            <verstretch>0</verstretch>
+                        </sizepolicy>
+                    </property>
+                    <property name="text">
+                        <string>&amp;Folder:</string>
+                    </property>
+                    <property name="buddy" stdset="0">
+                        <cstring>dir</cstring>
+                    </property>
+                </widget>
                 <widget class="KComboBox">
                     <property name="name">
                         <cstring>dir</cstring>
                     </property>
+                    <property name="maximumSize">
+                        <size>
+                            <width>600</width>
+                            <height>32767</height>
+                        </size>
+                    </property>
                     <property name="editable">
                         <bool>true</bool>
                     </property>
@@ -119,6 +144,23 @@
                         <string></string>
                     </property>
                 </widget>
+                <spacer>
+                    <property name="name">
+                        <cstring>spacer4</cstring>
+                    </property>
+                    <property name="orientation">
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property name="sizeType">
+                        <enum>Expanding</enum>
+                    </property>
+                    <property name="sizeHint">
+                        <size>
+                            <width>31</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
             </hbox>
         </widget>
         <spacer>
@@ -212,7 +254,7 @@
         <sender>buttonOk</sender>
         <signal>clicked()</signal>
         <receiver>InputDir</receiver>
-        <slot>accept()</slot>
+        <slot>buttonOkClicked()</slot>
     </connection>
     <connection>
         <sender>buttonCancel</sender>
@@ -238,14 +280,21 @@
     <include location="global" impldecl="in declaration">kurl.h</include>
     <include location="global" impldecl="in declaration">qstring.h</include>
     <include location="global" impldecl="in declaration">qfileinfo.h</include>
+    <include location="global" impldecl="in declaration">kconfig.h</include>
     <include location="local" impldecl="in implementation">inputdir.ui.h</include>
 </includes>
+<variables>
+    <variable access="private">int numOfHistoryItems;</variable>
+</variables>
 <slots>
     <slot access="private">openDirSelectionDialog()</slot>
     <slot access="private">textHasChanged( const QString &amp; txt )</slot>
+    <slot access="private">buttonOkClicked()</slot>
 </slots>
 <functions>
     <function access="private">init()</function>
+    <function access="private">readHistory()</function>
+    <function access="private">writeHistory()</function>
 </functions>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>
--- trunk/playground/utils/gwenrename/inputdir.ui.h #754306:754307
@@ -9,9 +9,14 @@
 ** These will automatically be called by the form's constructor and
 ** destructor.
 *****************************************************************************/
+
+#define HISTORY_ITEMS 25
+
 void InputDir::init(){
-    setCaption(caption()+" - GwenRename");
-
+	setCaption(caption()+" - GwenRename");
+	readHistory();
+	numOfHistoryItems=dir->count();
+	dir->setCurrentText(QString::null);
 }
 
 
@@ -37,3 +42,44 @@
 	}
 	buttonOk->setEnabled(mode);
 }
+
+
+void InputDir::readHistory(){
+	QString tmp;
+	QString group;
+	KConfig config("gwenrenamerc");
+	config.setGroup("FolderHistory");
+	for(int i=HISTORY_ITEMS-1;i>=0;i--){
+		group=QString("Exp%1").arg(i);
+		tmp=config.readEntry(group,QString::null);
+		if(!tmp.isEmpty()){
+			QFileInfo f(tmp);
+			if(f.exists() && f.isDir())
+				dir->insertItem(tmp,0);
+		}
+	}
+}
+
+
+void InputDir::writeHistory(){
+	QString group;
+	KConfig config("gwenrenamerc");
+	config.setGroup("FolderHistory");
+	for(int i=0;i<HISTORY_ITEMS;i++){
+		group=QString("Exp%1").arg(i);
+		config.deleteEntry(group);
+		if(i<numOfHistoryItems)
+			config.writeEntry(group,dir->text(i));
+	}
+}
+
+void InputDir::buttonOkClicked(){
+	if(!dir->contains(dir->currentText())){
+		dir->insertItem(dir->currentText(),0);
+		numOfHistoryItems++;
+		writeHistory();
+	}
+	dir->setSizeLimit(10);
+	accept();
+}
+
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic